"use strict";var Web5Agent=(()=>{var $0e=Object.create;var vS=Object.defineProperty;var N0e=Object.getOwnPropertyDescriptor;var j0e=Object.getOwnPropertyNames;var U0e=Object.getPrototypeOf,K0e=Object.prototype.hasOwnProperty;var q0e=(t,e)=>()=>(t&&(e=t(t=0)),e);var W=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),jr=(t,e)=>{for(var r in e)vS(t,r,{get:e[r],enumerable:!0})},bq=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of j0e(e))!K0e.call(t,i)&&i!==r&&vS(t,i,{get:()=>e[i],enumerable:!(n=N0e(e,i))||n.enumerable});return t};var Ut=(t,e,r)=>(r=t!=null?$0e(U0e(t)):{},bq(e||!t||!t.__esModule?vS(r,"default",{value:t,enumerable:!0}):r,t)),L0e=t=>bq(vS({},"__esModule",{value:!0}),t);var YI=W(wS=>{"use strict";h();wS.byteLength=z0e;wS.toByteArray=W0e;wS.fromByteArray=J0e;var ju=[],$c=[],F0e=typeof Uint8Array<"u"?Uint8Array:Array,JI="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(dy=0,vq=JI.length;dy0)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 z0e(t){var e=wq(t),r=e[0],n=e[1];return(r+n)*3/4-n}function G0e(t,e,r){return(e+r)*3/4-r}function W0e(t){var e,r=wq(t),n=r[0],i=r[1],o=new F0e(G0e(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=$c[t.charCodeAt(d)]<<2|$c[t.charCodeAt(d+1)]>>4,o[s++]=e&255),i===1&&(e=$c[t.charCodeAt(d)]<<10|$c[t.charCodeAt(d+1)]<<4|$c[t.charCodeAt(d+2)]>>2,o[s++]=e>>8&255,o[s++]=e&255),o}function H0e(t){return ju[t>>18&63]+ju[t>>12&63]+ju[t>>6&63]+ju[t&63]}function V0e(t,e,r){for(var n,i=[],o=e;oa?a:s+o));return n===1?(e=t[r-1],i.push(ju[e>>2]+ju[e<<4&63]+"==")):n===2&&(e=(t[r-2]<<8)+t[r-1],i.push(ju[e>>10]+ju[e>>4&63]+ju[e<<2&63]+"=")),i.join("")}});var XI=W(ZI=>{h();ZI.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,m=r?-1:1,p=t[e+l];for(l+=m,o=p&(1<<-c)-1,p>>=-c,c+=a;c>0;o=o*256+t[e+l],l+=m,c-=8);for(s=o&(1<<-c)-1,o>>=-c,c+=n;c>0;s=s*256+t[e+l],l+=m,c-=8);if(o===0)o=1-u;else{if(o===d)return s?NaN:(p?-1:1)*(1/0);s=s+Math.pow(2,n),o=o-u}return(p?-1:1)*s*Math.pow(2,o-n)};ZI.write=function(t,e,r,n,i,o){var s,a,d,u=o*8-i-1,c=(1<>1,m=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:o-1,g=n?1:-1,b=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+=m/d:e+=m*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+p]=a&255,p+=g,a/=256,i-=8);for(s=s<0;t[r+p]=s&255,p+=g,s/=256,u-=8);t[r+p-g]|=b*128}});var Bq=W(mb=>{"use strict";h();var QI=YI(),pb=XI(),_q=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;mb.Buffer=me;mb.SlowBuffer=tge;mb.INSPECT_MAX_BYTES=50;var _S=2147483647;mb.kMaxLength=_S;me.TYPED_ARRAY_SUPPORT=Y0e();!me.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 Y0e(){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(me.prototype,"parent",{enumerable:!0,get:function(){if(me.isBuffer(this))return this.buffer}});Object.defineProperty(me.prototype,"offset",{enumerable:!0,get:function(){if(me.isBuffer(this))return this.byteOffset}});function ef(t){if(t>_S)throw new RangeError('The value "'+t+'" is invalid for option "size"');var e=new Uint8Array(t);return Object.setPrototypeOf(e,me.prototype),e}function me(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 nk(t)}return Sq(t,e,r)}me.poolSize=8192;function Sq(t,e,r){if(typeof t=="string")return X0e(t,e);if(ArrayBuffer.isView(t))return Q0e(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(Uu(t,ArrayBuffer)||t&&Uu(t.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(Uu(t,SharedArrayBuffer)||t&&Uu(t.buffer,SharedArrayBuffer)))return tk(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 me.from(n,e,r);var i=ege(t);if(i)return i;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof t[Symbol.toPrimitive]=="function")return me.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)}me.from=function(t,e,r){return Sq(t,e,r)};Object.setPrototypeOf(me.prototype,Uint8Array.prototype);Object.setPrototypeOf(me,Uint8Array);function Aq(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 Z0e(t,e,r){return Aq(t),t<=0?ef(t):e!==void 0?typeof r=="string"?ef(t).fill(e,r):ef(t).fill(e):ef(t)}me.alloc=function(t,e,r){return Z0e(t,e,r)};function nk(t){return Aq(t),ef(t<0?0:ik(t)|0)}me.allocUnsafe=function(t){return nk(t)};me.allocUnsafeSlow=function(t){return nk(t)};function X0e(t,e){if((typeof e!="string"||e==="")&&(e="utf8"),!me.isEncoding(e))throw new TypeError("Unknown encoding: "+e);var r=Pq(t,e)|0,n=ef(r),i=n.write(t,e);return i!==r&&(n=n.slice(0,i)),n}function ek(t){for(var e=t.length<0?0:ik(t.length)|0,r=ef(e),n=0;n=_S)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+_S.toString(16)+" bytes");return t|0}function tge(t){return+t!=t&&(t=0),me.alloc(+t)}me.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==me.prototype};me.compare=function(e,r){if(Uu(e,Uint8Array)&&(e=me.from(e,e.offset,e.byteLength)),Uu(r,Uint8Array)&&(r=me.from(r,r.offset,r.byteLength)),!me.isBuffer(e)||!me.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?me.from(s).copy(i,o):Uint8Array.prototype.set.call(i,s,o);else if(me.isBuffer(s))s.copy(i,o);else throw new TypeError('"list" argument must be an Array of Buffers');o+=s.length}return i};function Pq(t,e){if(me.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||Uu(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 rk(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return Mq(t).length;default:if(i)return n?-1:rk(t).length;e=(""+e).toLowerCase(),i=!0}}me.byteLength=Pq;function rge(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 fge(this,e,r);case"utf8":case"utf-8":return Iq(this,e,r);case"ascii":return uge(this,e,r);case"latin1":case"binary":return lge(this,e,r);case"base64":return cge(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return hge(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}me.prototype._isBuffer=!0;function uy(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}me.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+=" ... "),""};_q&&(me.prototype[_q]=me.prototype.inspect);me.prototype.compare=function(e,r,n,i,o){if(Uu(e,Uint8Array)&&(e=me.from(e,e.offset,e.byteLength)),!me.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,ok(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=me.from(e,n)),me.isBuffer(e))return e.length===0?-1:xq(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):xq(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function xq(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(p,g){return o===1?p[g]:p.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,m=0;mi&&(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 nge(this,e,r,n);case"utf8":case"utf-8":return ige(this,e,r,n);case"ascii":case"latin1":case"binary":return oge(this,e,r,n);case"base64":return sge(this,e,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return age(this,e,r,n);default:if(s)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),s=!0}};me.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function cge(t,e,r){return e===0&&r===t.length?QI.fromByteArray(t):QI.fromByteArray(t.slice(e,r))}function Iq(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 dge(n)}var Eq=4096;function dge(t){var e=t.length;if(e<=Eq)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")}me.prototype.readUintLE=me.prototype.readUIntLE=function(e,r,n){e=e>>>0,r=r>>>0,n||so(e,r,this.length);for(var i=this[e],o=1,s=0;++s>>0,r=r>>>0,n||so(e,r,this.length);for(var i=this[e+--r],o=1;r>0&&(o*=256);)i+=this[e+--r]*o;return i};me.prototype.readUint8=me.prototype.readUInt8=function(e,r){return e=e>>>0,r||so(e,1,this.length),this[e]};me.prototype.readUint16LE=me.prototype.readUInt16LE=function(e,r){return e=e>>>0,r||so(e,2,this.length),this[e]|this[e+1]<<8};me.prototype.readUint16BE=me.prototype.readUInt16BE=function(e,r){return e=e>>>0,r||so(e,2,this.length),this[e]<<8|this[e+1]};me.prototype.readUint32LE=me.prototype.readUInt32LE=function(e,r){return e=e>>>0,r||so(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216};me.prototype.readUint32BE=me.prototype.readUInt32BE=function(e,r){return e=e>>>0,r||so(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])};me.prototype.readIntLE=function(e,r,n){e=e>>>0,r=r>>>0,n||so(e,r,this.length);for(var i=this[e],o=1,s=0;++s=o&&(i-=Math.pow(2,8*r)),i};me.prototype.readIntBE=function(e,r,n){e=e>>>0,r=r>>>0,n||so(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};me.prototype.readInt8=function(e,r){return e=e>>>0,r||so(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]};me.prototype.readInt16LE=function(e,r){e=e>>>0,r||so(e,2,this.length);var n=this[e]|this[e+1]<<8;return n&32768?n|4294901760:n};me.prototype.readInt16BE=function(e,r){e=e>>>0,r||so(e,2,this.length);var n=this[e+1]|this[e]<<8;return n&32768?n|4294901760:n};me.prototype.readInt32LE=function(e,r){return e=e>>>0,r||so(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24};me.prototype.readInt32BE=function(e,r){return e=e>>>0,r||so(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]};me.prototype.readFloatLE=function(e,r){return e=e>>>0,r||so(e,4,this.length),pb.read(this,e,!0,23,4)};me.prototype.readFloatBE=function(e,r){return e=e>>>0,r||so(e,4,this.length),pb.read(this,e,!1,23,4)};me.prototype.readDoubleLE=function(e,r){return e=e>>>0,r||so(e,8,this.length),pb.read(this,e,!0,52,8)};me.prototype.readDoubleBE=function(e,r){return e=e>>>0,r||so(e,8,this.length),pb.read(this,e,!1,52,8)};function ya(t,e,r,n,i,o){if(!me.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||et.length)throw new RangeError("Index out of range")}me.prototype.writeUintLE=me.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;ya(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;ya(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};me.prototype.writeUint8=me.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};me.prototype.writeUint16LE=me.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};me.prototype.writeUint16BE=me.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};me.prototype.writeUint32LE=me.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};me.prototype.writeUint32BE=me.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};me.prototype.writeIntLE=function(e,r,n,i){if(e=+e,r=r>>>0,!i){var o=Math.pow(2,8*n-1);ya(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};me.prototype.writeIntBE=function(e,r,n,i){if(e=+e,r=r>>>0,!i){var o=Math.pow(2,8*n-1);ya(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};me.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};me.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};me.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};me.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};me.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};function kq(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 Rq(t,e,r,n,i){return e=+e,r=r>>>0,i||kq(t,e,r,4,34028234663852886e22,-34028234663852886e22),pb.write(t,e,r,n,23,4),r+4}me.prototype.writeFloatLE=function(e,r,n){return Rq(this,e,r,!0,n)};me.prototype.writeFloatBE=function(e,r,n){return Rq(this,e,r,!1,n)};function Dq(t,e,r,n,i){return e=+e,r=r>>>0,i||kq(t,e,r,8,17976931348623157e292,-17976931348623157e292),pb.write(t,e,r,n,52,8),r+8}me.prototype.writeDoubleLE=function(e,r,n){return Dq(this,e,r,!0,n)};me.prototype.writeDoubleBE=function(e,r,n){return Dq(this,e,r,!1,n)};me.prototype.copy=function(e,r,n,i){if(!me.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 yge(t){for(var e=[],r=0;r>8,i=r%256,o.push(i),o.push(n);return o}function Mq(t){return QI.toByteArray(mge(t))}function xS(t,e,r,n){for(var i=0;i=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function Uu(t,e){return t instanceof e||t!=null&&t.constructor!=null&&t.constructor.name!=null&&t.constructor.name===e.name}function ok(t){return t!==t}var bge=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 ls=W((DYe,Nq)=>{h();var vi=Nq.exports={},Ku,qu;function sk(){throw new Error("setTimeout has not been defined")}function ak(){throw new Error("clearTimeout has not been defined")}(function(){try{typeof setTimeout=="function"?Ku=setTimeout:Ku=sk}catch{Ku=sk}try{typeof clearTimeout=="function"?qu=clearTimeout:qu=ak}catch{qu=ak}})();function Cq(t){if(Ku===setTimeout)return setTimeout(t,0);if((Ku===sk||!Ku)&&setTimeout)return Ku=setTimeout,setTimeout(t,0);try{return Ku(t,0)}catch{try{return Ku.call(null,t,0)}catch{return Ku.call(this,t,0)}}}function vge(t){if(qu===clearTimeout)return clearTimeout(t);if((qu===ak||!qu)&&clearTimeout)return qu=clearTimeout,clearTimeout(t);try{return qu(t)}catch{try{return qu.call(null,t)}catch{return qu.call(this,t)}}}var tf=[],yb=!1,ly,ES=-1;function wge(){!yb||!ly||(yb=!1,ly.length?tf=ly.concat(tf):ES=-1,tf.length&&Oq())}function Oq(){if(!yb){var t=Cq(wge);yb=!0;for(var e=tf.length;e;){for(ly=tf,tf=[];++ES1)for(var r=1;r{O=Ut(Bq()),B=Ut(ls()),BYe=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 Uq=W((OYe,jq)=>{h();var _ge=typeof globalThis=="object"&&globalThis&&globalThis.Object===Object&&globalThis;jq.exports=_ge});var qq=W((NYe,Kq)=>{h();var xge=Uq(),Ege=typeof self=="object"&&self&&self.Object===Object&&self,Sge=xge||Ege||Function("return this")();Kq.exports=Sge});var ck=W((UYe,Lq)=>{h();var Age=qq(),Pge=Age.Symbol;Lq.exports=Pge});var Wq=W((qYe,Gq)=>{h();var Fq=ck(),zq=Object.prototype,Tge=zq.hasOwnProperty,Ige=zq.toString,a2=Fq?Fq.toStringTag:void 0;function kge(t){var e=Tge.call(t,a2),r=t[a2];try{t[a2]=void 0;var n=!0}catch{}var i=Ige.call(t);return n&&(e?t[a2]=r:delete t[a2]),i}Gq.exports=kge});var Vq=W((FYe,Hq)=>{h();var Rge=Object.prototype,Dge=Rge.toString;function Mge(t){return Dge.call(t)}Hq.exports=Mge});var Xq=W((GYe,Zq)=>{h();var Jq=ck(),Bge=Wq(),Cge=Vq(),Oge="[object Null]",$ge="[object Undefined]",Yq=Jq?Jq.toStringTag:void 0;function Nge(t){return t==null?t===void 0?$ge:Oge:Yq&&Yq in Object(t)?Bge(t):Cge(t)}Zq.exports=Nge});var eL=W((HYe,Qq)=>{h();function jge(t,e){return function(r){return t(e(r))}}Qq.exports=jge});var rL=W((JYe,tL)=>{h();var Uge=eL(),Kge=Uge(Object.getPrototypeOf,Object);tL.exports=Kge});var iL=W((ZYe,nL)=>{h();function qge(t){return t!=null&&typeof t=="object"}nL.exports=qge});var aL=W((QYe,sL)=>{h();var Lge=Xq(),Fge=rL(),zge=iL(),Gge="[object Object]",Wge=Function.prototype,Hge=Object.prototype,oL=Wge.toString,Vge=Hge.hasOwnProperty,Jge=oL.call(Object);function Yge(t){if(!zge(t)||Lge(t)!=Gge)return!1;var e=Fge(t);if(e===null)return!0;var r=Vge.call(e,"constructor")&&e.constructor;return typeof r=="function"&&r instanceof r&&oL.call(r)==Jge}sL.exports=Yge});var Xa=W((dnt,uG)=>{"use strict";h();function dG(t,e){for(let r in e)Object.defineProperty(t,r,{value:e[r],enumerable:!0,configurable:!0});return t}function n2e(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 dG(t,r)}catch{r.message=t.message,r.stack=t.stack;let i=function(){};return i.prototype=Object.create(Object.getPrototypeOf(t)),dG(new i,r)}}uG.exports=n2e});var mW=W((s_,_3)=>{h();(function(t,e){"use strict";var r={version:"3.0.0",x86:{},x64:{},inputValidation:!0};function n(p){if(!Array.isArray(p)&&!ArrayBuffer.isView(p))return!1;for(var g=0;g255)return!1;return!0}function i(p,g){return(p&65535)*g+(((p>>>16)*g&65535)<<16)}function o(p,g){return p<>>32-g}function s(p){return p^=p>>>16,p=i(p,2246822507),p^=p>>>13,p=i(p,3266489909),p^=p>>>16,p}function a(p,g){p=[p[0]>>>16,p[0]&65535,p[1]>>>16,p[1]&65535],g=[g[0]>>>16,g[0]&65535,g[1]>>>16,g[1]&65535];var b=[0,0,0,0];return b[3]+=p[3]+g[3],b[2]+=b[3]>>>16,b[3]&=65535,b[2]+=p[2]+g[2],b[1]+=b[2]>>>16,b[2]&=65535,b[1]+=p[1]+g[1],b[0]+=b[1]>>>16,b[1]&=65535,b[0]+=p[0]+g[0],b[0]&=65535,[b[0]<<16|b[1],b[2]<<16|b[3]]}function d(p,g){p=[p[0]>>>16,p[0]&65535,p[1]>>>16,p[1]&65535],g=[g[0]>>>16,g[0]&65535,g[1]>>>16,g[1]&65535];var b=[0,0,0,0];return b[3]+=p[3]*g[3],b[2]+=b[3]>>>16,b[3]&=65535,b[2]+=p[2]*g[3],b[1]+=b[2]>>>16,b[2]&=65535,b[2]+=p[3]*g[2],b[1]+=b[2]>>>16,b[2]&=65535,b[1]+=p[1]*g[3],b[0]+=b[1]>>>16,b[1]&=65535,b[1]+=p[2]*g[2],b[0]+=b[1]>>>16,b[1]&=65535,b[1]+=p[3]*g[1],b[0]+=b[1]>>>16,b[1]&=65535,b[0]+=p[0]*g[3]+p[1]*g[2]+p[2]*g[1]+p[3]*g[0],b[0]&=65535,[b[0]<<16|b[1],b[2]<<16|b[3]]}function u(p,g){return g%=64,g===32?[p[1],p[0]]:g<32?[p[0]<>>32-g,p[1]<>>32-g]:(g-=32,[p[1]<>>32-g,p[0]<>>32-g])}function c(p,g){return g%=64,g===0?p:g<32?[p[0]<>>32-g,p[1]<>>1]),p=d(p,[4283543511,3981806797]),p=l(p,[0,p[0]>>>1]),p=d(p,[3301882366,444984403]),p=l(p,[0,p[0]>>>1]),p}r.x86.hash32=function(p,g){if(r.inputValidation&&!n(p))return e;g=g||0;for(var b=p.length%4,S=p.length-b,A=g,I=0,P=3432918353,$=461845907,N=0;N>>0},r.x86.hash128=function(p,g){if(r.inputValidation&&!n(p))return e;g=g||0;for(var b=p.length%16,S=p.length-b,A=g,I=g,P=g,$=g,N=0,L=0,F=0,U=0,G=597399067,q=2869860233,T=951274213,E=2716044179,k=0;k>>0).toString(16)).slice(-8)+("00000000"+(I>>>0).toString(16)).slice(-8)+("00000000"+(P>>>0).toString(16)).slice(-8)+("00000000"+($>>>0).toString(16)).slice(-8)},r.x64.hash128=function(p,g){if(r.inputValidation&&!n(p))return e;g=g||0;for(var b=p.length%16,S=p.length-b,A=[0,g],I=[0,g],P=[0,0],$=[0,0],N=[2277735313,289559509],L=[1291169091,658871167],F=0;F>>0).toString(16)).slice(-8)+("00000000"+(A[1]>>>0).toString(16)).slice(-8)+("00000000"+(I[0]>>>0).toString(16)).slice(-8)+("00000000"+(I[1]>>>0).toString(16)).slice(-8)},typeof s_<"u"?(typeof _3<"u"&&_3.exports&&(s_=_3.exports=r),s_.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)})(s_)});var gW=W((Sat,yW)=>{h();yW.exports=mW()});var wW=W((Bat,vW)=>{"use strict";h();vW.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(X_e,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(Q_e),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(exe)}};function X_e(t,e){return t+bW(e)}function bW(t){let e=t;return e=e-(e>>1&1431655765),e=(e&858993459)+(e>>2&858993459),(e+(e>>4)&252645135)*16843009>>24}function Q_e(t,e){return t[0]-e[0]}function exe(t){return t[1]}});var Un=W(nv=>{"use strict";h();var I9=YI(),tv=XI(),CW=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;nv.Buffer=fe;nv.SlowBuffer=bxe;nv.INSPECT_MAX_BYTES=50;var T3=2147483647;nv.kMaxLength=T3;fe.TYPED_ARRAY_SUPPORT=hxe();!fe.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 hxe(){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(fe.prototype,"parent",{enumerable:!0,get:function(){if(fe.isBuffer(this))return this.buffer}});Object.defineProperty(fe.prototype,"offset",{enumerable:!0,get:function(){if(fe.isBuffer(this))return this.byteOffset}});function Ef(t){if(t>T3)throw new RangeError('The value "'+t+'" is invalid for option "size"');let e=new Uint8Array(t);return Object.setPrototypeOf(e,fe.prototype),e}function fe(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 M9(t)}return jW(t,e,r)}fe.poolSize=8192;function jW(t,e,r){if(typeof t=="string")return mxe(t,e);if(ArrayBuffer.isView(t))return yxe(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(Xu(t,ArrayBuffer)||t&&Xu(t.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(Xu(t,SharedArrayBuffer)||t&&Xu(t.buffer,SharedArrayBuffer)))return R9(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 fe.from(n,e,r);let i=gxe(t);if(i)return i;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof t[Symbol.toPrimitive]=="function")return fe.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)}fe.from=function(t,e,r){return jW(t,e,r)};Object.setPrototypeOf(fe.prototype,Uint8Array.prototype);Object.setPrototypeOf(fe,Uint8Array);function UW(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 pxe(t,e,r){return UW(t),t<=0?Ef(t):e!==void 0?typeof r=="string"?Ef(t).fill(e,r):Ef(t).fill(e):Ef(t)}fe.alloc=function(t,e,r){return pxe(t,e,r)};function M9(t){return UW(t),Ef(t<0?0:B9(t)|0)}fe.allocUnsafe=function(t){return M9(t)};fe.allocUnsafeSlow=function(t){return M9(t)};function mxe(t,e){if((typeof e!="string"||e==="")&&(e="utf8"),!fe.isEncoding(e))throw new TypeError("Unknown encoding: "+e);let r=KW(t,e)|0,n=Ef(r),i=n.write(t,e);return i!==r&&(n=n.slice(0,i)),n}function k9(t){let e=t.length<0?0:B9(t.length)|0,r=Ef(e);for(let n=0;n=T3)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+T3.toString(16)+" bytes");return t|0}function bxe(t){return+t!=t&&(t=0),fe.alloc(+t)}fe.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==fe.prototype};fe.compare=function(e,r){if(Xu(e,Uint8Array)&&(e=fe.from(e,e.offset,e.byteLength)),Xu(r,Uint8Array)&&(r=fe.from(r,r.offset,r.byteLength)),!fe.isBuffer(e)||!fe.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?(fe.isBuffer(s)||(s=fe.from(s)),s.copy(i,o)):Uint8Array.prototype.set.call(i,s,o);else if(fe.isBuffer(s))s.copy(i,o);else throw new TypeError('"list" argument must be an Array of Buffers');o+=s.length}return i};function KW(t,e){if(fe.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||Xu(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 D9(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return JW(t).length;default:if(i)return n?-1:D9(t).length;e=(""+e).toLowerCase(),i=!0}}fe.byteLength=KW;function vxe(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 kxe(this,e,r);case"utf8":case"utf-8":return LW(this,e,r);case"ascii":return Txe(this,e,r);case"latin1":case"binary":return Ixe(this,e,r);case"base64":return Axe(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Rxe(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}fe.prototype._isBuffer=!0;function jy(t,e,r){let n=t[e];t[e]=t[r],t[r]=n}fe.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+=" ... "),""};CW&&(fe.prototype[CW]=fe.prototype.inspect);fe.prototype.compare=function(e,r,n,i,o){if(Xu(e,Uint8Array)&&(e=fe.from(e,e.offset,e.byteLength)),!fe.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,O9(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=fe.from(e,n)),fe.isBuffer(e))return e.length===0?-1:OW(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):OW(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function OW(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 wxe(this,e,r,n);case"utf8":case"utf-8":return _xe(this,e,r,n);case"ascii":case"latin1":case"binary":return xxe(this,e,r,n);case"base64":return Exe(this,e,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Sxe(this,e,r,n);default:if(s)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),s=!0}};fe.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Axe(t,e,r){return e===0&&r===t.length?I9.fromByteArray(t):I9.fromByteArray(t.slice(e,r))}function LW(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 Pxe(n)}var $W=4096;function Pxe(t){let e=t.length;if(e<=$W)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")}fe.prototype.readUintLE=fe.prototype.readUIntLE=function(e,r,n){e=e>>>0,r=r>>>0,n||ho(e,r,this.length);let i=this[e],o=1,s=0;for(;++s>>0,r=r>>>0,n||ho(e,r,this.length);let i=this[e+--r],o=1;for(;r>0&&(o*=256);)i+=this[e+--r]*o;return i};fe.prototype.readUint8=fe.prototype.readUInt8=function(e,r){return e=e>>>0,r||ho(e,1,this.length),this[e]};fe.prototype.readUint16LE=fe.prototype.readUInt16LE=function(e,r){return e=e>>>0,r||ho(e,2,this.length),this[e]|this[e+1]<<8};fe.prototype.readUint16BE=fe.prototype.readUInt16BE=function(e,r){return e=e>>>0,r||ho(e,2,this.length),this[e]<<8|this[e+1]};fe.prototype.readUint32LE=fe.prototype.readUInt32LE=function(e,r){return e=e>>>0,r||ho(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216};fe.prototype.readUint32BE=fe.prototype.readUInt32BE=function(e,r){return e=e>>>0,r||ho(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])};fe.prototype.readBigUInt64LE=up(function(e){e=e>>>0,rv(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&c_(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,rv(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&c_(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||ho(e,r,this.length);let i=this[e],o=1,s=0;for(;++s=o&&(i-=Math.pow(2,8*r)),i};fe.prototype.readIntBE=function(e,r,n){e=e>>>0,r=r>>>0,n||ho(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};fe.prototype.readInt8=function(e,r){return e=e>>>0,r||ho(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]};fe.prototype.readInt16LE=function(e,r){e=e>>>0,r||ho(e,2,this.length);let n=this[e]|this[e+1]<<8;return n&32768?n|4294901760:n};fe.prototype.readInt16BE=function(e,r){e=e>>>0,r||ho(e,2,this.length);let n=this[e+1]|this[e]<<8;return n&32768?n|4294901760:n};fe.prototype.readInt32LE=function(e,r){return e=e>>>0,r||ho(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24};fe.prototype.readInt32BE=function(e,r){return e=e>>>0,r||ho(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]};fe.prototype.readBigInt64LE=up(function(e){e=e>>>0,rv(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&c_(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,rv(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&c_(e,this.length-8);let i=(r<<24)+this[++e]*2**16+this[++e]*2**8+this[++e];return(BigInt(i)<>>0,r||ho(e,4,this.length),tv.read(this,e,!0,23,4)};fe.prototype.readFloatBE=function(e,r){return e=e>>>0,r||ho(e,4,this.length),tv.read(this,e,!1,23,4)};fe.prototype.readDoubleLE=function(e,r){return e=e>>>0,r||ho(e,8,this.length),tv.read(this,e,!0,52,8)};fe.prototype.readDoubleBE=function(e,r){return e=e>>>0,r||ho(e,8,this.length),tv.read(this,e,!1,52,8)};function wa(t,e,r,n,i,o){if(!fe.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||et.length)throw new RangeError("Index out of range")}fe.prototype.writeUintLE=fe.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;wa(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;wa(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};fe.prototype.writeUint8=fe.prototype.writeUInt8=function(e,r,n){return e=+e,r=r>>>0,n||wa(this,e,r,1,255,0),this[r]=e&255,r+1};fe.prototype.writeUint16LE=fe.prototype.writeUInt16LE=function(e,r,n){return e=+e,r=r>>>0,n||wa(this,e,r,2,65535,0),this[r]=e&255,this[r+1]=e>>>8,r+2};fe.prototype.writeUint16BE=fe.prototype.writeUInt16BE=function(e,r,n){return e=+e,r=r>>>0,n||wa(this,e,r,2,65535,0),this[r]=e>>>8,this[r+1]=e&255,r+2};fe.prototype.writeUint32LE=fe.prototype.writeUInt32LE=function(e,r,n){return e=+e,r=r>>>0,n||wa(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};fe.prototype.writeUint32BE=fe.prototype.writeUInt32BE=function(e,r,n){return e=+e,r=r>>>0,n||wa(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 FW(t,e,r,n,i){VW(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 zW(t,e,r,n,i){VW(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}fe.prototype.writeBigUInt64LE=up(function(e,r=0){return FW(this,e,r,BigInt(0),BigInt("0xffffffffffffffff"))});fe.prototype.writeBigUInt64BE=up(function(e,r=0){return zW(this,e,r,BigInt(0),BigInt("0xffffffffffffffff"))});fe.prototype.writeIntLE=function(e,r,n,i){if(e=+e,r=r>>>0,!i){let d=Math.pow(2,8*n-1);wa(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};fe.prototype.writeIntBE=function(e,r,n,i){if(e=+e,r=r>>>0,!i){let d=Math.pow(2,8*n-1);wa(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};fe.prototype.writeInt8=function(e,r,n){return e=+e,r=r>>>0,n||wa(this,e,r,1,127,-128),e<0&&(e=255+e+1),this[r]=e&255,r+1};fe.prototype.writeInt16LE=function(e,r,n){return e=+e,r=r>>>0,n||wa(this,e,r,2,32767,-32768),this[r]=e&255,this[r+1]=e>>>8,r+2};fe.prototype.writeInt16BE=function(e,r,n){return e=+e,r=r>>>0,n||wa(this,e,r,2,32767,-32768),this[r]=e>>>8,this[r+1]=e&255,r+2};fe.prototype.writeInt32LE=function(e,r,n){return e=+e,r=r>>>0,n||wa(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};fe.prototype.writeInt32BE=function(e,r,n){return e=+e,r=r>>>0,n||wa(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};fe.prototype.writeBigInt64LE=up(function(e,r=0){return FW(this,e,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});fe.prototype.writeBigInt64BE=up(function(e,r=0){return zW(this,e,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function GW(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 WW(t,e,r,n,i){return e=+e,r=r>>>0,i||GW(t,e,r,4,34028234663852886e22,-34028234663852886e22),tv.write(t,e,r,n,23,4),r+4}fe.prototype.writeFloatLE=function(e,r,n){return WW(this,e,r,!0,n)};fe.prototype.writeFloatBE=function(e,r,n){return WW(this,e,r,!1,n)};function HW(t,e,r,n,i){return e=+e,r=r>>>0,i||GW(t,e,r,8,17976931348623157e292,-17976931348623157e292),tv.write(t,e,r,n,52,8),r+8}fe.prototype.writeDoubleLE=function(e,r,n){return HW(this,e,r,!0,n)};fe.prototype.writeDoubleBE=function(e,r,n){return HW(this,e,r,!1,n)};fe.prototype.copy=function(e,r,n,i){if(!fe.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=NW(String(r)):typeof r=="bigint"&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=NW(i)),i+="n"),n+=` It must be ${e}. Received ${i}`,n},RangeError);function NW(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 Dxe(t,e,r){rv(e,"offset"),(t[e]===void 0||t[e+r]===void 0)&&c_(e,t.length-(r+1))}function VW(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 ev.ERR_OUT_OF_RANGE("value",a,t)}Dxe(n,i,o)}function rv(t,e){if(typeof t!="number")throw new ev.ERR_INVALID_ARG_TYPE(e,"number",t)}function c_(t,e,r){throw Math.floor(t)!==t?(rv(t,r),new ev.ERR_OUT_OF_RANGE(r||"offset","an integer",t)):e<0?new ev.ERR_BUFFER_OUT_OF_BOUNDS:new ev.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}var Mxe=/[^+/0-9A-Za-z-_]/g;function Bxe(t){if(t=t.split("=")[0],t=t.trim().replace(Mxe,""),t.length<2)return"";for(;t.length%4!==0;)t=t+"=";return t}function D9(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 Cxe(t){let e=[];for(let r=0;r>8,i=r%256,o.push(i),o.push(n);return o}function JW(t){return I9.toByteArray(Bxe(t))}function I3(t,e,r,n){let i;for(i=0;i=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function Xu(t,e){return t instanceof e||t!=null&&t.constructor!=null&&t.constructor.name!=null&&t.constructor.name===e.name}function O9(t){return t!==t}var $xe=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 up(t){return typeof BigInt>"u"?Nxe:t}function Nxe(){throw new Error("BigInt not supported")}});var ar=W(($9,ZW)=>{h();var k3=Un(),Qu=k3.Buffer;function YW(t,e){for(var r in t)e[r]=t[r]}Qu.from&&Qu.alloc&&Qu.allocUnsafe&&Qu.allocUnsafeSlow?ZW.exports=k3:(YW(k3,$9),$9.Buffer=Uy);function Uy(t,e,r){return Qu(t,e,r)}Uy.prototype=Object.create(Qu.prototype);YW(Qu,Uy);Uy.from=function(t,e,r){if(typeof t=="number")throw new TypeError("Argument must not be a number");return Qu(t,e,r)};Uy.alloc=function(t,e,r){if(typeof t!="number")throw new TypeError("Argument must be a number");var n=Qu(t);return e!==void 0?typeof r=="string"?n.fill(e,r):n.fill(e):n.fill(0),n};Uy.allocUnsafe=function(t){if(typeof t!="number")throw new TypeError("Argument must be a number");return Qu(t)};Uy.allocUnsafeSlow=function(t){if(typeof t!="number")throw new TypeError("Argument must be a number");return k3.SlowBuffer(t)}});var Ky=W(($ct,j9)=>{"use strict";h();var N9=65536,jxe=4294967295;function Uxe(){throw new Error(`Secure random number generation is not supported by this browser. Use Chrome, Firefox or Internet Explorer 11`)}var Kxe=ar().Buffer,R3=globalThis.crypto||globalThis.msCrypto;R3&&R3.getRandomValues?j9.exports=qxe:j9.exports=Uxe;function qxe(t,e){if(t>jxe)throw new RangeError("requested too many random bytes");var r=Kxe.allocUnsafe(t);if(t>0)if(t>N9)for(var n=0;n{h();typeof Object.create=="function"?U9.exports=function(e,r){r&&(e.super_=r,e.prototype=Object.create(r.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:U9.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 nc=W((Kct,K9)=>{"use strict";h();var iv=typeof Reflect=="object"?Reflect:null,XW=iv&&typeof iv.apply=="function"?iv.apply:function(e,r,n){return Function.prototype.apply.call(e,r,n)},D3;iv&&typeof iv.ownKeys=="function"?D3=iv.ownKeys:Object.getOwnPropertySymbols?D3=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:D3=function(e){return Object.getOwnPropertyNames(e)};function Lxe(t){console&&console.warn&&console.warn(t)}var eH=Number.isNaN||function(e){return e!==e};function un(){un.init.call(this)}K9.exports=un;K9.exports.once=Wxe;un.EventEmitter=un;un.prototype._events=void 0;un.prototype._eventsCount=0;un.prototype._maxListeners=void 0;var QW=10;function M3(t){if(typeof t!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}Object.defineProperty(un,"defaultMaxListeners",{enumerable:!0,get:function(){return QW},set:function(t){if(typeof t!="number"||t<0||eH(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");QW=t}});un.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};un.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||eH(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 tH(t){return t._maxListeners===void 0?un.defaultMaxListeners:t._maxListeners}un.prototype.getMaxListeners=function(){return tH(this)};un.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")XW(d,this,r);else for(var u=d.length,c=sH(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,Lxe(a)}return t}un.prototype.addListener=function(e,r){return rH(this,e,r,!1)};un.prototype.on=un.prototype.addListener;un.prototype.prependListener=function(e,r){return rH(this,e,r,!0)};function Fxe(){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 nH(t,e,r){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},i=Fxe.bind(n);return i.listener=r,n.wrapFn=i,i}un.prototype.once=function(e,r){return M3(r),this.on(e,nH(this,e,r)),this};un.prototype.prependOnceListener=function(e,r){return M3(r),this.prependListener(e,nH(this,e,r)),this};un.prototype.removeListener=function(e,r){var n,i,o,s,a;if(M3(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():zxe(n,o),n.length===1&&(i[e]=n[0]),i.removeListener!==void 0&&this.emit("removeListener",e,a||r)}return this};un.prototype.off=un.prototype.removeListener;un.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 iH(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?Gxe(i):sH(i,i.length)}un.prototype.listeners=function(e){return iH(this,e,!0)};un.prototype.rawListeners=function(e){return iH(this,e,!1)};un.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):oH.call(t,e)};un.prototype.listenerCount=oH;function oH(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}un.prototype.eventNames=function(){return this._eventsCount>0?D3(this._events):[]};function sH(t,e){for(var r=new Array(e),n=0;n{h();cH.exports=nc().EventEmitter});var L9=W(()=>{h()});var pH=W((Hct,hH)=>{"use strict";h();function dH(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 uH(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 B3.alloc(0);for(var n=B3.allocUnsafe(r>>>0),i=this.head,o=0;i;)tEe(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=B3.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:eEe,value:function(r,n){return F9(this,uH(uH({},n),{},{depth:0,customInspect:!1}))}}]),t}()});var G9=W((Jct,yH)=>{"use strict";h();function rEe(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,B.default.nextTick(z9,this,t)):B.default.nextTick(z9,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?B.default.nextTick(C3,r):(r._writableState.errorEmitted=!0,B.default.nextTick(mH,r,o)):B.default.nextTick(mH,r,o):e?(B.default.nextTick(C3,r),e(o)):B.default.nextTick(C3,r)}),this)}function mH(t,e){z9(t,e),C3(t)}function C3(t){t._writableState&&!t._writableState.emitClose||t._readableState&&!t._readableState.emitClose||t.emit("close")}function nEe(){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 z9(t,e){t.emit("error",e)}function iEe(t,e){var r=t._readableState,n=t._writableState;r&&r.autoDestroy||n&&n.autoDestroy?t.destroy(e):t.emit("error",e)}yH.exports={destroy:rEe,undestroy:nEe,errorOrDestroy:iEe}});var qy=W((Zct,vH)=>{"use strict";h();function oEe(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}var bH={};function Lc(t,e,r){r||(r=Error);function n(o,s,a){return typeof e=="string"?e:e(o,s,a)}var i=function(o){oEe(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,bH[t]=i}function gH(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 sEe(t,e,r){return t.substr(!r||r<0?0:+r,e.length)===e}function aEe(t,e,r){return(r===void 0||r>t.length)&&(r=t.length),t.substring(r-e.length,r)===e}function cEe(t,e,r){return typeof r!="number"&&(r=0),r+e.length>t.length?!1:t.indexOf(e,r)!==-1}Lc("ERR_INVALID_OPT_VALUE",function(t,e){return'The value "'+e+'" is invalid for option "'+t+'"'},TypeError);Lc("ERR_INVALID_ARG_TYPE",function(t,e,r){var n;typeof e=="string"&&sEe(e,"not ")?(n="must not be",e=e.replace(/^not /,"")):n="must be";var i;if(aEe(t," argument"))i="The ".concat(t," ").concat(n," ").concat(gH(e,"type"));else{var o=cEe(t,".")?"property":"argument";i='The "'.concat(t,'" ').concat(o," ").concat(n," ").concat(gH(e,"type"))}return i+=". Received type ".concat(typeof r),i},TypeError);Lc("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF");Lc("ERR_METHOD_NOT_IMPLEMENTED",function(t){return"The "+t+" method is not implemented"});Lc("ERR_STREAM_PREMATURE_CLOSE","Premature close");Lc("ERR_STREAM_DESTROYED",function(t){return"Cannot call "+t+" after a stream was destroyed"});Lc("ERR_MULTIPLE_CALLBACK","Callback called multiple times");Lc("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable");Lc("ERR_STREAM_WRITE_AFTER_END","write after end");Lc("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError);Lc("ERR_UNKNOWN_ENCODING",function(t){return"Unknown encoding: "+t},TypeError);Lc("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event");vH.exports.codes=bH});var W9=W((Qct,wH)=>{"use strict";h();var dEe=qy().codes.ERR_INVALID_OPT_VALUE;function uEe(t,e,r){return t.highWaterMark!=null?t.highWaterMark:e?t[r]:null}function lEe(t,e,r,n){var i=uEe(e,n,r);if(i!=null){if(!(isFinite(i)&&Math.floor(i)===i)||i<0){var o=n?r:"highWaterMark";throw new dEe(o,i)}return Math.floor(i)}return t.objectMode?16:16*1024}wH.exports={getHighWaterMark:lEe}});var xH=W((tdt,_H)=>{h();_H.exports=fEe;function fEe(t,e){if(H9("noDeprecation"))return t;var r=!1;function n(){if(!r){if(H9("throwDeprecation"))throw new Error(e);H9("traceDeprecation")?console.trace(e):console.warn(e),r=!0}return t.apply(this,arguments)}return n}function H9(t){try{if(!globalThis.localStorage)return!1}catch{return!1}var e=globalThis.localStorage[t];return e==null?!1:String(e).toLowerCase()==="true"}});var N3=W((ndt,IH)=>{"use strict";h();IH.exports=ai;function SH(t){var e=this;this.next=null,this.entry=null,this.finish=function(){UEe(e,t)}}var ov;ai.WritableState=u_;var hEe={deprecate:xH()},AH=q9(),$3=Un().Buffer,pEe=(typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function mEe(t){return $3.from(t)}function yEe(t){return $3.isBuffer(t)||t instanceof pEe}var J9=G9(),gEe=W9(),bEe=gEe.getHighWaterMark,lp=qy().codes,vEe=lp.ERR_INVALID_ARG_TYPE,wEe=lp.ERR_METHOD_NOT_IMPLEMENTED,_Ee=lp.ERR_MULTIPLE_CALLBACK,xEe=lp.ERR_STREAM_CANNOT_PIPE,EEe=lp.ERR_STREAM_DESTROYED,SEe=lp.ERR_STREAM_NULL_VALUES,AEe=lp.ERR_STREAM_WRITE_AFTER_END,PEe=lp.ERR_UNKNOWN_ENCODING,sv=J9.errorOrDestroy;cr()(ai,AH);function TEe(){}function u_(t,e,r){ov=ov||fp(),t=t||{},typeof r!="boolean"&&(r=e instanceof ov),this.objectMode=!!t.objectMode,r&&(this.objectMode=this.objectMode||!!t.writableObjectMode),this.highWaterMark=bEe(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){CEe(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 SH(this)}u_.prototype.getBuffer=function(){for(var e=this.bufferedRequest,r=[];e;)r.push(e),e=e.next;return r};(function(){try{Object.defineProperty(u_.prototype,"buffer",{get:hEe.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch{}})();var O3;typeof Symbol=="function"&&Symbol.hasInstance&&typeof Function.prototype[Symbol.hasInstance]=="function"?(O3=Function.prototype[Symbol.hasInstance],Object.defineProperty(ai,Symbol.hasInstance,{value:function(e){return O3.call(this,e)?!0:this!==ai?!1:e&&e._writableState instanceof u_}})):O3=function(e){return e instanceof this};function ai(t){ov=ov||fp();var e=this instanceof ov;if(!e&&!O3.call(ai,this))return new ai(t);this._writableState=new u_(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)),AH.call(this)}ai.prototype.pipe=function(){sv(this,new xEe)};function IEe(t,e){var r=new AEe;sv(t,r),B.default.nextTick(e,r)}function kEe(t,e,r,n){var i;return r===null?i=new SEe:typeof r!="string"&&!e.objectMode&&(i=new vEe("chunk",["string","Buffer"],r)),i?(sv(t,i),B.default.nextTick(n,i),!1):!0}ai.prototype.write=function(t,e,r){var n=this._writableState,i=!1,o=!n.objectMode&&yEe(t);return o&&!$3.isBuffer(t)&&(t=mEe(t)),typeof e=="function"&&(r=e,e=null),o?e="buffer":e||(e=n.defaultEncoding),typeof r!="function"&&(r=TEe),n.ending?IEe(this,r):(o||kEe(this,n,t,r))&&(n.pendingcb++,i=DEe(this,n,o,t,e,r)),i};ai.prototype.cork=function(){this._writableState.corked++};ai.prototype.uncork=function(){var t=this._writableState;t.corked&&(t.corked--,!t.writing&&!t.corked&&!t.bufferProcessing&&t.bufferedRequest&&PH(this,t))};ai.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 PEe(e);return this._writableState.defaultEncoding=e,this};Object.defineProperty(ai.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}});function REe(t,e,r){return!t.objectMode&&t.decodeStrings!==!1&&typeof e=="string"&&(e=$3.from(e,r)),e}Object.defineProperty(ai.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function DEe(t,e,r,n,i,o){if(!r){var s=REe(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";h();var KEe=Object.keys||function(t){var e=[];for(var r in t)e.push(r);return e};RH.exports=el;var kH=K3(),Z9=N3();cr()(el,kH);for(Y9=KEe(Z9.prototype),j3=0;j3{"use strict";h();var Q9=ar().Buffer,DH=Q9.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 FEe(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 zEe(t){var e=FEe(t);if(typeof e!="string"&&(Q9.isEncoding===DH||!DH(t)))throw new Error("Unknown encoding: "+t);return e||t}MH.StringDecoder=l_;function l_(t){this.encoding=zEe(t);var e;switch(this.encoding){case"utf16le":this.text=YEe,this.end=ZEe,e=4;break;case"utf8":this.fillLast=HEe,e=4;break;case"base64":this.text=XEe,this.end=QEe,e=3;break;default:this.write=e6e,this.end=t6e;return}this.lastNeed=0,this.lastTotal=0,this.lastChar=Q9.allocUnsafe(e)}l_.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 GEe(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 WEe(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 HEe(t){var e=this.lastTotal-this.lastNeed,r=WEe(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 VEe(t,e){var r=GEe(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 JEe(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+"\uFFFD":e}function YEe(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 ZEe(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 XEe(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 QEe(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+this.lastChar.toString("base64",0,3-this.lastNeed):e}function e6e(t){return t.toString(this.encoding)}function t6e(t){return t&&t.length?this.write(t):""}});var f_=W((ddt,OH)=>{"use strict";h();var BH=qy().codes.ERR_STREAM_PREMATURE_CLOSE;function r6e(t){var e=!1;return function(){if(!e){e=!0;for(var r=arguments.length,n=new Array(r),i=0;i{"use strict";h();var q3;function hp(t,e,r){return e=o6e(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function o6e(t){var e=s6e(t,"string");return typeof e=="symbol"?e:String(e)}function s6e(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 a6e=f_(),pp=Symbol("lastResolve"),Ly=Symbol("lastReject"),h_=Symbol("error"),L3=Symbol("ended"),Fy=Symbol("lastPromise"),eD=Symbol("handlePromise"),zy=Symbol("stream");function mp(t,e){return{value:t,done:e}}function c6e(t){var e=t[pp];if(e!==null){var r=t[zy].read();r!==null&&(t[Fy]=null,t[pp]=null,t[Ly]=null,e(mp(r,!1)))}}function d6e(t){B.default.nextTick(c6e,t)}function u6e(t,e){return function(r,n){t.then(function(){if(e[L3]){r(mp(void 0,!0));return}e[eD](r,n)},n)}}var l6e=Object.getPrototypeOf(function(){}),f6e=Object.setPrototypeOf((q3={get stream(){return this[zy]},next:function(){var e=this,r=this[h_];if(r!==null)return Promise.reject(r);if(this[L3])return Promise.resolve(mp(void 0,!0));if(this[zy].destroyed)return new Promise(function(s,a){B.default.nextTick(function(){e[h_]?a(e[h_]):s(mp(void 0,!0))})});var n=this[Fy],i;if(n)i=new Promise(u6e(n,this));else{var o=this[zy].read();if(o!==null)return Promise.resolve(mp(o,!1));i=new Promise(this[eD])}return this[Fy]=i,i}},hp(q3,Symbol.asyncIterator,function(){return this}),hp(q3,"return",function(){var e=this;return new Promise(function(r,n){e[zy].destroy(null,function(i){if(i){n(i);return}r(mp(void 0,!0))})})}),q3),l6e),h6e=function(e){var r,n=Object.create(f6e,(r={},hp(r,zy,{value:e,writable:!0}),hp(r,pp,{value:null,writable:!0}),hp(r,Ly,{value:null,writable:!0}),hp(r,h_,{value:null,writable:!0}),hp(r,L3,{value:e._readableState.endEmitted,writable:!0}),hp(r,eD,{value:function(o,s){var a=n[zy].read();a?(n[Fy]=null,n[pp]=null,n[Ly]=null,o(mp(a,!1))):(n[pp]=o,n[Ly]=s)},writable:!0}),r));return n[Fy]=null,a6e(e,function(i){if(i&&i.code!=="ERR_STREAM_PREMATURE_CLOSE"){var o=n[Ly];o!==null&&(n[Fy]=null,n[pp]=null,n[Ly]=null,o(i)),n[h_]=i;return}var s=n[pp];s!==null&&(n[Fy]=null,n[pp]=null,n[Ly]=null,s(mp(void 0,!0))),n[L3]=!0}),e.on("readable",d6e.bind(null,n)),n};$H.exports=h6e});var UH=W((hdt,jH)=>{h();jH.exports=function(){throw new Error("Readable.from is not available in the browser")}});var K3=W((ydt,JH)=>{"use strict";h();JH.exports=Fr;var cv;Fr.ReadableState=FH;var mdt=nc().EventEmitter,LH=function(e,r){return e.listeners(r).length},m_=q9(),F3=Un().Buffer,p6e=(typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function m6e(t){return F3.from(t)}function y6e(t){return F3.isBuffer(t)||t instanceof p6e}var tD=L9(),wr;tD&&tD.debuglog?wr=tD.debuglog("stream"):wr=function(){};var g6e=pH(),cD=G9(),b6e=W9(),v6e=b6e.getHighWaterMark,z3=qy().codes,w6e=z3.ERR_INVALID_ARG_TYPE,_6e=z3.ERR_STREAM_PUSH_AFTER_EOF,x6e=z3.ERR_METHOD_NOT_IMPLEMENTED,E6e=z3.ERR_STREAM_UNSHIFT_AFTER_END_EVENT,dv,rD,nD;cr()(Fr,m_);var p_=cD.errorOrDestroy,iD=["error","close","destroy","pause","resume"];function S6e(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 FH(t,e,r){cv=cv||fp(),t=t||{},typeof r!="boolean"&&(r=e instanceof cv),this.objectMode=!!t.objectMode,r&&(this.objectMode=this.objectMode||!!t.readableObjectMode),this.highWaterMark=v6e(this,t,"readableHighWaterMark",r),this.buffer=new g6e,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&&(dv||(dv=av().StringDecoder),this.decoder=new dv(t.encoding),this.encoding=t.encoding)}function Fr(t){if(cv=cv||fp(),!(this instanceof Fr))return new Fr(t);var e=this instanceof cv;this._readableState=new FH(t,this,e),this.readable=!0,t&&(typeof t.read=="function"&&(this._read=t.read),typeof t.destroy=="function"&&(this._destroy=t.destroy)),m_.call(this)}Object.defineProperty(Fr.prototype,"destroyed",{enumerable:!1,get:function(){return this._readableState===void 0?!1:this._readableState.destroyed},set:function(e){this._readableState&&(this._readableState.destroyed=e)}});Fr.prototype.destroy=cD.destroy;Fr.prototype._undestroy=cD.undestroy;Fr.prototype._destroy=function(t,e){e(t)};Fr.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=F3.from(t,e),e=""),n=!0),zH(this,t,e,!1,n)};Fr.prototype.unshift=function(t){return zH(this,t,null,!0,!1)};function zH(t,e,r,n,i){wr("readableAddChunk",e);var o=t._readableState;if(e===null)o.reading=!1,T6e(t,o);else{var s;if(i||(s=A6e(o,e)),s)p_(t,s);else if(o.objectMode||e&&e.length>0)if(typeof e!="string"&&!o.objectMode&&Object.getPrototypeOf(e)!==F3.prototype&&(e=m6e(e)),n)o.endEmitted?p_(t,new E6e):oD(t,o,e,!0);else if(o.ended)p_(t,new _6e);else{if(o.destroyed)return!1;o.reading=!1,o.decoder&&!r?(e=o.decoder.write(e),o.objectMode||e.length!==0?oD(t,o,e,!1):aD(t,o)):oD(t,o,e,!1)}else n||(o.reading=!1,aD(t,o))}return!o.ended&&(o.length=KH?t=KH:(t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++),t}function qH(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=P6e(t)),t<=e.length?t:e.ended?e.length:(e.needReadable=!0,0))}Fr.prototype.read=function(t){wr("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 wr("read: emitReadable",e.length,e.ended),e.length===0&&e.ended?sD(this):G3(this),null;if(t=qH(t,e),t===0&&e.ended)return e.length===0&&sD(this),null;var n=e.needReadable;wr("need readable",n),(e.length===0||e.length-t0?i=HH(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&&sD(this)),i!==null&&this.emit("data",i),i};function T6e(t,e){if(wr("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?G3(t):(e.needReadable=!1,e.emittedReadable||(e.emittedReadable=!0,GH(t)))}}function G3(t){var e=t._readableState;wr("emitReadable",e.needReadable,e.emittedReadable),e.needReadable=!1,e.emittedReadable||(wr("emitReadable",e.flowing),e.emittedReadable=!0,B.default.nextTick(GH,t))}function GH(t){var e=t._readableState;wr("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,dD(t)}function aD(t,e){e.readingMore||(e.readingMore=!0,B.default.nextTick(I6e,t,e))}function I6e(t,e){for(;!e.reading&&!e.ended&&(e.length1&&VH(n.pipes,t)!==-1)&&!u&&(wr("false write response, pause",n.awaitDrain),n.awaitDrain++),r.pause())}function m(S){wr("onerror",S),b(),t.removeListener("error",m),LH(t,"error")===0&&p_(t,S)}S6e(t,"error",m);function p(){t.removeListener("finish",g),b()}t.once("close",p);function g(){wr("onfinish"),t.removeListener("close",p),b()}t.once("finish",g);function b(){wr("unpipe"),r.unpipe(t)}return t.emit("pipe",r),n.flowing||(wr("pipe resume"),r.resume()),t};function k6e(t){return function(){var r=t._readableState;wr("pipeOnDrain",r.awaitDrain),r.awaitDrain&&r.awaitDrain--,r.awaitDrain===0&&LH(t,"data")&&(r.flowing=!0,dD(t))}}Fr.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,wr("on readable",n.length,n.reading),n.length?G3(this):n.reading||B.default.nextTick(R6e,this)),r};Fr.prototype.addListener=Fr.prototype.on;Fr.prototype.removeListener=function(t,e){var r=m_.prototype.removeListener.call(this,t,e);return t==="readable"&&B.default.nextTick(WH,this),r};Fr.prototype.removeAllListeners=function(t){var e=m_.prototype.removeAllListeners.apply(this,arguments);return(t==="readable"||t===void 0)&&B.default.nextTick(WH,this),e};function WH(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 R6e(t){wr("readable nexttick read 0"),t.read(0)}Fr.prototype.resume=function(){var t=this._readableState;return t.flowing||(wr("resume"),t.flowing=!t.readableListening,D6e(this,t)),t.paused=!1,this};function D6e(t,e){e.resumeScheduled||(e.resumeScheduled=!0,B.default.nextTick(M6e,t,e))}function M6e(t,e){wr("resume",e.reading),e.reading||t.read(0),e.resumeScheduled=!1,t.emit("resume"),dD(t),e.flowing&&!e.reading&&t.read(0)}Fr.prototype.pause=function(){return wr("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(wr("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this};function dD(t){var e=t._readableState;for(wr("flow",e.flowing);e.flowing&&t.read()!==null;);}Fr.prototype.wrap=function(t){var e=this,r=this._readableState,n=!1;t.on("end",function(){if(wr("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(wr("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 sD(t){var e=t._readableState;wr("endReadable",e.endEmitted),e.endEmitted||(e.ended=!0,B.default.nextTick(B6e,e,t))}function B6e(t,e){if(wr("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"&&(Fr.from=function(t,e){return nD===void 0&&(nD=UH()),nD(Fr,t,e)});function VH(t,e){for(var r=0,n=t.length;r{"use strict";h();ZH.exports=Sf;var W3=qy().codes,C6e=W3.ERR_METHOD_NOT_IMPLEMENTED,O6e=W3.ERR_MULTIPLE_CALLBACK,$6e=W3.ERR_TRANSFORM_ALREADY_TRANSFORMING,N6e=W3.ERR_TRANSFORM_WITH_LENGTH_0,H3=fp();cr()(Sf,H3);function j6e(t,e){var r=this._transformState;r.transforming=!1;var n=r.writecb;if(n===null)return this.emit("error",new O6e);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";h();QH.exports=y_;var XH=V3();cr()(y_,XH);function y_(t){if(!(this instanceof y_))return new y_(t);XH.call(this,t)}y_.prototype._transform=function(t,e,r){r(null,t)}});var fD=W((xdt,nV)=>{"use strict";h();var lD;function K6e(t){var e=!1;return function(){e||(e=!0,t.apply(void 0,arguments))}}var rV=qy().codes,q6e=rV.ERR_MISSING_ARGS,L6e=rV.ERR_STREAM_DESTROYED;function eV(t){if(t)throw t}function F6e(t){return t.setHeader&&typeof t.abort=="function"}function z6e(t,e,r,n){n=K6e(n);var i=!1;t.on("close",function(){i=!0}),lD===void 0&&(lD=f_()),lD(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,F6e(t))return t.abort();if(typeof t.destroy=="function")return t.destroy();n(s||new L6e("pipe"))}}}function tV(t){t()}function G6e(t,e){return t.pipe(e)}function W6e(t){return!t.length||typeof t[t.length-1]!="function"?eV:t.pop()}function H6e(){for(var t=arguments.length,e=new Array(t),r=0;r0;return z6e(s,d,u,function(c){i||(i=c),c&&o.forEach(tV),!d&&(o.forEach(tV),n(i))})});return e.reduce(G6e)}nV.exports=H6e});var J3=W((Fc,iV)=>{h();Fc=iV.exports=K3();Fc.Stream=Fc;Fc.Readable=Fc;Fc.Writable=N3();Fc.Duplex=fp();Fc.Transform=V3();Fc.PassThrough=uD();Fc.finished=f_();Fc.pipeline=fD()});var hD=W((Adt,sV)=>{"use strict";h();var Y3=ar().Buffer,oV=J3().Transform,V6e=cr();function J6e(t,e){if(!Y3.isBuffer(t)&&typeof t!="string")throw new TypeError(e+" must be a string or a buffer")}function yp(t){oV.call(this),this._block=Y3.allocUnsafe(t),this._blockSize=t,this._blockOffset=0,this._length=[0,0,0,0],this._finalized=!1}V6e(yp,oV);yp.prototype._transform=function(t,e,r){var n=null;try{this.update(t,e)}catch(i){n=i}r(n)};yp.prototype._flush=function(t){var e=null;try{this.push(this.digest())}catch(r){e=r}t(e)};yp.prototype.update=function(t,e){if(J6e(t,"Data"),this._finalized)throw new Error("Digest already called");Y3.isBuffer(t)||(t=Y3.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};yp.prototype._update=function(){throw new Error("_update is not implemented")};yp.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};yp.prototype._digest=function(){throw new Error("_digest is not implemented")};sV.exports=yp});var Q3=W((Tdt,cV)=>{"use strict";h();var Y6e=cr(),aV=hD(),Z6e=ar().Buffer,X6e=new Array(16);function Z3(){aV.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878}Y6e(Z3,aV);Z3.prototype._update=function(){for(var t=X6e,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=xs(r,n,i,o,t[0],3614090360,7),o=xs(o,r,n,i,t[1],3905402710,12),i=xs(i,o,r,n,t[2],606105819,17),n=xs(n,i,o,r,t[3],3250441966,22),r=xs(r,n,i,o,t[4],4118548399,7),o=xs(o,r,n,i,t[5],1200080426,12),i=xs(i,o,r,n,t[6],2821735955,17),n=xs(n,i,o,r,t[7],4249261313,22),r=xs(r,n,i,o,t[8],1770035416,7),o=xs(o,r,n,i,t[9],2336552879,12),i=xs(i,o,r,n,t[10],4294925233,17),n=xs(n,i,o,r,t[11],2304563134,22),r=xs(r,n,i,o,t[12],1804603682,7),o=xs(o,r,n,i,t[13],4254626195,12),i=xs(i,o,r,n,t[14],2792965006,17),n=xs(n,i,o,r,t[15],1236535329,22),r=Es(r,n,i,o,t[1],4129170786,5),o=Es(o,r,n,i,t[6],3225465664,9),i=Es(i,o,r,n,t[11],643717713,14),n=Es(n,i,o,r,t[0],3921069994,20),r=Es(r,n,i,o,t[5],3593408605,5),o=Es(o,r,n,i,t[10],38016083,9),i=Es(i,o,r,n,t[15],3634488961,14),n=Es(n,i,o,r,t[4],3889429448,20),r=Es(r,n,i,o,t[9],568446438,5),o=Es(o,r,n,i,t[14],3275163606,9),i=Es(i,o,r,n,t[3],4107603335,14),n=Es(n,i,o,r,t[8],1163531501,20),r=Es(r,n,i,o,t[13],2850285829,5),o=Es(o,r,n,i,t[2],4243563512,9),i=Es(i,o,r,n,t[7],1735328473,14),n=Es(n,i,o,r,t[12],2368359562,20),r=Ss(r,n,i,o,t[5],4294588738,4),o=Ss(o,r,n,i,t[8],2272392833,11),i=Ss(i,o,r,n,t[11],1839030562,16),n=Ss(n,i,o,r,t[14],4259657740,23),r=Ss(r,n,i,o,t[1],2763975236,4),o=Ss(o,r,n,i,t[4],1272893353,11),i=Ss(i,o,r,n,t[7],4139469664,16),n=Ss(n,i,o,r,t[10],3200236656,23),r=Ss(r,n,i,o,t[13],681279174,4),o=Ss(o,r,n,i,t[0],3936430074,11),i=Ss(i,o,r,n,t[3],3572445317,16),n=Ss(n,i,o,r,t[6],76029189,23),r=Ss(r,n,i,o,t[9],3654602809,4),o=Ss(o,r,n,i,t[12],3873151461,11),i=Ss(i,o,r,n,t[15],530742520,16),n=Ss(n,i,o,r,t[2],3299628645,23),r=As(r,n,i,o,t[0],4096336452,6),o=As(o,r,n,i,t[7],1126891415,10),i=As(i,o,r,n,t[14],2878612391,15),n=As(n,i,o,r,t[5],4237533241,21),r=As(r,n,i,o,t[12],1700485571,6),o=As(o,r,n,i,t[3],2399980690,10),i=As(i,o,r,n,t[10],4293915773,15),n=As(n,i,o,r,t[1],2240044497,21),r=As(r,n,i,o,t[8],1873313359,6),o=As(o,r,n,i,t[15],4264355552,10),i=As(i,o,r,n,t[6],2734768916,15),n=As(n,i,o,r,t[13],1309151649,21),r=As(r,n,i,o,t[4],4149444226,6),o=As(o,r,n,i,t[11],3174756917,10),i=As(i,o,r,n,t[2],718787259,15),n=As(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};Z3.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=Z6e.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 X3(t,e){return t<>>32-e}function xs(t,e,r,n,i,o,s){return X3(t+(e&r|~e&n)+i+o|0,s)+e|0}function Es(t,e,r,n,i,o,s){return X3(t+(e&n|r&~n)+i+o|0,s)+e|0}function Ss(t,e,r,n,i,o,s){return X3(t+(e^r^n)+i+o|0,s)+e|0}function As(t,e,r,n,i,o,s){return X3(t+(r^(e|~n))+i+o|0,s)+e|0}cV.exports=Z3});var t5=W((kdt,mV)=>{"use strict";h();var pD=Un().Buffer,Q6e=cr(),pV=hD(),eSe=new Array(16),g_=[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],b_=[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],v_=[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],w_=[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],__=[0,1518500249,1859775393,2400959708,2840853838],x_=[1352829926,1548603684,1836072691,2053994217,0];function e5(){pV.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520}Q6e(e5,pV);e5.prototype._update=function(){for(var t=eSe,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,m=0;m<80;m+=1){var p,g;m<16?(p=dV(r,n,i,o,s,t[g_[m]],__[0],v_[m]),g=hV(a,d,u,c,l,t[b_[m]],x_[0],w_[m])):m<32?(p=uV(r,n,i,o,s,t[g_[m]],__[1],v_[m]),g=fV(a,d,u,c,l,t[b_[m]],x_[1],w_[m])):m<48?(p=lV(r,n,i,o,s,t[g_[m]],__[2],v_[m]),g=lV(a,d,u,c,l,t[b_[m]],x_[2],w_[m])):m<64?(p=fV(r,n,i,o,s,t[g_[m]],__[3],v_[m]),g=uV(a,d,u,c,l,t[b_[m]],x_[3],w_[m])):(p=hV(r,n,i,o,s,t[g_[m]],__[4],v_[m]),g=dV(a,d,u,c,l,t[b_[m]],x_[4],w_[m])),r=s,s=o,o=Gy(i,10),i=n,n=p,a=l,l=c,c=Gy(u,10),u=d,d=g}var b=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=b};e5.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=pD.alloc?pD.alloc(20):new pD(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 Gy(t,e){return t<>>32-e}function dV(t,e,r,n,i,o,s,a){return Gy(t+(e^r^n)+o+s|0,a)+i|0}function uV(t,e,r,n,i,o,s,a){return Gy(t+(e&r|~e&n)+o+s|0,a)+i|0}function lV(t,e,r,n,i,o,s,a){return Gy(t+((e|~r)^n)+o+s|0,a)+i|0}function fV(t,e,r,n,i,o,s,a){return Gy(t+(e&n|r&~n)+o+s|0,a)+i|0}function hV(t,e,r,n,i,o,s,a){return Gy(t+(e^(r|~n))+o+s|0,a)+i|0}mV.exports=e5});var Wy=W((Ddt,gV)=>{h();var yV=ar().Buffer;function r5(t,e){this._block=yV.alloc(t),this._finalSize=e,this._blockSize=t,this._len=0}r5.prototype.update=function(t,e){typeof t=="string"&&(e=e||"utf8",t=yV.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};r5.prototype._update=function(){throw new Error("_update must be implemented by subclass")};gV.exports=r5});var wV=W((Bdt,vV)=>{h();var tSe=cr(),bV=Wy(),rSe=ar().Buffer,nSe=[1518500249,1859775393,-1894007588,-899497514],iSe=new Array(80);function E_(){this.init(),this._w=iSe,bV.call(this,64,56)}tSe(E_,bV);E_.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function oSe(t){return t<<5|t>>>27}function sSe(t){return t<<30|t>>>2}function aSe(t,e,r,n){return t===0?e&r|~e&n:t===2?e&r|e&n|r&n:e^r^n}E_.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=oSe(r)+aSe(u,n,i,o)+s+e[d]+nSe[u]|0;s=o,o=i,i=sSe(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};E_.prototype._hash=function(){var t=rSe.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};vV.exports=E_});var EV=W((Odt,xV)=>{h();var cSe=cr(),_V=Wy(),dSe=ar().Buffer,uSe=[1518500249,1859775393,-1894007588,-899497514],lSe=new Array(80);function S_(){this.init(),this._w=lSe,_V.call(this,64,56)}cSe(S_,_V);S_.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function fSe(t){return t<<1|t>>>31}function hSe(t){return t<<5|t>>>27}function pSe(t){return t<<30|t>>>2}function mSe(t,e,r,n){return t===0?e&r|~e&n:t===2?e&r|e&n|r&n:e^r^n}S_.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]=fSe(e[a-3]^e[a-8]^e[a-14]^e[a-16]);for(var d=0;d<80;++d){var u=~~(d/20),c=hSe(r)+mSe(u,n,i,o)+s+e[d]+uSe[u]|0;s=o,o=i,i=pSe(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};S_.prototype._hash=function(){var t=dSe.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};xV.exports=S_});var mD=W((Ndt,AV)=>{h();var ySe=cr(),SV=Wy(),gSe=ar().Buffer,bSe=[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],vSe=new Array(64);function A_(){this.init(),this._w=vSe,SV.call(this,64,56)}ySe(A_,SV);A_.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 wSe(t,e,r){return r^t&(e^r)}function _Se(t,e,r){return t&e|r&(t|e)}function xSe(t){return(t>>>2|t<<30)^(t>>>13|t<<19)^(t>>>22|t<<10)}function ESe(t){return(t>>>6|t<<26)^(t>>>11|t<<21)^(t>>>25|t<<7)}function SSe(t){return(t>>>7|t<<25)^(t>>>18|t<<14)^t>>>3}function ASe(t){return(t>>>17|t<<15)^(t>>>19|t<<13)^t>>>10}A_.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]=ASe(e[c-2])+e[c-7]+SSe(e[c-15])+e[c-16]|0;for(var l=0;l<64;++l){var m=u+ESe(s)+wSe(s,a,d)+bSe[l]+e[l]|0,p=xSe(r)+_Se(r,n,i)|0;u=d,d=a,a=s,s=o+m|0,o=i,i=n,n=r,r=m+p|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};A_.prototype._hash=function(){var t=gSe.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};AV.exports=A_});var TV=W((Udt,PV)=>{h();var PSe=cr(),TSe=mD(),ISe=Wy(),kSe=ar().Buffer,RSe=new Array(64);function n5(){this.init(),this._w=RSe,ISe.call(this,64,56)}PSe(n5,TSe);n5.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};n5.prototype._hash=function(){var t=kSe.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};PV.exports=n5});var yD=W((qdt,CV)=>{h();var DSe=cr(),BV=Wy(),MSe=ar().Buffer,IV=[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],BSe=new Array(160);function P_(){this.init(),this._w=BSe,BV.call(this,128,112)}DSe(P_,BV);P_.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 kV(t,e,r){return r^t&(e^r)}function RV(t,e,r){return t&e|r&(t|e)}function DV(t,e){return(t>>>28|e<<4)^(e>>>2|t<<30)^(e>>>7|t<<25)}function MV(t,e){return(t>>>14|e<<18)^(t>>>18|e<<14)^(e>>>9|t<<23)}function CSe(t,e){return(t>>>1|e<<31)^(t>>>8|e<<24)^t>>>7}function OSe(t,e){return(t>>>1|e<<31)^(t>>>8|e<<24)^(t>>>7|e<<25)}function $Se(t,e){return(t>>>19|e<<13)^(e>>>29|t<<3)^t>>>6}function NSe(t,e){return(t>>>19|e<<13)^(e>>>29|t<<3)^(t>>>6|e<<26)}function po(t,e){return t>>>0>>0?1:0}P_.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,m=this._cl|0,p=this._dl|0,g=this._el|0,b=this._fl|0,S=this._gl|0,A=this._hl|0,I=0;I<32;I+=2)e[I]=t.readInt32BE(I*4),e[I+1]=t.readInt32BE(I*4+4);for(;I<160;I+=2){var P=e[I-30],$=e[I-15*2+1],N=CSe(P,$),L=OSe($,P);P=e[I-2*2],$=e[I-2*2+1];var F=$Se(P,$),U=NSe($,P),G=e[I-7*2],q=e[I-7*2+1],T=e[I-16*2],E=e[I-16*2+1],k=L+q|0,f=N+G+po(k,L)|0;k=k+U|0,f=f+F+po(k,U)|0,k=k+E|0,f=f+T+po(k,E)|0,e[I]=f,e[I+1]=k}for(var y=0;y<160;y+=2){f=e[y],k=e[y+1];var w=RV(r,n,i),_=RV(c,l,m),x=DV(r,c),v=DV(c,r),D=MV(s,g),K=MV(g,s),M=IV[y],j=IV[y+1],J=kV(s,a,d),Z=kV(g,b,S),V=A+K|0,H=u+D+po(V,A)|0;V=V+Z|0,H=H+J+po(V,Z)|0,V=V+j|0,H=H+M+po(V,j)|0,V=V+k|0,H=H+f+po(V,k)|0;var X=v+_|0,ee=x+w+po(X,v)|0;u=d,A=S,d=a,S=b,a=s,b=g,g=p+V|0,s=o+H+po(g,p)|0,o=i,p=m,i=n,m=l,n=r,l=c,c=V+X|0,r=H+ee+po(c,V)|0}this._al=this._al+c|0,this._bl=this._bl+l|0,this._cl=this._cl+m|0,this._dl=this._dl+p|0,this._el=this._el+g|0,this._fl=this._fl+b|0,this._gl=this._gl+S|0,this._hl=this._hl+A|0,this._ah=this._ah+r+po(this._al,c)|0,this._bh=this._bh+n+po(this._bl,l)|0,this._ch=this._ch+i+po(this._cl,m)|0,this._dh=this._dh+o+po(this._dl,p)|0,this._eh=this._eh+s+po(this._el,g)|0,this._fh=this._fh+a+po(this._fl,b)|0,this._gh=this._gh+d+po(this._gl,S)|0,this._hh=this._hh+u+po(this._hl,A)|0};P_.prototype._hash=function(){var t=MSe.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};CV.exports=P_});var $V=W((Fdt,OV)=>{h();var jSe=cr(),USe=yD(),KSe=Wy(),qSe=ar().Buffer,LSe=new Array(160);function i5(){this.init(),this._w=LSe,KSe.call(this,128,112)}jSe(i5,USe);i5.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};i5.prototype._hash=function(){var t=qSe.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};OV.exports=i5});var o5=W((Af,NV)=>{h();var Af=NV.exports=function(e){e=e.toLowerCase();var r=Af[e];if(!r)throw new Error(e+" is not supported (we accept pull requests)");return new r};Af.sha=wV();Af.sha1=EV();Af.sha224=TV();Af.sha256=mD();Af.sha384=$V();Af.sha512=yD()});var UV=W((Wdt,jV)=>{h();jV.exports=zc;var gD=nc().EventEmitter,FSe=cr();FSe(zc,gD);zc.Readable=K3();zc.Writable=N3();zc.Duplex=fp();zc.Transform=V3();zc.PassThrough=uD();zc.finished=f_();zc.pipeline=fD();zc.Stream=zc;function zc(){gD.call(this)}zc.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(),gD.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 Pf=W((Vdt,LV)=>{h();var KV=ar().Buffer,qV=UV().Transform,zSe=av().StringDecoder,GSe=cr();function zd(t){qV.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}GSe(zd,qV);zd.prototype.update=function(t,e,r){typeof t=="string"&&(t=KV.from(t,e));var n=this._update(t);return this.hashMode?this:(r&&(n=this._toString(n,r)),n)};zd.prototype.setAutoPadding=function(){};zd.prototype.getAuthTag=function(){throw new Error("trying to get auth tag in unsupported state")};zd.prototype.setAuthTag=function(){throw new Error("trying to set auth tag in unsupported state")};zd.prototype.setAAD=function(){throw new Error("trying to set aad in unsupported state")};zd.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)}};zd.prototype._flush=function(t){var e;try{this.push(this.__final())}catch(r){e=r}t(e)};zd.prototype._finalOrDigest=function(t){var e=this.__final()||KV.alloc(0);return t&&(e=this._toString(e,t,!0)),e};zd.prototype._toString=function(t,e,r){if(this._decoder||(this._decoder=new zSe(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};LV.exports=zd});var uv=W((Ydt,zV)=>{"use strict";h();var WSe=cr(),HSe=Q3(),VSe=t5(),JSe=o5(),FV=Pf();function s5(t){FV.call(this,"digest"),this._hash=t}WSe(s5,FV);s5.prototype._update=function(t){this._hash.update(t)};s5.prototype._final=function(){return this._hash.digest()};zV.exports=function(e){return e=e.toLowerCase(),e==="md5"?new HSe:e==="rmd160"||e==="ripemd160"?new VSe:new s5(JSe(e))}});var HV=W((Xdt,WV)=>{"use strict";h();var YSe=cr(),Hy=ar().Buffer,GV=Pf(),ZSe=Hy.alloc(128),lv=64;function a5(t,e){GV.call(this,"digest"),typeof e=="string"&&(e=Hy.from(e)),this._alg=t,this._key=e,e.length>lv?e=t(e):e.length{h();var XSe=Q3();VV.exports=function(t){return new XSe().update(t).digest()}});var _D=W((rut,YV)=>{"use strict";h();var QSe=cr(),e3e=HV(),JV=Pf(),T_=ar().Buffer,t3e=bD(),vD=t5(),wD=o5(),r3e=T_.alloc(128);function I_(t,e){JV.call(this,"digest"),typeof e=="string"&&(e=T_.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 vD:wD(t);e=n.update(e).digest()}else e.length{n3e.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 XV=W((out,ZV)=>{"use strict";h();ZV.exports=xD()});var ED=W((aut,QV)=>{h();var i3e=Math.pow(2,30)-1;QV.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>i3e||e!==e)throw new TypeError("Bad key length")}});var SD=W((dut,tJ)=>{h();var c5;globalThis.process&&globalThis.process.browser?c5="utf-8":globalThis.process&&globalThis.process.version?(eJ=parseInt(B.default.version.split(".")[0].slice(1),10),c5=eJ>=6?"utf-8":"binary"):c5="utf-8";var eJ;tJ.exports=c5});var PD=W((lut,rJ)=>{h();var AD=ar().Buffer;rJ.exports=function(t,e,r){if(AD.isBuffer(t))return t;if(typeof t=="string")return AD.from(t,e);if(ArrayBuffer.isView(t))return AD.from(t.buffer);throw new TypeError(r+" must be a string, a Buffer, a typed array or a DataView")}});var TD=W((hut,sJ)=>{h();var o3e=bD(),s3e=t5(),a3e=o5(),Vy=ar().Buffer,c3e=ED(),nJ=SD(),iJ=PD(),d3e=Vy.alloc(128),d5={md5:16,sha1:20,sha224:28,sha256:32,sha384:48,sha512:64,rmd160:20,ripemd160:20};function oJ(t,e,r){var n=u3e(t),i=t==="sha512"||t==="sha384"?128:64;e.length>i?e=n(e):e.length{h();var uJ=ar().Buffer,f3e=ED(),aJ=SD(),cJ=TD(),dJ=PD(),u5,k_=globalThis.crypto&&globalThis.crypto.subtle,h3e={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"},ID=[];function p3e(t){if(globalThis.process&&!globalThis.process.browser||!k_||!k_.importKey||!k_.deriveBits)return Promise.resolve(!1);if(ID[t]!==void 0)return ID[t];u5=u5||uJ.alloc(8);var e=lJ(u5,u5,10,128,t).then(function(){return!0}).catch(function(){return!1});return ID[t]=e,e}var Jy;function kD(){return Jy||(globalThis.process&&globalThis.process.nextTick?Jy=globalThis.process.nextTick:globalThis.queueMicrotask?Jy=globalThis.queueMicrotask:globalThis.setImmediate?Jy=globalThis.setImmediate:Jy=globalThis.setTimeout,Jy)}function lJ(t,e,r,n,i){return k_.importKey("raw",t,{name:"PBKDF2"},!1,["deriveBits"]).then(function(o){return k_.deriveBits({name:"PBKDF2",salt:e,iterations:r,hash:{name:i}},o,n<<3)}).then(function(o){return uJ.from(o)})}function m3e(t,e){t.then(function(r){kD()(function(){e(null,r)})},function(r){kD()(function(){e(r)})})}fJ.exports=function(t,e,r,n,i,o){typeof i=="function"&&(o=i,i=void 0),i=i||"sha1";var s=h3e[i.toLowerCase()];if(!s||typeof globalThis.Promise!="function"){kD()(function(){var a;try{a=cJ(t,e,r,n,i)}catch(d){return o(d)}o(null,a)});return}if(f3e(r,n),t=dJ(t,aJ,"Password"),e=dJ(e,aJ,"Salt"),typeof o!="function")throw new Error("No callback provided to pbkdf2");m3e(p3e(s).then(function(a){return a?lJ(t,e,r,n,s):cJ(t,e,r,n,i)}),o)}});var DD=W(RD=>{h();RD.pbkdf2=hJ();RD.pbkdf2Sync=TD()});var MD=W(Gc=>{"use strict";h();Gc.readUInt32BE=function(e,r){var n=e[0+r]<<24|e[1+r]<<16|e[2+r]<<8|e[3+r];return n>>>0};Gc.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};Gc.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};Gc.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};Gc.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};Gc.r28shl=function(e,r){return e<>>28-r};var l5=[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];Gc.pc2=function(e,r,n,i){for(var o=0,s=0,a=l5.length>>>1,d=0;d>>l5[d]&1;for(var d=a;d>>l5[d]&1;n[i+0]=o>>>0,n[i+1]=s>>>0};Gc.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 pJ=[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];Gc.substitute=function(e,r){for(var n=0,i=0;i<4;i++){var o=e>>>18-i*6&63,s=pJ[i*64+o];n<<=4,n|=s}for(var i=0;i<4;i++){var o=r>>>18-i*6&63,s=pJ[4*64+i*64+o];n<<=4,n|=s}return n>>>0};var mJ=[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];Gc.permute=function(e){for(var r=0,n=0;n>>mJ[n]&1;return r>>>0};Gc.padSplit=function(e,r,n){for(var i=e.toString(2);i.length{h();gJ.exports=yJ;function yJ(t,e){if(!t)throw new Error(e||"Assertion failed")}yJ.equal=function(e,r,n){if(e!=r)throw new Error(n||"Assertion failed: "+e+" != "+r)}});var f5=W((Eut,bJ)=>{"use strict";h();var y3e=ic();function Wc(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}bJ.exports=Wc;Wc.prototype._init=function(){};Wc.prototype.update=function(e){return e.length===0?[]:this.type==="decrypt"?this._updateDecrypt(e):this._updateEncrypt(e)};Wc.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};Wc.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};Wc.prototype._pad=function(e,r){if(r===0)return!1;for(;r{"use strict";h();var vJ=ic(),g3e=cr(),zi=MD(),wJ=f5();function b3e(){this.tmp=new Array(2),this.keys=null}function tl(t){wJ.call(this,t);var e=new b3e;this._desState=e,this.deriveKeys(e,t.key)}g3e(tl,wJ);_J.exports=tl;tl.create=function(e){return new tl(e)};var v3e=[1,1,2,2,2,2,2,2,1,2,2,2,2,2,2,1];tl.prototype.deriveKeys=function(e,r){e.keys=new Array(16*2),vJ.equal(r.length,this.blockSize,"Invalid key length");var n=zi.readUInt32BE(r,0),i=zi.readUInt32BE(r,4);zi.pc1(n,i,e.tmp,0),n=e.tmp[0],i=e.tmp[1];for(var o=0;o>>1];n=zi.r28shl(n,s),i=zi.r28shl(i,s),zi.pc2(n,i,e.keys,o)}};tl.prototype._update=function(e,r,n,i){var o=this._desState,s=zi.readUInt32BE(e,r),a=zi.readUInt32BE(e,r+4);zi.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],zi.writeUInt32BE(n,s,i),zi.writeUInt32BE(n,a,i+4)};tl.prototype._pad=function(e,r){if(this.padding===!1)return!1;for(var n=e.length-r,i=r;i>>0,s=p}zi.rip(a,s,i,o)};tl.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];zi.expand(s,e.tmp,0),u^=e.tmp[0],c^=e.tmp[1];var l=zi.substitute(u,c),m=zi.permute(l),p=s;s=(a^m)>>>0,a=p}zi.rip(s,a,i,o)}});var EJ=W(xJ=>{"use strict";h();var w3e=ic(),_3e=cr(),h5={};function x3e(t){w3e.equal(t.length,8,"Invalid IV length"),this.iv=new Array(8);for(var e=0;e{"use strict";h();var S3e=ic(),A3e=cr(),SJ=f5(),gp=BD();function P3e(t,e){S3e.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=[gp.create({type:"encrypt",key:r}),gp.create({type:"decrypt",key:n}),gp.create({type:"encrypt",key:i})]:this.ciphers=[gp.create({type:"decrypt",key:i}),gp.create({type:"encrypt",key:n}),gp.create({type:"decrypt",key:r})]}function Yy(t){SJ.call(this,t);var e=new P3e(this.type,this.options.key);this._edeState=e}A3e(Yy,SJ);AJ.exports=Yy;Yy.create=function(e){return new Yy(e)};Yy.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)};Yy.prototype._pad=gp.prototype._pad;Yy.prototype._unpad=gp.prototype._unpad});var TJ=W(fv=>{"use strict";h();fv.utils=MD();fv.Cipher=f5();fv.DES=BD();fv.CBC=EJ();fv.EDE=PJ()});var RJ=W((But,kJ)=>{h();var IJ=Pf(),Tf=TJ(),T3e=cr(),Zy=ar().Buffer,R_={"des-ede3-cbc":Tf.CBC.instantiate(Tf.EDE),"des-ede3":Tf.EDE,"des-ede-cbc":Tf.CBC.instantiate(Tf.EDE),"des-ede":Tf.EDE,"des-cbc":Tf.CBC.instantiate(Tf.DES),"des-ecb":Tf.DES};R_.des=R_["des-cbc"];R_.des3=R_["des-ede3-cbc"];kJ.exports=p5;T3e(p5,IJ);function p5(t){IJ.call(this);var e=t.mode.toLowerCase(),r=R_[e],n;t.decrypt?n="decrypt":n="encrypt";var i=t.key;Zy.isBuffer(i)||(i=Zy.from(i)),(e==="des-ede"||e==="des-ede-cbc")&&(i=Zy.concat([i,i.slice(0,8)]));var o=t.iv;Zy.isBuffer(o)||(o=Zy.from(o)),this._des=r.create({key:i,iv:o,type:n})}p5.prototype._update=function(t){return Zy.from(this._des.update(t))};p5.prototype._final=function(){return Zy.from(this._des.final())}});var DJ=W(CD=>{h();CD.encrypt=function(t,e){return t._cipher.encryptBlock(e)};CD.decrypt=function(t,e){return t._cipher.decryptBlock(e)}});var hv=W((Nut,MJ)=>{h();MJ.exports=function(e,r){for(var n=Math.min(e.length,r.length),i=new O.Buffer(n),o=0;o{h();var BJ=hv();OD.encrypt=function(t,e){var r=BJ(e,t._prev);return t._prev=t._cipher.encryptBlock(r),t._prev};OD.decrypt=function(t,e){var r=t._prev;t._prev=e;var n=t._cipher.decryptBlock(e);return BJ(n,r)}});var NJ=W($J=>{h();var D_=ar().Buffer,I3e=hv();function OJ(t,e,r){var n=e.length,i=I3e(e,t._cache);return t._cache=t._cache.slice(n),t._prev=D_.concat([t._prev,r?e:i]),i}$J.encrypt=function(t,e,r){for(var n=D_.allocUnsafe(0),i;e.length;)if(t._cache.length===0&&(t._cache=t._cipher.encryptBlock(t._prev),t._prev=D_.allocUnsafe(0)),t._cache.length<=e.length)i=t._cache.length,n=D_.concat([n,OJ(t,e.slice(0,i),r)]),e=e.slice(i);else{n=D_.concat([n,OJ(t,e,r)]);break}return n}});var UJ=W(jJ=>{h();var $D=ar().Buffer;function k3e(t,e,r){var n=t._cipher.encryptBlock(t._prev),i=n[0]^e;return t._prev=$D.concat([t._prev.slice(1),$D.from([r?e:i])]),i}jJ.encrypt=function(t,e,r){for(var n=e.length,i=$D.allocUnsafe(n),o=-1;++o{h();var m5=ar().Buffer;function R3e(t,e,r){for(var n,i=-1,o=8,s=0,a,d;++i>i%8,t._prev=D3e(t._prev,r?a:d);return s}function D3e(t,e){var r=t.length,n=-1,i=m5.allocUnsafe(t.length);for(t=m5.concat([t,m5.from([e])]);++n>7;return i}KJ.encrypt=function(t,e,r){for(var n=e.length,i=m5.allocUnsafe(n),o=-1;++o{h();var M3e=hv();function B3e(t){return t._prev=t._cipher.encryptBlock(t._prev),t._prev}LJ.encrypt=function(t,e){for(;t._cache.length{h();function C3e(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}}zJ.exports=C3e});var UD=W(WJ=>{h();var O3e=hv(),GJ=ar().Buffer,$3e=ND();function N3e(t){var e=t._cipher.encryptBlockRaw(t._prev);return $3e(t._prev),e}var jD=16;WJ.encrypt=function(t,e){var r=Math.ceil(e.length/jD),n=t._cache.length;t._cache=GJ.concat([t._cache,GJ.allocUnsafe(r*jD)]);for(var i=0;i{j3e.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 g5=W((elt,HJ)=>{h();var U3e={ECB:DJ(),CBC:CJ(),CFB:NJ(),CFB8:UJ(),CFB1:qJ(),OFB:FJ(),CTR:UD(),GCM:UD()},y5=KD();for(qD in y5)y5[qD].module=U3e[y5[qD].mode];var qD;HJ.exports=y5});var M_=W((rlt,JJ)=>{h();var b5=ar().Buffer;function FD(t){b5.isBuffer(t)||(t=b5.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[m&255]^e[A++],g=o[c>>>24]^s[l>>>16&255]^a[m>>>8&255]^d[u&255]^e[A++],b=o[l>>>24]^s[m>>>16&255]^a[u>>>8&255]^d[c&255]^e[A++],S=o[m>>>24]^s[u>>>16&255]^a[c>>>8&255]^d[l&255]^e[A++],u=p,c=g,l=b,m=S;return p=(n[u>>>24]<<24|n[c>>>16&255]<<16|n[l>>>8&255]<<8|n[m&255])^e[A++],g=(n[c>>>24]<<24|n[l>>>16&255]<<16|n[m>>>8&255]<<8|n[u&255])^e[A++],b=(n[l>>>24]<<24|n[m>>>16&255]<<16|n[u>>>8&255]<<8|n[c&255])^e[A++],S=(n[m>>>24]<<24|n[u>>>16&255]<<16|n[c>>>8&255]<<8|n[l&255])^e[A++],p=p>>>0,g=g>>>0,b=b>>>0,S=S>>>0,[p,g,b,S]}var K3e=[0,1,2,4,8,16,32,64,128,27,54],$i=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],m=t[l],p=t[u]*257^u*16843008;i[0][s]=p<<24|p>>>8,i[1][s]=p<<16|p>>>16,i[2][s]=p<<8|p>>>24,i[3][s]=p,p=m*16843009^l*65537^c*257^s*16843008,o[0][u]=p<<24|p>>>8,o[1][u]=p<<16|p>>>16,o[2][u]=p<<8|p>>>24,o[3][u]=p,s===0?s=a=1:(s=c^t[t[t[m^c]]],a^=t[t[a]])}return{SBOX:r,INV_SBOX:n,SUB_MIX:i,INV_SUB_MIX:o}}();function Hc(t){this._key=FD(t),this._reset()}Hc.blockSize=4*4;Hc.keySize=256/8;Hc.prototype.blockSize=Hc.blockSize;Hc.prototype.keySize=Hc.keySize;Hc.prototype._reset=function(){for(var t=this._key,e=t.length,r=e+6,n=(r+1)*4,i=[],o=0;o>>24,s=$i.SBOX[s>>>24]<<24|$i.SBOX[s>>>16&255]<<16|$i.SBOX[s>>>8&255]<<8|$i.SBOX[s&255],s^=K3e[o/e|0]<<24):e>6&&o%e===4&&(s=$i.SBOX[s>>>24]<<24|$i.SBOX[s>>>16&255]<<16|$i.SBOX[s>>>8&255]<<8|$i.SBOX[s&255]),i[o]=i[o-e]^s}for(var a=[],d=0;d>>24]]^$i.INV_SUB_MIX[1][$i.SBOX[c>>>16&255]]^$i.INV_SUB_MIX[2][$i.SBOX[c>>>8&255]]^$i.INV_SUB_MIX[3][$i.SBOX[c&255]]}this._nRounds=r,this._keySchedule=i,this._invKeySchedule=a};Hc.prototype.encryptBlockRaw=function(t){return t=FD(t),VJ(t,this._keySchedule,$i.SUB_MIX,$i.SBOX,this._nRounds)};Hc.prototype.encryptBlock=function(t){var e=this.encryptBlockRaw(t),r=b5.allocUnsafe(16);return r.writeUInt32BE(e[0],0),r.writeUInt32BE(e[1],4),r.writeUInt32BE(e[2],8),r.writeUInt32BE(e[3],12),r};Hc.prototype.decryptBlock=function(t){t=FD(t);var e=t[1];t[1]=t[3],t[3]=e;var r=VJ(t,this._invKeySchedule,$i.INV_SUB_MIX,$i.INV_SBOX,this._nRounds),n=b5.allocUnsafe(16);return n.writeUInt32BE(r[0],0),n.writeUInt32BE(r[3],4),n.writeUInt32BE(r[2],8),n.writeUInt32BE(r[1],12),n};Hc.prototype.scrub=function(){LD(this._keySchedule),LD(this._invKeySchedule),LD(this._key)};JJ.exports.AES=Hc});var XJ=W((ilt,ZJ)=>{h();var pv=ar().Buffer,q3e=pv.alloc(16,0);function L3e(t){return[t.readUInt32BE(0),t.readUInt32BE(4),t.readUInt32BE(8),t.readUInt32BE(12)]}function YJ(t){var e=pv.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 B_(t){this.h=t,this.state=pv.alloc(16,0),this.cache=pv.allocUnsafe(0)}B_.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=YJ(e)};B_.prototype.update=function(t){this.cache=pv.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)};B_.prototype.final=function(t,e){return this.cache.length&&this.ghash(pv.concat([this.cache,q3e],16)),this.ghash(YJ([0,t,0,e])),this.state};ZJ.exports=B_});var zD=W((slt,tY)=>{h();var F3e=M_(),_a=ar().Buffer,QJ=Pf(),z3e=cr(),eY=XJ(),G3e=hv(),W3e=ND();function H3e(t,e){var r=0;t.length!==e.length&&r++;for(var n=Math.min(t.length,e.length),i=0;i{h();var J3e=M_(),GD=ar().Buffer,rY=Pf(),Y3e=cr();function v5(t,e,r,n){rY.call(this),this._cipher=new J3e.AES(e),this._prev=GD.from(r),this._cache=GD.allocUnsafe(0),this._secCache=GD.allocUnsafe(0),this._decrypt=n,this._mode=t}Y3e(v5,rY);v5.prototype._update=function(t){return this._mode.encrypt(this,t,this._decrypt)};v5.prototype._final=function(){this._cipher.scrub()};nY.exports=v5});var C_=W((ult,iY)=>{h();var Qy=ar().Buffer,Z3e=Q3();function X3e(t,e,r,n){if(Qy.isBuffer(t)||(t=Qy.from(t,"binary")),e&&(Qy.isBuffer(e)||(e=Qy.from(e,"binary")),e.length!==8))throw new RangeError("salt should be Buffer with 8 byte length");for(var i=r/8,o=Qy.alloc(i),s=Qy.alloc(n||0),a=Qy.alloc(0);i>0||n>0;){var d=new Z3e;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,m=Math.min(n,a.length-u);a.copy(s,l,u,u+m),n-=m}}return a.fill(0),{key:o,iv:s}}iY.exports=X3e});var cY=W(HD=>{h();var oY=g5(),Q3e=zD(),If=ar().Buffer,e5e=WD(),sY=Pf(),t5e=M_(),r5e=C_(),n5e=cr();function O_(t,e,r){sY.call(this),this._cache=new w5,this._cipher=new t5e.AES(e),this._prev=If.from(r),this._mode=t,this._autopadding=!0}n5e(O_,sY);O_.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 If.concat(n)};var i5e=If.alloc(16,16);O_.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(i5e))throw this._cipher.scrub(),new Error("data not multiple of block length")};O_.prototype.setAutoPadding=function(t){return this._autopadding=!!t,this};function w5(){this.cache=If.allocUnsafe(0)}w5.prototype.add=function(t){this.cache=If.concat([this.cache,t])};w5.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};w5.prototype.flush=function(){for(var t=16-this.cache.length,e=If.allocUnsafe(t),r=-1;++r{h();var s5e=zD(),mv=ar().Buffer,dY=g5(),a5e=WD(),uY=Pf(),c5e=M_(),d5e=C_(),u5e=cr();function $_(t,e,r){uY.call(this),this._cache=new _5,this._last=void 0,this._cipher=new c5e.AES(e),this._prev=mv.from(r),this._mode=t,this._autopadding=!0}u5e($_,uY);$_.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 mv.concat(n)};$_.prototype._final=function(){var t=this._cache.flush();if(this._autopadding)return l5e(this._mode.decrypt(this,t));if(t)throw new Error("data not multiple of block length")};$_.prototype.setAutoPadding=function(t){return this._autopadding=!!t,this};function _5(){this.cache=mv.allocUnsafe(0)}_5.prototype.add=function(t){this.cache=mv.concat([this.cache,t])};_5.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};_5.prototype.flush=function(){if(this.cache.length)return this.cache};function l5e(t){var e=t[15];if(e<1||e>16)throw new Error("unable to decrypt data");for(var r=-1;++r{h();var hY=cY(),pY=fY(),h5e=KD();function p5e(){return Object.keys(h5e)}Gd.createCipher=Gd.Cipher=hY.createCipher;Gd.createCipheriv=Gd.Cipheriv=hY.createCipheriv;Gd.createDecipher=Gd.Decipher=pY.createDecipher;Gd.createDecipheriv=Gd.Decipheriv=pY.createDecipheriv;Gd.listCiphers=Gd.getCiphers=p5e});var mY=W(kf=>{h();kf["des-ecb"]={key:8,iv:0};kf["des-cbc"]=kf.des={key:8,iv:8};kf["des-ede3-cbc"]=kf.des3={key:24,iv:8};kf["des-ede3"]={key:24,iv:0};kf["des-ede-cbc"]={key:16,iv:8};kf["des-ede"]={key:16,iv:0}});var wY=W(Wd=>{h();var yY=RJ(),JD=x5(),bp=g5(),Rf=mY(),gY=C_();function m5e(t,e){t=t.toLowerCase();var r,n;if(bp[t])r=bp[t].key,n=bp[t].iv;else if(Rf[t])r=Rf[t].key*8,n=Rf[t].iv;else throw new TypeError("invalid suite type");var i=gY(e,!1,r,n);return bY(t,i.key,i.iv)}function y5e(t,e){t=t.toLowerCase();var r,n;if(bp[t])r=bp[t].key,n=bp[t].iv;else if(Rf[t])r=Rf[t].key*8,n=Rf[t].iv;else throw new TypeError("invalid suite type");var i=gY(e,!1,r,n);return vY(t,i.key,i.iv)}function bY(t,e,r){if(t=t.toLowerCase(),bp[t])return JD.createCipheriv(t,e,r);if(Rf[t])return new yY({key:e,iv:r,mode:t});throw new TypeError("invalid suite type")}function vY(t,e,r){if(t=t.toLowerCase(),bp[t])return JD.createDecipheriv(t,e,r);if(Rf[t])return new yY({key:e,iv:r,mode:t,decrypt:!0});throw new TypeError("invalid suite type")}function g5e(){return Object.keys(Rf).concat(JD.getCiphers())}Wd.createCipher=Wd.Cipher=m5e;Wd.createCipheriv=Wd.Cipheriv=bY;Wd.createDecipher=Wd.Decipher=y5e;Wd.createDecipheriv=Wd.Decipheriv=vY;Wd.listCiphers=Wd.getCiphers=g5e});var YD=W(()=>{h()});var Gi=W((_Y,ZD)=>{h();(function(t,e){"use strict";function r(q,T){if(!q)throw new Error(T||"Assertion failed")}function n(q,T){q.super_=T;var E=function(){};E.prototype=T.prototype,q.prototype=new E,q.prototype.constructor=q}function i(q,T,E){if(i.isBN(q))return q;this.negative=0,this.words=null,this.length=0,this.red=null,q!==null&&((T==="le"||T==="be")&&(E=T,T=10),this._init(q||0,T||10,E||"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=YD().Buffer}catch{}i.isBN=function(T){return T instanceof i?!0:T!==null&&typeof T=="object"&&T.constructor.wordSize===i.wordSize&&Array.isArray(T.words)},i.max=function(T,E){return T.cmp(E)>0?T:E},i.min=function(T,E){return T.cmp(E)<0?T:E},i.prototype._init=function(T,E,k){if(typeof T=="number")return this._initNumber(T,E,k);if(typeof T=="object")return this._initArray(T,E,k);E==="hex"&&(E=16),r(E===(E|0)&&E>=2&&E<=36),T=T.toString().replace(/\s+/g,"");var f=0;T[0]==="-"&&(f++,this.negative=1),f=0;f-=3)w=T[f]|T[f-1]<<8|T[f-2]<<16,this.words[y]|=w<<_&67108863,this.words[y+1]=w>>>26-_&67108863,_+=24,_>=26&&(_-=26,y++);else if(k==="le")for(f=0,y=0;f>>26-_&67108863,_+=24,_>=26&&(_-=26,y++);return this.strip()};function s(q,T){var E=q.charCodeAt(T);return E>=65&&E<=70?E-55:E>=97&&E<=102?E-87:E-48&15}function a(q,T,E){var k=s(q,E);return E-1>=T&&(k|=s(q,E-1)<<4),k}i.prototype._parseHex=function(T,E,k){this.length=Math.ceil((T.length-E)/6),this.words=new Array(this.length);for(var f=0;f=E;f-=2)_=a(T,E,f)<=18?(y-=18,w+=1,this.words[w]|=_>>>26):y+=8;else{var x=T.length-E;for(f=x%2===0?E+1:E;f=18?(y-=18,w+=1,this.words[w]|=_>>>26):y+=8}this.strip()};function d(q,T,E,k){for(var f=0,y=Math.min(q.length,E),w=T;w=49?f+=_-49+10:_>=17?f+=_-17+10:f+=_}return f}i.prototype._parseBase=function(T,E,k){this.words=[0],this.length=1;for(var f=0,y=1;y<=67108863;y*=E)f++;f--,y=y/E|0;for(var w=T.length-k,_=w%f,x=Math.min(w,w-_)+k,v=0,D=k;D1&&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(T,E){T=T||10,E=E|0||1;var k;if(T===16||T==="hex"){k="";for(var f=0,y=0,w=0;w>>24-f&16777215,y!==0||w!==this.length-1?k=u[6-x.length]+x+k:k=x+k,f+=2,f>=26&&(f-=26,w--)}for(y!==0&&(k=y.toString(16)+k);k.length%E!==0;)k="0"+k;return this.negative!==0&&(k="-"+k),k}if(T===(T|0)&&T>=2&&T<=36){var v=c[T],D=l[T];k="";var K=this.clone();for(K.negative=0;!K.isZero();){var M=K.modn(D).toString(T);K=K.idivn(D),K.isZero()?k=M+k:k=u[v-M.length]+M+k}for(this.isZero()&&(k="0"+k);k.length%E!==0;)k="0"+k;return this.negative!==0&&(k="-"+k),k}r(!1,"Base should be between 2 and 36")},i.prototype.toNumber=function(){var T=this.words[0];return this.length===2?T+=this.words[1]*67108864:this.length===3&&this.words[2]===1?T+=4503599627370496+this.words[1]*67108864:this.length>2&&r(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-T:T},i.prototype.toJSON=function(){return this.toString(16)},i.prototype.toBuffer=function(T,E){return r(typeof o<"u"),this.toArrayLike(o,T,E)},i.prototype.toArray=function(T,E){return this.toArrayLike(Array,T,E)},i.prototype.toArrayLike=function(T,E,k){var f=this.byteLength(),y=k||Math.max(1,f);r(f<=y,"byte array longer than desired length"),r(y>0,"Requested array length <= 0"),this.strip();var w=E==="le",_=new T(y),x,v,D=this.clone();if(w){for(v=0;!D.isZero();v++)x=D.andln(255),D.iushrn(8),_[v]=x;for(;v=4096&&(k+=13,E>>>=13),E>=64&&(k+=7,E>>>=7),E>=8&&(k+=4,E>>>=4),E>=2&&(k+=2,E>>>=2),k+E},i.prototype._zeroBits=function(T){if(T===0)return 26;var E=T,k=0;return E&8191||(k+=13,E>>>=13),E&127||(k+=7,E>>>=7),E&15||(k+=4,E>>>=4),E&3||(k+=2,E>>>=2),E&1||k++,k},i.prototype.bitLength=function(){var T=this.words[this.length-1],E=this._countBits(T);return(this.length-1)*26+E};function m(q){for(var T=new Array(q.bitLength()),E=0;E>>f}return T}i.prototype.zeroBits=function(){if(this.isZero())return 0;for(var T=0,E=0;ET.length?this.clone().ior(T):T.clone().ior(this)},i.prototype.uor=function(T){return this.length>T.length?this.clone().iuor(T):T.clone().iuor(this)},i.prototype.iuand=function(T){var E;this.length>T.length?E=T:E=this;for(var k=0;kT.length?this.clone().iand(T):T.clone().iand(this)},i.prototype.uand=function(T){return this.length>T.length?this.clone().iuand(T):T.clone().iuand(this)},i.prototype.iuxor=function(T){var E,k;this.length>T.length?(E=this,k=T):(E=T,k=this);for(var f=0;fT.length?this.clone().ixor(T):T.clone().ixor(this)},i.prototype.uxor=function(T){return this.length>T.length?this.clone().iuxor(T):T.clone().iuxor(this)},i.prototype.inotn=function(T){r(typeof T=="number"&&T>=0);var E=Math.ceil(T/26)|0,k=T%26;this._expand(E),k>0&&E--;for(var f=0;f0&&(this.words[f]=~this.words[f]&67108863>>26-k),this.strip()},i.prototype.notn=function(T){return this.clone().inotn(T)},i.prototype.setn=function(T,E){r(typeof T=="number"&&T>=0);var k=T/26|0,f=T%26;return this._expand(k+1),E?this.words[k]=this.words[k]|1<T.length?(k=this,f=T):(k=T,f=this);for(var y=0,w=0;w>>26;for(;y!==0&&w>>26;if(this.length=k.length,y!==0)this.words[this.length]=y,this.length++;else if(k!==this)for(;wT.length?this.clone().iadd(T):T.clone().iadd(this)},i.prototype.isub=function(T){if(T.negative!==0){T.negative=0;var E=this.iadd(T);return T.negative=1,E._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(T),this.negative=1,this._normSign();var k=this.cmp(T);if(k===0)return this.negative=0,this.length=1,this.words[0]=0,this;var f,y;k>0?(f=this,y=T):(f=T,y=this);for(var w=0,_=0;_>26,this.words[_]=E&67108863;for(;w!==0&&_>26,this.words[_]=E&67108863;if(w===0&&_>>26,K=x&67108863,M=Math.min(v,T.length-1),j=Math.max(0,v-q.length+1);j<=M;j++){var J=v-j|0;f=q.words[J]|0,y=T.words[j]|0,w=f*y+K,D+=w/67108864|0,K=w&67108863}E.words[v]=K|0,x=D|0}return x!==0?E.words[v]=x|0:E.length--,E.strip()}var g=function(T,E,k){var f=T.words,y=E.words,w=k.words,_=0,x,v,D,K=f[0]|0,M=K&8191,j=K>>>13,J=f[1]|0,Z=J&8191,V=J>>>13,H=f[2]|0,X=H&8191,ee=H>>>13,ue=f[3]|0,ae=ue&8191,ce=ue>>>13,pe=f[4]|0,Ee=pe&8191,Ue=pe>>>13,le=f[5]|0,ge=le&8191,ve=le>>>13,Ce=f[6]|0,Ie=Ce&8191,je=Ce>>>13,gt=f[7]|0,Pe=gt&8191,De=gt>>>13,It=f[8]|0,we=It&8191,Se=It>>>13,Lr=f[9]|0,Fe=Lr&8191,He=Lr>>>13,js=y[0]|0,ft=js&8191,Rt=js>>>13,yi=y[1]|0,At=yi&8191,Ze=yi>>>13,Cc=y[2]|0,Pt=Cc&8191,$t=Cc>>>13,oy=y[3]|0,Bt=oy&8191,Wt=oy>>>13,Oc=y[4]|0,Ht=Oc&8191,Lt=Oc>>>13,sy=y[5]|0,Nt=sy&8191,Ft=sy>>>13,ay=y[6]|0,zt=ay&8191,Vt=ay>>>13,Uh=y[7]|0,Q=Uh&8191,Y=Uh>>>13,te=y[8]|0,re=te&8191,ie=te>>>13,$e=y[9]|0,ke=$e&8191,Ne=$e>>>13;k.negative=T.negative^E.negative,k.length=19,x=Math.imul(M,ft),v=Math.imul(M,Rt),v=v+Math.imul(j,ft)|0,D=Math.imul(j,Rt);var Ar=(_+x|0)+((v&8191)<<13)|0;_=(D+(v>>>13)|0)+(Ar>>>26)|0,Ar&=67108863,x=Math.imul(Z,ft),v=Math.imul(Z,Rt),v=v+Math.imul(V,ft)|0,D=Math.imul(V,Rt),x=x+Math.imul(M,At)|0,v=v+Math.imul(M,Ze)|0,v=v+Math.imul(j,At)|0,D=D+Math.imul(j,Ze)|0;var jt=(_+x|0)+((v&8191)<<13)|0;_=(D+(v>>>13)|0)+(jt>>>26)|0,jt&=67108863,x=Math.imul(X,ft),v=Math.imul(X,Rt),v=v+Math.imul(ee,ft)|0,D=Math.imul(ee,Rt),x=x+Math.imul(Z,At)|0,v=v+Math.imul(Z,Ze)|0,v=v+Math.imul(V,At)|0,D=D+Math.imul(V,Ze)|0,x=x+Math.imul(M,Pt)|0,v=v+Math.imul(M,$t)|0,v=v+Math.imul(j,Pt)|0,D=D+Math.imul(j,$t)|0;var dt=(_+x|0)+((v&8191)<<13)|0;_=(D+(v>>>13)|0)+(dt>>>26)|0,dt&=67108863,x=Math.imul(ae,ft),v=Math.imul(ae,Rt),v=v+Math.imul(ce,ft)|0,D=Math.imul(ce,Rt),x=x+Math.imul(X,At)|0,v=v+Math.imul(X,Ze)|0,v=v+Math.imul(ee,At)|0,D=D+Math.imul(ee,Ze)|0,x=x+Math.imul(Z,Pt)|0,v=v+Math.imul(Z,$t)|0,v=v+Math.imul(V,Pt)|0,D=D+Math.imul(V,$t)|0,x=x+Math.imul(M,Bt)|0,v=v+Math.imul(M,Wt)|0,v=v+Math.imul(j,Bt)|0,D=D+Math.imul(j,Wt)|0;var Jr=(_+x|0)+((v&8191)<<13)|0;_=(D+(v>>>13)|0)+(Jr>>>26)|0,Jr&=67108863,x=Math.imul(Ee,ft),v=Math.imul(Ee,Rt),v=v+Math.imul(Ue,ft)|0,D=Math.imul(Ue,Rt),x=x+Math.imul(ae,At)|0,v=v+Math.imul(ae,Ze)|0,v=v+Math.imul(ce,At)|0,D=D+Math.imul(ce,Ze)|0,x=x+Math.imul(X,Pt)|0,v=v+Math.imul(X,$t)|0,v=v+Math.imul(ee,Pt)|0,D=D+Math.imul(ee,$t)|0,x=x+Math.imul(Z,Bt)|0,v=v+Math.imul(Z,Wt)|0,v=v+Math.imul(V,Bt)|0,D=D+Math.imul(V,Wt)|0,x=x+Math.imul(M,Ht)|0,v=v+Math.imul(M,Lt)|0,v=v+Math.imul(j,Ht)|0,D=D+Math.imul(j,Lt)|0;var an=(_+x|0)+((v&8191)<<13)|0;_=(D+(v>>>13)|0)+(an>>>26)|0,an&=67108863,x=Math.imul(ge,ft),v=Math.imul(ge,Rt),v=v+Math.imul(ve,ft)|0,D=Math.imul(ve,Rt),x=x+Math.imul(Ee,At)|0,v=v+Math.imul(Ee,Ze)|0,v=v+Math.imul(Ue,At)|0,D=D+Math.imul(Ue,Ze)|0,x=x+Math.imul(ae,Pt)|0,v=v+Math.imul(ae,$t)|0,v=v+Math.imul(ce,Pt)|0,D=D+Math.imul(ce,$t)|0,x=x+Math.imul(X,Bt)|0,v=v+Math.imul(X,Wt)|0,v=v+Math.imul(ee,Bt)|0,D=D+Math.imul(ee,Wt)|0,x=x+Math.imul(Z,Ht)|0,v=v+Math.imul(Z,Lt)|0,v=v+Math.imul(V,Ht)|0,D=D+Math.imul(V,Lt)|0,x=x+Math.imul(M,Nt)|0,v=v+Math.imul(M,Ft)|0,v=v+Math.imul(j,Nt)|0,D=D+Math.imul(j,Ft)|0;var Wr=(_+x|0)+((v&8191)<<13)|0;_=(D+(v>>>13)|0)+(Wr>>>26)|0,Wr&=67108863,x=Math.imul(Ie,ft),v=Math.imul(Ie,Rt),v=v+Math.imul(je,ft)|0,D=Math.imul(je,Rt),x=x+Math.imul(ge,At)|0,v=v+Math.imul(ge,Ze)|0,v=v+Math.imul(ve,At)|0,D=D+Math.imul(ve,Ze)|0,x=x+Math.imul(Ee,Pt)|0,v=v+Math.imul(Ee,$t)|0,v=v+Math.imul(Ue,Pt)|0,D=D+Math.imul(Ue,$t)|0,x=x+Math.imul(ae,Bt)|0,v=v+Math.imul(ae,Wt)|0,v=v+Math.imul(ce,Bt)|0,D=D+Math.imul(ce,Wt)|0,x=x+Math.imul(X,Ht)|0,v=v+Math.imul(X,Lt)|0,v=v+Math.imul(ee,Ht)|0,D=D+Math.imul(ee,Lt)|0,x=x+Math.imul(Z,Nt)|0,v=v+Math.imul(Z,Ft)|0,v=v+Math.imul(V,Nt)|0,D=D+Math.imul(V,Ft)|0,x=x+Math.imul(M,zt)|0,v=v+Math.imul(M,Vt)|0,v=v+Math.imul(j,zt)|0,D=D+Math.imul(j,Vt)|0;var sr=(_+x|0)+((v&8191)<<13)|0;_=(D+(v>>>13)|0)+(sr>>>26)|0,sr&=67108863,x=Math.imul(Pe,ft),v=Math.imul(Pe,Rt),v=v+Math.imul(De,ft)|0,D=Math.imul(De,Rt),x=x+Math.imul(Ie,At)|0,v=v+Math.imul(Ie,Ze)|0,v=v+Math.imul(je,At)|0,D=D+Math.imul(je,Ze)|0,x=x+Math.imul(ge,Pt)|0,v=v+Math.imul(ge,$t)|0,v=v+Math.imul(ve,Pt)|0,D=D+Math.imul(ve,$t)|0,x=x+Math.imul(Ee,Bt)|0,v=v+Math.imul(Ee,Wt)|0,v=v+Math.imul(Ue,Bt)|0,D=D+Math.imul(Ue,Wt)|0,x=x+Math.imul(ae,Ht)|0,v=v+Math.imul(ae,Lt)|0,v=v+Math.imul(ce,Ht)|0,D=D+Math.imul(ce,Lt)|0,x=x+Math.imul(X,Nt)|0,v=v+Math.imul(X,Ft)|0,v=v+Math.imul(ee,Nt)|0,D=D+Math.imul(ee,Ft)|0,x=x+Math.imul(Z,zt)|0,v=v+Math.imul(Z,Vt)|0,v=v+Math.imul(V,zt)|0,D=D+Math.imul(V,Vt)|0,x=x+Math.imul(M,Q)|0,v=v+Math.imul(M,Y)|0,v=v+Math.imul(j,Q)|0,D=D+Math.imul(j,Y)|0;var Yr=(_+x|0)+((v&8191)<<13)|0;_=(D+(v>>>13)|0)+(Yr>>>26)|0,Yr&=67108863,x=Math.imul(we,ft),v=Math.imul(we,Rt),v=v+Math.imul(Se,ft)|0,D=Math.imul(Se,Rt),x=x+Math.imul(Pe,At)|0,v=v+Math.imul(Pe,Ze)|0,v=v+Math.imul(De,At)|0,D=D+Math.imul(De,Ze)|0,x=x+Math.imul(Ie,Pt)|0,v=v+Math.imul(Ie,$t)|0,v=v+Math.imul(je,Pt)|0,D=D+Math.imul(je,$t)|0,x=x+Math.imul(ge,Bt)|0,v=v+Math.imul(ge,Wt)|0,v=v+Math.imul(ve,Bt)|0,D=D+Math.imul(ve,Wt)|0,x=x+Math.imul(Ee,Ht)|0,v=v+Math.imul(Ee,Lt)|0,v=v+Math.imul(Ue,Ht)|0,D=D+Math.imul(Ue,Lt)|0,x=x+Math.imul(ae,Nt)|0,v=v+Math.imul(ae,Ft)|0,v=v+Math.imul(ce,Nt)|0,D=D+Math.imul(ce,Ft)|0,x=x+Math.imul(X,zt)|0,v=v+Math.imul(X,Vt)|0,v=v+Math.imul(ee,zt)|0,D=D+Math.imul(ee,Vt)|0,x=x+Math.imul(Z,Q)|0,v=v+Math.imul(Z,Y)|0,v=v+Math.imul(V,Q)|0,D=D+Math.imul(V,Y)|0,x=x+Math.imul(M,re)|0,v=v+Math.imul(M,ie)|0,v=v+Math.imul(j,re)|0,D=D+Math.imul(j,ie)|0;var Rr=(_+x|0)+((v&8191)<<13)|0;_=(D+(v>>>13)|0)+(Rr>>>26)|0,Rr&=67108863,x=Math.imul(Fe,ft),v=Math.imul(Fe,Rt),v=v+Math.imul(He,ft)|0,D=Math.imul(He,Rt),x=x+Math.imul(we,At)|0,v=v+Math.imul(we,Ze)|0,v=v+Math.imul(Se,At)|0,D=D+Math.imul(Se,Ze)|0,x=x+Math.imul(Pe,Pt)|0,v=v+Math.imul(Pe,$t)|0,v=v+Math.imul(De,Pt)|0,D=D+Math.imul(De,$t)|0,x=x+Math.imul(Ie,Bt)|0,v=v+Math.imul(Ie,Wt)|0,v=v+Math.imul(je,Bt)|0,D=D+Math.imul(je,Wt)|0,x=x+Math.imul(ge,Ht)|0,v=v+Math.imul(ge,Lt)|0,v=v+Math.imul(ve,Ht)|0,D=D+Math.imul(ve,Lt)|0,x=x+Math.imul(Ee,Nt)|0,v=v+Math.imul(Ee,Ft)|0,v=v+Math.imul(Ue,Nt)|0,D=D+Math.imul(Ue,Ft)|0,x=x+Math.imul(ae,zt)|0,v=v+Math.imul(ae,Vt)|0,v=v+Math.imul(ce,zt)|0,D=D+Math.imul(ce,Vt)|0,x=x+Math.imul(X,Q)|0,v=v+Math.imul(X,Y)|0,v=v+Math.imul(ee,Q)|0,D=D+Math.imul(ee,Y)|0,x=x+Math.imul(Z,re)|0,v=v+Math.imul(Z,ie)|0,v=v+Math.imul(V,re)|0,D=D+Math.imul(V,ie)|0,x=x+Math.imul(M,ke)|0,v=v+Math.imul(M,Ne)|0,v=v+Math.imul(j,ke)|0,D=D+Math.imul(j,Ne)|0;var Us=(_+x|0)+((v&8191)<<13)|0;_=(D+(v>>>13)|0)+(Us>>>26)|0,Us&=67108863,x=Math.imul(Fe,At),v=Math.imul(Fe,Ze),v=v+Math.imul(He,At)|0,D=Math.imul(He,Ze),x=x+Math.imul(we,Pt)|0,v=v+Math.imul(we,$t)|0,v=v+Math.imul(Se,Pt)|0,D=D+Math.imul(Se,$t)|0,x=x+Math.imul(Pe,Bt)|0,v=v+Math.imul(Pe,Wt)|0,v=v+Math.imul(De,Bt)|0,D=D+Math.imul(De,Wt)|0,x=x+Math.imul(Ie,Ht)|0,v=v+Math.imul(Ie,Lt)|0,v=v+Math.imul(je,Ht)|0,D=D+Math.imul(je,Lt)|0,x=x+Math.imul(ge,Nt)|0,v=v+Math.imul(ge,Ft)|0,v=v+Math.imul(ve,Nt)|0,D=D+Math.imul(ve,Ft)|0,x=x+Math.imul(Ee,zt)|0,v=v+Math.imul(Ee,Vt)|0,v=v+Math.imul(Ue,zt)|0,D=D+Math.imul(Ue,Vt)|0,x=x+Math.imul(ae,Q)|0,v=v+Math.imul(ae,Y)|0,v=v+Math.imul(ce,Q)|0,D=D+Math.imul(ce,Y)|0,x=x+Math.imul(X,re)|0,v=v+Math.imul(X,ie)|0,v=v+Math.imul(ee,re)|0,D=D+Math.imul(ee,ie)|0,x=x+Math.imul(Z,ke)|0,v=v+Math.imul(Z,Ne)|0,v=v+Math.imul(V,ke)|0,D=D+Math.imul(V,Ne)|0;var gi=(_+x|0)+((v&8191)<<13)|0;_=(D+(v>>>13)|0)+(gi>>>26)|0,gi&=67108863,x=Math.imul(Fe,Pt),v=Math.imul(Fe,$t),v=v+Math.imul(He,Pt)|0,D=Math.imul(He,$t),x=x+Math.imul(we,Bt)|0,v=v+Math.imul(we,Wt)|0,v=v+Math.imul(Se,Bt)|0,D=D+Math.imul(Se,Wt)|0,x=x+Math.imul(Pe,Ht)|0,v=v+Math.imul(Pe,Lt)|0,v=v+Math.imul(De,Ht)|0,D=D+Math.imul(De,Lt)|0,x=x+Math.imul(Ie,Nt)|0,v=v+Math.imul(Ie,Ft)|0,v=v+Math.imul(je,Nt)|0,D=D+Math.imul(je,Ft)|0,x=x+Math.imul(ge,zt)|0,v=v+Math.imul(ge,Vt)|0,v=v+Math.imul(ve,zt)|0,D=D+Math.imul(ve,Vt)|0,x=x+Math.imul(Ee,Q)|0,v=v+Math.imul(Ee,Y)|0,v=v+Math.imul(Ue,Q)|0,D=D+Math.imul(Ue,Y)|0,x=x+Math.imul(ae,re)|0,v=v+Math.imul(ae,ie)|0,v=v+Math.imul(ce,re)|0,D=D+Math.imul(ce,ie)|0,x=x+Math.imul(X,ke)|0,v=v+Math.imul(X,Ne)|0,v=v+Math.imul(ee,ke)|0,D=D+Math.imul(ee,Ne)|0;var Mi=(_+x|0)+((v&8191)<<13)|0;_=(D+(v>>>13)|0)+(Mi>>>26)|0,Mi&=67108863,x=Math.imul(Fe,Bt),v=Math.imul(Fe,Wt),v=v+Math.imul(He,Bt)|0,D=Math.imul(He,Wt),x=x+Math.imul(we,Ht)|0,v=v+Math.imul(we,Lt)|0,v=v+Math.imul(Se,Ht)|0,D=D+Math.imul(Se,Lt)|0,x=x+Math.imul(Pe,Nt)|0,v=v+Math.imul(Pe,Ft)|0,v=v+Math.imul(De,Nt)|0,D=D+Math.imul(De,Ft)|0,x=x+Math.imul(Ie,zt)|0,v=v+Math.imul(Ie,Vt)|0,v=v+Math.imul(je,zt)|0,D=D+Math.imul(je,Vt)|0,x=x+Math.imul(ge,Q)|0,v=v+Math.imul(ge,Y)|0,v=v+Math.imul(ve,Q)|0,D=D+Math.imul(ve,Y)|0,x=x+Math.imul(Ee,re)|0,v=v+Math.imul(Ee,ie)|0,v=v+Math.imul(Ue,re)|0,D=D+Math.imul(Ue,ie)|0,x=x+Math.imul(ae,ke)|0,v=v+Math.imul(ae,Ne)|0,v=v+Math.imul(ce,ke)|0,D=D+Math.imul(ce,Ne)|0;var Cr=(_+x|0)+((v&8191)<<13)|0;_=(D+(v>>>13)|0)+(Cr>>>26)|0,Cr&=67108863,x=Math.imul(Fe,Ht),v=Math.imul(Fe,Lt),v=v+Math.imul(He,Ht)|0,D=Math.imul(He,Lt),x=x+Math.imul(we,Nt)|0,v=v+Math.imul(we,Ft)|0,v=v+Math.imul(Se,Nt)|0,D=D+Math.imul(Se,Ft)|0,x=x+Math.imul(Pe,zt)|0,v=v+Math.imul(Pe,Vt)|0,v=v+Math.imul(De,zt)|0,D=D+Math.imul(De,Vt)|0,x=x+Math.imul(Ie,Q)|0,v=v+Math.imul(Ie,Y)|0,v=v+Math.imul(je,Q)|0,D=D+Math.imul(je,Y)|0,x=x+Math.imul(ge,re)|0,v=v+Math.imul(ge,ie)|0,v=v+Math.imul(ve,re)|0,D=D+Math.imul(ve,ie)|0,x=x+Math.imul(Ee,ke)|0,v=v+Math.imul(Ee,Ne)|0,v=v+Math.imul(Ue,ke)|0,D=D+Math.imul(Ue,Ne)|0;var bi=(_+x|0)+((v&8191)<<13)|0;_=(D+(v>>>13)|0)+(bi>>>26)|0,bi&=67108863,x=Math.imul(Fe,Nt),v=Math.imul(Fe,Ft),v=v+Math.imul(He,Nt)|0,D=Math.imul(He,Ft),x=x+Math.imul(we,zt)|0,v=v+Math.imul(we,Vt)|0,v=v+Math.imul(Se,zt)|0,D=D+Math.imul(Se,Vt)|0,x=x+Math.imul(Pe,Q)|0,v=v+Math.imul(Pe,Y)|0,v=v+Math.imul(De,Q)|0,D=D+Math.imul(De,Y)|0,x=x+Math.imul(Ie,re)|0,v=v+Math.imul(Ie,ie)|0,v=v+Math.imul(je,re)|0,D=D+Math.imul(je,ie)|0,x=x+Math.imul(ge,ke)|0,v=v+Math.imul(ge,Ne)|0,v=v+Math.imul(ve,ke)|0,D=D+Math.imul(ve,Ne)|0;var Bi=(_+x|0)+((v&8191)<<13)|0;_=(D+(v>>>13)|0)+(Bi>>>26)|0,Bi&=67108863,x=Math.imul(Fe,zt),v=Math.imul(Fe,Vt),v=v+Math.imul(He,zt)|0,D=Math.imul(He,Vt),x=x+Math.imul(we,Q)|0,v=v+Math.imul(we,Y)|0,v=v+Math.imul(Se,Q)|0,D=D+Math.imul(Se,Y)|0,x=x+Math.imul(Pe,re)|0,v=v+Math.imul(Pe,ie)|0,v=v+Math.imul(De,re)|0,D=D+Math.imul(De,ie)|0,x=x+Math.imul(Ie,ke)|0,v=v+Math.imul(Ie,Ne)|0,v=v+Math.imul(je,ke)|0,D=D+Math.imul(je,Ne)|0;var oo=(_+x|0)+((v&8191)<<13)|0;_=(D+(v>>>13)|0)+(oo>>>26)|0,oo&=67108863,x=Math.imul(Fe,Q),v=Math.imul(Fe,Y),v=v+Math.imul(He,Q)|0,D=Math.imul(He,Y),x=x+Math.imul(we,re)|0,v=v+Math.imul(we,ie)|0,v=v+Math.imul(Se,re)|0,D=D+Math.imul(Se,ie)|0,x=x+Math.imul(Pe,ke)|0,v=v+Math.imul(Pe,Ne)|0,v=v+Math.imul(De,ke)|0,D=D+Math.imul(De,Ne)|0;var Ks=(_+x|0)+((v&8191)<<13)|0;_=(D+(v>>>13)|0)+(Ks>>>26)|0,Ks&=67108863,x=Math.imul(Fe,re),v=Math.imul(Fe,ie),v=v+Math.imul(He,re)|0,D=Math.imul(He,ie),x=x+Math.imul(we,ke)|0,v=v+Math.imul(we,Ne)|0,v=v+Math.imul(Se,ke)|0,D=D+Math.imul(Se,Ne)|0;var Mo=(_+x|0)+((v&8191)<<13)|0;_=(D+(v>>>13)|0)+(Mo>>>26)|0,Mo&=67108863,x=Math.imul(Fe,ke),v=Math.imul(Fe,Ne),v=v+Math.imul(He,ke)|0,D=Math.imul(He,Ne);var Ga=(_+x|0)+((v&8191)<<13)|0;return _=(D+(v>>>13)|0)+(Ga>>>26)|0,Ga&=67108863,w[0]=Ar,w[1]=jt,w[2]=dt,w[3]=Jr,w[4]=an,w[5]=Wr,w[6]=sr,w[7]=Yr,w[8]=Rr,w[9]=Us,w[10]=gi,w[11]=Mi,w[12]=Cr,w[13]=bi,w[14]=Bi,w[15]=oo,w[16]=Ks,w[17]=Mo,w[18]=Ga,_!==0&&(w[19]=_,k.length++),k};Math.imul||(g=p);function b(q,T,E){E.negative=T.negative^q.negative,E.length=q.length+T.length;for(var k=0,f=0,y=0;y>>26)|0,f+=w>>>26,w&=67108863}E.words[y]=_,k=w,w=f}return k!==0?E.words[y]=k:E.length--,E.strip()}function S(q,T,E){var k=new A;return k.mulp(q,T,E)}i.prototype.mulTo=function(T,E){var k,f=this.length+T.length;return this.length===10&&T.length===10?k=g(this,T,E):f<63?k=p(this,T,E):f<1024?k=b(this,T,E):k=S(this,T,E),k};function A(q,T){this.x=q,this.y=T}A.prototype.makeRBT=function(T){for(var E=new Array(T),k=i.prototype._countBits(T)-1,f=0;f>=1;return f},A.prototype.permute=function(T,E,k,f,y,w){for(var _=0;_>>1)y++;return 1<>>13,k[2*w+1]=y&8191,y=y>>>13;for(w=2*E;w>=26,E+=f/67108864|0,E+=y>>>26,this.words[k]=y&67108863}return E!==0&&(this.words[k]=E,this.length++),this},i.prototype.muln=function(T){return this.clone().imuln(T)},i.prototype.sqr=function(){return this.mul(this)},i.prototype.isqr=function(){return this.imul(this.clone())},i.prototype.pow=function(T){var E=m(T);if(E.length===0)return new i(1);for(var k=this,f=0;f=0);var E=T%26,k=(T-E)/26,f=67108863>>>26-E<<26-E,y;if(E!==0){var w=0;for(y=0;y>>26-E}w&&(this.words[y]=w,this.length++)}if(k!==0){for(y=this.length-1;y>=0;y--)this.words[y+k]=this.words[y];for(y=0;y=0);var f;E?f=(E-E%26)/26:f=0;var y=T%26,w=Math.min((T-y)/26,this.length),_=67108863^67108863>>>y<w)for(this.length-=w,v=0;v=0&&(D!==0||v>=f);v--){var K=this.words[v]|0;this.words[v]=D<<26-y|K>>>y,D=K&_}return x&&D!==0&&(x.words[x.length++]=D),this.length===0&&(this.words[0]=0,this.length=1),this.strip()},i.prototype.ishrn=function(T,E,k){return r(this.negative===0),this.iushrn(T,E,k)},i.prototype.shln=function(T){return this.clone().ishln(T)},i.prototype.ushln=function(T){return this.clone().iushln(T)},i.prototype.shrn=function(T){return this.clone().ishrn(T)},i.prototype.ushrn=function(T){return this.clone().iushrn(T)},i.prototype.testn=function(T){r(typeof T=="number"&&T>=0);var E=T%26,k=(T-E)/26,f=1<=0);var E=T%26,k=(T-E)/26;if(r(this.negative===0,"imaskn works only with positive numbers"),this.length<=k)return this;if(E!==0&&k++,this.length=Math.min(k,this.length),E!==0){var f=67108863^67108863>>>E<=67108864;E++)this.words[E]-=67108864,E===this.length-1?this.words[E+1]=1:this.words[E+1]++;return this.length=Math.max(this.length,E+1),this},i.prototype.isubn=function(T){if(r(typeof T=="number"),r(T<67108864),T<0)return this.iaddn(-T);if(this.negative!==0)return this.negative=0,this.iaddn(T),this.negative=1,this;if(this.words[0]-=T,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var E=0;E>26)-(x/67108864|0),this.words[y+k]=w&67108863}for(;y>26,this.words[y+k]=w&67108863;if(_===0)return this.strip();for(r(_===-1),_=0,y=0;y>26,this.words[y]=w&67108863;return this.negative=1,this.strip()},i.prototype._wordDiv=function(T,E){var k=this.length-T.length,f=this.clone(),y=T,w=y.words[y.length-1]|0,_=this._countBits(w);k=26-_,k!==0&&(y=y.ushln(k),f.iushln(k),w=y.words[y.length-1]|0);var x=f.length-y.length,v;if(E!=="mod"){v=new i(null),v.length=x+1,v.words=new Array(v.length);for(var D=0;D=0;M--){var j=(f.words[y.length+M]|0)*67108864+(f.words[y.length+M-1]|0);for(j=Math.min(j/w|0,67108863),f._ishlnsubmul(y,j,M);f.negative!==0;)j--,f.negative=0,f._ishlnsubmul(y,1,M),f.isZero()||(f.negative^=1);v&&(v.words[M]=j)}return v&&v.strip(),f.strip(),E!=="div"&&k!==0&&f.iushrn(k),{div:v||null,mod:f}},i.prototype.divmod=function(T,E,k){if(r(!T.isZero()),this.isZero())return{div:new i(0),mod:new i(0)};var f,y,w;return this.negative!==0&&T.negative===0?(w=this.neg().divmod(T,E),E!=="mod"&&(f=w.div.neg()),E!=="div"&&(y=w.mod.neg(),k&&y.negative!==0&&y.iadd(T)),{div:f,mod:y}):this.negative===0&&T.negative!==0?(w=this.divmod(T.neg(),E),E!=="mod"&&(f=w.div.neg()),{div:f,mod:w.mod}):this.negative&T.negative?(w=this.neg().divmod(T.neg(),E),E!=="div"&&(y=w.mod.neg(),k&&y.negative!==0&&y.isub(T)),{div:w.div,mod:y}):T.length>this.length||this.cmp(T)<0?{div:new i(0),mod:this}:T.length===1?E==="div"?{div:this.divn(T.words[0]),mod:null}:E==="mod"?{div:null,mod:new i(this.modn(T.words[0]))}:{div:this.divn(T.words[0]),mod:new i(this.modn(T.words[0]))}:this._wordDiv(T,E)},i.prototype.div=function(T){return this.divmod(T,"div",!1).div},i.prototype.mod=function(T){return this.divmod(T,"mod",!1).mod},i.prototype.umod=function(T){return this.divmod(T,"mod",!0).mod},i.prototype.divRound=function(T){var E=this.divmod(T);if(E.mod.isZero())return E.div;var k=E.div.negative!==0?E.mod.isub(T):E.mod,f=T.ushrn(1),y=T.andln(1),w=k.cmp(f);return w<0||y===1&&w===0?E.div:E.div.negative!==0?E.div.isubn(1):E.div.iaddn(1)},i.prototype.modn=function(T){r(T<=67108863);for(var E=(1<<26)%T,k=0,f=this.length-1;f>=0;f--)k=(E*k+(this.words[f]|0))%T;return k},i.prototype.idivn=function(T){r(T<=67108863);for(var E=0,k=this.length-1;k>=0;k--){var f=(this.words[k]|0)+E*67108864;this.words[k]=f/T|0,E=f%T}return this.strip()},i.prototype.divn=function(T){return this.clone().idivn(T)},i.prototype.egcd=function(T){r(T.negative===0),r(!T.isZero());var E=this,k=T.clone();E.negative!==0?E=E.umod(T):E=E.clone();for(var f=new i(1),y=new i(0),w=new i(0),_=new i(1),x=0;E.isEven()&&k.isEven();)E.iushrn(1),k.iushrn(1),++x;for(var v=k.clone(),D=E.clone();!E.isZero();){for(var K=0,M=1;!(E.words[0]&M)&&K<26;++K,M<<=1);if(K>0)for(E.iushrn(K);K-- >0;)(f.isOdd()||y.isOdd())&&(f.iadd(v),y.isub(D)),f.iushrn(1),y.iushrn(1);for(var j=0,J=1;!(k.words[0]&J)&&j<26;++j,J<<=1);if(j>0)for(k.iushrn(j);j-- >0;)(w.isOdd()||_.isOdd())&&(w.iadd(v),_.isub(D)),w.iushrn(1),_.iushrn(1);E.cmp(k)>=0?(E.isub(k),f.isub(w),y.isub(_)):(k.isub(E),w.isub(f),_.isub(y))}return{a:w,b:_,gcd:k.iushln(x)}},i.prototype._invmp=function(T){r(T.negative===0),r(!T.isZero());var E=this,k=T.clone();E.negative!==0?E=E.umod(T):E=E.clone();for(var f=new i(1),y=new i(0),w=k.clone();E.cmpn(1)>0&&k.cmpn(1)>0;){for(var _=0,x=1;!(E.words[0]&x)&&_<26;++_,x<<=1);if(_>0)for(E.iushrn(_);_-- >0;)f.isOdd()&&f.iadd(w),f.iushrn(1);for(var v=0,D=1;!(k.words[0]&D)&&v<26;++v,D<<=1);if(v>0)for(k.iushrn(v);v-- >0;)y.isOdd()&&y.iadd(w),y.iushrn(1);E.cmp(k)>=0?(E.isub(k),f.isub(y)):(k.isub(E),y.isub(f))}var K;return E.cmpn(1)===0?K=f:K=y,K.cmpn(0)<0&&K.iadd(T),K},i.prototype.gcd=function(T){if(this.isZero())return T.abs();if(T.isZero())return this.abs();var E=this.clone(),k=T.clone();E.negative=0,k.negative=0;for(var f=0;E.isEven()&&k.isEven();f++)E.iushrn(1),k.iushrn(1);do{for(;E.isEven();)E.iushrn(1);for(;k.isEven();)k.iushrn(1);var y=E.cmp(k);if(y<0){var w=E;E=k,k=w}else if(y===0||k.cmpn(1)===0)break;E.isub(k)}while(!0);return k.iushln(f)},i.prototype.invm=function(T){return this.egcd(T).a.umod(T)},i.prototype.isEven=function(){return(this.words[0]&1)===0},i.prototype.isOdd=function(){return(this.words[0]&1)===1},i.prototype.andln=function(T){return this.words[0]&T},i.prototype.bincn=function(T){r(typeof T=="number");var E=T%26,k=(T-E)/26,f=1<>>26,_&=67108863,this.words[w]=_}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(T){var E=T<0;if(this.negative!==0&&!E)return-1;if(this.negative===0&&E)return 1;this.strip();var k;if(this.length>1)k=1;else{E&&(T=-T),r(T<=67108863,"Number is too big");var f=this.words[0]|0;k=f===T?0:fT.length)return 1;if(this.length=0;k--){var f=this.words[k]|0,y=T.words[k]|0;if(f!==y){fy&&(E=1);break}}return E},i.prototype.gtn=function(T){return this.cmpn(T)===1},i.prototype.gt=function(T){return this.cmp(T)===1},i.prototype.gten=function(T){return this.cmpn(T)>=0},i.prototype.gte=function(T){return this.cmp(T)>=0},i.prototype.ltn=function(T){return this.cmpn(T)===-1},i.prototype.lt=function(T){return this.cmp(T)===-1},i.prototype.lten=function(T){return this.cmpn(T)<=0},i.prototype.lte=function(T){return this.cmp(T)<=0},i.prototype.eqn=function(T){return this.cmpn(T)===0},i.prototype.eq=function(T){return this.cmp(T)===0},i.red=function(T){return new U(T)},i.prototype.toRed=function(T){return r(!this.red,"Already a number in reduction context"),r(this.negative===0,"red works only with positives"),T.convertTo(this)._forceRed(T)},i.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},i.prototype._forceRed=function(T){return this.red=T,this},i.prototype.forceRed=function(T){return r(!this.red,"Already a number in reduction context"),this._forceRed(T)},i.prototype.redAdd=function(T){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,T)},i.prototype.redIAdd=function(T){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,T)},i.prototype.redSub=function(T){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,T)},i.prototype.redISub=function(T){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,T)},i.prototype.redShl=function(T){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,T)},i.prototype.redMul=function(T){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,T),this.red.mul(this,T)},i.prototype.redIMul=function(T){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,T),this.red.imul(this,T)},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(T){return r(this.red&&!T.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,T)};var I={k256:null,p224:null,p192:null,p25519:null};function P(q,T){this.name=q,this.p=new i(T,16),this.n=this.p.bitLength(),this.k=new i(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}P.prototype._tmp=function(){var T=new i(null);return T.words=new Array(Math.ceil(this.n/13)),T},P.prototype.ireduce=function(T){var E=T,k;do this.split(E,this.tmp),E=this.imulK(E),E=E.iadd(this.tmp),k=E.bitLength();while(k>this.n);var f=k0?E.isub(this.p):E.strip!==void 0?E.strip():E._strip(),E},P.prototype.split=function(T,E){T.iushrn(this.n,0,E)},P.prototype.imulK=function(T){return T.imul(this.k)};function $(){P.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}n($,P),$.prototype.split=function(T,E){for(var k=4194303,f=Math.min(T.length,9),y=0;y>>22,w=_}w>>>=22,T.words[y-10]=w,w===0&&T.length>10?T.length-=10:T.length-=9},$.prototype.imulK=function(T){T.words[T.length]=0,T.words[T.length+1]=0,T.length+=2;for(var E=0,k=0;k>>=26,T.words[k]=y,E=f}return E!==0&&(T.words[T.length++]=E),T},i._prime=function(T){if(I[T])return I[T];var E;if(T==="k256")E=new $;else if(T==="p224")E=new N;else if(T==="p192")E=new L;else if(T==="p25519")E=new F;else throw new Error("Unknown prime "+T);return I[T]=E,E};function U(q){if(typeof q=="string"){var T=i._prime(q);this.m=T.p,this.prime=T}else r(q.gtn(1),"modulus must be greater than 1"),this.m=q,this.prime=null}U.prototype._verify1=function(T){r(T.negative===0,"red works only with positives"),r(T.red,"red works only with red numbers")},U.prototype._verify2=function(T,E){r((T.negative|E.negative)===0,"red works only with positives"),r(T.red&&T.red===E.red,"red works only with red numbers")},U.prototype.imod=function(T){return this.prime?this.prime.ireduce(T)._forceRed(this):T.umod(this.m)._forceRed(this)},U.prototype.neg=function(T){return T.isZero()?T.clone():this.m.sub(T)._forceRed(this)},U.prototype.add=function(T,E){this._verify2(T,E);var k=T.add(E);return k.cmp(this.m)>=0&&k.isub(this.m),k._forceRed(this)},U.prototype.iadd=function(T,E){this._verify2(T,E);var k=T.iadd(E);return k.cmp(this.m)>=0&&k.isub(this.m),k},U.prototype.sub=function(T,E){this._verify2(T,E);var k=T.sub(E);return k.cmpn(0)<0&&k.iadd(this.m),k._forceRed(this)},U.prototype.isub=function(T,E){this._verify2(T,E);var k=T.isub(E);return k.cmpn(0)<0&&k.iadd(this.m),k},U.prototype.shl=function(T,E){return this._verify1(T),this.imod(T.ushln(E))},U.prototype.imul=function(T,E){return this._verify2(T,E),this.imod(T.imul(E))},U.prototype.mul=function(T,E){return this._verify2(T,E),this.imod(T.mul(E))},U.prototype.isqr=function(T){return this.imul(T,T.clone())},U.prototype.sqr=function(T){return this.mul(T,T)},U.prototype.sqrt=function(T){if(T.isZero())return T.clone();var E=this.m.andln(3);if(r(E%2===1),E===3){var k=this.m.add(new i(1)).iushrn(2);return this.pow(T,k)}for(var f=this.m.subn(1),y=0;!f.isZero()&&f.andln(1)===0;)y++,f.iushrn(1);r(!f.isZero());var w=new i(1).toRed(this),_=w.redNeg(),x=this.m.subn(1).iushrn(1),v=this.m.bitLength();for(v=new i(2*v*v).toRed(this);this.pow(v,x).cmp(_)!==0;)v.redIAdd(_);for(var D=this.pow(v,f),K=this.pow(T,f.addn(1).iushrn(1)),M=this.pow(T,f),j=y;M.cmp(w)!==0;){for(var J=M,Z=0;J.cmp(w)!==0;Z++)J=J.redSqr();r(Z=0;y--){for(var D=E.words[y],K=v-1;K>=0;K--){var M=D>>K&1;if(w!==f[0]&&(w=this.sqr(w)),M===0&&_===0){x=0;continue}_<<=1,_|=M,x++,!(x!==k&&(y!==0||K!==0))&&(w=this.mul(w,f[_]),x=0,_=0)}v=26}return w},U.prototype.convertTo=function(T){var E=T.umod(this.m);return E===T?E.clone():E},U.prototype.convertFrom=function(T){var E=T.clone();return E.red=null,E},i.mont=function(T){return new G(T)};function G(q){U.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(G,U),G.prototype.convertTo=function(T){return this.imod(T.ushln(this.shift))},G.prototype.convertFrom=function(T){var E=this.imod(T.mul(this.rinv));return E.red=null,E},G.prototype.imul=function(T,E){if(T.isZero()||E.isZero())return T.words[0]=0,T.length=1,T;var k=T.imul(E),f=k.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),y=k.isub(f).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)},G.prototype.mul=function(T,E){if(T.isZero()||E.isZero())return new i(0)._forceRed(this);var k=T.mul(E),f=k.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),y=k.isub(f).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)},G.prototype.invm=function(T){var E=this.imod(T._invmp(this.m).mul(this.r2));return E._forceRed(this)}})(typeof ZD>"u"||ZD,_Y)});var E5=W((Plt,e7)=>{h();var XD;e7.exports=function(e){return XD||(XD=new vp(null)),XD.generate(e)};function vp(t){this.rand=t}e7.exports.Rand=vp;vp.prototype.generate=function(e){return this._rand(e)};vp.prototype._rand=function(e){if(this.rand.getBytes)return this.rand.getBytes(e);for(var r=new Uint8Array(e),n=0;n{h();var e0=Gi(),b5e=E5();function t0(t){this.rand=t||new b5e.Rand}xY.exports=t0;t0.create=function(e){return new t0(e)};t0.prototype._randbelow=function(e){var r=e.bitLength(),n=Math.ceil(r/8);do var i=new e0(this.rand.generate(n));while(i.cmp(e)>=0);return i};t0.prototype._randrange=function(e,r){var n=r.sub(e);return e.add(this._randbelow(n))};t0.prototype.test=function(e,r,n){var i=e.bitLength(),o=e0.mont(e),s=new e0(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 m=this._randrange(new e0(2),a);n&&n(m);var p=m.toRed(o).redPow(u);if(!(p.cmp(s)===0||p.cmp(c)===0)){for(var g=1;g0;r--){var c=this._randrange(new e0(2),s),l=e.gcd(c);if(l.cmpn(1)!==0)return l;var m=c.toRed(i).redPow(d);if(!(m.cmp(o)===0||m.cmp(u)===0)){for(var p=1;p{h();var v5e=Ky();AY.exports=s7;s7.simpleSieve=i7;s7.fermatTest=o7;var $o=Gi(),w5e=new $o(24),_5e=t7(),EY=new _5e,x5e=new $o(1),n7=new $o(2),E5e=new $o(5),Rlt=new $o(16),Dlt=new $o(8),S5e=new $o(10),A5e=new $o(3),Mlt=new $o(7),P5e=new $o(11),SY=new $o(4),Blt=new $o(12),r7=null;function T5e(){if(r7!==null)return r7;var t=1048576,e=[];e[0]=2;for(var r=1,n=3;nt;)r.ishrn(1);if(r.isEven()&&r.iadd(x5e),r.testn(1)||r.iadd(n7),e.cmp(n7)){if(!e.cmp(E5e))for(;r.mod(S5e).cmp(A5e);)r.iadd(SY)}else for(;r.mod(w5e).cmp(P5e);)r.iadd(SY);if(n=r.shrn(1),i7(n)&&i7(r)&&o7(n)&&o7(r)&&EY.test(n)&&EY.test(r))return r}}});var PY=W(($lt,I5e)=>{I5e.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 RY=W((Nlt,kY)=>{h();var Vc=Gi(),k5e=t7(),TY=new k5e,R5e=new Vc(24),D5e=new Vc(11),M5e=new Vc(10),B5e=new Vc(3),C5e=new Vc(7),IY=a7(),O5e=Ky();kY.exports=Df;function $5e(t,e){return e=e||"utf8",O.Buffer.isBuffer(t)||(t=new O.Buffer(t,e)),this._pub=new Vc(t),this}function N5e(t,e){return e=e||"utf8",O.Buffer.isBuffer(t)||(t=new O.Buffer(t,e)),this._priv=new Vc(t),this}var A5={};function j5e(t,e){var r=e.toString("hex"),n=[r,t.toString(16)].join("_");if(n in A5)return A5[n];var i=0;if(t.isEven()||!IY.simpleSieve||!IY.fermatTest(t)||!TY.test(t))return i+=1,r==="02"||r==="05"?i+=8:i+=4,A5[n]=i,i;TY.test(t.shrn(1))||(i+=2);var o;switch(r){case"02":t.mod(R5e).cmp(D5e)&&(i+=8);break;case"05":o=t.mod(M5e),o.cmp(B5e)&&o.cmp(C5e)&&(i+=8);break;default:i+=4}return A5[n]=i,i}function Df(t,e,r){this.setGenerator(e),this.__prime=new Vc(t),this._prime=Vc.mont(this.__prime),this._primeLen=t.length,this._pub=void 0,this._priv=void 0,this._primeCode=void 0,r?(this.setPublicKey=$5e,this.setPrivateKey=N5e):this._primeCode=8}Object.defineProperty(Df.prototype,"verifyError",{enumerable:!0,get:function(){return typeof this._primeCode!="number"&&(this._primeCode=j5e(this.__prime,this.__gen)),this._primeCode}});Df.prototype.generateKeys=function(){return this._priv||(this._priv=new Vc(O5e(this._primeLen))),this._pub=this._gen.toRed(this._prime).redPow(this._priv).fromRed(),this.getPublicKey()};Df.prototype.computeSecret=function(t){t=new Vc(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{h();var U5e=a7(),DY=PY(),c7=RY();function K5e(t){var e=new O.Buffer(DY[t].prime,"hex"),r=new O.Buffer(DY[t].gen,"hex");return new c7(e,r)}var q5e={binary:!0,hex:!0,base64:!0};function MY(t,e,r,n){return O.Buffer.isBuffer(e)||q5e[e]===void 0?MY(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 c7(U5e(t,r),r,!0):(O.Buffer.isBuffer(t)||(t=new O.Buffer(t,e)),new c7(t,r,!0)))}yv.DiffieHellmanGroup=yv.createDiffieHellmanGroup=yv.getDiffieHellman=K5e;yv.createDiffieHellman=yv.DiffieHellman=MY});var T5=W((CY,d7)=>{h();(function(t,e){"use strict";function r(k,f){if(!k)throw new Error(f||"Assertion failed")}function n(k,f){k.super_=f;var y=function(){};y.prototype=f.prototype,k.prototype=new y,k.prototype.constructor=k}function i(k,f,y){if(i.isBN(k))return k;this.negative=0,this.words=null,this.length=0,this.red=null,k!==null&&((f==="le"||f==="be")&&(y=f,f=10),this._init(k||0,f||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=YD().Buffer}catch{}i.isBN=function(f){return f instanceof i?!0:f!==null&&typeof f=="object"&&f.constructor.wordSize===i.wordSize&&Array.isArray(f.words)},i.max=function(f,y){return f.cmp(y)>0?f:y},i.min=function(f,y){return f.cmp(y)<0?f:y},i.prototype._init=function(f,y,w){if(typeof f=="number")return this._initNumber(f,y,w);if(typeof f=="object")return this._initArray(f,y,w);y==="hex"&&(y=16),r(y===(y|0)&&y>=2&&y<=36),f=f.toString().replace(/\s+/g,"");var _=0;f[0]==="-"&&(_++,this.negative=1),_=0;_-=3)v=f[_]|f[_-1]<<8|f[_-2]<<16,this.words[x]|=v<>>26-D&67108863,D+=24,D>=26&&(D-=26,x++);else if(w==="le")for(_=0,x=0;_>>26-D&67108863,D+=24,D>=26&&(D-=26,x++);return this._strip()};function s(k,f){var y=k.charCodeAt(f);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 "+k)}function a(k,f,y){var w=s(k,y);return y-1>=f&&(w|=s(k,y-1)<<4),w}i.prototype._parseHex=function(f,y,w){this.length=Math.ceil((f.length-y)/6),this.words=new Array(this.length);for(var _=0;_=y;_-=2)D=a(f,y,_)<=18?(x-=18,v+=1,this.words[v]|=D>>>26):x+=8;else{var K=f.length-y;for(_=K%2===0?y+1:y;_=18?(x-=18,v+=1,this.words[v]|=D>>>26):x+=8}this._strip()};function d(k,f,y,w){for(var _=0,x=0,v=Math.min(k.length,y),D=f;D=49?x=K-49+10:K>=17?x=K-17+10:x=K,r(K>=0&&x1&&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"],m=[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],p=[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(f,y){f=f||10,y=y|0||1;var w;if(f===16||f==="hex"){w="";for(var _=0,x=0,v=0;v>>24-_&16777215,_+=2,_>=26&&(_-=26,v--),x!==0||v!==this.length-1?w=l[6-K.length]+K+w:w=K+w}for(x!==0&&(w=x.toString(16)+w);w.length%y!==0;)w="0"+w;return this.negative!==0&&(w="-"+w),w}if(f===(f|0)&&f>=2&&f<=36){var M=m[f],j=p[f];w="";var J=this.clone();for(J.negative=0;!J.isZero();){var Z=J.modrn(j).toString(f);J=J.idivn(j),J.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 f=this.words[0];return this.length===2?f+=this.words[1]*67108864:this.length===3&&this.words[2]===1?f+=4503599627370496+this.words[1]*67108864:this.length>2&&r(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-f:f},i.prototype.toJSON=function(){return this.toString(16,2)},o&&(i.prototype.toBuffer=function(f,y){return this.toArrayLike(o,f,y)}),i.prototype.toArray=function(f,y){return this.toArrayLike(Array,f,y)};var g=function(f,y){return f.allocUnsafe?f.allocUnsafe(y):new f(y)};i.prototype.toArrayLike=function(f,y,w){this._strip();var _=this.byteLength(),x=w||Math.max(1,_);r(_<=x,"byte array longer than desired length"),r(x>0,"Requested array length <= 0");var v=g(f,x),D=y==="le"?"LE":"BE";return this["_toArrayLike"+D](v,_),v},i.prototype._toArrayLikeLE=function(f,y){for(var w=0,_=0,x=0,v=0;x>8&255),w>16&255),v===6?(w>24&255),_=0,v=0):(_=D>>>24,v+=2)}if(w=0&&(f[w--]=D>>8&255),w>=0&&(f[w--]=D>>16&255),v===6?(w>=0&&(f[w--]=D>>24&255),_=0,v=0):(_=D>>>24,v+=2)}if(w>=0)for(f[w--]=_;w>=0;)f[w--]=0},Math.clz32?i.prototype._countBits=function(f){return 32-Math.clz32(f)}:i.prototype._countBits=function(f){var y=f,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(f){if(f===0)return 26;var y=f,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 f=this.words[this.length-1],y=this._countBits(f);return(this.length-1)*26+y};function b(k){for(var f=new Array(k.bitLength()),y=0;y>>_&1}return f}i.prototype.zeroBits=function(){if(this.isZero())return 0;for(var f=0,y=0;yf.length?this.clone().ior(f):f.clone().ior(this)},i.prototype.uor=function(f){return this.length>f.length?this.clone().iuor(f):f.clone().iuor(this)},i.prototype.iuand=function(f){var y;this.length>f.length?y=f:y=this;for(var w=0;wf.length?this.clone().iand(f):f.clone().iand(this)},i.prototype.uand=function(f){return this.length>f.length?this.clone().iuand(f):f.clone().iuand(this)},i.prototype.iuxor=function(f){var y,w;this.length>f.length?(y=this,w=f):(y=f,w=this);for(var _=0;_f.length?this.clone().ixor(f):f.clone().ixor(this)},i.prototype.uxor=function(f){return this.length>f.length?this.clone().iuxor(f):f.clone().iuxor(this)},i.prototype.inotn=function(f){r(typeof f=="number"&&f>=0);var y=Math.ceil(f/26)|0,w=f%26;this._expand(y),w>0&&y--;for(var _=0;_0&&(this.words[_]=~this.words[_]&67108863>>26-w),this._strip()},i.prototype.notn=function(f){return this.clone().inotn(f)},i.prototype.setn=function(f,y){r(typeof f=="number"&&f>=0);var w=f/26|0,_=f%26;return this._expand(w+1),y?this.words[w]=this.words[w]|1<<_:this.words[w]=this.words[w]&~(1<<_),this._strip()},i.prototype.iadd=function(f){var y;if(this.negative!==0&&f.negative===0)return this.negative=0,y=this.isub(f),this.negative^=1,this._normSign();if(this.negative===0&&f.negative!==0)return f.negative=0,y=this.isub(f),f.negative=1,y._normSign();var w,_;this.length>f.length?(w=this,_=f):(w=f,_=this);for(var x=0,v=0;v<_.length;v++)y=(w.words[v]|0)+(_.words[v]|0)+x,this.words[v]=y&67108863,x=y>>>26;for(;x!==0&&v>>26;if(this.length=w.length,x!==0)this.words[this.length]=x,this.length++;else if(w!==this)for(;vf.length?this.clone().iadd(f):f.clone().iadd(this)},i.prototype.isub=function(f){if(f.negative!==0){f.negative=0;var y=this.iadd(f);return f.negative=1,y._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(f),this.negative=1,this._normSign();var w=this.cmp(f);if(w===0)return this.negative=0,this.length=1,this.words[0]=0,this;var _,x;w>0?(_=this,x=f):(_=f,x=this);for(var v=0,D=0;D>26,this.words[D]=y&67108863;for(;v!==0&&D<_.length;D++)y=(_.words[D]|0)+v,v=y>>26,this.words[D]=y&67108863;if(v===0&&D<_.length&&_!==this)for(;D<_.length;D++)this.words[D]=_.words[D];return this.length=Math.max(this.length,D),_!==this&&(this.negative=1),this._strip()},i.prototype.sub=function(f){return this.clone().isub(f)};function S(k,f,y){y.negative=f.negative^k.negative;var w=k.length+f.length|0;y.length=w,w=w-1|0;var _=k.words[0]|0,x=f.words[0]|0,v=_*x,D=v&67108863,K=v/67108864|0;y.words[0]=D;for(var M=1;M>>26,J=K&67108863,Z=Math.min(M,f.length-1),V=Math.max(0,M-k.length+1);V<=Z;V++){var H=M-V|0;_=k.words[H]|0,x=f.words[V]|0,v=_*x+J,j+=v/67108864|0,J=v&67108863}y.words[M]=J|0,K=j|0}return K!==0?y.words[M]=K|0:y.length--,y._strip()}var A=function(f,y,w){var _=f.words,x=y.words,v=w.words,D=0,K,M,j,J=_[0]|0,Z=J&8191,V=J>>>13,H=_[1]|0,X=H&8191,ee=H>>>13,ue=_[2]|0,ae=ue&8191,ce=ue>>>13,pe=_[3]|0,Ee=pe&8191,Ue=pe>>>13,le=_[4]|0,ge=le&8191,ve=le>>>13,Ce=_[5]|0,Ie=Ce&8191,je=Ce>>>13,gt=_[6]|0,Pe=gt&8191,De=gt>>>13,It=_[7]|0,we=It&8191,Se=It>>>13,Lr=_[8]|0,Fe=Lr&8191,He=Lr>>>13,js=_[9]|0,ft=js&8191,Rt=js>>>13,yi=x[0]|0,At=yi&8191,Ze=yi>>>13,Cc=x[1]|0,Pt=Cc&8191,$t=Cc>>>13,oy=x[2]|0,Bt=oy&8191,Wt=oy>>>13,Oc=x[3]|0,Ht=Oc&8191,Lt=Oc>>>13,sy=x[4]|0,Nt=sy&8191,Ft=sy>>>13,ay=x[5]|0,zt=ay&8191,Vt=ay>>>13,Uh=x[6]|0,Q=Uh&8191,Y=Uh>>>13,te=x[7]|0,re=te&8191,ie=te>>>13,$e=x[8]|0,ke=$e&8191,Ne=$e>>>13,Ar=x[9]|0,jt=Ar&8191,dt=Ar>>>13;w.negative=f.negative^y.negative,w.length=19,K=Math.imul(Z,At),M=Math.imul(Z,Ze),M=M+Math.imul(V,At)|0,j=Math.imul(V,Ze);var Jr=(D+K|0)+((M&8191)<<13)|0;D=(j+(M>>>13)|0)+(Jr>>>26)|0,Jr&=67108863,K=Math.imul(X,At),M=Math.imul(X,Ze),M=M+Math.imul(ee,At)|0,j=Math.imul(ee,Ze),K=K+Math.imul(Z,Pt)|0,M=M+Math.imul(Z,$t)|0,M=M+Math.imul(V,Pt)|0,j=j+Math.imul(V,$t)|0;var an=(D+K|0)+((M&8191)<<13)|0;D=(j+(M>>>13)|0)+(an>>>26)|0,an&=67108863,K=Math.imul(ae,At),M=Math.imul(ae,Ze),M=M+Math.imul(ce,At)|0,j=Math.imul(ce,Ze),K=K+Math.imul(X,Pt)|0,M=M+Math.imul(X,$t)|0,M=M+Math.imul(ee,Pt)|0,j=j+Math.imul(ee,$t)|0,K=K+Math.imul(Z,Bt)|0,M=M+Math.imul(Z,Wt)|0,M=M+Math.imul(V,Bt)|0,j=j+Math.imul(V,Wt)|0;var Wr=(D+K|0)+((M&8191)<<13)|0;D=(j+(M>>>13)|0)+(Wr>>>26)|0,Wr&=67108863,K=Math.imul(Ee,At),M=Math.imul(Ee,Ze),M=M+Math.imul(Ue,At)|0,j=Math.imul(Ue,Ze),K=K+Math.imul(ae,Pt)|0,M=M+Math.imul(ae,$t)|0,M=M+Math.imul(ce,Pt)|0,j=j+Math.imul(ce,$t)|0,K=K+Math.imul(X,Bt)|0,M=M+Math.imul(X,Wt)|0,M=M+Math.imul(ee,Bt)|0,j=j+Math.imul(ee,Wt)|0,K=K+Math.imul(Z,Ht)|0,M=M+Math.imul(Z,Lt)|0,M=M+Math.imul(V,Ht)|0,j=j+Math.imul(V,Lt)|0;var sr=(D+K|0)+((M&8191)<<13)|0;D=(j+(M>>>13)|0)+(sr>>>26)|0,sr&=67108863,K=Math.imul(ge,At),M=Math.imul(ge,Ze),M=M+Math.imul(ve,At)|0,j=Math.imul(ve,Ze),K=K+Math.imul(Ee,Pt)|0,M=M+Math.imul(Ee,$t)|0,M=M+Math.imul(Ue,Pt)|0,j=j+Math.imul(Ue,$t)|0,K=K+Math.imul(ae,Bt)|0,M=M+Math.imul(ae,Wt)|0,M=M+Math.imul(ce,Bt)|0,j=j+Math.imul(ce,Wt)|0,K=K+Math.imul(X,Ht)|0,M=M+Math.imul(X,Lt)|0,M=M+Math.imul(ee,Ht)|0,j=j+Math.imul(ee,Lt)|0,K=K+Math.imul(Z,Nt)|0,M=M+Math.imul(Z,Ft)|0,M=M+Math.imul(V,Nt)|0,j=j+Math.imul(V,Ft)|0;var Yr=(D+K|0)+((M&8191)<<13)|0;D=(j+(M>>>13)|0)+(Yr>>>26)|0,Yr&=67108863,K=Math.imul(Ie,At),M=Math.imul(Ie,Ze),M=M+Math.imul(je,At)|0,j=Math.imul(je,Ze),K=K+Math.imul(ge,Pt)|0,M=M+Math.imul(ge,$t)|0,M=M+Math.imul(ve,Pt)|0,j=j+Math.imul(ve,$t)|0,K=K+Math.imul(Ee,Bt)|0,M=M+Math.imul(Ee,Wt)|0,M=M+Math.imul(Ue,Bt)|0,j=j+Math.imul(Ue,Wt)|0,K=K+Math.imul(ae,Ht)|0,M=M+Math.imul(ae,Lt)|0,M=M+Math.imul(ce,Ht)|0,j=j+Math.imul(ce,Lt)|0,K=K+Math.imul(X,Nt)|0,M=M+Math.imul(X,Ft)|0,M=M+Math.imul(ee,Nt)|0,j=j+Math.imul(ee,Ft)|0,K=K+Math.imul(Z,zt)|0,M=M+Math.imul(Z,Vt)|0,M=M+Math.imul(V,zt)|0,j=j+Math.imul(V,Vt)|0;var Rr=(D+K|0)+((M&8191)<<13)|0;D=(j+(M>>>13)|0)+(Rr>>>26)|0,Rr&=67108863,K=Math.imul(Pe,At),M=Math.imul(Pe,Ze),M=M+Math.imul(De,At)|0,j=Math.imul(De,Ze),K=K+Math.imul(Ie,Pt)|0,M=M+Math.imul(Ie,$t)|0,M=M+Math.imul(je,Pt)|0,j=j+Math.imul(je,$t)|0,K=K+Math.imul(ge,Bt)|0,M=M+Math.imul(ge,Wt)|0,M=M+Math.imul(ve,Bt)|0,j=j+Math.imul(ve,Wt)|0,K=K+Math.imul(Ee,Ht)|0,M=M+Math.imul(Ee,Lt)|0,M=M+Math.imul(Ue,Ht)|0,j=j+Math.imul(Ue,Lt)|0,K=K+Math.imul(ae,Nt)|0,M=M+Math.imul(ae,Ft)|0,M=M+Math.imul(ce,Nt)|0,j=j+Math.imul(ce,Ft)|0,K=K+Math.imul(X,zt)|0,M=M+Math.imul(X,Vt)|0,M=M+Math.imul(ee,zt)|0,j=j+Math.imul(ee,Vt)|0,K=K+Math.imul(Z,Q)|0,M=M+Math.imul(Z,Y)|0,M=M+Math.imul(V,Q)|0,j=j+Math.imul(V,Y)|0;var Us=(D+K|0)+((M&8191)<<13)|0;D=(j+(M>>>13)|0)+(Us>>>26)|0,Us&=67108863,K=Math.imul(we,At),M=Math.imul(we,Ze),M=M+Math.imul(Se,At)|0,j=Math.imul(Se,Ze),K=K+Math.imul(Pe,Pt)|0,M=M+Math.imul(Pe,$t)|0,M=M+Math.imul(De,Pt)|0,j=j+Math.imul(De,$t)|0,K=K+Math.imul(Ie,Bt)|0,M=M+Math.imul(Ie,Wt)|0,M=M+Math.imul(je,Bt)|0,j=j+Math.imul(je,Wt)|0,K=K+Math.imul(ge,Ht)|0,M=M+Math.imul(ge,Lt)|0,M=M+Math.imul(ve,Ht)|0,j=j+Math.imul(ve,Lt)|0,K=K+Math.imul(Ee,Nt)|0,M=M+Math.imul(Ee,Ft)|0,M=M+Math.imul(Ue,Nt)|0,j=j+Math.imul(Ue,Ft)|0,K=K+Math.imul(ae,zt)|0,M=M+Math.imul(ae,Vt)|0,M=M+Math.imul(ce,zt)|0,j=j+Math.imul(ce,Vt)|0,K=K+Math.imul(X,Q)|0,M=M+Math.imul(X,Y)|0,M=M+Math.imul(ee,Q)|0,j=j+Math.imul(ee,Y)|0,K=K+Math.imul(Z,re)|0,M=M+Math.imul(Z,ie)|0,M=M+Math.imul(V,re)|0,j=j+Math.imul(V,ie)|0;var gi=(D+K|0)+((M&8191)<<13)|0;D=(j+(M>>>13)|0)+(gi>>>26)|0,gi&=67108863,K=Math.imul(Fe,At),M=Math.imul(Fe,Ze),M=M+Math.imul(He,At)|0,j=Math.imul(He,Ze),K=K+Math.imul(we,Pt)|0,M=M+Math.imul(we,$t)|0,M=M+Math.imul(Se,Pt)|0,j=j+Math.imul(Se,$t)|0,K=K+Math.imul(Pe,Bt)|0,M=M+Math.imul(Pe,Wt)|0,M=M+Math.imul(De,Bt)|0,j=j+Math.imul(De,Wt)|0,K=K+Math.imul(Ie,Ht)|0,M=M+Math.imul(Ie,Lt)|0,M=M+Math.imul(je,Ht)|0,j=j+Math.imul(je,Lt)|0,K=K+Math.imul(ge,Nt)|0,M=M+Math.imul(ge,Ft)|0,M=M+Math.imul(ve,Nt)|0,j=j+Math.imul(ve,Ft)|0,K=K+Math.imul(Ee,zt)|0,M=M+Math.imul(Ee,Vt)|0,M=M+Math.imul(Ue,zt)|0,j=j+Math.imul(Ue,Vt)|0,K=K+Math.imul(ae,Q)|0,M=M+Math.imul(ae,Y)|0,M=M+Math.imul(ce,Q)|0,j=j+Math.imul(ce,Y)|0,K=K+Math.imul(X,re)|0,M=M+Math.imul(X,ie)|0,M=M+Math.imul(ee,re)|0,j=j+Math.imul(ee,ie)|0,K=K+Math.imul(Z,ke)|0,M=M+Math.imul(Z,Ne)|0,M=M+Math.imul(V,ke)|0,j=j+Math.imul(V,Ne)|0;var Mi=(D+K|0)+((M&8191)<<13)|0;D=(j+(M>>>13)|0)+(Mi>>>26)|0,Mi&=67108863,K=Math.imul(ft,At),M=Math.imul(ft,Ze),M=M+Math.imul(Rt,At)|0,j=Math.imul(Rt,Ze),K=K+Math.imul(Fe,Pt)|0,M=M+Math.imul(Fe,$t)|0,M=M+Math.imul(He,Pt)|0,j=j+Math.imul(He,$t)|0,K=K+Math.imul(we,Bt)|0,M=M+Math.imul(we,Wt)|0,M=M+Math.imul(Se,Bt)|0,j=j+Math.imul(Se,Wt)|0,K=K+Math.imul(Pe,Ht)|0,M=M+Math.imul(Pe,Lt)|0,M=M+Math.imul(De,Ht)|0,j=j+Math.imul(De,Lt)|0,K=K+Math.imul(Ie,Nt)|0,M=M+Math.imul(Ie,Ft)|0,M=M+Math.imul(je,Nt)|0,j=j+Math.imul(je,Ft)|0,K=K+Math.imul(ge,zt)|0,M=M+Math.imul(ge,Vt)|0,M=M+Math.imul(ve,zt)|0,j=j+Math.imul(ve,Vt)|0,K=K+Math.imul(Ee,Q)|0,M=M+Math.imul(Ee,Y)|0,M=M+Math.imul(Ue,Q)|0,j=j+Math.imul(Ue,Y)|0,K=K+Math.imul(ae,re)|0,M=M+Math.imul(ae,ie)|0,M=M+Math.imul(ce,re)|0,j=j+Math.imul(ce,ie)|0,K=K+Math.imul(X,ke)|0,M=M+Math.imul(X,Ne)|0,M=M+Math.imul(ee,ke)|0,j=j+Math.imul(ee,Ne)|0,K=K+Math.imul(Z,jt)|0,M=M+Math.imul(Z,dt)|0,M=M+Math.imul(V,jt)|0,j=j+Math.imul(V,dt)|0;var Cr=(D+K|0)+((M&8191)<<13)|0;D=(j+(M>>>13)|0)+(Cr>>>26)|0,Cr&=67108863,K=Math.imul(ft,Pt),M=Math.imul(ft,$t),M=M+Math.imul(Rt,Pt)|0,j=Math.imul(Rt,$t),K=K+Math.imul(Fe,Bt)|0,M=M+Math.imul(Fe,Wt)|0,M=M+Math.imul(He,Bt)|0,j=j+Math.imul(He,Wt)|0,K=K+Math.imul(we,Ht)|0,M=M+Math.imul(we,Lt)|0,M=M+Math.imul(Se,Ht)|0,j=j+Math.imul(Se,Lt)|0,K=K+Math.imul(Pe,Nt)|0,M=M+Math.imul(Pe,Ft)|0,M=M+Math.imul(De,Nt)|0,j=j+Math.imul(De,Ft)|0,K=K+Math.imul(Ie,zt)|0,M=M+Math.imul(Ie,Vt)|0,M=M+Math.imul(je,zt)|0,j=j+Math.imul(je,Vt)|0,K=K+Math.imul(ge,Q)|0,M=M+Math.imul(ge,Y)|0,M=M+Math.imul(ve,Q)|0,j=j+Math.imul(ve,Y)|0,K=K+Math.imul(Ee,re)|0,M=M+Math.imul(Ee,ie)|0,M=M+Math.imul(Ue,re)|0,j=j+Math.imul(Ue,ie)|0,K=K+Math.imul(ae,ke)|0,M=M+Math.imul(ae,Ne)|0,M=M+Math.imul(ce,ke)|0,j=j+Math.imul(ce,Ne)|0,K=K+Math.imul(X,jt)|0,M=M+Math.imul(X,dt)|0,M=M+Math.imul(ee,jt)|0,j=j+Math.imul(ee,dt)|0;var bi=(D+K|0)+((M&8191)<<13)|0;D=(j+(M>>>13)|0)+(bi>>>26)|0,bi&=67108863,K=Math.imul(ft,Bt),M=Math.imul(ft,Wt),M=M+Math.imul(Rt,Bt)|0,j=Math.imul(Rt,Wt),K=K+Math.imul(Fe,Ht)|0,M=M+Math.imul(Fe,Lt)|0,M=M+Math.imul(He,Ht)|0,j=j+Math.imul(He,Lt)|0,K=K+Math.imul(we,Nt)|0,M=M+Math.imul(we,Ft)|0,M=M+Math.imul(Se,Nt)|0,j=j+Math.imul(Se,Ft)|0,K=K+Math.imul(Pe,zt)|0,M=M+Math.imul(Pe,Vt)|0,M=M+Math.imul(De,zt)|0,j=j+Math.imul(De,Vt)|0,K=K+Math.imul(Ie,Q)|0,M=M+Math.imul(Ie,Y)|0,M=M+Math.imul(je,Q)|0,j=j+Math.imul(je,Y)|0,K=K+Math.imul(ge,re)|0,M=M+Math.imul(ge,ie)|0,M=M+Math.imul(ve,re)|0,j=j+Math.imul(ve,ie)|0,K=K+Math.imul(Ee,ke)|0,M=M+Math.imul(Ee,Ne)|0,M=M+Math.imul(Ue,ke)|0,j=j+Math.imul(Ue,Ne)|0,K=K+Math.imul(ae,jt)|0,M=M+Math.imul(ae,dt)|0,M=M+Math.imul(ce,jt)|0,j=j+Math.imul(ce,dt)|0;var Bi=(D+K|0)+((M&8191)<<13)|0;D=(j+(M>>>13)|0)+(Bi>>>26)|0,Bi&=67108863,K=Math.imul(ft,Ht),M=Math.imul(ft,Lt),M=M+Math.imul(Rt,Ht)|0,j=Math.imul(Rt,Lt),K=K+Math.imul(Fe,Nt)|0,M=M+Math.imul(Fe,Ft)|0,M=M+Math.imul(He,Nt)|0,j=j+Math.imul(He,Ft)|0,K=K+Math.imul(we,zt)|0,M=M+Math.imul(we,Vt)|0,M=M+Math.imul(Se,zt)|0,j=j+Math.imul(Se,Vt)|0,K=K+Math.imul(Pe,Q)|0,M=M+Math.imul(Pe,Y)|0,M=M+Math.imul(De,Q)|0,j=j+Math.imul(De,Y)|0,K=K+Math.imul(Ie,re)|0,M=M+Math.imul(Ie,ie)|0,M=M+Math.imul(je,re)|0,j=j+Math.imul(je,ie)|0,K=K+Math.imul(ge,ke)|0,M=M+Math.imul(ge,Ne)|0,M=M+Math.imul(ve,ke)|0,j=j+Math.imul(ve,Ne)|0,K=K+Math.imul(Ee,jt)|0,M=M+Math.imul(Ee,dt)|0,M=M+Math.imul(Ue,jt)|0,j=j+Math.imul(Ue,dt)|0;var oo=(D+K|0)+((M&8191)<<13)|0;D=(j+(M>>>13)|0)+(oo>>>26)|0,oo&=67108863,K=Math.imul(ft,Nt),M=Math.imul(ft,Ft),M=M+Math.imul(Rt,Nt)|0,j=Math.imul(Rt,Ft),K=K+Math.imul(Fe,zt)|0,M=M+Math.imul(Fe,Vt)|0,M=M+Math.imul(He,zt)|0,j=j+Math.imul(He,Vt)|0,K=K+Math.imul(we,Q)|0,M=M+Math.imul(we,Y)|0,M=M+Math.imul(Se,Q)|0,j=j+Math.imul(Se,Y)|0,K=K+Math.imul(Pe,re)|0,M=M+Math.imul(Pe,ie)|0,M=M+Math.imul(De,re)|0,j=j+Math.imul(De,ie)|0,K=K+Math.imul(Ie,ke)|0,M=M+Math.imul(Ie,Ne)|0,M=M+Math.imul(je,ke)|0,j=j+Math.imul(je,Ne)|0,K=K+Math.imul(ge,jt)|0,M=M+Math.imul(ge,dt)|0,M=M+Math.imul(ve,jt)|0,j=j+Math.imul(ve,dt)|0;var Ks=(D+K|0)+((M&8191)<<13)|0;D=(j+(M>>>13)|0)+(Ks>>>26)|0,Ks&=67108863,K=Math.imul(ft,zt),M=Math.imul(ft,Vt),M=M+Math.imul(Rt,zt)|0,j=Math.imul(Rt,Vt),K=K+Math.imul(Fe,Q)|0,M=M+Math.imul(Fe,Y)|0,M=M+Math.imul(He,Q)|0,j=j+Math.imul(He,Y)|0,K=K+Math.imul(we,re)|0,M=M+Math.imul(we,ie)|0,M=M+Math.imul(Se,re)|0,j=j+Math.imul(Se,ie)|0,K=K+Math.imul(Pe,ke)|0,M=M+Math.imul(Pe,Ne)|0,M=M+Math.imul(De,ke)|0,j=j+Math.imul(De,Ne)|0,K=K+Math.imul(Ie,jt)|0,M=M+Math.imul(Ie,dt)|0,M=M+Math.imul(je,jt)|0,j=j+Math.imul(je,dt)|0;var Mo=(D+K|0)+((M&8191)<<13)|0;D=(j+(M>>>13)|0)+(Mo>>>26)|0,Mo&=67108863,K=Math.imul(ft,Q),M=Math.imul(ft,Y),M=M+Math.imul(Rt,Q)|0,j=Math.imul(Rt,Y),K=K+Math.imul(Fe,re)|0,M=M+Math.imul(Fe,ie)|0,M=M+Math.imul(He,re)|0,j=j+Math.imul(He,ie)|0,K=K+Math.imul(we,ke)|0,M=M+Math.imul(we,Ne)|0,M=M+Math.imul(Se,ke)|0,j=j+Math.imul(Se,Ne)|0,K=K+Math.imul(Pe,jt)|0,M=M+Math.imul(Pe,dt)|0,M=M+Math.imul(De,jt)|0,j=j+Math.imul(De,dt)|0;var Ga=(D+K|0)+((M&8191)<<13)|0;D=(j+(M>>>13)|0)+(Ga>>>26)|0,Ga&=67108863,K=Math.imul(ft,re),M=Math.imul(ft,ie),M=M+Math.imul(Rt,re)|0,j=Math.imul(Rt,ie),K=K+Math.imul(Fe,ke)|0,M=M+Math.imul(Fe,Ne)|0,M=M+Math.imul(He,ke)|0,j=j+Math.imul(He,Ne)|0,K=K+Math.imul(we,jt)|0,M=M+Math.imul(we,dt)|0,M=M+Math.imul(Se,jt)|0,j=j+Math.imul(Se,dt)|0;var Kh=(D+K|0)+((M&8191)<<13)|0;D=(j+(M>>>13)|0)+(Kh>>>26)|0,Kh&=67108863,K=Math.imul(ft,ke),M=Math.imul(ft,Ne),M=M+Math.imul(Rt,ke)|0,j=Math.imul(Rt,Ne),K=K+Math.imul(Fe,jt)|0,M=M+Math.imul(Fe,dt)|0,M=M+Math.imul(He,jt)|0,j=j+Math.imul(He,dt)|0;var qh=(D+K|0)+((M&8191)<<13)|0;D=(j+(M>>>13)|0)+(qh>>>26)|0,qh&=67108863,K=Math.imul(ft,jt),M=Math.imul(ft,dt),M=M+Math.imul(Rt,jt)|0,j=Math.imul(Rt,dt);var Nu=(D+K|0)+((M&8191)<<13)|0;return D=(j+(M>>>13)|0)+(Nu>>>26)|0,Nu&=67108863,v[0]=Jr,v[1]=an,v[2]=Wr,v[3]=sr,v[4]=Yr,v[5]=Rr,v[6]=Us,v[7]=gi,v[8]=Mi,v[9]=Cr,v[10]=bi,v[11]=Bi,v[12]=oo,v[13]=Ks,v[14]=Mo,v[15]=Ga,v[16]=Kh,v[17]=qh,v[18]=Nu,D!==0&&(v[19]=D,w.length++),w};Math.imul||(A=S);function I(k,f,y){y.negative=f.negative^k.negative,y.length=k.length+f.length;for(var w=0,_=0,x=0;x>>26)|0,_+=v>>>26,v&=67108863}y.words[x]=D,w=v,v=_}return w!==0?y.words[x]=w:y.length--,y._strip()}function P(k,f,y){return I(k,f,y)}i.prototype.mulTo=function(f,y){var w,_=this.length+f.length;return this.length===10&&f.length===10?w=A(this,f,y):_<63?w=S(this,f,y):_<1024?w=I(this,f,y):w=P(this,f,y),w};function $(k,f){this.x=k,this.y=f}$.prototype.makeRBT=function(f){for(var y=new Array(f),w=i.prototype._countBits(f)-1,_=0;_>=1;return _},$.prototype.permute=function(f,y,w,_,x,v){for(var D=0;D>>1)x++;return 1<>>13,w[2*v+1]=x&8191,x=x>>>13;for(v=2*y;v<_;++v)w[v]=0;r(x===0),r((x&-8192)===0)},$.prototype.stub=function(f){for(var y=new Array(f),w=0;w>=26,w+=x/67108864|0,w+=v>>>26,this.words[_]=v&67108863}return w!==0&&(this.words[_]=w,this.length++),y?this.ineg():this},i.prototype.muln=function(f){return this.clone().imuln(f)},i.prototype.sqr=function(){return this.mul(this)},i.prototype.isqr=function(){return this.imul(this.clone())},i.prototype.pow=function(f){var y=b(f);if(y.length===0)return new i(1);for(var w=this,_=0;_=0);var y=f%26,w=(f-y)/26,_=67108863>>>26-y<<26-y,x;if(y!==0){var v=0;for(x=0;x>>26-y}v&&(this.words[x]=v,this.length++)}if(w!==0){for(x=this.length-1;x>=0;x--)this.words[x+w]=this.words[x];for(x=0;x=0);var _;y?_=(y-y%26)/26:_=0;var x=f%26,v=Math.min((f-x)/26,this.length),D=67108863^67108863>>>x<v)for(this.length-=v,M=0;M=0&&(j!==0||M>=_);M--){var J=this.words[M]|0;this.words[M]=j<<26-x|J>>>x,j=J&D}return K&&j!==0&&(K.words[K.length++]=j),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},i.prototype.ishrn=function(f,y,w){return r(this.negative===0),this.iushrn(f,y,w)},i.prototype.shln=function(f){return this.clone().ishln(f)},i.prototype.ushln=function(f){return this.clone().iushln(f)},i.prototype.shrn=function(f){return this.clone().ishrn(f)},i.prototype.ushrn=function(f){return this.clone().iushrn(f)},i.prototype.testn=function(f){r(typeof f=="number"&&f>=0);var y=f%26,w=(f-y)/26,_=1<=0);var y=f%26,w=(f-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 _=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(f){if(r(typeof f=="number"),r(f<67108864),f<0)return this.iaddn(-f);if(this.negative!==0)return this.negative=0,this.iaddn(f),this.negative=1,this;if(this.words[0]-=f,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var y=0;y>26)-(K/67108864|0),this.words[x+w]=v&67108863}for(;x>26,this.words[x+w]=v&67108863;if(D===0)return this._strip();for(r(D===-1),D=0,x=0;x>26,this.words[x]=v&67108863;return this.negative=1,this._strip()},i.prototype._wordDiv=function(f,y){var w=this.length-f.length,_=this.clone(),x=f,v=x.words[x.length-1]|0,D=this._countBits(v);w=26-D,w!==0&&(x=x.ushln(w),_.iushln(w),v=x.words[x.length-1]|0);var K=_.length-x.length,M;if(y!=="mod"){M=new i(null),M.length=K+1,M.words=new Array(M.length);for(var j=0;j=0;Z--){var V=(_.words[x.length+Z]|0)*67108864+(_.words[x.length+Z-1]|0);for(V=Math.min(V/v|0,67108863),_._ishlnsubmul(x,V,Z);_.negative!==0;)V--,_.negative=0,_._ishlnsubmul(x,1,Z),_.isZero()||(_.negative^=1);M&&(M.words[Z]=V)}return M&&M._strip(),_._strip(),y!=="div"&&w!==0&&_.iushrn(w),{div:M||null,mod:_}},i.prototype.divmod=function(f,y,w){if(r(!f.isZero()),this.isZero())return{div:new i(0),mod:new i(0)};var _,x,v;return this.negative!==0&&f.negative===0?(v=this.neg().divmod(f,y),y!=="mod"&&(_=v.div.neg()),y!=="div"&&(x=v.mod.neg(),w&&x.negative!==0&&x.iadd(f)),{div:_,mod:x}):this.negative===0&&f.negative!==0?(v=this.divmod(f.neg(),y),y!=="mod"&&(_=v.div.neg()),{div:_,mod:v.mod}):this.negative&f.negative?(v=this.neg().divmod(f.neg(),y),y!=="div"&&(x=v.mod.neg(),w&&x.negative!==0&&x.isub(f)),{div:v.div,mod:x}):f.length>this.length||this.cmp(f)<0?{div:new i(0),mod:this}:f.length===1?y==="div"?{div:this.divn(f.words[0]),mod:null}:y==="mod"?{div:null,mod:new i(this.modrn(f.words[0]))}:{div:this.divn(f.words[0]),mod:new i(this.modrn(f.words[0]))}:this._wordDiv(f,y)},i.prototype.div=function(f){return this.divmod(f,"div",!1).div},i.prototype.mod=function(f){return this.divmod(f,"mod",!1).mod},i.prototype.umod=function(f){return this.divmod(f,"mod",!0).mod},i.prototype.divRound=function(f){var y=this.divmod(f);if(y.mod.isZero())return y.div;var w=y.div.negative!==0?y.mod.isub(f):y.mod,_=f.ushrn(1),x=f.andln(1),v=w.cmp(_);return v<0||x===1&&v===0?y.div:y.div.negative!==0?y.div.isubn(1):y.div.iaddn(1)},i.prototype.modrn=function(f){var y=f<0;y&&(f=-f),r(f<=67108863);for(var w=(1<<26)%f,_=0,x=this.length-1;x>=0;x--)_=(w*_+(this.words[x]|0))%f;return y?-_:_},i.prototype.modn=function(f){return this.modrn(f)},i.prototype.idivn=function(f){var y=f<0;y&&(f=-f),r(f<=67108863);for(var w=0,_=this.length-1;_>=0;_--){var x=(this.words[_]|0)+w*67108864;this.words[_]=x/f|0,w=x%f}return this._strip(),y?this.ineg():this},i.prototype.divn=function(f){return this.clone().idivn(f)},i.prototype.egcd=function(f){r(f.negative===0),r(!f.isZero());var y=this,w=f.clone();y.negative!==0?y=y.umod(f):y=y.clone();for(var _=new i(1),x=new i(0),v=new i(0),D=new i(1),K=0;y.isEven()&&w.isEven();)y.iushrn(1),w.iushrn(1),++K;for(var M=w.clone(),j=y.clone();!y.isZero();){for(var J=0,Z=1;!(y.words[0]&Z)&&J<26;++J,Z<<=1);if(J>0)for(y.iushrn(J);J-- >0;)(_.isOdd()||x.isOdd())&&(_.iadd(M),x.isub(j)),_.iushrn(1),x.iushrn(1);for(var V=0,H=1;!(w.words[0]&H)&&V<26;++V,H<<=1);if(V>0)for(w.iushrn(V);V-- >0;)(v.isOdd()||D.isOdd())&&(v.iadd(M),D.isub(j)),v.iushrn(1),D.iushrn(1);y.cmp(w)>=0?(y.isub(w),_.isub(v),x.isub(D)):(w.isub(y),v.isub(_),D.isub(x))}return{a:v,b:D,gcd:w.iushln(K)}},i.prototype._invmp=function(f){r(f.negative===0),r(!f.isZero());var y=this,w=f.clone();y.negative!==0?y=y.umod(f):y=y.clone();for(var _=new i(1),x=new i(0),v=w.clone();y.cmpn(1)>0&&w.cmpn(1)>0;){for(var D=0,K=1;!(y.words[0]&K)&&D<26;++D,K<<=1);if(D>0)for(y.iushrn(D);D-- >0;)_.isOdd()&&_.iadd(v),_.iushrn(1);for(var M=0,j=1;!(w.words[0]&j)&&M<26;++M,j<<=1);if(M>0)for(w.iushrn(M);M-- >0;)x.isOdd()&&x.iadd(v),x.iushrn(1);y.cmp(w)>=0?(y.isub(w),_.isub(x)):(w.isub(y),x.isub(_))}var J;return y.cmpn(1)===0?J=_:J=x,J.cmpn(0)<0&&J.iadd(f),J},i.prototype.gcd=function(f){if(this.isZero())return f.abs();if(f.isZero())return this.abs();var y=this.clone(),w=f.clone();y.negative=0,w.negative=0;for(var _=0;y.isEven()&&w.isEven();_++)y.iushrn(1),w.iushrn(1);do{for(;y.isEven();)y.iushrn(1);for(;w.isEven();)w.iushrn(1);var x=y.cmp(w);if(x<0){var v=y;y=w,w=v}else if(x===0||w.cmpn(1)===0)break;y.isub(w)}while(!0);return w.iushln(_)},i.prototype.invm=function(f){return this.egcd(f).a.umod(f)},i.prototype.isEven=function(){return(this.words[0]&1)===0},i.prototype.isOdd=function(){return(this.words[0]&1)===1},i.prototype.andln=function(f){return this.words[0]&f},i.prototype.bincn=function(f){r(typeof f=="number");var y=f%26,w=(f-y)/26,_=1<>>26,D&=67108863,this.words[v]=D}return x!==0&&(this.words[v]=x,this.length++),this},i.prototype.isZero=function(){return this.length===1&&this.words[0]===0},i.prototype.cmpn=function(f){var y=f<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&&(f=-f),r(f<=67108863,"Number is too big");var _=this.words[0]|0;w=_===f?0:_f.length)return 1;if(this.length=0;w--){var _=this.words[w]|0,x=f.words[w]|0;if(_!==x){_x&&(y=1);break}}return y},i.prototype.gtn=function(f){return this.cmpn(f)===1},i.prototype.gt=function(f){return this.cmp(f)===1},i.prototype.gten=function(f){return this.cmpn(f)>=0},i.prototype.gte=function(f){return this.cmp(f)>=0},i.prototype.ltn=function(f){return this.cmpn(f)===-1},i.prototype.lt=function(f){return this.cmp(f)===-1},i.prototype.lten=function(f){return this.cmpn(f)<=0},i.prototype.lte=function(f){return this.cmp(f)<=0},i.prototype.eqn=function(f){return this.cmpn(f)===0},i.prototype.eq=function(f){return this.cmp(f)===0},i.red=function(f){return new T(f)},i.prototype.toRed=function(f){return r(!this.red,"Already a number in reduction context"),r(this.negative===0,"red works only with positives"),f.convertTo(this)._forceRed(f)},i.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},i.prototype._forceRed=function(f){return this.red=f,this},i.prototype.forceRed=function(f){return r(!this.red,"Already a number in reduction context"),this._forceRed(f)},i.prototype.redAdd=function(f){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,f)},i.prototype.redIAdd=function(f){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,f)},i.prototype.redSub=function(f){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,f)},i.prototype.redISub=function(f){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,f)},i.prototype.redShl=function(f){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,f)},i.prototype.redMul=function(f){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,f),this.red.mul(this,f)},i.prototype.redIMul=function(f){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,f),this.red.imul(this,f)},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(f){return r(this.red&&!f.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,f)};var N={k256:null,p224:null,p192:null,p25519:null};function L(k,f){this.name=k,this.p=new i(f,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 f=new i(null);return f.words=new Array(Math.ceil(this.n/13)),f},L.prototype.ireduce=function(f){var y=f,w;do this.split(y,this.tmp),y=this.imulK(y),y=y.iadd(this.tmp),w=y.bitLength();while(w>this.n);var _=w0?y.isub(this.p):y.strip!==void 0?y.strip():y._strip(),y},L.prototype.split=function(f,y){f.iushrn(this.n,0,y)},L.prototype.imulK=function(f){return f.imul(this.k)};function F(){L.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}n(F,L),F.prototype.split=function(f,y){for(var w=4194303,_=Math.min(f.length,9),x=0;x<_;x++)y.words[x]=f.words[x];if(y.length=_,f.length<=9){f.words[0]=0,f.length=1;return}var v=f.words[9];for(y.words[y.length++]=v&w,x=10;x>>22,v=D}v>>>=22,f.words[x-10]=v,v===0&&f.length>10?f.length-=10:f.length-=9},F.prototype.imulK=function(f){f.words[f.length]=0,f.words[f.length+1]=0,f.length+=2;for(var y=0,w=0;w>>=26,f.words[w]=x,y=_}return y!==0&&(f.words[f.length++]=y),f},i._prime=function(f){if(N[f])return N[f];var y;if(f==="k256")y=new F;else if(f==="p224")y=new U;else if(f==="p192")y=new G;else if(f==="p25519")y=new q;else throw new Error("Unknown prime "+f);return N[f]=y,y};function T(k){if(typeof k=="string"){var f=i._prime(k);this.m=f.p,this.prime=f}else r(k.gtn(1),"modulus must be greater than 1"),this.m=k,this.prime=null}T.prototype._verify1=function(f){r(f.negative===0,"red works only with positives"),r(f.red,"red works only with red numbers")},T.prototype._verify2=function(f,y){r((f.negative|y.negative)===0,"red works only with positives"),r(f.red&&f.red===y.red,"red works only with red numbers")},T.prototype.imod=function(f){return this.prime?this.prime.ireduce(f)._forceRed(this):(u(f,f.umod(this.m)._forceRed(this)),f)},T.prototype.neg=function(f){return f.isZero()?f.clone():this.m.sub(f)._forceRed(this)},T.prototype.add=function(f,y){this._verify2(f,y);var w=f.add(y);return w.cmp(this.m)>=0&&w.isub(this.m),w._forceRed(this)},T.prototype.iadd=function(f,y){this._verify2(f,y);var w=f.iadd(y);return w.cmp(this.m)>=0&&w.isub(this.m),w},T.prototype.sub=function(f,y){this._verify2(f,y);var w=f.sub(y);return w.cmpn(0)<0&&w.iadd(this.m),w._forceRed(this)},T.prototype.isub=function(f,y){this._verify2(f,y);var w=f.isub(y);return w.cmpn(0)<0&&w.iadd(this.m),w},T.prototype.shl=function(f,y){return this._verify1(f),this.imod(f.ushln(y))},T.prototype.imul=function(f,y){return this._verify2(f,y),this.imod(f.imul(y))},T.prototype.mul=function(f,y){return this._verify2(f,y),this.imod(f.mul(y))},T.prototype.isqr=function(f){return this.imul(f,f.clone())},T.prototype.sqr=function(f){return this.mul(f,f)},T.prototype.sqrt=function(f){if(f.isZero())return f.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(f,w)}for(var _=this.m.subn(1),x=0;!_.isZero()&&_.andln(1)===0;)x++,_.iushrn(1);r(!_.isZero());var v=new i(1).toRed(this),D=v.redNeg(),K=this.m.subn(1).iushrn(1),M=this.m.bitLength();for(M=new i(2*M*M).toRed(this);this.pow(M,K).cmp(D)!==0;)M.redIAdd(D);for(var j=this.pow(M,_),J=this.pow(f,_.addn(1).iushrn(1)),Z=this.pow(f,_),V=x;Z.cmp(v)!==0;){for(var H=Z,X=0;H.cmp(v)!==0;X++)H=H.redSqr();r(X=0;x--){for(var j=y.words[x],J=M-1;J>=0;J--){var Z=j>>J&1;if(v!==_[0]&&(v=this.sqr(v)),Z===0&&D===0){K=0;continue}D<<=1,D|=Z,K++,!(K!==w&&(x!==0||J!==0))&&(v=this.mul(v,_[D]),K=0,D=0)}M=26}return v},T.prototype.convertTo=function(f){var y=f.umod(this.m);return y===f?y.clone():y},T.prototype.convertFrom=function(f){var y=f.clone();return y.red=null,y},i.mont=function(f){return new E(f)};function E(k){T.call(this,k),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(E,T),E.prototype.convertTo=function(f){return this.imod(f.ushln(this.shift))},E.prototype.convertFrom=function(f){var y=this.imod(f.mul(this.rinv));return y.red=null,y},E.prototype.imul=function(f,y){if(f.isZero()||y.isZero())return f.words[0]=0,f.length=1,f;var w=f.imul(y),_=w.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),x=w.isub(_).iushrn(this.shift),v=x;return x.cmp(this.m)>=0?v=x.isub(this.m):x.cmpn(0)<0&&(v=x.iadd(this.m)),v._forceRed(this)},E.prototype.mul=function(f,y){if(f.isZero()||y.isZero())return new i(0)._forceRed(this);var w=f.mul(y),_=w.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),x=w.isub(_).iushrn(this.shift),v=x;return x.cmp(this.m)>=0?v=x.isub(this.m):x.cmpn(0)<0&&(v=x.iadd(this.m)),v._forceRed(this)},E.prototype.invm=function(f){var y=this.imod(f._invmp(this.m).mul(this.r2));return y._forceRed(this)}})(typeof d7>"u"||d7,CY)});var I5=W((Llt,NY)=>{h();var gv=T5(),L5e=Ky();function F5e(t){var e=OY(t),r=e.toRed(gv.mont(t.modulus)).redPow(new gv(t.publicExponent)).fromRed();return{blinder:r,unblinder:e.invm(t.modulus)}}function OY(t){var e=t.modulus.byteLength(),r;do r=new gv(L5e(e));while(r.cmp(t.modulus)>=0||!r.umod(t.prime1)||!r.umod(t.prime2));return r}function $Y(t,e){var r=F5e(e),n=e.modulus.byteLength(),i=new gv(t).mul(r.blinder).umod(e.modulus),o=i.toRed(gv.mont(e.prime1)),s=i.toRed(gv.mont(e.prime2)),a=e.coefficient,d=e.prime1,u=e.prime2,c=o.redPow(e.exponent1).fromRed(),l=s.redPow(e.exponent2).fromRed(),m=c.isub(l).imul(a).umod(d).imul(u);return l.iadd(m).imul(r.unblinder).umod(e.modulus).toArrayLike(O.Buffer,"be",n)}$Y.getr=OY;NY.exports=$Y});var jY=W((zlt,z5e)=>{z5e.exports={name:"elliptic",version:"6.5.4",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 u7=W(qY=>{"use strict";h();var k5=qY;function G5e(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}k5.toArray=G5e;function UY(t){return t.length===1?"0"+t:t}k5.zero2=UY;function KY(t){for(var e="",r=0;r{"use strict";h();var Hd=LY,W5e=Gi(),H5e=ic(),R5=u7();Hd.assert=H5e;Hd.toArray=R5.toArray;Hd.zero2=R5.zero2;Hd.toHex=R5.toHex;Hd.encode=R5.encode;function V5e(t,e,r){var n=new Array(Math.max(t.bitLength(),r)+1);n.fill(0);for(var i=1<(i>>1)-1?a=(i>>1)-d:a=d,o.isubn(a)):a=0,n[s]=a,o.iushrn(1)}return n}Hd.getNAF=V5e;function J5e(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}Hd.getJSF=J5e;function Y5e(t,e,r){var n="_"+e;t.prototype[e]=function(){return this[n]!==void 0?this[n]:this[n]=r.call(this)}}Hd.cachedProperty=Y5e;function Z5e(t){return typeof t=="string"?Hd.toArray(t,"hex"):t}Hd.parseBytes=Z5e;function X5e(t){return new W5e(t,"hex","le")}Hd.intFromLE=X5e});var j_=W((Jlt,FY)=>{"use strict";h();var r0=Gi(),N_=oc(),D5=N_.getNAF,Q5e=N_.getJSF,M5=N_.assert;function wp(t,e){this.type=t,this.p=new r0(e.p,16),this.red=e.prime?r0.red(e.prime):r0.mont(this.p),this.zero=new r0(0).toRed(this.red),this.one=new r0(1).toRed(this.red),this.two=new r0(2).toRed(this.red),this.n=e.n&&new r0(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))}FY.exports=wp;wp.prototype.point=function(){throw new Error("Not implemented")};wp.prototype.validate=function(){throw new Error("Not implemented")};wp.prototype._fixedNafMul=function(e,r){M5(e.precomputed);var n=e._getDoubles(),i=D5(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),m=o;m>0;m--){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];M5(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};wp.prototype._wnafMulAdd=function(e,r,n,i,o){var s=this._wnafT1,a=this._wnafT2,d=this._wnafT3,u=0,c,l,m;for(c=0;c=1;c-=2){var g=c-1,b=c;if(s[g]!==1||s[b]!==1){d[g]=D5(n[g],s[g],this._bitLength),d[b]=D5(n[b],s[b],this._bitLength),u=Math.max(d[g].length,u),u=Math.max(d[b].length,u);continue}var S=[r[g],null,null,r[b]];r[g].y.cmp(r[b].y)===0?(S[1]=r[g].add(r[b]),S[2]=r[g].toJ().mixedAdd(r[b].neg())):r[g].y.cmp(r[b].y.redNeg())===0?(S[1]=r[g].toJ().mixedAdd(r[b]),S[2]=r[g].add(r[b].neg())):(S[1]=r[g].toJ().mixedAdd(r[b]),S[2]=r[g].toJ().mixedAdd(r[b].neg()));var A=[-3,-1,-5,-7,0,7,5,1,3],I=Q5e(n[g],n[b]);for(u=Math.max(I[0].length,u),d[g]=new Array(u),d[b]=new Array(u),l=0;l=0;c--){for(var F=0;c>=0;){var U=!0;for(l=0;l=0&&F++,N=N.dblp(F),c<0)break;for(l=0;l0?m=a[l][G-1>>1]:G<0&&(m=a[l][-G-1>>1].neg()),m.type==="affine"?N=N.mixedAdd(m):N=N.add(m))}}for(c=0;c=Math.ceil((e.bitLength()+1)/r.step):!1};Jc.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";h();var e8e=oc(),ci=Gi(),l7=cr(),bv=j_(),t8e=e8e.assert;function Yc(t){bv.call(this,"short",t),this.a=new ci(t.a,16).toRed(this.red),this.b=new ci(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)}l7(Yc,bv);zY.exports=Yc;Yc.prototype._getEndomorphism=function(e){if(!(!this.zeroA||!this.g||!this.n||this.p.modn(3)!==1)){var r,n;if(e.beta)r=new ci(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 ci(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],t8e(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 ci(a.a,16),b:new ci(a.b,16)}}):s=this._getEndoBasis(n),{beta:r,lambda:n,basis:s}}};Yc.prototype._getEndoRoots=function(e){var r=e===this.p?this.red:ci.mont(e),n=new ci(2).toRed(r).redInvm(),i=n.redNeg(),o=new ci(3).toRed(r).redNeg().redSqrt().redMul(n),s=i.redAdd(o).fromRed(),a=i.redSub(o).fromRed();return[s,a]};Yc.prototype._getEndoBasis=function(e){for(var r=this.n.ushrn(Math.floor(this.n.bitLength()/2)),n=e,i=this.n.clone(),o=new ci(1),s=new ci(0),a=new ci(0),d=new ci(1),u,c,l,m,p,g,b,S=0,A,I;n.cmpn(0)!==0;){var P=i.div(n);A=i.sub(P.mul(n)),I=a.sub(P.mul(o));var $=d.sub(P.mul(s));if(!l&&A.cmp(r)<0)u=b.neg(),c=o,l=A.neg(),m=I;else if(l&&++S===2)break;b=A,i=n,n=A,a=o,o=I,d=s,s=$}p=A.neg(),g=I;var N=l.sqr().add(m.sqr()),L=p.sqr().add(g.sqr());return L.cmp(N)>=0&&(p=u,g=c),l.negative&&(l=l.neg(),m=m.neg()),p.negative&&(p=p.neg(),g=g.neg()),[{a:l,b:m},{a:p,b:g}]};Yc.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),m=u.add(c).neg();return{k1:l,k2:m}};Yc.prototype.pointFromX=function(e,r){e=new ci(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)};Yc.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};Yc.prototype._endoWnafMulAdd=function(e,r,n){for(var i=this._endoWnafT1,o=this._endoWnafT2,s=0;s":""};mo.prototype.isInfinity=function(){return this.inf};mo.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)};mo.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)};mo.prototype.getX=function(){return this.x.fromRed()};mo.prototype.getY=function(){return this.y.fromRed()};mo.prototype.mul=function(e){return e=new ci(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)};mo.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)};mo.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)};mo.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)};mo.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};mo.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 No(t,e,r,n){bv.BasePoint.call(this,t,"jacobian"),e===null&&r===null&&n===null?(this.x=this.curve.one,this.y=this.curve.one,this.z=new ci(0)):(this.x=new ci(e,16),this.y=new ci(r,16),this.z=new ci(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}l7(No,bv.BasePoint);Yc.prototype.jpoint=function(e,r,n){return new No(this,e,r,n)};No.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)};No.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)};No.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),m=i.redMul(c),p=u.redSqr().redIAdd(l).redISub(m).redISub(m),g=u.redMul(m.redISub(p)).redISub(s.redMul(l)),b=this.z.redMul(e.z).redMul(d);return this.curve.jpoint(p,g,b)};No.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),m=d.redSqr().redIAdd(c).redISub(l).redISub(l),p=d.redMul(l.redISub(m)).redISub(o.redMul(c)),g=this.z.redMul(a);return this.curve.jpoint(m,p,g)};No.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}};No.prototype.inspect=function(){return this.isInfinity()?"":""};No.prototype.isInfinity=function(){return this.z.cmpn(0)===0}});var VY=W((Qlt,HY)=>{"use strict";h();var vv=Gi(),WY=cr(),B5=j_(),r8e=oc();function wv(t){B5.call(this,"mont",t),this.a=new vv(t.a,16).toRed(this.red),this.b=new vv(t.b,16).toRed(this.red),this.i4=new vv(4).toRed(this.red).redInvm(),this.two=new vv(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}WY(wv,B5);HY.exports=wv;wv.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 yo(t,e,r){B5.BasePoint.call(this,t,"projective"),e===null&&r===null?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new vv(e,16),this.z=new vv(r,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}WY(yo,B5.BasePoint);wv.prototype.decodePoint=function(e,r){return this.point(r8e.toArray(e,r),1)};wv.prototype.point=function(e,r){return new yo(this,e,r)};wv.prototype.pointFromJSON=function(e){return yo.fromJSON(this,e)};yo.prototype.precompute=function(){};yo.prototype._encode=function(){return this.getX().toArray("be",this.curve.p.byteLength())};yo.fromJSON=function(e,r){return new yo(e,r[0],r[1]||e.one)};yo.prototype.inspect=function(){return this.isInfinity()?"":""};yo.prototype.isInfinity=function(){return this.z.cmpn(0)===0};yo.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)};yo.prototype.add=function(){throw new Error("Not supported on Montgomery curve")};yo.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)};yo.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};yo.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")};yo.prototype.jumlAdd=function(){throw new Error("Not supported on Montgomery curve")};yo.prototype.eq=function(e){return this.getX().cmp(e.getX())===0};yo.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this};yo.prototype.getX=function(){return this.normalize(),this.x.fromRed()}});var ZY=W((tft,YY)=>{"use strict";h();var n8e=oc(),Mf=Gi(),JY=cr(),C5=j_(),i8e=n8e.assert;function rl(t){this.twisted=(t.a|0)!==1,this.mOneA=this.twisted&&(t.a|0)===-1,this.extended=this.mOneA,C5.call(this,"edwards",t),this.a=new Mf(t.a,16).umod(this.red.m),this.a=this.a.toRed(this.red),this.c=new Mf(t.c,16).toRed(this.red),this.c2=this.c.redSqr(),this.d=new Mf(t.d,16).toRed(this.red),this.dd=this.d.redAdd(this.d),i8e(!this.twisted||this.c.fromRed().cmpn(1)===0),this.oneC=(t.c|0)===1}JY(rl,C5);YY.exports=rl;rl.prototype._mulA=function(e){return this.mOneA?e.redNeg():this.a.redMul(e)};rl.prototype._mulC=function(e){return this.oneC?e:this.c.redMul(e)};rl.prototype.jpoint=function(e,r,n,i){return this.point(e,r,n,i)};rl.prototype.pointFromX=function(e,r){e=new Mf(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)};rl.prototype.pointFromY=function(e,r){e=new Mf(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)};rl.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 An(t,e,r,n,i){C5.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 Mf(e,16),this.y=new Mf(r,16),this.z=n?new Mf(n,16):this.curve.one,this.t=i&&new Mf(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()))))}JY(An,C5.BasePoint);rl.prototype.pointFromJSON=function(e){return An.fromJSON(this,e)};rl.prototype.point=function(e,r,n,i){return new An(this,e,r,n,i)};An.fromJSON=function(e,r){return new An(e,r[0],r[1],r[2])};An.prototype.inspect=function(){return this.isInfinity()?"":""};An.prototype.isInfinity=function(){return this.x.cmpn(0)===0&&(this.y.cmp(this.z)===0||this.zOne&&this.y.cmp(this.curve.c)===0)};An.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),m=a.redMul(s);return this.curve.point(u,c,m,l)};An.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)};An.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()};An.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),m=s.redMul(u),p=a.redMul(d);return this.curve.point(c,l,p,m)};An.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,m;return this.curve.twisted?(l=r.redMul(d).redMul(o.redSub(this.curve._mulA(i))),m=a.redMul(d)):(l=r.redMul(d).redMul(o.redSub(i)),m=this.curve._mulC(a).redMul(d)),this.curve.point(c,l,m)};An.prototype.add=function(e){return this.isInfinity()?e:e.isInfinity()?this:this.curve.extended?this._extAdd(e):this._projAdd(e)};An.prototype.mul=function(e){return this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve._wnafMul(this,e)};An.prototype.mulAdd=function(e,r,n){return this.curve._wnafMulAdd(1,[this,r],[e,n],2,!1)};An.prototype.jmulAdd=function(e,r,n){return this.curve._wnafMulAdd(1,[this,r],[e,n],2,!0)};An.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};An.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())};An.prototype.getX=function(){return this.normalize(),this.x.fromRed()};An.prototype.getY=function(){return this.normalize(),this.y.fromRed()};An.prototype.eq=function(e){return this===e||this.getX().cmp(e.getX())===0&&this.getY().cmp(e.getY())===0};An.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}};An.prototype.toP=An.prototype.normalize;An.prototype.mixedAdd=An.prototype.add});var f7=W(XY=>{"use strict";h();var O5=XY;O5.base=j_();O5.short=GY();O5.mont=VY();O5.edwards=ZY()});var Vd=W(gn=>{"use strict";h();var o8e=ic(),s8e=cr();gn.inherits=s8e;function a8e(t,e){return(t.charCodeAt(e)&64512)!==55296||e<0||e+1>=t.length?!1:(t.charCodeAt(e+1)&64512)===56320}function c8e(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):a8e(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}gn.htonl=QY;function u8e(t,e){for(var r="",n=0;n>>0}return o}gn.join32=l8e;function f8e(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}gn.split32=f8e;function h8e(t,e){return t>>>e|t<<32-e}gn.rotr32=h8e;function p8e(t,e){return t<>>32-e}gn.rotl32=p8e;function m8e(t,e){return t+e>>>0}gn.sum32=m8e;function y8e(t,e,r){return t+e+r>>>0}gn.sum32_3=y8e;function g8e(t,e,r,n){return t+e+r+n>>>0}gn.sum32_4=g8e;function b8e(t,e,r,n,i){return t+e+r+n+i>>>0}gn.sum32_5=b8e;function v8e(t,e,r,n){var i=t[e],o=t[e+1],s=n+o>>>0,a=(s>>0,t[e+1]=s}gn.sum64=v8e;function w8e(t,e,r,n){var i=e+n>>>0,o=(i>>0}gn.sum64_hi=w8e;function _8e(t,e,r,n){var i=e+n;return i>>>0}gn.sum64_lo=_8e;function x8e(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}gn.sum64_4_hi=x8e;function E8e(t,e,r,n,i,o,s,a){var d=e+n+o+a;return d>>>0}gn.sum64_4_lo=E8e;function S8e(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}gn.sum64_5_hi=S8e;function A8e(t,e,r,n,i,o,s,a,d,u){var c=e+n+o+a+u;return c>>>0}gn.sum64_5_lo=A8e;function P8e(t,e,r){var n=e<<32-r|t>>>r;return n>>>0}gn.rotr64_hi=P8e;function T8e(t,e,r){var n=t<<32-r|e>>>r;return n>>>0}gn.rotr64_lo=T8e;function I8e(t,e,r){return t>>>r}gn.shr64_hi=I8e;function k8e(t,e,r){var n=t<<32-r|e>>>r;return n>>>0}gn.shr64_lo=k8e});var _v=W(nZ=>{"use strict";h();var rZ=Vd(),R8e=ic();function $5(){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}nZ.BlockHash=$5;$5.prototype.update=function(e,r){if(e=rZ.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=rZ.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";h();var D8e=Vd(),nl=D8e.rotr32;function M8e(t,e,r,n){if(t===0)return iZ(e,r,n);if(t===1||t===3)return sZ(e,r,n);if(t===2)return oZ(e,r,n)}Bf.ft_1=M8e;function iZ(t,e,r){return t&e^~t&r}Bf.ch32=iZ;function oZ(t,e,r){return t&e^t&r^e&r}Bf.maj32=oZ;function sZ(t,e,r){return t^e^r}Bf.p32=sZ;function B8e(t){return nl(t,2)^nl(t,13)^nl(t,22)}Bf.s0_256=B8e;function C8e(t){return nl(t,6)^nl(t,11)^nl(t,25)}Bf.s1_256=C8e;function O8e(t){return nl(t,7)^nl(t,18)^t>>>3}Bf.g0_256=O8e;function $8e(t){return nl(t,17)^nl(t,19)^t>>>10}Bf.g1_256=$8e});var dZ=W((lft,cZ)=>{"use strict";h();var xv=Vd(),N8e=_v(),j8e=h7(),p7=xv.rotl32,U_=xv.sum32,U8e=xv.sum32_5,K8e=j8e.ft_1,aZ=N8e.BlockHash,q8e=[1518500249,1859775393,2400959708,3395469782];function il(){if(!(this instanceof il))return new il;aZ.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}xv.inherits(il,aZ);cZ.exports=il;il.blockSize=512;il.outSize=160;il.hmacStrength=80;il.padLength=64;il.prototype._update=function(e,r){for(var n=this.W,i=0;i<16;i++)n[i]=e[r+i];for(;i{"use strict";h();var Ev=Vd(),L8e=_v(),Sv=h7(),F8e=ic(),Jd=Ev.sum32,z8e=Ev.sum32_4,G8e=Ev.sum32_5,W8e=Sv.ch32,H8e=Sv.maj32,V8e=Sv.s0_256,J8e=Sv.s1_256,Y8e=Sv.g0_256,Z8e=Sv.g1_256,uZ=L8e.BlockHash,X8e=[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 ol(){if(!(this instanceof ol))return new ol;uZ.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=X8e,this.W=new Array(64)}Ev.inherits(ol,uZ);lZ.exports=ol;ol.blockSize=512;ol.outSize=256;ol.hmacStrength=192;ol.padLength=64;ol.prototype._update=function(e,r){for(var n=this.W,i=0;i<16;i++)n[i]=e[r+i];for(;i{"use strict";h();var y7=Vd(),fZ=m7();function Cf(){if(!(this instanceof Cf))return new Cf;fZ.call(this),this.h=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]}y7.inherits(Cf,fZ);hZ.exports=Cf;Cf.blockSize=512;Cf.outSize=224;Cf.hmacStrength=192;Cf.padLength=64;Cf.prototype._digest=function(e){return e==="hex"?y7.toHex32(this.h.slice(0,7),"big"):y7.split32(this.h.slice(0,7),"big")}});var v7=W((gft,bZ)=>{"use strict";h();var xa=Vd(),Q8e=_v(),e4e=ic(),sl=xa.rotr64_hi,al=xa.rotr64_lo,mZ=xa.shr64_hi,yZ=xa.shr64_lo,_p=xa.sum64,g7=xa.sum64_hi,b7=xa.sum64_lo,t4e=xa.sum64_4_hi,r4e=xa.sum64_4_lo,n4e=xa.sum64_5_hi,i4e=xa.sum64_5_lo,gZ=Q8e.BlockHash,o4e=[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 Yd(){if(!(this instanceof Yd))return new Yd;gZ.call(this),this.h=[1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209],this.k=o4e,this.W=new Array(160)}xa.inherits(Yd,gZ);bZ.exports=Yd;Yd.blockSize=1024;Yd.outSize=512;Yd.hmacStrength=192;Yd.padLength=128;Yd.prototype._prepareBlock=function(e,r){for(var n=this.W,i=0;i<32;i++)n[i]=e[r+i];for(;i{"use strict";h();var w7=Vd(),vZ=v7();function Of(){if(!(this instanceof Of))return new Of;vZ.call(this),this.h=[3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]}w7.inherits(Of,vZ);wZ.exports=Of;Of.blockSize=1024;Of.outSize=384;Of.hmacStrength=192;Of.padLength=128;Of.prototype._digest=function(e){return e==="hex"?w7.toHex32(this.h.slice(0,12),"big"):w7.split32(this.h.slice(0,12),"big")}});var xZ=W(Av=>{"use strict";h();Av.sha1=dZ();Av.sha224=pZ();Av.sha256=m7();Av.sha384=_Z();Av.sha512=v7()});var IZ=W(TZ=>{"use strict";h();var n0=Vd(),b4e=_v(),N5=n0.rotl32,EZ=n0.sum32,K_=n0.sum32_3,SZ=n0.sum32_4,PZ=b4e.BlockHash;function cl(){if(!(this instanceof cl))return new cl;PZ.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.endian="little"}n0.inherits(cl,PZ);TZ.ripemd160=cl;cl.blockSize=512;cl.outSize=160;cl.hmacStrength=192;cl.padLength=64;cl.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,m=a,p=0;p<80;p++){var g=EZ(N5(SZ(n,AZ(p,i,o,s),e[_4e[p]+r],v4e(p)),E4e[p]),a);n=a,a=s,s=N5(o,10),o=i,i=g,g=EZ(N5(SZ(d,AZ(79-p,u,c,l),e[x4e[p]+r],w4e(p)),S4e[p]),m),d=m,m=l,l=N5(c,10),c=u,u=g}g=K_(this.h[1],o,l),this.h[1]=K_(this.h[2],s,m),this.h[2]=K_(this.h[3],a,d),this.h[3]=K_(this.h[4],n,u),this.h[4]=K_(this.h[0],i,c),this.h[0]=g};cl.prototype._digest=function(e){return e==="hex"?n0.toHex32(this.h,"little"):n0.split32(this.h,"little")};function AZ(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 v4e(t){return t<=15?0:t<=31?1518500249:t<=47?1859775393:t<=63?2400959708:2840853838}function w4e(t){return t<=15?1352829926:t<=31?1548603684:t<=47?1836072691:t<=63?2053994217:0}var _4e=[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],x4e=[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],E4e=[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],S4e=[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 RZ=W((Aft,kZ)=>{"use strict";h();var A4e=Vd(),P4e=ic();function Pv(t,e,r){if(!(this instanceof Pv))return new Pv(t,e,r);this.Hash=t,this.blockSize=t.blockSize/8,this.outSize=t.outSize/8,this.inner=null,this.outer=null,this._init(A4e.toArray(e,r))}kZ.exports=Pv;Pv.prototype._init=function(e){e.length>this.blockSize&&(e=new this.Hash().update(e).digest()),P4e(e.length<=this.blockSize);for(var r=e.length;r{h();var jo=DZ;jo.utils=Vd();jo.common=_v();jo.sha=xZ();jo.ripemd=IZ();jo.hmac=RZ();jo.sha1=jo.sha.sha1;jo.sha256=jo.sha.sha256;jo.sha224=jo.sha.sha224;jo.sha384=jo.sha.sha384;jo.sha512=jo.sha.sha512;jo.ripemd160=jo.ripemd.ripemd160});var BZ=W((kft,MZ)=>{h();MZ.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 U5=W($Z=>{"use strict";h();var x7=$Z,xp=j5(),_7=f7(),T4e=oc(),CZ=T4e.assert;function OZ(t){t.type==="short"?this.curve=new _7.short(t):t.type==="edwards"?this.curve=new _7.edwards(t):this.curve=new _7.mont(t),this.g=this.curve.g,this.n=this.curve.n,this.hash=t.hash,CZ(this.g.validate(),"Invalid curve"),CZ(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}x7.PresetCurve=OZ;function Ep(t,e){Object.defineProperty(x7,t,{configurable:!0,enumerable:!0,get:function(){var r=new OZ(e);return Object.defineProperty(x7,t,{configurable:!0,enumerable:!0,value:r}),r}})}Ep("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:xp.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]});Ep("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:xp.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]});Ep("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:xp.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]});Ep("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:xp.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"]});Ep("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:xp.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"]});Ep("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:xp.sha256,gRed:!1,g:["9"]});Ep("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:xp.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});var E7;try{E7=BZ()}catch{E7=void 0}Ep("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:xp.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",E7]})});var UZ=W((Bft,jZ)=>{"use strict";h();var I4e=j5(),i0=u7(),NZ=ic();function Sp(t){if(!(this instanceof Sp))return new Sp(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=i0.toArray(t.entropy,t.entropyEnc||"hex"),r=i0.toArray(t.nonce,t.nonceEnc||"hex"),n=i0.toArray(t.pers,t.persEnc||"hex");NZ(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(e,r,n)}jZ.exports=Sp;Sp.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};Sp.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=i0.toArray(n,i||"hex"),this._update(n));for(var o=[];o.length{"use strict";h();var k4e=Gi(),R4e=oc(),S7=R4e.assert;function Ps(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)}KZ.exports=Ps;Ps.fromPublic=function(e,r,n){return r instanceof Ps?r:new Ps(e,{pub:r,pubEnc:n})};Ps.fromPrivate=function(e,r,n){return r instanceof Ps?r:new Ps(e,{priv:r,privEnc:n})};Ps.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"}};Ps.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};Ps.prototype.getPrivate=function(e){return e==="hex"?this.priv.toString(16,2):this.priv};Ps.prototype._importPrivate=function(e,r){this.priv=new k4e(e,r||16),this.priv=this.priv.umod(this.ec.curve.n)};Ps.prototype._importPublic=function(e,r){if(e.x||e.y){this.ec.curve.type==="mont"?S7(e.x,"Need x coordinate"):(this.ec.curve.type==="short"||this.ec.curve.type==="edwards")&&S7(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)};Ps.prototype.derive=function(e){return e.validate()||S7(e.validate(),"public point not validated"),e.mul(this.priv).getX()};Ps.prototype.sign=function(e,r,n){return this.ec.sign(e,this,r,n)};Ps.prototype.verify=function(e,r){return this.ec.verify(e,r,this)};Ps.prototype.inspect=function(){return""}});var zZ=W((Nft,FZ)=>{"use strict";h();var K5=Gi(),T7=oc(),D4e=T7.assert;function q5(t,e){if(t instanceof q5)return t;this._importDER(t,e)||(D4e(t.r&&t.s,"Signature without r or s"),this.r=new K5(t.r,16),this.s=new K5(t.s,16),t.recoveryParam===void 0?this.recoveryParam=null:this.recoveryParam=t.recoveryParam)}FZ.exports=q5;function M4e(){this.place=0}function A7(t,e){var r=t[e.place++];if(!(r&128))return r;var n=r&15;if(n===0||n>4)return!1;for(var i=0,o=0,s=e.place;o>>=0;return i<=127?!1:(e.place=s,i)}function LZ(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)}q5.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=LZ(r),n=LZ(n);!n[0]&&!(n[1]&128);)n=n.slice(1);var i=[2];P7(i,r.length),i=i.concat(r),i.push(2),P7(i,n.length);var o=i.concat(n),s=[48];return P7(s,o.length),s=s.concat(o),T7.encode(s,e)}});var VZ=W((Uft,HZ)=>{"use strict";h();var o0=Gi(),GZ=UZ(),B4e=oc(),I7=U5(),C4e=E5(),WZ=B4e.assert,k7=qZ(),L5=zZ();function Zc(t){if(!(this instanceof Zc))return new Zc(t);typeof t=="string"&&(WZ(Object.prototype.hasOwnProperty.call(I7,t),"Unknown curve "+t),t=I7[t]),t instanceof I7.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}HZ.exports=Zc;Zc.prototype.keyPair=function(e){return new k7(this,e)};Zc.prototype.keyFromPrivate=function(e,r){return k7.fromPrivate(this,e,r)};Zc.prototype.keyFromPublic=function(e,r){return k7.fromPublic(this,e,r)};Zc.prototype.genKeyPair=function(e){e||(e={});for(var r=new GZ({hash:this.hash,pers:e.pers,persEnc:e.persEnc||"utf8",entropy:e.entropy||C4e(this.hash.hmacStrength),entropyEnc:e.entropy&&e.entropyEnc||"utf8",nonce:this.n.toArray()}),n=this.n.byteLength(),i=this.n.sub(new o0(2));;){var o=new o0(r.generate(n));if(!(o.cmp(i)>0))return o.iaddn(1),this.keyFromPrivate(o)}};Zc.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};Zc.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 o0(e,16));for(var o=this.n.byteLength(),s=r.getPrivate().toArray("be",o),a=e.toArray("be",o),d=new GZ({hash:this.hash,entropy:s,nonce:a,pers:i.pers,persEnc:i.persEnc||"utf8"}),u=this.n.sub(new o0(1)),c=0;;c++){var l=i.k?i.k(c):new o0(d.generate(this.n.byteLength()));if(l=this._truncateToN(l,!0),!(l.cmpn(1)<=0||l.cmp(u)>=0)){var m=this.g.mul(l);if(!m.isInfinity()){var p=m.getX(),g=p.umod(this.n);if(g.cmpn(0)!==0){var b=l.invm(this.n).mul(g.mul(r.getPrivate()).iadd(e));if(b=b.umod(this.n),b.cmpn(0)!==0){var S=(m.getY().isOdd()?1:0)|(p.cmp(g)!==0?2:0);return i.canonical&&b.cmp(this.nh)>0&&(b=this.n.sub(b),S^=1),new L5({r:g,s:b,recoveryParam:S})}}}}}};Zc.prototype.verify=function(e,r,n,i){e=this._truncateToN(new o0(e,16)),n=this.keyFromPublic(n,i),r=new L5(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)};Zc.prototype.recoverPubKey=function(t,e,r,n){WZ((3&r)===r,"The recovery param is more than two bits"),e=new L5(e,n);var i=this.n,o=new o0(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),m=a.mul(c).umod(i);return this.g.mulAdd(l,s,m)};Zc.prototype.getKeyRecoveryParam=function(t,e,r,n){if(e=new L5(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 XZ=W((qft,ZZ)=>{"use strict";h();var q_=oc(),YZ=q_.assert,JZ=q_.parseBytes,Tv=q_.cachedProperty;function go(t,e){this.eddsa=t,this._secret=JZ(e.secret),t.isPoint(e.pub)?this._pub=e.pub:this._pubBytes=JZ(e.pub)}go.fromPublic=function(e,r){return r instanceof go?r:new go(e,{pub:r})};go.fromSecret=function(e,r){return r instanceof go?r:new go(e,{secret:r})};go.prototype.secret=function(){return this._secret};Tv(go,"pubBytes",function(){return this.eddsa.encodePoint(this.pub())});Tv(go,"pub",function(){return this._pubBytes?this.eddsa.decodePoint(this._pubBytes):this.eddsa.g.mul(this.priv())});Tv(go,"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});Tv(go,"priv",function(){return this.eddsa.decodeInt(this.privBytes())});Tv(go,"hash",function(){return this.eddsa.hash().update(this.secret()).digest()});Tv(go,"messagePrefix",function(){return this.hash().slice(this.eddsa.encodingLength)});go.prototype.sign=function(e){return YZ(this._secret,"KeyPair can only verify"),this.eddsa.sign(e,this)};go.prototype.verify=function(e,r){return this.eddsa.verify(e,r,this)};go.prototype.getSecret=function(e){return YZ(this._secret,"KeyPair is public only"),q_.encode(this.secret(),e)};go.prototype.getPublic=function(e){return q_.encode(this.pubBytes(),e)};ZZ.exports=go});var eX=W((Fft,QZ)=>{"use strict";h();var O4e=Gi(),F5=oc(),$4e=F5.assert,z5=F5.cachedProperty,N4e=F5.parseBytes;function s0(t,e){this.eddsa=t,typeof e!="object"&&(e=N4e(e)),Array.isArray(e)&&(e={R:e.slice(0,t.encodingLength),S:e.slice(t.encodingLength)}),$4e(e.R&&e.S,"Signature without R or S"),t.isPoint(e.R)&&(this._R=e.R),e.S instanceof O4e&&(this._S=e.S),this._Rencoded=Array.isArray(e.R)?e.R:e.Rencoded,this._Sencoded=Array.isArray(e.S)?e.S:e.Sencoded}z5(s0,"S",function(){return this.eddsa.decodeInt(this.Sencoded())});z5(s0,"R",function(){return this.eddsa.decodePoint(this.Rencoded())});z5(s0,"Rencoded",function(){return this.eddsa.encodePoint(this.R())});z5(s0,"Sencoded",function(){return this.eddsa.encodeInt(this.S())});s0.prototype.toBytes=function(){return this.Rencoded().concat(this.Sencoded())};s0.prototype.toHex=function(){return F5.encode(this.toBytes(),"hex").toUpperCase()};QZ.exports=s0});var oX=W((Gft,iX)=>{"use strict";h();var j4e=j5(),U4e=U5(),Iv=oc(),K4e=Iv.assert,rX=Iv.parseBytes,nX=XZ(),tX=eX();function Ea(t){if(K4e(t==="ed25519","only tested with ed25519 so far"),!(this instanceof Ea))return new Ea(t);t=U4e[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=j4e.sha512}iX.exports=Ea;Ea.prototype.sign=function(e,r){e=rX(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})};Ea.prototype.verify=function(e,r,n){e=rX(e),r=this.makeSignature(r);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)};Ea.prototype.hashInt=function(){for(var e=this.hash(),r=0;r{"use strict";h();var a0=sX;a0.version=jY().version;a0.utils=oc();a0.rand=E5();a0.curve=f7();a0.curves=U5();a0.ec=VZ();a0.eddsa=oX()});var H5=W((Jft,aX)=>{"use strict";h();var W5=Un(),kv=W5.Buffer,Xc={},Qc;for(Qc in W5)W5.hasOwnProperty(Qc)&&(Qc==="SlowBuffer"||Qc==="Buffer"||(Xc[Qc]=W5[Qc]));var Rv=Xc.Buffer={};for(Qc in kv)kv.hasOwnProperty(Qc)&&(Qc==="allocUnsafe"||Qc==="allocUnsafeSlow"||(Rv[Qc]=kv[Qc]));Xc.Buffer.prototype=kv.prototype;(!Rv.from||Rv.from===Uint8Array.from)&&(Rv.from=function(t,e,r){if(typeof t=="number")throw new TypeError('The "value" argument must not be of type number. Received type '+typeof t);if(t&&typeof t.length>"u")throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);return kv(t,e,r)});Rv.alloc||(Rv.alloc=function(t,e,r){if(typeof t!="number")throw new TypeError('The "size" argument must be of type number. Received type '+typeof t);if(t<0||t>=2*(1<<30))throw new RangeError('The value "'+t+'" is invalid for option "size"');var n=kv(t);return!e||e.length===0?n.fill(0):typeof r=="string"?n.fill(e,r):n.fill(e),n});if(!Xc.kStringMaxLength)try{Xc.kStringMaxLength=B.default.binding("buffer").kStringMaxLength}catch{}Xc.constants||(Xc.constants={MAX_LENGTH:Xc.kMaxLength},Xc.kStringMaxLength&&(Xc.constants.MAX_STRING_LENGTH=Xc.kStringMaxLength));aX.exports=Xc});var V5=W(cX=>{"use strict";h();var q4e=cr();function ed(t){this._reporterState={obj:null,path:[],options:t||{},errors:[]}}cX.Reporter=ed;ed.prototype.isError=function(e){return e instanceof Dv};ed.prototype.save=function(){let e=this._reporterState;return{obj:e.obj,pathLen:e.path.length}};ed.prototype.restore=function(e){let r=this._reporterState;r.obj=e.obj,r.path=r.path.slice(0,e.pathLen)};ed.prototype.enterKey=function(e){return this._reporterState.path.push(e)};ed.prototype.exitKey=function(e){let r=this._reporterState;r.path=r.path.slice(0,e-1)};ed.prototype.leaveKey=function(e,r,n){let i=this._reporterState;this.exitKey(e),i.obj!==null&&(i.obj[r]=n)};ed.prototype.path=function(){return this._reporterState.path.join("/")};ed.prototype.enterObject=function(){let e=this._reporterState,r=e.obj;return e.obj={},r};ed.prototype.leaveObject=function(e){let r=this._reporterState,n=r.obj;return r.obj=e,n};ed.prototype.error=function(e){let r,n=this._reporterState,i=e instanceof Dv;if(i?r=e:r=new Dv(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};ed.prototype.wrapResult=function(e){let r=this._reporterState;return r.options.partial?{result:this.isError(e)?null:e,errors:r.errors}:e};function Dv(t,e){this.path=t,this.rethrow(e)}q4e(Dv,Error);Dv.prototype.rethrow=function(e){if(this.message=e+" at: "+(this.path||"(shallow)"),Error.captureStackTrace&&Error.captureStackTrace(this,Dv),!this.stack)try{throw new Error(this.message)}catch(r){this.stack=r.stack}return this}});var Cv=W(R7=>{"use strict";h();var L4e=cr(),J5=V5().Reporter,Mv=H5().Buffer;function td(t,e){if(J5.call(this,e),!Mv.isBuffer(t)){this.error("Input not Buffer");return}this.base=t,this.offset=0,this.length=t.length}L4e(td,J5);R7.DecoderBuffer=td;td.isDecoderBuffer=function(e){return e instanceof td?!0:typeof e=="object"&&Mv.isBuffer(e.base)&&e.constructor.name==="DecoderBuffer"&&typeof e.offset=="number"&&typeof e.length=="number"&&typeof e.save=="function"&&typeof e.restore=="function"&&typeof e.isEmpty=="function"&&typeof e.readUInt8=="function"&&typeof e.skip=="function"&&typeof e.raw=="function"};td.prototype.save=function(){return{offset:this.offset,reporter:J5.prototype.save.call(this)}};td.prototype.restore=function(e){let r=new td(this.base);return r.offset=e.offset,r.length=this.offset,this.offset=e.offset,J5.prototype.restore.call(this,e.reporter),r};td.prototype.isEmpty=function(){return this.offset===this.length};td.prototype.readUInt8=function(e){return this.offset+1<=this.length?this.base.readUInt8(this.offset++,!0):this.error(e||"DecoderBuffer overrun")};td.prototype.skip=function(e,r){if(!(this.offset+e<=this.length))return this.error(r||"DecoderBuffer overrun");let n=new td(this.base);return n._reporterState=this._reporterState,n.offset=this.offset,n.length=this.offset+e,this.offset+=e,n};td.prototype.raw=function(e){return this.base.slice(e?e.offset:this.offset,this.length)};function Bv(t,e){if(Array.isArray(t))this.length=0,this.value=t.map(function(r){return Bv.isEncoderBuffer(r)||(r=new Bv(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=Mv.byteLength(t);else if(Mv.isBuffer(t))this.value=t,this.length=t.length;else return e.error("Unsupported type: "+typeof t)}R7.EncoderBuffer=Bv;Bv.isEncoderBuffer=function(e){return e instanceof Bv?!0:typeof e=="object"&&e.constructor.name==="EncoderBuffer"&&typeof e.length=="number"&&typeof e.join=="function"};Bv.prototype.join=function(e,r){return e||(e=Mv.alloc(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):Mv.isBuffer(this.value)&&this.value.copy(e,r),r+=this.length)),e}});var Y5=W((tht,uX)=>{"use strict";h();var F4e=V5().Reporter,z4e=Cv().EncoderBuffer,G4e=Cv().DecoderBuffer,Js=ic(),dX=["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"],W4e=["key","obj","use","optional","explicit","implicit","def","choice","any","contains"].concat(dX),H4e=["_peekTag","_decodeTag","_use","_decodeStr","_decodeObjid","_decodeTime","_decodeNull","_decodeInt","_decodeBool","_decodeList","_encodeComposite","_encodeStr","_encodeObjid","_encodeTime","_encodeNull","_encodeInt","_encodeBool"];function ln(t,e,r){let n={};this._baseState=n,n.name=r,n.enc=t,n.parent=e||null,n.children=null,n.tag=null,n.args=null,n.reverseArgs=null,n.choice=null,n.optional=!1,n.any=!1,n.obj=!1,n.use=null,n.useDecoder=null,n.key=null,n.default=null,n.explicit=null,n.implicit=null,n.contains=null,n.parent||(n.children=[],this._wrap())}uX.exports=ln;var V4e=["enc","parent","children","tag","args","reverseArgs","choice","optional","any","obj","use","alteredUse","key","default","explicit","implicit","contains"];ln.prototype.clone=function(){let e=this._baseState,r={};V4e.forEach(function(i){r[i]=e[i]});let n=new this.constructor(r.parent);return n._baseState=r,n};ln.prototype._wrap=function(){let e=this._baseState;W4e.forEach(function(r){this[r]=function(){let i=new this.constructor(this);return e.children.push(i),i[r].apply(i,arguments)}},this)};ln.prototype._init=function(e){let r=this._baseState;Js(r.parent===null),e.call(this),r.children=r.children.filter(function(n){return n._baseState.parent===this},this),Js.equal(r.children.length,1,"Root node can have only one child")};ln.prototype._useArgs=function(e){let 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&&(Js(r.children===null),r.children=n,n.forEach(function(i){i._baseState.parent=this},this)),e.length!==0&&(Js(r.args===null),r.args=e,r.reverseArgs=e.map(function(i){if(typeof i!="object"||i.constructor!==Object)return i;let o={};return Object.keys(i).forEach(function(s){s==(s|0)&&(s|=0);let a=i[s];o[a]=s}),o}))};H4e.forEach(function(t){ln.prototype[t]=function(){let r=this._baseState;throw new Error(t+" not implemented for encoding: "+r.enc)}});dX.forEach(function(t){ln.prototype[t]=function(){let r=this._baseState,n=Array.prototype.slice.call(arguments);return Js(r.tag===null),r.tag=t,this._useArgs(n),this}});ln.prototype.use=function(e){Js(e);let r=this._baseState;return Js(r.use===null),r.use=e,this};ln.prototype.optional=function(){let e=this._baseState;return e.optional=!0,this};ln.prototype.def=function(e){let r=this._baseState;return Js(r.default===null),r.default=e,r.optional=!0,this};ln.prototype.explicit=function(e){let r=this._baseState;return Js(r.explicit===null&&r.implicit===null),r.explicit=e,this};ln.prototype.implicit=function(e){let r=this._baseState;return Js(r.explicit===null&&r.implicit===null),r.implicit=e,this};ln.prototype.obj=function(){let e=this._baseState,r=Array.prototype.slice.call(arguments);return e.obj=!0,r.length!==0&&this._useArgs(r),this};ln.prototype.key=function(e){let r=this._baseState;return Js(r.key===null),r.key=e,this};ln.prototype.any=function(){let e=this._baseState;return e.any=!0,this};ln.prototype.choice=function(e){let r=this._baseState;return Js(r.choice===null),r.choice=e,this._useArgs(Object.keys(e).map(function(n){return e[n]})),this};ln.prototype.contains=function(e){let r=this._baseState;return Js(r.use===null),r.contains=e,this};ln.prototype._decode=function(e,r){let n=this._baseState;if(n.parent===null)return e.wrapResult(n.children[0]._decode(e,r));let i=n.default,o=!0,s=null;if(n.key!==null&&(s=e.enterKey(n.key)),n.optional){let d=null;if(n.explicit!==null?d=n.explicit:n.implicit!==null?d=n.implicit:n.tag!==null&&(d=n.tag),d===null&&!n.any){let u=e.save();try{n.choice===null?this._decodeGeneric(n.tag,e,r):this._decodeChoice(e,r),o=!0}catch{o=!1}e.restore(u)}else if(o=this._peekTag(e,d,n.any),e.isError(o))return o}let a;if(n.obj&&o&&(a=e.enterObject()),o){if(n.explicit!==null){let u=this._decodeTag(e,n.explicit);if(e.isError(u))return u;e=u}let d=e.offset;if(n.use===null&&n.choice===null){let u;n.any&&(u=e.save());let c=this._decodeTag(e,n.implicit!==null?n.implicit:n.tag,n.any);if(e.isError(c))return c;n.any?i=e.raw(u):e=c}if(r&&r.track&&n.tag!==null&&r.track(e.path(),d,e.length,"tagged"),r&&r.track&&n.tag!==null&&r.track(e.path(),e.offset,e.length,"content"),n.any||(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(c){c._decode(e,r)}),n.contains&&(n.tag==="octstr"||n.tag==="bitstr")){let u=new G4e(i);i=this._getUse(n.contains,e._reporterState.obj)._decode(u,r)}}return n.obj&&o&&(i=e.leaveObject(a)),n.key!==null&&(i!==null||o===!0)?e.leaveKey(s,n.key,i):s!==null&&e.exitKey(s),i};ln.prototype._decodeGeneric=function(e,r,n){let 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)};ln.prototype._getUse=function(e,r){let n=this._baseState;return n.useDecoder=this._use(e,r),Js(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};ln.prototype._decodeChoice=function(e,r){let n=this._baseState,i=null,o=!1;return Object.keys(n.choice).some(function(s){let a=e.save(),d=n.choice[s];try{let 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")};ln.prototype._createEncoderBuffer=function(e){return new z4e(e,this.reporter)};ln.prototype._encode=function(e,r,n){let i=this._baseState;if(i.default!==null&&i.default===e)return;let o=this._encodeValue(e,r,n);if(o!==void 0&&!this._skipDefault(o,r,n))return o};ln.prototype._encodeValue=function(e,r,n){let i=this._baseState;if(i.parent===null)return i.children[0]._encode(e,r||new F4e);let o=null;if(this.reporter=r,i.optional&&e===void 0)if(i.default!==null)e=i.default;else return;let s=null,a=!1;if(i.any)o=this._createEncoderBuffer(e);else if(i.choice)o=this._encodeChoice(e,r);else if(i.contains)s=this._getUse(i.contains,n)._encode(e,r),a=!0;else if(i.children)s=i.children.map(function(d){if(d._baseState.tag==="null_")return d._encode(null,r,e);if(d._baseState.key===null)return r.error("Child should have a key");let u=r.enterKey(d._baseState.key);if(typeof e!="object")return r.error("Child expected, but input is not object");let c=d._encode(e[d._baseState.key],r,e);return r.leaveKey(u),c},this).filter(function(d){return d}),s=this._createEncoderBuffer(s);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");let d=this.clone();d._baseState.implicit=null,s=this._createEncoderBuffer(e.map(function(u){let c=this._baseState;return this._getUse(c.args[0],e)._encode(u,r)},d))}else i.use!==null?o=this._getUse(i.use,n)._encode(e,r):(s=this._encodePrimitive(i.tag,e),a=!0);if(!i.any&&i.choice===null){let d=i.implicit!==null?i.implicit:i.tag,u=i.implicit===null?"universal":"context";d===null?i.use===null&&r.error("Tag could be omitted only for .use()"):i.use===null&&(o=this._encodeComposite(d,a,u,s))}return i.explicit!==null&&(o=this._encodeComposite(i.explicit,!1,"context",o)),o};ln.prototype._encodeChoice=function(e,r){let n=this._baseState,i=n.choice[e.type];return i||Js(!1,e.type+" not found in "+JSON.stringify(Object.keys(n.choice))),i._encode(e.value,r)};ln.prototype._encodePrimitive=function(e,r){let 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)};ln.prototype._isNumstr=function(e){return/^[0-9 ]*$/.test(e)};ln.prototype._isPrintstr=function(e){return/^[A-Za-z0-9 '()+,-./:=?]*$/.test(e)}});var Z5=W(c0=>{"use strict";h();function lX(t){let e={};return Object.keys(t).forEach(function(r){(r|0)==r&&(r=r|0);let n=t[r];e[n]=r}),e}c0.tagClass={0:"universal",1:"application",2:"context",3:"private"};c0.tagClassByName=lX(c0.tagClass);c0.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"};c0.tagByName=lX(c0.tag)});var M7=W((oht,pX)=>{"use strict";h();var J4e=cr(),$f=H5().Buffer,fX=Y5(),D7=Z5();function hX(t){this.enc="der",this.name=t.name,this.entity=t,this.tree=new Zd,this.tree._init(t.body)}pX.exports=hX;hX.prototype.encode=function(e,r){return this.tree._encode(e,r).join()};function Zd(t){fX.call(this,"der",t)}J4e(Zd,fX);Zd.prototype._encodeComposite=function(e,r,n,i){let o=Y4e(e,r,n,this.reporter);if(i.length<128){let d=$f.alloc(2);return d[0]=o,d[1]=i.length,this._createEncoderBuffer([d,i])}let s=1;for(let d=i.length;d>=256;d>>=8)s++;let a=$f.alloc(2+s);a[0]=o,a[1]=128|s;for(let d=1+s,u=i.length;u>0;d--,u>>=8)a[d]=u&255;return this._createEncoderBuffer([a,i])};Zd.prototype._encodeStr=function(e,r){if(r==="bitstr")return this._createEncoderBuffer([e.unused|0,e.data]);if(r==="bmpstr"){let n=$f.alloc(e.length*2);for(let i=0;i=40)return this.reporter.error("Second objid identifier OOB");e.splice(0,2,e[0]*40+e[1])}let i=0;for(let a=0;a=128;d>>=7)i++}let o=$f.alloc(i),s=o.length-1;for(let a=e.length-1;a>=0;a--){let d=e[a];for(o[s--]=d&127;(d>>=7)>0;)o[s--]=128|d&127}return this._createEncoderBuffer(o)};function rd(t){return t<10?"0"+t:t}Zd.prototype._encodeTime=function(e,r){let n,i=new Date(e);return r==="gentime"?n=[rd(i.getUTCFullYear()),rd(i.getUTCMonth()+1),rd(i.getUTCDate()),rd(i.getUTCHours()),rd(i.getUTCMinutes()),rd(i.getUTCSeconds()),"Z"].join(""):r==="utctime"?n=[rd(i.getUTCFullYear()%100),rd(i.getUTCMonth()+1),rd(i.getUTCDate()),rd(i.getUTCHours()),rd(i.getUTCMinutes()),rd(i.getUTCSeconds()),"Z"].join(""):this.reporter.error("Encoding "+r+" time is not supported yet"),this._encodeStr(n,"octstr")};Zd.prototype._encodeNull=function(){return this._createEncoderBuffer("")};Zd.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"&&!$f.isBuffer(e)){let o=e.toArray();!e.sign&&o[0]&128&&o.unshift(0),e=$f.from(o)}if($f.isBuffer(e)){let o=e.length;e.length===0&&o++;let s=$f.alloc(o);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]);let n=1;for(let o=e;o>=256;o>>=8)n++;let i=new Array(n);for(let o=i.length-1;o>=0;o--)i[o]=e&255,e>>=8;return i[0]&128&&i.unshift(0),this._createEncoderBuffer($f.from(i))};Zd.prototype._encodeBool=function(e){return this._createEncoderBuffer(e?255:0)};Zd.prototype._use=function(e,r){return typeof e=="function"&&(e=e(r)),e._getEncoder("der").tree};Zd.prototype._skipDefault=function(e,r,n){let i=this._baseState,o;if(i.default===null)return!1;let 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|=D7.tagClassByName[r||"universal"]<<6,i)}});var yX=W((aht,mX)=>{"use strict";h();var Z4e=cr(),B7=M7();function C7(t){B7.call(this,t),this.enc="pem"}Z4e(C7,B7);mX.exports=C7;C7.prototype.encode=function(e,r){let i=B7.prototype.encode.call(this,e).toString("base64"),o=["-----BEGIN "+r.label+"-----"];for(let s=0;s{"use strict";h();var gX=bX;gX.der=M7();gX.pem=yX()});var N7=W((lht,SX)=>{"use strict";h();var X4e=cr(),Q4e=Gi(),vX=Cv().DecoderBuffer,_X=Y5(),wX=Z5();function xX(t){this.enc="der",this.name=t.name,this.entity=t,this.tree=new sc,this.tree._init(t.body)}SX.exports=xX;xX.prototype.decode=function(e,r){return vX.isDecoderBuffer(e)||(e=new vX(e,r)),this.tree._decode(e,r)};function sc(t){_X.call(this,"der",t)}X4e(sc,_X);sc.prototype._peekTag=function(e,r,n){if(e.isEmpty())return!1;let i=e.save(),o=$7(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)};sc.prototype._decodeTag=function(e,r,n){let i=$7(e,'Failed to decode tag of "'+r+'"');if(e.isError(i))return i;let o=EX(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+'"');let 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+'"'))};sc.prototype._skipUntilEnd=function(e,r){for(;;){let n=$7(e,r);if(e.isError(n))return n;let i=EX(e,n.primitive,r);if(e.isError(i))return i;let 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}};sc.prototype._decodeList=function(e,r,n,i){let o=[];for(;!e.isEmpty();){let s=this._peekTag(e,"end");if(e.isError(s))return s;let a=n.decode(e,"der",i);if(e.isError(a)&&s)break;o.push(a)}return o};sc.prototype._decodeStr=function(e,r){if(r==="bitstr"){let n=e.readUInt8();return e.isError(n)?n:{unused:n,data:e.raw()}}else if(r==="bmpstr"){let n=e.raw();if(n.length%2===1)return e.error("Decoding of string type: bmpstr length mismatch");let i="";for(let o=0;o>6],i=(r&32)===0;if((r&31)===31){let s=r;for(r=0;(s&128)===128;){if(s=t.readUInt8(e),t.isError(s))return s;r<<=7,r|=s&127}}else r&=31;let o=wX.tag[r];return{cls:n,primitive:i,tag:r,tagStr:o}}function EX(t,e,r){let n=t.readUInt8(r);if(t.isError(n))return n;if(!e&&n===128)return null;if(!(n&128))return n;let i=n&127;if(i>4)return t.error("length octect is too long");n=0;for(let o=0;o{"use strict";h();var eAe=cr(),tAe=H5().Buffer,j7=N7();function U7(t){j7.call(this,t),this.enc="pem"}eAe(U7,j7);AX.exports=U7;U7.prototype.decode=function(e,r){let n=e.toString().split(/[\r\n]+/g),i=r.label.toUpperCase(),o=/^-----(BEGIN|END) ([^-]+)-----$/,s=-1,a=-1;for(let c=0;c{"use strict";h();var TX=IX;TX.der=N7();TX.pem=PX()});var RX=W(kX=>{"use strict";h();var rAe=O7(),nAe=K7(),iAe=cr(),oAe=kX;oAe.define=function(e,r){return new Ov(e,r)};function Ov(t,e){this.name=t,this.body=e,this.decoders={},this.encoders={}}Ov.prototype._createNamed=function(e){let r=this.name;function n(i){this._initNamed(i,r)}return iAe(n,e),n.prototype._initNamed=function(o,s){e.call(this,o,s)},new n(this)};Ov.prototype._getDecoder=function(e){return e=e||"der",this.decoders.hasOwnProperty(e)||(this.decoders[e]=this._createNamed(nAe[e])),this.decoders[e]};Ov.prototype.decode=function(e,r,n){return this._getDecoder(r).decode(e,n)};Ov.prototype._getEncoder=function(e){return e=e||"der",this.encoders.hasOwnProperty(e)||(this.encoders[e]=this._createNamed(rAe[e])),this.encoders[e]};Ov.prototype.encode=function(e,r,n){return this._getEncoder(r).encode(e,n)}});var MX=W(DX=>{"use strict";h();var X5=DX;X5.Reporter=V5().Reporter;X5.DecoderBuffer=Cv().DecoderBuffer;X5.EncoderBuffer=Cv().EncoderBuffer;X5.Node=Y5()});var OX=W(CX=>{"use strict";h();var BX=CX;BX._reverse=function(e){let r={};return Object.keys(e).forEach(function(n){(n|0)==n&&(n=n|0);let i=e[n];r[i]=n}),r};BX.der=Z5()});var q7=W($X=>{"use strict";h();var $v=$X;$v.bignum=Gi();$v.define=RX().define;$v.base=MX();$v.constants=OX();$v.decoders=K7();$v.encoders=O7()});var KX=W((Aht,UX)=>{"use strict";h();var Xd=q7(),NX=Xd.define("Time",function(){this.choice({utcTime:this.utctime(),generalTime:this.gentime()})}),sAe=Xd.define("AttributeTypeValue",function(){this.seq().obj(this.key("type").objid(),this.key("value").any())}),L7=Xd.define("AlgorithmIdentifier",function(){this.seq().obj(this.key("algorithm").objid(),this.key("parameters").optional(),this.key("curve").objid().optional())}),aAe=Xd.define("SubjectPublicKeyInfo",function(){this.seq().obj(this.key("algorithm").use(L7),this.key("subjectPublicKey").bitstr())}),cAe=Xd.define("RelativeDistinguishedName",function(){this.setof(sAe)}),dAe=Xd.define("RDNSequence",function(){this.seqof(cAe)}),jX=Xd.define("Name",function(){this.choice({rdnSequence:this.use(dAe)})}),uAe=Xd.define("Validity",function(){this.seq().obj(this.key("notBefore").use(NX),this.key("notAfter").use(NX))}),lAe=Xd.define("Extension",function(){this.seq().obj(this.key("extnID").objid(),this.key("critical").bool().def(!1),this.key("extnValue").octstr())}),fAe=Xd.define("TBSCertificate",function(){this.seq().obj(this.key("version").explicit(0).int().optional(),this.key("serialNumber").int(),this.key("signature").use(L7),this.key("issuer").use(jX),this.key("validity").use(uAe),this.key("subject").use(jX),this.key("subjectPublicKeyInfo").use(aAe),this.key("issuerUniqueID").implicit(1).bitstr().optional(),this.key("subjectUniqueID").implicit(2).bitstr().optional(),this.key("extensions").explicit(3).seqof(lAe).optional())}),hAe=Xd.define("X509Certificate",function(){this.seq().obj(this.key("tbsCertificate").use(fAe),this.key("signatureAlgorithm").use(L7),this.key("signatureValue").bitstr())});UX.exports=hAe});var LX=W(eu=>{"use strict";h();var Qd=q7();eu.certificate=KX();var pAe=Qd.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())});eu.RSAPrivateKey=pAe;var mAe=Qd.define("RSAPublicKey",function(){this.seq().obj(this.key("modulus").int(),this.key("publicExponent").int())});eu.RSAPublicKey=mAe;var yAe=Qd.define("SubjectPublicKeyInfo",function(){this.seq().obj(this.key("algorithm").use(qX),this.key("subjectPublicKey").bitstr())});eu.PublicKey=yAe;var qX=Qd.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())}),gAe=Qd.define("PrivateKeyInfo",function(){this.seq().obj(this.key("version").int(),this.key("algorithm").use(qX),this.key("subjectPrivateKey").octstr())});eu.PrivateKey=gAe;var bAe=Qd.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())});eu.EncryptedPrivateKey=bAe;var vAe=Qd.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())});eu.DSAPrivateKey=vAe;eu.DSAparam=Qd.define("DSAparam",function(){this.int()});var wAe=Qd.define("ECPrivateKey",function(){this.seq().obj(this.key("version").int(),this.key("privateKey").octstr(),this.key("parameters").optional().explicit(0).use(_Ae),this.key("publicKey").optional().explicit(1).bitstr())});eu.ECPrivateKey=wAe;var _Ae=Qd.define("ECParameters",function(){this.choice({namedCurve:this.objid()})});eu.signature=Qd.define("signature",function(){this.seq().obj(this.key("r").int(),this.key("s").int())})});var FX=W((kht,xAe)=>{xAe.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 GX=W((Rht,zX)=>{h();var EAe=/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,SAe=/^-----BEGIN ((?:.*? KEY)|CERTIFICATE)-----/m,AAe=/^-----BEGIN ((?:.*? KEY)|CERTIFICATE)-----([0-9A-z\n\r+/=]+)-----END \1-----$/m,PAe=C_(),TAe=x5(),Q5=ar().Buffer;zX.exports=function(t,e){var r=t.toString(),n=r.match(EAe),i;if(n){var s="aes"+n[1],a=Q5.from(n[2],"hex"),d=Q5.from(n[3].replace(/[\r\n]/g,""),"base64"),u=PAe(e,a.slice(0,8),parseInt(n[1],10)).key,c=[],l=TAe.createDecipheriv(s,u,a);c.push(l.update(d)),c.push(l.final()),i=Q5.concat(c)}else{var o=r.match(AAe);i=Q5.from(o[2].replace(/[\r\n]/g,""),"base64")}var m=r.match(SAe)[1];return{tag:m,data:i}}});var L_=W((Mht,HX)=>{h();var Sa=LX(),IAe=FX(),kAe=GX(),RAe=x5(),DAe=DD(),F7=ar().Buffer;HX.exports=WX;function WX(t){var e;typeof t=="object"&&!F7.isBuffer(t)&&(e=t.passphrase,t=t.key),typeof t=="string"&&(t=F7.from(t));var r=kAe(t,e),n=r.tag,i=r.data,o,s;switch(n){case"CERTIFICATE":s=Sa.certificate.decode(i,"der").tbsCertificate.subjectPublicKeyInfo;case"PUBLIC KEY":switch(s||(s=Sa.PublicKey.decode(i,"der")),o=s.algorithm.algorithm.join("."),o){case"1.2.840.113549.1.1.1":return Sa.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=Sa.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=Sa.EncryptedPrivateKey.decode(i,"der"),i=MAe(i,e);case"PRIVATE KEY":switch(s=Sa.PrivateKey.decode(i,"der"),o=s.algorithm.algorithm.join("."),o){case"1.2.840.113549.1.1.1":return Sa.RSAPrivateKey.decode(s.subjectPrivateKey,"der");case"1.2.840.10045.2.1":return{curve:s.algorithm.curve,privateKey:Sa.ECPrivateKey.decode(s.subjectPrivateKey,"der").privateKey};case"1.2.840.10040.4.1":return s.algorithm.params.priv_key=Sa.DSAparam.decode(s.subjectPrivateKey,"der"),{type:"dsa",params:s.algorithm.params};default:throw new Error("unknown key id "+o)}case"RSA PUBLIC KEY":return Sa.RSAPublicKey.decode(i,"der");case"RSA PRIVATE KEY":return Sa.RSAPrivateKey.decode(i,"der");case"DSA PRIVATE KEY":return{type:"dsa",params:Sa.DSAPrivateKey.decode(i,"der")};case"EC PRIVATE KEY":return i=Sa.ECPrivateKey.decode(i,"der"),{curve:i.parameters.value,privateKey:i.privateKey};default:throw new Error("unknown key type "+n)}}WX.signature=Sa.signature;function MAe(t,e){var r=t.algorithm.decrypt.kde.kdeparams.salt,n=parseInt(t.algorithm.decrypt.kde.kdeparams.iters.toString(),10),i=IAe[t.algorithm.decrypt.cipher.algo.join(".")],o=t.algorithm.decrypt.cipher.iv,s=t.subjectPrivateKey,a=parseInt(i.split("-")[1],10)/8,d=DAe.pbkdf2Sync(e,r,n,a,"sha1"),u=RAe.createDecipheriv(i,d,o),c=[];return c.push(u.update(s)),c.push(u.final()),F7.concat(c)}});var z7=W((Cht,BAe)=>{BAe.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 YX=W((Oht,t8)=>{"use strict";h();var Ts=ar().Buffer,d0=_D(),CAe=I5(),OAe=G5().ec,e8=T5(),$Ae=L_(),NAe=z7(),jAe=1;function UAe(t,e,r,n,i){var o=$Ae(e);if(o.curve){if(n!=="ecdsa"&&n!=="ecdsa/rsa")throw new Error("wrong private key type");return KAe(t,o)}else if(o.type==="dsa"){if(n!=="dsa")throw new Error("wrong private key type");return qAe(t,o,r)}if(n!=="rsa"&&n!=="ecdsa/rsa")throw new Error("wrong private key type");if(e.padding!==void 0&&e.padding!==jAe)throw new Error("illegal or unsupported padding mode");t=Ts.concat([i,t]);for(var s=o.modulus.byteLength(),a=[0,1];t.length+a.length+10&&r.ishrn(n),r}function FAe(t,e){t=G7(t,e),t=t.mod(e);var r=Ts.from(t.toArray());if(r.length{"use strict";h();var W7=ar().Buffer,F_=T5(),GAe=G5().ec,XX=L_(),WAe=z7();function HAe(t,e,r,n,i){var o=XX(r);if(o.type==="ec"){if(n!=="ecdsa"&&n!=="ecdsa/rsa")throw new Error("wrong public key type");return VAe(t,e,o)}else if(o.type==="dsa"){if(n!=="dsa")throw new Error("wrong public key type");return JAe(t,e,o)}if(n!=="rsa"&&n!=="ecdsa/rsa")throw new Error("wrong public key type");e=W7.concat([i,e]);for(var s=o.modulus.byteLength(),a=[1],d=0;e.length+a.length+2=0)throw new Error("invalid sig")}QX.exports=HAe});var sQ=W((Uht,oQ)=>{"use strict";h();var r8=ar().Buffer,nQ=uv(),n8=J3(),iQ=cr(),YAe=YX(),ZAe=eQ(),u0=xD();Object.keys(u0).forEach(function(t){u0[t].id=r8.from(u0[t].id,"hex"),u0[t.toLowerCase()]=u0[t]});function z_(t){n8.Writable.call(this);var e=u0[t];if(!e)throw new Error("Unknown message digest");this._hashType=e.hash,this._hash=nQ(e.hash),this._tag=e.id,this._signType=e.sign}iQ(z_,n8.Writable);z_.prototype._write=function(e,r,n){this._hash.update(e),n()};z_.prototype.update=function(e,r){return this._hash.update(typeof e=="string"?r8.from(e,r):e),this};z_.prototype.sign=function(e,r){this.end();var n=this._hash.digest(),i=YAe(n,e,this._hashType,this._signType,this._tag);return r?i.toString(r):i};function G_(t){n8.Writable.call(this);var e=u0[t];if(!e)throw new Error("Unknown message digest");this._hash=nQ(e.hash),this._tag=e.id,this._signType=e.sign}iQ(G_,n8.Writable);G_.prototype._write=function(e,r,n){this._hash.update(e),n()};G_.prototype.update=function(e,r){return this._hash.update(typeof e=="string"?r8.from(e,r):e),this};G_.prototype.verify=function(e,r,n){var i=typeof r=="string"?r8.from(r,n):r;this.end();var o=this._hash.digest();return ZAe(i,o,e,this._signType,this._tag)};function tQ(t){return new z_(t)}function rQ(t){return new G_(t)}oQ.exports={Sign:tQ,Verify:rQ,createSign:tQ,createVerify:rQ}});var cQ=W((qht,aQ)=>{h();var XAe=G5(),QAe=Gi();aQ.exports=function(e){return new l0(e)};var ac={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}};ac.p224=ac.secp224r1;ac.p256=ac.secp256r1=ac.prime256v1;ac.p192=ac.secp192r1=ac.prime192v1;ac.p384=ac.secp384r1;ac.p521=ac.secp521r1;function l0(t){this.curveType=ac[t],this.curveType||(this.curveType={name:t}),this.curve=new XAe.ec(this.curveType.name),this.keys=void 0}l0.prototype.generateKeys=function(t,e){return this.keys=this.curve.genKeyPair(),this.getPublicKey(t,e)};l0.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 H7(i,r,this.curveType.byteLength)};l0.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),H7(r,t)};l0.prototype.getPrivateKey=function(t){return H7(this.keys.getPrivate(),t)};l0.prototype.setPublicKey=function(t,e){return e=e||"utf8",O.Buffer.isBuffer(t)||(t=new O.Buffer(t,e)),this.keys._importPublic(t),this};l0.prototype.setPrivateKey=function(t,e){e=e||"utf8",O.Buffer.isBuffer(t)||(t=new O.Buffer(t,e));var r=new QAe(t);return r=r.toString(16),this.keys=this.curve.genKeyPair(),this.keys._importPrivate(r),this};function H7(t,e,r){Array.isArray(t)||(t=t.toArray());var n=new O.Buffer(t);if(r&&n.length{h();var ePe=uv(),V7=ar().Buffer;dQ.exports=function(t,e){for(var r=V7.alloc(0),n=0,i;r.length{h();uQ.exports=function(e,r){for(var n=e.length,i=-1;++i{h();var lQ=Gi(),rPe=ar().Buffer;function nPe(t,e){return rPe.from(t.toRed(lQ.mont(e.modulus)).redPow(new lQ(e.publicExponent)).fromRed().toArray())}fQ.exports=nPe});var yQ=W((Jht,mQ)=>{h();var iPe=L_(),X7=Ky(),oPe=uv(),hQ=J7(),pQ=Y7(),Q7=Gi(),sPe=Z7(),aPe=I5(),tu=ar().Buffer;mQ.exports=function(e,r,n){var i;e.padding?i=e.padding:n?i=1:i=4;var o=iPe(e),s;if(i===4)s=cPe(o,r);else if(i===1)s=dPe(o,r,n);else if(i===3){if(s=new Q7(r),s.cmp(o.modulus)>=0)throw new Error("data too long for modulus")}else throw new Error("unknown padding");return n?aPe(s,o):sPe(s,o)};function cPe(t,e){var r=t.modulus.byteLength(),n=e.length,i=oPe("sha1").update(tu.alloc(0)).digest(),o=i.length,s=2*o;if(n>r-s-2)throw new Error("message too long");var a=tu.alloc(r-n-s-2),d=r-o-1,u=X7(o),c=pQ(tu.concat([i,a,tu.alloc(1,1),e],d),hQ(u,d)),l=pQ(u,hQ(c,o));return new Q7(tu.concat([tu.alloc(1),l,c],r))}function dPe(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=tu.alloc(i-n-3,255):o=uPe(i-n-3),new Q7(tu.concat([tu.from([0,r?1:2]),o,tu.alloc(1),e],i))}function uPe(t){for(var e=tu.allocUnsafe(t),r=0,n=X7(t*2),i=0,o;r{h();var lPe=L_(),gQ=J7(),bQ=Y7(),vQ=Gi(),fPe=I5(),hPe=uv(),pPe=Z7(),W_=ar().Buffer;wQ.exports=function(e,r,n){var i;e.padding?i=e.padding:n?i=1:i=4;var o=lPe(e),s=o.modulus.byteLength();if(r.length>s||new vQ(r).cmp(o.modulus)>=0)throw new Error("decryption error");var a;n?a=pPe(new vQ(r),o):a=fPe(r,o);var d=W_.alloc(s-a.length);if(a=W_.concat([d,a],s),i===4)return mPe(o,a);if(i===1)return yPe(o,a,n);if(i===3)return a;throw new Error("unknown padding")};function mPe(t,e){var r=t.modulus.byteLength(),n=hPe("sha1").update(W_.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=bQ(o,gQ(s,i)),d=bQ(s,gQ(a,r-i-1));if(gPe(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 yPe(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 gPe(t,e){t=W_.from(t),e=W_.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{h();f0.publicEncrypt=yQ();f0.privateDecrypt=_Q();f0.privateEncrypt=function(e,r){return f0.publicEncrypt(e,r,!0)};f0.publicDecrypt=function(e,r){return f0.privateDecrypt(e,r,!0)}});var MQ=W(H_=>{"use strict";h();function EQ(){throw new Error(`secure random number generation not supported by this browser use chrome, FireFox or Internet Explorer 11`)}var AQ=ar(),SQ=Ky(),PQ=AQ.Buffer,TQ=AQ.kMaxLength,eM=globalThis.crypto||globalThis.msCrypto,IQ=Math.pow(2,32)-1;function kQ(t,e){if(typeof t!="number"||t!==t)throw new TypeError("offset must be a number");if(t>IQ||t<0)throw new TypeError("offset must be a uint32");if(t>TQ||t>e)throw new RangeError("offset out of range")}function RQ(t,e,r){if(typeof t!="number"||t!==t)throw new TypeError("size must be a number");if(t>IQ||t<0)throw new TypeError("size must be a uint32");if(t+e>r||t>TQ)throw new RangeError("buffer too small")}eM&&eM.getRandomValues||!B.default.browser?(H_.randomFill=bPe,H_.randomFillSync=vPe):(H_.randomFill=EQ,H_.randomFillSync=EQ);function bPe(t,e,r,n){if(!PQ.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 kQ(e,t.length),RQ(r,e,t.length),DQ(t,e,r,n)}function DQ(t,e,r,n){if(B.default.browser){var i=t.buffer,o=new Uint8Array(i,e,r);if(eM.getRandomValues(o),n){B.default.nextTick(function(){n(null,t)});return}return t}if(n){SQ(r,function(a,d){if(a)return n(a);d.copy(t,e),n(null,t)});return}var s=SQ(r);return s.copy(t,e),t}function vPe(t,e,r){if(typeof e>"u"&&(e=0),!PQ.isBuffer(t)&&!(t instanceof globalThis.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');return kQ(e,t.length),r===void 0&&(r=t.length-e),RQ(r,e,t.length),DQ(t,e,r)}});var S5=W(dr=>{"use strict";h();dr.randomBytes=dr.rng=dr.pseudoRandomBytes=dr.prng=Ky();dr.createHash=dr.Hash=uv();dr.createHmac=dr.Hmac=_D();var wPe=XV(),_Pe=Object.keys(wPe),xPe=["sha1","sha224","sha256","sha384","sha512","md5","rmd160"].concat(_Pe);dr.getHashes=function(){return xPe};var BQ=DD();dr.pbkdf2=BQ.pbkdf2;dr.pbkdf2Sync=BQ.pbkdf2Sync;var dl=wY();dr.Cipher=dl.Cipher;dr.createCipher=dl.createCipher;dr.Cipheriv=dl.Cipheriv;dr.createCipheriv=dl.createCipheriv;dr.Decipher=dl.Decipher;dr.createDecipher=dl.createDecipher;dr.Decipheriv=dl.Decipheriv;dr.createDecipheriv=dl.createDecipheriv;dr.getCiphers=dl.getCiphers;dr.listCiphers=dl.listCiphers;var V_=BY();dr.DiffieHellmanGroup=V_.DiffieHellmanGroup;dr.createDiffieHellmanGroup=V_.createDiffieHellmanGroup;dr.getDiffieHellman=V_.getDiffieHellman;dr.createDiffieHellman=V_.createDiffieHellman;dr.DiffieHellman=V_.DiffieHellman;var i8=sQ();dr.createSign=i8.createSign;dr.Sign=i8.Sign;dr.createVerify=i8.createVerify;dr.Verify=i8.Verify;dr.createECDH=cQ();var o8=xQ();dr.publicEncrypt=o8.publicEncrypt;dr.privateEncrypt=o8.privateEncrypt;dr.publicDecrypt=o8.publicDecrypt;dr.privateDecrypt=o8.privateDecrypt;var CQ=MQ();dr.randomFill=CQ.randomFill;dr.randomFillSync=CQ.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 ru=W(ur=>{"use strict";h();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 rM=t=>t instanceof Uint8Array,EPe=t=>new Uint8Array(t.buffer,t.byteOffset,t.byteLength);ur.u8=EPe;var SPe=t=>new Uint16Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/2));ur.u16=SPe;var APe=t=>new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4));ur.u32=APe;var PPe=t=>new DataView(t.buffer,t.byteOffset,t.byteLength);ur.createView=PPe;ur.isLE=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!ur.isLE)throw new Error("Non little-endian hardware is not supported");var TPe=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function IPe(t){if(!rM(t))throw new Error("Uint8Array expected");let e="";for(let r=0;r{};ur.nextTick=RPe;async function DPe(t,e,r){let n=Date.now();for(let i=0;i=0&&on+i.length,0)),r=0;return t.forEach(n=>{if(!rM(n))throw new Error("Uint8Array expected");e.set(n,r),r+=n.length}),e}ur.concatBytes=CPe;var OPe=t=>Object.prototype.toString.call(t)==="[object Object]"&&t.constructor===Object;function $Pe(t,e){if(e!==void 0&&(typeof e!="object"||!OPe(e)))throw new Error("options must be object or undefined");return Object.assign(t,e)}ur.checkOpts=$Pe;function NPe(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=NPe;function jPe(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=UPe});var J_=W(Is=>{"use strict";h();Object.defineProperty(Is,"__esModule",{value:!0});Is.AEAD_TAG_LENGTH=Is.XCHACHA20_NONCE_LENGTH=Is.CURVE25519_PUBLIC_KEY_SIZE=Is.ETH_PUBLIC_KEY_SIZE=Is.UNCOMPRESSED_PUBLIC_KEY_SIZE=Is.COMPRESSED_PUBLIC_KEY_SIZE=Is.SECRET_KEY_LENGTH=void 0;Is.SECRET_KEY_LENGTH=32;Is.COMPRESSED_PUBLIC_KEY_SIZE=33;Is.UNCOMPRESSED_PUBLIC_KEY_SIZE=65;Is.ETH_PUBLIC_KEY_SIZE=64;Is.CURVE25519_PUBLIC_KEY_SIZE=32;Is.XCHACHA20_NONCE_LENGTH=24;Is.AEAD_TAG_LENGTH=16});var h0=W(Kn=>{"use strict";h();Object.defineProperty(Kn,"__esModule",{value:!0});Kn.ephemeralKeySize=Kn.symmetricNonceLength=Kn.symmetricAlgorithm=Kn.isHkdfKeyCompressed=Kn.isEphemeralKeyCompressed=Kn.ellipticCurve=Kn.ECIES_CONFIG=void 0;var s8=J_(),KPe=function(){function t(){this.ellipticCurve="secp256k1",this.isEphemeralKeyCompressed=!1,this.isHkdfKeyCompressed=!1,this.symmetricAlgorithm="aes-256-gcm",this.symmetricNonceLength=16}return t}();Kn.ECIES_CONFIG=new KPe;var qPe=function(){return Kn.ECIES_CONFIG.ellipticCurve};Kn.ellipticCurve=qPe;var LPe=function(){return Kn.ECIES_CONFIG.isEphemeralKeyCompressed};Kn.isEphemeralKeyCompressed=LPe;var FPe=function(){return Kn.ECIES_CONFIG.isHkdfKeyCompressed};Kn.isHkdfKeyCompressed=FPe;var zPe=function(){return Kn.ECIES_CONFIG.symmetricAlgorithm};Kn.symmetricAlgorithm=zPe;var GPe=function(){return Kn.ECIES_CONFIG.symmetricNonceLength};Kn.symmetricNonceLength=GPe;var WPe=function(){var t={secp256k1:Kn.ECIES_CONFIG.isEphemeralKeyCompressed?s8.COMPRESSED_PUBLIC_KEY_SIZE:s8.UNCOMPRESSED_PUBLIC_KEY_SIZE,x25519:s8.CURVE25519_PUBLIC_KEY_SIZE,ed25519:s8.CURVE25519_PUBLIC_KEY_SIZE};if(Kn.ECIES_CONFIG.ellipticCurve in t)return t[Kn.ECIES_CONFIG.ellipticCurve];throw new Error("Not implemented")};Kn.ephemeralKeySize=WPe});var $Q=W(a8=>{"use strict";h();Object.defineProperty(a8,"__esModule",{value:!0});a8.crypto=void 0;a8.crypto=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0});var nM=W(Nv=>{"use strict";h();Object.defineProperty(Nv,"__esModule",{value:!0});Nv.getWebcryptoSubtle=Nv.randomBytes=void 0;var p0=$Q();function HPe(t=32){if(p0.crypto&&typeof p0.crypto.getRandomValues=="function")return p0.crypto.getRandomValues(new Uint8Array(t));throw new Error("crypto.getRandomValues must be defined")}Nv.randomBytes=HPe;function VPe(){if(p0.crypto&&typeof p0.crypto.subtle=="object"&&p0.crypto.subtle!=null)return p0.crypto.subtle;throw new Error("crypto.subtle must be defined")}Nv.getWebcryptoSubtle=VPe});var oM=W(Ys=>{"use strict";h();Object.defineProperty(Ys,"__esModule",{value:!0});Ys.output=Ys.exists=Ys.hash=Ys.bytes=Ys.bool=Ys.number=void 0;function c8(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`Wrong positive integer: ${t}`)}Ys.number=c8;function NQ(t){if(typeof t!="boolean")throw new Error(`Expected boolean, not ${t}`)}Ys.bool=NQ;function JPe(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}function iM(t,...e){if(!JPe(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}`)}Ys.bytes=iM;function jQ(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");c8(t.outputLen),c8(t.blockLen)}Ys.hash=jQ;function UQ(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")}Ys.exists=UQ;function KQ(t,e){iM(t);let r=e.outputLen;if(t.length{"use strict";h();Object.defineProperty(d8,"__esModule",{value:!0});d8.crypto=void 0;d8.crypto=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0});var Ap=W(lr=>{"use strict";h();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 sM=qQ(),ZPe=t=>new Uint8Array(t.buffer,t.byteOffset,t.byteLength);lr.u8=ZPe;var XPe=t=>new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4));lr.u32=XPe;function cM(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}var QPe=t=>new DataView(t.buffer,t.byteOffset,t.byteLength);lr.createView=QPe;var eTe=(t,e)=>t<<32-e|t>>>e;lr.rotr=eTe;lr.isLE=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!lr.isLE)throw new Error("Non little-endian hardware is not supported");var tTe=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function rTe(t){if(!cM(t))throw new Error("Uint8Array expected");let e="";for(let r=0;r=Nf._0&&t<=Nf._9)return t-Nf._0;if(t>=Nf._A&&t<=Nf._F)return t-(Nf._A-10);if(t>=Nf._a&&t<=Nf._f)return t-(Nf._a-10)}function nTe(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=iTe;async function oTe(t,e,r){let n=Date.now();for(let i=0;i=0&&ot().update(u8(n)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}lr.wrapConstructor=dTe;function uTe(t){let e=(n,i)=>t(i).update(u8(n)).digest(),r=t({});return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=n=>t(n),e}lr.wrapConstructorWithOpts=uTe;function lTe(t){let e=(n,i)=>t(i).update(u8(n)).digest(),r=t({});return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=n=>t(n),e}lr.wrapXOFConstructorWithOpts=lTe;function fTe(t=32){if(sM.crypto&&typeof sM.crypto.getRandomValues=="function")return sM.crypto.getRandomValues(new Uint8Array(t));throw new Error("crypto.getRandomValues must be defined")}lr.randomBytes=fTe});var lM=W(l8=>{"use strict";h();Object.defineProperty(l8,"__esModule",{value:!0});l8.SHA2=void 0;var dM=oM(),Y_=Ap();function hTe(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 uM=class extends Y_.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,Y_.createView)(this.buffer)}update(e){(0,dM.exists)(this);let{view:r,buffer:n,blockLen:i}=this;e=(0,Y_.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";h();Object.defineProperty(Dt,"__esModule",{value:!0});Dt.add5L=Dt.add5H=Dt.add4H=Dt.add4L=Dt.add3H=Dt.add3L=Dt.add=Dt.rotlBL=Dt.rotlBH=Dt.rotlSL=Dt.rotlSH=Dt.rotr32L=Dt.rotr32H=Dt.rotrBL=Dt.rotrBH=Dt.rotrSL=Dt.rotrSH=Dt.shrSL=Dt.shrSH=Dt.toBig=Dt.split=Dt.fromBig=void 0;var f8=BigInt(2**32-1),fM=BigInt(32);function hM(t,e=!1){return e?{h:Number(t&f8),l:Number(t>>fM&f8)}:{h:Number(t>>fM&f8)|0,l:Number(t&f8)|0}}Dt.fromBig=hM;function zQ(t,e=!1){let r=new Uint32Array(t.length),n=new Uint32Array(t.length);for(let i=0;iBigInt(t>>>0)<>>0);Dt.toBig=GQ;var WQ=(t,e,r)=>t>>>r;Dt.shrSH=WQ;var HQ=(t,e,r)=>t<<32-r|e>>>r;Dt.shrSL=HQ;var VQ=(t,e,r)=>t>>>r|e<<32-r;Dt.rotrSH=VQ;var JQ=(t,e,r)=>t<<32-r|e>>>r;Dt.rotrSL=JQ;var YQ=(t,e,r)=>t<<64-r|e>>>r-32;Dt.rotrBH=YQ;var ZQ=(t,e,r)=>t>>>r-32|e<<64-r;Dt.rotrBL=ZQ;var XQ=(t,e)=>e;Dt.rotr32H=XQ;var QQ=(t,e)=>t;Dt.rotr32L=QQ;var eee=(t,e,r)=>t<>>32-r;Dt.rotlSH=eee;var tee=(t,e,r)=>e<>>32-r;Dt.rotlSL=tee;var ree=(t,e,r)=>e<>>64-r;Dt.rotlBH=ree;var nee=(t,e,r)=>t<>>64-r;Dt.rotlBL=nee;function iee(t,e,r,n){let i=(e>>>0)+(n>>>0);return{h:t+r+(i/2**32|0)|0,l:i|0}}Dt.add=iee;var oee=(t,e,r)=>(t>>>0)+(e>>>0)+(r>>>0);Dt.add3L=oee;var see=(t,e,r,n)=>e+r+n+(t/2**32|0)|0;Dt.add3H=see;var aee=(t,e,r,n)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0);Dt.add4L=aee;var cee=(t,e,r,n,i)=>e+r+n+i+(t/2**32|0)|0;Dt.add4H=cee;var dee=(t,e,r,n,i)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0)+(i>>>0);Dt.add5L=dee;var uee=(t,e,r,n,i,o)=>e+r+n+i+o+(t/2**32|0)|0;Dt.add5H=uee;var pTe={fromBig:hM,split:zQ,toBig:GQ,shrSH:WQ,shrSL:HQ,rotrSH:VQ,rotrSL:JQ,rotrBH:YQ,rotrBL:ZQ,rotr32H:XQ,rotr32L:QQ,rotlSH:eee,rotlSL:tee,rotlBH:ree,rotlBL:nee,add:iee,add3L:oee,add3H:see,add4L:aee,add4H:cee,add5H:uee,add5L:dee};Dt.default=pTe});var fee=W(nd=>{"use strict";h();Object.defineProperty(nd,"__esModule",{value:!0});nd.sha384=nd.sha512_256=nd.sha512_224=nd.sha512=nd.SHA512=void 0;var mTe=lM(),fr=lee(),h8=Ap(),[yTe,gTe]=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))),Pp=new Uint32Array(80),Tp=new Uint32Array(80),m0=class extends mTe.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:m,Gh:p,Gl:g,Hh:b,Hl:S}=this;return[e,r,n,i,o,s,a,d,u,c,l,m,p,g,b,S]}set(e,r,n,i,o,s,a,d,u,c,l,m,p,g,b,S){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=m|0,this.Gh=p|0,this.Gl=g|0,this.Hh=b|0,this.Hl=S|0}process(e,r){for(let P=0;P<16;P++,r+=4)Pp[P]=e.getUint32(r),Tp[P]=e.getUint32(r+=4);for(let P=16;P<80;P++){let $=Pp[P-15]|0,N=Tp[P-15]|0,L=fr.default.rotrSH($,N,1)^fr.default.rotrSH($,N,8)^fr.default.shrSH($,N,7),F=fr.default.rotrSL($,N,1)^fr.default.rotrSL($,N,8)^fr.default.shrSL($,N,7),U=Pp[P-2]|0,G=Tp[P-2]|0,q=fr.default.rotrSH(U,G,19)^fr.default.rotrBH(U,G,61)^fr.default.shrSH(U,G,6),T=fr.default.rotrSL(U,G,19)^fr.default.rotrBL(U,G,61)^fr.default.shrSL(U,G,6),E=fr.default.add4L(F,T,Tp[P-7],Tp[P-16]),k=fr.default.add4H(E,L,q,Pp[P-7],Pp[P-16]);Pp[P]=k|0,Tp[P]=E|0}let{Ah:n,Al:i,Bh:o,Bl:s,Ch:a,Cl:d,Dh:u,Dl:c,Eh:l,El:m,Fh:p,Fl:g,Gh:b,Gl:S,Hh:A,Hl:I}=this;for(let P=0;P<80;P++){let $=fr.default.rotrSH(l,m,14)^fr.default.rotrSH(l,m,18)^fr.default.rotrBH(l,m,41),N=fr.default.rotrSL(l,m,14)^fr.default.rotrSL(l,m,18)^fr.default.rotrBL(l,m,41),L=l&p^~l&b,F=m&g^~m&S,U=fr.default.add5L(I,N,F,gTe[P],Tp[P]),G=fr.default.add5H(U,A,$,L,yTe[P],Pp[P]),q=U|0,T=fr.default.rotrSH(n,i,28)^fr.default.rotrBH(n,i,34)^fr.default.rotrBH(n,i,39),E=fr.default.rotrSL(n,i,28)^fr.default.rotrBL(n,i,34)^fr.default.rotrBL(n,i,39),k=n&o^n&a^o&a,f=i&s^i&d^s&d;A=b|0,I=S|0,b=p|0,S=g|0,p=l|0,g=m|0,{h:l,l:m}=fr.default.add(u|0,c|0,G|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,E,f);n=fr.default.add3H(y,G,T,k),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:m}=fr.default.add(this.Eh|0,this.El|0,l|0,m|0),{h:p,l:g}=fr.default.add(this.Fh|0,this.Fl|0,p|0,g|0),{h:b,l:S}=fr.default.add(this.Gh|0,this.Gl|0,b|0,S|0),{h:A,l:I}=fr.default.add(this.Hh|0,this.Hl|0,A|0,I|0),this.set(n,i,o,s,a,d,u,c,l,m,p,g,b,S,A,I)}roundClean(){Pp.fill(0),Tp.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)}};nd.SHA512=m0;var pM=class extends m0{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}},mM=class extends m0{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}},yM=class extends m0{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}};nd.sha512=(0,h8.wrapConstructor)(()=>new m0);nd.sha512_224=(0,h8.wrapConstructor)(()=>new pM);nd.sha512_256=(0,h8.wrapConstructor)(()=>new mM);nd.sha384=(0,h8.wrapConstructor)(()=>new yM)});var nu=W(Jt=>{"use strict";h();Object.defineProperty(Jt,"__esModule",{value:!0});Jt.validateObject=Jt.createHmacDrbg=Jt.bitMask=Jt.bitSet=Jt.bitGet=Jt.bitLen=Jt.utf8ToBytes=Jt.equalBytes=Jt.concatBytes=Jt.ensureBytes=Jt.numberToVarBytesBE=Jt.numberToBytesLE=Jt.numberToBytesBE=Jt.bytesToNumberLE=Jt.bytesToNumberBE=Jt.hexToBytes=Jt.hexToNumber=Jt.numberToHexUnpadded=Jt.bytesToHex=Jt.isBytes=void 0;var mee=BigInt(0),p8=BigInt(1),bTe=BigInt(2);function jv(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}Jt.isBytes=jv;var vTe=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function bM(t){if(!jv(t))throw new Error("Uint8Array expected");let e="";for(let r=0;r=jf._0&&t<=jf._9)return t-jf._0;if(t>=jf._A&&t<=jf._F)return t-(jf._A-10);if(t>=jf._a&&t<=jf._f)return t-(jf._a-10)}function m8(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;imee;t>>=p8,e+=1);return e}Jt.bitLen=TTe;function ITe(t,e){return t>>BigInt(e)&p8}Jt.bitGet=ITe;var kTe=(t,e,r)=>t|(r?p8:mee)<(bTe<new Uint8Array(t),pee=t=>Uint8Array.from(t);function DTe(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=gM(t),i=gM(t),o=0,s=()=>{n.fill(1),i.fill(0),o=0},a=(...l)=>r(i,n,...l),d=(l=gM())=>{i=a(pee([0]),l),n=a(),l.length!==0&&(i=a(pee([1]),l),n=a())},u=()=>{if(o++>=1e3)throw new Error("drbg: tried 1000 values");let l=0,m=[];for(;l{s(),d(l);let p;for(;!(p=m(u()));)d();return s(),p}}Jt.createHmacDrbg=DTe;var MTe={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"||jv(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 BTe(t,e,r={}){let n=(i,o,s)=>{let a=MTe[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}Jt.validateObject=BTe});var kp=W(Yt=>{"use strict";h();Object.defineProperty(Yt,"__esModule",{value:!0});Yt.mapHashToField=Yt.getMinHashLength=Yt.getFieldBytesLength=Yt.hashToPrivateScalar=Yt.FpSqrtEven=Yt.FpSqrtOdd=Yt.Field=Yt.nLength=Yt.FpIsSquare=Yt.FpDiv=Yt.FpInvertBatch=Yt.FpPow=Yt.validateField=Yt.isNegativeLE=Yt.FpSqrt=Yt.tonelliShanks=Yt.invert=Yt.pow2=Yt.pow=Yt.mod=void 0;var dc=nu(),Wi=BigInt(0),bn=BigInt(1),Ip=BigInt(2),CTe=BigInt(3),wM=BigInt(4),vee=BigInt(5),wee=BigInt(8),OTe=BigInt(9),$Te=BigInt(16);function cc(t,e){let r=t%e;return r>=Wi?r:e+r}Yt.mod=cc;function _ee(t,e,r){if(r<=Wi||e 0");if(r===bn)return Wi;let n=bn;for(;e>Wi;)e&bn&&(n=n*t%r),t=t*t%r,e>>=bn;return n}Yt.pow=_ee;function NTe(t,e,r){let n=t;for(;e-- >Wi;)n*=n,n%=r;return n}Yt.pow2=NTe;function y8(t,e){if(t===Wi||e<=Wi)throw new Error(`invert: expected positive integers, got n=${t} mod=${e}`);let r=cc(t,e),n=e,i=Wi,o=bn,s=bn,a=Wi;for(;r!==Wi;){let u=n/r,c=n%r,l=i-s*u,m=o-a*u;n=r,r=c,i=s,o=a,s=l,a=m}if(n!==bn)throw new Error("invert: does not exist");return cc(i,e)}Yt.invert=y8;function xee(t){let e=(t-bn)/Ip,r,n,i;for(r=t-bn,n=0;r%Ip===Wi;r/=Ip,n++);for(i=Ip;i(cc(t,e)&bn)===bn;Yt.isNegativeLE=jTe;var UTe=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function KTe(t){let e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},r=UTe.reduce((n,i)=>(n[i]="function",n),e);return(0,dc.validateObject)(t,r)}Yt.validateField=KTe;function See(t,e,r){if(r 0");if(r===Wi)return t.ONE;if(r===bn)return e;let n=t.ONE,i=e;for(;r>Wi;)r&bn&&(n=t.mul(n,i)),i=t.sqr(i),r>>=bn;return n}Yt.FpPow=See;function Aee(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}Yt.FpInvertBatch=Aee;function qTe(t,e,r){return t.mul(e,typeof r=="bigint"?y8(r,t.ORDER):t.inv(r))}Yt.FpDiv=qTe;function LTe(t){let e=(t.ORDER-bn)/Ip;return r=>{let n=t.pow(r,e);return t.eql(n,t.ZERO)||t.eql(n,t.ONE)}}Yt.FpIsSquare=LTe;function _M(t,e){let r=e!==void 0?e:t.toString(2).length,n=Math.ceil(r/8);return{nBitLength:r,nByteLength:n}}Yt.nLength=_M;function FTe(t,e,r=!1,n={}){if(t<=Wi)throw new Error(`Expected Field ORDER > 0, got ${t}`);let{nBitLength:i,nByteLength:o}=_M(t,e);if(o>2048)throw new Error("Field lengths over 2048 bytes are not supported");let s=Eee(t),a=Object.freeze({ORDER:t,BITS:i,BYTES:o,MASK:(0,dc.bitMask)(i),ZERO:Wi,ONE:bn,create:d=>cc(d,t),isValid:d=>{if(typeof d!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof d}`);return Wi<=d&&dd===Wi,isOdd:d=>(d&bn)===bn,neg:d=>cc(-d,t),eql:(d,u)=>d===u,sqr:d=>cc(d*d,t),add:(d,u)=>cc(d+u,t),sub:(d,u)=>cc(d-u,t),mul:(d,u)=>cc(d*u,t),pow:(d,u)=>See(a,d,u),div:(d,u)=>cc(d*y8(u,t),t),sqrN:d=>d*d,addN:(d,u)=>d+u,subN:(d,u)=>d-u,mulN:(d,u)=>d*u,inv:d=>y8(d,t),sqrt:n.sqrt||(d=>s(a,d)),invertBatch:d=>Aee(a,d),cmov:(d,u,c)=>c?u:d,toBytes:d=>r?(0,dc.numberToBytesLE)(d,o):(0,dc.numberToBytesBE)(d,o),fromBytes:d=>{if(d.length!==o)throw new Error(`Fp.fromBytes: expected ${o}, got ${d.length}`);return r?(0,dc.bytesToNumberLE)(d):(0,dc.bytesToNumberBE)(d)}});return Object.freeze(a)}Yt.Field=FTe;function zTe(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)}Yt.FpSqrtOdd=zTe;function GTe(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}Yt.FpSqrtEven=GTe;function WTe(t,e,r=!1){t=(0,dc.ensureBytes)("privateHash",t);let n=t.length,i=_M(e).nByteLength+8;if(i<24||n1024)throw new Error(`hashToPrivateScalar: expected ${i}-1024 bytes of input, got ${n}`);let o=r?(0,dc.bytesToNumberLE)(t):(0,dc.bytesToNumberBE)(t);return cc(o,e-bn)+bn}Yt.hashToPrivateScalar=WTe;function xM(t){if(typeof t!="bigint")throw new Error("field order must be bigint");let e=t.toString(2).length;return Math.ceil(e/8)}Yt.getFieldBytesLength=xM;function Pee(t){let e=xM(t);return e+Math.ceil(e/2)}Yt.getMinHashLength=Pee;function HTe(t,e,r=!1){let n=t.length,i=xM(e),o=Pee(e);if(n<16||n1024)throw new Error(`expected ${o}-1024 bytes of input, got ${n}`);let s=r?(0,dc.bytesToNumberBE)(t):(0,dc.bytesToNumberLE)(t),a=cc(s,e-bn)+bn;return r?(0,dc.numberToBytesLE)(a,i):(0,dc.numberToBytesBE)(a,i)}Yt.mapHashToField=HTe});var SM=W(Uv=>{"use strict";h();Object.defineProperty(Uv,"__esModule",{value:!0});Uv.validateBasic=Uv.wNAF=void 0;var Tee=kp(),VTe=nu(),JTe=BigInt(0),EM=BigInt(1);function YTe(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>JTe;)o&EM&&(s=s.add(a)),a=a.double(),o>>=EM;return s},precomputeWindow(i,o){let{windows:s,windowSize:a}=n(o),d=[],u=i,c=u;for(let l=0;l>=p,S>d&&(S-=m,s+=EM);let A=b,I=b+Math.abs(S)-1,P=g%2!==0,$=S<0;S===0?c=c.add(r(P,o[A])):u=u.add(r($,o[I]))}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)}}}Uv.wNAF=YTe;function ZTe(t){return(0,Tee.validateField)(t.Fp),(0,VTe.validateObject)(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...(0,Tee.nLength)(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}Uv.validateBasic=ZTe});var kee=W(b8=>{"use strict";h();Object.defineProperty(b8,"__esModule",{value:!0});b8.twistedEdwards=void 0;var XTe=kp(),Uf=nu(),Rp=nu(),Iee=SM(),iu=BigInt(0),uc=BigInt(1),g8=BigInt(2),QTe=BigInt(8),eIe={zip215:!0};function tIe(t){let e=(0,Iee.validateBasic)(t);return Uf.validateObject(t,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}function rIe(t){let e=tIe(t),{Fp:r,n,prehash:i,hash:o,randomBytes:s,nByteLength:a,h:d}=e,u=g8<{try{return{isValid:!0,value:r.sqrt(x*r.inv(v))}}catch{return{isValid:!1,value:iu}}}),m=e.adjustScalarBytes||(x=>x),p=e.domain||((x,v,D)=>{if(v.length||D)throw new Error("Contexts/pre-hash are not supported");return x}),g=x=>typeof x=="bigint"&&iug(x)&&g(v)&&xx===iu||b(x,u);function A(x,v){if(b(x,v))return x;throw new Error(`Expected valid scalar < ${v}, got ${typeof x} ${x}`)}function I(x){return x===iu?x:A(x,n)}let P=new Map;function $(x){if(!(x instanceof N))throw new Error("ExtendedPoint expected")}class N{constructor(v,D,K,M){if(this.ex=v,this.ey=D,this.ez=K,this.et=M,!S(v))throw new Error("x required");if(!S(D))throw new Error("y required");if(!S(K))throw new Error("z required");if(!S(M))throw new Error("t required")}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(v){if(v instanceof N)throw new Error("extended point not allowed");let{x:D,y:K}=v||{};if(!S(D)||!S(K))throw new Error("invalid affine point");return new N(D,K,uc,c(D*K))}static normalizeZ(v){let D=r.invertBatch(v.map(K=>K.ez));return v.map((K,M)=>K.toAffine(D[M])).map(N.fromAffine)}_setWindowSize(v){this._WINDOW_SIZE=v,P.delete(this)}assertValidity(){let{a:v,d:D}=e;if(this.is0())throw new Error("bad point: ZERO");let{ex:K,ey:M,ez:j,et:J}=this,Z=c(K*K),V=c(M*M),H=c(j*j),X=c(H*H),ee=c(Z*v),ue=c(H*c(ee+V)),ae=c(X+c(D*c(Z*V)));if(ue!==ae)throw new Error("bad point: equation left != right (1)");let ce=c(K*M),pe=c(j*J);if(ce!==pe)throw new Error("bad point: equation left != right (2)")}equals(v){$(v);let{ex:D,ey:K,ez:M}=this,{ex:j,ey:J,ez:Z}=v,V=c(D*Z),H=c(j*M),X=c(K*Z),ee=c(J*M);return V===H&&X===ee}is0(){return this.equals(N.ZERO)}negate(){return new N(c(-this.ex),this.ey,this.ez,c(-this.et))}double(){let{a:v}=e,{ex:D,ey:K,ez:M}=this,j=c(D*D),J=c(K*K),Z=c(g8*c(M*M)),V=c(v*j),H=D+K,X=c(c(H*H)-j-J),ee=V+J,ue=ee-Z,ae=V-J,ce=c(X*ue),pe=c(ee*ae),Ee=c(X*ae),Ue=c(ue*ee);return new N(ce,pe,Ue,Ee)}add(v){$(v);let{a:D,d:K}=e,{ex:M,ey:j,ez:J,et:Z}=this,{ex:V,ey:H,ez:X,et:ee}=v;if(D===BigInt(-1)){let gt=c((j-M)*(H+V)),Pe=c((j+M)*(H-V)),De=c(Pe-gt);if(De===iu)return this.double();let It=c(J*g8*ee),we=c(Z*g8*X),Se=we+It,Lr=Pe+gt,Fe=we-It,He=c(Se*De),js=c(Lr*Fe),ft=c(Se*Fe),Rt=c(De*Lr);return new N(He,js,Rt,ft)}let ue=c(M*V),ae=c(j*H),ce=c(Z*K*ee),pe=c(J*X),Ee=c((M+j)*(V+H)-ue-ae),Ue=pe-ce,le=pe+ce,ge=c(ae-D*ue),ve=c(Ee*Ue),Ce=c(le*ge),Ie=c(Ee*ge),je=c(Ue*le);return new N(ve,Ce,je,Ie)}subtract(v){return this.add(v.negate())}wNAF(v){return U.wNAFCached(this,P,v,N.normalizeZ)}multiply(v){let{p:D,f:K}=this.wNAF(A(v,n));return N.normalizeZ([D,K])[0]}multiplyUnsafe(v){let D=I(v);return D===iu?F:this.equals(F)||D===uc?this:this.equals(L)?this.wNAF(D).p:U.unsafeLadder(this,D)}isSmallOrder(){return this.multiplyUnsafe(d).is0()}isTorsionFree(){return U.unsafeLadder(this,n).is0()}toAffine(v){let{ex:D,ey:K,ez:M}=this,j=this.is0();v==null&&(v=j?QTe:r.inv(M));let J=c(D*v),Z=c(K*v),V=c(M*v);if(j)return{x:iu,y:uc};if(V!==uc)throw new Error("invZ was invalid");return{x:J,y:Z}}clearCofactor(){let{h:v}=e;return v===uc?this:this.multiplyUnsafe(v)}static fromHex(v,D=!1){let{d:K,a:M}=e,j=r.BYTES;v=(0,Rp.ensureBytes)("pointHex",v,j);let J=v.slice(),Z=v[j-1];J[j-1]=Z&-129;let V=Uf.bytesToNumberLE(J);V===iu||(D?A(V,u):A(V,r.ORDER));let H=c(V*V),X=c(H-uc),ee=c(K*H-M),{isValid:ue,value:ae}=l(X,ee);if(!ue)throw new Error("Point.fromHex: invalid y coordinate");let ce=(ae&uc)===uc,pe=(Z&128)!==0;if(!D&&ae===iu&&pe)throw new Error("Point.fromHex: x=0 and x_0=1");return pe!==ce&&(ae=c(-ae)),N.fromAffine({x:ae,y:V})}static fromPrivateKey(v){return T(v).point}toRawBytes(){let{x:v,y:D}=this.toAffine(),K=Uf.numberToBytesLE(D,r.BYTES);return K[K.length-1]|=v&uc?128:0,K}toHex(){return Uf.bytesToHex(this.toRawBytes())}}N.BASE=new N(e.Gx,e.Gy,uc,c(e.Gx*e.Gy)),N.ZERO=new N(iu,uc,uc,iu);let{BASE:L,ZERO:F}=N,U=(0,Iee.wNAF)(N,a*8);function G(x){return(0,XTe.mod)(x,n)}function q(x){return G(Uf.bytesToNumberLE(x))}function T(x){let v=a;x=(0,Rp.ensureBytes)("private key",x,v);let D=(0,Rp.ensureBytes)("hashed private key",o(x),2*v),K=m(D.slice(0,v)),M=D.slice(v,2*v),j=q(K),J=L.multiply(j),Z=J.toRawBytes();return{head:K,prefix:M,scalar:j,point:J,pointBytes:Z}}function E(x){return T(x).pointBytes}function k(x=new Uint8Array,...v){let D=Uf.concatBytes(...v);return q(o(p(D,(0,Rp.ensureBytes)("context",x),!!i)))}function f(x,v,D={}){x=(0,Rp.ensureBytes)("message",x),i&&(x=i(x));let{prefix:K,scalar:M,pointBytes:j}=T(v),J=k(D.context,K,x),Z=L.multiply(J).toRawBytes(),V=k(D.context,Z,j,x),H=G(J+V*M);I(H);let X=Uf.concatBytes(Z,Uf.numberToBytesLE(H,r.BYTES));return(0,Rp.ensureBytes)("result",X,a*2)}let y=eIe;function w(x,v,D,K=y){let{context:M,zip215:j}=K,J=r.BYTES;x=(0,Rp.ensureBytes)("signature",x,2*J),v=(0,Rp.ensureBytes)("message",v),i&&(v=i(v));let Z=Uf.bytesToNumberLE(x.slice(J,2*J)),V,H,X;try{V=N.fromHex(D,j),H=N.fromHex(x.slice(0,J),j),X=L.multiplyUnsafe(Z)}catch{return!1}if(!j&&V.isSmallOrder())return!1;let ee=k(M,H.toRawBytes(),V.toRawBytes(),v);return H.add(V.multiplyUnsafe(ee)).subtract(X).clearCofactor().equals(N.ZERO)}return L._setWindowSize(8),{CURVE:e,getPublicKey:E,sign:f,verify:w,ExtendedPoint:N,utils:{getExtendedPublicKey:T,randomPrivateKey:()=>s(r.BYTES),precompute(x=8,v=N.BASE){return v._setWindowSize(x),v.multiply(BigInt(3)),v}}}}b8.twistedEdwards=rIe});var Dee=W(v8=>{"use strict";h();Object.defineProperty(v8,"__esModule",{value:!0});v8.montgomery=void 0;var Ree=kp(),Kv=nu(),Z_=BigInt(0),AM=BigInt(1);function nIe(t){return(0,Kv.validateObject)(t,{a:"bigint"},{montgomeryBits:"isSafeInteger",nByteLength:"isSafeInteger",adjustScalarBytes:"function",domain:"function",powPminus2:"function",Gu:"bigint"}),Object.freeze({...t})}function iIe(t){let e=nIe(t),{P:r}=e,n=P=>(0,Ree.mod)(P,r),i=e.montgomeryBits,o=Math.ceil(i/8),s=e.nByteLength,a=e.adjustScalarBytes||(P=>P),d=e.powPminus2||(P=>(0,Ree.pow)(P,r-BigInt(2),r));function u(P,$,N){let L=n(P*($-N));return $=n($-L),N=n(N+L),[$,N]}function c(P){if(typeof P=="bigint"&&Z_<=P&&P=Z_;y--){let w=L>>y&AM;E^=w,k=u(E,U,q),U=k[0],q=k[1],k=u(E,G,T),G=k[0],T=k[1],E=w;let _=U+G,x=n(_*_),v=U-G,D=n(v*v),K=x-D,M=q+T,j=q-T,J=n(j*_),Z=n(M*v),V=J+Z,H=J-Z;q=n(V*V),T=n(F*n(H*H)),U=n(x*D),G=n(K*(x+n(l*K)))}k=u(E,U,q),U=k[0],q=k[1],k=u(E,G,T),G=k[0],T=k[1];let f=d(G);return n(U*f)}function p(P){return(0,Kv.numberToBytesLE)(n(P),o)}function g(P){let $=(0,Kv.ensureBytes)("u coordinate",P,o);return s===32&&($[31]&=127),(0,Kv.bytesToNumberLE)($)}function b(P){let $=(0,Kv.ensureBytes)("scalar",P),N=$.length;if(N!==o&&N!==s)throw new Error(`Expected ${o} or ${s} bytes, got ${N}`);return(0,Kv.bytesToNumberLE)(a($))}function S(P,$){let N=g($),L=b(P),F=m(N,L);if(F===Z_)throw new Error("Invalid private or public key received");return p(F)}let A=p(e.Gu);function I(P){return S(P,A)}return{scalarMult:S,scalarMultBase:I,getSharedSecret:(P,$)=>S(P,$),getPublicKey:P=>I(P),utils:{randomPrivateKey:()=>e.randomBytes(e.nByteLength)},GuBytes:A}}v8.montgomery=iIe});var IM=W(id=>{"use strict";h();Object.defineProperty(id,"__esModule",{value:!0});id.createHasher=id.isogenyMap=id.hash_to_field=id.expand_message_xof=id.expand_message_xmd=void 0;var oIe=kp(),lc=nu();function sIe(t){if((0,lc.isBytes)(t))return t;if(typeof t=="string")return(0,lc.utf8ToBytes)(t);throw new Error("DST must be Uint8Array or string")}var aIe=lc.bytesToNumberBE;function Dp(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 cIe(t,e){let r=new Uint8Array(t.length);for(let n=0;n255&&(e=n((0,lc.concatBytes)((0,lc.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,lc.concatBytes)(e,Dp(e.length,1)),d=Dp(0,o),u=Dp(r,2),c=new Array(s),l=n((0,lc.concatBytes)(d,t,u,Dp(0,1),a));c[0]=n((0,lc.concatBytes)(l,Dp(1,1),a));for(let p=1;p<=s;p++){let g=[cIe(l,c[p-1]),Dp(p+1,1),a];c[p]=n((0,lc.concatBytes)(...g))}return(0,lc.concatBytes)(...c).slice(0,r)}id.expand_message_xmd=Mee;function Bee(t,e,r,n,i){if(X_(t),X_(e),TM(r),e.length>255){let o=Math.ceil(2*n/8);e=i.create({dkLen:o}).update((0,lc.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(Dp(r,2)).update(e).update(Dp(e.length,1)).digest()}id.expand_message_xof=Bee;function PM(t,e,r){(0,lc.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;X_(t),TM(e);let u=sIe(d),c=n.toString(2).length,l=Math.ceil((c+i)/8),m=e*o*l,p;if(a==="xmd")p=Mee(t,u,m,s);else if(a==="xof")p=Bee(t,u,m,i,s);else if(a==="_internal_pass")p=t;else throw new Error('expand must be "xmd" or "xof"');let g=new Array(e);for(let b=0;bArray.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}}}id.isogenyMap=dIe;function uIe(t,e,r){if(typeof e!="function")throw new Error("mapToCurve() must be defined");return{hashToCurve(n,i){let o=PM(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=PM(n,1,{...r,DST:r.encodeDST,...i}),s=t.fromAffine(e(o[0])).clearCofactor();return s.assertValidity(),s}}}id.createHasher=uIe});var Wee=W(Ct=>{"use strict";h();Object.defineProperty(Ct,"__esModule",{value:!0});Ct.hash_to_ristretto255=Ct.hashToRistretto255=Ct.RistrettoPoint=Ct.encodeToCurve=Ct.hashToCurve=Ct.edwardsToMontgomeryPriv=Ct.edwardsToMontgomery=Ct.edwardsToMontgomeryPub=Ct.x25519=Ct.ed25519ph=Ct.ed25519ctx=Ct.ed25519=Ct.ED25519_TORSION_SUBGROUP=void 0;var _8=fee(),Q_=Ap(),BM=kee(),lIe=Dee(),rn=kp(),y0=nu(),Kee=IM(),ex=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),DM=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),fIe=BigInt(0),ul=BigInt(1),w8=BigInt(2),hIe=BigInt(5),Cee=BigInt(10),pIe=BigInt(20),mIe=BigInt(40),Oee=BigInt(80);function qee(t){let e=ex,n=t*t%e*t%e,i=(0,rn.pow2)(n,w8,e)*n%e,o=(0,rn.pow2)(i,ul,e)*t%e,s=(0,rn.pow2)(o,hIe,e)*o%e,a=(0,rn.pow2)(s,Cee,e)*s%e,d=(0,rn.pow2)(a,pIe,e)*a%e,u=(0,rn.pow2)(d,mIe,e)*d%e,c=(0,rn.pow2)(u,Oee,e)*u%e,l=(0,rn.pow2)(c,Oee,e)*u%e,m=(0,rn.pow2)(l,Cee,e)*s%e;return{pow_p_5_8:(0,rn.pow2)(m,w8,e)*t%e,b2:n}}function Lee(t){return t[0]&=248,t[31]&=127,t[31]|=64,t}function CM(t,e){let r=ex,n=(0,rn.mod)(e*e*e,r),i=(0,rn.mod)(n*n*e,r),o=qee(t*i).pow_p_5_8,s=(0,rn.mod)(t*n*o,r),a=(0,rn.mod)(e*s*s,r),d=s,u=(0,rn.mod)(s*DM,r),c=a===t,l=a===(0,rn.mod)(-t,r),m=a===(0,rn.mod)(-t*DM,r);return c&&(s=d),(l||m)&&(s=u),(0,rn.isNegativeLE)(s,r)&&(s=(0,rn.mod)(-s,r)),{isValid:c||l,value:s}}Ct.ED25519_TORSION_SUBGROUP=["0100000000000000000000000000000000000000000000000000000000000000","c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac037a","0000000000000000000000000000000000000000000000000000000000000080","26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc05","ecffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f","26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc85","0000000000000000000000000000000000000000000000000000000000000000","c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac03fa"];var Ke=(0,rn.Field)(ex,void 0,!0),tx={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:Ke,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:BigInt(8),Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:_8.sha512,randomBytes:Q_.randomBytes,adjustScalarBytes:Lee,uvRatio:CM};Ct.ed25519=(0,BM.twistedEdwards)(tx);function Fee(t,e,r){if(e.length>255)throw new Error("Context is too big");return(0,Q_.concatBytes)((0,Q_.utf8ToBytes)("SigEd25519 no Ed25519 collisions"),new Uint8Array([r?1:0,e.length]),e,t)}Ct.ed25519ctx=(0,BM.twistedEdwards)({...tx,domain:Fee});Ct.ed25519ph=(0,BM.twistedEdwards)({...tx,domain:Fee,prehash:_8.sha512});Ct.x25519=(0,lIe.montgomery)({P:ex,a:BigInt(486662),montgomeryBits:255,nByteLength:32,Gu:BigInt(9),powPminus2:t=>{let e=ex,{pow_p_5_8:r,b2:n}=qee(t);return(0,rn.mod)((0,rn.pow2)(r,BigInt(3),e)*n,e)},adjustScalarBytes:Lee,randomBytes:Q_.randomBytes});function zee(t){let{y:e}=Ct.ed25519.ExtendedPoint.fromHex(t),r=BigInt(1);return Ke.toBytes(Ke.create((r+e)*Ke.inv(r-e)))}Ct.edwardsToMontgomeryPub=zee;Ct.edwardsToMontgomery=zee;function yIe(t){let e=tx.hash(t.subarray(0,32));return tx.adjustScalarBytes(e).subarray(0,32)}Ct.edwardsToMontgomeryPriv=yIe;var gIe=(Ke.ORDER+BigInt(3))/BigInt(8),bIe=Ke.pow(w8,gIe),$ee=Ke.sqrt(Ke.neg(Ke.ONE)),vIe=(Ke.ORDER-BigInt(5))/BigInt(8),Nee=BigInt(486662);function wIe(t){let e=Ke.sqr(t);e=Ke.mul(e,w8);let r=Ke.add(e,Ke.ONE),n=Ke.neg(Nee),i=Ke.sqr(r),o=Ke.mul(i,r),s=Ke.mul(e,Nee);s=Ke.mul(s,n),s=Ke.add(s,i),s=Ke.mul(s,n);let a=Ke.sqr(o);i=Ke.sqr(a),a=Ke.mul(a,o),a=Ke.mul(a,s),i=Ke.mul(i,a);let d=Ke.pow(i,vIe);d=Ke.mul(d,a);let u=Ke.mul(d,$ee);i=Ke.sqr(d),i=Ke.mul(i,o);let c=Ke.eql(i,s),l=Ke.cmov(u,d,c),m=Ke.mul(n,e),p=Ke.mul(d,t);p=Ke.mul(p,bIe);let g=Ke.mul(p,$ee),b=Ke.mul(s,e);i=Ke.sqr(p),i=Ke.mul(i,o);let S=Ke.eql(i,b),A=Ke.cmov(g,p,S);i=Ke.sqr(l),i=Ke.mul(i,o);let I=Ke.eql(i,s),P=Ke.cmov(m,n,I),$=Ke.cmov(A,l,I),N=Ke.isOdd($);return $=Ke.cmov($,Ke.neg($),I!==N),{xMn:P,xMd:r,yMn:$,yMd:ul}}var _Ie=(0,rn.FpSqrtEven)(Ke,Ke.neg(BigInt(486664)));function xIe(t){let{xMn:e,xMd:r,yMn:n,yMd:i}=wIe(t),o=Ke.mul(e,i);o=Ke.mul(o,_Ie);let s=Ke.mul(r,n),a=Ke.sub(e,r),d=Ke.add(e,r),u=Ke.mul(s,d),c=Ke.eql(u,Ke.ZERO);o=Ke.cmov(o,Ke.ZERO,c),s=Ke.cmov(s,Ke.ONE,c),a=Ke.cmov(a,Ke.ONE,c),d=Ke.cmov(d,Ke.ONE,c);let l=Ke.invertBatch([s,d]);return{x:Ke.mul(o,l[0]),y:Ke.mul(a,l[1])}}var Gee=(0,Kee.createHasher)(Ct.ed25519.ExtendedPoint,t=>xIe(t[0]),{DST:"edwards25519_XMD:SHA-512_ELL2_RO_",encodeDST:"edwards25519_XMD:SHA-512_ELL2_NU_",p:Ke.ORDER,m:1,k:128,expand:"xmd",hash:_8.sha512});Ct.hashToCurve=Gee.hashToCurve;Ct.encodeToCurve=Gee.encodeToCurve;function kM(t){if(!(t instanceof ou))throw new Error("RistrettoPoint expected")}var MM=DM,EIe=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),SIe=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),AIe=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),PIe=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952"),jee=t=>CM(ul,t),TIe=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),RM=t=>Ct.ed25519.CURVE.Fp.create((0,y0.bytesToNumberLE)(t)&TIe);function Uee(t){let{d:e}=Ct.ed25519.CURVE,r=Ct.ed25519.CURVE.Fp.ORDER,n=Ct.ed25519.CURVE.Fp.create,i=n(MM*t*t),o=n((i+ul)*AIe),s=BigInt(-1),a=n((s-e*i)*n(i+e)),{isValid:d,value:u}=CM(o,a),c=n(u*t);(0,rn.isNegativeLE)(c,r)||(c=n(-c)),d||(u=c),d||(s=i);let l=n(s*(i-ul)*PIe-a),m=u*u,p=n((u+u)*a),g=n(l*EIe),b=n(ul-m),S=n(ul+m);return new Ct.ed25519.ExtendedPoint(n(p*S),n(b*g),n(g*S),n(p*b))}var ou=class t{constructor(e){this.ep=e}static fromAffine(e){return new t(Ct.ed25519.ExtendedPoint.fromAffine(e))}static hashToCurve(e){e=(0,y0.ensureBytes)("ristrettoHash",e,64);let r=RM(e.slice(0,32)),n=Uee(r),i=RM(e.slice(32,64)),o=Uee(i);return new t(n.add(o))}static fromHex(e){e=(0,y0.ensureBytes)("ristrettoHex",e,32);let{a:r,d:n}=Ct.ed25519.CURVE,i=Ct.ed25519.CURVE.Fp.ORDER,o=Ct.ed25519.CURVE.Fp.create,s="RistrettoPoint.fromHex: the hex is not valid encoding of RistrettoPoint",a=RM(e);if(!(0,y0.equalBytes)((0,y0.numberToBytesLE)(a,32),e)||(0,rn.isNegativeLE)(a,i))throw new Error(s);let d=o(a*a),u=o(ul+r*d),c=o(ul-r*d),l=o(u*u),m=o(c*c),p=o(r*n*l-m),{isValid:g,value:b}=jee(o(p*m)),S=o(b*c),A=o(b*S*p),I=o((a+a)*S);(0,rn.isNegativeLE)(I,i)&&(I=o(-I));let P=o(u*A),$=o(I*P);if(!g||(0,rn.isNegativeLE)($,i)||P===fIe)throw new Error(s);return new t(new Ct.ed25519.ExtendedPoint(I,P,ul,$))}toRawBytes(){let{ex:e,ey:r,ez:n,et:i}=this.ep,o=Ct.ed25519.CURVE.Fp.ORDER,s=Ct.ed25519.CURVE.Fp.create,a=s(s(n+r)*s(n-r)),d=s(e*r),u=s(d*d),{value:c}=jee(s(a*u)),l=s(c*a),m=s(c*d),p=s(l*m*i),g;if((0,rn.isNegativeLE)(i*p,o)){let S=s(r*MM),A=s(e*MM);e=S,r=A,g=s(l*SIe)}else g=m;(0,rn.isNegativeLE)(e*p,o)&&(r=s(-r));let b=s((n-r)*g);return(0,rn.isNegativeLE)(b,o)&&(b=s(-b)),(0,y0.numberToBytesLE)(b,32)}toHex(){return(0,y0.bytesToHex)(this.toRawBytes())}toString(){return this.toHex()}equals(e){kM(e);let{ex:r,ey:n}=this.ep,{ex:i,ey:o}=e.ep,s=Ct.ed25519.CURVE.Fp.create,a=s(r*o)===s(n*i),d=s(n*o)===s(r*i);return a||d}add(e){return kM(e),new t(this.ep.add(e.ep))}subtract(e){return kM(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())}};Ct.RistrettoPoint=(ou.BASE||(ou.BASE=new ou(Ct.ed25519.ExtendedPoint.BASE)),ou.ZERO||(ou.ZERO=new ou(Ct.ed25519.ExtendedPoint.ZERO)),ou);var IIe=(t,e)=>{let r=e.DST,n=typeof r=="string"?(0,Q_.utf8ToBytes)(r):r,i=(0,Kee.expand_message_xmd)(t,n,64,_8.sha512);return ou.hashToCurve(i)};Ct.hashToRistretto255=IIe;Ct.hash_to_ristretto255=Ct.hashToRistretto255});var Hee=W(qv=>{"use strict";h();Object.defineProperty(qv,"__esModule",{value:!0});qv.sha224=qv.sha256=void 0;var kIe=lM(),od=Ap(),RIe=(t,e,r)=>t&e^~t&r,DIe=(t,e,r)=>t&e^t&r^e&r,MIe=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]),Mp=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Bp=new Uint32Array(64),x8=class extends kIe.SHA2{constructor(){super(64,32,8,!1),this.A=Mp[0]|0,this.B=Mp[1]|0,this.C=Mp[2]|0,this.D=Mp[3]|0,this.E=Mp[4]|0,this.F=Mp[5]|0,this.G=Mp[6]|0,this.H=Mp[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)Bp[l]=e.getUint32(r,!1);for(let l=16;l<64;l++){let m=Bp[l-15],p=Bp[l-2],g=(0,od.rotr)(m,7)^(0,od.rotr)(m,18)^m>>>3,b=(0,od.rotr)(p,17)^(0,od.rotr)(p,19)^p>>>10;Bp[l]=b+Bp[l-7]+g+Bp[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 m=(0,od.rotr)(a,6)^(0,od.rotr)(a,11)^(0,od.rotr)(a,25),p=c+m+RIe(a,d,u)+MIe[l]+Bp[l]|0,b=((0,od.rotr)(n,2)^(0,od.rotr)(n,13)^(0,od.rotr)(n,22))+DIe(n,i,o)|0;c=u,u=d,d=a,a=s+p|0,s=o,o=i,i=n,n=p+b|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(){Bp.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}},OM=class extends x8{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}};qv.sha256=(0,od.wrapConstructor)(()=>new x8);qv.sha224=(0,od.wrapConstructor)(()=>new OM)});var NM=W(Hi=>{"use strict";h();Object.defineProperty(Hi,"__esModule",{value:!0});Hi.mapToCurveSimpleSWU=Hi.SWUFpSqrtRatio=Hi.weierstrass=Hi.weierstrassPoints=Hi.DER=void 0;var Lv=kp(),zn=nu(),ll=nu(),$M=SM();function BIe(t){let e=(0,$M.validateBasic)(t);zn.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:CIe,hexToBytes:OIe}=zn;Hi.DER={Err:class extends Error{constructor(e=""){super(e)}},_parseInt(t){let{Err:e}=Hi.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:CIe(n),l:t.subarray(r+2)}},toSig(t){let{Err:e}=Hi.DER,r=typeof t=="string"?OIe(t):t;if(!zn.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}=Hi.DER._parseInt(r.subarray(2)),{d:s,l:a}=Hi.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 su=BigInt(0),di=BigInt(1),Cp=BigInt(2),E8=BigInt(3),Vee=BigInt(4);function Jee(t){let e=BIe(t),{Fp:r}=e,n=e.toBytes||((g,b,S)=>{let A=b.toAffine();return zn.concatBytes(Uint8Array.from([4]),r.toBytes(A.x),r.toBytes(A.y))}),i=e.fromBytes||(g=>{let b=g.subarray(1),S=r.fromBytes(b.subarray(0,r.BYTES)),A=r.fromBytes(b.subarray(r.BYTES,2*r.BYTES));return{x:S,y:A}});function o(g){let{a:b,b:S}=e,A=r.sqr(g),I=r.mul(A,g);return r.add(r.add(I,r.mul(g,b)),S)}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"&&sur.eql(P,r.ZERO);return I(S)&&I(A)?l.ZERO:new l(S,A,r.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(b){let S=r.invertBatch(b.map(A=>A.pz));return b.map((A,I)=>A.toAffine(S[I])).map(l.fromAffine)}static fromHex(b){let S=l.fromAffine(i((0,ll.ensureBytes)("pointHex",b)));return S.assertValidity(),S}static fromPrivateKey(b){return l.BASE.multiply(d(b))}_setWindowSize(b){this._WINDOW_SIZE=b,u.delete(this)}assertValidity(){if(this.is0()){if(e.allowInfinityPoint&&!r.is0(this.py))return;throw new Error("bad point: ZERO")}let{x:b,y:S}=this.toAffine();if(!r.isValid(b)||!r.isValid(S))throw new Error("bad point: x or y not FE");let A=r.sqr(S),I=o(b);if(!r.eql(A,I))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){let{y:b}=this.toAffine();if(r.isOdd)return!r.isOdd(b);throw new Error("Field doesn't support isOdd")}equals(b){c(b);let{px:S,py:A,pz:I}=this,{px:P,py:$,pz:N}=b,L=r.eql(r.mul(S,N),r.mul(P,I)),F=r.eql(r.mul(A,N),r.mul($,I));return L&&F}negate(){return new l(this.px,r.neg(this.py),this.pz)}double(){let{a:b,b:S}=e,A=r.mul(S,E8),{px:I,py:P,pz:$}=this,N=r.ZERO,L=r.ZERO,F=r.ZERO,U=r.mul(I,I),G=r.mul(P,P),q=r.mul($,$),T=r.mul(I,P);return T=r.add(T,T),F=r.mul(I,$),F=r.add(F,F),N=r.mul(b,F),L=r.mul(A,q),L=r.add(N,L),N=r.sub(G,L),L=r.add(G,L),L=r.mul(N,L),N=r.mul(T,N),F=r.mul(A,F),q=r.mul(b,q),T=r.sub(U,q),T=r.mul(b,T),T=r.add(T,F),F=r.add(U,U),U=r.add(F,U),U=r.add(U,q),U=r.mul(U,T),L=r.add(L,U),q=r.mul(P,$),q=r.add(q,q),U=r.mul(q,T),N=r.sub(N,U),F=r.mul(q,G),F=r.add(F,F),F=r.add(F,F),new l(N,L,F)}add(b){c(b);let{px:S,py:A,pz:I}=this,{px:P,py:$,pz:N}=b,L=r.ZERO,F=r.ZERO,U=r.ZERO,G=e.a,q=r.mul(e.b,E8),T=r.mul(S,P),E=r.mul(A,$),k=r.mul(I,N),f=r.add(S,A),y=r.add(P,$);f=r.mul(f,y),y=r.add(T,E),f=r.sub(f,y),y=r.add(S,I);let w=r.add(P,N);return y=r.mul(y,w),w=r.add(T,k),y=r.sub(y,w),w=r.add(A,I),L=r.add($,N),w=r.mul(w,L),L=r.add(E,k),w=r.sub(w,L),U=r.mul(G,y),L=r.mul(q,k),U=r.add(L,U),L=r.sub(E,U),U=r.add(E,U),F=r.mul(L,U),E=r.add(T,T),E=r.add(E,T),k=r.mul(G,k),y=r.mul(q,y),E=r.add(E,k),k=r.sub(T,k),k=r.mul(G,k),y=r.add(y,k),T=r.mul(E,y),F=r.add(F,T),T=r.mul(w,y),L=r.mul(f,L),L=r.sub(L,T),T=r.mul(f,E),U=r.mul(w,U),U=r.add(U,T),new l(L,F,U)}subtract(b){return this.add(b.negate())}is0(){return this.equals(l.ZERO)}wNAF(b){return p.wNAFCached(this,u,b,S=>{let A=r.invertBatch(S.map(I=>I.pz));return S.map((I,P)=>I.toAffine(A[P])).map(l.fromAffine)})}multiplyUnsafe(b){let S=l.ZERO;if(b===su)return S;if(a(b),b===di)return this;let{endo:A}=e;if(!A)return p.unsafeLadder(this,b);let{k1neg:I,k1:P,k2neg:$,k2:N}=A.splitScalar(b),L=S,F=S,U=this;for(;P>su||N>su;)P&di&&(L=L.add(U)),N&di&&(F=F.add(U)),U=U.double(),P>>=di,N>>=di;return I&&(L=L.negate()),$&&(F=F.negate()),F=new l(r.mul(F.px,A.beta),F.py,F.pz),L.add(F)}multiply(b){a(b);let S=b,A,I,{endo:P}=e;if(P){let{k1neg:$,k1:N,k2neg:L,k2:F}=P.splitScalar(S),{p:U,f:G}=this.wNAF(N),{p:q,f:T}=this.wNAF(F);U=p.constTimeNegate($,U),q=p.constTimeNegate(L,q),q=new l(r.mul(q.px,P.beta),q.py,q.pz),A=U.add(q),I=G.add(T)}else{let{p:$,f:N}=this.wNAF(S);A=$,I=N}return l.normalizeZ([A,I])[0]}multiplyAndAddUnsafe(b,S,A){let I=l.BASE,P=(N,L)=>L===su||L===di||!N.equals(I)?N.multiplyUnsafe(L):N.multiply(L),$=P(this,S).add(P(b,A));return $.is0()?void 0:$}toAffine(b){let{px:S,py:A,pz:I}=this,P=this.is0();b==null&&(b=P?r.ONE:r.inv(I));let $=r.mul(S,b),N=r.mul(A,b),L=r.mul(I,b);if(P)return{x:r.ZERO,y:r.ZERO};if(!r.eql(L,r.ONE))throw new Error("invZ was invalid");return{x:$,y:N}}isTorsionFree(){let{h:b,isTorsionFree:S}=e;if(b===di)return!0;if(S)return S(l,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:b,clearCofactor:S}=e;return b===di?this:S?S(l,this):this.multiplyUnsafe(e.h)}toRawBytes(b=!0){return this.assertValidity(),n(l,this,b)}toHex(b=!0){return zn.bytesToHex(this.toRawBytes(b))}}l.BASE=new l(e.Gx,e.Gy,r.ONE),l.ZERO=new l(r.ZERO,r.ONE,r.ZERO);let m=e.nBitLength,p=(0,$M.wNAF)(l,e.endo?Math.ceil(m/2):m);return{CURVE:e,ProjectivePoint:l,normPrivateKeyToScalar:d,weierstrassEquation:o,isWithinCurveOrder:s}}Hi.weierstrassPoints=Jee;function $Ie(t){let e=(0,$M.validateBasic)(t);return zn.validateObject(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function NIe(t){let e=$Ie(t),{Fp:r,n}=e,i=r.BYTES+1,o=2*r.BYTES+1;function s(y){return suzn.bytesToHex(zn.numberToBytesBE(y,e.nByteLength));function g(y){let w=n>>di;return y>w}function b(y){return g(y)?a(-y):y}let S=(y,w,_)=>zn.bytesToNumberBE(y.slice(w,_));class A{constructor(w,_,x){this.r=w,this.s=_,this.recovery=x,this.assertValidity()}static fromCompact(w){let _=e.nByteLength;return w=(0,ll.ensureBytes)("compactSignature",w,_*2),new A(S(w,0,_),S(w,_,2*_))}static fromDER(w){let{r:_,s:x}=Hi.DER.toSig((0,ll.ensureBytes)("DER",w));return new A(_,x)}assertValidity(){if(!m(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!m(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(w){return new A(this.r,this.s,w)}recoverPublicKey(w){let{r:_,s:x,recovery:v}=this,D=F((0,ll.ensureBytes)("msgHash",w));if(v==null||![0,1,2,3].includes(v))throw new Error("recovery id invalid");let K=v===2||v===3?_+e.n:_;if(K>=r.ORDER)throw new Error("recovery id 2 or 3 invalid");let M=v&1?"03":"02",j=u.fromHex(M+p(K)),J=d(K),Z=a(-D*J),V=a(x*J),H=u.BASE.multiplyAndAddUnsafe(j,Z,V);if(!H)throw new Error("point at infinify");return H.assertValidity(),H}hasHighS(){return g(this.s)}normalizeS(){return this.hasHighS()?new A(this.r,a(-this.s),this.recovery):this}toDERRawBytes(){return zn.hexToBytes(this.toDERHex())}toDERHex(){return Hi.DER.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return zn.hexToBytes(this.toCompactHex())}toCompactHex(){return p(this.r)+p(this.s)}}let I={isValidPrivateKey(y){try{return c(y),!0}catch{return!1}},normPrivateKeyToScalar:c,randomPrivateKey:()=>{let y=Lv.getMinHashLength(e.n);return Lv.mapHashToField(e.randomBytes(y),e.n)},precompute(y=8,w=u.BASE){return w._setWindowSize(y),w.multiply(BigInt(3)),w}};function P(y,w=!0){return u.fromPrivateKey(y).toRawBytes(w)}function $(y){let w=zn.isBytes(y),_=typeof y=="string",x=(w||_)&&y.length;return w?x===i||x===o:_?x===2*i||x===2*o:y instanceof u}function N(y,w,_=!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(_)}let L=e.bits2int||function(y){let w=zn.bytesToNumberBE(y),_=y.length*8-e.nBitLength;return _>0?w>>BigInt(_):w},F=e.bits2int_modN||function(y){return a(L(y))},U=zn.bitMask(e.nBitLength);function G(y){if(typeof y!="bigint")throw new Error("bigint expected");if(!(su<=y&&yee in _))throw new Error("sign() legacy options not supported");let{hash:x,randomBytes:v}=e,{lowS:D,prehash:K,extraEntropy:M}=_;D==null&&(D=!0),y=(0,ll.ensureBytes)("msgHash",y),K&&(y=(0,ll.ensureBytes)("prehashed msgHash",x(y)));let j=F(y),J=c(w),Z=[G(J),G(j)];if(M!=null){let ee=M===!0?v(r.BYTES):M;Z.push((0,ll.ensureBytes)("extraEntropy",ee))}let V=zn.concatBytes(...Z),H=j;function X(ee){let ue=L(ee);if(!m(ue))return;let ae=d(ue),ce=u.BASE.multiply(ue).toAffine(),pe=a(ce.x);if(pe===su)return;let Ee=a(ae*a(H+pe*J));if(Ee===su)return;let Ue=(ce.x===pe?0:2)|Number(ce.y&di),le=Ee;return D&&g(Ee)&&(le=b(Ee),Ue^=1),new A(pe,le,Ue)}return{seed:V,k2sig:X}}let T={lowS:e.lowS,prehash:!1},E={lowS:e.lowS,prehash:!1};function k(y,w,_=T){let{seed:x,k2sig:v}=q(y,w,_),D=e;return zn.createHmacDrbg(D.hash.outputLen,D.nByteLength,D.hmac)(x,v)}u.BASE._setWindowSize(8);function f(y,w,_,x=E){let v=y;if(w=(0,ll.ensureBytes)("msgHash",w),_=(0,ll.ensureBytes)("publicKey",_),"strict"in x)throw new Error("options.strict was renamed to lowS");let{lowS:D,prehash:K}=x,M,j;try{if(typeof v=="string"||zn.isBytes(v))try{M=A.fromDER(v)}catch(ce){if(!(ce instanceof Hi.DER.Err))throw ce;M=A.fromCompact(v)}else if(typeof v=="object"&&typeof v.r=="bigint"&&typeof v.s=="bigint"){let{r:ce,s:pe}=v;M=new A(ce,pe)}else throw new Error("PARSE");j=u.fromHex(_)}catch(ce){if(ce.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(D&&M.hasHighS())return!1;K&&(w=e.hash(w));let{r:J,s:Z}=M,V=F(w),H=d(Z),X=a(V*H),ee=a(J*H),ue=u.BASE.multiplyAndAddUnsafe(j,X,ee)?.toAffine();return ue?a(ue.x)===J:!1}return{CURVE:e,getPublicKey:P,getSharedSecret:N,sign:k,verify:f,ProjectivePoint:u,Signature:A,utils:I}}Hi.weierstrass=NIe;function Yee(t,e){let r=t.ORDER,n=su;for(let g=r-di;g%Cp===su;g/=Cp)n+=di;let i=n,o=Cp<{let S=l,A=t.pow(b,u),I=t.sqr(A);I=t.mul(I,b);let P=t.mul(g,I);P=t.pow(P,d),P=t.mul(P,A),A=t.mul(P,b),I=t.mul(P,g);let $=t.mul(I,A);P=t.pow($,c);let N=t.eql(P,t.ONE);A=t.mul(I,m),P=t.mul($,S),I=t.cmov(A,I,N),$=t.cmov(P,$,N);for(let L=i;L>di;L--){let F=L-Cp;F=Cp<{let I=t.sqr(A),P=t.mul(S,A);I=t.mul(I,P);let $=t.pow(I,g);$=t.mul($,P);let N=t.mul($,b),L=t.mul(t.sqr($),A),F=t.eql(L,S),U=t.cmov(N,$,F);return{isValid:F,value:U}}}return p}Hi.SWUFpSqrtRatio=Yee;function jIe(t,e){if(Lv.validateField(t),!t.isValid(e.A)||!t.isValid(e.B)||!t.isValid(e.Z))throw new Error("mapToCurveSimpleSWU: invalid opts");let r=Yee(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:m,value:p}=r(o,u);l=t.mul(i,n),l=t.mul(l,p),c=t.cmov(c,s,m),l=t.cmov(l,p,m);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}}}Hi.mapToCurveSimpleSWU=jIe});var Xee=W(g0=>{"use strict";h();Object.defineProperty(g0,"__esModule",{value:!0});g0.hmac=g0.HMAC=void 0;var S8=oM(),Zee=Ap(),rx=class extends Zee.Hash{constructor(e,r){super(),this.finished=!1,this.destroyed=!1,(0,S8.hash)(e);let n=(0,Zee.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 rx(t,e).update(r).digest();g0.hmac=UIe;g0.hmac.create=(t,e)=>new rx(t,e)});var tte=W(Fv=>{"use strict";h();Object.defineProperty(Fv,"__esModule",{value:!0});Fv.createCurve=Fv.getHash=void 0;var KIe=Xee(),Qee=Ap(),qIe=NM();function ete(t){return{hash:t,hmac:(e,...r)=>(0,KIe.hmac)(t,e,(0,Qee.concatBytes)(...r)),randomBytes:Qee.randomBytes}}Fv.getHash=ete;function LIe(t,e){let r=n=>(0,qIe.weierstrass)({...t,...ete(n)});return Object.freeze({...r(e),create:r})}Fv.createCurve=LIe});var fte=W(Aa=>{"use strict";h();Object.defineProperty(Aa,"__esModule",{value:!0});Aa.encodeToCurve=Aa.hashToCurve=Aa.schnorr=Aa.secp256k1=void 0;var A8=Hee(),FIe=Ap(),bo=kp(),zIe=NM(),ks=nu(),ite=IM(),GIe=tte(),k8=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),P8=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),ote=BigInt(1),T8=BigInt(2),rte=(t,e)=>(t+e/T8)/e;function ste(t){let e=k8,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,bo.pow2)(c,r,e)*c%e,m=(0,bo.pow2)(l,r,e)*c%e,p=(0,bo.pow2)(m,T8,e)*u%e,g=(0,bo.pow2)(p,i,e)*p%e,b=(0,bo.pow2)(g,o,e)*g%e,S=(0,bo.pow2)(b,a,e)*b%e,A=(0,bo.pow2)(S,d,e)*S%e,I=(0,bo.pow2)(A,a,e)*b%e,P=(0,bo.pow2)(I,r,e)*c%e,$=(0,bo.pow2)(P,s,e)*g%e,N=(0,bo.pow2)($,n,e)*u%e,L=(0,bo.pow2)(N,T8,e);if(!Op.eql(Op.sqr(L),t))throw new Error("Cannot find square root");return L}var Op=(0,bo.Field)(k8,void 0,void 0,{sqrt:ste});Aa.secp256k1=(0,GIe.createCurve)({a:BigInt(0),b:BigInt(7),Fp:Op,n:P8,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:t=>{let e=P8,r=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-ote*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),o=r,s=BigInt("0x100000000000000000000000000000000"),a=rte(o*t,e),d=rte(-n*t,e),u=(0,bo.mod)(t-a*r-d*i,e),c=(0,bo.mod)(-a*n-d*o,e),l=u>s,m=c>s;if(l&&(u=e-u),m&&(c=e-c),u>s||c>s)throw new Error("splitScalar: Endomorphism failed, k="+t);return{k1neg:l,k1:u,k2neg:m,k2:c}}}},A8.sha256);var R8=BigInt(0),ate=t=>typeof t=="bigint"&&R8typeof t=="bigint"&&R8i.charCodeAt(0)));r=(0,ks.concatBytes)(n,n),nte[t]=r}return(0,A8.sha256)((0,ks.concatBytes)(r,...e))}var qM=t=>t.toRawBytes(!0).slice(1),UM=t=>(0,ks.numberToBytesBE)(t,32),jM=t=>(0,bo.mod)(t,k8),nx=t=>(0,bo.mod)(t,P8),LM=Aa.secp256k1.ProjectivePoint,HIe=(t,e,r)=>LM.BASE.multiplyAndAddUnsafe(t,e,r);function KM(t){let e=Aa.secp256k1.utils.normPrivateKeyToScalar(t),r=LM.fromPrivateKey(e);return{scalar:r.hasEvenY()?e:nx(-e),bytes:qM(r)}}function cte(t){if(!ate(t))throw new Error("bad x: need 0 < x < p");let e=jM(t*t),r=jM(e*t+BigInt(7)),n=ste(r);n%T8!==R8&&(n=jM(-n));let i=new LM(t,n,ote);return i.assertValidity(),i}function dte(...t){return nx((0,ks.bytesToNumberBE)(I8("BIP0340/challenge",...t)))}function VIe(t){return KM(t).bytes}function JIe(t,e,r=(0,FIe.randomBytes)(32)){let n=(0,ks.ensureBytes)("message",t),{bytes:i,scalar:o}=KM(e),s=(0,ks.ensureBytes)("auxRand",r,32),a=UM(o^(0,ks.bytesToNumberBE)(I8("BIP0340/aux",s))),d=I8("BIP0340/nonce",a,i,n),u=nx((0,ks.bytesToNumberBE)(d));if(u===R8)throw new Error("sign failed: k is zero");let{bytes:c,scalar:l}=KM(u),m=dte(c,i,n),p=new Uint8Array(64);if(p.set(c,0),p.set(UM(nx(l+m*o)),32),!ute(p,n,i))throw new Error("sign: Invalid signature produced");return p}function ute(t,e,r){let n=(0,ks.ensureBytes)("signature",t,64),i=(0,ks.ensureBytes)("message",e),o=(0,ks.ensureBytes)("publicKey",r,32);try{let s=cte((0,ks.bytesToNumberBE)(o)),a=(0,ks.bytesToNumberBE)(n.subarray(0,32));if(!ate(a))return!1;let d=(0,ks.bytesToNumberBE)(n.subarray(32,64));if(!WIe(d))return!1;let u=dte(UM(a),qM(s),i),c=HIe(s,d,nx(-u));return!(!c||!c.hasEvenY()||c.toAffine().x!==a)}catch{return!1}}Aa.schnorr={getPublicKey:VIe,sign:JIe,verify:ute,utils:{randomPrivateKey:Aa.secp256k1.utils.randomPrivateKey,lift_x:cte,pointToBytes:qM,numberToBytesBE:ks.numberToBytesBE,bytesToNumberBE:ks.bytesToNumberBE,taggedHash:I8,mod:bo.mod}};var YIe=(0,ite.isogenyMap)(Op,[["0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa8c7","0x7d3d4c80bc321d5b9f315cea7fd44c5d595d2fc0bf63b92dfff1044f17c6581","0x534c328d23f234e6e2a413deca25caece4506144037c40314ecbd0b53d9dd262","0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa88c"],["0xd35771193d94918a9ca34ccbb7b640dd86cd409542f8487d9fe6b745781eb49b","0xedadc6f64383dc1df7c4b2d51b54225406d36b641f5e41bbc52a56612a8c6d14","0x0000000000000000000000000000000000000000000000000000000000000001"],["0x4bda12f684bda12f684bda12f684bda12f684bda12f684bda12f684b8e38e23c","0xc75e0c32d5cb7c0fa9d0a54b12a0a6d5647ab046d686da6fdffc90fc201d71a3","0x29a6194691f91a73715209ef6512e576722830a201be2018a765e85a9ecee931","0x2f684bda12f684bda12f684bda12f684bda12f684bda12f684bda12f38e38d84"],["0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffff93b","0x7a06534bb8bdb49fd5e9e6632722c2989467c1bfc8e8d978dfb425d2685c2573","0x6484aa716545ca2cf3a70c3fa8fe337e0a3d21162f0d6299a7bf8192bfd2a76f","0x0000000000000000000000000000000000000000000000000000000000000001"]].map(t=>t.map(e=>BigInt(e)))),ZIe=(0,zIe.mapToCurveSimpleSWU)(Op,{A:BigInt("0x3f8731abdd661adca08a5558f0f5d272e953d363cb6f0e5d405447c01a444533"),B:BigInt("1771"),Z:Op.create(BigInt("-11"))}),lte=(0,ite.createHasher)(Aa.secp256k1.ProjectivePoint,t=>{let{x:e,y:r}=ZIe(Op.create(t[0]));return YIe(e,r)},{DST:"secp256k1_XMD:SHA-256_SSWU_RO_",encodeDST:"secp256k1_XMD:SHA-256_SSWU_NU_",p:Op.ORDER,m:1,k:128,expand:"xmd",hash:A8.sha256});Aa.hashToCurve=lte.hashToCurve;Aa.encodeToCurve=lte.encodeToCurve});var FM=W(zv=>{"use strict";h();Object.defineProperty(zv,"__esModule",{value:!0});zv.decodeHex=zv.remove0x=void 0;var XIe=ru();function hte(t){return t.startsWith("0x")||t.startsWith("0X")?t.slice(2):t}zv.remove0x=hte;function QIe(t){return(0,XIe.hexToBytes)(hte(t))}zv.decodeHex=QIe});var GM=W(Zs=>{"use strict";h();Object.defineProperty(Zs,"__esModule",{value:!0});Zs.output=Zs.exists=Zs.hash=Zs.bytes=Zs.bool=Zs.number=void 0;function D8(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`Wrong positive integer: ${t}`)}Zs.number=D8;function pte(t){if(typeof t!="boolean")throw new Error(`Expected boolean, not ${t}`)}Zs.bool=pte;function zM(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}`)}Zs.bytes=zM;function mte(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("hash must be wrapped by utils.wrapConstructor");D8(t.outputLen),D8(t.blockLen)}Zs.hash=mte;function yte(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")}Zs.exists=yte;function gte(t,e){zM(t);let r=e.outputLen;if(t.length{"use strict";h();Object.defineProperty(Gv,"__esModule",{value:!0});Gv.poly1305=Gv.wrapConstructorWithKey=void 0;var M8=ru(),WM=GM(),Uo=(t,e)=>t[e++]&255|(t[e++]&255)<<8,HM=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,M8.toBytes)(e),(0,M8.ensureBytes)(e,32);let r=Uo(e,0),n=Uo(e,2),i=Uo(e,4),o=Uo(e,6),s=Uo(e,8),a=Uo(e,10),d=Uo(e,12),u=Uo(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]=Uo(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],m=s[5],p=s[6],g=s[7],b=s[8],S=s[9],A=Uo(e,r+0),I=Uo(e,r+2),P=Uo(e,r+4),$=Uo(e,r+6),N=Uo(e,r+8),L=Uo(e,r+10),F=Uo(e,r+12),U=Uo(e,r+14),G=o[0]+(A&8191),q=o[1]+((A>>>13|I<<3)&8191),T=o[2]+((I>>>10|P<<6)&8191),E=o[3]+((P>>>7|$<<9)&8191),k=o[4]+(($>>>4|N<<12)&8191),f=o[5]+(N>>>1&8191),y=o[6]+((N>>>14|L<<2)&8191),w=o[7]+((L>>>11|F<<5)&8191),_=o[8]+((F>>>8|U<<8)&8191),x=o[9]+(U>>>5|i),v=0,D=v+G*a+q*(5*S)+T*(5*b)+E*(5*g)+k*(5*p);v=D>>>13,D&=8191,D+=f*(5*m)+y*(5*l)+w*(5*c)+_*(5*u)+x*(5*d),v+=D>>>13,D&=8191;let K=v+G*d+q*a+T*(5*S)+E*(5*b)+k*(5*g);v=K>>>13,K&=8191,K+=f*(5*p)+y*(5*m)+w*(5*l)+_*(5*c)+x*(5*u),v+=K>>>13,K&=8191;let M=v+G*u+q*d+T*a+E*(5*S)+k*(5*b);v=M>>>13,M&=8191,M+=f*(5*g)+y*(5*p)+w*(5*m)+_*(5*l)+x*(5*c),v+=M>>>13,M&=8191;let j=v+G*c+q*u+T*d+E*a+k*(5*S);v=j>>>13,j&=8191,j+=f*(5*b)+y*(5*g)+w*(5*p)+_*(5*m)+x*(5*l),v+=j>>>13,j&=8191;let J=v+G*l+q*c+T*u+E*d+k*a;v=J>>>13,J&=8191,J+=f*(5*S)+y*(5*b)+w*(5*g)+_*(5*p)+x*(5*m),v+=J>>>13,J&=8191;let Z=v+G*m+q*l+T*c+E*u+k*d;v=Z>>>13,Z&=8191,Z+=f*a+y*(5*S)+w*(5*b)+_*(5*g)+x*(5*p),v+=Z>>>13,Z&=8191;let V=v+G*p+q*m+T*l+E*c+k*u;v=V>>>13,V&=8191,V+=f*d+y*a+w*(5*S)+_*(5*b)+x*(5*g),v+=V>>>13,V&=8191;let H=v+G*g+q*p+T*m+E*l+k*c;v=H>>>13,H&=8191,H+=f*u+y*d+w*a+_*(5*S)+x*(5*b),v+=H>>>13,H&=8191;let X=v+G*b+q*g+T*p+E*m+k*l;v=X>>>13,X&=8191,X+=f*c+y*u+w*d+_*a+x*(5*S),v+=X>>>13,X&=8191;let ee=v+G*S+q*b+T*g+E*p+k*m;v=ee>>>13,ee&=8191,ee+=f*l+y*c+w*u+_*d+x*a,v+=ee>>>13,ee&=8191,v=(v<<2)+v|0,v=v+D|0,D=v&8191,v=v>>>13,K+=v,o[0]=D,o[1]=K,o[2]=M,o[3]=j,o[4]=J,o[5]=Z,o[6]=V,o[7]=H,o[8]=X,o[9]=ee}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){WM.default.exists(this);let{buffer:r,blockLen:n}=this;e=(0,M8.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 bte(t){let e=(n,i)=>t(i).update((0,M8.toBytes)(n)).digest(),r=t(new Uint8Array(32));return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=n=>t(n),e}Gv.wrapConstructorWithKey=bte;Gv.poly1305=bte(t=>new HM(t))});var wte=W(C8=>{"use strict";h();Object.defineProperty(C8,"__esModule",{value:!0});C8.salsaBasic=void 0;var fl=GM(),hl=ru(),tke=(0,hl.utf8ToBytes)("expand 16-byte k"),rke=(0,hl.utf8ToBytes)("expand 32-byte k"),nke=(0,hl.u32)(tke),ike=(0,hl.u32)(rke),B8=t=>!(t.byteOffset%4),oke=t=>{let{core:e,rounds:r,counterRight:n,counterLen:i,allow128bitKeys:o,extendNonceFn:s,blockLen:a}=(0,hl.checkOpts)({rounds:20,counterRight:!1,counterLen:8,allow128bitKeys:!0,blockLen:64},t);fl.default.number(i),fl.default.number(r),fl.default.number(a),fl.default.bool(n),fl.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,m,p=0)=>{if(fl.default.bytes(u),fl.default.bytes(c),fl.default.bytes(l),m||(m=new Uint8Array(l.length)),fl.default.bytes(m),fl.default.number(p),p<0||p>=2**32-1)throw new Error("Salsa/ChaCha: counter overflow");if(m.length=2**32-1)throw new Error("Salsa/ChaCha: counter overflow");let T=Math.min(a,U-G);if(T===a&&F&&L){let E=G/4;if(G%4!==0)throw new Error("Salsa/ChaCha: invalid block position");for(let k=0;k{"use strict";h();Object.defineProperty(qn,"__esModule",{value:!0});qn.xchacha20poly1305=qn.chacha20poly1305=qn._poly1305_aead=qn.chacha12=qn.chacha8=qn.xchacha20=qn.chacha20=qn.chacha20orig=qn.hchacha=void 0;var au=ru(),ske=vte(),ix=wte(),Qe=(t,e)=>t<>>32-e;function ox(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],m=e[2],p=e[3],g=e[4],b=e[5],S=e[6],A=e[7],I=i,P=r[0],$=r[1],N=r[2],L=s,F=a,U=d,G=u,q=c,T=l,E=m,k=p,f=g,y=b,w=S,_=A,x=I,v=P,D=$,K=N;for(let j=0;j{t.update(e);let r=e.length%16;r&&t.update(ake.subarray(r))},xte=(t,e,r,n,i)=>{let o=t(e,r,new Uint8Array(32)),s=ske.poly1305.create(o);i&&_te(s,i),_te(s,n);let a=new Uint8Array(16),d=(0,au.createView)(a);(0,au.setBigUint64)(d,0,BigInt(i?i.length:0),!0),(0,au.setBigUint64)(d,8,BigInt(n.length),!0),s.update(a);let u=s.digest();return o.fill(0),u},cke=t=>(e,r,n)=>((0,au.ensureBytes)(e,32),(0,au.ensureBytes)(r),{tagLength:16,encrypt:(o,s)=>{let a=o.length,d=a+16;s?(0,au.ensureBytes)(s,d):s=new Uint8Array(d),t(e,r,o,s,1);let u=xte(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,au.ensureBytes)(s,d):s=new Uint8Array(d);let u=o.subarray(0,-16),c=o.subarray(-16),l=xte(t,e,r,u,n);if(!(0,au.equalBytes)(c,l))throw new Error("invalid tag");return t(e,r,u,s,1),s}});qn._poly1305_aead=cke;qn.chacha20poly1305=(0,qn._poly1305_aead)(qn.chacha20);qn.xchacha20poly1305=(0,qn._poly1305_aead)(qn.xchacha20)});var sx=W(Ko=>{"use strict";h();Object.defineProperty(Ko,"__esModule",{value:!0});Ko.output=Ko.exists=Ko.hash=Ko.bytes=Ko.bool=Ko.number=Ko.isBytes=void 0;function O8(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`positive integer expected, not ${t}`)}Ko.number=O8;function Ate(t){if(typeof t!="boolean")throw new Error(`boolean expected, not ${t}`)}Ko.bool=Ate;function Pte(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}Ko.isBytes=Pte;function VM(t,...e){if(!Pte(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}`)}Ko.bytes=VM;function Tte(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");O8(t.outputLen),O8(t.blockLen)}Ko.hash=Tte;function Ite(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")}Ko.exists=Ite;function kte(t,e){VM(t);let r=e.outputLen;if(t.length{"use strict";h();Object.defineProperty($8,"__esModule",{value:!0});$8.crypto=void 0;$8.crypto=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0});var ax=W(yt=>{"use strict";h();Object.defineProperty(yt,"__esModule",{value:!0});yt.randomBytes=yt.wrapXOFConstructorWithOpts=yt.wrapConstructorWithOpts=yt.wrapConstructor=yt.checkOpts=yt.Hash=yt.concatBytes=yt.toBytes=yt.utf8ToBytes=yt.asyncLoop=yt.nextTick=yt.hexToBytes=yt.bytesToHex=yt.byteSwap32=yt.byteSwapIfBE=yt.byteSwap=yt.isLE=yt.rotl=yt.rotr=yt.createView=yt.u32=yt.u8=yt.isBytes=void 0;var JM=Rte(),ZM=sx();function uke(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}yt.isBytes=uke;var lke=t=>new Uint8Array(t.buffer,t.byteOffset,t.byteLength);yt.u8=lke;var fke=t=>new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4));yt.u32=fke;var hke=t=>new DataView(t.buffer,t.byteOffset,t.byteLength);yt.createView=hke;var pke=(t,e)=>t<<32-e|t>>>e;yt.rotr=pke;var mke=(t,e)=>t<>>32-e>>>0;yt.rotl=mke;yt.isLE=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;var yke=t=>t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255;yt.byteSwap=yke;yt.byteSwapIfBE=yt.isLE?t=>t:t=>(0,yt.byteSwap)(t);function gke(t){for(let e=0;ee.toString(16).padStart(2,"0"));function vke(t){(0,ZM.bytes)(t);let e="";for(let r=0;r=Kf._0&&t<=Kf._9)return t-Kf._0;if(t>=Kf._A&&t<=Kf._F)return t-(Kf._A-10);if(t>=Kf._a&&t<=Kf._f)return t-(Kf._a-10)}function wke(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{};yt.nextTick=_ke;async function xke(t,e,r){let n=Date.now();for(let i=0;i=0&&ot().update(N8(n)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}yt.wrapConstructor=Pke;function Tke(t){let e=(n,i)=>t(i).update(N8(n)).digest(),r=t({});return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=n=>t(n),e}yt.wrapConstructorWithOpts=Tke;function Ike(t){let e=(n,i)=>t(i).update(N8(n)).digest(),r=t({});return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=n=>t(n),e}yt.wrapXOFConstructorWithOpts=Ike;function kke(t=32){if(JM.crypto&&typeof JM.crypto.getRandomValues=="function")return JM.crypto.getRandomValues(new Uint8Array(t));throw new Error("crypto.getRandomValues must be defined")}yt.randomBytes=kke});var Cte=W(b0=>{"use strict";h();Object.defineProperty(b0,"__esModule",{value:!0});b0.hmac=b0.HMAC=void 0;var j8=sx(),Bte=ax(),cx=class extends Bte.Hash{constructor(e,r){super(),this.finished=!1,this.destroyed=!1,(0,j8.hash)(e);let n=(0,Bte.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 cx(t,e).update(r).digest();b0.hmac=Rke;b0.hmac.create=(t,e)=>new cx(t,e)});var Kte=W($p=>{"use strict";h();Object.defineProperty($p,"__esModule",{value:!0});$p.hkdf=$p.expand=$p.extract=void 0;var QM=sx(),Ote=ax(),Nte=Cte();function jte(t,e,r){return(0,QM.hash)(t),r===void 0&&(r=new Uint8Array(t.outputLen)),(0,Nte.hmac)(t,(0,Ote.toBytes)(r),(0,Ote.toBytes)(e))}$p.extract=jte;var XM=new Uint8Array([0]),$te=new Uint8Array;function Ute(t,e,r,n=32){if((0,QM.hash)(t),(0,QM.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=$te);let o=new Uint8Array(i*t.outputLen),s=Nte.hmac.create(t,e),a=s._cloneInto(),d=new Uint8Array(s.outputLen);for(let u=0;uUte(t,jte(t,e,r),n,i);$p.hkdf=Dke});var qte=W(Np=>{"use strict";h();Object.defineProperty(Np,"__esModule",{value:!0});Np.HashMD=Np.Maj=Np.Chi=void 0;var eB=sx(),dx=ax();function Mke(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 Bke=(t,e,r)=>t&e^~t&r;Np.Chi=Bke;var Cke=(t,e,r)=>t&e^t&r^e&r;Np.Maj=Cke;var tB=class extends dx.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,dx.createView)(this.buffer)}update(e){(0,eB.exists)(this);let{view:r,buffer:n,blockLen:i}=this;e=(0,dx.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";h();Object.defineProperty(Wv,"__esModule",{value:!0});Wv.sha224=Wv.sha256=void 0;var rB=qte(),sd=ax(),Oke=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]),jp=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Up=new Uint32Array(64),U8=class extends rB.HashMD{constructor(){super(64,32,8,!1),this.A=jp[0]|0,this.B=jp[1]|0,this.C=jp[2]|0,this.D=jp[3]|0,this.E=jp[4]|0,this.F=jp[5]|0,this.G=jp[6]|0,this.H=jp[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)Up[l]=e.getUint32(r,!1);for(let l=16;l<64;l++){let m=Up[l-15],p=Up[l-2],g=(0,sd.rotr)(m,7)^(0,sd.rotr)(m,18)^m>>>3,b=(0,sd.rotr)(p,17)^(0,sd.rotr)(p,19)^p>>>10;Up[l]=b+Up[l-7]+g+Up[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 m=(0,sd.rotr)(a,6)^(0,sd.rotr)(a,11)^(0,sd.rotr)(a,25),p=c+m+(0,rB.Chi)(a,d,u)+Oke[l]+Up[l]|0,b=((0,sd.rotr)(n,2)^(0,sd.rotr)(n,13)^(0,sd.rotr)(n,22))+(0,rB.Maj)(n,i,o)|0;c=u,u=d,d=a,a=s+p|0,s=o,o=i,i=n,n=p+b|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(){Up.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}},nB=class extends U8{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}};Wv.sha256=(0,sd.wrapConstructor)(()=>new U8);Wv.sha224=(0,sd.wrapConstructor)(()=>new nB)});var Gte=W(K8=>{"use strict";h();Object.defineProperty(K8,"__esModule",{value:!0});K8.aes256gcm=void 0;var Fte=ru(),zte=S5(),iB=J_();function $ke(t,e,r){var n=function(o){var s=(0,zte.createCipheriv)("aes-256-gcm",t,e);r&&s.setAAD(r);var a=s.update(o),d=s.final();return(0,Fte.concatBytes)(a,d,s.getAuthTag())},i=function(o){var s=o.subarray(0,o.length-iB.AEAD_TAG_LENGTH),a=o.subarray(-iB.AEAD_TAG_LENGTH),d=(0,zte.createDecipheriv)("aes-256-gcm",t,e);r&&d.setAAD(r),d.setAuthTag(a);var u=d.update(s),c=d.final();return(0,Fte.concatBytes)(u,c)};return{tagLength:iB.AEAD_TAG_LENGTH,encrypt:n,decrypt:i}}K8.aes256gcm=$ke});var oB=W(Kp=>{"use strict";h();Object.defineProperty(Kp,"__esModule",{value:!0});Kp.deriveKey=Kp.aesDecrypt=Kp.aesEncrypt=void 0;var Nke=Ste(),Hte=ru(),jke=nM(),Uke=Kte(),Kke=Lte(),Wte=h0(),q8=J_(),qke=Gte();function Lke(t,e){return Vte(!0,t,e)}Kp.aesEncrypt=Lke;function Fke(t,e){return Vte(!1,t,e)}Kp.aesDecrypt=Fke;function zke(t){return(0,Uke.hkdf)(Kke.sha256,t,void 0,void 0,32)}Kp.deriveKey=zke;function Vte(t,e,r){var n=(0,Wte.symmetricAlgorithm)(),i=t?Gke:Wke;if(n==="aes-256-gcm")return i(qke.aes256gcm,e,r,(0,Wte.symmetricNonceLength)());if(n==="xchacha20")return i(Nke.xchacha20poly1305,e,r,q8.XCHACHA20_NONCE_LENGTH);throw new Error("Not implemented")}function Gke(t,e,r,n){var i=(0,jke.randomBytes)(n),o=t(e,i),s=o.encrypt(r),a=s.subarray(0,s.length-q8.AEAD_TAG_LENGTH),d=s.subarray(-q8.AEAD_TAG_LENGTH);return(0,Hte.concatBytes)(i,d,a)}function Wke(t,e,r,n){var i=n+q8.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,Hte.concatBytes)(a,s);return d.decrypt(u)}});var Xte=W(Rs=>{"use strict";h();Object.defineProperty(Rs,"__esModule",{value:!0});Rs.hexToPublicKey=Rs.convertPublicKeyFormat=Rs.getSharedPoint=Rs.getSharedKey=Rs.getPublicKey=Rs.isValidPrivateKey=Rs.getValidSecret=void 0;var Hke=ru(),Vke=nM(),Jte=Wee(),Jke=fte(),sB=h0(),Yte=J_(),Yke=FM(),Zke=oB();function Xke(){var t;do t=(0,Vke.randomBytes)(Yte.SECRET_KEY_LENGTH);while(!Zte(t));return t}Rs.getValidSecret=Xke;function Zte(t){return ux(function(e){return e.utils.isValidPrivateKey(t)},function(){return!0},function(){return!0})}Rs.isValidPrivateKey=Zte;function Qke(t){return ux(function(e){return e.getPublicKey(t)},function(e){return e.getPublicKey(t)},function(e){return e.getPublicKey(t)})}Rs.getPublicKey=Qke;function eRe(t,e){return(0,Zke.deriveKey)((0,Hke.concatBytes)(t,e))}Rs.getSharedKey=eRe;function tRe(t,e,r){return ux(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()})}Rs.getSharedPoint=tRe;function rRe(t,e){return ux(function(r){return r.getSharedSecret(BigInt(1),t,e)},function(){return t},function(){return t})}Rs.convertPublicKeyFormat=rRe;function nRe(t){var e=(0,Yke.decodeHex)(t);return ux(function(){if(e.length===Yte.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})}Rs.hexToPublicKey=nRe;function ux(t,e,r){if((0,sB.ellipticCurve)()==="secp256k1")return t(Jke.secp256k1);if((0,sB.ellipticCurve)()==="x25519")return e(Jte.x25519);if((0,sB.ellipticCurve)()==="ed25519")return r(Jte.ed25519);throw new Error("Not implemented")}});var L8=W(qf=>{"use strict";h();var iRe=qf&&qf.__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]}),aB=qf&&qf.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&iRe(e,t,r)};Object.defineProperty(qf,"__esModule",{value:!0});aB(Xte(),qf);aB(FM(),qf);aB(oB(),qf)});var dB=W(z8=>{"use strict";h();Object.defineProperty(z8,"__esModule",{value:!0});z8.PublicKey=void 0;var cB=ru(),oRe=h0(),F8=L8(),sRe=function(){function t(e){this.data=(0,F8.convertPublicKeyFormat)(e,!0)}return t.fromHex=function(e){return new t((0,F8.hexToPublicKey)(e))},Object.defineProperty(t.prototype,"uncompressed",{get:function(){return O.Buffer.from((0,F8.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,cB.bytesToHex)(this.data):(0,cB.bytesToHex)(this.uncompressed)},t.prototype.decapsulate=function(e){var r,n;return(0,oRe.isHkdfKeyCompressed)()?(r=this.data,n=e.multiply(this,!0)):(r=this.uncompressed,n=e.multiply(this,!1)),(0,F8.getSharedKey)(r,n)},t.prototype.equals=function(e){return(0,cB.equalBytes)(this.data,e.data)},t}();z8.PublicKey=sRe});var ere=W(G8=>{"use strict";h();Object.defineProperty(G8,"__esModule",{value:!0});G8.PrivateKey=void 0;var Qte=ru(),aRe=h0(),Hv=L8(),cRe=dB(),dRe=function(){function t(e){var r=e===void 0?(0,Hv.getValidSecret)():e;if(!(0,Hv.isValidPrivateKey)(r))throw new Error("Invalid private key");this.data=r,this.publicKey=new cRe.PublicKey((0,Hv.getPublicKey)(r))}return t.fromHex=function(e){return new t((0,Hv.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,Qte.bytesToHex)(this.data)},t.prototype.encapsulate=function(e){var r,n;return(0,aRe.isHkdfKeyCompressed)()?(r=this.publicKey.compressed,n=this.multiply(e,!0)):(r=this.publicKey.uncompressed,n=this.multiply(e,!1)),(0,Hv.getSharedKey)(r,n)},t.prototype.multiply=function(e,r){return r===void 0&&(r=!1),(0,Hv.getSharedPoint)(this.data,e.compressed,r)},t.prototype.equals=function(e){return(0,Qte.equalBytes)(this.data,e.data)},t}();G8.PrivateKey=dRe});var uB=W(Vv=>{"use strict";h();Object.defineProperty(Vv,"__esModule",{value:!0});Vv.PublicKey=Vv.PrivateKey=void 0;var uRe=ere();Object.defineProperty(Vv,"PrivateKey",{enumerable:!0,get:function(){return uRe.PrivateKey}});var lRe=dB();Object.defineProperty(Vv,"PublicKey",{enumerable:!0,get:function(){return lRe.PublicKey}})});var nre=W(Pa=>{"use strict";h();Object.defineProperty(Pa,"__esModule",{value:!0});Pa.utils=Pa.PublicKey=Pa.PrivateKey=Pa.ECIES_CONFIG=Pa.decrypt=Pa.encrypt=void 0;var fRe=ru(),tre=h0(),Jv=uB(),v0=L8();function hRe(t,e){var r=new Jv.PrivateKey,n=t instanceof Uint8Array?new Jv.PublicKey(t):Jv.PublicKey.fromHex(t),i=r.encapsulate(n),o=(0,v0.aesEncrypt)(i,e),s;return(0,tre.isEphemeralKeyCompressed)()?s=r.publicKey.compressed:s=r.publicKey.uncompressed,O.Buffer.from((0,fRe.concatBytes)(s,o))}Pa.encrypt=hRe;function pRe(t,e){var r=t instanceof Uint8Array?new Jv.PrivateKey(t):Jv.PrivateKey.fromHex(t),n=(0,tre.ephemeralKeySize)(),i=new Jv.PublicKey(e.subarray(0,n)),o=e.subarray(n),s=i.decapsulate(r);return O.Buffer.from((0,v0.aesDecrypt)(s,o))}Pa.decrypt=pRe;var mRe=h0();Object.defineProperty(Pa,"ECIES_CONFIG",{enumerable:!0,get:function(){return mRe.ECIES_CONFIG}});var rre=uB();Object.defineProperty(Pa,"PrivateKey",{enumerable:!0,get:function(){return rre.PrivateKey}});Object.defineProperty(Pa,"PublicKey",{enumerable:!0,get:function(){return rre.PublicKey}});Pa.utils={aesDecrypt:v0.aesDecrypt,aesEncrypt:v0.aesEncrypt,decodeHex:v0.decodeHex,getValidSecret:v0.getValidSecret,remove0x:v0.remove0x}});var Gn=W((jmt,ire)=>{"use strict";h();ire.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 Lf=W((Kmt,W8)=>{"use strict";h();var{AbortController:ore,AbortSignal:yRe}=typeof self<"u"?self:typeof window<"u"?window:void 0;W8.exports=ore;W8.exports.AbortSignal=yRe;W8.exports.default=ore});var Ds=W((Lmt,fB)=>{"use strict";h();var gRe=Un(),{kResistStopPropagation:bRe,SymbolDispose:vRe}=Gn(),wRe=globalThis.AbortSignal||Lf().AbortSignal,_Re=globalThis.AbortController||Lf().AbortController,xRe=Object.getPrototypeOf(async function(){}).constructor,sre=globalThis.Blob||gRe.Blob,ERe=typeof sre<"u"?function(e){return e instanceof sre}:function(e){return!1},are=(t,e)=>{if(t!==void 0&&(t===null||typeof t!="object"||!("aborted"in t)))throw new ERR_INVALID_ARG_TYPE(e,"AbortSignal",t)},SRe=(t,e)=>{if(typeof t!="function")throw new ERR_INVALID_ARG_TYPE(e,"Function",t)},lB=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 xRe},isArrayBufferView(t){return ArrayBuffer.isView(t)}},isBlob:ERe,deprecate(t,e){return t},addAbortListener:nc().addAbortListener||function(e,r){if(e===void 0)throw new ERR_INVALID_ARG_TYPE("signal","AbortSignal",e);are(e,"signal"),SRe(r,"listener");let n;return e.aborted?queueMicrotask(()=>r()):(e.addEventListener("abort",r,{__proto__:null,once:!0,[bRe]:!0}),n=()=>{e.removeEventListener("abort",r)}),{__proto__:null,[vRe](){var i;(i=n)===null||i===void 0||i()}}},AbortSignalAny:wRe.any||function(e){if(e.length===1)return e[0];let r=new _Re,n=()=>r.abort();return e.forEach(i=>{are(i,"signals"),i.addEventListener("abort",n,{once:!0})}),r.signal.addEventListener("abort",()=>{e.forEach(i=>i.removeEventListener("abort",n))},{once:!0}),r.signal}};fB.exports.promisify.custom=Symbol.for("nodejs.util.promisify.custom")});var Xs=W((zmt,ure)=>{"use strict";h();var{format:ARe,inspect:H8,AggregateError:PRe}=Ds(),TRe=globalThis.AggregateError||PRe,IRe=Symbol("kIsNodeError"),kRe=["string","function","number","object","Function","Object","boolean","bigint","symbol"],RRe=/^([A-Z][a-z0-9]*)+$/,DRe="__node_internal_",V8={};function w0(t,e){if(!t)throw new V8.ERR_INTERNAL_ASSERTION(e)}function cre(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 MRe(t,e,r){if(typeof e=="function")return w0(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 w0(n===r.length,`Code: ${t}; The provided arguments length (${r.length}) does not match the required ones (${n}).`),r.length===0?e:ARe(e,...r)}function qo(t,e,r){r||(r=Error);class n extends r{constructor(...o){super(MRe(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[IRe]=!0,V8[t]=n}function dre(t){let e=DRe+t.name;return Object.defineProperty(t,"name",{value:e}),t}function BRe(t,e){if(t&&e&&t!==e){if(Array.isArray(e.errors))return e.errors.push(t),e;let r=new TRe([e,t],e.message);return r.code=e.code,r}return t||e}var hB=class extends Error{constructor(e="The operation was aborted",r=void 0){if(r!==void 0&&typeof r!="object")throw new V8.ERR_INVALID_ARG_TYPE("options","Object",r);super(e,r),this.code="ABORT_ERR",this.name="AbortError"}};qo("ERR_ASSERTION","%s",Error);qo("ERR_INVALID_ARG_TYPE",(t,e,r)=>{w0(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)w0(typeof d=="string","All expected entries have to be of type string"),kRe.includes(d)?i.push(d.toLowerCase()):RRe.test(d)?o.push(d):(w0(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=H8(r,{depth:-1});n+=`. Received ${d}`}}else{let d=H8(r,{colors:!1});d.length>25&&(d=`${d.slice(0,25)}...`),n+=`. Received type ${typeof r} (${d})`}return n},TypeError);qo("ERR_INVALID_ARG_VALUE",(t,e,r="is invalid")=>{let n=H8(e);return n.length>128&&(n=n.slice(0,128)+"..."),`The ${t.includes(".")?"property":"argument"} '${t}' ${r}. Received ${n}`},TypeError);qo("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);qo("ERR_MISSING_ARGS",(...t)=>{w0(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);qo("ERR_OUT_OF_RANGE",(t,e,r)=>{w0(e,'Missing "range" argument');let n;return Number.isInteger(r)&&Math.abs(r)>2**32?n=cre(String(r)):typeof r=="bigint"?(n=String(r),(r>2n**32n||r<-(2n**32n))&&(n=cre(n)),n+="n"):n=H8(r),`The value of "${t}" is out of range. It must be ${e}. Received ${n}`},RangeError);qo("ERR_MULTIPLE_CALLBACK","Callback called multiple times",Error);qo("ERR_METHOD_NOT_IMPLEMENTED","The %s method is not implemented",Error);qo("ERR_STREAM_ALREADY_FINISHED","Cannot call %s after a stream was finished",Error);qo("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable",Error);qo("ERR_STREAM_DESTROYED","Cannot call %s after a stream was destroyed",Error);qo("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError);qo("ERR_STREAM_PREMATURE_CLOSE","Premature close",Error);qo("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF",Error);qo("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event",Error);qo("ERR_STREAM_WRITE_AFTER_END","write after end",Error);qo("ERR_UNKNOWN_ENCODING","Unknown encoding: %s",TypeError);ure.exports={AbortError:hB,aggregateTwoErrors:dre(BRe),hideStackFrames:dre,codes:V8}});var Zv=W((Wmt,wre)=>{"use strict";h();var{ArrayIsArray:mB,ArrayPrototypeIncludes:pre,ArrayPrototypeJoin:mre,ArrayPrototypeMap:CRe,NumberIsInteger:yB,NumberIsNaN:ORe,NumberMAX_SAFE_INTEGER:$Re,NumberMIN_SAFE_INTEGER:NRe,NumberParseInt:jRe,ObjectPrototypeHasOwnProperty:URe,RegExpPrototypeExec:yre,String:KRe,StringPrototypeToUpperCase:qRe,StringPrototypeTrim:LRe}=Gn(),{hideStackFrames:ad,codes:{ERR_SOCKET_BAD_PORT:FRe,ERR_INVALID_ARG_TYPE:Ms,ERR_INVALID_ARG_VALUE:Yv,ERR_OUT_OF_RANGE:_0,ERR_UNKNOWN_SIGNAL:lre}}=Xs(),{normalizeEncoding:zRe}=Ds(),{isAsyncFunction:GRe,isArrayBufferView:WRe}=Ds().types,fre={};function HRe(t){return t===(t|0)}function VRe(t){return t===t>>>0}var JRe=/^[0-7]+$/,YRe="must be a 32-bit unsigned integer or an octal string";function ZRe(t,e,r){if(typeof t>"u"&&(t=r),typeof t=="string"){if(yre(JRe,t)===null)throw new Yv(e,t,YRe);t=jRe(t,8)}return gre(t,e),t}var XRe=ad((t,e,r=NRe,n=$Re)=>{if(typeof t!="number")throw new Ms(e,"number",t);if(!yB(t))throw new _0(e,"an integer",t);if(tn)throw new _0(e,`>= ${r} && <= ${n}`,t)}),QRe=ad((t,e,r=-2147483648,n=2147483647)=>{if(typeof t!="number")throw new Ms(e,"number",t);if(!yB(t))throw new _0(e,"an integer",t);if(tn)throw new _0(e,`>= ${r} && <= ${n}`,t)}),gre=ad((t,e,r=!1)=>{if(typeof t!="number")throw new Ms(e,"number",t);if(!yB(t))throw new _0(e,"an integer",t);let n=r?1:0,i=4294967295;if(ti)throw new _0(e,`>= ${n} && <= ${i}`,t)});function gB(t,e){if(typeof t!="string")throw new Ms(e,"string",t)}function e9e(t,e,r=void 0,n){if(typeof t!="number")throw new Ms(e,"number",t);if(r!=null&&tn||(r!=null||n!=null)&&ORe(t))throw new _0(e,`${r!=null?`>= ${r}`:""}${r!=null&&n!=null?" && ":""}${n!=null?`<= ${n}`:""}`,t)}var t9e=ad((t,e,r)=>{if(!pre(r,t)){let i="must be one of: "+mre(CRe(r,o=>typeof o=="string"?`'${o}'`:KRe(o)),", ");throw new Yv(e,t,i)}});function bre(t,e){if(typeof t!="boolean")throw new Ms(e,"boolean",t)}function pB(t,e,r){return t==null||!URe(t,e)?r:t[e]}var r9e=ad((t,e,r=null)=>{let n=pB(r,"allowArray",!1),i=pB(r,"allowFunction",!1);if(!pB(r,"nullable",!1)&&t===null||!n&&mB(t)||typeof t!="object"&&(!i||typeof t!="function"))throw new Ms(e,"Object",t)}),n9e=ad((t,e)=>{if(t!=null&&typeof t!="object"&&typeof t!="function")throw new Ms(e,"a dictionary",t)}),J8=ad((t,e,r=0)=>{if(!mB(t))throw new Ms(e,"Array",t);if(t.length{if(!WRe(t))throw new Ms(e,["Buffer","TypedArray","DataView"],t)});function d9e(t,e){let r=zRe(e),n=t.length;if(r==="hex"&&n%2!==0)throw new Yv("encoding",e,`is invalid for data of length ${n}`)}function u9e(t,e="Port",r=!0){if(typeof t!="number"&&typeof t!="string"||typeof t=="string"&&LRe(t).length===0||+t!==+t>>>0||t>65535||t===0&&!r)throw new FRe(e,t,r);return t|0}var vre=ad((t,e)=>{if(t!==void 0&&(t===null||typeof t!="object"||!("aborted"in t)))throw new Ms(e,"AbortSignal",t)}),l9e=ad((t,e)=>{if(typeof t!="function")throw new Ms(e,"Function",t)}),f9e=ad((t,e)=>{if(typeof t!="function"||GRe(t))throw new Ms(e,"Function",t)}),h9e=ad((t,e)=>{if(t!==void 0)throw new Ms(e,"undefined",t)});function p9e(t,e,r){if(!pre(r,t))throw new Ms(e,`('${mre(r,"|")}')`,t)}var m9e=/^(?:<[^>]*>)(?:\s*;\s*[^;"\s]+(?:=(")?[^;"\s]*\1)?)*$/;function hre(t,e){if(typeof t>"u"||!yre(m9e,t))throw new Yv(e,t,'must be an array or string of format "; rel=preload; as=style"')}function y9e(t){if(typeof t=="string")return hre(t,"hints"),t;if(mB(t)){let e=t.length,r="";if(e===0)return r;for(let n=0;n; rel=preload; as=style"')}wre.exports={isInt32:HRe,isUint32:VRe,parseFileMode:ZRe,validateArray:J8,validateStringArray:i9e,validateBooleanArray:o9e,validateAbortSignalArray:s9e,validateBoolean:bre,validateBuffer:c9e,validateDictionary:n9e,validateEncoding:d9e,validateFunction:l9e,validateInt32:QRe,validateInteger:XRe,validateNumber:e9e,validateObject:r9e,validateOneOf:t9e,validatePlainFunction:f9e,validatePort:u9e,validateSignalName:a9e,validateString:gB,validateUint32:gre,validateUndefined:h9e,validateUnion:p9e,validateAbortSignal:vre,validateLinkHeaderValue:y9e}});var ml=W((Vmt,Ore)=>{"use strict";h();var{SymbolAsyncIterator:_re,SymbolIterator:xre,SymbolFor:x0}=Gn(),Ere=x0("nodejs.stream.destroyed"),Sre=x0("nodejs.stream.errored"),bB=x0("nodejs.stream.readable"),vB=x0("nodejs.stream.writable"),Are=x0("nodejs.stream.disturbed"),g9e=x0("nodejs.webstream.isClosedPromise"),b9e=x0("nodejs.webstream.controllerErrorFunction");function Y8(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 Z8(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 v9e(t){return!!(t&&typeof t.pipe=="function"&&t._readableState&&typeof t.on=="function"&&typeof t.write=="function")}function pl(t){return t&&(t._readableState||t._writableState||typeof t.write=="function"&&typeof t.on=="function"||typeof t.pipe=="function"&&typeof t.on=="function")}function Pre(t){return!!(t&&!pl(t)&&typeof t.pipeThrough=="function"&&typeof t.getReader=="function"&&typeof t.cancel=="function")}function Tre(t){return!!(t&&!pl(t)&&typeof t.getWriter=="function"&&typeof t.abort=="function")}function Ire(t){return!!(t&&!pl(t)&&typeof t.readable=="object"&&typeof t.writable=="object")}function w9e(t){return Pre(t)||Tre(t)||Ire(t)}function _9e(t,e){return t==null?!1:e===!0?typeof t[_re]=="function":e===!1?typeof t[xre]=="function":typeof t[_re]=="function"||typeof t[xre]=="function"}function X8(t){if(!pl(t))return null;let e=t._writableState,r=t._readableState,n=e||r;return!!(t.destroyed||t[Ere]||n!=null&&n.destroyed)}function kre(t){if(!Z8(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 x9e(t,e){if(!Z8(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 E9e(t){if(!Y8(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 Rre(t,e){if(!Y8(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 Dre(t){return t&&t[bB]!=null?t[bB]:typeof t?.readable!="boolean"?null:X8(t)?!1:Y8(t)&&t.readable&&!Rre(t)}function Mre(t){return t&&t[vB]!=null?t[vB]:typeof t?.writable!="boolean"?null:X8(t)?!1:Z8(t)&&t.writable&&!kre(t)}function S9e(t,e){return pl(t)?X8(t)?!0:!(e?.readable!==!1&&Dre(t)||e?.writable!==!1&&Mre(t)):null}function A9e(t){var e,r;return pl(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 P9e(t){var e,r;return pl(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 T9e(t){if(!pl(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"&&Bre(t)?t._closed:null}function Bre(t){return typeof t._closed=="boolean"&&typeof t._defaultKeepAlive=="boolean"&&typeof t._removedConnection=="boolean"&&typeof t._removedContLen=="boolean"}function Cre(t){return typeof t._sent100=="boolean"&&Bre(t)}function I9e(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 k9e(t){if(!pl(t))return null;let e=t._writableState,r=t._readableState,n=e||r;return!n&&Cre(t)||!!(n&&n.autoDestroy&&n.emitClose&&n.closed===!1)}function R9e(t){var e;return!!(t&&((e=t[Are])!==null&&e!==void 0?e:t.readableDidRead||t.readableAborted))}function D9e(t){var e,r,n,i,o,s,a,d,u,c;return!!(t&&((e=(r=(n=(i=(o=(s=t[Sre])!==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))}Ore.exports={isDestroyed:X8,kIsDestroyed:Ere,isDisturbed:R9e,kIsDisturbed:Are,isErrored:D9e,kIsErrored:Sre,isReadable:Dre,kIsReadable:bB,kIsClosedPromise:g9e,kControllerErrorFunction:b9e,kIsWritable:vB,isClosed:T9e,isDuplexNodeStream:v9e,isFinished:S9e,isIterable:_9e,isReadableNodeStream:Y8,isReadableStream:Pre,isReadableEnded:E9e,isReadableFinished:Rre,isReadableErrored:P9e,isNodeStream:pl,isWebStream:w9e,isWritable:Mre,isWritableNodeStream:Z8,isWritableStream:Tre,isWritableEnded:kre,isWritableFinished:x9e,isWritableErrored:A9e,isServerRequest:I9e,isServerResponse:Cre,willEmitClose:k9e,isTransformStream:Ire}});var Ff=W((Ymt,SB)=>{h();var qp=ls(),{AbortError:zre,codes:M9e}=Xs(),{ERR_INVALID_ARG_TYPE:B9e,ERR_STREAM_PREMATURE_CLOSE:$re}=M9e,{kEmptyObject:_B,once:xB}=Ds(),{validateAbortSignal:C9e,validateFunction:O9e,validateObject:$9e,validateBoolean:N9e}=Zv(),{Promise:j9e,PromisePrototypeThen:U9e,SymbolDispose:Gre}=Gn(),{isClosed:K9e,isReadable:Nre,isReadableNodeStream:wB,isReadableStream:q9e,isReadableFinished:jre,isReadableErrored:Ure,isWritable:Kre,isWritableNodeStream:qre,isWritableStream:L9e,isWritableFinished:Lre,isWritableErrored:Fre,isNodeStream:F9e,willEmitClose:z9e,kIsClosedPromise:G9e}=ml(),Xv;function W9e(t){return t.setHeader&&typeof t.abort=="function"}var EB=()=>{};function Wre(t,e,r){var n,i;if(arguments.length===2?(r=e,e=_B):e==null?e=_B:$9e(e,"options"),O9e(r,"callback"),C9e(e.signal,"options.signal"),r=xB(r),q9e(t)||L9e(t))return H9e(t,e,r);if(!F9e(t))throw new B9e("stream",["ReadableStream","WritableStream","Stream"],t);let o=(n=e.readable)!==null&&n!==void 0?n:wB(t),s=(i=e.writable)!==null&&i!==void 0?i:qre(t),a=t._writableState,d=t._readableState,u=()=>{t.writable||m()},c=z9e(t)&&wB(t)===o&&qre(t)===s,l=Lre(t,!1),m=()=>{l=!0,t.destroyed&&(c=!1),!(c&&(!t.readable||o))&&(!o||p)&&r.call(t)},p=jre(t,!1),g=()=>{p=!0,t.destroyed&&(c=!1),!(c&&(!t.writable||s))&&(!s||l)&&r.call(t)},b=N=>{r.call(t,N)},S=K9e(t),A=()=>{S=!0;let N=Fre(t)||Ure(t);if(N&&typeof N!="boolean")return r.call(t,N);if(o&&!p&&wB(t,!0)&&!jre(t,!1))return r.call(t,new $re);if(s&&!l&&!Lre(t,!1))return r.call(t,new $re);r.call(t)},I=()=>{S=!0;let N=Fre(t)||Ure(t);if(N&&typeof N!="boolean")return r.call(t,N);r.call(t)},P=()=>{t.req.on("finish",m)};W9e(t)?(t.on("complete",m),c||t.on("abort",A),t.req?P():t.on("request",P)):s&&!a&&(t.on("end",u),t.on("close",u)),!c&&typeof t.aborted=="boolean"&&t.on("aborted",A),t.on("end",g),t.on("finish",m),e.error!==!1&&t.on("error",b),t.on("close",A),S?qp.nextTick(A):a!=null&&a.errorEmitted||d!=null&&d.errorEmitted?c||qp.nextTick(I):(!o&&(!c||Nre(t))&&(l||Kre(t)===!1)||!s&&(!c||Kre(t))&&(p||Nre(t)===!1)||d&&t.req&&t.aborted)&&qp.nextTick(I);let $=()=>{r=EB,t.removeListener("aborted",A),t.removeListener("complete",m),t.removeListener("abort",A),t.removeListener("request",P),t.req&&t.req.removeListener("finish",m),t.removeListener("end",u),t.removeListener("close",u),t.removeListener("finish",m),t.removeListener("end",g),t.removeListener("error",b),t.removeListener("close",A)};if(e.signal&&!S){let N=()=>{let L=r;$(),L.call(t,new zre(void 0,{cause:e.signal.reason}))};if(e.signal.aborted)qp.nextTick(N);else{Xv=Xv||Ds().addAbortListener;let L=Xv(e.signal,N),F=r;r=xB((...U)=>{L[Gre](),F.apply(t,U)})}}return $}function H9e(t,e,r){let n=!1,i=EB;if(e.signal)if(i=()=>{n=!0,r.call(t,new zre(void 0,{cause:e.signal.reason}))},e.signal.aborted)qp.nextTick(i);else{Xv=Xv||Ds().addAbortListener;let s=Xv(e.signal,i),a=r;r=xB((...d)=>{s[Gre](),a.apply(t,d)})}let o=(...s)=>{n||qp.nextTick(()=>r.apply(t,s))};return U9e(t[G9e].promise,o,o),EB}function V9e(t,e){var r;let n=!1;return e===null&&(e=_B),(r=e)!==null&&r!==void 0&&r.cleanup&&(N9e(e.cleanup,"cleanup"),n=e.cleanup),new j9e((i,o)=>{let s=Wre(t,e,a=>{n&&s(),a?o(a):i()})})}SB.exports=Wre;SB.exports.finished=V9e});var E0=W((Xmt,ene)=>{"use strict";h();var yl=ls(),{aggregateTwoErrors:J9e,codes:{ERR_MULTIPLE_CALLBACK:Y9e},AbortError:Z9e}=Xs(),{Symbol:Jre}=Gn(),{kIsDestroyed:X9e,isDestroyed:Q9e,isFinished:eDe,isServerRequest:tDe}=ml(),Yre=Jre("kDestroy"),AB=Jre("kConstruct");function Zre(t,e,r){t&&(t.stack,e&&!e.errored&&(e.errored=t),r&&!r.errored&&(r.errored=t))}function rDe(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):(Zre(t,n,r),n&&(n.destroyed=!0),r&&(r.destroyed=!0),i.constructed?Hre(this,t,e):this.once(Yre,function(o){Hre(this,J9e(o,t),e)}),this)}function Hre(t,e,r){let n=!1;function i(o){if(n)return;n=!0;let s=t._readableState,a=t._writableState;Zre(o,a,s),a&&(a.closed=!0),s&&(s.closed=!0),typeof r=="function"&&r(o),o?yl.nextTick(nDe,t,o):yl.nextTick(Xre,t)}try{t._destroy(e||null,i)}catch(o){i(o)}}function nDe(t,e){PB(t,e),Xre(t)}function Xre(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 PB(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 iDe(){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 TB(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(PB,t,e):PB(t,e))}function oDe(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(AB,e),!(t.listenerCount(AB)>1)&&yl.nextTick(sDe,t)}function sDe(t){let e=!1;function r(n){if(e){TB(t,n??new Y9e);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(Yre,n):n?TB(t,n,!0):yl.nextTick(aDe,t)}try{t._construct(n=>{yl.nextTick(r,n)})}catch(n){yl.nextTick(r,n)}}function aDe(t){t.emit(AB)}function Vre(t){return t?.setHeader&&typeof t.abort=="function"}function Qre(t){t.emit("close")}function cDe(t,e){t.emit("error",e),yl.nextTick(Qre,t)}function dDe(t,e){!t||Q9e(t)||(!e&&!eDe(t)&&(e=new Z9e),tDe(t)?(t.socket=null,t.destroy(e)):Vre(t)?t.abort():Vre(t.req)?t.req.abort():typeof t.destroy=="function"?t.destroy(e):typeof t.close=="function"?t.close():e?yl.nextTick(cDe,t,e):yl.nextTick(Qre,t),t.destroyed||(t[X9e]=!0))}ene.exports={construct:oDe,destroyer:dDe,destroy:rDe,undestroy:iDe,errorOrDestroy:TB}});var t4=W((eyt,rne)=>{"use strict";h();var{ArrayIsArray:uDe,ObjectSetPrototypeOf:tne}=Gn(),{EventEmitter:Q8}=nc();function e4(t){Q8.call(this,t)}tne(e4.prototype,Q8.prototype);tne(e4,Q8);e4.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(),Q8.listenerCount(this,"error")===0&&this.emit("error",c)}IB(r,"error",d),IB(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 IB(t,e,r){if(typeof t.prependListener=="function")return t.prependListener(e,r);!t._events||!t._events[e]?t.on(e,r):uDe(t._events[e])?t._events[e].unshift(r):t._events[e]=[r,t._events[e]]}rne.exports={Stream:e4,prependListener:IB}});var lx=W((ryt,r4)=>{"use strict";h();var{SymbolDispose:lDe}=Gn(),{AbortError:nne,codes:fDe}=Xs(),{isNodeStream:ine,isWebStream:hDe,kControllerErrorFunction:pDe}=ml(),mDe=Ff(),{ERR_INVALID_ARG_TYPE:one}=fDe,kB,yDe=(t,e)=>{if(typeof t!="object"||!("aborted"in t))throw new one(e,"AbortSignal",t)};r4.exports.addAbortSignal=function(e,r){if(yDe(e,"signal"),!ine(r)&&!hDe(r))throw new one("stream",["ReadableStream","WritableStream","Stream"],r);return r4.exports.addAbortSignalNoValidate(e,r)};r4.exports.addAbortSignalNoValidate=function(t,e){if(typeof t!="object"||!("aborted"in t))return e;let r=ine(e)?()=>{e.destroy(new nne(void 0,{cause:t.reason}))}:()=>{e[pDe](new nne(void 0,{cause:t.reason}))};if(t.aborted)r();else{kB=kB||Ds().addAbortListener;let n=kB(t,r);mDe(e,n[lDe])}return e}});var cne=W((oyt,ane)=>{"use strict";h();var{StringPrototypeSlice:sne,SymbolIterator:gDe,TypedArrayPrototypeSet:n4,Uint8Array:bDe}=Gn(),{Buffer:RB}=Un(),{inspect:vDe}=Ds();ane.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 RB.alloc(0);let r=RB.allocUnsafe(e>>>0),n=this.head,i=0;for(;n;)n4(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+=sne(o,0,e),this.head=n,n.data=sne(o,e));break}++i}while((n=n.next)!==null);return this.length-=i,r}_getBuffer(e){let r=RB.allocUnsafe(e),n=e,i=this.head,o=0;do{let s=i.data;if(e>s.length)n4(r,s,n-e),e-=s.length;else{e===s.length?(n4(r,s,n-e),++o,i.next?this.head=i.next:this.head=this.tail=null):(n4(r,new bDe(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 vDe(this,{...r,depth:0,customInspect:!1})}}});var fx=W((ayt,fne)=>{"use strict";h();var{MathFloor:wDe,NumberIsInteger:_De}=Gn(),{validateInteger:xDe}=Zv(),{ERR_INVALID_ARG_VALUE:EDe}=Xs().codes,dne=16*1024,une=16;function SDe(t,e,r){return t.highWaterMark!=null?t.highWaterMark:e?t[r]:null}function lne(t){return t?une:dne}function ADe(t,e){xDe(e,"value",0),t?une=e:dne=e}function PDe(t,e,r,n){let i=SDe(e,n,r);if(i!=null){if(!_De(i)||i<0){let o=n?`options.${r}`:"options.highWaterMark";throw new EDe(o,i)}return wDe(i)}return lne(t.objectMode)}fne.exports={getHighWaterMark:PDe,getDefaultHighWaterMark:lne,setDefaultHighWaterMark:ADe}});var DB=W((dyt,yne)=>{"use strict";h();var hne=ls(),{PromisePrototypeThen:TDe,SymbolAsyncIterator:pne,SymbolIterator:mne}=Gn(),{Buffer:IDe}=Un(),{ERR_INVALID_ARG_TYPE:kDe,ERR_STREAM_NULL_VALUES:RDe}=Xs().codes;function DDe(t,e,r){let n;if(typeof e=="string"||e instanceof IDe)return new t({objectMode:!0,...r,read(){this.push(e),this.push(null)}});let i;if(e&&e[pne])i=!0,n=e[pne]();else if(e&&e[mne])i=!1,n=e[mne]();else throw new kDe("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){TDe(a(u),()=>hne.nextTick(c,u),l=>hne.nextTick(c,l||u))};async function a(u){let c=u!=null,l=typeof n.throw=="function";if(c&&l){let{value:m,done:p}=await n.throw(u);if(await m,p)return}if(typeof n.return=="function"){let{value:m}=await n.return();await m}}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 RDe;if(o.push(l))continue;s=!1}}catch(u){o.destroy(u)}break}}return o}yne.exports=DDe});var px=W((lyt,Cne)=>{h();var cu=ls(),{ArrayPrototypeIndexOf:MDe,NumberIsInteger:BDe,NumberIsNaN:CDe,NumberParseInt:ODe,ObjectDefineProperties:UB,ObjectKeys:$De,ObjectSetPrototypeOf:vne,Promise:wne,SafeSet:NDe,SymbolAsyncDispose:jDe,SymbolAsyncIterator:UDe,Symbol:KDe}=Gn();Cne.exports=hr;hr.ReadableState=a4;var{EventEmitter:qDe}=nc(),{Stream:Lp,prependListener:LDe}=t4(),{Buffer:MB}=Un(),{addAbortSignal:FDe}=lx(),_ne=Ff(),Dr=Ds().debuglog("stream",t=>{Dr=t}),zDe=cne(),tw=E0(),{getHighWaterMark:GDe,getDefaultHighWaterMark:WDe}=fx(),{aggregateTwoErrors:gne,codes:{ERR_INVALID_ARG_TYPE:HDe,ERR_METHOD_NOT_IMPLEMENTED:VDe,ERR_OUT_OF_RANGE:JDe,ERR_STREAM_PUSH_AFTER_EOF:YDe,ERR_STREAM_UNSHIFT_AFTER_END_EVENT:ZDe},AbortError:XDe}=Xs(),{validateObject:QDe}=Zv(),S0=KDe("kPaused"),{StringDecoder:xne}=av(),e7e=DB();vne(hr.prototype,Lp.prototype);vne(hr,Lp);var BB=()=>{},{errorOrDestroy:Qv}=tw,ew=1,t7e=2,Ene=4,hx=8,Sne=16,i4=32,o4=64,Ane=128,r7e=256,n7e=512,i7e=1024,NB=2048,jB=4096,o7e=8192,s7e=16384,a7e=32768,Pne=65536,c7e=1<<17,d7e=1<<18;function Vi(t){return{enumerable:!1,get(){return(this.state&t)!==0},set(e){e?this.state|=t:this.state&=~t}}}UB(a4.prototype,{objectMode:Vi(ew),ended:Vi(t7e),endEmitted:Vi(Ene),reading:Vi(hx),constructed:Vi(Sne),sync:Vi(i4),needReadable:Vi(o4),emittedReadable:Vi(Ane),readableListening:Vi(r7e),resumeScheduled:Vi(n7e),errorEmitted:Vi(i7e),emitClose:Vi(NB),autoDestroy:Vi(jB),destroyed:Vi(o7e),closed:Vi(s7e),closeEmitted:Vi(a7e),multiAwaitDrain:Vi(Pne),readingMore:Vi(c7e),dataEmitted:Vi(d7e)});function a4(t,e,r){typeof r!="boolean"&&(r=e instanceof gl()),this.state=NB|jB|Sne|i4,t&&t.objectMode&&(this.state|=ew),r&&t&&t.readableObjectMode&&(this.state|=ew),this.highWaterMark=t?GDe(this,t,"readableHighWaterMark",r):WDe(!1),this.buffer=new zDe,this.length=0,this.pipes=[],this.flowing=null,this[S0]=null,t&&t.emitClose===!1&&(this.state&=~NB),t&&t.autoDestroy===!1&&(this.state&=~jB),this.errored=null,this.defaultEncoding=t&&t.defaultEncoding||"utf8",this.awaitDrainWriters=null,this.decoder=null,this.encoding=null,t&&t.encoding&&(this.decoder=new xne(t.encoding),this.encoding=t.encoding)}function hr(t){if(!(this instanceof hr))return new hr(t);let e=this instanceof gl();this._readableState=new a4(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&&FDe(t.signal,this)),Lp.call(this,t),tw.construct(this,()=>{this._readableState.needReadable&&s4(this,this._readableState)})}hr.prototype.destroy=tw.destroy;hr.prototype._undestroy=tw.undestroy;hr.prototype._destroy=function(t,e){e(t)};hr.prototype[qDe.captureRejectionSymbol]=function(t){this.destroy(t)};hr.prototype[jDe]=function(){let t;return this.destroyed||(t=this.readableEnded?null:new XDe,this.destroy(t)),new wne((e,r)=>_ne(this,n=>n&&n!==t?r(n):e(null)))};hr.prototype.push=function(t,e){return Tne(this,t,e,!1)};hr.prototype.unshift=function(t,e){return Tne(this,t,e,!0)};function Tne(t,e,r,n){Dr("readableAddChunk",e);let i=t._readableState,o;if(i.state&ew||(typeof e=="string"?(r=r||i.defaultEncoding,i.encoding!==r&&(n&&i.encoding?e=MB.from(e,r).toString(i.encoding):(e=MB.from(e,r),r=""))):e instanceof MB?r="":Lp._isUint8Array(e)?(e=Lp._uint8ArrayToBuffer(e),r=""):e!=null&&(o=new HDe("chunk",["string","Buffer","Uint8Array"],e))),o)Qv(t,o);else if(e===null)i.state&=~hx,f7e(t,i);else if(i.state&ew||e&&e.length>0)if(n)if(i.state&Ene)Qv(t,new ZDe);else{if(i.destroyed||i.errored)return!1;CB(t,i,e,!0)}else if(i.ended)Qv(t,new YDe);else{if(i.destroyed||i.errored)return!1;i.state&=~hx,i.decoder&&!r?(e=i.decoder.write(e),i.objectMode||e.length!==0?CB(t,i,e,!1):s4(t,i)):CB(t,i,e,!1)}else n||(i.state&=~hx,s4(t,i));return!i.ended&&(i.length0?(e.state&Pne?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&o4&&c4(t)),s4(t,e)}hr.prototype.isPaused=function(){let t=this._readableState;return t[S0]===!0||t.flowing===!1};hr.prototype.setEncoding=function(t){let e=new xne(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 u7e=1073741824;function l7e(t){if(t>u7e)throw new JDe("size","<= 1GiB",t);return t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++,t}function bne(t,e){return t<=0||e.length===0&&e.ended?0:e.state&ew?1:CDe(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){Dr("read",t),t===void 0?t=NaN:BDe(t)||(t=ODe(t,10));let e=this._readableState,r=t;if(t>e.highWaterMark&&(e.highWaterMark=l7e(t)),t!==0&&(e.state&=~Ane),t===0&&e.needReadable&&((e.highWaterMark!==0?e.length>=e.highWaterMark:e.length>0)||e.ended))return Dr("read: emitReadable",e.length,e.ended),e.length===0&&e.ended?OB(this):c4(this),null;if(t=bne(t,e),t===0&&e.ended)return e.length===0&&OB(this),null;let n=(e.state&o4)!==0;if(Dr("need readable",n),(e.length===0||e.length-t0?i=Mne(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&&OB(this)),i!==null&&!e.errorEmitted&&!e.closeEmitted&&(e.dataEmitted=!0,this.emit("data",i)),i};function f7e(t,e){if(Dr("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?c4(t):(e.needReadable=!1,e.emittedReadable=!0,Ine(t))}}function c4(t){let e=t._readableState;Dr("emitReadable",e.needReadable,e.emittedReadable),e.needReadable=!1,e.emittedReadable||(Dr("emitReadable",e.flowing),e.emittedReadable=!0,cu.nextTick(Ine,t))}function Ine(t){let e=t._readableState;Dr("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,Rne(t)}function s4(t,e){!e.readingMore&&e.constructed&&(e.readingMore=!0,cu.nextTick(h7e,t,e))}function h7e(t,e){for(;!e.reading&&!e.ended&&(e.length1&&n.pipes.includes(t)&&(Dr("false write response, pause",n.awaitDrainWriters.size),n.awaitDrainWriters.add(t)),r.pause()),d||(d=p7e(r,t),t.on("drain",d))}r.on("data",m);function m(A){Dr("ondata");let I=t.write(A);Dr("dest.write",I),I===!1&&l()}function p(A){if(Dr("onerror",A),S(),t.removeListener("error",p),t.listenerCount("error")===0){let I=t._writableState||t._readableState;I&&!I.errorEmitted?Qv(t,A):t.emit("error",A)}}LDe(t,"error",p);function g(){t.removeListener("finish",b),S()}t.once("close",g);function b(){Dr("onfinish"),t.removeListener("close",g),S()}t.once("finish",b);function S(){Dr("unpipe"),r.unpipe(t)}return t.emit("pipe",r),t.writableNeedDrain===!0?l():n.flowing||(Dr("pipe resume"),r.resume()),t};function p7e(t,e){return function(){let n=t._readableState;n.awaitDrainWriters===e?(Dr("pipeOnDrain",1),n.awaitDrainWriters=null):n.multiAwaitDrain&&(Dr("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,Dr("on readable",n.length,n.reading),n.length?c4(this):n.reading||cu.nextTick(m7e,this)),r};hr.prototype.addListener=hr.prototype.on;hr.prototype.removeListener=function(t,e){let r=Lp.prototype.removeListener.call(this,t,e);return t==="readable"&&cu.nextTick(kne,this),r};hr.prototype.off=hr.prototype.removeListener;hr.prototype.removeAllListeners=function(t){let e=Lp.prototype.removeAllListeners.apply(this,arguments);return(t==="readable"||t===void 0)&&cu.nextTick(kne,this),e};function kne(t){let e=t._readableState;e.readableListening=t.listenerCount("readable")>0,e.resumeScheduled&&e[S0]===!1?e.flowing=!0:t.listenerCount("data")>0?t.resume():e.readableListening||(e.flowing=null)}function m7e(t){Dr("readable nexttick read 0"),t.read(0)}hr.prototype.resume=function(){let t=this._readableState;return t.flowing||(Dr("resume"),t.flowing=!t.readableListening,y7e(this,t)),t[S0]=!1,this};function y7e(t,e){e.resumeScheduled||(e.resumeScheduled=!0,cu.nextTick(g7e,t,e))}function g7e(t,e){Dr("resume",e.reading),e.reading||t.read(0),e.resumeScheduled=!1,t.emit("resume"),Rne(t),e.flowing&&!e.reading&&t.read(0)}hr.prototype.pause=function(){return Dr("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(Dr("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState[S0]=!0,this};function Rne(t){let e=t._readableState;for(Dr("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=>{Qv(this,n)}),t.on("close",()=>{this.destroy()}),t.on("destroy",()=>{this.destroy()}),this._read=()=>{e&&t.resume&&(e=!1,t.resume())};let r=$De(t);for(let n=1;n{i=s?gne(i,s):null,r(),r=BB});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 wne(n)}}}catch(s){throw i=gne(i,s),i}finally{(i||e?.destroyOnReturn!==!1)&&(i===void 0||t._readableState.autoDestroy)?tw.destroyer(t,null):(t.off("readable",n),o())}}UB(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}}});UB(a4.prototype,{pipesCount:{__proto__:null,get(){return this.pipes.length}},paused:{__proto__:null,get(){return this[S0]!==!1},set(t){this[S0]=!!t}}});hr._fromList=Mne;function Mne(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 OB(t){let e=t._readableState;Dr("endReadable",e.endEmitted),e.endEmitted||(e.ended=!0,cu.nextTick(v7e,e,t))}function v7e(t,e){if(Dr("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)cu.nextTick(w7e,e);else if(t.autoDestroy){let r=e._writableState;(!r||r.autoDestroy&&(r.finished||r.writable===!1))&&e.destroy()}}}function w7e(t){t.writable&&!t.writableEnded&&!t.destroyed&&t.end()}hr.from=function(t,e){return e7e(hr,t,e)};var $B;function Bne(){return $B===void 0&&($B={}),$B}hr.fromWeb=function(t,e){return Bne().newStreamReadableFromReadableStream(t,e)};hr.toWeb=function(t,e){return Bne().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){tw.destroyer(t,i),o(i)}}).wrap(t)}});var h4=W((hyt,Wne)=>{h();var A0=ls(),{ArrayPrototypeSlice:Nne,Error:_7e,FunctionPrototypeSymbolHasInstance:jne,ObjectDefineProperty:Une,ObjectDefineProperties:x7e,ObjectSetPrototypeOf:Kne,StringPrototypeToLowerCase:E7e,Symbol:S7e,SymbolHasInstance:A7e}=Gn();Wne.exports=Wn;Wn.WritableState=gx;var{EventEmitter:P7e}=nc(),mx=t4().Stream,{Buffer:d4}=Un(),f4=E0(),{addAbortSignal:T7e}=lx(),{getHighWaterMark:I7e,getDefaultHighWaterMark:k7e}=fx(),{ERR_INVALID_ARG_TYPE:R7e,ERR_METHOD_NOT_IMPLEMENTED:D7e,ERR_MULTIPLE_CALLBACK:qne,ERR_STREAM_CANNOT_PIPE:M7e,ERR_STREAM_DESTROYED:yx,ERR_STREAM_ALREADY_FINISHED:B7e,ERR_STREAM_NULL_VALUES:C7e,ERR_STREAM_WRITE_AFTER_END:O7e,ERR_UNKNOWN_ENCODING:Lne}=Xs().codes,{errorOrDestroy:rw}=f4;Kne(Wn.prototype,mx.prototype);Kne(Wn,mx);function LB(){}var nw=S7e("kOnFinished");function gx(t,e,r){typeof r!="boolean"&&(r=e instanceof gl()),this.objectMode=!!(t&&t.objectMode),r&&(this.objectMode=this.objectMode||!!(t&&t.writableObjectMode)),this.highWaterMark=t?I7e(this,t,"writableHighWaterMark",r):k7e(!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=N7e.bind(void 0,e),this.writecb=null,this.writelen=0,this.afterWriteTickInfo=null,l4(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[nw]=[]}function l4(t){t.buffered=[],t.bufferedIndex=0,t.allBuffers=!0,t.allNoop=!0}gx.prototype.getBuffer=function(){return Nne(this.buffered,this.bufferedIndex)};Une(gx.prototype,"bufferedRequestCount",{__proto__:null,get(){return this.buffered.length-this.bufferedIndex}});function Wn(t){let e=this instanceof gl();if(!e&&!jne(Wn,this))return new Wn(t);this._writableState=new gx(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&&T7e(t.signal,this)),mx.call(this,t),f4.construct(this,()=>{let r=this._writableState;r.writing||zB(this,r),GB(this,r)})}Une(Wn,A7e,{__proto__:null,value:function(t){return jne(this,t)?!0:this!==Wn?!1:t&&t._writableState instanceof gx}});Wn.prototype.pipe=function(){rw(this,new M7e)};function Fne(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"&&!d4.isEncoding(r))throw new Lne(r);typeof n!="function"&&(n=LB)}if(e===null)throw new C7e;if(!i.objectMode)if(typeof e=="string")i.decodeStrings!==!1&&(e=d4.from(e,r),r="buffer");else if(e instanceof d4)r="buffer";else if(mx._isUint8Array(e))e=mx._uint8ArrayToBuffer(e),r="buffer";else throw new R7e("chunk",["string","Buffer","Uint8Array"],e);let o;return i.ending?o=new O7e:i.destroyed&&(o=new yx("write")),o?(A0.nextTick(n,o),rw(t,o,!0),o):(i.pendingcb++,$7e(t,i,e,r,n))}Wn.prototype.write=function(t,e,r){return Fne(this,t,e,r)===!0};Wn.prototype.cork=function(){this._writableState.corked++};Wn.prototype.uncork=function(){let t=this._writableState;t.corked&&(t.corked--,t.writing||zB(this,t))};Wn.prototype.setDefaultEncoding=function(e){if(typeof e=="string"&&(e=E7e(e)),!d4.isEncoding(e))throw new Lne(e);return this._writableState.defaultEncoding=e,this};function $7e(t,e,r,n,i){let o=e.objectMode?1:r.length;e.length+=o;let s=e.lengthr.bufferedIndex&&zB(t,r),n?r.afterWriteTickInfo!==null&&r.afterWriteTickInfo.cb===i?r.afterWriteTickInfo.count++:(r.afterWriteTickInfo={count:1,cb:i,stream:t,state:r},A0.nextTick(j7e,r.afterWriteTickInfo)):zne(t,r,1,i))}function j7e({stream:t,state:e,count:r,cb:n}){return e.afterWriteTickInfo=null,zne(t,e,r,n)}function zne(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&&FB(e),GB(t,e)}function FB(t){if(t.writing)return;for(let i=t.bufferedIndex;i1&&t._writev){e.pendingcb-=o-1;let a=e.allNoop?LB:u=>{for(let c=s;c256?(r.splice(0,s),e.bufferedIndex=0):e.bufferedIndex=s}e.bufferProcessing=!1}Wn.prototype._write=function(t,e,r){if(this._writev)this._writev([{chunk:t,encoding:e}],r);else throw new D7e("_write()")};Wn.prototype._writev=null;Wn.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=Fne(this,t,e);o instanceof _7e&&(i=o)}return n.corked&&(n.corked=1,this.uncork()),i||(!n.errored&&!n.ending?(n.ending=!0,GB(this,n,!0),n.ended=!0):n.finished?i=new B7e("end"):n.destroyed&&(i=new yx("end"))),typeof r=="function"&&(i||n.finished?A0.nextTick(r,i):n[nw].push(r)),this};function u4(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 U7e(t,e){let r=!1;function n(i){if(r){rw(t,i??qne());return}if(r=!0,e.pendingcb--,i){let o=e[nw].splice(0);for(let s=0;s{u4(i)?qB(n,i):i.pendingcb--},t,e)):u4(e)&&(e.pendingcb++,qB(t,e))))}function qB(t,e){e.pendingcb--,e.finished=!0;let r=e[nw].splice(0);for(let n=0;n{h();var WB=ls(),L7e=Un(),{isReadable:F7e,isWritable:z7e,isIterable:Hne,isNodeStream:G7e,isReadableNodeStream:Vne,isWritableNodeStream:Jne,isDuplexNodeStream:W7e,isReadableStream:Yne,isWritableStream:Zne}=ml(),Xne=Ff(),{AbortError:iie,codes:{ERR_INVALID_ARG_TYPE:H7e,ERR_INVALID_RETURN_VALUE:Qne}}=Xs(),{destroyer:ow}=E0(),V7e=gl(),oie=px(),J7e=h4(),{createDeferredPromise:eie}=Ds(),tie=DB(),rie=globalThis.Blob||L7e.Blob,Y7e=typeof rie<"u"?function(e){return e instanceof rie}:function(e){return!1},Z7e=globalThis.AbortController||Lf().AbortController,{FunctionPrototypeCall:nie}=Gn(),Fp=class extends V7e{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)}};sie.exports=function t(e,r){if(W7e(e))return e;if(Vne(e))return iw({readable:e});if(Jne(e))return iw({writable:e});if(G7e(e))return iw({writable:!1,readable:!1});if(Yne(e))return iw({readable:oie.fromWeb(e)});if(Zne(e))return iw({writable:J7e.fromWeb(e)});if(typeof e=="function"){let{value:i,write:o,final:s,destroy:a}=X7e(e);if(Hne(i))return tie(Fp,i,{objectMode:!0,write:o,final:s,destroy:a});let d=i?.then;if(typeof d=="function"){let u,c=nie(d,i,l=>{if(l!=null)throw new Qne("nully","body",l)},l=>{ow(u,l)});return u=new Fp({objectMode:!0,readable:!1,write:o,final(l){s(async()=>{try{await c,WB.nextTick(l,null)}catch(m){WB.nextTick(l,m)}})},destroy:a})}throw new Qne("Iterable, AsyncIterable or AsyncFunction",r,i)}if(Y7e(e))return t(e.arrayBuffer());if(Hne(e))return tie(Fp,e,{objectMode:!0,writable:!1});if(Yne(e?.readable)&&Zne(e?.writable))return Fp.fromWeb(e);if(typeof e?.writable=="object"||typeof e?.readable=="object"){let i=e!=null&&e.readable?Vne(e?.readable)?e?.readable:t(e.readable):void 0,o=e!=null&&e.writable?Jne(e?.writable)?e?.writable:t(e.writable):void 0;return iw({readable:i,writable:o})}let n=e?.then;if(typeof n=="function"){let i;return nie(n,e,o=>{o!=null&&i.push(o),i.push(null)},o=>{ow(i,o)}),i=new Fp({objectMode:!0,writable:!1,read(){}})}throw new H7e(r,["Blob","ReadableStream","WritableStream","Stream","Iterable","AsyncIterable","Function","{ readable, writable } pair","Promise"],e)};function X7e(t){let{promise:e,resolve:r}=eie(),n=new Z7e,i=n.signal;return{value:t(async function*(){for(;;){let s=e;e=null;let{chunk:a,done:d,cb:u}=await s;if(WB.nextTick(u),d)return;if(i.aborted)throw new iie(void 0,{cause:i.reason});({promise:e,resolve:r}=eie()),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 iw(t){let e=t.readable&&typeof t.readable.read!="function"?oie.wrap(t.readable):t.readable,r=t.writable,n=!!F7e(e),i=!!z7e(r),o,s,a,d,u;function c(l){let m=d;d=null,m?m(l):l&&u.destroy(l)}return u=new Fp({readableObjectMode:!!(e!=null&&e.readableObjectMode),writableObjectMode:!!(r!=null&&r.writableObjectMode),readable:n,writable:i}),i&&(Xne(r,l=>{i=!1,l&&ow(e,l),c(l)}),u._write=function(l,m,p){r.write(l,m)?p():o=p},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&&(Xne(e,l=>{n=!1,l&&ow(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,m){!l&&d!==null&&(l=new iie),a=null,o=null,s=null,d===null?m(l):(d=m,ow(r,l),ow(e,l))},u}});var gl=W((gyt,uie)=>{"use strict";h();var{ObjectDefineProperties:Q7e,ObjectGetOwnPropertyDescriptor:zf,ObjectKeys:eMe,ObjectSetPrototypeOf:cie}=Gn();uie.exports=du;var JB=px(),cd=h4();cie(du.prototype,JB.prototype);cie(du,JB);{let t=eMe(cd.prototype);for(let e=0;e{"use strict";h();var{ObjectSetPrototypeOf:lie,Symbol:tMe}=Gn();fie.exports=Gf;var{ERR_METHOD_NOT_IMPLEMENTED:rMe}=Xs().codes,ZB=gl(),{getHighWaterMark:nMe}=fx();lie(Gf.prototype,ZB.prototype);lie(Gf,ZB);var bx=tMe("kCallback");function Gf(t){if(!(this instanceof Gf))return new Gf(t);let e=t?nMe(this,t,"readableHighWaterMark",!0):null;e===0&&(t={...t,highWaterMark:null,readableHighWaterMark:e,writableHighWaterMark:t.writableHighWaterMark||0}),ZB.call(this,t),this._readableState.sync=!1,this[bx]=null,t&&(typeof t.transform=="function"&&(this._transform=t.transform),typeof t.flush=="function"&&(this._flush=t.flush)),this.on("prefinish",iMe)}function YB(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 iMe(){this._final!==YB&&YB.call(this)}Gf.prototype._final=YB;Gf.prototype._transform=function(t,e,r){throw new rMe("_transform()")};Gf.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";h();var{ObjectSetPrototypeOf:hie}=Gn();pie.exports=sw;var QB=XB();hie(sw.prototype,QB.prototype);hie(sw,QB);function sw(t){if(!(this instanceof sw))return new sw(t);QB.call(this,t)}sw.prototype._transform=function(t,e,r){r(null,t)}});var g4=W((Eyt,vie)=>{h();var vx=ls(),{ArrayIsArray:oMe,Promise:sMe,SymbolAsyncIterator:aMe,SymbolDispose:cMe}=Gn(),y4=Ff(),{once:dMe}=Ds(),uMe=E0(),mie=gl(),{aggregateTwoErrors:lMe,codes:{ERR_INVALID_ARG_TYPE:dC,ERR_INVALID_RETURN_VALUE:tC,ERR_MISSING_ARGS:fMe,ERR_STREAM_DESTROYED:hMe,ERR_STREAM_PREMATURE_CLOSE:pMe},AbortError:mMe}=Xs(),{validateFunction:yMe,validateAbortSignal:gMe}=Zv(),{isIterable:P0,isReadable:rC,isReadableNodeStream:m4,isNodeStream:yie,isTransformStream:aw,isWebStream:bMe,isReadableStream:nC,isReadableFinished:vMe}=ml(),wMe=globalThis.AbortController||Lf().AbortController,iC,oC,sC;function gie(t,e,r){let n=!1;t.on("close",()=>{n=!0});let i=y4(t,{readable:e,writable:r},o=>{n=!o});return{destroy:o=>{n||(n=!0,uMe.destroyer(t,o||new hMe("pipe")))},cleanup:i}}function _Me(t){return yMe(t[t.length-1],"streams[stream.length - 1]"),t.pop()}function aC(t){if(P0(t))return t;if(m4(t))return xMe(t);throw new dC("val",["Readable","Iterable","AsyncIterable"],t)}async function*xMe(t){oC||(oC=px()),yield*oC.prototype[aMe].call(t)}async function p4(t,e,r,{end:n}){let i,o=null,s=u=>{if(u&&(i=u),o){let c=o;o=null,c()}},a=()=>new sMe((u,c)=>{i?c(i):o=()=>{i?c(i):u()}});e.on("drain",s);let d=y4(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?lMe(i,u):u)}finally{d(),e.off("drain",s)}}async function cC(t,e,r,{end:n}){aw(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 EMe(...t){return bie(t,dMe(_Me(t)))}function bie(t,e,r){if(t.length===1&&oMe(t[0])&&(t=t[0]),t.length<2)throw new fMe("streams");let n=new wMe,i=n.signal,o=r?.signal,s=[];gMe(o,"options.signal");function a(){g(new mMe)}sC=sC||Ds().addAbortListener;let d;o&&(d=sC(o,a));let u,c,l=[],m=0;function p(P){g(P,--m===0)}function g(P,$){var N;if(P&&(!u||u.code==="ERR_STREAM_PREMATURE_CLOSE")&&(u=P),!(!u&&!$)){for(;l.length;)l.shift()(u);(N=d)===null||N===void 0||N[cMe](),n.abort(),$&&(u||s.forEach(L=>L()),vx.nextTick(e,u,c))}}let b;for(let P=0;P0,F=N||r?.end!==!1,U=P===t.length-1;if(yie($)){let G=function(q){q&&q.name!=="AbortError"&&q.code!=="ERR_STREAM_PREMATURE_CLOSE"&&p(q)};var I=G;if(F){let{destroy:q,cleanup:T}=gie($,N,L);l.push(q),rC($)&&U&&s.push(T)}$.on("error",G),rC($)&&U&&s.push(()=>{$.removeListener("error",G)})}if(P===0)if(typeof $=="function"){if(b=$({signal:i}),!P0(b))throw new tC("Iterable, AsyncIterable or Stream","source",b)}else P0($)||m4($)||aw($)?b=$:b=mie.from($);else if(typeof $=="function"){if(aw(b)){var S;b=aC((S=b)===null||S===void 0?void 0:S.readable)}else b=aC(b);if(b=$(b,{signal:i}),N){if(!P0(b,!0))throw new tC("AsyncIterable",`transform[${P-1}]`,b)}else{var A;iC||(iC=eC());let G=new iC({objectMode:!0}),q=(A=b)===null||A===void 0?void 0:A.then;if(typeof q=="function")m++,q.call(b,k=>{c=k,k!=null&&G.write(k),F&&G.end(),vx.nextTick(p)},k=>{G.destroy(k),vx.nextTick(p,k)});else if(P0(b,!0))m++,p4(b,G,p,{end:F});else if(nC(b)||aw(b)){let k=b.readable||b;m++,p4(k,G,p,{end:F})}else throw new tC("AsyncIterable or Promise","destination",b);b=G;let{destroy:T,cleanup:E}=gie(b,!1,!0);l.push(T),U&&s.push(E)}}else if(yie($)){if(m4(b)){m+=2;let G=SMe(b,$,p,{end:F});rC($)&&U&&s.push(G)}else if(aw(b)||nC(b)){let G=b.readable||b;m++,p4(G,$,p,{end:F})}else if(P0(b))m++,p4(b,$,p,{end:F});else throw new dC("val",["Readable","Iterable","AsyncIterable","ReadableStream","TransformStream"],b);b=$}else if(bMe($)){if(m4(b))m++,cC(aC(b),$,p,{end:F});else if(nC(b)||P0(b))m++,cC(b,$,p,{end:F});else if(aw(b))m++,cC(b.readable,$,p,{end:F});else throw new dC("val",["Readable","Iterable","AsyncIterable","ReadableStream","TransformStream"],b);b=$}else b=mie.from($)}return(i!=null&&i.aborted||o!=null&&o.aborted)&&vx.nextTick(a),b}function SMe(t,e,r,{end:n}){let i=!1;if(e.on("close",()=>{i||r(new pMe)}),t.pipe(e,{end:!1}),n){let s=function(){i=!0,e.end()};var o=s;vMe(t)?vx.nextTick(s):t.once("end",s)}else r();return y4(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)}),y4(e,{readable:!1,writable:!0},r)}vie.exports={pipelineImpl:bie,pipeline:EMe}});var lC=W((Ayt,Aie)=>{"use strict";h();var{pipeline:AMe}=g4(),b4=gl(),{destroyer:PMe}=E0(),{isNodeStream:v4,isReadable:wie,isWritable:_ie,isWebStream:uC,isTransformStream:T0,isWritableStream:xie,isReadableStream:Eie}=ml(),{AbortError:TMe,codes:{ERR_INVALID_ARG_VALUE:Sie,ERR_MISSING_ARGS:IMe}}=Xs(),kMe=Ff();Aie.exports=function(...e){if(e.length===0)throw new IMe("streams");if(e.length===1)return b4.from(e[0]);let r=[...e];if(typeof e[0]=="function"&&(e[0]=b4.from(e[0])),typeof e[e.length-1]=="function"){let p=e.length-1;e[p]=b4.from(e[p])}for(let p=0;p0&&!(_ie(e[p])||xie(e[p])||T0(e[p])))throw new Sie(`streams[${p}]`,r[p],"must be writable")}let n,i,o,s,a;function d(p){let g=s;s=null,g?g(p):p?a.destroy(p):!m&&!l&&a.destroy()}let u=e[0],c=AMe(e,d),l=!!(_ie(u)||xie(u)||T0(u)),m=!!(wie(c)||Eie(c)||T0(c));if(a=new b4({writableObjectMode:!!(u!=null&&u.writableObjectMode),readableObjectMode:!!(c!=null&&c.readableObjectMode),writable:l,readable:m}),l){if(v4(u))a._write=function(g,b,S){u.write(g,b)?S():n=S},a._final=function(g){u.end(),i=g},u.on("drain",function(){if(n){let g=n;n=null,g()}});else if(uC(u)){let b=(T0(u)?u.writable:u).getWriter();a._write=async function(S,A,I){try{await b.ready,b.write(S).catch(()=>{}),I()}catch(P){I(P)}},a._final=async function(S){try{await b.ready,b.close().catch(()=>{}),i=S}catch(A){S(A)}}}let p=T0(c)?c.readable:c;kMe(p,()=>{if(i){let g=i;i=null,g()}})}if(m){if(v4(c))c.on("readable",function(){if(o){let p=o;o=null,p()}}),c.on("end",function(){a.push(null)}),a._read=function(){for(;;){let p=c.read();if(p===null){o=a._read;return}if(!a.push(p))return}};else if(uC(c)){let g=(T0(c)?c.readable:c).getReader();a._read=async function(){for(;;)try{let{value:b,done:S}=await g.read();if(!a.push(b))return;if(S){a.push(null);return}}catch{return}}}}return a._destroy=function(p,g){!p&&s!==null&&(p=new TMe),o=null,n=null,i=null,s===null?g(p):(s=g,v4(c)&&PMe(c,p))},a}});var Oie=W((Tyt,pC)=>{"use strict";h();var RMe=globalThis.AbortController||Lf().AbortController,{codes:{ERR_INVALID_ARG_VALUE:DMe,ERR_INVALID_ARG_TYPE:wx,ERR_MISSING_ARGS:MMe,ERR_OUT_OF_RANGE:BMe},AbortError:bl}=Xs(),{validateAbortSignal:I0,validateInteger:Pie,validateObject:k0}=Zv(),CMe=Gn().Symbol("kWeak"),OMe=Gn().Symbol("kResistStopPropagation"),{finished:$Me}=Ff(),NMe=lC(),{addAbortSignalNoValidate:jMe}=lx(),{isWritable:UMe,isNodeStream:KMe}=ml(),{deprecate:qMe}=Ds(),{ArrayPrototypePush:LMe,Boolean:FMe,MathFloor:Tie,Number:zMe,NumberIsNaN:GMe,Promise:Iie,PromiseReject:kie,PromiseResolve:WMe,PromisePrototypeThen:Rie,Symbol:Mie}=Gn(),w4=Mie("kEmpty"),Die=Mie("kEof");function HMe(t,e){if(e!=null&&k0(e,"options"),e?.signal!=null&&I0(e.signal,"options.signal"),KMe(t)&&!UMe(t))throw new DMe("stream",t,"must be writable");let r=NMe(this,t);return e!=null&&e.signal&&jMe(e.signal,r),r}function _4(t,e){if(typeof t!="function")throw new wx("fn",["Function","AsyncFunction"],t);e!=null&&k0(e,"options"),e?.signal!=null&&I0(e.signal,"options.signal");let r=1;e?.concurrency!=null&&(r=Tie(e.concurrency));let n=r-1;return e?.highWaterMark!=null&&(n=Tie(e.highWaterMark)),Pie(r,"options.concurrency",1),Pie(n,"options.highWaterMark",0),n+=r,(async function*(){let o=Ds().AbortSignalAny([e?.signal].filter(FMe)),s=this,a=[],d={signal:o},u,c,l=!1,m=0;function p(){l=!0,g()}function g(){m-=1,b()}function b(){c&&!l&&m=n||m>=r)&&await new Iie(I=>{c=I})}a.push(Die)}catch(A){let I=kie(A);Rie(I,g,p),a.push(I)}finally{l=!0,u&&(u(),u=null)}}S();try{for(;;){for(;a.length>0;){let A=await a[0];if(A===Die)return;if(o.aborted)throw new bl;A!==w4&&(yield A),a.shift(),b()}await new Iie(A=>{u=A})}}finally{l=!0,c&&(c(),c=null)}}).call(this)}function VMe(t=void 0){return t!=null&&k0(t,"options"),t?.signal!=null&&I0(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 bl({cause:t.signal.reason});yield[r++,i]}}).call(this)}async function Bie(t,e=void 0){for await(let r of hC.call(this,t,e))return!0;return!1}async function JMe(t,e=void 0){if(typeof t!="function")throw new wx("fn",["Function","AsyncFunction"],t);return!await Bie.call(this,async(...r)=>!await t(...r),e)}async function YMe(t,e){for await(let r of hC.call(this,t,e))return r}async function ZMe(t,e){if(typeof t!="function")throw new wx("fn",["Function","AsyncFunction"],t);async function r(n,i){return await t(n,i),w4}for await(let n of _4.call(this,r,e));}function hC(t,e){if(typeof t!="function")throw new wx("fn",["Function","AsyncFunction"],t);async function r(n,i){return await t(n,i)?n:w4}return _4.call(this,r,e)}var fC=class extends MMe{constructor(){super("reduce"),this.message="Reduce of an empty stream requires an initial value"}};async function XMe(t,e,r){var n;if(typeof t!="function")throw new wx("reducer",["Function","AsyncFunction"],t);r!=null&&k0(r,"options"),r?.signal!=null&&I0(r.signal,"options.signal");let i=arguments.length>1;if(r!=null&&(n=r.signal)!==null&&n!==void 0&&n.aborted){let u=new bl(void 0,{cause:r.signal.reason});throw this.once("error",()=>{}),await $Me(this.destroy(u)),u}let o=new RMe,s=o.signal;if(r!=null&&r.signal){let u={once:!0,[CMe]:this,[OMe]:!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 bl;i?e=await t(e,u,{signal:s}):(e=u,i=!0)}if(!a&&!i)throw new fC}finally{o.abort()}return e}async function QMe(t){t!=null&&k0(t,"options"),t?.signal!=null&&I0(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 bl(void 0,{cause:t.signal.reason});LMe(e,n)}return e}function eBe(t,e){let r=_4.call(this,t,e);return(async function*(){for await(let i of r)yield*i}).call(this)}function Cie(t){if(t=zMe(t),GMe(t))return 0;if(t<0)throw new BMe("number",">= 0",t);return t}function tBe(t,e=void 0){return e!=null&&k0(e,"options"),e?.signal!=null&&I0(e.signal,"options.signal"),t=Cie(t),(async function*(){var n;if(e!=null&&(n=e.signal)!==null&&n!==void 0&&n.aborted)throw new bl;for await(let o of this){var i;if(e!=null&&(i=e.signal)!==null&&i!==void 0&&i.aborted)throw new bl;t--<=0&&(yield o)}}).call(this)}function rBe(t,e=void 0){return e!=null&&k0(e,"options"),e?.signal!=null&&I0(e.signal,"options.signal"),t=Cie(t),(async function*(){var n;if(e!=null&&(n=e.signal)!==null&&n!==void 0&&n.aborted)throw new bl;for await(let o of this){var i;if(e!=null&&(i=e.signal)!==null&&i!==void 0&&i.aborted)throw new bl;if(t-- >0&&(yield o),t<=0)return}}).call(this)}pC.exports.streamReturningOperators={asIndexedPairs:qMe(VMe,"readable.asIndexedPairs will be removed in a future version."),drop:tBe,filter:hC,flatMap:eBe,map:_4,take:rBe,compose:HMe};pC.exports.promiseReturningOperators={every:JMe,forEach:ZMe,reduce:XMe,toArray:QMe,some:Bie,find:YMe}});var mC=W((kyt,$ie)=>{"use strict";h();var{ArrayPrototypePop:nBe,Promise:iBe}=Gn(),{isIterable:oBe,isNodeStream:sBe,isWebStream:aBe}=ml(),{pipelineImpl:cBe}=g4(),{finished:dBe}=Ff();yC();function uBe(...t){return new iBe((e,r)=>{let n,i,o=t[t.length-1];if(o&&typeof o=="object"&&!sBe(o)&&!oBe(o)&&!aBe(o)){let s=nBe(t);n=s.signal,i=s.end}cBe(t,(s,a)=>{s?r(s):e(a)},{signal:n,end:i})})}$ie.exports={finished:dBe,pipeline:uBe}});var yC=W((Dyt,Gie)=>{h();var{Buffer:lBe}=Un(),{ObjectDefineProperty:Wf,ObjectKeys:Uie,ReflectApply:Kie}=Gn(),{promisify:{custom:qie}}=Ds(),{streamReturningOperators:Nie,promiseReturningOperators:jie}=Oie(),{codes:{ERR_ILLEGAL_CONSTRUCTOR:Lie}}=Xs(),fBe=lC(),{setDefaultHighWaterMark:hBe,getDefaultHighWaterMark:pBe}=fx(),{pipeline:Fie}=g4(),{destroyer:mBe}=E0(),zie=Ff(),gC=mC(),_x=ml(),Mn=Gie.exports=t4().Stream;Mn.isDestroyed=_x.isDestroyed;Mn.isDisturbed=_x.isDisturbed;Mn.isErrored=_x.isErrored;Mn.isReadable=_x.isReadable;Mn.isWritable=_x.isWritable;Mn.Readable=px();for(let t of Uie(Nie)){let r=function(...n){if(new.target)throw Lie();return Mn.Readable.from(Kie(e,this,n))};bC=r;let e=Nie[t];Wf(r,"name",{__proto__:null,value:e.name}),Wf(r,"length",{__proto__:null,value:e.length}),Wf(Mn.Readable.prototype,t,{__proto__:null,value:r,enumerable:!1,configurable:!0,writable:!0})}var bC;for(let t of Uie(jie)){let r=function(...i){if(new.target)throw Lie();return Kie(e,this,i)};bC=r;let e=jie[t];Wf(r,"name",{__proto__:null,value:e.name}),Wf(r,"length",{__proto__:null,value:e.length}),Wf(Mn.Readable.prototype,t,{__proto__:null,value:r,enumerable:!1,configurable:!0,writable:!0})}var bC;Mn.Writable=h4();Mn.Duplex=gl();Mn.Transform=XB();Mn.PassThrough=eC();Mn.pipeline=Fie;var{addAbortSignal:yBe}=lx();Mn.addAbortSignal=yBe;Mn.finished=zie;Mn.destroy=mBe;Mn.compose=fBe;Mn.setDefaultHighWaterMark=hBe;Mn.getDefaultHighWaterMark=pBe;Wf(Mn,"promises",{__proto__:null,configurable:!0,enumerable:!0,get(){return gC}});Wf(Fie,qie,{__proto__:null,enumerable:!0,get(){return gC.pipeline}});Wf(zie,qie,{__proto__:null,enumerable:!0,get(){return gC.finished}});Mn.Stream=Mn;Mn._isUint8Array=function(e){return e instanceof Uint8Array};Mn._uint8ArrayToBuffer=function(e){return lBe.from(e.buffer,e.byteOffset,e.byteLength)}});var x4=W((Byt,_i)=>{"use strict";h();var Ji=yC(),gBe=mC(),bBe=Ji.Readable.destroy;_i.exports=Ji.Readable;_i.exports._uint8ArrayToBuffer=Ji._uint8ArrayToBuffer;_i.exports._isUint8Array=Ji._isUint8Array;_i.exports.isDisturbed=Ji.isDisturbed;_i.exports.isErrored=Ji.isErrored;_i.exports.isReadable=Ji.isReadable;_i.exports.Readable=Ji.Readable;_i.exports.Writable=Ji.Writable;_i.exports.Duplex=Ji.Duplex;_i.exports.Transform=Ji.Transform;_i.exports.PassThrough=Ji.PassThrough;_i.exports.addAbortSignal=Ji.addAbortSignal;_i.exports.finished=Ji.finished;_i.exports.destroy=Ji.destroy;_i.exports.destroy=bBe;_i.exports.pipeline=Ji.pipeline;_i.exports.compose=Ji.compose;Object.defineProperty(Ji,"promises",{configurable:!0,enumerable:!0,get(){return gBe}});_i.exports.Stream=Ji.Stream;_i.exports.default=_i.exports});var Jie=W((EC,SC)=>{h();(function(t,e){typeof EC=="object"&&typeof SC<"u"?SC.exports=e():typeof define=="function"&&define.amd?define(e):(t=t||self,t.JSBI=e())})(EC,function(){"use strict";var t=Math.imul,e=Math.clz32;function r(U){"@babel/helpers - typeof";return r=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(G){return typeof G}:function(G){return G&&typeof Symbol=="function"&&G.constructor===Symbol&&G!==Symbol.prototype?"symbol":typeof G},r(U)}function n(U,G){if(!(U instanceof G))throw new TypeError("Cannot call a class as a function")}function i(U,G){for(var q,T=0;T"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(U,G,q){var T=[null];T.push.apply(T,G);var E=Function.bind.apply(U,T),k=new E;return q&&d(k,q.prototype),k},c.apply(null,arguments)}function l(U){return Function.toString.call(U).indexOf("[native code]")!==-1}function m(U){var G=typeof Map=="function"?new Map:void 0;return m=function(q){function T(){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 G<"u"){if(G.has(q))return G.get(q);G.set(q,T)}return T.prototype=Object.create(q.prototype,{constructor:{value:T,enumerable:!1,writable:!0,configurable:!0}}),d(T,q)},m(U)}function p(U){if(U===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return U}function g(U,G){if(G&&(typeof G=="object"||typeof G=="function"))return G;if(G!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return p(U)}function b(U){var G=u();return function(){var q,T=a(U);if(G){var E=a(this).constructor;q=Reflect.construct(T,arguments,E)}else q=T.apply(this,arguments);return g(this,q)}}function S(U,G){return A(U)||I(U,G)||P(U,G)||N()}function A(U){if(Array.isArray(U))return U}function I(U,G){var q=U==null?null:typeof Symbol<"u"&&U[Symbol.iterator]||U["@@iterator"];if(q!=null){var T,E,k=[],f=!0,y=!1;try{for(q=q.call(U);!(f=(T=q.next()).done)&&(k.push(T.value),!(G&&k.length===G));f=!0);}catch(w){y=!0,E=w}finally{try{f||q.return==null||q.return()}finally{if(y)throw E}}return k}}function P(U,G){if(U){if(typeof U=="string")return $(U,G);var q=Object.prototype.toString.call(U).slice(8,-1);return q==="Object"&&U.constructor&&(q=U.constructor.name),q==="Map"||q==="Set"?Array.from(U):q==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(q)?$(U,G):void 0}}function $(U,G){(G==null||G>U.length)&&(G=U.length);for(var q=0,T=Array(G);q=U.length?{done:!0}:{done:!1,value:U[T++]}},e:function(w){throw w},f:E}}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 k,f=!0,y=!1;return{s:function(){q=q.call(U)},n:function(){var w=q.next();return f=w.done,w},e:function(w){y=!0,k=w},f:function(){try{f||q.return==null||q.return()}finally{if(y)throw k}}}}var F=function(U){var G=Math.abs,q=Math.max,T=Math.floor;function E(f,y){var w;if(n(this,E),w=k.call(this,f),w.sign=y,Object.setPrototypeOf(p(w),E.prototype),f>E.__kMaxLength)throw new RangeError("Maximum BigInt size exceeded");return w}s(E,U);var k=b(E);return o(E,[{key:"toDebugString",value:function(){var f,y=["BigInt["],w=L(this);try{for(w.s();!(f=w.n()).done;){var _=f.value;y.push((_&&(_>>>0).toString(16))+", ")}}catch(x){w.e(x)}finally{w.f()}return y.push("]"),y.join("")}},{key:"toString",value:function(){var f=0f||36this.length&&(w=this.length);for(var _=32767&f,x=f>>>15,v=0,D=y,K=0;K>>15,Z=E.__imul(j,_),V=E.__imul(j,x),H=E.__imul(J,_),X=E.__imul(J,x),ee=D+Z+v;v=ee>>>30,ee&=1073741823,ee+=((32767&V)<<15)+((32767&H)<<15),v+=ee>>>30,D=X+(V>>>15)+(H>>>15),this.__setDigit(K,1073741823&ee)}if(v!==0||D!==0)throw new Error("implementation bug")}},{key:"__inplaceAdd",value:function(f,y,w){for(var _,x=0,v=0;v>>15,this.__setHalfDigit(y+v,32767&_);return x}},{key:"__inplaceSub",value:function(f,y,w){var _=0;if(1&y){y>>=1;for(var x=this.__digit(y),v=32767&x,D=0;D>>1;D++){var K=f.__digit(D),M=(x>>>15)-(32767&K)-_;_=1&M>>>15,this.__setDigit(y+D,(32767&M)<<15|32767&v),x=this.__digit(y+D+1),v=(32767&x)-(K>>>15)-_,_=1&v>>>15}var j=f.__digit(D),J=(x>>>15)-(32767&j)-_;if(_=1&J>>>15,this.__setDigit(y+D,(32767&J)<<15|32767&v),y+D+1>=this.length)throw new RangeError("out of bounds");!(1&w)&&(x=this.__digit(y+D+1),v=(32767&x)-(j>>>15)-_,_=1&v>>>15,this.__setDigit(y+f.length,1073709056&x|32767&v))}else{y>>=1;for(var Z=0;Z>>15;var ee=(V>>>15)-(H>>>15)-_;_=1&ee>>>15,this.__setDigit(y+Z,(32767&ee)<<15|32767&X)}var ue=this.__digit(y+Z),ae=f.__digit(Z),ce=(32767&ue)-(32767&ae)-_;_=1&ce>>>15;var pe=0;!(1&w)&&(pe=(ue>>>15)-(ae>>>15)-_,_=1&pe>>>15),this.__setDigit(y+Z,(32767&pe)<<15|32767&ce)}return _}},{key:"__inplaceRightShift",value:function(f){if(f!==0){for(var y,w=this.__digit(0)>>>f,_=this.length-1,x=0;x<_;x++)y=this.__digit(x+1),this.__setDigit(x,1073741823&y<<30-f|w),w=y>>>f;this.__setDigit(_,w)}}},{key:"__digit",value:function(f){return this[f]}},{key:"__unsignedDigit",value:function(f){return this[f]>>>0}},{key:"__setDigit",value:function(f,y){this[f]=0|y}},{key:"__setDigitGrow",value:function(f,y){this[f]=0|y}},{key:"__halfDigitLength",value:function(){var f=this.length;return 32767>=this.__unsignedDigit(f-1)?2*f-1:2*f}},{key:"__halfDigit",value:function(f){return 32767&this[f>>>1]>>>15*(1&f)}},{key:"__setHalfDigit",value:function(f,y){var w=f>>>1,_=this.__digit(w),x=1&f?32767&_|y<<15:1073709056&_|32767&y;this.__setDigit(w,x)}}],[{key:"BigInt",value:function(f){var y=Number.isFinite;if(typeof f=="number"){if(f===0)return E.__zero();if(E.__isOneDigitInt(f))return 0>f?E.__oneDigit(-f,!0):E.__oneDigit(f,!1);if(!y(f)||T(f)!==f)throw new RangeError("The number "+f+" cannot be converted to BigInt because it is not an integer");return E.__fromDouble(f)}if(typeof f=="string"){var w=E.__fromString(f);if(w===null)throw new SyntaxError("Cannot convert "+f+" to a BigInt");return w}if(typeof f=="boolean")return f===!0?E.__oneDigit(1,!1):E.__zero();if(r(f)==="object"){if(f.constructor===E)return f;var _=E.__toPrimitive(f);return E.BigInt(_)}throw new TypeError("Cannot convert "+f+" to a BigInt")}},{key:"toNumber",value:function(f){var y=f.length;if(y===0)return 0;if(y===1){var w=f.__unsignedDigit(0);return f.sign?-w:w}var _=f.__digit(y-1),x=E.__clz30(_),v=30*y-x;if(1024>>=12;var Z=j-12,V=12<=j?0:K<<20+j,H=20+j;for(0>>30-Z,V=K<>>30-H,H-=30;var X=E.__decideRounding(f,H,M,K);if((X===1||X===0&&(1&V)==1)&&(V=V+1>>>0,V===0&&(J++,J>>>20!=0&&(J=0,D++,1023=E.__kMaxLengthBits)throw new RangeError("BigInt too big");if(f.length===1&&f.__digit(0)===2){var _=1+(0|w/30),x=f.sign&&(1&w)!=0,v=new E(_,x);v.__initializeDigits();var D=1<>=1;w!==0;w>>=1)M=E.multiply(M,M),1&w&&(K===null?K=M:K=E.multiply(K,M));return K}},{key:"multiply",value:function(f,y){if(f.length===0)return f;if(y.length===0)return y;var w=f.length+y.length;30<=f.__clzmsd()+y.__clzmsd()&&w--;var _=new E(w,f.sign!==y.sign);_.__initializeDigits();for(var x=0;xE.__absoluteCompare(f,y))return E.__zero();var w,_=f.sign!==y.sign,x=y.__unsignedDigit(0);if(y.length===1&&32767>=x){if(x===1)return _===f.sign?f:E.unaryMinus(f);w=E.__absoluteDivSmall(f,x,null)}else w=E.__absoluteDivLarge(f,y,!0,!1);return w.sign=_,w.__trim()}},{key:"remainder",value:function(y,w){if(w.length===0)throw new RangeError("Division by zero");if(0>E.__absoluteCompare(y,w))return y;var _=w.__unsignedDigit(0);if(w.length===1&&32767>=_){if(_===1)return E.__zero();var x=E.__absoluteModSmall(y,_);return x===0?E.__zero():E.__oneDigit(x,y.sign)}var v=E.__absoluteDivLarge(y,w,!1,!0);return v.sign=y.sign,v.__trim()}},{key:"add",value:function(f,y){var w=f.sign;return w===y.sign?E.__absoluteAdd(f,y,w):0<=E.__absoluteCompare(f,y)?E.__absoluteSub(f,y,w):E.__absoluteSub(y,f,!w)}},{key:"subtract",value:function(f,y){var w=f.sign;return w===y.sign?0<=E.__absoluteCompare(f,y)?E.__absoluteSub(f,y,w):E.__absoluteSub(y,f,!w):E.__absoluteAdd(f,y,w)}},{key:"leftShift",value:function(f,y){return y.length===0||f.length===0?f:y.sign?E.__rightShiftByAbsolute(f,y):E.__leftShiftByAbsolute(f,y)}},{key:"signedRightShift",value:function(f,y){return y.length===0||f.length===0?f:y.sign?E.__leftShiftByAbsolute(f,y):E.__rightShiftByAbsolute(f,y)}},{key:"unsignedRightShift",value:function(){throw new TypeError("BigInts have no unsigned right shift; use >> instead")}},{key:"lessThan",value:function(f,y){return 0>E.__compareToBigInt(f,y)}},{key:"lessThanOrEqual",value:function(f,y){return 0>=E.__compareToBigInt(f,y)}},{key:"greaterThan",value:function(f,y){return 0f)throw new RangeError("Invalid value: not (convertible to) a safe integer");if(f===0)return E.__zero();if(f>=E.__kMaxLengthBits)return y;var w=0|(f+29)/30;if(y.lengthf)throw new RangeError("Invalid value: not (convertible to) a safe integer");if(f===0)return E.__zero();if(y.sign){if(f>E.__kMaxLengthBits)throw new RangeError("BigInt too big");return E.__truncateAndSubFromPowerOfTwo(f,y,!1)}if(f>=E.__kMaxLengthBits)return y;var w=0|(f+29)/30;if(y.length>>_))return y}return E.__truncateToNBits(f,y)}},{key:"ADD",value:function(f,y){if(f=E.__toPrimitive(f),y=E.__toPrimitive(y),typeof f=="string")return typeof y!="string"&&(y=y.toString()),f+y;if(typeof y=="string")return f.toString()+y;if(f=E.__toNumeric(f),y=E.__toNumeric(y),E.__isBigInt(f)&&E.__isBigInt(y))return E.add(f,y);if(typeof f=="number"&&typeof y=="number")return f+y;throw new TypeError("Cannot mix BigInt and other types, use explicit conversions")}},{key:"LT",value:function(f,y){return E.__compare(f,y,0)}},{key:"LE",value:function(f,y){return E.__compare(f,y,1)}},{key:"GT",value:function(f,y){return E.__compare(f,y,2)}},{key:"GE",value:function(f,y){return E.__compare(f,y,3)}},{key:"EQ",value:function(f,y){for(;;){if(E.__isBigInt(f))return E.__isBigInt(y)?E.equal(f,y):E.EQ(y,f);if(typeof f=="number"){if(E.__isBigInt(y))return E.__equalToNumber(y,f);if(r(y)!=="object")return f==y;y=E.__toPrimitive(y)}else if(typeof f=="string"){if(E.__isBigInt(y))return f=E.__fromString(f),f!==null&&E.equal(f,y);if(r(y)!=="object")return f==y;y=E.__toPrimitive(y)}else if(typeof f=="boolean"){if(E.__isBigInt(y))return E.__equalToNumber(y,+f);if(r(y)!=="object")return f==y;y=E.__toPrimitive(y)}else if(r(f)==="symbol"){if(E.__isBigInt(y))return!1;if(r(y)!=="object")return f==y;y=E.__toPrimitive(y)}else if(r(f)==="object"){if(r(y)==="object"&&y.constructor!==E)return f==y;f=E.__toPrimitive(f)}else return f==y}}},{key:"NE",value:function(f,y){return!E.EQ(f,y)}},{key:"DataViewGetBigInt64",value:function(f,y){var w=2>>30),j.__setDigit(2,K>>>28),j.__trim()}},{key:"DataViewSetBigInt64",value:function(f,y,w){var _=3>>2,2y)x=-y-1;else{if(w===0)return-1;w--,_=f.__digit(w),x=29}var v=1<>>20,_=w-1023,x=(0|_/30)+1,v=new E(x,0>f),D=1048575&E.__kBitConversionInts[1]|1048576,K=E.__kBitConversionInts[0],M=20,j=_%30,J=0;if(j>>Z,D=D<<32-Z|K>>>Z,K<<=32-Z}else if(j===M)J=32,y=D,D=K,K=0;else{var V=j-M;J=32-V,y=D<>>32-V,D=K<>>2,D=D<<30|K>>>2,K<<=30):y=0,v.__setDigit(H,y);return v.__trim()}},{key:"__isWhitespace",value:function(f){return 13>=f&&9<=f||(159>=f?f==32:131071>=f?f==160||f==5760:196607>=f?(f&=131071,10>=f||f==40||f==41||f==47||f==95||f==4096):f==65279)}},{key:"__fromString",value:function(f){var y=11073741824/K)return null;var j=K*D+M>>>E.__kBitsPerCharTableShift,J=new E(0|(j+29)/30,!1),Z=10>y?y:10,V=10>>0>>0>>E.__kBitsPerCharTableShift)/30;J.__inplaceMultiplyAdd(ge,le,Ce)}while(!pe)}else{K>>=E.__kBitsPerCharTableShift;var H=[],X=[],ee=!1;do{for(var ue,ae=0,ce=0;;){if(ue=void 0,v-48>>>0>>0>>M-v)}if(x!==0){if(_>=f.length)throw new Error("implementation bug");f.__setDigit(_++,x)}for(;_>>1)+(85&_),_=(51&_>>>2)+(51&_),_=(15&_>>>4)+(15&_);var x=_,v=y-1,D=f.__digit(w-1),K=E.__clz30(D),M=0|(30*w-K+x-1)/x;if(f.sign&&M++,268435456>>ue,V=30-ue;V>=x;)j[J--]=E.__kConversionChars[Z&v],Z>>>=x,V-=x}var ae=(Z|D<>>x-V;Z!==0;)j[J--]=E.__kConversionChars[Z&v],Z>>>=x;if(f.sign&&(j[J--]="-"),J!==-1)throw new Error("implementation bug");return j.join("")}},{key:"__toStringGeneric",value:function(f,y,w){var _=f.length;if(_===0)return"";if(_===1){var x=f.__unsignedDigit(0).toString(y);return w===!1&&f.sign&&(x="-"+x),x}var v=30*_-E.__clz30(f.__digit(_-1)),D=E.__kMaxBitsPerChar[y],K=D-1,M=v*E.__kBitsPerCharTableMultiplier;M+=K-1,M=0|M/K;var j,J,Z=M+1>>1,V=E.exponentiate(E.__oneDigit(y,!1),E.__oneDigit(Z,!1)),H=V.__unsignedDigit(0);if(V.length===1&&32767>=H){j=new E(f.length,!1),j.__initializeDigits();for(var X,ee=0,ue=2*f.length-1;0<=ue;ue--)X=ee<<15|f.__halfDigit(ue),j.__setHalfDigit(ue,0|X/H),ee=0|X%H;J=ee.toString(y)}else{var ae=E.__absoluteDivLarge(f,V,!0,!0);j=ae.quotient;var ce=ae.remainder.__trim();J=E.__toStringGeneric(ce,y,!0)}j.__trim();for(var pe=E.__toStringGeneric(j,y,!0);J.length_?E.__absoluteLess(w):0}},{key:"__compareToNumber",value:function(f,y){if(E.__isOneDigitInt(y)){var w=f.sign,_=0>y;if(w!==_)return E.__unequalSign(w);if(f.length===0){if(_)throw new Error("implementation bug");return y===0?0:-1}if(1x?E.__absoluteGreater(w):vy)return E.__unequalSign(w);if(y===0)throw new Error("implementation bug: should be handled elsewhere");if(f.length===0)return-1;E.__kBitConversionDouble[0]=y;var _=2047&E.__kBitConversionInts[1]>>>20;if(_==2047)throw new Error("implementation bug: handled elsewhere");var x=_-1023;if(0>x)return E.__absoluteGreater(w);var v=f.length,D=f.__digit(v-1),K=E.__clz30(D),M=30*v-K,j=x+1;if(Mj)return E.__absoluteGreater(w);var J=1048576|1048575&E.__kBitConversionInts[1],Z=E.__kBitConversionInts[0],V=20,H=29-K;if(H!==(0|(M-1)%30))throw new Error("implementation bug");var X,ee=0;if(H>>ue,J=J<<32-ue|Z>>>ue,Z<<=32-ue}else if(H===V)ee=32,X=J,J=Z,Z=0;else{var ae=H-V;ee=32-ae,X=J<>>32-ae,J=Z<>>=0,X>>>=0,D>X)return E.__absoluteGreater(w);if(D>>2,J=J<<30|Z>>>2,Z<<=30):X=0;var pe=f.__unsignedDigit(ce);if(pe>X)return E.__absoluteGreater(w);if(pey&&f.__unsignedDigit(0)===G(y):E.__compareToDouble(f,y)===0}},{key:"__comparisonResultToBool",value:function(f,y){return y===0?0>f:y===1?0>=f:y===2?0y;case 3:return f>=y}if(E.__isBigInt(f)&&typeof y=="string")return y=E.__fromString(y),y!==null&&E.__comparisonResultToBool(E.__compareToBigInt(f,y),w);if(typeof f=="string"&&E.__isBigInt(y))return f=E.__fromString(f),f!==null&&E.__comparisonResultToBool(E.__compareToBigInt(f,y),w);if(f=E.__toNumeric(f),y=E.__toNumeric(y),E.__isBigInt(f)){if(E.__isBigInt(y))return E.__comparisonResultToBool(E.__compareToBigInt(f,y),w);if(typeof y!="number")throw new Error("implementation bug");return E.__comparisonResultToBool(E.__compareToNumber(f,y),w)}if(typeof f!="number")throw new Error("implementation bug");if(E.__isBigInt(y))return E.__comparisonResultToBool(E.__compareToNumber(y,f),2^w);if(typeof y!="number")throw new Error("implementation bug");return w===0?fy:w===3?f>=y:void 0}},{key:"__absoluteAdd",value:function(f,y,w){if(f.length>>30,v.__setDigit(K,1073741823&x);for(;K>>30,v.__setDigit(K,1073741823&M)}return K>>30,x.__setDigit(D,1073741823&_);for(;D>>30,x.__setDigit(D,1073741823&K)}return x.__trim()}},{key:"__absoluteAddOne",value:function(f,y){var w=2>>30,w.__setDigit(D,1073741823&x);return v!==0&&w.__setDigitGrow(_,1),w}},{key:"__absoluteSubOne",value:function(f,y){var w=f.length;y=y||w;for(var _,x=new E(y,!1),v=1,D=0;D>>30,x.__setDigit(D,1073741823&_);if(v!==0)throw new Error("implementation bug");for(var K=w;K_?0:f.__unsignedDigit(_)>y.__unsignedDigit(_)?1:-1}},{key:"__multiplyAccumulate",value:function(f,y,w,_){if(y!==0){for(var x=32767&y,v=y>>>15,D=0,K=0,M=0;M>>15,H=E.__imul(Z,x),X=E.__imul(Z,v),ee=E.__imul(V,x),ue=E.__imul(V,v);j+=K+H+D,D=j>>>30,j&=1073741823,j+=((32767&X)<<15)+((32767&ee)<<15),D+=j>>>30,K=ue+(X>>>15)+(ee>>>15),w.__setDigit(_,1073741823&j)}for(;D!==0||K!==0;_++){var ae=w.__digit(_);ae+=D+K,K=0,D=ae>>>30,w.__setDigit(_,1073741823&ae)}}}},{key:"__internalMultiplyAdd",value:function(f,y,w,_,x){for(var v=w,D=0,K=0;K<_;K++){var M=f.__digit(K),j=E.__imul(32767&M,y),J=E.__imul(M>>>15,y),Z=j+((32767&J)<<15)+D+v;v=Z>>>30,D=J>>>15,x.__setDigit(K,1073741823&Z)}if(x.length>_)for(x.__setDigit(_++,v+D);_>>0,D=0|v/y;_=0|v%y,v=(_<<15|f.__halfDigit(x-1))>>>0;var K=0|v/y;_=0|v%y,w.__setDigit(x>>>1,D<<15|K)}return w}},{key:"__absoluteModSmall",value:function(f,y){for(var w,_=0,x=2*f.length-1;0<=x;x--)w=(_<<15|f.__halfDigit(x))>>>0,_=0|w%y;return _}},{key:"__absoluteDivLarge",value:function(f,y,w,_){var x=y.__halfDigitLength(),v=y.length,D=f.__halfDigitLength()-x,K=null;w&&(K=new E(D+2>>>1,!1),K.__initializeDigits());var M=new E(x+2>>>1,!1);M.__initializeDigits();var j=E.__clz15(y.__halfDigit(x-1));0>>0;X=0|ue/Z;for(var ae=0|ue%Z,ce=y.__halfDigit(x-2),pe=J.__halfDigit(H+x-2);E.__imul(X,ce)>>>0>(ae<<16|pe)>>>0&&(X--,ae+=Z,!(32767>>1,V|X))}if(_)return J.__inplaceRightShift(j),w?{quotient:K,remainder:J}:J;if(w)return K;throw new Error("unreachable")}},{key:"__clz15",value:function(f){return E.__clz30(f)-15}},{key:"__specialLeftShift",value:function(f,y,w){var _=f.length,x=new E(_+w,!1);if(y===0){for(var v=0;v<_;v++)x.__setDigit(v,f.__digit(v));return 0>>30-y;return 0w)throw new RangeError("BigInt too big");var _=0|w/30,x=w%30,v=f.length,D=x!==0&&f.__digit(v-1)>>>30-x!=0,K=v+_+(D?1:0),M=new E(K,f.sign);if(x===0){for(var j=0;j<_;j++)M.__setDigit(j,0);for(;j>>30-x;if(D)M.__setDigit(v+_,J);else if(J!==0)throw new Error("implementation bug")}return M.__trim()}},{key:"__rightShiftByAbsolute",value:function(f,y){var w=f.length,_=f.sign,x=E.__toShiftAmount(y);if(0>x)return E.__rightShiftByMaximum(_);var v=0|x/30,D=x%30,K=w-v;if(0>=K)return E.__rightShiftByMaximum(_);var M=!1;if(_){if(f.__digit(v)&(1<>>D,ee=w-v-1,ue=0;ue>>D;Z.__setDigit(ee,X)}return M&&(Z=E.__absoluteAddOne(Z,!0,Z)),Z.__trim()}},{key:"__rightShiftByMaximum",value:function(f){return f?E.__oneDigit(1,!0):E.__zero()}},{key:"__toShiftAmount",value:function(f){if(1E.__kMaxLengthBits?-1:y}},{key:"__toPrimitive",value:function(f){var y=1>>K}return _.__setDigit(x,D),_.__trim()}},{key:"__truncateAndSubFromPowerOfTwo",value:function(f,y,w){for(var _=Math.min,x,v=0|(f+29)/30,D=new E(v,w),K=0,M=v-1,j=0,J=_(M,y.length);K>>30,D.__setDigit(K,1073741823&x);for(;K>>X;var ee=1<<32-X;Z=ee-V-j,Z&=ee-1}return D.__setDigit(M,Z),D.__trim()}},{key:"__digitPow",value:function(f,y){for(var w=1;0>>=1,f*=f;return w}},{key:"__isOneDigitInt",value:function(f){return(1073741823&f)===f}}]),E}(m(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)/G)},F.__imul=t||function(U,G){return 0|U*G},F})});var oE=W(Gr=>{"use strict";h();Object.defineProperty(Gr,"__esModule",{value:!0});Gr.regexpCode=Gr.getEsmExportName=Gr.getProperty=Gr.safeStringify=Gr.stringify=Gr.strConcat=Gr.addCodeArg=Gr.str=Gr._=Gr.nil=Gr._Code=Gr.Name=Gr.IDENTIFIER=Gr._CodeOrName=void 0;var nE=class{};Gr._CodeOrName=nE;Gr.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var V0=class extends nE{constructor(e){if(super(),!Gr.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}}};Gr.Name=V0;var fd=class extends nE{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 V0&&(r[n.str]=(r[n.str]||0)+1),r),{})}};Gr._Code=fd;Gr.nil=new fd("");function Fse(t,...e){let r=[t[0]],n=0;for(;n{"use strict";h();Object.defineProperty(ia,"__esModule",{value:!0});ia.ValueScope=ia.ValueScopeName=ia.Scope=ia.varKinds=ia.UsedValueState=void 0;var Da=oE(),OO=class extends Error{constructor(e){super(`CodeGen: "code" for ${e} not defined`),this.value=e.value}},$O;(function(t){t[t.Started=0]="Started",t[t.Completed=1]="Completed"})($O=ia.UsedValueState||(ia.UsedValueState={}));ia.varKinds={const:new Da.Name("const"),let:new Da.Name("let"),var:new Da.Name("var")};var gA=class{constructor({prefixes:e,parent:r}={}){this._names={},this._prefixes=e,this._parent=r}toName(e){return e instanceof Da.Name?e:this.name(e)}name(e){return new Da.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}}};ia.Scope=gA;var bA=class extends Da.Name{constructor(e,r){super(r),this.prefix=e}setValue(e,{property:r,itemIndex:n}){this.value=e,this.scopePath=(0,Da._)`.${new Da.Name(r)}[${n}]`}};ia.ValueScopeName=bA;var ACe=(0,Da._)`\n`,NO=class extends gA{constructor(e){super(e),this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?ACe:Da.nil}}get(){return this._scope}name(e){return new bA(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,Da._)`${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=Da.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,$O.Started);let c=r(u);if(c){let l=this.opts.es5?ia.varKinds.var:ia.varKinds.const;o=(0,Da._)`${o}${l} ${u} = ${c};${this.opts._n}`}else if(c=i?.(u))o=(0,Da._)`${o}${c}${this.opts._n}`;else throw new OO(u);d.set(u,$O.Completed)})}return o}};ia.ValueScope=NO});var Qt=W(yr=>{"use strict";h();Object.defineProperty(yr,"__esModule",{value:!0});yr.or=yr.and=yr.not=yr.CodeGen=yr.operators=yr.varKinds=yr.ValueScopeName=yr.ValueScope=yr.Scope=yr.Name=yr.regexpCode=yr.stringify=yr.getProperty=yr.nil=yr.strConcat=yr.str=yr._=void 0;var Nr=oE(),yu=jO(),dm=oE();Object.defineProperty(yr,"_",{enumerable:!0,get:function(){return dm._}});Object.defineProperty(yr,"str",{enumerable:!0,get:function(){return dm.str}});Object.defineProperty(yr,"strConcat",{enumerable:!0,get:function(){return dm.strConcat}});Object.defineProperty(yr,"nil",{enumerable:!0,get:function(){return dm.nil}});Object.defineProperty(yr,"getProperty",{enumerable:!0,get:function(){return dm.getProperty}});Object.defineProperty(yr,"stringify",{enumerable:!0,get:function(){return dm.stringify}});Object.defineProperty(yr,"regexpCode",{enumerable:!0,get:function(){return dm.regexpCode}});Object.defineProperty(yr,"Name",{enumerable:!0,get:function(){return dm.Name}});var xA=jO();Object.defineProperty(yr,"Scope",{enumerable:!0,get:function(){return xA.Scope}});Object.defineProperty(yr,"ValueScope",{enumerable:!0,get:function(){return xA.ValueScope}});Object.defineProperty(yr,"ValueScopeName",{enumerable:!0,get:function(){return xA.ValueScopeName}});Object.defineProperty(yr,"varKinds",{enumerable:!0,get:function(){return xA.varKinds}});yr.operators={GT:new Nr._Code(">"),GTE:new Nr._Code(">="),LT:new Nr._Code("<"),LTE:new Nr._Code("<="),EQ:new Nr._Code("==="),NEQ:new Nr._Code("!=="),NOT:new Nr._Code("!"),OR:new Nr._Code("||"),AND:new Nr._Code("&&"),ADD:new Nr._Code("+")};var sh=class{optimizeNodes(){return this}optimizeNames(e,r){return this}},UO=class extends sh{constructor(e,r,n){super(),this.varKind=e,this.name=r,this.rhs=n}render({es5:e,_n:r}){let n=e?yu.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=Cw(this.rhs,e,r)),this}get names(){return this.rhs instanceof Nr._CodeOrName?this.rhs.names:{}}},vA=class extends sh{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 Nr.Name&&!e[this.lhs.str]&&!this.sideEffects))return this.rhs=Cw(this.rhs,e,r),this}get names(){let e=this.lhs instanceof Nr.Name?{}:{...this.lhs.names};return _A(e,this.rhs)}},KO=class extends vA{constructor(e,r,n,i){super(e,n,i),this.op=r}render({_n:e}){return`${this.lhs} ${this.op}= ${this.rhs};`+e}},qO=class extends sh{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`${this.label}:`+e}},LO=class extends sh{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`break${this.label?` ${this.label}`:""};`+e}},FO=class extends sh{constructor(e){super(),this.error=e}render({_n:e}){return`throw ${this.error};`+e}get names(){return this.error.names}},zO=class extends sh{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=Cw(this.code,e,r),this}get names(){return this.code instanceof Nr._CodeOrName?this.code.names:{}}},sE=class extends sh{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)||(PCe(e,o.names),n.splice(i,1))}return n.length>0?this:void 0}get names(){return this.nodes.reduce((e,r)=>Z0(e,r.names),{})}},ah=class extends sE{render(e){return"{"+e._n+super.render(e)+"}"+e._n}},GO=class extends sE{},Bw=class extends ah{};Bw.kind="else";var J0=class t extends ah{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 Bw(n):n}if(r)return e===!1?r instanceof t?r:r.nodes:this.nodes.length?this:new t(Gse(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=Cw(this.condition,e,r),this}get names(){let e=super.names;return _A(e,this.condition),this.else&&Z0(e,this.else.names),e}};J0.kind="if";var Y0=class extends ah{};Y0.kind="for";var WO=class extends Y0{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=Cw(this.iteration,e,r),this}get names(){return Z0(super.names,this.iteration.names)}},HO=class extends Y0{constructor(e,r,n,i){super(),this.varKind=e,this.name=r,this.from=n,this.to=i}render(e){let r=e.es5?yu.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=_A(super.names,this.from);return _A(e,this.to)}},wA=class extends Y0{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=Cw(this.iterable,e,r),this}get names(){return Z0(super.names,this.iterable.names)}},aE=class extends ah{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)}};aE.kind="func";var cE=class extends sE{render(e){return"return "+super.render(e)}};cE.kind="return";var VO=class extends ah{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&&Z0(e,this.catch.names),this.finally&&Z0(e,this.finally.names),e}},dE=class extends ah{constructor(e){super(),this.error=e}render(e){return`catch(${this.error})`+super.render(e)}};dE.kind="catch";var uE=class extends ah{render(e){return"finally"+super.render(e)}};uE.kind="finally";var JO=class{constructor(e,r={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...r,_n:r.lines?` `:""},this._extScope=e,this._scope=new yu.Scope({parent:e}),this._nodes=[new GO]}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 UO(e,o,n)),o}const(e,r,n){return this._def(yu.varKinds.const,e,r,n)}let(e,r,n){return this._def(yu.varKinds.let,e,r,n)}var(e,r,n){return this._def(yu.varKinds.var,e,r,n)}assign(e,r,n){return this._leafNode(new vA(e,r,n))}add(e,r){return this._leafNode(new KO(e,yr.operators.ADD,r))}code(e){return typeof e=="function"?e():e!==Nr.nil&&this._leafNode(new zO(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,Nr.addCodeArg)(r,i));return r.push("}"),new Nr._Code(r)}if(e,r,n){if(this._blockNode(new J0(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 J0(e))}else(){return this._elseNode(new Bw)}endIf(){return this._endBlockNode(J0,Bw)}_for(e,r){return this._blockNode(e),r&&this.code(r).endFor(),this}for(e,r){return this._for(new WO(e),r)}forRange(e,r,n,i,o=this.opts.es5?yu.varKinds.var:yu.varKinds.let){let s=this._scope.toName(e);return this._for(new HO(o,s,r,n),()=>i(s))}forOf(e,r,n,i=yu.varKinds.const){let o=this._scope.toName(e);if(this.opts.es5){let s=r instanceof Nr.Name?r:this.var("_arr",r);return this.forRange("_i",0,(0,Nr._)`${s}.length`,a=>{this.var(o,(0,Nr._)`${s}[${a}]`),n(o)})}return this._for(new wA("of",i,o,r),()=>n(o))}forIn(e,r,n,i=this.opts.es5?yu.varKinds.var:yu.varKinds.const){if(this.opts.ownProperties)return this.forOf(e,(0,Nr._)`Object.keys(${r})`,n);let o=this._scope.toName(e);return this._for(new wA("in",i,o,r),()=>n(o))}endFor(){return this._endBlockNode(Y0)}label(e){return this._leafNode(new qO(e))}break(e){return this._leafNode(new LO(e))}return(e){let r=new cE;if(this._blockNode(r),this.code(e),r.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(cE)}try(e,r,n){if(!r&&!n)throw new Error('CodeGen: "try" without "catch" and "finally"');let i=new VO;if(this._blockNode(i),this.code(e),r){let o=this.name("e");this._currNode=i.catch=new dE(o),r(o)}return n&&(this._currNode=i.finally=new uE,this.code(n)),this._endBlockNode(dE,uE)}throw(e){return this._leafNode(new FO(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=Nr.nil,n,i){return this._blockNode(new aE(e,r,n)),i&&this.code(i).endFunc(),this}endFunc(){return this._endBlockNode(aE)}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 J0))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}};yr.CodeGen=JO;function Z0(t,e){for(let r in e)t[r]=(t[r]||0)+(e[r]||0);return t}function _A(t,e){return e instanceof Nr._CodeOrName?Z0(t,e.names):t}function Cw(t,e,r){if(t instanceof Nr.Name)return n(t);if(!i(t))return t;return new Nr._Code(t._items.reduce((o,s)=>(s instanceof Nr.Name&&(s=n(s)),s instanceof Nr._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 Nr._Code&&o._items.some(s=>s instanceof Nr.Name&&e[s.str]===1&&r[s.str]!==void 0)}}function PCe(t,e){for(let r in e)t[r]=(t[r]||0)-(e[r]||0)}function Gse(t){return typeof t=="boolean"||typeof t=="number"||t===null?!t:(0,Nr._)`!${YO(t)}`}yr.not=Gse;var TCe=Wse(yr.operators.AND);function ICe(...t){return t.reduce(TCe)}yr.and=ICe;var kCe=Wse(yr.operators.OR);function RCe(...t){return t.reduce(kCe)}yr.or=RCe;function Wse(t){return(e,r)=>e===Nr.nil?r:r===Nr.nil?e:(0,Nr._)`${YO(e)} ${t} ${YO(r)}`}function YO(t){return t instanceof Nr.Name?t:(0,Nr._)`(${t})`}});var Ir=W(gr=>{"use strict";h();Object.defineProperty(gr,"__esModule",{value:!0});gr.checkStrictMode=gr.getErrorPath=gr.Type=gr.useFunc=gr.setEvaluated=gr.evaluatedPropsToName=gr.mergeEvaluated=gr.eachItem=gr.unescapeJsonPointer=gr.escapeJsonPointer=gr.escapeFragment=gr.unescapeFragment=gr.schemaRefOrVal=gr.schemaHasRulesButRef=gr.schemaHasRules=gr.checkUnknownRules=gr.alwaysValidSchema=gr.toHash=void 0;var xn=Qt(),DCe=oE();function MCe(t){let e={};for(let r of t)e[r]=!0;return e}gr.toHash=MCe;function BCe(t,e){return typeof e=="boolean"?e:Object.keys(e).length===0?!0:(Jse(t,e),!Yse(e,t.self.RULES.all))}gr.alwaysValidSchema=BCe;function Jse(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]||eae(t,`unknown keyword: "${o}"`)}gr.checkUnknownRules=Jse;function Yse(t,e){if(typeof t=="boolean")return!t;for(let r in t)if(e[r])return!0;return!1}gr.schemaHasRules=Yse;function CCe(t,e){if(typeof t=="boolean")return!t;for(let r in t)if(r!=="$ref"&&e.all[r])return!0;return!1}gr.schemaHasRulesButRef=CCe;function OCe({topSchemaRef:t,schemaPath:e},r,n,i){if(!i){if(typeof r=="number"||typeof r=="boolean")return r;if(typeof r=="string")return(0,xn._)`${r}`}return(0,xn._)`${t}${e}${(0,xn.getProperty)(n)}`}gr.schemaRefOrVal=OCe;function $Ce(t){return Zse(decodeURIComponent(t))}gr.unescapeFragment=$Ce;function NCe(t){return encodeURIComponent(ZO(t))}gr.escapeFragment=NCe;function ZO(t){return typeof t=="number"?`${t}`:t.replace(/~/g,"~0").replace(/\//g,"~1")}gr.escapeJsonPointer=ZO;function Zse(t){return t.replace(/~1/g,"/").replace(/~0/g,"~")}gr.unescapeJsonPointer=Zse;function jCe(t,e){if(Array.isArray(t))for(let r of t)e(r);else e(t)}gr.eachItem=jCe;function Hse({mergeNames:t,mergeToName:e,mergeValues:r,resultToName:n}){return(i,o,s,a)=>{let d=s===void 0?o:s instanceof xn.Name?(o instanceof xn.Name?t(i,o,s):e(i,o,s),s):o instanceof xn.Name?(e(i,s,o),o):r(o,s);return a===xn.Name&&!(d instanceof xn.Name)?n(i,d):d}}gr.mergeEvaluated={props:Hse({mergeNames:(t,e,r)=>t.if((0,xn._)`${r} !== true && ${e} !== undefined`,()=>{t.if((0,xn._)`${e} === true`,()=>t.assign(r,!0),()=>t.assign(r,(0,xn._)`${r} || {}`).code((0,xn._)`Object.assign(${r}, ${e})`))}),mergeToName:(t,e,r)=>t.if((0,xn._)`${r} !== true`,()=>{e===!0?t.assign(r,!0):(t.assign(r,(0,xn._)`${r} || {}`),XO(t,r,e))}),mergeValues:(t,e)=>t===!0?!0:{...t,...e},resultToName:Xse}),items:Hse({mergeNames:(t,e,r)=>t.if((0,xn._)`${r} !== true && ${e} !== undefined`,()=>t.assign(r,(0,xn._)`${e} === true ? true : ${r} > ${e} ? ${r} : ${e}`)),mergeToName:(t,e,r)=>t.if((0,xn._)`${r} !== true`,()=>t.assign(r,e===!0?!0:(0,xn._)`${r} > ${e} ? ${r} : ${e}`)),mergeValues:(t,e)=>t===!0?!0:Math.max(t,e),resultToName:(t,e)=>t.var("items",e)})};function Xse(t,e){if(e===!0)return t.var("props",!0);let r=t.var("props",(0,xn._)`{}`);return e!==void 0&&XO(t,r,e),r}gr.evaluatedPropsToName=Xse;function XO(t,e,r){Object.keys(r).forEach(n=>t.assign((0,xn._)`${e}${(0,xn.getProperty)(n)}`,!0))}gr.setEvaluated=XO;var Vse={};function UCe(t,e){return t.scopeValue("func",{ref:e,code:Vse[e.code]||(Vse[e.code]=new DCe._Code(e.code))})}gr.useFunc=UCe;var Qse;(function(t){t[t.Num=0]="Num",t[t.Str=1]="Str"})(Qse=gr.Type||(gr.Type={}));function KCe(t,e,r){if(t instanceof xn.Name){let n=e===Qse.Num;return r?n?(0,xn._)`"[" + ${t} + "]"`:(0,xn._)`"['" + ${t} + "']"`:n?(0,xn._)`"/" + ${t}`:(0,xn._)`"/" + ${t}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,xn.getProperty)(t).toString():"/"+ZO(t)}gr.getErrorPath=KCe;function eae(t,e,r=t.opts.strictSchema){if(r){if(e=`strict mode: ${e}`,r===!0)throw new Error(e);t.self.logger.warn(e)}}gr.checkStrictMode=eae});var hd=W(QO=>{"use strict";h();Object.defineProperty(QO,"__esModule",{value:!0});var Cs=Qt(),qCe={data:new Cs.Name("data"),valCxt:new Cs.Name("valCxt"),instancePath:new Cs.Name("instancePath"),parentData:new Cs.Name("parentData"),parentDataProperty:new Cs.Name("parentDataProperty"),rootData:new Cs.Name("rootData"),dynamicAnchors:new Cs.Name("dynamicAnchors"),vErrors:new Cs.Name("vErrors"),errors:new Cs.Name("errors"),this:new Cs.Name("this"),self:new Cs.Name("self"),scope:new Cs.Name("scope"),json:new Cs.Name("json"),jsonPos:new Cs.Name("jsonPos"),jsonLen:new Cs.Name("jsonLen"),jsonPart:new Cs.Name("jsonPart")};QO.default=qCe});var lE=W(Os=>{"use strict";h();Object.defineProperty(Os,"__esModule",{value:!0});Os.extendErrors=Os.resetErrorsCount=Os.reportExtraError=Os.reportError=Os.keyword$DataError=Os.keywordError=void 0;var Kr=Qt(),EA=Ir(),oa=hd();Os.keywordError={message:({keyword:t})=>(0,Kr.str)`must pass "${t}" keyword validation`};Os.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 LCe(t,e=Os.keywordError,r,n){let{it:i}=t,{gen:o,compositeRule:s,allErrors:a}=i,d=nae(t,e,r);n??(s||a)?tae(o,d):rae(i,(0,Kr._)`[${d}]`)}Os.reportError=LCe;function FCe(t,e=Os.keywordError,r){let{it:n}=t,{gen:i,compositeRule:o,allErrors:s}=n,a=nae(t,e,r);tae(i,a),o||s||rae(n,oa.default.vErrors)}Os.reportExtraError=FCe;function zCe(t,e){t.assign(oa.default.errors,e),t.if((0,Kr._)`${oa.default.vErrors} !== null`,()=>t.if(e,()=>t.assign((0,Kr._)`${oa.default.vErrors}.length`,e),()=>t.assign(oa.default.vErrors,null)))}Os.resetErrorsCount=zCe;function GCe({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,oa.default.errors,a=>{t.const(s,(0,Kr._)`${oa.default.vErrors}[${a}]`),t.if((0,Kr._)`${s}.instancePath === undefined`,()=>t.assign((0,Kr._)`${s}.instancePath`,(0,Kr.strConcat)(oa.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))})}Os.extendErrors=GCe;function tae(t,e){let r=t.const("err",e);t.if((0,Kr._)`${oa.default.vErrors} === null`,()=>t.assign(oa.default.vErrors,(0,Kr._)`[${r}]`),(0,Kr._)`${oa.default.vErrors}.push(${r})`),t.code((0,Kr._)`${oa.default.errors}++`)}function rae(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 X0={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 nae(t,e,r){let{createErrors:n}=t.it;return n===!1?(0,Kr._)`{}`:WCe(t,e,r)}function WCe(t,e,r={}){let{gen:n,it:i}=t,o=[HCe(i,r),VCe(t,r)];return JCe(t,e,o),n.object(...o)}function HCe({errorPath:t},{instancePath:e}){let r=e?(0,Kr.str)`${t}${(0,EA.getErrorPath)(e,EA.Type.Str)}`:t;return[oa.default.instancePath,(0,Kr.strConcat)(oa.default.instancePath,r)]}function VCe({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,EA.getErrorPath)(r,EA.Type.Str)}`),[X0.schemaPath,i]}function JCe(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([X0.keyword,i],[X0.params,typeof e=="function"?e(t):e||(0,Kr._)`{}`]),d.messages&&n.push([X0.message,typeof r=="function"?r(t):r]),d.verbose&&n.push([X0.schema,s],[X0.parentSchema,(0,Kr._)`${c}${l}`],[oa.default.data,o]),u&&n.push([X0.propertyName,u])}});var oae=W(Ow=>{"use strict";h();Object.defineProperty(Ow,"__esModule",{value:!0});Ow.boolOrEmptySchema=Ow.topBoolOrEmptySchema=void 0;var YCe=lE(),ZCe=Qt(),XCe=hd(),QCe={message:"boolean schema is false"};function eOe(t){let{gen:e,schema:r,validateName:n}=t;r===!1?iae(t,!1):typeof r=="object"&&r.$async===!0?e.return(XCe.default.data):(e.assign((0,ZCe._)`${n}.errors`,null),e.return(!0))}Ow.topBoolOrEmptySchema=eOe;function tOe(t,e){let{gen:r,schema:n}=t;n===!1?(r.var(e,!1),iae(t)):r.var(e,!0)}Ow.boolOrEmptySchema=tOe;function iae(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,YCe.reportError)(i,QCe,void 0,e)}});var e$=W($w=>{"use strict";h();Object.defineProperty($w,"__esModule",{value:!0});$w.getRules=$w.isJSONType=void 0;var rOe=["string","number","integer","boolean","null","object","array"],nOe=new Set(rOe);function iOe(t){return typeof t=="string"&&nOe.has(t)}$w.isJSONType=iOe;function oOe(){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:{}}}$w.getRules=oOe});var t$=W(um=>{"use strict";h();Object.defineProperty(um,"__esModule",{value:!0});um.shouldUseRule=um.shouldUseGroup=um.schemaHasRulesForType=void 0;function sOe({schema:t,self:e},r){let n=e.RULES.types[r];return n&&n!==!0&&sae(t,n)}um.schemaHasRulesForType=sOe;function sae(t,e){return e.rules.some(r=>aae(t,r))}um.shouldUseGroup=sae;function aae(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))}um.shouldUseRule=aae});var hE=W(es=>{"use strict";h();Object.defineProperty(es,"__esModule",{value:!0});es.reportTypeError=es.checkDataTypes=es.checkDataType=es.coerceAndCheckDataType=es.getJSONTypes=es.getSchemaTypes=es.DataType=void 0;var aOe=e$(),cOe=t$(),dOe=lE(),rr=Qt(),cae=Ir(),fE;(function(t){t[t.Correct=0]="Correct",t[t.Wrong=1]="Wrong"})(fE=es.DataType||(es.DataType={}));function uOe(t){let e=dae(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=uOe;function dae(t){let e=Array.isArray(t)?t:t?[t]:[];if(e.every(aOe.isJSONType))return e;throw new Error("type must be JSONType or JSONType[]: "+e.join(","))}es.getJSONTypes=dae;function lOe(t,e){let{gen:r,data:n,opts:i}=t,o=fOe(e,i.coerceTypes),s=e.length>0&&!(o.length===0&&e.length===1&&(0,cOe.schemaHasRulesForType)(t,e[0]));if(s){let a=n$(e,n,i.strictNumbers,fE.Wrong);r.if(a,()=>{o.length?hOe(t,e,o):i$(t)})}return s}es.coerceAndCheckDataType=lOe;var uae=new Set(["string","number","integer","boolean","null"]);function fOe(t,e){return e?t.filter(r=>uae.has(r)||e==="array"&&r==="array"):[]}function hOe(t,e,r){let{gen:n,data:i,opts:o}=t,s=n.let("dataType",(0,rr._)`typeof ${i}`),a=n.let("coerced",(0,rr._)`undefined`);o.coerceTypes==="array"&&n.if((0,rr._)`${s} == 'object' && Array.isArray(${i}) && ${i}.length == 1`,()=>n.assign(i,(0,rr._)`${i}[0]`).assign(s,(0,rr._)`typeof ${i}`).if(n$(e,i,o.strictNumbers),()=>n.assign(a,i))),n.if((0,rr._)`${a} !== undefined`);for(let u of r)(uae.has(u)||u==="array"&&o.coerceTypes==="array")&&d(u);n.else(),i$(t),n.endIf(),n.if((0,rr._)`${a} !== undefined`,()=>{n.assign(i,a),pOe(t,a)});function d(u){switch(u){case"string":n.elseIf((0,rr._)`${s} == "number" || ${s} == "boolean"`).assign(a,(0,rr._)`"" + ${i}`).elseIf((0,rr._)`${i} === null`).assign(a,(0,rr._)`""`);return;case"number":n.elseIf((0,rr._)`${s} == "boolean" || ${i} === null || (${s} == "string" && ${i} && ${i} == +${i})`).assign(a,(0,rr._)`+${i}`);return;case"integer":n.elseIf((0,rr._)`${s} === "boolean" || ${i} === null || (${s} === "string" && ${i} && ${i} == +${i} && !(${i} % 1))`).assign(a,(0,rr._)`+${i}`);return;case"boolean":n.elseIf((0,rr._)`${i} === "false" || ${i} === 0 || ${i} === null`).assign(a,!1).elseIf((0,rr._)`${i} === "true" || ${i} === 1`).assign(a,!0);return;case"null":n.elseIf((0,rr._)`${i} === "" || ${i} === 0 || ${i} === false`),n.assign(a,null);return;case"array":n.elseIf((0,rr._)`${s} === "string" || ${s} === "number" || ${s} === "boolean" || ${i} === null`).assign(a,(0,rr._)`[${i}]`)}}}function pOe({gen:t,parentData:e,parentDataProperty:r},n){t.if((0,rr._)`${e} !== undefined`,()=>t.assign((0,rr._)`${e}[${r}]`,n))}function r$(t,e,r,n=fE.Correct){let i=n===fE.Correct?rr.operators.EQ:rr.operators.NEQ,o;switch(t){case"null":return(0,rr._)`${e} ${i} null`;case"array":o=(0,rr._)`Array.isArray(${e})`;break;case"object":o=(0,rr._)`${e} && typeof ${e} == "object" && !Array.isArray(${e})`;break;case"integer":o=s((0,rr._)`!(${e} % 1) && !isNaN(${e})`);break;case"number":o=s();break;default:return(0,rr._)`typeof ${e} ${i} ${t}`}return n===fE.Correct?o:(0,rr.not)(o);function s(a=rr.nil){return(0,rr.and)((0,rr._)`typeof ${e} == "number"`,a,r?(0,rr._)`isFinite(${e})`:rr.nil)}}es.checkDataType=r$;function n$(t,e,r,n){if(t.length===1)return r$(t[0],e,r,n);let i,o=(0,cae.toHash)(t);if(o.array&&o.object){let s=(0,rr._)`typeof ${e} != "object"`;i=o.null?s:(0,rr._)`!${e} || ${s}`,delete o.null,delete o.array,delete o.object}else i=rr.nil;o.number&&delete o.integer;for(let s in o)i=(0,rr.and)(i,r$(s,e,r,n));return i}es.checkDataTypes=n$;var mOe={message:({schema:t})=>`must be ${t}`,params:({schema:t,schemaValue:e})=>typeof t=="string"?(0,rr._)`{type: ${t}}`:(0,rr._)`{type: ${e}}`};function i$(t){let e=yOe(t);(0,dOe.reportError)(e,mOe)}es.reportTypeError=i$;function yOe(t){let{gen:e,data:r,schema:n}=t,i=(0,cae.schemaRefOrVal)(t,n,"type");return{gen:e,keyword:"type",data:r,schema:n.type,schemaCode:i,schemaValue:i,parentSchema:n,params:{},it:t}}});var fae=W(SA=>{"use strict";h();Object.defineProperty(SA,"__esModule",{value:!0});SA.assignDefaults=void 0;var Nw=Qt(),gOe=Ir();function bOe(t,e){let{properties:r,items:n}=t.schema;if(e==="object"&&r)for(let i in r)lae(t,i,r[i].default);else e==="array"&&Array.isArray(n)&&n.forEach((i,o)=>lae(t,o,i.default))}SA.assignDefaults=bOe;function lae(t,e,r){let{gen:n,compositeRule:i,data:o,opts:s}=t;if(r===void 0)return;let a=(0,Nw._)`${o}${(0,Nw.getProperty)(e)}`;if(i){(0,gOe.checkStrictMode)(t,`default is ignored for: ${a}`);return}let d=(0,Nw._)`${a} === undefined`;s.useDefaults==="empty"&&(d=(0,Nw._)`${d} || ${a} === null || ${a} === ""`),n.if(d,(0,Nw._)`${a} = ${(0,Nw.stringify)(r)}`)}});var pd=W(mn=>{"use strict";h();Object.defineProperty(mn,"__esModule",{value:!0});mn.validateUnion=mn.validateArray=mn.usePattern=mn.callValidateCode=mn.schemaProperties=mn.allSchemaProperties=mn.noPropertyInData=mn.propertyInData=mn.isOwnProperty=mn.hasPropFunc=mn.reportMissingProp=mn.checkMissingProp=mn.checkReportMissingProp=void 0;var Bn=Qt(),o$=Ir(),lm=hd(),vOe=Ir();function wOe(t,e){let{gen:r,data:n,it:i}=t;r.if(a$(r,n,e,i.opts.ownProperties),()=>{t.setParams({missingProperty:(0,Bn._)`${e}`},!0),t.error()})}mn.checkReportMissingProp=wOe;function _Oe({gen:t,data:e,it:{opts:r}},n,i){return(0,Bn.or)(...n.map(o=>(0,Bn.and)(a$(t,e,o,r.ownProperties),(0,Bn._)`${i} = ${o}`)))}mn.checkMissingProp=_Oe;function xOe(t,e){t.setParams({missingProperty:e},!0),t.error()}mn.reportMissingProp=xOe;function hae(t){return t.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,Bn._)`Object.prototype.hasOwnProperty`})}mn.hasPropFunc=hae;function s$(t,e,r){return(0,Bn._)`${hae(t)}.call(${e}, ${r})`}mn.isOwnProperty=s$;function EOe(t,e,r,n){let i=(0,Bn._)`${e}${(0,Bn.getProperty)(r)} !== undefined`;return n?(0,Bn._)`${i} && ${s$(t,e,r)}`:i}mn.propertyInData=EOe;function a$(t,e,r,n){let i=(0,Bn._)`${e}${(0,Bn.getProperty)(r)} === undefined`;return n?(0,Bn.or)(i,(0,Bn.not)(s$(t,e,r))):i}mn.noPropertyInData=a$;function pae(t){return t?Object.keys(t).filter(e=>e!=="__proto__"):[]}mn.allSchemaProperties=pae;function SOe(t,e){return pae(e).filter(r=>!(0,o$.alwaysValidSchema)(t,e[r]))}mn.schemaProperties=SOe;function AOe({schemaCode:t,data:e,it:{gen:r,topSchemaRef:n,schemaPath:i,errorPath:o},it:s},a,d,u){let c=u?(0,Bn._)`${t}, ${e}, ${n}${i}`:e,l=[[lm.default.instancePath,(0,Bn.strConcat)(lm.default.instancePath,o)],[lm.default.parentData,s.parentData],[lm.default.parentDataProperty,s.parentDataProperty],[lm.default.rootData,lm.default.rootData]];s.opts.dynamicRef&&l.push([lm.default.dynamicAnchors,lm.default.dynamicAnchors]);let m=(0,Bn._)`${c}, ${r.object(...l)}`;return d!==Bn.nil?(0,Bn._)`${a}.call(${d}, ${m})`:(0,Bn._)`${a}(${m})`}mn.callValidateCode=AOe;var POe=(0,Bn._)`new RegExp`;function TOe({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,Bn._)`${i.code==="new RegExp"?POe:(0,vOe.useFunc)(t,i)}(${r}, ${n})`})}mn.usePattern=TOe;function IOe(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,Bn._)`${r}.length`);e.forRange("i",0,d,u=>{t.subschema({keyword:n,dataProp:u,dataPropType:o$.Type.Num},o),e.if((0,Bn.not)(o),a)})}}mn.validateArray=IOe;function kOe(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,o$.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,Bn._)`${s} || ${a}`),t.mergeValidEvaluated(c,a)||e.if((0,Bn.not)(s))})),t.result(s,()=>t.reset(),()=>t.error(!0))}mn.validateUnion=kOe});var gae=W(Bl=>{"use strict";h();Object.defineProperty(Bl,"__esModule",{value:!0});Bl.validateKeywordUsage=Bl.validSchemaType=Bl.funcKeywordCode=Bl.macroKeywordCode=void 0;var sa=Qt(),Q0=hd(),ROe=pd(),DOe=lE();function MOe(t,e){let{gen:r,keyword:n,schema:i,parentSchema:o,it:s}=t,a=e.macro.call(s.self,i,o,s),d=yae(r,n,a);s.opts.validateSchema!==!1&&s.self.validateSchema(a,!0);let u=r.name("valid");t.subschema({schema:a,schemaPath:sa.nil,errSchemaPath:`${s.errSchemaPath}/${n}`,topSchemaRef:d,compositeRule:!0},u),t.pass(u,()=>t.error(!0))}Bl.macroKeywordCode=MOe;function BOe(t,e){var r;let{gen:n,keyword:i,schema:o,parentSchema:s,$data:a,it:d}=t;OOe(d,e);let u=!a&&e.compile?e.compile.call(d.self,o,s,d):e.validate,c=yae(n,i,u),l=n.let("valid");t.block$data(l,m),t.ok((r=e.valid)!==null&&r!==void 0?r:l);function m(){if(e.errors===!1)b(),e.modifying&&mae(t),S(()=>t.error());else{let A=e.async?p():g();e.modifying&&mae(t),S(()=>COe(t,A))}}function p(){let A=n.let("ruleErrs",null);return n.try(()=>b((0,sa._)`await `),I=>n.assign(l,!1).if((0,sa._)`${I} instanceof ${d.ValidationError}`,()=>n.assign(A,(0,sa._)`${I}.errors`),()=>n.throw(I))),A}function g(){let A=(0,sa._)`${c}.errors`;return n.assign(A,null),b(sa.nil),A}function b(A=e.async?(0,sa._)`await `:sa.nil){let I=d.opts.passContext?Q0.default.this:Q0.default.self,P=!("compile"in e&&!a||e.schema===!1);n.assign(l,(0,sa._)`${A}${(0,ROe.callValidateCode)(t,c,I,P)}`,e.modifying)}function S(A){var I;n.if((0,sa.not)((I=e.valid)!==null&&I!==void 0?I:l),A)}}Bl.funcKeywordCode=BOe;function mae(t){let{gen:e,data:r,it:n}=t;e.if(n.parentData,()=>e.assign(r,(0,sa._)`${n.parentData}[${n.parentDataProperty}]`))}function COe(t,e){let{gen:r}=t;r.if((0,sa._)`Array.isArray(${e})`,()=>{r.assign(Q0.default.vErrors,(0,sa._)`${Q0.default.vErrors} === null ? ${e} : ${Q0.default.vErrors}.concat(${e})`).assign(Q0.default.errors,(0,sa._)`${Q0.default.vErrors}.length`),(0,DOe.extendErrors)(t)},()=>t.error())}function OOe({schemaEnv:t},e){if(e.async&&!t.$async)throw new Error("async keyword in sync schema")}function yae(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,sa.stringify)(r)})}function $Oe(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")}Bl.validSchemaType=$Oe;function NOe({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)}}Bl.validateKeywordUsage=NOe});var vae=W(fm=>{"use strict";h();Object.defineProperty(fm,"__esModule",{value:!0});fm.extendSubschemaMode=fm.extendSubschemaData=fm.getSubschema=void 0;var Cl=Qt(),bae=Ir();function jOe(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,Cl._)`${t.schemaPath}${(0,Cl.getProperty)(e)}`,errSchemaPath:`${t.errSchemaPath}/${e}`}:{schema:a[r],schemaPath:(0,Cl._)`${t.schemaPath}${(0,Cl.getProperty)(e)}${(0,Cl.getProperty)(r)}`,errSchemaPath:`${t.errSchemaPath}/${e}/${(0,bae.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')}fm.getSubschema=jOe;function UOe(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,m=a.let("data",(0,Cl._)`${e.data}${(0,Cl.getProperty)(r)}`,!0);d(m),t.errorPath=(0,Cl.str)`${u}${(0,bae.getErrorPath)(r,n,l.jsPropertySyntax)}`,t.parentDataProperty=(0,Cl._)`${r}`,t.dataPathArr=[...c,t.parentDataProperty]}if(i!==void 0){let u=i instanceof Cl.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]}}fm.extendSubschemaData=UOe;function KOe(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}fm.extendSubschemaMode=KOe});var c$=W((Lvt,wae)=>{"use strict";h();wae.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 xae=W((zvt,_ae)=>{"use strict";h();var hm=_ae.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(){};AA(e,n,i,t,"",t)};hm.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0};hm.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};hm.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};hm.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 AA(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 hm.arrayKeywords)for(var m=0;m{"use strict";h();Object.defineProperty(Ma,"__esModule",{value:!0});Ma.getSchemaRefs=Ma.resolveUrl=Ma.normalizeId=Ma._getFullPath=Ma.getFullPath=Ma.inlineRef=void 0;var LOe=Ir(),FOe=c$(),zOe=xae(),GOe=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);function WOe(t,e=!0){return typeof t=="boolean"?!0:e===!0?!d$(t):e?Eae(t)<=e:!1}Ma.inlineRef=WOe;var HOe=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function d$(t){for(let e in t){if(HOe.has(e))return!0;let r=t[e];if(Array.isArray(r)&&r.some(d$)||typeof r=="object"&&d$(r))return!0}return!1}function Eae(t){let e=0;for(let r in t){if(r==="$ref")return 1/0;if(e++,!GOe.has(r)&&(typeof t[r]=="object"&&(0,LOe.eachItem)(t[r],n=>e+=Eae(n)),e===1/0))return 1/0}return e}function Sae(t,e="",r){r!==!1&&(e=jw(e));let n=t.parse(e);return Aae(t,n)}Ma.getFullPath=Sae;function Aae(t,e){return t.serialize(e).split("#")[0]+"#"}Ma._getFullPath=Aae;var VOe=/#\/?$/;function jw(t){return t?t.replace(VOe,""):""}Ma.normalizeId=jw;function JOe(t,e,r){return r=jw(r),t.resolve(e,r)}Ma.resolveUrl=JOe;var YOe=/^[a-z_][-a-z0-9._]*$/i;function ZOe(t,e){if(typeof t=="boolean")return{};let{schemaId:r,uriResolver:n}=this.opts,i=jw(t[r]||e),o={"":i},s=Sae(n,i,!1),a={},d=new Set;return zOe(t,{allKeys:!0},(l,m,p,g)=>{if(g===void 0)return;let b=s+m,S=o[g];typeof l[r]=="string"&&(S=A.call(this,l[r])),I.call(this,l.$anchor),I.call(this,l.$dynamicAnchor),o[m]=S;function A(P){let $=this.opts.uriResolver.resolve;if(P=jw(S?$(S,P):P),d.has(P))throw c(P);d.add(P);let N=this.refs[P];return typeof N=="string"&&(N=this.refs[N]),typeof N=="object"?u(l,N.schema,P):P!==jw(b)&&(P[0]==="#"?(u(l,a[P],P),a[P]=l):this.refs[P]=b),P}function I(P){if(typeof P=="string"){if(!YOe.test(P))throw new Error(`invalid anchor "${P}"`);A.call(this,`#${P}`)}}}),a;function u(l,m,p){if(m!==void 0&&!FOe(l,m))throw c(p)}function c(l){return new Error(`reference "${l}" resolves to more than one schema`)}}Ma.getSchemaRefs=ZOe});var gE=W(pm=>{"use strict";h();Object.defineProperty(pm,"__esModule",{value:!0});pm.getData=pm.KeywordCxt=pm.validateFunctionCode=void 0;var Rae=oae(),Pae=hE(),l$=t$(),PA=hE(),XOe=fae(),yE=gae(),u$=vae(),lt=Qt(),Ot=hd(),QOe=pE(),ch=Ir(),mE=lE();function e$e(t){if(Bae(t)&&(Cae(t),Mae(t))){n$e(t);return}Dae(t,()=>(0,Rae.topBoolOrEmptySchema)(t))}pm.validateFunctionCode=e$e;function Dae({gen:t,validateName:e,schema:r,schemaEnv:n,opts:i},o){i.code.es5?t.func(e,(0,lt._)`${Ot.default.data}, ${Ot.default.valCxt}`,n.$async,()=>{t.code((0,lt._)`"use strict"; ${Tae(r,i)}`),r$e(t,i),t.code(o)}):t.func(e,(0,lt._)`${Ot.default.data}, ${t$e(i)}`,n.$async,()=>t.code(Tae(r,i)).code(o))}function t$e(t){return(0,lt._)`{${Ot.default.instancePath}="", ${Ot.default.parentData}, ${Ot.default.parentDataProperty}, ${Ot.default.rootData}=${Ot.default.data}${t.dynamicRef?(0,lt._)`, ${Ot.default.dynamicAnchors}={}`:lt.nil}}={}`}function r$e(t,e){t.if(Ot.default.valCxt,()=>{t.var(Ot.default.instancePath,(0,lt._)`${Ot.default.valCxt}.${Ot.default.instancePath}`),t.var(Ot.default.parentData,(0,lt._)`${Ot.default.valCxt}.${Ot.default.parentData}`),t.var(Ot.default.parentDataProperty,(0,lt._)`${Ot.default.valCxt}.${Ot.default.parentDataProperty}`),t.var(Ot.default.rootData,(0,lt._)`${Ot.default.valCxt}.${Ot.default.rootData}`),e.dynamicRef&&t.var(Ot.default.dynamicAnchors,(0,lt._)`${Ot.default.valCxt}.${Ot.default.dynamicAnchors}`)},()=>{t.var(Ot.default.instancePath,(0,lt._)`""`),t.var(Ot.default.parentData,(0,lt._)`undefined`),t.var(Ot.default.parentDataProperty,(0,lt._)`undefined`),t.var(Ot.default.rootData,Ot.default.data),e.dynamicRef&&t.var(Ot.default.dynamicAnchors,(0,lt._)`{}`)})}function n$e(t){let{schema:e,opts:r,gen:n}=t;Dae(t,()=>{r.$comment&&e.$comment&&$ae(t),c$e(t),n.let(Ot.default.vErrors,null),n.let(Ot.default.errors,0),r.unevaluated&&i$e(t),Oae(t),l$e(t)})}function i$e(t){let{gen:e,validateName:r}=t;t.evaluated=e.const("evaluated",(0,lt._)`${r}.evaluated`),e.if((0,lt._)`${t.evaluated}.dynamicProps`,()=>e.assign((0,lt._)`${t.evaluated}.props`,(0,lt._)`undefined`)),e.if((0,lt._)`${t.evaluated}.dynamicItems`,()=>e.assign((0,lt._)`${t.evaluated}.items`,(0,lt._)`undefined`))}function Tae(t,e){let r=typeof t=="object"&&t[e.schemaId];return r&&(e.code.source||e.code.process)?(0,lt._)`/*# sourceURL=${r} */`:lt.nil}function o$e(t,e){if(Bae(t)&&(Cae(t),Mae(t))){s$e(t,e);return}(0,Rae.boolOrEmptySchema)(t,e)}function Mae({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 Bae(t){return typeof t.schema!="boolean"}function s$e(t,e){let{schema:r,gen:n,opts:i}=t;i.$comment&&r.$comment&&$ae(t),d$e(t),u$e(t);let o=n.const("_errs",Ot.default.errors);Oae(t,o),n.var(e,(0,lt._)`${o} === ${Ot.default.errors}`)}function Cae(t){(0,ch.checkUnknownRules)(t),a$e(t)}function Oae(t,e){if(t.opts.jtd)return Iae(t,[],!1,e);let r=(0,Pae.getSchemaTypes)(t.schema),n=(0,Pae.coerceAndCheckDataType)(t,r);Iae(t,r,!n,e)}function a$e(t){let{schema:e,errSchemaPath:r,opts:n,self:i}=t;e.$ref&&n.ignoreKeywordsWithRef&&(0,ch.schemaHasRulesButRef)(e,i.RULES)&&i.logger.warn(`$ref: keywords ignored in schema at path "${r}"`)}function c$e(t){let{schema:e,opts:r}=t;e.default!==void 0&&r.useDefaults&&r.strictSchema&&(0,ch.checkStrictMode)(t,"default is ignored in the schema root")}function d$e(t){let e=t.schema[t.opts.schemaId];e&&(t.baseId=(0,QOe.resolveUrl)(t.opts.uriResolver,t.baseId,e))}function u$e(t){if(t.schema.$async&&!t.schemaEnv.$async)throw new Error("async schema in sync schema")}function $ae({gen:t,schemaEnv:e,schema:r,errSchemaPath:n,opts:i}){let o=r.$comment;if(i.$comment===!0)t.code((0,lt._)`${Ot.default.self}.logger.log(${o})`);else if(typeof i.$comment=="function"){let s=(0,lt.str)`${n}/$comment`,a=t.scopeValue("root",{ref:e.root});t.code((0,lt._)`${Ot.default.self}.opts.$comment(${o}, ${s}, ${a}.schema)`)}}function l$e(t){let{gen:e,schemaEnv:r,validateName:n,ValidationError:i,opts:o}=t;r.$async?e.if((0,lt._)`${Ot.default.errors} === 0`,()=>e.return(Ot.default.data),()=>e.throw((0,lt._)`new ${i}(${Ot.default.vErrors})`)):(e.assign((0,lt._)`${n}.errors`,Ot.default.vErrors),o.unevaluated&&f$e(t),e.return((0,lt._)`${Ot.default.errors} === 0`))}function f$e({gen:t,evaluated:e,props:r,items:n}){r instanceof lt.Name&&t.assign((0,lt._)`${e}.props`,r),n instanceof lt.Name&&t.assign((0,lt._)`${e}.items`,n)}function Iae(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,ch.schemaHasRulesButRef)(o,c))){i.block(()=>jae(t,"$ref",c.all.$ref.definition));return}d.jtd||h$e(t,e),i.block(()=>{for(let m of c.rules)l(m);l(c.post)});function l(m){(0,l$.shouldUseGroup)(o,m)&&(m.type?(i.if((0,PA.checkDataType)(m.type,s,d.strictNumbers)),kae(t,m),e.length===1&&e[0]===m.type&&r&&(i.else(),(0,PA.reportTypeError)(t)),i.endIf()):kae(t,m),a||i.if((0,lt._)`${Ot.default.errors} === ${n||0}`))}}function kae(t,e){let{gen:r,schema:n,opts:{useDefaults:i}}=t;i&&(0,XOe.assignDefaults)(t,e.type),r.block(()=>{for(let o of e.rules)(0,l$.shouldUseRule)(n,o)&&jae(t,o.keyword,o.definition,e.type)})}function h$e(t,e){t.schemaEnv.meta||!t.opts.strictTypes||(p$e(t,e),t.opts.allowUnionTypes||m$e(t,e),y$e(t,t.dataTypes))}function p$e(t,e){if(e.length){if(!t.dataTypes.length){t.dataTypes=e;return}e.forEach(r=>{Nae(t.dataTypes,r)||f$(t,`type "${r}" not allowed by context "${t.dataTypes.join(",")}"`)}),b$e(t,e)}}function m$e(t,e){e.length>1&&!(e.length===2&&e.includes("null"))&&f$(t,"use allowUnionTypes to allow union type keyword")}function y$e(t,e){let r=t.self.RULES.all;for(let n in r){let i=r[n];if(typeof i=="object"&&(0,l$.shouldUseRule)(t.schema,i)){let{type:o}=i.definition;o.length&&!o.some(s=>g$e(e,s))&&f$(t,`missing type "${o.join(",")}" for keyword "${n}"`)}}}function g$e(t,e){return t.includes(e)||e==="number"&&t.includes("integer")}function Nae(t,e){return t.includes(e)||e==="integer"&&t.includes("number")}function b$e(t,e){let r=[];for(let n of t.dataTypes)Nae(e,n)?r.push(n):e.includes("integer")&&n==="number"&&r.push("integer");t.dataTypes=r}function f$(t,e){let r=t.schemaEnv.baseId+t.errSchemaPath;e+=` at "${r}" (strictTypes)`,(0,ch.checkStrictMode)(t,e,t.opts.strictTypes)}var TA=class{constructor(e,r,n){if((0,yE.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,ch.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",Uae(this.$data,e));else if(this.schemaCode=this.schemaValue,!(0,yE.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",Ot.default.errors))}result(e,r,n){this.failResult((0,lt.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,lt.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,lt._)`${r} !== undefined && (${(0,lt.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?mE.reportExtraError:mE.reportError)(this,this.def.error,r)}$dataError(){(0,mE.reportError)(this,this.def.$dataError||mE.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0,mE.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=lt.nil){this.gen.block(()=>{this.check$data(e,n),r()})}check$data(e=lt.nil,r=lt.nil){if(!this.$data)return;let{gen:n,schemaCode:i,schemaType:o,def:s}=this;n.if((0,lt.or)((0,lt._)`${i} === undefined`,r)),e!==lt.nil&&n.assign(e,!0),(o.length||s.validateSchema)&&(n.elseIf(this.invalid$data()),this.$dataError(),e!==lt.nil&&n.assign(e,!1)),n.else()}invalid$data(){let{gen:e,schemaCode:r,schemaType:n,def:i,it:o}=this;return(0,lt.or)(s(),a());function s(){if(n.length){if(!(r instanceof lt.Name))throw new Error("ajv implementation error");let d=Array.isArray(n)?n:[n];return(0,lt._)`${(0,PA.checkDataTypes)(d,r,o.opts.strictNumbers,PA.DataType.Wrong)}`}return lt.nil}function a(){if(i.validateSchema){let d=e.scopeValue("validate$data",{ref:i.validateSchema});return(0,lt._)`!${d}(${r})`}return lt.nil}}subschema(e,r){let n=(0,u$.getSubschema)(this.it,e);(0,u$.extendSubschemaData)(n,this.it,e),(0,u$.extendSubschemaMode)(n,e);let i={...this.it,...n,items:void 0,props:void 0};return o$e(i,r),i}mergeEvaluated(e,r){let{it:n,gen:i}=this;n.opts.unevaluated&&(n.props!==!0&&e.props!==void 0&&(n.props=ch.mergeEvaluated.props(i,e.props,n.props,r)),n.items!==!0&&e.items!==void 0&&(n.items=ch.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,lt.Name)),!0}};pm.KeywordCxt=TA;function jae(t,e,r,n){let i=new TA(t,r,e);"code"in r?r.code(i,n):i.$data&&r.validate?(0,yE.funcKeywordCode)(i,r):"macro"in r?(0,yE.macroKeywordCode)(i,r):(r.compile||r.validate)&&(0,yE.funcKeywordCode)(i,r)}var v$e=/^\/(?:[^~]|~0|~1)*$/,w$e=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function Uae(t,{dataLevel:e,dataNames:r,dataPathArr:n}){let i,o;if(t==="")return Ot.default.rootData;if(t[0]==="/"){if(!v$e.test(t))throw new Error(`Invalid JSON-pointer: ${t}`);i=t,o=Ot.default.rootData}else{let u=w$e.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,lt._)`${o}${(0,lt.getProperty)((0,ch.unescapeJsonPointer)(u))}`,s=(0,lt._)`${s} && ${o}`);return s;function d(u,c){return`Cannot access ${u} ${c} levels up, current level is ${e}`}}pm.getData=Uae});var IA=W(p$=>{"use strict";h();Object.defineProperty(p$,"__esModule",{value:!0});var h$=class extends Error{constructor(e){super("validation failed"),this.errors=e,this.ajv=this.validation=!0}};p$.default=h$});var kA=W(g$=>{"use strict";h();Object.defineProperty(g$,"__esModule",{value:!0});var m$=pE(),y$=class extends Error{constructor(e,r,n,i){super(i||`can't resolve reference ${n} from id ${r}`),this.missingRef=(0,m$.resolveUrl)(e,r,n),this.missingSchema=(0,m$.normalizeId)((0,m$.getFullPath)(e,this.missingRef))}};g$.default=y$});var bE=W(md=>{"use strict";h();Object.defineProperty(md,"__esModule",{value:!0});md.resolveSchema=md.getCompilingSchema=md.resolveRef=md.compileSchema=md.SchemaEnv=void 0;var gu=Qt(),_$e=IA(),eg=hd(),bu=pE(),Kae=Ir(),x$e=gE(),Uw=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,bu.normalizeId)(n?.[e.schemaId||"$id"]),this.schemaPath=e.schemaPath,this.localRefs=e.localRefs,this.meta=e.meta,this.$async=n?.$async,this.refs={}}};md.SchemaEnv=Uw;function v$(t){let e=qae.call(this,t);if(e)return e;let r=(0,bu.getFullPath)(this.opts.uriResolver,t.root.baseId),{es5:n,lines:i}=this.opts.code,{ownProperties:o}=this.opts,s=new gu.CodeGen(this.scope,{es5:n,lines:i,ownProperties:o}),a;t.$async&&(a=s.scopeValue("Error",{ref:_$e.default,code:(0,gu._)`require("ajv/dist/runtime/validation_error").default`}));let d=s.scopeName("validate");t.validateName=d;let u={gen:s,allErrors:this.opts.allErrors,data:eg.default.data,parentData:eg.default.parentData,parentDataProperty:eg.default.parentDataProperty,dataNames:[eg.default.data],dataPathArr:[gu.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:s.scopeValue("schema",this.opts.code.source===!0?{ref:t.schema,code:(0,gu.stringify)(t.schema)}:{ref:t.schema}),validateName:d,ValidationError:a,schema:t.schema,schemaEnv:t,rootId:r,baseId:t.baseId||r,schemaPath:gu.nil,errSchemaPath:t.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0,gu._)`""`,opts:this.opts,self:this},c;try{this._compilations.add(t),(0,x$e.validateFunctionCode)(u),s.optimize(this.opts.code.optimize);let l=s.toString();c=`${s.scopeRefs(eg.default.scope)}return ${l}`,this.opts.code.process&&(c=this.opts.code.process(c,t));let p=new Function(`${eg.default.self}`,`${eg.default.scope}`,c)(this,this.scope.get());if(this.scope.value(d,{ref:p}),p.errors=null,p.schema=t.schema,p.schemaEnv=t,t.$async&&(p.$async=!0),this.opts.code.source===!0&&(p.source={validateName:d,validateCode:l,scopeValues:s._values}),this.opts.unevaluated){let{props:g,items:b}=u;p.evaluated={props:g instanceof gu.Name?void 0:g,items:b instanceof gu.Name?void 0:b,dynamicProps:g instanceof gu.Name,dynamicItems:b instanceof gu.Name},p.source&&(p.source.evaluated=(0,gu.stringify)(p.evaluated))}return t.validate=p,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)}}md.compileSchema=v$;function E$e(t,e,r){var n;r=(0,bu.resolveUrl)(this.opts.uriResolver,e,r);let i=t.refs[r];if(i)return i;let o=P$e.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 Uw({schema:s,schemaId:a,root:t,baseId:e}))}if(o!==void 0)return t.refs[r]=S$e.call(this,o)}md.resolveRef=E$e;function S$e(t){return(0,bu.inlineRef)(t.schema,this.opts.inlineRefs)?t.schema:t.validate?t:v$.call(this,t)}function qae(t){for(let e of this._compilations)if(A$e(e,t))return e}md.getCompilingSchema=qae;function A$e(t,e){return t.schema===e.schema&&t.root===e.root&&t.baseId===e.baseId}function P$e(t,e){let r;for(;typeof(r=this.refs[e])=="string";)e=r;return r||this.schemas[e]||RA.call(this,t,e)}function RA(t,e){let r=this.opts.uriResolver.parse(e),n=(0,bu._getFullPath)(this.opts.uriResolver,r),i=(0,bu.getFullPath)(this.opts.uriResolver,t.baseId,void 0);if(Object.keys(t.schema).length>0&&n===i)return b$.call(this,r,t);let o=(0,bu.normalizeId)(n),s=this.refs[o]||this.schemas[o];if(typeof s=="string"){let a=RA.call(this,t,s);return typeof a?.schema!="object"?void 0:b$.call(this,r,a)}if(typeof s?.schema=="object"){if(s.validate||v$.call(this,s),o===(0,bu.normalizeId)(e)){let{schema:a}=s,{schemaId:d}=this.opts,u=a[d];return u&&(i=(0,bu.resolveUrl)(this.opts.uriResolver,i,u)),new Uw({schema:a,schemaId:d,root:t,baseId:i})}return b$.call(this,r,s)}}md.resolveSchema=RA;var T$e=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function b$(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,Kae.unescapeFragment)(a)];if(d===void 0)return;r=d;let u=typeof r=="object"&&r[this.opts.schemaId];!T$e.has(a)&&u&&(e=(0,bu.resolveUrl)(this.opts.uriResolver,e,u))}let o;if(typeof r!="boolean"&&r.$ref&&!(0,Kae.schemaHasRulesButRef)(r,this.RULES)){let a=(0,bu.resolveUrl)(this.opts.uriResolver,e,r.$ref);o=RA.call(this,n,a)}let{schemaId:s}=this.opts;if(o=o||new Uw({schema:r,schemaId:s,root:n,baseId:e}),o.schema!==o.root.schema)return o}});var Lae=W((rwt,I$e)=>{I$e.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 w$=W((DA,Fae)=>{h();(function(t,e){typeof DA=="object"&&typeof Fae<"u"?e(DA):typeof define=="function"&&define.amd?define(["exports"],e):e(t.URI=t.URI||{})})(DA,function(t){"use strict";function e(){for(var Q=arguments.length,Y=Array(Q),te=0;te1){Y[0]=Y[0].slice(0,-1);for(var re=Y.length-1,ie=1;ie= 0x80 (not a basic code point)","invalid-input":"Invalid input"},G=p-g,q=Math.floor,T=String.fromCharCode;function E(Q){throw new RangeError(U[Q])}function k(Q,Y){for(var te=[],re=Q.length;re--;)te[re]=Y(Q[re]);return te}function f(Q,Y){var te=Q.split("@"),re="";te.length>1&&(re=te[0]+"@",Q=te[1]),Q=Q.replace(F,".");var ie=Q.split("."),$e=k(ie,Y).join(".");return re+$e}function y(Q){for(var Y=[],te=0,re=Q.length;te=55296&&ie<=56319&&te>1,Y+=q(Y/te);Y>G*b>>1;ie+=p)Y=q(Y/G);return q(ie+(G+1)*Y/(Y+S))},D=function(Y){var te=[],re=Y.length,ie=0,$e=P,ke=I,Ne=Y.lastIndexOf($);Ne<0&&(Ne=0);for(var Ar=0;Ar=128&&E("not-basic"),te.push(Y.charCodeAt(Ar));for(var jt=Ne>0?Ne+1:0;jt=re&&E("invalid-input");var Wr=_(Y.charCodeAt(jt++));(Wr>=p||Wr>q((m-ie)/Jr))&&E("overflow"),ie+=Wr*Jr;var sr=an<=ke?g:an>=ke+b?b:an-ke;if(Wrq(m/Yr)&&E("overflow"),Jr*=Yr}var Rr=te.length+1;ke=v(ie-dt,Rr,dt==0),q(ie/Rr)>m-$e&&E("overflow"),$e+=q(ie/Rr),ie%=Rr,te.splice(ie++,0,$e)}return String.fromCodePoint.apply(String,te)},K=function(Y){var te=[];Y=y(Y);var re=Y.length,ie=P,$e=0,ke=I,Ne=!0,Ar=!1,jt=void 0;try{for(var dt=Y[Symbol.iterator](),Jr;!(Ne=(Jr=dt.next()).done);Ne=!0){var an=Jr.value;an<128&&te.push(T(an))}}catch(cy){Ar=!0,jt=cy}finally{try{!Ne&&dt.return&&dt.return()}finally{if(Ar)throw jt}}var Wr=te.length,sr=Wr;for(Wr&&te.push($);sr=ie&&biq((m-$e)/Bi)&&E("overflow"),$e+=(Yr-ie)*Bi,ie=Yr;var oo=!0,Ks=!1,Mo=void 0;try{for(var Ga=Y[Symbol.iterator](),Kh;!(oo=(Kh=Ga.next()).done);oo=!0){var qh=Kh.value;if(qhm&&E("overflow"),qh==ie){for(var Nu=$e,db=p;;db+=p){var Xl=db<=ke?g:db>=ke+b?b:db-ke;if(Nu>6|192).toString(16).toUpperCase()+"%"+(Y&63|128).toString(16).toUpperCase():te="%"+(Y>>12|224).toString(16).toUpperCase()+"%"+(Y>>6&63|128).toString(16).toUpperCase()+"%"+(Y&63|128).toString(16).toUpperCase(),te}function H(Q){for(var Y="",te=0,re=Q.length;te=194&&ie<224){if(re-te>=6){var $e=parseInt(Q.substr(te+4,2),16);Y+=String.fromCharCode((ie&31)<<6|$e&63)}else Y+=Q.substr(te,6);te+=6}else if(ie>=224){if(re-te>=9){var ke=parseInt(Q.substr(te+4,2),16),Ne=parseInt(Q.substr(te+7,2),16);Y+=String.fromCharCode((ie&15)<<12|(ke&63)<<6|Ne&63)}else Y+=Q.substr(te,9);te+=9}else Y+=Q.substr(te,3),te+=3}return Y}function X(Q,Y){function te(re){var ie=H(re);return ie.match(Y.UNRESERVED)?ie:re}return Q.scheme&&(Q.scheme=String(Q.scheme).replace(Y.PCT_ENCODED,te).toLowerCase().replace(Y.NOT_SCHEME,"")),Q.userinfo!==void 0&&(Q.userinfo=String(Q.userinfo).replace(Y.PCT_ENCODED,te).replace(Y.NOT_USERINFO,V).replace(Y.PCT_ENCODED,i)),Q.host!==void 0&&(Q.host=String(Q.host).replace(Y.PCT_ENCODED,te).toLowerCase().replace(Y.NOT_HOST,V).replace(Y.PCT_ENCODED,i)),Q.path!==void 0&&(Q.path=String(Q.path).replace(Y.PCT_ENCODED,te).replace(Q.scheme?Y.NOT_PATH:Y.NOT_PATH_NOSCHEME,V).replace(Y.PCT_ENCODED,i)),Q.query!==void 0&&(Q.query=String(Q.query).replace(Y.PCT_ENCODED,te).replace(Y.NOT_QUERY,V).replace(Y.PCT_ENCODED,i)),Q.fragment!==void 0&&(Q.fragment=String(Q.fragment).replace(Y.PCT_ENCODED,te).replace(Y.NOT_FRAGMENT,V).replace(Y.PCT_ENCODED,i)),Q}function ee(Q){return Q.replace(/^0*(.*)/,"$1")||"0"}function ue(Q,Y){var te=Q.match(Y.IPV4ADDRESS)||[],re=c(te,2),ie=re[1];return ie?ie.split(".").map(ee).join("."):Q}function ae(Q,Y){var te=Q.match(Y.IPV6ADDRESS)||[],re=c(te,3),ie=re[1],$e=re[2];if(ie){for(var ke=ie.toLowerCase().split("::").reverse(),Ne=c(ke,2),Ar=Ne[0],jt=Ne[1],dt=jt?jt.split(":").map(ee):[],Jr=Ar.split(":").map(ee),an=Y.IPV4ADDRESS.test(Jr[Jr.length-1]),Wr=an?7:8,sr=Jr.length-Wr,Yr=Array(Wr),Rr=0;Rr1){var Cr=Yr.slice(0,gi.index),bi=Yr.slice(gi.index+gi.length);Mi=Cr.join(":")+"::"+bi.join(":")}else Mi=Yr.join(":");return $e&&(Mi+="%"+$e),Mi}else return Q}var ce=/^(?:([^:\/?#]+):)?(?:\/\/((?:([^\/?#@]*)@)?(\[[^\/?#\]]+\]|[^\/?#:]*)(?:\:(\d*))?))?([^?#]*)(?:\?([^#]*))?(?:#((?:.|\n|\r)*))?/i,pe="".match(/(){0}/)[1]===void 0;function Ee(Q){var Y=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},te={},re=Y.iri!==!1?u:d;Y.reference==="suffix"&&(Q=(Y.scheme?Y.scheme+":":"")+"//"+Q);var ie=Q.match(ce);if(ie){pe?(te.scheme=ie[1],te.userinfo=ie[3],te.host=ie[4],te.port=parseInt(ie[5],10),te.path=ie[6]||"",te.query=ie[7],te.fragment=ie[8],isNaN(te.port)&&(te.port=ie[5])):(te.scheme=ie[1]||void 0,te.userinfo=Q.indexOf("@")!==-1?ie[3]:void 0,te.host=Q.indexOf("//")!==-1?ie[4]:void 0,te.port=parseInt(ie[5],10),te.path=ie[6]||"",te.query=Q.indexOf("?")!==-1?ie[7]:void 0,te.fragment=Q.indexOf("#")!==-1?ie[8]:void 0,isNaN(te.port)&&(te.port=Q.match(/\/\/(?:.|\n)*\:(?:\/|\?|\#|$)/)?ie[4]:void 0)),te.host&&(te.host=ae(ue(te.host,re),re)),te.scheme===void 0&&te.userinfo===void 0&&te.host===void 0&&te.port===void 0&&!te.path&&te.query===void 0?te.reference="same-document":te.scheme===void 0?te.reference="relative":te.fragment===void 0?te.reference="absolute":te.reference="uri",Y.reference&&Y.reference!=="suffix"&&Y.reference!==te.reference&&(te.error=te.error||"URI is not a "+Y.reference+" reference.");var $e=Z[(Y.scheme||te.scheme||"").toLowerCase()];if(!Y.unicodeSupport&&(!$e||!$e.unicodeSupport)){if(te.host&&(Y.domainHost||$e&&$e.domainHost))try{te.host=J.toASCII(te.host.replace(re.PCT_ENCODED,H).toLowerCase())}catch(ke){te.error=te.error||"Host's domain name can not be converted to ASCII via punycode: "+ke}X(te,d)}else X(te,re);$e&&$e.parse&&$e.parse(te,Y)}else te.error=te.error||"URI can not be parsed.";return te}function Ue(Q,Y){var te=Y.iri!==!1?u:d,re=[];return Q.userinfo!==void 0&&(re.push(Q.userinfo),re.push("@")),Q.host!==void 0&&re.push(ae(ue(String(Q.host),te),te).replace(te.IPV6ADDRESS,function(ie,$e,ke){return"["+$e+(ke?"%25"+ke:"")+"]"})),(typeof Q.port=="number"||typeof Q.port=="string")&&(re.push(":"),re.push(String(Q.port))),re.length?re.join(""):void 0}var le=/^\.\.?\//,ge=/^\/\.(\/|$)/,ve=/^\/\.\.(\/|$)/,Ce=/^\/?(?:.|\n)*?(?=\/|$)/;function Ie(Q){for(var Y=[];Q.length;)if(Q.match(le))Q=Q.replace(le,"");else if(Q.match(ge))Q=Q.replace(ge,"/");else if(Q.match(ve))Q=Q.replace(ve,"/"),Y.pop();else if(Q==="."||Q==="..")Q="";else{var te=Q.match(Ce);if(te){var re=te[0];Q=Q.slice(re.length),Y.push(re)}else throw new Error("Unexpected dot segment condition")}return Y.join("")}function je(Q){var Y=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},te=Y.iri?u:d,re=[],ie=Z[(Y.scheme||Q.scheme||"").toLowerCase()];if(ie&&ie.serialize&&ie.serialize(Q,Y),Q.host&&!te.IPV6ADDRESS.test(Q.host)){if(Y.domainHost||ie&&ie.domainHost)try{Q.host=Y.iri?J.toUnicode(Q.host):J.toASCII(Q.host.replace(te.PCT_ENCODED,H).toLowerCase())}catch(Ne){Q.error=Q.error||"Host's domain name can not be converted to "+(Y.iri?"Unicode":"ASCII")+" via punycode: "+Ne}}X(Q,te),Y.reference!=="suffix"&&Q.scheme&&(re.push(Q.scheme),re.push(":"));var $e=Ue(Q,Y);if($e!==void 0&&(Y.reference!=="suffix"&&re.push("//"),re.push($e),Q.path&&Q.path.charAt(0)!=="/"&&re.push("/")),Q.path!==void 0){var ke=Q.path;!Y.absolutePath&&(!ie||!ie.absolutePath)&&(ke=Ie(ke)),$e===void 0&&(ke=ke.replace(/^\/\//,"/%2F")),re.push(ke)}return Q.query!==void 0&&(re.push("?"),re.push(Q.query)),Q.fragment!==void 0&&(re.push("#"),re.push(Q.fragment)),re.join("")}function gt(Q,Y){var te=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},re=arguments[3],ie={};return re||(Q=Ee(je(Q,te),te),Y=Ee(je(Y,te),te)),te=te||{},!te.tolerant&&Y.scheme?(ie.scheme=Y.scheme,ie.userinfo=Y.userinfo,ie.host=Y.host,ie.port=Y.port,ie.path=Ie(Y.path||""),ie.query=Y.query):(Y.userinfo!==void 0||Y.host!==void 0||Y.port!==void 0?(ie.userinfo=Y.userinfo,ie.host=Y.host,ie.port=Y.port,ie.path=Ie(Y.path||""),ie.query=Y.query):(Y.path?(Y.path.charAt(0)==="/"?ie.path=Ie(Y.path):((Q.userinfo!==void 0||Q.host!==void 0||Q.port!==void 0)&&!Q.path?ie.path="/"+Y.path:Q.path?ie.path=Q.path.slice(0,Q.path.lastIndexOf("/")+1)+Y.path:ie.path=Y.path,ie.path=Ie(ie.path)),ie.query=Y.query):(ie.path=Q.path,Y.query!==void 0?ie.query=Y.query:ie.query=Q.query),ie.userinfo=Q.userinfo,ie.host=Q.host,ie.port=Q.port),ie.scheme=Q.scheme),ie.fragment=Y.fragment,ie}function Pe(Q,Y,te){var re=s({scheme:"null"},te);return je(gt(Ee(Q,re),Ee(Y,re),re,!0),re)}function De(Q,Y){return typeof Q=="string"?Q=je(Ee(Q,Y),Y):n(Q)==="object"&&(Q=Ee(je(Q,Y),Y)),Q}function It(Q,Y,te){return typeof Q=="string"?Q=je(Ee(Q,te),te):n(Q)==="object"&&(Q=je(Q,te)),typeof Y=="string"?Y=je(Ee(Y,te),te):n(Y)==="object"&&(Y=je(Y,te)),Q===Y}function we(Q,Y){return Q&&Q.toString().replace(!Y||!Y.iri?d.ESCAPE:u.ESCAPE,V)}function Se(Q,Y){return Q&&Q.toString().replace(!Y||!Y.iri?d.PCT_ENCODED:u.PCT_ENCODED,H)}var Lr={scheme:"http",domainHost:!0,parse:function(Y,te){return Y.host||(Y.error=Y.error||"HTTP URIs must have a host."),Y},serialize:function(Y,te){var re=String(Y.scheme).toLowerCase()==="https";return(Y.port===(re?443:80)||Y.port==="")&&(Y.port=void 0),Y.path||(Y.path="/"),Y}},Fe={scheme:"https",domainHost:Lr.domainHost,parse:Lr.parse,serialize:Lr.serialize};function He(Q){return typeof Q.secure=="boolean"?Q.secure:String(Q.scheme).toLowerCase()==="wss"}var js={scheme:"ws",domainHost:!0,parse:function(Y,te){var re=Y;return re.secure=He(re),re.resourceName=(re.path||"/")+(re.query?"?"+re.query:""),re.path=void 0,re.query=void 0,re},serialize:function(Y,te){if((Y.port===(He(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 re=Y.resourceName.split("?"),ie=c(re,2),$e=ie[0],ke=ie[1];Y.path=$e&&$e!=="/"?$e:void 0,Y.query=ke,Y.resourceName=void 0}return Y.fragment=void 0,Y}},ft={scheme:"wss",domainHost:js.domainHost,parse:js.parse,serialize:js.serialize},Rt={},yi=!0,At="[A-Za-z0-9\\-\\.\\_\\~"+(yi?"\\xA0-\\u200D\\u2010-\\u2029\\u202F-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF":"")+"]",Ze="[0-9A-Fa-f]",Cc=r(r("%[EFef]"+Ze+"%"+Ze+Ze+"%"+Ze+Ze)+"|"+r("%[89A-Fa-f]"+Ze+"%"+Ze+Ze)+"|"+r("%"+Ze+Ze)),Pt="[A-Za-z0-9\\!\\$\\%\\'\\*\\+\\-\\^\\_\\`\\{\\|\\}\\~]",$t="[\\!\\$\\%\\'\\(\\)\\*\\+\\,\\-\\.0-9\\<\\>A-Z\\x5E-\\x7E]",oy=e($t,'[\\"\\\\]'),Bt="[\\!\\$\\'\\(\\)\\*\\+\\,\\;\\:\\@]",Wt=new RegExp(At,"g"),Oc=new RegExp(Cc,"g"),Ht=new RegExp(e("[^]",Pt,"[\\.]",'[\\"]',oy),"g"),Lt=new RegExp(e("[^]",At,Bt),"g"),sy=Lt;function Nt(Q){var Y=H(Q);return Y.match(Wt)?Y:Q}var Ft={scheme:"mailto",parse:function(Y,te){var re=Y,ie=re.to=re.path?re.path.split(","):[];if(re.path=void 0,re.query){for(var $e=!1,ke={},Ne=re.query.split("&"),Ar=0,jt=Ne.length;Ar{"use strict";h();Object.defineProperty(_$,"__esModule",{value:!0});var zae=w$();zae.code='require("ajv/dist/runtime/uri").default';_$.default=zae});var Qae=W(ts=>{"use strict";h();Object.defineProperty(ts,"__esModule",{value:!0});ts.CodeGen=ts.Name=ts.nil=ts.stringify=ts.str=ts._=ts.KeywordCxt=void 0;var k$e=gE();Object.defineProperty(ts,"KeywordCxt",{enumerable:!0,get:function(){return k$e.KeywordCxt}});var Kw=Qt();Object.defineProperty(ts,"_",{enumerable:!0,get:function(){return Kw._}});Object.defineProperty(ts,"str",{enumerable:!0,get:function(){return Kw.str}});Object.defineProperty(ts,"stringify",{enumerable:!0,get:function(){return Kw.stringify}});Object.defineProperty(ts,"nil",{enumerable:!0,get:function(){return Kw.nil}});Object.defineProperty(ts,"Name",{enumerable:!0,get:function(){return Kw.Name}});Object.defineProperty(ts,"CodeGen",{enumerable:!0,get:function(){return Kw.CodeGen}});var R$e=IA(),Yae=kA(),D$e=e$(),vE=bE(),M$e=Qt(),wE=pE(),MA=hE(),E$=Ir(),Wae=Lae(),B$e=Gae(),Zae=(t,e)=>new RegExp(t,e);Zae.code="new RegExp";var C$e=["removeAdditional","useDefaults","coerceTypes"],O$e=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),$$e={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."},N$e={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},Hae=200;function j$e(t){var e,r,n,i,o,s,a,d,u,c,l,m,p,g,b,S,A,I,P,$,N,L,F,U,G;let q=t.strict,T=(e=t.code)===null||e===void 0?void 0:e.optimize,E=T===!0||T===void 0?1:T||0,k=(n=(r=t.code)===null||r===void 0?void 0:r.regExp)!==null&&n!==void 0?n:Zae,f=(i=t.uriResolver)!==null&&i!==void 0?i:B$e.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:(m=(l=t.strictTuples)!==null&&l!==void 0?l:q)!==null&&m!==void 0?m:"log",strictRequired:(g=(p=t.strictRequired)!==null&&p!==void 0?p:q)!==null&&g!==void 0?g:!1,code:t.code?{...t.code,optimize:E,regExp:k}:{optimize:E,regExp:k},loopRequired:(b=t.loopRequired)!==null&&b!==void 0?b:Hae,loopEnum:(S=t.loopEnum)!==null&&S!==void 0?S:Hae,meta:(A=t.meta)!==null&&A!==void 0?A:!0,messages:(I=t.messages)!==null&&I!==void 0?I:!0,inlineRefs:(P=t.inlineRefs)!==null&&P!==void 0?P:!0,schemaId:($=t.schemaId)!==null&&$!==void 0?$:"$id",addUsedSchema:(N=t.addUsedSchema)!==null&&N!==void 0?N:!0,validateSchema:(L=t.validateSchema)!==null&&L!==void 0?L:!0,validateFormats:(F=t.validateFormats)!==null&&F!==void 0?F:!0,unicodeRegExp:(U=t.unicodeRegExp)!==null&&U!==void 0?U:!0,int32range:(G=t.int32range)!==null&&G!==void 0?G:!0,uriResolver:f}}var _E=class{constructor(e={}){this.schemas={},this.refs={},this.formats={},this._compilations=new Set,this._loading={},this._cache=new Map,e=this.opts={...e,...j$e(e)};let{es5:r,lines:n}=this.opts.code;this.scope=new M$e.ValueScope({scope:{},prefixes:O$e,es5:r,lines:n}),this.logger=z$e(e.logger);let i=e.validateFormats;e.validateFormats=!1,this.RULES=(0,D$e.getRules)(),Vae.call(this,$$e,e,"NOT SUPPORTED"),Vae.call(this,N$e,e,"DEPRECATED","warn"),this._metaOpts=L$e.call(this),e.formats&&K$e.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),e.keywords&&q$e.call(this,e.keywords),typeof e.meta=="object"&&this.addMetaSchema(e.meta),U$e.call(this),e.validateFormats=i}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){let{$data:e,meta:r,schemaId:n}=this.opts,i=Wae;n==="id"&&(i={...Wae},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 m=this._addSchema(c,l);return m.validate||s.call(this,m)}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 Yae.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,wE.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=Jae.call(this,e))=="string";)e=r;if(r===void 0){let{schemaId:n}=this.opts,i=new vE.SchemaEnv({schema:{},schemaId:n});if(r=vE.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=Jae.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,wE.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(W$e.call(this,n,r),!r)return(0,E$.eachItem)(n,o=>x$.call(this,o)),this;V$e.call(this,r);let i={...r,type:(0,MA.getJSONTypes)(r.type),schemaType:(0,MA.getJSONTypes)(r.schemaType)};return(0,E$.eachItem)(n,i.type.length===0?o=>x$.call(this,o,i):o=>i.type.forEach(s=>x$.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]=Xae(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,wE.normalizeId)(s||n);let u=wE.getSchemaRefs.call(this,e,n);return d=new vE.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):vE.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{vE.compileSchema.call(this,e)}finally{this.opts=r}}};ts.default=_E;_E.ValidationError=R$e.default;_E.MissingRefError=Yae.default;function Vae(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 Jae(t){return t=(0,wE.normalizeId)(t),this.schemas[t]||this.refs[t]}function U$e(){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 K$e(){for(let t in this.opts.formats){let e=this.opts.formats[t];e&&this.addFormat(t,e)}}function q$e(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 L$e(){let t={...this.opts};for(let e of C$e)delete t[e];return t}var F$e={log(){},warn(){},error(){}};function z$e(t){if(t===!1)return F$e;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 G$e=/^[a-z_$][a-z0-9_$:-]*$/i;function W$e(t,e){let{RULES:r}=this;if((0,E$.eachItem)(t,n=>{if(r.keywords[n])throw new Error(`Keyword ${n} is already defined`);if(!G$e.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 x$(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,MA.getJSONTypes)(e.type),schemaType:(0,MA.getJSONTypes)(e.schemaType)}};e.before?H$e.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 H$e(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 V$e(t){let{metaSchema:e}=t;e!==void 0&&(t.$data&&this.opts.$data&&(e=Xae(e)),t.validateSchema=this.compile(e,!0))}var J$e={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function Xae(t){return{anyOf:[t,J$e]}}});var ece=W(S$=>{"use strict";h();Object.defineProperty(S$,"__esModule",{value:!0});var Y$e={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};S$.default=Y$e});var OA=W(tg=>{"use strict";h();Object.defineProperty(tg,"__esModule",{value:!0});tg.callRef=tg.getValidate=void 0;var Z$e=kA(),tce=pd(),Ba=Qt(),qw=hd(),rce=bE(),BA=Ir(),X$e={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=rce.resolveRef.call(d,u,i,r);if(c===void 0)throw new Z$e.default(n.opts.uriResolver,i,r);if(c instanceof rce.SchemaEnv)return m(c);return p(c);function l(){if(o===u)return CA(t,s,o,o.$async);let g=e.scopeValue("root",{ref:u});return CA(t,(0,Ba._)`${g}.validate`,u,u.$async)}function m(g){let b=nce(t,g);CA(t,b,g,g.$async)}function p(g){let b=e.scopeValue("schema",a.code.source===!0?{ref:g,code:(0,Ba.stringify)(g)}:{ref:g}),S=e.name("valid"),A=t.subschema({schema:g,dataTypes:[],schemaPath:Ba.nil,topSchemaRef:b,errSchemaPath:r},S);t.mergeEvaluated(A),t.ok(S)}}};function nce(t,e){let{gen:r}=t;return e.validate?r.scopeValue("validate",{ref:e.validate}):(0,Ba._)`${r.scopeValue("wrapper",{ref:e})}.validate`}tg.getValidate=nce;function CA(t,e,r,n){let{gen:i,it:o}=t,{allErrors:s,schemaEnv:a,opts:d}=o,u=d.passContext?qw.default.this:Ba.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,Ba._)`await ${(0,tce.callValidateCode)(t,e,u)}`),p(e),s||i.assign(g,!0)},b=>{i.if((0,Ba._)`!(${b} instanceof ${o.ValidationError})`,()=>i.throw(b)),m(b),s||i.assign(g,!1)}),t.ok(g)}function l(){t.result((0,tce.callValidateCode)(t,e,u),()=>p(e),()=>m(e))}function m(g){let b=(0,Ba._)`${g}.errors`;i.assign(qw.default.vErrors,(0,Ba._)`${qw.default.vErrors} === null ? ${b} : ${qw.default.vErrors}.concat(${b})`),i.assign(qw.default.errors,(0,Ba._)`${qw.default.vErrors}.length`)}function p(g){var b;if(!o.opts.unevaluated)return;let S=(b=r?.validate)===null||b===void 0?void 0:b.evaluated;if(o.props!==!0)if(S&&!S.dynamicProps)S.props!==void 0&&(o.props=BA.mergeEvaluated.props(i,S.props,o.props));else{let A=i.var("props",(0,Ba._)`${g}.evaluated.props`);o.props=BA.mergeEvaluated.props(i,A,o.props,Ba.Name)}if(o.items!==!0)if(S&&!S.dynamicItems)S.items!==void 0&&(o.items=BA.mergeEvaluated.items(i,S.items,o.items));else{let A=i.var("items",(0,Ba._)`${g}.evaluated.items`);o.items=BA.mergeEvaluated.items(i,A,o.items,Ba.Name)}}}tg.callRef=CA;tg.default=X$e});var ice=W(A$=>{"use strict";h();Object.defineProperty(A$,"__esModule",{value:!0});var Q$e=ece(),eNe=OA(),tNe=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",Q$e.default,eNe.default];A$.default=tNe});var oce=W(P$=>{"use strict";h();Object.defineProperty(P$,"__esModule",{value:!0});var $A=Qt(),mm=$A.operators,NA={maximum:{okStr:"<=",ok:mm.LTE,fail:mm.GT},minimum:{okStr:">=",ok:mm.GTE,fail:mm.LT},exclusiveMaximum:{okStr:"<",ok:mm.LT,fail:mm.GTE},exclusiveMinimum:{okStr:">",ok:mm.GT,fail:mm.LTE}},rNe={message:({keyword:t,schemaCode:e})=>(0,$A.str)`must be ${NA[t].okStr} ${e}`,params:({keyword:t,schemaCode:e})=>(0,$A._)`{comparison: ${NA[t].okStr}, limit: ${e}}`},nNe={keyword:Object.keys(NA),type:"number",schemaType:"number",$data:!0,error:rNe,code(t){let{keyword:e,data:r,schemaCode:n}=t;t.fail$data((0,$A._)`${r} ${NA[e].fail} ${n} || isNaN(${r})`)}};P$.default=nNe});var sce=W(T$=>{"use strict";h();Object.defineProperty(T$,"__esModule",{value:!0});var xE=Qt(),iNe={message:({schemaCode:t})=>(0,xE.str)`must be multiple of ${t}`,params:({schemaCode:t})=>(0,xE._)`{multipleOf: ${t}}`},oNe={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:iNe,code(t){let{gen:e,data:r,schemaCode:n,it:i}=t,o=i.opts.multipleOfPrecision,s=e.let("res"),a=o?(0,xE._)`Math.abs(Math.round(${s}) - ${s}) > 1e-${o}`:(0,xE._)`${s} !== parseInt(${s})`;t.fail$data((0,xE._)`(${n} === 0 || (${s} = ${r}/${n}, ${a}))`)}};T$.default=oNe});var cce=W(I$=>{"use strict";h();Object.defineProperty(I$,"__esModule",{value:!0});function ace(t){let e=t.length,r=0,n=0,i;for(;n=55296&&i<=56319&&n{"use strict";h();Object.defineProperty(k$,"__esModule",{value:!0});var rg=Qt(),sNe=Ir(),aNe=cce(),cNe={message({keyword:t,schemaCode:e}){let r=t==="maxLength"?"more":"fewer";return(0,rg.str)`must NOT have ${r} than ${e} characters`},params:({schemaCode:t})=>(0,rg._)`{limit: ${t}}`},dNe={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:cNe,code(t){let{keyword:e,data:r,schemaCode:n,it:i}=t,o=e==="maxLength"?rg.operators.GT:rg.operators.LT,s=i.opts.unicode===!1?(0,rg._)`${r}.length`:(0,rg._)`${(0,sNe.useFunc)(t.gen,aNe.default)}(${r})`;t.fail$data((0,rg._)`${s} ${o} ${n}`)}};k$.default=dNe});var uce=W(R$=>{"use strict";h();Object.defineProperty(R$,"__esModule",{value:!0});var uNe=pd(),jA=Qt(),lNe={message:({schemaCode:t})=>(0,jA.str)`must match pattern "${t}"`,params:({schemaCode:t})=>(0,jA._)`{pattern: ${t}}`},fNe={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:lNe,code(t){let{data:e,$data:r,schema:n,schemaCode:i,it:o}=t,s=o.opts.unicodeRegExp?"u":"",a=r?(0,jA._)`(new RegExp(${i}, ${s}))`:(0,uNe.usePattern)(t,n);t.fail$data((0,jA._)`!${a}.test(${e})`)}};R$.default=fNe});var lce=W(D$=>{"use strict";h();Object.defineProperty(D$,"__esModule",{value:!0});var EE=Qt(),hNe={message({keyword:t,schemaCode:e}){let r=t==="maxProperties"?"more":"fewer";return(0,EE.str)`must NOT have ${r} than ${e} properties`},params:({schemaCode:t})=>(0,EE._)`{limit: ${t}}`},pNe={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:hNe,code(t){let{keyword:e,data:r,schemaCode:n}=t,i=e==="maxProperties"?EE.operators.GT:EE.operators.LT;t.fail$data((0,EE._)`Object.keys(${r}).length ${i} ${n}`)}};D$.default=pNe});var fce=W(M$=>{"use strict";h();Object.defineProperty(M$,"__esModule",{value:!0});var SE=pd(),AE=Qt(),mNe=Ir(),yNe={message:({params:{missingProperty:t}})=>(0,AE.str)`must have required property '${t}'`,params:({params:{missingProperty:t}})=>(0,AE._)`{missingProperty: ${t}}`},gNe={keyword:"required",type:"object",schemaType:"array",$data:!0,error:yNe,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 p=t.parentSchema.properties,{definedProperties:g}=t.it;for(let b of r)if(p?.[b]===void 0&&!g.has(b)){let S=s.schemaEnv.baseId+s.errSchemaPath,A=`required property "${b}" is not defined at "${S}" (strictRequired)`;(0,mNe.checkStrictMode)(s,A,s.opts.strictRequired)}}function u(){if(d||o)t.block$data(AE.nil,l);else for(let p of r)(0,SE.checkReportMissingProp)(t,p)}function c(){let p=e.let("missing");if(d||o){let g=e.let("valid",!0);t.block$data(g,()=>m(p,g)),t.ok(g)}else e.if((0,SE.checkMissingProp)(t,r,p)),(0,SE.reportMissingProp)(t,p),e.else()}function l(){e.forOf("prop",n,p=>{t.setParams({missingProperty:p}),e.if((0,SE.noPropertyInData)(e,i,p,a.ownProperties),()=>t.error())})}function m(p,g){t.setParams({missingProperty:p}),e.forOf(p,n,()=>{e.assign(g,(0,SE.propertyInData)(e,i,p,a.ownProperties)),e.if((0,AE.not)(g),()=>{t.error(),e.break()})},AE.nil)}}};M$.default=gNe});var hce=W(B$=>{"use strict";h();Object.defineProperty(B$,"__esModule",{value:!0});var PE=Qt(),bNe={message({keyword:t,schemaCode:e}){let r=t==="maxItems"?"more":"fewer";return(0,PE.str)`must NOT have ${r} than ${e} items`},params:({schemaCode:t})=>(0,PE._)`{limit: ${t}}`},vNe={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:bNe,code(t){let{keyword:e,data:r,schemaCode:n}=t,i=e==="maxItems"?PE.operators.GT:PE.operators.LT;t.fail$data((0,PE._)`${r}.length ${i} ${n}`)}};B$.default=vNe});var UA=W(C$=>{"use strict";h();Object.defineProperty(C$,"__esModule",{value:!0});var pce=c$();pce.code='require("ajv/dist/runtime/equal").default';C$.default=pce});var mce=W($$=>{"use strict";h();Object.defineProperty($$,"__esModule",{value:!0});var O$=hE(),rs=Qt(),wNe=Ir(),_Ne=UA(),xNe={message:({params:{i:t,j:e}})=>(0,rs.str)`must NOT have duplicate items (items ## ${e} and ${t} are identical)`,params:({params:{i:t,j:e}})=>(0,rs._)`{i: ${t}, j: ${e}}`},ENe={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:xNe,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,O$.getSchemaTypes)(o.items):[];t.block$data(d,c,(0,rs._)`${s} === false`),t.ok(d);function c(){let g=e.let("i",(0,rs._)`${r}.length`),b=e.let("j");t.setParams({i:g,j:b}),e.assign(d,!0),e.if((0,rs._)`${g} > 1`,()=>(l()?m:p)(g,b))}function l(){return u.length>0&&!u.some(g=>g==="object"||g==="array")}function m(g,b){let S=e.name("item"),A=(0,O$.checkDataTypes)(u,S,a.opts.strictNumbers,O$.DataType.Wrong),I=e.const("indices",(0,rs._)`{}`);e.for((0,rs._)`;${g}--;`,()=>{e.let(S,(0,rs._)`${r}[${g}]`),e.if(A,(0,rs._)`continue`),u.length>1&&e.if((0,rs._)`typeof ${S} == "string"`,(0,rs._)`${S} += "_"`),e.if((0,rs._)`typeof ${I}[${S}] == "number"`,()=>{e.assign(b,(0,rs._)`${I}[${S}]`),t.error(),e.assign(d,!1).break()}).code((0,rs._)`${I}[${S}] = ${g}`)})}function p(g,b){let S=(0,wNe.useFunc)(e,_Ne.default),A=e.name("outer");e.label(A).for((0,rs._)`;${g}--;`,()=>e.for((0,rs._)`${b} = ${g}; ${b}--;`,()=>e.if((0,rs._)`${S}(${r}[${g}], ${r}[${b}])`,()=>{t.error(),e.assign(d,!1).break(A)})))}}};$$.default=ENe});var yce=W(j$=>{"use strict";h();Object.defineProperty(j$,"__esModule",{value:!0});var N$=Qt(),SNe=Ir(),ANe=UA(),PNe={message:"must be equal to constant",params:({schemaCode:t})=>(0,N$._)`{allowedValue: ${t}}`},TNe={keyword:"const",$data:!0,error:PNe,code(t){let{gen:e,data:r,$data:n,schemaCode:i,schema:o}=t;n||o&&typeof o=="object"?t.fail$data((0,N$._)`!${(0,SNe.useFunc)(e,ANe.default)}(${r}, ${i})`):t.fail((0,N$._)`${o} !== ${r}`)}};j$.default=TNe});var gce=W(U$=>{"use strict";h();Object.defineProperty(U$,"__esModule",{value:!0});var TE=Qt(),INe=Ir(),kNe=UA(),RNe={message:"must be equal to one of the allowed values",params:({schemaCode:t})=>(0,TE._)`{allowedValues: ${t}}`},DNe={keyword:"enum",schemaType:"array",$data:!0,error:RNe,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,INe.useFunc)(e,kNe.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 p=e.const("vSchema",o);c=(0,TE.or)(...i.map((g,b)=>m(p,b)))}t.pass(c);function l(){e.assign(c,!1),e.forOf("v",o,p=>e.if((0,TE._)`${u()}(${r}, ${p})`,()=>e.assign(c,!0).break()))}function m(p,g){let b=i[g];return typeof b=="object"&&b!==null?(0,TE._)`${u()}(${r}, ${p}[${g}])`:(0,TE._)`${r} === ${b}`}}};U$.default=DNe});var bce=W(K$=>{"use strict";h();Object.defineProperty(K$,"__esModule",{value:!0});var MNe=oce(),BNe=sce(),CNe=dce(),ONe=uce(),$Ne=lce(),NNe=fce(),jNe=hce(),UNe=mce(),KNe=yce(),qNe=gce(),LNe=[MNe.default,BNe.default,CNe.default,ONe.default,$Ne.default,NNe.default,jNe.default,UNe.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},KNe.default,qNe.default];K$.default=LNe});var L$=W(IE=>{"use strict";h();Object.defineProperty(IE,"__esModule",{value:!0});IE.validateAdditionalItems=void 0;var ng=Qt(),q$=Ir(),FNe={message:({params:{len:t}})=>(0,ng.str)`must NOT have more than ${t} items`,params:({params:{len:t}})=>(0,ng._)`{limit: ${t}}`},zNe={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:FNe,code(t){let{parentSchema:e,it:r}=t,{items:n}=e;if(!Array.isArray(n)){(0,q$.checkStrictMode)(r,'"additionalItems" is ignored when "items" is not an array of schemas');return}vce(t,n)}};function vce(t,e){let{gen:r,schema:n,data:i,keyword:o,it:s}=t;s.items=!0;let a=r.const("len",(0,ng._)`${i}.length`);if(n===!1)t.setParams({len:e.length}),t.pass((0,ng._)`${a} <= ${e.length}`);else if(typeof n=="object"&&!(0,q$.alwaysValidSchema)(s,n)){let u=r.var("valid",(0,ng._)`${a} <= ${e.length}`);r.if((0,ng.not)(u),()=>d(u)),t.ok(u)}function d(u){r.forRange("i",e.length,a,c=>{t.subschema({keyword:o,dataProp:c,dataPropType:q$.Type.Num},u),s.allErrors||r.if((0,ng.not)(u),()=>r.break())})}}IE.validateAdditionalItems=vce;IE.default=zNe});var F$=W(kE=>{"use strict";h();Object.defineProperty(kE,"__esModule",{value:!0});kE.validateTuple=void 0;var wce=Qt(),KA=Ir(),GNe=pd(),WNe={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(t){let{schema:e,it:r}=t;if(Array.isArray(e))return _ce(t,"additionalItems",e);r.items=!0,!(0,KA.alwaysValidSchema)(r,e)&&t.ok((0,GNe.validateArray)(t))}};function _ce(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=KA.mergeEvaluated.items(n,r.length,a.items));let d=n.name("valid"),u=n.const("len",(0,wce._)`${o}.length`);r.forEach((l,m)=>{(0,KA.alwaysValidSchema)(a,l)||(n.if((0,wce._)`${u} > ${m}`,()=>t.subschema({keyword:s,schemaProp:m,dataProp:m},d)),t.ok(d))});function c(l){let{opts:m,errSchemaPath:p}=a,g=r.length,b=g===l.minItems&&(g===l.maxItems||l[e]===!1);if(m.strictTuples&&!b){let S=`"${s}" is ${g}-tuple, but minItems or maxItems/${e} are not specified or different at path "${p}"`;(0,KA.checkStrictMode)(a,S,m.strictTuples)}}}kE.validateTuple=_ce;kE.default=WNe});var xce=W(z$=>{"use strict";h();Object.defineProperty(z$,"__esModule",{value:!0});var HNe=F$(),VNe={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:t=>(0,HNe.validateTuple)(t,"items")};z$.default=VNe});var Sce=W(G$=>{"use strict";h();Object.defineProperty(G$,"__esModule",{value:!0});var Ece=Qt(),JNe=Ir(),YNe=pd(),ZNe=L$(),XNe={message:({params:{len:t}})=>(0,Ece.str)`must NOT have more than ${t} items`,params:({params:{len:t}})=>(0,Ece._)`{limit: ${t}}`},QNe={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:XNe,code(t){let{schema:e,parentSchema:r,it:n}=t,{prefixItems:i}=r;n.items=!0,!(0,JNe.alwaysValidSchema)(n,e)&&(i?(0,ZNe.validateAdditionalItems)(t,i):t.ok((0,YNe.validateArray)(t)))}};G$.default=QNe});var Ace=W(W$=>{"use strict";h();Object.defineProperty(W$,"__esModule",{value:!0});var yd=Qt(),qA=Ir(),eje={message:({params:{min:t,max:e}})=>e===void 0?(0,yd.str)`must contain at least ${t} valid item(s)`:(0,yd.str)`must contain at least ${t} and no more than ${e} valid item(s)`,params:({params:{min:t,max:e}})=>e===void 0?(0,yd._)`{minContains: ${t}}`:(0,yd._)`{minContains: ${t}, maxContains: ${e}}`},tje={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:eje,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,yd._)`${i}.length`);if(t.setParams({min:s,max:a}),a===void 0&&s===0){(0,qA.checkStrictMode)(o,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(a!==void 0&&s>a){(0,qA.checkStrictMode)(o,'"minContains" > "maxContains" is always invalid'),t.fail();return}if((0,qA.alwaysValidSchema)(o,r)){let b=(0,yd._)`${c} >= ${s}`;a!==void 0&&(b=(0,yd._)`${b} && ${c} <= ${a}`),t.pass(b);return}o.items=!0;let l=e.name("valid");a===void 0&&s===1?p(l,()=>e.if(l,()=>e.break())):s===0?(e.let(l,!0),a!==void 0&&e.if((0,yd._)`${i}.length > 0`,m)):(e.let(l,!1),m()),t.result(l,()=>t.reset());function m(){let b=e.name("_valid"),S=e.let("count",0);p(b,()=>e.if(b,()=>g(S)))}function p(b,S){e.forRange("i",0,c,A=>{t.subschema({keyword:"contains",dataProp:A,dataPropType:qA.Type.Num,compositeRule:!0},b),S()})}function g(b){e.code((0,yd._)`${b}++`),a===void 0?e.if((0,yd._)`${b} >= ${s}`,()=>e.assign(l,!0).break()):(e.if((0,yd._)`${b} > ${a}`,()=>e.assign(l,!1).break()),s===1?e.assign(l,!0):e.if((0,yd._)`${b} >= ${s}`,()=>e.assign(l,!0)))}}};W$.default=tje});var LA=W(Ol=>{"use strict";h();Object.defineProperty(Ol,"__esModule",{value:!0});Ol.validateSchemaDeps=Ol.validatePropertyDeps=Ol.error=void 0;var H$=Qt(),rje=Ir(),RE=pd();Ol.error={message:({params:{property:t,depsCount:e,deps:r}})=>{let n=e===1?"property":"properties";return(0,H$.str)`must have ${n} ${r} when property ${t} is present`},params:({params:{property:t,depsCount:e,deps:r,missingProperty:n}})=>(0,H$._)`{property: ${t}, missingProperty: ${n}, depsCount: ${e}, deps: ${r}}`};var nje={keyword:"dependencies",type:"object",schemaType:"object",error:Ol.error,code(t){let[e,r]=ije(t);Pce(t,e),Tce(t,r)}};function ije({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 Pce(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,RE.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,RE.checkReportMissingProp)(t,u)}):(r.if((0,H$._)`${d} && (${(0,RE.checkMissingProp)(t,a,o)})`),(0,RE.reportMissingProp)(t,o),r.else())}}Ol.validatePropertyDeps=Pce;function Tce(t,e=t.schema){let{gen:r,data:n,keyword:i,it:o}=t,s=r.name("valid");for(let a in e)(0,rje.alwaysValidSchema)(o,e[a])||(r.if((0,RE.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))}Ol.validateSchemaDeps=Tce;Ol.default=nje});var kce=W(V$=>{"use strict";h();Object.defineProperty(V$,"__esModule",{value:!0});var Ice=Qt(),oje=Ir(),sje={message:"property name must be valid",params:({params:t})=>(0,Ice._)`{propertyName: ${t.propertyName}}`},aje={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:sje,code(t){let{gen:e,schema:r,data:n,it:i}=t;if((0,oje.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,Ice.not)(o),()=>{t.error(!0),i.allErrors||e.break()})}),t.ok(o)}};V$.default=aje});var Y$=W(J$=>{"use strict";h();Object.defineProperty(J$,"__esModule",{value:!0});var FA=pd(),vu=Qt(),cje=hd(),zA=Ir(),dje={message:"must NOT have additional properties",params:({params:t})=>(0,vu._)`{additionalProperty: ${t.additionalProperty}}`},uje={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:dje,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,zA.alwaysValidSchema)(s,r))return;let u=(0,FA.allSchemaProperties)(n.properties),c=(0,FA.allSchemaProperties)(n.patternProperties);l(),t.ok((0,vu._)`${o} === ${cje.default.errors}`);function l(){e.forIn("key",i,S=>{!u.length&&!c.length?g(S):e.if(m(S),()=>g(S))})}function m(S){let A;if(u.length>8){let I=(0,zA.schemaRefOrVal)(s,n.properties,"properties");A=(0,FA.isOwnProperty)(e,I,S)}else u.length?A=(0,vu.or)(...u.map(I=>(0,vu._)`${S} === ${I}`)):A=vu.nil;return c.length&&(A=(0,vu.or)(A,...c.map(I=>(0,vu._)`${(0,FA.usePattern)(t,I)}.test(${S})`))),(0,vu.not)(A)}function p(S){e.code((0,vu._)`delete ${i}[${S}]`)}function g(S){if(d.removeAdditional==="all"||d.removeAdditional&&r===!1){p(S);return}if(r===!1){t.setParams({additionalProperty:S}),t.error(),a||e.break();return}if(typeof r=="object"&&!(0,zA.alwaysValidSchema)(s,r)){let A=e.name("valid");d.removeAdditional==="failing"?(b(S,A,!1),e.if((0,vu.not)(A),()=>{t.reset(),p(S)})):(b(S,A),a||e.if((0,vu.not)(A),()=>e.break()))}}function b(S,A,I){let P={keyword:"additionalProperties",dataProp:S,dataPropType:zA.Type.Str};I===!1&&Object.assign(P,{compositeRule:!0,createErrors:!1,allErrors:!1}),t.subschema(P,A)}}};J$.default=uje});var Mce=W(X$=>{"use strict";h();Object.defineProperty(X$,"__esModule",{value:!0});var lje=gE(),Rce=pd(),Z$=Ir(),Dce=Y$(),fje={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&&Dce.default.code(new lje.KeywordCxt(o,Dce.default,"additionalProperties"));let s=(0,Rce.allSchemaProperties)(r);for(let l of s)o.definedProperties.add(l);o.opts.unevaluated&&s.length&&o.props!==!0&&(o.props=Z$.mergeEvaluated.props(e,(0,Z$.toHash)(s),o.props));let a=s.filter(l=>!(0,Z$.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,Rce.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)}}};X$.default=fje});var $ce=W(Q$=>{"use strict";h();Object.defineProperty(Q$,"__esModule",{value:!0});var Bce=pd(),GA=Qt(),Cce=Ir(),Oce=Ir(),hje={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,Bce.allSchemaProperties)(r),d=a.filter(b=>(0,Cce.alwaysValidSchema)(o,r[b]));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 GA.Name)&&(o.props=(0,Oce.evaluatedPropsToName)(e,o.props));let{props:l}=o;m();function m(){for(let b of a)u&&p(b),o.allErrors?g(b):(e.var(c,!0),g(b),e.if(c))}function p(b){for(let S in u)new RegExp(b).test(S)&&(0,Cce.checkStrictMode)(o,`property ${S} matches pattern ${b} (use allowMatchingProperties)`)}function g(b){e.forIn("key",n,S=>{e.if((0,GA._)`${(0,Bce.usePattern)(t,b)}.test(${S})`,()=>{let A=d.includes(b);A||t.subschema({keyword:"patternProperties",schemaProp:b,dataProp:S,dataPropType:Oce.Type.Str},c),o.opts.unevaluated&&l!==!0?e.assign((0,GA._)`${l}[${S}]`,!0):!A&&!o.allErrors&&e.if((0,GA.not)(c),()=>e.break())})})}}};Q$.default=hje});var Nce=W(eN=>{"use strict";h();Object.defineProperty(eN,"__esModule",{value:!0});var pje=Ir(),mje={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(t){let{gen:e,schema:r,it:n}=t;if((0,pje.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"}};eN.default=mje});var jce=W(tN=>{"use strict";h();Object.defineProperty(tN,"__esModule",{value:!0});var yje=pd(),gje={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:yje.validateUnion,error:{message:"must match a schema in anyOf"}};tN.default=gje});var Uce=W(rN=>{"use strict";h();Object.defineProperty(rN,"__esModule",{value:!0});var WA=Qt(),bje=Ir(),vje={message:"must match exactly one schema in oneOf",params:({params:t})=>(0,WA._)`{passingSchemas: ${t.passing}}`},wje={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:vje,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 m;(0,bje.alwaysValidSchema)(i,c)?e.var(d,!0):m=t.subschema({keyword:"oneOf",schemaProp:l,compositeRule:!0},d),l>0&&e.if((0,WA._)`${d} && ${s}`).assign(s,!1).assign(a,(0,WA._)`[${a}, ${l}]`).else(),e.if(d,()=>{e.assign(s,!0),e.assign(a,l),m&&t.mergeEvaluated(m,WA.Name)})})}}};rN.default=wje});var Kce=W(nN=>{"use strict";h();Object.defineProperty(nN,"__esModule",{value:!0});var _je=Ir(),xje={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,_je.alwaysValidSchema)(n,o))return;let a=t.subschema({keyword:"allOf",schemaProp:s},i);t.ok(i),t.mergeEvaluated(a)})}};nN.default=xje});var Fce=W(iN=>{"use strict";h();Object.defineProperty(iN,"__esModule",{value:!0});var HA=Qt(),Lce=Ir(),Eje={message:({params:t})=>(0,HA.str)`must match "${t.ifClause}" schema`,params:({params:t})=>(0,HA._)`{failingKeyword: ${t.ifClause}}`},Sje={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:Eje,code(t){let{gen:e,parentSchema:r,it:n}=t;r.then===void 0&&r.else===void 0&&(0,Lce.checkStrictMode)(n,'"if" without "then" and "else" is ignored');let i=qce(n,"then"),o=qce(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,HA.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 m=t.subschema({keyword:c},a);e.assign(s,a),t.mergeValidEvaluated(m,s),l?e.assign(l,(0,HA._)`${c}`):t.setParams({ifClause:c})}}}};function qce(t,e){let r=t.schema[e];return r!==void 0&&!(0,Lce.alwaysValidSchema)(t,r)}iN.default=Sje});var zce=W(oN=>{"use strict";h();Object.defineProperty(oN,"__esModule",{value:!0});var Aje=Ir(),Pje={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:t,parentSchema:e,it:r}){e.if===void 0&&(0,Aje.checkStrictMode)(r,`"${t}" without "if" is ignored`)}};oN.default=Pje});var Gce=W(sN=>{"use strict";h();Object.defineProperty(sN,"__esModule",{value:!0});var Tje=L$(),Ije=xce(),kje=F$(),Rje=Sce(),Dje=Ace(),Mje=LA(),Bje=kce(),Cje=Y$(),Oje=Mce(),$je=$ce(),Nje=Nce(),jje=jce(),Uje=Uce(),Kje=Kce(),qje=Fce(),Lje=zce();function Fje(t=!1){let e=[Nje.default,jje.default,Uje.default,Kje.default,qje.default,Lje.default,Bje.default,Cje.default,Mje.default,Oje.default,$je.default];return t?e.push(Ije.default,Rje.default):e.push(Tje.default,kje.default),e.push(Dje.default),e}sN.default=Fje});var cN=W(DE=>{"use strict";h();Object.defineProperty(DE,"__esModule",{value:!0});DE.dynamicAnchor=void 0;var aN=Qt(),zje=hd(),Wce=bE(),Gje=OA(),Wje={keyword:"$dynamicAnchor",schemaType:"string",code:t=>Hce(t,t.schema)};function Hce(t,e){let{gen:r,it:n}=t;n.schemaEnv.root.dynamicAnchors[e]=!0;let i=(0,aN._)`${zje.default.dynamicAnchors}${(0,aN.getProperty)(e)}`,o=n.errSchemaPath==="#"?n.validateName:Hje(t);r.if((0,aN._)`!${i}`,()=>r.assign(i,o))}DE.dynamicAnchor=Hce;function Hje(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 Wce.SchemaEnv({schema:r,schemaId:d,root:i,baseId:o,localRefs:s,meta:a});return Wce.compileSchema.call(n,u),(0,Gje.getValidate)(t,u)}DE.default=Wje});var dN=W(ME=>{"use strict";h();Object.defineProperty(ME,"__esModule",{value:!0});ME.dynamicRef=void 0;var Vce=Qt(),Vje=hd(),Jce=OA(),Jje={keyword:"$dynamicRef",schemaType:"string",code:t=>Yce(t,t.schema)};function Yce(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,Vce._)`${Vje.default.dynamicAnchors}${(0,Vce.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,Jce.callRef)(t,d),r.let(u,!0)}):()=>(0,Jce.callRef)(t,d)}}ME.dynamicRef=Yce;ME.default=Jje});var Zce=W(uN=>{"use strict";h();Object.defineProperty(uN,"__esModule",{value:!0});var Yje=cN(),Zje=Ir(),Xje={keyword:"$recursiveAnchor",schemaType:"boolean",code(t){t.schema?(0,Yje.dynamicAnchor)(t,""):(0,Zje.checkStrictMode)(t.it,"$recursiveAnchor: false is ignored")}};uN.default=Xje});var Xce=W(lN=>{"use strict";h();Object.defineProperty(lN,"__esModule",{value:!0});var Qje=dN(),eUe={keyword:"$recursiveRef",schemaType:"string",code:t=>(0,Qje.dynamicRef)(t,t.schema)};lN.default=eUe});var Qce=W(fN=>{"use strict";h();Object.defineProperty(fN,"__esModule",{value:!0});var tUe=cN(),rUe=dN(),nUe=Zce(),iUe=Xce(),oUe=[tUe.default,rUe.default,nUe.default,iUe.default];fN.default=oUe});var tde=W(hN=>{"use strict";h();Object.defineProperty(hN,"__esModule",{value:!0});var ede=LA(),sUe={keyword:"dependentRequired",type:"object",schemaType:"object",error:ede.error,code:t=>(0,ede.validatePropertyDeps)(t)};hN.default=sUe});var rde=W(pN=>{"use strict";h();Object.defineProperty(pN,"__esModule",{value:!0});var aUe=LA(),cUe={keyword:"dependentSchemas",type:"object",schemaType:"object",code:t=>(0,aUe.validateSchemaDeps)(t)};pN.default=cUe});var nde=W(mN=>{"use strict";h();Object.defineProperty(mN,"__esModule",{value:!0});var dUe=Ir(),uUe={keyword:["maxContains","minContains"],type:"array",schemaType:"number",code({keyword:t,parentSchema:e,it:r}){e.contains===void 0&&(0,dUe.checkStrictMode)(r,`"${t}" without "contains" is ignored`)}};mN.default=uUe});var ide=W(yN=>{"use strict";h();Object.defineProperty(yN,"__esModule",{value:!0});var lUe=tde(),fUe=rde(),hUe=nde(),pUe=[lUe.default,fUe.default,hUe.default];yN.default=pUe});var sde=W(gN=>{"use strict";h();Object.defineProperty(gN,"__esModule",{value:!0});var ym=Qt(),ode=Ir(),mUe=hd(),yUe={message:"must NOT have unevaluated properties",params:({params:t})=>(0,ym._)`{unevaluatedProperty: ${t.unevaluatedProperty}}`},gUe={keyword:"unevaluatedProperties",type:"object",schemaType:["boolean","object"],trackErrors:!0,error:yUe,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 ym.Name?e.if((0,ym._)`${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,ym._)`${i} === ${mUe.default.errors}`);function d(l){if(r===!1){t.setParams({unevaluatedProperty:l}),t.error(),s||e.break();return}if(!(0,ode.alwaysValidSchema)(o,r)){let m=e.name("valid");t.subschema({keyword:"unevaluatedProperties",dataProp:l,dataPropType:ode.Type.Str},m),s||e.if((0,ym.not)(m),()=>e.break())}}function u(l,m){return(0,ym._)`!${l} || !${l}[${m}]`}function c(l,m){let p=[];for(let g in l)l[g]===!0&&p.push((0,ym._)`${m} !== ${g}`);return(0,ym.and)(...p)}}};gN.default=gUe});var cde=W(bN=>{"use strict";h();Object.defineProperty(bN,"__esModule",{value:!0});var ig=Qt(),ade=Ir(),bUe={message:({params:{len:t}})=>(0,ig.str)`must NOT have more than ${t} items`,params:({params:{len:t}})=>(0,ig._)`{limit: ${t}}`},vUe={keyword:"unevaluatedItems",type:"array",schemaType:["boolean","object"],error:bUe,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,ig._)`${n}.length`);if(r===!1)t.setParams({len:o}),t.fail((0,ig._)`${s} > ${o}`);else if(typeof r=="object"&&!(0,ade.alwaysValidSchema)(i,r)){let d=e.var("valid",(0,ig._)`${s} <= ${o}`);e.if((0,ig.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:ade.Type.Num},d),i.allErrors||e.if((0,ig.not)(d),()=>e.break())})}}};bN.default=vUe});var dde=W(vN=>{"use strict";h();Object.defineProperty(vN,"__esModule",{value:!0});var wUe=sde(),_Ue=cde(),xUe=[wUe.default,_Ue.default];vN.default=xUe});var ude=W(wN=>{"use strict";h();Object.defineProperty(wN,"__esModule",{value:!0});var Ti=Qt(),EUe={message:({schemaCode:t})=>(0,Ti.str)`must match format "${t}"`,params:({schemaCode:t})=>(0,Ti._)`{format: ${t}}`},SUe={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:EUe,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?m():p();function m(){let g=r.scopeValue("formats",{ref:l.formats,code:d.code.formats}),b=r.const("fDef",(0,Ti._)`${g}[${s}]`),S=r.let("fType"),A=r.let("format");r.if((0,Ti._)`typeof ${b} == "object" && !(${b} instanceof RegExp)`,()=>r.assign(S,(0,Ti._)`${b}.type || "string"`).assign(A,(0,Ti._)`${b}.validate`),()=>r.assign(S,(0,Ti._)`"string"`).assign(A,b)),t.fail$data((0,Ti.or)(I(),P()));function I(){return d.strictSchema===!1?Ti.nil:(0,Ti._)`${s} && !${A}`}function P(){let $=c.$async?(0,Ti._)`(${b}.async ? await ${A}(${n}) : ${A}(${n}))`:(0,Ti._)`${A}(${n})`,N=(0,Ti._)`(typeof ${A} == "function" ? ${$} : ${A}.test(${n}))`;return(0,Ti._)`${A} && ${A} !== true && ${S} === ${e} && !${N}`}}function p(){let g=l.formats[o];if(!g){I();return}if(g===!0)return;let[b,S,A]=P(g);b===e&&t.pass($());function I(){if(d.strictSchema===!1){l.logger.warn(N());return}throw new Error(N());function N(){return`unknown format "${o}" ignored in schema at path "${u}"`}}function P(N){let L=N instanceof RegExp?(0,Ti.regexpCode)(N):d.code.formats?(0,Ti._)`${d.code.formats}${(0,Ti.getProperty)(o)}`:void 0,F=r.scopeValue("formats",{key:o,ref:N,code:L});return typeof N=="object"&&!(N instanceof RegExp)?[N.type||"string",N.validate,(0,Ti._)`${F}.validate`]:["string",N,F]}function $(){if(typeof g=="object"&&!(g instanceof RegExp)&&g.async){if(!c.$async)throw new Error("async format in sync schema");return(0,Ti._)`await ${A}(${n})`}return typeof S=="function"?(0,Ti._)`${A}(${n})`:(0,Ti._)`${A}.test(${n})`}}}};wN.default=SUe});var lde=W(_N=>{"use strict";h();Object.defineProperty(_N,"__esModule",{value:!0});var AUe=ude(),PUe=[AUe.default];_N.default=PUe});var fde=W(Lw=>{"use strict";h();Object.defineProperty(Lw,"__esModule",{value:!0});Lw.contentVocabulary=Lw.metadataVocabulary=void 0;Lw.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];Lw.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]});var pde=W(xN=>{"use strict";h();Object.defineProperty(xN,"__esModule",{value:!0});var TUe=ice(),IUe=bce(),kUe=Gce(),RUe=Qce(),DUe=ide(),MUe=dde(),BUe=lde(),hde=fde(),CUe=[RUe.default,TUe.default,IUe.default,(0,kUe.default)(!0),BUe.default,hde.metadataVocabulary,hde.contentVocabulary,DUe.default,MUe.default];xN.default=CUe});var mde=W(BE=>{"use strict";h();Object.defineProperty(BE,"__esModule",{value:!0});BE.DiscrError=void 0;var OUe;(function(t){t.Tag="tag",t.Mapping="mapping"})(OUe=BE.DiscrError||(BE.DiscrError={}))});var gde=W(SN=>{"use strict";h();Object.defineProperty(SN,"__esModule",{value:!0});var Fw=Qt(),EN=mde(),yde=bE(),$Ue=Ir(),NUe={message:({params:{discrError:t,tagName:e}})=>t===EN.DiscrError.Tag?`tag "${e}" must be string`:`value of tag "${e}" must be in oneOf`,params:({params:{discrError:t,tag:e,tagName:r}})=>(0,Fw._)`{error: ${t}, tag: ${r}, tagValue: ${e}}`},jUe={keyword:"discriminator",type:"object",schemaType:"object",error:NUe,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,Fw._)`${r}${(0,Fw.getProperty)(a)}`);e.if((0,Fw._)`typeof ${u} == "string"`,()=>c(),()=>t.error(!1,{discrError:EN.DiscrError.Tag,tag:u,tagName:a})),t.ok(d);function c(){let p=m();e.if(!1);for(let g in p)e.elseIf((0,Fw._)`${u} === ${g}`),e.assign(d,l(p[g]));e.else(),t.error(!1,{discrError:EN.DiscrError.Mapping,tag:u,tagName:a}),e.endIf()}function l(p){let g=e.name("valid"),b=t.subschema({keyword:"oneOf",schemaProp:p},g);return t.mergeEvaluated(b,Fw.Name),g}function m(){var p;let g={},b=A(i),S=!0;for(let $=0;${UUe.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 vde=W((n2t,KUe)=>{KUe.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 wde=W((i2t,qUe)=>{qUe.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 _de=W((o2t,LUe)=>{LUe.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 xde=W((s2t,FUe)=>{FUe.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 Ede=W((a2t,zUe)=>{zUe.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 Sde=W((c2t,GUe)=>{GUe.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 Ade=W((d2t,WUe)=>{WUe.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 Pde=W(AN=>{"use strict";h();Object.defineProperty(AN,"__esModule",{value:!0});var HUe=bde(),VUe=vde(),JUe=wde(),YUe=_de(),ZUe=xde(),XUe=Ede(),QUe=Sde(),eKe=Ade(),tKe=["/properties"];function rKe(t){return[HUe,VUe,JUe,YUe,ZUe,e(this,XUe),QUe,e(this,eKe)].forEach(r=>this.addMetaSchema(r,void 0,!1)),this;function e(r,n){return t?r.$dataMetaSchema(n,tKe):n}}AN.default=rKe});var TN=W((Zn,Tde)=>{"use strict";h();Object.defineProperty(Zn,"__esModule",{value:!0});Zn.MissingRefError=Zn.ValidationError=Zn.CodeGen=Zn.Name=Zn.nil=Zn.stringify=Zn.str=Zn._=Zn.KeywordCxt=void 0;var nKe=Qae(),iKe=pde(),oKe=gde(),sKe=Pde(),PN="https://json-schema.org/draft/2020-12/schema",VA=class extends nKe.default{constructor(e={}){super({...e,dynamicRef:!0,next:!0,unevaluated:!0})}_addVocabularies(){super._addVocabularies(),iKe.default.forEach(e=>this.addVocabulary(e)),this.opts.discriminator&&this.addKeyword(oKe.default)}_addDefaultMetaSchema(){super._addDefaultMetaSchema();let{$data:e,meta:r}=this.opts;r&&(sKe.default.call(this,e),this.refs["http://json-schema.org/schema"]=PN)}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(PN)?PN:void 0)}};Tde.exports=Zn=VA;Object.defineProperty(Zn,"__esModule",{value:!0});Zn.default=VA;var aKe=gE();Object.defineProperty(Zn,"KeywordCxt",{enumerable:!0,get:function(){return aKe.KeywordCxt}});var zw=Qt();Object.defineProperty(Zn,"_",{enumerable:!0,get:function(){return zw._}});Object.defineProperty(Zn,"str",{enumerable:!0,get:function(){return zw.str}});Object.defineProperty(Zn,"stringify",{enumerable:!0,get:function(){return zw.stringify}});Object.defineProperty(Zn,"nil",{enumerable:!0,get:function(){return zw.nil}});Object.defineProperty(Zn,"Name",{enumerable:!0,get:function(){return zw.Name}});Object.defineProperty(Zn,"CodeGen",{enumerable:!0,get:function(){return zw.CodeGen}});var cKe=IA();Object.defineProperty(Zn,"ValidationError",{enumerable:!0,get:function(){return cKe.default}});var dKe=kA();Object.defineProperty(Zn,"MissingRefError",{enumerable:!0,get:function(){return dKe.default}})});var Ode=W((EEt,Cde)=>{h();var pKe=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,oP=()=>pKe.now(),mKe=t=>t&&t===Math.floor(t)&&t>0&&isFinite(t),MN=t=>t===1/0||mKe(t),BN=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&&!MN(r))throw new TypeError("ttl must be positive integer or Infinity if set");if(!MN(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-oP());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 B.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(oP()+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(!MN(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-oP())):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(oP());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()}};Cde.exports=BN});var Kde=W(Ude=>{"use strict";h();Ude.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 _u=W((FEt,qde)=>{"use strict";h();qde.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 $N=W((GEt,Lde)=>{"use strict";h();var ON=null;Lde.exports=function(){return ON===null&&(ON={textEncoder:new TextEncoder,textDecoder:new TextDecoder}),ON}});var UN=W(Fde=>{"use strict";h();var NN=_u(),yKe=new Set(["buffer","view","utf8"]),jN=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"||!yKe.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 NN(`Encoding '${this.name}' cannot be transcoded to 'buffer'`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"})}createViewTranscoder(){throw new NN(`Encoding '${this.name}' cannot be transcoded to 'view'`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"})}createUTF8Transcoder(){throw new NN(`Encoding '${this.name}' cannot be transcoded to 'utf8'`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"})}};Fde.Encoding=jN});var FN=W(aP=>{"use strict";h();var{Buffer:qN}=Un()||{},{Encoding:LN}=UN(),gKe=$N(),$E=class extends LN{constructor(e){super({...e,format:"buffer"})}createViewTranscoder(){return new NE({encode:this.encode,decode:e=>this.decode(qN.from(e.buffer,e.byteOffset,e.byteLength)),name:`${this.name}+view`})}createBufferTranscoder(){return this}},NE=class extends LN{constructor(e){super({...e,format:"view"})}createBufferTranscoder(){return new $E({encode:e=>{let r=this.encode(e);return qN.from(r.buffer,r.byteOffset,r.byteLength)},decode:this.decode,name:`${this.name}+buffer`})}createViewTranscoder(){return this}},KN=class extends LN{constructor(e){super({...e,format:"utf8"})}createBufferTranscoder(){return new $E({encode:e=>qN.from(this.encode(e),"utf8"),decode:e=>this.decode(e.toString("utf8")),name:`${this.name}+buffer`})}createViewTranscoder(){let{textEncoder:e,textDecoder:r}=gKe();return new NE({encode:n=>e.encode(this.encode(n)),decode:n=>this.decode(r.decode(n)),name:`${this.name}+view`})}createUTF8Transcoder(){return this}};aP.BufferFormat=$E;aP.ViewFormat=NE;aP.UTF8Format=KN});var Hde=W(dg=>{"use strict";h();var{Buffer:$s}=Un()||{Buffer:{isBuffer:()=>!1}},{textEncoder:Gde,textDecoder:zde}=$N()(),{BufferFormat:jE,ViewFormat:zN,UTF8Format:Wde}=FN(),cP=t=>t;dg.utf8=new Wde({encode:function(t){return $s.isBuffer(t)?t.toString("utf8"):ArrayBuffer.isView(t)?zde.decode(t):String(t)},decode:cP,name:"utf8",createViewTranscoder(){return new zN({encode:function(t){return ArrayBuffer.isView(t)?t:Gde.encode(t)},decode:function(t){return zde.decode(t)},name:`${this.name}+view`})},createBufferTranscoder(){return new jE({encode:function(t){return $s.isBuffer(t)?t:ArrayBuffer.isView(t)?$s.from(t.buffer,t.byteOffset,t.byteLength):$s.from(String(t),"utf8")},decode:function(t){return t.toString("utf8")},name:`${this.name}+buffer`})}});dg.json=new Wde({encode:JSON.stringify,decode:JSON.parse,name:"json"});dg.buffer=new jE({encode:function(t){return $s.isBuffer(t)?t:ArrayBuffer.isView(t)?$s.from(t.buffer,t.byteOffset,t.byteLength):$s.from(String(t),"utf8")},decode:cP,name:"buffer",createViewTranscoder(){return new zN({encode:function(t){return ArrayBuffer.isView(t)?t:$s.from(String(t),"utf8")},decode:function(t){return $s.from(t.buffer,t.byteOffset,t.byteLength)},name:`${this.name}+view`})}});dg.view=new zN({encode:function(t){return ArrayBuffer.isView(t)?t:Gde.encode(t)},decode:cP,name:"view",createBufferTranscoder(){return new jE({encode:function(t){return $s.isBuffer(t)?t:ArrayBuffer.isView(t)?$s.from(t.buffer,t.byteOffset,t.byteLength):$s.from(String(t),"utf8")},decode:cP,name:`${this.name}+buffer`})}});dg.hex=new jE({encode:function(t){return $s.isBuffer(t)?t:$s.from(String(t),"hex")},decode:function(t){return t.toString("hex")},name:"hex"});dg.base64=new jE({encode:function(t){return $s.isBuffer(t)?t:$s.from(String(t),"base64")},decode:function(t){return t.toString("base64")},name:"base64"})});var Yde=W(Jde=>{"use strict";h();var Vde=_u(),uP=Hde(),{Encoding:bKe}=UN(),{BufferFormat:vKe,ViewFormat:wKe,UTF8Format:_Ke}=FN(),UE=Symbol("formats"),dP=Symbol("encodings"),xKe=new Set(["buffer","view","utf8"]),GN=class{constructor(e){if(Array.isArray(e)){if(!e.every(r=>xKe.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[dP]=new Map,this[UE]=new Set(e);for(let r in uP)try{this.encoding(r)}catch(n){if(n.code!=="LEVEL_ENCODING_NOT_SUPPORTED")throw n}}encodings(){return Array.from(new Set(this[dP].values()))}encoding(e){let r=this[dP].get(e);if(r===void 0){if(typeof e=="string"&&e!==""){if(r=PKe[e],!r)throw new Vde(`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=EKe(e)}let{name:n,format:i}=r;if(!this[UE].has(i))if(this[UE].has("view"))r=r.createViewTranscoder();else if(this[UE].has("buffer"))r=r.createBufferTranscoder();else if(this[UE].has("utf8"))r=r.createUTF8Transcoder();else throw new Vde(`Encoding '${n}' cannot be transcoded`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"});for(let o of[e,n,r.name,r.commonName])this[dP].set(o,r)}return r}};Jde.Transcoder=GN;function EKe(t){if(t instanceof bKe)return t;let e="type"in t&&typeof t.type=="string"?t.type:void 0,r=t.name||e||`anonymous-${TKe++}`;switch(SKe(t)){case"view":return new wKe({...t,name:r});case"utf8":return new _Ke({...t,name:r});case"buffer":return new vKe({...t,name:r});default:throw new TypeError("Format must be one of 'buffer', 'view', 'utf8'")}}function SKe(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 AKe={binary:uP.buffer,"utf-8":uP.utf8},PKe={...uP,...AKe},TKe=0});var Xde=W((t6t,Zde)=>{h();Zde.exports=typeof queueMicrotask=="function"?queueMicrotask:t=>Promise.resolve().then(t)});var KE=W(WN=>{"use strict";h();var Qde=Xde();WN.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};WN.fromPromise=function(t,e){if(e===void 0)return t;t.then(function(r){Qde(()=>e(null,r))}).catch(function(r){Qde(()=>e(r))})}});var lP=W(HN=>{"use strict";h();HN.getCallback=function(t,e){return typeof t=="function"?t:e};HN.getOptions=function(t,e){return typeof t=="object"&&t!==null?t:e!==void 0?e:{}}});var Im=W(mP=>{"use strict";h();var{fromCallback:VN}=KE(),bc=_u(),{getOptions:JN,getCallback:eue}=lP(),ug=Symbol("promise"),Ww=Symbol("callback"),$l=Symbol("working"),lg=Symbol("handleOne"),uh=Symbol("handleMany"),YN=Symbol("autoClose"),Pm=Symbol("finishWork"),Nl=Symbol("returnMany"),Em=Symbol("closing"),qE=Symbol("handleClose"),fP=Symbol("closed"),LE=Symbol("closeCallbacks"),Am=Symbol("keyEncoding"),fg=Symbol("valueEncoding"),ZN=Symbol("abortOnClose"),hP=Symbol("legacy"),XN=Symbol("keys"),QN=Symbol("values"),Sm=Symbol("limit"),gd=Symbol("count"),pP=Object.freeze({}),IKe=()=>{},tue=!1,FE=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[fP]=!1,this[LE]=[],this[$l]=!1,this[Em]=!1,this[YN]=!1,this[Ww]=null,this[lg]=this[lg].bind(this),this[uh]=this[uh].bind(this),this[qE]=this[qE].bind(this),this[Am]=r[Am],this[fg]=r[fg],this[hP]=n,this[Sm]=Number.isInteger(r.limit)&&r.limit>=0?r.limit:1/0,this[gd]=0,this[ZN]=!!r.abortOnClose,this.db=e,this.db.attachResource(this),this.nextTick=e.nextTick}get count(){return this[gd]}get limit(){return this[Sm]}next(e){let r;if(e===void 0)r=new Promise((n,i)=>{e=(o,s,a)=>{o?i(o):this[hP]?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[Em]?this.nextTick(e,new bc("Iterator is not open: cannot call next() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this[$l]?this.nextTick(e,new bc("Iterator is busy: cannot call next() until previous call has completed",{code:"LEVEL_ITERATOR_BUSY"})):(this[$l]=!0,this[Ww]=e,this[gd]>=this[Sm]?this.nextTick(this[lg],null):this._next(this[lg])),r}_next(e){this.nextTick(e)}nextv(e,r,n){return n=eue(r,n),n=VN(n,ug),r=JN(r,pP),Number.isInteger(e)?(this[Em]?this.nextTick(n,new bc("Iterator is not open: cannot call nextv() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this[$l]?this.nextTick(n,new bc("Iterator is busy: cannot call nextv() until previous call has completed",{code:"LEVEL_ITERATOR_BUSY"})):(e<1&&(e=1),this[Sm]<1/0&&(e=Math.min(e,this[Sm]-this[gd])),this[$l]=!0,this[Ww]=n,e<=0?this.nextTick(this[uh],null,[]):this._nextv(e,r,this[uh])),n[ug]):(this.nextTick(n,new TypeError("The first argument 'size' must be an integer")),n[ug])}_nextv(e,r,n){let i=[],o=(s,a,d)=>{if(s)return n(s);if(this[hP]?a===void 0&&d===void 0:a===void 0)return n(null,i);i.push(this[hP]?[a,d]:a),i.length===e?n(null,i):this._next(o)};this._next(o)}all(e,r){return r=eue(e,r),r=VN(r,ug),e=JN(e,pP),this[Em]?this.nextTick(r,new bc("Iterator is not open: cannot call all() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this[$l]?this.nextTick(r,new bc("Iterator is busy: cannot call all() until previous call has completed",{code:"LEVEL_ITERATOR_BUSY"})):(this[$l]=!0,this[Ww]=r,this[YN]=!0,this[gd]>=this[Sm]?this.nextTick(this[uh],null,[]):this._all(e,this[uh])),r[ug]}_all(e,r){let n=this[gd],i=[],o=()=>{let a=this[Sm]<1/0?Math.min(1e3,this[Sm]-n):1e3;a<=0?this.nextTick(r,null,i):this._nextv(a,pP,s)},s=(a,d)=>{a?r(a):d.length===0?r(null,i):(i.push.apply(i,d),n+=d.length,o())};o()}[Pm](){let e=this[Ww];return this[ZN]&&e===null?IKe:(this[$l]=!1,this[Ww]=null,this[Em]&&this._close(this[qE]),e)}[Nl](e,r,n){this[YN]?this.close(e.bind(null,r,n)):e(r,n)}seek(e,r){if(r=JN(r,pP),!this[Em]){if(this[$l])throw new bc("Iterator is busy: cannot call seek() until next() has completed",{code:"LEVEL_ITERATOR_BUSY"});{let n=this.db.keyEncoding(r.keyEncoding||this[Am]),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 bc("Iterator does not support seek()",{code:"LEVEL_NOT_SUPPORTED"})}close(e){return e=VN(e,ug),this[fP]?this.nextTick(e):this[Em]?this[LE].push(e):(this[Em]=!0,this[LE].push(e),this[$l]?this[ZN]&&this[Pm]()(new bc("Aborted on iterator close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this._close(this[qE])),e[ug]}_close(e){this.nextTick(e)}[qE](){this[fP]=!0,this.db.detachResource(this);let e=this[LE];this[LE]=[];for(let r of e)r()}async*[Symbol.asyncIterator](){try{let e;for(;(e=await this.next())!==void 0;)yield e}finally{this[fP]||await this.close()}}},Hw=class extends FE{constructor(e,r){super(e,r,!0),this[XN]=r.keys!==!1,this[QN]=r.values!==!1}[lg](e,r,n){let i=this[Pm]();if(e)return i(e);try{r=this[XN]&&r!==void 0?this[Am].decode(r):void 0,n=this[QN]&&n!==void 0?this[fg].decode(n):void 0}catch(o){return i(new Tm("entry",o))}r===void 0&&n===void 0||this[gd]++,i(null,r,n)}[uh](e,r){let n=this[Pm]();if(e)return this[Nl](n,e);try{for(let i of r){let o=i[0],s=i[1];i[0]=this[XN]&&o!==void 0?this[Am].decode(o):void 0,i[1]=this[QN]&&s!==void 0?this[fg].decode(s):void 0}}catch(i){return this[Nl](n,new Tm("entries",i))}this[gd]+=r.length,this[Nl](n,null,r)}end(e){return!tue&&typeof console<"u"&&(tue=!0,console.warn(new bc("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)}},ej=class extends FE{constructor(e,r){super(e,r,!1)}[lg](e,r){let n=this[Pm]();if(e)return n(e);try{r=r!==void 0?this[Am].decode(r):void 0}catch(i){return n(new Tm("key",i))}r!==void 0&&this[gd]++,n(null,r)}[uh](e,r){let n=this[Pm]();if(e)return this[Nl](n,e);try{for(let i=0;i{"use strict";h();var{AbstractKeyIterator:kKe,AbstractValueIterator:RKe}=Im(),hg=Symbol("iterator"),zE=Symbol("callback"),Vw=Symbol("handleOne"),pg=Symbol("handleMany"),GE=class extends kKe{constructor(e,r){super(e,r),this[hg]=e.iterator({...r,keys:!0,values:!1}),this[Vw]=this[Vw].bind(this),this[pg]=this[pg].bind(this)}},yP=class extends RKe{constructor(e,r){super(e,r),this[hg]=e.iterator({...r,keys:!1,values:!0}),this[Vw]=this[Vw].bind(this),this[pg]=this[pg].bind(this)}};for(let t of[GE,yP]){let e=t===GE,r=e?n=>n[0]:n=>n[1];t.prototype._next=function(n){this[zE]=n,this[hg].next(this[Vw])},t.prototype[Vw]=function(n,i,o){let s=this[zE];n?s(n):s(null,e?i:o)},t.prototype._nextv=function(n,i,o){this[zE]=o,this[hg].nextv(n,i,this[pg])},t.prototype._all=function(n,i){this[zE]=i,this[hg].all(n,this[pg])},t.prototype[pg]=function(n,i){let o=this[zE];n?o(n):o(null,i.map(r))},t.prototype._seek=function(n,i){this[hg].seek(n,i)},t.prototype._close=function(n){this[hg].close(n)}}rj.DefaultKeyIterator=GE;rj.DefaultValueIterator=yP});var nue=W(xP=>{"use strict";h();var{AbstractIterator:DKe,AbstractKeyIterator:MKe,AbstractValueIterator:BKe}=Im(),nj=_u(),Oa=Symbol("nut"),wP=Symbol("undefer"),_P=Symbol("factory"),gP=class extends DKe{constructor(e,r){super(e,r),this[Oa]=null,this[_P]=()=>e.iterator(r),this.db.defer(()=>this[wP]())}},bP=class extends MKe{constructor(e,r){super(e,r),this[Oa]=null,this[_P]=()=>e.keys(r),this.db.defer(()=>this[wP]())}},vP=class extends BKe{constructor(e,r){super(e,r),this[Oa]=null,this[_P]=()=>e.values(r),this.db.defer(()=>this[wP]())}};for(let t of[gP,bP,vP])t.prototype[wP]=function(){this.db.status==="open"&&(this[Oa]=this[_P]())},t.prototype._next=function(e){this[Oa]!==null?this[Oa].next(e):this.db.status==="opening"?this.db.defer(()=>this._next(e)):this.nextTick(e,new nj("Iterator is not open: cannot call next() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"}))},t.prototype._nextv=function(e,r,n){this[Oa]!==null?this[Oa].nextv(e,r,n):this.db.status==="opening"?this.db.defer(()=>this._nextv(e,r,n)):this.nextTick(n,new nj("Iterator is not open: cannot call nextv() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"}))},t.prototype._all=function(e,r){this[Oa]!==null?this[Oa].all(r):this.db.status==="opening"?this.db.defer(()=>this._all(e,r)):this.nextTick(r,new nj("Iterator is not open: cannot call all() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"}))},t.prototype._seek=function(e,r){this[Oa]!==null?this[Oa]._seek(e,r):this.db.status==="opening"&&this.db.defer(()=>this._seek(e,r))},t.prototype._close=function(e){this[Oa]!==null?this[Oa].close(e):this.db.status==="opening"?this.db.defer(()=>this._close(e)):this.nextTick(e)};xP.DeferredIterator=gP;xP.DeferredKeyIterator=bP;xP.DeferredValueIterator=vP});var oj=W(oue=>{"use strict";h();var{fromCallback:iue}=KE(),EP=_u(),{getCallback:CKe,getOptions:OKe}=lP(),SP=Symbol("promise"),bd=Symbol("status"),Jw=Symbol("operations"),WE=Symbol("finishClose"),Yw=Symbol("closeCallbacks"),ij=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[Jw]=[],this[Yw]=[],this[bd]="open",this[WE]=this[WE].bind(this),this.db=e,this.db.attachResource(this),this.nextTick=e.nextTick}get length(){return this[Jw].length}put(e,r,n){if(this[bd]!=="open")throw new EP("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[Jw].push({...s,type:"put",key:e,value:r}),this}_put(e,r,n){}del(e,r){if(this[bd]!=="open")throw new EP("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[Jw].push({...o,type:"del",key:e}),this}_del(e,r){}clear(){if(this[bd]!=="open")throw new EP("Batch is not open: cannot call clear() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"});return this._clear(),this[Jw]=[],this}_clear(){}write(e,r){return r=CKe(e,r),r=iue(r,SP),e=OKe(e),this[bd]!=="open"?this.nextTick(r,new EP("Batch is not open: cannot call write() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"})):this.length===0?this.close(r):(this[bd]="writing",this._write(e,n=>{this[bd]="closing",this[Yw].push(()=>r(n)),n||this.db.emit("batch",this[Jw]),this._close(this[WE])})),r[SP]}_write(e,r){}close(e){return e=iue(e,SP),this[bd]==="closing"?this[Yw].push(e):this[bd]==="closed"?this.nextTick(e):(this[Yw].push(e),this[bd]!=="writing"&&(this[bd]="closing",this._close(this[WE]))),e[SP]}_close(e){this.nextTick(e)}[WE](){this[bd]="closed",this.db.detachResource(this);let e=this[Yw];this[Yw]=[];for(let r of e)r()}};oue.AbstractChainedBatch=ij});var aue=W(sue=>{"use strict";h();var{AbstractChainedBatch:$Ke}=oj(),NKe=_u(),Zw=Symbol("encoded"),sj=class extends $Ke{constructor(e){super(e),this[Zw]=[]}_put(e,r,n){this[Zw].push({...n,type:"put",key:e,value:r})}_del(e,r){this[Zw].push({...r,type:"del",key:e})}_clear(){this[Zw]=[]}_write(e,r){this.db.status==="opening"?this.db.defer(()=>this._write(e,r)):this.db.status==="open"?this[Zw].length===0?this.nextTick(r):this.db._batch(this[Zw],e,r):this.nextTick(r,new NKe("Batch is not open: cannot call write() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"}))}};sue.DefaultChainedBatch=sj});var uue=W((g6t,due)=>{"use strict";h();var cue=_u(),jKe=Object.prototype.hasOwnProperty,UKe=new Set(["lt","lte","gt","gte"]);due.exports=function(t,e){let r={};for(let n in t)if(jKe.call(t,n)&&!(n==="keyEncoding"||n==="valueEncoding")){if(n==="start"||n==="end")throw new cue(`The legacy range option '${n}' has been removed`,{code:"LEVEL_LEGACY"});if(n==="encoding")throw new cue("The levelup-style 'encoding' alias has been removed, use 'valueEncoding' instead",{code:"LEVEL_LEGACY"});UKe.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 aj=W((v6t,fue)=>{h();var lue;fue.exports=typeof queueMicrotask=="function"?queueMicrotask.bind(typeof window<"u"?window:globalThis):t=>(lue||(lue=Promise.resolve())).then(t).catch(e=>setTimeout(()=>{throw e},0))});var mue=W((_6t,pue)=>{"use strict";h();var hue=aj();pue.exports=function(t,...e){e.length===0?hue(t):hue(()=>t(...e))}});var yue=W(AP=>{"use strict";h();var{AbstractIterator:KKe,AbstractKeyIterator:qKe,AbstractValueIterator:LKe}=Im(),Xw=Symbol("unfix"),xu=Symbol("iterator"),mg=Symbol("handleOne"),km=Symbol("handleMany"),lh=Symbol("callback"),HE=class extends KKe{constructor(e,r,n,i){super(e,r),this[xu]=n,this[Xw]=i,this[mg]=this[mg].bind(this),this[km]=this[km].bind(this),this[lh]=null}[mg](e,r,n){let i=this[lh];if(e)return i(e);r!==void 0&&(r=this[Xw](r)),i(e,r,n)}[km](e,r){let n=this[lh];if(e)return n(e);for(let i of r){let o=i[0];o!==void 0&&(i[0]=this[Xw](o))}n(e,r)}},VE=class extends qKe{constructor(e,r,n,i){super(e,r),this[xu]=n,this[Xw]=i,this[mg]=this[mg].bind(this),this[km]=this[km].bind(this),this[lh]=null}[mg](e,r){let n=this[lh];if(e)return n(e);r!==void 0&&(r=this[Xw](r)),n(e,r)}[km](e,r){let n=this[lh];if(e)return n(e);for(let i=0;i{"use strict";h();var cj=_u(),{Buffer:lj}=Un()||{},{AbstractSublevelIterator:FKe,AbstractSublevelKeyIterator:zKe,AbstractSublevelValueIterator:GKe}=yue(),fh=Symbol("prefix"),gue=Symbol("upperBound"),YE=Symbol("prefixRange"),vc=Symbol("parent"),dj=Symbol("unfix"),bue=new TextEncoder,WKe={separator:"!"};vue.exports=function({AbstractLevel:t}){class e extends t{static defaults(n){if(typeof n=="string")throw new cj("The subleveldown string shorthand for { separator } has been removed",{code:"LEVEL_LEGACY"});if(n&&n.open)throw new cj("The subleveldown open option has been removed",{code:"LEVEL_LEGACY"});return n==null?WKe:n.separator?n:{...n,separator:"!"}}constructor(n,i,o){let{separator:s,manifest:a,...d}=e.defaults(o);i=VKe(i,s);let u=s.charCodeAt(0)+1,c=n[vc]||n;if(!bue.encode(i).every(p=>p>u&&p<127))throw new cj(`Prefix must use bytes > ${u} < 127`,{code:"LEVEL_INVALID_PREFIX"});super(HKe(c,a),d);let l=(n.prefix||"")+s+i+s,m=l.slice(0,-1)+String.fromCharCode(u);this[vc]=c,this[fh]=new PP(l),this[gue]=new PP(m),this[dj]=new fj,this.nextTick=c.nextTick}prefixKey(n,i){if(i==="utf8")return this[fh].utf8+n;if(n.byteLength===0)return this[fh][i];if(i==="view"){let o=this[fh].view,s=new Uint8Array(o.byteLength+n.byteLength);return s.set(o,0),s.set(n,o.byteLength),s}else{let o=this[fh].buffer;return lj.concat([o,n],o.byteLength+n.byteLength)}}[YE](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[fh][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[gue][i]}get prefix(){return this[fh].utf8}get db(){return this[vc]}_open(n,i){this[vc].open({passive:!0},i)}_put(n,i,o,s){this[vc].put(n,i,o,s)}_get(n,i,o){this[vc].get(n,i,o)}_getMany(n,i,o){this[vc].getMany(n,i,o)}_del(n,i,o){this[vc].del(n,i,o)}_batch(n,i,o){this[vc].batch(n,i,o)}_clear(n,i){this[YE](n,n.keyEncoding),this[vc].clear(n,i)}_iterator(n){this[YE](n,n.keyEncoding);let i=this[vc].iterator(n),o=this[dj].get(this[fh].utf8.length,n.keyEncoding);return new FKe(this,n,i,o)}_keys(n){this[YE](n,n.keyEncoding);let i=this[vc].keys(n),o=this[dj].get(this[fh].utf8.length,n.keyEncoding);return new zKe(this,n,i,o)}_values(n){this[YE](n,n.keyEncoding);let i=this[vc].values(n);return new GKe(this,n,i)}}return{AbstractSublevel:e}};var HKe=function(t,e){return{...t.supports,createIfMissing:!1,errorIfExists:!1,events:{},additionalMethods:{},...e,encodings:{utf8:uj(t,"utf8"),buffer:uj(t,"buffer"),view:uj(t,"view")}}},uj=function(t,e){return t.supports.encodings[e]?t.keyEncoding(e).name===e:!1},PP=class{constructor(e){this.utf8=e,this.view=bue.encode(e),this.buffer=lj?lj.from(this.view.buffer,0,this.view.byteLength):{}}},fj=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}},VKe=function(t,e){let r=0,n=t.length;for(;rr&&t[n-1]===e;)n--;return t.slice(r,n)}});var gj=W(yj=>{"use strict";h();var{supports:JKe}=Kde(),{Transcoder:YKe}=Yde(),{EventEmitter:ZKe}=nc(),{fromCallback:Rm}=KE(),Eu=_u(),{AbstractIterator:yg}=Im(),{DefaultKeyIterator:XKe,DefaultValueIterator:QKe}=rue(),{DeferredIterator:eqe,DeferredKeyIterator:tqe,DeferredValueIterator:rqe}=nue(),{DefaultChainedBatch:_ue}=aue(),{getCallback:gg,getOptions:Dm}=lP(),TP=uue(),pr=Symbol("promise"),hh=Symbol("landed"),bg=Symbol("resources"),hj=Symbol("closeResources"),ZE=Symbol("operations"),XE=Symbol("undefer"),IP=Symbol("deferOpen"),xue=Symbol("options"),kr=Symbol("status"),vg=Symbol("defaultOptions"),Qw=Symbol("transcoder"),kP=Symbol("keyEncoding"),pj=Symbol("valueEncoding"),nqe=()=>{},QE=class extends ZKe{constructor(e,r){if(super(),typeof e!="object"||e===null)throw new TypeError("The first argument 'manifest' must be an object");r=Dm(r);let{keyEncoding:n,valueEncoding:i,passive:o,...s}=r;this[bg]=new Set,this[ZE]=[],this[IP]=!0,this[xue]=s,this[kr]="opening",this.supports=JKe(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[Qw]=new YKe(iqe(this)),this[kP]=this[Qw].encoding(n||"utf8"),this[pj]=this[Qw].encoding(i||"utf8");for(let a of this[Qw].encodings())this.supports.encodings[a.commonName]||(this.supports.encodings[a.commonName]=!0);this[vg]={empty:Object.freeze({}),entry:Object.freeze({keyEncoding:this[kP].commonName,valueEncoding:this[pj].commonName}),key:Object.freeze({keyEncoding:this[kP].commonName})},this.nextTick(()=>{this[IP]&&this.open({passive:!1},nqe)})}get status(){return this[kr]}keyEncoding(e){return this[Qw].encoding(e??this[kP])}valueEncoding(e){return this[Qw].encoding(e??this[pj])}open(e,r){r=gg(e,r),r=Rm(r,pr),e={...this[xue],...Dm(e)},e.createIfMissing=e.createIfMissing!==!1,e.errorIfExists=!!e.errorIfExists;let n=i=>{this[kr]==="closing"||this[kr]==="opening"?this.once(hh,i?()=>n(i):n):this[kr]!=="open"?r(new Eu("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN",cause:i})):r()};return e.passive?this[kr]==="opening"?this.once(hh,n):this.nextTick(n):this[kr]==="closed"||this[IP]?(this[IP]=!1,this[kr]="opening",this.emit("opening"),this._open(e,i=>{if(i){this[kr]="closed",this[hj](()=>{this.emit(hh),n(i)}),this[XE]();return}this[kr]="open",this[XE](),this.emit(hh),this[kr]==="open"&&this.emit("open"),this[kr]==="open"&&this.emit("ready"),n()})):this[kr]==="open"?this.nextTick(n):this.once(hh,()=>this.open(e,r)),r[pr]}_open(e,r){this.nextTick(r)}close(e){e=Rm(e,pr);let r=n=>{this[kr]==="opening"||this[kr]==="closing"?this.once(hh,n?r(n):r):this[kr]!=="closed"?e(new Eu("Database is not closed",{code:"LEVEL_DATABASE_NOT_CLOSED",cause:n})):e()};if(this[kr]==="open"){this[kr]="closing",this.emit("closing");let n=i=>{this[kr]="open",this[XE](),this.emit(hh),r(i)};this[hj](()=>{this._close(i=>{if(i)return n(i);this[kr]="closed",this[XE](),this.emit(hh),this[kr]==="closed"&&this.emit("closed"),r()})})}else this[kr]==="closed"?this.nextTick(r):this.once(hh,()=>this.close(e));return e[pr]}[hj](e){if(this[bg].size===0)return this.nextTick(e);let r=this[bg].size,n=!0,i=()=>{--r===0&&(n?this.nextTick(e):e())};for(let o of this[bg])o.close(i);n=!1,this[bg].clear()}_close(e){this.nextTick(e)}get(e,r,n){if(n=gg(r,n),n=Rm(n,pr),r=Dm(r,this[vg].entry),this[kr]==="opening")return this.defer(()=>this.get(e,r,n)),n[pr];if(e1(this,n))return n[pr];let i=this._checkKey(e);if(i)return this.nextTick(n,i),n[pr];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 Eu("Could not decode value",{code:"LEVEL_DECODE_ERROR",cause:l}))}n(null,c)}),n[pr]}_get(e,r,n){this.nextTick(n,new Error("NotFound"))}getMany(e,r,n){if(n=gg(r,n),n=Rm(n,pr),r=Dm(r,this[vg].entry),this[kr]==="opening")return this.defer(()=>this.getMany(e,r,n)),n[pr];if(e1(this,n))return n[pr];if(!Array.isArray(e))return this.nextTick(n,new TypeError("The first argument 'keys' must be an array")),n[pr];if(e.length===0)return this.nextTick(n,null,[]),n[pr];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[pr];if(e1(this,i))return i[pr];let o=this._checkKey(e)||this._checkValue(r);if(o)return this.nextTick(i,o),i[pr];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,m=>{if(m)return i(m);this.emit("put",e,r),i()}),i[pr]}_put(e,r,n,i){this.nextTick(i)}del(e,r,n){if(n=gg(r,n),n=Rm(n,pr),r=Dm(r,this[vg].key),this[kr]==="opening")return this.defer(()=>this.del(e,r,n)),n[pr];if(e1(this,n))return n[pr];let i=this._checkKey(e);if(i)return this.nextTick(n,i),n[pr];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[pr]}_del(e,r,n){this.nextTick(n)}batch(e,r,n){if(!arguments.length){if(this[kr]==="opening")return new _ue(this);if(this[kr]!=="open")throw new Eu("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"});return this._chainedBatch()}if(typeof e=="function"?n=e:n=gg(r,n),n=Rm(n,pr),r=Dm(r,this[vg].empty),this[kr]==="opening")return this.defer(()=>this.batch(e,r,n)),n[pr];if(e1(this,n))return n[pr];if(!Array.isArray(e))return this.nextTick(n,new TypeError("The first argument 'operations' must be an array")),n[pr];if(e.length===0)return this.nextTick(n),n[pr];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[pr]}_batch(e,r,n){this.nextTick(n)}sublevel(e,r){return this._sublevel(e,mj.defaults(r))}_sublevel(e,r){return new mj(this,e,r)}prefixKey(e,r){return e}clear(e,r){if(r=gg(e,r),r=Rm(r,pr),e=Dm(e,this[vg].empty),this[kr]==="opening")return this.defer(()=>this.clear(e,r)),r[pr];if(e1(this,r))return r[pr];let n=e,i=this.keyEncoding(e.keyEncoding);return e=TP(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[pr]}_clear(e,r){this.nextTick(r)}iterator(e){let r=this.keyEncoding(e&&e.keyEncoding),n=this.valueEncoding(e&&e.valueEncoding);if(e=TP(e,r),e.keys=e.keys!==!1,e.values=e.values!==!1,e[yg.keyEncoding]=r,e[yg.valueEncoding]=n,e.keyEncoding=r.format,e.valueEncoding=n.format,this[kr]==="opening")return new eqe(this,e);if(this[kr]!=="open")throw new Eu("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"});return this._iterator(e)}_iterator(e){return new yg(this,e)}keys(e){let r=this.keyEncoding(e&&e.keyEncoding),n=this.valueEncoding(e&&e.valueEncoding);if(e=TP(e,r),e[yg.keyEncoding]=r,e[yg.valueEncoding]=n,e.keyEncoding=r.format,e.valueEncoding=n.format,this[kr]==="opening")return new tqe(this,e);if(this[kr]!=="open")throw new Eu("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"});return this._keys(e)}_keys(e){return new XKe(this,e)}values(e){let r=this.keyEncoding(e&&e.keyEncoding),n=this.valueEncoding(e&&e.valueEncoding);if(e=TP(e,r),e[yg.keyEncoding]=r,e[yg.valueEncoding]=n,e.keyEncoding=r.format,e.valueEncoding=n.format,this[kr]==="opening")return new rqe(this,e);if(this[kr]!=="open")throw new Eu("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"});return this._values(e)}_values(e){return new QKe(this,e)}defer(e){if(typeof e!="function")throw new TypeError("The first argument must be a function");this[ZE].push(e)}[XE](){if(this[ZE].length===0)return;let e=this[ZE];this[ZE]=[];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[bg].add(e)}detachResource(e){this[bg].delete(e)}_chainedBatch(){return new _ue(this)}_checkKey(e){if(e==null)return new Eu("Key cannot be null or undefined",{code:"LEVEL_INVALID_KEY"})}_checkValue(e){if(e==null)return new Eu("Value cannot be null or undefined",{code:"LEVEL_INVALID_VALUE"})}};QE.prototype.nextTick=mue();var{AbstractSublevel:mj}=wue()({AbstractLevel:QE});yj.AbstractLevel=QE;yj.AbstractSublevel=mj;var e1=function(t,e){return t[kr]!=="open"?(t.nextTick(e,new Eu("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"})),!0):!1},iqe=function(t){return Object.keys(t.supports.encodings).filter(e=>!!t.supports.encodings[e])}});var bj=W(wg=>{"use strict";h();wg.AbstractLevel=gj().AbstractLevel;wg.AbstractSublevel=gj().AbstractSublevel;wg.AbstractIterator=Im().AbstractIterator;wg.AbstractKeyIterator=Im().AbstractKeyIterator;wg.AbstractValueIterator=Im().AbstractValueIterator;wg.AbstractChainedBatch=oj().AbstractChainedBatch});var Sue=W((D6t,Eue)=>{h();Eue.exports=sqe;var oqe=aj();function sqe(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(m){function p(){r&&r(m,n),r=null}d?oqe(p):p()}function l(m,p,g){if(n[m]=g,p&&(a=!0),--o===0||p)c(p);else if(!a&&u{"use strict";h();Aue.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 wj=W((O6t,Pue)=>{"use strict";h();var aqe=new TextEncoder;Pue.exports=function(t){return t instanceof Uint8Array?t:t instanceof ArrayBuffer?new Uint8Array(t):aqe.encode(t)}});var Due=W(Rue=>{"use strict";h();var{AbstractIterator:cqe}=bj(),Tue=vj(),RP=wj(),jl=Symbol("cache"),ph=Symbol("finished"),wc=Symbol("options"),mh=Symbol("currentOptions"),_g=Symbol("position"),_j=Symbol("location"),t1=Symbol("first"),Iue={},xj=class extends cqe{constructor(e,r,n){super(e,n),this[jl]=[],this[ph]=this.limit===0,this[wc]=n,this[mh]={...n},this[_g]=void 0,this[_j]=r,this[t1]=!0}_nextv(e,r,n){if(this[t1]=!1,this[ph])return this.nextTick(n,null,[]);if(this[jl].length>0)return e=Math.min(e,this[jl].length),this.nextTick(n,null,this[jl].splice(0,e));this[_g]!==void 0&&(this[wc].reverse?(this[mh].lt=this[_g],this[mh].lte=void 0):(this[mh].gt=this[_g],this[mh].gte=void 0));let i;try{i=Tue(this[mh])}catch{return this[ph]=!0,this.nextTick(n,null,[])}let o=this.db.db.transaction([this[_j]],"readonly"),s=o.objectStore(this[_j]),a=[];if(this[wc].reverse){let d=!this[wc].values&&s.openKeyCursor?"openKeyCursor":"openCursor";s[d](i,"prev").onsuccess=u=>{let c=u.target.result;if(c){let{key:l,value:m}=c;this[_g]=l,a.push([this[wc].keys&&l!==void 0?RP(l):void 0,this[wc].values&&m!==void 0?RP(m):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[ph]=!0:this[_g]=d[l-1],a.length=l;for(let m=0;m{d=l.target.result,c()}:(d=[],this.nextTick(c)),this[wc].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[jl].length>0){let[r,n]=this[jl].shift();this.nextTick(e,null,r,n)}else if(this[ph])this.nextTick(e);else{let r=Math.min(100,this.limit-this.count);this[t1]&&(this[t1]=!1,r=1),this._nextv(r,Iue,(n,i)=>{if(n)return e(n);this[jl]=i,this._next(e)})}}_all(e,r){this[t1]=!1;let n=this[jl].splice(0,this[jl].length),i=this.limit-this.count-n.length;if(i<=0)return this.nextTick(r,null,n);this._nextv(i,Iue,(o,s)=>{if(o)return r(o);n.length>0&&(s=n.concat(s)),r(null,s)})}_seek(e,r){this[t1]=!0,this[jl]=[],this[ph]=!1,this[_g]=void 0,this[mh]={...this[wc]};let n;try{n=Tue(this[wc])}catch{this[ph]=!0;return}n!==null&&!n.includes(e)?this[ph]=!0:this[wc].reverse?this[mh].lte=e:this[mh].gte=e}};Rue.Iterator=xj;function kue(t){typeof t.commit=="function"&&t.commit()}});var Bue=W((U6t,Mue)=>{"use strict";h();Mue.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 m=l.target.result;m&&(a.delete(m.key).onsuccess=function(){(i.limit<=0||++d{"use strict";h();var{AbstractLevel:dqe}=bj(),Cue=_u(),uqe=Sue(),{fromCallback:lqe}=KE(),{Iterator:fqe}=Due(),Oue=wj(),hqe=Bue(),pqe=vj(),Nue="level-js-",e6=Symbol("idb"),Ej=Symbol("namePrefix"),yh=Symbol("location"),Sj=Symbol("version"),xg=Symbol("store"),t6=Symbol("onComplete"),$ue=Symbol("promise"),DP=class extends dqe{constructor(e,r,n){if(typeof r=="function"||typeof n=="function")throw new Cue("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[yh]=e,this[Ej]=i??Nue,this[Sj]=parseInt(o||1,10),this[e6]=null}get location(){return this[yh]}get namePrefix(){return this[Ej]}get version(){return this[Sj]}get db(){return this[e6]}get type(){return"browser-level"}_open(e,r){let n=indexedDB.open(this[Ej]+this[yh],this[Sj]);n.onerror=function(){r(n.error||new Error("unknown error"))},n.onsuccess=()=>{this[e6]=n.result,r()},n.onupgradeneeded=i=>{let o=i.target.result;o.objectStoreNames.contains(this[yh])||o.createObjectStore(this[yh])}}[xg](e){return this[e6].transaction([this[yh]],e).objectStore(this[yh])}[t6](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[xg]("readonly"),o;try{o=i.get(e)}catch(s){return this.nextTick(n,s)}this[t6](o,function(s,a){if(s)return n(s);if(a===void 0)return n(new Cue("Entry not found",{code:"LEVEL_NOT_FOUND"}));n(null,Oue(a))})}_getMany(e,r,n){let i=this[xg]("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:Oue(u))},d.onerror=u=>{u.stopPropagation(),a(d.error)}});uqe(o,16,n)}_del(e,r,n){let i=this[xg]("readwrite"),o;try{o=i.delete(e)}catch(s){return this.nextTick(n,s)}this[t6](o,n)}_put(e,r,n,i){let o=this[xg]("readwrite"),s;try{s=o.put(r,e)}catch(a){return this.nextTick(i,a)}this[t6](s,i)}_iterator(e){return new fqe(this,this[yh],e)}_batch(e,r,n){let i=this[xg]("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(m){a=m,o.abort();return}s=0)return hqe(this,this[yh],n,e,r);try{let o=this[xg]("readwrite");i=n?o.delete(n):o.clear()}catch(o){return this.nextTick(r,o)}this[t6](i,r)}_close(e){this[e6].close(),this.nextTick(e)}};DP.destroy=function(t,e,r){typeof e=="function"&&(r=e,e=Nue),r=lqe(r,$ue);let n=indexedDB.deleteDatabase(e+t);return n.onsuccess=function(){r()},n.onerror=function(i){r(i)},r[$ue]};jue.BrowserLevel=DP});var r6=W(Uue=>{h();Uue.Level=Aj().BrowserLevel});var Ui=W((Y6t,que)=>{"use strict";h();que.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 Ul=W((X6t,Tj)=>{"use strict";h();var yqe=Un(),gqe=Object.getPrototypeOf(async function(){}).constructor,Lue=globalThis.Blob||yqe.Blob,bqe=typeof Lue<"u"?function(e){return e instanceof Lue}:function(e){return!1},Pj=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 gqe},isArrayBufferView(t){return ArrayBuffer.isView(t)}},isBlob:bqe};Tj.exports.promisify.custom=Symbol.for("nodejs.util.promisify.custom")});var aa=W((eSt,Gue)=>{"use strict";h();var{format:vqe,inspect:CP,AggregateError:wqe}=Ul(),_qe=globalThis.AggregateError||wqe,xqe=Symbol("kIsNodeError"),Eqe=["string","function","number","object","Function","Object","boolean","bigint","symbol"],Sqe=/^([A-Z][a-z0-9]*)+$/,Aqe="__node_internal_",OP={};function Eg(t,e){if(!t)throw new OP.ERR_INTERNAL_ASSERTION(e)}function Fue(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 Pqe(t,e,r){if(typeof e=="function")return Eg(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 Eg(n===r.length,`Code: ${t}; The provided arguments length (${r.length}) does not match the required ones (${n}).`),r.length===0?e:vqe(e,...r)}function is(t,e,r){r||(r=Error);class n extends r{constructor(...o){super(Pqe(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[xqe]=!0,OP[t]=n}function zue(t){let e=Aqe+t.name;return Object.defineProperty(t,"name",{value:e}),t}function Tqe(t,e){if(t&&e&&t!==e){if(Array.isArray(e.errors))return e.errors.push(t),e;let r=new _qe([e,t],e.message);return r.code=e.code,r}return t||e}var Ij=class extends Error{constructor(e="The operation was aborted",r=void 0){if(r!==void 0&&typeof r!="object")throw new OP.ERR_INVALID_ARG_TYPE("options","Object",r);super(e,r),this.code="ABORT_ERR",this.name="AbortError"}};is("ERR_ASSERTION","%s",Error);is("ERR_INVALID_ARG_TYPE",(t,e,r)=>{Eg(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)Eg(typeof d=="string","All expected entries have to be of type string"),Eqe.includes(d)?i.push(d.toLowerCase()):Sqe.test(d)?o.push(d):(Eg(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=CP(r,{depth:-1});n+=`. Received ${d}`}}else{let d=CP(r,{colors:!1});d.length>25&&(d=`${d.slice(0,25)}...`),n+=`. Received type ${typeof r} (${d})`}return n},TypeError);is("ERR_INVALID_ARG_VALUE",(t,e,r="is invalid")=>{let n=CP(e);return n.length>128&&(n=n.slice(0,128)+"..."),`The ${t.includes(".")?"property":"argument"} '${t}' ${r}. Received ${n}`},TypeError);is("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);is("ERR_MISSING_ARGS",(...t)=>{Eg(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);is("ERR_OUT_OF_RANGE",(t,e,r)=>{Eg(e,'Missing "range" argument');let n;return Number.isInteger(r)&&Math.abs(r)>2**32?n=Fue(String(r)):typeof r=="bigint"?(n=String(r),(r>2n**32n||r<-(2n**32n))&&(n=Fue(n)),n+="n"):n=CP(r),`The value of "${t}" is out of range. It must be ${e}. Received ${n}`},RangeError);is("ERR_MULTIPLE_CALLBACK","Callback called multiple times",Error);is("ERR_METHOD_NOT_IMPLEMENTED","The %s method is not implemented",Error);is("ERR_STREAM_ALREADY_FINISHED","Cannot call %s after a stream was finished",Error);is("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable",Error);is("ERR_STREAM_DESTROYED","Cannot call %s after a stream was destroyed",Error);is("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError);is("ERR_STREAM_PREMATURE_CLOSE","Premature close",Error);is("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF",Error);is("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event",Error);is("ERR_STREAM_WRITE_AFTER_END","write after end",Error);is("ERR_UNKNOWN_ENCODING","Unknown encoding: %s",TypeError);Gue.exports={AbortError:Ij,aggregateTwoErrors:zue(Tqe),hideStackFrames:zue,codes:OP}});var o6=W((rSt,ele)=>{"use strict";h();var{ArrayIsArray:Rj,ArrayPrototypeIncludes:Jue,ArrayPrototypeJoin:Yue,ArrayPrototypeMap:Iqe,NumberIsInteger:Dj,NumberIsNaN:kqe,NumberMAX_SAFE_INTEGER:Rqe,NumberMIN_SAFE_INTEGER:Dqe,NumberParseInt:Mqe,ObjectPrototypeHasOwnProperty:Bqe,RegExpPrototypeExec:Zue,String:Cqe,StringPrototypeToUpperCase:Oqe,StringPrototypeTrim:$qe}=Ui(),{hideStackFrames:wd,codes:{ERR_SOCKET_BAD_PORT:Nqe,ERR_INVALID_ARG_TYPE:ca,ERR_INVALID_ARG_VALUE:r1,ERR_OUT_OF_RANGE:Sg,ERR_UNKNOWN_SIGNAL:Wue}}=aa(),{normalizeEncoding:jqe}=Ul(),{isAsyncFunction:Uqe,isArrayBufferView:Kqe}=Ul().types,Hue={};function qqe(t){return t===(t|0)}function Lqe(t){return t===t>>>0}var Fqe=/^[0-7]+$/,zqe="must be a 32-bit unsigned integer or an octal string";function Gqe(t,e,r){if(typeof t>"u"&&(t=r),typeof t=="string"){if(Zue(Fqe,t)===null)throw new r1(e,t,zqe);t=Mqe(t,8)}return Xue(t,e),t}var Wqe=wd((t,e,r=Dqe,n=Rqe)=>{if(typeof t!="number")throw new ca(e,"number",t);if(!Dj(t))throw new Sg(e,"an integer",t);if(tn)throw new Sg(e,`>= ${r} && <= ${n}`,t)}),Hqe=wd((t,e,r=-2147483648,n=2147483647)=>{if(typeof t!="number")throw new ca(e,"number",t);if(!Dj(t))throw new Sg(e,"an integer",t);if(tn)throw new Sg(e,`>= ${r} && <= ${n}`,t)}),Xue=wd((t,e,r=!1)=>{if(typeof t!="number")throw new ca(e,"number",t);if(!Dj(t))throw new Sg(e,"an integer",t);let n=r?1:0,i=4294967295;if(ti)throw new Sg(e,`>= ${n} && <= ${i}`,t)});function Mj(t,e){if(typeof t!="string")throw new ca(e,"string",t)}function Vqe(t,e,r=void 0,n){if(typeof t!="number")throw new ca(e,"number",t);if(r!=null&&tn||(r!=null||n!=null)&&kqe(t))throw new Sg(e,`${r!=null?`>= ${r}`:""}${r!=null&&n!=null?" && ":""}${n!=null?`<= ${n}`:""}`,t)}var Jqe=wd((t,e,r)=>{if(!Jue(r,t)){let i="must be one of: "+Yue(Iqe(r,o=>typeof o=="string"?`'${o}'`:Cqe(o)),", ");throw new r1(e,t,i)}});function Que(t,e){if(typeof t!="boolean")throw new ca(e,"boolean",t)}function kj(t,e,r){return t==null||!Bqe(t,e)?r:t[e]}var Yqe=wd((t,e,r=null)=>{let n=kj(r,"allowArray",!1),i=kj(r,"allowFunction",!1);if(!kj(r,"nullable",!1)&&t===null||!n&&Rj(t)||typeof t!="object"&&(!i||typeof t!="function"))throw new ca(e,"Object",t)}),Zqe=wd((t,e)=>{if(t!=null&&typeof t!="object"&&typeof t!="function")throw new ca(e,"a dictionary",t)}),Bj=wd((t,e,r=0)=>{if(!Rj(t))throw new ca(e,"Array",t);if(t.length{if(!Kqe(t))throw new ca(e,["Buffer","TypedArray","DataView"],t)});function rLe(t,e){let r=jqe(e),n=t.length;if(r==="hex"&&n%2!==0)throw new r1("encoding",e,`is invalid for data of length ${n}`)}function nLe(t,e="Port",r=!0){if(typeof t!="number"&&typeof t!="string"||typeof t=="string"&&$qe(t).length===0||+t!==+t>>>0||t>65535||t===0&&!r)throw new Nqe(e,t,r);return t|0}var iLe=wd((t,e)=>{if(t!==void 0&&(t===null||typeof t!="object"||!("aborted"in t)))throw new ca(e,"AbortSignal",t)}),oLe=wd((t,e)=>{if(typeof t!="function")throw new ca(e,"Function",t)}),sLe=wd((t,e)=>{if(typeof t!="function"||Uqe(t))throw new ca(e,"Function",t)}),aLe=wd((t,e)=>{if(t!==void 0)throw new ca(e,"undefined",t)});function cLe(t,e,r){if(!Jue(r,t))throw new ca(e,`('${Yue(r,"|")}')`,t)}var dLe=/^(?:<[^>]*>)(?:\s*;\s*[^;"\s]+(?:=(")?[^;"\s]*\1)?)*$/;function Vue(t,e){if(typeof t>"u"||!Zue(dLe,t))throw new r1(e,t,'must be an array or string of format "; rel=preload; as=style"')}function uLe(t){if(typeof t=="string")return Vue(t,"hints"),t;if(Rj(t)){let e=t.length,r="";if(e===0)return r;for(let n=0;n; rel=preload; as=style"')}ele.exports={isInt32:qqe,isUint32:Lqe,parseFileMode:Gqe,validateArray:Bj,validateStringArray:Xqe,validateBooleanArray:Qqe,validateBoolean:Que,validateBuffer:tLe,validateDictionary:Zqe,validateEncoding:rLe,validateFunction:oLe,validateInt32:Hqe,validateInteger:Wqe,validateNumber:Vqe,validateObject:Yqe,validateOneOf:Jqe,validatePlainFunction:sLe,validatePort:nLe,validateSignalName:eLe,validateString:Mj,validateUint32:Xue,validateUndefined:aLe,validateUnion:cLe,validateAbortSignal:iLe,validateLinkHeaderValue:uLe}});var ql=W((iSt,yle)=>{"use strict";h();var{Symbol:$P,SymbolAsyncIterator:tle,SymbolIterator:rle,SymbolFor:nle}=Ui(),ile=$P("kDestroyed"),ole=$P("kIsErrored"),Cj=$P("kIsReadable"),sle=$P("kIsDisturbed"),lLe=nle("nodejs.webstream.isClosedPromise"),fLe=nle("nodejs.webstream.controllerErrorFunction");function NP(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 jP(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 hLe(t){return!!(t&&typeof t.pipe=="function"&&t._readableState&&typeof t.on=="function"&&typeof t.write=="function")}function Kl(t){return t&&(t._readableState||t._writableState||typeof t.write=="function"&&typeof t.on=="function"||typeof t.pipe=="function"&&typeof t.on=="function")}function ale(t){return!!(t&&!Kl(t)&&typeof t.pipeThrough=="function"&&typeof t.getReader=="function"&&typeof t.cancel=="function")}function cle(t){return!!(t&&!Kl(t)&&typeof t.getWriter=="function"&&typeof t.abort=="function")}function dle(t){return!!(t&&!Kl(t)&&typeof t.readable=="object"&&typeof t.writable=="object")}function pLe(t){return ale(t)||cle(t)||dle(t)}function mLe(t,e){return t==null?!1:e===!0?typeof t[tle]=="function":e===!1?typeof t[rle]=="function":typeof t[tle]=="function"||typeof t[rle]=="function"}function UP(t){if(!Kl(t))return null;let e=t._writableState,r=t._readableState,n=e||r;return!!(t.destroyed||t[ile]||n!=null&&n.destroyed)}function ule(t){if(!jP(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 yLe(t,e){if(!jP(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 gLe(t){if(!NP(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 lle(t,e){if(!NP(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 fle(t){return t&&t[Cj]!=null?t[Cj]:typeof t?.readable!="boolean"?null:UP(t)?!1:NP(t)&&t.readable&&!lle(t)}function hle(t){return typeof t?.writable!="boolean"?null:UP(t)?!1:jP(t)&&t.writable&&!ule(t)}function bLe(t,e){return Kl(t)?UP(t)?!0:!(e?.readable!==!1&&fle(t)||e?.writable!==!1&&hle(t)):null}function vLe(t){var e,r;return Kl(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 wLe(t){var e,r;return Kl(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 _Le(t){if(!Kl(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"&&ple(t)?t._closed:null}function ple(t){return typeof t._closed=="boolean"&&typeof t._defaultKeepAlive=="boolean"&&typeof t._removedConnection=="boolean"&&typeof t._removedContLen=="boolean"}function mle(t){return typeof t._sent100=="boolean"&&ple(t)}function xLe(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 ELe(t){if(!Kl(t))return null;let e=t._writableState,r=t._readableState,n=e||r;return!n&&mle(t)||!!(n&&n.autoDestroy&&n.emitClose&&n.closed===!1)}function SLe(t){var e;return!!(t&&((e=t[sle])!==null&&e!==void 0?e:t.readableDidRead||t.readableAborted))}function ALe(t){var e,r,n,i,o,s,a,d,u,c;return!!(t&&((e=(r=(n=(i=(o=(s=t[ole])!==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))}yle.exports={kDestroyed:ile,isDisturbed:SLe,kIsDisturbed:sle,isErrored:ALe,kIsErrored:ole,isReadable:fle,kIsReadable:Cj,kIsClosedPromise:lLe,kControllerErrorFunction:fLe,isClosed:_Le,isDestroyed:UP,isDuplexNodeStream:hLe,isFinished:bLe,isIterable:mLe,isReadableNodeStream:NP,isReadableStream:ale,isReadableEnded:gLe,isReadableFinished:lle,isReadableErrored:wLe,isNodeStream:Kl,isWebStream:pLe,isWritable:hle,isWritableNodeStream:jP,isWritableStream:cle,isWritableEnded:ule,isWritableFinished:yLe,isWritableErrored:vLe,isServerRequest:xLe,isServerResponse:mle,willEmitClose:ELe,isTransformStream:dle}});var gh=W((sSt,Uj)=>{h();var Bm=ls(),{AbortError:Ale,codes:PLe}=aa(),{ERR_INVALID_ARG_TYPE:TLe,ERR_STREAM_PREMATURE_CLOSE:gle}=PLe,{kEmptyObject:$j,once:Nj}=Ul(),{validateAbortSignal:ILe,validateFunction:kLe,validateObject:RLe,validateBoolean:DLe}=o6(),{Promise:MLe,PromisePrototypeThen:BLe}=Ui(),{isClosed:CLe,isReadable:ble,isReadableNodeStream:Oj,isReadableStream:OLe,isReadableFinished:vle,isReadableErrored:wle,isWritable:_le,isWritableNodeStream:xle,isWritableStream:$Le,isWritableFinished:Ele,isWritableErrored:Sle,isNodeStream:NLe,willEmitClose:jLe,kIsClosedPromise:ULe}=ql();function KLe(t){return t.setHeader&&typeof t.abort=="function"}var jj=()=>{};function Ple(t,e,r){var n,i;if(arguments.length===2?(r=e,e=$j):e==null?e=$j:RLe(e,"options"),kLe(r,"callback"),ILe(e.signal,"options.signal"),r=Nj(r),OLe(t)||$Le(t))return qLe(t,e,r);if(!NLe(t))throw new TLe("stream",["ReadableStream","WritableStream","Stream"],t);let o=(n=e.readable)!==null&&n!==void 0?n:Oj(t),s=(i=e.writable)!==null&&i!==void 0?i:xle(t),a=t._writableState,d=t._readableState,u=()=>{t.writable||m()},c=jLe(t)&&Oj(t)===o&&xle(t)===s,l=Ele(t,!1),m=()=>{l=!0,t.destroyed&&(c=!1),!(c&&(!t.readable||o))&&(!o||p)&&r.call(t)},p=vle(t,!1),g=()=>{p=!0,t.destroyed&&(c=!1),!(c&&(!t.writable||s))&&(!s||l)&&r.call(t)},b=N=>{r.call(t,N)},S=CLe(t),A=()=>{S=!0;let N=Sle(t)||wle(t);if(N&&typeof N!="boolean")return r.call(t,N);if(o&&!p&&Oj(t,!0)&&!vle(t,!1))return r.call(t,new gle);if(s&&!l&&!Ele(t,!1))return r.call(t,new gle);r.call(t)},I=()=>{S=!0;let N=Sle(t)||wle(t);if(N&&typeof N!="boolean")return r.call(t,N);r.call(t)},P=()=>{t.req.on("finish",m)};KLe(t)?(t.on("complete",m),c||t.on("abort",A),t.req?P():t.on("request",P)):s&&!a&&(t.on("end",u),t.on("close",u)),!c&&typeof t.aborted=="boolean"&&t.on("aborted",A),t.on("end",g),t.on("finish",m),e.error!==!1&&t.on("error",b),t.on("close",A),S?Bm.nextTick(A):a!=null&&a.errorEmitted||d!=null&&d.errorEmitted?c||Bm.nextTick(I):(!o&&(!c||ble(t))&&(l||_le(t)===!1)||!s&&(!c||_le(t))&&(p||ble(t)===!1)||d&&t.req&&t.aborted)&&Bm.nextTick(I);let $=()=>{r=jj,t.removeListener("aborted",A),t.removeListener("complete",m),t.removeListener("abort",A),t.removeListener("request",P),t.req&&t.req.removeListener("finish",m),t.removeListener("end",u),t.removeListener("close",u),t.removeListener("finish",m),t.removeListener("end",g),t.removeListener("error",b),t.removeListener("close",A)};if(e.signal&&!S){let N=()=>{let L=r;$(),L.call(t,new Ale(void 0,{cause:e.signal.reason}))};if(e.signal.aborted)Bm.nextTick(N);else{let L=r;r=Nj((...F)=>{e.signal.removeEventListener("abort",N),L.apply(t,F)}),e.signal.addEventListener("abort",N)}}return $}function qLe(t,e,r){let n=!1,i=jj;if(e.signal)if(i=()=>{n=!0,r.call(t,new Ale(void 0,{cause:e.signal.reason}))},e.signal.aborted)Bm.nextTick(i);else{let s=r;r=Nj((...a)=>{e.signal.removeEventListener("abort",i),s.apply(t,a)}),e.signal.addEventListener("abort",i)}let o=(...s)=>{n||Bm.nextTick(()=>r.apply(t,s))};return BLe(t[ULe].promise,o,o),jj}function LLe(t,e){var r;let n=!1;return e===null&&(e=$j),(r=e)!==null&&r!==void 0&&r.cleanup&&(DLe(e.cleanup,"cleanup"),n=e.cleanup),new MLe((i,o)=>{let s=Ple(t,e,a=>{n&&s(),a?o(a):i()})})}Uj.exports=Ple;Uj.exports.finished=LLe});var Ag=W((cSt,Cle)=>{"use strict";h();var Ll=ls(),{aggregateTwoErrors:FLe,codes:{ERR_MULTIPLE_CALLBACK:zLe},AbortError:GLe}=aa(),{Symbol:kle}=Ui(),{kDestroyed:WLe,isDestroyed:HLe,isFinished:VLe,isServerRequest:JLe}=ql(),Rle=kle("kDestroy"),Kj=kle("kConstruct");function Dle(t,e,r){t&&(t.stack,e&&!e.errored&&(e.errored=t),r&&!r.errored&&(r.errored=t))}function YLe(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):(Dle(t,n,r),n&&(n.destroyed=!0),r&&(r.destroyed=!0),i.constructed?Tle(this,t,e):this.once(Rle,function(o){Tle(this,FLe(o,t),e)}),this)}function Tle(t,e,r){let n=!1;function i(o){if(n)return;n=!0;let s=t._readableState,a=t._writableState;Dle(o,a,s),a&&(a.closed=!0),s&&(s.closed=!0),typeof r=="function"&&r(o),o?Ll.nextTick(ZLe,t,o):Ll.nextTick(Mle,t)}try{t._destroy(e||null,i)}catch(o){i(o)}}function ZLe(t,e){qj(t,e),Mle(t)}function Mle(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 qj(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 XLe(){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 Lj(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?Ll.nextTick(qj,t,e):qj(t,e))}function QLe(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(Kj,e),!(t.listenerCount(Kj)>1)&&Ll.nextTick(eFe,t)}function eFe(t){let e=!1;function r(n){if(e){Lj(t,n??new zLe);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(Rle,n):n?Lj(t,n,!0):Ll.nextTick(tFe,t)}try{t._construct(n=>{Ll.nextTick(r,n)})}catch(n){Ll.nextTick(r,n)}}function tFe(t){t.emit(Kj)}function Ile(t){return t?.setHeader&&typeof t.abort=="function"}function Ble(t){t.emit("close")}function rFe(t,e){t.emit("error",e),Ll.nextTick(Ble,t)}function nFe(t,e){!t||HLe(t)||(!e&&!VLe(t)&&(e=new GLe),JLe(t)?(t.socket=null,t.destroy(e)):Ile(t)?t.abort():Ile(t.req)?t.req.abort():typeof t.destroy=="function"?t.destroy(e):typeof t.close=="function"?t.close():e?Ll.nextTick(rFe,t,e):Ll.nextTick(Ble,t),t.destroyed||(t[WLe]=!0))}Cle.exports={construct:QLe,destroyer:nFe,destroy:YLe,undestroy:XLe,errorOrDestroy:Lj}});var LP=W((uSt,$le)=>{"use strict";h();var{ArrayIsArray:iFe,ObjectSetPrototypeOf:Ole}=Ui(),{EventEmitter:KP}=nc();function qP(t){KP.call(this,t)}Ole(qP.prototype,KP.prototype);Ole(qP,KP);qP.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(),KP.listenerCount(this,"error")===0&&this.emit("error",c)}Fj(r,"error",d),Fj(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 Fj(t,e,r){if(typeof t.prependListener=="function")return t.prependListener(e,r);!t._events||!t._events[e]?t.on(e,r):iFe(t._events[e])?t._events[e].unshift(r):t._events[e]=[r,t._events[e]]}$le.exports={Stream:qP,prependListener:Fj}});var s6=W((fSt,FP)=>{"use strict";h();var{AbortError:Nle,codes:oFe}=aa(),{isNodeStream:jle,isWebStream:sFe,kControllerErrorFunction:aFe}=ql(),cFe=gh(),{ERR_INVALID_ARG_TYPE:Ule}=oFe,dFe=(t,e)=>{if(typeof t!="object"||!("aborted"in t))throw new Ule(e,"AbortSignal",t)};FP.exports.addAbortSignal=function(e,r){if(dFe(e,"signal"),!jle(r)&&!sFe(r))throw new Ule("stream",["ReadableStream","WritableStream","Stream"],r);return FP.exports.addAbortSignalNoValidate(e,r)};FP.exports.addAbortSignalNoValidate=function(t,e){if(typeof t!="object"||!("aborted"in t))return e;let r=jle(e)?()=>{e.destroy(new Nle(void 0,{cause:t.reason}))}:()=>{e[aFe](new Nle(void 0,{cause:t.reason}))};return t.aborted?r():(t.addEventListener("abort",r),cFe(e,()=>t.removeEventListener("abort",r))),e}});var Lle=W((mSt,qle)=>{"use strict";h();var{StringPrototypeSlice:Kle,SymbolIterator:uFe,TypedArrayPrototypeSet:zP,Uint8Array:lFe}=Ui(),{Buffer:zj}=Un(),{inspect:fFe}=Ul();qle.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 zj.alloc(0);let r=zj.allocUnsafe(e>>>0),n=this.head,i=0;for(;n;)zP(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+=Kle(o,0,e),this.head=n,n.data=Kle(o,e));break}++i}while((n=n.next)!==null);return this.length-=i,r}_getBuffer(e){let r=zj.allocUnsafe(e),n=e,i=this.head,o=0;do{let s=i.data;if(e>s.length)zP(r,s,n-e),e-=s.length;else{e===s.length?(zP(r,s,n-e),++o,i.next?this.head=i.next:this.head=this.tail=null):(zP(r,new lFe(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 fFe(this,{...r,depth:0,customInspect:!1})}}});var GP=W((gSt,zle)=>{"use strict";h();var{MathFloor:hFe,NumberIsInteger:pFe}=Ui(),{ERR_INVALID_ARG_VALUE:mFe}=aa().codes;function yFe(t,e,r){return t.highWaterMark!=null?t.highWaterMark:e?t[r]:null}function Fle(t){return t?16:16*1024}function gFe(t,e,r,n){let i=yFe(e,n,r);if(i!=null){if(!pFe(i)||i<0){let o=n?`options.${r}`:"options.highWaterMark";throw new mFe(o,i)}return hFe(i)}return Fle(t.objectMode)}zle.exports={getHighWaterMark:gFe,getDefaultHighWaterMark:Fle}});var Gj=W((vSt,Vle)=>{"use strict";h();var Gle=ls(),{PromisePrototypeThen:bFe,SymbolAsyncIterator:Wle,SymbolIterator:Hle}=Ui(),{Buffer:vFe}=Un(),{ERR_INVALID_ARG_TYPE:wFe,ERR_STREAM_NULL_VALUES:_Fe}=aa().codes;function xFe(t,e,r){let n;if(typeof e=="string"||e instanceof vFe)return new t({objectMode:!0,...r,read(){this.push(e),this.push(null)}});let i;if(e&&e[Wle])i=!0,n=e[Wle]();else if(e&&e[Hle])i=!1,n=e[Hle]();else throw new wFe("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){bFe(a(u),()=>Gle.nextTick(c,u),l=>Gle.nextTick(c,l||u))};async function a(u){let c=u!=null,l=typeof n.throw=="function";if(c&&l){let{value:m,done:p}=await n.throw(u);if(await m,p)return}if(typeof n.return=="function"){let{value:m}=await n.return();await m}}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 _Fe;if(o.push(l))continue;s=!1}}catch(u){o.destroy(u)}break}}return o}Vle.exports=xFe});var a6=W((_St,afe)=>{h();var Su=ls(),{ArrayPrototypeIndexOf:EFe,NumberIsInteger:SFe,NumberIsNaN:AFe,NumberParseInt:PFe,ObjectDefineProperties:Zle,ObjectKeys:TFe,ObjectSetPrototypeOf:Xle,Promise:IFe,SafeSet:kFe,SymbolAsyncIterator:RFe,Symbol:DFe}=Ui();afe.exports=vr;vr.ReadableState=Zj;var{EventEmitter:MFe}=nc(),{Stream:Cm,prependListener:BFe}=LP(),{Buffer:Wj}=Un(),{addAbortSignal:CFe}=s6(),OFe=gh(),Mr=Ul().debuglog("stream",t=>{Mr=t}),$Fe=Lle(),i1=Ag(),{getHighWaterMark:NFe,getDefaultHighWaterMark:jFe}=GP(),{aggregateTwoErrors:Jle,codes:{ERR_INVALID_ARG_TYPE:UFe,ERR_METHOD_NOT_IMPLEMENTED:KFe,ERR_OUT_OF_RANGE:qFe,ERR_STREAM_PUSH_AFTER_EOF:LFe,ERR_STREAM_UNSHIFT_AFTER_END_EVENT:FFe}}=aa(),{validateObject:zFe}=o6(),Pg=DFe("kPaused"),{StringDecoder:Qle}=av(),GFe=Gj();Xle(vr.prototype,Cm.prototype);Xle(vr,Cm);var Hj=()=>{},{errorOrDestroy:n1}=i1;function Zj(t,e,r){typeof r!="boolean"&&(r=e instanceof Fl()),this.objectMode=!!(t&&t.objectMode),r&&(this.objectMode=this.objectMode||!!(t&&t.readableObjectMode)),this.highWaterMark=t?NFe(this,t,"readableHighWaterMark",r):jFe(!1),this.buffer=new $Fe,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[Pg]=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 Qle(t.encoding),this.encoding=t.encoding)}function vr(t){if(!(this instanceof vr))return new vr(t);let e=this instanceof Fl();this._readableState=new Zj(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&&CFe(t.signal,this)),Cm.call(this,t),i1.construct(this,()=>{this._readableState.needReadable&&WP(this,this._readableState)})}vr.prototype.destroy=i1.destroy;vr.prototype._undestroy=i1.undestroy;vr.prototype._destroy=function(t,e){e(t)};vr.prototype[MFe.captureRejectionSymbol]=function(t){this.destroy(t)};vr.prototype.push=function(t,e){return efe(this,t,e,!1)};vr.prototype.unshift=function(t,e){return efe(this,t,e,!0)};function efe(t,e,r,n){Mr("readableAddChunk",e);let i=t._readableState,o;if(i.objectMode||(typeof e=="string"?(r=r||i.defaultEncoding,i.encoding!==r&&(n&&i.encoding?e=Wj.from(e,r).toString(i.encoding):(e=Wj.from(e,r),r=""))):e instanceof Wj?r="":Cm._isUint8Array(e)?(e=Cm._uint8ArrayToBuffer(e),r=""):e!=null&&(o=new UFe("chunk",["string","Buffer","Uint8Array"],e))),o)n1(t,o);else if(e===null)i.reading=!1,VFe(t,i);else if(i.objectMode||e&&e.length>0)if(n)if(i.endEmitted)n1(t,new FFe);else{if(i.destroyed||i.errored)return!1;Vj(t,i,e,!0)}else if(i.ended)n1(t,new LFe);else{if(i.destroyed||i.errored)return!1;i.reading=!1,i.decoder&&!r?(e=i.decoder.write(e),i.objectMode||e.length!==0?Vj(t,i,e,!1):WP(t,i)):Vj(t,i,e,!1)}else n||(i.reading=!1,WP(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&&HP(t)),WP(t,e)}vr.prototype.isPaused=function(){let t=this._readableState;return t[Pg]===!0||t.flowing===!1};vr.prototype.setEncoding=function(t){let e=new Qle(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 WFe=1073741824;function HFe(t){if(t>WFe)throw new qFe("size","<= 1GiB",t);return t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++,t}function Yle(t,e){return t<=0||e.length===0&&e.ended?0:e.objectMode?1:AFe(t)?e.flowing&&e.length?e.buffer.first().length:e.length:t<=e.length?t:e.ended?e.length:0}vr.prototype.read=function(t){Mr("read",t),t===void 0?t=NaN:SFe(t)||(t=PFe(t,10));let e=this._readableState,r=t;if(t>e.highWaterMark&&(e.highWaterMark=HFe(t)),t!==0&&(e.emittedReadable=!1),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?Jj(this):HP(this),null;if(t=Yle(t,e),t===0&&e.ended)return e.length===0&&Jj(this),null;let n=e.needReadable;if(Mr("need readable",n),(e.length===0||e.length-t0?i=ofe(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&&Jj(this)),i!==null&&!e.errorEmitted&&!e.closeEmitted&&(e.dataEmitted=!0,this.emit("data",i)),i};function VFe(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?HP(t):(e.needReadable=!1,e.emittedReadable=!0,tfe(t))}}function HP(t){let e=t._readableState;Mr("emitReadable",e.needReadable,e.emittedReadable),e.needReadable=!1,e.emittedReadable||(Mr("emitReadable",e.flowing),e.emittedReadable=!0,Su.nextTick(tfe,t))}function tfe(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,nfe(t)}function WP(t,e){!e.readingMore&&e.constructed&&(e.readingMore=!0,Su.nextTick(JFe,t,e))}function JFe(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=YFe(r,t),t.on("drain",d))}r.on("data",m);function m(A){Mr("ondata");let I=t.write(A);Mr("dest.write",I),I===!1&&l()}function p(A){if(Mr("onerror",A),S(),t.removeListener("error",p),t.listenerCount("error")===0){let I=t._writableState||t._readableState;I&&!I.errorEmitted?n1(t,A):t.emit("error",A)}}BFe(t,"error",p);function g(){t.removeListener("finish",b),S()}t.once("close",g);function b(){Mr("onfinish"),t.removeListener("close",g),S()}t.once("finish",b);function S(){Mr("unpipe"),r.unpipe(t)}return t.emit("pipe",r),t.writableNeedDrain===!0?n.flowing&&l():n.flowing||(Mr("pipe resume"),r.resume()),t};function YFe(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()}}vr.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?HP(this):n.reading||Su.nextTick(ZFe,this)),r};vr.prototype.addListener=vr.prototype.on;vr.prototype.removeListener=function(t,e){let r=Cm.prototype.removeListener.call(this,t,e);return t==="readable"&&Su.nextTick(rfe,this),r};vr.prototype.off=vr.prototype.removeListener;vr.prototype.removeAllListeners=function(t){let e=Cm.prototype.removeAllListeners.apply(this,arguments);return(t==="readable"||t===void 0)&&Su.nextTick(rfe,this),e};function rfe(t){let e=t._readableState;e.readableListening=t.listenerCount("readable")>0,e.resumeScheduled&&e[Pg]===!1?e.flowing=!0:t.listenerCount("data")>0?t.resume():e.readableListening||(e.flowing=null)}function ZFe(t){Mr("readable nexttick read 0"),t.read(0)}vr.prototype.resume=function(){let t=this._readableState;return t.flowing||(Mr("resume"),t.flowing=!t.readableListening,XFe(this,t)),t[Pg]=!1,this};function XFe(t,e){e.resumeScheduled||(e.resumeScheduled=!0,Su.nextTick(QFe,t,e))}function QFe(t,e){Mr("resume",e.reading),e.reading||t.read(0),e.resumeScheduled=!1,t.emit("resume"),nfe(t),e.flowing&&!e.reading&&t.read(0)}vr.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[Pg]=!0,this};function nfe(t){let e=t._readableState;for(Mr("flow",e.flowing);e.flowing&&t.read()!==null;);}vr.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=>{n1(this,n)}),t.on("close",()=>{this.destroy()}),t.on("destroy",()=>{this.destroy()}),this._read=()=>{e&&t.resume&&(e=!1,t.resume())};let r=TFe(t);for(let n=1;n{i=s?Jle(i,s):null,r(),r=Hj});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 IFe(n)}}}catch(s){throw i=Jle(i,s),i}finally{(i||e?.destroyOnReturn!==!1)&&(i===void 0||t._readableState.autoDestroy)?i1.destroyer(t,null):(t.off("readable",n),o())}}Zle(vr.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}}});Zle(Zj.prototype,{pipesCount:{__proto__:null,get(){return this.pipes.length}},paused:{__proto__:null,get(){return this[Pg]!==!1},set(t){this[Pg]=!!t}}});vr._fromList=ofe;function ofe(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 Jj(t){let e=t._readableState;Mr("endReadable",e.endEmitted),e.endEmitted||(e.ended=!0,Su.nextTick(tze,e,t))}function tze(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)Su.nextTick(rze,e);else if(t.autoDestroy){let r=e._writableState;(!r||r.autoDestroy&&(r.finished||r.writable===!1))&&e.destroy()}}}function rze(t){t.writable&&!t.writableEnded&&!t.destroyed&&t.end()}vr.from=function(t,e){return GFe(vr,t,e)};var Yj;function sfe(){return Yj===void 0&&(Yj={}),Yj}vr.fromWeb=function(t,e){return sfe().newStreamReadableFromReadableStream(t,e)};vr.toWeb=function(t,e){return sfe().newReadableStreamFromStreamReadable(t,e)};vr.wrap=function(t,e){var r,n;return new vr({objectMode:(r=(n=t.readableObjectMode)!==null&&n!==void 0?n:t.objectMode)!==null&&r!==void 0?r:!0,...e,destroy(i,o){i1.destroyer(t,i),o(i)}}).wrap(t)}});var iU=W((ESt,vfe)=>{h();var Tg=ls(),{ArrayPrototypeSlice:ufe,Error:nze,FunctionPrototypeSymbolHasInstance:lfe,ObjectDefineProperty:ffe,ObjectDefineProperties:ize,ObjectSetPrototypeOf:hfe,StringPrototypeToLowerCase:oze,Symbol:sze,SymbolHasInstance:aze}=Ui();vfe.exports=Qn;Qn.WritableState=u6;var{EventEmitter:cze}=nc(),c6=LP().Stream,{Buffer:VP}=Un(),ZP=Ag(),{addAbortSignal:dze}=s6(),{getHighWaterMark:uze,getDefaultHighWaterMark:lze}=GP(),{ERR_INVALID_ARG_TYPE:fze,ERR_METHOD_NOT_IMPLEMENTED:hze,ERR_MULTIPLE_CALLBACK:pfe,ERR_STREAM_CANNOT_PIPE:pze,ERR_STREAM_DESTROYED:d6,ERR_STREAM_ALREADY_FINISHED:mze,ERR_STREAM_NULL_VALUES:yze,ERR_STREAM_WRITE_AFTER_END:gze,ERR_UNKNOWN_ENCODING:mfe}=aa().codes,{errorOrDestroy:o1}=ZP;hfe(Qn.prototype,c6.prototype);hfe(Qn,c6);function eU(){}var s1=sze("kOnFinished");function u6(t,e,r){typeof r!="boolean"&&(r=e instanceof Fl()),this.objectMode=!!(t&&t.objectMode),r&&(this.objectMode=this.objectMode||!!(t&&t.writableObjectMode)),this.highWaterMark=t?uze(this,t,"writableHighWaterMark",r):lze(!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=vze.bind(void 0,e),this.writecb=null,this.writelen=0,this.afterWriteTickInfo=null,YP(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[s1]=[]}function YP(t){t.buffered=[],t.bufferedIndex=0,t.allBuffers=!0,t.allNoop=!0}u6.prototype.getBuffer=function(){return ufe(this.buffered,this.bufferedIndex)};ffe(u6.prototype,"bufferedRequestCount",{__proto__:null,get(){return this.buffered.length-this.bufferedIndex}});function Qn(t){let e=this instanceof Fl();if(!e&&!lfe(Qn,this))return new Qn(t);this._writableState=new u6(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&&dze(t.signal,this)),c6.call(this,t),ZP.construct(this,()=>{let r=this._writableState;r.writing||rU(this,r),nU(this,r)})}ffe(Qn,aze,{__proto__:null,value:function(t){return lfe(this,t)?!0:this!==Qn?!1:t&&t._writableState instanceof u6}});Qn.prototype.pipe=function(){o1(this,new pze)};function yfe(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"&&!VP.isEncoding(r))throw new mfe(r);typeof n!="function"&&(n=eU)}if(e===null)throw new yze;if(!i.objectMode)if(typeof e=="string")i.decodeStrings!==!1&&(e=VP.from(e,r),r="buffer");else if(e instanceof VP)r="buffer";else if(c6._isUint8Array(e))e=c6._uint8ArrayToBuffer(e),r="buffer";else throw new fze("chunk",["string","Buffer","Uint8Array"],e);let o;return i.ending?o=new gze:i.destroyed&&(o=new d6("write")),o?(Tg.nextTick(n,o),o1(t,o,!0),o):(i.pendingcb++,bze(t,i,e,r,n))}Qn.prototype.write=function(t,e,r){return yfe(this,t,e,r)===!0};Qn.prototype.cork=function(){this._writableState.corked++};Qn.prototype.uncork=function(){let t=this._writableState;t.corked&&(t.corked--,t.writing||rU(this,t))};Qn.prototype.setDefaultEncoding=function(e){if(typeof e=="string"&&(e=oze(e)),!VP.isEncoding(e))throw new mfe(e);return this._writableState.defaultEncoding=e,this};function bze(t,e,r,n,i){let o=e.objectMode?1:r.length;e.length+=o;let s=e.lengthr.bufferedIndex&&rU(t,r),n?r.afterWriteTickInfo!==null&&r.afterWriteTickInfo.cb===i?r.afterWriteTickInfo.count++:(r.afterWriteTickInfo={count:1,cb:i,stream:t,state:r},Tg.nextTick(wze,r.afterWriteTickInfo)):gfe(t,r,1,i))}function wze({stream:t,state:e,count:r,cb:n}){return e.afterWriteTickInfo=null,gfe(t,e,r,n)}function gfe(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&&tU(e),nU(t,e)}function tU(t){if(t.writing)return;for(let i=t.bufferedIndex;i1&&t._writev){e.pendingcb-=o-1;let a=e.allNoop?eU:u=>{for(let c=s;c256?(r.splice(0,s),e.bufferedIndex=0):e.bufferedIndex=s}e.bufferProcessing=!1}Qn.prototype._write=function(t,e,r){if(this._writev)this._writev([{chunk:t,encoding:e}],r);else throw new hze("_write()")};Qn.prototype._writev=null;Qn.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=yfe(this,t,e);o instanceof nze&&(i=o)}return n.corked&&(n.corked=1,this.uncork()),i||(!n.errored&&!n.ending?(n.ending=!0,nU(this,n,!0),n.ended=!0):n.finished?i=new mze("end"):n.destroyed&&(i=new d6("end"))),typeof r=="function"&&(i||n.finished?Tg.nextTick(r,i):n[s1].push(r)),this};function JP(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 _ze(t,e){let r=!1;function n(i){if(r){o1(t,i??pfe());return}if(r=!0,e.pendingcb--,i){let o=e[s1].splice(0);for(let s=0;s{JP(i)?Qj(n,i):i.pendingcb--},t,e)):JP(e)&&(e.pendingcb++,Qj(t,e))))}function Qj(t,e){e.pendingcb--,e.finished=!0;let r=e[s1].splice(0);for(let n=0;n{h();var oU=ls(),Sze=Un(),{isReadable:Aze,isWritable:Pze,isIterable:wfe,isNodeStream:Tze,isReadableNodeStream:_fe,isWritableNodeStream:xfe,isDuplexNodeStream:Ize}=ql(),Efe=gh(),{AbortError:kfe,codes:{ERR_INVALID_ARG_TYPE:kze,ERR_INVALID_RETURN_VALUE:Sfe}}=aa(),{destroyer:a1}=Ag(),Rze=Fl(),Dze=a6(),{createDeferredPromise:Afe}=Ul(),Pfe=Gj(),Tfe=globalThis.Blob||Sze.Blob,Mze=typeof Tfe<"u"?function(e){return e instanceof Tfe}:function(e){return!1},Bze=globalThis.AbortController||Lf().AbortController,{FunctionPrototypeCall:Ife}=Ui(),Ig=class extends Rze{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)}};Rfe.exports=function t(e,r){if(Ize(e))return e;if(_fe(e))return XP({readable:e});if(xfe(e))return XP({writable:e});if(Tze(e))return XP({writable:!1,readable:!1});if(typeof e=="function"){let{value:i,write:o,final:s,destroy:a}=Cze(e);if(wfe(i))return Pfe(Ig,i,{objectMode:!0,write:o,final:s,destroy:a});let d=i?.then;if(typeof d=="function"){let u,c=Ife(d,i,l=>{if(l!=null)throw new Sfe("nully","body",l)},l=>{a1(u,l)});return u=new Ig({objectMode:!0,readable:!1,write:o,final(l){s(async()=>{try{await c,oU.nextTick(l,null)}catch(m){oU.nextTick(l,m)}})},destroy:a})}throw new Sfe("Iterable, AsyncIterable or AsyncFunction",r,i)}if(Mze(e))return t(e.arrayBuffer());if(wfe(e))return Pfe(Ig,e,{objectMode:!0,writable:!1});if(typeof e?.writable=="object"||typeof e?.readable=="object"){let i=e!=null&&e.readable?_fe(e?.readable)?e?.readable:t(e.readable):void 0,o=e!=null&&e.writable?xfe(e?.writable)?e?.writable:t(e.writable):void 0;return XP({readable:i,writable:o})}let n=e?.then;if(typeof n=="function"){let i;return Ife(n,e,o=>{o!=null&&i.push(o),i.push(null)},o=>{a1(i,o)}),i=new Ig({objectMode:!0,writable:!1,read(){}})}throw new kze(r,["Blob","ReadableStream","WritableStream","Stream","Iterable","AsyncIterable","Function","{ readable, writable } pair","Promise"],e)};function Cze(t){let{promise:e,resolve:r}=Afe(),n=new Bze,i=n.signal;return{value:t(async function*(){for(;;){let s=e;e=null;let{chunk:a,done:d,cb:u}=await s;if(oU.nextTick(u),d)return;if(i.aborted)throw new kfe(void 0,{cause:i.reason});({promise:e,resolve:r}=Afe()),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 XP(t){let e=t.readable&&typeof t.readable.read!="function"?Dze.wrap(t.readable):t.readable,r=t.writable,n=!!Aze(e),i=!!Pze(r),o,s,a,d,u;function c(l){let m=d;d=null,m?m(l):l&&u.destroy(l)}return u=new Ig({readableObjectMode:!!(e!=null&&e.readableObjectMode),writableObjectMode:!!(r!=null&&r.writableObjectMode),readable:n,writable:i}),i&&(Efe(r,l=>{i=!1,l&&a1(e,l),c(l)}),u._write=function(l,m,p){r.write(l,m)?p():o=p},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&&(Efe(e,l=>{n=!1,l&&a1(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,m){!l&&d!==null&&(l=new kfe),a=null,o=null,s=null,d===null?m(l):(d=m,a1(r,l),a1(e,l))},u}});var Fl=W((TSt,Cfe)=>{"use strict";h();var{ObjectDefineProperties:Oze,ObjectGetOwnPropertyDescriptor:bh,ObjectKeys:$ze,ObjectSetPrototypeOf:Mfe}=Ui();Cfe.exports=Au;var cU=a6(),_d=iU();Mfe(Au.prototype,cU.prototype);Mfe(Au,cU);{let t=$ze(_d.prototype);for(let e=0;e{"use strict";h();var{ObjectSetPrototypeOf:Ofe,Symbol:Nze}=Ui();$fe.exports=vh;var{ERR_METHOD_NOT_IMPLEMENTED:jze}=aa().codes,uU=Fl(),{getHighWaterMark:Uze}=GP();Ofe(vh.prototype,uU.prototype);Ofe(vh,uU);var l6=Nze("kCallback");function vh(t){if(!(this instanceof vh))return new vh(t);let e=t?Uze(this,t,"readableHighWaterMark",!0):null;e===0&&(t={...t,highWaterMark:null,readableHighWaterMark:e,writableHighWaterMark:t.writableHighWaterMark||0}),uU.call(this,t),this._readableState.sync=!1,this[l6]=null,t&&(typeof t.transform=="function"&&(this._transform=t.transform),typeof t.flush=="function"&&(this._flush=t.flush)),this.on("prefinish",Kze)}function dU(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 Kze(){this._final!==dU&&dU.call(this)}vh.prototype._final=dU;vh.prototype._transform=function(t,e,r){throw new jze("_transform()")};vh.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";h();var{ObjectSetPrototypeOf:Nfe}=Ui();jfe.exports=c1;var fU=lU();Nfe(c1.prototype,fU.prototype);Nfe(c1,fU);function c1(t){if(!(this instanceof c1))return new c1(t);fU.call(this,t)}c1.prototype._transform=function(t,e,r){r(null,t)}});var rT=W((BSt,Ffe)=>{h();var f6=ls(),{ArrayIsArray:qze,Promise:Lze,SymbolAsyncIterator:Fze}=Ui(),tT=gh(),{once:zze}=Ul(),Gze=Ag(),Ufe=Fl(),{aggregateTwoErrors:Wze,codes:{ERR_INVALID_ARG_TYPE:_U,ERR_INVALID_RETURN_VALUE:pU,ERR_MISSING_ARGS:Hze,ERR_STREAM_DESTROYED:Vze,ERR_STREAM_PREMATURE_CLOSE:Jze},AbortError:Yze}=aa(),{validateFunction:Zze,validateAbortSignal:Xze}=o6(),{isIterable:kg,isReadable:mU,isReadableNodeStream:eT,isNodeStream:Kfe,isTransformStream:d1,isWebStream:Qze,isReadableStream:yU,isReadableEnded:eGe}=ql(),tGe=globalThis.AbortController||Lf().AbortController,gU,bU;function qfe(t,e,r){let n=!1;t.on("close",()=>{n=!0});let i=tT(t,{readable:e,writable:r},o=>{n=!o});return{destroy:o=>{n||(n=!0,Gze.destroyer(t,o||new Vze("pipe")))},cleanup:i}}function rGe(t){return Zze(t[t.length-1],"streams[stream.length - 1]"),t.pop()}function vU(t){if(kg(t))return t;if(eT(t))return nGe(t);throw new _U("val",["Readable","Iterable","AsyncIterable"],t)}async function*nGe(t){bU||(bU=a6()),yield*bU.prototype[Fze].call(t)}async function QP(t,e,r,{end:n}){let i,o=null,s=u=>{if(u&&(i=u),o){let c=o;o=null,c()}},a=()=>new Lze((u,c)=>{i?c(i):o=()=>{i?c(i):u()}});e.on("drain",s);let d=tT(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?Wze(i,u):u)}finally{d(),e.off("drain",s)}}async function wU(t,e,r,{end:n}){d1(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 iGe(...t){return Lfe(t,zze(rGe(t)))}function Lfe(t,e,r){if(t.length===1&&qze(t[0])&&(t=t[0]),t.length<2)throw new Hze("streams");let n=new tGe,i=n.signal,o=r?.signal,s=[];Xze(o,"options.signal");function a(){p(new Yze)}o?.addEventListener("abort",a);let d,u,c=[],l=0;function m(I){p(I,--l===0)}function p(I,P){if(I&&(!d||d.code==="ERR_STREAM_PREMATURE_CLOSE")&&(d=I),!(!d&&!P)){for(;c.length;)c.shift()(d);o?.removeEventListener("abort",a),n.abort(),P&&(d||s.forEach($=>$()),f6.nextTick(e,d,u))}}let g;for(let I=0;I0,L=$||r?.end!==!1,F=I===t.length-1;if(Kfe(P)){let U=function(G){G&&G.name!=="AbortError"&&G.code!=="ERR_STREAM_PREMATURE_CLOSE"&&m(G)};var A=U;if(L){let{destroy:G,cleanup:q}=qfe(P,$,N);c.push(G),mU(P)&&F&&s.push(q)}P.on("error",U),mU(P)&&F&&s.push(()=>{P.removeListener("error",U)})}if(I===0)if(typeof P=="function"){if(g=P({signal:i}),!kg(g))throw new pU("Iterable, AsyncIterable or Stream","source",g)}else kg(P)||eT(P)||d1(P)?g=P:g=Ufe.from(P);else if(typeof P=="function"){if(d1(g)){var b;g=vU((b=g)===null||b===void 0?void 0:b.readable)}else g=vU(g);if(g=P(g,{signal:i}),$){if(!kg(g,!0))throw new pU("AsyncIterable",`transform[${I-1}]`,g)}else{var S;gU||(gU=hU());let U=new gU({objectMode:!0}),G=(S=g)===null||S===void 0?void 0:S.then;if(typeof G=="function")l++,G.call(g,E=>{u=E,E!=null&&U.write(E),L&&U.end(),f6.nextTick(m)},E=>{U.destroy(E),f6.nextTick(m,E)});else if(kg(g,!0))l++,QP(g,U,m,{end:L});else if(yU(g)||d1(g)){let E=g.readable||g;l++,QP(E,U,m,{end:L})}else throw new pU("AsyncIterable or Promise","destination",g);g=U;let{destroy:q,cleanup:T}=qfe(g,!1,!0);c.push(q),F&&s.push(T)}}else if(Kfe(P)){if(eT(g)){l+=2;let U=oGe(g,P,m,{end:L});mU(P)&&F&&s.push(U)}else if(d1(g)||yU(g)){let U=g.readable||g;l++,QP(U,P,m,{end:L})}else if(kg(g))l++,QP(g,P,m,{end:L});else throw new _U("val",["Readable","Iterable","AsyncIterable","ReadableStream","TransformStream"],g);g=P}else if(Qze(P)){if(eT(g))l++,wU(vU(g),P,m,{end:L});else if(yU(g)||kg(g))l++,wU(g,P,m,{end:L});else if(d1(g))l++,wU(g.readable,P,m,{end:L});else throw new _U("val",["Readable","Iterable","AsyncIterable","ReadableStream","TransformStream"],g);g=P}else g=Ufe.from(P)}return(i!=null&&i.aborted||o!=null&&o.aborted)&&f6.nextTick(a),g}function oGe(t,e,r,{end:n}){let i=!1;if(e.on("close",()=>{i||r(new Jze)}),t.pipe(e,{end:!1}),n){let s=function(){i=!0,e.end()};var o=s;eGe(t)?f6.nextTick(s):t.once("end",s)}else r();return tT(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)}),tT(e,{readable:!1,writable:!0},r)}Ffe.exports={pipelineImpl:Lfe,pipeline:iGe}});var EU=W((OSt,Jfe)=>{"use strict";h();var{pipeline:sGe}=rT(),nT=Fl(),{destroyer:aGe}=Ag(),{isNodeStream:iT,isReadable:zfe,isWritable:Gfe,isWebStream:xU,isTransformStream:Rg,isWritableStream:Wfe,isReadableStream:Hfe}=ql(),{AbortError:cGe,codes:{ERR_INVALID_ARG_VALUE:Vfe,ERR_MISSING_ARGS:dGe}}=aa(),uGe=gh();Jfe.exports=function(...e){if(e.length===0)throw new dGe("streams");if(e.length===1)return nT.from(e[0]);let r=[...e];if(typeof e[0]=="function"&&(e[0]=nT.from(e[0])),typeof e[e.length-1]=="function"){let p=e.length-1;e[p]=nT.from(e[p])}for(let p=0;p0&&!(Gfe(e[p])||Wfe(e[p])||Rg(e[p])))throw new Vfe(`streams[${p}]`,r[p],"must be writable")}let n,i,o,s,a;function d(p){let g=s;s=null,g?g(p):p?a.destroy(p):!m&&!l&&a.destroy()}let u=e[0],c=sGe(e,d),l=!!(Gfe(u)||Wfe(u)||Rg(u)),m=!!(zfe(c)||Hfe(c)||Rg(c));if(a=new nT({writableObjectMode:!!(u!=null&&u.writableObjectMode),readableObjectMode:!!(c!=null&&c.writableObjectMode),writable:l,readable:m}),l){if(iT(u))a._write=function(g,b,S){u.write(g,b)?S():n=S},a._final=function(g){u.end(),i=g},u.on("drain",function(){if(n){let g=n;n=null,g()}});else if(xU(u)){let b=(Rg(u)?u.writable:u).getWriter();a._write=async function(S,A,I){try{await b.ready,b.write(S).catch(()=>{}),I()}catch(P){I(P)}},a._final=async function(S){try{await b.ready,b.close().catch(()=>{}),i=S}catch(A){S(A)}}}let p=Rg(c)?c.readable:c;uGe(p,()=>{if(i){let g=i;i=null,g()}})}if(m){if(iT(c))c.on("readable",function(){if(o){let p=o;o=null,p()}}),c.on("end",function(){a.push(null)}),a._read=function(){for(;;){let p=c.read();if(p===null){o=a._read;return}if(!a.push(p))return}};else if(xU(c)){let g=(Rg(c)?c.readable:c).getReader();a._read=async function(){for(;;)try{let{value:b,done:S}=await g.read();if(!a.push(b))return;if(S){a.push(null);return}}catch{return}}}}return a._destroy=function(p,g){!p&&s!==null&&(p=new cGe),o=null,n=null,i=null,s===null?g(p):(s=g,iT(c)&&aGe(c,p))},a}});var nhe=W((NSt,PU)=>{"use strict";h();var Qfe=globalThis.AbortController||Lf().AbortController,{codes:{ERR_INVALID_ARG_VALUE:lGe,ERR_INVALID_ARG_TYPE:h6,ERR_MISSING_ARGS:fGe,ERR_OUT_OF_RANGE:hGe},AbortError:zl}=aa(),{validateAbortSignal:Dg,validateInteger:pGe,validateObject:Mg}=o6(),mGe=Ui().Symbol("kWeak"),{finished:yGe}=gh(),gGe=EU(),{addAbortSignalNoValidate:bGe}=s6(),{isWritable:vGe,isNodeStream:wGe}=ql(),{ArrayPrototypePush:_Ge,MathFloor:xGe,Number:EGe,NumberIsNaN:SGe,Promise:Yfe,PromiseReject:Zfe,PromisePrototypeThen:AGe,Symbol:ehe}=Ui(),oT=ehe("kEmpty"),Xfe=ehe("kEof");function PGe(t,e){if(e!=null&&Mg(e,"options"),e?.signal!=null&&Dg(e.signal,"options.signal"),wGe(t)&&!vGe(t))throw new lGe("stream",t,"must be writable");let r=gGe(this,t);return e!=null&&e.signal&&bGe(e.signal,r),r}function sT(t,e){if(typeof t!="function")throw new h6("fn",["Function","AsyncFunction"],t);e!=null&&Mg(e,"options"),e?.signal!=null&&Dg(e.signal,"options.signal");let r=1;return e?.concurrency!=null&&(r=xGe(e.concurrency)),pGe(r,"concurrency",1),(async function*(){var i,o;let s=new Qfe,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 m,p,g=!1;function b(){g=!0}async function S(){try{for await(let P of a){var A;if(g)return;if(u.aborted)throw new zl;try{P=t(P,c)}catch($){P=Zfe($)}P!==oT&&(typeof((A=P)===null||A===void 0?void 0:A.catch)=="function"&&P.catch(b),d.push(P),m&&(m(),m=null),!g&&d.length&&d.length>=r&&await new Yfe($=>{p=$}))}d.push(Xfe)}catch(P){let $=Zfe(P);AGe($,void 0,b),d.push($)}finally{var I;g=!0,m&&(m(),m=null),e==null||(I=e.signal)===null||I===void 0||I.removeEventListener("abort",l)}}S();try{for(;;){for(;d.length>0;){let A=await d[0];if(A===Xfe)return;if(u.aborted)throw new zl;A!==oT&&(yield A),d.shift(),p&&(p(),p=null)}await new Yfe(A=>{m=A})}}finally{s.abort(),g=!0,p&&(p(),p=null)}}).call(this)}function TGe(t=void 0){return t!=null&&Mg(t,"options"),t?.signal!=null&&Dg(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 zl({cause:t.signal.reason});yield[r++,i]}}).call(this)}async function the(t,e=void 0){for await(let r of AU.call(this,t,e))return!0;return!1}async function IGe(t,e=void 0){if(typeof t!="function")throw new h6("fn",["Function","AsyncFunction"],t);return!await the.call(this,async(...r)=>!await t(...r),e)}async function kGe(t,e){for await(let r of AU.call(this,t,e))return r}async function RGe(t,e){if(typeof t!="function")throw new h6("fn",["Function","AsyncFunction"],t);async function r(n,i){return await t(n,i),oT}for await(let n of sT.call(this,r,e));}function AU(t,e){if(typeof t!="function")throw new h6("fn",["Function","AsyncFunction"],t);async function r(n,i){return await t(n,i)?n:oT}return sT.call(this,r,e)}var SU=class extends fGe{constructor(){super("reduce"),this.message="Reduce of an empty stream requires an initial value"}};async function DGe(t,e,r){var n;if(typeof t!="function")throw new h6("reducer",["Function","AsyncFunction"],t);r!=null&&Mg(r,"options"),r?.signal!=null&&Dg(r.signal,"options.signal");let i=arguments.length>1;if(r!=null&&(n=r.signal)!==null&&n!==void 0&&n.aborted){let u=new zl(void 0,{cause:r.signal.reason});throw this.once("error",()=>{}),await yGe(this.destroy(u)),u}let o=new Qfe,s=o.signal;if(r!=null&&r.signal){let u={once:!0,[mGe]: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 zl;i?e=await t(e,u,{signal:s}):(e=u,i=!0)}if(!a&&!i)throw new SU}finally{o.abort()}return e}async function MGe(t){t!=null&&Mg(t,"options"),t?.signal!=null&&Dg(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 zl(void 0,{cause:t.signal.reason});_Ge(e,n)}return e}function BGe(t,e){let r=sT.call(this,t,e);return(async function*(){for await(let i of r)yield*i}).call(this)}function rhe(t){if(t=EGe(t),SGe(t))return 0;if(t<0)throw new hGe("number",">= 0",t);return t}function CGe(t,e=void 0){return e!=null&&Mg(e,"options"),e?.signal!=null&&Dg(e.signal,"options.signal"),t=rhe(t),(async function*(){var n;if(e!=null&&(n=e.signal)!==null&&n!==void 0&&n.aborted)throw new zl;for await(let o of this){var i;if(e!=null&&(i=e.signal)!==null&&i!==void 0&&i.aborted)throw new zl;t--<=0&&(yield o)}}).call(this)}function OGe(t,e=void 0){return e!=null&&Mg(e,"options"),e?.signal!=null&&Dg(e.signal,"options.signal"),t=rhe(t),(async function*(){var n;if(e!=null&&(n=e.signal)!==null&&n!==void 0&&n.aborted)throw new zl;for await(let o of this){var i;if(e!=null&&(i=e.signal)!==null&&i!==void 0&&i.aborted)throw new zl;if(t-- >0)yield o;else return}}).call(this)}PU.exports.streamReturningOperators={asIndexedPairs:TGe,drop:CGe,filter:AU,flatMap:BGe,map:sT,take:OGe,compose:PGe};PU.exports.promiseReturningOperators={every:IGe,forEach:RGe,reduce:DGe,toArray:MGe,some:the,find:kGe}});var TU=W((USt,ihe)=>{"use strict";h();var{ArrayPrototypePop:$Ge,Promise:NGe}=Ui(),{isIterable:jGe,isNodeStream:UGe,isWebStream:KGe}=ql(),{pipelineImpl:qGe}=rT(),{finished:LGe}=gh();IU();function FGe(...t){return new NGe((e,r)=>{let n,i,o=t[t.length-1];if(o&&typeof o=="object"&&!UGe(o)&&!jGe(o)&&!KGe(o)){let s=$Ge(t);n=s.signal,i=s.end}qGe(t,(s,a)=>{s?r(s):e(a)},{signal:n,end:i})})}ihe.exports={finished:LGe,pipeline:FGe}});var IU=W((qSt,hhe)=>{h();var{Buffer:zGe}=Un(),{ObjectDefineProperty:wh,ObjectKeys:ahe,ReflectApply:che}=Ui(),{promisify:{custom:dhe}}=Ul(),{streamReturningOperators:ohe,promiseReturningOperators:she}=nhe(),{codes:{ERR_ILLEGAL_CONSTRUCTOR:uhe}}=aa(),GGe=EU(),{pipeline:lhe}=rT(),{destroyer:WGe}=Ag(),fhe=gh(),kU=TU(),RU=ql(),Ii=hhe.exports=LP().Stream;Ii.isDisturbed=RU.isDisturbed;Ii.isErrored=RU.isErrored;Ii.isReadable=RU.isReadable;Ii.Readable=a6();for(let t of ahe(ohe)){let r=function(...n){if(new.target)throw uhe();return Ii.Readable.from(che(e,this,n))};DU=r;let e=ohe[t];wh(r,"name",{__proto__:null,value:e.name}),wh(r,"length",{__proto__:null,value:e.length}),wh(Ii.Readable.prototype,t,{__proto__:null,value:r,enumerable:!1,configurable:!0,writable:!0})}var DU;for(let t of ahe(she)){let r=function(...i){if(new.target)throw uhe();return che(e,this,i)};DU=r;let e=she[t];wh(r,"name",{__proto__:null,value:e.name}),wh(r,"length",{__proto__:null,value:e.length}),wh(Ii.Readable.prototype,t,{__proto__:null,value:r,enumerable:!1,configurable:!0,writable:!0})}var DU;Ii.Writable=iU();Ii.Duplex=Fl();Ii.Transform=lU();Ii.PassThrough=hU();Ii.pipeline=lhe;var{addAbortSignal:HGe}=s6();Ii.addAbortSignal=HGe;Ii.finished=fhe;Ii.destroy=WGe;Ii.compose=GGe;wh(Ii,"promises",{__proto__:null,configurable:!0,enumerable:!0,get(){return kU}});wh(lhe,dhe,{__proto__:null,enumerable:!0,get(){return kU.pipeline}});wh(fhe,dhe,{__proto__:null,enumerable:!0,get(){return kU.finished}});Ii.Stream=Ii;Ii._isUint8Array=function(e){return e instanceof Uint8Array};Ii._uint8ArrayToBuffer=function(e){return zGe.from(e.buffer,e.byteOffset,e.byteLength)}});var MU=W((FSt,ki)=>{"use strict";h();var eo=IU(),VGe=TU(),JGe=eo.Readable.destroy;ki.exports=eo.Readable;ki.exports._uint8ArrayToBuffer=eo._uint8ArrayToBuffer;ki.exports._isUint8Array=eo._isUint8Array;ki.exports.isDisturbed=eo.isDisturbed;ki.exports.isErrored=eo.isErrored;ki.exports.isReadable=eo.isReadable;ki.exports.Readable=eo.Readable;ki.exports.Writable=eo.Writable;ki.exports.Duplex=eo.Duplex;ki.exports.Transform=eo.Transform;ki.exports.PassThrough=eo.PassThrough;ki.exports.addAbortSignal=eo.addAbortSignal;ki.exports.finished=eo.finished;ki.exports.destroy=eo.destroy;ki.exports.destroy=JGe;ki.exports.pipeline=eo.pipeline;ki.exports.compose=eo.compose;Object.defineProperty(eo,"promises",{configurable:!0,enumerable:!0,get(){return VGe}});ki.exports.Stream=eo.Stream;ki.exports.default=ki.exports});var Spe=W((mPt,Epe)=>{"use strict";h();Epe.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 Lg=W((oIt,Dpe)=>{h();var P1=1e3,T1=P1*60,I1=T1*60,qg=I1*24,zHe=qg*7,GHe=qg*365.25;Dpe.exports=function(t,e){e=e||{};var r=typeof t;if(r==="string"&&t.length>0)return WHe(t);if(r==="number"&&isFinite(t))return e.long?VHe(t):HHe(t);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(t))};function WHe(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*GHe;case"weeks":case"week":case"w":return r*zHe;case"days":case"day":case"d":return r*qg;case"hours":case"hour":case"hrs":case"hr":case"h":return r*I1;case"minutes":case"minute":case"mins":case"min":case"m":return r*T1;case"seconds":case"second":case"secs":case"sec":case"s":return r*P1;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}}}function HHe(t){var e=Math.abs(t);return e>=qg?Math.round(t/qg)+"d":e>=I1?Math.round(t/I1)+"h":e>=T1?Math.round(t/T1)+"m":e>=P1?Math.round(t/P1)+"s":t+"ms"}function VHe(t){var e=Math.abs(t);return e>=qg?UT(t,e,qg,"day"):e>=I1?UT(t,e,I1,"hour"):e>=T1?UT(t,e,T1,"minute"):e>=P1?UT(t,e,P1,"second"):t+" ms"}function UT(t,e,r,n){var i=e>=r*1.5;return Math.round(t/r)+" "+n+(i?"s":"")}});var vK=W(Mpe=>{h();Mpe.Level=Aj().BrowserLevel});var fye=W((K9t,DK)=>{"use strict";h();var rJe=Object.prototype.hasOwnProperty,ha="~";function z6(){}Object.create&&(z6.prototype=Object.create(null),new z6().__proto__||(ha=!1));function nJe(t,e,r){this.fn=t,this.context=e,this.once=r||!1}function lye(t,e,r,n,i){if(typeof r!="function")throw new TypeError("The listener must be a function");var o=new nJe(r,n||t,i),s=ha?ha+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 oI(t,e){--t._eventsCount===0?t._events=new z6:delete t._events[e]}function Ns(){this._events=new z6,this._eventsCount=0}Ns.prototype.eventNames=function(){var e=[],r,n;if(this._eventsCount===0)return e;for(n in r=this._events)rJe.call(r,n)&&e.push(ha?n.slice(1):n);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(r)):e};Ns.prototype.listeners=function(e){var r=ha?ha+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";h();Object.defineProperty(BI,"__esModule",{value:!0});BI.ReadableWebToNodeStream=void 0;var $Je=J3(),tq=class extends $Je.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()}};BI.ReadableWebToNodeStream=tq});var mYe={};jr(mYe,{AgentCryptoApi:()=>Mc,AgentDidApi:()=>Y1,AgentDwnApi:()=>Z1,AgentIdentityApi:()=>Q1,AgentSyncApi:()=>yS,BearerIdentity:()=>ey,DidInterface:()=>e0e,DidRpcMethod:()=>S0e,DwnConstant:()=>wu,DwnDataStore:()=>$h,DwnDateSort:()=>xi,DwnDidStore:()=>oS,DwnEncryptionAlgorithm:()=>Gp,DwnIdentityStore:()=>pS,DwnInterface:()=>qr,DwnKeyDerivationScheme:()=>Ni,DwnKeyStore:()=>dS,HdIdentityVault:()=>X1,HttpWeb5RpcClient:()=>GI,InMemoryDataStore:()=>Nh,InMemoryDidStore:()=>ib,InMemoryIdentityStore:()=>cb,InMemoryKeyStore:()=>ab,LocalKeyManager:()=>Bc,PlatformAgentTestHarness:()=>hq,SyncEngineLevel:()=>gS,Web5RpcClient:()=>mS,WebSocketWeb5RpcClient:()=>WI,blobToIsomorphicNodeReadable:()=>CI,dwnMessageConstructors:()=>z1,getDwnServiceEndpointUrls:()=>sS,getPaginationCursor:()=>jJe,getRecordAuthor:()=>NJe,getRecordMessageCid:()=>n0e,isDidRequest:()=>eq,isDwnMessage:()=>UJe,isDwnRequest:()=>i0e,isIdentityMetadata:()=>_0e,isPortableIdentity:()=>lYe,isRecordsWrite:()=>ob,webReadableToIsomorphicNodeReadable:()=>aS});h();h();h();h();h();h();var BF=Ut(aL(),1);h();h();h();h();function Zge(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n>>0,$=new Uint8Array(P);A!==I;){for(var N=g[A],L=0,F=P-1;(N!==0||L>>0,$[F]=N%a>>>0,N=N/a>>>0;if(N!==0)throw new Error("Non-zero carry");S=L,A++}for(var U=P-S;U!==P&&$[U]===0;)U++;for(var G=d.repeat(b);U>>0,P=new Uint8Array(I);g[b];){var $=r[g.charCodeAt(b)];if($===255)return;for(var N=0,L=I-1;($!==0||N>>0,P[L]=$%256>>>0,$=$/256>>>0;if($!==0)throw new Error("Non-zero carry");A=N,b++}if(g[b]!==" "){for(var F=I-A;F!==I&&P[F]===0;)F++;for(var U=new Uint8Array(S+(I-F)),G=S;F!==I;)U[G++]=P[F++];return U}}}function p(g){var b=m(g);if(b)return b;throw new Error(`Non-${e} character`)}return{encode:l,decodeUnsafe:m,decode:p}}var Xge=Zge,Qge=Xge,cL=Qge;h();var nZe=new Uint8Array(0);var dL=(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")};h();var dk=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")}},uk=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 lL(this,e)}},lk=class{constructor(e){this.decoders=e}or(e){return lL(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`)}},lL=(t,e)=>new lk({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}}),fk=class{constructor(e,r,n,i){this.name=e,this.prefix=r,this.baseEncode=n,this.baseDecode=i,this.encoder=new dk(e,r,n),this.decoder=new uk(e,r,i)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},fL=({name:t,prefix:e,encode:r,decode:n})=>new fk(t,e,r,n),hk=({prefix:t,name:e,alphabet:r})=>{let{encode:n,decode:i}=cL(r,e);return fL({prefix:t,name:e,encode:n,decode:o=>Bd(i(o))})},ebe=(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},tbe=(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<fL({prefix:e,name:t,encode(i){return tbe(i,n,r)},decode(i){return ebe(i,n,r,t)}});var fZe=qs({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),hZe=qs({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Ls=qs({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),pZe=qs({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var pk=new TextEncoder,rbe=new TextDecoder,Ye=class t{static base64UrlToBytes(e){return Ls.baseDecode(e)}static base64UrlToObject(e){let r=Ls.baseDecode(e);return t.bytesToObject(r)}static bytesToBase64Url(e){return Ls.baseEncode(e)}static bytesToString(e){return rbe.decode(e)}static bytesToObject(e){let r=t.bytesToString(e);return JSON.parse(r)}static objectToBytes(e){let r=JSON.stringify(e);return pk.encode(r)}static stringToBase64Url(e){let r=pk.encode(e);return Ls.baseEncode(r)}static stringToBytes(e){return pk.encode(e)}};h();h();h();h();var Bo=2n**255n-19n,gb=2n**252n+27742317777372353535851937790883648493n,mk=0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51an,yk=0x6666666666666666666666666666666666666666666666666666666666666658n,SS={a:-1n,d:37095705934669439343138083508754565189542113879843219016388785533085940283555n,p:Bo,n:gb,h:8,Gx:mk,Gy:yk},Fs=(t="")=>{throw new Error(t)},gL=t=>typeof t=="string",TS=(t,e)=>!(t instanceof Uint8Array)||typeof e=="number"&&e>0&&t.length!==e?Fs("Uint8Array expected"):t,bb=t=>new Uint8Array(t),vb=(t,e)=>TS(gL(t)?bk(t):bb(t),e),pt=(t,e=Bo)=>{let r=t%e;return r>=0n?r:e+r},hL=t=>t instanceof Fu?t:Fs("Point expected"),pL,Fu=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,pt(e.x*e.y))}static fromHex(e,r=!0){let{d:n}=SS;e=vb(e,32);let i=e.slice();i[31]=e[31]&-129;let o=vk(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(SS.h),!1)}isSmallOrder(){return this.clearCofactor().is0()}isTorsionFree(){let e=this.mul(gb/2n,!1).double();return gb%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=wL(n);return pt(n*i)!==1n&&Fs("invalid inverse"),{x:pt(e*i),y:pt(r*i)}}toRawBytes(){let{x:e,y:r}=this.toAffine(),n=vL(r);return n[31]|=e&1n?128:0,n}toHex(){return gk(this.toRawBytes())}};Fu.BASE=new Fu(mk,yk,1n,pt(mk*yk));Fu.ZERO=new Fu(0n,1n,1n,0n);var{BASE:Lh,ZERO:AS}=Fu,bL=(t,e)=>t.toString(16).padStart(e,"0"),gk=t=>Array.from(t).map(e=>bL(e,2)).join(""),bk=t=>{let e=t.length;(!gL(t)||e%2)&&Fs("hex invalid 1");let r=bb(e/2);for(let n=0;nbk(bL(t,32*2)).reverse(),vk=t=>BigInt("0x"+gk(bb(TS(t)).reverse())),d2=(...t)=>{let e=bb(t.reduce((n,i)=>n+TS(i).length,0)),r=0;return t.forEach(n=>{e.set(n,r),r+=n.length}),e},wL=(t,e=Bo)=>{(t===0n||e<=0n)&&Fs("no inverse n="+t+" mod="+e);let r=pt(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?pt(i,e):Fs("no inverse")},Lu=(t,e)=>{let r=t;for(;e-- >0n;)r*=r,r%=Bo;return r},nbe=t=>{let r=t*t%Bo*t%Bo,n=Lu(r,2n)*r%Bo,i=Lu(n,1n)*t%Bo,o=Lu(i,5n)*i%Bo,s=Lu(o,10n)*o%Bo,a=Lu(s,20n)*s%Bo,d=Lu(a,40n)*a%Bo,u=Lu(d,80n)*d%Bo,c=Lu(u,80n)*d%Bo,l=Lu(c,10n)*o%Bo;return{pow_p_5_8:Lu(l,2n)*t%Bo,b2:r}},mL=19681161376707505956807079304988542015446066515923890162744021073123829784752n,ibe=(t,e)=>{let r=pt(e*e*e),n=pt(r*r*e),i=nbe(t*n).pow_p_5_8,o=pt(t*r*i),s=pt(e*o*o),a=o,d=pt(o*mL),u=s===t,c=s===pt(-t),l=s===pt(-t*mL);return u&&(o=a),(c||l)&&(o=d),(pt(o)&1n)===1n&&(o=pt(-o)),{isValid:u||c,value:o}},PS=t=>pt(vk(t),gb),c2,wk=(...t)=>IS.sha512Async(...t),_L=(...t)=>typeof c2=="function"?c2(...t):Fs("etc.sha512Sync not set"),xL=t=>{let e=t.slice(0,32);e[0]&=248,e[31]&=127,e[31]|=64;let r=t.slice(32,64),n=PS(e),i=Lh.mul(n),o=i.toRawBytes();return{head:e,prefix:r,scalar:n,point:i,pointBytes:o}},_k=t=>wk(vb(t,32)).then(xL),obe=t=>xL(_L(vb(t,32))),xk=t=>_k(t).then(e=>e.pointBytes);function EL(t,e){return t?wk(e.hashable).then(e.finish):e.finish(_L(e.hashable))}var sbe=(t,e,r)=>{let{pointBytes:n,scalar:i}=t,o=PS(e),s=Lh.mul(o).toRawBytes();return{hashable:d2(s,n,r),finish:u=>{let c=pt(o+PS(u)*i,gb);return TS(d2(s,vL(c)),64)}}},SL=async(t,e)=>{let r=vb(t),n=await _k(e),i=await wk(n.prefix,r);return EL(!0,sbe(n,i,r))};var abe=(t,e,r)=>{e=vb(e),t=vb(t,64);let n=Fu.fromHex(r,!1),i=Fu.fromHex(t.slice(0,32),!1),o=vk(t.slice(32,64)),s=Lh.mul(o,!1);return{hashable:d2(i.toRawBytes(),n.toRawBytes(),e),finish:u=>{let c=PS(u);return i.add(n.mul(c,!1)).add(s.negate()).clearCofactor().is0()}}},AL=async(t,e,r)=>EL(!0,abe(t,e,r));var yL=()=>typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0,IS={bytesToHex:gk,hexToBytes:bk,concatBytes:d2,mod:pt,invert:wL,randomBytes:t=>{let e=yL();return e||Fs("crypto.getRandomValues must be defined"),e.getRandomValues(bb(t))},sha512Async:async(...t)=>{let e=yL();e||Fs("crypto.subtle or etc.sha512Async must be defined");let r=d2(...t);return bb(await e.subtle.digest("SHA-512",r.buffer))},sha512Sync:void 0};Object.defineProperties(IS,{sha512Sync:{configurable:!1,get(){return c2},set(t){c2||(c2=t)}}});var Ek={getExtendedPublicKeyAsync:_k,getExtendedPublicKey:obe,randomPrivateKey:()=>IS.randomBytes(32),precompute(t=8,e=Lh){return e.multiply(3n),e}},fy=8,cbe=()=>{let t=[],e=256/fy+1,r=Lh,n=r;for(let i=0;i{let e=pL||(pL=cbe()),r=(c,l)=>{let m=l.negate();return c?m:l},n=AS,i=Lh,o=1+256/fy,s=2**(fy-1),a=BigInt(2**fy-1),d=2**fy,u=BigInt(fy);for(let c=0;c>=u,m>s&&(m-=d,t+=1n);let p=l,g=l+Math.abs(m)-1,b=c%2!==0,S=m<0;m===0?i=i.add(r(b,e[p])):n=n.add(r(S,e[g]))}return{p:n,f:i}};h();var oe=class extends Error{constructor(e,r){super(`${e}: ${r}`),this.code=e,this.name="DwnError"}},ne;(function(t){t.AuthenticateJwsMissing="AuthenticateJwsMissing",t.AuthenticateDescriptorCidMismatch="AuthenticateDescriptorCidMismatch",t.AuthenticationMoreThanOneSignatureNotSupported="AuthenticationMoreThanOneSignatureNotSupported",t.AuthorizationAuthorNotOwner="AuthorizationAuthorNotOwner",t.AuthorizationNotGrantedToAuthor="AuthorizationNotGrantedToAuthor",t.ComputeCidCodecNotSupported="ComputeCidCodecNotSupported",t.ComputeCidMultihashNotSupported="ComputeCidMultihashNotSupported",t.DidMethodNotSupported="DidMethodNotSupported",t.DidNotString="DidNotString",t.DidNotValid="DidNotValid",t.DidResolutionFailed="DidResolutionFailed",t.Ed25519InvalidJwk="Ed25519InvalidJwk",t.EventEmitterStreamNotOpenError="EventEmitterStreamNotOpenError",t.EventsSubscribeEventStreamUnimplemented="EventsSubscribeEventStreamUnimplemented",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.MessageGetInvalidCid="MessageGetInvalidCid",t.ParseCidCodecNotSupported="ParseCidCodecNotSupported",t.ParseCidMultihashNotSupported="ParseCidMultihashNotSupported",t.PermissionsProtocolValidateSchemaUnexpectedRecord="PermissionsProtocolValidateSchemaUnexpectedRecord",t.PermissionsProtocolValidateScopeContextIdProhibitedProperties="PermissionsProtocolValidateScopeContextIdProhibitedProperties",t.PermissionsProtocolValidateScopeSchemaProhibitedProperties="PermissionsProtocolValidateScopeSchemaProhibitedProperties",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.ProtocolAuthorizationQueryWithoutRole="ProtocolAuthorizationQueryWithoutRole",t.ProtocolAuthorizationRoleMissingRecipient="ProtocolAuthorizationRoleMissingRecipient",t.ProtocolAuthorizationTagsInvalidSchema="ProtocolAuthorizationTagsInvalidSchema",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.ProtocolsConfigureQueryNotAllowed="ProtocolsConfigureQueryNotAllowed",t.ProtocolsConfigureRecordNestingDepthExceeded="ProtocolsConfigureRecordNestingDepthExceeded",t.ProtocolsConfigureRoleDoesNotExistAtGivenPath="ProtocolsConfigureRoleDoesNotExistAtGivenPath",t.ProtocolsConfigureUnauthorized="ProtocolsConfigureUnauthorized",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.RecordsGrantAuthorizationScopeMissingProtocol="RecordsGrantAuthorizationScopeMissingProtocol",t.RecordsGrantAuthorizationScopeNotRecords="RecordsGrantAuthorizationScopeNotRecords",t.RecordsGrantAuthorizationScopeProtocolMismatch="RecordsGrantAuthorizationScopeProtocolMismatch",t.RecordsGrantAuthorizationScopeProtocolPathMismatch="RecordsGrantAuthorizationScopeProtocolPathMismatch",t.RecordsGrantAuthorizationScopeSchema="RecordsGrantAuthorizationScopeSchema",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.RecordsWriteGetInitialWriteNotFound="RecordsWriteGetInitialWriteNotFound",t.RecordsWriteImmutablePropertyChanged="RecordsWriteImmutablePropertyChanged",t.RecordsWriteMissingSigner="RecordsWriteMissingSigner",t.RecordsWriteMissingDataInPrevious="RecordsWriteMissingDataInPrevious",t.RecordsWriteMissingEncodedDataInPrevious="RecordsWriteMissingEncodedDataInPrevious",t.RecordsWriteMissingDataStream="RecordsWriteMissingDataStream",t.RecordsWriteMissingProtocol="RecordsWriteMissingProtocol",t.RecordsWriteMissingSchema="RecordsWriteMissingSchema",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",t.UrlSchemaNotNormalizable="UrlSchemaNotNormalizable"})(ne||(ne={}));var kS=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 TL(t){if(t.kty!=="OKP"||t.crv!=="Ed25519")throw new oe(ne.Ed25519InvalidJwk,"invalid jwk. kty MUST be OKP. crv MUST be Ed25519")}function IL(t){return{alg:"EdDSA",kty:"OKP",crv:"Ed25519",x:Ye.bytesToBase64Url(t)}}var Sk={sign:(t,e)=>kS(void 0,void 0,void 0,function*(){TL(e);let r=Ye.base64UrlToBytes(e.d);return SL(t,r)}),verify:(t,e,r)=>kS(void 0,void 0,void 0,function*(){TL(r);let n=Ye.base64UrlToBytes(r.x);return AL(e,t,n)}),generateKeyPair:()=>kS(void 0,void 0,void 0,function*(){let t=Ek.randomPrivateKey(),e=yield xk(t),r=Ye.bytesToBase64Url(t),n=IL(e),i=Object.assign(Object.assign({},n),{d:r});return{publicJwk:n,privateJwk:i}}),publicKeyToJwk:t=>kS(void 0,void 0,void 0,function*(){return IL(t)})};h();h();var Tk=2n**256n,Fh=Tk-0x1000003d1n,qi=Tk-0x14551231950b75fc4402da1732fc9bebfn,CL=0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798n,OL=0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8n,$L={p:Fh,n:qi,a:0n,b:7n,Gx:CL,Gy:OL},fs=32,kL=t=>We(We(t*t)*t+$L.b),cn=(t="")=>{throw new Error(t)},BS=t=>typeof t=="bigint",NL=t=>typeof t=="string",Ak=t=>BS(t)&&0nBS(t)&&0n!(t instanceof Uint8Array)||typeof e=="number"&&e>0&&t.length!==e?cn("Uint8Array expected"):t,Wa=t=>new Uint8Array(t),of=(t,e)=>jL(NL(t)?p2(t):Wa(t),e),We=(t,e=Fh)=>{let r=t%e;return r>=0n?r:e+r},RL=t=>t instanceof hs?t:cn("Point expected"),DL,hs=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=of(e);let r,n=e[0],i=e.subarray(1),o=DS(i,0,fs),s=e.length;if(s===33&&[2,3].includes(n)){Ak(o)||cn("Point hex invalid: x not FE");let a=ube(kL(o)),d=(a&1n)===1n;(n&1)===1!==d&&(a=We(-a)),r=new t(o,a,1n)}return s===65&&n===4&&(r=new t(o,DS(i,fs,2*fs),1n)),r?r.ok():cn("Point is not on curve")}static fromPrivateKey(e){return nf.mul(MS(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}=RL(e),d=We(r*a),u=We(o*i),c=We(n*a),l=We(s*i);return d===u&&c===l}negate(){return new t(this.px,We(-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}=RL(e),{a:d,b:u}=$L,c=0n,l=0n,m=0n,p=We(u*3n),g=We(r*o),b=We(n*s),S=We(i*a),A=We(r+n),I=We(o+s);A=We(A*I),I=We(g+b),A=We(A-I),I=We(r+i);let P=We(o+a);return I=We(I*P),P=We(g+S),I=We(I-P),P=We(n+i),c=We(s+a),P=We(P*c),c=We(b+S),P=We(P-c),m=We(d*I),c=We(p*S),m=We(c+m),c=We(b-m),m=We(b+m),l=We(c*m),b=We(g+g),b=We(b+g),S=We(d*S),I=We(p*I),b=We(b+S),S=We(g-S),S=We(d*S),I=We(I+S),g=We(b*I),l=We(l+g),g=We(P*I),c=We(A*c),c=We(c-g),g=We(A*b),m=We(P*m),m=We(m+g),new t(c,l,m)}mul(e,r=!0){if(!r&&e===0n)return RS;if(f2(e)||cn("invalid scalar"),this.equals(nf))return mbe(e).p;let n=RS,i=nf;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(RS))return{x:0n,y:0n};if(n===1n)return{x:e,y:r};let i=y2(n);return We(n*i)!==1n&&cn("invalid inverse"),{x:We(e*i),y:We(r*i)}}assertValidity(){let{x:e,y:r}=this.aff();return(!Ak(e)||!Ak(r))&&cn("Point invalid: x or y"),We(r*r)===kL(e)?this:cn("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")+u2(r)+(e?"":u2(n))}toRawBytes(e=!0){return p2(this.toHex(e))}};hs.BASE=new hs(CL,OL,1n);hs.ZERO=new hs(0n,1n,0n);var{BASE:nf,ZERO:RS}=hs,UL=(t,e)=>t.toString(16).padStart(e,"0"),Ik=t=>Array.from(t).map(e=>UL(e,2)).join(""),p2=t=>{let e=t.length;(!NL(t)||e%2)&&cn("hex invalid 1");let r=Wa(e/2);for(let n=0;nBigInt("0x"+(Ik(t)||"0")),DS=(t,e,r)=>m2(t.slice(e,r)),CS=t=>BS(t)&&t>=0n&&tIk(CS(t)),Pk=(...t)=>{let e=Wa(t.reduce((n,i)=>n+jL(i).length,0)),r=0;return t.forEach(n=>{e.set(n,r),r+=n.length}),e},y2=(t,e=Fh)=>{(t===0n||e<=0n)&&cn("no inverse n="+t+" mod="+e);let r=We(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?We(i,e):cn("no inverse")},ube=t=>{let e=1n;for(let r=t,n=(Fh+1n)/4n;n>0n;n>>=1n)n&1n&&(e=e*r%Fh),r=r*r%Fh;return We(e*e)===t?e:cn("sqrt invalid")},MS=t=>(BS(t)||(t=m2(of(t,fs))),f2(t)?t:cn("private key out of range")),kk=t=>t>qi>>1n;function g2(t,e=!0){return hs.fromPrivateKey(t).toRawBytes(e)}var h2=class t{constructor(e,r,n){this.r=e,this.s=r,this.recovery=n,this.assertValidity()}static fromCompact(e){return e=of(e,64),new t(DS(e,0,fs),DS(e,fs,2*fs))}assertValidity(){return f2(this.r)&&f2(this.s)?this:cn()}addRecoveryBit(e){return new t(this.r,this.s,e)}hasHighS(){return kk(this.s)}recoverPublicKey(e){let{r,s:n,recovery:i}=this;[0,1,2,3].includes(i)||cn("recovery id invalid");let o=Rk(of(e,32)),s=i===2||i===3?r+qi:r;s>=Fh&&cn("q.x invalid");let a=i&1?"03":"02",d=hs.fromHex(a+u2(s)),u=y2(s,qi),c=We(-o*u,qi),l=We(n*u,qi);return nf.mulAddQUns(d,c,l)}toCompactRawBytes(){return p2(this.toCompactHex())}toCompactHex(){return u2(this.r)+u2(this.s)}},KL=t=>{let e=t.length*8-256,r=m2(t);return e>0?r>>BigInt(e):r},Rk=t=>We(KL(t),qi),ML=t=>CS(t),BL=()=>typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0,l2,qL={lowS:!0},lbe={lowS:!0};function fbe(t,e,r=qL){["der","recovered","canonical"].some(l=>l in r)&&cn("sign() legacy options not supported");let{lowS:n}=r;n==null&&(n=!0);let i=Rk(of(t)),o=ML(i),s=MS(e),a=[ML(s),o],d=r.extraEntropy;if(d){d===!0&&(d=zh.randomBytes(fs));let l=of(d);l.length!==fs&&cn(),a.push(l)}let u=i,c=l=>{let m=KL(l);if(!f2(m))return;let p=y2(m,qi),g=nf.mul(m).aff(),b=We(g.x,qi);if(b===0n)return;let S=We(p*We(u+We(s*b,qi),qi),qi);if(S===0n)return;let A=S,I=(g.x===b?0:2)|Number(g.y&1n);return n&&kk(S)&&(A=We(-S,qi),I^=1),new h2(b,A,I)};return{seed:Pk(...a),k2sig:c}}function hbe(t){let e=Wa(fs),r=Wa(fs),n=0,i=()=>{e.fill(1),r.fill(0),n=0},o="drbg: tried 1000 values";if(t){let s=(...u)=>zh.hmacSha256Async(r,e,...u),a=async(u=Wa())=>{r=await s(Wa([0]),u),e=await s(),u.length!==0&&(r=await s(Wa([1]),u),e=await s())},d=async()=>(n++>=1e3&&cn(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=l2;return c||cn("etc.hmacSha256Sync not set"),c(r,e,...u)},a=(u=Wa())=>{r=s(Wa([0]),u),e=s(),u.length!==0&&(r=s(Wa([1]),u),e=s())},d=()=>(n++>=1e3&&cn(o),e=s(),e);return(u,c)=>{i(),a(u);let l;for(;!(l=c(d()));)a();return i(),l}}}async function Dk(t,e,r=qL){let{seed:n,k2sig:i}=fbe(t,e,r);return hbe(!0)(n,i)}function LL(t,e,r,n=lbe){let{lowS:i}=n;i==null&&(i=!0),"strict"in n&&cn("verify() legacy options not supported");let o,s,a,d=t&&typeof t=="object"&&"r"in t;!d&&of(t).length!==2*fs&&cn("signature must be 64 bytes");try{o=d?new h2(t.r,t.s).assertValidity():h2.fromCompact(t),s=Rk(of(e,fs)),a=r instanceof hs?r.ok():hs.fromHex(r)}catch{return!1}if(!o)return!1;let{r:u,s:c}=o;if(i&&kk(c))return!1;let l;try{let p=y2(c,qi),g=We(s*p,qi),b=We(u*p,qi);l=nf.mulAddQUns(a,g,b).aff()}catch{return!1}return l?We(l.x,qi)===u:!1}function FL(t){t=of(t);let e=fs+8;(t.length1024)&&cn("expected proper params");let r=We(m2(t),qi-1n)+1n;return CS(r)}var zh={hexToBytes:p2,bytesToHex:Ik,concatBytes:Pk,bytesToNumberBE:m2,numberToBytesBE:CS,mod:We,invert:y2,hmacSha256Async:async(t,...e)=>{let r=BL();if(!r)return cn("etc.hmacSha256Async not set");let n=r.subtle,i=await n.importKey("raw",t,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]);return Wa(await n.sign("HMAC",i,Pk(...e)))},hmacSha256Sync:l2,hashToPrivateKey:FL,randomBytes:t=>{let e=BL();return e||cn("crypto.getRandomValues must be defined"),e.getRandomValues(Wa(t))}},OS={normPrivateKeyToScalar:MS,isValidPrivateKey:t=>{try{return!!MS(t)}catch{return!1}},randomPrivateKey:()=>FL(zh.randomBytes(fs+8)),precompute(t=8,e=nf){return e.multiply(3n),e}};Object.defineProperties(zh,{hmacSha256Sync:{configurable:!1,get(){return l2},set(t){l2||(l2=t)}}});var hy=8,pbe=()=>{let t=[],e=256/hy+1,r=nf,n=r;for(let i=0;i{let e=DL||(DL=pbe()),r=(c,l)=>{let m=l.negate();return c?m:l},n=RS,i=nf,o=1+256/hy,s=2**(hy-1),a=BigInt(2**hy-1),d=2**hy,u=BigInt(hy);for(let c=0;c>=u,m>s&&(m-=d,t+=1n);let p=l,g=l+Math.abs(m)-1,b=c%2!==0,S=m<0;m===0?i=i.add(r(b,e[p])):n=n.add(r(S,e[g]))}return{p:n,f:i}};h();h();h();var sf={};jr(sf,{decode:()=>wb,encodeTo:()=>py,encodingLength:()=>my});h();h();var ybe=WL,zL=128,gbe=127,bbe=~gbe,vbe=Math.pow(2,31);function WL(t,e,r){e=e||[],r=r||0;for(var n=r;t>=vbe;)e[r++]=t&255|zL,t/=128;for(;t&bbe;)e[r++]=t&255|zL,t>>>=7;return e[r]=t|0,WL.bytes=r-n+1,e}var wbe=Bk,_be=128,GL=127;function Bk(t,n){var r=0,n=n||0,i=0,o=n,s,a=t.length;do{if(o>=a)throw Bk.bytes=0,new RangeError("Could not decode varint");s=t[o++],r+=i<28?(s&GL)<=_be);return Bk.bytes=o-n,r}var xbe=Math.pow(2,7),Ebe=Math.pow(2,14),Sbe=Math.pow(2,21),Abe=Math.pow(2,28),Pbe=Math.pow(2,35),Tbe=Math.pow(2,42),Ibe=Math.pow(2,49),kbe=Math.pow(2,56),Rbe=Math.pow(2,63),Dbe=function(t){return t[b2.decode(t,e),b2.decode.bytes],py=(t,e,r=0)=>(b2.encode(t,e,r),e),my=t=>b2.encodingLength(t);var yy=(t,e)=>{let r=e.byteLength,n=my(t),i=n+my(r),o=new Uint8Array(i+r);return py(t,o,0),py(r,o,n),o.set(e,i),new _b(t,r,e,o)},$S=t=>{let e=Bd(t),[r,n]=wb(e),[i,o]=wb(e.subarray(n)),s=e.subarray(n+o);if(s.byteLength!==i)throw new Error("Incorrect length");return new _b(r,i,s,e)},HL=(t,e)=>{if(t===e)return!0;{let r=e;return t.code===r.code&&t.size===r.size&&r.bytes instanceof Uint8Array&&dL(t.bytes,r.bytes)}},_b=class{constructor(e,r,n,i){this.code=e,this.size=r,this.digest=n,this.bytes=i}};var Ok=({name:t,code:e,encode:r})=>new Ck(t,e,r),Ck=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?yy(this.code,r):r.then(n=>yy(this.code,n))}else throw Error("Unknown type, must be binary type")}};var VL=t=>async e=>new Uint8Array(await crypto.subtle.digest(t,e)),ps=Ok({name:"sha2-256",code:18,encode:VL("SHA-256")}),$Ze=Ok({name:"sha2-512",code:19,encode:VL("SHA-512")});var Gh=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())})},Obe=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(`Expected Uint8Array of length ${e}, not of length=${t.length}`)}function NS(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 xb(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 JL(t,e){af(t);let r=e.outputLen;if(t.lengthnew DataView(t.buffer,t.byteOffset,t.byteLength),Cd=(t,e)=>t<<32-e|t>>>e,Nbe=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!Nbe)throw new Error("Non little-endian hardware is not supported");var jbe=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function Nk(t){if(!$k(t))throw new Error("Uint8Array expected");let e="";for(let r=0;r=cf._0&&t<=cf._9)return t-cf._0;if(t>=cf._A&&t<=cf._F)return t-(cf._A-10);if(t>=cf._a&&t<=cf._f)return t-(cf._a-10)}function ZL(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 XL(t,e,r){let n=Date.now();for(let i=0;i=0&&ot().update(Hh(n)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function uf(t=32){if(Eb&&typeof Eb.getRandomValues=="function")return Eb.getRandomValues(new Uint8Array(t));throw new Error("crypto.getRandomValues must be defined")}var jS=class extends Sb{constructor(e,r){super(),this.finished=!1,this.destroyed=!1,NS(e);let n=Hh(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 jS(t,e).update(r).digest();Vh.create=(t,e)=>new jS(t,e);h();h();var KS={};jr(KS,{bitGet:()=>Hbe,bitLen:()=>Wbe,bitMask:()=>_2,bitSet:()=>Vbe,bytesToHex:()=>ff,bytesToNumberBE:()=>hf,bytesToNumberLE:()=>$d,concatBytes:()=>mf,createHmacDrbg:()=>Kk,ensureBytes:()=>Rn,equalBytes:()=>zbe,hexToBytes:()=>by,hexToNumber:()=>Uk,isBytes:()=>Od,numberToBytesBE:()=>ga,numberToBytesLE:()=>pf,numberToHexUnpadded:()=>nF,numberToVarBytesBE:()=>Fbe,utf8ToBytes:()=>Gbe,validateObject:()=>Nc});h();var rF=BigInt(0),US=BigInt(1),qbe=BigInt(2);function Od(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}var Lbe=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function ff(t){if(!Od(t))throw new Error("Uint8Array expected");let e="";for(let r=0;r=lf._0&&t<=lf._9)return t-lf._0;if(t>=lf._A&&t<=lf._F)return t-(lf._A-10);if(t>=lf._a&&t<=lf._f)return t-(lf._a-10)}function by(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;irF;t>>=US,e+=1);return e}function Hbe(t,e){return t>>BigInt(e)&US}var Vbe=(t,e,r)=>t|(r?US:rF)<(qbe<new Uint8Array(t),tF=t=>Uint8Array.from(t);function Kk(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(tF([0]),l),n=a(),l.length!==0&&(i=a(tF([1]),l),n=a())},u=()=>{if(o++>=1e3)throw new Error("drbg: tried 1000 values");let l=0,m=[];for(;l{s(),d(l);let p;for(;!(p=m(u()));)d();return s(),p}}var Jbe={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"||Od(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 Nc(t,e,r={}){let n=(i,o,s)=>{let a=Jbe[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 Li=BigInt(0),On=BigInt(1),vy=BigInt(2),Ybe=BigInt(3),qk=BigInt(4),iF=BigInt(5),oF=BigInt(8),Zbe=BigInt(9),Xbe=BigInt(16);function Zr(t,e){let r=t%e;return r>=Li?r:e+r}function Lk(t,e,r){if(r<=Li||e 0");if(r===On)return Li;let n=On;for(;e>Li;)e&On&&(n=n*t%r),t=t*t%r,e>>=On;return n}function Dn(t,e,r){let n=t;for(;e-- >Li;)n*=n,n%=r;return n}function qS(t,e){if(t===Li||e<=Li)throw new Error(`invert: expected positive integers, got n=${t} mod=${e}`);let r=Zr(t,e),n=e,i=Li,o=On,s=On,a=Li;for(;r!==Li;){let u=n/r,c=n%r,l=i-s*u,m=o-a*u;n=r,r=c,i=s,o=a,s=l,a=m}if(n!==On)throw new Error("invert: does not exist");return Zr(i,e)}function Qbe(t){let e=(t-On)/vy,r,n,i;for(r=t-On,n=0;r%vy===Li;r/=vy,n++);for(i=vy;i(Zr(t,e)&On)===On,tve=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Fk(t){let e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},r=tve.reduce((n,i)=>(n[i]="function",n),e);return Nc(t,r)}function rve(t,e,r){if(r 0");if(r===Li)return t.ONE;if(r===On)return e;let n=t.ONE,i=e;for(;r>Li;)r&On&&(n=t.mul(n,i)),i=t.sqr(i),r>>=On;return n}function nve(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 Pb(t,e,r=!1,n={}){if(t<=Li)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=eve(t),a=Object.freeze({ORDER:t,BITS:i,BYTES:o,MASK:_2(i),ZERO:Li,ONE:On,create:d=>Zr(d,t),isValid:d=>{if(typeof d!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof d}`);return Li<=d&&dd===Li,isOdd:d=>(d&On)===On,neg:d=>Zr(-d,t),eql:(d,u)=>d===u,sqr:d=>Zr(d*d,t),add:(d,u)=>Zr(d+u,t),sub:(d,u)=>Zr(d-u,t),mul:(d,u)=>Zr(d*u,t),pow:(d,u)=>rve(a,d,u),div:(d,u)=>Zr(d*qS(u,t),t),sqrN:d=>d*d,addN:(d,u)=>d+u,subN:(d,u)=>d-u,mulN:(d,u)=>d*u,inv:d=>qS(d,t),sqrt:n.sqrt||(d=>s(a,d)),invertBatch:d=>nve(a,d),cmov:(d,u,c)=>c?u:d,toBytes:d=>r?pf(d,o):ga(d,o),fromBytes:d=>{if(d.length!==o)throw new Error(`Fp.fromBytes: expected ${o}, got ${d.length}`);return r?$d(d):hf(d)}});return Object.freeze(a)}function aF(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 cF(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 Gk(t){let e=cF(t);return e+Math.ceil(e/2)}function dF(t,e,r=!1){let n=t.length,i=cF(e),o=Gk(e);if(n<16||n1024)throw new Error(`expected ${o}-1024 bytes of input, got ${n}`);let s=r?hf(t):$d(t),a=Zr(s,e-On)+On;return r?pf(a,i):ga(a,i)}h();var ove=BigInt(0),Wk=BigInt(1);function LS(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>ove;)o&Wk&&(s=s.add(a)),a=a.double(),o>>=Wk;return s},precomputeWindow(i,o){let{windows:s,windowSize:a}=n(o),d=[],u=i,c=u;for(let l=0;l>=p,S>d&&(S-=m,s+=Wk);let A=b,I=b+Math.abs(S)-1,P=g%2!==0,$=S<0;S===0?c=c.add(r(P,o[A])):u=u.add(r($,o[I]))}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 x2(t){return Fk(t.Fp),Nc(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 sve(t){let e=x2(t);Nc(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:ave,hexToBytes:cve}=KS,wy={Err:class extends Error{constructor(e=""){super(e)}},_parseInt(t){let{Err:e}=wy;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:ave(n),l:t.subarray(r+2)}},toSig(t){let{Err:e}=wy,r=typeof t=="string"?cve(t):t;if(!Od(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}=wy._parseInt(r.subarray(2)),{d:s,l:a}=wy._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}`}},yf=BigInt(0),jc=BigInt(1),lXe=BigInt(2),uF=BigInt(3),fXe=BigInt(4);function dve(t){let e=sve(t),{Fp:r}=e,n=e.toBytes||((g,b,S)=>{let A=b.toAffine();return mf(Uint8Array.from([4]),r.toBytes(A.x),r.toBytes(A.y))}),i=e.fromBytes||(g=>{let b=g.subarray(1),S=r.fromBytes(b.subarray(0,r.BYTES)),A=r.fromBytes(b.subarray(r.BYTES,2*r.BYTES));return{x:S,y:A}});function o(g){let{a:b,b:S}=e,A=r.sqr(g),I=r.mul(A,g);return r.add(r.add(I,r.mul(g,b)),S)}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"&&yfr.eql(P,r.ZERO);return I(S)&&I(A)?l.ZERO:new l(S,A,r.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(b){let S=r.invertBatch(b.map(A=>A.pz));return b.map((A,I)=>A.toAffine(S[I])).map(l.fromAffine)}static fromHex(b){let S=l.fromAffine(i(Rn("pointHex",b)));return S.assertValidity(),S}static fromPrivateKey(b){return l.BASE.multiply(d(b))}_setWindowSize(b){this._WINDOW_SIZE=b,u.delete(this)}assertValidity(){if(this.is0()){if(e.allowInfinityPoint&&!r.is0(this.py))return;throw new Error("bad point: ZERO")}let{x:b,y:S}=this.toAffine();if(!r.isValid(b)||!r.isValid(S))throw new Error("bad point: x or y not FE");let A=r.sqr(S),I=o(b);if(!r.eql(A,I))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){let{y:b}=this.toAffine();if(r.isOdd)return!r.isOdd(b);throw new Error("Field doesn't support isOdd")}equals(b){c(b);let{px:S,py:A,pz:I}=this,{px:P,py:$,pz:N}=b,L=r.eql(r.mul(S,N),r.mul(P,I)),F=r.eql(r.mul(A,N),r.mul($,I));return L&&F}negate(){return new l(this.px,r.neg(this.py),this.pz)}double(){let{a:b,b:S}=e,A=r.mul(S,uF),{px:I,py:P,pz:$}=this,N=r.ZERO,L=r.ZERO,F=r.ZERO,U=r.mul(I,I),G=r.mul(P,P),q=r.mul($,$),T=r.mul(I,P);return T=r.add(T,T),F=r.mul(I,$),F=r.add(F,F),N=r.mul(b,F),L=r.mul(A,q),L=r.add(N,L),N=r.sub(G,L),L=r.add(G,L),L=r.mul(N,L),N=r.mul(T,N),F=r.mul(A,F),q=r.mul(b,q),T=r.sub(U,q),T=r.mul(b,T),T=r.add(T,F),F=r.add(U,U),U=r.add(F,U),U=r.add(U,q),U=r.mul(U,T),L=r.add(L,U),q=r.mul(P,$),q=r.add(q,q),U=r.mul(q,T),N=r.sub(N,U),F=r.mul(q,G),F=r.add(F,F),F=r.add(F,F),new l(N,L,F)}add(b){c(b);let{px:S,py:A,pz:I}=this,{px:P,py:$,pz:N}=b,L=r.ZERO,F=r.ZERO,U=r.ZERO,G=e.a,q=r.mul(e.b,uF),T=r.mul(S,P),E=r.mul(A,$),k=r.mul(I,N),f=r.add(S,A),y=r.add(P,$);f=r.mul(f,y),y=r.add(T,E),f=r.sub(f,y),y=r.add(S,I);let w=r.add(P,N);return y=r.mul(y,w),w=r.add(T,k),y=r.sub(y,w),w=r.add(A,I),L=r.add($,N),w=r.mul(w,L),L=r.add(E,k),w=r.sub(w,L),U=r.mul(G,y),L=r.mul(q,k),U=r.add(L,U),L=r.sub(E,U),U=r.add(E,U),F=r.mul(L,U),E=r.add(T,T),E=r.add(E,T),k=r.mul(G,k),y=r.mul(q,y),E=r.add(E,k),k=r.sub(T,k),k=r.mul(G,k),y=r.add(y,k),T=r.mul(E,y),F=r.add(F,T),T=r.mul(w,y),L=r.mul(f,L),L=r.sub(L,T),T=r.mul(f,E),U=r.mul(w,U),U=r.add(U,T),new l(L,F,U)}subtract(b){return this.add(b.negate())}is0(){return this.equals(l.ZERO)}wNAF(b){return p.wNAFCached(this,u,b,S=>{let A=r.invertBatch(S.map(I=>I.pz));return S.map((I,P)=>I.toAffine(A[P])).map(l.fromAffine)})}multiplyUnsafe(b){let S=l.ZERO;if(b===yf)return S;if(a(b),b===jc)return this;let{endo:A}=e;if(!A)return p.unsafeLadder(this,b);let{k1neg:I,k1:P,k2neg:$,k2:N}=A.splitScalar(b),L=S,F=S,U=this;for(;P>yf||N>yf;)P&jc&&(L=L.add(U)),N&jc&&(F=F.add(U)),U=U.double(),P>>=jc,N>>=jc;return I&&(L=L.negate()),$&&(F=F.negate()),F=new l(r.mul(F.px,A.beta),F.py,F.pz),L.add(F)}multiply(b){a(b);let S=b,A,I,{endo:P}=e;if(P){let{k1neg:$,k1:N,k2neg:L,k2:F}=P.splitScalar(S),{p:U,f:G}=this.wNAF(N),{p:q,f:T}=this.wNAF(F);U=p.constTimeNegate($,U),q=p.constTimeNegate(L,q),q=new l(r.mul(q.px,P.beta),q.py,q.pz),A=U.add(q),I=G.add(T)}else{let{p:$,f:N}=this.wNAF(S);A=$,I=N}return l.normalizeZ([A,I])[0]}multiplyAndAddUnsafe(b,S,A){let I=l.BASE,P=(N,L)=>L===yf||L===jc||!N.equals(I)?N.multiplyUnsafe(L):N.multiply(L),$=P(this,S).add(P(b,A));return $.is0()?void 0:$}toAffine(b){let{px:S,py:A,pz:I}=this,P=this.is0();b==null&&(b=P?r.ONE:r.inv(I));let $=r.mul(S,b),N=r.mul(A,b),L=r.mul(I,b);if(P)return{x:r.ZERO,y:r.ZERO};if(!r.eql(L,r.ONE))throw new Error("invZ was invalid");return{x:$,y:N}}isTorsionFree(){let{h:b,isTorsionFree:S}=e;if(b===jc)return!0;if(S)return S(l,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:b,clearCofactor:S}=e;return b===jc?this:S?S(l,this):this.multiplyUnsafe(e.h)}toRawBytes(b=!0){return this.assertValidity(),n(l,this,b)}toHex(b=!0){return ff(this.toRawBytes(b))}}l.BASE=new l(e.Gx,e.Gy,r.ONE),l.ZERO=new l(r.ZERO,r.ONE,r.ZERO);let m=e.nBitLength,p=LS(l,e.endo?Math.ceil(m/2):m);return{CURVE:e,ProjectivePoint:l,normPrivateKeyToScalar:d,weierstrassEquation:o,isWithinCurveOrder:s}}function uve(t){let e=x2(t);return Nc(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function lF(t){let e=uve(t),{Fp:r,n}=e,i=r.BYTES+1,o=2*r.BYTES+1;function s(y){return yfff(ga(y,e.nByteLength));function g(y){let w=n>>jc;return y>w}function b(y){return g(y)?a(-y):y}let S=(y,w,_)=>hf(y.slice(w,_));class A{constructor(w,_,x){this.r=w,this.s=_,this.recovery=x,this.assertValidity()}static fromCompact(w){let _=e.nByteLength;return w=Rn("compactSignature",w,_*2),new A(S(w,0,_),S(w,_,2*_))}static fromDER(w){let{r:_,s:x}=wy.toSig(Rn("DER",w));return new A(_,x)}assertValidity(){if(!m(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!m(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(w){return new A(this.r,this.s,w)}recoverPublicKey(w){let{r:_,s:x,recovery:v}=this,D=F(Rn("msgHash",w));if(v==null||![0,1,2,3].includes(v))throw new Error("recovery id invalid");let K=v===2||v===3?_+e.n:_;if(K>=r.ORDER)throw new Error("recovery id 2 or 3 invalid");let M=v&1?"03":"02",j=u.fromHex(M+p(K)),J=d(K),Z=a(-D*J),V=a(x*J),H=u.BASE.multiplyAndAddUnsafe(j,Z,V);if(!H)throw new Error("point at infinify");return H.assertValidity(),H}hasHighS(){return g(this.s)}normalizeS(){return this.hasHighS()?new A(this.r,a(-this.s),this.recovery):this}toDERRawBytes(){return by(this.toDERHex())}toDERHex(){return wy.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return by(this.toCompactHex())}toCompactHex(){return p(this.r)+p(this.s)}}let I={isValidPrivateKey(y){try{return c(y),!0}catch{return!1}},normPrivateKeyToScalar:c,randomPrivateKey:()=>{let y=Gk(e.n);return dF(e.randomBytes(y),e.n)},precompute(y=8,w=u.BASE){return w._setWindowSize(y),w.multiply(BigInt(3)),w}};function P(y,w=!0){return u.fromPrivateKey(y).toRawBytes(w)}function $(y){let w=Od(y),_=typeof y=="string",x=(w||_)&&y.length;return w?x===i||x===o:_?x===2*i||x===2*o:y instanceof u}function N(y,w,_=!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(_)}let L=e.bits2int||function(y){let w=hf(y),_=y.length*8-e.nBitLength;return _>0?w>>BigInt(_):w},F=e.bits2int_modN||function(y){return a(L(y))},U=_2(e.nBitLength);function G(y){if(typeof y!="bigint")throw new Error("bigint expected");if(!(yf<=y&&yee in _))throw new Error("sign() legacy options not supported");let{hash:x,randomBytes:v}=e,{lowS:D,prehash:K,extraEntropy:M}=_;D==null&&(D=!0),y=Rn("msgHash",y),K&&(y=Rn("prehashed msgHash",x(y)));let j=F(y),J=c(w),Z=[G(J),G(j)];if(M!=null){let ee=M===!0?v(r.BYTES):M;Z.push(Rn("extraEntropy",ee))}let V=mf(...Z),H=j;function X(ee){let ue=L(ee);if(!m(ue))return;let ae=d(ue),ce=u.BASE.multiply(ue).toAffine(),pe=a(ce.x);if(pe===yf)return;let Ee=a(ae*a(H+pe*J));if(Ee===yf)return;let Ue=(ce.x===pe?0:2)|Number(ce.y&jc),le=Ee;return D&&g(Ee)&&(le=b(Ee),Ue^=1),new A(pe,le,Ue)}return{seed:V,k2sig:X}}let T={lowS:e.lowS,prehash:!1},E={lowS:e.lowS,prehash:!1};function k(y,w,_=T){let{seed:x,k2sig:v}=q(y,w,_),D=e;return Kk(D.hash.outputLen,D.nByteLength,D.hmac)(x,v)}u.BASE._setWindowSize(8);function f(y,w,_,x=E){let v=y;if(w=Rn("msgHash",w),_=Rn("publicKey",_),"strict"in x)throw new Error("options.strict was renamed to lowS");let{lowS:D,prehash:K}=x,M,j;try{if(typeof v=="string"||Od(v))try{M=A.fromDER(v)}catch(ce){if(!(ce instanceof wy.Err))throw ce;M=A.fromCompact(v)}else if(typeof v=="object"&&typeof v.r=="bigint"&&typeof v.s=="bigint"){let{r:ce,s:pe}=v;M=new A(ce,pe)}else throw new Error("PARSE");j=u.fromHex(_)}catch(ce){if(ce.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(D&&M.hasHighS())return!1;K&&(w=e.hash(w));let{r:J,s:Z}=M,V=F(w),H=d(Z),X=a(V*H),ee=a(J*H),ue=u.BASE.multiplyAndAddUnsafe(j,X,ee)?.toAffine();return ue?a(ue.x)===J:!1}return{CURVE:e,getPublicKey:P,getSharedSecret:N,sign:k,verify:f,ProjectivePoint:u,Signature:A,utils:I}}function lve(t){return{hash:t,hmac:(e,...r)=>Vh(t,e,gy(...r)),randomBytes:uf}}function FS(t,e){let r=n=>lF({...t,...lve(n)});return Object.freeze({...r(e),create:r})}h();h();function fve(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 Jh=class extends Sb{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=df(this.buffer)}update(e){xb(this);let{view:r,buffer:n,blockLen:i}=this;e=Hh(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,pve=(t,e,r)=>t&e^t&r^e&r,mve=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]),Yh=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Zh=new Uint32Array(64),Hk=class extends Jh{constructor(){super(64,32,8,!1),this.A=Yh[0]|0,this.B=Yh[1]|0,this.C=Yh[2]|0,this.D=Yh[3]|0,this.E=Yh[4]|0,this.F=Yh[5]|0,this.G=Yh[6]|0,this.H=Yh[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)Zh[l]=e.getUint32(r,!1);for(let l=16;l<64;l++){let m=Zh[l-15],p=Zh[l-2],g=Cd(m,7)^Cd(m,18)^m>>>3,b=Cd(p,17)^Cd(p,19)^p>>>10;Zh[l]=b+Zh[l-7]+g+Zh[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 m=Cd(a,6)^Cd(a,11)^Cd(a,25),p=c+m+hve(a,d,u)+mve[l]+Zh[l]|0,b=(Cd(n,2)^Cd(n,13)^Cd(n,22))+pve(n,i,o)|0;c=u,u=d,d=a,a=s+p|0,s=o,o=i,i=n,n=p+b|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(){Zh.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var ms=Ab(()=>new Hk);var fF=Pb(BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff")),yve=fF.create(BigInt("-3")),gve=BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),gf=FS({a:yve,b:gve,Fp:fF,n:BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),Gx:BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),Gy:BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5"),h:BigInt(1),lowS:!1},ms),zs=gf;h();h();h();h();h();function Tb(t){return globalThis.Buffer!=null?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):t}function zS(t=0){return globalThis.Buffer?.allocUnsafe!=null?Tb(globalThis.Buffer.allocUnsafe(t)):new Uint8Array(t)}h();h();h();h();var Xk={};jr(Xk,{base10:()=>Eve});h();h();h();function bve(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n>>0,$=new Uint8Array(P);A!==I;){for(var N=g[A],L=0,F=P-1;(N!==0||L>>0,$[F]=N%a>>>0,N=N/a>>>0;if(N!==0)throw new Error("Non-zero carry");S=L,A++}for(var U=P-S;U!==P&&$[U]===0;)U++;for(var G=d.repeat(b);U>>0,P=new Uint8Array(I);g[b];){var $=r[g.charCodeAt(b)];if($===255)return;for(var N=0,L=I-1;($!==0||N>>0,P[L]=$%256>>>0,$=$/256>>>0;if($!==0)throw new Error("Non-zero carry");A=N,b++}if(g[b]!==" "){for(var F=I-A;F!==I&&P[F]===0;)F++;for(var U=new Uint8Array(S+(I-F)),G=S;F!==I;)U[G++]=P[F++];return U}}}function p(g){var b=m(g);if(b)return b;throw new Error(`Non-${e} character`)}return{encode:l,decodeUnsafe:m,decode:p}}var vve=bve,wve=vve,hF=wve;h();var VXe=new Uint8Array(0);var pF=(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 mF=t=>new TextEncoder().encode(t),yF=t=>new TextDecoder().decode(t);h();var Vk=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")}},Jk=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 bF(this,e)}},Yk=class{constructor(e){this.decoders=e}or(e){return bF(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`)}},bF=(t,e)=>new Yk({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}}),Zk=class{constructor(e,r,n,i){this.name=e,this.prefix=r,this.baseEncode=n,this.baseDecode=i,this.encoder=new Vk(e,r,n),this.decoder=new Jk(e,r,i)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},Ib=({name:t,prefix:e,encode:r,decode:n})=>new Zk(t,e,r,n),Xh=({prefix:t,name:e,alphabet:r})=>{let{encode:n,decode:i}=hF(r,e);return Ib({prefix:t,name:e,encode:n,decode:o=>bf(i(o))})},_ve=(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},xve=(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<Ib({prefix:e,name:t,encode(i){return xve(i,n,r)},decode(i){return _ve(i,n,r,t)}});var Eve=Xh({prefix:"9",name:"base10",alphabet:"0123456789"});var Qk={};jr(Qk,{base16:()=>Sve,base16upper:()=>Ave});h();var Sve=ni({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Ave=ni({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var eR={};jr(eR,{base2:()=>Pve});h();var Pve=ni({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var tR={};jr(tR,{base256emoji:()=>Dve});h();var vF=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}"),Tve=vF.reduce((t,e,r)=>(t[r]=e,t),[]),Ive=vF.reduce((t,e,r)=>(t[e.codePointAt(0)]=r,t),[]);function kve(t){return t.reduce((e,r)=>(e+=Tve[r],e),"")}function Rve(t){let e=[];for(let r of t){let n=Ive[r.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(n)}return new Uint8Array(e)}var Dve=Ib({prefix:"\u{1F680}",name:"base256emoji",encode:kve,decode:Rve});var rR={};jr(rR,{base32:()=>kb,base32hex:()=>Ove,base32hexpad:()=>Nve,base32hexpadupper:()=>jve,base32hexupper:()=>$ve,base32pad:()=>Bve,base32padupper:()=>Cve,base32upper:()=>Mve,base32z:()=>Uve});h();var kb=ni({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Mve=ni({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Bve=ni({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Cve=ni({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Ove=ni({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),$ve=ni({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Nve=ni({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),jve=ni({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Uve=ni({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var nR={};jr(nR,{base36:()=>Kve,base36upper:()=>qve});h();var Kve=Xh({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),qve=Xh({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var iR={};jr(iR,{base58btc:()=>zu,base58flickr:()=>Lve});h();var zu=Xh({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Lve=Xh({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var oR={};jr(oR,{base64:()=>Fve,base64pad:()=>zve,base64url:()=>Rb,base64urlpad:()=>Gve});h();var Fve=ni({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),zve=ni({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Rb=ni({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Gve=ni({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var sR={};jr(sR,{base8:()=>Wve});h();var Wve=ni({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var aR={};jr(aR,{identity:()=>Hve});h();var Hve=Ib({prefix:"\0",name:"identity",encode:t=>yF(t),decode:t=>mF(t)});h();var EQe=new TextEncoder,SQe=new TextDecoder;h();var dR={};jr(dR,{identity:()=>ywe});h();h();h();h();var Yve=xF,wF=128,Zve=127,Xve=~Zve,Qve=Math.pow(2,31);function xF(t,e,r){e=e||[],r=r||0;for(var n=r;t>=Qve;)e[r++]=t&255|wF,t/=128;for(;t&Xve;)e[r++]=t&255|wF,t>>>=7;return e[r]=t|0,xF.bytes=r-n+1,e}var ewe=cR,twe=128,_F=127;function cR(t,n){var r=0,n=n||0,i=0,o=n,s,a=t.length;do{if(o>=a)throw cR.bytes=0,new RangeError("Could not decode varint");s=t[o++],r+=i<28?(s&_F)<=twe);return cR.bytes=o-n,r}var rwe=Math.pow(2,7),nwe=Math.pow(2,14),iwe=Math.pow(2,21),owe=Math.pow(2,28),swe=Math.pow(2,35),awe=Math.pow(2,42),cwe=Math.pow(2,49),dwe=Math.pow(2,56),uwe=Math.pow(2,63),lwe=function(t){return t[E2.decode(t,e),E2.decode.bytes],Db=(t,e,r=0)=>(E2.encode(t,e,r),e),Mb=t=>E2.encodingLength(t);var _y=(t,e)=>{let r=e.byteLength,n=Mb(t),i=n+Mb(r),o=new Uint8Array(i+r);return Db(t,o,0),Db(r,o,n),o.set(e,i),new Bb(t,r,e,o)},WS=t=>{let e=bf(t),[r,n]=S2(e),[i,o]=S2(e.subarray(n)),s=e.subarray(n+o);if(s.byteLength!==i)throw new Error("Incorrect length");return new Bb(r,i,s,e)},EF=(t,e)=>{if(t===e)return!0;{let r=e;return t.code===r.code&&t.size===r.size&&r.bytes instanceof Uint8Array&&pF(t.bytes,r.bytes)}},Bb=class{constructor(e,r,n,i){this.code=e,this.size=r,this.digest=n,this.bytes=i}};var SF=0,pwe="identity",AF=bf,mwe=t=>_y(SF,AF(t)),ywe={code:SF,name:pwe,encode:AF,digest:mwe};var fR={};jr(fR,{sha256:()=>P2,sha512:()=>gwe});h();h();var lR=({name:t,code:e,encode:r})=>new uR(t,e,r),uR=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?_y(this.code,r):r.then(n=>_y(this.code,n))}else throw Error("Unknown type, must be binary type")}};var TF=t=>async e=>new Uint8Array(await crypto.subtle.digest(t,e)),P2=lR({name:"sha2-256",code:18,encode:TF("SHA-256")}),gwe=lR({name:"sha2-512",code:19,encode:TF("SHA-512")});h();h();h();var IF=(t,e)=>{let{bytes:r,version:n}=t;switch(n){case 0:return vwe(r,hR(t),e||zu.encoder);default:return wwe(r,hR(t),e||kb.encoder)}};var kF=new WeakMap,hR=t=>{let e=kF.get(t);if(e==null){let r=new Map;return kF.set(t,r),r}return e},xy=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!==T2)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==_we)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=_y(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&&EF(e.multihash,n.multihash)}toString(e){return IF(this,e)}toJSON(){return{"/":IF(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||RF(n,i,o.bytes))}else if(r[xwe]===!0){let{version:n,multihash:i,code:o}=r,s=WS(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!==T2)throw new Error(`Version 0 CID must use dag-pb (code: ${T2}) block encoding`);return new t(e,r,n,n.bytes)}case 1:{let i=RF(e,r,n.bytes);return new t(e,r,n,i)}default:throw new Error("Invalid version")}}static createV0(e){return t.create(0,T2,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=bf(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 Bb(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,m]=S2(e.subarray(r));return r+=m,l},i=n(),o=T2;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]=bwe(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 hR(o).set(n,e),o}},bwe=(t,e)=>{switch(t[0]){case"Q":{let r=e||zu;return[zu.prefix,r.decode(`${zu.prefix}${t}`)]}case zu.prefix:{let r=e||zu;return[zu.prefix,r.decode(t)]}case kb.prefix:{let r=e||kb;return[kb.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)]}}},vwe=(t,e,r)=>{let{prefix:n}=r;if(n!==zu.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},wwe=(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},T2=112,_we=18,RF=(t,e,r)=>{let n=Mb(t),i=n+Mb(e),o=new Uint8Array(i+r.byteLength);return Db(t,o,0),Db(e,o,n),o.set(r,i),o},xwe=Symbol.for("@ipld/js-cid/CID");h();var pR={...aR,...eR,...sR,...Xk,...Qk,...rR,...nR,...iR,...oR,...tR},QQe={...fR,...dR};function MF(t,e,r,n){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:n}}}var DF=MF("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),mR=MF("ascii","a",t=>{let e="a";for(let r=0;r{t=t.substring(1);let e=zS(t.length);for(let r=0;rt.createSigner(n))}static createSigner(e){let r=e.keyPair.privateJwk,n=e.keyId;return new Ob({privateJwk:r,keyId:n})}};h();h();var k2=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,OF=new Set,gR=typeof B.default=="object"&&B.default?B.default:{},$F=(t,e,r,n)=>{typeof gR.emitWarning=="function"?gR.emitWarning(t,e,r,n):console.error(`[${r}] ${e}: ${t}`)},JS=globalThis.AbortController,CF=globalThis.AbortSignal;if(typeof JS>"u"){CF=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(n,i){this._onabort.push(i)}},JS=class{constructor(){e()}signal=new CF;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=gR.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",e=()=>{t&&(t=!1,$F("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 Twe=t=>!OF.has(t),ttt=Symbol("type"),ep=t=>t&&t===Math.floor(t)&&t>0&&isFinite(t),NF=t=>ep(t)?t<=Math.pow(2,8)?Uint8Array:t<=Math.pow(2,16)?Uint16Array:t<=Math.pow(2,32)?Uint32Array:t<=Number.MAX_SAFE_INTEGER?$b:null:null,$b=class extends Array{constructor(e){super(e),this.fill(0)}},bR=class t{heap;length;static#c=!1;static create(e){let r=NF(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]}},YS=class t{#c;#l;#b;#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;#v;#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.#M(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.#b}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:m,maxSize:p=0,maxEntrySize:g=0,sizeCalculation:b,fetchMethod:S,noDeleteOnFetchRejection:A,noDeleteOnStaleGet:I,allowStaleOnFetchRejection:P,allowStaleOnFetchAbort:$,ignoreFetchAbort:N}=e;if(r!==0&&!ep(r))throw new TypeError("max option must be a nonnegative integer");let L=r?NF(r):Array;if(!L)throw new Error("invalid max value: "+r);if(this.#c=r,this.#l=p,this.maxEntrySize=g||this.#l,this.sizeCalculation=b,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(S!==void 0&&typeof S!="function")throw new TypeError("fetchMethod must be a function if specified");if(this.#k=S,this.#A=!!S,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=bR.create(r),this.#n=0,this.#m=0,typeof u=="function"&&(this.#b=u),typeof c=="function"?(this.#p=c,this.#s=[]):(this.#p=void 0,this.#s=void 0),this.#v=!!this.#b,this.#u=!!this.#p,this.noDisposeOnSet=!!l,this.noUpdateTTL=!!m,this.noDeleteOnFetchRejection=!!A,this.allowStaleOnFetchRejection=!!P,this.allowStaleOnFetchAbort=!!$,this.ignoreFetchAbort=!!N,this.maxEntrySize!==0){if(this.#l!==0&&!ep(this.#l))throw new TypeError("maxSize must be a positive integer if specified");if(!ep(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#j()}if(this.allowStale=!!d,this.noDeleteOnStaleGet=!!I,this.updateAgeOnGet=!!s,this.updateAgeOnHas=!!a,this.ttlResolution=ep(i)||i===0?i:1,this.ttlAutopurge=!!o,this.ttl=n||0,this.ttl){if(!ep(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#B()}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";Twe(F)&&(OF.add(F),$F("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}#B(){let e=new $b(this.#c),r=new $b(this.#c);this.#g=e,this.#E=r,this.#C=(o,s,a=k2.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.#P=o=>{r[o]=e[o]!==0?k2.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=k2.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]}#P=()=>{};#S=()=>{};#C=()=>{};#h=()=>!1;#j(){let e=new $b(this.#c);this.#m=0,this.#x=e,this.#T=r=>{this.#m-=e[r],e[r]=0},this.#O=(r,n,i,o)=>{if(this.#t(n))return 0;if(!ep(i))if(o){if(typeof o!="function")throw new TypeError("sizeCalculation must be a function");if(i=o(n,r),!ep(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)}}#T=e=>{};#R=(e,r,n)=>{};#O=(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=k2.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=k2.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.#O(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 m=this.#e[l];if(r!==m){if(this.#A&&this.#t(m)?m.__abortController.abort(new Error("replaced")):s||(this.#v&&this.#b?.(m,e,"set"),this.#u&&this.#s?.push([m,e,"set"])),this.#T(l),this.#R(l,c,d),this.#e[l]=r,d){d.set="replace";let p=m&&this.#t(m)?m.__staleWhileFetching:m;p!==void 0&&(d.oldValue=p)}}else d&&(d.set="update")}if(i!==0&&!this.#g&&this.#B(),this.#g&&(u||this.#C(l,i,o),d&&this.#S(d,l)),!s&&this.#u&&this.#s){let m=this.#s,p;for(;p=m?.shift();)this.#p?.(...p)}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.#v||this.#u)&&(this.#v&&this.#b?.(i,n,"evict"),this.#u&&this.#s?.push([i,n,"evict"])),this.#T(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.#P(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}}#M(e,r,n,i){let o=r===void 0?void 0:this.#e[r];if(this.#t(o))return o;let s=new JS,{signal:a}=n;a?.addEventListener("abort",()=>s.abort(a.reason),{signal:s.signal});let d={signal:s.signal,options:n,context:i},u=(b,S=!1)=>{let{aborted:A}=s.signal,I=n.ignoreFetchAbort&&b!==void 0;if(n.status&&(A&&!S?(n.status.fetchAborted=!0,n.status.fetchError=s.signal.reason,I&&(n.status.fetchAbortIgnored=!0)):n.status.fetchResolved=!0),A&&!I&&!S)return l(s.signal.reason);let P=p;return this.#e[r]===p&&(b===void 0?P.__staleWhileFetching?this.#e[r]=P.__staleWhileFetching:this.delete(e):(n.status&&(n.status.fetchUpdated=!0),this.set(e,b,d.options))),b},c=b=>(n.status&&(n.status.fetchRejected=!0,n.status.fetchError=b),l(b)),l=b=>{let{aborted:S}=s.signal,A=S&&n.allowStaleOnFetchAbort,I=A||n.allowStaleOnFetchRejection,P=I||n.noDeleteOnFetchRejection,$=p;if(this.#e[r]===p&&(!P||$.__staleWhileFetching===void 0?this.delete(e):A||(this.#e[r]=$.__staleWhileFetching)),I)return n.status&&$.__staleWhileFetching!==void 0&&(n.status.returnedStale=!0),$.__staleWhileFetching;if($.__returned===$)throw b},m=(b,S)=>{let A=this.#k?.(e,o,d);A&&A instanceof Promise&&A.then(I=>b(I),S),s.signal.addEventListener("abort",()=>{(!n.ignoreFetchAbort||n.allowStaleOnFetchAbort)&&(b(),n.allowStaleOnFetchAbort&&(b=I=>u(I,!0)))})};n.status&&(n.status.fetchDispatched=!0);let p=new Promise(m).then(u,c),g=Object.assign(p,{__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 JS}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:m=this.allowStaleOnFetchRejection,ignoreFetchAbort:p=this.ignoreFetchAbort,allowStaleOnFetchAbort:g=this.allowStaleOnFetchAbort,context:b,forceRefresh:S=!1,status:A,signal:I}=r;if(!this.#A)return A&&(A.fetch="get"),this.get(e,{allowStale:n,updateAgeOnGet:i,noDeleteOnStaleGet:o,status:A});let P={allowStale:n,updateAgeOnGet:i,noDeleteOnStaleGet:o,ttl:s,noDisposeOnSet:a,size:d,sizeCalculation:u,noUpdateTTL:c,noDeleteOnFetchRejection:l,allowStaleOnFetchRejection:m,allowStaleOnFetchAbort:g,ignoreFetchAbort:p,status:A,signal:I},$=this.#i.get(e);if($===void 0){A&&(A.fetch="miss");let N=this.#M(e,$,P,b);return N.__returned=N}else{let N=this.#e[$];if(this.#t(N)){let q=n&&N.__staleWhileFetching!==void 0;return A&&(A.fetch="inflight",q&&(A.returnedStale=!0)),q?N.__staleWhileFetching:N.__returned=N}let L=this.#h($);if(!S&&!L)return A&&(A.fetch="hit"),this.#I($),i&&this.#P($),A&&this.#S(A,$),N;let F=this.#M(e,$,P,b),G=F.__staleWhileFetching!==void 0&&n;return A&&(A.fetch=L?"stale":"refresh",G&&L&&(A.returnedStale=!0)),G?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.#P(a),d))}else s&&(s.get="miss")}#N(e,r){this.#f[r]=e,this.#d[e]=r}#I(e){e!==this.#o&&(e===this.#a?this.#a=this.#d[e]:this.#N(this.#f[e],this.#d[e]),this.#N(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.#T(n);let i=this.#e[n];this.#t(i)?i.__abortController.abort(new Error("deleted")):(this.#v||this.#u)&&(this.#v&&this.#b?.(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.#v&&this.#b?.(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 jF=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())})},ZS=class{constructor(e){this.timeToLiveInSeconds=e,this.cache=new YS({max:1e5,ttl:e*1e3})}set(e,r){return jF(this,void 0,void 0,function*(){try{this.cache.set(e,r)}catch{}})}get(e){return jF(this,void 0,void 0,function*(){return this.cache.get(e)})}};h();var xR={};jr(xR,{Authorization:()=>Iwe,AuthorizationDelegatedGrant:()=>kwe,AuthorizationOwner:()=>Mwe,Definitions:()=>Fwe,EventsFilter:()=>Uwe,EventsGet:()=>Kwe,EventsQuery:()=>qwe,EventsSubscribe:()=>Lwe,GeneralJwk:()=>zwe,GeneralJws:()=>Gwe,GenericSignaturePayload:()=>l1e,JwkVerificationMethod:()=>Wwe,MessagesGet:()=>Vwe,NumberRangeFilter:()=>Jwe,PaginationCursor:()=>Ywe,PermissionGrantData:()=>Zwe,PermissionRequestData:()=>Xwe,PermissionRevocationData:()=>Qwe,PermissionsDefinitions:()=>e1e,PermissionsScopes:()=>t1e,ProtocolDefinition:()=>r1e,ProtocolRuleSet:()=>o1e,ProtocolsConfigure:()=>s1e,ProtocolsQuery:()=>a1e,PublicJwk:()=>u1e,RecordsDelete:()=>Bwe,RecordsFilter:()=>d1e,RecordsQuery:()=>Cwe,RecordsRead:()=>c1e,RecordsSubscribe:()=>Owe,RecordsWrite:()=>$we,RecordsWriteDataEncoded:()=>Nwe,RecordsWriteSignaturePayload:()=>f1e,RecordsWriteUnidentified:()=>jwe,StringRangeFilter:()=>h1e});h();var Iwe=jn;var Ay=new RegExp("^[A-Za-z0-9_-]+$","u");function tn(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:i=t,dynamicAnchors:o={}}={}){let s=null,a=0,d=tn.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=a;for(let p in t)if(!(p==="payload"||p==="signatures")){return tn.errors=[{instancePath:e,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:p},message:"must NOT have additional properties"}],!1;break}if(m===a){if(t.payload!==void 0){let p=t.payload,g=a;if(a===a)if(typeof p=="string"){if(!Ay.test(p))return tn.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 tn.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 p=t.signatures,g=a;if(a===g)if(Array.isArray(p)){if(p.length<1)return tn.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 S=p.length;for(let A=0;A10)return Le.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(Ce).length<1)return Le.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 gt in Ce){let Pe=Ce[gt],De=a,It=a,we=!1,Se=null,Lr=a;if(typeof Pe!="string"){let He={instancePath:e+"/descriptor/tags/"+gt.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=[He]:s.push(He),a++}var _=Lr===a;_&&(we=!0,Se=0);let Fe=a;if(!(typeof Pe=="number"&&isFinite(Pe))){let He={instancePath:e+"/descriptor/tags/"+gt.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=[He]:s.push(He),a++}var _=Fe===a;if(_&&we)we=!1,Se=[Se,1];else{_&&(we=!0,Se=1);let He=a;if(typeof Pe!="boolean"){let ft={instancePath:e+"/descriptor/tags/"+gt.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=[ft]:s.push(ft),a++}var _=He===a;if(_&&we)we=!1,Se=[Se,2];else{_&&(we=!0,Se=2);let ft=a;if(a===ft)if(Array.isArray(Pe))if(Pe.length>10){let yi={instancePath:e+"/descriptor/tags/"+gt.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=[yi]:s.push(yi),a++}else if(Pe.length<1){let yi={instancePath:e+"/descriptor/tags/"+gt.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=[yi]:s.push(yi),a++}else{var x=!0;let yi=Pe.length;for(let At=0;At10){let Ze={instancePath:e+"/descriptor/tags/"+gt.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=[Ze]:s.push(Ze),a++}else if(Pe.length<1){let Ze={instancePath:e+"/descriptor/tags/"+gt.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=[Ze]:s.push(Ze),a++}else{var D=!0;let Ze=Pe.length;for(let Cc=0;Cc=",limit:1},message:"must be >= 1"}],!1}else return dn.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=G===a}else var l=!0;if(l)if($.cursor!==void 0){let U=$.cursor,G=a;if(a===a)if(U&&typeof U=="object"&&!Array.isArray(U)){if(Object.keys(U).length<1)return dn.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 E;if(U.messageCid===void 0&&(E="messageCid")||U.value===void 0&&(E="value"))return dn.errors=[{instancePath:e+"/descriptor/pagination/cursor",schemaPath:"https://identity.foundation/dwn/json-schemas/pagination-cursor.json/required",keyword:"required",params:{missingProperty:E},message:"must have required property '"+E+"'"}],!1;{let k=a;for(let f in U)if(!(f==="messageCid"||f==="value")){return dn.errors=[{instancePath:e+"/descriptor/pagination/cursor",schemaPath:"https://identity.foundation/dwn/json-schemas/pagination-cursor.json/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:f},message:"must NOT have additional properties"}],!1;break}if(k===a){if(U.messageCid!==void 0){let f=a;if(typeof U.messageCid!="string")return dn.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 m=f===a}else var m=!0;if(m)if(U.value!==void 0){let f=U.value,y=a;if(typeof f!="string"&&!(typeof f=="number"&&isFinite(f)))return dn.errors=[{instancePath:e+"/descriptor/pagination/cursor/value",schemaPath:"https://identity.foundation/dwn/json-schemas/pagination-cursor.json/properties/value/type",keyword:"type",params:{type:QS.properties.value.type},message:"must be string,number"}],!1;var m=y===a}else var m=!0}}}}else return dn.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=G===a}else var l=!0}}else return dn.errors=[{instancePath:e+"/descriptor/pagination",schemaPath:"#/properties/descriptor/properties/pagination/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var c=N===a}else var c=!0;if(c)if(b.dateSort!==void 0){let $=b.dateSort,N=a;if(typeof $!="string")return dn.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 dn.errors=[{instancePath:e+"/descriptor/dateSort",schemaPath:"#/properties/descriptor/properties/dateSort/enum",keyword:"enum",params:{allowedValues:vR.properties.descriptor.properties.dateSort.enum},message:"must be equal to one of the allowed values"}],!1;var c=N===a}else var c=!0}}}}}}}else return dn.errors=[{instancePath:e+"/descriptor",schemaPath:"#/properties/descriptor/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var u=S===a}else var u=!0}}}else return dn.errors=[{instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;return dn.errors=s,a===0}dn.evaluated={props:!0,dynamicProps:!1,dynamicItems:!1};var Owe=ys,qF={$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 ys(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:i=t,dynamicAnchors:o={}}={}){let s=null,a=0,d=ys.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 ys.errors=[{instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:l},message:"must have required property '"+l+"'"}],!1;{let m=a;for(let p in t)if(!(p==="authorization"||p==="descriptor")){return ys.errors=[{instancePath:e,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:p},message:"must NOT have additional properties"}],!1;break}if(m===a){if(t.authorization!==void 0){let p=a;co(t.authorization,{instancePath:e+"/authorization",parentData:t,parentDataProperty:"authorization",rootData:i,dynamicAnchors:o})||(s=s===null?co.errors:s.concat(co.errors),a=s.length);var u=p===a}else var u=!0;if(u)if(t.descriptor!==void 0){let p=t.descriptor,g=a;if(a===g)if(p&&typeof p=="object"&&!Array.isArray(p)){let S;if(p.interface===void 0&&(S="interface")||p.method===void 0&&(S="method")||p.messageTimestamp===void 0&&(S="messageTimestamp")||p.filter===void 0&&(S="filter"))return ys.errors=[{instancePath:e+"/descriptor",schemaPath:"#/properties/descriptor/required",keyword:"required",params:{missingProperty:S},message:"must have required property '"+S+"'"}],!1;{let A=a;for(let I in p)if(!(I==="interface"||I==="method"||I==="messageTimestamp"||I==="filter")){return ys.errors=[{instancePath:e+"/descriptor",schemaPath:"#/properties/descriptor/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:I},message:"must NOT have additional properties"}],!1;break}if(A===a){if(p.interface!==void 0){let I=p.interface,P=a;if(typeof I!="string")return ys.errors=[{instancePath:e+"/descriptor/interface",schemaPath:"#/properties/descriptor/properties/interface/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;if(I!=="Records")return ys.errors=[{instancePath:e+"/descriptor/interface",schemaPath:"#/properties/descriptor/properties/interface/enum",keyword:"enum",params:{allowedValues:qF.properties.descriptor.properties.interface.enum},message:"must be equal to one of the allowed values"}],!1;var c=P===a}else var c=!0;if(c){if(p.method!==void 0){let I=p.method,P=a;if(typeof I!="string")return ys.errors=[{instancePath:e+"/descriptor/method",schemaPath:"#/properties/descriptor/properties/method/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;if(I!=="Subscribe")return ys.errors=[{instancePath:e+"/descriptor/method",schemaPath:"#/properties/descriptor/properties/method/enum",keyword:"enum",params:{allowedValues:qF.properties.descriptor.properties.method.enum},message:"must be equal to one of the allowed values"}],!1;var c=P===a}else var c=!0;if(c){if(p.messageTimestamp!==void 0){let I=p.messageTimestamp,P=a;if(a===a)if(typeof I=="string"){if(!Nn.test(I))return ys.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 ys.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=P===a}else var c=!0;if(c)if(p.filter!==void 0){let I=a;Je(p.filter,{instancePath:e+"/descriptor/filter",parentData:p,parentDataProperty:"filter",rootData:i,dynamicAnchors:o})||(s=s===null?Je.errors:s.concat(Je.errors),a=s.length);var c=I===a}else var c=!0}}}}}else return ys.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 ys.errors=[{instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;return ys.errors=s,a===0}ys.evaluated={props:!0,dynamicProps:!1,dynamicItems:!1};var $we=Ey;function Ey(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:i=t,dynamicAnchors:o={}}={}){let s=null,a=0,d=Ey.evaluated;if(d.dynamicProps&&(d.props=void 0),d.dynamicItems&&(d.items=void 0),!Le(t,{instancePath:e,parentData:r,parentDataProperty:n,rootData:i,dynamicAnchors:o}))s=s===null?Le.errors:s.concat(Le.errors),a=s.length;else var u=Le.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 Ey.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 Ey.errors=[{instancePath:e,schemaPath:"#/unevaluatedProperties",keyword:"unevaluatedProperties",params:{unevaluatedProperty:l},message:"must NOT have unevaluated properties"}],!1;break}}}else return Ey.errors=[{instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;return Ey.errors=s,a===0}Ey.evaluated={props:!0,dynamicProps:!1,dynamicItems:!1};var Nwe=Uc,jwe=Le,Uwe=ut,XS={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://identity.foundation/dwn/json-schemas/events-filter.json",type:"object",additionalProperties:!1,minProperties:1,properties:{interface:{enum:["Permissions","Protocols","Records"],type:"string"},method:{enum:["Configure","Delete","Grant","Revoke","Write"],type:"string"},protocol:{type:"string"},protocolPath:{type:"string"},recipient:{$ref:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/did"},contextId:{type:"string"},schema:{type:"string"},recordId:{type:"string"},parentId:{type:"string"},dataFormat:{type:"string"},dataSize:{$ref:"https://identity.foundation/dwn/json-schemas/number-range-filter.json"},dateCreated:{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"}}},datePublished:{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"}}},dateUpdated:{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"}}}},dependencies:{datePublished:{oneOf:[{properties:{published:{enum:[!0]}},required:["published"]},{not:{required:["published"]}}]}}};function ut(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:i=t,dynamicAnchors:o={}}={}){let s=null,a=0,d=ut.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 ut.errors=[{instancePath:e,schemaPath:"#/minProperties",keyword:"minProperties",params:{limit:1},message:"must NOT have fewer than 1 properties"}],!1;{let F=a;for(let U in t)if(!_R.call(XS.properties,U)){return ut.errors=[{instancePath:e,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:U},message:"must NOT have additional properties"}],!1;break}if(F===a){if(t.datePublished!==void 0){let U=a,G=a,q=!1,T=null,E=a;if(t&&typeof t=="object"&&!Array.isArray(t)){let w;if(t.published===void 0&&(w="published")){let _={instancePath:e,schemaPath:"#/dependencies/datePublished/oneOf/0/required",keyword:"required",params:{missingProperty:w},message:"must have required property '"+w+"'"};s===null?s=[_]:s.push(_),a++}else if(t.published!==void 0&&t.published!==!0){let _={instancePath:e+"/published",schemaPath:"#/dependencies/datePublished/oneOf/0/properties/published/enum",keyword:"enum",params:{allowedValues:XS.dependencies.datePublished.oneOf[0].properties.published.enum},message:"must be equal to one of the allowed values"};s===null?s=[_]:s.push(_),a++}}var l=E===a;if(l){q=!0,T=0;var u={};u.published=!0}let k=a,f=a,y=a;if(t&&typeof t=="object"&&!Array.isArray(t)){let w;if(t.published===void 0&&(w="published")){let _={};s===null?s=[_]:s.push(_),a++}}var c=y===a;if(c){let w={instancePath:e,schemaPath:"#/dependencies/datePublished/oneOf/1/not",keyword:"not",params:{},message:"must NOT be valid"};s===null?s=[w]:s.push(w),a++}else a=f,s!==null&&(f?s.length=f:s=null);var l=k===a;if(l&&q?(q=!1,T=[T,1]):l&&(q=!0,T=1),q)a=G,s!==null&&(G?s.length=G:s=null);else{let w={instancePath:e,schemaPath:"#/dependencies/datePublished/oneOf",keyword:"oneOf",params:{passingSchemas:T},message:"must match exactly one schema in oneOf"};return s===null?s=[w]:s.push(w),a++,ut.errors=s,!1}var m=U===a}else var m=!0;if(m){if(t.interface!==void 0){let U=t.interface,G=a;if(typeof U!="string")return ut.errors=[{instancePath:e+"/interface",schemaPath:"#/properties/interface/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;if(!(U==="Permissions"||U==="Protocols"||U==="Records"))return ut.errors=[{instancePath:e+"/interface",schemaPath:"#/properties/interface/enum",keyword:"enum",params:{allowedValues:XS.properties.interface.enum},message:"must be equal to one of the allowed values"}],!1;var p=G===a}else var p=!0;if(p){if(t.method!==void 0){let U=t.method,G=a;if(typeof U!="string")return ut.errors=[{instancePath:e+"/method",schemaPath:"#/properties/method/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;if(!(U==="Configure"||U==="Delete"||U==="Grant"||U==="Revoke"||U==="Write"))return ut.errors=[{instancePath:e+"/method",schemaPath:"#/properties/method/enum",keyword:"enum",params:{allowedValues:XS.properties.method.enum},message:"must be equal to one of the allowed values"}],!1;var p=G===a}else var p=!0;if(p){if(t.protocol!==void 0){let U=a;if(typeof t.protocol!="string")return ut.errors=[{instancePath:e+"/protocol",schemaPath:"#/properties/protocol/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var p=U===a}else var p=!0;if(p){if(t.protocolPath!==void 0){let U=a;if(typeof t.protocolPath!="string")return ut.errors=[{instancePath:e+"/protocolPath",schemaPath:"#/properties/protocolPath/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var p=U===a}else var p=!0;if(p){if(t.recipient!==void 0){let U=t.recipient,G=a;if(a===a)if(typeof U=="string"){if(!Py.test(U))return ut.errors=[{instancePath:e+"/recipient",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 ut.errors=[{instancePath:e+"/recipient",schemaPath:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/did/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var p=G===a}else var p=!0;if(p){if(t.contextId!==void 0){let U=a;if(typeof t.contextId!="string")return ut.errors=[{instancePath:e+"/contextId",schemaPath:"#/properties/contextId/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var p=U===a}else var p=!0;if(p){if(t.schema!==void 0){let U=a;if(typeof t.schema!="string")return ut.errors=[{instancePath:e+"/schema",schemaPath:"#/properties/schema/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var p=U===a}else var p=!0;if(p){if(t.recordId!==void 0){let U=a;if(typeof t.recordId!="string")return ut.errors=[{instancePath:e+"/recordId",schemaPath:"#/properties/recordId/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var p=U===a}else var p=!0;if(p){if(t.parentId!==void 0){let U=a;if(typeof t.parentId!="string")return ut.errors=[{instancePath:e+"/parentId",schemaPath:"#/properties/parentId/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var p=U===a}else var p=!0;if(p){if(t.dataFormat!==void 0){let U=a;if(typeof t.dataFormat!="string")return ut.errors=[{instancePath:e+"/dataFormat",schemaPath:"#/properties/dataFormat/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var p=U===a}else var p=!0;if(p){if(t.dataSize!==void 0){let U=t.dataSize,G=a;if(a===a)if(U&&typeof U=="object"&&!Array.isArray(U)){if(Object.keys(U).length<1)return ut.errors=[{instancePath:e+"/dataSize",schemaPath:"https://identity.foundation/dwn/json-schemas/number-range-filter.json/minProperties",keyword:"minProperties",params:{limit:1},message:"must NOT have fewer than 1 properties"}],!1;{let E=a;for(let k in U)if(!(k==="gt"||k==="gte"||k==="lt"||k==="lte")){return ut.errors=[{instancePath:e+"/dataSize",schemaPath:"https://identity.foundation/dwn/json-schemas/number-range-filter.json/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:k},message:"must NOT have additional properties"}],!1;break}if(E===a){if(U.gt!==void 0){let k=a,f=a,y=a;if(U&&typeof U=="object"&&!Array.isArray(U)){let w;if(U.gte===void 0&&(w="gte")){let _={};s===null?s=[_]:s.push(_),a++}}var g=y===a;if(g)return ut.errors=[{instancePath:e+"/dataSize",schemaPath:"https://identity.foundation/dwn/json-schemas/number-range-filter.json/dependencies/gt/not",keyword:"not",params:{},message:"must NOT be valid"}],!1;a=f,s!==null&&(f?s.length=f:s=null);var b=k===a}else var b=!0;if(b){if(U.gte!==void 0){let k=a,f=a,y=a;if(U&&typeof U=="object"&&!Array.isArray(U)){let _;if(U.gt===void 0&&(_="gt")){let x={};s===null?s=[x]:s.push(x),a++}}var S=y===a;if(S)return ut.errors=[{instancePath:e+"/dataSize",schemaPath:"https://identity.foundation/dwn/json-schemas/number-range-filter.json/dependencies/gte/not",keyword:"not",params:{},message:"must NOT be valid"}],!1;a=f,s!==null&&(f?s.length=f:s=null);var b=k===a}else var b=!0;if(b){if(U.lt!==void 0){let k=a,f=a,y=a;if(U&&typeof U=="object"&&!Array.isArray(U)){let _;if(U.lte===void 0&&(_="lte")){let x={};s===null?s=[x]:s.push(x),a++}}var A=y===a;if(A)return ut.errors=[{instancePath:e+"/dataSize",schemaPath:"https://identity.foundation/dwn/json-schemas/number-range-filter.json/dependencies/lt/not",keyword:"not",params:{},message:"must NOT be valid"}],!1;a=f,s!==null&&(f?s.length=f:s=null);var b=k===a}else var b=!0;if(b){if(U.lte!==void 0){let k=a,f=a,y=a;if(U&&typeof U=="object"&&!Array.isArray(U)){let _;if(U.lt===void 0&&(_="lt")){let x={};s===null?s=[x]:s.push(x),a++}}var I=y===a;if(I)return ut.errors=[{instancePath:e+"/dataSize",schemaPath:"https://identity.foundation/dwn/json-schemas/number-range-filter.json/dependencies/lte/not",keyword:"not",params:{},message:"must NOT be valid"}],!1;a=f,s!==null&&(f?s.length=f:s=null);var b=k===a}else var b=!0;if(b){if(U.gt!==void 0){let k=U.gt,f=a;if(!(typeof k=="number"&&isFinite(k)))return ut.errors=[{instancePath:e+"/dataSize/gt",schemaPath:"https://identity.foundation/dwn/json-schemas/number-range-filter.json/properties/gt/type",keyword:"type",params:{type:"number"},message:"must be number"}],!1;var P=f===a}else var P=!0;if(P){if(U.gte!==void 0){let k=U.gte,f=a;if(!(typeof k=="number"&&isFinite(k)))return ut.errors=[{instancePath:e+"/dataSize/gte",schemaPath:"https://identity.foundation/dwn/json-schemas/number-range-filter.json/properties/gte/type",keyword:"type",params:{type:"number"},message:"must be number"}],!1;var P=f===a}else var P=!0;if(P){if(U.lt!==void 0){let k=U.lt,f=a;if(!(typeof k=="number"&&isFinite(k)))return ut.errors=[{instancePath:e+"/dataSize/lt",schemaPath:"https://identity.foundation/dwn/json-schemas/number-range-filter.json/properties/lt/type",keyword:"type",params:{type:"number"},message:"must be number"}],!1;var P=f===a}else var P=!0;if(P)if(U.lte!==void 0){let k=U.lte,f=a;if(!(typeof k=="number"&&isFinite(k)))return ut.errors=[{instancePath:e+"/dataSize/lte",schemaPath:"https://identity.foundation/dwn/json-schemas/number-range-filter.json/properties/lte/type",keyword:"type",params:{type:"number"},message:"must be number"}],!1;var P=f===a}else var P=!0}}}}}}}}}else return ut.errors=[{instancePath:e+"/dataSize",schemaPath:"https://identity.foundation/dwn/json-schemas/number-range-filter.json/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var p=G===a}else var p=!0;if(p){if(t.dateCreated!==void 0){let U=t.dateCreated,G=a;if(a===G)if(U&&typeof U=="object"&&!Array.isArray(U)){if(Object.keys(U).length<1)return ut.errors=[{instancePath:e+"/dateCreated",schemaPath:"#/properties/dateCreated/minProperties",keyword:"minProperties",params:{limit:1},message:"must NOT have fewer than 1 properties"}],!1;{let T=a;for(let E in U)if(!(E==="from"||E==="to")){return ut.errors=[{instancePath:e+"/dateCreated",schemaPath:"#/properties/dateCreated/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:E},message:"must NOT have additional properties"}],!1;break}if(T===a){if(U.from!==void 0){let E=U.from,k=a;if(a===a)if(typeof E=="string"){if(!Nn.test(E))return ut.errors=[{instancePath:e+"/dateCreated/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 ut.errors=[{instancePath:e+"/dateCreated/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 $=k===a}else var $=!0;if($)if(U.to!==void 0){let E=U.to,k=a;if(a===a)if(typeof E=="string"){if(!Nn.test(E))return ut.errors=[{instancePath:e+"/dateCreated/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 ut.errors=[{instancePath:e+"/dateCreated/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 $=k===a}else var $=!0}}}else return ut.errors=[{instancePath:e+"/dateCreated",schemaPath:"#/properties/dateCreated/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var p=G===a}else var p=!0;if(p){if(t.datePublished!==void 0){let U=t.datePublished,G=a;if(a===G)if(U&&typeof U=="object"&&!Array.isArray(U)){if(Object.keys(U).length<1)return ut.errors=[{instancePath:e+"/datePublished",schemaPath:"#/properties/datePublished/minProperties",keyword:"minProperties",params:{limit:1},message:"must NOT have fewer than 1 properties"}],!1;{let T=a;for(let E in U)if(!(E==="from"||E==="to")){return ut.errors=[{instancePath:e+"/datePublished",schemaPath:"#/properties/datePublished/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:E},message:"must NOT have additional properties"}],!1;break}if(T===a){if(U.from!==void 0){let E=U.from,k=a;if(a===a)if(typeof E=="string"){if(!Nn.test(E))return ut.errors=[{instancePath:e+"/datePublished/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 ut.errors=[{instancePath:e+"/datePublished/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 N=k===a}else var N=!0;if(N)if(U.to!==void 0){let E=U.to,k=a;if(a===a)if(typeof E=="string"){if(!Nn.test(E))return ut.errors=[{instancePath:e+"/datePublished/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 ut.errors=[{instancePath:e+"/datePublished/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 N=k===a}else var N=!0}}}else return ut.errors=[{instancePath:e+"/datePublished",schemaPath:"#/properties/datePublished/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var p=G===a}else var p=!0;if(p)if(t.dateUpdated!==void 0){let U=t.dateUpdated,G=a;if(a===G)if(U&&typeof U=="object"&&!Array.isArray(U)){if(Object.keys(U).length<1)return ut.errors=[{instancePath:e+"/dateUpdated",schemaPath:"#/properties/dateUpdated/minProperties",keyword:"minProperties",params:{limit:1},message:"must NOT have fewer than 1 properties"}],!1;{let T=a;for(let E in U)if(!(E==="from"||E==="to")){return ut.errors=[{instancePath:e+"/dateUpdated",schemaPath:"#/properties/dateUpdated/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:E},message:"must NOT have additional properties"}],!1;break}if(T===a){if(U.from!==void 0){let E=U.from,k=a;if(a===a)if(typeof E=="string"){if(!Nn.test(E))return ut.errors=[{instancePath:e+"/dateUpdated/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 ut.errors=[{instancePath:e+"/dateUpdated/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 L=k===a}else var L=!0;if(L)if(U.to!==void 0){let E=U.to,k=a;if(a===a)if(typeof E=="string"){if(!Nn.test(E))return ut.errors=[{instancePath:e+"/dateUpdated/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 ut.errors=[{instancePath:e+"/dateUpdated/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 L=k===a}else var L=!0}}}else return ut.errors=[{instancePath:e+"/dateUpdated",schemaPath:"#/properties/dateUpdated/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var p=G===a}else var p=!0}}}}}}}}}}}}}}}}else return ut.errors=[{instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;return ut.errors=s,a===0}ut.evaluated={props:!0,dynamicProps:!1,dynamicItems:!1};var Kwe=wi,LF={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://identity.foundation/dwn/json-schemas/events-get.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"],properties:{interface:{enum:["Events"],type:"string"},method:{enum:["Get"],type:"string"},messageTimestamp:{type:"string"},cursor:{$ref:"https://identity.foundation/dwn/json-schemas/pagination-cursor.json"}}}}};function wi(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:i=t,dynamicAnchors:o={}}={}){let s=null,a=0,d=wi.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 wi.errors=[{instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:m},message:"must have required property '"+m+"'"}],!1;{let p=a;for(let g in t)if(!(g==="authorization"||g==="descriptor")){return wi.errors=[{instancePath:e,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:g},message:"must NOT have additional properties"}],!1;break}if(p===a){if(t.authorization!==void 0){let g=a;jn(t.authorization,{instancePath:e+"/authorization",parentData:t,parentDataProperty:"authorization",rootData:i,dynamicAnchors:o})||(s=s===null?jn.errors:s.concat(jn.errors),a=s.length);var u=g===a}else var u=!0;if(u)if(t.descriptor!==void 0){let g=t.descriptor,b=a;if(a===b)if(g&&typeof g=="object"&&!Array.isArray(g)){let A;if(g.interface===void 0&&(A="interface")||g.method===void 0&&(A="method")||g.messageTimestamp===void 0&&(A="messageTimestamp"))return wi.errors=[{instancePath:e+"/descriptor",schemaPath:"#/properties/descriptor/required",keyword:"required",params:{missingProperty:A},message:"must have required property '"+A+"'"}],!1;{let I=a;for(let P in g)if(!(P==="interface"||P==="method"||P==="messageTimestamp"||P==="cursor")){return wi.errors=[{instancePath:e+"/descriptor",schemaPath:"#/properties/descriptor/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:P},message:"must NOT have additional properties"}],!1;break}if(I===a){if(g.interface!==void 0){let P=g.interface,$=a;if(typeof P!="string")return wi.errors=[{instancePath:e+"/descriptor/interface",schemaPath:"#/properties/descriptor/properties/interface/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;if(P!=="Events")return wi.errors=[{instancePath:e+"/descriptor/interface",schemaPath:"#/properties/descriptor/properties/interface/enum",keyword:"enum",params:{allowedValues:LF.properties.descriptor.properties.interface.enum},message:"must be equal to one of the allowed values"}],!1;var c=$===a}else var c=!0;if(c){if(g.method!==void 0){let P=g.method,$=a;if(typeof P!="string")return wi.errors=[{instancePath:e+"/descriptor/method",schemaPath:"#/properties/descriptor/properties/method/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;if(P!=="Get")return wi.errors=[{instancePath:e+"/descriptor/method",schemaPath:"#/properties/descriptor/properties/method/enum",keyword:"enum",params:{allowedValues:LF.properties.descriptor.properties.method.enum},message:"must be equal to one of the allowed values"}],!1;var c=$===a}else var c=!0;if(c){if(g.messageTimestamp!==void 0){let P=a;if(typeof g.messageTimestamp!="string")return wi.errors=[{instancePath:e+"/descriptor/messageTimestamp",schemaPath:"#/properties/descriptor/properties/messageTimestamp/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var c=P===a}else var c=!0;if(c)if(g.cursor!==void 0){let P=g.cursor,$=a;if(a===a)if(P&&typeof P=="object"&&!Array.isArray(P)){if(Object.keys(P).length<1)return wi.errors=[{instancePath:e+"/descriptor/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 F;if(P.messageCid===void 0&&(F="messageCid")||P.value===void 0&&(F="value"))return wi.errors=[{instancePath:e+"/descriptor/cursor",schemaPath:"https://identity.foundation/dwn/json-schemas/pagination-cursor.json/required",keyword:"required",params:{missingProperty:F},message:"must have required property '"+F+"'"}],!1;{let U=a;for(let G in P)if(!(G==="messageCid"||G==="value")){return wi.errors=[{instancePath:e+"/descriptor/cursor",schemaPath:"https://identity.foundation/dwn/json-schemas/pagination-cursor.json/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:G},message:"must NOT have additional properties"}],!1;break}if(U===a){if(P.messageCid!==void 0){let G=a;if(typeof P.messageCid!="string")return wi.errors=[{instancePath:e+"/descriptor/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 l=G===a}else var l=!0;if(l)if(P.value!==void 0){let G=P.value,q=a;if(typeof G!="string"&&!(typeof G=="number"&&isFinite(G)))return wi.errors=[{instancePath:e+"/descriptor/cursor/value",schemaPath:"https://identity.foundation/dwn/json-schemas/pagination-cursor.json/properties/value/type",keyword:"type",params:{type:QS.properties.value.type},message:"must be string,number"}],!1;var l=q===a}else var l=!0}}}}else return wi.errors=[{instancePath:e+"/descriptor/cursor",schemaPath:"https://identity.foundation/dwn/json-schemas/pagination-cursor.json/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var c=$===a}else var c=!0}}}}}else return wi.errors=[{instancePath:e+"/descriptor",schemaPath:"#/properties/descriptor/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var u=b===a}else var u=!0}}}else return wi.errors=[{instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;return wi.errors=s,a===0}wi.evaluated={props:!0,dynamicProps:!1,dynamicItems:!1};var qwe=$n,FF={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://identity.foundation/dwn/json-schemas/events-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:["Events"],type:"string"},method:{enum:["Query"],type:"string"},messageTimestamp:{$ref:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/date-time"},filters:{type:"array",minItems:1,items:{$ref:"https://identity.foundation/dwn/json-schemas/events-filter.json"}},cursor:{$ref:"https://identity.foundation/dwn/json-schemas/pagination-cursor.json"}}}}};function $n(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:i=t,dynamicAnchors:o={}}={}){let s=null,a=0,d=$n.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;if(t.authorization===void 0&&(p="authorization")||t.descriptor===void 0&&(p="descriptor"))return $n.errors=[{instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:p},message:"must have required property '"+p+"'"}],!1;{let g=a;for(let b in t)if(!(b==="authorization"||b==="descriptor")){return $n.errors=[{instancePath:e,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:b},message:"must NOT have additional properties"}],!1;break}if(g===a){if(t.authorization!==void 0){let b=a;jn(t.authorization,{instancePath:e+"/authorization",parentData:t,parentDataProperty:"authorization",rootData:i,dynamicAnchors:o})||(s=s===null?jn.errors:s.concat(jn.errors),a=s.length);var u=b===a}else var u=!0;if(u)if(t.descriptor!==void 0){let b=t.descriptor,S=a;if(a===S)if(b&&typeof b=="object"&&!Array.isArray(b)){let I;if(b.interface===void 0&&(I="interface")||b.method===void 0&&(I="method")||b.messageTimestamp===void 0&&(I="messageTimestamp")||b.filters===void 0&&(I="filters"))return $n.errors=[{instancePath:e+"/descriptor",schemaPath:"#/properties/descriptor/required",keyword:"required",params:{missingProperty:I},message:"must have required property '"+I+"'"}],!1;{let P=a;for(let $ in b)if(!($==="interface"||$==="method"||$==="messageTimestamp"||$==="filters"||$==="cursor")){return $n.errors=[{instancePath:e+"/descriptor",schemaPath:"#/properties/descriptor/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:$},message:"must NOT have additional properties"}],!1;break}if(P===a){if(b.interface!==void 0){let $=b.interface,N=a;if(typeof $!="string")return $n.errors=[{instancePath:e+"/descriptor/interface",schemaPath:"#/properties/descriptor/properties/interface/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;if($!=="Events")return $n.errors=[{instancePath:e+"/descriptor/interface",schemaPath:"#/properties/descriptor/properties/interface/enum",keyword:"enum",params:{allowedValues:FF.properties.descriptor.properties.interface.enum},message:"must be equal to one of the allowed values"}],!1;var c=N===a}else var c=!0;if(c){if(b.method!==void 0){let $=b.method,N=a;if(typeof $!="string")return $n.errors=[{instancePath:e+"/descriptor/method",schemaPath:"#/properties/descriptor/properties/method/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;if($!=="Query")return $n.errors=[{instancePath:e+"/descriptor/method",schemaPath:"#/properties/descriptor/properties/method/enum",keyword:"enum",params:{allowedValues:FF.properties.descriptor.properties.method.enum},message:"must be equal to one of the allowed values"}],!1;var c=N===a}else var c=!0;if(c){if(b.messageTimestamp!==void 0){let $=b.messageTimestamp,N=a;if(a===a)if(typeof $=="string"){if(!Nn.test($))return $n.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 $n.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=N===a}else var c=!0;if(c){if(b.filters!==void 0){let $=b.filters,N=a;if(a===N)if(Array.isArray($)){if($.length<1)return $n.errors=[{instancePath:e+"/descriptor/filters",schemaPath:"#/properties/descriptor/properties/filters/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"}],!1;{var l=!0;let F=$.length;for(let U=0;U=",limit:0},message:"must be >= 0"}],!1}else return Pr.errors=[{instancePath:e+"/$size/min",schemaPath:"#/properties/%24size/properties/min/type",keyword:"type",params:{type:"number"},message:"must be number"}],!1;var I=x===a}else var I=!0;if(I)if(k.max!==void 0){let _=k.max,x=a;if(a===x)if(typeof _=="number"&&isFinite(_)){if(_<0||isNaN(_))return Pr.errors=[{instancePath:e+"/$size/max",schemaPath:"#/properties/%24size/properties/max/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"}],!1}else return Pr.errors=[{instancePath:e+"/$size/max",schemaPath:"#/properties/%24size/properties/max/type",keyword:"type",params:{type:"number"},message:"must be number"}],!1;var I=x===a}else var I=!0}}else return Pr.errors=[{instancePath:e+"/$size",schemaPath:"#/properties/%24size/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var c=f===a}else var c=!0;if(c){if(t.$tags!==void 0){let k=t.$tags,f=a;if(a===f)if(k&&typeof k=="object"&&!Array.isArray(k)){if(Object.keys(k).length<1)return Pr.errors=[{instancePath:e+"/$tags",schemaPath:"#/properties/%24tags/minProperties",keyword:"minProperties",params:{limit:1},message:"must NOT have fewer than 1 properties"}],!1;if(k.$requiredTags!==void 0){let w=k.$requiredTags,_=a;if(a===_)if(Array.isArray(w)){var P=!0;let x=w.length;for(let v=0;vU2,decode:()=>Z1e,encode:()=>Y1e,name:()=>J1e});h();h();h();h();var p1e=["string","number","bigint","symbol"],m1e=["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 ez(t){if(t===null)return"null";if(t===void 0)return"undefined";if(t===!0||t===!1)return"boolean";let e=typeof t;if(p1e.includes(e))return e;if(e==="function")return"Function";if(Array.isArray(t))return"Array";if(y1e(t))return"Buffer";let r=g1e(t);return r||"Object"}function y1e(t){return t&&t.constructor&&t.constructor.isBuffer&&t.constructor.isBuffer.call(null,t)}function g1e(t){let e=Object.prototype.toString.call(t).slice(8,-1);if(m1e.includes(e))return e}h();var he=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}};he.uint=new he(0,"uint",!0);he.negint=new he(1,"negint",!0);he.bytes=new he(2,"bytes",!0);he.string=new he(3,"string",!0);he.array=new he(4,"array",!1);he.map=new he(5,"map",!1);he.tag=new he(6,"tag",!1);he.float=new he(7,"float",!0);he.false=new he(7,"false",!0);he.true=new he(7,"true",!0);he.null=new he(7,"null",!0);he.undefined=new he(7,"undefined",!0);he.break=new he(7,"break",!0);var ze=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}`}};h();h();var Ub=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",b1e=new TextDecoder,v1e=new TextEncoder;function e3(t){return Ub&&globalThis.Buffer.isBuffer(t)}function SR(t){return t instanceof Uint8Array?e3(t)?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):t:Uint8Array.from(t)}var iz=Ub?(t,e,r)=>r-e>64?globalThis.Buffer.from(t.subarray(e,r)).toString("utf8"):rz(t,e,r):(t,e,r)=>r-e>64?b1e.decode(t.subarray(e,r)):rz(t,e,r),oz=Ub?t=>t.length>64?globalThis.Buffer.from(t):tz(t):t=>t.length>64?v1e.encode(t):tz(t),Hu=t=>Uint8Array.from(t),Kb=Ub?(t,e,r)=>e3(t)?new Uint8Array(t.subarray(e,r)):t.slice(e,r):(t,e,r)=>t.slice(e,r),sz=Ub?(t,e)=>(t=t.map(r=>r instanceof Uint8Array?r:globalThis.Buffer.from(r)),SR(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},az=Ub?t=>globalThis.Buffer.allocUnsafe(t):t=>new Uint8Array(t);function cz(t,e){if(e3(t)&&e3(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 rz(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 w1e(n)}var nz=4096;function w1e(t){let e=t.length;if(e<=nz)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=Kb(n,0,this.cursor)}else r=sz(this.chunks,this.cursor);return e&&this.reset(),r}};h();var Kt="CBOR decode error:",AR="CBOR encode error:",C2=[];C2[23]=1;C2[24]=2;C2[25]=3;C2[26]=5;C2[27]=9;function wf(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`)}}Kc.encodedSize=function(e){return Oo.encodedSize(e.value)};Oo.encodedSize=function(e){return er.value?1:0};h();function hz(t,e,r,n){return new ze(he.negint,-1-Va(t,e+1,n),2)}function pz(t,e,r,n){return new ze(he.negint,-1-Ja(t,e+1,n),3)}function mz(t,e,r,n){return new ze(he.negint,-1-Ya(t,e+1,n),5)}var PR=BigInt(-1),yz=BigInt(1);function gz(t,e,r,n){let i=Za(t,e+1,n);if(typeof i!="bigint"){let o=-1-i;if(o>=Number.MIN_SAFE_INTEGER)return new ze(he.negint,o,9)}if(n.allowBigInt!==!0)throw new Error(`${Kt} integers outside of the safe integer range are not supported`);return new ze(he.negint,PR-BigInt(i),9)}function t3(t,e){let r=e.value,n=typeof r=="bigint"?r*PR-yz:r*-1-1;Oo(t,e.type.majorEncoded,n)}t3.encodedSize=function(e){let r=e.value,n=typeof r=="bigint"?r*PR-yz:r*-1-1;return nr.value?-1:0};h();function O2(t,e,r,n){wf(t,e,r+n);let i=Kb(t,e+r,e+r+n);return new ze(he.bytes,i,r+n)}function bz(t,e,r,n){return O2(t,e,1,r)}function vz(t,e,r,n){return O2(t,e,2,Va(t,e+1,n))}function wz(t,e,r,n){return O2(t,e,3,Ja(t,e+1,n))}function _z(t,e,r,n){return O2(t,e,5,Ya(t,e+1,n))}function xz(t,e,r,n){let i=Za(t,e+1,n);if(typeof i=="bigint")throw new Error(`${Kt} 64-bit integer bytes lengths not supported`);return O2(t,e,9,i)}function r3(t){return t.encodedBytes===void 0&&(t.encodedBytes=t.type===he.string?oz(t.value):t.value),t.encodedBytes}function qb(t,e){let r=r3(e);Oo(t,e.type.majorEncoded,r.length),t.push(r)}qb.encodedSize=function(e){let r=r3(e);return Oo.encodedSize(r.length)+r.length};qb.compareTokens=function(e,r){return E1e(r3(e),r3(r))};function E1e(t,e){return t.lengthe.length?1:cz(t,e)}h();function $2(t,e,r,n,i){let o=r+n;wf(t,e,o);let s=new ze(he.string,iz(t,e+r,e+o),o);return i.retainStringBytes===!0&&(s.byteValue=Kb(t,e+r,e+o)),s}function Ez(t,e,r,n){return $2(t,e,1,r,n)}function Sz(t,e,r,n){return $2(t,e,2,Va(t,e+1,n),n)}function Az(t,e,r,n){return $2(t,e,3,Ja(t,e+1,n),n)}function Pz(t,e,r,n){return $2(t,e,5,Ya(t,e+1,n),n)}function Tz(t,e,r,n){let i=Za(t,e+1,n);if(typeof i=="bigint")throw new Error(`${Kt} 64-bit integer string lengths not supported`);return $2(t,e,9,i,n)}var Iz=qb;h();function Lb(t,e,r,n){return new ze(he.array,n,r)}function kz(t,e,r,n){return Lb(t,e,1,r)}function Rz(t,e,r,n){return Lb(t,e,2,Va(t,e+1,n))}function Dz(t,e,r,n){return Lb(t,e,3,Ja(t,e+1,n))}function Mz(t,e,r,n){return Lb(t,e,5,Ya(t,e+1,n))}function Bz(t,e,r,n){let i=Za(t,e+1,n);if(typeof i=="bigint")throw new Error(`${Kt} 64-bit integer array lengths not supported`);return Lb(t,e,9,i)}function Cz(t,e,r,n){if(n.allowIndefinite===!1)throw new Error(`${Kt} indefinite length items not allowed`);return Lb(t,e,1,1/0)}function n3(t,e){Oo(t,he.array.majorEncoded,e.value)}n3.compareTokens=Kc.compareTokens;n3.encodedSize=function(e){return Oo.encodedSize(e.value)};h();function Fb(t,e,r,n){return new ze(he.map,n,r)}function Oz(t,e,r,n){return Fb(t,e,1,r)}function $z(t,e,r,n){return Fb(t,e,2,Va(t,e+1,n))}function Nz(t,e,r,n){return Fb(t,e,3,Ja(t,e+1,n))}function jz(t,e,r,n){return Fb(t,e,5,Ya(t,e+1,n))}function Uz(t,e,r,n){let i=Za(t,e+1,n);if(typeof i=="bigint")throw new Error(`${Kt} 64-bit integer map lengths not supported`);return Fb(t,e,9,i)}function Kz(t,e,r,n){if(n.allowIndefinite===!1)throw new Error(`${Kt} indefinite length items not allowed`);return Fb(t,e,1,1/0)}function i3(t,e){Oo(t,he.map.majorEncoded,e.value)}i3.compareTokens=Kc.compareTokens;i3.encodedSize=function(e){return Oo.encodedSize(e.value)};h();function qz(t,e,r,n){return new ze(he.tag,r,1)}function Lz(t,e,r,n){return new ze(he.tag,Va(t,e+1,n),2)}function Fz(t,e,r,n){return new ze(he.tag,Ja(t,e+1,n),3)}function zz(t,e,r,n){return new ze(he.tag,Ya(t,e+1,n),5)}function Gz(t,e,r,n){return new ze(he.tag,Za(t,e+1,n),9)}function o3(t,e){Oo(t,he.tag.majorEncoded,e.value)}o3.compareTokens=Kc.compareTokens;o3.encodedSize=function(e){return Oo.encodedSize(e.value)};h();var k1e=20,R1e=21,D1e=22,M1e=23;function Wz(t,e,r,n){if(n.allowUndefined===!1)throw new Error(`${Kt} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new ze(he.null,null,1):new ze(he.undefined,void 0,1)}function Hz(t,e,r,n){if(n.allowIndefinite===!1)throw new Error(`${Kt} indefinite length items not allowed`);return new ze(he.break,void 0,1)}function TR(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 ze(he.float,t,e)}function Vz(t,e,r,n){return TR(IR(t,e+1),3,n)}function Jz(t,e,r,n){return TR(kR(t,e+1),5,n)}function Yz(t,e,r,n){return TR(eG(t,e+1),9,n)}function s3(t,e,r){let n=e.value;if(n===!1)t.push([he.float.majorEncoded|k1e]);else if(n===!0)t.push([he.float.majorEncoded|R1e]);else if(n===null)t.push([he.float.majorEncoded|D1e]);else if(n===void 0)t.push([he.float.majorEncoded|M1e]);else{let i,o=!1;(!r||r.float64!==!0)&&(Xz(n),i=IR(Ud,1),n===i||Number.isNaN(n)?(Ud[0]=249,t.push(Ud.slice(0,3)),o=!0):(Qz(n),i=kR(Ud,1),n===i&&(Ud[0]=250,t.push(Ud.slice(0,5)),o=!0))),o||(B1e(n),i=eG(Ud,1),Ud[0]=251,t.push(Ud.slice(0,9)))}}s3.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){Xz(n);let i=IR(Ud,1);if(n===i||Number.isNaN(n))return 3;if(Qz(n),i=kR(Ud,1),n===i)return 5}return 9};var Zz=new ArrayBuffer(9),qc=new DataView(Zz,1),Ud=new Uint8Array(Zz,0);function Xz(t){if(t===1/0)qc.setUint16(0,31744,!1);else if(t===-1/0)qc.setUint16(0,64512,!1);else if(Number.isNaN(t))qc.setUint16(0,32256,!1);else{qc.setFloat32(0,t);let e=qc.getUint32(0),r=(e&2139095040)>>23,n=e&8388607;if(r===255)qc.setUint16(0,31744,!1);else if(r===0)qc.setUint16(0,(t&2147483648)>>16|n>>13,!1);else{let i=r-127;i<-24?qc.setUint16(0,0):i<-14?qc.setUint16(0,(e&2147483648)>>16|1<<24+i,!1):qc.setUint16(0,(e&2147483648)>>16|i+15<<10|n>>13,!1)}}}function IR(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 Qz(t){qc.setFloat32(0,t,!1)}function kR(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 B1e(t){qc.setFloat64(0,t,!1)}function eG(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)}s3.compareTokens=Kc.compareTokens;function Hr(t,e,r){throw new Error(`${Kt} encountered invalid minor (${r}) for major ${t[e]>>>5}`)}function a3(t){return()=>{throw new Error(`${Kt} ${t}`)}}var Me=[];for(let t=0;t<=23;t++)Me[t]=Hr;Me[24]=dz;Me[25]=uz;Me[26]=lz;Me[27]=fz;Me[28]=Hr;Me[29]=Hr;Me[30]=Hr;Me[31]=Hr;for(let t=32;t<=55;t++)Me[t]=Hr;Me[56]=hz;Me[57]=pz;Me[58]=mz;Me[59]=gz;Me[60]=Hr;Me[61]=Hr;Me[62]=Hr;Me[63]=Hr;for(let t=64;t<=87;t++)Me[t]=bz;Me[88]=vz;Me[89]=wz;Me[90]=_z;Me[91]=xz;Me[92]=Hr;Me[93]=Hr;Me[94]=Hr;Me[95]=a3("indefinite length bytes/strings are not supported");for(let t=96;t<=119;t++)Me[t]=Ez;Me[120]=Sz;Me[121]=Az;Me[122]=Pz;Me[123]=Tz;Me[124]=Hr;Me[125]=Hr;Me[126]=Hr;Me[127]=a3("indefinite length bytes/strings are not supported");for(let t=128;t<=151;t++)Me[t]=kz;Me[152]=Rz;Me[153]=Dz;Me[154]=Mz;Me[155]=Bz;Me[156]=Hr;Me[157]=Hr;Me[158]=Hr;Me[159]=Cz;for(let t=160;t<=183;t++)Me[t]=Oz;Me[184]=$z;Me[185]=Nz;Me[186]=jz;Me[187]=Uz;Me[188]=Hr;Me[189]=Hr;Me[190]=Hr;Me[191]=Kz;for(let t=192;t<=215;t++)Me[t]=qz;Me[216]=Lz;Me[217]=Fz;Me[218]=zz;Me[219]=Gz;Me[220]=Hr;Me[221]=Hr;Me[222]=Hr;Me[223]=Hr;for(let t=224;t<=243;t++)Me[t]=a3("simple values are not supported");Me[244]=Hr;Me[245]=Hr;Me[246]=Hr;Me[247]=Wz;Me[248]=a3("simple values are not supported");Me[249]=Vz;Me[250]=Jz;Me[251]=Yz;Me[252]=Hr;Me[253]=Hr;Me[254]=Hr;Me[255]=Hz;var Kd=[];for(let t=0;t<24;t++)Kd[t]=new ze(he.uint,t,1);for(let t=-1;t>=-24;t--)Kd[31-t]=new ze(he.negint,t,1);Kd[64]=new ze(he.bytes,new Uint8Array(0),1);Kd[96]=new ze(he.string,"",1);Kd[128]=new ze(he.array,0,1);Kd[160]=new ze(he.map,0,1);Kd[244]=new ze(he.false,!1,1);Kd[245]=new ze(he.true,!0,1);Kd[246]=new ze(he.null,null,1);function tG(t){switch(t.type){case he.false:return Hu([244]);case he.true:return Hu([245]);case he.null:return Hu([246]);case he.bytes:return t.value.length?void 0:Hu([64]);case he.string:return t.value===""?Hu([96]):void 0;case he.array:return t.value===0?Hu([128]):void 0;case he.map:return t.value===0?Hu([160]):void 0;case he.uint:return t.value<24?Hu([Number(t.value)]):void 0;case he.negint:if(t.value>=-24)return Hu([31-Number(t.value)])}}var O1e={float64:!1,mapSorter:j1e,quickEncodeToken:tG};function $1e(){let t=[];return t[he.uint.major]=Kc,t[he.negint.major]=t3,t[he.bytes.major]=qb,t[he.string.major]=Iz,t[he.array.major]=n3,t[he.map.major]=i3,t[he.tag.major]=o3,t[he.float.major]=s3,t}var rG=$1e(),RR=new B2,d3=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(`${AR} object contains circular references`);return new t(r,e)}},rp={null:new ze(he.null,null),undefined:new ze(he.undefined,void 0),true:new ze(he.true,!0),false:new ze(he.false,!1),emptyArray:new ze(he.array,0),emptyMap:new ze(he.map,0)},np={number(t,e,r,n){return!Number.isInteger(t)||!Number.isSafeInteger(t)?new ze(he.float,t):t>=0?new ze(he.uint,t):new ze(he.negint,t)},bigint(t,e,r,n){return t>=BigInt(0)?new ze(he.uint,t):new ze(he.negint,t)},Uint8Array(t,e,r,n){return new ze(he.bytes,t)},string(t,e,r,n){return new ze(he.string,t)},boolean(t,e,r,n){return t?rp.true:rp.false},null(t,e,r,n){return rp.null},undefined(t,e,r,n){return rp.undefined},ArrayBuffer(t,e,r,n){return new ze(he.bytes,new Uint8Array(t))},DataView(t,e,r,n){return new ze(he.bytes,new Uint8Array(t.buffer,t.byteOffset,t.byteLength))},Array(t,e,r,n){if(!t.length)return r.addBreakTokens===!0?[rp.emptyArray,new ze(he.break)]:rp.emptyArray;n=d3.createCheck(n,t);let i=[],o=0;for(let s of t)i[o++]=c3(s,r,n);return r.addBreakTokens?[new ze(he.array,t.length),i,new ze(he.break)]:[new ze(he.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?[rp.emptyMap,new ze(he.break)]:rp.emptyMap;n=d3.createCheck(n,t);let a=[],d=0;for(let u of o)a[d++]=[c3(u,r,n),c3(i?t.get(u):t[u],r,n)];return N1e(a,r),r.addBreakTokens?[new ze(he.map,s),a,new ze(he.break)]:[new ze(he.map,s),a]}};np.Map=np.Object;np.Buffer=np.Uint8Array;for(let t of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))np[`${t}Array`]=np.DataView;function c3(t,e={},r){let n=ez(t),i=e&&e.typeEncoders&&e.typeEncoders[n]||np[n];if(typeof i=="function"){let s=i(t,n,e,r);if(s!=null)return s}let o=np[n];if(!o)throw new Error(`${AR} unsupported type: ${n}`);return o(t,n,e,r)}function N1e(t,e){e.mapSorter&&t.sort(e.mapSorter)}function j1e(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 nG(t,e,r,n){if(Array.isArray(e))for(let i of e)nG(t,i,r,n);else r[e.type.major](t,e,n)}function U1e(t,e,r){let n=c3(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 B2(s);if(o(a,n,r),a.chunks.length!==1)throw new Error(`Unexpected error: pre-calculated length for ${n} was wrong`);return SR(a.chunks[0])}}return RR.reset(),nG(RR,n,e,r),RR.toBytes(!0)}function DR(t,e){return e=Object.assign({},O1e,e),U1e(t,rG,e)}h();var K1e={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},MR=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=Kd[e];if(r===void 0){let n=Me[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}},N2=Symbol.for("DONE"),u3=Symbol.for("BREAK");function q1e(t,e,r){let n=[];for(let i=0;iDR(t,H1e),Z1e=t=>BR(t,oG);h();h();h();h();var ba=hk({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Crt=hk({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});h();var K2=qs({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),jrt=qs({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Urt=qs({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Krt=qs({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),qrt=qs({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Lrt=qs({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Frt=qs({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),zrt=qs({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),CR=qs({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});h();var sG=(t,e)=>{let{bytes:r,version:n}=t;switch(n){case 0:return Q1e(r,OR(t),e||ba.encoder);default:return e2e(r,OR(t),e||K2.encoder)}};var aG=new WeakMap,OR=t=>{let e=aG.get(t);if(e==null){let r=new Map;return aG.set(t,r),r}return e},Or=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!==q2)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==t2e)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=yy(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&&HL(e.multihash,n.multihash)}toString(e){return sG(this,e)}toJSON(){return{"/":sG(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||cG(n,i,o.bytes))}else if(r[r2e]===!0){let{version:n,multihash:i,code:o}=r,s=$S(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!==q2)throw new Error(`Version 0 CID must use dag-pb (code: ${q2}) block encoding`);return new t(e,r,n,n.bytes)}case 1:{let i=cG(e,r,n.bytes);return new t(e,r,n,i)}default:throw new Error("Invalid version")}}static createV0(e){return t.create(0,q2,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=Bd(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 _b(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,m]=wb(e.subarray(r));return r+=m,l},i=n(),o=q2;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]=X1e(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 OR(o).set(n,e),o}},X1e=(t,e)=>{switch(t[0]){case"Q":{let r=e||ba;return[ba.prefix,r.decode(`${ba.prefix}${t}`)]}case ba.prefix:{let r=e||ba;return[ba.prefix,r.decode(t)]}case K2.prefix:{let r=e||K2;return[K2.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)]}}},Q1e=(t,e,r)=>{let{prefix:n}=r;if(n!==ba.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},e2e=(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},q2=112,t2e=18,cG=(t,e,r)=>{let n=my(t),i=n+my(e),o=new Uint8Array(i+r.byteLength);return py(t,o,0),py(e,o,n),o.set(r,i),o},r2e=Symbol.for("@ipld/js-cid/CID");h();var ip=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())})},l3=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)}},lo=function(t){return this instanceof lo?(this.v=t,this):new lo(t)},f3=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(m){n[m]&&(i[m]=function(p){return new Promise(function(g,b){o.push([m,p,g,b])>1||a(m,p)})})}function a(m,p){try{d(n[m](p))}catch(g){l(o[0][3],g)}}function d(m){m.value instanceof lo?Promise.resolve(m.value.v).then(u,c):l(o[0][2],m)}function u(m){a("next",m)}function c(m){a("throw",m)}function l(m,p){m(p),o.shift(),o.length&&a(o[0][0],o[0][1])}},L2=class{open(){return ip(this,void 0,void 0,function*(){})}close(){return ip(this,void 0,void 0,function*(){})}put(e,r,n){return ip(this,void 0,void 0,function*(){return e})}get(e,r){return ip(this,void 0,void 0,function*(){return new Uint8Array})}has(e,r){return ip(this,void 0,void 0,function*(){return!1})}delete(e,r){return ip(this,void 0,void 0,function*(){})}isEmpty(e){return ip(this,void 0,void 0,function*(){return!0})}putMany(e,r){return f3(this,arguments,function*(){var i,o,s,a;try{for(var d=!0,u=l3(e),c;c=yield lo(u.next()),i=c.done,!i;d=!0){a=c.value,d=!1;let l=a;yield lo(this.put(l.cid,l.block,r)),yield yield lo(l.cid)}}catch(l){o={error:l}}finally{try{!d&&!i&&(s=u.return)&&(yield lo(s.call(u)))}finally{if(o)throw o.error}}})}getMany(e,r){return f3(this,arguments,function*(){var i,o,s,a;try{for(var d=!0,u=l3(e),c;c=yield lo(u.next()),i=c.done,!i;d=!0){a=c.value,d=!1;let l=a;yield yield lo({cid:l,block:yield lo(this.get(l,r))})}}catch(l){o={error:l}}finally{try{!d&&!i&&(s=u.return)&&(yield lo(s.call(u)))}finally{if(o)throw o.error}}})}getAll(e){return f3(this,arguments,function*(){var n,i,o,s;let a=this.db.iterator({keys:!0,keyEncoding:"buffer"},e);try{for(var d=!0,u=l3(a),c;c=yield lo(u.next()),n=c.done,!n;d=!0){s=c.value,d=!1;let[l,m]=s;yield yield lo({cid:Or.decode(l),block:m})}}catch(l){i={error:l}}finally{try{!d&&!n&&(o=u.return)&&(yield lo(o.call(u)))}finally{if(i)throw i.error}}})}deleteMany(e,r){return f3(this,arguments,function*(){var i,o,s,a;try{for(var d=!0,u=l3(e),c;c=yield lo(u.next()),i=c.done,!i;d=!0){a=c.value,d=!1;let l=a;yield lo(this.delete(l,r)),yield yield lo(l)}}catch(l){o={error:l}}finally{try{!d&&!i&&(s=u.return)&&(yield lo(s.call(u)))}finally{if(o)throw o.error}}})}clear(){return ip(this,void 0,void 0,function*(){})}};h();var fxe=Ut(Xa(),1);h();h();h();function i2e(t){return t[Symbol.asyncIterator]!=null}function o2e(t,e=1){return e=Number(e),i2e(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 F2=o2e;async function*z2(t,e=1){for await(let r of F2(t,e)){let n=r.map(async i=>i().then(o=>({ok:!0,value:o}),o=>({ok:!1,err:o})));for(let i=0;ii+o.length,0));let r=Qa(e),n=0;for(let i of t)r.set(i,n),n+=i.length;return op(r)}h();function lG(t,e){if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let r=0;r0&&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(h3(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(h3(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=fG(this.bufs,e);return r.buf[r.index]}set(e,r){let n=fG(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 G2(n,i)}subarray(e,r){let{bufs:n,length:i}=this._subList(e,r);return n.length===1?n[0]:G2(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(!h3(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;m--){let p=this.get(l+m);if(n[m]!==p){c=Math.max(1,m-a[p]);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=Qa(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=_f(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=_f(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=_f(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=Qa(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=_f(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=_f(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=_f(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=_f(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=_f(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 s2e=262144,pG=(t={})=>{let e=t.chunkSize??s2e;return async function*(n){let i=new zb,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 zb,o=0;else{let d=new zb;d.append(i.sublist(e)),i=d,o-=e}(!s||o>0)&&(yield i.subarray(0,o))}};h();var By={};jr(By,{code:()=>Z2,createLink:()=>OG,createNode:()=>CG,decode:()=>xf,encode:()=>tc,name:()=>n_e,prepare:()=>ec,validate:()=>JR});h();h();var FR={};jr(FR,{base32:()=>Hb,base32hex:()=>b2e,base32hexpad:()=>w2e,base32hexpadupper:()=>_2e,base32hexupper:()=>v2e,base32pad:()=>y2e,base32padupper:()=>g2e,base32upper:()=>m2e,base32z:()=>x2e});h();h();var Gb={};jr(Gb,{coerce:()=>Vu,empty:()=>mG,equals:()=>$R,fromHex:()=>c2e,fromString:()=>NR,isBinary:()=>d2e,toHex:()=>a2e,toString:()=>jR});h();var mG=new Uint8Array(0);function a2e(t){return t.reduce((e,r)=>e+r.toString(16).padStart(2,"0"),"")}function c2e(t){let e=t.match(/../g);return e!=null?new Uint8Array(e.map(r=>parseInt(r,16))):mG}function $R(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(P);A!==I;){for(var N=g[A],L=0,F=P-1;(N!==0||L>>0,$[F]=N%a>>>0,N=N/a>>>0;if(N!==0)throw new Error("Non-zero carry");S=L,A++}for(var U=P-S;U!==P&&$[U]===0;)U++;for(var G=d.repeat(b);U>>0,P=new Uint8Array(I);g[b];){var $=r[g.charCodeAt(b)];if($===255)return;for(var N=0,L=I-1;($!==0||N>>0,P[L]=$%256>>>0,$=$/256>>>0;if($!==0)throw new Error("Non-zero carry");A=N,b++}if(g[b]!==" "){for(var F=I-A;F!==I&&P[F]===0;)F++;for(var U=new Uint8Array(S+(I-F)),G=S;F!==I;)U[G++]=P[F++];return U}}}function p(g){var b=m(g);if(b)return b;throw new Error(`Non-${e} character`)}return{encode:l,decodeUnsafe:m,decode:p}}var l2e=u2e,f2e=l2e,yG=f2e;var UR=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")}},KR=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 gG(this,e)}},qR=class{decoders;constructor(e){this.decoders=e}or(e){return gG(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 gG(t,e){return new qR({...t.decoders??{[t.prefix]:t},...e.decoders??{[e.prefix]:e}})}var LR=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 UR(e,r,n),this.decoder=new KR(e,r,i)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function Wb({name:t,prefix:e,encode:r,decode:n}){return new LR(t,e,r,n)}function sp({name:t,prefix:e,alphabet:r}){let{encode:n,decode:i}=yG(r,t);return Wb({prefix:e,name:t,encode:n,decode:o=>Vu(i(o))})}function h2e(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 p2e(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<Ju,base58flickr:()=>E2e});h();var Ju=sp({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),E2e=sp({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});h();h();h();var S2e=wG,bG=128,A2e=127,P2e=~A2e,T2e=Math.pow(2,31);function wG(t,e,r){e=e||[],r=r||0;for(var n=r;t>=T2e;)e[r++]=t&255|bG,t/=128;for(;t&P2e;)e[r++]=t&255|bG,t>>>=7;return e[r]=t|0,wG.bytes=r-n+1,e}var I2e=GR,k2e=128,vG=127;function GR(t,n){var r=0,n=n||0,i=0,o=n,s,a=t.length;do{if(o>=a)throw GR.bytes=0,new RangeError("Could not decode varint");s=t[o++],r+=i<28?(s&vG)<=k2e);return GR.bytes=o-n,r}var R2e=Math.pow(2,7),D2e=Math.pow(2,14),M2e=Math.pow(2,21),B2e=Math.pow(2,28),C2e=Math.pow(2,35),O2e=Math.pow(2,42),$2e=Math.pow(2,49),N2e=Math.pow(2,56),j2e=Math.pow(2,63),U2e=function(t){return t{let[l,m]=H2(e.subarray(r));return r+=m,l},i=n(),o=J2;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]=L2e(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 WR(o).set(n,e),o}};function L2e(t,e){switch(t[0]){case"Q":{let r=e??Ju;return[Ju.prefix,r.decode(`${Ju.prefix}${t}`)]}case Ju.prefix:{let r=e??Ju;return[Ju.prefix,r.decode(t)]}case Hb.prefix:{let r=e??Hb;return[Hb.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 F2e(t,e,r){let{prefix:n}=r;if(n!==Ju.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 z2e(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 J2=112,G2e=18;function AG(t,e,r){let n=Jb(t),i=n+Jb(e),o=new Uint8Array(i+r.byteLength);return Vb(t,o,0),Vb(e,o,n),o.set(r,i),o}var W2e=Symbol.for("@ipld/js-cid/CID");h();var H2e=new TextDecoder;function HR(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 PG(t,e){let r;return[r,e]=HR(t,e),[r&7,r>>3,e]}function V2e(t){let e={},r=t.length,n=0;for(;nr)throw new Error("protobuf: (PBLink) unexpected end of data");return e}function TG(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}h();var kG=new TextEncoder,IG=2**32,J2e=2**31;function Y2e(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=Y2(e,r,t.Tsize)-1,e[r]=24}if(typeof t.Name=="string"){let n=kG.encode(t.Name);r-=n.length,e.set(n,r),r=Y2(e,r,n.length)-1,e[r]=18}return t.Hash&&(r-=t.Hash.length,e.set(t.Hash,r),r=Y2(e,r,t.Hash.length)-1,e[r]=10),e.length-r}function RG(t){let e=X2e(t),r=new Uint8Array(e),n=e;if(t.Data&&(n-=t.Data.length,r.set(t.Data,n),n=Y2(r,n,t.Data.length)-1,r[n]=10),t.Links)for(let i=t.Links.length-1;i>=0;i--){let o=Y2e(t.Links[i],r.subarray(0,n));n-=o,n=Y2(r,n,o)-1,r[n]=18}return r}function Z2e(t){let e=0;if(t.Hash){let r=t.Hash.length;e+=1+r+Zb(r)}if(typeof t.Name=="string"){let r=kG.encode(t.Name).length;e+=1+r+Zb(r)}return typeof t.Tsize=="number"&&(e+=1+Zb(t.Tsize)),e}function X2e(t){let e=0;if(t.Data){let r=t.Data.length;e+=1+r+Zb(r)}if(t.Links)for(let r of t.Links){let n=Z2e(r);e+=1+n+Zb(n)}return e}function Y2(t,e,r){e-=Zb(r);let n=e;for(;r>=J2e;)t[e++]=r&127|128,r/=128;for(;r>=128;)t[e++]=r&127|128,r>>>=7;return t[e]=r,n}function Zb(t){return t%2===0&&t++,Math.floor((Q2e(t)+6)/7)}function Q2e(t){let e=0;return t>=IG&&(t=Math.floor(t/IG),e=32),t>=65536&&(t>>>=16,e+=16),t>=256&&(t>>>=8,e+=8),e+e_e[t]}var e_e=[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];h();var t_e=["Data","Links"],r_e=["Hash","Name","Tsize"],VR=new TextEncoder;function MG(t,e){if(t===e)return 0;let r=t.Name?VR.encode(t.Name):[],n=e.Name?VR.encode(e.Name):[],i=r.length,o=n.length;for(let s=0,a=Math.min(i,o);s!e.includes(r))}function BG(t){if(typeof t.asCID=="object"){let r=va.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=va.asCID(t.Hash);try{r||(typeof t.Hash=="string"?r=va.parse(t.Hash):t.Hash instanceof Uint8Array&&(r=va.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 ec(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=VR.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(BG),e.Links.sort(MG);else throw new TypeError("Invalid DAG-PB form");else e.Links=[];return e}function JR(t){if(!t||typeof t!="object"||Array.isArray(t)||t instanceof Uint8Array||t["/"]&&t["/"]===t.bytes)throw new TypeError("Invalid DAG-PB form");if(!DG(t,t_e))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&&MG(r,t.Links[e-1])===-1)throw new TypeError("Invalid DAG-PB form (links must be sorted by Name bytes)")}}function CG(t,e=[]){return ec({Data:t,Links:e})}function OG(t,e,r){return BG({Hash:r,Name:t,Tsize:e})}function $G(t){return t instanceof ArrayBuffer?new Uint8Array(t,0,t.byteLength):t}var n_e="dag-pb",Z2=112;function tc(t){JR(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),RG(e)}function xf(t){let e=$G(t),r=TG(e),n={};return r.Data&&(n.Data=r.Data),r.Links&&(n.Links=r.Links.map(i=>{let o={};try{o.Hash=va.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}h();var _9=Ut(Xa(),1);h();h();h();h();h();var i_e=Math.pow(2,7),o_e=Math.pow(2,14),s_e=Math.pow(2,21),NG=Math.pow(2,28),jG=Math.pow(2,35),UG=Math.pow(2,42),KG=Math.pow(2,49),Vs=128,ap=127;function X2(t){if(tNumber.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function qG(t,e,r=0){switch(X2(t)){case 8:e[r++]=t&255|Vs,t/=128;case 7:e[r++]=t&255|Vs,t/=128;case 6:e[r++]=t&255|Vs,t/=128;case 5:e[r++]=t&255|Vs,t/=128;case 4:e[r++]=t&255|Vs,t>>>=7;case 3:e[r++]=t&255|Vs,t>>>=7;case 2:e[r++]=t&255|Vs,t>>>=7;case 1:{e[r++]=t&255,t>>>=7;break}default:throw new Error("unreachable")}return e}function LG(t,e){let r=t[e],n=0;if(n+=r&ap,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 Cy;if(ec_e)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>HG&&(i=0n,++n>HG&&(n=0n))),new t(Number(i),Number(n))}static fromNumber(e){if(e===0)return Cy;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):Cy}},Cy=new rc(0,0);Cy.toBigInt=function(){return 0n};Cy.zzEncode=Cy.zzDecode=function(){return this};Cy.length=function(){return 1};var HG=4294967296n;h();function VG(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 XR(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 qd(t,e){return RangeError(`index out of range: ${t.pos} + ${e??1} > ${t.len}`)}function y3(t,e){return(t[e-4]|t[e-3]<<8|t[e-2]<<16|t[e-1]<<24)>>>0}var QR=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,qd(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 qd(this,4);return y3(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw qd(this,4);return y3(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw qd(this,4);let e=zG(this.buf,this.pos);return this.pos+=4,e}double(){if(this.pos+8>this.len)throw qd(this,4);let e=WG(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 qd(this,e);return this.pos+=e,r===n?new Uint8Array(0):this.buf.subarray(r,n)}string(){let e=this.bytes();return JG(e,0,e.length)}skip(e){if(typeof e=="number"){if(this.pos+e>this.len)throw qd(this,e);this.pos+=e}else do if(this.pos>=this.len)throw qd(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 rc(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 qd(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 qd(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 qd(this,8);let e=y3(this.buf,this.pos+=4),r=y3(this.buf,this.pos+=4);return new rc(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=LG(this.buf,this.pos);return this.pos+=X2(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 e9(t){return new QR(t instanceof Uint8Array?t:t.subarray())}function Q2(t,e,r){let n=e9(t);return e.decode(n,void 0,r)}h();h();h();h();h();var t9={};jr(t9,{base10:()=>d_e});h();var d_e=sp({prefix:"9",name:"base10",alphabet:"0123456789"});var r9={};jr(r9,{base16:()=>u_e,base16upper:()=>l_e});h();var u_e=oi({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),l_e=oi({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var n9={};jr(n9,{base2:()=>f_e});h();var f_e=oi({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var i9={};jr(i9,{base256emoji:()=>g_e});h();var ZG=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}"),h_e=ZG.reduce((t,e,r)=>(t[r]=e,t),[]),p_e=ZG.reduce((t,e,r)=>(t[e.codePointAt(0)]=r,t),[]);function m_e(t){return t.reduce((e,r)=>(e+=h_e[r],e),"")}function y_e(t){let e=[];for(let r of t){let n=p_e[r.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(n)}return new Uint8Array(e)}var g_e=Wb({prefix:"\u{1F680}",name:"base256emoji",encode:m_e,decode:y_e});var o9={};jr(o9,{base36:()=>b_e,base36upper:()=>v_e});h();var b_e=sp({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),v_e=sp({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var s9={};jr(s9,{base64:()=>w_e,base64pad:()=>__e,base64url:()=>x_e,base64urlpad:()=>E_e});h();var w_e=oi({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),__e=oi({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),x_e=oi({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),E_e=oi({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var a9={};jr(a9,{base8:()=>S_e});h();var S_e=oi({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var c9={};jr(c9,{identity:()=>A_e});h();var A_e=Wb({prefix:"\0",name:"identity",encode:t=>jR(t),decode:t=>NR(t)});h();var Xit=new TextEncoder,Qit=new TextDecoder;h();var d9={};jr(d9,{identity:()=>R_e});h();var XG=0,I_e="identity",QG=Vu;function k_e(t){return My(XG,QG(t))}var R_e={code:XG,name:I_e,encode:QG,digest:k_e};var l9={};jr(l9,{sha256:()=>D_e,sha512:()=>M_e});h();h();function Oy({name:t,code:e,encode:r}){return new u9(t,e,r)}var u9=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?My(this.code,r):r.then(n=>My(this.code,n))}else throw Error("Unknown type, must be binary type")}};function tW(t){return async e=>new Uint8Array(await crypto.subtle.digest(t,e))}var D_e=Oy({name:"sha2-256",code:18,encode:tW("SHA-256")}),M_e=Oy({name:"sha2-512",code:19,encode:tW("SHA-512")});h();h();h();h();h();h();var f9={...c9,...n9,...a9,...t9,...r9,...FR,...o9,...zR,...s9,...i9},Eot={...l9,...d9};function nW(t,e,r,n){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:n}}}var rW=nW("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),h9=nW("ascii","a",t=>{let e="a";for(let r=0;r{t=t.substring(1);let e=Qa(t.length);for(let r=0;r>>1,n,i=e;return function(s){if(s<1||s>r)return Qa(s);i+s>e&&(n=Qa(e),i=0);let a=n.subarray(i,i+=s);return i&7&&(i=(i|7)+1),a}}var $y=class{fn;len;next;val;constructor(e,r,n){this.fn=e,this.len=r,this.next=void 0,this.val=n}};function m9(){}var g9=class{head;tail;len;next;constructor(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}},C_e=p9();function O_e(t){return globalThis.Buffer!=null?Qa(t):C_e(t)}var t_=class{len;head;tail;states;constructor(){this.len=0,this.head=new $y(m9,0,0),this.tail=this.head,this.states=null}_push(e,r,n){return this.tail=this.tail.next=new $y(e,r,n),this.len+=r,this}uint32(e){return this.len+=(this.tail=this.tail.next=new b9((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(b3,10,rc.fromNumber(e)):this.uint32(e)}sint32(e){return this.uint32((e<<1^e>>31)>>>0)}uint64(e){let r=rc.fromBigInt(e);return this._push(b3,r.length(),r)}uint64Number(e){return this._push(qG,X2(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=rc.fromBigInt(e).zzEncode();return this._push(b3,r.length(),r)}sint64Number(e){let r=rc.fromNumber(e).zzEncode();return this._push(b3,r.length(),r)}sint64String(e){return this.sint64(BigInt(e))}bool(e){return this._push(y9,1,e?1:0)}fixed32(e){return this._push(e_,4,e>>>0)}sfixed32(e){return this.fixed32(e)}fixed64(e){let r=rc.fromBigInt(e);return this._push(e_,4,r.lo)._push(e_,4,r.hi)}fixed64Number(e){let r=rc.fromNumber(e);return this._push(e_,4,r.lo)._push(e_,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(FG,4,e)}double(e){return this._push(GG,8,e)}bytes(e){let r=e.length>>>0;return r===0?this._push(y9,1,0):this.uint32(r)._push(N_e,r,e)}string(e){let r=VG(e);return r!==0?this.uint32(r)._push(XR,r,e):this._push(y9,1,0)}fork(){return this.states=new g9(this),this.head=this.tail=new $y(m9,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 $y(m9,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=O_e(this.len),n=0;for(;e!=null;)e.fn(e.val,r,n),n+=e.len,e=e.next;return r}};function y9(t,e,r){e[r]=t&255}function $_e(t,e,r){for(;t>127;)e[r++]=t&127|128,t>>>=7;e[r]=t}var b9=class extends $y{next;constructor(e,r){super($_e,e,r),this.next=void 0}};function b3(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 e_(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 N_e(t,e,r){e.set(t,r)}globalThis.Buffer!=null&&(t_.prototype.bytes=function(t){let e=t.length>>>0;return this.uint32(e),e>0&&this._push(j_e,e,t),this},t_.prototype.string=function(t){let e=globalThis.Buffer.byteLength(t);return this.uint32(e),e>0&&this._push(U_e,e,t),this});function j_e(t,e,r){e.set(t,r)}function U_e(t,e,r){t.length<40?XR(t,e,r):e.utf8Write!=null?e.utf8Write(t,r):e.set(g3(t),r)}function v9(){return new t_}function r_(t,e){let r=v9();return e.encode(t,r,{lengthDelimited:!1}),r.finish()}h();h();var Xb;(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"})(Xb||(Xb={}));function v3(t,e,r,n){return{name:t,type:e,encode:r,decode:n}}function w9(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 v3("enum",Xb.VARINT,r,n)}h();function n_(t,e){return v3("message",Xb.LENGTH_DELIMITED,t,e)}var Ld;(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=()=>w9(r)}(e=t.DataType||(t.DataType={}));let n;t.codec=()=>(n==null&&(n=n_((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),w3.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=w3.codec().decode(i,i.uint32());break;default:i.skipType(d&7);break}}return s})),n),t.encode=i=>r_(i,t.codec()),t.decode=i=>Q2(i,t.codec())})(Ld||(Ld={}));var w3;(function(t){let e;t.codec=()=>(e==null&&(e=n_((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=>r_(r,t.codec()),t.decode=r=>Q2(r,t.codec())})(w3||(w3={}));var oW;(function(t){let e;t.codec=()=>(e==null&&(e=n_((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=>r_(r,t.codec()),t.decode=r=>Q2(r,t.codec())})(oW||(oW={}));var sW={Raw:"raw",Directory:"directory",File:"file",Metadata:"metadata",Symlink:"symlink",HAMTShard:"hamt-sharded-directory"},K_e=["directory","hamt-sharded-directory"],aW=parseInt("0644",8),cW=parseInt("0755",8),fo=class t{static unmarshal(e){let r=Ld.decode(e),n=new t({type:sW[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(sW).includes(r))throw(0,_9.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()?cW:aW:this._mode=e&4095}get mode(){return this._mode}isDirectory(){return K_e.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=Ld.DataType.Raw;break;case"directory":e=Ld.DataType.Directory;break;case"file":e=Ld.DataType.File;break;case"metadata":e=Ld.DataType.Metadata;break;case"symlink":e=Ld.DataType.Symlink;break;case"hamt-sharded-directory":e=Ld.DataType.HAMTShard;break;default:throw(0,_9.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===aW&&!this.isDirectory()&&(n=void 0),n===cW&&this.isDirectory()&&(n=void 0));let i;return this.mtime!=null&&(i={Seconds:this.mtime.secs,FractionalNanoseconds:this.mtime.nsecs}),Ld.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 Qb={};jr(Qb,{code:()=>dp,decode:()=>F_e,encode:()=>L_e,name:()=>q_e});h();var q_e="raw",dp=85,L_e=t=>Bd(t),F_e=t=>Bd(t);h();var si=class extends Event{constructor(e,r){super(e),this.detail=r}};h();var Fd=async(t,e,r)=>{r.codec==null&&(r.codec=By);let n=await ps.digest(t),i=Or.create(r.cidVersion,r.codec.code,n);return await e.put(i,t,r),i};function dW(t){return async function*(r,n){let i=0n;for await(let o of r.content)yield async()=>{let s,a={codec:By,cidVersion:t.cidVersion,onProgress:t.onProgress};t.rawLeaves?(a.codec=Qb,a.cidVersion=1):(s=new fo({type:t.leafType,data:o}),o=tc({Data:s.marshal(),Links:[]}));let d=await Fd(o,n,a);return i+=BigInt(o.byteLength),t.onProgress?.(new si("unixfs:importer:progress:file:write",{bytesWritten:i,cid:d,path:r.path})),{cid:d,unixfs:s,size:BigInt(o.length),block:o}}}}h();var x9=Ut(Xa(),1);h();var uW=async(t,e,r)=>{let n=new fo({type:"directory",mtime:t.mtime,mode:t.mode}),i=tc(ec({Data:n.marshal()})),o=await Fd(i,e,r),s=t.path;return{cid:o,path:s,unixfs:n,size:BigInt(i.length),originalPath:t.originalPath,block:i}};h();async function*z_e(t,e,r){let n=-1,i;for await(let o of z2(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 lW(t){return t.single===!0}var G_e=(t,e,r)=>async function(i){if(i.length===1&&lW(i[0])&&r.reduceSingleLeafToSelf){let c=i[0],l=c.block;return lW(c)&&(t.mtime!==void 0||t.mode!==void 0)&&(c.unixfs=new fo({type:"file",mtime:t.mtime,mode:t.mode,data:c.block}),l={Data:c.unixfs.marshal(),Links:[]},c.block=tc(ec(l)),c.cid=await Fd(c.block,e,{...r,cidVersion:r.cidVersion}),c.size=BigInt(c.block.length)),r.onProgress?.(new si("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 fo({type:"file",mtime:t.mtime,mode:t.mode}),s=i.filter(c=>c.cid.code===dp&&c.size>0||c.unixfs!=null&&c.unixfs.data==null&&c.unixfs.fileSize()>0n?!0:!!c.unixfs?.data?.length).map(c=>c.cid.code===dp?(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=tc(ec(a)),u=await Fd(d,e,r);return r.onProgress?.(new si("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}},fW=async(t,e,r)=>r.layout(z_e(t,e,r),G_e(t,e,r));function W_e(t){return Symbol.iterator in t}function H_e(t){return Symbol.asyncIterator in t}function V_e(t){try{if(t instanceof Uint8Array)return async function*(){yield t}();if(W_e(t))return async function*(){yield*t}();if(H_e(t))return t}catch{throw(0,x9.default)(new Error("Content was invalid"),"ERR_INVALID_CONTENT")}throw(0,x9.default)(new Error("Content was invalid"),"ERR_INVALID_CONTENT")}function hW(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("/")),J_e(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(V_e(i.content)))){let u=BigInt(d.byteLength);a+=u,t.onProgress?.(new si("unixfs:importer:progress:file:read",{bytesRead:a,chunkSize:u,path:i.path})),yield d}}(),originalPath:o};yield async()=>fW(s,n,t)}else if(i.path!=null){let s={path:i.path,mtime:i.mtime,mode:i.mode,originalPath:o};yield async()=>uW(s,n,t)}else throw new Error("Import candidate must have content or path or both")}}}function J_e(t){return t.content!=null}h();var E9=Ut(Xa(),1);var pW=()=>async function*(e){for await(let r of e){if(r.length===void 0)throw(0,E9.default)(new Error("Content was invalid"),"ERR_INVALID_CONTENT");if(typeof r=="string"||r instanceof String)yield I2(r.toString());else if(Array.isArray(r))yield Uint8Array.from(r);else if(r instanceof Uint8Array)yield r;else throw(0,E9.default)(new Error("Content was invalid"),"ERR_INVALID_CONTENT")}};h();h();var Y_e=174;function S9(t){let e=t?.maxChildrenPerNode??Y_e;return async function r(n,i){let o=[];for await(let s of F2(n,e))o.push(await i(s));return o.length>1?r(o,i):o[0]}}h();h();h();h();h();h();var Yu=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}},i_=Or.parse("QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn"),o_=Or.parse("zdj7WbTaiJT1fgatdet9Ei9iDB5hdCxkbVyhyh8YTUnXMiwYi");var Ny=class extends Yu{_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?o_.bytes.byteLength:i_.bytes.byteLength));return this.nodeSize}async*flush(e){let r=[];for(let[d,u]of this._children.entries()){let c=u;if(u instanceof Yu)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 fo({type:"directory",mtime:this.mtime,mode:this.mode}),i={Data:n.marshal(),Links:r},o=tc(ec(i)),s=await Fd(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)}}};h();h();h();var x3=Ut(gW(),1);function Z_e(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 Iat=Oy({name:"murmur3-32",code:35,encode:t=>Z_e(x3.default.x86.hash32(t))}),E3=Oy({name:"murmur3-128",code:34,encode:t=>Gb.fromHex(x3.default.x64.hash128(t))}),kat=Oy({name:"murmur3-x64-64",code:34,encode:t=>Gb.fromHex(x3.default.x64.hash128(t)).subarray(0,8)});h();h();var _W=Ut(wW(),1);var Zu=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 _W.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 xW(this,e,r)}toJSON(){return this.serialize(rxe,nxe)}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"?g3(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(txe);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 txe(t){return!!t}function rxe(t,e){return t.key}function nxe(t){return t}async function xW(t,e,r){let n=[];for(let i of t._children.compactArray())if(i instanceof Zu)await xW(i,e,r);else{let o=await e(i);n.push({bitField:t._children.bitField(),children:o})}return r(n)}h();h();var ixe=[255,254,252,248,240,224,192,128],oxe=[1,3,7,15,31,63,127,255],S3=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=sxe(i,o-s,s);n=(n<7;)this._currentBitPos-=8,this._currentBytePos+=1}_haveBits(){return this._currentBytePos>=0}};function sxe(t,e,r){let n=axe(e,r);return(t&n)>>>e}function axe(t,e){return ixe[t]&oxe[Math.min(e+t-1,7)]}function EW(t){function e(r){return r instanceof A3?r:new A3(r,t)}return e}var A3=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?G2([this._value,Uint8Array.from([this._depth])]):this._value,r=await this._hashFn(e),n=new S3(r);this._buffers.push(n),this._availableBits+=n.availableBits()}};function P3(t){if(t==null||t.hashFn==null)throw new Error("please define an options.hashFn");let e={bits:t.bits??8,hash:EW(t.hashFn)};return new Zu(e)}async function cxe(t){return(await E3.encode(t)).slice(0,8).reverse()}var SW=BigInt(34),A9=class extends Yu{_bucket;constructor(e,r){super(e,r),this._bucket=P3({hashFn:cxe,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=TW(this._bucket,this,this.options),this.nodeSize)}async*flush(e){for await(let r of PW(this._bucket,e,this,this.options))yield{...r,path:this.path}}},AW=A9;async function*PW(t,e,r,n){let i=t._children,o=[],s=0n;for(let p=0;pr&&(i=await uxe(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 P9(i,o,r,n)}return i}async function uxe(t,e){let r=new AW({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}h();var IW=(t="")=>(t.trim().match(/([^\\/]|\\\/)+/g)??[]).filter(Boolean);async function lxe(t,e,r){let n=IW(t.path??""),i=n.length-1,o=e,s="";for(let a=0;a1)yield*kW(i,n);else for await(let a of i.eachChildSeries())a!=null&&(yield*kW(a.child,n))}}async function*a_(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,m=r.chunker??pG(),p=r.chunkValidator??pW(),g=r.dagBuilder??hW({chunker:m,chunkValidator:p,wrapWithDirectory:i,layout:r.layout??S9(),bufferImporter:r.bufferImporter??dW({cidVersion:s,rawLeaves:a,leafType:d,onProgress:r.onProgress}),blockWriteConcurrency:c,reduceSingleLeafToSelf:l,cidVersion:s,onProgress:r.onProgress}),b=r.treeBuilder??RW({wrapWithDirectory:i,shardSplitThresholdBytes:o,cidVersion:s,onProgress:r.onProgress});for await(let S of b(z2(g(n,e),u),e))yield{cid:S.cid,path:S.path,unixfs:S.unixfs,size:S.size}}var T9=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())})},DW=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)}},MW={[ps.code]:ps},BW={[U2]:Dy},Sn=class{static computeCid(e,r=U2,n=ps.code){return T9(this,void 0,void 0,function*(){let i=BW[r];if(!i)throw new oe(ne.ComputeCidCodecNotSupported,`codec [${r}] not supported`);let o=MW[n];if(!o)throw new oe(ne.ComputeCidMultihashNotSupported,`multihash code [${n}] not supported`);let s=i.encode(e),a=yield o.digest(s);return(yield Or.createV1(i.code,a)).toString()})}static parseCid(e){let r=Or.parse(e).toV1();if(!BW[r.code])throw new oe(ne.ParseCidCodecNotSupported,`codec [${r.code}] not supported`);if(!MW[r.multihash.code])throw new oe(ne.ParseCidMultihashNotSupported,`multihash code [${r.multihash.code}] not supported`);return r}static computeDagPbCidFromBytes(e){var r,n,i,o;return T9(this,void 0,void 0,function*(){let s=a_([{content:e}],new L2,{cidVersion:1}),a;try{for(var d=!0,u=DW(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 T9(this,void 0,void 0,function*(){let s=a_([{content:e}],new L2,{cidVersion:1}),a;try{for(var d=!0,u=DW(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():""})}};h();var S4=Ut(S5(),1),zp=Ut(nre(),1),vC=Ut(x4(),1),E4=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())})};zp.ECIES_CONFIG.isEphemeralKeyCompressed=!0;var Hf=class t{static aes256CtrEncrypt(e,r,n){return E4(this,void 0,void 0,function*(){let i=S4.createCipheriv("aes-256-ctr",e,r),o=new vC.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 E4(this,void 0,void 0,function*(){let i=S4.createDecipheriv("aes-256-ctr",e,r),o=new vC.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 E4(this,void 0,void 0,function*(){let n=O.Buffer.from(e),i=O.Buffer.from(r),o=zp.encrypt(n,i),s=0,a=t.isEphemeralKeyCompressed?33:65,d=o.subarray(s,a);s=a,a+=zp.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 E4(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 zp.decrypt(r,n)})}static get isEphemeralKeyCompressed(){return zp.ECIES_CONFIG.isEphemeralKeyCompressed}},Gp;(function(t){t.Aes256Ctr="A256CTR",t.EciesSecp256k1="ECIES-ES256K"})(Gp||(Gp={}));h();var Wie=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())})},R0=class t{constructor(e){this.jws=e}static create(e,r=[]){return Wie(this,void 0,void 0,function*(){let n={payload:Ye.bytesToBase64Url(e),signatures:[]},i=new t(n);for(let o of r)yield i.addSignature(o);return i})}addSignature(e){return Wie(this,void 0,void 0,function*(){let r={kid:e.keyId,alg:e.algorithm},n=JSON.stringify(r),i=Ye.stringToBase64Url(n),o=`${i}.${this.jws.payload}`,s=Ye.stringToBytes(o),a=yield e.sign(s),d=Ye.bytesToBase64Url(a);this.jws.signatures.push({protected:i,signature:d})})}getJws(){return this.jws}};h();h();h();var A4=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function xx(){if(A4&&typeof A4.subtle=="object"&&A4.subtle!=null)return A4.subtle;throw new Error("crypto.subtle must be defined")}h();function vBe(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}function Ex(t,...e){if(!vBe(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}`)}var Hie={async encrypt(t,e,r,n){let i=xx(),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=xx(),o=await i.importKey("raw",t,e,!0,["decrypt"]),s=await i.decrypt(r,o,n);return new Uint8Array(s)}},vl={CBC:"AES-CBC",CTR:"AES-CTR",GCM:"AES-GCM"};function wBe(t,e,r){if(t===vl.CBC)return{name:vl.CBC,iv:e};if(t===vl.CTR)return{name:vl.CTR,counter:e,length:64};if(t===vl.GCM)return r?{name:vl.GCM,iv:e,additionalData:r}:{name:vl.GCM,iv:e};throw new Error("unknown aes block mode")}function wC(t){return(e,r,n)=>{Ex(e),Ex(r);let i={name:t,length:e.length*8},o=wBe(t,r,n);return{encrypt(s){return Ex(s),Hie.encrypt(e,i,o,s)},decrypt(s){return Ex(s),Hie.decrypt(e,i,o,s)}}}}var Vyt=wC(vl.CBC),Jyt=wC(vl.CTR),Yyt=wC(vl.GCM);var P4=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())})},Ni;(function(t){t.DataFormats="dataFormats",t.ProtocolContext="protocolContext",t.ProtocolPath="protocolPath",t.Schemas="schemas"})(Ni||(Ni={}));var D0=class t{static derivePrivateKey(e,r){var n;return P4(this,void 0,void 0,function*(){let i=Ci.privateJwkToBytes(e.derivedPrivateKey),o=(n=e.derivationPath)!==null&&n!==void 0?n:[],s=yield t.derivePrivateKeyBytes(i,r),a=yield Ci.privateKeyToJwk(s);return{rootKeyId:e.rootKeyId,derivationScheme:e.derivationScheme,derivationPath:[...o,...r],derivedPrivateKey:a}})}static derivePublicKey(e,r){return P4(this,void 0,void 0,function*(){let n=yield t.derivePrivateKey(e,r);return yield Ci.getPublicJwk(n.derivedPrivateKey)})}static derivePrivateKeyBytes(e,r){return P4(this,void 0,void 0,function*(){t.validateKeyDerivationPath(r);let n=e;for(let i of r){let o=Ye.stringToBytes(i);n=yield t.deriveKeyUsingHkdf({hashAlgorithm:"SHA-256",initialKeyMaterial:n,info:o,keyLengthInBytes:32})}return n})}static deriveKeyUsingHkdf(e){return P4(this,void 0,void 0,function*(){let{hashAlgorithm:r,initialKeyMaterial:n,info:i,keyLengthInBytes:o}=e,a=yield xx().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 oe(ne.HdKeyDerivationPathInvalid,`Invalid key derivation path: ${e}`)}};h();h();function Sx(t,e){return t>e?1:t{t[e]===void 0?delete t[e]:typeof t[e]=="object"&&vn(t[e])})}var wl=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())})},be=class t{static validateJsonSchema(e){let r=e.descriptor.interface,n=e.descriptor.method,i=r+n;vf(i,e)}static getSigner(e){return e.authorization===void 0?void 0:Qr.getSignerDid(e.authorization.signature.signatures[0])}static getCid(e){return wl(this,void 0,void 0,function*(){let r=Object.assign({},e);return r.encodedData&&delete r.encodedData,yield Sn.computeCid(r)})}static compareCid(e,r){return wl(this,void 0,void 0,function*(){let n=yield t.getCid(e),i=yield t.getCid(r);return Sx(n,i)})}static createAuthorization(e){return wl(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 wl(this,void 0,void 0,function*(){let i=yield Sn.computeCid(e),o=Object.assign({descriptorCid:i},n);vn(o);let s=Ye.objectToBytes(o);return(yield R0.create(s,[r])).getJws()})}static getNewestMessage(e){return wl(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 wl(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 wl(this,void 0,void 0,function*(){return(yield t.compareMessageTimestamp(e,r))>0})}static isOlder(e,r){return wl(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 wl(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&&rb.rootKeyId===r.rootKeyId&&b.derivationScheme===r.derivationScheme);if(o===void 0)throw new oe(ne.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=Ye.base64UrlToBytes(o.encryptedKey),u=Ci.publicJwkToBytes(o.ephemeralPublicKey),c=Ye.base64UrlToBytes(o.initializationVector),l=Ye.base64UrlToBytes(o.messageAuthenticationCode),m=yield Hf.eciesSecp256k1Decrypt({ciphertext:d,ephemeralPublicKey:u,initializationVector:c,messageAuthenticationCode:l,privateKey:a}),p=Ye.base64UrlToBytes(i.initializationVector);return yield Hf.aes256CtrDecrypt(m,p,n)})}static constructKeyDerivationPath(e,r){let n=r.descriptor,i=r.contextId,o;return e===Ni.DataFormats?o=t.constructKeyDerivationPathUsingDataFormatsScheme(n.schema,n.dataFormat):e===Ni.ProtocolPath?o=t.constructKeyDerivationPathUsingProtocolPathScheme(n):e===Ni.ProtocolContext?o=t.constructKeyDerivationPathUsingProtocolContextScheme(i):o=t.constructKeyDerivationPathUsingSchemasScheme(n.schema),o}static constructKeyDerivationPathUsingDataFormatsScheme(e,r){return e!==void 0?[Ni.DataFormats,e,r]:[Ni.DataFormats,r]}static constructKeyDerivationPathUsingProtocolPathScheme(e){if(e.protocol===void 0)throw new oe(ne.RecordsProtocolPathDerivationSchemeMissingProtocol,"Unable to construct key derivation path using `protocols` scheme because `protocol` is missing.");let r=e.protocolPath.split("/");return[Ni.ProtocolPath,e.protocol,...r]}static constructKeyDerivationPathUsingProtocolContextScheme(e){if(e===void 0)throw new oe(ne.RecordsProtocolContextDerivationSchemeMissingContextId,"Unable to construct key derivation path using `protocolContext` scheme because `contextId` is missing.");let r=e.split("/")[0];return[Ni.ProtocolContext,r]}static constructKeyDerivationPathUsingSchemasScheme(e){if(e===void 0)throw new oe(ne.RecordsSchemasDerivationSchemeMissingSchema,"Unable to construct key derivation path using `schemas` scheme because `schema` is missing.");return[Ni.Schemas,e]}static derivePrivateKey(e,r){var n;return _C(this,void 0,void 0,function*(){if(e.derivedPrivateKey.crv!=="secp256k1")throw new oe(ne.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=Ci.privateJwkToBytes(e.derivedPrivateKey);return yield D0.derivePrivateKeyBytes(s,o)})}static validateAncestorKeyAndDescentKeyDerivationPathsMatch(e,r){for(let n=0;n=n.dateExpires)throw new oe(ne.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 be.getOldestMessage(s);if(a!==void 0&&a.descriptor.messageTimestamp<=r)throw new oe(ne.GrantAuthorizationGrantRevoked,`Permission grant with CID ${n.id} has been revoked`)})}static verifyGrantScopeInterfaceAndMethod(e,r,n){return xC(this,void 0,void 0,function*(){if(e!==n.scope.interface)throw new oe(ne.GrantAuthorizationInterfaceMismatch,`DWN Interface of incoming message is outside the scope of permission grant with ID ${n.id}`);if(r!==n.scope.method)throw new oe(ne.GrantAuthorizationMethodMismatch,`DWN Method of incoming message is outside the scope of permission grant with ID ${n.id}`)})}};h();var Px;(function(t){t.Required="Required",t.Prohibited="Prohibited"})(Px||(Px={}));var I4=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())})},Lo=class t{static authorizeWrite(e){return I4(this,void 0,void 0,function*(){let{recordsWriteMessage:r,expectedGrantor:n,expectedGrantee:i,permissionGrant:o,messageStore:s}=e;yield Jf.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 I4(this,void 0,void 0,function*(){let{recordsReadMessage:r,recordsWriteMessageToBeRead:n,expectedGrantor:i,expectedGrantee:o,permissionGrant:s,messageStore:a}=e;yield Jf.performBaseValidation({incomingMessage:r,expectedGrantor:i,expectedGrantee:o,permissionGrant:s,messageStore:a}),t.verifyScope(n,s.scope)})}static authorizeQueryOrSubscribe(e){return I4(this,void 0,void 0,function*(){let{incomingMessage:r,expectedGrantor:n,expectedGrantee:i,permissionGrant:o,messageStore:s}=e;yield Jf.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 oe(ne.RecordsGrantAuthorizationQueryOrSubscribeProtocolScopeMismatch,`Grant protocol scope ${d} does not match protocol in message ${u}`)})}static authorizeDelete(e){return I4(this,void 0,void 0,function*(){let{recordsDeleteMessage:r,recordsWriteToDelete:n,expectedGrantor:i,expectedGrantee:o,permissionGrant:s,messageStore:a}=e;yield Jf.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 oe(ne.RecordsGrantAuthorizationDeleteProtocolScopeMismatch,`Grant protocol scope ${u} does not match protocol in record to delete ${c}`)})}static verifyScope(e,r){t.isUnrestrictedScope(r)||(e.descriptor.protocol!==void 0?t.verifyProtocolRecordScope(e,r):t.verifyFlatRecordScope(e,r))}static verifyProtocolRecordScope(e,r){if(r.protocol===void 0)throw new oe(ne.RecordsGrantAuthorizationScopeMissingProtocol,"Grant for protocol record must specify protocol in its scope");if(r.protocol!==e.descriptor.protocol)throw new oe(ne.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 oe(ne.RecordsGrantAuthorizationScopeContextIdMismatch,"Grant scope specifies different contextId than what appears in the record");if(r.protocolPath!==void 0&&r.protocolPath!==e.descriptor.protocolPath)throw new oe(ne.RecordsGrantAuthorizationScopeProtocolPathMismatch,"Grant scope specifies different protocolPath than what appears in the record")}static verifyFlatRecordScope(e,r){if(r.schema!==void 0&&r.schema!==e.descriptor.schema)throw new oe(ne.RecordsGrantAuthorizationScopeSchema,`Record does not have schema in permission grant scope with schema '${r.schema}'`)}static verifyConditions(e,r){if(r?.publication===Px.Required&&!e.descriptor.published)throw new oe(ne.RecordsGrantAuthorizationConditionPublicationRequired,"Permission grant requires message to be published");if(r?.publication===Px.Prohibited&&e.descriptor.published)throw new oe(ne.RecordsGrantAuthorizationConditionPublicationProhibited,"Permission grant prohibits message from being published")}static isUnrestrictedScope(e){return e.protocol===void 0&&e.schema===void 0}};h();h();var z=Ut(Jie(),1),DC={};function kl(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))}_n(e,t),_n(`${e}.prototype`,t.prototype)}function _n(t,e){let r=`%${t}%`;if(DC[r]!==void 0)throw new Error(`intrinsic ${t} already exists`);DC[r]=e}function xe(t){return DC[t]}var Yie,Zie,ct="slot-epochNanoSeconds",xl="slot-timezone-identifier",Te="slot-year",Re="slot-month",Oe="slot-day",vt="slot-hour",wt="slot-minute",_t="slot-second",xt="slot-millisecond",Et="slot-microsecond",St="slot-nanosecond",se="slot-calendar",Moe="slot-date-brand",Boe="slot-year-month-brand",Coe="slot-month-day-brand",xo="slot-cached-instant",$r="slot-time-zone",Fo="slot-years",ji="slot-months",Bs="slot-weeks",zo="slot-days",Go="slot-hours",Wo="slot-minutes",Ho="slot-seconds",Vo="slot-milliseconds",Jo="slot-microseconds",Yo="slot-nanoseconds",wn="slot-calendar-identifier",Ooe=new WeakMap,MC=Symbol.for("@@Temporal__GetSlots");(Yie=globalThis)[MC]||(Yie[MC]=function(e){return Ooe.get(e)});var aO=globalThis[MC],BC=Symbol.for("@@Temporal__CreateSlots");(Zie=globalThis)[BC]||(Zie[BC]=function(e){Ooe.set(e,Object.create(null))});var Rl=globalThis[BC];function Ai(t,...e){if(!t||typeof t!="object")return!1;let r=aO(t);return!!r&&e.every(n=>n in r)}function R(t,e){let r=aO(t)?.[e];if(r===void 0)throw new TypeError(`Missing internal slot ${e}`);return r}function kt(t,e,r){let n=aO(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 Xie=/\.[-A-Za-z_]|\.\.[-A-Za-z._]{1,12}|\.[-A-Za-z_][-A-Za-z._]{0,12}|[A-Za-z_][-A-Za-z._]{0,13}/,zx=new RegExp("(?:"+[`(?:${Xie.source})(?:\\/(?:${Xie.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("|")+")"),$oe=/(?:[+\u2212-]\d{6}|\d{4})/,C4=/(?:0[1-9]|1[0-2])/,CC=/(?:0[1-9]|[12]\d|3[01])/,ABe=new RegExp(`(${$oe.source})(?:-(${C4.source})-(${CC.source})|(${C4.source})(${CC.source}))`),Noe=/(\d{2})(?::(\d{2})(?::(\d{2})(?:[.,](\d{1,9}))?)?|(\d{2})(?:(\d{2})(?:[.,](\d{1,9}))?)?)?/,joe=/([+\u2212-])([01][0-9]|2[0-3])(?::?([0-5][0-9])(?::?([0-5][0-9])(?:[.,](\d{1,9}))?)?)?/,Uoe=new RegExp(`([zZ])|${joe.source}?`),tm=/\[(!)?([a-z_][a-z0-9_-]*)=([A-Za-z0-9]+(?:-[A-Za-z0-9]+)*)\]/g,PBe=new RegExp([`^${ABe.source}`,`(?:(?:T|\\s+)${Noe.source}(?:${Uoe.source})?)?`,`(?:\\[!?(${zx.source})\\])?`,`((?:${tm.source})*)$`].join(""),"i"),TBe=new RegExp([`^T?${Noe.source}`,`(?:${Uoe.source})?`,`(?:\\[!?${zx.source}\\])?`,`((?:${tm.source})*)$`].join(""),"i"),IBe=new RegExp(`^(${$oe.source})-?(${C4.source})(?:\\[!?${zx.source}\\])?((?:${tm.source})*)$`),kBe=new RegExp(`^(?:--)?(${C4.source})-?(${CC.source})(?:\\[!?${zx.source}\\])?((?:${tm.source})*)$`),AC=/(\d+)(?:[.,](\d{1,9}))?/,RBe=new RegExp(`(?:${AC.source}H)?(?:${AC.source}M)?(?:${AC.source}S)?`),DBe=new RegExp(`^([+\u2212-])?P${/(?:(\d+)Y)?(?:(\d+)M)?(?:(\d+)W)?(?:(\d+)D)?/.source}(?:T(?!$)${RBe.source})?$`,"i"),MBe=Array.prototype.includes,Koe=Array.prototype.push,qoe=globalThis.Intl.DateTimeFormat,BBe=Math.min,CBe=Math.max,on=Math.abs,ta=Math.floor,bw=Math.sign,C0=Math.trunc,Y4=Number.isNaN,Zo=Number.isFinite,OBe=Number,Gx=String,$Be=Number.MAX_SAFE_INTEGER,So=Object.create,NBe=Object.getOwnPropertyDescriptor,Z4=Reflect.apply,jBe=Reflect.ownKeys,kn=z.default.BigInt(0),Tw=z.default.BigInt(1),El=z.default.BigInt(60),Loe=z.default.BigInt(24),xr=z.default.BigInt(1e3),pc=z.default.BigInt(1e6),Sl=z.default.BigInt(1e9),UBe=z.default.BigInt(-1),Foe=z.default.multiply(z.default.BigInt(3600),Sl),zoe=z.default.multiply(El,Sl),Pl=z.default.multiply(Foe,Loe),Dx=z.default.multiply(z.default.BigInt(-86400),z.default.BigInt(1e17)),vw=z.default.multiply(z.default.BigInt(86400),z.default.BigInt(1e17)),O4=-271821,$4=275760,lw=z.default.multiply(z.default.BigInt(-388152),z.default.BigInt(1e13)),KBe=z.default.multiply(Pl,z.default.BigInt(3660)),Goe=z.default.multiply(Pl,z.default.BigInt(366)),Woe=z.default.multiply(Pl,z.default.BigInt(14)),qBe=["iso8601","hebrew","islamic","islamic-umalqura","islamic-tbla","islamic-civil","islamic-rgsa","islamicc","persian","ethiopic","ethioaa","coptic","chinese","dangi","roc","indian","buddhist","japanese","gregory"];function hc(t){return z.default.equal(t,kn)}function Tr(t,e){let r=t[e];if(r!==void 0)return r}function Ve(t,e,r){let n=arguments.length>2?r:[];return Z4(t,e,n)}function sn(t){return typeof t=="object"&&t!==null||typeof t=="function"}function ww(t){if(typeof t=="bigint")throw new TypeError("Cannot convert BigInt to number");return OBe(t)}function Vn(t){let e=ww(t);if(Y4(e)||e===0)return 0;if(!Zo(e))return e;let r=ta(on(e));return r===0?0:bw(e)*r}function Ra(t){if(typeof t!="number"||Y4(t)||!Zo(t))return!1;let e=on(t);return ta(e)===e}function Qo(t){if(typeof t=="symbol")throw new TypeError("Cannot convert a Symbol value to a String");return Gx(t)}function mr(t){let e=ww(t);if(e===0)return 0;if(Y4(e)||!Zo(e))throw new RangeError("invalid number value");let r=C0(e);return r===0?0:r}function Qie(t,e){let r=mr(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 Si(t){let e=ww(t);if(!Zo(e))throw new RangeError("infinity is out of range");if(!Ra(e))throw new RangeError(`unsupported fractional value ${t}`);return e===0?0:e}function Ln(t,e){return{quotient:z.default.divide(t,e),remainder:z.default.remainder(t,e)}}function N4(t){return z.default.lessThan(t,kn)}function eoe(t){return hc(t)?0:N4(t)?-1:1}function lu(t){return z.default.lessThan(t,kn)?z.default.multiply(t,UBe):t}var toe=new Map([["year",mr],["month",Qie],["monthCode",Qo],["day",Qie],["hour",mr],["minute",mr],["second",mr],["millisecond",mr],["microsecond",mr],["nanosecond",mr],["years",Si],["months",Si],["weeks",Si],["days",Si],["hours",Si],["minutes",Si],["seconds",Si],["milliseconds",Si],["microseconds",Si],["nanoseconds",Si],["era",Qo],["eraYear",Vn],["offset",Qo]]),LBe=new Map([["hour",0],["minute",0],["second",0],["millisecond",0],["microsecond",0],["nanosecond",0]]),Wx=[["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"]],j4=new Map(Wx.map(t=>[t[0],t[1]])),FBe=new Map(Wx.map(([t,e])=>[e,t])),roe=Wx.map(([,t])=>t),noe=Array.from(j4.keys()).sort(),ioe=new Map;function Hoe(t){let e=ioe.get(t);return e===void 0&&(e=new qoe("en-us",{timeZone:Gx(t),hour12:!1,era:"short",year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"}),ioe.set(t,e)),e}function ooe(t){if(t==null)throw new TypeError(`Expected object not ${t}`);return Object(t)}function fw(t,e,r,n){if(e==null)return;let i=jBe(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 li(t){return Ai(t,ct)&&!Ai(t,$r,se)}function fc(t){return Ai(t,xl)}function Pn(t){return Ai(t,wn)}function Tn(t){return Ai(t,Fo,ji,zo,Go,Wo,Ho,Vo,Jo,Yo)}function Gt(t){return Ai(t,Moe)}function In(t){return Ai(t,vt,wt,_t,xt,Et,St)&&!Ai(t,Te,Re,Oe)}function bt(t){return Ai(t,Te,Re,Oe,vt,wt,_t,xt,Et,St)}function _r(t){return Ai(t,Boe)}function Ei(t){return Ai(t,Coe)}function qe(t){return Ai(t,ct,$r,se)}function Iw(t){if(Ai(t,se)||Ai(t,$r))throw new TypeError("with() does not support a calendar or timeZone property");if(In(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 zBe(t){let{ianaName:e,offset:r,z:n}=function(o){if(new RegExp(`^${zx.source}$`,"i").test(o))return{ianaName:o};try{let s=Dl(o);if(s.z||s.offset||s.ianaName)return s}catch{}throw new RangeError(`Invalid time zone: ${o}`)}(t);return e?bO(e):n?"UTC":dA(Jp(r))}function cO(t,e){return e==="never"?"":dO(Qi(t),e)}function dO(t,e){return e==="never"||e==="auto"&&t==="iso8601"?"":`[${e==="critical"?"!":""}u-ca=${t}]`}function Dl(t){let e=PBe.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=Vn(r),i=Vn(e[2]||e[4]),o=Vn(e[3]||e[5]),s=Vn(e[6]),a=e[6]!==void 0,d=Vn(e[7]||e[10]),u=Vn(e[8]||e[11]);u===60&&(u=59);let c=(e[9]||e[12])+"000000000",l=Vn(c.slice(0,3)),m=Vn(c.slice(3,6)),p=Vn(c.slice(6,9)),g,b=!1;if(e[13])g=void 0,b=!0;else if(e[14]&&e[15]){let P=e[14]==="-"||e[14]==="\u2212"?"-":"+",$=e[15]||"00",N=e[16]||"00",L=e[17]||"00",F=e[18]||"0";if(g=`${P}${$}:${N}`,+F){for(;F.endsWith("0");)F=F.slice(0,-1);g+=`:${L}.${F}`}else+L&&(g+=`:${L}`);g==="-00:00"&&(g="+00:00")}let S=e[19],A=e[20],I;for(let[,P,$,N]of A.matchAll(tm))if($==="u-ca")I===void 0&&(I=N);else if(P==="!")throw new RangeError(`Unrecognized annotation: !${$}=${N}`);return _O(n,i,o,s,d,u,l,m,p),{year:n,month:i,day:o,hasTime:a,hour:s,minute:d,second:u,millisecond:l,microsecond:m,nanosecond:p,ianaName:S,offset:g,z:b,calendar:I}}function uO(t){let e=IBe.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=Vn(s),n=Vn(e[2]);let a=e[3];for(let[,d,u,c]of a.matchAll(tm))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}=Dl(t),s)throw new RangeError("Z designator not supported for PlainYearMonth")}return{year:r,month:n,calendar:i,referenceISODay:o}}function lO(t){let e=kBe.exec(t),r,n,i,o;if(e){r=Vn(e[1]),n=Vn(e[2]);let s=e[3];for(let[,a,d,u]of s.matchAll(tm))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}=Dl(t),s)throw new RangeError("Z designator not supported for PlainMonthDay")}return{month:r,day:n,calendar:i,referenceISOYear:o}}function GBe(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(b){let S=Dl(b);if(!S.z&&!S.offset)throw new RangeError("Temporal.Instant requires a time zone offset");return S}(t);if(!l&&!c)throw new RangeError("Temporal.Instant requires a time zone offset");let m=l?0:Jp(c);({year:e,month:r,day:n,hour:i,minute:o,second:s,millisecond:a,microsecond:d,nanosecond:u}=vO(e,r,n,i,o,s,a,d,u-m));let p=Yp(e,r,n,i,o,s,a,d,u);if(p===null)throw new RangeError("DateTime outside of supported range");return p}function U4(t,e,r,n){let i=t,o=e,s=r;switch(n){case"reject":Tl(i,o,s);break;case"constrain":({year:i,month:o,day:s}=use(i,o,s))}return{year:i,month:o,day:s}}function X4(t,e,r,n,i,o,s){let a=t,d=e,u=r,c=n,l=i,m=o;switch(s){case"reject":lA(a,d,u,c,l,m);break;case"constrain":({hour:a,minute:d,second:u,millisecond:c,microsecond:l,nanosecond:m}=function(g,b,S,A,I,P){let $=ea(g,0,23),N=ea(b,0,59),L=ea(S,0,59),F=ea(A,0,999),U=ea(I,0,999),G=ea(P,0,999);return{hour:$,minute:N,second:L,millisecond:F,microsecond:U,nanosecond:G}}(a,d,u,c,l,m))}return{hour:a,minute:d,second:u,millisecond:c,microsecond:l,nanosecond:m}}function G0(t){if(!sn(t))return function(g){let b=DBe.exec(g);if(!b)throw new RangeError(`invalid duration: ${g}`);if(b.slice(2).every(_=>_===void 0))throw new RangeError(`invalid duration: ${g}`);let S=b[1]==="-"||b[1]==="\u2212"?-1:1,A=b[2]===void 0?0:mr(b[2])*S,I=b[3]===void 0?0:mr(b[3])*S,P=b[4]===void 0?0:mr(b[4])*S,$=b[5]===void 0?0:mr(b[5])*S,N=b[6]===void 0?0:mr(b[6])*S,L=b[7],F=b[8],U=b[9],G=b[10],q=b[11],T=0,E=0,k=0;if(L!==void 0){if(F??U??G??q)throw new RangeError("only the smallest unit can be fractional");k=3600*Vn((L+"000000000").slice(0,9))*S}else if(T=F===void 0?0:mr(F)*S,U!==void 0){if(G??q)throw new RangeError("only the smallest unit can be fractional");k=60*Vn((U+"000000000").slice(0,9))*S}else E=G===void 0?0:mr(G)*S,q!==void 0&&(k=Vn((q+"000000000").slice(0,9))*S);let f=k%1e3,y=C0(k/1e3)%1e3,w=C0(k/1e6)%1e3;return E+=C0(k/1e9)%60,T+=C0(k/6e10),G4(A,I,P,$,N,T,E,w,y,f),{years:A,months:I,weeks:P,days:$,hours:N,minutes:T,seconds:E,milliseconds:w,microseconds:y,nanoseconds:f}}(Qo(t));if(Tn(t))return{years:R(t,Fo),months:R(t,ji),weeks:R(t,Bs),days:R(t,zo),hours:R(t,Go),minutes:R(t,Wo),seconds:R(t,Ho),milliseconds:R(t,Vo),microseconds:R(t,Jo),nanoseconds:R(t,Yo)};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(!sn(g))throw new TypeError("invalid duration-like");let b={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},S=!1;for(let A of noe){let I=g[A];I!==void 0&&(S=!0,b[A]=Si(I))}if(!S)throw new TypeError("invalid duration-like");return b}(t);for(let p of noe){let g=r[p];g!==void 0&&(e[p]=g)}let{years:n,months:i,weeks:o,days:s,hours:a,minutes:d,seconds:u,milliseconds:c,microseconds:l,nanoseconds:m}=e;return G4(n,i,o,s,a,d,u,c,l,m),{years:n,months:i,weeks:o,days:s,hours:a,minutes:d,seconds:u,milliseconds:c,microseconds:l,nanoseconds:m}}function Fn(t){return t===void 0?"constrain":Xp(t,"overflow",["constrain","reject"],"constrain")}function _w(t){return t===void 0?"compatible":Xp(t,"disambiguation",["compatible","earlier","later","reject"],"compatible")}function hu(t,e){return Xp(t,"roundingMode",["ceil","floor","expand","trunc","halfCeil","halfFloor","halfExpand","halfTrunc","halfEven"],e)}function K4(t,e){return t===void 0?e:Xp(t,"offset",["prefer","use","ignore","reject"],e)}function Hx(t){return Xp(t,"calendarName",["auto","always","never","critical"],"auto")}function kw(t){let e=t.roundingIncrement;if(e===void 0)return 1;if(e=ww(e),!Zo(e))throw new RangeError("roundingIncrement must be finite");let r=C0(e);if(r<1||r>1e9)throw new RangeError(`roundingIncrement must be at least 1 and at most 1e9, not ${e}`);return r}function Rw(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 Vx(t){let e=t.fractionalSecondDigits;if(e===void 0)return"auto";if(typeof e!="number"){if(Qo(e)!=="auto")throw new RangeError(`fractionalSecondDigits must be 'auto' or 0 through 9, not ${e}`);return"auto"}let r=ta(e);if(!Zo(r)||r<0||r>9)throw new RangeError(`fractionalSecondDigits must be 'auto' or 0 through 9, not ${e}`);return r}function Jx(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 U0=Symbol("~required~");function ra(t,e,r,n,i=[]){let o=[];for(let[,u,c]of Wx)r!=="datetime"&&r!==c||o.push(u);o.push(...i);let s=n;s===U0?s=void 0:s!==void 0&&o.push(s);let a=[...o];for(let u of o){let c=FBe.get(u);c!==void 0&&a.push(c)}let d=Xp(t,e,a,s);if(d===void 0&&n===U0)throw new RangeError(`${e} is required`);return j4.has(d)?j4.get(d):d}function R4(t){let e=t.relativeTo;if(e===void 0)return e;let r,n,i,o,s,a,d,u,c,l,m,p,g="option",b=!1;if(sn(e)){if(qe(e)||Gt(e))return e;if(bt(e))return Ew(e);l=Qx(e);let S=Jn(l,["day","hour","microsecond","millisecond","minute","month","monthCode","nanosecond","second","year"]);S.push("timeZone","offset");let A=Mt(e,S,[]),I=So(null);I.overflow="constrain",{year:r,month:n,day:i,hour:o,minute:s,second:a,millisecond:d,microsecond:u,nanosecond:c}=Yx(l,A,I),p=A.offset,p===void 0&&(g="wall"),m=A.timeZone,m!==void 0&&(m=Eo(m))}else{let S,A;if({year:r,month:n,day:i,hour:o,minute:s,second:a,millisecond:d,microsecond:u,nanosecond:c,calendar:l,ianaName:S,offset:p,z:A}=Dl(Qo(e)),S)m=Eo(S),A?g="exact":p||(g="wall"),b=!0;else if(A)throw new RangeError("Z designator not supported for PlainDate relativeTo; either remove the Z or add a bracketed time zone");if(l||(l="iso8601"),!nh(l))throw new RangeError(`invalid calendar identifier ${l}`);l=Il(l)}return m===void 0?yc(r,n,i,l):Yi(L4(r,n,i,o,s,a,d,u,c,g,g==="option"?Jp(p):0,m,"compatible","reject",b),m,l)}function OC(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 j4.get(c);return"nanosecond"}function K0(t,e){return roe.indexOf(t)>roe.indexOf(e)?e:t}function Mt(t,e,r,{emptySourceErrorMessage:n}={emptySourceErrorMessage:"no supported properties found"}){let i=So(null),o=!1;e.sort();for(let s of e){let a=t[s];if(a!==void 0)o=!0,toe.has(s)&&(a=toe.get(s)(a)),i[s]=a;else if(r!=="partial"){if(MBe.call(r,s))throw new TypeError(`required property '${s}' missing or undefined`);a=LBe.get(s),i[s]=a}}if(r==="partial"&&!o)throw new TypeError(n);return i}function q4(t,e="complete"){let r=["hour","microsecond","millisecond","minute","nanosecond","second"],n=Mt(t,r,"partial",{emptySourceErrorMessage:"invalid time-like"}),i={};for(let o of r){let s=NBe(n,o);s!==void 0?i[o]=s.value:e==="complete"&&(i[o]=0)}return i}function Ur(t,e){let r=t;if(sn(r)){if(Gt(r))return r;if(qe(r)&&(Fn(e),r=ka(R(r,$r),R(r,xo),R(r,se))),bt(r))return Fn(e),yc(R(r,Te),R(r,Re),R(r,Oe),R(r,se));let d=Qx(r);return th(d,Mt(r,Jn(d,["day","month","monthCode","year"]),[]),e)}Fn(e);let{year:n,month:i,day:o,calendar:s,z:a}=function(u){return Dl(u)}(Qo(r));if(a)throw new RangeError("Z designator not supported for PlainDate");if(s||(s="iso8601"),!nh(s))throw new RangeError(`invalid calendar identifier ${s}`);return s=Il(s),yc(n,i,o,s)}function Yx(t,e,r){let{hour:n,minute:i,second:o,millisecond:s,microsecond:a,nanosecond:d}=q4(e),u=Fn(r),c=th(t,e,r),l=R(c,Te),m=R(c,Re),p=R(c,Oe);return{hour:n,minute:i,second:o,millisecond:s,microsecond:a,nanosecond:d}=X4(n,i,o,s,a,d,u),{year:l,month:m,day:p,hour:n,minute:i,second:o,millisecond:s,microsecond:a,nanosecond:d}}function O0(t,e){let r,n,i,o,s,a,d,u,c,l;if(sn(t)){if(bt(t))return t;if(qe(t))return Fn(e),ka(R(t,$r),R(t,xo),R(t,se));if(Gt(t))return Fn(e),Qs(R(t,Te),R(t,Re),R(t,Oe),0,0,0,0,0,0,R(t,se));l=Qx(t);let m=Mt(t,Jn(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}=Yx(l,m,e))}else{let m;if(Fn(e),{year:r,month:n,day:i,hour:o,minute:s,second:a,millisecond:d,microsecond:u,nanosecond:c,calendar:l,z:m}=function(g){return Dl(g)}(Qo(t)),m)throw new RangeError("Z designator not supported for PlainDateTime");if(_O(r,n,i,o,s,a,d,u,c),l||(l="iso8601"),!nh(l))throw new RangeError(`invalid calendar identifier ${l}`);l=Il(l)}return Qs(r,n,i,o,s,a,d,u,c,l)}function hw(t){if(Tn(t))return t;let{years:e,months:r,weeks:n,days:i,hours:o,minutes:s,seconds:a,milliseconds:d,microseconds:u,nanoseconds:c}=G0(t);return new(xe("%Temporal.Duration%"))(e,r,n,i,o,s,a,d,u,c)}function fu(t){if(li(t))return t;if(qe(t))return new(xe("%Temporal.Instant%"))(R(t,ct));let e=GBe(Qo(t));return new(xe("%Temporal.Instant%"))(e)}function soe(t,e){let r=t;if(sn(r)){if(Ei(r))return r;let a,d;if(Ai(r,se))a=R(r,se),d=!1;else{let c=r.calendar;d=c===void 0,c===void 0&&(c="iso8601"),a=na(c)}let u=Mt(r,Jn(a,["day","month","monthCode","year"]),[]);return d&&u.month!==void 0&&u.monthCode===void 0&&u.year===void 0&&(u.year=1972),xw(a,u,e)}Fn(e);let{month:n,day:i,referenceISOYear:o,calendar:s}=lO(Qo(r));if(s===void 0&&(s="iso8601"),!nh(s))throw new RangeError(`invalid calendar identifier ${s}`);return s=Il(s),o===void 0?(Tl(1972,n,i),Mx(n,i,s)):xw(s,Mx(n,i,s,o))}function Zf(t,e="constrain"){let r,n,i,o,s,a,d=t;if(sn(d)){if(In(d))return d;if(qe(d)&&(d=ka(R(d,$r),R(d,xo),R(d,se))),bt(d))return new(xe("%Temporal.PlainTime%"))(R(d,vt),R(d,wt),R(d,_t),R(d,xt),R(d,Et),R(d,St));({hour:r,minute:n,second:i,millisecond:o,microsecond:s,nanosecond:a}=q4(d)),{hour:r,minute:n,second:i,millisecond:o,microsecond:s,nanosecond:a}=X4(r,n,i,o,s,a,e)}else({hour:r,minute:n,second:i,millisecond:o,microsecond:s,nanosecond:a}=function(c){let l=TBe.exec(c),m,p,g,b,S,A,I;if(l){m=Vn(l[1]),p=Vn(l[2]||l[5]),g=Vn(l[3]||l[6]),g===60&&(g=59);let P=(l[4]||l[7])+"000000000";b=Vn(P.slice(0,3)),S=Vn(P.slice(3,6)),A=Vn(P.slice(6,9)),I=l[14];for(let[,$,N,L]of I.matchAll(tm))if(N!=="u-ca"&&$==="!")throw new RangeError(`Unrecognized annotation: !${N}=${L}`);if(l[8])throw new RangeError("Z designator not supported for PlainTime")}else{let P,$;if({hasTime:$,hour:m,minute:p,second:g,millisecond:b,microsecond:S,nanosecond:A,z:P}=Dl(c),!$)throw new RangeError(`time is missing in string: ${c}`);if(P)throw new RangeError("Z designator not supported for PlainTime")}if(/[tT ][0-9][0-9]/.test(c))return{hour:m,minute:p,second:g,millisecond:b,microsecond:S,nanosecond:A};try{let{month:P,day:$}=lO(c);Tl(1972,P,$)}catch{try{let{year:P,month:$}=uO(c);Tl(P,$,1)}catch{return{hour:m,minute:p,second:g,millisecond:b,microsecond:S,nanosecond:A}}}throw new RangeError(`invalid ISO 8601 time-only string ${c}; may need a T prefix`)}(Qo(d))),lA(r,n,i,o,s,a);return new(xe("%Temporal.PlainTime%"))(r,n,i,o,s,a)}function Tx(t,e){if(sn(t)){if(_r(t))return t;let s=Qx(t);return L0(s,Mt(t,Jn(s,["month","monthCode","year"]),[]),e)}Fn(e);let{year:r,month:n,referenceISODay:i,calendar:o}=uO(Qo(t));if(o===void 0&&(o="iso8601"),!nh(o))throw new RangeError(`invalid calendar identifier ${o}`);return o=Il(o),i===void 0?(Tl(r,n,1),Bx(r,n,o)):L0(o,Bx(r,n,o,i))}function L4(t,e,r,n,i,o,s,a,d,u,c,l,m,p,g){let b=new(xe("%Temporal.PlainDateTime%"))(t,e,r,n,i,o,s,a,d);if(u==="wall"||p==="ignore")return R(Xo(l,b,m),ct);if(u==="exact"||p==="use"){let A=Yp(t,e,r,n,i,o,s,a,d);if(A===null)throw new RangeError("ZonedDateTime outside of supported range");return z.default.subtract(A,z.default.BigInt(c))}let S=F4(l,b);for(let A of S){let I=pu(l,A),P=z.default.toNumber(Ia(z.default.BigInt(I),zoe,"halfExpand"));if(I===c||g&&P===c)return R(A,ct)}if(p==="reject"){let A=dA(c),I=fc(l)?R(l,xl):"time zone";throw new RangeError(`Offset ${A} is invalid for ${b.toString()} in ${I}`)}return R(rse(S,l,b,m),ct)}function Ix(t,e){let r,n,i,o,s,a,d,u,c,l,m,p,g,b,S=!1,A="option";if(sn(t)){if(qe(t))return t;p=Qx(t);let P=Jn(p,["day","hour","microsecond","millisecond","minute","month","monthCode","nanosecond","second","year"]);P.push("timeZone","offset");let $=Mt(t,P,["timeZone"]);l=Eo($.timeZone),m=$.offset,m===void 0&&(A="wall"),g=_w(e),b=K4(e,"reject"),{year:r,month:n,day:i,hour:o,minute:s,second:a,millisecond:d,microsecond:u,nanosecond:c}=Yx(p,$,e)}else{let P,$;if({year:r,month:n,day:i,hour:o,minute:s,second:a,millisecond:d,microsecond:u,nanosecond:c,ianaName:P,offset:m,z:$,calendar:p}=function(L){let F=Dl(L);if(!F.ianaName)throw new RangeError("Temporal.ZonedDateTime requires a time zone ID in brackets");return F}(Qo(t)),l=Eo(P),$?A="exact":m||(A="wall"),p||(p="iso8601"),!nh(p))throw new RangeError(`invalid calendar identifier ${p}`);p=Il(p),S=!0,g=_w(e),b=K4(e,"reject"),Fn(e)}let I=0;return A==="option"&&(I=Jp(m)),Yi(L4(r,n,i,o,s,a,d,u,c,A,I,l,g,b,S),l,p)}function Voe(t,e,r,n,i){Tl(e,r,n),lse(e,r,n),Rl(t),kt(t,Te,e),kt(t,Re,r),kt(t,Oe,n),kt(t,se,i),kt(t,Moe,!0)}function yc(t,e,r,n="iso8601"){let i=xe("%Temporal.PlainDate%"),o=So(i.prototype);return Voe(o,t,e,r,n),o}function Joe(t,e,r,n,i,o,s,a,d,u,c){_O(e,r,n,i,o,s,a,d,u),fse(e,r,n,i,o,s,a,d,u),Rl(t),kt(t,Te,e),kt(t,Re,r),kt(t,Oe,n),kt(t,vt,i),kt(t,wt,o),kt(t,_t,s),kt(t,xt,a),kt(t,Et,d),kt(t,St,u),kt(t,se,c)}function Qs(t,e,r,n,i,o,s,a,d,u="iso8601"){let c=xe("%Temporal.PlainDateTime%"),l=So(c.prototype);return Joe(l,t,e,r,n,i,o,s,a,d,u),l}function Yoe(t,e,r,n,i){Tl(i,e,r),lse(i,e,r),Rl(t),kt(t,Re,e),kt(t,Oe,r),kt(t,Te,i),kt(t,se,n),kt(t,Coe,!0)}function Mx(t,e,r="iso8601",n=1972){let i=xe("%Temporal.PlainMonthDay%"),o=So(i.prototype);return Yoe(o,t,e,r,n),o}function Zoe(t,e,r,n,i){Tl(e,r,i),function(s,a){Xi(s,O4,$4),s===O4?Xi(a,4,12):s===$4&&Xi(a,1,9)}(e,r),Rl(t),kt(t,Te,e),kt(t,Re,r),kt(t,Oe,i),kt(t,se,n),kt(t,Boe,!0)}function Bx(t,e,r="iso8601",n=1){let i=xe("%Temporal.PlainYearMonth%"),o=So(i.prototype);return Zoe(o,t,e,r,n),o}function Xoe(t,e,r,n){B0(e),Rl(t),kt(t,ct,e),kt(t,$r,r),kt(t,se,n);let i=new(xe("%Temporal.Instant%"))(R(t,ct));kt(t,xo,i)}function Yi(t,e,r="iso8601"){let n=xe("%Temporal.ZonedDateTime%"),i=So(n.prototype);return Xoe(i,t,e,r),i}function Jn(t,e){if(typeof t=="string"){let i=new(xe("%Temporal.Calendar%"))(t);return Ve(xe("%Temporal.Calendar.prototype.fields%"),i,[e])}let r=Ve(Tr(t,"fields"),t,[e]),n=[];for(let i of r){if(typeof i!="string")throw new TypeError("bad return from calendar.fields()");Koe.call(n,i)}return n}function q0(t,e,r){if(typeof t=="string"){let i=new(xe("%Temporal.Calendar%"))(t);return Ve(xe("%Temporal.Calendar.prototype.mergeFields%"),i,[e,r])}let n=Ve(Tr(t,"mergeFields"),t,[e,r]);if(!sn(n))throw new TypeError("bad return from calendar.mergeFields()");return n}function Zi(t,e,r,n,i){let o=i;if(typeof t=="string"){let a=new(xe("%Temporal.Calendar%"))(t);return Ve(xe("%Temporal.Calendar.prototype.dateAdd%"),a,[e,r,n])}o===void 0&&(o=Tr(t,"dateAdd"));let s=Z4(o,t,[e,r,n]);if(!Gt(s))throw new TypeError("invalid result");return s}function Vp(t,e,r,n,i){let o=i;if(typeof t=="string"){let a=new(xe("%Temporal.Calendar%"))(t);return Ve(xe("%Temporal.Calendar.prototype.dateUntil%"),a,[e,r,n])}o===void 0&&(o=Tr(t,"dateUntil"));let s=Z4(o,t,[e,r,n]);if(!Tn(s))throw new TypeError("invalid result");return s}function Q4(t,e){if(typeof t=="string"){let n=new(xe("%Temporal.Calendar%"))(t);return Ve(xe("%Temporal.Calendar.prototype.year%"),n,[e])}let r=Ve(Tr(t,"year"),t,[e]);if(typeof r!="number")throw new TypeError("calendar year result must be an integer");if(!Ra(r))throw new RangeError("calendar year result must be an integer");return r}function eA(t,e){if(typeof t=="string"){let n=new(xe("%Temporal.Calendar%"))(t);return Ve(xe("%Temporal.Calendar.prototype.month%"),n,[e])}let r=Ve(Tr(t,"month"),t,[e]);if(typeof r!="number")throw new TypeError("calendar month result must be a positive integer");if(!Ra(r)||r<1)throw new RangeError("calendar month result must be a positive integer");return r}function Zx(t,e){if(typeof t=="string"){let n=new(xe("%Temporal.Calendar%"))(t);return Ve(xe("%Temporal.Calendar.prototype.monthCode%"),n,[e])}let r=Ve(Tr(t,"monthCode"),t,[e]);if(typeof r!="string")throw new TypeError("calendar monthCode result must be a string");return r}function Xx(t,e){if(typeof t=="string"){let n=new(xe("%Temporal.Calendar%"))(t);return Ve(xe("%Temporal.Calendar.prototype.day%"),n,[e])}let r=Ve(Tr(t,"day"),t,[e]);if(typeof r!="number")throw new TypeError("calendar day result must be a positive integer");if(!Ra(r)||r<1)throw new RangeError("calendar day result must be a positive integer");return r}function tA(t,e){if(typeof t=="string"){let n=new(xe("%Temporal.Calendar%"))(t);return Ve(xe("%Temporal.Calendar.prototype.era%"),n,[e])}let r=Ve(Tr(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 rA(t,e){if(typeof t=="string"){let n=new(xe("%Temporal.Calendar%"))(t);return Ve(xe("%Temporal.Calendar.prototype.eraYear%"),n,[e])}let r=Ve(Tr(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(!Ra(r))throw new RangeError("calendar eraYear result must be an integer or undefined");return r}function fO(t,e){if(typeof t=="string"){let n=new(xe("%Temporal.Calendar%"))(t);return Ve(xe("%Temporal.Calendar.prototype.dayOfWeek%"),n,[e])}let r=Ve(Tr(t,"dayOfWeek"),t,[e]);if(typeof r!="number")throw new TypeError("calendar dayOfWeek result must be a positive integer");if(!Ra(r)||r<1)throw new RangeError("calendar dayOfWeek result must be a positive integer");return r}function hO(t,e){if(typeof t=="string"){let n=new(xe("%Temporal.Calendar%"))(t);return Ve(xe("%Temporal.Calendar.prototype.dayOfYear%"),n,[e])}let r=Ve(Tr(t,"dayOfYear"),t,[e]);if(typeof r!="number")throw new TypeError("calendar dayOfYear result must be a positive integer");if(!Ra(r)||r<1)throw new RangeError("calendar dayOfYear result must be a positive integer");return r}function pO(t,e){if(typeof t=="string"){let n=new(xe("%Temporal.Calendar%"))(t);return Ve(xe("%Temporal.Calendar.prototype.weekOfYear%"),n,[e])}let r=Ve(Tr(t,"weekOfYear"),t,[e]);if(typeof r!="number")throw new TypeError("calendar weekOfYear result must be a positive integer");if(!Ra(r)||r<1)throw new RangeError("calendar weekOfYear result must be a positive integer");return r}function mO(t,e){if(typeof t=="string"){let n=new(xe("%Temporal.Calendar%"))(t);return Ve(xe("%Temporal.Calendar.prototype.yearOfWeek%"),n,[e])}let r=Ve(Tr(t,"yearOfWeek"),t,[e]);if(typeof r!="number")throw new TypeError("calendar yearOfWeek result must be an integer");if(!Ra(r))throw new RangeError("calendar yearOfWeek result must be an integer");return r}function yO(t,e){if(typeof t=="string"){let n=new(xe("%Temporal.Calendar%"))(t);return Ve(xe("%Temporal.Calendar.prototype.daysInWeek%"),n,[e])}let r=Ve(Tr(t,"daysInWeek"),t,[e]);if(typeof r!="number")throw new TypeError("calendar daysInWeek result must be a positive integer");if(!Ra(r)||r<1)throw new RangeError("calendar daysInWeek result must be a positive integer");return r}function nA(t,e){if(typeof t=="string"){let n=new(xe("%Temporal.Calendar%"))(t);return Ve(xe("%Temporal.Calendar.prototype.daysInMonth%"),n,[e])}let r=Ve(Tr(t,"daysInMonth"),t,[e]);if(typeof r!="number")throw new TypeError("calendar daysInMonth result must be a positive integer");if(!Ra(r)||r<1)throw new RangeError("calendar daysInMonth result must be a positive integer");return r}function iA(t,e){if(typeof t=="string"){let n=new(xe("%Temporal.Calendar%"))(t);return Ve(xe("%Temporal.Calendar.prototype.daysInYear%"),n,[e])}let r=Ve(Tr(t,"daysInYear"),t,[e]);if(typeof r!="number")throw new TypeError("calendar daysInYear result must be a positive integer");if(!Ra(r)||r<1)throw new RangeError("calendar daysInYear result must be a positive integer");return r}function oA(t,e){if(typeof t=="string"){let n=new(xe("%Temporal.Calendar%"))(t);return Ve(xe("%Temporal.Calendar.prototype.monthsInYear%"),n,[e])}let r=Ve(Tr(t,"monthsInYear"),t,[e]);if(typeof r!="number")throw new TypeError("calendar monthsInYear result must be a positive integer");if(!Ra(r)||r<1)throw new RangeError("calendar monthsInYear result must be a positive integer");return r}function sA(t,e){if(typeof t=="string"){let n=new(xe("%Temporal.Calendar%"))(t);return Ve(xe("%Temporal.Calendar.prototype.inLeapYear%"),n,[e])}let r=Ve(Tr(t,"inLeapYear"),t,[e]);if(typeof r!="boolean")throw new TypeError("calendar inLeapYear result must be a boolean");return r}function na(t){if(sn(t)){if(Ai(t,se))return R(t,se);if(!function(i){return!!Pn(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=Qo(t);if(nh(e))return Il(e);let r;try{({calendar:r}=Dl(e))}catch{try{({calendar:r}=uO(e))}catch{({calendar:r}=lO(e))}}if(r||(r="iso8601"),!nh(r))throw new RangeError(`invalid calendar identifier ${r}`);return Il(r)}function Qx(t){if(Ai(t,se))return R(t,se);let{calendar:e}=t;return e===void 0?"iso8601":na(e)}function Qi(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 Dw(t){return sn(t)?t:new(xe("%Temporal.Calendar%"))(t)}function eE(t,e){return t===e?!0:Qi(t)===Qi(e)}function aA(t,e,r){if(t===e)return;let n=Qi(t),i=Qi(e);if(n!==i)throw new RangeError(`cannot ${r} of ${n} and ${i} calendars`)}function Qoe(t,e){if(t===e)return e;let r=Qi(t),n=Qi(e);if(r===n||r==="iso8601")return e;if(n==="iso8601")return t;throw new RangeError("irreconcilable calendars")}function th(t,e,r,n){if(typeof t=="string"){let o=new(xe("%Temporal.Calendar%"))(t);return Ve(xe("%Temporal.Calendar.prototype.dateFromFields%"),o,[e,r])}let i=Ve(n??Tr(t,"dateFromFields"),t,[e,r]);if(!Gt(i))throw new TypeError("invalid result");return i}function L0(t,e,r){if(typeof t=="string"){let i=new(xe("%Temporal.Calendar%"))(t);return Ve(xe("%Temporal.Calendar.prototype.yearMonthFromFields%"),i,[e,r])}let n=Ve(Tr(t,"yearMonthFromFields"),t,[e,r]);if(!_r(n))throw new TypeError("invalid result");return n}function xw(t,e,r){if(typeof t=="string"){let i=new(xe("%Temporal.Calendar%"))(t);return Ve(xe("%Temporal.Calendar.prototype.monthDayFromFields%"),i,[e,r])}let n=Ve(Tr(t,"monthDayFromFields"),t,[e,r]);if(!Ei(n))throw new TypeError("invalid result");return n}function Eo(t){if(sn(t)){if(qe(t))return R(t,$r);if(!function(r){return!!fc(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 zBe(Qo(t))}function Cx(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 ese(t){return sn(t)?t:new(xe("%Temporal.TimeZone%"))(t)}function tse(t,e){return t===e?!0:Cx(t)===Cx(e)}function Ew(t){return yc(R(t,Te),R(t,Re),R(t,Oe),R(t,se))}function gO(t){return new(xe("%Temporal.PlainTime%"))(R(t,vt),R(t,wt),R(t,_t),R(t,xt),R(t,Et),R(t,St))}function pu(t,e,r){if(typeof t=="string"){let i=new(xe("%Temporal.TimeZone%"))(t);return Ve(xe("%Temporal.TimeZone.prototype.getOffsetNanosecondsFor%"),i,[e])}let n=Ve(r??Tr(t,"getOffsetNanosecondsFor"),t,[e]);if(typeof n!="number")throw new TypeError("bad return from getOffsetNanosecondsFor");if(!Ra(n)||on(n)>=864e11)throw new RangeError("out-of-range return from getOffsetNanosecondsFor");return n}function $C(t,e){return dA(pu(t,e))}function ka(t,e,r){let n=R(e,ct),i=pu(t,e),{year:o,month:s,day:a,hour:d,minute:u,second:c,millisecond:l,microsecond:m,nanosecond:p}=ise(n);return{year:o,month:s,day:a,hour:d,minute:u,second:c,millisecond:l,microsecond:m,nanosecond:p}=vO(o,s,a,d,u,c,l,m,p+i),Qs(o,s,a,d,u,c,l,m,p,r)}function Xo(t,e,r){return rse(F4(t,e),t,e,r)}function rse(t,e,r,n){let i=xe("%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,Te),a=R(r,Re),d=R(r,Oe),u=R(r,vt),c=R(r,wt),l=R(r,_t),m=R(r,xt),p=R(r,Et),g=R(r,St),b=Yp(s,a,d,u,c,l,m,p,g);if(b===null)throw new RangeError("DateTime outside of supported range");let S=new i(z.default.subtract(b,Pl)),A=new i(z.default.add(b,Pl)),I=pu(e,S),P=pu(e,A)-I;switch(n){case"earlier":{let $=R(r,se),N=xe("%Temporal.PlainDateTime%"),L=KC(s,a,d,u,c,l,m,p,g,$,0,0,0,0,0,0,0,0,0,-P,void 0);return F4(e,new N(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,se),N=xe("%Temporal.PlainDateTime%"),L=KC(s,a,d,u,c,l,m,p,g,$,0,0,0,0,0,0,0,0,0,P,void 0),F=F4(e,new N(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 F4(t,e,r){if(typeof t=="string"){let o=new(xe("%Temporal.TimeZone%"))(t);return Ve(xe("%Temporal.TimeZone.prototype.getPossibleInstantsFor%"),o,[e])}let n=Ve(r??Tr(t,"getPossibleInstantsFor"),t,[e]),i=[];for(let o of n){if(!li(o))throw new TypeError("bad return from getPossibleInstantsFor");Koe.call(i,o)}return i}function W0(t){let e;return t<0||t>9999?e=(t<0?"-":"+")+`000000${on(t)}`.slice(-6):e=`0000${t}`.slice(-4),e}function pn(t){return`00${t}`.slice(-2)}function cA(t,e,r,n,i){if(i==="minute")return"";let o=`:${pn(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 aoe(t,e,r){let n=e;n===void 0&&(n="UTC");let i=ka(n,t,"iso8601"),o=W0(R(i,Te)),s=pn(R(i,Re)),a=pn(R(i,Oe)),d=pn(R(i,vt)),u=pn(R(i,wt)),c=cA(R(i,_t),R(i,xt),R(i,Et),R(i,St),r),l="Z";return e!==void 0&&(l=nse(pu(n,t))),`${o}-${s}-${a}T${d}:${u}${c}${l}`}function PC(t,e="auto",r){function n(G){return G<=$Be?G.toString(10):z.default.BigInt(G).toString(10)}let i=R(t,Fo),o=R(t,ji),s=R(t,Bs),a=R(t,zo),d=R(t,Go),u=R(t,Wo),c=R(t,Ho),l=R(t,Vo),m=R(t,Jo),p=R(t,Yo),g=Al(i,o,s,a,d,u,c,l,m,p);if(r){let{unit:G,increment:q,roundingMode:T}=r;({seconds:c,milliseconds:l,microseconds:m,nanoseconds:p}=rh(0,0,0,0,0,0,c,l,m,p,q,G,T))}let b=[];i&&b.push(`${n(on(i))}Y`),o&&b.push(`${n(on(o))}M`),s&&b.push(`${n(on(s))}W`),a&&b.push(`${n(on(a))}D`);let S=[];d&&S.push(`${n(on(d))}H`),u&&S.push(`${n(on(u))}M`);let A=[],I,P,$,N,L=Sw(0,0,0,c,l,m,p,0);({quotient:L,remainder:I}=Ln(L,xr)),{quotient:L,remainder:P}=Ln(L,xr),{quotient:N,remainder:$}=Ln(L,xr);let F=1e6*on(z.default.toNumber($))+1e3*on(z.default.toNumber(P))+on(z.default.toNumber(I)),U;if(e==="auto"){if(F!==0)for(U=`${F}`.padStart(9,"0");U[U.length-1]==="0";)U=U.slice(0,-1)}else e!==0&&(U=`${F}`.padStart(9,"0").slice(0,e));return U&&A.unshift(".",U),z.default.equal(N,kn)&&!A.length&&e==="auto"||A.unshift(lu(N).toString()),A.length&&S.push(`${A.join("")}S`),S.length&&S.unshift("T"),b.length||S.length?`${g<0?"-":""}P${b.join("")}${S.join("")}`:"PT0S"}function coe(t,e="auto"){return`${W0(R(t,Te))}-${pn(R(t,Re))}-${pn(R(t,Oe))}${cO(R(t,se),e)}`}function doe(t,e,r="auto",n){let i=R(t,Te),o=R(t,Re),s=R(t,Oe),a=R(t,vt),d=R(t,wt),u=R(t,_t),c=R(t,xt),l=R(t,Et),m=R(t,St);if(n){let{unit:p,increment:g,roundingMode:b}=n;({year:i,month:o,day:s,hour:a,minute:d,second:u,millisecond:c,microsecond:l,nanosecond:m}=AO(i,o,s,a,d,u,c,l,m,g,p,b))}return`${W0(i)}-${pn(o)}-${pn(s)}T${pn(a)}:${pn(d)}${cA(u,c,l,m,e)}${cO(R(t,se),r)}`}function uoe(t,e="auto"){let r=`${pn(R(t,Re))}-${pn(R(t,Oe))}`,n=Qi(R(t,se));(e==="always"||e==="critical"||n!=="iso8601")&&(r=`${W0(R(t,Te))}-${r}`);let i=dO(n,e);return i&&(r+=i),r}function loe(t,e="auto"){let r=`${W0(R(t,Te))}-${pn(R(t,Re))}`,n=Qi(R(t,se));(e==="always"||e==="critical"||n!=="iso8601")&&(r+=`-${pn(R(t,Oe))}`);let i=dO(n,e);return i&&(r+=i),r}function foe(t,e,r="auto",n="auto",i="auto",o){let s=R(t,xo);if(o){let{unit:c,increment:l,roundingMode:m}=o,p=W4(R(t,ct),l,c,m);s=new(xe("%Temporal.Instant%"))(p)}let a=R(t,$r),d=ka(a,s,"iso8601"),u=`${W0(R(d,Te))}-${pn(R(d,Re))}-${pn(R(d,Oe))}T${pn(R(d,vt))}:${pn(R(d,wt))}${cA(R(d,_t),R(d,xt),R(d,Et),R(d,St),e)}`;return i!=="never"&&(u+=nse(pu(a,s))),n!=="never"&&(u+=`[${n==="critical"?"!":""}${Cx(a)}]`),u+=cO(R(t,se),r),u}function uw(t){return vse.test(Gx(t))}function Jp(t){let e=vse.exec(Gx(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 bO(t){return uw(t)?dA(Jp(t)):Hoe(Gx(t)).resolvedOptions().timeZone}function Xf(t,e){let{year:r,month:n,day:i,hour:o,minute:s,second:a,millisecond:d,microsecond:u,nanosecond:c}=ose(t,e),l=r%400,m=(r-l)/400,p=z.default.multiply(z.default.BigInt(146097),Pl),g=Yp(l,n,i,o,s,a,d,u,c),b=z.default.add(g,z.default.multiply(p,z.default.BigInt(m)));return z.default.toNumber(z.default.subtract(b,e))}function dA(t){let e=t<0?"-":"+",r=on(t),n=r%1e9,i=ta(r/1e9)%60,o=ta(r/6e10)%60,s=pn(ta(r/36e11)),a=pn(o),d=pn(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 nse(t){let e=z.default.toNumber(Ia(z.default.BigInt(t),zoe,"halfExpand")),r=e<0?"-":"+";e=on(e);let n=e/6e10%60;return`${r}${pn(ta(e/36e11))}:${pn(n)}`}function Yp(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(Y4(c))return null;let l=z.default.multiply(z.default.BigInt(c),pc);return l=z.default.add(l,z.default.multiply(z.default.BigInt(a),xr)),l=z.default.add(l,z.default.BigInt(d)),z.default.lessThan(l,Dx)||z.default.greaterThan(l,vw)?null:l}function ise(t){let{quotient:e,remainder:r}=Ln(t,pc),n=z.default.toNumber(e),i=z.default.toNumber(r);i<0&&(i+=1e6,n-=1);let o=ta(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 ose(t,e){let{epochMilliseconds:r,millisecond:n,microsecond:i,nanosecond:o}=ise(e),{year:s,month:a,day:d,hour:u,minute:c,second:l}=function(p,g){let b=Hoe(p).format(new Date(g));return function(A){let I=A.split(/[^\w]+/);if(I.length!==7)throw new RangeError(`expected 7 parts in "${A}`);let P=+I[0],$=+I[1],N=+I[2],L=I[3].toUpperCase();if(L==="B"||L==="BC")N=1-N;else if(L!=="A"&&L!=="AD")throw new RangeError(`Unknown era ${L} in "${A}`);let F=+I[4];F===24&&(F=0);let U=+I[5],G=+I[6];if(!(Zo(N)&&Zo(P)&&Zo($)&&Zo(F)&&Zo(U)&&Zo(G)))throw new RangeError(`Invalid number in "${A}`);return{year:N,month:P,day:$,hour:F,minute:U,second:G}}(b)}(t,r);return vO(s,a,d,u,c,l,n,i,o)}function hoe(t,e){return z.default.lessThan(t,e)?e:t}function sse(){return z.default.add(TO(),KBe)}function ase(t,e){if(z.default.lessThan(e,lw))return ase(t,lw);let r=z.default.add(e,Goe),n=hoe(sse(),r),i=hoe(lw,e),o=Xf(t,i),s=i,a=o;for(;o===a&&z.default.lessThan(z.default.BigInt(i),n);){if(s=z.default.add(i,Woe),z.default.greaterThan(s,vw))return null;a=Xf(t,s),o===a&&(i=s)}return o===a?null:wse(d=>Xf(t,d),i,s,o,a)}function NC(t,e){let r=sse(),n=z.default.greaterThan(e,r),i=n?z.default.subtract(e,Goe):lw;if(t==="Africa/Casablanca"||t==="Africa/El_Aaiun"){let u=R(fu("2088-01-01T00Z"),ct);if(z.default.lessThan(u,e))return NC(t,u)}let o=z.default.subtract(e,Tw);if(z.default.lessThan(o,lw))return null;let s=Xf(t,o),a=o,d=s;for(;s===d&&z.default.greaterThan(o,i);){if(a=z.default.subtract(o,Woe),z.default.lessThan(a,lw))return null;d=Xf(t,a),s===d&&(o=a)}if(s===d){if(n){let u=z.default.subtract(r,Pl);return NC(t,u)}return null}return wse(u=>Xf(t,u),a,o,d,s)}function Zp(t){return t===void 0?!1:t%4==0&&(t%100!=0||t%400==0)}function Qf(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]}[Zp(t)?"leapyear":"standard"][e-1]}function jC(t,e,r){let n=e+(e<3?10:-2),i=t-(e<3?1:0),o=ta(i/100),s=i-100*o,a=(r+ta(2.6*n-.2)+(s+ta(s/4))+(ta(o/4)-2*o))%7;return a+(a<=0?7:0)}function z4(t,e,r){let n=r;for(let i=e-1;i>0;i--)n+=Qf(t,i);return n}function poe(t,e,r){let n=z4(t,e,r),i=jC(t,e,r)||7,o=jC(t,1,1),s=ta((n-i+10)/7);return s<1?o===5||o===6&&Zp(t-1)?{week:53,year:t-1}:{week:52,year:t-1}:s===53&&(Zp(t)?366:365)-n<4-i?{week:1,year:t+1}:{week:s,year:t}}function Al(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 D4(t,e){let r=t,n=e;if(!Zo(r)||!Zo(n))throw new RangeError("infinity is out of range");return n-=1,r+=ta(n/12),n%=12,n<0&&(n+=12),n+=1,{year:r,month:n}}function uA(t,e,r){let n=t,i=e,o=r;if(!Zo(o))throw new RangeError("infinity is out of range");({year:n,month:i}=D4(n,i));let s=146097;if(on(o)>s){let u=C0(o/s);n+=400*u,o-=u*s}let a=0,d=i>2?n:n-1;for(;a=Zp(d)?366:365,o<-a;)n-=1,d-=1,o+=a;for(d+=1;a=Zp(d)?366:365,o>a;)n+=1,d+=1,o-=a;for(;o<1;)({year:n,month:i}=D4(n,i-1)),o+=Qf(n,i);for(;o>Qf(n,i);)o-=Qf(n,i),{year:n,month:i}=D4(n,i+1);return{year:n,month:i,day:o}}function vO(t,e,r,n,i,o,s,a,d){let{deltaDays:u,hour:c,minute:l,second:m,millisecond:p,microsecond:g,nanosecond:b}=Yf(n,i,o,s,a,d),{year:S,month:A,day:I}=uA(t,e,r+u);return{year:S,month:A,day:I,hour:c,minute:l,second:m,millisecond:p,microsecond:g,nanosecond:b}}function Yf(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),m=z.default.BigInt(o);return{quotient:s,remainder:m}=M0(m,xr),l=z.default.add(l,s),{quotient:s,remainder:l}=M0(l,xr),c=z.default.add(c,s),{quotient:s,remainder:c}=M0(c,xr),u=z.default.add(u,s),{quotient:s,remainder:u}=M0(u,El),d=z.default.add(d,s),{quotient:s,remainder:d}=M0(d,El),a=z.default.add(a,s),{quotient:s,remainder:a}=M0(a,Loe),{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(m)}}function Sw(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,El)),m=z.default.add(z.default.BigInt(n),z.default.multiply(l,El)),p=z.default.add(z.default.BigInt(i),z.default.multiply(m,xr)),g=z.default.add(z.default.BigInt(o),z.default.multiply(p,xr));return z.default.add(z.default.BigInt(u),z.default.multiply(g,xr))}function wO(t,e){let r=xe("%Temporal.Instant%"),n=bw(z.default.toNumber(t)),i=z.default.BigInt(t),o=864e11;if(n===0)return{days:0,nanoseconds:kn,dayLengthNs:o};if(!qe(e)){let P;return{quotient:P,remainder:i}=Ln(i,z.default.BigInt(o)),{days:z.default.toNumber(P),nanoseconds:i,dayLengthNs:o}}let s=R(e,ct),a=R(e,xo),d=z.default.add(s,i),u=new r(d),c=R(e,$r),l=R(e,se),m=ka(c,a,l),p=ka(c,u,l),{days:g}=SO(R(m,Te),R(m,Re),R(m,Oe),R(m,vt),R(m,wt),R(m,_t),R(m,xt),R(m,Et),R(m,St),R(p,Te),R(p,Re),R(p,Oe),R(p,vt),R(p,wt),R(p,_t),R(p,xt),R(p,Et),R(p,St),l,"day",So(null)),b=mc(a,c,l,0,0,0,g,0,0,0,0,0,0),S=z.default.BigInt(g);if(n===1)for(;z.default.greaterThan(S,kn)&&z.default.greaterThan(b,d);)S=z.default.subtract(S,Tw),b=mc(a,c,l,0,0,0,z.default.toNumber(S),0,0,0,0,0,0);i=z.default.subtract(d,b);let A=!1,I=new r(b);do{let P=mc(I,c,l,0,0,0,n,0,0,0,0,0,0),$=R(I,ct);o=z.default.toNumber(z.default.subtract(P,$)),A=z.default.greaterThanOrEqual(z.default.multiply(z.default.subtract(i,z.default.BigInt(o)),z.default.BigInt(n)),kn),A&&(i=z.default.subtract(i,z.default.BigInt(o)),I=new r(P),S=z.default.add(S,z.default.BigInt(n)))}while(A);if(!hc(S)&&eoe(S)!==n)throw new RangeError("Time zone or calendar converted nanoseconds into a number of days with the opposite sign");if(!hc(i)&&eoe(i)!==n)throw N4(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(lu(i),lu(z.default.BigInt(o))))throw new Error("assert not reached");return{days:z.default.toNumber(S),nanoseconds:i,dayLengthNs:on(o)}}function ld(t,e,r,n,i,o,s,a,d){let u=cse(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 cse(t,e,r,n,i,o,s,a,d){let u,c,l,m,p,g,b=t;if(qe(d)){let F=mc(R(d,xo),R(d,$r),R(d,se),0,0,0,b,e,r,n,i,o,s),U=R(d,ct);u=z.default.subtract(F,U)}else u=Sw(b,e,r,n,i,o,s,0);a==="year"||a==="month"||a==="week"||a==="day"?{days:b,nanoseconds:u}=wO(u,d):b=0;let S=z.default.lessThan(u,kn)?-1:1;switch(u=lu(u),c=l=m=p=g=kn,a){case"year":case"month":case"week":case"day":case"hour":({quotient:c,remainder:u}=Ln(u,xr)),{quotient:l,remainder:c}=Ln(c,xr),{quotient:m,remainder:l}=Ln(l,xr),{quotient:p,remainder:m}=Ln(m,El),{quotient:g,remainder:p}=Ln(p,El);break;case"minute":({quotient:c,remainder:u}=Ln(u,xr)),{quotient:l,remainder:c}=Ln(c,xr),{quotient:m,remainder:l}=Ln(l,xr),{quotient:p,remainder:m}=Ln(m,El);break;case"second":({quotient:c,remainder:u}=Ln(u,xr)),{quotient:l,remainder:c}=Ln(c,xr),{quotient:m,remainder:l}=Ln(l,xr);break;case"millisecond":({quotient:c,remainder:u}=Ln(u,xr)),{quotient:l,remainder:c}=Ln(c,xr);break;case"microsecond":({quotient:c,remainder:u}=Ln(u,xr));break;case"nanosecond":break;default:throw new Error("assert not reached")}let A=z.default.toNumber(g)*S,I=z.default.toNumber(p)*S,P=z.default.toNumber(m)*S,$=z.default.toNumber(l)*S,N=z.default.toNumber(c)*S,L=z.default.toNumber(u)*S;for(let F of[b,A,I,P,$,N,L])if(!Zo(F))return S===1?"positive overflow":"negative overflow";return{days:b,hours:A,minutes:I,seconds:P,milliseconds:$,microseconds:N,nanoseconds:L}}function k4(t,e,r,n,i,o){let s=xe("%Temporal.Duration%"),a=Al(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),m=z.default.BigInt(e),p=z.default.BigInt(r),g=z.default.BigInt(n);o&&(c=Ur(o),u=R(c,se));let b=new s(a),S=new s(0,a),A=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 I,P;for(typeof u!="string"&&(I=Tr(u,"dateAdd"),P=Tr(u,"dateUntil"));!hc(l);){let $=Zi(u,c,b,void 0,I),N=So(null);N.largestUnit="month";let L=Vp(u,c,$,N,P),F=z.default.BigInt(R(L,ji));c=$,m=z.default.add(m,F),l=z.default.subtract(l,d)}}break;case"week":{if(!u)throw new RangeError("a starting point is required for weeks balancing");let I=typeof u!="string"?Tr(u,"dateAdd"):void 0;for(;!hc(l);){let P;({relativeTo:c,days:P}=_o(u,c,b,I)),g=z.default.add(g,z.default.BigInt(P)),l=z.default.subtract(l,d)}for(;!hc(m);){let P;({relativeTo:c,days:P}=_o(u,c,S,I)),g=z.default.add(g,z.default.BigInt(P)),m=z.default.subtract(m,d)}break}default:{if(hc(l)&&hc(m)&&hc(p))break;if(!u)throw new RangeError("a starting point is required for balancing calendar units");let I=typeof u!="string"?Tr(u,"dateAdd"):void 0;for(;!hc(l);){let P;({relativeTo:c,days:P}=_o(u,c,b,I)),g=z.default.add(g,z.default.BigInt(P)),l=z.default.subtract(l,d)}for(;!hc(m);){let P;({relativeTo:c,days:P}=_o(u,c,S,I)),g=z.default.add(g,z.default.BigInt(P)),m=z.default.subtract(m,d)}for(;!hc(p);){let P;({relativeTo:c,days:P}=_o(u,c,A,I)),g=z.default.add(g,z.default.BigInt(P)),p=z.default.subtract(p,d)}break}}return{years:z.default.toNumber(l),months:z.default.toNumber(m),weeks:z.default.toNumber(p),days:z.default.toNumber(g)}}function moe(t,e,r,n,i){if(qe(t)){let o=R(t,xo),s=R(t,$r),a=R(t,se),d=pu(s,o),u=mc(o,s,a,e,r,n,i,0,0,0,0,0,0);return pu(s,new(xe("%Temporal.Instant%"))(u))-d}return 0}function dse(t){return new(xe("%Temporal.Duration%"))(-R(t,Fo),-R(t,ji),-R(t,Bs),-R(t,zo),-R(t,Go),-R(t,Wo),-R(t,Ho),-R(t,Vo),-R(t,Jo),-R(t,Yo))}function ea(t,e,r){return BBe(r,CBe(e,t))}function use(t,e,r){let n=ea(e,1,12);return{year:t,month:n,day:ea(r,1,Qf(t,n))}}function Xi(t,e,r){if(tr)throw new RangeError(`value out of range: ${e} <= ${t} <= ${r}`)}function Tl(t,e,r){Xi(e,1,12),Xi(r,1,Qf(t,e))}function lse(t,e,r){fse(t,e,r,12,0,0,0,0,0)}function lA(t,e,r,n,i,o){Xi(t,0,23),Xi(e,0,59),Xi(r,0,59),Xi(n,0,999),Xi(i,0,999),Xi(o,0,999)}function _O(t,e,r,n,i,o,s,a,d){Tl(t,e,r),lA(n,i,o,s,a,d)}function fse(t,e,r,n,i,o,s,a,d){if(Xi(t,O4,$4),t===O4&&Yp(t,e,r+1,n,i,o,s,a,d-1)==null||t===$4&&Yp(t,e,r-1,n,i,o,s,a,d+1)==null)throw new RangeError("DateTime outside of supported range")}function B0(t){if(z.default.lessThan(t,Dx)||z.default.greaterThan(t,vw))throw new RangeError("Instant outside of supported range")}function G4(t,e,r,n,i,o,s,a,d,u){let c=Al(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(!Zo(l))throw new RangeError("infinite values not allowed as duration fields");let m=bw(l);if(m!==0&&m!==c)throw new RangeError("mixed-sign values not allowed as duration fields")}}function xO(t,e,r,n,i,o,s){switch(s){case"year":case"month":{let a=-Hp(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=$0(t,e,r,c,0,0,0,"constrain"),m=-Hp(l.year,l.month,l.day,n,i,o);if(m===0)return s==="year"?{years:c,months:0,weeks:0,days:0}:{years:0,months:12*c,weeks:0,days:0};let p=u.month-d.month;if(m!==a&&(c-=a,p+=12*a),l=$0(t,e,r,c,p,0,0,"constrain"),m=-Hp(l.year,l.month,l.day,n,i,o),m===0)return s==="year"?{years:c,months:p,weeks:0,days:0}:{years:0,months:p+12*c,weeks:0,days:0};m!==a&&(p-=a,p===-a&&(c-=a,p=11*a),l=$0(t,e,r,c,p,0,0,"constrain"));let g=0;return g=l.month===u.month?u.day-l.day:a<0?-l.day-(Qf(u.year,u.month)-u.day):u.day+(Qf(l.year,l.month)-l.day),s==="month"&&(p+=12*c,c=0),{years:c,months:p,weeks:0,days:g}}case"week":case"day":{let a,d,u;Hp(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=z4(a.year,a.month,a.day)-z4(d.year,d.month,d.day);for(let m=d.year;m{let b=g[0],S=g[1],A=g[2];return r!=="datetime"&&A!==r||n.includes(S)||p.push(S,b),p},[]),a=ra(e,"largestUnit",r,"auto");if(n.includes(a))throw new RangeError(`largestUnit must be one of ${s.join(", ")}, not ${a}`);let d=kw(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=ra(e,"smallestUnit",r,i);if(n.includes(c))throw new RangeError(`smallestUnit must be one of ${s.join(", ")}, not ${c}`);let l=K0(o,c);if(a==="auto"&&(a=l),K0(a,c)!==a)throw new RangeError(`largestUnit ${a} cannot be smaller than smallestUnit ${c}`);let m={hour:24,minute:60,second:60,millisecond:1e3,microsecond:1e3,nanosecond:1e3}[c];return m!==void 0&&Rw(d,m,!1),{largestUnit:a,roundingIncrement:d,roundingMode:u,smallestUnit:c}}function yoe(t,e,r,n){let i=t==="since"?-1:1,o=fu(r),s=Mw(t,rm(n),"time",[],"nanosecond","second"),a=R(e,ct),d=R(o,ct),{hours:u,minutes:c,seconds:l,milliseconds:m,microseconds:p,nanoseconds:g}=EO(a,d,s.roundingIncrement,s.smallestUnit,s.largestUnit,s.roundingMode);return new(xe("%Temporal.Duration%"))(0,0,0,0,i*u,i*c,i*l,i*m,i*p,i*g)}function goe(t,e,r,n){let i=t==="since"?-1:1,o=Ur(r),s=R(e,se);aA(s,R(o,se),"compute difference between dates");let a=rm(n),d=Mw(t,a,"date",[],"day","day");a.largestUnit=d.largestUnit;let{years:u,months:c,weeks:l,days:m}=Vp(s,e,o,a);return d.smallestUnit==="day"&&d.roundingIncrement===1||({years:u,months:c,weeks:l,days:m}=rh(u,c,l,m,0,0,0,0,0,0,d.roundingIncrement,d.smallestUnit,d.roundingMode,e)),new(xe("%Temporal.Duration%"))(i*u,i*c,i*l,i*m,0,0,0,0,0,0)}function boe(t,e,r,n){let i=t==="since"?-1:1,o=O0(r),s=R(e,se);aA(s,R(o,se),"compute difference between dates");let a=rm(n),d=Mw(t,a,"datetime",[],"nanosecond","day"),{years:u,months:c,weeks:l,days:m,hours:p,minutes:g,seconds:b,milliseconds:S,microseconds:A,nanoseconds:I}=SO(R(e,Te),R(e,Re),R(e,Oe),R(e,vt),R(e,wt),R(e,_t),R(e,xt),R(e,Et),R(e,St),R(o,Te),R(o,Re),R(o,Oe),R(o,vt),R(o,wt),R(o,_t),R(o,xt),R(o,Et),R(o,St),s,d.largestUnit,a),P=Ew(e);return{years:u,months:c,weeks:l,days:m,hours:p,minutes:g,seconds:b,milliseconds:S,microseconds:A,nanoseconds:I}=rh(u,c,l,m,p,g,b,S,A,I,d.roundingIncrement,d.smallestUnit,d.roundingMode,P),{days:m,hours:p,minutes:g,seconds:b,milliseconds:S,microseconds:A,nanoseconds:I}=ld(m,p,g,b,S,A,I,d.largestUnit),new(xe("%Temporal.Duration%"))(i*u,i*c,i*l,i*m,i*p,i*g,i*b,i*S,i*A,i*I)}function voe(t,e,r,n){let i=t==="since"?-1:1,o=Zf(r),s=Mw(t,rm(n),"time",[],"nanosecond","hour"),{hours:a,minutes:d,seconds:u,milliseconds:c,microseconds:l,nanoseconds:m}=hse(R(e,vt),R(e,wt),R(e,_t),R(e,xt),R(e,Et),R(e,St),R(o,vt),R(o,wt),R(o,_t),R(o,xt),R(o,Et),R(o,St));return{hours:a,minutes:d,seconds:u,milliseconds:c,microseconds:l,nanoseconds:m}=rh(0,0,0,0,a,d,u,c,l,m,s.roundingIncrement,s.smallestUnit,s.roundingMode),{hours:a,minutes:d,seconds:u,milliseconds:c,microseconds:l,nanoseconds:m}=ld(0,a,d,u,c,l,m,s.largestUnit),new(xe("%Temporal.Duration%"))(0,0,0,0,i*a,i*d,i*u,i*c,i*l,i*m)}function woe(t,e,r,n){let i=t==="since"?-1:1,o=Tx(r),s=R(e,se);aA(s,R(o,se),"compute difference between months");let a=rm(n),d=Mw(t,a,"date",["week","day"],"month","year");a.largestUnit=d.largestUnit;let u=Jn(s,["monthCode","year"]),c=Mt(e,u,[]);c.day=1;let l=th(s,c),m=Mt(o,u,[]);m.day=1;let p=th(s,m),{years:g,months:b}=Vp(s,l,p,a);return d.smallestUnit==="month"&&d.roundingIncrement===1||({years:g,months:b}=rh(g,b,0,0,0,0,0,0,0,0,d.roundingIncrement,d.smallestUnit,d.roundingMode,l)),new(xe("%Temporal.Duration%"))(i*g,i*b,0,0,0,0,0,0,0,0)}function _oe(t,e,r,n){let i=t==="since"?-1:1,o=Ix(r),s=R(e,se);aA(s,R(o,se),"compute difference between dates");let a=rm(n),d=Mw(t,a,"datetime",[],"nanosecond","hour");a.largestUnit=d.largestUnit;let u=R(e,ct),c=R(o,ct),l,m,p,g,b,S,A,I,P,$;if(d.largestUnit!=="year"&&d.largestUnit!=="month"&&d.largestUnit!=="week"&&d.largestUnit!=="day")l=0,m=0,p=0,g=0,{hours:b,minutes:S,seconds:A,milliseconds:I,microseconds:P,nanoseconds:$}=EO(u,c,d.roundingIncrement,d.smallestUnit,d.largestUnit,d.roundingMode);else{let N=R(e,$r);if(!tse(N,R(o,$r)))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:m,weeks:p,days:g,hours:b,minutes:S,seconds:A,milliseconds:I,microseconds:P,nanoseconds:$}=pse(u,c,N,s,d.largestUnit,a)),{years:l,months:m,weeks:p,days:g,hours:b,minutes:S,seconds:A,milliseconds:I,microseconds:P,nanoseconds:$}=rh(l,m,p,g,b,S,A,I,P,$,d.roundingIncrement,d.smallestUnit,d.roundingMode,e),{years:l,months:m,weeks:p,days:g,hours:b,minutes:S,seconds:A,milliseconds:I,microseconds:P,nanoseconds:$}=bse(l,m,p,g,b,S,A,I,P,$,d.roundingIncrement,d.smallestUnit,d.roundingMode,e)}return new(xe("%Temporal.Duration%"))(i*l,i*m,i*p,i*g,i*b,i*S,i*A,i*I,i*P,i*$)}function $0(t,e,r,n,i,o,s,a){let d=t,u=e,c=r,l=o,m=s;return d+=n,u+=i,{year:d,month:u}=D4(d,u),{year:d,month:u,day:c}=U4(d,u,c,a),m+=7*l,c+=m,{year:d,month:u,day:c}=uA(d,u,c),{year:d,month:u,day:c}}function mse(t,e,r,n,i,o,s,a,d,u,c,l){let m=t,p=e,g=r,b=n,S=i,A=o;m+=s,p+=a,g+=d,b+=u,S+=c,A+=l;let I=0;return{deltaDays:I,hour:m,minute:p,second:g,millisecond:b,microsecond:S,nanosecond:A}=Yf(m,p,g,b,S,A),{deltaDays:I,hour:m,minute:p,second:g,millisecond:b,microsecond:S,nanosecond:A}}function yse(t,e,r,n,i,o,s,a,d,u,c,l,m,p,g,b,S,A,I,P,$){let N=K0(OC(t,e,r,n,i,o,s,a,d,u),OC(c,l,m,p,g,b,S,A,I,P)),L,F,U,G,q,T,E,k,f,y;if($)if(Gt($)){let w=xe("%Temporal.Duration%"),_=R($,se),x=new w(t,e,r,n,0,0,0,0,0,0),v=new w(c,l,m,p,0,0,0,0,0,0),D=typeof _!="string"?Tr(_,"dateAdd"):void 0,K=Zi(_,$,x,void 0,D),M=Zi(_,K,v,void 0,D),j=K0("day",N),J=So(null);J.largestUnit=j,{years:L,months:F,weeks:U,days:G}=Vp(_,$,M,J),{days:G,hours:q,minutes:T,seconds:E,milliseconds:k,microseconds:f,nanoseconds:y}=ld(G,z.default.add(z.default.BigInt(i),z.default.BigInt(g)),z.default.add(z.default.BigInt(o),z.default.BigInt(b)),z.default.add(z.default.BigInt(s),z.default.BigInt(S)),z.default.add(z.default.BigInt(a),z.default.BigInt(A)),z.default.add(z.default.BigInt(d),z.default.BigInt(I)),z.default.add(z.default.BigInt(u),z.default.BigInt(P)),N)}else{let w=xe("%Temporal.Instant%"),_=R($,$r),x=R($,se),v=mc(R($,xo),_,x,t,e,r,n,i,o,s,a,d,u),D=mc(new w(v),_,x,c,l,m,p,g,b,S,A,I,P);N!=="year"&&N!=="month"&&N!=="week"&&N!=="day"?(L=0,F=0,U=0,G=0,{hours:q,minutes:T,seconds:E,milliseconds:k,microseconds:f,nanoseconds:y}=EO(R($,ct),D,1,"nanosecond",N,"halfExpand")):{years:L,months:F,weeks:U,days:G,hours:q,minutes:T,seconds:E,milliseconds:k,microseconds:f,nanoseconds:y}=pse(R($,ct),D,_,x,N,So(null))}else{if(N==="year"||N==="month"||N==="week")throw new RangeError("relativeTo is required for years, months, or weeks arithmetic");L=F=U=0,{days:G,hours:q,minutes:T,seconds:E,milliseconds:k,microseconds:f,nanoseconds:y}=ld(n+p,z.default.add(z.default.BigInt(i),z.default.BigInt(g)),z.default.add(z.default.BigInt(o),z.default.BigInt(b)),z.default.add(z.default.BigInt(s),z.default.BigInt(S)),z.default.add(z.default.BigInt(a),z.default.BigInt(A)),z.default.add(z.default.BigInt(d),z.default.BigInt(I)),z.default.add(z.default.BigInt(u),z.default.BigInt(P)),N)}return G4(L,F,U,G,q,T,E,k,f,y),{years:L,months:F,weeks:U,days:G,hours:q,minutes:T,seconds:E,milliseconds:k,microseconds:f,nanoseconds:y}}function UC(t,e,r,n,i,o,s){let a=kn;a=z.default.add(a,z.default.BigInt(s)),a=z.default.add(a,z.default.multiply(z.default.BigInt(o),xr)),a=z.default.add(a,z.default.multiply(z.default.BigInt(i),pc)),a=z.default.add(a,z.default.multiply(z.default.BigInt(n),Sl)),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 B0(d),d}function KC(t,e,r,n,i,o,s,a,d,u,c,l,m,p,g,b,S,A,I,P,$){let N=p,{deltaDays:L,hour:F,minute:U,second:G,millisecond:q,microsecond:T,nanosecond:E}=mse(n,i,o,s,a,d,g,b,S,A,I,P);N+=L;let k=xe("%Temporal.Duration%"),f=Zi(u,yc(t,e,r,u),new k(c,l,m,N,0,0,0,0,0,0),$);return{year:R(f,Te),month:R(f,Re),day:R(f,Oe),hour:F,minute:U,second:G,millisecond:q,microsecond:T,nanosecond:E}}function mc(t,e,r,n,i,o,s,a,d,u,c,l,m,p){let g=xe("%Temporal.Duration%");if(Al(n,i,o,s,0,0,0,0,0,0)===0)return UC(R(t,ct),a,d,u,c,l,m);let b=ka(e,t,r),S=Zi(r,yc(R(b,Te),R(b,Re),R(b,Oe),r),new g(n,i,o,s,0,0,0,0,0,0),p),A=Qs(R(S,Te),R(S,Re),R(S,Oe),R(b,vt),R(b,wt),R(b,_t),R(b,xt),R(b,Et),R(b,St),r);return UC(R(Xo(e,A,"compatible"),ct),a,d,u,c,l,m)}function xoe(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:m,microseconds:p,nanoseconds:g}=G0(r),b=R4(Zt(n));return{years:o,months:s,weeks:a,days:d,hours:u,minutes:c,seconds:l,milliseconds:m,microseconds:p,nanoseconds:g}=yse(R(e,Fo),R(e,ji),R(e,Bs),R(e,zo),R(e,Go),R(e,Wo),R(e,Ho),R(e,Vo),R(e,Jo),R(e,Yo),i*o,i*s,i*a,i*d,i*u,i*c,i*l,i*m,i*p,i*g,b),new(xe("%Temporal.Duration%"))(o,s,a,d,u,c,l,m,p,g)}function Eoe(t,e,r){let n=t==="subtract"?-1:1,{hours:i,minutes:o,seconds:s,milliseconds:a,microseconds:d,nanoseconds:u}=function(m,p){let g=G0(m);for(let b of p)if(g[b]!==0)throw new RangeError(`Duration field ${b} not supported by Temporal.Instant. Try Temporal.ZonedDateTime instead.`);return g}(r,["years","months","weeks","days"]),c=UC(R(e,ct),n*i,n*o,n*s,n*a,n*d,n*u);return new(xe("%Temporal.Instant%"))(c)}function Soe(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:m,microseconds:p,nanoseconds:g}=G0(r),b=Zt(n),S=R(e,se),{year:A,month:I,day:P,hour:$,minute:N,second:L,millisecond:F,microsecond:U,nanosecond:G}=KC(R(e,Te),R(e,Re),R(e,Oe),R(e,vt),R(e,wt),R(e,_t),R(e,xt),R(e,Et),R(e,St),S,i*o,i*s,i*a,i*d,i*u,i*c,i*l,i*m,i*p,i*g,b);return Qs(A,I,P,$,N,L,F,U,G,S)}function Aoe(t,e,r){let n=t==="subtract"?-1:1,{hours:i,minutes:o,seconds:s,milliseconds:a,microseconds:d,nanoseconds:u}=G0(r),{hour:c,minute:l,second:m,millisecond:p,microsecond:g,nanosecond:b}=mse(R(e,vt),R(e,wt),R(e,_t),R(e,xt),R(e,Et),R(e,St),n*i,n*o,n*s,n*a,n*d,n*u);return{hour:c,minute:l,second:m,millisecond:p,microsecond:g,nanosecond:b}=X4(c,l,m,p,g,b,"reject"),new(xe("%Temporal.PlainTime%"))(c,l,m,p,g,b)}function Poe(t,e,r,n){let i=G0(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:m,microseconds:p,nanoseconds:g}=i;({days:d}=ld(d,u,c,l,m,p,g,"day"));let b=Zt(n),S=R(e,se),A=Jn(S,["monthCode","year"]),I=Mt(e,A,[]),P=So(null);fw(P,I,[]),I.day=1;let $=th(S,I),N=Al(o,s,a,d,0,0,0,0,0,0),L=Tr(S,"dateAdd"),F=xe("%Temporal.Duration%");if(N<0){let q=Zi(S,$,new F(0,1,0,0,0,0,0,0,0,0),void 0,L),T=Zi(S,q,new F(0,0,0,-1,0,0,0,0,0,0),void 0,L);P.day=Xx(S,T),$=th(S,P)}let U=new F(o,s,a,d,0,0,0,0,0,0),G=rm(b);return L0(S,Mt(Zi(S,$,U,b,L),A,[]),G)}function Toe(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:m,microseconds:p,nanoseconds:g}=G0(r),b=Zt(n),S=R(e,$r),A=R(e,se);return Yi(mc(R(e,xo),S,A,i*o,i*s,i*a,i*d,i*u,i*c,i*l,i*m,i*p,i*g,b),S,A)}function Ia(t,e,r){if(z.default.equal(e,Tw))return t;let{quotient:n,remainder:i}=Ln(t,e);if(z.default.equal(i,kn))return t;let o=z.default.lessThan(i,kn)?-1:1,s=lu(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(lu(n),z.default.BigInt(2)))===1)&&(n=z.default.add(n,z.default.BigInt(o)))}return z.default.multiply(n,e)}function W4(t,e,r,n){let{remainder:i}=M0(t,Pl),o=z.default.subtract(t,i),s=Ia(i,z.default.BigInt(_se[r]*e),n);return z.default.add(o,s)}function AO(t,e,r,n,i,o,s,a,d,u,c,l,m=864e11){let{deltaDays:p,hour:g,minute:b,second:S,millisecond:A,microsecond:I,nanosecond:P}=PO(n,i,o,s,a,d,u,c,l,m),{year:$,month:N,day:L}=uA(t,e,r+p);return{year:$,month:N,day:L,hour:g,minute:b,second:S,millisecond:A,microsecond:I,nanosecond:P}}function PO(t,e,r,n,i,o,s,a,d,u=864e11){let c=kn;switch(a){case"day":case"hour":c=z.default.BigInt(t);case"minute":c=z.default.add(z.default.multiply(c,El),z.default.BigInt(e));case"second":c=z.default.add(z.default.multiply(c,El),z.default.BigInt(r));case"millisecond":c=z.default.add(z.default.multiply(c,xr),z.default.BigInt(n));case"microsecond":c=z.default.add(z.default.multiply(c,xr),z.default.BigInt(i));case"nanosecond":c=z.default.add(z.default.multiply(c,xr),z.default.BigInt(o))}let l=a==="day"?u:_se[a],m=Ia(c,z.default.BigInt(l*s),d),p=z.default.toNumber(z.default.divide(m,z.default.BigInt(l)));switch(a){case"day":return{deltaDays:p,hour:0,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0};case"hour":return Yf(p,0,0,0,0,0);case"minute":return Yf(t,p,0,0,0,0);case"second":return Yf(t,e,p,0,0,0);case"millisecond":return Yf(t,e,r,p,0,0);case"microsecond":return Yf(t,e,r,n,p,0);case"nanosecond":return Yf(t,e,r,n,i,p);default:throw new Error(`Invalid unit ${a}`)}}function M4(t,e){return xO(R(t,Te),R(t,Re),R(t,Oe),R(e,Te),R(e,Re),R(e,Oe),"day").days}function _o(t,e,r,n){let i=Zi(t,e,r,void 0,n);return{relativeTo:i,days:M4(e,i)}}function gse(t,e,r,n,i){let o=R(t,$r),s=R(t,se);return Yi(mc(R(t,xo),o,s,e,r,n,i,0,0,0,0,0,0),o,s)}function bse(t,e,r,n,i,o,s,a,d,u,c,l,m,p){let g=t,b=e,S=r,A=n,I=i,P=o,$=s,N=a,L=d,F=u;if(!qe(p)||l==="year"||l==="month"||l==="week"||l==="day"||l==="nanosecond"&&c===1)return{years:g,months:b,weeks:S,days:A,hours:I,minutes:P,seconds:$,milliseconds:N,microseconds:L,nanoseconds:F};let U=Sw(0,I,P,$,N,L,F,0),G=bw(z.default.toNumber(U)),q=R(p,$r),T=R(p,se),E=mc(R(p,xo),q,T,g,b,S,A,0,0,0,0,0,0),k=mc(new(xe("%Temporal.Instant%"))(E),q,T,0,0,0,G,0,0,0,0,0,0),f=z.default.subtract(k,E);return z.default.greaterThanOrEqual(z.default.multiply(z.default.subtract(U,f),z.default.BigInt(G)),kn)&&({years:g,months:b,weeks:S,days:A}=yse(g,b,S,A,0,0,0,0,0,0,0,0,0,G,0,0,0,0,0,0,p),U=W4(z.default.subtract(U,f),c,l,m),{hours:I,minutes:P,seconds:$,milliseconds:N,microseconds:L,nanoseconds:F}=ld(0,0,0,0,0,0,z.default.toNumber(U),"hour")),{years:g,months:b,weeks:S,days:A,hours:I,minutes:P,seconds:$,milliseconds:N,microseconds:L,nanoseconds:F}}function rh(t,e,r,n,i,o,s,a,d,u,c,l,m,p){let g=t,b=e,S=r,A=n,I=i,P=o,$=s,N=a,L=d,F=z.default.BigInt(u),U=xe("%Temporal.Duration%"),G,q,T,E,k=p;if(k){if(qe(k))q=k,k=Ur(k);else if(!Gt(k))throw new TypeError("starting point must be PlainDate or ZonedDateTime");G=R(k,se)}if(l==="year"||l==="month"||l==="week"||l==="day"){let f,y,w;F=Sw(0,I,P,$,N,L,u,0),q&&(f=gse(q,g,b,S,A)),{days:y,nanoseconds:F,dayLengthNs:w}=wO(F,f),T=z.default.BigInt(w),A+=y,I=P=$=N=L=0}switch(l){case"year":{if(!G)throw new RangeError("A starting point is required for years rounding");let f=new U(g),y=typeof G!="string"?Tr(G,"dateAdd"):void 0,w=Zi(G,k,f,void 0,y),_=Zi(G,k,new U(g,b,S),void 0,y);k=w,A+=M4(w,_);let x=Zi(G,k,new U(0,0,0,A),void 0,y),v=So(null);v.largestUnit="year";let D=Vp(G,k,x,v).years;g+=D;let K=k;k=Zi(G,k,new U(D),void 0,y),A-=M4(K,k);let M=new U(A<0?-1:1),{days:j}=_o(G,k,M,y);j=on(j);let J=z.default.multiply(z.default.BigInt(j),T);F=z.default.add(z.default.add(z.default.multiply(J,z.default.BigInt(g)),z.default.multiply(z.default.BigInt(A),T)),F);let Z=Ia(F,z.default.multiply(J,z.default.BigInt(c)),m);E=_l(F,J),g=z.default.toNumber(z.default.divide(Z,J)),F=kn,b=S=A=0;break}case"month":{if(!G)throw new RangeError("A starting point is required for months rounding");let f=new U(g,b),y=typeof G!="string"?Tr(G,"dateAdd"):void 0,w=Zi(G,k,f,void 0,y),_=Zi(G,k,new U(g,b,S),void 0,y);k=w,A+=M4(w,_);let x=bw(A),v=new U(0,A<0?-1:1),D;for({relativeTo:k,days:D}=_o(G,k,v,y);on(A)>=on(D);)b+=x,A-=D,{relativeTo:k,days:D}=_o(G,k,v,y);D=on(D);let K=z.default.multiply(z.default.BigInt(D),T);F=z.default.add(z.default.add(z.default.multiply(K,z.default.BigInt(b)),z.default.multiply(z.default.BigInt(A),T)),F);let M=Ia(F,z.default.multiply(K,z.default.BigInt(c)),m);E=_l(F,K),b=z.default.toNumber(z.default.divide(M,K)),F=kn,S=A=0;break}case"week":{if(!G)throw new RangeError("A starting point is required for weeks rounding");let f=bw(A),y=new U(0,0,A<0?-1:1),w=typeof G!="string"?Tr(G,"dateAdd"):void 0,_;for({relativeTo:k,days:_}=_o(G,k,y,w);on(A)>=on(_);)S+=f,A-=_,{relativeTo:k,days:_}=_o(G,k,y,w);_=on(_);let x=z.default.multiply(z.default.BigInt(_),T);F=z.default.add(z.default.add(z.default.multiply(x,z.default.BigInt(S)),z.default.multiply(z.default.BigInt(A),T)),F);let v=Ia(F,z.default.multiply(x,z.default.BigInt(c)),m);E=_l(F,x),S=z.default.toNumber(z.default.divide(v,x)),F=kn,A=0;break}case"day":{let f=T;F=z.default.add(z.default.multiply(f,z.default.BigInt(A)),F);let y=Ia(F,z.default.multiply(f,z.default.BigInt(c)),m);E=_l(F,f),A=z.default.toNumber(z.default.divide(y,f)),F=kn;break}case"hour":{let y=z.default.multiply(z.default.BigInt(I),z.default.BigInt(36e11));y=z.default.add(y,z.default.multiply(z.default.BigInt(P),z.default.BigInt(6e10))),y=z.default.add(y,z.default.multiply(z.default.BigInt($),Sl)),y=z.default.add(y,z.default.multiply(z.default.BigInt(N),pc)),y=z.default.add(y,z.default.multiply(z.default.BigInt(L),xr)),y=z.default.add(y,F),E=_l(y,z.default.BigInt(36e11));let w=Ia(y,z.default.BigInt(36e11*c),m);I=z.default.toNumber(z.default.divide(w,z.default.BigInt(36e11))),F=kn,P=$=N=L=0;break}case"minute":{let y=z.default.multiply(z.default.BigInt(P),z.default.BigInt(6e10));y=z.default.add(y,z.default.multiply(z.default.BigInt($),Sl)),y=z.default.add(y,z.default.multiply(z.default.BigInt(N),pc)),y=z.default.add(y,z.default.multiply(z.default.BigInt(L),xr)),y=z.default.add(y,F),E=_l(y,z.default.BigInt(6e10));let w=Ia(y,z.default.BigInt(6e10*c),m);P=z.default.toNumber(z.default.divide(w,z.default.BigInt(6e10))),F=kn,$=N=L=0;break}case"second":{let y=z.default.multiply(z.default.BigInt($),Sl);y=z.default.add(y,z.default.multiply(z.default.BigInt(N),pc)),y=z.default.add(y,z.default.multiply(z.default.BigInt(L),xr)),y=z.default.add(y,F),E=_l(y,z.default.BigInt(1e9));let w=Ia(y,z.default.BigInt(1e9*c),m);$=z.default.toNumber(z.default.divide(w,z.default.BigInt(1e9))),F=kn,N=L=0;break}case"millisecond":{let y=z.default.multiply(z.default.BigInt(N),pc);y=z.default.add(y,z.default.multiply(z.default.BigInt(L),xr)),y=z.default.add(y,F),E=_l(y,z.default.BigInt(1e6));let w=Ia(y,z.default.BigInt(1e6*c),m);N=z.default.toNumber(z.default.divide(w,z.default.BigInt(1e6))),F=kn,L=0;break}case"microsecond":{let y=z.default.multiply(z.default.BigInt(L),xr);y=z.default.add(y,F),E=_l(y,z.default.BigInt(1e3));let w=Ia(y,z.default.BigInt(1e3*c),m);L=z.default.toNumber(z.default.divide(w,z.default.BigInt(1e3))),F=kn;break}case"nanosecond":E=z.default.toNumber(F),F=Ia(z.default.BigInt(F),z.default.BigInt(c),m)}return{years:g,months:b,weeks:S,days:A,hours:I,minutes:P,seconds:$,milliseconds:N,microseconds:L,nanoseconds:z.default.toNumber(F),total:E}}function Hp(t,e,r,n,i,o){for(let[s,a]of[[t,n],[e,i],[r,o]])if(s!==a)return N0(s-a);return 0}function M0(t,e){let{quotient:r,remainder:n}=Ln(t,e);return z.default.lessThan(n,kn)&&(r=z.default.subtract(r,Tw),n=z.default.add(n,e)),{quotient:r,remainder:n}}function pw(t,e){let{quotient:r,remainder:n}=Ln(t,e);return hc(n)||!N4(t)==!N4(e)?r:z.default.subtract(r,Tw)}function _l(t,e){let{quotient:r,remainder:n}=Ln(t,e);return z.default.toNumber(r)+z.default.toNumber(n)/z.default.toNumber(e)}function H4(t){let e=kx(t);return globalThis.BigInt!==void 0?globalThis.BigInt(e.toString(10)):e}function kx(t){let e=t;if(typeof t=="object"){let r=t[Symbol.toPrimitive];r&&typeof r=="function"&&(e=Z4(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 TO=(()=>{let t=z.default.BigInt(Date.now()%1e6);return()=>{let e=z.default.BigInt(Date.now()),r=z.default.add(z.default.multiply(e,pc),t);return t=z.default.remainder(e,pc),z.default.greaterThan(r,vw)?vw:z.default.lessThan(r,Dx)?Dx:r}})();function Wp(){return new qoe().resolvedOptions().timeZone}function N0(t){return t<0?-1:t>0?1:t}function Zt(t){if(t===void 0)return So(null);if(sn(t)&&t!==null)return t;throw new TypeError("Options parameter must be an object, not "+(t===null?"null":typeof t))}function Aw(t,e){let r=So(null);return r[t]=e,r}function rm(t){let e=So(null);return fw(e,Zt(t),[]),e}function Xp(t,e,r,n){let i=t[e];if(i!==void 0){if(i=Qo(i),!r.includes(i))throw new RangeError(`${e} must be one of ${r.join(", ")}, not ${i}`);return i}return n}function nh(t){return qBe.includes(Il(t))}function Il(t){return t.replace(/[A-Z]/g,e=>{let r=e.charCodeAt(0);return String.fromCharCode(r+32)})}var vse=new RegExp(`^${joe.source}$`);function wse(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),Tw);){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 _se={hour:36e11,minute:6e10,second:1e9,millisecond:1e6,microsecond:1e3,nanosecond:1},xse=Symbol("date"),Ese=Symbol("ym"),Sse=Symbol("md"),Ase=Symbol("time"),Pse=Symbol("datetime"),Tse=Symbol("instant"),mw=Symbol("original"),dw=Symbol("timezone"),ud=Symbol("calendar-id"),Ise=Symbol("locale"),qC=Symbol("options"),Rx=t=>({value:t,enumerable:!0,writable:!1,configurable:!0}),yw=globalThis.Intl.DateTimeFormat,ih=Object.assign,WBe=Object.prototype.hasOwnProperty,HBe=Reflect.apply;function cw(t,e){let r=t[e];return typeof r=="function"&&(r=new yw(t[Ise],r(t[qC])),t[e]=r),r}function F0(t,e={}){if(!(this instanceof F0))return new F0(t,e);let r=e!==void 0,n=r?ih({},e):{},i=new yw(t,n),o=i.resolvedOptions();if(r){let s=ih({},o);for(let a in s)HBe(WBe,n,[a])||delete s[a];this[qC]=s}else this[qC]=n;this[Ise]=o.locale,this[mw]=i,this[dw]=o.timeZone,this[ud]=o.calendar,this[xse]=ZBe,this[Ese]=JBe,this[Sse]=YBe,this[Ase]=VBe,this[Pse]=XBe,this[Tse]=QBe}Object.defineProperty(F0,"name",{writable:!0,value:"DateTimeFormat"}),F0.supportedLocalesOf=function(t,e){return yw.supportedLocalesOf(t,e)};var TC={resolvedOptions:Rx(function(){return this[mw].resolvedOptions()}),format:Rx(function(e,...r){let{instant:n,formatter:i}=gw(e,this);return n&&i?i.format(n.epochMilliseconds):this[mw].format(e,...r)}),formatRange:Rx(function(e,r){if(Pw(e)||Pw(r)){if(!kse(e,r))throw new TypeError("Intl.DateTimeFormat.formatRange accepts two values of the same type");let{instant:n,formatter:i}=gw(e,this),{instant:o,formatter:s}=gw(r,this);if(n&&o&&i&&s&&i===s)return i.formatRange(n.epochMilliseconds,o.epochMilliseconds)}return this[mw].formatRange(e,r)})};"formatToParts"in yw.prototype&&(TC.formatToParts=Rx(function(e,...r){let{instant:n,formatter:i}=gw(e,this);return n&&i?i.formatToParts(n.epochMilliseconds):this[mw].formatToParts(e,...r)})),"formatRangeToParts"in yw.prototype&&(TC.formatRangeToParts=Rx(function(e,r){if(Pw(e)||Pw(r)){if(!kse(e,r))throw new TypeError("Intl.DateTimeFormat.formatRangeToParts accepts two values of the same type");let{instant:n,formatter:i}=gw(e,this),{instant:o,formatter:s}=gw(r,this);if(n&&o&&i&&s&&i===s)return i.formatRangeToParts(n.epochMilliseconds,o.epochMilliseconds)}return this[mw].formatRangeToParts(e,r)})),F0.prototype=Object.create(yw.prototype,TC),Object.defineProperty(F0,"prototype",{writable:!1,enumerable:!1,configurable:!1});var oh=F0;function tE(t={},e={}){let r=ih({},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 VBe(t){let e=tE(t,{year:!1,month:!1,day:!1,weekday:!1,timeZoneName:!1,dateStyle:!1});return kO(e)||(e=ih({},e,{hour:"numeric",minute:"numeric",second:"numeric"})),e}function JBe(t){let e=tE(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=ih(e,{year:"numeric",month:"numeric"})),e}function YBe(t){let e=tE(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=ih({},e,{month:"numeric",day:"numeric"})),e}function ZBe(t){let e=tE(t,{hour:!1,minute:!1,second:!1,dayPeriod:!1,timeZoneName:!1,timeStyle:!1});return IO(e)||(e=ih({},e,{year:"numeric",month:"numeric",day:"numeric"})),e}function XBe(t){let e=tE(t,{timeZoneName:!1});return kO(e)||IO(e)||(e=ih({},e,{year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"})),e}function QBe(t){let e=t;return kO(e)||IO(e)||(e=ih({},e,{year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"})),e}function IO(t){return"year"in t||"month"in t||"day"in t||"weekday"in t||"dateStyle"in t}function kO(t){return"hour"in t||"minute"in t||"second"in t||"timeStyle"in t||"dayPeriod"in t}function Pw(t){return Gt(t)||In(t)||bt(t)||qe(t)||_r(t)||Ei(t)||li(t)}function kse(t,e){return!(!Pw(t)||!Pw(e))&&!(In(t)&&!In(e))&&!(Gt(t)&&!Gt(e))&&!(bt(t)&&!bt(e))&&!(qe(t)&&!qe(e))&&!(_r(t)&&!_r(e))&&!(Ei(t)&&!Ei(e))&&!(li(t)&&!li(e))}function gw(t,e){let r=xe("%Temporal.PlainDateTime%");if(In(t)){let n=new r(1970,1,1,R(t,vt),R(t,wt),R(t,_t),R(t,xt),R(t,Et),R(t,St),e[ud]);return{instant:Xo(e[dw],n,"compatible"),formatter:cw(e,Ase)}}if(_r(t)){let n=R(t,Te),i=R(t,Re),o=R(t,Oe),s=Qi(R(t,se));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:Xo(e[dw],a,"compatible"),formatter:cw(e,Ese)}}if(Ei(t)){let n=R(t,Te),i=R(t,Re),o=R(t,Oe),s=Qi(R(t,se));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:Xo(e[dw],a,"compatible"),formatter:cw(e,Sse)}}if(Gt(t)){let n=R(t,Te),i=R(t,Re),o=R(t,Oe),s=Qi(R(t,se));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:Xo(e[dw],a,"compatible"),formatter:cw(e,xse)}}if(bt(t)){let n=R(t,Te),i=R(t,Re),o=R(t,Oe),s=R(t,vt),a=R(t,wt),d=R(t,_t),u=R(t,xt),c=R(t,Et),l=R(t,St),m=Qi(R(t,se));if(m!=="iso8601"&&m!==e[ud])throw new RangeError(`cannot format PlainDateTime with calendar ${m} in locale with calendar ${e[ud]}`);let p=t;return m==="iso8601"&&(p=new r(n,i,o,s,a,d,u,c,l,e[ud])),{instant:Xo(e[dw],p,"compatible"),formatter:cw(e,Pse)}}if(qe(t))throw new TypeError("Temporal.ZonedDateTime not supported in DateTimeFormat methods. Use toLocaleString() instead.");return li(t)?{instant:t,formatter:cw(e,Tse)}:{}}var ogt=Object.freeze({__proto__:null,DateTimeFormat:oh}),Ox=class t{constructor(e){if(arguments.length<1)throw new TypeError("missing argument: epochNanoseconds is required");let r=kx(e);B0(r),Rl(this),kt(this,ct,r)}get epochSeconds(){if(!li(this))throw new TypeError("invalid receiver");let e=R(this,ct);return z.default.toNumber(pw(e,Sl))}get epochMilliseconds(){if(!li(this))throw new TypeError("invalid receiver");let e=z.default.BigInt(R(this,ct));return z.default.toNumber(pw(e,pc))}get epochMicroseconds(){if(!li(this))throw new TypeError("invalid receiver");return H4(pw(z.default.BigInt(R(this,ct)),xr))}get epochNanoseconds(){if(!li(this))throw new TypeError("invalid receiver");return H4(z.default.BigInt(R(this,ct)))}add(e){if(!li(this))throw new TypeError("invalid receiver");return Eoe("add",this,e)}subtract(e){if(!li(this))throw new TypeError("invalid receiver");return Eoe("subtract",this,e)}until(e,r){if(!li(this))throw new TypeError("invalid receiver");return yoe("until",this,e,r)}since(e,r){if(!li(this))throw new TypeError("invalid receiver");return yoe("since",this,e,r)}round(e){if(!li(this))throw new TypeError("invalid receiver");if(e===void 0)throw new TypeError("options parameter is required");let r=typeof e=="string"?Aw("smallestUnit",e):Zt(e),n=kw(r),i=hu(r,"halfExpand"),o=ra(r,"smallestUnit","time",U0);Rw(n,{hour:24,minute:1440,second:86400,millisecond:864e5,microsecond:864e8,nanosecond:864e11}[o],!0);let s=W4(R(this,ct),n,o,i);return new t(s)}equals(e){if(!li(this))throw new TypeError("invalid receiver");let r=fu(e),n=R(this,ct),i=R(r,ct);return z.default.equal(z.default.BigInt(n),z.default.BigInt(i))}toString(e){if(!li(this))throw new TypeError("invalid receiver");let r=Zt(e),n=Vx(r),i=hu(r,"trunc"),o=ra(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=Eo(s));let{precision:a,unit:d,increment:u}=Jx(o,n),c=W4(R(this,ct),u,d,i);return aoe(new t(c),s,a)}toJSON(){if(!li(this))throw new TypeError("invalid receiver");return aoe(this,void 0,"auto")}toLocaleString(e,r){if(!li(this))throw new TypeError("invalid receiver");return new oh(e,r).format(this)}valueOf(){throw new TypeError("use compare() or equals() to compare Temporal.Instant")}toZonedDateTime(e){if(!li(this))throw new TypeError("invalid receiver");if(!sn(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=na(r),i=e.timeZone;if(i===void 0)throw new TypeError("missing timeZone property in toZonedDateTime");let o=Eo(i);return Yi(R(this,ct),o,n)}toZonedDateTimeISO(e){if(!li(this))throw new TypeError("invalid receiver");let r=Eo(e);return Yi(R(this,ct),r,"iso8601")}static fromEpochSeconds(e){let r=ww(e),n=z.default.multiply(z.default.BigInt(r),Sl);return B0(n),new t(n)}static fromEpochMilliseconds(e){let r=ww(e),n=z.default.multiply(z.default.BigInt(r),pc);return B0(n),new t(n)}static fromEpochMicroseconds(e){let r=kx(e),n=z.default.multiply(r,xr);return B0(n),new t(n)}static fromEpochNanoseconds(e){let r=kx(e);return B0(r),new t(r)}static from(e){return li(e)?new t(R(e,ct)):fu(e)}static compare(e,r){let n=fu(e),i=fu(r),o=R(n,ct),s=R(i,ct);return z.default.lessThan(o,s)?-1:z.default.greaterThan(o,s)?1:0}};kl(Ox,"Temporal.Instant");var Rse=Array.prototype.includes,eCe=Array.prototype.push,tCe=globalThis.Intl.DateTimeFormat,rCe=Array.prototype.sort,nCe=Math.abs,iCe=Math.floor,IC=Object.create,LC=Object.entries,Dse=Set,Ioe=Reflect.ownKeys,wo=Set.prototype.add,Mse=Set.prototype.values,hn={},fn=class{constructor(e){if(arguments.length<1)throw new RangeError("missing argument: id is required");let r=Qo(e);if(!nh(r))throw new RangeError(`invalid calendar identifier ${r}`);Rl(this),kt(this,wn,Il(r))}get id(){if(!Pn(this))throw new TypeError("invalid receiver");return R(this,wn)}dateFromFields(e,r){if(!Pn(this))throw new TypeError("invalid receiver");if(!sn(e))throw new TypeError("invalid fields");let n=Zt(r),i=R(this,wn);return hn[i].dateFromFields(e,n,i)}yearMonthFromFields(e,r){if(!Pn(this))throw new TypeError("invalid receiver");if(!sn(e))throw new TypeError("invalid fields");let n=Zt(r),i=R(this,wn);return hn[i].yearMonthFromFields(e,n,i)}monthDayFromFields(e,r){if(!Pn(this))throw new TypeError("invalid receiver");if(!sn(e))throw new TypeError("invalid fields");let n=Zt(r),i=R(this,wn);return hn[i].monthDayFromFields(e,n,i)}fields(e){if(!Pn(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),eCe.call(r,i)}return hn[R(this,wn)].fields(r)}mergeFields(e,r){if(!Pn(this))throw new TypeError("invalid receiver");let n=ooe(e),i=IC(null);fw(i,n,[],[void 0]);let o=ooe(r),s=IC(null);fw(s,o,[],[void 0]);let a=Ioe(s),d=hn[R(this,wn)].fieldKeysToIgnore(a),u=IC(null),c=Ioe(i);for(let l of c){let m;m=Ve(Rse,d,[l])?s[l]:i[l],m!==void 0&&(u[l]=m)}return fw(u,s,[]),u}dateAdd(e,r,n){if(!Pn(this))throw new TypeError("invalid receiver");let i=Ur(e),o=hw(r),s=Fn(Zt(n)),{days:a}=ld(R(o,zo),R(o,Go),R(o,Wo),R(o,Ho),R(o,Vo),R(o,Jo),R(o,Yo),"day"),d=R(this,wn);return hn[d].dateAdd(i,R(o,Fo),R(o,ji),R(o,Bs),a,s,d)}dateUntil(e,r,n){if(!Pn(this))throw new TypeError("invalid receiver");let i=Ur(e),o=Ur(r),s=ra(Zt(n),"largestUnit","date","auto");s==="auto"&&(s="day");let{years:a,months:d,weeks:u,days:c}=hn[R(this,wn)].dateUntil(i,o,s);return new(xe("%Temporal.Duration%"))(a,d,u,c,0,0,0,0,0,0)}year(e){let r=e;if(!Pn(this))throw new TypeError("invalid receiver");return _r(r)||(r=Ur(r)),hn[R(this,wn)].year(r)}month(e){let r=e;if(!Pn(this))throw new TypeError("invalid receiver");if(Ei(r))throw new TypeError("use monthCode on PlainMonthDay instead");return _r(r)||(r=Ur(r)),hn[R(this,wn)].month(r)}monthCode(e){let r=e;if(!Pn(this))throw new TypeError("invalid receiver");return _r(r)||Ei(r)||(r=Ur(r)),hn[R(this,wn)].monthCode(r)}day(e){let r=e;if(!Pn(this))throw new TypeError("invalid receiver");return Ei(r)||(r=Ur(r)),hn[R(this,wn)].day(r)}era(e){let r=e;if(!Pn(this))throw new TypeError("invalid receiver");return _r(r)||(r=Ur(r)),hn[R(this,wn)].era(r)}eraYear(e){let r=e;if(!Pn(this))throw new TypeError("invalid receiver");return _r(r)||(r=Ur(r)),hn[R(this,wn)].eraYear(r)}dayOfWeek(e){if(!Pn(this))throw new TypeError("invalid receiver");let r=Ur(e);return hn[R(this,wn)].dayOfWeek(r)}dayOfYear(e){if(!Pn(this))throw new TypeError("invalid receiver");let r=Ur(e);return hn[R(this,wn)].dayOfYear(r)}weekOfYear(e){if(!Pn(this))throw new TypeError("invalid receiver");let r=Ur(e);return hn[R(this,wn)].weekOfYear(r)}yearOfWeek(e){if(!Pn(this))throw new TypeError("invalid receiver");let r=Ur(e);return hn[R(this,wn)].yearOfWeek(r)}daysInWeek(e){if(!Pn(this))throw new TypeError("invalid receiver");let r=Ur(e);return hn[R(this,wn)].daysInWeek(r)}daysInMonth(e){let r=e;if(!Pn(this))throw new TypeError("invalid receiver");return _r(r)||(r=Ur(r)),hn[R(this,wn)].daysInMonth(r)}daysInYear(e){let r=e;if(!Pn(this))throw new TypeError("invalid receiver");return _r(r)||(r=Ur(r)),hn[R(this,wn)].daysInYear(r)}monthsInYear(e){let r=e;if(!Pn(this))throw new TypeError("invalid receiver");return _r(r)||(r=Ur(r)),hn[R(this,wn)].monthsInYear(r)}inLeapYear(e){let r=e;if(!Pn(this))throw new TypeError("invalid receiver");return _r(r)||(r=Ur(r)),hn[R(this,wn)].inLeapYear(r)}toString(){if(!Pn(this))throw new TypeError("invalid receiver");return R(this,wn)}toJSON(){if(!Pn(this))throw new TypeError("invalid receiver");return R(this,wn)}static from(e){return Dw(na(e))}};function RO(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 eh(t,e=!1){return`M${t.toString().padStart(2,"0")}${e?"L":""}`}function B4(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"&&Xi(n,1,r),e==="constrain"&&(n=ea(n,1,r)),i=eh(n)}else{let o=RO(i);if(n!==void 0&&n!==o)throw new RangeError(`monthCode ${i} and month ${n} must match if both are present`);if(i!==eh(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}}kl(fn,"Temporal.Calendar"),_n("Temporal.Calendar.from",fn.from),_n("Temporal.Calendar.prototype.dateAdd",fn.prototype.dateAdd),_n("Temporal.Calendar.prototype.dateFromFields",fn.prototype.dateFromFields),_n("Temporal.Calendar.prototype.dateUntil",fn.prototype.dateUntil),_n("Temporal.Calendar.prototype.day",fn.prototype.day),_n("Temporal.Calendar.prototype.dayOfWeek",fn.prototype.dayOfWeek),_n("Temporal.Calendar.prototype.dayOfYear",fn.prototype.dayOfYear),_n("Temporal.Calendar.prototype.daysInMonth",fn.prototype.daysInMonth),_n("Temporal.Calendar.prototype.daysInWeek",fn.prototype.daysInWeek),_n("Temporal.Calendar.prototype.daysInYear",fn.prototype.daysInYear),_n("Temporal.Calendar.prototype.era",fn.prototype.era),_n("Temporal.Calendar.prototype.eraYear",fn.prototype.eraYear),_n("Temporal.Calendar.prototype.fields",fn.prototype.fields),_n("Temporal.Calendar.prototype.inLeapYear",fn.prototype.inLeapYear),_n("Temporal.Calendar.prototype.mergeFields",fn.prototype.mergeFields),_n("Temporal.Calendar.prototype.month",fn.prototype.month),_n("Temporal.Calendar.prototype.monthCode",fn.prototype.monthCode),_n("Temporal.Calendar.prototype.monthDayFromFields",fn.prototype.monthDayFromFields),_n("Temporal.Calendar.prototype.monthsInYear",fn.prototype.monthsInYear),_n("Temporal.Calendar.prototype.weekOfYear",fn.prototype.weekOfYear),_n("Temporal.Calendar.prototype.year",fn.prototype.year),_n("Temporal.Calendar.prototype.yearMonthFromFields",fn.prototype.yearMonthFromFields),_n("Temporal.Calendar.prototype.yearOfWeek",fn.prototype.yearOfWeek),hn.iso8601={dateFromFields(t,e,r){let n=Mt(t,["day","month","monthCode","year"],["year","day"]),i=Fn(e);n=B4(n);let{year:o,month:s,day:a}=n;return{year:o,month:s,day:a}=U4(o,s,a,i),yc(o,s,a,r)},yearMonthFromFields(t,e,r){let n=Mt(t,["month","monthCode","year"],["year"]),i=Fn(e);n=B4(n);let{year:o,month:s}=n;return{year:o,month:s}=function(d,u,c){let l=d,m=u;switch(c){case"reject":Tl(l,m,1);break;case"constrain":({year:l,month:m}=use(l,m))}return{year:l,month:m}}(o,s,i),Bx(o,s,r,1)},monthDayFromFields(t,e,r){let n=Mt(t,["day","month","monthCode","year"],["day"]),i=Fn(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=B4(n);let{month:s,day:a,year:d}=n;return{month:s,day:a}=U4(o?d:1972,s,a,i),Mx(s,a,r,1972)},fields:t=>t,fieldKeysToIgnore(t){let e=new Dse;for(let r=0;rxO(R(t,Te),R(t,Re),R(t,Oe),R(e,Te),R(e,Re),R(e,Oe),r),year:t=>R(t,Te),era(){},eraYear(){},month:t=>R(t,Re),monthCode:t=>eh(R(t,Re)),day:t=>R(t,Oe),dayOfWeek:t=>jC(R(t,Te),R(t,Re),R(t,Oe)),dayOfYear:t=>z4(R(t,Te),R(t,Re),R(t,Oe)),weekOfYear:t=>poe(R(t,Te),R(t,Re),R(t,Oe)).week,yearOfWeek:t=>poe(R(t,Te),R(t,Re),R(t,Oe)).year,daysInWeek:()=>7,daysInMonth:t=>Qf(R(t,Te),R(t,Re)),daysInYear(t){let e=t;return Ai(e,Te)||(e=Ur(e)),Zp(R(e,Te))?366:365},monthsInYear:()=>12,inLeapYear(t){let e=t;return Ai(e,Te)||(e=Ur(e)),Zp(R(e,Te))}};var ui=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 Bse({isoYear:t,isoMonth:e,isoDay:r}){return`${W0(t)}-${pn(e)}-${pn(r)}T00:00Z`}function kC(t,e){return{years:t.year-e.year,months:t.month-e.month,days:t.day-e.day}}ui.objectMap=new WeakMap,ui.MAX_CACHE_ENTRIES=1e3;var Qp=class{constructor(){this.eraLength="short",this.hasEra=!0,this.erasBeginMidYear=!1}getFormatter(){return this.formatter===void 0&&(this.formatter=new tCe(`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=Bse({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:p,value:g}of u){if(p==="year"&&(l.eraYear=+g),p==="relatedYear"&&(l.eraYear=+g),p==="month"){let b=/^([0-9]*)(.*?)$/.exec(g);if(!b||b.length!=3||!b[1]&&!b[2])throw new RangeError(`Unexpected month: ${g}`);if(l.month=b[1]?+b[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)`);b[2]&&(l.monthExtra=b[2])}p==="day"&&(l.day=+g),this.hasEra&&p==="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:p,eraYear:g}=this.reviseIntlEra(l,e);l.era=p,l.eraYear=g}this.checkIcuBugs&&this.checkIcuBugs(e);let m=this.adjustCalendarDate(l,r,"constrain",!0);if(m.year===void 0)throw new RangeError(`Missing year converting ${JSON.stringify(e)}`);if(m.month===void 0)throw new RangeError(`Missing month converting ${JSON.stringify(e)}`);if(m.day===void 0)throw new RangeError(`Missing day converting ${JSON.stringify(e)}`);return r.set(s,m),["constrain","reject"].forEach(p=>{let g=JSON.stringify({func:"calendarToIsoDate",year:m.year,month:m.month,day:m.day,overflow:p,id:this.id});r.set(g,e)}),m}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}=B4(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"?(Xi(o,1,i),Xi(s,1,this.maximumMonthLength(e))):(o=ea(o,1,i),s=ea(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 m=this.estimateIsoDate({year:s,month:a,day:d}),p=I=>{let P=this.addDaysIso(m,I);if(o.day>this.minimumMonthLength(o)){let $=this.isoToCalendarDate(P,n);for(;$.month!==a||$.year!==s;){if(r==="reject")throw new RangeError(`day ${d} does not exist in month ${a} of year ${s}`);P=this.addDaysIso(P,-1),$=this.isoToCalendarDate(P,n)}}return P},g=0,b=this.isoToCalendarDate(m,n),S=kC(o,b);if(S.years!==0||S.months!==0||S.days!==0){let I=365*S.years+30*S.months+S.days;m=this.addDaysIso(m,I),b=this.isoToCalendarDate(m,n),S=kC(o,b),S.years===0&&S.months===0?m=p(S.days):g=this.compareCalendarDates(o,b)}let A=8;for(;g;){m=this.addDaysIso(m,g*A);let I=b;b=this.isoToCalendarDate(m,n);let P=g;if(g=this.compareCalendarDates(o,b),g){if(S=kC(o,b),S.years===0&&S.months===0)m=p(S.days),g=0;else if(P&&g!==P)if(A>1)A/=2;else{if(r==="reject")throw new RangeError(`Can't find ISO date from calendar date: ${JSON.stringify({...i})}`);this.compareCalendarDates(b,I)>0&&(m=this.addDaysIso(m,-1)),g=0}}}if(n.set(u,m),c&&n.set(c,m),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 m}temporalToCalendarDate(e,r){let n={year:R(e,Te),month:R(e,Re),day:R(e,Oe)};return this.isoToCalendarDate(n,r)}compareCalendarDates(e,r){let n=Mt(e,["day","month","year"],["day","month","year"]),i=Mt(r,["day","month","year"],["day","month","year"]);return n.year!==i.year?N0(n.year-i.year):n.month!==i.month?N0(n.month-i.month):n.day!==i.day?N0(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 $0(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=nCe(r);a0){let g=this.monthsInYear(c,i);for(;o.month-1!=u%g;)p=this.addDaysIso(p,-1),o=this.isoToCalendarDate(p,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),m=this.addMonthsCalendar(l,n,s,a),p=o+7*i;return this.addDaysCalendar(m,p,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(m,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 xO(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:p,era:g,eraYear:b}=e;if(p===void 0&&(g===void 0||b===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),m=l.monthCode>u||l.monthCode===u&&l.day>=c?l.year:l.year-1;for(let p=0;p<100;p++){let g=this.adjustCalendarDate({day:c,monthCode:u,year:m-p},n),b=this.calendarToIsoDate(g,"constrain",n),S=this.isoToCalendarDate(b,n);if({year:i,month:o,day:s}=b,S.monthCode===u&&S.day===c)return{month:o,day:s,year:i};r==="constrain"&&(a===void 0||S.monthCode===a.monthCode&&S.day>a.day)&&(a=S,d=b)}if(r==="constrain"&&d!==void 0)return d;throw new RangeError(`No recent ${this.id} year with monthCode ${u} and day ${c}`)}},FC=class extends Qp{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=LC(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?eh(5,!0):eh(r<6?r:r-1):eh(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=RO(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"?(Xi(a,1,this.monthsInYear({year:o})),Xi(u,1,this.maximumMonthLength({year:o,month:a}))):(a=ea(a,1,this.monthsInYear({year:o})),u=ea(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}}},em=class extends Qp{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:iCe(r*this.DAYS_PER_ISLAMIC_YEAR/this.DAYS_PER_ISO_YEAR)+622,month:1,day:1}}},V4=class extends em{constructor(){super(...arguments),this.id="islamic"}},zC=class extends em{constructor(){super(...arguments),this.id="islamic-umalqura"}},GC=class extends em{constructor(){super(...arguments),this.id="islamic-tbla"}},WC=class extends em{constructor(){super(...arguments),this.id="islamic-civil"}},HC=class extends em{constructor(){super(...arguments),this.id="islamic-rgsa"}},VC=class extends em{constructor(){super(...arguments),this.id="islamicc"}},JC=class extends Qp{constructor(){super(...arguments),this.id="persian",this.calendarType="solar",this.constantEra="ap"}inLeapYear(e,r){return V4.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}}},YC=class extends Qp{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 Cse(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 $0(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 Cse(t){return t%4==0&&(t%100!=0||t%400==0)}var z0=class extends Qp{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 m=d.find(p=>p.name===l);if(m===void 0)throw new RangeError(`Invalid era data: unmatched reverseOf era: ${l}`);c.reverseOf=m,c.anchorEpoch=m.anchorEpoch,c.isoEpoch=m.isoEpoch}c.anchorEpoch.month===void 0&&(c.anchorEpoch.month=1),c.anchorEpoch.day===void 0&&(c.anchorEpoch.day=1)}),rCe.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 Cse(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,m)=>{if(m===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:RO(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 U4(n+s.isoEpoch.year-(s.hasYearZero?0:1),i,o,"constrain")}checkIcuBugs(e){if(this.calendarIsVulnerableToJulianBug&&this.v8IsVulnerableToJulianBug&&Hp(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)`)}},$x=class extends z0{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)}},ZC=class extends $x{constructor(){super("ethioaa",[{name:"era0",isoEpoch:{year:-5492,month:7,day:17}}])}},XC=class extends $x{constructor(){super("coptic",[{name:"era1",isoEpoch:{year:284,month:8,day:29}},{name:"era0",reverseOf:"era1"}])}},QC=class extends $x{constructor(){super("ethiopic",[{name:"era0",isoEpoch:{year:-5492,month:7,day:17}},{name:"era1",isoEpoch:{year:8,month:8,day:27},anchorEpoch:{year:5501}}])}},eO=class extends z0{constructor(){super("roc",[{name:"minguo",isoEpoch:{year:1912,month:1,day:1}},{name:"before-roc",reverseOf:"minguo"}]),this.calendarIsVulnerableToJulianBug=!0}},tO=class extends z0{constructor(){super("buddhist",[{name:"be",hasYearZero:!0,isoEpoch:{year:-543,month:1,day:1}}]),this.calendarIsVulnerableToJulianBug=!0}},rO=class extends z0{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}}},nO=class extends z0{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}}},J4=class extends Qp{constructor(){super(...arguments),this.calendarType="lunisolar",this.hasEra=!1}inLeapYear(e,r){let n=this.getMonthList(e.year,r);return LC(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=(S,A)=>{let I=Bse({isoYear:S,isoMonth:2,isoDay:1}),P=new Date(I);P.setUTCDate(A+1);let $=o.formatToParts(P),N=$.find(U=>U.type==="month").value,L=+$.find(U=>U.type==="day").value,F=$.find(U=>U.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:N,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={},m,p,g=1,b=!1;do({calendarMonthString:d,calendarDay:u,calendarYearToVerify:c}=s(e,a)),m&&(l[p].daysInMonth=m+30-u),c!==e?b=!0:(l[d]={monthIndex:g++},a+=30),m=u,p=d;while(!b);return l[p].daysInMonth=m+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=eh(s,a!==void 0),m=`${s}${a||""}`,p=this.getMonthList(o,r)[m];if(p===void 0)throw new RangeError(`Unmatched month ${m} in Chinese year ${o}`);return s=p.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),m=u.replace("L","bis").slice(1);m[0]==="0"&&(m=m.slice(1));let p=l[m];if(s=p&&p.monthIndex,s===void 0&&u.endsWith("L")&&u!="M13L"&&n==="constrain"){let g=u.slice(1,-1);g[0]==="0"&&(g=g.slice(1)),p=l[g],p&&(s=p.monthIndex,u=eh(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),m=LC(l),p=m.length;n==="reject"?(Xi(s,1,p),Xi(d,1,this.maximumMonthLength())):(s=ea(s,1,p),d=ea(d,1,this.maximumMonthLength()));let g=m.find(([,b])=>b.monthIndex===s);if(g===void 0)throw new RangeError(`Invalid month ${s} in Chinese year ${o}`);u=eh(g[0].replace("bis",""),g[0].indexOf("bis")!==-1)}else{let l=this.getMonthList(o,r),m=u.replace("L","bis").slice(1);m[0]==="0"&&(m=m.slice(1));let p=l[m];if(!p)throw new RangeError(`Unmatched monthCode ${u} in Chinese year ${o}`);if(s!==p.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}}},iO=class extends J4{constructor(){super(...arguments),this.id="chinese"}},oO=class extends J4{constructor(){super(...arguments),this.id="dangi"}},sO=class{constructor(e){this.helper=e}dateFromFields(e,r,n){let i=new ui,o=Mt(e,this.fields(["day","month","monthCode","year"]),[]),s=Fn(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 ui,o=Mt(e,this.fields(["month","monthCode","year"]),[]),s=Fn(r),{year:a,month:d,day:u}=this.helper.calendarToIsoDate({...o,day:1},s,i),c=Bx(a,d,n,u);return i.setObject(c),c}monthDayFromFields(e,r,n){let i=new ui,o=Mt(e,this.fields(["day","month","monthCode","year"]),[]),s=Fn(r),{year:a,month:d,day:u}=this.helper.monthDayFromFields(o,s,i),c=Mx(d,u,n,a);return i.setObject(c),c}fields(e){let r=e;return Rse.call(r,"year")&&(r=[...r,"era","eraYear"]),r}fieldKeysToIgnore(e){let r=new Dse;for(let n=0;nnew(xe("%Temporal.Instant%"))(TO()),koe=(t,e=Wp())=>{let r=Eo(e),n=na(t);return ka(r,DO(),n)},RC=(t=Wp())=>ka(Eo(t),DO(),"iso8601"),Roe=(t,e=Wp())=>{let r=Eo(e),n=na(t);return Yi(TO(),r,n)},Ose={instant:DO,plainDateTime:koe,plainDateTimeISO:RC,plainDate:(t,e=Wp())=>Ew(koe(t,e)),plainDateISO:(t=Wp())=>Ew(RC(t)),plainTimeISO:(t=Wp())=>gO(RC(t)),timeZoneId:()=>Wp(),zonedDateTime:Roe,zonedDateTimeISO:(t=Wp())=>Roe("iso8601",t),[Symbol.toStringTag]:"Temporal.Now"};Object.defineProperty(Ose,Symbol.toStringTag,{value:"Temporal.Now",writable:!1,enumerable:!1,configurable:!0});var sCe=Object.assign;function Doe(t,e,r){let n=R(t,vt),i=R(t,wt),o=R(t,_t),s=R(t,xt),a=R(t,Et),d=R(t,St);if(r){let{unit:u,increment:c,roundingMode:l}=r;({hour:n,minute:i,second:o,millisecond:s,microsecond:a,nanosecond:d}=PO(n,i,o,s,a,d,c,u,l))}return`${pn(n)}:${pn(i)}${cA(o,s,a,d,e)}`}var qx=class t{constructor(e=0,r=0,n=0,i=0,o=0,s=0){let a=e===void 0?0:mr(e),d=r===void 0?0:mr(r),u=n===void 0?0:mr(n),c=i===void 0?0:mr(i),l=o===void 0?0:mr(o),m=s===void 0?0:mr(s);lA(a,d,u,c,l,m),Rl(this),kt(this,vt,a),kt(this,wt,d),kt(this,_t,u),kt(this,xt,c),kt(this,Et,l),kt(this,St,m)}get hour(){if(!In(this))throw new TypeError("invalid receiver");return R(this,vt)}get minute(){if(!In(this))throw new TypeError("invalid receiver");return R(this,wt)}get second(){if(!In(this))throw new TypeError("invalid receiver");return R(this,_t)}get millisecond(){if(!In(this))throw new TypeError("invalid receiver");return R(this,xt)}get microsecond(){if(!In(this))throw new TypeError("invalid receiver");return R(this,Et)}get nanosecond(){if(!In(this))throw new TypeError("invalid receiver");return R(this,St)}with(e,r){if(!In(this))throw new TypeError("invalid receiver");if(!sn(e))throw new TypeError("invalid argument");Iw(e);let n=Fn(Zt(r)),i=q4(e,"partial"),o=q4(this),{hour:s,minute:a,second:d,millisecond:u,microsecond:c,nanosecond:l}=sCe(o,i);return{hour:s,minute:a,second:d,millisecond:u,microsecond:c,nanosecond:l}=X4(s,a,d,u,c,l,n),new t(s,a,d,u,c,l)}add(e){if(!In(this))throw new TypeError("invalid receiver");return Aoe("add",this,e)}subtract(e){if(!In(this))throw new TypeError("invalid receiver");return Aoe("subtract",this,e)}until(e,r){if(!In(this))throw new TypeError("invalid receiver");return voe("until",this,e,r)}since(e,r){if(!In(this))throw new TypeError("invalid receiver");return voe("since",this,e,r)}round(e){if(!In(this))throw new TypeError("invalid receiver");if(e===void 0)throw new TypeError("options parameter is required");let r=typeof e=="string"?Aw("smallestUnit",e):Zt(e),n=kw(r),i=hu(r,"halfExpand"),o=ra(r,"smallestUnit","time",U0);Rw(n,{hour:24,minute:60,second:60,millisecond:1e3,microsecond:1e3,nanosecond:1e3}[o],!1);let s=R(this,vt),a=R(this,wt),d=R(this,_t),u=R(this,xt),c=R(this,Et),l=R(this,St);return{hour:s,minute:a,second:d,millisecond:u,microsecond:c,nanosecond:l}=PO(s,a,d,u,c,l,n,o,i),new t(s,a,d,u,c,l)}equals(e){if(!In(this))throw new TypeError("invalid receiver");let r=Zf(e);for(let n of[vt,wt,_t,xt,Et,St])if(R(this,n)!==R(r,n))return!1;return!0}toString(e){if(!In(this))throw new TypeError("invalid receiver");let r=Zt(e),n=Vx(r),i=hu(r,"trunc"),o=ra(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}=Jx(o,n);return Doe(this,s,{unit:a,increment:d,roundingMode:i})}toJSON(){if(!In(this))throw new TypeError("invalid receiver");return Doe(this,"auto")}toLocaleString(e,r){if(!In(this))throw new TypeError("invalid receiver");return new oh(e,r).format(this)}valueOf(){throw new TypeError("use compare() or equals() to compare Temporal.PlainTime")}toPlainDateTime(e){if(!In(this))throw new TypeError("invalid receiver");let r=Ur(e),n=R(r,Te),i=R(r,Re),o=R(r,Oe),s=R(r,se);return Qs(n,i,o,R(this,vt),R(this,wt),R(this,_t),R(this,xt),R(this,Et),R(this,St),s)}toZonedDateTime(e){if(!In(this))throw new TypeError("invalid receiver");if(!sn(e))throw new TypeError("invalid argument");let r=e.plainDate;if(r===void 0)throw new TypeError("missing date property");let n=Ur(r),i=e.timeZone;if(i===void 0)throw new TypeError("missing timeZone property");let o=Eo(i),s=R(n,Te),a=R(n,Re),d=R(n,Oe),u=R(n,se),c=R(this,vt),l=R(this,wt),m=R(this,_t),p=R(this,xt),g=R(this,Et),b=R(this,St);return Yi(R(Xo(o,new(xe("%Temporal.PlainDateTime%"))(s,a,d,c,l,m,p,g,b,u),"compatible"),ct),o,u)}getISOFields(){if(!In(this))throw new TypeError("invalid receiver");return{isoHour:R(this,vt),isoMicrosecond:R(this,Et),isoMillisecond:R(this,xt),isoMinute:R(this,wt),isoNanosecond:R(this,St),isoSecond:R(this,_t)}}static from(e,r){let n=Fn(Zt(r));return In(e)?new t(R(e,vt),R(e,wt),R(e,_t),R(e,xt),R(e,Et),R(e,St)):Zf(e,n)}static compare(e,r){let n=Zf(e),i=Zf(r);for(let o of[vt,wt,_t,xt,Et,St]){let s=R(n,o),a=R(i,o);if(s!==a)return N0(s-a)}return 0}};kl(qx,"Temporal.PlainTime");var j0=class{constructor(e){if(arguments.length<1)throw new RangeError("missing argument: identifier is required");let r=bO(e);Rl(this),kt(this,xl,r)}get id(){if(!fc(this))throw new TypeError("invalid receiver");return R(this,xl)}getOffsetNanosecondsFor(e){if(!fc(this))throw new TypeError("invalid receiver");let r=fu(e),n=R(this,xl);return uw(n)?Jp(n):Xf(n,R(r,ct))}getOffsetStringFor(e){if(!fc(this))throw new TypeError("invalid receiver");return $C(this,fu(e))}getPlainDateTimeFor(e,r="iso8601"){if(!fc(this))throw new TypeError("invalid receiver");return ka(this,fu(e),na(r))}getInstantFor(e,r){if(!fc(this))throw new TypeError("invalid receiver");return Xo(this,O0(e),_w(Zt(r)))}getPossibleInstantsFor(e){if(!fc(this))throw new TypeError("invalid receiver");let r=O0(e),n=xe("%Temporal.Instant%"),i=R(this,xl);if(uw(i)){let s=Yp(R(r,Te),R(r,Re),R(r,Oe),R(r,vt),R(r,wt),R(r,_t),R(r,xt),R(r,Et),R(r,St));if(s===null)throw new RangeError("DateTime outside of supported range");let a=Jp(i);return[new n(z.default.subtract(s,z.default.BigInt(a)))]}return function(a,d,u,c,l,m,p,g,b,S){let A=Yp(d,u,c,l,m,p,g,b,S);if(A===null)throw new RangeError("DateTime outside of supported range");let I=z.default.subtract(A,Pl);z.default.lessThan(I,Dx)&&(I=A);let P=z.default.add(A,Pl);z.default.greaterThan(P,vw)&&(P=A);let $=Xf(a,I),N=Xf(a,P);return($===N?[$]:[$,N]).map(L=>{let F=z.default.subtract(A,z.default.BigInt(L)),U=ose(a,F);if(d===U.year&&u===U.month&&c===U.day&&l===U.hour&&m===U.minute&&p===U.second&&g===U.millisecond&&b===U.microsecond&&S===U.nanosecond)return F}).filter(L=>L!==void 0)}(i,R(r,Te),R(r,Re),R(r,Oe),R(r,vt),R(r,wt),R(r,_t),R(r,xt),R(r,Et),R(r,St)).map(s=>new n(s))}getNextTransition(e){if(!fc(this))throw new TypeError("invalid receiver");let r=fu(e),n=R(this,xl);if(uw(n)||n==="UTC")return null;let i=R(r,ct),o=xe("%Temporal.Instant%");return i=ase(n,i),i===null?null:new o(i)}getPreviousTransition(e){if(!fc(this))throw new TypeError("invalid receiver");let r=fu(e),n=R(this,xl);if(uw(n)||n==="UTC")return null;let i=R(r,ct),o=xe("%Temporal.Instant%");return i=NC(n,i),i===null?null:new o(i)}toString(){if(!fc(this))throw new TypeError("invalid receiver");return R(this,xl)}toJSON(){if(!fc(this))throw new TypeError("invalid receiver");return R(this,xl)}static from(e){return ese(Eo(e))}};kl(j0,"Temporal.TimeZone"),_n("Temporal.TimeZone.prototype.getOffsetNanosecondsFor",j0.prototype.getOffsetNanosecondsFor),_n("Temporal.TimeZone.prototype.getPossibleInstantsFor",j0.prototype.getPossibleInstantsFor);var aCe=Object.create,Lx=class{constructor(e,r,n="iso8601",i=1){Zoe(this,mr(e),mr(r),na(n),mr(i))}get year(){if(!_r(this))throw new TypeError("invalid receiver");return Q4(R(this,se),this)}get month(){if(!_r(this))throw new TypeError("invalid receiver");return eA(R(this,se),this)}get monthCode(){if(!_r(this))throw new TypeError("invalid receiver");return Zx(R(this,se),this)}get calendarId(){if(!_r(this))throw new TypeError("invalid receiver");return Qi(R(this,se))}get era(){if(!_r(this))throw new TypeError("invalid receiver");return tA(R(this,se),this)}get eraYear(){if(!_r(this))throw new TypeError("invalid receiver");return rA(R(this,se),this)}get daysInMonth(){if(!_r(this))throw new TypeError("invalid receiver");return nA(R(this,se),this)}get daysInYear(){if(!_r(this))throw new TypeError("invalid receiver");return iA(R(this,se),this)}get monthsInYear(){if(!_r(this))throw new TypeError("invalid receiver");return oA(R(this,se),this)}get inLeapYear(){if(!_r(this))throw new TypeError("invalid receiver");return sA(R(this,se),this)}with(e,r){if(!_r(this))throw new TypeError("invalid receiver");if(!sn(e))throw new TypeError("invalid argument");Iw(e);let n=Zt(r),i=R(this,se),o=Jn(i,["month","monthCode","year"]),s=Mt(this,o,[]);return s=q0(i,s,Mt(e,o,"partial")),s=Mt(s,o,[]),L0(i,s,n)}add(e,r){if(!_r(this))throw new TypeError("invalid receiver");return Poe("add",this,e,r)}subtract(e,r){if(!_r(this))throw new TypeError("invalid receiver");return Poe("subtract",this,e,r)}until(e,r){if(!_r(this))throw new TypeError("invalid receiver");return woe("until",this,e,r)}since(e,r){if(!_r(this))throw new TypeError("invalid receiver");return woe("since",this,e,r)}equals(e){if(!_r(this))throw new TypeError("invalid receiver");let r=Tx(e);for(let n of[Te,Re,Oe])if(R(this,n)!==R(r,n))return!1;return eE(R(this,se),R(r,se))}toString(e){if(!_r(this))throw new TypeError("invalid receiver");return loe(this,Hx(Zt(e)))}toJSON(){if(!_r(this))throw new TypeError("invalid receiver");return loe(this)}toLocaleString(e,r){if(!_r(this))throw new TypeError("invalid receiver");return new oh(e,r).format(this)}valueOf(){throw new TypeError("use compare() or equals() to compare Temporal.PlainYearMonth")}toPlainDate(e){if(!_r(this))throw new TypeError("invalid receiver");if(!sn(e))throw new TypeError("argument should be an object");let r=R(this,se),n=Jn(r,["monthCode","year"]),i=Mt(this,n,[]),o=Jn(r,["day"]),s=q0(r,i,Mt(e,o,[]));s=Mt(s,[...new Set([...n,...o])],[]);let a=aCe(null);return a.overflow="reject",th(r,s,a)}getISOFields(){if(!_r(this))throw new TypeError("invalid receiver");return{calendar:R(this,se),isoDay:R(this,Oe),isoMonth:R(this,Re),isoYear:R(this,Te)}}getCalendar(){if(!_r(this))throw new TypeError("invalid receiver");return Dw(R(this,se))}static from(e,r){let n=Zt(r);return _r(e)?(Fn(n),Bx(R(e,Te),R(e,Re),R(e,se),R(e,Oe))):Tx(e,n)}static compare(e,r){let n=Tx(e),i=Tx(r);return Hp(R(n,Te),R(n,Re),R(n,Oe),R(i,Te),R(i,Re),R(i,Oe))}};kl(Lx,"Temporal.PlainYearMonth");var cCe=oh.prototype.resolvedOptions,dCe=Object.create,Fx=class{constructor(e,r,n="iso8601"){if(arguments.length<1)throw new TypeError("missing argument: epochNanoseconds is required");Xoe(this,kx(e),Eo(r),na(n))}get calendarId(){if(!qe(this))throw new TypeError("invalid receiver");return Qi(R(this,se))}get timeZoneId(){if(!qe(this))throw new TypeError("invalid receiver");return Cx(R(this,$r))}get year(){if(!qe(this))throw new TypeError("invalid receiver");return Q4(R(this,se),nn(this))}get month(){if(!qe(this))throw new TypeError("invalid receiver");return eA(R(this,se),nn(this))}get monthCode(){if(!qe(this))throw new TypeError("invalid receiver");return Zx(R(this,se),nn(this))}get day(){if(!qe(this))throw new TypeError("invalid receiver");return Xx(R(this,se),nn(this))}get hour(){if(!qe(this))throw new TypeError("invalid receiver");return R(nn(this),vt)}get minute(){if(!qe(this))throw new TypeError("invalid receiver");return R(nn(this),wt)}get second(){if(!qe(this))throw new TypeError("invalid receiver");return R(nn(this),_t)}get millisecond(){if(!qe(this))throw new TypeError("invalid receiver");return R(nn(this),xt)}get microsecond(){if(!qe(this))throw new TypeError("invalid receiver");return R(nn(this),Et)}get nanosecond(){if(!qe(this))throw new TypeError("invalid receiver");return R(nn(this),St)}get era(){if(!qe(this))throw new TypeError("invalid receiver");return tA(R(this,se),nn(this))}get eraYear(){if(!qe(this))throw new TypeError("invalid receiver");return rA(R(this,se),nn(this))}get epochSeconds(){if(!qe(this))throw new TypeError("invalid receiver");let e=R(this,ct);return z.default.toNumber(pw(e,Sl))}get epochMilliseconds(){if(!qe(this))throw new TypeError("invalid receiver");let e=R(this,ct);return z.default.toNumber(pw(e,pc))}get epochMicroseconds(){if(!qe(this))throw new TypeError("invalid receiver");return H4(pw(R(this,ct),xr))}get epochNanoseconds(){if(!qe(this))throw new TypeError("invalid receiver");return H4(R(this,ct))}get dayOfWeek(){if(!qe(this))throw new TypeError("invalid receiver");return fO(R(this,se),nn(this))}get dayOfYear(){if(!qe(this))throw new TypeError("invalid receiver");return hO(R(this,se),nn(this))}get weekOfYear(){if(!qe(this))throw new TypeError("invalid receiver");return pO(R(this,se),nn(this))}get yearOfWeek(){if(!qe(this))throw new TypeError("invalid receiver");return mO(R(this,se),nn(this))}get hoursInDay(){if(!qe(this))throw new TypeError("invalid receiver");let e=nn(this),r=xe("%Temporal.PlainDateTime%"),n=R(e,Te),i=R(e,Re),o=R(e,Oe),s=new r(n,i,o,0,0,0,0,0,0),a=$0(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,$r),c=R(Xo(u,s,"compatible"),ct),l=R(Xo(u,d,"compatible"),ct);return _l(z.default.subtract(l,c),Foe)}get daysInWeek(){if(!qe(this))throw new TypeError("invalid receiver");return yO(R(this,se),nn(this))}get daysInMonth(){if(!qe(this))throw new TypeError("invalid receiver");return nA(R(this,se),nn(this))}get daysInYear(){if(!qe(this))throw new TypeError("invalid receiver");return iA(R(this,se),nn(this))}get monthsInYear(){if(!qe(this))throw new TypeError("invalid receiver");return oA(R(this,se),nn(this))}get inLeapYear(){if(!qe(this))throw new TypeError("invalid receiver");return sA(R(this,se),nn(this))}get offset(){if(!qe(this))throw new TypeError("invalid receiver");return $C(R(this,$r),R(this,xo))}get offsetNanoseconds(){if(!qe(this))throw new TypeError("invalid receiver");return pu(R(this,$r),R(this,xo))}with(e,r){if(!qe(this))throw new TypeError("invalid receiver");if(!sn(e))throw new TypeError("invalid zoned-date-time-like");Iw(e);let n=Zt(r),i=R(this,se),o=Jn(i,["day","hour","microsecond","millisecond","minute","month","monthCode","nanosecond","second","year"]);o.push("offset");let s=Mt(this,o,["offset"]);s=q0(i,s,Mt(e,o,"partial")),s=Mt(s,o,["offset"]);let a=_w(n),d=K4(n,"prefer"),{year:u,month:c,day:l,hour:m,minute:p,second:g,millisecond:b,microsecond:S,nanosecond:A}=Yx(i,s,n),I=Jp(s.offset),P=R(this,$r);return Yi(L4(u,c,l,m,p,g,b,S,A,"option",I,P,a,d,!1),P,i)}withPlainDate(e){if(!qe(this))throw new TypeError("invalid receiver");let r=Ur(e),n=R(r,Te),i=R(r,Re),o=R(r,Oe),s=R(r,se),a=nn(this),d=R(a,vt),u=R(a,wt),c=R(a,_t),l=R(a,xt),m=R(a,Et),p=R(a,St);s=Qoe(R(this,se),s);let g=R(this,$r);return Yi(R(Xo(g,new(xe("%Temporal.PlainDateTime%"))(n,i,o,d,u,c,l,m,p,s),"compatible"),ct),g,s)}withPlainTime(e){if(!qe(this))throw new TypeError("invalid receiver");let r=xe("%Temporal.PlainTime%"),n=e===void 0?new r:Zf(e),i=nn(this),o=R(i,Te),s=R(i,Re),a=R(i,Oe),d=R(this,se),u=R(n,vt),c=R(n,wt),l=R(n,_t),m=R(n,xt),p=R(n,Et),g=R(n,St),b=R(this,$r);return Yi(R(Xo(b,new(xe("%Temporal.PlainDateTime%"))(o,s,a,u,c,l,m,p,g,d),"compatible"),ct),b,d)}withTimeZone(e){if(!qe(this))throw new TypeError("invalid receiver");let r=Eo(e);return Yi(R(this,ct),r,R(this,se))}withCalendar(e){if(!qe(this))throw new TypeError("invalid receiver");let r=na(e);return Yi(R(this,ct),R(this,$r),r)}add(e,r){if(!qe(this))throw new TypeError("invalid receiver");return Toe("add",this,e,r)}subtract(e,r){if(!qe(this))throw new TypeError("invalid receiver");return Toe("subtract",this,e,r)}until(e,r){if(!qe(this))throw new TypeError("invalid receiver");return _oe("until",this,e,r)}since(e,r){if(!qe(this))throw new TypeError("invalid receiver");return _oe("since",this,e,r)}round(e){if(!qe(this))throw new TypeError("invalid receiver");if(e===void 0)throw new TypeError("options parameter is required");let r=typeof e=="string"?Aw("smallestUnit",e):Zt(e),n=kw(r),i=hu(r,"halfExpand"),o=ra(r,"smallestUnit","time",U0,["day"]),s={day:1,hour:24,minute:60,second:60,millisecond:1e3,microsecond:1e3,nanosecond:1e3}[o];Rw(n,s,s===1);let a=nn(this),d=R(a,Te),u=R(a,Re),c=R(a,Oe),l=R(a,vt),m=R(a,wt),p=R(a,_t),g=R(a,xt),b=R(a,Et),S=R(a,St),A=xe("%Temporal.PlainDateTime%"),I=R(this,$r),P=R(this,se),$=Xo(I,new A(R(a,Te),R(a,Re),R(a,Oe),0,0,0,0,0,0),"compatible"),N=mc($,I,P,0,0,0,1,0,0,0,0,0,0),L=z.default.subtract(N,z.default.BigInt(R($,ct)));if(z.default.lessThanOrEqual(L,kn))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:m,second:p,millisecond:g,microsecond:b,nanosecond:S}=AO(d,u,c,l,m,p,g,b,S,n,o,i,z.default.toNumber(L)),Yi(L4(d,u,c,l,m,p,g,b,S,"option",pu(I,R(this,xo)),I,"compatible","prefer",!1),I,R(this,se))}equals(e){if(!qe(this))throw new TypeError("invalid receiver");let r=Ix(e),n=R(this,ct),i=R(r,ct);return!!z.default.equal(z.default.BigInt(n),z.default.BigInt(i))&&!!tse(R(this,$r),R(r,$r))&&eE(R(this,se),R(r,se))}toString(e){if(!qe(this))throw new TypeError("invalid receiver");let r=Zt(e),n=Hx(r),i=Vx(r),o=function(p){return Xp(p,"offset",["auto","never"],"auto")}(r),s=hu(r,"trunc"),a=ra(r,"smallestUnit","time",void 0);if(a==="hour")throw new RangeError('smallestUnit must be a time unit other than "hour"');let d=function(p){return Xp(p,"timeZoneName",["auto","never","critical"],"auto")}(r),{precision:u,unit:c,increment:l}=Jx(a,i);return foe(this,u,n,d,o,{unit:c,increment:l,roundingMode:s})}toLocaleString(e,r){if(!qe(this))throw new TypeError("invalid receiver");let n=Zt(r),i=dCe(null);if(fw(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=Cx(R(this,$r));if(uw(o))throw new RangeError("toLocaleString does not support offset string time zones");o=bO(o),i.timeZone=o;let s=new oh(e,i),a=Ve(cCe,s,[]).calendar,d=Qi(R(this,se));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,xo))}toJSON(){if(!qe(this))throw new TypeError("invalid receiver");return foe(this,"auto")}valueOf(){throw new TypeError("use compare() or equals() to compare Temporal.ZonedDateTime")}startOfDay(){if(!qe(this))throw new TypeError("invalid receiver");let e=nn(this),r=xe("%Temporal.PlainDateTime%"),n=R(this,se),i=new r(R(e,Te),R(e,Re),R(e,Oe),0,0,0,0,0,0,n),o=R(this,$r);return Yi(R(Xo(o,i,"compatible"),ct),o,n)}toInstant(){if(!qe(this))throw new TypeError("invalid receiver");return new(xe("%Temporal.Instant%"))(R(this,ct))}toPlainDate(){if(!qe(this))throw new TypeError("invalid receiver");return Ew(nn(this))}toPlainTime(){if(!qe(this))throw new TypeError("invalid receiver");return gO(nn(this))}toPlainDateTime(){if(!qe(this))throw new TypeError("invalid receiver");return nn(this)}toPlainYearMonth(){if(!qe(this))throw new TypeError("invalid receiver");let e=R(this,se);return L0(e,Mt(this,Jn(e,["monthCode","year"]),[]))}toPlainMonthDay(){if(!qe(this))throw new TypeError("invalid receiver");let e=R(this,se);return xw(e,Mt(this,Jn(e,["day","monthCode"]),[]))}getISOFields(){if(!qe(this))throw new TypeError("invalid receiver");let e=nn(this),r=R(this,$r);return{calendar:R(this,se),isoDay:R(e,Oe),isoHour:R(e,vt),isoMicrosecond:R(e,Et),isoMillisecond:R(e,xt),isoMinute:R(e,wt),isoMonth:R(e,Re),isoNanosecond:R(e,St),isoSecond:R(e,_t),isoYear:R(e,Te),offset:$C(r,R(this,xo)),timeZone:r}}getCalendar(){if(!qe(this))throw new TypeError("invalid receiver");return Dw(R(this,se))}getTimeZone(){if(!qe(this))throw new TypeError("invalid receiver");return ese(R(this,$r))}static from(e,r){let n=Zt(r);return qe(e)?(_w(n),K4(n,"reject"),Fn(n),Yi(R(e,ct),R(e,$r),R(e,se))):Ix(e,n)}static compare(e,r){let n=Ix(e),i=Ix(r),o=R(n,ct),s=R(i,ct);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 nn(t){return ka(R(t,$r),R(t,xo),R(t,se))}kl(Fx,"Temporal.ZonedDateTime");var H0=Object.freeze({__proto__:null,Calendar:fn,Duration:Ux,Instant:Ox,Now:Ose,PlainDate:Nx,PlainDateTime:jx,PlainMonthDay:Kx,PlainTime:qx,PlainYearMonth:Lx,TimeZone:j0,ZonedDateTime:Fx});var uCe=[Ox,fn,Nx,jx,Ux,Kx,qx,j0,Lx,Fx];for(let t of uCe){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 $se=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())})},tr=class t{static sleep(e){return $se(this,void 0,void 0,function*(){return new Promise(r=>setTimeout(r,e))})}static minimalSleep(){return $se(this,void 0,void 0,function*(){yield t.sleep(2)})}static getCurrentTimestamp(){return H0.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 H0.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?H0.Instant.from(r):H0.Now.instant(),i=H0.Duration.from(e);return n.add(i).toString({smallestUnit:"microseconds"})}static validateTimestamp(e){try{H0.Instant.from(e)}catch{throw new oe(ne.TimestampInvalid,`Invalid timestamp: ${e}`)}}};var Pi=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())})},lCe=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 Pi(this,void 0,void 0,function*(){let s=e.recordsWriteMessage,a=yield t.parse(s),d=tr.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:ht.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 Pi(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 Pi(this,void 0,void 0,function*(){let{signer:n,delegatedGrant:i,permissionGrantId:o,protocolRole:s}=e,a,d;i!==void 0?(a=yield be.getCid(i),d=Qr.getSignerDid(i.authorization.signature.signatures[0])):d=Qr.extractDid(n.keyId);let u=this._message.descriptor,c=yield Sn.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=Qr.decodePlainObjectPayload(l),this._author=d})}signAsOwner(e){return Pi(this,void 0,void 0,function*(){if(this._author===void 0)throw new oe(ne.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 be.createSignature(r,e);this._message.authorization.ownerSignature=n,this._ownerSignaturePayload=Qr.decodePlainObjectPayload(n),this._owner=Qr.extractDid(e.keyId)})}signAsOwnerDelegate(e,r){return Pi(this,void 0,void 0,function*(){if(this._author===void 0)throw new oe(ne.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 be.getCid(r),i=this._message.descriptor,o=yield be.createSignature(i,e,{delegatedGrantId:n});this._message.authorization.ownerSignature=o,this._message.authorization.ownerDelegatedGrant=r,this._ownerSignaturePayload=Qr.decodePlainObjectPayload(o),this._owner=Qr.getSignerDid(r.authorization.signature.signatures[0])})}validateIntegrity(){return Pi(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 oe(ne.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 oe(ne.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 oe(ne.RecordsWriteValidateIntegrityRecordIdUnauthorized,`recordId in message ${this.message.recordId} does not match recordId in authorization: ${r.recordId}`);if(this.message.contextId!==r.contextId)throw new oe(ne.RecordsWriteValidateIntegrityContextIdNotInSignerSignaturePayload,`contextId in message ${this.message.contextId} does not match contextId in authorization: ${r.contextId}`);if(yield ht.validateDelegatedGrantReferentialIntegrity(this.message,r,this.ownerSignaturePayload),r.attestationCid!==void 0){let n=yield Sn.computeCid(this.message.attestation),i=r.attestationCid;if(i!==n)throw new oe(ne.RecordsWriteValidateIntegrityAttestationMismatch,`CID ${n} of attestation property in message does not match attestationCid in authorization: ${i}`)}if(r.encryptionCid!==void 0){let n=yield Sn.computeCid(this.message.encryption),i=r.encryptionCid;if(i!==n)throw new oe(ne.RecordsWriteValidateIntegrityEncryptionCidMismatch,`CID ${n} of encryption property in message does not match encryptionCid in authorization: ${i}`)}this.message.descriptor.protocol!==void 0&&Ta(this.message.descriptor.protocol),this.message.descriptor.schema!==void 0&&dd(this.message.descriptor.schema),tr.validateTimestamp(this.message.descriptor.messageTimestamp),tr.validateTimestamp(this.message.descriptor.dateCreated),this.message.descriptor.datePublished&&tr.validateTimestamp(this.message.descriptor.datePublished)})}static validateAttestationIntegrity(e){return Pi(this,void 0,void 0,function*(){if(e.attestation===void 0)return;if(e.attestation.signatures.length!==1)throw new oe(ne.RecordsWriteAttestationIntegrityMoreThanOneSignature,`Currently implementation only supports 1 attester, but got ${e.attestation.signatures.length}`);let r=Qr.decodePlainObjectPayload(e.attestation),{descriptorCid:n}=r,i=yield Sn.computeCid(e.descriptor);if(n!==i)throw new oe(ne.RecordsWriteAttestationIntegrityDescriptorCidMismatch,`descriptorCid ${n} does not match expected descriptorCid ${i}`);let o=Object.keys(r).length;if(o>1)throw new oe(ne.RecordsWriteAttestationIntegrityInvalidPayloadProperty,`Only 'descriptorCid' is allowed in attestation payload, but got ${o} properties.`)})}getEntryId(){return Pi(this,void 0,void 0,function*(){return yield t.getEntryId(this.author,this.message.descriptor)})}static getEntryId(e,r){return Pi(this,void 0,void 0,function*(){if(e===void 0)throw new oe(ne.RecordsWriteGetEntryIdUndefinedAuthor,"Property `author` is needed to compute entry ID.");let n=Object.assign({},r);return n.author=e,yield Sn.computeCid(n)})}isInitialWrite(){return Pi(this,void 0,void 0,function*(){return(yield this.getEntryId())===this.message.recordId})}constructIndexes(e){return Pi(this,void 0,void 0,function*(){let r=this.message,n=r.descriptor,{tags:i}=n,o=lCe(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=ht.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 Pi(this,void 0,void 0,function*(){let r=yield vo.parse(this.message.authorization.authorDelegatedGrant);yield Lo.authorizeWrite({recordsWriteMessage:this.message,expectedGrantor:this.author,expectedGrantee:this.signer,permissionGrant:r,messageStore:e})})}authorizeOwnerDelegate(e){return Pi(this,void 0,void 0,function*(){let r=yield vo.parse(this.message.authorization.ownerDelegatedGrant);yield Lo.authorizeWrite({recordsWriteMessage:this.message,expectedGrantor:this.owner,expectedGrantee:this.ownerSignatureSigner,permissionGrant:r,messageStore:e})})}static isInitialWrite(e){return Pi(this,void 0,void 0,function*(){if(e.descriptor.interface!==Ae.Records||e.descriptor.method!==_e.Write)return!1;let r=e,n=ht.getAuthor(r);return(yield t.getEntryId(n,r.descriptor))===r.recordId})}static createEncryptionProperty(e,r){var n,i;return Pi(this,void 0,void 0,function*(){if(r===void 0)return;let o=[];for(let a of r.keyEncryptionInputs){if(a.derivationScheme===Ni.ProtocolPath&&e.protocol===void 0)throw new oe(ne.RecordsWriteMissingProtocol,"`protocols` encryption scheme cannot be applied to record without the `protocol` property.");if(a.derivationScheme===Ni.Schemas&&e.schema===void 0)throw new oe(ne.RecordsWriteMissingSchema,"`schemas` encryption scheme cannot be applied to record without the `schema` property.");let d=Ci.publicJwkToBytes(a.publicKey),u=yield Hf.eciesSecp256k1Encrypt(d,r.key),c=Ye.bytesToBase64Url(u.ciphertext),l=yield Ci.publicKeyToJwk(u.ephemeralPublicKey),m=Ye.bytesToBase64Url(u.initializationVector),p=Ye.bytesToBase64Url(u.messageAuthenticationCode),g={rootKeyId:a.publicKeyId,algorithm:(n=a.algorithm)!==null&&n!==void 0?n:Gp.EciesSecp256k1,derivationScheme:a.derivationScheme,ephemeralPublicKey:l,initializationVector:m,messageAuthenticationCode:p,encryptedKey:c};a.derivationScheme===Ni.ProtocolContext&&(g.derivedPublicKey=a.publicKey),o.push(g)}return{algorithm:(i=r.algorithm)!==null&&i!==void 0?i:Gp.Aes256Ctr,initializationVector:Ye.bytesToBase64Url(r.initializationVector),keyEncryption:o}})}static createAttestation(e,r){return Pi(this,void 0,void 0,function*(){if(r===void 0||r.length===0)return;let n={descriptorCid:e},i=Ye.objectToBytes(n);return(yield R0.create(i,r)).getJws()})}static createSignerSignature(e){return Pi(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 Sn.computeCid(o):void 0,m=s?yield Sn.computeCid(s):void 0,p={recordId:r,descriptorCid:i,contextId:n,attestationCid:l,encryptionCid:m,delegatedGrantId:d,permissionGrantId:u,protocolRole:c};vn(p);let g=Ye.objectToBytes(p);return(yield R0.create(g,[a])).getJws()})}static getInitialWrite(e){return Pi(this,void 0,void 0,function*(){for(let r of e)if(yield t.isInitialWrite(r))return r;throw new oe(ne.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 oe(ne.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=>Qr.getSignerDid(s))}static fetchInitialRecordsWrite(e,r,n){return Pi(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 Nse=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 Yn(t,e){return Nse(this,void 0,void 0,function*(){if(t===void 0)throw new oe(ne.AuthenticateJwsMissing,"Missing JWS.");if(yield ky.verifySignatures(t.signature,e),t.ownerSignature!==void 0&&(yield ky.verifySignatures(t.ownerSignature,e)),t.authorDelegatedGrant!==void 0){let r=yield zr.parse(t.authorDelegatedGrant);yield ky.verifySignatures(r.message.authorization.signature,e)}if(t.ownerDelegatedGrant!==void 0){let r=yield zr.parse(t.ownerDelegatedGrant);yield ky.verifySignatures(r.message.authorization.signature,e)}})}function Ml(t,e){return Nse(this,void 0,void 0,function*(){if(e.author!==t)throw new oe(ne.AuthorizationAuthorNotOwner,`Message authored by ${e.author}, not authored by expected owner ${t}.`)})}h();var fCe=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())})},rE=class{isActiveTenant(e){return fCe(this,void 0,void 0,function*(){return{isActiveTenant:!0}})}};h();h();var fi=class{get message(){return this._message}get signer(){return this._signer}get author(){return this._author}get signaturePayload(){return this._signaturePayload}constructor(e){this._message=e,e.authorization!==void 0&&(this._signer=be.getSigner(e),e.authorization.authorDelegatedGrant!==void 0?this._author=be.getSigner(e.authorization.authorDelegatedGrant):this._author=this._signer,this._signaturePayload=Qr.decodePlainObjectPayload(e.authorization.signature))}toJSON(){return this.message}};var MO=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())})},nm=class t extends fi{static parse(e){return MO(this,void 0,void 0,function*(){if(e.descriptor.filter.published===!1&&(e.descriptor.dateSort===xi.PublishedAscending||e.descriptor.dateSort===xi.PublishedDescending))throw new oe(ne.RecordsQueryParseFilterPublishedSortInvalid,`queries must not filter for \`published:false\` and sort by ${e.descriptor.dateSort}`);let r;if(e.authorization!==void 0&&(r=yield be.validateSignatureStructure(e.authorization.signature,e.descriptor)),yield ht.validateDelegatedGrantReferentialIntegrity(e,r),r?.protocolRole!==void 0&&e.descriptor.filter.protocolPath===void 0)throw new oe(ne.RecordsQueryFilterMissingRequiredProperties,"Role-authorized queries must include `protocolPath` in the filter");return e.descriptor.filter.protocol!==void 0&&Ta(e.descriptor.filter.protocol),e.descriptor.filter.schema!==void 0&&dd(e.descriptor.filter.schema),tr.validateTimestamp(e.descriptor.messageTimestamp),new t(e)})}static create(e){var r;return MO(this,void 0,void 0,function*(){let n={interface:Ae.Records,method:_e.Query,messageTimestamp:(r=e.messageTimestamp)!==null&&r!==void 0?r:tr.getCurrentTimestamp(),filter:ht.normalizeFilter(e.filter),dateSort:e.dateSort,pagination:e.pagination};if(e.filter.published===!1&&(e.dateSort===xi.PublishedAscending||e.dateSort===xi.PublishedDescending))throw new oe(ne.RecordsQueryCreateFilterPublishedSortInvalid,`queries must not filter for \`published:false\` and sort by ${e.dateSort}`);vn(n);let i=e.signer,o;i&&(o=yield be.createAuthorization({descriptor:n,signer:i,protocolRole:e.protocolRole,delegatedGrant:e.delegatedGrant}));let s={descriptor:n,authorization:o};return be.validateJsonSchema(s),new t(s)})}authorizeDelegate(e){return MO(this,void 0,void 0,function*(){let r=yield vo.parse(this.message.authorization.authorDelegatedGrant);yield Lo.authorizeQueryOrSubscribe({incomingMessage:this.message,expectedGrantee:this.signer,expectedGrantor:this.author,permissionGrant:r,messageStore:e})})}};h();var fA=Ut(x4(),1),jse=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())})},mu=class t{static toBytes(e){return jse(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 jse(this,void 0,void 0,function*(){let r=yield t.toBytes(e);return Ye.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 fA.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=Ye.objectToBytes(e);return t.fromBytes(r)}static duplicateDataStream(e,r){let n=[];for(let i=0;i{e===c&&Hn.matchAnyFilter(m,s)&&n(l)},u=yield this.eventStream.subscribe(e,a,d);return{status:{code:200,detail:"OK"},subscription:u}})}};h();h();var Lse=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())})},cm=class t extends fi{static parse(e){return Lse(this,void 0,void 0,function*(){return be.validateJsonSchema(e),this.validateMessageCids(e.descriptor.messageCids),yield be.validateSignatureStructure(e.authorization.signature,e.descriptor),tr.validateTimestamp(e.descriptor.messageTimestamp),new t(e)})}static create(e){var r;return Lse(this,void 0,void 0,function*(){let n={interface:Ae.Messages,method:_e.Get,messageCids:e.messageCids,messageTimestamp:(r=e?.messageTimestamp)!==null&&r!==void 0?r:tr.getCurrentTimestamp()},i=yield be.createAuthorization({descriptor:n,signer:e.signer}),o={descriptor:n,authorization:i};return be.validateJsonSchema(o),t.validateMessageCids(e.messageCids),new t(o)})}static validateMessageCids(e){for(let r of e)try{Sn.parseCid(r)}catch{throw new oe(ne.MessageGetInvalidCid,`${r} is not a valid CID`)}}};var yCe=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())})},yA=class{constructor(e,r,n){this.didResolver=e,this.messageStore=r,this.dataStore=n}handle({tenant:e,message:r}){return yCe(this,void 0,void 0,function*(){let n;try{n=yield cm.parse(r)}catch(a){return Xt(a,400)}try{yield Yn(r.authorization,this.didResolver),yield Ml(e,n)}catch(a){return Xt(a,401)}let i=[],o=new Set(r.descriptor.messageCids);for(let a of o){let d=this.messageStore.get(e,a).then(u=>({messageCid:a,message:u})).catch(u=>({messageCid:a,message:void 0,error:`Failed to get message ${a}`}));i.push(d)}let s=yield Promise.all(i);for(let a of s){let{message:d}=a;if(!d)continue;let{interface:u,method:c}=d.descriptor;if(u!==Ae.Records||c!==_e.Write)continue;let l=d;l.encodedData!==void 0&&(a.encodedData=l.encodedData,delete l.encodedData)}return{status:{code:200,detail:"OK"},entries:s}})}};h();h();var kde=Ut(TN(),1);h();var dh;(function(t){t.Anyone="anyone",t.Author="author",t.Recipient="recipient"})(dh||(dh={}));var hi;(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"})(hi||(hi={}));var Ide=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())})},uKe=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 oe(ne.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![hi.CoUpdate,hi.CoDelete,hi.CoPrune].includes(l)))throw new oe(ne.ProtocolsConfigureInvalidRecipientOfAction,"Rules for `recipient` without `of` property must have `can` containing only `co-update`, `co-delete`, and `co-prune`.");if(u.who===dh.Author&&!u.of)throw new oe(ne.ProtocolsConfigureInvalidActionMissingOf,"'of' is required when 'author' is specified as 'who'");if(u.can!==void 0){if(u.can.includes(hi.Update)&&!u.can.includes(hi.Create))throw new oe(ne.ProtocolsConfigureInvalidActionUpdateWithoutCreate,`Action rule ${JSON.stringify(u)} contains 'update' action but missing the required 'create' action.`);if(u.can.includes(hi.Delete)&&!u.can.includes(hi.Create))throw new oe(ne.ProtocolsConfigureInvalidActionDeleteWithoutCreate,`Action rule ${JSON.stringify(u)} contains 'delete' action but missing the required 'create' action.`)}for(let c=d+1;c0)throw new oe(ne.ProtocolAuthorizationMissingContextId,"Could not verify role because contextId is missing.");if(l>0){let g=i.split("/").slice(0,l).join("/"),b=Hn.constructPrefixFilterAsRangeFilter(g);c.contextId=b}let{messages:m}=yield s.query(e,[c]);if(m.length===0)throw new oe(ne.ProtocolAuthorizationMatchingRoleRecordNotFound,`No matching role record found for protocol path ${d}`)})}static getActionsSeekingARuleMatch(e,r,n){return Ca(this,void 0,void 0,function*(){switch(r.message.descriptor.method){case _e.Delete:let i=r,o=i.message.descriptor.recordId,s=yield zr.fetchInitialRecordsWrite(n,e,o);if(s===void 0)return[];let a=[];return i.message.descriptor.prune?(a.push(hi.CoPrune),r.author===s.author&&a.push(hi.Prune)):(a.push(hi.CoDelete),r.author===s.author&&a.push(hi.Delete)),a;case _e.Query:return[hi.Query];case _e.Read:return[hi.Read];case _e.Subscribe:return[hi.Subscribe];case _e.Write:if(yield r.isInitialWrite())return[hi.Create];{let c=r.message.recordId,l=yield zr.fetchInitialRecordsWrite(n,e,c);return l===void 0?[]:r.author===l.author?[hi.CoUpdate,hi.Update]:[hi.CoUpdate]}}return[]})}static authorizeAgainstAllowedActions(e,r,n,i,o){var s;return Ca(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 oe(ne.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 m of c){if(!m.can.some(b=>d.includes(b)))continue;if(m.who===dh.Anyone)return;if(u===void 0)continue;if(l!==void 0){if(m.role===l)return;continue}if(m.who===dh.Recipient&&m.of===void 0){let b;if(r.message.descriptor.method===_e.Write?b=r.message:b=i[i.length-1],b.descriptor.recipient===u)return;continue}if(yield t.checkActor(u,m,i))return}throw new oe(ne.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 oe(ne.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=hKe(s,["$allowUndefinedTags","$requiredTags"]),c=a||!1,l=d||[],m=new Dde.default.default,p=m.compile({type:"object",properties:u,required:l,additionalProperties:c});if(!p(n)){let b=m.errorsText(p.errors,{dataVar:`${i}/${o}/$tags`});throw new oe(ne.ProtocolAuthorizationTagsInvalidSchema,`tags schema validation error: ${b}`)}}}static verifyAsRoleRecordIfNeeded(e,r,n,i){return Ca(this,void 0,void 0,function*(){if(!n.$role)return;let o=r,s=o.message.descriptor.recipient;if(s===void 0)throw new oe(ne.ProtocolAuthorizationRoleMissingRecipient,"Role records must have a recipient");let a=o.message.descriptor.protocolPath,d={interface:Ae.Records,method:_e.Write,isLatestBaseState:!0,protocol:o.message.descriptor.protocol,protocolPath:a,recipient:s},u=ht.getParentContextFromOfContextId(o.message.contextId);if(u!==""){let p=Hn.constructPrefixFilterAsRangeFilter(u);d.contextId=p}let{messages:c}=yield i.query(e,[d]);if(c.filter(p=>p.recordId!==o.message.recordId).length>0)throw new oe(ne.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===dh.Recipient)return e===i.descriptor.recipient;{let o=(yield zr.parse(i)).author;return e===o}})}static getTypeName(e){return e.split("/").slice(-1)[0]}};h();var kN=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())})},vm=class t extends fi{static parse(e){return kN(this,void 0,void 0,function*(){let r;return e.authorization!==void 0&&(r=yield be.validateSignatureStructure(e.authorization.signature,e.descriptor)),yield ht.validateDelegatedGrantReferentialIntegrity(e,r),tr.validateTimestamp(e.descriptor.messageTimestamp),new t(e)})}static create(e){var r,n;return kN(this,void 0,void 0,function*(){let i=e.recordId,o=tr.getCurrentTimestamp(),s={interface:Ae.Records,method:_e.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 be.createAuthorization({descriptor:s,signer:e.signer,protocolRole:e.protocolRole,delegatedGrant:e.delegatedGrant}),d={descriptor:s,authorization:a};return be.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 vn(c),c}authorizeDelegate(e,r){return kN(this,void 0,void 0,function*(){let n=yield vo.parse(this.message.authorization.authorDelegatedGrant);yield Lo.authorizeDelete({recordsDeleteMessage:this.message,recordsWriteToDelete:e,expectedGrantor:this.author,expectedGrantee:this.signer,permissionGrant:n,messageStore:r})})}};h();h();var wu=class{};wu.maxDataSizeAllowedToBeEncoded=3e4;var XA=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())})},og=class t{static deleteFromDataStoreIfNeeded(e,r,n,i){return XA(this,void 0,void 0,function*(){if(n.descriptor.method!==_e.Write)return;let o=n;o.descriptor.dataSize<=wu.maxDataSizeAllowedToBeEncoded||o.descriptor.dataCid!==i.descriptor.dataCid&&(yield e.delete(r,o.recordId,o.descriptor.dataCid))})}static purgeRecordDescendants(e,r,n,i,o){return XA(this,void 0,void 0,function*(){let s={interface:Ae.Records,parentId:r},{messages:a}=yield n.query(e,[s]),d=new Map;for(let u of a){let c;ht.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 XA(this,void 0,void 0,function*(){let s=r.filter(u=>u.descriptor.method===_e.Write),a=yield be.getNewestMessage(s);yield i.delete(e,a.recordId,a.descriptor.dataCid);let d=yield Promise.all(r.map(u=>be.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 XA(this,void 0,void 0,function*(){let a=[];for(let d of r){if(yield be.isOlder(d,n)){yield t.deleteFromDataStoreIfNeeded(o,e,d,n);let c=yield be.getCid(d);if(yield i.delete(e,c),yield zr.isInitialWrite(d)){let m=yield zr.parse(d),p=!1,g=yield m.constructIndexes(p),b=d;delete b.encodedData,yield i.put(e,b,g)}else{let m=yield be.getCid(d);a.push(m)}}yield s.deleteEventsByCid(e,a)}})}};var Mde=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())})},QA=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}){return Mde(this,void 0,void 0,function*(){let n;try{n=yield vm.parse(r)}catch(p){return Xt(p,400)}try{yield Yn(r.authorization,this.didResolver)}catch(p){return Xt(p,401)}let i={interface:Ae.Records,recordId:r.descriptor.recordId},{messages:o}=yield this.messageStore.query(e,[i]),s=yield be.getNewestMessage(o),a=!1,d;if(s===void 0||(yield be.isNewer(r,s))?(a=!0,d=r):d=s,!a)return{status:{code:409,detail:"Conflict"}};if(s===void 0||s.descriptor.method===_e.Delete)return{status:{code:404,detail:"Not Found"}};try{yield t.authorizeRecordsDelete(e,n,yield zr.parse(s),this.messageStore)}catch(p){return Xt(p,401)}let u=yield zr.getInitialWrite(o),c=n.constructIndexes(u),l=yield be.getCid(r);return yield this.messageStore.put(e,r,c),yield this.eventLog.append(e,l,c),this.eventStream!==void 0&&this.eventStream.emit(e,{message:r,initialWrite:u},c),r.descriptor.prune&&(yield og.purgeRecordDescendants(e,r.descriptor.recordId,this.messageStore,this.dataStore,this.eventLog)),yield og.deleteAllOlderMessagesButKeepInitialWrite(e,o,d,this.messageStore,this.dataStore,this.eventLog),{status:{code:202,detail:"Accepted"}}})}static authorizeRecordsDelete(e,r,n,i){return Mde(this,void 0,void 0,function*(){if(be.isSignedByAuthorDelegate(r.message)&&(yield r.authorizeDelegate(n.message,i)),r.author!==e)if(n.message.descriptor.protocol!==void 0)yield gc.authorizeDelete(e,r,n,i);else throw new oe(ne.RecordsDeleteAuthorizationFailed,"RecordsDelete message failed authorization")})}};h();h();var ns;(function(t){t[t.Descending=-1]="Descending",t[t.Ascending=1]="Ascending"})(ns||(ns={}));var CE=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())})},eP=class t{constructor(e,r,n){this.didResolver=e,this.messageStore=r,this.dataStore=n}handle({tenant:e,message:r}){return CE(this,void 0,void 0,function*(){let n;try{n=yield nm.parse(r)}catch(s){return Xt(s,400)}let i,o;if(ht.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 Yn(r.authorization,this.didResolver),yield t.authorizeRecordsQuery(e,n,this.messageStore)}catch(s){return Xt(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 zr.isInitialWrite(s))){let d=(yield this.messageStore.query(e,[{recordId:s.recordId,isLatestBaseState:!1,method:_e.Write}])).messages[0];delete d.encodedData,s.initialWrite=d}return{status:{code:200,detail:"OK"},entries:i,cursor:o}})}convertDateSort(e){switch(e){case xi.CreatedAscending:return{dateCreated:ns.Ascending};case xi.CreatedDescending:return{dateCreated:ns.Descending};case xi.PublishedAscending:return{datePublished:ns.Ascending};case xi.PublishedDescending:return{datePublished:ns.Descending};default:return{dateCreated:ns.Ascending}}}fetchRecordsAsOwner(e,r){return CE(this,void 0,void 0,function*(){let{dateSort:n,filter:i,pagination:o}=r.message.descriptor,s=Object.assign(Object.assign({},ht.convertFilter(i,n)),{interface:Ae.Records,method:_e.Write,isLatestBaseState:!0}),a=this.convertDateSort(n);return this.messageStore.query(e,[s],a,o)})}fetchRecordsAsNonOwner(e,r){return CE(this,void 0,void 0,function*(){let{dateSort:n,pagination:i,filter:o}=r.message.descriptor,s=[];if(ht.filterIncludesPublishedRecords(o)&&s.push(t.buildPublishedRecordsFilter(r)),ht.filterIncludesUnpublishedRecords(o)){s.push(t.buildUnpublishedRecordsByQueryAuthorFilter(r));let d=r.message.descriptor.filter.recipient;(d===void 0||d===r.author)&&s.push(t.buildUnpublishedRecordsForQueryAuthorFilter(r)),ht.shouldProtocolAuthorize(r.signaturePayload)&&s.push(t.buildUnpublishedProtocolAuthorizedRecordsFilter(r))}let a=this.convertDateSort(n);return this.messageStore.query(e,s,a,i)})}fetchPublishedRecords(e,r){return CE(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({},ht.convertFilter(n,r)),{interface:Ae.Records,method:_e.Write,published:!0,isLatestBaseState:!0})}static buildUnpublishedRecordsForQueryAuthorFilter(e){let{dateSort:r,filter:n}=e.message.descriptor;return Object.assign(Object.assign({},ht.convertFilter(n,r)),{interface:Ae.Records,method:_e.Write,recipient:e.author,isLatestBaseState:!0,published:!1})}static buildUnpublishedProtocolAuthorizedRecordsFilter(e){let{dateSort:r,filter:n}=e.message.descriptor;return Object.assign(Object.assign({},ht.convertFilter(n,r)),{interface:Ae.Records,method:_e.Write,isLatestBaseState:!0,published:!1})}static buildUnpublishedRecordsByQueryAuthorFilter(e){let{dateSort:r,filter:n}=e.message.descriptor;return Object.assign(Object.assign({},ht.convertFilter(n,r)),{author:e.author,interface:Ae.Records,method:_e.Write,isLatestBaseState:!0,published:!1})}static authorizeRecordsQuery(e,r,n){return CE(this,void 0,void 0,function*(){be.isSignedByAuthorDelegate(r.message)&&(yield r.authorizeDelegate(n)),ht.shouldProtocolAuthorize(r.signaturePayload)&&(yield gc.authorizeQueryOrSubscribe(e,r,n))})}};h();h();var RN=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())})},sg=class t extends fi{static parse(e){return RN(this,void 0,void 0,function*(){let r;return e.authorization!==void 0&&(r=yield be.validateSignatureStructure(e.authorization.signature,e.descriptor)),yield ht.validateDelegatedGrantReferentialIntegrity(e,r),tr.validateTimestamp(e.descriptor.messageTimestamp),new t(e)})}static create(e){var r;return RN(this,void 0,void 0,function*(){let{filter:n,signer:i,permissionGrantId:o,protocolRole:s}=e,a=tr.getCurrentTimestamp(),d={interface:Ae.Records,method:_e.Read,filter:ht.normalizeFilter(n),messageTimestamp:(r=e.messageTimestamp)!==null&&r!==void 0?r:a};vn(d);let u;i!==void 0&&(u=yield be.createAuthorization({descriptor:d,signer:i,permissionGrantId:o,protocolRole:s,delegatedGrant:e.delegatedGrant}));let c={descriptor:d,authorization:u};return be.validateJsonSchema(c),new t(c)})}authorizeDelegate(e,r){return RN(this,void 0,void 0,function*(){let n=yield vo.parse(this.message.authorization.authorDelegatedGrant);yield Lo.authorizeRead({recordsReadMessage:this.message,recordsWriteMessageToBeRead:e,expectedGrantor:this.author,expectedGrantee:this.signer,permissionGrant:n,messageStore:r})})}};var Bde=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())})},tP=class t{constructor(e,r,n){this.didResolver=e,this.messageStore=r,this.dataStore=n}handle({tenant:e,message:r}){return Bde(this,void 0,void 0,function*(){let n;try{n=yield sg.parse(r)}catch(c){return Xt(c,400)}try{n.author!==void 0&&(yield Yn(r.authorization,this.didResolver))}catch(c){return Xt(c,401)}let i=Object.assign({interface:Ae.Records,isLatestBaseState:!0},ht.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 Xt(new oe(ne.RecordsReadReturnedMultiple,"Multiple records exist for the RecordsRead filter"),400);let s=o[0];try{yield t.authorizeRecordsRead(e,n,yield zr.parse(s),this.messageStore)}catch(c){return Xt(c,401)}let a;if(s.encodedData!==void 0){let c=Ye.base64UrlToBytes(s.encodedData);a=mu.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 zr.isInitialWrite(d))){let l=(yield this.messageStore.query(e,[{recordId:d.recordId,isLatestBaseState:!1,method:_e.Write}])).messages[0];delete l.encodedData,d.initialWrite=l}return{status:{code:200,detail:"OK"},record:d}})}static authorizeRecordsRead(e,r,n,i){return Bde(this,void 0,void 0,function*(){be.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 pi.fetchGrant(e,i,r.signaturePayload.permissionGrantId);yield Lo.authorizeRead({recordsReadMessage:r.message,recordsWriteMessageToBeRead:n.message,expectedGrantor:e,expectedGrantee:r.author,permissionGrant:s,messageStore:i})}else if(o.protocol!==void 0)yield gc.authorizeRead(e,r,n,i);else throw new oe(ne.RecordsReadAuthorizationFailed,"message failed authorization")}})}};h();h();var DN=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())})},wm=class t extends fi{static parse(e){return DN(this,void 0,void 0,function*(){let r;if(e.authorization!==void 0&&(r=yield be.validateSignatureStructure(e.authorization.signature,e.descriptor)),yield ht.validateDelegatedGrantReferentialIntegrity(e,r),r?.protocolRole!==void 0&&e.descriptor.filter.protocolPath===void 0)throw new oe(ne.RecordsSubscribeFilterMissingRequiredProperties,"Role-authorized subscriptions must include `protocolPath` in the filter");return e.descriptor.filter.protocol!==void 0&&Ta(e.descriptor.filter.protocol),e.descriptor.filter.schema!==void 0&&dd(e.descriptor.filter.schema),tr.validateTimestamp(e.descriptor.messageTimestamp),new t(e)})}static create(e){var r;return DN(this,void 0,void 0,function*(){let n={interface:Ae.Records,method:_e.Subscribe,messageTimestamp:(r=e.messageTimestamp)!==null&&r!==void 0?r:tr.getCurrentTimestamp(),filter:ht.normalizeFilter(e.filter)};vn(n);let i=e.signer,o;i&&(o=yield be.createAuthorization({descriptor:n,signer:i,protocolRole:e.protocolRole,delegatedGrant:e.delegatedGrant}));let s={descriptor:n,authorization:o};return be.validateJsonSchema(s),new t(s)})}authorizeDelegate(e){return DN(this,void 0,void 0,function*(){let r=yield vo.parse(this.message.authorization.authorDelegatedGrant);yield Lo.authorizeQueryOrSubscribe({incomingMessage:this.message,expectedGrantor:this.author,expectedGrantee:this.signer,permissionGrant:r,messageStore:e})})}};var rP=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())})},nP=class t{constructor(e,r,n){this.didResolver=e,this.messageStore=r,this.eventStream=n}handle({tenant:e,message:r,subscriptionHandler:n}){return rP(this,void 0,void 0,function*(){if(this.eventStream===void 0)return Xt(new oe(ne.RecordsSubscribeEventStreamUnimplemented,"Subscriptions are not supported"),501);let i;try{i=yield wm.parse(r)}catch(u){return Xt(u,400)}let o=[];if(ht.filterIncludesPublishedRecords(i.message.descriptor.filter)&&i.author===void 0)o=[t.buildPublishedRecordsFilter(i)],delete r.authorization;else{try{yield Yn(r.authorization,this.didResolver),yield t.authorizeRecordsSubscribe(e,i,this.messageStore)}catch(u){return Xt(u,401)}i.author===e?o=yield t.filterAsOwner(i):o=yield t.filterAsNonOwner(i)}let s=(u,c,l)=>{e===u&&Hn.matchAnyFilter(l,o)&&n(c)},a=yield be.getCid(r),d=yield this.eventStream.subscribe(e,a,s);return{status:{code:200,detail:"OK"},subscription:d}})}static filterAsOwner(e){return rP(this,void 0,void 0,function*(){let{filter:r}=e.message.descriptor;return[Object.assign(Object.assign({},ht.convertFilter(r)),{interface:Ae.Records,method:[_e.Write,_e.Delete]})]})}static filterAsNonOwner(e){return rP(this,void 0,void 0,function*(){let r=[],{filter:n}=e.message.descriptor;if(ht.filterIncludesPublishedRecords(n)&&r.push(t.buildPublishedRecordsFilter(e)),ht.filterIncludesUnpublishedRecords(n)){r.push(t.buildUnpublishedRecordsBySubscribeAuthorFilter(e));let i=e.message.descriptor.filter.recipient;(i===void 0||i===e.author)&&r.push(t.buildUnpublishedRecordsForSubscribeAuthorFilter(e)),ht.shouldProtocolAuthorize(e.signaturePayload)&&r.push(t.buildUnpublishedProtocolAuthorizedRecordsFilter(e))}return r})}static buildPublishedRecordsFilter(e){return Object.assign(Object.assign({},ht.convertFilter(e.message.descriptor.filter)),{interface:Ae.Records,method:[_e.Write,_e.Delete],published:!0})}static buildUnpublishedRecordsForSubscribeAuthorFilter(e){return Object.assign(Object.assign({},ht.convertFilter(e.message.descriptor.filter)),{interface:Ae.Records,method:[_e.Write,_e.Delete],recipient:e.author,published:!1})}static buildUnpublishedProtocolAuthorizedRecordsFilter(e){return Object.assign(Object.assign({},ht.convertFilter(e.message.descriptor.filter)),{interface:Ae.Records,method:[_e.Write,_e.Delete],published:!1})}static buildUnpublishedRecordsBySubscribeAuthorFilter(e){return Object.assign(Object.assign({},ht.convertFilter(e.message.descriptor.filter)),{author:e.author,interface:Ae.Records,method:[_e.Write,_e.Delete],published:!1})}static authorizeRecordsSubscribe(e,r,n){return rP(this,void 0,void 0,function*(){be.isSignedByAuthorDelegate(r.message)&&(yield r.authorizeDelegate(n)),ht.shouldProtocolAuthorize(r.signaturePayload)&&(yield gc.authorizeQueryOrSubscribe(e,r,n))})}};h();var Gw=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=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 Gw(this,void 0,void 0,function*(){let i;try{i=yield zr.parse(r),r.descriptor.protocol!==void 0&&(yield gc.validateReferentialIntegrity(e,i,this.messageStore))}catch(p){return Xt(p,400)}try{yield Yn(r.authorization,this.didResolver),yield t.authorizeRecordsWrite(e,i,this.messageStore)}catch(p){return Xt(p,401)}let o={interface:Ae.Records,recordId:r.recordId},{messages:s}=yield this.messageStore.query(e,[o]),a=yield i.isInitialWrite(),d;if(!a)try{d=yield zr.getInitialWrite(s),zr.verifyEqualityOfImmutableProperties(d,r)}catch(p){return Xt(p,400)}let u=yield be.getNewestMessage(s),c=!1,l;if(u===void 0||(yield be.isNewer(r,u))?(c=!0,l=r):l=u,!c)return{status:{code:409,detail:"Conflict"}};try{let p=!1,g=r;if(n!==void 0)g=yield this.processMessageWithDataStream(e,r,n),p=!0;else{if(u?.descriptor.method===_e.Delete)throw new oe(ne.RecordsWriteMissingDataStream,"No data stream was provided with the previous message being a delete");if(!a){let S=u;g=yield this.processMessageWithoutDataStream(e,r,S),p=!0}}let b=yield i.constructIndexes(p);yield this.messageStore.put(e,g,b),yield this.eventLog.append(e,yield be.getCid(r),b),this.eventStream!==void 0&&p&&this.eventStream.emit(e,{message:r,initialWrite:d},b)}catch(p){let g=p;if(g.code!==void 0&&(g.code===ne.RecordsWriteMissingEncodedDataInPrevious||g.code===ne.RecordsWriteMissingDataInPrevious||g.code===ne.RecordsWriteMissingDataStream||g.code===ne.RecordsWriteDataCidMismatch||g.code===ne.RecordsWriteDataSizeMismatch||g.code.startsWith("PermissionsProtocolValidate")||g.code.startsWith("SchemaValidator")))return Xt(p,400);throw p}let m={status:{code:202,detail:"Accepted"}};return yield og.deleteAllOlderMessagesButKeepInitialWrite(e,s,l,this.messageStore,this.dataStore,this.eventLog),yield this.postProcessingForCoreRecordsWrite(e,i),m})}static validateSchemaForCoreRecordsWrite(e,r){e.descriptor.protocol===pi.uri&&pi.validateSchema(e,r)}postProcessingForCoreRecordsWrite(e,r){return Gw(this,void 0,void 0,function*(){if(r.message.descriptor.protocol===pi.uri&&r.message.descriptor.protocolPath===pi.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 be.getCid(a);yield this.messageStore.delete(e,d)}this.eventLog.deleteEventsByCid(e,s)}})}cloneAndAddEncodedData(e,r){return Gw(this,void 0,void 0,function*(){let n=Object.assign({},e);return n.encodedData=Ye.bytesToBase64Url(r),n})}processMessageWithDataStream(e,r,n){return Gw(this,void 0,void 0,function*(){let i=r;if(r.descriptor.dataSize<=wu.maxDataSizeAllowedToBeEncoded){let o=yield mu.toBytes(n),s=yield Sn.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]=mu.duplicateDataStream(n,2);try{let[a,d]=yield Promise.all([Sn.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 Gw(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<=wu.maxDataSizeAllowedToBeEncoded)if(n.encodedData!==void 0)i.encodedData=n.encodedData;else throw new oe(ne.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 oe(ne.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 oe(ne.RecordsWriteDataCidMismatch,`actual data CID ${n} does not match dataCid in descriptor: ${e}`);if(r!==i)throw new oe(ne.RecordsWriteDataSizeMismatch,`actual data size ${i} bytes does not match dataSize in descriptor: ${r}`)}static authorizeRecordsWrite(e,r,n){return Gw(this,void 0,void 0,function*(){if(r.owner!==void 0&&r.owner!==e)throw new oe(ne.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 pi.fetchGrant(e,n,r.signaturePayload.permissionGrantId);yield Lo.authorizeWrite({recordsWriteMessage:r.message,expectedGrantor:e,expectedGrantee:r.author,permissionGrant:i,messageStore:n})}else if(r.message.descriptor.protocol!==void 0)yield gc.authorizeWrite(e,r,n);else throw new oe(ne.RecordsWriteAuthorizationFailed,"message failed authorization")}})}};h();h();var ag;(function(t){t.authentication="authentication",t.assertionMethod="assertionMethod",t.keyAgreement="keyAgreement",t.capabilityInvocation="capabilityInvocation",t.capabilityDelegation="capabilityDelegation"})(ag||(ag={}));h();var Xn={"@context":"https://w3id.org/did-resolution/v1",didResolutionMetadata:{},didDocument:null,didDocumentMetadata:{}};h();var br=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[m,p]=l.split("=");u[m]=p}d.params=u}return d}};br.METHOD_PATTERN="([a-z0-9]+)";br.PCT_ENCODED_PATTERN="(?:%[0-9a-fA-F]{2})";br.ID_CHAR_PATTERN=`(?:[a-zA-Z0-9._-]|${br.PCT_ENCODED_PATTERN})`;br.METHOD_ID_PATTERN=`((?:${br.ID_CHAR_PATTERN}*:)*(${br.ID_CHAR_PATTERN}+))`;br.PATH_PATTERN="(/[^#?]*)?";br.QUERY_PATTERN="([?][^#]*)?";br.FRAGMENT_PATTERN="(#.*)?";br.DID_URI_PATTERN=new RegExp(`^did:(?${br.METHOD_PATTERN}):(?${br.METHOD_ID_PATTERN})(?${br.PATH_PATTERN})(?${br.QUERY_PATTERN})(?${br.FRAGMENT_PATTERN})$`);h();var ot=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)}},et;(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"})(et||(et={}));h();h();h();h();h();var _m=Ut(Ode(),1);h();h();function $de(t){return t.byteOffset!==0||t.byteLength!==t.buffer.byteLength}function Nde(t){return typeof t!="object"||t===null?!1:typeof t[Symbol.asyncIterator]=="function"}function xm(t){let r=Object.prototype.toString.call(t).match(/\s([a-zA-Z0-9]+)/),[n,i]=r;return i}var OE=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())})},jde=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)}},sP=new TextEncoder,cg=new TextDecoder,de=class t{constructor(e,r){this.data=e,this.format=r}static arrayBuffer(e){return new t(e,"ArrayBuffer")}static asyncIterable(e){if(!Nde(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 ba.baseDecode(this.data).buffer;case"Base64Url":return Ls.baseDecode(this.data).buffer;case"BufferSource":{if(xm(this.data)==="ArrayBuffer")return this.data;if(ArrayBuffer.isView(this.data))return $de(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 OE(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 CR.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 ba.baseEncode(e)}case"Multibase":return this.data.substring(1);case"Uint8Array":return ba.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 Ls.baseEncode(e)}case"BufferSource":{let e=this.toUint8Array();return Ls.baseEncode(e)}case"Object":{let e=JSON.stringify(this.data),r=sP.encode(e);return Ls.baseEncode(r)}case"String":{let e=sP.encode(this.data);return Ls.baseEncode(e)}case"Uint8Array":return Ls.baseEncode(this.data);default:throw new TypeError(`Conversion from ${this.format} to Base64Url is not supported.`)}}toBlobAsync(){var e,r,n,i;return OE(this,void 0,void 0,function*(){switch(this.format){case"AsyncIterable":{let d=[];try{for(var o=!0,s=jde(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"&&CN(t[e])})}h();var Kue=Ut(r6(),1),vd=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())})},MP=class{constructor({db:e,location:r="DATASTORE"}={}){this.store=e??new Kue.Level(r)}clear(){return vd(this,void 0,void 0,function*(){yield this.store.clear()})}close(){return vd(this,void 0,void 0,function*(){yield this.store.close()})}delete(e){return vd(this,void 0,void 0,function*(){yield this.store.del(e)})}get(e){return vd(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 vd(this,void 0,void 0,function*(){yield this.store.put(e,r)})}},Mm=class{constructor(){this.store=new Map}clear(){return vd(this,void 0,void 0,function*(){this.store.clear()})}close(){return vd(this,void 0,void 0,function*(){})}delete(e){return vd(this,void 0,void 0,function*(){return this.store.delete(e)})}get(e){return vd(this,void 0,void 0,function*(){return this.store.get(e)})}has(e){return vd(this,void 0,void 0,function*(){return this.store.has(e)})}list(){return vd(this,void 0,void 0,function*(){return Array.from(this.store.values())})}set(e,r){return vd(this,void 0,void 0,function*(){this.store.set(e,r)})}};h();var n6=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())})},i6=function(t){return this instanceof i6?(this.v=t,this):new i6(t)},mqe=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(m){n[m]&&(i[m]=function(p){return new Promise(function(g,b){o.push([m,p,g,b])>1||a(m,p)})})}function a(m,p){try{d(n[m](p))}catch(g){l(o[0][3],g)}}function d(m){m.value instanceof i6?Promise.resolve(m.value.v).then(u,c):l(o[0][2],m)}function u(m){a("next",m)}function c(m){a("throw",m)}function l(m,p){m(p),o.shift(),o.length&&a(o[0][0],o[0][1])}},BP=class t{static asAsyncIterator(e){return mqe(this,arguments,function*(){let n=e.getReader();try{for(;;){let{done:i,value:o}=yield i6(n.read());if(i)break;yield yield i6(o)}}finally{n.releaseLock()}})}static consumeToArrayBuffer({readableStream:e}){return n6(this,void 0,void 0,function*(){let r=t.asAsyncIterator(e);return yield de.asyncIterable(r).toArrayBufferAsync()})}static consumeToBlob({readableStream:e}){return n6(this,void 0,void 0,function*(){let r=t.asAsyncIterator(e);return yield de.asyncIterable(r).toBlobAsync()})}static consumeToBytes({readableStream:e}){return n6(this,void 0,void 0,function*(){let r=t.asAsyncIterator(e);return yield de.asyncIterable(r).toUint8ArrayAsync()})}static consumeToJson({readableStream:e}){return n6(this,void 0,void 0,function*(){let r=t.asAsyncIterator(e);return yield de.asyncIterable(r).toObjectAsync()})}static consumeToText({readableStream:e}){return n6(this,void 0,void 0,function*(){let r=t.asAsyncIterator(e);return yield de.asyncIterable(r).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 m=0;m{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()}})}};h();h();var ZGe=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())})},u1=class{static digest({data:e}){return ZGe(this,void 0,void 0,function*(){return ms(e)})}};h();var ei=class{};var XGe=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())})},Om=class extends ei{digest({algorithm:e,data:r}){return XGe(this,void 0,void 0,function*(){switch(e){case"SHA-256":return yield u1.digest({data:r})}})}};h();h();h();var ghe=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),mhe=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),QGe=BigInt(1),BU=BigInt(2),yhe=(t,e)=>(t+e/BU)/e;function eWe(t){let e=ghe,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=Dn(c,r,e)*c%e,m=Dn(l,r,e)*c%e,p=Dn(m,BU,e)*u%e,g=Dn(p,i,e)*p%e,b=Dn(g,o,e)*g%e,S=Dn(b,a,e)*b%e,A=Dn(S,d,e)*S%e,I=Dn(A,a,e)*b%e,P=Dn(I,r,e)*c%e,$=Dn(P,s,e)*g%e,N=Dn($,n,e)*u%e,L=Dn(N,BU,e);if(!CU.eql(CU.sqr(L),t))throw new Error("Cannot find square root");return L}var CU=Pb(ghe,void 0,void 0,{sqrt:eWe}),$a=FS({a:BigInt(0),b:BigInt(7),Fp:CU,n:mhe,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:t=>{let e=mhe,r=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-QGe*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),o=r,s=BigInt("0x100000000000000000000000000000000"),a=yhe(o*t,e),d=yhe(-n*t,e),u=Zr(t-a*r-d*i,e),c=Zr(-a*n-d*o,e),l=u>s,m=c>s;if(l&&(u=e-u),m&&(c=e-c),u>s||c>s)throw new Error("splitScalar: Endomorphism failed, k="+t);return{k1neg:l,k1:u,k2neg:m,k2:c}}}},ms),g3t=BigInt(0);var b3t=$a.ProjectivePoint;h();h();function bhe(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 tWe=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())})},Bg="urn:jwk:";function rt({jwk:t}){return tWe(this,void 0,void 0,function*(){let e=t.kty,r;if(e==="EC")r={crv:t.crv,kty:t.kty,x:t.x,y:t.y};else if(e==="oct")r={k:t.k,kty:t.kty};else if(e==="OKP")r={crv:t.crv,kty:t.kty,x:t.x};else if(e==="RSA")r={e:t.e,kty:t.kty,n:t.n};else throw new Error(`Unsupported key type: ${e}`);CN(r);let n=bhe(r),i=de.string(n).toUint8Array(),o=yield u1.digest({data:i});return de.uint8Array(o).toBase64Url()})}function Na(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 $m(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 Cg(t){return!(!t||typeof t!="object"||!("kty"in t&&"k"in t)||t.kty!=="oct"||typeof t.k!="string")}function ja(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 Nm(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 l1(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 os=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())})},rWe=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>OU&aT)}:{h:Number(t>>OU&aT)|0,l:Number(t&aT)|0}}function iWe(t,e=!1){let r=new Uint32Array(t.length),n=new Uint32Array(t.length);for(let i=0;iBigInt(t>>>0)<>>0),sWe=(t,e,r)=>t>>>r,aWe=(t,e,r)=>t<<32-r|e>>>r,cWe=(t,e,r)=>t>>>r|e<<32-r,dWe=(t,e,r)=>t<<32-r|e>>>r,uWe=(t,e,r)=>t<<64-r|e>>>r-32,lWe=(t,e,r)=>t>>>r-32|e<<64-r,fWe=(t,e)=>e,hWe=(t,e)=>t,pWe=(t,e,r)=>t<>>32-r,mWe=(t,e,r)=>e<>>32-r,yWe=(t,e,r)=>e<>>64-r,gWe=(t,e,r)=>t<>>64-r;function bWe(t,e,r,n){let i=(e>>>0)+(n>>>0);return{h:t+r+(i/2**32|0)|0,l:i|0}}var vWe=(t,e,r)=>(t>>>0)+(e>>>0)+(r>>>0),wWe=(t,e,r,n)=>e+r+n+(t/2**32|0)|0,_We=(t,e,r,n)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0),xWe=(t,e,r,n,i)=>e+r+n+i+(t/2**32|0)|0,EWe=(t,e,r,n,i)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0)+(i>>>0),SWe=(t,e,r,n,i,o)=>e+r+n+i+o+(t/2**32|0)|0;var AWe={fromBig:vhe,split:iWe,toBig:oWe,shrSH:sWe,shrSL:aWe,rotrSH:cWe,rotrSL:dWe,rotrBH:uWe,rotrBL:lWe,rotr32H:fWe,rotr32L:hWe,rotlSH:pWe,rotlSL:mWe,rotlBH:yWe,rotlBL:gWe,add:bWe,add3L:vWe,add3H:wWe,add4L:_We,add4H:xWe,add5H:SWe,add5L:EWe},nr=AWe;var[PWe,TWe]=nr.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))),Um=new Uint32Array(80),Km=new Uint32Array(80),$U=class extends Jh{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:m,Gh:p,Gl:g,Hh:b,Hl:S}=this;return[e,r,n,i,o,s,a,d,u,c,l,m,p,g,b,S]}set(e,r,n,i,o,s,a,d,u,c,l,m,p,g,b,S){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=m|0,this.Gh=p|0,this.Gl=g|0,this.Hh=b|0,this.Hl=S|0}process(e,r){for(let P=0;P<16;P++,r+=4)Um[P]=e.getUint32(r),Km[P]=e.getUint32(r+=4);for(let P=16;P<80;P++){let $=Um[P-15]|0,N=Km[P-15]|0,L=nr.rotrSH($,N,1)^nr.rotrSH($,N,8)^nr.shrSH($,N,7),F=nr.rotrSL($,N,1)^nr.rotrSL($,N,8)^nr.shrSL($,N,7),U=Um[P-2]|0,G=Km[P-2]|0,q=nr.rotrSH(U,G,19)^nr.rotrBH(U,G,61)^nr.shrSH(U,G,6),T=nr.rotrSL(U,G,19)^nr.rotrBL(U,G,61)^nr.shrSL(U,G,6),E=nr.add4L(F,T,Km[P-7],Km[P-16]),k=nr.add4H(E,L,q,Um[P-7],Um[P-16]);Um[P]=k|0,Km[P]=E|0}let{Ah:n,Al:i,Bh:o,Bl:s,Ch:a,Cl:d,Dh:u,Dl:c,Eh:l,El:m,Fh:p,Fl:g,Gh:b,Gl:S,Hh:A,Hl:I}=this;for(let P=0;P<80;P++){let $=nr.rotrSH(l,m,14)^nr.rotrSH(l,m,18)^nr.rotrBH(l,m,41),N=nr.rotrSL(l,m,14)^nr.rotrSL(l,m,18)^nr.rotrBL(l,m,41),L=l&p^~l&b,F=m&g^~m&S,U=nr.add5L(I,N,F,TWe[P],Km[P]),G=nr.add5H(U,A,$,L,PWe[P],Um[P]),q=U|0,T=nr.rotrSH(n,i,28)^nr.rotrBH(n,i,34)^nr.rotrBH(n,i,39),E=nr.rotrSL(n,i,28)^nr.rotrBL(n,i,34)^nr.rotrBL(n,i,39),k=n&o^n&a^o&a,f=i&s^i&d^s&d;A=b|0,I=S|0,b=p|0,S=g|0,p=l|0,g=m|0,{h:l,l:m}=nr.add(u|0,c|0,G|0,q|0),u=a|0,c=d|0,a=o|0,d=s|0,o=n|0,s=i|0;let y=nr.add3L(q,E,f);n=nr.add3H(y,G,T,k),i=y|0}({h:n,l:i}=nr.add(this.Ah|0,this.Al|0,n|0,i|0)),{h:o,l:s}=nr.add(this.Bh|0,this.Bl|0,o|0,s|0),{h:a,l:d}=nr.add(this.Ch|0,this.Cl|0,a|0,d|0),{h:u,l:c}=nr.add(this.Dh|0,this.Dl|0,u|0,c|0),{h:l,l:m}=nr.add(this.Eh|0,this.El|0,l|0,m|0),{h:p,l:g}=nr.add(this.Fh|0,this.Fl|0,p|0,g|0),{h:b,l:S}=nr.add(this.Gh|0,this.Gl|0,b|0,S|0),{h:A,l:I}=nr.add(this.Hh|0,this.Hl|0,A|0,I|0),this.set(n,i,o,s,a,d,u,c,l,m,p,g,b,S,A,I)}roundClean(){Um.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)}};var qm=Ab(()=>new $U);h();var Pu=BigInt(0),_c=BigInt(1),cT=BigInt(2),IWe=BigInt(8),kWe={zip215:!0};function RWe(t){let e=x2(t);return Nc(t,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}function dT(t){let e=RWe(t),{Fp:r,n,prehash:i,hash:o,randomBytes:s,nByteLength:a,h:d}=e,u=cT<{try{return{isValid:!0,value:r.sqrt(x*r.inv(v))}}catch{return{isValid:!1,value:Pu}}}),m=e.adjustScalarBytes||(x=>x),p=e.domain||((x,v,D)=>{if(v.length||D)throw new Error("Contexts/pre-hash are not supported");return x}),g=x=>typeof x=="bigint"&&Pug(x)&&g(v)&&xx===Pu||b(x,u);function A(x,v){if(b(x,v))return x;throw new Error(`Expected valid scalar < ${v}, got ${typeof x} ${x}`)}function I(x){return x===Pu?x:A(x,n)}let P=new Map;function $(x){if(!(x instanceof N))throw new Error("ExtendedPoint expected")}class N{constructor(v,D,K,M){if(this.ex=v,this.ey=D,this.ez=K,this.et=M,!S(v))throw new Error("x required");if(!S(D))throw new Error("y required");if(!S(K))throw new Error("z required");if(!S(M))throw new Error("t required")}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(v){if(v instanceof N)throw new Error("extended point not allowed");let{x:D,y:K}=v||{};if(!S(D)||!S(K))throw new Error("invalid affine point");return new N(D,K,_c,c(D*K))}static normalizeZ(v){let D=r.invertBatch(v.map(K=>K.ez));return v.map((K,M)=>K.toAffine(D[M])).map(N.fromAffine)}_setWindowSize(v){this._WINDOW_SIZE=v,P.delete(this)}assertValidity(){let{a:v,d:D}=e;if(this.is0())throw new Error("bad point: ZERO");let{ex:K,ey:M,ez:j,et:J}=this,Z=c(K*K),V=c(M*M),H=c(j*j),X=c(H*H),ee=c(Z*v),ue=c(H*c(ee+V)),ae=c(X+c(D*c(Z*V)));if(ue!==ae)throw new Error("bad point: equation left != right (1)");let ce=c(K*M),pe=c(j*J);if(ce!==pe)throw new Error("bad point: equation left != right (2)")}equals(v){$(v);let{ex:D,ey:K,ez:M}=this,{ex:j,ey:J,ez:Z}=v,V=c(D*Z),H=c(j*M),X=c(K*Z),ee=c(J*M);return V===H&&X===ee}is0(){return this.equals(N.ZERO)}negate(){return new N(c(-this.ex),this.ey,this.ez,c(-this.et))}double(){let{a:v}=e,{ex:D,ey:K,ez:M}=this,j=c(D*D),J=c(K*K),Z=c(cT*c(M*M)),V=c(v*j),H=D+K,X=c(c(H*H)-j-J),ee=V+J,ue=ee-Z,ae=V-J,ce=c(X*ue),pe=c(ee*ae),Ee=c(X*ae),Ue=c(ue*ee);return new N(ce,pe,Ue,Ee)}add(v){$(v);let{a:D,d:K}=e,{ex:M,ey:j,ez:J,et:Z}=this,{ex:V,ey:H,ez:X,et:ee}=v;if(D===BigInt(-1)){let gt=c((j-M)*(H+V)),Pe=c((j+M)*(H-V)),De=c(Pe-gt);if(De===Pu)return this.double();let It=c(J*cT*ee),we=c(Z*cT*X),Se=we+It,Lr=Pe+gt,Fe=we-It,He=c(Se*De),js=c(Lr*Fe),ft=c(Se*Fe),Rt=c(De*Lr);return new N(He,js,Rt,ft)}let ue=c(M*V),ae=c(j*H),ce=c(Z*K*ee),pe=c(J*X),Ee=c((M+j)*(V+H)-ue-ae),Ue=pe-ce,le=pe+ce,ge=c(ae-D*ue),ve=c(Ee*Ue),Ce=c(le*ge),Ie=c(Ee*ge),je=c(Ue*le);return new N(ve,Ce,je,Ie)}subtract(v){return this.add(v.negate())}wNAF(v){return U.wNAFCached(this,P,v,N.normalizeZ)}multiply(v){let{p:D,f:K}=this.wNAF(A(v,n));return N.normalizeZ([D,K])[0]}multiplyUnsafe(v){let D=I(v);return D===Pu?F:this.equals(F)||D===_c?this:this.equals(L)?this.wNAF(D).p:U.unsafeLadder(this,D)}isSmallOrder(){return this.multiplyUnsafe(d).is0()}isTorsionFree(){return U.unsafeLadder(this,n).is0()}toAffine(v){let{ex:D,ey:K,ez:M}=this,j=this.is0();v==null&&(v=j?IWe:r.inv(M));let J=c(D*v),Z=c(K*v),V=c(M*v);if(j)return{x:Pu,y:_c};if(V!==_c)throw new Error("invZ was invalid");return{x:J,y:Z}}clearCofactor(){let{h:v}=e;return v===_c?this:this.multiplyUnsafe(v)}static fromHex(v,D=!1){let{d:K,a:M}=e,j=r.BYTES;v=Rn("pointHex",v,j);let J=v.slice(),Z=v[j-1];J[j-1]=Z&-129;let V=$d(J);V===Pu||(D?A(V,u):A(V,r.ORDER));let H=c(V*V),X=c(H-_c),ee=c(K*H-M),{isValid:ue,value:ae}=l(X,ee);if(!ue)throw new Error("Point.fromHex: invalid y coordinate");let ce=(ae&_c)===_c,pe=(Z&128)!==0;if(!D&&ae===Pu&&pe)throw new Error("Point.fromHex: x=0 and x_0=1");return pe!==ce&&(ae=c(-ae)),N.fromAffine({x:ae,y:V})}static fromPrivateKey(v){return T(v).point}toRawBytes(){let{x:v,y:D}=this.toAffine(),K=pf(D,r.BYTES);return K[K.length-1]|=v&_c?128:0,K}toHex(){return ff(this.toRawBytes())}}N.BASE=new N(e.Gx,e.Gy,_c,c(e.Gx*e.Gy)),N.ZERO=new N(Pu,_c,_c,Pu);let{BASE:L,ZERO:F}=N,U=LS(N,a*8);function G(x){return Zr(x,n)}function q(x){return G($d(x))}function T(x){let v=a;x=Rn("private key",x,v);let D=Rn("hashed private key",o(x),2*v),K=m(D.slice(0,v)),M=D.slice(v,2*v),j=q(K),J=L.multiply(j),Z=J.toRawBytes();return{head:K,prefix:M,scalar:j,point:J,pointBytes:Z}}function E(x){return T(x).pointBytes}function k(x=new Uint8Array,...v){let D=mf(...v);return q(o(p(D,Rn("context",x),!!i)))}function f(x,v,D={}){x=Rn("message",x),i&&(x=i(x));let{prefix:K,scalar:M,pointBytes:j}=T(v),J=k(D.context,K,x),Z=L.multiply(J).toRawBytes(),V=k(D.context,Z,j,x),H=G(J+V*M);I(H);let X=mf(Z,pf(H,r.BYTES));return Rn("result",X,a*2)}let y=kWe;function w(x,v,D,K=y){let{context:M,zip215:j}=K,J=r.BYTES;x=Rn("signature",x,2*J),v=Rn("message",v),i&&(v=i(v));let Z=$d(x.slice(J,2*J)),V,H,X;try{V=N.fromHex(D,j),H=N.fromHex(x.slice(0,J),j),X=L.multiplyUnsafe(Z)}catch{return!1}if(!j&&V.isSmallOrder())return!1;let ee=k(M,H.toRawBytes(),V.toRawBytes(),v);return H.add(V.multiplyUnsafe(ee)).subtract(X).clearCofactor().equals(N.ZERO)}return L._setWindowSize(8),{CURVE:e,getPublicKey:E,sign:f,verify:w,ExtendedPoint:N,utils:{getExtendedPublicKey:T,randomPrivateKey:()=>s(r.BYTES),precompute(x=8,v=N.BASE){return v._setWindowSize(x),v.multiply(BigInt(3)),v}}}}h();var y6=BigInt(0),NU=BigInt(1);function DWe(t){return Nc(t,{a:"bigint"},{montgomeryBits:"isSafeInteger",nByteLength:"isSafeInteger",adjustScalarBytes:"function",domain:"function",powPminus2:"function",Gu:"bigint"}),Object.freeze({...t})}function whe(t){let e=DWe(t),{P:r}=e,n=P=>Zr(P,r),i=e.montgomeryBits,o=Math.ceil(i/8),s=e.nByteLength,a=e.adjustScalarBytes||(P=>P),d=e.powPminus2||(P=>Lk(P,r-BigInt(2),r));function u(P,$,N){let L=n(P*($-N));return $=n($-L),N=n(N+L),[$,N]}function c(P){if(typeof P=="bigint"&&y6<=P&&P=y6;y--){let w=L>>y&NU;E^=w,k=u(E,U,q),U=k[0],q=k[1],k=u(E,G,T),G=k[0],T=k[1],E=w;let _=U+G,x=n(_*_),v=U-G,D=n(v*v),K=x-D,M=q+T,j=q-T,J=n(j*_),Z=n(M*v),V=J+Z,H=J-Z;q=n(V*V),T=n(F*n(H*H)),U=n(x*D),G=n(K*(x+n(l*K)))}k=u(E,U,q),U=k[0],q=k[1],k=u(E,G,T),G=k[0],T=k[1];let f=d(G);return n(U*f)}function p(P){return pf(n(P),o)}function g(P){let $=Rn("u coordinate",P,o);return s===32&&($[31]&=127),$d($)}function b(P){let $=Rn("scalar",P),N=$.length;if(N!==o&&N!==s)throw new Error(`Expected ${o} or ${s} bytes, got ${N}`);return $d(a($))}function S(P,$){let N=g($),L=b(P),F=m(N,L);if(F===y6)throw new Error("Invalid private or public key received");return p(F)}let A=p(e.Gu);function I(P){return S(P,A)}return{scalarMult:S,scalarMultBase:I,getSharedSecret:(P,$)=>S(P,$),getPublicKey:P=>I(P),utils:{randomPrivateKey:()=>e.randomBytes(e.nByteLength)},GuBytes:A}}var g6=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),_he=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),m5t=BigInt(0),MWe=BigInt(1),jU=BigInt(2),BWe=BigInt(5),xhe=BigInt(10),CWe=BigInt(20),OWe=BigInt(40),Ehe=BigInt(80);function She(t){let e=g6,n=t*t%e*t%e,i=Dn(n,jU,e)*n%e,o=Dn(i,MWe,e)*t%e,s=Dn(o,BWe,e)*o%e,a=Dn(s,xhe,e)*s%e,d=Dn(a,CWe,e)*a%e,u=Dn(d,OWe,e)*d%e,c=Dn(u,Ehe,e)*u%e,l=Dn(c,Ehe,e)*u%e,m=Dn(l,xhe,e)*s%e;return{pow_p_5_8:Dn(m,jU,e)*t%e,b2:n}}function Ahe(t){return t[0]&=248,t[31]&=127,t[31]|=64,t}function $We(t,e){let r=g6,n=Zr(e*e*e,r),i=Zr(n*n*e,r),o=She(t*i).pow_p_5_8,s=Zr(t*n*o,r),a=Zr(e*s*s,r),d=s,u=Zr(s*_he,r),c=a===t,l=a===Zr(-t,r),m=a===Zr(-t*_he,r);return c&&(s=d),(l||m)&&(s=u),sF(s,r)&&(s=Zr(-s,r)),{isValid:c||l,value:s}}var xd=Pb(g6,void 0,!0),b6={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:xd,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:BigInt(8),Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:qm,randomBytes:uf,adjustScalarBytes:Ahe,uvRatio:$We},Ed=dT(b6);function Phe(t,e,r){if(e.length>255)throw new Error("Context is too big");return gy(w2("SigEd25519 no Ed25519 collisions"),new Uint8Array([r?1:0,e.length]),e,t)}var y5t=dT({...b6,domain:Phe}),g5t=dT({...b6,domain:Phe,prehash:qm}),Og=whe({P:g6,a:BigInt(486662),montgomeryBits:255,nByteLength:32,Gu:BigInt(9),powPminus2:t=>{let e=g6,{pow_p_5_8:r,b2:n}=She(t);return Zr(Dn(r,BigInt(3),e)*n,e)},adjustScalarBytes:Ahe,randomBytes:uf});function The(t){let{y:e}=Ed.ExtendedPoint.fromHex(t),r=BigInt(1);return xd.toBytes(xd.create((r+e)*xd.inv(r-e)))}function Ihe(t){let e=b6.hash(t.subarray(0,32));return b6.adjustScalarBytes(e).subarray(0,32)}var NWe=(xd.ORDER+BigInt(3))/BigInt(8),b5t=xd.pow(jU,NWe),v5t=xd.sqrt(xd.neg(xd.ONE)),w5t=(xd.ORDER-BigInt(5))/BigInt(8),_5t=BigInt(486662);var x5t=aF(xd,xd.neg(BigInt(486664)));var E5t=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),S5t=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),A5t=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),P5t=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952");var T5t=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");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())})},jWe=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);iUWe,checkValidProperty:()=>KWe,getJoseSignatureAlgorithmFromPublicKey:()=>qWe,isWebCryptoSupported:()=>LWe,randomBytes:()=>FWe,randomUuid:()=>zWe});h();function UWe(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 KWe(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 qWe(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 LWe(){return!!(globalThis.crypto&&globalThis.crypto.subtle)}function FWe(t){return uf(t)}function zWe(){return Eb.randomUUID()}h();h();h();h();var w6=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;h();var Eh=t=>new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4));function khe(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}var Rhe=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),GWe=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!GWe)throw new Error("Non little-endian hardware is not supported");function uT(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}function lT(t){if(typeof t=="string")t=uT(t);else if(khe(t))t=t.slice();else throw new Error(`expected Uint8Array, got ${typeof t}`);return t}var WWe=t=>Object.prototype.toString.call(t)==="[object Object]"&&t.constructor===Object;function Dhe(t,e){if(e!==void 0&&(typeof e!="object"||!WWe(e)))throw new Error("options must be object or undefined");return Object.assign(t,e)}function $g(t,e){if(!khe(t))throw new Error("Uint8Array expected");if(typeof e=="number"&&t.length!==e)throw new Error(`Uint8Array length ${e} expected`)}function Mhe(t,e){if(t.length!==e.length)return!1;let r=0;for(let n=0;n(Object.assign(e,t),e);function qU(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)}h();function _6(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`wrong positive integer: ${t}`)}function LU(t){if(typeof t!="boolean")throw new Error(`boolean expected, not ${t}`)}function HWe(t){return t!=null&&typeof t=="object"&&(t instanceof Uint8Array||t.constructor.name==="Uint8Array")}function h1(t,...e){if(!HWe(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 FU(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 Bhe(t,e){h1(t);let r=e.outputLen;if(t.lengtht[e++]&255|(t[e++]&255)<<8,GU=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=lT(e),$g(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],m=s[5],p=s[6],g=s[7],b=s[8],S=s[9],A=as(e,r+0),I=as(e,r+2),P=as(e,r+4),$=as(e,r+6),N=as(e,r+8),L=as(e,r+10),F=as(e,r+12),U=as(e,r+14),G=o[0]+(A&8191),q=o[1]+((A>>>13|I<<3)&8191),T=o[2]+((I>>>10|P<<6)&8191),E=o[3]+((P>>>7|$<<9)&8191),k=o[4]+(($>>>4|N<<12)&8191),f=o[5]+(N>>>1&8191),y=o[6]+((N>>>14|L<<2)&8191),w=o[7]+((L>>>11|F<<5)&8191),_=o[8]+((F>>>8|U<<8)&8191),x=o[9]+(U>>>5|i),v=0,D=v+G*a+q*(5*S)+T*(5*b)+E*(5*g)+k*(5*p);v=D>>>13,D&=8191,D+=f*(5*m)+y*(5*l)+w*(5*c)+_*(5*u)+x*(5*d),v+=D>>>13,D&=8191;let K=v+G*d+q*a+T*(5*S)+E*(5*b)+k*(5*g);v=K>>>13,K&=8191,K+=f*(5*p)+y*(5*m)+w*(5*l)+_*(5*c)+x*(5*u),v+=K>>>13,K&=8191;let M=v+G*u+q*d+T*a+E*(5*S)+k*(5*b);v=M>>>13,M&=8191,M+=f*(5*g)+y*(5*p)+w*(5*m)+_*(5*l)+x*(5*c),v+=M>>>13,M&=8191;let j=v+G*c+q*u+T*d+E*a+k*(5*S);v=j>>>13,j&=8191,j+=f*(5*b)+y*(5*g)+w*(5*p)+_*(5*m)+x*(5*l),v+=j>>>13,j&=8191;let J=v+G*l+q*c+T*u+E*d+k*a;v=J>>>13,J&=8191,J+=f*(5*S)+y*(5*b)+w*(5*g)+_*(5*p)+x*(5*m),v+=J>>>13,J&=8191;let Z=v+G*m+q*l+T*c+E*u+k*d;v=Z>>>13,Z&=8191,Z+=f*a+y*(5*S)+w*(5*b)+_*(5*g)+x*(5*p),v+=Z>>>13,Z&=8191;let V=v+G*p+q*m+T*l+E*c+k*u;v=V>>>13,V&=8191,V+=f*d+y*a+w*(5*S)+_*(5*b)+x*(5*g),v+=V>>>13,V&=8191;let H=v+G*g+q*p+T*m+E*l+k*c;v=H>>>13,H&=8191,H+=f*u+y*d+w*a+_*(5*S)+x*(5*b),v+=H>>>13,H&=8191;let X=v+G*b+q*g+T*p+E*m+k*l;v=X>>>13,X&=8191,X+=f*c+y*u+w*d+_*a+x*(5*S),v+=X>>>13,X&=8191;let ee=v+G*S+q*b+T*g+E*p+k*m;v=ee>>>13,ee&=8191,ee+=f*l+y*c+w*u+_*d+x*a,v+=ee>>>13,ee&=8191,v=(v<<2)+v|0,v=v+D|0,D=v&8191,v=v>>>13,K+=v,o[0]=D,o[1]=K,o[2]=M,o[3]=j,o[4]=J,o[5]=Z,o[6]=V,o[7]=H,o[8]=X,o[9]=ee}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){FU(this);let{buffer:r,blockLen:n}=this;e=lT(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 YWe(t){let e=(n,i)=>t(i).update(lT(n)).digest(),r=t(new Uint8Array(32));return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=n=>t(n),e}var Ohe=YWe(t=>new GU(t));h();var ZWe=uT("expand 16-byte k"),XWe=uT("expand 32-byte k"),QWe=Eh(ZWe),eHe=Eh(XWe);function Xe(t,e){return t<>>32-e}function WU(t){return t.byteOffset%4===0}var mT=64,tHe=16,Nhe=2**32-1,$he=new Uint32Array;function rHe(t,e,r,n,i,o,s,a){let d=i.length,u=new Uint8Array(mT),c=Eh(u),l=WU(i)&&WU(o),m=l?Eh(i):$he,p=l?Eh(o):$he;for(let g=0;g=Nhe)throw new Error("arx: counter overflow");let b=Math.min(mT,d-g);if(l&&b===mT){let S=g/4;if(g%4!==0)throw new Error("arx: invalid block position");for(let A=0,I;A{h1(a),h1(d),h1(u);let m=u.length;if(c||(c=new Uint8Array(m)),h1(c),_6(l),l<0||l>=Nhe)throw new Error("arx: counter overflow");if(c.length0;)p.pop().fill(0);return c}}function Khe(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],m=e[2],p=e[3],g=e[4],b=e[5],S=e[6],A=e[7],I=i,P=r[0],$=r[1],N=r[2],L=s,F=a,U=d,G=u,q=c,T=l,E=m,k=p,f=g,y=b,w=S,_=A,x=I,v=P,D=$,K=N;for(let j=0;j{t.update(e);let r=e.length%16;r&&t.update(oHe.subarray(r))},sHe=new Uint8Array(32);function Uhe(t,e,r,n,i){let o=t(e,r,sHe),s=Ohe.create(o);i&&jhe(s,i),jhe(s,n);let a=new Uint8Array(16),d=Rhe(a);qU(d,0,BigInt(i?i.length:0),!0),qU(d,8,BigInt(n.length),!0),s.update(a);let u=s.digest();return o.fill(0),u}var Lhe=t=>(e,r,n)=>($g(e,32),$g(r),{encrypt:(o,s)=>{let a=o.length,d=a+16;s?$g(s,d):s=new Uint8Array(d),t(e,r,o,s,1);let u=Uhe(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?$g(s,d):s=new Uint8Array(d);let u=o.subarray(0,-16),c=o.subarray(-16),l=Uhe(t,e,r,u,n);if(!Mhe(c,l))throw new Error("invalid tag");return t(e,r,u,s,1),s}}),Z8t=KU({blockSize:64,nonceLength:12,tagLength:16},Lhe(iHe)),aHe=KU({blockSize:64,nonceLength:24,tagLength:16},Lhe(qhe));h();h();function xc(t){if(typeof t=="string"&&t.length!==0)return t.split("#").pop()}function JU({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(VU))!==null&&r!==void 0?r:[]),Object.keys(ag).forEach(i=>{var o,s;n.push(...(s=(o=t[i])===null||o===void 0?void 0:o.filter(VU))!==null&&s!==void 0?s:[])}),n}function Fhe({didDocument:t}){let r=JU({didDocument:t}).map(n=>n.type);return[...new Set(r)]}function zhe({didDocument:t,methodId:e}){let r=[];return Object.keys(ag).forEach(n=>{if(Array.isArray(t[n])){let i=t[n],o=xc(e);i.some(a=>{let d=xc(a)===o,u=VU(a)&&xc(a.id)===o;return d||u})&&r.push(n)}}),r}function VU(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 YU({keyBytes:t,multicodecCode:e,multicodecName:r}){let n=mi.addPrefix({code:e,data:t,name:r}),i=de.uint8Array(n).toBase58Btc();return de.base58Btc(i).toMultibase()}function ZU({multibaseKeyId:t}){try{let e=de.multibase(t).toBase58Btc(),r=de.base58Btc(e).toUint8Array(),{code:n,data:i,name:o}=mi.removePrefix({prefixedData:r});return{keyBytes:i,multicodecCode:n,multicodecName:o}}catch{throw new ot(et.InvalidDid,`Invalid multibase identifier: ${t}`)}}var E6=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())})},Ua=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 E6(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 E6(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 xc(d.id)===((u=xc(e?.methodId))!==null&&u!==void 0?u:xc((c=this.document.assertionMethod)===null||c===void 0?void 0:c[0]))});if(!(n&&n.publicKeyJwk))throw new ot(et.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:Ri.getJoseSignatureAlgorithmFromPublicKey(o),keyId:n.id,sign(d){return E6(this,arguments,void 0,function*({data:u}){return yield s.sign({data:u,keyUri:i})})},verify(d){return E6(this,arguments,void 0,function*({data:u,signature:c}){return yield s.verify({data:u,key:o,signature:c})})}}})}static import(e){return E6(this,arguments,void 0,function*({portableDid:r,keyManager:n=new Sr}){var i;let o=JU({didDocument:r.document});if(o.length===0)throw new ot(et.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})})}};h();h();h();h();h();var XU="0123456789abcdef",Whe=[],Ghe=[];for(let t=0;t<256;t++)Whe[t]=XU[t>>4&15]+XU[t&15],t<16&&(t<10?Ghe[48+t]=t:Ghe[87+t]=t);var QU=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};h();var Vhe="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",dHe=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(S6=0;S6e?new TextDecoder(e).decode(t):uHe.decode(t),lHe=new TextEncoder,Pd=t=>lHe.encode(t);var Jhe=typeof window<"u"?window:self,Yhe=Jhe.crypto||Jhe.msCrypto||{},rAt=Yhe.subtle||Yhe.webkitSubtle;h();function p1(t){let e=t<0?1:0;return t=Math.abs(Number(t||1)),Math.floor(Math.log10(t))+1+e}function yT(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 Xr(t,e,r){let n=[],i=null;return Xr._encode(n,t),i=Hhe(n),Xr.bytes=i.length,ArrayBuffer.isView(e)?(e.set(i,r),e):i}Xr.bytes=-1;Xr._floatConversionDetected=!1;Xr._encode=function(t,e){if(e!=null)switch(yT(e)){case"object":Xr.dict(t,e);break;case"map":Xr.dictMap(t,e);break;case"array":Xr.list(t,e);break;case"set":Xr.listSet(t,e);break;case"string":Xr.string(t,e);break;case"number":Xr.number(t,e);break;case"boolean":Xr.number(t,e);break;case"arraybufferview":Xr.buffer(t,new Uint8Array(e.buffer,e.byteOffset,e.byteLength));break;case"arraybuffer":Xr.buffer(t,new Uint8Array(e));break}};var gT=new Uint8Array([101]),Zhe=new Uint8Array([100]),Xhe=new Uint8Array([108]);Xr.buffer=function(t,e){t.push(Pd(e.length+":"),e)};Xr.string=function(t,e){t.push(Pd(Pd(e).byteLength+":"+e))};Xr.number=function(t,e){if(Number.isInteger(e))return t.push(Pd("i"+BigInt(e)+"e"));let r=2147483648,n=e/r<<0,i=e%r<<0,o=n*r+i;t.push(Pd("i"+o+"e")),o!==e&&!Xr._floatConversionDetected&&(Xr._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())};Xr.dict=function(t,e){t.push(Zhe);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 Tt(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),Tt.position=0,Tt.encoding=n||null,Tt.data=ArrayBuffer.isView(t)?new Uint8Array(t.slice(e,r)):Pd(t),Tt.bytes=Tt.data.length,Tt.next())}Tt.bytes=0;Tt.position=0;Tt.data=null;Tt.encoding=null;Tt.next=function(){switch(Tt.data[Tt.position]){case pHe:return Tt.dictionary();case mHe:return Tt.list();case fHe:return Tt.integer();default:return Tt.buffer()}};Tt.find=function(t){let e=Tt.position,r=Tt.data.length,n=Tt.data;for(;exHe.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&&EHe.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 g1(t,e,r){let n=t.length;r==null&&(r=0),e===void 0&&(e=new Uint8Array(sK(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 g1.bytes=i-r,e}g1.bytes=0;function b1(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 b1.bytes=r-e,n}b1.bytes=0;var Fm=t=>t instanceof Uint8Array;function Ah(t){return typeof t=="string"?sK(t):t.byteLength}function vT(t){return t instanceof Uint8Array?t:Array.isArray(t)?new Uint8Array(t):g1(t)}function wT(t,e,r){if(typeof e!="string")throw new Error("unknown input type");return g1(e,t,r),g1.bytes}var P6={},dpe=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}`;dpe[s]=a,P6[a]=s,P6[`${r}${i}`]=s,P6[`${e}${o}`]=s,P6[`${r}${o}`]=s}}function upe(t,e,r){let n="";for(let i=e;i>>1}function lpe(t,e,r,n){let i=0;for(;rt[e]*DHe+t[e+1]*MHe+t[e+2]*BHe+t[e+3],ir=(t,e)=>t[e]<<8|t[e+1],Hl=(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),mt=(t,e,r)=>(t[r]=e>>8,t[r+1]=e&255,r+2);function Ka(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:CHe(t,e,r,n,i)}function CHe(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 nt=En({encode(t,e,r){e||(e=new Uint8Array(nt.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=ir(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(b1(t,e,e+a)),e+=a,o+=s?0:a}}return nt.decode.bytes=o,r.length===0?".":r.join(".")},encodingLength(t){return t==="."||t===".."?1:Ah(t.replace(/^\.|\.$/gm,""))+2}}),to=En({encode(t,e,r){e||(e=new Uint8Array(to.encodingLength(t))),r||(r=0);let n=wT(e,t,r+1);return e[r]=n,to.encode.bytes=n+1,e},decode(t,e){e||(e=0);let r=t[e],n=b1(t,e+1,e+1+r);return to.decode.bytes=r+1,n},encodingLength(t){return Ah(t)+1}}),v1=En({bytes:12,encode(t,e,r){e||(e=new Uint8Array(v1.encodingLength(t))),r||(r=0);let n=(t.flags||0)&32767,i=t.type==="response"?fpe:$He;return mt(e,t.id||0,r),mt(e,n|i,r+2),mt(e,t.questions.length,r+4),mt(e,t.answers.length,r+6),mt(e,t.authorities.length,r+8),mt(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=ir(t,e+2);return{id:ir(t,e),type:r&fpe?"response":"query",flags:r&32767,flag_qr:(r>>15&1)===1,opcode:ape(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:spe(r&15),questions:new Array(ir(t,e+4)),answers:new Array(ir(t,e+6)),authorities:new Array(ir(t,e+8)),additionals:new Array(ir(t,e+10))}},encodingLength(){return 12}}),xT=En({encode(t,e,r){e||(e=new Uint8Array(xT.encodingLength(t))),r||(r=0);let n=t.length;return mt(e,n,r),Ka(t,e,r+2,0,n),xT.encode.bytes=n+2,e},decode(t,e){e||(e=0);let r=ir(t,e),n=t.slice(e+2,e+2+r);return xT.decode.bytes=r+2,n},encodingLength(t){return t.length+2}}),ET=En({encode(t,e,r){return e||(e=new Uint8Array(ET.encodingLength(t))),r||(r=0),nt.encode(t,e,r+2),mt(e,nt.encode.bytes,r),ET.encode.bytes=nt.encode.bytes+2,e},decode(t,e){e||(e=0);let r=ir(t,e),n=nt.decode(t,e+2);return ET.decode.bytes=r+2,n},encodingLength(t){return nt.encodingLength(t)+2}}),ST=En({encode(t,e,r){e||(e=new Uint8Array(ST.encodingLength(t))),r||(r=0);let n=r;return r+=2,nt.encode(t.mname,e,r),r+=nt.encode.bytes,nt.encode(t.rname,e,r),r+=nt.encode.bytes,Hl(e,t.serial||0,r),r+=4,Hl(e,t.refresh||0,r),r+=4,Hl(e,t.retry||0,r),r+=4,Hl(e,t.expire||0,r),r+=4,Hl(e,t.minimum||0,r),r+=4,mt(e,r-n-2,n),ST.encode.bytes=r-n,e},decode(t,e){e||(e=0);let r=e,n={};return e+=2,n.mname=nt.decode(t,e),e+=nt.decode.bytes,n.rname=nt.decode(t,e),e+=nt.decode.bytes,n.serial=Wl(t,e),e+=4,n.refresh=Wl(t,e),e+=4,n.retry=Wl(t,e),e+=4,n.expire=Wl(t,e),e+=4,n.minimum=Wl(t,e),e+=4,ST.decode.bytes=e-r,n},encodingLength(t){return 22+nt.encodingLength(t.mname)+nt.encodingLength(t.rname)}}),AT=En({encode(t,e,r){Array.isArray(t)||(t=[t]);for(let i=0;i0;){let o=t[e++];if(--n,nnew Uint8Array(t),Ph=En({encode(t,e,r){e||(e=new Uint8Array(Ph.encodingLength(t))),r||(r=0);let n=r,i=oK(t.code);if(mt(e,i,r),r+=2,t.data)mt(e,t.data.length,r),r+=2,Ka(t.data,e,r),r+=t.data.length;else switch(i){case 8:{let o=t.sourcePrefixLength||0,s=t.family||npe(t.ip,hpe),a=ipe(t.ip,hpe),d=Math.ceil(o/8);mt(e,d+4,r),r+=2,mt(e,s,r),r+=2,e[r++]=o,e[r++]=t.scopePrefixLength||0,Ka(a,e,r,0,d),r+=d}break;case 11:t.timeout?(mt(e,2,r),r+=2,mt(e,t.timeout,r),r+=2):(mt(e,0,r),r+=2);break;case 12:{let o=t.length||0;mt(e,o,r),r+=2,e.fill(0,r,r+o),r+=o}break;case 14:{let o=t.tags.length*2;mt(e,o,r),r+=2;for(let s of t.tags)mt(e,s,r),r+=2}break;default:throw new Error(`Unknown roption code: ${t.code}`)}return Ph.encode.bytes=r-n,e},decode(t,e){e||(e=0);let r={};r.code=ir(t,e),r.type=cpe(r.code),e+=2;let n=ir(t,e);switch(e+=2,r.data=t.slice(e,e+n),r.code){case 8:r.family=ir(t,e),e+=2,r.sourcePrefixLength=t[e++],r.scopePrefixLength=t[e++];{let i=new Uint8Array(r.family===1?4:16);Ka(t,i,0,e,e+n-4),r.ip=ope(i)}break;case 11:n>0&&(r.timeout=ir(t,e),e+=2);break;case 14:r.tags=[];for(let i=0;i0;)n[o++]=Ph.decode(t,e),e+=Ph.decode.bytes,i-=Ph.decode.bytes;return Gm.decode.bytes=e-r,n},encodingLength(t){return 2+_1(t||[],Ph)}}),Vl=En({encode(t,e,r){e||(e=new Uint8Array(Vl.encodingLength(t))),r||(r=0);let n=r,i=t.key;if(!Fm(i))throw new Error("Key must be a Buffer");return r+=2,mt(e,t.flags,r),r+=2,e[r]=Vl.PROTOCOL_DNSSEC,r+=1,e[r]=t.algorithm,r+=1,Ka(i,e,r,0,i.length),r+=i.length,Vl.encode.bytes=r-n,mt(e,Vl.encode.bytes-2,n),e},decode(t,e){e||(e=0);let r=e,n={},i=ir(t,e);if(e+=2,n.flags=ir(t,e),e+=2,t[e]!==Vl.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,Vl.decode.bytes=e-r,n},encodingLength(t){return 6+Ah(t.key)}});Vl.PROTOCOL_DNSSEC=3;Vl.ZONE_KEY=128;Vl.SECURE_ENTRYPOINT=32768;var T6=En({encode(t,e,r){e||(e=new Uint8Array(T6.encodingLength(t))),r||(r=0);let n=r,i=t.signature;if(!Fm(i))throw new Error("Signature must be a Buffer");return r+=2,mt(e,y1(t.typeCovered),r),r+=2,e[r]=t.algorithm,r+=1,e[r]=t.labels,r+=1,Hl(e,t.originalTTL,r),r+=4,Hl(e,t.expiration,r),r+=4,Hl(e,t.inception,r),r+=4,mt(e,t.keyTag,r),r+=2,nt.encode(t.signersName,e,r),r+=nt.encode.bytes,Ka(i,e,r,0,i.length),r+=i.length,T6.encode.bytes=r-n,mt(e,T6.encode.bytes-2,n),e},decode(t,e){e||(e=0);let r=e,n={},i=ir(t,e);return e+=2,n.typeCovered=A6(ir(t,e)),e+=2,n.algorithm=t[e],e+=1,n.labels=t[e],e+=1,n.originalTTL=Wl(t,e),e+=4,n.expiration=Wl(t,e),e+=4,n.inception=Wl(t,e),e+=4,n.keyTag=ir(t,e),e+=2,n.signersName=nt.decode(t,e),e+=nt.decode.bytes,n.signature=t.slice(e,r+i+2),e+=n.signature.length,T6.decode.bytes=e-r,n},encodingLength(t){return 20+nt.encodingLength(t.signersName)+Ah(t.signature)}}),I6=En({encode(t,e,r){e||(e=new Uint8Array(I6.encodingLength(t))),r||(r=0);let n=r;return r+=2,nt.encode(t.mbox||".",e,r),r+=nt.encode.bytes,nt.encode(t.txt||".",e,r),r+=nt.encode.bytes,I6.encode.bytes=r-n,mt(e,I6.encode.bytes-2,n),e},decode(t,e){e||(e=0);let r=e,n={};return e+=2,n.mbox=nt.decode(t,e)||".",e+=nt.decode.bytes,n.txt=nt.decode(t,e)||".",e+=nt.decode.bytes,I6.decode.bytes=e-r,n},encodingLength(t){return 2+nt.encodingLength(t.mbox||".")+nt.encodingLength(t.txt||".")}}),Ec=En({encode(t,e,r){e||(e=new Uint8Array(Ec.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=Gm.decode(t,e+8),e+=8+Gm.decode.bytes;else{let i=ir(t,e+2);r.ttl=Wl(t,e+4),r.class=nK(i&NHe),r.flush=!!(i&dK);let o=cK(r.type);r.data=o.decode(t,e+8),e+=8+o.decode.bytes}return Td.decode.bytes=e-n,r},encodingLength(t){let e=t.data!==null&&t.data!==void 0?t.data:t.options;return nt.encodingLength(t.name)+8+cK(t.type).encodingLength(e)}}),E1=En({encode(t,e,r){e||(e=new Uint8Array(E1.encodingLength(t))),r||(r=0);let n=r;return nt.encode(t.name,e,r),r+=nt.encode.bytes,mt(e,y1(t.type),r),r+=2,mt(e,iK(t.class===void 0?"IN":t.class),r),r+=2,E1.encode.bytes=r-n,t},decode(t,e){e||(e=0);let r=e,n={};return n.name=nt.decode(t,e),e+=nt.decode.bytes,n.type=A6(ir(t,e)),e+=2,n.class=nK(ir(t,e)),e+=2,!!(n.class&ppe)&&(n.class&=jHe),E1.decode.bytes=e-r,n},encodingLength(t){return nt.encodingLength(t.name)+4}});var CT=1024;var cs={encode:function(t,e,r){let n=!e;n&&(e=new Uint8Array(UHe(t))),r||(r=0);let i=r;return t.questions||(t.questions=[]),t.answers||(t.answers=[]),t.authorities||(t.authorities=[]),t.additionals||(t.additionals=[]),v1.encode(t,e,r),r+=v1.encode.bytes,r=M6(t.questions,E1,e,r),r=M6(t.answers,Td,e,r),r=M6(t.authorities,Td,e,r),r=M6(t.additionals,Td,e,r),cs.encode.bytes=r-i,n&&Ng.bytes!==e.length?e.slice(0,Ng.bytes):e},decode:function(t,e){e||(e=0);let r=e,n=v1.decode(t,e);return e+=v1.decode.bytes,e=_T(n.questions,E1,t,e),e=_T(n.answers,Td,t,e),e=_T(n.authorities,Td,t,e),e=_T(n.additionals,Td,t,e),cs.decode.bytes=e-r,n},encodingLength:function(t){return v1.encodingLength(t)+_1(t.questions||[],E1)+_1(t.answers||[],Td)+_1(t.authorities||[],Td)+_1(t.additionals||[],Td)}};cs.encode.bytes=0;cs.decode.bytes=0;function DT(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 MT={encode:function(t,e,r){return e=cs.encode(DT(t,"query"),e,r),MT.encode.bytes=cs.encode.bytes,e},decode:function(t,e){let r=cs.decode(t,e);return MT.decode.bytes=cs.decode.bytes,r.questions&&(r.question=r.questions[0],delete r.questions),r},encodingLength:function(t){return cs.encodingLength(DT(t,"query"))}};MT.encode.bytes=0;MT.decode.bytes=0;var BT={encode:function(t,e,r){return e=cs.encode(DT(t,"response"),e,r),BT.encode.bytes=cs.encode.bytes,e},decode:function(t,e){let r=cs.decode(t,e);return BT.decode.bytes=cs.decode.bytes,r.questions&&(r.question=r.questions[0],delete r.questions),r},encodingLength:function(t){return cs.encodingLength(DT(t,"response"))}};BT.encode.bytes=0;BT.decode.bytes=0;var Ng=cs.encode,S1=cs.decode,UHe=cs.encodingLength;function ype(t){let e=Ng(t),r=new Uint8Array(2+e.byteLength);return mt(r,e.byteLength),Ka(e,r,2,0,e.length),ype.bytes=r.byteLength,r}ype.bytes=0;function gpe(t){let e=ir(t,0);if(t.byteLength!(N.algorithm in xpe)))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(N=>"id"in N).map(N=>N.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(N=>!N.id||!N.type||!N.serviceEndpoint))throw new Error("One or more services are missing required properties");let b=yield e.generateKey({algorithm:"Ed25519"}),S=yield e.getPublicKey({keyUri:b}),A=yield Ao.identityKeyToIdentifier({identityKey:S}),I=Object.assign(Object.assign({id:A},r.alsoKnownAs&&{alsoKnownAs:r.alsoKnownAs}),r.controllers&&{controller:r.controllers}),P=[...(s=r.verificationMethods)!==null&&s!==void 0?s:[]];P?.some(N=>{var L;return((L=N.id)===null||L===void 0?void 0:L.split("#").pop())==="0"})||P.unshift({algorithm:"Ed25519",id:"0",purposes:["authentication","assertionMethod","capabilityDelegation","capabilityInvocation"]});for(let N of P){let L=N.id&&N.id.split("#").pop()==="0"?b:yield e.generateKey({algorithm:N.algorithm}),F=yield e.getPublicKey({keyUri:L}),U=(d=(a=N.id)!==null&&a!==void 0?a:F.kid)!==null&&d!==void 0?d:yield rt({jwk:F});U=`${A}#${xc(U)}`,(u=I.verificationMethod)!==null&&u!==void 0||(I.verificationMethod=[]),I.verificationMethod.push({id:U,type:"JsonWebKey",controller:(c=N.controller)!==null&&c!==void 0?c:A,publicKeyJwk:F});for(let G of(l=N.purposes)!==null&&l!==void 0?l:[])I[G]||(I[G]=[]),I[G].push(U)}(m=r.services)===null||m===void 0||m.forEach(N=>{var L;(L=I.service)!==null&&L!==void 0||(I.service=[]),N.id=`${A}#${N.id.split("#").pop()}`,I.service.push(N)});let $=new Ua({uri:A,document:I,metadata:Object.assign({published:!1},r.types&&{types:r.types}),keyManager:e});if(!((p=r.publish)!==null&&p!==void 0)||p){let N=yield t.publish({did:$,gatewayUri:r.gatewayUri});$.metadata=N.didDocumentMetadata}return $})}static import(e){return Po(this,arguments,void 0,function*({portableDid:r,keyManager:n=new Sr}){var i;let o=br.parse(r.uri);if(o?.method!==t.methodName)throw new ot(et.MethodNotSupported,"Method not supported");let s=yield Ua.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 ot(et.InvalidDidDocument,"DID document must contain an Identity Key");return s})}static getSigningMethod(e){return Po(this,arguments,void 0,function*({didDocument:r,methodId:n="#0"}){var i;let o=br.parse(r.id);if(o&&o.method!==this.methodName)throw new ot(et.MethodNotSupported,`Method not supported: ${o.method}`);let s=(i=r.verificationMethod)===null||i===void 0?void 0:i.find(a=>{var d,u;return xc(a.id)===((d=xc(n))!==null&&d!==void 0?d:xc((u=r.assertionMethod)===null||u===void 0?void 0:u[0]))});if(!(s&&s.publicKeyJwk))throw new ot(et.InternalError,"A verification method intended for signing could not be determined from the DID Document");return s})}static publish(e){return Po(this,arguments,void 0,function*({did:r,gatewayUri:n=wpe}){return yield $T.put({did:r,gatewayUri:n})})}static resolve(e){return Po(this,arguments,void 0,function*(r,n={}){var i;let o=(i=n?.gatewayUri)!==null&&i!==void 0?i:wpe;try{yield Ao.identifierToIdentityKey({didUri:r});let{didDocument:s,didDocumentMetadata:a}=yield $T.get({didUri:r,gatewayUri:o});return Object.assign(Object.assign({},Xn),{didDocument:s,didDocumentMetadata:a})}catch(s){if(!(s instanceof ot))throw new Error(s);return Object.assign(Object.assign({},Xn),{didResolutionMetadata:Object.assign({error:s.code},s.message&&{errorMessage:s.message})})}})}};jg.methodName="dht";var $T=class t{static get(e){return Po(this,arguments,void 0,function*({didUri:r,gatewayUri:n}){let i=Ao.identifierToIdentityKeyBytes({didUri:r}),o=yield t.pkarrGet({gatewayUri:n,publicKeyBytes:i}),s=yield Ao.parseBep44GetMessage({bep44Message:o}),a=yield t.fromDnsPacket({didUri:r,dnsPacket:s});return a.didDocumentMetadata.versionId=o.seq.toString(),a})}static put(e){return Po(this,arguments,void 0,function*({did:r,gatewayUri:n}){let i=yield t.toDnsPacket({didDocument:r.document,didMetadata:r.metadata,authoritativeGatewayUris:[n]}),o=yield Ao.createBep44PutMessage({dnsPacket:i,publicKeyBytes:Ao.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 Po(this,arguments,void 0,function*({gatewayUri:r,publicKeyBytes:n}){let i=de.uint8Array(n).toBase32Z(),o=new URL(i,r).href,s;try{if(s=yield fetch(o,{method:"GET"}),!s.ok)throw new ot(et.NotFound,`Pkarr record not found for: ${i}`)}catch(u){throw u instanceof ot?u:new ot(et.InternalError,`Failed to fetch Pkarr record: ${u.message}`)}let a=yield s.arrayBuffer();if(!a)throw new ot(et.NotFound,`Pkarr record not found for: ${i}`);if(a.byteLength<72)throw new ot(et.InvalidDidDocumentLength,`Pkarr response must be at least 72 bytes but got: ${a.byteLength}`);if(a.byteLength>1072)throw new ot(et.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 Po(this,arguments,void 0,function*({gatewayUri:r,bep44Message:n}){let i=de.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 ot(et.InternalError,`Failed to put Pkarr record for identifier ${i}: ${d.message}`)}return a.ok})}static fromDnsPacket(e){return Po(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 m=Ao.parseTxtDataToString(c.data);a.alsoKnownAs=m.split(ua);break}case l.startsWith("cnt"):{let m=Ao.parseTxtDataToString(c.data);a.controller=m.includes(ua)?m.split(ua):m;break}case l.startsWith("k"):{let{id:m,t:p,k:g,c:b,a:S}=Ao.parseTxtDataToObject(c.data),A=de.base64Url(g).toUint8Array(),I=la[Number(p)],P=yield Ao.keyConverter(I).bytesToPublicKey({publicKeyBytes:A});P.alg=S||_pe[Number(p)];let $=l==="k0"?"0":m!==void 0?m:yield rt({jwk:P});(o=a.verificationMethod)!==null&&o!==void 0||(a.verificationMethod=[]);let N=`${r}#${$}`;a.verificationMethod.push({id:N,type:"JsonWebKey",controller:b??r,publicKeyJwk:P}),u.set(l,N);break}case l.startsWith("s"):{let m=Ao.parseTxtDataToObject(c.data),{id:p,t:g,se:b}=m,S=vpe(m,["id","t","se"]),A=b.includes(ua)?b.split(ua):[b],I=Object.fromEntries(Object.entries(S).map(([P,$])=>[P,$.includes(ua)?$.split(ua):$]));(s=a.service)!==null&&s!==void 0||(a.service=[]),a.service.push(Object.assign(Object.assign({},I),{id:`${r}#${p}`,type:g,serviceEndpoint:A}));break}case l.startsWith("typ"):{let{id:m}=Ao.parseTxtDataToObject(c.data);d.types=m.split(ua).map(p=>Number(p));break}case l.startsWith("did"):{let m=I=>I.split(ua).map(P=>u.get(P)).filter(P=>typeof P=="string"),{auth:p,asm:g,del:b,inv:S,agm:A}=Ao.parseTxtDataToObject(c.data);p&&(a.authentication=m(p)),g&&(a.assertionMethod=m(g)),b&&(a.capabilityDelegation=m(b)),S&&(a.capabilityInvocation=m(S)),A&&(a.keyAgreement=m(A));break}}}return{didDocument:a,didDocumentMetadata:d,didResolutionMetadata:{}}})}static toDnsPacket(e){return Po(this,arguments,void 0,function*({didDocument:r,didMetadata:n,authoritativeGatewayUris:i,previousDidProof:o}){var s,a,d,u,c;let l=[],m=[],p=new Map,g=[],b=[];if(o!==void 0){let{signature:I,previousDid:P}=o;yield Ao.validatePreviousDidProof({newDid:r.id,previousDidProof:o}),l.push({type:"TXT",name:"_prv._did.",ttl:Wm,data:`id=${P};s=${I}`})}if(r.alsoKnownAs&&l.push({type:"TXT",name:"_aka._did.",ttl:Wm,data:r.alsoKnownAs.join(ua)}),r.controller){let I=Array.isArray(r.controller)?r.controller.join(ua):r.controller;l.push({type:"TXT",name:"_cnt._did.",ttl:Wm,data:I})}for(let[I,P]of(a=(s=r.verificationMethod)===null||s===void 0?void 0:s.entries())!==null&&a!==void 0?a:[]){let $=`k${I}`;b.push($);let N=P.id.split("#").pop();p.set(N,$);let L=P.publicKeyJwk;if(!(L?.crv&&L.crv in xpe))throw new ot(et.InvalidPublicKeyType,`Verification method '${P.id}' contains an unsupported key type: ${(d=L?.crv)!==null&&d!==void 0?d:"undefined"}`);let F=la[L.crv],U=yield Ao.keyConverter(L.crv).publicKeyToBytes({publicKey:L}),G=de.uint8Array(U).toBase64Url(),q=[`t=${F}`,`k=${G}`];N!=="0"&&(yield rt({jwk:L}))!==N&&q.unshift(`id=${N}`),L.alg!==_pe[F]&&q.push(`a=${L.alg}`),P.controller!==r.id&&q.push(`c=${P.controller}`),l.push({type:"TXT",name:`_${$}._did.`,ttl:Wm,data:q.join(OT)})}(u=r.service)===null||u===void 0||u.forEach((I,P)=>{let $=`s${P}`;g.push($);let{id:N,type:L,serviceEndpoint:F}=I,U=vpe(I,["id","type","serviceEndpoint"]);N=xc(N),F=Array.isArray(F)?F.join(","):F;let q=Object.entries(Object.assign({id:N,t:L,se:F},U)).map(([E,k])=>`${E}=${k}`).join(OT),T=Ao.chunkDataIfNeeded(q);l.push({type:"TXT",name:`_${$}._did.`,ttl:Wm,data:T})});let S=[`v=${KHe}`];if(b.length&&S.push(`vm=${b.join(ua)}`),Object.keys(ag).forEach(I=>{var P;let $=(P=r[I])===null||P===void 0?void 0:P.map(N=>p.get(N.split("#").pop()));if($){let N=fK[I];S.push(`${N}=${$.join(ua)}`)}}),g.length&&S.push(`svc=${g.join(ua)}`),!((c=n.types)===null||c===void 0)&&c.length){let P=n.types.map($=>typeof $=="string"?lK[$]:$);l.push({type:"TXT",name:"_typ._did.",ttl:Wm,data:`id=${P.join(ua)}`})}l.push({type:"TXT",name:"_did."+t.getUniqueDidSuffix(r.id)+".",ttl:Wm,data:S.join(OT)});for(let I of i||[])m.push({type:"NS",name:"_did."+t.getUniqueDidSuffix(r.id)+".",ttl:Wm,data:I+"."});return{id:0,type:"response",flags:CT,answers:[...l,...m]}})}static getUniqueDidSuffix(e){return e.split(":")[2]}},Ao=class t{static createBep44PutMessage(e){return Po(this,arguments,void 0,function*({dnsPacket:r,publicKeyBytes:n,signer:i}){let o=Math.ceil(Date.now()/1e3),s=Ng(r),a=m1.encode({seq:o,v:s}).subarray(1,-1);if(a.length>1e3)throw new ot(et.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 Po(this,arguments,void 0,function*({didUri:r}){let n=t.identifierToIdentityKeyBytes({didUri:r});return yield er.bytesToPublicKey({publicKeyBytes:n})})}static identifierToIdentityKeyBytes({didUri:e}){let r=br.parse(e);if(!r)throw new ot(et.InvalidDid,`Invalid DID URI: ${e}`);if(r.method!==jg.methodName)throw new ot(et.MethodNotSupported,`Method not supported: ${r.method}`);let n;try{n=de.base32Z(r.id).toUint8Array()}catch{throw new ot(et.InvalidPublicKey,"Failed to decode method-specific identifier")}if(n.length!==32)throw new ot(et.InvalidPublicKeyLength,`Invalid public key length: ${n.length}`);return n}static identityKeyToIdentifier(e){return Po(this,arguments,void 0,function*({identityKey:r}){let n=yield er.publicKeyToBytes({publicKey:r}),i=de.uint8Array(n).toBase32Z();return`did:${jg.methodName}:${i}`})}static keyConverter(e){let n={Ed25519:er,"P-256":{publicKeyToBytes:i=>Po(this,[i],void 0,function*({publicKey:o}){let s=yield Br.publicKeyToBytes({publicKey:o});return yield Br.compressPublicKey({publicKeyBytes:s})}),bytesToPublicKey:Br.bytesToPublicKey,privateKeyToBytes:Br.privateKeyToBytes,bytesToPrivateKey:Br.bytesToPrivateKey},secp256k1:{publicKeyToBytes:i=>Po(this,[i],void 0,function*({publicKey:o}){let s=yield Er.publicKeyToBytes({publicKey:o});return yield Er.compressPublicKey({publicKeyBytes:s})}),bytesToPublicKey:Er.bytesToPublicKey,privateKeyToBytes:Er.privateKeyToBytes,bytesToPrivateKey:Er.bytesToPrivateKey},X25519:Gl}[e];if(!n)throw new ot(et.InvalidPublicKeyType,`Unsupported curve: ${e}`);return n}static parseBep44GetMessage(e){return Po(this,arguments,void 0,function*({bep44Message:r}){let n=yield er.bytesToPublicKey({publicKeyBytes:r.k}),i=m1.encode({seq:r.seq,v:r.v}).subarray(1,-1);if(!(yield er.verify({key:n,signature:r.sig,data:i})))throw new ot(et.InvalidSignature,"Invalid signature for DHT BEP44 message");return S1(r.v)})}static parseTxtDataToObject(e){return this.parseTxtDataToString(e).split(OT).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 de.uint8Array(e).toString();if(Array.isArray(e))return e.map(r=>this.parseTxtDataToString(r)).join("");throw new ot(et.InternalError,"Pkarr returned DNS TXT record with invalid data type")}static validatePreviousDidProof(e){return Po(this,arguments,void 0,function*({newDid:r,previousDidProof:n}){let i=yield t.identifierToIdentityKey({didUri:n.previousDid}),o=t.identifierToIdentityKeyBytes({didUri:r}),s=de.base64Url(n.signature).toUint8Array();if(!(yield er.verify({key:i,data:o,signature:s})))throw new ot(et.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 yn(Cn.IdTooLong,`Key ID length ${e.length} exceed max allowed length of 50.`);if(!qa.isBase64UrlString(e))throw new yn(Cn.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 yn(Cn.PublicKeyPurposeDuplicated,`Public key purpose '${n}' already specified.`);r.add(n)}}};h();var B6=class{};B6.hashAlgorithmInMultihashCode=18;B6.maxCanonicalizedDeltaSizeInBytes=1e3;var fa=B6;h();var Ape=Ut(Spe(),1);var Iu=class t{static canonicalizeAsBytes(e){let r=t.removeAllUndefinedProperties(e),n=Ape.default(r);return qa.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}};h();var C6=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())})},To=class t{static hash(e,r){return C6(this,void 0,void 0,function*(){let n;switch(r){case 18:n=(yield P2.digest(e)).bytes;break;default:throw new yn(Cn.MultihashUnsupportedHashAlgorithm,`Hash algorithm defined in multihash code ${r} is not supported.`)}return n})}static hashAsNonMultihashBytes(e,r){return C6(this,void 0,void 0,function*(){let n;switch(r){case 18:n=yield P2.encode(e);break;default:throw new yn(Cn.MultihashUnsupportedHashAlgorithm,`Hash algorithm defined in multihash code ${r} is not supported.`)}return n})}static canonicalizeThenHashThenEncode(e,r){return C6(this,void 0,void 0,function*(){let n=Iu.canonicalizeAsBytes(e);return yield t.hashThenEncode(n,r)})}static canonicalizeThenDoubleHashThenEncode(e,r){return C6(this,void 0,void 0,function*(){let n=Iu.canonicalizeAsBytes(e),i=yield t.hashAsNonMultihashBytes(n,r);return yield t.hashThenEncode(i,r)})}static hashThenEncode(e,r){return C6(this,void 0,void 0,function*(){let n=yield t.hash(e,r);return qa.encode(n)})}static validateEncodedHashComputedUsingSupportedHashAlgorithm(e,r){let n,i=qa.decodeAsBytes(e,r);try{n=WS(i)}catch{throw new yn(Cn.MultihashStringNotAMultihash,`Given ${r} string '${e}' is not a multihash after decoding.`)}let o=fa.hashAlgorithmInMultihashCode;if(o!==n.code)throw new yn(Cn.MultihashUnsupportedHashAlgorithm,`Given ${r} uses unsupported multihash algorithm with code ${n.code}, should use ${o} or change IonSdkConfig to desired hashing algorithm.`)}};h();var pK;(function(t){t.Create="create",t.Update="update",t.Deactivate="deactivate",t.Recover="recover"})(pK||(pK={}));var O6=pK;h();var mK;(function(t){t.Replace="replace",t.AddPublicKeys="add-public-keys",t.RemovePublicKeys="remove-public-keys",t.AddServices="add-services",t.RemoveServices="remove-services"})(mK||(mK={}));var Ug=mK;var NT=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())})},Jl=class t{static createCreateRequest(e){return NT(this,void 0,void 0,function*(){let r=e.recoveryKey,n=e.updateKey,i=e.document.publicKeys,o=e.document.services;ro.validateEs256kOperationKey(r,Sc.Public),ro.validateEs256kOperationKey(n,Sc.Public),t.validateDidDocumentKeys(i),t.validateServices(o);let s=fa.hashAlgorithmInMultihashCode,a=[{action:Ug.Replace,document:e.document}],d={updateCommitment:yield To.canonicalizeThenDoubleHashThenEncode(n,s),patches:a};t.validateDeltaSize(d);let c={deltaHash:yield To.canonicalizeThenHashThenEncode(d,s),recoveryCommitment:yield To.canonicalizeThenDoubleHashThenEncode(r,s)};return{type:O6.Create,suffixData:c,delta:d}})}static createDeactivateRequest(e){return NT(this,void 0,void 0,function*(){t.validateDidSuffix(e.didSuffix),ro.validateEs256kOperationKey(e.recoveryPublicKey,Sc.Public);let r=fa.hashAlgorithmInMultihashCode,n=yield To.canonicalizeThenHashThenEncode(e.recoveryPublicKey,r),i={didSuffix:e.didSuffix,recoveryKey:e.recoveryPublicKey},o=yield e.signer.sign({alg:"ES256K"},i);return{type:O6.Deactivate,didSuffix:e.didSuffix,revealValue:n,signedData:o}})}static createRecoverRequest(e){return NT(this,void 0,void 0,function*(){t.validateDidSuffix(e.didSuffix),ro.validateEs256kOperationKey(e.recoveryPublicKey,Sc.Public),ro.validateEs256kOperationKey(e.nextRecoveryPublicKey,Sc.Public),ro.validateEs256kOperationKey(e.nextUpdatePublicKey,Sc.Public),t.validateDidDocumentKeys(e.document.publicKeys),t.validateServices(e.document.services);let r=fa.hashAlgorithmInMultihashCode,n=yield To.canonicalizeThenHashThenEncode(e.recoveryPublicKey,r),i=[{action:Ug.Replace,document:e.document}],o=yield To.canonicalizeThenDoubleHashThenEncode(e.nextUpdatePublicKey,r),s={patches:i,updateCommitment:o},a=yield To.canonicalizeThenHashThenEncode(s,r),u={recoveryCommitment:yield To.canonicalizeThenDoubleHashThenEncode(e.nextRecoveryPublicKey,r),recoveryKey:e.recoveryPublicKey,deltaHash:a},c=yield e.signer.sign({alg:"ES256K"},u);return{type:O6.Recover,didSuffix:e.didSuffix,revealValue:n,delta:s,signedData:c}})}static createUpdateRequest(e){return NT(this,void 0,void 0,function*(){if(t.validateDidSuffix(e.didSuffix),ro.validateEs256kOperationKey(e.updatePublicKey,Sc.Public),ro.validateEs256kOperationKey(e.nextUpdatePublicKey,Sc.Public),t.validateServices(e.servicesToAdd),t.validateDidDocumentKeys(e.publicKeysToAdd),e.idsOfServicesToRemove!==void 0)for(let g of e.idsOfServicesToRemove)ro.validateId(g);if(e.idsOfPublicKeysToRemove!==void 0)for(let g of e.idsOfPublicKeysToRemove)ro.validateId(g);let r=[],n=e.servicesToAdd;if(n!==void 0&&n.length>0){let g={action:Ug.AddServices,services:n};r.push(g)}let i=e.idsOfServicesToRemove;if(i!==void 0&&i.length>0){let g={action:Ug.RemoveServices,ids:i};r.push(g)}let o=e.publicKeysToAdd;if(o!==void 0&&o.length>0){let g={action:Ug.AddPublicKeys,publicKeys:o};r.push(g)}let s=e.idsOfPublicKeysToRemove;if(s!==void 0&&s.length>0){let g={action:Ug.RemovePublicKeys,ids:s};r.push(g)}let a=fa.hashAlgorithmInMultihashCode,d=yield To.canonicalizeThenHashThenEncode(e.updatePublicKey,a),u=yield To.canonicalizeThenDoubleHashThenEncode(e.nextUpdatePublicKey,a),c={patches:r,updateCommitment:u},l=yield To.canonicalizeThenHashThenEncode(c,a),m={updateKey:e.updatePublicKey,deltaHash:l},p=yield e.signer.sign({alg:"ES256K"},m);return{type:O6.Update,didSuffix:e.didSuffix,revealValue:d,delta:c,signedData:p}})}static validateDidSuffix(e){To.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 yn(Cn.DidDocumentPublicKeyMissingOrIncorrectType,"DID Document key 'publicKeyJwk' property is not a non-array object.");if(ro.validateId(n.id),r.has(n.id))throw new yn(Cn.DidDocumentPublicKeyIdDuplicated,`DID Document key with ID '${n.id}' already exists.`);r.add(n.id),ro.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 yn(Cn.DidDocumentServiceIdDuplicated,"Service id has to be unique");r.add(n.id)}}}static validateService(e){ro.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 yn(Cn.ServiceTypeTooLong,n)}if(Array.isArray(e.serviceEndpoint)){let n="Service endpoint value cannot be an array.";throw new yn(Cn.ServiceEndpointCannotBeAnArray,n)}if(typeof e.serviceEndpoint=="string"&&Ppe.parse(e.serviceEndpoint).error!==void 0)throw new yn(Cn.ServiceEndpointStringNotValidUri,`Service endpoint string '${e.serviceEndpoint}' is not a URI.`)}static validateDeltaSize(e){let r=Iu.canonicalizeAsBytes(e);if(r.length>fa.maxCanonicalizedDeltaSizeInBytes){let n=`Delta of ${r.length} bytes exceeded limit of ${fa.maxCanonicalizedDeltaSizeInBytes} bytes.`;throw new yn(Cn.DeltaExceedsMaximumSize,n)}}};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())})},Hm=class t{static createLongFormDid(e){return Tpe(this,void 0,void 0,function*(){let r=yield Jl.createCreateRequest(e),n=yield t.computeDidUniqueSuffix(r.suffixData),i;fa.network===void 0||fa.network==="mainnet"?i=`did:ion:${n}`:i=`did:ion:${fa.network}:${n}`;let o={suffixData:r.suffixData,delta:r.delta},s=Iu.canonicalizeAsBytes(o),a=qa.encode(s);return`${i}:${a}`})}static computeDidUniqueSuffix(e){return Tpe(this,void 0,void 0,function*(){let r=Iu.canonicalizeAsBytes(e),n=yield To.hash(r,fa.hashAlgorithmInMultihashCode);return qa.encode(n)})}};h();h();var Ipe;(function(t){t.Mainnet="mainnet",t.Testnet="test"})(Ipe||(Ipe={}));h();var kpe;(function(t){t.Authentication="authentication",t.AssertionMethod="assertionMethod",t.CapabilityInvocation="capabilityInvocation",t.CapabilityDelegation="capabilityDelegation",t.KeyAgreement="keyAgreement"})(kpe||(kpe={}));h();var Vm=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())})},Yl;(function(t){t.Ed25519="Ed25519",t.secp256k1="secp256k1",t.secp256r1="secp256r1",t.X25519="X25519"})(Yl||(Yl={}));var qHe={Ed25519:Yl.Ed25519,ES256K:Yl.secp256k1,ES256:Yl.secp256r1,"P-256":Yl.secp256r1,secp256k1:Yl.secp256k1,secp256r1:Yl.secp256r1},Rpe="https://ion.tbd.engineering",$6=class t extends Id{static create(){return Vm(this,arguments,void 0,function*({keyManager:e=new Sr,options:r={}}={}){var n,i,o,s,a,d,u;if(!((n=r.verificationMethods)===null||n===void 0)&&n.some(N=>!(N.algorithm in qHe)))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(N=>"id"in N).map(N=>N.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(N=>!N.id||!N.type||!N.serviceEndpoint))throw new Error("One or more services are missing required properties");let l={algorithm:"Ed25519",purposes:["authentication","assertionMethod","capabilityDelegation","capabilityInvocation"]},m=[];for(let N of(s=r.verificationMethods)!==null&&s!==void 0?s:[l]){let L=yield e.generateKey({algorithm:N.algorithm}),F=yield e.getPublicKey({keyUri:L});m.push({id:N.id,publicKeyJwk:F,purposes:(a=N.purposes)!==null&&a!==void 0?a:["authentication","assertionMethod","capabilityDelegation","capabilityInvocation"]})}let p=yield e.generateKey({algorithm:Yl.secp256k1}),g=yield e.getPublicKey({keyUri:p}),b=yield e.generateKey({algorithm:Yl.secp256k1}),S=yield e.getPublicKey({keyUri:b}),A=yield Kg.computeLongFormDidUri({recoveryKey:g,updateKey:S,services:(d=r.services)!==null&&d!==void 0?d:[],verificationMethods:m}),{didDocument:I,didResolutionMetadata:P}=yield t.resolve(A,{gatewayUri:r.gatewayUri});if(I===null)throw new Error(`Unable to resolve DID during creation: ${P?.error}`);let $=new Ua({uri:A,document:I,metadata:{published:!1,canonicalId:A.split(":",3).join(":"),recoveryKey:g,updateKey:S},keyManager:e});if(!((u=r.publish)!==null&&u!==void 0)||u){let N=yield t.publish({did:$,gatewayUri:r.gatewayUri});$.metadata=N.didDocumentMetadata}return $})}static getSigningMethod(e){return Vm(this,arguments,void 0,function*({didDocument:r,methodId:n}){var i;let o=br.parse(r.id);if(o&&o.method!==this.methodName)throw new ot(et.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 ot(et.InternalError,"A verification method intended for signing could not be determined from the DID Document");return s})}static import(e){return Vm(this,arguments,void 0,function*({portableDid:r,keyManager:n=new Sr}){let i=br.parse(r.uri);if(i?.method!==t.methodName)throw new ot(et.MethodNotSupported,"Method not supported");return yield Ua.import({portableDid:r,keyManager:n})})}static publish(e){return Vm(this,arguments,void 0,function*({did:r,gatewayUri:n=Rpe}){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:zhe({didDocument:r.document,methodId:c.id})})))!==null&&o!==void 0?o:[],d=yield Kg.createIonDocument({services:(s=r.document.service)!==null&&s!==void 0?s:[],verificationMethods:a}),u=yield Kg.constructCreateRequest({ionDocument:d,recoveryKey:r.metadata.recoveryKey,updateKey:r.metadata.updateKey});try{let c=Kg.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:et.InternalError,errorMessage:`Failed to publish DID document for: ${r.uri}`}}}})}static resolve(e){return Vm(this,arguments,void 0,function*(r,n={}){var i,o;let s=br.parse(r);if(!s)return Object.assign(Object.assign({},Xn),{didResolutionMetadata:{error:"invalidDid"}});if(s.method!==t.methodName)return Object.assign(Object.assign({},Xn),{didResolutionMetadata:{error:"methodNotSupported"}});let a=(i=n?.gatewayUri)!==null&&i!==void 0?i:Rpe;try{let d=Kg.appendPathToUrl({baseUrl:a,path:`/identifiers/${r}`}),u=yield fetch(d);if(!u.ok)throw new ot(et.NotFound,`Unable to find DID document for: ${r}`);let{didDocument:c,didDocumentMetadata:l}=yield u.json();return Object.assign(Object.assign(Object.assign({},Xn),c&&{didDocument:c}),{didDocumentMetadata:Object.assign({published:(o=l?.method)===null||o===void 0?void 0:o.published},l)})}catch(d){if(!(d instanceof ot))throw new Error(d);return Object.assign(Object.assign({},Xn),{didResolutionMetadata:Object.assign({error:d.code},d.message&&{errorMessage:d.message})})}})}};$6.methodName="ion";var Kg=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 Vm(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 Hm.createLongFormDid({document:s,recoveryKey:a,updateKey:d})})}static constructCreateRequest(e){return Vm(this,arguments,void 0,function*({ionDocument:r,recoveryKey:n,updateKey:i}){return yield Jl.createCreateRequest({document:r,recoveryKey:t.normalizeJwk(n),updateKey:t.normalizeJwk(i)})})}static createIonDocument(e){return Vm(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 rt({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}};h();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())})},yK=class t extends Id{static create(){return jT(this,arguments,void 0,function*({keyManager:e=new Sr,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=de.object(u).toBase64Url(),l=`did:${t.methodName}:${c}`,p=(yield t.resolve(l)).didDocument;return new Ua({uri:l,document:p,metadata:{},keyManager:e})})}static getSigningMethod(e){return jT(this,arguments,void 0,function*({didDocument:r}){var n;let i=br.parse(r.id);if(i&&i.method!==this.methodName)throw new ot(et.MethodNotSupported,`Method not supported: ${i.method}`);let[o]=(n=r.verificationMethod)!==null&&n!==void 0?n:[];if(!(o&&o.publicKeyJwk))throw new ot(et.InternalError,"A verification method intended for signing could not be determined from the DID Document");return o})}static import(e){return jT(this,arguments,void 0,function*({portableDid:r,keyManager:n=new Sr}){let i=br.parse(r.uri);if(i?.method!==t.methodName)throw new ot(et.MethodNotSupported,"Method not supported");let o=yield Ua.import({portableDid:r,keyManager:n});if(o.document.verificationMethod.length!==1)throw new ot(et.InvalidDidDocument,"DID document must contain exactly one verification method");return o})}static resolve(e,r){return jT(this,void 0,void 0,function*(){let n=br.parse(e),i;try{i=de.base64Url(n.id).toObject()}catch{}if(!n||!i)return Object.assign(Object.assign({},Xn),{didResolutionMetadata:{error:"invalidDid"}});if(n.method!==t.methodName)return Object.assign(Object.assign({},Xn),{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({},Xn),{didDocument:o})})}};yK.methodName="jwk";h();var ku=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())})},Th;(function(t){t.Ed25519="Ed25519",t.secp256k1="secp256k1",t.secp256r1="secp256r1",t.X25519="X25519"})(Th||(Th={}));var gK={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"},LHe={Ed25519:Th.Ed25519,ES256K:Th.secp256k1,ES256:Th.secp256r1,"P-256":Th.secp256r1,secp256k1:Th.secp256k1,secp256r1:Th.secp256r1,X25519:Th.X25519},A1=class t extends Id{static create(){return ku(this,arguments,void 0,function*({keyManager:e=new Sr,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 La.publicKeyToMultibaseId({publicKey:u}),l=`did:${t.methodName}:${c}`,p=(yield t.resolve(l,r)).didDocument;return new Ua({uri:l,document:p,metadata:{},keyManager:e})})}static getSigningMethod(e){return ku(this,arguments,void 0,function*({didDocument:r}){var n;let i=br.parse(r.id);if(i&&i.method!==this.methodName)throw new ot(et.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 ot(et.InternalError,"A verification method intended for signing could not be determined from the DID Document");return s})}static import(e){return ku(this,arguments,void 0,function*({portableDid:r,keyManager:n=new Sr}){let i=br.parse(r.uri);if(i?.method!==t.methodName)throw new ot(et.MethodNotSupported,"Method not supported");let o=yield Ua.import({portableDid:r,keyManager:n});if(o.document.verificationMethod.length!==1)throw new ot(et.InvalidDidDocument,"DID document must contain exactly one verification method");return o})}static resolve(e,r){return ku(this,void 0,void 0,function*(){try{let n=yield t.createDocument({didUri:e,options:r});return Object.assign(Object.assign({},Xn),{didDocument:n})}catch(n){if(!(n instanceof ot))throw new Error(n);return Object.assign(Object.assign({},Xn),{didResolutionMetadata:Object.assign({error:n.code},n.message&&{errorMessage:n.message})})}})}static createDocument(e){return ku(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=br.parse(r);if(!u)throw new ot(et.InvalidDid,`Invalid DID URI: ${r}`);let c=u.id;if(u.method!==t.methodName)throw new ot(et.MethodNotSupported,`Method not supported: ${u.method}`);if(!t.validateIdentifier(u))throw new ot(et.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",b=yield this.createEncryptionMethod({didUri:r,multibaseValue:c,options:{enableExperimentalPublicKeyTypes:s,publicKeyFormat:g}});d.verificationMethod.push(b),d.keyAgreement=[b.id]}let m=[i];return Fhe({didDocument:d}).forEach(g=>{let b=gK[g];m.push(b)}),d["@context"]=m,d})}static createEncryptionMethod(e){return ku(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=La.MULTICODEC_PUBLIC_KEY_LENGTH[u];if(c!==l)throw new ot(et.InvalidPublicKeyLength,`Expected ${c} bytes. Actual: ${l}`);let m=YU({keyBytes:d,multicodecCode:u});a.id=`${r}#${m}`;try{new URL(a.id)}catch{throw new ot(et.InvalidDidUrl,"Verification Method ID is not a valid DID URL.")}if(!(s in gK))throw new ot(et.UnsupportedPublicKeyType,`Unsupported format: ${s}`);if(o===!1&&!["Multikey","JsonWebKey2020","X25519KeyAgreementKey2020"].includes(s))throw new ot(et.InvalidPublicKeyType,`Specified '${s}' without setting enableExperimentalPublicKeyTypes to true.`);if(a.type=s,a.controller=r,s==="X25519KeyAgreementKey2020"&&(a.publicKeyMultibase=m),s==="JsonWebKey2020"){let{crv:g}=yield La.multicodecToJwk({code:u});a.publicKeyJwk=yield La.keyConverter(g).bytesToPublicKey({publicKeyBytes:d})}return a})}static createSignatureMethod(e){return ku(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}=ZU({multibaseKeyId:n}),l=d.byteLength,m=La.MULTICODEC_PUBLIC_KEY_LENGTH[u];if(l!==m)throw new ot(et.InvalidPublicKeyLength,`Expected ${l} bytes. Actual: ${m}`);let p=!1;switch(c){case"secp256k1-pub":p=yield Er.validatePublicKey({publicKeyBytes:d});break;case"ed25519-pub":p=yield er.validatePublicKey({publicKeyBytes:d});break;case"x25519-pub":p=!0;break}if(!p)throw new ot(et.InvalidPublicKey,"Invalid public key detected.");a.id=`${r}#${n}`;try{new URL(a.id)}catch{throw new ot(et.InvalidDidUrl,"Verification Method ID is not a valid DID URL.")}if(!(s in gK))throw new ot(et.UnsupportedPublicKeyType,`Unsupported format: ${s}`);if(o===!1&&!["Multikey","JsonWebKey2020","Ed25519VerificationKey2020"].includes(s))throw new ot(et.InvalidPublicKeyType,`Specified '${s}' without setting enableExperimentalPublicKeyTypes to true.`);if(a.type=s,a.controller=r,s==="Ed25519VerificationKey2020"&&(a.publicKeyMultibase=n),s==="JsonWebKey2020"){let{crv:b}=yield La.multicodecToJwk({code:u});a.publicKeyJwk=yield La.keyConverter(b).bytesToPublicKey({publicKeyBytes:d})}return a})}static deriveEncryptionKey(e){return ku(this,arguments,void 0,function*({multibaseValue:r}){let n={keyBytes:new Uint8Array,multicodecCode:0},{keyBytes:i,multicodecCode:o}=ZU({multibaseKeyId:r});if(o===237){let s=yield La.keyConverter("Ed25519").bytesToPublicKey({publicKeyBytes:i}),a=yield er.convertPublicKeyToX25519({publicKey:s});n={keyBytes:yield La.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&&xm(n)==="String"&&n.startsWith("z")}};A1.methodName="key";var La=class t{static jwkToMulticodec(e){return ku(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:mi.getCodeFromName({name:o}),name:o}})}static keyCompressor(e){let n={"P-256":Br.compressPublicKey,secp256k1:Er.compressPublicKey}[e];if(!n)throw new ot(et.InvalidPublicKeyType,`Unsupported curve: ${e}`);return n}static keyConverter(e){let n={Ed25519:er,"P-256":Br,secp256k1:Er,X25519:Gl}[e];if(!n)throw new ot(et.InvalidPublicKeyType,`Unsupported curve: ${e}`);return n}static multicodecToJwk(e){return ku(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?mi.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 ku(this,arguments,void 0,function*({publicKey:r}){var n;if(!(r?.crv&&r.crv in LHe))throw new ot(et.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 YU({keyBytes:i,multicodecName:o})})}};La.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"};La.MULTICODEC_PUBLIC_KEY_LENGTH={231:33,236:32,237:32};La.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:""}};h();var FHe=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())})},bK=class t extends Id{static resolve(e,r){return FHe(this,void 0,void 0,function*(){let n=br.parse(e);if(!n)return Object.assign(Object.assign({},Xn),{didResolutionMetadata:{error:"invalidDid"}});if(n.method!==t.methodName)return Object.assign(Object.assign({},Xn),{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({},Xn),{didDocument:a})}catch{return Object.assign(Object.assign({},Xn),{didResolutionMetadata:{error:"notFound"}})}})}};bK.methodName="web";h();var Bpe=Ut(Lg(),1),Cpe=Ut(vK(),1),JHe=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())})},KT=class{constructor({db:e,location:r="DATA/DID_RESOLVERCACHE",ttl:n="15m"}={}){this.cache=e??new Cpe.Level(r),this.ttl=(0,Bpe.default)(n)}get(e){return JHe(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()}};h();var Ope={get:function(t){return null},set:function(t,e){return null},delete:function(t){return null},clear:function(){return null},close:function(){return null}};h();var $pe=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())})},qT=class{constructor({cache:e,didResolvers:r}){this.didResolvers=new Map,this.cache=e||Ope;for(let n of r)this.didResolvers.set(n.methodName,n)}resolve(e,r){return $pe(this,void 0,void 0,function*(){let n=br.parse(e);if(!n)return Object.assign(Object.assign({},Xn),{didResolutionMetadata:{error:et.InvalidDid,errorMessage:`Invalid DID URI: ${e}`}});let i=this.didResolvers.get(n.method);if(!i)return Object.assign(Object.assign({},Xn),{didResolutionMetadata:{error:et.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 $pe(this,void 0,void 0,function*(){let n=br.parse(e);if(!n)return{dereferencingMetadata:{error:et.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:et.NotFound},contentStream:null,contentMetadata:{}}})}};var k1=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())})},N6=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.eventLog=e.eventLog,this.eventStream=e.eventStream,this.methodHandlers={[Ae.Events+_e.Get]:new hA(this.didResolver,this.eventLog),[Ae.Events+_e.Query]:new pA(this.didResolver,this.eventLog),[Ae.Events+_e.Subscribe]:new mA(this.didResolver,this.eventStream),[Ae.Messages+_e.Get]:new yA(this.didResolver,this.messageStore,this.dataStore),[Ae.Protocols+_e.Configure]:new JA(this.didResolver,this.messageStore,this.eventLog,this.eventStream),[Ae.Protocols+_e.Query]:new ZA(this.didResolver,this.messageStore,this.dataStore),[Ae.Records+_e.Delete]:new QA(this.didResolver,this.messageStore,this.dataStore,this.eventLog,this.eventStream),[Ae.Records+_e.Query]:new eP(this.didResolver,this.messageStore,this.dataStore),[Ae.Records+_e.Read]:new tP(this.didResolver,this.messageStore,this.dataStore),[Ae.Records+_e.Subscribe]:new nP(this.didResolver,this.messageStore,this.eventStream),[Ae.Records+_e.Write]:new iP(this.didResolver,this.messageStore,this.dataStore,this.eventLog,this.eventStream)}}static create(e){var r,n;return k1(this,void 0,void 0,function*(){(r=e.didResolver)!==null&&r!==void 0||(e.didResolver=new qT({didResolvers:[jg,$6,A1],cache:new KT({location:"RESOLVERCACHE"})})),(n=e.tenantGate)!==null&&n!==void 0||(e.tenantGate=new rE);let i=new t(e);return yield i.open(),i})}open(){var e;return k1(this,void 0,void 0,function*(){yield this.messageStore.open(),yield this.dataStore.open(),yield this.eventLog.open(),yield(e=this.eventStream)===null||e===void 0?void 0:e.open()})}close(){var e;return k1(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.eventLog.close()})}processMessage(e,r,n={}){var i;return k1(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 k1(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 k1(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{be.validateJsonSchema(e)}catch(s){return Xt(s,400)}})}};h();var YHe=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 ZHe(t){return new Promise((e,r)=>{if(t.aborted){r(t.reason);return}t.addEventListener("abort",()=>{r(t.reason)})})}function Ki(t,e){return YHe(this,void 0,void 0,function*(){return e?Promise.race([t,ZHe(e)]):t})}h();h();h();h();var jpe=Ut(r6(),1),Ac=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())})},Ru=function(t){return this instanceof Ru?(this.v=t,this):new Ru(t)},wK=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)}},Npe=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(m){n[m]&&(i[m]=function(p){return new Promise(function(g,b){o.push([m,p,g,b])>1||a(m,p)})})}function a(m,p){try{d(n[m](p))}catch(g){l(o[0][3],g)}}function d(m){m.value instanceof Ru?Promise.resolve(m.value.v).then(u,c):l(o[0][2],m)}function u(m){a("next",m)}function c(m){a("throw",m)}function l(m,p){m(p),o.shift(),o.length&&a(o[0][0],o[0][1])}};function Du(t,e){return Ac(this,void 0,void 0,function*(){return new jpe.Level(t,Object.assign(Object.assign({},e),{keyEncoding:"utf8"}))})}var R1=class t{constructor(e,r){this.config=Object.assign({createLevelDatabase:Du},e),this.db=r}open(){return Ac(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 Ac(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 Ac(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 Ac(this,void 0,void 0,function*(){(n=r?.signal)===null||n===void 0||n.throwIfAborted(),yield Ki(this.createLevelDatabase(),r?.signal);try{return yield Ki(this.db.get(String(e)),r?.signal)}catch(i){if(i.code==="LEVEL_NOT_FOUND")return;throw i}})}has(e,r){return Ac(this,void 0,void 0,function*(){return!!(yield this.get(e,r))})}keys(e){var r,n;return Npe(this,arguments,function*(){var o,s,a,d;(r=e?.signal)===null||r===void 0||r.throwIfAborted(),yield Ru(Ki(this.createLevelDatabase(),e?.signal));try{for(var u=!0,c=wK(this.db.keys()),l;l=yield Ru(c.next()),o=l.done,!o;u=!0){d=l.value,u=!1;let m=d;(n=e?.signal)===null||n===void 0||n.throwIfAborted(),yield yield Ru(m)}}catch(m){s={error:m}}finally{try{!u&&!o&&(a=c.return)&&(yield Ru(a.call(c)))}finally{if(s)throw s.error}}})}iterator(e,r){var n,i;return Npe(this,arguments,function*(){var s,a,d,u;(n=r?.signal)===null||n===void 0||n.throwIfAborted(),yield Ru(Ki(this.createLevelDatabase(),r?.signal));try{for(var c=!0,l=wK(this.db.iterator(e)),m;m=yield Ru(l.next()),s=m.done,!s;c=!0){u=m.value,c=!1;let p=u;(i=r?.signal)===null||i===void 0||i.throwIfAborted(),yield yield Ru(p)}}catch(p){a={error:p}}finally{try{!c&&!s&&(d=l.return)&&(yield Ru(d.call(l)))}finally{if(a)throw a.error}}})}put(e,r,n){var i;return Ac(this,void 0,void 0,function*(){return(i=n?.signal)===null||i===void 0||i.throwIfAborted(),yield Ki(this.createLevelDatabase(),n?.signal),Ki(this.db.put(String(e),r),n?.signal)})}delete(e,r){var n;return Ac(this,void 0,void 0,function*(){return(n=r?.signal)===null||n===void 0||n.throwIfAborted(),yield Ki(this.createLevelDatabase(),r?.signal),Ki(this.db.del(String(e)),r?.signal)})}isEmpty(e){var r,n,i,o;return Ac(this,void 0,void 0,function*(){try{for(var s=!0,a=wK(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 Ac(this,void 0,void 0,function*(){yield this.createLevelDatabase(),yield this.db.clear(),yield this.compactUnderlyingStorage()})}batch(e,r){var n;return Ac(this,void 0,void 0,function*(){return(n=r?.signal)===null||n===void 0||n.throwIfAborted(),yield Ki(this.createLevelDatabase(),r?.signal),Ki(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 Ac(this,void 0,void 0,function*(){(r=e?.signal)===null||r===void 0||r.throwIfAborted(),yield Ki(this.createLevelDatabase(),e?.signal);let o=this.sublevelRange;if(!o)return;let s=this.root;if(s.db.supports.additionalMethods.compactRange)return Ki((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 Ac(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 Ih=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())})},LT=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)}},Io=function(t){return this instanceof Io?(this.v=t,this):new Io(t)},FT=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(m){n[m]&&(i[m]=function(p){return new Promise(function(g,b){o.push([m,p,g,b])>1||a(m,p)})})}function a(m,p){try{d(n[m](p))}catch(g){l(o[0][3],g)}}function d(m){m.value instanceof Io?Promise.resolve(m.value.v).then(u,c):l(o[0][2],m)}function u(m){a("next",m)}function c(m){a("throw",m)}function l(m,p){m(p),o.shift(),o.length&&a(o[0][0],o[0][1])}},D1=class t{constructor(e,r){this.config=Object.assign({createLevelDatabase:Du},e),this.db=r??new R1(Object.assign(Object.assign({},this.config),{valueEncoding:"binary"}))}open(){return Ih(this,void 0,void 0,function*(){return this.db.open()})}close(){return Ih(this,void 0,void 0,function*(){return this.db.close()})}partition(e){return Ih(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 Ih(this,void 0,void 0,function*(){return yield this.db.put(String(e),r,n),Or.parse(e.toString())})}get(e,r){return Ih(this,void 0,void 0,function*(){return yield this.db.get(String(e),r)})}has(e,r){return Ih(this,void 0,void 0,function*(){return this.db.has(String(e),r)})}delete(e,r){return Ih(this,void 0,void 0,function*(){return this.db.delete(String(e),r)})}isEmpty(e){return Ih(this,void 0,void 0,function*(){return this.db.isEmpty(e)})}putMany(e,r){return FT(this,arguments,function*(){var i,o,s,a;try{for(var d=!0,u=LT(e),c;c=yield Io(u.next()),i=c.done,!i;d=!0){a=c.value,d=!1;let l=a;yield Io(this.put(l.cid,l.block,r)),yield yield Io(l.cid)}}catch(l){o={error:l}}finally{try{!d&&!i&&(s=u.return)&&(yield Io(s.call(u)))}finally{if(o)throw o.error}}})}getMany(e,r){return FT(this,arguments,function*(){var i,o,s,a;try{for(var d=!0,u=LT(e),c;c=yield Io(u.next()),i=c.done,!i;d=!0){a=c.value,d=!1;let l=a;yield yield Io({cid:l,block:yield Io(this.get(l,r))})}}catch(l){o={error:l}}finally{try{!d&&!i&&(s=u.return)&&(yield Io(s.call(u)))}finally{if(o)throw o.error}}})}getAll(e){return FT(this,arguments,function*(){var n,i,o,s;let a=this.db.iterator({keys:!0,keyEncoding:"buffer"},e);try{for(var d=!0,u=LT(a),c;c=yield Io(u.next()),n=c.done,!n;d=!0){s=c.value,d=!1;let[l,m]=s;yield yield Io({cid:Or.decode(l),block:m})}}catch(l){i={error:l}}finally{try{!d&&!n&&(o=u.return)&&(yield Io(o.call(u)))}finally{if(i)throw i.error}}})}deleteMany(e,r){return FT(this,arguments,function*(){var i,o,s,a;try{for(var d=!0,u=LT(e),c;c=yield Io(u.next()),i=c.done,!i;d=!0){a=c.value,d=!1;let l=a;yield Io(this.delete(l,r)),yield yield Io(l)}}catch(l){o={error:l}}finally{try{!d&&!i&&(s=u.return)&&(yield Io(s.call(u)))}finally{if(o)throw o.error}}})}clear(){return Ih(this,void 0,void 0,function*(){return this.db.clear()})}};h();var pI=Ut(Xa(),1);h();function XHe(t){return t[Symbol.asyncIterator]!=null}function QHe(t){if(XHe(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 Upe=QHe;h();h();h();h();h();var eVe=["string","number","bigint","symbol"],tVe=["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 Kpe(t){if(t===null)return"null";if(t===void 0)return"undefined";if(t===!0||t===!1)return"boolean";let e=typeof t;if(eVe.includes(e))return e;if(e==="function")return"Function";if(Array.isArray(t))return"Array";if(rVe(t))return"Buffer";let r=nVe(t);return r||"Object"}function rVe(t){return t&&t.constructor&&t.constructor.isBuffer&&t.constructor.isBuffer.call(null,t)}function nVe(t){let e=Object.prototype.toString.call(t).slice(8,-1);if(tVe.includes(e))return e}h();var ye=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}};ye.uint=new ye(0,"uint",!0);ye.negint=new ye(1,"negint",!0);ye.bytes=new ye(2,"bytes",!0);ye.string=new ye(3,"string",!0);ye.array=new ye(4,"array",!1);ye.map=new ye(5,"map",!1);ye.tag=new ye(6,"tag",!1);ye.float=new ye(7,"float",!0);ye.false=new ye(7,"false",!0);ye.true=new ye(7,"true",!0);ye.null=new ye(7,"null",!0);ye.undefined=new ye(7,"undefined",!0);ye.break=new ye(7,"break",!0);var Ge=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}`}};h();h();var M1=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",iVe=new TextDecoder,oVe=new TextEncoder;function zT(t){return M1&&globalThis.Buffer.isBuffer(t)}function zpe(t){return t instanceof Uint8Array?zT(t)?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):t:Uint8Array.from(t)}var Gpe=M1?(t,e,r)=>r-e>64?globalThis.Buffer.from(t.subarray(e,r)).toString("utf8"):Lpe(t,e,r):(t,e,r)=>r-e>64?iVe.decode(t.subarray(e,r)):Lpe(t,e,r),Wpe=M1?t=>t.length>64?globalThis.Buffer.from(t):qpe(t):t=>t.length>64?oVe.encode(t):qpe(t);var B1=M1?(t,e,r)=>zT(t)?new Uint8Array(t.subarray(e,r)):t.slice(e,r):(t,e,r)=>t.slice(e,r),Hpe=M1?(t,e)=>(t=t.map(r=>r instanceof Uint8Array?r:globalThis.Buffer.from(r)),zpe(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},Vpe=M1?t=>globalThis.Buffer.allocUnsafe(t):t=>new Uint8Array(t);function Jpe(t,e){if(zT(t)&&zT(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 Lpe(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 sVe(n)}var Fpe=4096;function sVe(t){let e=t.length;if(e<=Fpe)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=B1(n,0,this.cursor)}else r=Hpe(this.chunks,this.cursor);return e&&this.reset(),r}};h();var qt="CBOR decode error:",_K="CBOR encode error:",j6=[];j6[23]=1;j6[24]=2;j6[25]=3;j6[26]=5;j6[27]=9;function kh(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(`${qt} encountered BigInt larger than allowable range`)}}kd.encodedSize=function(e){return ds.encodedSize(e.value)};ds.encodedSize=function(e){return er.value?1:0};h();function eme(t,e,r,n){return new Ge(ye.negint,-1-Pc(t,e+1,n),2)}function tme(t,e,r,n){return new Ge(ye.negint,-1-Tc(t,e+1,n),3)}function rme(t,e,r,n){return new Ge(ye.negint,-1-Ic(t,e+1,n),5)}var xK=BigInt(-1),nme=BigInt(1);function ime(t,e,r,n){let i=kc(t,e+1,n);if(typeof i!="bigint"){let o=-1-i;if(o>=Number.MIN_SAFE_INTEGER)return new Ge(ye.negint,o,9)}if(n.allowBigInt!==!0)throw new Error(`${qt} integers outside of the safe integer range are not supported`);return new Ge(ye.negint,xK-BigInt(i),9)}function WT(t,e){let r=e.value,n=typeof r=="bigint"?r*xK-nme:r*-1-1;ds(t,e.type.majorEncoded,n)}WT.encodedSize=function(e){let r=e.value,n=typeof r=="bigint"?r*xK-nme:r*-1-1;return nr.value?-1:0};h();function U6(t,e,r,n){kh(t,e,r+n);let i=B1(t,e+r,e+r+n);return new Ge(ye.bytes,i,r+n)}function ome(t,e,r,n){return U6(t,e,1,r)}function sme(t,e,r,n){return U6(t,e,2,Pc(t,e+1,n))}function ame(t,e,r,n){return U6(t,e,3,Tc(t,e+1,n))}function cme(t,e,r,n){return U6(t,e,5,Ic(t,e+1,n))}function dme(t,e,r,n){let i=kc(t,e+1,n);if(typeof i=="bigint")throw new Error(`${qt} 64-bit integer bytes lengths not supported`);return U6(t,e,9,i)}function HT(t){return t.encodedBytes===void 0&&(t.encodedBytes=t.type===ye.string?Wpe(t.value):t.value),t.encodedBytes}function C1(t,e){let r=HT(e);ds(t,e.type.majorEncoded,r.length),t.push(r)}C1.encodedSize=function(e){let r=HT(e);return ds.encodedSize(r.length)+r.length};C1.compareTokens=function(e,r){return dVe(HT(e),HT(r))};function dVe(t,e){return t.lengthe.length?1:Jpe(t,e)}h();function K6(t,e,r,n,i){let o=r+n;kh(t,e,o);let s=new Ge(ye.string,Gpe(t,e+r,e+o),o);return i.retainStringBytes===!0&&(s.byteValue=B1(t,e+r,e+o)),s}function ume(t,e,r,n){return K6(t,e,1,r,n)}function lme(t,e,r,n){return K6(t,e,2,Pc(t,e+1,n),n)}function fme(t,e,r,n){return K6(t,e,3,Tc(t,e+1,n),n)}function hme(t,e,r,n){return K6(t,e,5,Ic(t,e+1,n),n)}function pme(t,e,r,n){let i=kc(t,e+1,n);if(typeof i=="bigint")throw new Error(`${qt} 64-bit integer string lengths not supported`);return K6(t,e,9,i,n)}var mme=C1;h();function O1(t,e,r,n){return new Ge(ye.array,n,r)}function yme(t,e,r,n){return O1(t,e,1,r)}function gme(t,e,r,n){return O1(t,e,2,Pc(t,e+1,n))}function bme(t,e,r,n){return O1(t,e,3,Tc(t,e+1,n))}function vme(t,e,r,n){return O1(t,e,5,Ic(t,e+1,n))}function wme(t,e,r,n){let i=kc(t,e+1,n);if(typeof i=="bigint")throw new Error(`${qt} 64-bit integer array lengths not supported`);return O1(t,e,9,i)}function _me(t,e,r,n){if(n.allowIndefinite===!1)throw new Error(`${qt} indefinite length items not allowed`);return O1(t,e,1,1/0)}function VT(t,e){ds(t,ye.array.majorEncoded,e.value)}VT.compareTokens=kd.compareTokens;VT.encodedSize=function(e){return ds.encodedSize(e.value)};h();function $1(t,e,r,n){return new Ge(ye.map,n,r)}function xme(t,e,r,n){return $1(t,e,1,r)}function Eme(t,e,r,n){return $1(t,e,2,Pc(t,e+1,n))}function Sme(t,e,r,n){return $1(t,e,3,Tc(t,e+1,n))}function Ame(t,e,r,n){return $1(t,e,5,Ic(t,e+1,n))}function Pme(t,e,r,n){let i=kc(t,e+1,n);if(typeof i=="bigint")throw new Error(`${qt} 64-bit integer map lengths not supported`);return $1(t,e,9,i)}function Tme(t,e,r,n){if(n.allowIndefinite===!1)throw new Error(`${qt} indefinite length items not allowed`);return $1(t,e,1,1/0)}function JT(t,e){ds(t,ye.map.majorEncoded,e.value)}JT.compareTokens=kd.compareTokens;JT.encodedSize=function(e){return ds.encodedSize(e.value)};h();function Ime(t,e,r,n){return new Ge(ye.tag,r,1)}function kme(t,e,r,n){return new Ge(ye.tag,Pc(t,e+1,n),2)}function Rme(t,e,r,n){return new Ge(ye.tag,Tc(t,e+1,n),3)}function Dme(t,e,r,n){return new Ge(ye.tag,Ic(t,e+1,n),5)}function Mme(t,e,r,n){return new Ge(ye.tag,kc(t,e+1,n),9)}function YT(t,e){ds(t,ye.tag.majorEncoded,e.value)}YT.compareTokens=kd.compareTokens;YT.encodedSize=function(e){return ds.encodedSize(e.value)};h();var mVe=20,yVe=21,gVe=22,bVe=23;function Bme(t,e,r,n){if(n.allowUndefined===!1)throw new Error(`${qt} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new Ge(ye.null,null,1):new Ge(ye.undefined,void 0,1)}function Cme(t,e,r,n){if(n.allowIndefinite===!1)throw new Error(`${qt} indefinite length items not allowed`);return new Ge(ye.break,void 0,1)}function EK(t,e,r){if(r){if(r.allowNaN===!1&&Number.isNaN(t))throw new Error(`${qt} NaN values are not supported`);if(r.allowInfinity===!1&&(t===1/0||t===-1/0))throw new Error(`${qt} Infinity values are not supported`)}return new Ge(ye.float,t,e)}function Ome(t,e,r,n){return EK(SK(t,e+1),3,n)}function $me(t,e,r,n){return EK(AK(t,e+1),5,n)}function Nme(t,e,r,n){return EK(qme(t,e+1),9,n)}function ZT(t,e,r){let n=e.value;if(n===!1)t.push([ye.float.majorEncoded|mVe]);else if(n===!0)t.push([ye.float.majorEncoded|yVe]);else if(n===null)t.push([ye.float.majorEncoded|gVe]);else if(n===void 0)t.push([ye.float.majorEncoded|bVe]);else{let i,o=!1;(!r||r.float64!==!0)&&(Ume(n),i=SK(Mu,1),n===i||Number.isNaN(n)?(Mu[0]=249,t.push(Mu.slice(0,3)),o=!0):(Kme(n),i=AK(Mu,1),n===i&&(Mu[0]=250,t.push(Mu.slice(0,5)),o=!0))),o||(vVe(n),i=qme(Mu,1),Mu[0]=251,t.push(Mu.slice(0,9)))}}ZT.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){Ume(n);let i=SK(Mu,1);if(n===i||Number.isNaN(n))return 3;if(Kme(n),i=AK(Mu,1),n===i)return 5}return 9};var jme=new ArrayBuffer(9),Rd=new DataView(jme,1),Mu=new Uint8Array(jme,0);function Ume(t){if(t===1/0)Rd.setUint16(0,31744,!1);else if(t===-1/0)Rd.setUint16(0,64512,!1);else if(Number.isNaN(t))Rd.setUint16(0,32256,!1);else{Rd.setFloat32(0,t);let e=Rd.getUint32(0),r=(e&2139095040)>>23,n=e&8388607;if(r===255)Rd.setUint16(0,31744,!1);else if(r===0)Rd.setUint16(0,(t&2147483648)>>16|n>>13,!1);else{let i=r-127;i<-24?Rd.setUint16(0,0):i<-14?Rd.setUint16(0,(e&2147483648)>>16|1<<24+i,!1):Rd.setUint16(0,(e&2147483648)>>16|i+15<<10|n>>13,!1)}}}function SK(t,e){if(t.length-e<2)throw new Error(`${qt} 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 Kme(t){Rd.setFloat32(0,t,!1)}function AK(t,e){if(t.length-e<4)throw new Error(`${qt} not enough data for float32`);let r=(t.byteOffset||0)+e;return new DataView(t.buffer,r,4).getFloat32(0,!1)}function vVe(t){Rd.setFloat64(0,t,!1)}function qme(t,e){if(t.length-e<8)throw new Error(`${qt} not enough data for float64`);let r=(t.byteOffset||0)+e;return new DataView(t.buffer,r,8).getFloat64(0,!1)}ZT.compareTokens=kd.compareTokens;function Vr(t,e,r){throw new Error(`${qt} encountered invalid minor (${r}) for major ${t[e]>>>5}`)}function XT(t){return()=>{throw new Error(`${qt} ${t}`)}}var Be=[];for(let t=0;t<=23;t++)Be[t]=Vr;Be[24]=Ype;Be[25]=Zpe;Be[26]=Xpe;Be[27]=Qpe;Be[28]=Vr;Be[29]=Vr;Be[30]=Vr;Be[31]=Vr;for(let t=32;t<=55;t++)Be[t]=Vr;Be[56]=eme;Be[57]=tme;Be[58]=rme;Be[59]=ime;Be[60]=Vr;Be[61]=Vr;Be[62]=Vr;Be[63]=Vr;for(let t=64;t<=87;t++)Be[t]=ome;Be[88]=sme;Be[89]=ame;Be[90]=cme;Be[91]=dme;Be[92]=Vr;Be[93]=Vr;Be[94]=Vr;Be[95]=XT("indefinite length bytes/strings are not supported");for(let t=96;t<=119;t++)Be[t]=ume;Be[120]=lme;Be[121]=fme;Be[122]=hme;Be[123]=pme;Be[124]=Vr;Be[125]=Vr;Be[126]=Vr;Be[127]=XT("indefinite length bytes/strings are not supported");for(let t=128;t<=151;t++)Be[t]=yme;Be[152]=gme;Be[153]=bme;Be[154]=vme;Be[155]=wme;Be[156]=Vr;Be[157]=Vr;Be[158]=Vr;Be[159]=_me;for(let t=160;t<=183;t++)Be[t]=xme;Be[184]=Eme;Be[185]=Sme;Be[186]=Ame;Be[187]=Pme;Be[188]=Vr;Be[189]=Vr;Be[190]=Vr;Be[191]=Tme;for(let t=192;t<=215;t++)Be[t]=Ime;Be[216]=kme;Be[217]=Rme;Be[218]=Dme;Be[219]=Mme;Be[220]=Vr;Be[221]=Vr;Be[222]=Vr;Be[223]=Vr;for(let t=224;t<=243;t++)Be[t]=XT("simple values are not supported");Be[244]=Vr;Be[245]=Vr;Be[246]=Vr;Be[247]=Bme;Be[248]=XT("simple values are not supported");Be[249]=Ome;Be[250]=$me;Be[251]=Nme;Be[252]=Vr;Be[253]=Vr;Be[254]=Vr;Be[255]=Cme;var Bu=[];for(let t=0;t<24;t++)Bu[t]=new Ge(ye.uint,t,1);for(let t=-1;t>=-24;t--)Bu[31-t]=new Ge(ye.negint,t,1);Bu[64]=new Ge(ye.bytes,new Uint8Array(0),1);Bu[96]=new Ge(ye.string,"",1);Bu[128]=new Ge(ye.array,0,1);Bu[160]=new Ge(ye.map,0,1);Bu[244]=new Ge(ye.false,!1,1);Bu[245]=new Ge(ye.true,!0,1);Bu[246]=new Ge(ye.null,null,1);function _Ve(){let t=[];return t[ye.uint.major]=kd,t[ye.negint.major]=WT,t[ye.bytes.major]=C1,t[ye.string.major]=mme,t[ye.array.major]=VT,t[ye.map.major]=JT,t[ye.tag.major]=YT,t[ye.float.major]=ZT,t}var vRt=_Ve(),wRt=new GT,QT=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(`${_K} object contains circular references`);return new t(r,e)}},Jm={null:new Ge(ye.null,null),undefined:new Ge(ye.undefined,void 0),true:new Ge(ye.true,!0),false:new Ge(ye.false,!1),emptyArray:new Ge(ye.array,0),emptyMap:new Ge(ye.map,0)},Ym={number(t,e,r,n){return!Number.isInteger(t)||!Number.isSafeInteger(t)?new Ge(ye.float,t):t>=0?new Ge(ye.uint,t):new Ge(ye.negint,t)},bigint(t,e,r,n){return t>=BigInt(0)?new Ge(ye.uint,t):new Ge(ye.negint,t)},Uint8Array(t,e,r,n){return new Ge(ye.bytes,t)},string(t,e,r,n){return new Ge(ye.string,t)},boolean(t,e,r,n){return t?Jm.true:Jm.false},null(t,e,r,n){return Jm.null},undefined(t,e,r,n){return Jm.undefined},ArrayBuffer(t,e,r,n){return new Ge(ye.bytes,new Uint8Array(t))},DataView(t,e,r,n){return new Ge(ye.bytes,new Uint8Array(t.buffer,t.byteOffset,t.byteLength))},Array(t,e,r,n){if(!t.length)return r.addBreakTokens===!0?[Jm.emptyArray,new Ge(ye.break)]:Jm.emptyArray;n=QT.createCheck(n,t);let i=[],o=0;for(let s of t)i[o++]=PK(s,r,n);return r.addBreakTokens?[new Ge(ye.array,t.length),i,new Ge(ye.break)]:[new Ge(ye.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?[Jm.emptyMap,new Ge(ye.break)]:Jm.emptyMap;n=QT.createCheck(n,t);let a=[],d=0;for(let u of o)a[d++]=[PK(u,r,n),PK(i?t.get(u):t[u],r,n)];return xVe(a,r),r.addBreakTokens?[new Ge(ye.map,s),a,new Ge(ye.break)]:[new Ge(ye.map,s),a]}};Ym.Map=Ym.Object;Ym.Buffer=Ym.Uint8Array;for(let t of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))Ym[`${t}Array`]=Ym.DataView;function PK(t,e={},r){let n=Kpe(t),i=e&&e.typeEncoders&&e.typeEncoders[n]||Ym[n];if(typeof i=="function"){let s=i(t,n,e,r);if(s!=null)return s}let o=Ym[n];if(!o)throw new Error(`${_K} unsupported type: ${n}`);return o(t,n,e,r)}function xVe(t,e){e.mapSorter&&t.sort(e.mapSorter)}h();var EVe={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},TK=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=Bu[e];if(r===void 0){let n=Be[e];if(!n)throw new Error(`${qt} 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}},q6=Symbol.for("DONE"),eI=Symbol.for("BREAK");function SVe(t,e,r){let n=[];for(let i=0;i0)throw new Error(`${qt} too many terminals, data makes no sense`);return r}var zme=42;function IVe(t){return t instanceof ArrayBuffer?new Uint8Array(t,0,t.byteLength):t}function kVe(t){if(t.asCID!==t&&t["/"]!==t.bytes)return null;let e=va.asCID(t);if(!e)return null;let r=new Uint8Array(e.bytes.byteLength+1);return r.set(e.bytes,1),[new Ge(ye.tag,zme),new Ge(ye.bytes,r)]}function RVe(){throw new Error("`undefined` is not supported by the IPLD Data Model and cannot be encoded")}function DVe(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 Fme={float64:!0,typeEncoders:{Object:kVe,undefined:RVe,number:DVe}},BRt={...Fme,typeEncoders:{...Fme.typeEncoders}};function MVe(t){if(t[0]!==0)throw new Error("Invalid CID for CBOR tag 42; expected leading 0x00");return va.decode(t.subarray(1))}var tI={allowIndefinite:!1,coerceUndefinedToNull:!0,allowNaN:!1,allowInfinity:!1,allowBigInt:!0,strict:!0,useMaps:!1,rejectDuplicateMapKeys:!0,tags:[]};tI.tags[zme]=MVe;var CRt={...tI,tags:tI.tags.slice()};var Gme=113;var Wme=t=>IK(IVe(t),tI);var Tye=Ut(Xa(),1);h();var Vme=0,BVe="identity",Jme=Bd,CVe=t=>yy(Vme,Jme(t)),Yme={code:Vme,name:BVe,encode:Jme,digest:CVe};h();var Zme=Ut(Xa(),1);var OVe=async(t,e,r,n,i,o,s,a)=>{let d=await s.get(t,a),u=Wme(d),c=u,l=r;for(;n.length>0;){let m=n[0];if(m in c){n.shift(),l=`${l}/${m}`;let p=Or.asCID(c[m]);if(p!=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:p,name:m,path:l,toResolve:n}};c=c[m]}else throw(0,Zme.default)(new Error(`No property named ${m} 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}}}},Xme=OVe;h();var Qme=Ut(Xa(),1);h();function $Ve(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,F6.default)(new Error("Offset must be greater than or equal to 0"),"ERR_INVALID_PARAMS");if(i>n)throw(0,F6.default)(new Error("Offset must be less than the file size"),"ERR_INVALID_PARAMS");if(o<0n)throw(0,F6.default)(new Error("Length must be greater than or equal to 0"),"ERR_INVALID_PARAMS");if(o>n)throw(0,F6.default)(new Error("Length must be less than the file size"),"ERR_INVALID_PARAMS");return{start:i,end:o}},N1=NVe;var jVe=t=>{async function*e(r={}){let{start:n,end:i}=N1(t.length,r.offset,r.length),o=zg(t,0n,n,i);r.onProgress?.(new si("unixfs:exporter:progress:identity",{bytesRead:BigInt(o.byteLength),totalBytes:i-n,fileSize:BigInt(t.byteLength)})),yield o}return e},UVe=async(t,e,r,n,i,o,s,a)=>{if(n.length>0)throw(0,Qme.default)(new Error(`No link named ${r} found in raw node ${t}`),"ERR_NOT_FOUND");let d=$S(t.multihash.bytes);return{entry:{type:"identity",name:e,path:r,cid:t,content:jVe(d.digest),depth:o,size:BigInt(d.digest.length),node:d.digest}}},eye=UVe;h();var tye=Ut(Xa(),1);var KVe=t=>{async function*e(r={}){let{start:n,end:i}=N1(t.length,r.offset,r.length),o=zg(t,0n,n,i);r.onProgress?.(new si("unixfs:exporter:progress:raw",{bytesRead:BigInt(o.byteLength),totalBytes:i-n,fileSize:BigInt(t.byteLength)})),yield o}return e},qVe=async(t,e,r,n,i,o,s,a)=>{if(n.length>0)throw(0,tye.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:KVe(d),depth:o,size:BigInt(d.length),node:d}}},rye=qVe;h();var Z6=Ut(Xa(),1);h();var LVe=async function(t){return(await E3.encode(t)).slice(0,8).reverse()},FVe=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 Zu({hash:r._options.hash,bits:r._options.bits},e,i));return}await r.put(n.Name.substring(2),!0)}))},nye=t=>t.toString(16).toUpperCase().padStart(2,"0").substring(0,2),zVe=t=>{let e=t.bucket,r=[];for(;e._parent!=null;)r.push(e),e=e._parent;return r.push(e),r.reverse()},iye=async(t,e,r,n,i)=>{if(n==null){let c=P3({hashFn:LVe});n={rootBucket:c,hamtDepth:1,lastBucket:c}}await FVe(t.Links,n.lastBucket,n.rootBucket);let o=await n.rootBucket._findNewBucketAndPos(e),s=nye(o.pos),a=zVe(o);a.length>n.hamtDepth&&(n.lastBucket=a[n.hamtDepth],s=nye(n.lastBucket._posAtParent));let d=t.Links.find(c=>{if(c.Name==null)return!1;let l=c.Name.substring(0,2),m=c.Name.substring(2);return!(l!==s||m!==""&&m!==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=xf(u),iye(t,e,r,n,i)},oye=iye;h();h();h();function GVe(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 rI=GVe;function WVe(t){return t[Symbol.asyncIterator]!=null}function HVe(t,e){if(WVe(t))return async function*(){for await(let a of t)await e(a)&&(yield a)}();let r=rI(t),{value:n,done:i}=r.next();if(i===!0)return function*(){}();let o=e(n);if(typeof o.then=="function")return async function*(){await o&&(yield n);for await(let a of r)await e(a)&&(yield a)}();let s=e;return function*(){o===!0&&(yield n);for(let a of r)s(a)&&(yield a)}()}var sye=HVe;h();function VVe(t){return t[Symbol.asyncIterator]!=null}function JVe(t,e){if(VVe(t))return async function*(){for await(let a of t)yield e(a)}();let r=rI(t),{value:n,done:i}=r.next();if(i===!0)return function*(){}();let o=e(n);if(typeof o.then=="function")return async function*(){yield await o;for await(let a of r)yield e(a)}();let s=e;return function*(){yield o;for(let a of r)yield s(a)}()}var j1=JVe;h();h();function Rh(){let t={};return t.promise=new Promise((e,r)=>{t.resolve=e,t.reject=r}),t}var nI=globalThis.CustomEvent??Event;async function*Gg(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=Rh(),a=Rh(),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=Rh(),await s.promise),c)break;let b={done:!1};o.push(b),g().then(S=>{b.done=!0,b.ok=!0,b.value=S,i.dispatchEvent(new nI("task-complete"))},S=>{b.done=!0,b.err=S,i.dispatchEvent(new nI("task-complete"))})}d=!0,i.dispatchEvent(new nI("task-complete"))}catch(g){u=g,i.dispatchEvent(new nI("task-complete"))}});function l(){return n?o[0]?.done:!!o.find(g=>g.done)}function*m(){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*p(){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}},U1=class{size;hwm;head;tail;constructor(e={}){this.hwm=e.splitLimit??16,this.head=new iI(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 iI(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 kK=class extends Error{type;code;constructor(e,r){super(e??"The operation was aborted"),this.type="aborted",this.code=r??"ABORT_ERR"}};function K1(t={}){return YVe(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 YVe(t,e){e=e??{};let r=e.onEnd,n=new U1,i,o,s,a=Rh(),d=async()=>{try{return n.isEmpty()?s?{done:!0}:await new Promise((S,A)=>{o=I=>{o=null,n.push(I);try{S(t(n))}catch(P){A(P)}return i}}):t(n)}finally{n.isEmpty()&&queueMicrotask(()=>{a.resolve(),a=Rh()})}},u=S=>o!=null?o(S):(n.push(S),i),c=S=>(n=new U1,o!=null?o({error:S}):(n.push({error:S}),i)),l=S=>{if(s)return i;if(e?.objectMode!==!0&&S?.byteLength==null)throw new Error("objectMode was not true but tried to push non-Uint8Array value");return u({done:!1,value:S})},m=S=>s?i:(s=!0,S!=null?c(S):u({done:!0})),p=()=>(n=new U1,m(),{done:!0}),g=S=>(m(S),{done:!0});if(i={[Symbol.asyncIterator](){return this},next:d,return:p,throw:g,push:l,end:m,get readableLength(){return n.size},onEmpty:async S=>{let A=S?.signal;if(A?.throwIfAborted(),n.isEmpty())return;let I,P;A!=null&&(I=new Promise(($,N)=>{P=()=>{N(new kK)},A.addEventListener("abort",P)}));try{await Promise.race([a.promise,I])}finally{P!=null&&A!=null&&A?.removeEventListener("abort",P)}}},r==null)return i;let b=i;return i={[Symbol.asyncIterator](){return this},next(){return b.next()},throw(S){return b.throw(S),r!=null&&(r(S),r=void 0),{done:!0}},return(){return b.return(),r!=null&&(r(),r=void 0),{done:!0}},push:l,end(S){return b.end(S),r!=null&&(r(S),r=void 0),i},get readableLength(){return b.readableLength},onEmpty:S=>b.onEmpty(S)},i}h();function ZVe(t){return t[Symbol.asyncIterator]!=null}function XVe(...t){let e=[];for(let r of t)ZVe(r)||e.push(r);return e.length===t.length?function*(){for(let r of e)yield*r}():async function*(){let r=K1({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 aye=XVe;function q1(t,...e){if(t==null)throw new Error("Empty pipeline");if(RK(t)){let n=t;t=()=>n.source}else if(dye(t)||cye(t)){let n=t;t=()=>n}let r=[t,...e];if(r.length>1&&RK(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},cye=t=>t?.[Symbol.asyncIterator]!=null,dye=t=>t?.[Symbol.iterator]!=null,RK=t=>t==null?!1:t.sink!=null&&t.source!=null,eJe=t=>e=>{let r=t.sink(e);if(r?.then!=null){let n=K1({objectMode:!0});r.then(()=>{n.end()},s=>{n.end(s)});let i,o=t.source;if(cye(o))i=async function*(){yield*o,n.end()};else if(dye(o))i=function*(){yield*o,n.end()};else throw new Error("Unknown duplex source type - must be Iterable or AsyncIterable");return aye(n,i())}return t.source};var tJe=(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 si("unixfs:exporter:walk:directory",{cid:t})),yield*q1(l,m=>j1(m,p=>async()=>{let g=p.Name??"",b=`${n}/${g}`;return(await i(p.Hash,g,b,[],o+1,s,d)).entry}),m=>Gg(m,{ordered:!0}),m=>sye(m,p=>p!=null))}return a},uye=tJe;h();var Hg=Ut(Xa(),1);h();h();var MK=Ut(fye(),1);h();var G6=class extends Error{constructor(e){super(e),this.name="TimeoutError"}},BK=class extends Error{constructor(e){super(),this.name="AbortError",this.message=e}},hye=t=>globalThis.DOMException===void 0?new BK(t):new DOMException(t),pye=t=>{let e=t.reason===void 0?hye("This operation was aborted."):t.reason;return e instanceof Error?e:hye(e)};function CK(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(pye(d)),d.addEventListener("abort",()=>{a(pye(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 G6(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}h();h();function OK(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 Wg=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)},Dh,$K=class{constructor(){Dh.set(this,[])}enqueue(e,r){r={priority:0,...r};let n={priority:r.priority,run:e};if(this.size&&Wg(this,Dh,"f")[this.size-1].priority>=r.priority){Wg(this,Dh,"f").push(n);return}let i=OK(Wg(this,Dh,"f"),n,(o,s)=>s.priority-o.priority);Wg(this,Dh,"f").splice(i,0,n)}dequeue(){let e=Wg(this,Dh,"f").shift();return e?.run}filter(e){return Wg(this,Dh,"f").filter(r=>r.priority===e.priority).map(r=>r.run)}get size(){return Wg(this,Dh,"f").length}};Dh=new WeakMap;var mye=$K;var ti=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},st=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)},Di,H6,V6,Xm,lI,J6,sI,Cu,W6,Rc,aI,Dc,Y6,Zm,cI,yye,gye,wye,bye,vye,dI,NK,jK,fI,_ye,uI,hI=class extends Error{},UK=class extends MK.default{constructor(e){var r,n,i,o;if(super(),Di.add(this),H6.set(this,void 0),V6.set(this,void 0),Xm.set(this,0),lI.set(this,void 0),J6.set(this,void 0),sI.set(this,0),Cu.set(this,void 0),W6.set(this,void 0),Rc.set(this,void 0),aI.set(this,void 0),Dc.set(this,0),Y6.set(this,void 0),Zm.set(this,void 0),cI.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:mye,...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})`);ti(this,H6,e.carryoverConcurrencyCount,"f"),ti(this,V6,e.intervalCap===Number.POSITIVE_INFINITY||e.interval===0,"f"),ti(this,lI,e.intervalCap,"f"),ti(this,J6,e.interval,"f"),ti(this,Rc,new e.queueClass,"f"),ti(this,aI,e.queueClass,"f"),this.concurrency=e.concurrency,this.timeout=e.timeout,ti(this,cI,e.throwOnTimeout===!0,"f"),ti(this,Zm,e.autoStart===!1,"f")}get concurrency(){return st(this,Y6,"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})`);ti(this,Y6,e,"f"),st(this,Di,"m",fI).call(this)}async add(e,r={}){return r={timeout:this.timeout,throwOnTimeout:st(this,cI,"f"),...r},new Promise((n,i)=>{st(this,Rc,"f").enqueue(async()=>{var o,s,a;ti(this,Dc,(s=st(this,Dc,"f"),s++,s),"f"),ti(this,Xm,(a=st(this,Xm,"f"),a++,a),"f");try{if(!((o=r.signal)===null||o===void 0)&&o.aborted)throw new hI("The task was aborted.");let d=e({signal:r.signal});r.timeout&&(d=CK(Promise.resolve(d),r.timeout)),r.signal&&(d=Promise.race([d,st(this,Di,"m",_ye).call(this,r.signal)]));let u=await d;n(u),this.emit("completed",u)}catch(d){if(d instanceof G6&&!r.throwOnTimeout){n();return}i(d),this.emit("error",d)}finally{st(this,Di,"m",wye).call(this)}},r),this.emit("add"),st(this,Di,"m",dI).call(this)})}async addAll(e,r){return Promise.all(e.map(async n=>this.add(n,r)))}start(){return st(this,Zm,"f")?(ti(this,Zm,!1,"f"),st(this,Di,"m",fI).call(this),this):this}pause(){ti(this,Zm,!0,"f")}clear(){ti(this,Rc,new(st(this,aI,"f")),"f")}async onEmpty(){st(this,Rc,"f").size!==0&&await st(this,Di,"m",uI).call(this,"empty")}async onSizeLessThan(e){st(this,Rc,"f").sizest(this,Rc,"f").size{st(this,Di,"m",bye).call(this)},r),"f"),!0}return!1},dI=function(){if(st(this,Rc,"f").size===0)return st(this,Cu,"f")&&clearInterval(st(this,Cu,"f")),ti(this,Cu,void 0,"f"),this.emit("empty"),st(this,Dc,"f")===0&&this.emit("idle"),!1;if(!st(this,Zm,"f")){let e=!st(this,Di,"a",vye);if(st(this,Di,"a",yye)&&st(this,Di,"a",gye)){let r=st(this,Rc,"f").dequeue();return r?(this.emit("active"),r(),e&&st(this,Di,"m",NK).call(this),!0):!1}}return!1},NK=function(){st(this,V6,"f")||st(this,Cu,"f")!==void 0||(ti(this,Cu,setInterval(()=>{st(this,Di,"m",jK).call(this)},st(this,J6,"f")),"f"),ti(this,sI,Date.now()+st(this,J6,"f"),"f"))},jK=function(){st(this,Xm,"f")===0&&st(this,Dc,"f")===0&&st(this,Cu,"f")&&(clearInterval(st(this,Cu,"f")),ti(this,Cu,void 0,"f")),ti(this,Xm,st(this,H6,"f")?st(this,Dc,"f"):0,"f"),st(this,Di,"m",fI).call(this)},fI=function(){for(;st(this,Di,"m",dI).call(this););},_ye=async function(e){return new Promise((r,n)=>{e.addEventListener("abort",()=>{n(new hI("The task was aborted."))},{once:!0})})},uI=async function(e,r){return new Promise(n=>{let i=()=>{r&&!r()||(this.off(e,i),n())};this.on(e,i)})};var xye=UK;async function Eye(t,e,r,n,i,o,s){if(e instanceof Uint8Array){let u=zg(e,n,i,o);r.push(u);return}if(e.Data==null)throw(0,Hg.default)(new Error("no data in PBNode"),"ERR_NOT_UNIXFS");let a;try{a=fo.unmarshal(e.Data)}catch(u){throw(0,Hg.default)(u,"ERR_NOT_UNIXFS")}if(a.data!=null){let u=a.data,c=zg(u,n,i,o);r.push(c),n+=BigInt(c.byteLength)}let d=[];if(e.Links.length!==a.blockSizes.length)throw(0,Hg.default)(new Error("Inconsistent block sizes and dag links"),"ERR_NOT_UNIXFS");for(let u=0;u=l&&i=l&&o<=m||im)&&d.push({link:c,blockStart:n}),n=m,n>o)break}await q1(d,u=>j1(u,c=>async()=>{let l=await t.get(c.link.Hash,s);return{...c,block:l}}),u=>Gg(u,{ordered:!0}),async u=>{for await(let{link:c,block:l,blockStart:m}of u){let p;switch(c.Hash.code){case Z2:p=xf(l);break;case dp:p=l;break;default:r.end((0,Hg.default)(new Error(`Unsupported codec: ${c.Hash.code}`),"ERR_NOT_UNIXFS"));return}let g=new xye({concurrency:1});g.on("error",b=>{r.end(b)}),g.add(async()=>{s.onProgress?.(new si("unixfs:exporter:walk:file",{cid:c.Hash})),await Eye(t,p,r,m,i,o,s)}),await g.onIdle()}}),n>=o&&r.end()}var iJe=(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}=N1(u,d.offset,d.length);if(l===0n)return;let m=0n,p=l-c,g=K1();d.onProgress?.(new si("unixfs:exporter:walk:file",{cid:t})),Eye(s,e,g,0n,c,l,d).catch(b=>{g.end(b)});for await(let b of g)if(b!=null){if(m+=BigInt(b.byteLength),m>p)throw g.end(),(0,Hg.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");m===p&&g.end(),d.onProgress?.(new si("unixfs:exporter:progress:unixfs:file",{bytesRead:m,totalBytes:p,fileSize:u})),yield b}if(m{function a(d={}){return d.onProgress?.(new si("unixfs:exporter:walk:hamt-sharded-directory",{cid:t})),Sye(e,n,i,o,s,d)}return a};async function*Sye(t,e,r,n,i,o){let s=t.Links,a=q1(s,d=>j1(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=xf(l),o.onProgress?.(new si("unixfs:exporter:walk:hamt-sharded-directory",{cid:u.Hash})),{entries:Sye(t,e,r,n,i,o)}}}),d=>Gg(d,{ordered:!0}));for await(let{entries:d}of a)yield*d}var Aye=oJe;var sJe=(t,e)=>t.Links.find(n=>n.Name===e)?.Hash,aJe={raw:KK,file:KK,directory:uye,"hamt-sharded-directory":Aye,metadata:(t,e,r,n,i,o,s)=>()=>[],symlink:(t,e,r,n,i,o,s)=>()=>[]},cJe=async(t,e,r,n,i,o,s,a)=>{let d=await s.get(t,a),u=xf(d),c,l;if(e==null&&(e=t.toString()),u.Data==null)throw(0,Z6.default)(new Error("no data in PBNode"),"ERR_NOT_UNIXFS");try{c=fo.unmarshal(u.Data)}catch(p){throw(0,Z6.default)(p,"ERR_NOT_UNIXFS")}if(r==null&&(r=e),n.length>0){let p;if(c?.type==="hamt-sharded-directory"?p=await oye(u,n[0],s):p=sJe(u,n[0]),p==null)throw(0,Z6.default)(new Error("file does not exist"),"ERR_NOT_FOUND");let g=n.shift(),b=`${r}/${g}`;l={cid:p,toResolve:n,name:g??"",path:b}}let m=aJe[c.type](t,u,c,r,i,o,s);if(m==null)throw(0,Z6.default)(new Error("could not find content exporter"),"ERR_NOT_FOUND");return c.isDirectory()?{entry:{type:"directory",name:e,path:r,cid:t,content:m,unixfs:c,depth:o,node:u,size:c.fileSize()},next:l}:{entry:{type:"file",name:e,path:r,cid:t,content:m,unixfs:c,depth:o,node:u,size:c.fileSize()},next:l}},Pye=cJe;var dJe={[Z2]:Pye,[dp]:rye,[Gme]:Xme,[Yme.code]:eye},Iye=async(t,e,r,n,i,o,s)=>{let a=dJe[t.code];if(a==null)throw(0,Tye.default)(new Error(`No resolver for code ${t.code}`),"ERR_NO_RESOLVER");return a(t,e,r,n,Iye,i,o,s)},kye=Iye;var uJe=(t="")=>(t.trim().match(/([^\\^/]|\\\/)+/g)??[]).filter(Boolean),lJe=t=>{if(t instanceof Uint8Array)return{cid:Or.decode(t),toResolve:[]};let e=Or.asCID(t);if(e!=null)return{cid:e,toResolve:[]};if(typeof t=="string"){t.indexOf("/ipfs/")===0&&(t=t.substring(6));let r=uJe(t);return{cid:Or.parse(r[0]),toResolve:r.slice(1)}}throw(0,pI.default)(new Error(`Unknown path type ${t}`),"ERR_BAD_PATH")};async function*fJe(t,e,r={}){let{cid:n,toResolve:i}=lJe(t),o=n.toString(),s=o,a=i.length;for(;;){let d=await kye(n,o,s,i,a,e,r);if(d.entry==null&&d.next==null)throw(0,pI.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 Rye(t,e,r={}){let n=await Upe(fJe(t,e,r));if(n==null)throw(0,pI.default)(new Error(`Could not resolve ${t}`),"ERR_NOT_FOUND");return n}var Dye=Ut(x4(),1),Qm=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())})},hJe=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)}},Vg=class{constructor(e={}){this.config=Object.assign({blockstoreLocation:"DATASTORE",createLevelDatabase:Du},e),this.blockstore=new D1({location:this.config.blockstoreLocation,createLevelDatabase:this.config.createLevelDatabase})}open(){return Qm(this,void 0,void 0,function*(){yield this.blockstore.open()})}close(){return Qm(this,void 0,void 0,function*(){yield this.blockstore.close()})}put(e,r,n,i){var o,s,a,d,u,c;return Qm(this,void 0,void 0,function*(){let l=yield this.getBlockstoreForStoringData(e,r,n),m=a_([{content:i}],l,{cidVersion:1}),p;try{for(var g=!0,b=hJe(m),S;S=yield b.next(),o=S.done,!o;g=!0)d=S.value,g=!1,p=d}catch(A){s={error:A}}finally{try{!g&&!o&&(a=b.return)&&(yield a.call(b))}finally{if(s)throw s.error}}return{dataSize:Number((c=(u=p.unixfs)===null||u===void 0?void 0:u.fileSize())!==null&&c!==void 0?c:p.size)}})}get(e,r,n){return Qm(this,void 0,void 0,function*(){let i=yield this.getBlockstoreForStoringData(e,r,n);if(!(yield i.has(n)))return;let s=yield Rye(n,i),a=s.content(),d=new Dye.Readable({read(){return Qm(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 Qm(this,void 0,void 0,function*(){yield(yield this.getBlockstoreForStoringData(e,r,n)).clear()})}clear(){return Qm(this,void 0,void 0,function*(){yield this.blockstore.clear()})}getBlockstoreForStoringData(e,r,n){return Qm(this,void 0,void 0,function*(){let i="data";return yield(yield(yield(yield this.blockstore.partition(i)).partition(e)).partition(r)).partition(n)})}};h();h();var no=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())})},X6=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)}},Jg=function(t){return this instanceof Jg?(this.v=t,this):new Jg(t)},pJe=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(m){n[m]&&(i[m]=function(p){return new Promise(function(g,b){o.push([m,p,g,b])>1||a(m,p)})})}function a(m,p){try{d(n[m](p))}catch(g){l(o[0][3],g)}}function d(m){m.value instanceof Jg?Promise.resolve(m.value.v).then(u,c):l(o[0][2],m)}function u(m){a("next",m)}function c(m){a("throw",m)}function l(m,p){m(p),o.shift(),o.length&&a(o[0][0],o[0][1])}},Mye="index",Mh=class t{constructor(e){this.config=Object.assign({createLevelDatabase:Du},e),this.db=new R1({location:this.config.location,createLevelDatabase:this.config.createLevelDatabase,keyEncoding:"utf8"})}open(){return no(this,void 0,void 0,function*(){yield this.db.open()})}close(){return no(this,void 0,void 0,function*(){yield this.db.close()})}clear(){return no(this,void 0,void 0,function*(){yield this.db.clear()})}put(e,r,n,i){return no(this,void 0,void 0,function*(){if(Ax(n))throw new oe(ne.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 m of l){let p=this.createPutIndexedItemOperation(e,o,c,m);s.push(p)}else{let m=this.createPutIndexedItemOperation(e,o,c,l);s.push(m)}}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 no(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 m=this.createDeleteIndexedItemOperation(e,r,u,l);i.push(m)}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 no(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 no(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 no(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 no(this,void 0,void 0,function*(){return(yield this.db.partition(e)).createPartitionOperation(Mye,r)})}static getIndexPartitionName(e){return`__${e}__`}getIndexPartition(e,r){return no(this,void 0,void 0,function*(){let n=t.getIndexPartitionName(r);return(yield this.db.partition(e)).partition(n)})}getIndexesLookupPartition(e){return no(this,void 0,void 0,function*(){return(yield this.db.partition(e)).partition(Mye)})}query(e,r,n,i){return no(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 no(this,void 0,void 0,function*(){let{cursor:u,limit:c}=n,l=u?this.createStartingKeyFromCursor(u):"",m=[];try{for(var p=!0,g=X6(this.getIndexIterator(e,l,n,i)),b;b=yield g.next(),o=b.done,!o;p=!0){d=b.value,p=!1;let S=d;if(c!==void 0&&c===m.length)break;let{indexes:A}=S;Hn.matchAnyFilter(A,r)&&m.push(S)}}catch(S){s={error:S}}finally{try{!p&&!o&&(a=g.return)&&(yield a.call(g))}finally{if(s)throw s.error}}return m})}getIndexIterator(e,r,n,i){return pJe(this,arguments,function*(){var s,a,d,u;let{sortProperty:c,sortDirection:l=ns.Ascending,cursor:m}=n,p={gt:r};l===ns.Descending&&(p.reverse=!0,m!==void 0&&(p.lt=r,delete p.gt));let g=yield Jg(this.getIndexPartition(e,c));try{for(var b=!0,S=X6(g.iterator(p,i)),A;A=yield Jg(S.next()),s=A.done,!s;b=!0){u=A.value,b=!1;let[I,P]=u,{indexes:$,messageCid:N}=JSON.parse(P);yield yield Jg({indexes:$,messageCid:N})}}catch(I){a={error:I}}finally{try{!b&&!s&&(d=S.return)&&(yield Jg(d.call(S)))}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 oe(ne.IndexInvalidCursorSortProperty,`the sort property '${r}' is not defined within the given item.`);if(typeof o=="boolean"||Array.isArray(o))throw new oe(ne.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 no(this,void 0,void 0,function*(){let{sortProperty:o,sortDirection:s=ns.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===ne.IndexInvalidSortPropertyInMemory)return[]}let l=[...c.values()].sort((g,b)=>this.sortItems(g,b,o,s)),m=u!==void 0?this.findCursorStartingIndex(l,s,o,u):0;if(m<0)return[];let p=d!==void 0?m+d:void 0;return l.slice(m,p)})}executeSingleFilterQuery(e,r,n,i,o){return no(this,void 0,void 0,function*(){let s=[];if(Ax(r)){let d=this.getAllItems(e,n);s.push(d)}let a=T4.reduceFilter(r);for(let d in a){let u=a[d];if(Hn.isEqualFilter(u)){let c=this.filterExactMatches(e,d,u,o);s.push(c)}else if(Hn.isOneOfFilter(u))for(let c of new Set(u)){let l=this.filterExactMatches(e,d,c,o);s.push(l)}else if(Hn.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)||!Hn.matchFilter(c.indexes,r))){if(c.indexes[n]===void 0)throw new oe(ne.IndexInvalidSortPropertyInMemory,`invalid sort property ${n}`);i.set(c.messageCid,c)}}})}getAllItems(e,r){var n,i,o,s;return no(this,void 0,void 0,function*(){let a=yield this.getIndexPartition(e,r),d=[];try{for(var u=!0,c=X6(a.iterator()),l;l=yield c.next(),n=l.done,!n;u=!0){s=l.value,u=!1;let[m,p]=s;d.push(JSON.parse(p))}}catch(m){i={error:m}}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 no(this,void 0,void 0,function*(){let u=t.keySegmentJoin(t.encodeValue(n)),c={gt:u},l=yield this.getIndexPartition(e,r),m=[];try{for(var p=!0,g=X6(l.iterator(c,i)),b;b=yield g.next(),o=b.done,!o;p=!0){d=b.value,p=!1;let[S,A]=d;if(!S.startsWith(u))break;m.push(JSON.parse(A))}}catch(S){s={error:S}}finally{try{!p&&!o&&(a=g.return)&&(yield a.call(g))}finally{if(s)throw s.error}}return m})}filterRangeMatches(e,r,n,i){var o,s,a,d;return no(this,void 0,void 0,function*(){let u={};for(let b in n){let S=b;u[S]=t.encodeValue(n[S])}u.gt===void 0&&u.gte===void 0&&(u.reverse=!0);let c=[],l=yield this.getIndexPartition(e,r);try{for(var m=!0,p=X6(l.iterator(u,i)),g;g=yield p.next(),o=g.done,!o;m=!0){d=g.value,m=!1;let[b,S]=d;"gt"in n&&this.extractIndexValueFromKey(b)===t.encodeValue(n.gt)||c.push(JSON.parse(S))}}catch(b){s={error:b}}finally{try{!m&&!o&&(a=p.return)&&(yield a.call(p))}finally{if(s)throw s.error}}if("lte"in n)for(let b of yield this.filterExactMatches(e,r,n.lte,i))c.push(b);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===ns.Ascending?Sx(a,d):Sx(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===ns.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 Ou({info:{code:"PRNG_DETECT",...Yg}},"Failed to find a reliable PRNG")}function bJe(){return _Je()?self:typeof window<"u"?window:typeof globalThis<"u"||typeof globalThis<"u"?globalThis:null}function vJe(t,e){let r="";for(;t>0;t--)r=xJe(e)+r;return r}function $ye(t,e){if(isNaN(t))throw new Ou({info:{code:"ENC_TIME_NAN",...Yg}},`Time must be a number: ${t}`);if(t>Cye)throw new Ou({info:{code:"ENC_TIME_SIZE_EXCEED",...Yg}},`Cannot encode a time larger than ${Cye}: ${t}`);if(t<0)throw new Ou({info:{code:"ENC_TIME_NEG",...Yg}},`Time must be positive: ${t}`);if(Number.isInteger(t)===!1)throw new Ou({info:{code:"ENC_TIME_TYPE",...Yg}},`Time must be an integer: ${t}`);let r,n="";for(let i=e;i>0;i--)r=t%F1,n=eS.charAt(r)+n,t=(t-r)/F1;return n}function wJe(t){let e,r=t.length,n,i,o=t,s=F1-1;for(;!e&&r-->=0;){if(n=o[r],i=eS.indexOf(n),i===-1)throw new Ou({info:{code:"B32_INC_ENC",...Yg}},"Incorrectly encoded string");if(i===s){o=Nye(o,r,eS[0]);continue}e=Nye(o,r,eS[i+1])}if(typeof e=="string")return e;throw new Ou({info:{code:"B32_INC_INVALID",...Yg}},"Failed incrementing string")}function _Je(){return typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope}function mI(t){let e=t||gJe(),r=0,n;return function(o){let s=isNaN(o)?Date.now():o;if(s<=r){let d=n=wJe(n);return $ye(r,Oye)+d}r=s;let a=n=vJe(yJe,e);return $ye(s,Oye)+a}}function xJe(t){let e=Math.floor(t()*F1);return e===F1&&(e=F1-1),eS.charAt(e)}function Nye(t,e,r){return e>t.length-1?t:t.substr(0,e)+r+t.substr(e+1)}var Zg=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())})},Xg=class{constructor(e){this.index=new Mh(Object.assign({location:"EVENTLOG",createLevelDatabase:Du},e)),this.ulidFactory=mI()}open(){return Zg(this,void 0,void 0,function*(){return this.index.open()})}close(){return Zg(this,void 0,void 0,function*(){return this.index.close()})}clear(){return Zg(this,void 0,void 0,function*(){return this.index.clear()})}append(e,r,n){return Zg(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 Zg(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:Mh.createCursorFromLastArrayItem(i,"watermark")}})}getEvents(e,r){return Zg(this,void 0,void 0,function*(){return this.queryEvents(e,[],r)})}deleteEventsByCid(e,r){return Zg(this,void 0,void 0,function*(){let n=[];for(let i of r)n.push(this.index.delete(e,i));yield Promise.all(n)})}};h();h();function yI({enumerable:t=!0,configurable:e=!1}={}){return{enumerable:t,configurable:e,writable:!1}}function*EJe(t,e){if(e!=null&&typeof e=="object")if(Array.isArray(e))for(let[r,n]of e.entries()){let i=[...t,r],o=Or.asCID(n);o?yield[i.join("/"),o]:typeof n=="object"&&(yield*qK(n,i))}else{let r=Or.asCID(e);r?yield[t.join("/"),r]:yield*qK(e,t)}}function*qK(t,e){if(t==null||t instanceof Uint8Array)return;let r=Or.asCID(t);r&&(yield[e.join("/"),r]);for(let[n,i]of Object.entries(t)){let o=[...e,n];yield*EJe(o,i)}}function*SJe(t,e){if(Array.isArray(e))for(let[r,n]of e.entries()){let i=[...t,r];yield i.join("/"),typeof n=="object"&&!Or.asCID(n)&&(yield*LK(n,i))}else yield*LK(e,t)}function*LK(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"&&!Or.asCID(n)&&(yield*SJe(i,n))}}function AJe(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=Or.asCID(r);if(o)return{value:o,remaining:e.slice(n+1).join("/")}}return{value:r}}var gI=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:yI(),bytes:yI(),value:yI(),asBlock:yI()})}links(){return qK(this.value,[])}tree(){return LK(this.value,[])}get(e="/"){return AJe(this.value,e.split("/").filter(Boolean))}};async function jye({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=Or.create(1,e.code,i);return new gI({value:t,bytes:n,cid:o})}async function Uye({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=Or.create(1,e.code,i);return new gI({value:n,bytes:t,cid:o})}var Qg=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())})},eb=class t{constructor(e={}){this.config=Object.assign({blockstoreLocation:"MESSAGESTORE",indexLocation:"INDEX",createLevelDatabase:Du},e),this.blockstore=new D1({location:this.config.blockstoreLocation,createLevelDatabase:this.config.createLevelDatabase}),this.index=new Mh({location:this.config.indexLocation,createLevelDatabase:this.config.createLevelDatabase})}open(){return Qg(this,void 0,void 0,function*(){yield this.blockstore.open(),yield this.index.open()})}close(){return Qg(this,void 0,void 0,function*(){yield this.blockstore.close(),yield this.index.close()})}get(e,r,n){var i;return Qg(this,void 0,void 0,function*(){(i=n?.signal)===null||i===void 0||i.throwIfAborted();let o=yield Ki(this.blockstore.partition(e),n?.signal),s=Or.parse(r),a=yield o.get(s,n);return a?(yield Ki(Uye({bytes:a,codec:Dy,hasher:ps}),n?.signal)).value:void 0})}query(e,r,n,i,o){var s;return Qg(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 Qg(this,void 0,void 0,function*(){(i=n?.signal)===null||i===void 0||i.throwIfAborted();let o=yield Ki(this.blockstore.partition(e),n?.signal),s=Or.parse(r);yield o.delete(s,n),yield this.index.delete(e,r,n)})}put(e,r,n,i){var o;return Qg(this,void 0,void 0,function*(){(o=i?.signal)===null||o===void 0||o.throwIfAborted();let s=yield Ki(this.blockstore.partition(e),i?.signal),a=yield Ki(jye({value:r,codec:Dy,hasher:ps}),i?.signal),d=Sn.parseCid(yield be.getCid(r));yield s.put(d,a.bytes,i);let u=d.toString();yield this.index.put(e,u,n,i)})}clear(){return Qg(this,void 0,void 0,function*(){yield this.blockstore.clear(),yield this.index.clear()})}};h();var Kye=Ut(nc(),1);var bI=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())})},FK="events",tS=class{constructor(e={}){this.isOpen=!1,this.errorHandler=r=>{console.error("event emitter error",r)},this.eventEmitter=new Kye.EventEmitter({captureRejections:!0}),this.eventEmitter.setMaxListeners(0),e.errorHandler&&(this.errorHandler=e.errorHandler),this.eventEmitter.on("error",this.errorHandler)}subscribe(e,r,n){return bI(this,void 0,void 0,function*(){return this.eventEmitter.on(`${e}_${FK}`,n),{id:r,close:()=>bI(this,void 0,void 0,function*(){this.eventEmitter.off(`${e}_${FK}`,n)})}})}open(){return bI(this,void 0,void 0,function*(){this.isOpen=!0})}close(){return bI(this,void 0,void 0,function*(){this.isOpen=!1,this.eventEmitter.removeAllListeners()})}emit(e,r,n){if(!this.isOpen){this.errorHandler(new oe(ne.EventEmitterStreamNotOpenError,"a message emitted when EventEmitterStream is closed"));return}this.eventEmitter.emit(`${e}_${FK}`,e,r,n)}};h();var qr=(l=>(l[l.EventsGet=Ae.Events+_e.Get]="EventsGet",l[l.EventsQuery=Ae.Events+_e.Query]="EventsQuery",l[l.EventsSubscribe=Ae.Events+_e.Subscribe]="EventsSubscribe",l[l.MessagesGet=Ae.Messages+_e.Get]="MessagesGet",l[l.ProtocolsConfigure=Ae.Protocols+_e.Configure]="ProtocolsConfigure",l[l.ProtocolsQuery=Ae.Protocols+_e.Query]="ProtocolsQuery",l[l.RecordsDelete=Ae.Records+_e.Delete]="RecordsDelete",l[l.RecordsQuery=Ae.Records+_e.Query]="RecordsQuery",l[l.RecordsRead=Ae.Records+_e.Read]="RecordsRead",l[l.RecordsSubscribe=Ae.Records+_e.Subscribe]="RecordsSubscribe",l[l.RecordsWrite=Ae.Records+_e.Write]="RecordsWrite",l))(qr||{}),z1={[qr.EventsGet]:im,[qr.EventsQuery]:sm,[qr.EventsSubscribe]:am,[qr.MessagesGet]:cm,[qr.ProtocolsConfigure]:gm,[qr.ProtocolsQuery]:bm,[qr.RecordsDelete]:vm,[qr.RecordsQuery]:nm,[qr.RecordsRead]:sg,[qr.RecordsSubscribe]:wm,[qr.RecordsWrite]:zr};h();var ey=class{constructor({did:e,metadata:r}){this.did=e,this.metadata=r}async export(){return{portableDid:await this.did.export(),metadata:this.metadata}}};h();h();h();var vI=class{static async deriveKeyBytes({baseKeyBytes:e,length:r,hash:n,salt:i,info:o=new Uint8Array}){let a=await da().importKey("raw",e,{name:"HKDF"},!1,["deriveBits"]);i=typeof i=="string"?de.string(i).toUint8Array():i,o=typeof o=="string"?de.string(o).toUint8Array():o;let d=await crypto.subtle.deriveBits({name:"HKDF",hash:n,salt:i,info:o},a,r);return new Uint8Array(d)}};var wI=class extends ei{async deriveKeyBytes({algorithm:e,...r}){let n={"HKDF-256":"SHA-256","HKDF-384":"SHA-384","HKDF-512":"SHA-512"}[e];return await vI.deriveKeyBytes({...r,hash:n})}};h();h();var it=class t extends Error{constructor(r,n){super(n);this.code=r;this.name="CryptoError",Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,t)}};var rS=class extends ei{async bytesToPrivateKey({algorithm:e,privateKeyBytes:r}){switch(e){case"ES256K":case"secp256k1":{let n=await Er.bytesToPrivateKey({privateKeyBytes:r});return n.alg="EdDSA",n}case"ES256":case"secp256r1":{let n=await Br.bytesToPrivateKey({privateKeyBytes:r});return n.alg="EdDSA",n}default:throw new it("algorithmNotSupported",`Algorithm not supported: ${e}`)}}async bytesToPublicKey({algorithm:e,publicKeyBytes:r}){switch(e){case"ES256K":case"secp256k1":{let n=await Er.bytesToPublicKey({publicKeyBytes:r});return n.alg="EdDSA",n}case"ES256":case"secp256r1":{let n=await Br.bytesToPublicKey({publicKeyBytes:r});return n.alg="EdDSA",n}default:throw new it("algorithmNotSupported",`Algorithm not supported: ${e}`)}}async computePublicKey({key:e}){if(!Na(e))throw new TypeError("Invalid key provided. Must be an elliptic curve (EC) private key.");switch(e.crv){case"secp256k1":{let r=await Er.computePublicKey({key:e});return r.alg="ES256K",r}case"P-256":{let r=await Br.computePublicKey({key:e});return r.alg="ES256",r}default:throw new Error(`Unsupported curve: ${e.crv}`)}}async generateKey({algorithm:e}){switch(e){case"ES256K":case"secp256k1":{let r=await Er.generateKey();return r.alg="ES256K",r}case"ES256":case"secp256r1":{let r=await Br.generateKey();return r.alg="ES256",r}}}async getPublicKey({key:e}){if(!Na(e))throw new TypeError("Invalid key provided. Must be an elliptic curve (EC) private key.");switch(e.crv){case"secp256k1":{let r=await Er.getPublicKey({key:e});return r.alg="ES256K",r}case"P-256":{let r=await Br.getPublicKey({key:e});return r.alg="ES256",r}default:throw new Error(`Unsupported curve: ${e.crv}`)}}async privateKeyToBytes({privateKey:e}){switch(e.crv){case"secp256k1":return await Er.privateKeyToBytes({privateKey:e});case"P-256":return await Br.privateKeyToBytes({privateKey:e});default:throw new it("algorithmNotSupported",`Curve not supported: ${e.crv}`)}}async publicKeyToBytes({publicKey:e}){switch(e.crv){case"secp256k1":return await Er.publicKeyToBytes({publicKey:e});case"P-256":return await Br.publicKeyToBytes({publicKey:e});default:throw new it("algorithmNotSupported",`Curve not supported: ${e.crv}`)}}async sign({key:e,data:r}){if(!Na(e))throw new TypeError("Invalid key provided. Must be an elliptic curve (EC) private key.");switch(e.crv){case"secp256k1":return await Er.sign({key:e,data:r});case"P-256":return await Br.sign({key:e,data:r});default:throw new Error(`Unsupported curve: ${e.crv}`)}}async verify({key:e,signature:r,data:n}){if(!$m(e))throw new TypeError("Invalid key provided. Must be an elliptic curve (EC) public key.");switch(e.crv){case"secp256k1":return await Er.verify({key:e,signature:r,data:n});case"P-256":return await Br.verify({key:e,signature:r,data:n});default:throw new Error(`Unsupported curve: ${e.crv}`)}}};h();var _I=class extends ei{async bytesToPrivateKey({algorithm:e,privateKeyBytes:r}){switch(e){case"Ed25519":{let n=await er.bytesToPrivateKey({privateKeyBytes:r});return n.alg="EdDSA",n}default:throw new it("algorithmNotSupported",`Algorithm not supported: ${e}`)}}async bytesToPublicKey({algorithm:e,publicKeyBytes:r}){switch(e){case"Ed25519":{let n=await er.bytesToPublicKey({publicKeyBytes:r});return n.alg="EdDSA",n}default:throw new it("algorithmNotSupported",`Algorithm not supported: ${e}`)}}async computePublicKey({key:e}){if(!ja(e))throw new TypeError("Invalid key provided. Must be an octet key pair (OKP) private key.");switch(e.crv){case"Ed25519":{let r=await er.computePublicKey({key:e});return r.alg="EdDSA",r}default:throw new it("algorithmNotSupported",`Curve not supported: ${e.crv}`)}}async generateKey({algorithm:e}){switch(e){case"Ed25519":{let r=await er.generateKey();return r.alg="EdDSA",r}}}async getPublicKey({key:e}){if(!ja(e))throw new TypeError("Invalid key provided. Must be an octet key pair (OKP) private key.");switch(e.crv){case"Ed25519":{let r=await er.getPublicKey({key:e});return r.alg="EdDSA",r}default:throw new Error(`Unsupported curve: ${e.crv}`)}}async privateKeyToBytes({privateKey:e}){switch(e.crv){case"Ed25519":return await er.privateKeyToBytes({privateKey:e});default:throw new it("algorithmNotSupported",`Curve not supported: ${e.crv}`)}}async publicKeyToBytes({publicKey:e}){switch(e.crv){case"Ed25519":return await er.publicKeyToBytes({publicKey:e});default:throw new it("algorithmNotSupported",`Curve not supported: ${e.crv}`)}}async sign({key:e,data:r}){if(!ja(e))throw new TypeError("Invalid key provided. Must be an octet key pair (OKP) private key.");switch(e.crv){case"Ed25519":return await er.sign({key:e,data:r});default:throw new it("algorithmNotSupported",`Curve not supported: ${e.crv}`)}}async verify({key:e,signature:r,data:n}){if(!Nm(e))throw new TypeError("Invalid key provided. Must be an octet key pair (OKP) public key.");switch(e.crv){case"Ed25519":return await er.verify({key:e,signature:r,data:n});default:throw new it("algorithmNotSupported",`Curve not supported: ${e.crv}`)}}};h();h();var qye=[128,192,256],ty=class{static async bytesToPrivateKey({privateKeyBytes:e}){let r={k:de.uint8Array(e).toBase64Url(),kty:"oct"};r.kid=await rt({jwk:r});let n=e.length*8;return r.alg={128:"A128KW",192:"A192KW",256:"A256KW"}[n],r}static async generateKey({length:e}){if(!qye.includes(e))throw new RangeError(`The key length is invalid: Must be ${qye.join(", ")} bits`);let r=da(),n=await r.generateKey({name:"AES-KW",length:e},!0,["wrapKey","unwrapKey"]),{ext:i,key_ops:o,...s}=await r.exportKey("jwk",n);return s.kid=await rt({jwk:s}),s}static async privateKeyToBytes({privateKey:e}){if(!Cg(e))throw new Error("AesKw: The provided key is not a valid oct private key.");return de.base64Url(e.k).toUint8Array()}static async unwrapKey({wrappedKeyBytes:e,wrappedKeyAlgorithm:r,decryptionKey:n}){if(!("alg"in n&&n.alg))throw new it("invalidJwk","The decryption key is missing the 'alg' property.");if(!["A128KW","A192KW","A256KW"].includes(n.alg))throw new it("algorithmNotSupported",`The 'decryptionKey' algorithm is not supported: ${n.alg}`);let i=da(),o=await i.importKey("jwk",n,{name:"AES-KW"},!0,["unwrapKey"]),s={A128KW:"AES-KW",A192KW:"AES-KW",A256KW:"AES-KW",A128GCM:"AES-GCM",A192GCM:"AES-GCM",A256GCM:"AES-GCM"}[r];if(!s)throw new it("algorithmNotSupported",`The 'wrappedKeyAlgorithm' is not supported: ${r}`);let a=await i.unwrapKey("raw",e.buffer,o,"AES-KW",{name:s},!0,["unwrapKey"]),{ext:d,key_ops:u,...c}=await i.exportKey("jwk",a),l=c;return l.kid=await rt({jwk:l}),l}static async wrapKey({unwrappedKey:e,encryptionKey:r}){if(!("alg"in r&&r.alg))throw new it("invalidJwk","The encryption key is missing the 'alg' property.");if(!["A128KW","A192KW","A256KW"].includes(r.alg))throw new it("algorithmNotSupported",`The 'encryptionKey' algorithm is not supported: ${r.alg}`);if(!("alg"in e&&e.alg))throw new it("invalidJwk","The private key to wrap is missing the 'alg' property.");let n=da(),i=await n.importKey("jwk",r,{name:"AES-KW"},!0,["wrapKey"]),o={A128KW:"AES-KW",A192KW:"AES-KW",A256KW:"AES-KW",A128GCM:"AES-GCM",A192GCM:"AES-GCM",A256GCM:"AES-GCM"}[e.alg];if(!o)throw new it("algorithmNotSupported",`The 'unwrappedKey' algorithm is not supported: ${e.alg}`);let s=await n.importKey("jwk",e,{name:o},!0,["unwrapKey"]),a=await n.wrapKey("raw",s,i,"AES-KW");return new Uint8Array(a)}};var G1=class extends ei{async bytesToPrivateKey({privateKeyBytes:e}){let r=await ty.bytesToPrivateKey({privateKeyBytes:e});return r.alg={16:"A128KW",24:"A192KW",32:"A256KW"}[e.length],r}async generateKey({algorithm:e}){let r={A128KW:128,A192KW:192,A256KW:256}[e],n=await ty.generateKey({length:r});return n.alg=e,n}async privateKeyToBytes({privateKey:e}){return await ty.privateKeyToBytes({privateKey:e})}async unwrapKey(e){return await ty.unwrapKey(e)}async wrapKey(e){return ty.wrapKey(e)}};h();h();var xI=class{static async deriveKeyBytes({baseKeyBytes:e,hash:r,salt:n,iterations:i,length:o}){let s=da(),a=await s.importKey("raw",e,{name:"PBKDF2"},!1,["deriveBits"]),d=await s.deriveBits({name:"PBKDF2",hash:r,salt:n,iterations:i},a,o);return new Uint8Array(d)}};var EI=class extends ei{async deriveKeyBytes({algorithm:e,...r}){let[,n]=e.split(/[-+]/),i={HS256:"SHA-256",HS384:"SHA-384",HS512:"SHA-512"}[n];return await xI.deriveKeyBytes({...r,hash:i})}};h();var SI=class extends ei{async bytesToPrivateKey({privateKeyBytes:e}){let r=await Ad.bytesToPrivateKey({privateKeyBytes:e});return r.alg={16:"A128GCM",24:"A192GCM",32:"A256GCM"}[e.length],r}async decrypt(e){return Ad.decrypt(e)}async encrypt(e){return Ad.encrypt(e)}async generateKey({algorithm:e}){let r={A128GCM:128,A192GCM:192,A256GCM:256}[e],n=await Ad.generateKey({length:r});return n.alg=e,n}async privateKeyToBytes({privateKey:e}){return await Ad.privateKeyToBytes({privateKey:e})}};var zK={"AES-GCM":{implementation:SI,names:["A128GCM","A192GCM","A256GCM"],operations:["bytesToPrivateKey","decrypt","encrypt","generateKey"]},"AES-KW":{implementation:G1,names:["A128KW","A192KW","A256KW"],operations:["bytesToPrivateKey","generateKey","privateKeyToBytes","wrapKey","unwrapKey"]},Ed25519:{implementation:_I,names:["Ed25519"],operations:["bytesToPrivateKey","bytesToPublicKey","generateKey","sign","verify"]},HKDF:{implementation:wI,names:["HKDF-256","HKDF-384","HKDF-512"],operations:["deriveKey","deriveKeyBytes"]},PBKDF2:{implementation:EI,names:["PBES2-HS256+A128KW","PBES2-HS384+A192KW","PBES2-HS512+A256KW"],operations:["deriveKey","deriveKeyBytes"]},secp256k1:{implementation:rS,names:["ES256K","secp256k1"],operations:["bytesToPrivateKey","bytesToPublicKey","generateKey","sign","verify"]},secp256r1:{implementation:rS,names:["ES256","secp256r1"],operations:["bytesToPrivateKey","bytesToPublicKey","generateKey","sign","verify"]},"SHA-256":{implementation:Om,names:["SHA-256"],operations:["digest"]}},Mc=class{constructor(){this._algorithmInstances=new Map}async bytesToPrivateKey({algorithm:e,privateKeyBytes:r}){let n=this.getAlgorithmName({algorithm:e});return await this.getAlgorithm({algorithm:n}).bytesToPrivateKey({algorithm:e,privateKeyBytes:r})}async bytesToPublicKey({algorithm:e,publicKeyBytes:r}){let n=this.getAlgorithmName({algorithm:e});return await this.getAlgorithm({algorithm:n}).bytesToPublicKey({algorithm:e,publicKeyBytes:r})}async decrypt(e){let r=this.getAlgorithmName({key:e.key});return await this.getAlgorithm({algorithm:r}).decrypt(e)}async deriveKey(e){let r=this.getAlgorithmName({algorithm:e.algorithm}),n=this.getAlgorithm({algorithm:r}),i;switch(e.algorithm){case"HKDF-256":case"HKDF-384":case"HKDF-512":{i=e.derivedKeyAlgorithm;break}case"PBES2-HS256+A128KW":case"PBES2-HS384+A192KW":case"PBES2-HS512+A256KW":{i=e.algorithm.split(/[-+]/)[2];break}default:throw new it("algorithmNotSupported",`The specified "algorithm" is not supported: ${e.algorithm}`)}let o=+(i.match(/\d+/)?.[0]??-1);if(o===-1)throw new it("algorithmNotSupported",`The derived key algorithm" is not supported: ${i}`);let s=await n.deriveKeyBytes({...e,length:o});return await this.bytesToPrivateKey({algorithm:i,privateKeyBytes:s})}async deriveKeyBytes(e){let r=this.getAlgorithmName({algorithm:e.algorithm});return await this.getAlgorithm({algorithm:r}).deriveKeyBytes(e)}async digest({algorithm:e,data:r}){return await this.getAlgorithm({algorithm:e}).digest({algorithm:e,data:r})}async encrypt(e){let r=this.getAlgorithmName({key:e.key});return await this.getAlgorithm({algorithm:r}).encrypt(e)}async generateKey(e){let r=this.getAlgorithmName({algorithm:e.algorithm}),i=await this.getAlgorithm({algorithm:r}).generateKey({algorithm:e.algorithm});return i.kid??=await rt({jwk:i}),i}async getKeyUri(e){throw new Error("Method not implemented.")}async getPublicKey({key:e}){let r=this.getAlgorithmName({key:e});return await this.getAlgorithm({algorithm:r}).getPublicKey({key:e})}async privateKeyToBytes({privateKey:e}){let r=this.getAlgorithmName({key:e});return await this.getAlgorithm({algorithm:r}).privateKeyToBytes({privateKey:e})}async publicKeyToBytes({publicKey:e}){let r=this.getAlgorithmName({key:e});return await this.getAlgorithm({algorithm:r}).publicKeyToBytes({publicKey:e})}async sign({key:e,data:r}){let n=this.getAlgorithmName({key:e});return this.getAlgorithm({algorithm:n}).sign({data:r,key:e})}async unwrapKey(e){let r=this.getAlgorithmName({key:e.decryptionKey});return await this.getAlgorithm({algorithm:r}).unwrapKey(e)}async verify({key:e,signature:r,data:n}){let i=this.getAlgorithmName({key:e});return this.getAlgorithm({algorithm:i}).verify({key:e,signature:r,data:n})}async wrapKey(e){let r=this.getAlgorithmName({key:e.encryptionKey});return await this.getAlgorithm({algorithm:r}).wrapKey(e)}getAlgorithm({algorithm:e}){let r=zK[e]?.implementation;if(!r)throw new it("algorithmNotSupported",`Algorithm not supported: ${e}`);return this._algorithmInstances.has(r)||this._algorithmInstances.set(r,new r),this._algorithmInstances.get(r)}getAlgorithmName({algorithm:e,key:r}){let n=r?.alg??e,i=r?.crv;for(let o of Object.keys(zK)){let s=zK[o].names;if(n&&s.includes(n))return o;if(i&&s.includes(i))return o}throw new it("algorithmNotSupported",`Algorithm not supported based on provided input: alg=${n}, crv=${i}. Please check the documentation for the list of supported algorithms.`)}};h();h();h();var rb;(function(t){t.authentication="authentication",t.assertionMethod="assertionMethod",t.keyAgreement="keyAgreement",t.capabilityInvocation="capabilityInvocation",t.capabilityDelegation="capabilityDelegation"})(rb||(rb={}));h();var ri={"@context":"https://w3id.org/did-resolution/v1",didResolutionMetadata:{},didDocument:null,didDocumentMetadata:{}};h();var or=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[m,p]=l.split("=");u[m]=p}d.params=u}return d}};or.METHOD_PATTERN="([a-z0-9]+)";or.PCT_ENCODED_PATTERN="(?:%[0-9a-fA-F]{2})";or.ID_CHAR_PATTERN=`(?:[a-zA-Z0-9._-]|${or.PCT_ENCODED_PATTERN})`;or.METHOD_ID_PATTERN=`((?:${or.ID_CHAR_PATTERN}*:)*(${or.ID_CHAR_PATTERN}+))`;or.PATH_PATTERN="(/[^#?]*)?";or.QUERY_PATTERN="([?][^#]*)?";or.FRAGMENT_PATTERN="(#.*)?";or.DID_URI_PATTERN=new RegExp(`^did:(?${or.METHOD_PATTERN}):(?${or.METHOD_ID_PATTERN})(?${or.PATH_PATTERN})(?${or.QUERY_PATTERN})(?${or.FRAGMENT_PATTERN})$`);h();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={}));h();var II={};jr(II,{extractDidFragment:()=>Fa,getServices:()=>IJe,getVerificationMethodByKey:()=>kJe,getVerificationMethodTypes:()=>GK,getVerificationMethods:()=>nS,getVerificationRelationshipsById:()=>WK,isDidService:()=>Lye,isDidVerificationMethod:()=>AI,isDwnDidService:()=>RJe,keyBytesToMultibaseId:()=>PI,multibaseIdToKeyBytes:()=>TI});h();var TJe=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 Fa(t){if(typeof t=="string"&&t.length!==0)return t.split("#").pop()}function IJe({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 kJe(t){return TJe(this,arguments,void 0,function*({didDocument:e,publicKeyJwk:r,publicKeyMultibase:n}){let i=nS({didDocument:e});for(let o of i)if(r&&o.publicKeyJwk){if((yield rt({jwk:r}))===(yield rt({jwk:o.publicKeyJwk})))return o}else if(n&&o.publicKeyMultibase&&n===o.publicKeyMultibase)return o;return null})}function nS({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(AI))!==null&&r!==void 0?r:[]),Object.keys(rb).forEach(i=>{var o,s;n.push(...(s=(o=t[i])===null||o===void 0?void 0:o.filter(AI))!==null&&s!==void 0?s:[])}),n}function GK({didDocument:t}){let r=nS({didDocument:t}).map(n=>n.type);return[...new Set(r)]}function WK({didDocument:t,methodId:e}){let r=[];return Object.keys(rb).forEach(n=>{if(Array.isArray(t[n])){let i=t[n],o=Fa(e);i.some(a=>{let d=Fa(a)===o,u=AI(a)&&Fa(a.id)===o;return d||u})&&r.push(n)}}),r}function Lye(t){return!t||typeof t!="object"||t===null?!1:"id"in t&&"type"in t&&"serviceEndpoint"in t}function RJe(t){if(!Lye(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 AI(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 PI({keyBytes:t,multicodecCode:e,multicodecName:r}){let n=mi.addPrefix({code:e,data:t,name:r}),i=de.uint8Array(n).toBase58Btc();return de.base58Btc(i).toMultibase()}function TI({multibaseKeyId:t}){try{let e=de.multibase(t).toBase58Btc(),r=de.base58Btc(e).toUint8Array(),{code:n,data:i,name:o}=mi.removePrefix({prefixedData:r});return{keyBytes:i,multicodecCode:n,multicodecName:o}}catch{throw new at(tt.InvalidDid,`Invalid multibase identifier: ${t}`)}}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())})},io=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 iS(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 iS(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 Fa(d.id)===((u=Fa(e?.methodId))!==null&&u!==void 0?u:Fa((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:Ri.getJoseSignatureAlgorithmFromPublicKey(o),keyId:n.id,sign(d){return iS(this,arguments,void 0,function*({data:u}){return yield s.sign({data:u,keyUri:i})})},verify(d){return iS(this,arguments,void 0,function*({data:u,signature:c}){return yield s.verify({data:u,key:o,signature:c})})}}})}static import(e){return iS(this,arguments,void 0,function*({portableDid:r,keyManager:n=new Sr}){var i;let o=nS({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})})}};h();h();var Fye=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())})},Dd=class{static getSigningMethod(e){return Fye(this,void 0,void 0,function*(){throw new Error("Not implemented: Classes extending DidMethod must implement getSigningMethod()")})}static resolve(e,r){return Fye(this,void 0,void 0,function*(){throw new Error("Not implemented: Classes extending DidMethod must implement resolve()")})}};var Do=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())})},zye=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!(N.algorithm in Hye)))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(N=>"id"in N).map(N=>N.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(N=>!N.id||!N.type||!N.serviceEndpoint))throw new Error("One or more services are missing required properties");let b=yield e.generateKey({algorithm:"Ed25519"}),S=yield e.getPublicKey({keyUri:b}),A=yield Ro.identityKeyToIdentifier({identityKey:S}),I=Object.assign(Object.assign({id:A},r.alsoKnownAs&&{alsoKnownAs:r.alsoKnownAs}),r.controllers&&{controller:r.controllers}),P=[...(s=r.verificationMethods)!==null&&s!==void 0?s:[]];P?.some(N=>{var L;return((L=N.id)===null||L===void 0?void 0:L.split("#").pop())==="0"})||P.unshift({algorithm:"Ed25519",id:"0",purposes:["authentication","assertionMethod","capabilityDelegation","capabilityInvocation"]});for(let N of P){let L=N.id&&N.id.split("#").pop()==="0"?b:yield e.generateKey({algorithm:N.algorithm}),F=yield e.getPublicKey({keyUri:L}),U=(d=(a=N.id)!==null&&a!==void 0?a:F.kid)!==null&&d!==void 0?d:yield rt({jwk:F});U=`${A}#${Fa(U)}`,(u=I.verificationMethod)!==null&&u!==void 0||(I.verificationMethod=[]),I.verificationMethod.push({id:U,type:"JsonWebKey",controller:(c=N.controller)!==null&&c!==void 0?c:A,publicKeyJwk:F});for(let G of(l=N.purposes)!==null&&l!==void 0?l:[])I[G]||(I[G]=[]),I[G].push(U)}(m=r.services)===null||m===void 0||m.forEach(N=>{var L;(L=I.service)!==null&&L!==void 0||(I.service=[]),N.id=`${A}#${N.id.split("#").pop()}`,I.service.push(N)});let $=new io({uri:A,document:I,metadata:Object.assign({published:!1},r.types&&{types:r.types}),keyManager:e});if(!((p=r.publish)!==null&&p!==void 0)||p){let N=yield t.publish({did:$,gatewayUri:r.gatewayUri});$.metadata=N.didDocumentMetadata}return $})}static import(e){return Do(this,arguments,void 0,function*({portableDid:r,keyManager:n=new Sr}){var i;let o=or.parse(r.uri);if(o?.method!==t.methodName)throw new at(tt.MethodNotSupported,"Method not supported");let s=yield io.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 Do(this,arguments,void 0,function*({didDocument:r,methodId:n="#0"}){var i;let o=or.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 Fa(a.id)===((d=Fa(n))!==null&&d!==void 0?d:Fa((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 Do(this,arguments,void 0,function*({did:r,gatewayUri:n=Gye}){return yield RI.put({did:r,gatewayUri:n})})}static resolve(e){return Do(this,arguments,void 0,function*(r,n={}){var i;let o=(i=n?.gatewayUri)!==null&&i!==void 0?i:Gye;try{yield Ro.identifierToIdentityKey({didUri:r});let{didDocument:s,didDocumentMetadata:a}=yield RI.get({didUri:r,gatewayUri:o});return Object.assign(Object.assign({},ri),{didDocument:s,didDocumentMetadata:a})}catch(s){if(!(s instanceof at))throw new Error(s);return Object.assign(Object.assign({},ri),{didResolutionMetadata:Object.assign({error:s.code},s.message&&{errorMessage:s.message})})}})}};Md.methodName="dht";var RI=class t{static get(e){return Do(this,arguments,void 0,function*({didUri:r,gatewayUri:n}){let i=Ro.identifierToIdentityKeyBytes({didUri:r}),o=yield t.pkarrGet({gatewayUri:n,publicKeyBytes:i}),s=yield Ro.parseBep44GetMessage({bep44Message:o}),a=yield t.fromDnsPacket({didUri:r,dnsPacket:s});return a.didDocumentMetadata.versionId=o.seq.toString(),a})}static put(e){return Do(this,arguments,void 0,function*({did:r,gatewayUri:n}){let i=yield t.toDnsPacket({didDocument:r.document,didMetadata:r.metadata,authoritativeGatewayUris:[n]}),o=yield Ro.createBep44PutMessage({dnsPacket:i,publicKeyBytes:Ro.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 Do(this,arguments,void 0,function*({gatewayUri:r,publicKeyBytes:n}){let i=de.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 Do(this,arguments,void 0,function*({gatewayUri:r,bep44Message:n}){let i=de.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 Do(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 m=Ro.parseTxtDataToString(c.data);a.alsoKnownAs=m.split(pa);break}case l.startsWith("cnt"):{let m=Ro.parseTxtDataToString(c.data);a.controller=m.includes(pa)?m.split(pa):m;break}case l.startsWith("k"):{let{id:m,t:p,k:g,c:b,a:S}=Ro.parseTxtDataToObject(c.data),A=de.base64Url(g).toUint8Array(),I=ma[Number(p)],P=yield Ro.keyConverter(I).bytesToPublicKey({publicKeyBytes:A});P.alg=S||Wye[Number(p)];let $=l==="k0"?"0":m!==void 0?m:yield rt({jwk:P});(o=a.verificationMethod)!==null&&o!==void 0||(a.verificationMethod=[]);let N=`${r}#${$}`;a.verificationMethod.push({id:N,type:"JsonWebKey",controller:b??r,publicKeyJwk:P}),u.set(l,N);break}case l.startsWith("s"):{let m=Ro.parseTxtDataToObject(c.data),{id:p,t:g,se:b}=m,S=zye(m,["id","t","se"]),A=b.includes(pa)?b.split(pa):[b],I=Object.fromEntries(Object.entries(S).map(([P,$])=>[P,$.includes(pa)?$.split(pa):$]));(s=a.service)!==null&&s!==void 0||(a.service=[]),a.service.push(Object.assign(Object.assign({},I),{id:`${r}#${p}`,type:g,serviceEndpoint:A}));break}case l.startsWith("typ"):{let{id:m}=Ro.parseTxtDataToObject(c.data);d.types=m.split(pa).map(p=>Number(p));break}case l.startsWith("did"):{let m=I=>I.split(pa).map(P=>u.get(P)).filter(P=>typeof P=="string"),{auth:p,asm:g,del:b,inv:S,agm:A}=Ro.parseTxtDataToObject(c.data);p&&(a.authentication=m(p)),g&&(a.assertionMethod=m(g)),b&&(a.capabilityDelegation=m(b)),S&&(a.capabilityInvocation=m(S)),A&&(a.keyAgreement=m(A));break}}}return{didDocument:a,didDocumentMetadata:d,didResolutionMetadata:{}}})}static toDnsPacket(e){return Do(this,arguments,void 0,function*({didDocument:r,didMetadata:n,authoritativeGatewayUris:i,previousDidProof:o}){var s,a,d,u,c;let l=[],m=[],p=new Map,g=[],b=[];if(o!==void 0){let{signature:I,previousDid:P}=o;yield Ro.validatePreviousDidProof({newDid:r.id,previousDidProof:o}),l.push({type:"TXT",name:"_prv._did.",ttl:ry,data:`id=${P};s=${I}`})}if(r.alsoKnownAs&&l.push({type:"TXT",name:"_aka._did.",ttl:ry,data:r.alsoKnownAs.join(pa)}),r.controller){let I=Array.isArray(r.controller)?r.controller.join(pa):r.controller;l.push({type:"TXT",name:"_cnt._did.",ttl:ry,data:I})}for(let[I,P]of(a=(s=r.verificationMethod)===null||s===void 0?void 0:s.entries())!==null&&a!==void 0?a:[]){let $=`k${I}`;b.push($);let N=P.id.split("#").pop();p.set(N,$);let L=P.publicKeyJwk;if(!(L?.crv&&L.crv in Hye))throw new at(tt.InvalidPublicKeyType,`Verification method '${P.id}' contains an unsupported key type: ${(d=L?.crv)!==null&&d!==void 0?d:"undefined"}`);let F=ma[L.crv],U=yield Ro.keyConverter(L.crv).publicKeyToBytes({publicKey:L}),G=de.uint8Array(U).toBase64Url(),q=[`t=${F}`,`k=${G}`];N!=="0"&&(yield rt({jwk:L}))!==N&&q.unshift(`id=${N}`),L.alg!==Wye[F]&&q.push(`a=${L.alg}`),P.controller!==r.id&&q.push(`c=${P.controller}`),l.push({type:"TXT",name:`_${$}._did.`,ttl:ry,data:q.join(kI)})}(u=r.service)===null||u===void 0||u.forEach((I,P)=>{let $=`s${P}`;g.push($);let{id:N,type:L,serviceEndpoint:F}=I,U=zye(I,["id","type","serviceEndpoint"]);N=Fa(N),F=Array.isArray(F)?F.join(","):F;let q=Object.entries(Object.assign({id:N,t:L,se:F},U)).map(([E,k])=>`${E}=${k}`).join(kI),T=Ro.chunkDataIfNeeded(q);l.push({type:"TXT",name:`_${$}._did.`,ttl:ry,data:T})});let S=[`v=${DJe}`];if(b.length&&S.push(`vm=${b.join(pa)}`),Object.keys(rb).forEach(I=>{var P;let $=(P=r[I])===null||P===void 0?void 0:P.map(N=>p.get(N.split("#").pop()));if($){let N=VK[I];S.push(`${N}=${$.join(pa)}`)}}),g.length&&S.push(`svc=${g.join(pa)}`),!((c=n.types)===null||c===void 0)&&c.length){let P=n.types.map($=>typeof $=="string"?HK[$]:$);l.push({type:"TXT",name:"_typ._did.",ttl:ry,data:`id=${P.join(pa)}`})}l.push({type:"TXT",name:"_did."+t.getUniqueDidSuffix(r.id)+".",ttl:ry,data:S.join(kI)});for(let I of i||[])m.push({type:"NS",name:"_did."+t.getUniqueDidSuffix(r.id)+".",ttl:ry,data:I+"."});return{id:0,type:"response",flags:CT,answers:[...l,...m]}})}static getUniqueDidSuffix(e){return e.split(":")[2]}},Ro=class t{static createBep44PutMessage(e){return Do(this,arguments,void 0,function*({dnsPacket:r,publicKeyBytes:n,signer:i}){let o=Math.ceil(Date.now()/1e3),s=Ng(r),a=m1.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 Do(this,arguments,void 0,function*({didUri:r}){let n=t.identifierToIdentityKeyBytes({didUri:r});return yield er.bytesToPublicKey({publicKeyBytes:n})})}static identifierToIdentityKeyBytes({didUri:e}){let r=or.parse(e);if(!r)throw new at(tt.InvalidDid,`Invalid DID URI: ${e}`);if(r.method!==Md.methodName)throw new at(tt.MethodNotSupported,`Method not supported: ${r.method}`);let n;try{n=de.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 Do(this,arguments,void 0,function*({identityKey:r}){let n=yield er.publicKeyToBytes({publicKey:r}),i=de.uint8Array(n).toBase32Z();return`did:${Md.methodName}:${i}`})}static keyConverter(e){let n={Ed25519:er,"P-256":{publicKeyToBytes:i=>Do(this,[i],void 0,function*({publicKey:o}){let s=yield Br.publicKeyToBytes({publicKey:o});return yield Br.compressPublicKey({publicKeyBytes:s})}),bytesToPublicKey:Br.bytesToPublicKey,privateKeyToBytes:Br.privateKeyToBytes,bytesToPrivateKey:Br.bytesToPrivateKey},secp256k1:{publicKeyToBytes:i=>Do(this,[i],void 0,function*({publicKey:o}){let s=yield Er.publicKeyToBytes({publicKey:o});return yield Er.compressPublicKey({publicKeyBytes:s})}),bytesToPublicKey:Er.bytesToPublicKey,privateKeyToBytes:Er.privateKeyToBytes,bytesToPrivateKey:Er.bytesToPrivateKey},X25519:Gl}[e];if(!n)throw new at(tt.InvalidPublicKeyType,`Unsupported curve: ${e}`);return n}static parseBep44GetMessage(e){return Do(this,arguments,void 0,function*({bep44Message:r}){let n=yield er.bytesToPublicKey({publicKeyBytes:r.k}),i=m1.encode({seq:r.seq,v:r.v}).subarray(1,-1);if(!(yield er.verify({key:n,signature:r.sig,data:i})))throw new at(tt.InvalidSignature,"Invalid signature for DHT BEP44 message");return S1(r.v)})}static parseTxtDataToObject(e){return this.parseTxtDataToString(e).split(kI).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 de.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 Do(this,arguments,void 0,function*({newDid:r,previousDidProof:n}){let i=yield t.identifierToIdentityKey({didUri:n.previousDid}),o=t.identifierToIdentityKeyBytes({didUri:r}),s=de.base64Url(n.signature).toUint8Array();if(!(yield er.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;n!(N.algorithm in MJe)))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(N=>"id"in N).map(N=>N.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(N=>!N.id||!N.type||!N.serviceEndpoint))throw new Error("One or more services are missing required properties");let l={algorithm:"Ed25519",purposes:["authentication","assertionMethod","capabilityDelegation","capabilityInvocation"]},m=[];for(let N of(s=r.verificationMethods)!==null&&s!==void 0?s:[l]){let L=yield e.generateKey({algorithm:N.algorithm}),F=yield e.getPublicKey({keyUri:L});m.push({id:N.id,publicKeyJwk:F,purposes:(a=N.purposes)!==null&&a!==void 0?a:["authentication","assertionMethod","capabilityDelegation","capabilityInvocation"]})}let p=yield e.generateKey({algorithm:Zl.secp256k1}),g=yield e.getPublicKey({keyUri:p}),b=yield e.generateKey({algorithm:Zl.secp256k1}),S=yield e.getPublicKey({keyUri:b}),A=yield nb.computeLongFormDidUri({recoveryKey:g,updateKey:S,services:(d=r.services)!==null&&d!==void 0?d:[],verificationMethods:m}),{didDocument:I,didResolutionMetadata:P}=yield t.resolve(A,{gatewayUri:r.gatewayUri});if(I===null)throw new Error(`Unable to resolve DID during creation: ${P?.error}`);let $=new io({uri:A,document:I,metadata:{published:!1,canonicalId:A.split(":",3).join(":"),recoveryKey:g,updateKey:S},keyManager:e});if(!((u=r.publish)!==null&&u!==void 0)||u){let N=yield t.publish({did:$,gatewayUri:r.gatewayUri});$.metadata=N.didDocumentMetadata}return $})}static getSigningMethod(e){return ny(this,arguments,void 0,function*({didDocument:r,methodId:n}){var i;let o=or.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 ny(this,arguments,void 0,function*({portableDid:r,keyManager:n=new Sr}){let i=or.parse(r.uri);if(i?.method!==t.methodName)throw new at(tt.MethodNotSupported,"Method not supported");return yield io.import({portableDid:r,keyManager:n})})}static publish(e){return ny(this,arguments,void 0,function*({did:r,gatewayUri:n=Vye}){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:WK({didDocument:r.document,methodId:c.id})})))!==null&&o!==void 0?o:[],d=yield nb.createIonDocument({services:(s=r.document.service)!==null&&s!==void 0?s:[],verificationMethods:a}),u=yield nb.constructCreateRequest({ionDocument:d,recoveryKey:r.metadata.recoveryKey,updateKey:r.metadata.updateKey});try{let c=nb.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 ny(this,arguments,void 0,function*(r,n={}){var i,o;let s=or.parse(r);if(!s)return Object.assign(Object.assign({},ri),{didResolutionMetadata:{error:"invalidDid"}});if(s.method!==t.methodName)return Object.assign(Object.assign({},ri),{didResolutionMetadata:{error:"methodNotSupported"}});let a=(i=n?.gatewayUri)!==null&&i!==void 0?i:Vye;try{let d=nb.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({},ri),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({},ri),{didResolutionMetadata:Object.assign({error:d.code},d.message&&{errorMessage:d.message})})}})}};JK.methodName="ion";var nb=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 ny(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 Hm.createLongFormDid({document:s,recoveryKey:a,updateKey:d})})}static constructCreateRequest(e){return ny(this,arguments,void 0,function*({ionDocument:r,recoveryKey:n,updateKey:i}){return yield Jl.createCreateRequest({document:r,recoveryKey:t.normalizeJwk(n),updateKey:t.normalizeJwk(i)})})}static createIonDocument(e){return ny(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 rt({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}};h();var DI=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())})},Bh=class t extends Dd{static create(){return DI(this,arguments,void 0,function*({keyManager:e=new Sr,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=de.object(u).toBase64Url(),l=`did:${t.methodName}:${c}`,p=(yield t.resolve(l)).didDocument;return new io({uri:l,document:p,metadata:{},keyManager:e})})}static getSigningMethod(e){return DI(this,arguments,void 0,function*({didDocument:r}){var n;let i=or.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 DI(this,arguments,void 0,function*({portableDid:r,keyManager:n=new Sr}){let i=or.parse(r.uri);if(i?.method!==t.methodName)throw new at(tt.MethodNotSupported,"Method not supported");let o=yield io.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 DI(this,void 0,void 0,function*(){let n=or.parse(e),i;try{i=de.base64Url(n.id).toObject()}catch{}if(!n||!i)return Object.assign(Object.assign({},ri),{didResolutionMetadata:{error:"invalidDid"}});if(n.method!==t.methodName)return Object.assign(Object.assign({},ri),{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({},ri),{didDocument:o})})}};Bh.methodName="jwk";h();var $u=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())})},Ch;(function(t){t.Ed25519="Ed25519",t.secp256k1="secp256k1",t.secp256r1="secp256r1",t.X25519="X25519"})(Ch||(Ch={}));var YK={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"},BJe={Ed25519:Ch.Ed25519,ES256K:Ch.secp256k1,ES256:Ch.secp256r1,"P-256":Ch.secp256r1,secp256k1:Ch.secp256k1,secp256r1:Ch.secp256r1,X25519:Ch.X25519},ZK=class t extends Dd{static create(){return $u(this,arguments,void 0,function*({keyManager:e=new Sr,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 za.publicKeyToMultibaseId({publicKey:u}),l=`did:${t.methodName}:${c}`,p=(yield t.resolve(l,r)).didDocument;return new io({uri:l,document:p,metadata:{},keyManager:e})})}static getSigningMethod(e){return $u(this,arguments,void 0,function*({didDocument:r}){var n;let i=or.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 $u(this,arguments,void 0,function*({portableDid:r,keyManager:n=new Sr}){let i=or.parse(r.uri);if(i?.method!==t.methodName)throw new at(tt.MethodNotSupported,"Method not supported");let o=yield io.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 $u(this,void 0,void 0,function*(){try{let n=yield t.createDocument({didUri:e,options:r});return Object.assign(Object.assign({},ri),{didDocument:n})}catch(n){if(!(n instanceof at))throw new Error(n);return Object.assign(Object.assign({},ri),{didResolutionMetadata:Object.assign({error:n.code},n.message&&{errorMessage:n.message})})}})}static createDocument(e){return $u(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=or.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",b=yield this.createEncryptionMethod({didUri:r,multibaseValue:c,options:{enableExperimentalPublicKeyTypes:s,publicKeyFormat:g}});d.verificationMethod.push(b),d.keyAgreement=[b.id]}let m=[i];return GK({didDocument:d}).forEach(g=>{let b=YK[g];m.push(b)}),d["@context"]=m,d})}static createEncryptionMethod(e){return $u(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=za.MULTICODEC_PUBLIC_KEY_LENGTH[u];if(c!==l)throw new at(tt.InvalidPublicKeyLength,`Expected ${c} bytes. Actual: ${l}`);let m=PI({keyBytes:d,multicodecCode:u});a.id=`${r}#${m}`;try{new URL(a.id)}catch{throw new at(tt.InvalidDidUrl,"Verification Method ID is not a valid DID URL.")}if(!(s in YK))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=m),s==="JsonWebKey2020"){let{crv:g}=yield za.multicodecToJwk({code:u});a.publicKeyJwk=yield za.keyConverter(g).bytesToPublicKey({publicKeyBytes:d})}return a})}static createSignatureMethod(e){return $u(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}=TI({multibaseKeyId:n}),l=d.byteLength,m=za.MULTICODEC_PUBLIC_KEY_LENGTH[u];if(l!==m)throw new at(tt.InvalidPublicKeyLength,`Expected ${l} bytes. Actual: ${m}`);let p=!1;switch(c){case"secp256k1-pub":p=yield Er.validatePublicKey({publicKeyBytes:d});break;case"ed25519-pub":p=yield er.validatePublicKey({publicKeyBytes:d});break;case"x25519-pub":p=!0;break}if(!p)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 YK))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:b}=yield za.multicodecToJwk({code:u});a.publicKeyJwk=yield za.keyConverter(b).bytesToPublicKey({publicKeyBytes:d})}return a})}static deriveEncryptionKey(e){return $u(this,arguments,void 0,function*({multibaseValue:r}){let n={keyBytes:new Uint8Array,multicodecCode:0},{keyBytes:i,multicodecCode:o}=TI({multibaseKeyId:r});if(o===237){let s=yield za.keyConverter("Ed25519").bytesToPublicKey({publicKeyBytes:i}),a=yield er.convertPublicKeyToX25519({publicKey:s});n={keyBytes:yield za.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&&xm(n)==="String"&&n.startsWith("z")}};ZK.methodName="key";var za=class t{static jwkToMulticodec(e){return $u(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:mi.getCodeFromName({name:o}),name:o}})}static keyCompressor(e){let n={"P-256":Br.compressPublicKey,secp256k1:Er.compressPublicKey}[e];if(!n)throw new at(tt.InvalidPublicKeyType,`Unsupported curve: ${e}`);return n}static keyConverter(e){let n={Ed25519:er,"P-256":Br,secp256k1:Er,X25519:Gl}[e];if(!n)throw new at(tt.InvalidPublicKeyType,`Unsupported curve: ${e}`);return n}static multicodecToJwk(e){return $u(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?mi.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 $u(this,arguments,void 0,function*({publicKey:r}){var n;if(!(r?.crv&&r.crv in BJe))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 PI({keyBytes:i,multicodecName:o})})}};za.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"};za.MULTICODEC_PUBLIC_KEY_LENGTH={231:33,236:32,237:32};za.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:""}};h();var CJe=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())})},XK=class t extends Dd{static resolve(e,r){return CJe(this,void 0,void 0,function*(){let n=or.parse(e);if(!n)return Object.assign(Object.assign({},ri),{didResolutionMetadata:{error:"invalidDid"}});if(n.method!==t.methodName)return Object.assign(Object.assign({},ri),{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({},ri),{didDocument:a})}catch{return Object.assign(Object.assign({},ri),{didResolutionMetadata:{error:"notFound"}})}})}};XK.methodName="web";h();var Jye=Ut(Lg(),1),Yye=Ut(vK(),1),OJe=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())})},W1=class{constructor({db:e,location:r="DATA/DID_RESOLVERCACHE",ttl:n="15m"}={}){this.cache=e??new Yye.Level(r),this.ttl=(0,Jye.default)(n)}get(e){return OJe(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()}};h();var Zye={get:function(t){return null},set:function(t,e){return null},delete:function(t){return null},clear:function(){return null},close:function(){return null}};h();var Xye=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())})},H1=class{constructor({cache:e,didResolvers:r}){this.didResolvers=new Map,this.cache=e||Zye;for(let n of r)this.didResolvers.set(n.methodName,n)}resolve(e,r){return Xye(this,void 0,void 0,function*(){let n=or.parse(e);if(!n)return Object.assign(Object.assign({},ri),{didResolutionMetadata:{error:tt.InvalidDid,errorMessage:`Invalid DID URI: ${e}`}});let i=this.didResolvers.get(n.method);if(!i)return Object.assign(Object.assign({},ri),{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 Xye(this,void 0,void 0,function*(){let n=or.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:{}}})}};h();h();var us="^",MI=class extends Sr{constructor(){super();this._predefinedKeys=new Map,this._keyGenerator=this._predefinedKeys.keys()}async addPredefinedKeys({privateKeys:r}){let n={};for(let i of r){i.kid??=await rt({jwk:i});let o=await this.getKeyUri({key:i});n[o]=i}this._predefinedKeys=new Map(Object.entries(n)),this._keyGenerator=this._predefinedKeys.keys()}async exportKey({keyUri:r}){let n=this._predefinedKeys.get(r);if(!n)throw new Error(`DeterministicKeyGenerator.exportKey: Key not found: ${r}`);return n}async generateKey(r){let{value:n,done:i}=this._keyGenerator.next();if(i)throw new Error("Ran out of predefined keys");return n}async getPublicKey({keyUri:r}){let n=this._predefinedKeys.get(r);if(!n)throw new Error(`DeterministicKeyGenerator.getPublicKey: Key not found: ${r}`);let{d:i,...o}=n;return o}async sign({keyUri:r,data:n}){let i=this._predefinedKeys.get(r);if(!i)throw new Error(`DeterministicKeyGenerator.sign: Key not found: ${r}`);return await er.sign({data:n,key:i})}};async function Oh({agent:t,tenant:e,didUri:r}){if(e)return e;if(t.agentDid)return t.agentDid.uri;if(!r)throw new Error("Failed to determine tenant DID: 'agent.agentDid', 'tenant', and 'didUri' are undefined");return r}h();function V1(t){return!(!t||typeof t!="object"||t===null)&&"uri"in t&&"document"in t&&"metadata"in t&&(!("keyManager"in t)||t.keyManager===void 0)}h();var QK=Ut(Lg(),1);var $h=class{constructor(){this.name="DwnDataStore";this._cache=new _m.default({ttl:(0,QK.default)("15 minutes"),max:100});this._index=new _m.default({ttl:(0,QK.default)("2 hours"),max:1e3});this._recordProperties={dataFormat:"application/json",schema:"https://identity.foundation/schemas/web5/private-jwk"}}async delete({id:e,agent:r,tenant:n}){let i=await Oh({agent:r,tenant:n,didUri:e}),o=await this.lookupRecordId({id:e,tenantDid:i,agent:r});if(!o)return!1;let{reply:{status:s}}=await r.dwn.processRequest({author:i,target:i,messageType:qr.RecordsDelete,messageParams:{recordId:o}});if(s.code===202)return this._index.delete(`${i}${us}${e}`),this._cache.delete(o),!0;throw new Error(`${this.name}: Failed to delete '${e}' from store: (${s.code}) ${s.detail}`)}async get({id:e,agent:r,tenant:n,useCache:i=!1}){let o=await Oh({agent:r,tenant:n,didUri:e}),s=await this.lookupRecordId({id:e,tenantDid:o,agent:r});if(s)return await this.getRecord({recordId:s,tenantDid:o,agent:r,useCache:i})}async list({agent:e,tenant:r}){let n=await Oh({tenant:r,agent:e});return await this.getAllRecords({agent:e,tenantDid:n})}async set({id:e,data:r,tenant:n,agent:i,preventDuplicates:o=!0,useCache:s=!1}){let a=await Oh({agent:i,tenant:n,didUri:e});if(o&&await this.lookupRecordId({id:e,tenantDid:a,agent:i}))throw new Error(`${this.name}: Import failed due to duplicate entry for: ${e}`);let d=de.object(r).toUint8Array(),{message:u,reply:{status:c}}=await i.dwn.processRequest({author:a,target:a,messageType:qr.RecordsWrite,messageParams:{...this._recordProperties},dataStream:new Blob([d],{type:"application/json"})});if(!(u&&c.code===202))throw new Error(`${this.name}: Failed to write data to store for: ${e}`);this._index.set(`${a}${us}${e}`,u.recordId),s&&this._cache.set(u.recordId,r)}async getAllRecords(e){throw new Error("Not implemented: Classes extending DwnDataStore must implement getAllRecords()")}async getRecord({recordId:e,tenantDid:r,agent:n,useCache:i}){if(i){let a=this._cache.get(e);if(a)return a}let{reply:o}=await n.dwn.processRequest({author:r,target:r,messageType:qr.RecordsRead,messageParams:{filter:{recordId:e}}});if(!o.record?.data)throw new Error(`${this.name}: Failed to read data from DWN for: ${e}`);let s=await _h.consumeToJson({readable:o.record.data});return i&&this._cache.set(e,s),s}async lookupRecordId({id:e,tenantDid:r,agent:n}){let i=this._index.get(`${r}${us}${e}`,{updateAgeOnGet:!0});return i||(await this.getAllRecords({agent:n,tenantDid:r}),i=this._index.get(`${r}${us}${e}`)),i}},Nh=class{constructor(){this.name="InMemoryDataStore";this.store=new Map}async delete({id:e,agent:r,tenant:n}){let i=await Oh({agent:r,tenant:n,didUri:e});return this.store.has(`${i}${us}${e}`)?(this.store.delete(`${i}${us}${e}`),!0):!1}async get({id:e,agent:r,tenant:n}){let i=await Oh({agent:r,tenant:n,didUri:e});return this.store.get(`${i}${us}${e}`)}async list({agent:e,tenant:r}){let n=await Oh({tenant:r,agent:e}),i=[];for(let[o,s]of this.store.entries())o.startsWith(`${n}${us}`)&&i.push(s);return i}async set({id:e,data:r,tenant:n,agent:i,preventDuplicates:o}){let s=await Oh({agent:i,tenant:n,didUri:e});if(o&&this.store.has(`${s}${us}${e}`))throw new Error(`${this.name}: Import failed due to duplicate entry for: ${e}`);let a=structuredClone(r);this.store.set(`${s}${us}${e}`,a)}};var oS=class extends $h{constructor(){super(...arguments);this.name="DwnDidStore";this._recordProperties={dataFormat:"application/json",schema:"https://identity.foundation/schemas/web5/portable-did"}}async delete(r){return await super.delete(r)}async get(r){return await super.get(r)}async list(r){return await super.list(r)}async set(r){return await super.set(r)}async getAllRecords({agent:r,tenantDid:n}){this._index.clear();let{reply:i}=await r.dwn.processRequest({author:n,target:n,messageType:qr.RecordsQuery,messageParams:{filter:{...this._recordProperties}}}),o=[];for(let s of i.entries??[]){if(!s.encodedData)throw new Error(`${this.name}: Expected 'encodedData' to be present in the DWN query result entry`);let a=de.base64Url(s.encodedData).toObject();if(V1(a)){let d=`${n}${us}${a.uri}`;this._index.set(d,s.recordId),this._cache.set(s.recordId,a),o.push(a)}}return o}},ib=class extends Nh{constructor(){super(...arguments);this.name="InMemoryDidStore"}async delete(r){return await super.delete(r)}async get(r){return await super.get(r)}async list(r){return await super.list(r)}async set(r){return await super.set(r)}};h();var Qye=Ut(Lg(),1);var J1=class{constructor({ttl:e="15m"}={}){this.cache=new _m.default({ttl:(0,Qye.default)(e)})}async get(e){if(!e)throw new Error("Key cannot be null or undefined");return this.cache.get(e)}async set(e,r){this.cache.set(e,r)}async delete(e){this.cache.delete(e)}async clear(){this.cache.clear()}async close(){}};var e0e=(r=>(r.Create="Create",r.Resolve="Resolve",r))(e0e||{});function eq(t,e){return t.messageType===e}var Y1=class extends H1{constructor({agent:r,didMethods:n,resolverCache:i,store:o}){if(!n)throw new TypeError("AgentDidApi: Required parameter missing: 'didMethods'");super({didResolvers:n,cache:i??new J1});this._didMethods=new Map;this._agent=r,this._store=o??new ib;for(let s of n)this._didMethods.set(s.methodName,s)}get agent(){if(this._agent===void 0)throw new Error("AgentDidApi: Unable to determine agent execution context.");return this._agent}set agent(r){this._agent=r}async create({method:r,tenant:n,options:i,store:o}){let a=await this.getMethod(r).create({keyManager:this.agent.keyManager,options:i});if(o??!0){let{uri:d,document:u,metadata:c}=a,l={uri:d,document:u,metadata:c};await this._store.set({id:l.uri,data:l,agent:this.agent,tenant:n??l.uri,preventDuplicates:!1,useCache:!0})}return a}async export({didUri:r,tenant:n}){let i=await this.get({didUri:r,tenant:n});if(!i)throw new Error(`AgentDidApi: Failed to export due to DID not found: ${r}`);return await i.export()}async get({didUri:r,tenant:n}){let i=await this._store.get({id:r,agent:this.agent,tenant:n,useCache:!0});return i?await io.import({portableDid:i,keyManager:this.agent.keyManager}):void 0}async getSigningMethod({didUri:r,methodId:n}){let i=or.parse(r);if(!i)throw new Error(`Invalid DID URI: ${r}`);let o=this.getMethod(i.method),{didDocument:s,didResolutionMetadata:a}=await this.resolve(r);if(!s)throw new Error(`DID resolution failed for '${r}': ${JSON.stringify(a)}`);return await o.getSigningMethod({didDocument:s,methodId:n})}async import({portableDid:r,tenant:n}){let i=await io.import({keyManager:this.agent.keyManager,portableDid:r}),{uri:o,document:s,metadata:a}=i,d={uri:o,document:s,metadata:a};return await this._store.set({id:d.uri,data:d,agent:this.agent,tenant:n??d.uri,preventDuplicates:!0,useCache:!0}),i}async processRequest(r){if(eq(r,"Create"))try{let n=await this.create({...r.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:n.message??"Unknown error occurred"}}}if(eq(r,"Resolve")){let{didUri:n,options:i}=r.messageParams;return{result:await this.resolve(n,i),ok:!0,status:{code:200,message:"OK"}}}throw new Error(`AgentDidApi: Unsupported request type: ${r.messageType}`)}getMethod(r){let n=this._didMethods.get(r);if(n===void 0)throw new Error(`DID Method not supported: ${r}`);return n}};h();h();var r0e=Ut(t0e(),1);function CI(t){return aS(t.stream())}async function sS(t,e){let r=await e.dereference(`${t}#dwn`);if(r.dereferencingMetadata.error)throw new Error(`Failed to dereference '${t}#dwn': ${r.dereferencingMetadata.error}`);if(II.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 NJe(t){return ht.getAuthor(t)}function ob(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===Ae.Records&&"method"in t.message.descriptor&&t.message.descriptor.method===_e.Write}function n0e(t){return be.getCid(t)}async function jJe(t,e){let r=e===xi.CreatedAscending||e===xi.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:await n0e(t),value:r}}function aS(t){return new r0e.ReadableWebToNodeStream(t)}function i0e(t,e){return t.messageType===e}function UJe(t,e){return e.descriptor.interface+e.descriptor.method===t}var Z1=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 async createDwn({dataPath:e,dataStore:r,didResolver:n,eventLog:i,eventStream:o,messageStore:s,tenantGate:a}){return r??=new Vg({blockstoreLocation:`${e}/DWN_DATASTORE`}),n??=new H1({didResolvers:[Md,Bh],cache:new W1({location:`${e}/DID_RESOLVERCACHE`})}),i??=new Xg({location:`${e}/DWN_EVENTLOG`}),s??=new eb({blockstoreLocation:`${e}/DWN_MESSAGESTORE`,indexLocation:`${e}/DWN_MESSAGEINDEX`}),await N6.create({dataStore:r,didResolver:n,eventLog:i,eventStream:o,messageStore:s,tenantGate:a})}async processRequest(e){let{message:r,dataStream:n}=await this.constructDwnMessage({request:e}),{subscriptionHandler:i}=e;return{reply:e.store!==!1?await this._dwn.processMessage(e.target,r,{dataStream:n,subscriptionHandler:i}):{status:{code:202,detail:"Accepted"}},message:r,messageCid:await be.getCid(r)}}async sendRequest(e){let r=await sS(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}=await this.getDwnMessage({author:e.author,messageCid:e.messageCid,messageType:e.messageType})),n=e.messageCid;else{if({message:i}=await 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=await this.sendDwnRpcRequest({targetDid:e.target,dwnEndpointUrls:r,message:i,data:o,subscriptionHandler:s});return n??=await be.getCid(i),{reply:a,message:i,messageCid:n}}async sendDwnRpcRequest({targetDid:e,dwnEndpointUrls:r,message:n,data:i,subscriptionHandler:o}){let s=[];if(n.descriptor.method===_e.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(!(await 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 await 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)}`)}async constructDwnMessage({request:e}){let r=e.rawMessage,n;if(i0e(e,qr.RecordsWrite)){let a=e.messageParams;if(e.dataStream&&!a?.data){let{dataStream:d}=e,u;if(d instanceof Blob)u=CI(d),n=CI(d);else if(d instanceof ReadableStream){let[c,l]=d.tee();u=aS(c),n=aS(l)}r||(a.dataCid=await Sn.computeDagPbCidFromStream(u),a.dataSize??=u.bytesRead)}}let i=await this.getSigner(e.author),o=z1[e.messageType],s=r?await o.parse(r):await o.create({...e.messageParams,signer:i});return ob(s)&&e.signAsOwner&&await s.signAsOwner(i),{message:s.message,dataStream:n}}async getSigner(e){if(e===this.agent.agentDid.uri){let r=await this.agent.agentDid.getSigner();return{algorithm:r.algorithm,keyId:r.keyId,sign:async n=>await r.sign({data:n})}}else try{let r=await 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=await this.agent.keyManager.getKeyUri({key:r.publicKeyJwk}),i=await this.agent.keyManager.getPublicKey({keyUri:n}),o=this.agent.keyManager;return{algorithm:Ri.getJoseSignatureAlgorithmFromPublicKey(i),keyId:r.id,sign:async s=>await o.sign({data:s,keyUri:n})}}catch(r){throw new Error(`AgentDwnApi: Unable to get signer for author '${e}': ${r.message}`)}}async getDwnMessage({author:e,messageCid:r}){let n=await this.getSigner(e),i=await z1[qr.MessagesGet].create({messageCids:[r],signer:n}),o=await this._dwn.processMessage(e,i.message);if(!(o.entries&&o.entries.length===1))throw new Error("AgentDwnApi: Expected 1 message entry in the MessagesGet response but received none or more than one.");let[s]=o.entries,a=s.message;if(!a)throw new Error(`AgentDwnApi: Message not found with CID: ${r}`);let d={message:a};if(ob(s))if(s.encodedData){let u=de.base64Url(s.encodedData).toUint8Array();d.data=new Blob([u])}else{let u=await z1[qr.RecordsRead].create({filter:{recordId:s.message.recordId},signer:n}),c=await this._dwn.processMessage(e,u.message);if(c.status.code>=400){let{status:{code:l,detail:m}}=c;throw new Error(`AgentDwnApi: (${l}) Failed to read data associated with record ${s.message.recordId}. ${m}}`)}else if(c.record){let l=await _h.consumeToBytes({readable:c.record.data});d.data=new Blob([l])}}return d}async createMessage({author:e,messageParams:r,messageType:n}){let i=await this.getSigner(e);return await z1[n].create({...r,signer:i})}async processMessage({dataStream:e,message:r,targetDid:n}){return await this._dwn.processMessage(n,r,{dataStream:e})}};h();h();h();var KJe=new Uint8Array([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),s0e=Uint8Array.from({length:16},(t,e)=>e),qJe=s0e.map(t=>(9*t+5)%16),nq=[s0e],iq=[qJe];for(let t=0;t<4;t++)for(let e of[nq,iq])e.push(e[t].map(r=>KJe[r]));var a0e=[[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)),LJe=nq.map((t,e)=>t.map(r=>a0e[e][r])),FJe=iq.map((t,e)=>t.map(r=>a0e[e][r])),zJe=new Uint32Array([0,1518500249,1859775393,2400959708,2840853838]),GJe=new Uint32Array([1352829926,1548603684,1836072691,2053994217,0]),OI=(t,e)=>t<>>32-e;function o0e(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 $I=new Uint32Array(16),rq=class extends Jh{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 p=0;p<16;p++,r+=4)$I[p]=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,m=l;for(let p=0;p<5;p++){let g=4-p,b=zJe[p],S=GJe[p],A=nq[p],I=iq[p],P=LJe[p],$=FJe[p];for(let N=0;N<16;N++){let L=OI(n+o0e(p,o,a,u)+$I[A[N]]+b,P[N])+l|0;n=l,l=u,u=OI(a,10)|0,a=o,o=L}for(let N=0;N<16;N++){let L=OI(i+o0e(g,s,d,c)+$I[I[N]]+S,$[N])+m|0;i=m,m=c,c=OI(d,10)|0,d=s,s=L}}this.set(this.h1+a+c|0,this.h2+u+m|0,this.h3+l+i|0,this.h4+n+s|0,this.h0+o+d|0)}roundClean(){$I.fill(0)}destroy(){this.destroyed=!0,this.buffer.fill(0),this.set(0,0,0,0,0)}},c0e=Ab(()=>new rq);var WJe=w2("ed25519 seed"),oq=2147483648,d0e=new Uint8Array([0]);function u0e(t,...e){return typeof t=="string"&&(t=ZL(t)),af(t,...e),t}var HJe=t=>c0e(ms(t)),VJe=t=>df(t).getUint32(0,!1),sq=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 df(e).setUint32(0,t,!1),e},NI=class t{get publicKeyRaw(){return Ed.getPublicKey(this.privateKey)}get publicKey(){return gy(d0e,this.publicKeyRaw)}get pubHash(){return HJe(this.publicKey)}get fingerprint(){return VJe(this.pubHash)}get fingerprintHex(){return Nk(sq(this.fingerprint))}get parentFingerprintHex(){return Nk(sq(this.parentFingerprint))}static fromMasterSeed(e){if(e=u0e(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=Vh(qm,WJe,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(af(e.privateKey,32),af(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>=oq)throw new Error("Invalid index");(r||s[2]==="'")&&(a+=oq),i=i.deriveChild(a)}return i}deriveChild(e){if(e