Dorian 0d073fa89e Add comprehensive installation and setup documentation
- Add GETTING_STARTED.md with quick start guide and development modes
- Add INSTALL.sh automated installation script
- Add INSTALLATION_CHECKLIST.md, INSTALLATION_SUCCESS.md, and INSTALLATION_SUMMARY.md
- Add QUICK_REFERENCE.md for common commands
- Add SETUP_GUIDE.md with detailed setup instructions
- Update README.md with improved project overview
- Add did-wallet app dependencies and node_modules
2026-01-27 17:18:21 +00:00

2196 lines
1.9 MiB

var tge=Object.create;var uk=Object.defineProperty;var rge=Object.getOwnPropertyDescriptor;var nge=Object.getOwnPropertyNames;var ige=Object.getPrototypeOf,oge=Object.prototype.hasOwnProperty;var sge=(t,e)=>()=>(t&&(e=t(t=0)),e);var H=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Fr=(t,e)=>{for(var r in e)uk(t,r,{get:e[r],enumerable:!0})},age=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of nge(e))!oge.call(t,i)&&i!==r&&uk(t,i,{get:()=>e[i],enumerable:!(n=rge(e,i))||n.enumerable});return t};var qt=(t,e,r)=>(r=t!=null?tge(ige(t)):{},age(e||!t||!t.__esModule?uk(r,"default",{value:t,enumerable:!0}):r,t));var fk=H(N3=>{"use strict";h();N3.byteLength=dge;N3.toByteArray=lge;N3.fromByteArray=pge;var zu=[],jc=[],cge=typeof Uint8Array<"u"?Uint8Array:Array,lk="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(gy=0,CL=lk.length;gy<CL;++gy)zu[gy]=lk[gy],jc[lk.charCodeAt(gy)]=gy;var gy,CL;jc[45]=62;jc[95]=63;function $L(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");r===-1&&(r=e);var n=r===e?0:4-r%4;return[r,n]}function dge(t){var e=$L(t),r=e[0],n=e[1];return(r+n)*3/4-n}function uge(t,e,r){return(e+r)*3/4-r}function lge(t){var e,r=$L(t),n=r[0],i=r[1],o=new cge(uge(t,n,i)),s=0,a=i>0?n-4:n,d;for(d=0;d<a;d+=4)e=jc[t.charCodeAt(d)]<<18|jc[t.charCodeAt(d+1)]<<12|jc[t.charCodeAt(d+2)]<<6|jc[t.charCodeAt(d+3)],o[s++]=e>>16&255,o[s++]=e>>8&255,o[s++]=e&255;return i===2&&(e=jc[t.charCodeAt(d)]<<2|jc[t.charCodeAt(d+1)]>>4,o[s++]=e&255),i===1&&(e=jc[t.charCodeAt(d)]<<10|jc[t.charCodeAt(d+1)]<<4|jc[t.charCodeAt(d+2)]>>2,o[s++]=e>>8&255,o[s++]=e&255),o}function fge(t){return zu[t>>18&63]+zu[t>>12&63]+zu[t>>6&63]+zu[t&63]}function hge(t,e,r){for(var n,i=[],o=e;o<r;o+=3)n=(t[o]<<16&16711680)+(t[o+1]<<8&65280)+(t[o+2]&255),i.push(fge(n));return i.join("")}function pge(t){for(var e,r=t.length,n=r%3,i=[],o=16383,s=0,a=r-n;s<a;s+=o)i.push(hge(t,s,s+o>a?a:s+o));return n===1?(e=t[r-1],i.push(zu[e>>2]+zu[e<<4&63]+"==")):n===2&&(e=(t[r-2]<<8)+t[r-1],i.push(zu[e>>10]+zu[e>>4&63]+zu[e<<2&63]+"=")),i.join("")}});var pk=H(hk=>{h();hk.read=function(t,e,r,n,i){var o,s,a=i*8-n-1,d=(1<<a)-1,u=d>>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)};hk.write=function(t,e,r,n,i,o){var s,a,d,u=o*8-i-1,c=(1<<u)-1,l=c>>1,m=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:o-1,g=n?1:-1,v=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=c):(s=Math.floor(Math.log(e)/Math.LN2),e*(d=Math.pow(2,-s))<1&&(s--,d*=2),s+l>=1?e+=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<<i|a,u+=i;u>0;t[r+p]=s&255,p+=g,s/=256,u-=8);t[r+p-g]|=v*128}});var JL=H(bv=>{"use strict";h();var mk=fk(),vv=pk(),NL=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;bv.Buffer=me;bv.SlowBuffer=wge;bv.INSPECT_MAX_BYTES=50;var j3=2147483647;bv.kMaxLength=j3;me.TYPED_ARRAY_SUPPORT=mge();!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 mge(){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 cf(t){if(t>j3)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 bk(t)}return qL(t,e,r)}me.poolSize=8192;function qL(t,e,r){if(typeof t=="string")return gge(t,e);if(ArrayBuffer.isView(t))return vge(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(Vu(t,ArrayBuffer)||t&&Vu(t.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(Vu(t,SharedArrayBuffer)||t&&Vu(t.buffer,SharedArrayBuffer)))return gk(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=bge(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 qL(t,e,r)};Object.setPrototypeOf(me.prototype,Uint8Array.prototype);Object.setPrototypeOf(me,Uint8Array);function LL(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 yge(t,e,r){return LL(t),t<=0?cf(t):e!==void 0?typeof r=="string"?cf(t).fill(e,r):cf(t).fill(e):cf(t)}me.alloc=function(t,e,r){return yge(t,e,r)};function bk(t){return LL(t),cf(t<0?0:wk(t)|0)}me.allocUnsafe=function(t){return bk(t)};me.allocUnsafeSlow=function(t){return bk(t)};function gge(t,e){if((typeof e!="string"||e==="")&&(e="utf8"),!me.isEncoding(e))throw new TypeError("Unknown encoding: "+e);var r=KL(t,e)|0,n=cf(r),i=n.write(t,e);return i!==r&&(n=n.slice(0,i)),n}function yk(t){for(var e=t.length<0?0:wk(t.length)|0,r=cf(e),n=0;n<e;n+=1)r[n]=t[n]&255;return r}function vge(t){if(Vu(t,Uint8Array)){var e=new Uint8Array(t);return gk(e.buffer,e.byteOffset,e.byteLength)}return yk(t)}function gk(t,e,r){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(r||0))throw new RangeError('"length" is outside of buffer bounds');var n;return e===void 0&&r===void 0?n=new Uint8Array(t):r===void 0?n=new Uint8Array(t,e):n=new Uint8Array(t,e,r),Object.setPrototypeOf(n,me.prototype),n}function bge(t){if(me.isBuffer(t)){var e=wk(t.length)|0,r=cf(e);return r.length===0||t.copy(r,0,0,e),r}if(t.length!==void 0)return typeof t.length!="number"||_k(t.length)?cf(0):yk(t);if(t.type==="Buffer"&&Array.isArray(t.data))return yk(t.data)}function wk(t){if(t>=j3)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+j3.toString(16)+" bytes");return t|0}function wge(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(Vu(e,Uint8Array)&&(e=me.from(e,e.offset,e.byteLength)),Vu(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);o<s;++o)if(e[o]!==r[o]){n=e[o],i=r[o];break}return n<i?-1:i<n?1:0};me.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}};me.concat=function(e,r){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(e.length===0)return me.alloc(0);var n;if(r===void 0)for(r=0,n=0;n<e.length;++n)r+=e[n].length;var i=me.allocUnsafe(r),o=0;for(n=0;n<e.length;++n){var s=e[n];if(Vu(s,Uint8Array))o+s.length>i.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 KL(t,e){if(me.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||Vu(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 vk(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return GL(t).length;default:if(i)return n?-1:vk(t).length;e=(""+e).toLowerCase(),i=!0}}me.byteLength=KL;function _ge(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 Bge(this,e,r);case"utf8":case"utf-8":return zL(this,e,r);case"ascii":return kge(this,e,r);case"latin1":case"binary":return Rge(this,e,r);case"base64":return Ige(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Mge(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}me.prototype._isBuffer=!0;function vy(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;r<e;r+=2)vy(this,r,r+1);return this};me.prototype.swap32=function(){var e=this.length;if(e%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var r=0;r<e;r+=4)vy(this,r,r+3),vy(this,r+1,r+2);return this};me.prototype.swap64=function(){var e=this.length;if(e%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var r=0;r<e;r+=8)vy(this,r,r+7),vy(this,r+1,r+6),vy(this,r+2,r+5),vy(this,r+3,r+4);return this};me.prototype.toString=function(){var e=this.length;return e===0?"":arguments.length===0?zL(this,0,e):_ge.apply(this,arguments)};me.prototype.toLocaleString=me.prototype.toString;me.prototype.equals=function(e){if(!me.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:me.compare(this,e)===0};me.prototype.inspect=function(){var e="",r=bv.INSPECT_MAX_BYTES;return e=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(e+=" ... "),"<Buffer "+e+">"};NL&&(me.prototype[NL]=me.prototype.inspect);me.prototype.compare=function(e,r,n,i,o){if(Vu(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;l<d;++l)if(u[l]!==c[l]){s=u[l],a=c[l];break}return s<a?-1:a<s?1:0};function FL(t,e,r,n,i){if(t.length===0)return-1;if(typeof r=="string"?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,_k(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:jL(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):jL(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function jL(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;u<s;u++)if(d(t,u)===d(e,c===-1?0:u-c)){if(c===-1&&(c=u),u-c+1===a)return c*o}else c!==-1&&(u-=u-c),c=-1}else for(r+a>s&&(r=s-a),u=r;u>=0;u--){for(var l=!0,m=0;m<a;m++)if(d(t,u+m)!==d(e,m)){l=!1;break}if(l)return u}return-1}me.prototype.includes=function(e,r,n){return this.indexOf(e,r,n)!==-1};me.prototype.indexOf=function(e,r,n){return FL(this,e,r,n,!0)};me.prototype.lastIndexOf=function(e,r,n){return FL(this,e,r,n,!1)};function xge(t,e,r,n){r=Number(r)||0;var i=t.length-r;n?(n=Number(n),n>i&&(n=i)):n=i;var o=e.length;n>o/2&&(n=o/2);for(var s=0;s<n;++s){var a=parseInt(e.substr(s*2,2),16);if(_k(a))return s;t[r+s]=a}return s}function Ege(t,e,r,n){return U3(vk(e,t.length-r),t,r,n)}function Sge(t,e,r,n){return U3(Cge(e),t,r,n)}function Age(t,e,r,n){return U3(GL(e),t,r,n)}function Tge(t,e,r,n){return U3($ge(e,t.length-r),t,r,n)}me.prototype.write=function(e,r,n,i){if(r===void 0)i="utf8",n=this.length,r=0;else if(n===void 0&&typeof r=="string")i=r,n=this.length,r=0;else if(isFinite(r))r=r>>>0,isFinite(n)?(n=n>>>0,i===void 0&&(i="utf8")):(i=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");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 xge(this,e,r,n);case"utf8":case"utf-8":return Ege(this,e,r,n);case"ascii":case"latin1":case"binary":return Sge(this,e,r,n);case"base64":return Age(this,e,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Tge(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 Ige(t,e,r){return e===0&&r===t.length?mk.fromByteArray(t):mk.fromByteArray(t.slice(e,r))}function zL(t,e,r){r=Math.min(t.length,r);for(var n=[],i=e;i<r;){var o=t[i],s=null,a=o>239?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 Pge(n)}var UL=4096;function Pge(t){var e=t.length;if(e<=UL)return String.fromCharCode.apply(String,t);for(var r="",n=0;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=UL));return r}function kge(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;i<r;++i)n+=String.fromCharCode(t[i]&127);return n}function Rge(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;i<r;++i)n+=String.fromCharCode(t[i]);return n}function Bge(t,e,r){var n=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>n)&&(r=n);for(var i="",o=e;o<r;++o)i+=Nge[t[o]];return i}function Mge(t,e,r){for(var n=t.slice(e,r),i="",o=0;o<n.length-1;o+=2)i+=String.fromCharCode(n[o]+n[o+1]*256);return i}me.prototype.slice=function(e,r){var n=this.length;e=~~e,r=r===void 0?n:~~r,e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),r<0?(r+=n,r<0&&(r=0)):r>n&&(r=n),r<e&&(r=e);var i=this.subarray(e,r);return Object.setPrototypeOf(i,me.prototype),i};function so(t,e,r){if(t%1!==0||t<0)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}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<r&&(o*=256);)i+=this[e+s]*o;return i};me.prototype.readUintBE=me.prototype.readUIntBE=function(e,r,n){e=e>>>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<r&&(o*=256);)i+=this[e+s]*o;return o*=128,i>=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),vv.read(this,e,!0,23,4)};me.prototype.readFloatBE=function(e,r){return e=e>>>0,r||so(e,4,this.length),vv.read(this,e,!1,23,4)};me.prototype.readDoubleLE=function(e,r){return e=e>>>0,r||so(e,8,this.length),vv.read(this,e,!0,52,8)};me.prototype.readDoubleBE=function(e,r){return e=e>>>0,r||so(e,8,this.length),vv.read(this,e,!1,52,8)};function va(t,e,r,n,i,o){if(!me.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||e<o)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}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;va(this,e,r,n,o,0)}var s=1,a=0;for(this[r]=e&255;++a<n&&(s*=256);)this[r+a]=e/s&255;return r+n};me.prototype.writeUintBE=me.prototype.writeUIntBE=function(e,r,n,i){if(e=+e,r=r>>>0,n=n>>>0,!i){var o=Math.pow(2,8*n)-1;va(this,e,r,n,o,0)}var s=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||va(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||va(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||va(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||va(this,e,r,4,4294967295,0),this[r+3]=e>>>24,this[r+2]=e>>>16,this[r+1]=e>>>8,this[r]=e&255,r+4};me.prototype.writeUint32BE=me.prototype.writeUInt32BE=function(e,r,n){return e=+e,r=r>>>0,n||va(this,e,r,4,4294967295,0),this[r]=e>>>24,this[r+1]=e>>>16,this[r+2]=e>>>8,this[r+3]=e&255,r+4};me.prototype.writeIntLE=function(e,r,n,i){if(e=+e,r=r>>>0,!i){var o=Math.pow(2,8*n-1);va(this,e,r,n,o-1,-o)}var s=0,a=1,d=0;for(this[r]=e&255;++s<n&&(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.writeIntBE=function(e,r,n,i){if(e=+e,r=r>>>0,!i){var o=Math.pow(2,8*n-1);va(this,e,r,n,o-1,-o)}var s=n-1,a=1,d=0;for(this[r+s]=e&255;--s>=0&&(a*=256);)e<0&&d===0&&this[r+s+1]!==0&&(d=1),this[r+s]=(e/a>>0)-d&255;return r+n};me.prototype.writeInt8=function(e,r,n){return e=+e,r=r>>>0,n||va(this,e,r,1,127,-128),e<0&&(e=255+e+1),this[r]=e&255,r+1};me.prototype.writeInt16LE=function(e,r,n){return e=+e,r=r>>>0,n||va(this,e,r,2,32767,-32768),this[r]=e&255,this[r+1]=e>>>8,r+2};me.prototype.writeInt16BE=function(e,r,n){return e=+e,r=r>>>0,n||va(this,e,r,2,32767,-32768),this[r]=e>>>8,this[r+1]=e&255,r+2};me.prototype.writeInt32LE=function(e,r,n){return e=+e,r=r>>>0,n||va(this,e,r,4,2147483647,-2147483648),this[r]=e&255,this[r+1]=e>>>8,this[r+2]=e>>>16,this[r+3]=e>>>24,r+4};me.prototype.writeInt32BE=function(e,r,n){return e=+e,r=r>>>0,n||va(this,e,r,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[r]=e>>>24,this[r+1]=e>>>16,this[r+2]=e>>>8,this[r+3]=e&255,r+4};function VL(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 HL(t,e,r,n,i){return e=+e,r=r>>>0,i||VL(t,e,r,4,34028234663852886e22,-34028234663852886e22),vv.write(t,e,r,n,23,4),r+4}me.prototype.writeFloatLE=function(e,r,n){return HL(this,e,r,!0,n)};me.prototype.writeFloatBE=function(e,r,n){return HL(this,e,r,!1,n)};function WL(t,e,r,n,i){return e=+e,r=r>>>0,i||VL(t,e,r,8,17976931348623157e292,-17976931348623157e292),vv.write(t,e,r,n,52,8),r+8}me.prototype.writeDoubleLE=function(e,r,n){return WL(this,e,r,!0,n)};me.prototype.writeDoubleBE=function(e,r,n){return WL(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<n&&(i=n),i===n||e.length===0||this.length===0)return 0;if(r<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),e.length-r<i-n&&(i=e.length-r+n);var o=i-n;return this===e&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(r,n,i):Uint8Array.prototype.set.call(e,this.subarray(n,i),r),o};me.prototype.fill=function(e,r,n,i){if(typeof e=="string"){if(typeof r=="string"?(i=r,r=0,n=this.length):typeof n=="string"&&(i=n,n=this.length),i!==void 0&&typeof i!="string")throw new TypeError("encoding must be a string");if(typeof i=="string"&&!me.isEncoding(i))throw new TypeError("Unknown encoding: "+i);if(e.length===1){var o=e.charCodeAt(0);(i==="utf8"&&o<128||i==="latin1")&&(e=o)}}else typeof e=="number"?e=e&255:typeof e=="boolean"&&(e=Number(e));if(r<0||this.length<r||this.length<n)throw new RangeError("Out of range index");if(n<=r)return this;r=r>>>0,n=n===void 0?this.length:n>>>0,e||(e=0);var s;if(typeof e=="number")for(s=r;s<n;++s)this[s]=e;else{var a=me.isBuffer(e)?e:me.from(e,i),d=a.length;if(d===0)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(s=0;s<n-r;++s)this[s+r]=a[s%d]}return this};var Dge=/[^+/0-9A-Za-z-_]/g;function Oge(t){if(t=t.split("=")[0],t=t.trim().replace(Dge,""),t.length<2)return"";for(;t.length%4!==0;)t=t+"=";return t}function vk(t,e){e=e||1/0;for(var r,n=t.length,i=null,o=[],s=0;s<n;++s){if(r=t.charCodeAt(s),r>55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}else if(s+1===n){(e-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&o.push(239,191,189),i=r;continue}r=(i-55296<<10|r-56320)+65536}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;o.push(r)}else if(r<2048){if((e-=2)<0)break;o.push(r>>6|192,r&63|128)}else if(r<65536){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<1114112){if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,r&63|128)}else throw new Error("Invalid code point")}return o}function Cge(t){for(var e=[],r=0;r<t.length;++r)e.push(t.charCodeAt(r)&255);return e}function $ge(t,e){for(var r,n,i,o=[],s=0;s<t.length&&!((e-=2)<0);++s)r=t.charCodeAt(s),n=r>>8,i=r%256,o.push(i),o.push(n);return o}function GL(t){return mk.toByteArray(Oge(t))}function U3(t,e,r,n){for(var i=0;i<n&&!(i+r>=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function Vu(t,e){return t instanceof e||t!=null&&t.constructor!=null&&t.constructor.name!=null&&t.constructor.name===e.name}function _k(t){return t!==t}var Nge=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 fs=H((sZe,QL)=>{h();var wi=QL.exports={},Hu,Wu;function xk(){throw new Error("setTimeout has not been defined")}function Ek(){throw new Error("clearTimeout has not been defined")}(function(){try{typeof setTimeout=="function"?Hu=setTimeout:Hu=xk}catch{Hu=xk}try{typeof clearTimeout=="function"?Wu=clearTimeout:Wu=Ek}catch{Wu=Ek}})();function YL(t){if(Hu===setTimeout)return setTimeout(t,0);if((Hu===xk||!Hu)&&setTimeout)return Hu=setTimeout,setTimeout(t,0);try{return Hu(t,0)}catch{try{return Hu.call(null,t,0)}catch{return Hu.call(this,t,0)}}}function jge(t){if(Wu===clearTimeout)return clearTimeout(t);if((Wu===Ek||!Wu)&&clearTimeout)return Wu=clearTimeout,clearTimeout(t);try{return Wu(t)}catch{try{return Wu.call(null,t)}catch{return Wu.call(this,t)}}}var df=[],wv=!1,by,q3=-1;function Uge(){!wv||!by||(wv=!1,by.length?df=by.concat(df):q3=-1,df.length&&ZL())}function ZL(){if(!wv){var t=YL(Uge);wv=!0;for(var e=df.length;e;){for(by=df,df=[];++q3<e;)by&&by[q3].run();q3=-1,e=df.length}by=null,wv=!1,jge(t)}}wi.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)e[r-1]=arguments[r];df.push(new XL(t,e)),df.length===1&&!wv&&YL(ZL)};function XL(t,e){this.fun=t,this.array=e}XL.prototype.run=function(){this.fun.apply(null,this.array)};wi.title="browser";wi.browser=!0;wi.env={};wi.argv=[];wi.version="";wi.versions={};function uf(){}wi.on=uf;wi.addListener=uf;wi.once=uf;wi.off=uf;wi.removeListener=uf;wi.removeAllListeners=uf;wi.emit=uf;wi.prependListener=uf;wi.prependOnceListener=uf;wi.listeners=function(t){return[]};wi.binding=function(t){throw new Error("process.binding is not supported")};wi.cwd=function(){return"/"};wi.chdir=function(t){throw new Error("process.chdir is not supported")};wi.umask=function(){return 0}});var C,D,cZe,h=sge(()=>{C=qt(JL()),D=qt(fs()),cZe=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 tK=H((uZe,eK)=>{h();var qge=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,L3=()=>qge.now(),Lge=t=>t&&t===Math.floor(t)&&t>0&&isFinite(t),Sk=t=>t===1/0||Lge(t),Ak=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&&!Sk(r))throw new TypeError("ttl must be positive integer or Infinity if set");if(!Sk(e))throw new TypeError("max must be positive integer or Infinity");if(this.ttl=r,this.max=e,this.updateAgeOnGet=!!n,this.checkAgeOnGet=!!i,this.noUpdateTTL=!!o,this.noDisposeOnSet=!!a,s!==void 0){if(typeof s!="function")throw new TypeError("dispose must be function if set");this.dispose=s}this.timer=void 0,this.timerExpiration=void 0}setTimer(e,r){if(this.timerExpiration<e)return;this.timer&&clearTimeout(this.timer);let n=setTimeout(()=>{this.timer=void 0,this.timerExpiration=void 0,this.purgeStale();for(let i in this.expirations){this.setTimer(i,i-L3());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 D.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(L3()+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(!Sk(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-L3())):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(L3());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()}};eK.exports=Ak});var vK=H(gK=>{"use strict";h();gK.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 Ud=H((TXe,bK)=>{"use strict";h();bK.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=H(Tv=>{"use strict";h();var Nk=fk(),Sv=pk(),wK=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;Tv.Buffer=fe;Tv.SlowBuffer=xve;Tv.INSPECT_MAX_BYTES=50;var z3=2147483647;Tv.kMaxLength=z3;fe.TYPED_ARRAY_SUPPORT=gve();!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 gve(){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 ff(t){if(t>z3)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 Lk(t)}return SK(t,e,r)}fe.poolSize=8192;function SK(t,e,r){if(typeof t=="string")return bve(t,e);if(ArrayBuffer.isView(t))return wve(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(Gu(t,ArrayBuffer)||t&&Gu(t.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(Gu(t,SharedArrayBuffer)||t&&Gu(t.buffer,SharedArrayBuffer)))return Uk(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=_ve(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 SK(t,e,r)};Object.setPrototypeOf(fe.prototype,Uint8Array.prototype);Object.setPrototypeOf(fe,Uint8Array);function AK(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 vve(t,e,r){return AK(t),t<=0?ff(t):e!==void 0?typeof r=="string"?ff(t).fill(e,r):ff(t).fill(e):ff(t)}fe.alloc=function(t,e,r){return vve(t,e,r)};function Lk(t){return AK(t),ff(t<0?0:Kk(t)|0)}fe.allocUnsafe=function(t){return Lk(t)};fe.allocUnsafeSlow=function(t){return Lk(t)};function bve(t,e){if((typeof e!="string"||e==="")&&(e="utf8"),!fe.isEncoding(e))throw new TypeError("Unknown encoding: "+e);let r=TK(t,e)|0,n=ff(r),i=n.write(t,e);return i!==r&&(n=n.slice(0,i)),n}function jk(t){let e=t.length<0?0:Kk(t.length)|0,r=ff(e);for(let n=0;n<e;n+=1)r[n]=t[n]&255;return r}function wve(t){if(Gu(t,Uint8Array)){let e=new Uint8Array(t);return Uk(e.buffer,e.byteOffset,e.byteLength)}return jk(t)}function Uk(t,e,r){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(r||0))throw new RangeError('"length" is outside of buffer bounds');let n;return e===void 0&&r===void 0?n=new Uint8Array(t):r===void 0?n=new Uint8Array(t,e):n=new Uint8Array(t,e,r),Object.setPrototypeOf(n,fe.prototype),n}function _ve(t){if(fe.isBuffer(t)){let e=Kk(t.length)|0,r=ff(e);return r.length===0||t.copy(r,0,0,e),r}if(t.length!==void 0)return typeof t.length!="number"||zk(t.length)?ff(0):jk(t);if(t.type==="Buffer"&&Array.isArray(t.data))return jk(t.data)}function Kk(t){if(t>=z3)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+z3.toString(16)+" bytes");return t|0}function xve(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(Gu(e,Uint8Array)&&(e=fe.from(e,e.offset,e.byteLength)),Gu(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);o<s;++o)if(e[o]!==r[o]){n=e[o],i=r[o];break}return n<i?-1:i<n?1:0};fe.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}};fe.concat=function(e,r){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(e.length===0)return fe.alloc(0);let n;if(r===void 0)for(r=0,n=0;n<e.length;++n)r+=e[n].length;let i=fe.allocUnsafe(r),o=0;for(n=0;n<e.length;++n){let s=e[n];if(Gu(s,Uint8Array))o+s.length>i.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 TK(t,e){if(fe.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||Gu(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 qk(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return CK(t).length;default:if(i)return n?-1:qk(t).length;e=(""+e).toLowerCase(),i=!0}}fe.byteLength=TK;function Eve(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 Dve(this,e,r);case"utf8":case"utf-8":return PK(this,e,r);case"ascii":return Bve(this,e,r);case"latin1":case"binary":return Mve(this,e,r);case"base64":return kve(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Ove(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}fe.prototype._isBuffer=!0;function Sy(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;r<e;r+=2)Sy(this,r,r+1);return this};fe.prototype.swap32=function(){let e=this.length;if(e%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let r=0;r<e;r+=4)Sy(this,r,r+3),Sy(this,r+1,r+2);return this};fe.prototype.swap64=function(){let e=this.length;if(e%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let r=0;r<e;r+=8)Sy(this,r,r+7),Sy(this,r+1,r+6),Sy(this,r+2,r+5),Sy(this,r+3,r+4);return this};fe.prototype.toString=function(){let e=this.length;return e===0?"":arguments.length===0?PK(this,0,e):Eve.apply(this,arguments)};fe.prototype.toLocaleString=fe.prototype.toString;fe.prototype.equals=function(e){if(!fe.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:fe.compare(this,e)===0};fe.prototype.inspect=function(){let e="",r=Tv.INSPECT_MAX_BYTES;return e=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(e+=" ... "),"<Buffer "+e+">"};wK&&(fe.prototype[wK]=fe.prototype.inspect);fe.prototype.compare=function(e,r,n,i,o){if(Gu(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;l<d;++l)if(u[l]!==c[l]){s=u[l],a=c[l];break}return s<a?-1:a<s?1:0};function IK(t,e,r,n,i){if(t.length===0)return-1;if(typeof r=="string"?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,zk(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:_K(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):_K(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function _K(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;u<s;u++)if(d(t,u)===d(e,c===-1?0:u-c)){if(c===-1&&(c=u),u-c+1===a)return c*o}else c!==-1&&(u-=u-c),c=-1}else for(r+a>s&&(r=s-a),u=r;u>=0;u--){let c=!0;for(let l=0;l<a;l++)if(d(t,u+l)!==d(e,l)){c=!1;break}if(c)return u}return-1}fe.prototype.includes=function(e,r,n){return this.indexOf(e,r,n)!==-1};fe.prototype.indexOf=function(e,r,n){return IK(this,e,r,n,!0)};fe.prototype.lastIndexOf=function(e,r,n){return IK(this,e,r,n,!1)};function Sve(t,e,r,n){r=Number(r)||0;let i=t.length-r;n?(n=Number(n),n>i&&(n=i)):n=i;let o=e.length;n>o/2&&(n=o/2);let s;for(s=0;s<n;++s){let a=parseInt(e.substr(s*2,2),16);if(zk(a))return s;t[r+s]=a}return s}function Ave(t,e,r,n){return V3(qk(e,t.length-r),t,r,n)}function Tve(t,e,r,n){return V3(jve(e),t,r,n)}function Ive(t,e,r,n){return V3(CK(e),t,r,n)}function Pve(t,e,r,n){return V3(Uve(e,t.length-r),t,r,n)}fe.prototype.write=function(e,r,n,i){if(r===void 0)i="utf8",n=this.length,r=0;else if(n===void 0&&typeof r=="string")i=r,n=this.length,r=0;else if(isFinite(r))r=r>>>0,isFinite(n)?(n=n>>>0,i===void 0&&(i="utf8")):(i=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let o=this.length-r;if((n===void 0||n>o)&&(n=o),e.length>0&&(n<0||r<0)||r>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");let s=!1;for(;;)switch(i){case"hex":return Sve(this,e,r,n);case"utf8":case"utf-8":return Ave(this,e,r,n);case"ascii":case"latin1":case"binary":return Tve(this,e,r,n);case"base64":return Ive(this,e,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Pve(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 kve(t,e,r){return e===0&&r===t.length?Nk.fromByteArray(t):Nk.fromByteArray(t.slice(e,r))}function PK(t,e,r){r=Math.min(t.length,r);let n=[],i=e;for(;i<r;){let o=t[i],s=null,a=o>239?4:o>223?3:o>191?2:1;if(i+a<=r){let 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 Rve(n)}var xK=4096;function Rve(t){let e=t.length;if(e<=xK)return String.fromCharCode.apply(String,t);let r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=xK));return r}function Bve(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(t[i]&127);return n}function Mve(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(t[i]);return n}function Dve(t,e,r){let n=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>n)&&(r=n);let i="";for(let o=e;o<r;++o)i+=qve[t[o]];return i}function Ove(t,e,r){let n=t.slice(e,r),i="";for(let o=0;o<n.length-1;o+=2)i+=String.fromCharCode(n[o]+n[o+1]*256);return i}fe.prototype.slice=function(e,r){let n=this.length;e=~~e,r=r===void 0?n:~~r,e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),r<0?(r+=n,r<0&&(r=0)):r>n&&(r=n),r<e&&(r=e);let i=this.subarray(e,r);return Object.setPrototypeOf(i,fe.prototype),i};function ao(t,e,r){if(t%1!==0||t<0)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}fe.prototype.readUintLE=fe.prototype.readUIntLE=function(e,r,n){e=e>>>0,r=r>>>0,n||ao(e,r,this.length);let i=this[e],o=1,s=0;for(;++s<r&&(o*=256);)i+=this[e+s]*o;return i};fe.prototype.readUintBE=fe.prototype.readUIntBE=function(e,r,n){e=e>>>0,r=r>>>0,n||ao(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||ao(e,1,this.length),this[e]};fe.prototype.readUint16LE=fe.prototype.readUInt16LE=function(e,r){return e=e>>>0,r||ao(e,2,this.length),this[e]|this[e+1]<<8};fe.prototype.readUint16BE=fe.prototype.readUInt16BE=function(e,r){return e=e>>>0,r||ao(e,2,this.length),this[e]<<8|this[e+1]};fe.prototype.readUint32LE=fe.prototype.readUInt32LE=function(e,r){return e=e>>>0,r||ao(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||ao(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])};fe.prototype.readBigUInt64LE=Qh(function(e){e=e>>>0,Av(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&y2(e,this.length-8);let i=r+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24,o=this[++e]+this[++e]*2**8+this[++e]*2**16+n*2**24;return BigInt(i)+(BigInt(o)<<BigInt(32))});fe.prototype.readBigUInt64BE=Qh(function(e){e=e>>>0,Av(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&y2(e,this.length-8);let i=r*2**24+this[++e]*2**16+this[++e]*2**8+this[++e],o=this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n;return(BigInt(i)<<BigInt(32))+BigInt(o)});fe.prototype.readIntLE=function(e,r,n){e=e>>>0,r=r>>>0,n||ao(e,r,this.length);let i=this[e],o=1,s=0;for(;++s<r&&(o*=256);)i+=this[e+s]*o;return o*=128,i>=o&&(i-=Math.pow(2,8*r)),i};fe.prototype.readIntBE=function(e,r,n){e=e>>>0,r=r>>>0,n||ao(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||ao(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]};fe.prototype.readInt16LE=function(e,r){e=e>>>0,r||ao(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||ao(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||ao(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||ao(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]};fe.prototype.readBigInt64LE=Qh(function(e){e=e>>>0,Av(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&y2(e,this.length-8);let i=this[e+4]+this[e+5]*2**8+this[e+6]*2**16+(n<<24);return(BigInt(i)<<BigInt(32))+BigInt(r+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24)});fe.prototype.readBigInt64BE=Qh(function(e){e=e>>>0,Av(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&y2(e,this.length-8);let i=(r<<24)+this[++e]*2**16+this[++e]*2**8+this[++e];return(BigInt(i)<<BigInt(32))+BigInt(this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n)});fe.prototype.readFloatLE=function(e,r){return e=e>>>0,r||ao(e,4,this.length),Sv.read(this,e,!0,23,4)};fe.prototype.readFloatBE=function(e,r){return e=e>>>0,r||ao(e,4,this.length),Sv.read(this,e,!1,23,4)};fe.prototype.readDoubleLE=function(e,r){return e=e>>>0,r||ao(e,8,this.length),Sv.read(this,e,!0,52,8)};fe.prototype.readDoubleBE=function(e,r){return e=e>>>0,r||ao(e,8,this.length),Sv.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||e<o)throw new RangeError('"value" argument is out of bounds');if(r+n>t.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<n&&(o*=256);)this[r+s]=e/o&255;return r+n};fe.prototype.writeUintBE=fe.prototype.writeUIntBE=function(e,r,n,i){if(e=+e,r=r>>>0,n=n>>>0,!i){let a=Math.pow(2,8*n)-1;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 kK(t,e,r,n,i){OK(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 RK(t,e,r,n,i){OK(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=Qh(function(e,r=0){return kK(this,e,r,BigInt(0),BigInt("0xffffffffffffffff"))});fe.prototype.writeBigUInt64BE=Qh(function(e,r=0){return RK(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<n&&(s*=256);)e<0&&a===0&&this[r+o-1]!==0&&(a=1),this[r+o]=(e/s>>0)-a&255;return r+n};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=Qh(function(e,r=0){return kK(this,e,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});fe.prototype.writeBigInt64BE=Qh(function(e,r=0){return RK(this,e,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function BK(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 MK(t,e,r,n,i){return e=+e,r=r>>>0,i||BK(t,e,r,4,34028234663852886e22,-34028234663852886e22),Sv.write(t,e,r,n,23,4),r+4}fe.prototype.writeFloatLE=function(e,r,n){return MK(this,e,r,!0,n)};fe.prototype.writeFloatBE=function(e,r,n){return MK(this,e,r,!1,n)};function DK(t,e,r,n,i){return e=+e,r=r>>>0,i||BK(t,e,r,8,17976931348623157e292,-17976931348623157e292),Sv.write(t,e,r,n,52,8),r+8}fe.prototype.writeDoubleLE=function(e,r,n){return DK(this,e,r,!0,n)};fe.prototype.writeDoubleBE=function(e,r,n){return DK(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<n&&(i=n),i===n||e.length===0||this.length===0)return 0;if(r<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),e.length-r<i-n&&(i=e.length-r+n);let o=i-n;return this===e&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(r,n,i):Uint8Array.prototype.set.call(e,this.subarray(n,i),r),o};fe.prototype.fill=function(e,r,n,i){if(typeof e=="string"){if(typeof r=="string"?(i=r,r=0,n=this.length):typeof n=="string"&&(i=n,n=this.length),i!==void 0&&typeof i!="string")throw new TypeError("encoding must be a string");if(typeof i=="string"&&!fe.isEncoding(i))throw new TypeError("Unknown encoding: "+i);if(e.length===1){let s=e.charCodeAt(0);(i==="utf8"&&s<128||i==="latin1")&&(e=s)}}else typeof e=="number"?e=e&255:typeof e=="boolean"&&(e=Number(e));if(r<0||this.length<r||this.length<n)throw new RangeError("Out of range index");if(n<=r)return this;r=r>>>0,n=n===void 0?this.length:n>>>0,e||(e=0);let o;if(typeof e=="number")for(o=r;o<n;++o)this[o]=e;else{let s=fe.isBuffer(e)?e:fe.from(e,i),a=s.length;if(a===0)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(o=0;o<n-r;++o)this[o+r]=s[o%a]}return this};var Ev={};function Fk(t,e,r){Ev[t]=class extends r{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${t}]`,this.stack,delete this.name}get code(){return t}set code(i){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:i,writable:!0})}toString(){return`${this.name} [${t}]: ${this.message}`}}}Fk("ERR_BUFFER_OUT_OF_BOUNDS",function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);Fk("ERR_INVALID_ARG_TYPE",function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`},TypeError);Fk("ERR_OUT_OF_RANGE",function(t,e,r){let n=`The value of "${t}" is out of range.`,i=r;return Number.isInteger(r)&&Math.abs(r)>2**32?i=EK(String(r)):typeof r=="bigint"&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=EK(i)),i+="n"),n+=` It must be ${e}. Received ${i}`,n},RangeError);function EK(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 Cve(t,e,r){Av(e,"offset"),(t[e]===void 0||t[e+r]===void 0)&&y2(e,t.length-(r+1))}function OK(t,e,r,n,i,o){if(t>r||t<e){let s=typeof e=="bigint"?"n":"",a;throw o>3?e===0||e===BigInt(0)?a=`>= 0${s} and < 2${s} ** ${(o+1)*8}${s}`:a=`>= -(2${s} ** ${(o+1)*8-1}${s}) and < 2 ** ${(o+1)*8-1}${s}`:a=`>= ${e}${s} and <= ${r}${s}`,new Ev.ERR_OUT_OF_RANGE("value",a,t)}Cve(n,i,o)}function Av(t,e){if(typeof t!="number")throw new Ev.ERR_INVALID_ARG_TYPE(e,"number",t)}function y2(t,e,r){throw Math.floor(t)!==t?(Av(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 $ve=/[^+/0-9A-Za-z-_]/g;function Nve(t){if(t=t.split("=")[0],t=t.trim().replace($ve,""),t.length<2)return"";for(;t.length%4!==0;)t=t+"=";return t}function qk(t,e){e=e||1/0;let r,n=t.length,i=null,o=[];for(let s=0;s<n;++s){if(r=t.charCodeAt(s),r>55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}else if(s+1===n){(e-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&o.push(239,191,189),i=r;continue}r=(i-55296<<10|r-56320)+65536}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;o.push(r)}else if(r<2048){if((e-=2)<0)break;o.push(r>>6|192,r&63|128)}else if(r<65536){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<1114112){if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,r&63|128)}else throw new Error("Invalid code point")}return o}function jve(t){let e=[];for(let r=0;r<t.length;++r)e.push(t.charCodeAt(r)&255);return e}function Uve(t,e){let r,n,i,o=[];for(let s=0;s<t.length&&!((e-=2)<0);++s)r=t.charCodeAt(s),n=r>>8,i=r%256,o.push(i),o.push(n);return o}function CK(t){return Nk.toByteArray(Nve(t))}function V3(t,e,r,n){let i;for(i=0;i<n&&!(i+r>=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function Gu(t,e){return t instanceof e||t!=null&&t.constructor!=null&&t.constructor.name!=null&&t.constructor.name===e.name}function zk(t){return t!==t}var qve=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 Qh(t){return typeof BigInt>"u"?Lve:t}function Lve(){throw new Error("BigInt not supported")}});var Hk=H((BXe,$K)=>{"use strict";h();var Vk=null;$K.exports=function(){return Vk===null&&(Vk={textEncoder:new TextEncoder,textDecoder:new TextDecoder}),Vk}});var Jk=H(NK=>{"use strict";h();var Wk=Ud(),Kve=new Set(["buffer","view","utf8"]),Gk=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"||!Kve.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 Wk(`Encoding '${this.name}' cannot be transcoded to 'buffer'`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"})}createViewTranscoder(){throw new Wk(`Encoding '${this.name}' cannot be transcoded to 'view'`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"})}createUTF8Transcoder(){throw new Wk(`Encoding '${this.name}' cannot be transcoded to 'utf8'`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"})}};NK.Encoding=Gk});var Qk=H(H3=>{"use strict";h();var{Buffer:Zk}=$n()||{},{Encoding:Xk}=Jk(),Fve=Hk(),g2=class extends Xk{constructor(e){super({...e,format:"buffer"})}createViewTranscoder(){return new v2({encode:this.encode,decode:e=>this.decode(Zk.from(e.buffer,e.byteOffset,e.byteLength)),name:`${this.name}+view`})}createBufferTranscoder(){return this}},v2=class extends Xk{constructor(e){super({...e,format:"view"})}createBufferTranscoder(){return new g2({encode:e=>{let r=this.encode(e);return Zk.from(r.buffer,r.byteOffset,r.byteLength)},decode:this.decode,name:`${this.name}+buffer`})}createViewTranscoder(){return this}},Yk=class extends Xk{constructor(e){super({...e,format:"utf8"})}createBufferTranscoder(){return new g2({encode:e=>Zk.from(this.encode(e),"utf8"),decode:e=>this.decode(e.toString("utf8")),name:`${this.name}+buffer`})}createViewTranscoder(){let{textEncoder:e,textDecoder:r}=Fve();return new v2({encode:n=>e.encode(this.encode(n)),decode:n=>this.decode(r.decode(n)),name:`${this.name}+view`})}createUTF8Transcoder(){return this}};H3.BufferFormat=g2;H3.ViewFormat=v2;H3.UTF8Format=Yk});var LK=H(Ay=>{"use strict";h();var{Buffer:hs}=$n()||{Buffer:{isBuffer:()=>!1}},{textEncoder:UK,textDecoder:jK}=Hk()(),{BufferFormat:b2,ViewFormat:e9,UTF8Format:qK}=Qk(),W3=t=>t;Ay.utf8=new qK({encode:function(t){return hs.isBuffer(t)?t.toString("utf8"):ArrayBuffer.isView(t)?jK.decode(t):String(t)},decode:W3,name:"utf8",createViewTranscoder(){return new e9({encode:function(t){return ArrayBuffer.isView(t)?t:UK.encode(t)},decode:function(t){return jK.decode(t)},name:`${this.name}+view`})},createBufferTranscoder(){return new b2({encode:function(t){return hs.isBuffer(t)?t:ArrayBuffer.isView(t)?hs.from(t.buffer,t.byteOffset,t.byteLength):hs.from(String(t),"utf8")},decode:function(t){return t.toString("utf8")},name:`${this.name}+buffer`})}});Ay.json=new qK({encode:JSON.stringify,decode:JSON.parse,name:"json"});Ay.buffer=new b2({encode:function(t){return hs.isBuffer(t)?t:ArrayBuffer.isView(t)?hs.from(t.buffer,t.byteOffset,t.byteLength):hs.from(String(t),"utf8")},decode:W3,name:"buffer",createViewTranscoder(){return new e9({encode:function(t){return ArrayBuffer.isView(t)?t:hs.from(String(t),"utf8")},decode:function(t){return hs.from(t.buffer,t.byteOffset,t.byteLength)},name:`${this.name}+view`})}});Ay.view=new e9({encode:function(t){return ArrayBuffer.isView(t)?t:UK.encode(t)},decode:W3,name:"view",createBufferTranscoder(){return new b2({encode:function(t){return hs.isBuffer(t)?t:ArrayBuffer.isView(t)?hs.from(t.buffer,t.byteOffset,t.byteLength):hs.from(String(t),"utf8")},decode:W3,name:`${this.name}+buffer`})}});Ay.hex=new b2({encode:function(t){return hs.isBuffer(t)?t:hs.from(String(t),"hex")},decode:function(t){return t.toString("hex")},name:"hex"});Ay.base64=new b2({encode:function(t){return hs.isBuffer(t)?t:hs.from(String(t),"base64")},decode:function(t){return t.toString("base64")},name:"base64"})});var zK=H(FK=>{"use strict";h();var KK=Ud(),J3=LK(),{Encoding:zve}=Jk(),{BufferFormat:Vve,ViewFormat:Hve,UTF8Format:Wve}=Qk(),w2=Symbol("formats"),G3=Symbol("encodings"),Gve=new Set(["buffer","view","utf8"]),t9=class{constructor(e){if(Array.isArray(e)){if(!e.every(r=>Gve.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[G3]=new Map,this[w2]=new Set(e);for(let r in J3)try{this.encoding(r)}catch(n){if(n.code!=="LEVEL_ENCODING_NOT_SUPPORTED")throw n}}encodings(){return Array.from(new Set(this[G3].values()))}encoding(e){let r=this[G3].get(e);if(r===void 0){if(typeof e=="string"&&e!==""){if(r=Xve[e],!r)throw new KK(`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=Jve(e)}let{name:n,format:i}=r;if(!this[w2].has(i))if(this[w2].has("view"))r=r.createViewTranscoder();else if(this[w2].has("buffer"))r=r.createBufferTranscoder();else if(this[w2].has("utf8"))r=r.createUTF8Transcoder();else throw new KK(`Encoding '${n}' cannot be transcoded`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"});for(let o of[e,n,r.name,r.commonName])this[G3].set(o,r)}return r}};FK.Transcoder=t9;function Jve(t){if(t instanceof zve)return t;let e="type"in t&&typeof t.type=="string"?t.type:void 0,r=t.name||e||`anonymous-${Qve++}`;switch(Yve(t)){case"view":return new Hve({...t,name:r});case"utf8":return new Wve({...t,name:r});case"buffer":return new Vve({...t,name:r});default:throw new TypeError("Format must be one of 'buffer', 'view', 'utf8'")}}function Yve(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 Zve={binary:J3.buffer,"utf-8":J3.utf8},Xve={...J3,...Zve},Qve=0});var Ja=H((LXe,r9)=>{"use strict";h();var Iv=typeof Reflect=="object"?Reflect:null,VK=Iv&&typeof Iv.apply=="function"?Iv.apply:function(e,r,n){return Function.prototype.apply.call(e,r,n)},Y3;Iv&&typeof Iv.ownKeys=="function"?Y3=Iv.ownKeys:Object.getOwnPropertySymbols?Y3=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Y3=function(e){return Object.getOwnPropertyNames(e)};function ebe(t){console&&console.warn&&console.warn(t)}var WK=Number.isNaN||function(e){return e!==e};function dn(){dn.init.call(this)}r9.exports=dn;r9.exports.once=ibe;dn.EventEmitter=dn;dn.prototype._events=void 0;dn.prototype._eventsCount=0;dn.prototype._maxListeners=void 0;var HK=10;function Z3(t){if(typeof t!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}Object.defineProperty(dn,"defaultMaxListeners",{enumerable:!0,get:function(){return HK},set:function(t){if(typeof t!="number"||t<0||WK(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");HK=t}});dn.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};dn.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||WK(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 GK(t){return t._maxListeners===void 0?dn.defaultMaxListeners:t._maxListeners}dn.prototype.getMaxListeners=function(){return GK(this)};dn.prototype.emit=function(e){for(var r=[],n=1;n<arguments.length;n++)r.push(arguments[n]);var i=e==="error",o=this._events;if(o!==void 0)i=i&&o.error===void 0;else if(!i)return!1;if(i){var s;if(r.length>0&&(s=r[0]),s instanceof Error)throw s;var a=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw a.context=s,a}var d=o[e];if(d===void 0)return!1;if(typeof d=="function")VK(d,this,r);else for(var u=d.length,c=QK(d,u),n=0;n<u;++n)VK(c[n],this,r);return!0};function JK(t,e,r,n){var i,o,s;if(Z3(r),o=t._events,o===void 0?(o=t._events=Object.create(null),t._eventsCount=0):(o.newListener!==void 0&&(t.emit("newListener",e,r.listener?r.listener:r),o=t._events),s=o[e]),s===void 0)s=o[e]=r,++t._eventsCount;else if(typeof s=="function"?s=o[e]=n?[r,s]:[s,r]:n?s.unshift(r):s.push(r),i=GK(t),i>0&&s.length>i&&!s.warned){s.warned=!0;var a=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");a.name="MaxListenersExceededWarning",a.emitter=t,a.type=e,a.count=s.length,ebe(a)}return t}dn.prototype.addListener=function(e,r){return JK(this,e,r,!1)};dn.prototype.on=dn.prototype.addListener;dn.prototype.prependListener=function(e,r){return JK(this,e,r,!0)};function tbe(){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 YK(t,e,r){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},i=tbe.bind(n);return i.listener=r,n.wrapFn=i,i}dn.prototype.once=function(e,r){return Z3(r),this.on(e,YK(this,e,r)),this};dn.prototype.prependOnceListener=function(e,r){return Z3(r),this.prependListener(e,YK(this,e,r)),this};dn.prototype.removeListener=function(e,r){var n,i,o,s,a;if(Z3(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():rbe(n,o),n.length===1&&(i[e]=n[0]),i.removeListener!==void 0&&this.emit("removeListener",e,a||r)}return this};dn.prototype.off=dn.prototype.removeListener;dn.prototype.removeAllListeners=function(e){var r,n,i;if(n=this._events,n===void 0)return this;if(n.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):n[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete n[e]),this;if(arguments.length===0){var o=Object.keys(n),s;for(i=0;i<o.length;++i)s=o[i],s!=="removeListener"&&this.removeAllListeners(s);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(r=n[e],typeof r=="function")this.removeListener(e,r);else if(r!==void 0)for(i=r.length-1;i>=0;i--)this.removeListener(e,r[i]);return this};function ZK(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?nbe(i):QK(i,i.length)}dn.prototype.listeners=function(e){return ZK(this,e,!0)};dn.prototype.rawListeners=function(e){return ZK(this,e,!1)};dn.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):XK.call(t,e)};dn.prototype.listenerCount=XK;function XK(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}dn.prototype.eventNames=function(){return this._eventsCount>0?Y3(this._events):[]};function QK(t,e){for(var r=new Array(e),n=0;n<e;++n)r[n]=t[n];return r}function rbe(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}function nbe(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}function ibe(t,e){return new Promise(function(r,n){function i(s){t.removeListener(e,o),n(s)}function o(){typeof t.removeListener=="function"&&t.removeListener("error",i),r([].slice.call(arguments))}eF(t,e,o,{once:!0}),e!=="error"&&obe(t,i,{once:!0})})}function obe(t,e,r){typeof t.on=="function"&&eF(t,"error",e,r)}function eF(t,e,r,n){if(typeof t.on=="function")n.once?t.once(e,r):t.on(e,r);else if(typeof t.addEventListener=="function")t.addEventListener(e,function i(o){n.once&&t.removeEventListener(e,i),r(o)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t)}});var rF=H((FXe,tF)=>{h();tF.exports=typeof queueMicrotask=="function"?queueMicrotask:t=>Promise.resolve().then(t)});var _2=H(n9=>{"use strict";h();var nF=rF();n9.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};n9.fromPromise=function(t,e){if(e===void 0)return t;t.then(function(r){nF(()=>e(null,r))}).catch(function(r){nF(()=>e(r))})}});var X3=H(i9=>{"use strict";h();i9.getCallback=function(t,e){return typeof t=="function"?t:e};i9.getOptions=function(t,e){return typeof t=="object"&&t!==null?t:e!==void 0?e:{}}});var op=H(rS=>{"use strict";h();var{fromCallback:o9}=_2(),Ya=Ud(),{getOptions:s9,getCallback:iF}=X3(),Ty=Symbol("promise"),Pv=Symbol("callback"),Ju=Symbol("working"),Iy=Symbol("handleOne"),hf=Symbol("handleMany"),a9=Symbol("autoClose"),np=Symbol("finishWork"),Yu=Symbol("returnMany"),ep=Symbol("closing"),x2=Symbol("handleClose"),Q3=Symbol("closed"),E2=Symbol("closeCallbacks"),rp=Symbol("keyEncoding"),Py=Symbol("valueEncoding"),c9=Symbol("abortOnClose"),eS=Symbol("legacy"),d9=Symbol("keys"),u9=Symbol("values"),tp=Symbol("limit"),Uc=Symbol("count"),tS=Object.freeze({}),sbe=()=>{},oF=!1,S2=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[Q3]=!1,this[E2]=[],this[Ju]=!1,this[ep]=!1,this[a9]=!1,this[Pv]=null,this[Iy]=this[Iy].bind(this),this[hf]=this[hf].bind(this),this[x2]=this[x2].bind(this),this[rp]=r[rp],this[Py]=r[Py],this[eS]=n,this[tp]=Number.isInteger(r.limit)&&r.limit>=0?r.limit:1/0,this[Uc]=0,this[c9]=!!r.abortOnClose,this.db=e,this.db.attachResource(this),this.nextTick=e.nextTick}get count(){return this[Uc]}get limit(){return this[tp]}next(e){let r;if(e===void 0)r=new Promise((n,i)=>{e=(o,s,a)=>{o?i(o):this[eS]?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[ep]?this.nextTick(e,new Ya("Iterator is not open: cannot call next() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this[Ju]?this.nextTick(e,new Ya("Iterator is busy: cannot call next() until previous call has completed",{code:"LEVEL_ITERATOR_BUSY"})):(this[Ju]=!0,this[Pv]=e,this[Uc]>=this[tp]?this.nextTick(this[Iy],null):this._next(this[Iy])),r}_next(e){this.nextTick(e)}nextv(e,r,n){return n=iF(r,n),n=o9(n,Ty),r=s9(r,tS),Number.isInteger(e)?(this[ep]?this.nextTick(n,new Ya("Iterator is not open: cannot call nextv() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this[Ju]?this.nextTick(n,new Ya("Iterator is busy: cannot call nextv() until previous call has completed",{code:"LEVEL_ITERATOR_BUSY"})):(e<1&&(e=1),this[tp]<1/0&&(e=Math.min(e,this[tp]-this[Uc])),this[Ju]=!0,this[Pv]=n,e<=0?this.nextTick(this[hf],null,[]):this._nextv(e,r,this[hf])),n[Ty]):(this.nextTick(n,new TypeError("The first argument 'size' must be an integer")),n[Ty])}_nextv(e,r,n){let i=[],o=(s,a,d)=>{if(s)return n(s);if(this[eS]?a===void 0&&d===void 0:a===void 0)return n(null,i);i.push(this[eS]?[a,d]:a),i.length===e?n(null,i):this._next(o)};this._next(o)}all(e,r){return r=iF(e,r),r=o9(r,Ty),e=s9(e,tS),this[ep]?this.nextTick(r,new Ya("Iterator is not open: cannot call all() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this[Ju]?this.nextTick(r,new Ya("Iterator is busy: cannot call all() until previous call has completed",{code:"LEVEL_ITERATOR_BUSY"})):(this[Ju]=!0,this[Pv]=r,this[a9]=!0,this[Uc]>=this[tp]?this.nextTick(this[hf],null,[]):this._all(e,this[hf])),r[Ty]}_all(e,r){let n=this[Uc],i=[],o=()=>{let a=this[tp]<1/0?Math.min(1e3,this[tp]-n):1e3;a<=0?this.nextTick(r,null,i):this._nextv(a,tS,s)},s=(a,d)=>{a?r(a):d.length===0?r(null,i):(i.push.apply(i,d),n+=d.length,o())};o()}[np](){let e=this[Pv];return this[c9]&&e===null?sbe:(this[Ju]=!1,this[Pv]=null,this[ep]&&this._close(this[x2]),e)}[Yu](e,r,n){this[a9]?this.close(e.bind(null,r,n)):e(r,n)}seek(e,r){if(r=s9(r,tS),!this[ep]){if(this[Ju])throw new Ya("Iterator is busy: cannot call seek() until next() has completed",{code:"LEVEL_ITERATOR_BUSY"});{let n=this.db.keyEncoding(r.keyEncoding||this[rp]),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 Ya("Iterator does not support seek()",{code:"LEVEL_NOT_SUPPORTED"})}close(e){return e=o9(e,Ty),this[Q3]?this.nextTick(e):this[ep]?this[E2].push(e):(this[ep]=!0,this[E2].push(e),this[Ju]?this[c9]&&this[np]()(new Ya("Aborted on iterator close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this._close(this[x2])),e[Ty]}_close(e){this.nextTick(e)}[x2](){this[Q3]=!0,this.db.detachResource(this);let e=this[E2];this[E2]=[];for(let r of e)r()}async*[Symbol.asyncIterator](){try{let e;for(;(e=await this.next())!==void 0;)yield e}finally{this[Q3]||await this.close()}}},kv=class extends S2{constructor(e,r){super(e,r,!0),this[d9]=r.keys!==!1,this[u9]=r.values!==!1}[Iy](e,r,n){let i=this[np]();if(e)return i(e);try{r=this[d9]&&r!==void 0?this[rp].decode(r):void 0,n=this[u9]&&n!==void 0?this[Py].decode(n):void 0}catch(o){return i(new ip("entry",o))}r===void 0&&n===void 0||this[Uc]++,i(null,r,n)}[hf](e,r){let n=this[np]();if(e)return this[Yu](n,e);try{for(let i of r){let o=i[0],s=i[1];i[0]=this[d9]&&o!==void 0?this[rp].decode(o):void 0,i[1]=this[u9]&&s!==void 0?this[Py].decode(s):void 0}}catch(i){return this[Yu](n,new ip("entries",i))}this[Uc]+=r.length,this[Yu](n,null,r)}end(e){return!oF&&typeof console<"u"&&(oF=!0,console.warn(new Ya("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)}},l9=class extends S2{constructor(e,r){super(e,r,!1)}[Iy](e,r){let n=this[np]();if(e)return n(e);try{r=r!==void 0?this[rp].decode(r):void 0}catch(i){return n(new ip("key",i))}r!==void 0&&this[Uc]++,n(null,r)}[hf](e,r){let n=this[np]();if(e)return this[Yu](n,e);try{for(let i=0;i<r.length;i++){let o=r[i];r[i]=o!==void 0?this[rp].decode(o):void 0}}catch(i){return this[Yu](n,new ip("keys",i))}this[Uc]+=r.length,this[Yu](n,null,r)}},f9=class extends S2{constructor(e,r){super(e,r,!1)}[Iy](e,r){let n=this[np]();if(e)return n(e);try{r=r!==void 0?this[Py].decode(r):void 0}catch(i){return n(new ip("value",i))}r!==void 0&&this[Uc]++,n(null,r)}[hf](e,r){let n=this[np]();if(e)return this[Yu](n,e);try{for(let i=0;i<r.length;i++){let o=r[i];r[i]=o!==void 0?this[Py].decode(o):void 0}}catch(i){return this[Yu](n,new ip("values",i))}this[Uc]+=r.length,this[Yu](n,null,r)}},ip=class extends Ya{constructor(e,r){super(`Iterator could not decode ${e}`,{code:"LEVEL_DECODE_ERROR",cause:r})}};for(let t of["_ended property","_nexting property","_end method"])Object.defineProperty(kv.prototype,t.split(" ")[0],{get(){throw new Ya(`The ${t} has been removed`,{code:"LEVEL_LEGACY"})},set(){throw new Ya(`The ${t} has been removed`,{code:"LEVEL_LEGACY"})}});kv.keyEncoding=rp;kv.valueEncoding=Py;rS.AbstractIterator=kv;rS.AbstractKeyIterator=l9;rS.AbstractValueIterator=f9});var sF=H(h9=>{"use strict";h();var{AbstractKeyIterator:abe,AbstractValueIterator:cbe}=op(),ky=Symbol("iterator"),A2=Symbol("callback"),Rv=Symbol("handleOne"),Ry=Symbol("handleMany"),T2=class extends abe{constructor(e,r){super(e,r),this[ky]=e.iterator({...r,keys:!0,values:!1}),this[Rv]=this[Rv].bind(this),this[Ry]=this[Ry].bind(this)}},nS=class extends cbe{constructor(e,r){super(e,r),this[ky]=e.iterator({...r,keys:!1,values:!0}),this[Rv]=this[Rv].bind(this),this[Ry]=this[Ry].bind(this)}};for(let t of[T2,nS]){let e=t===T2,r=e?n=>n[0]:n=>n[1];t.prototype._next=function(n){this[A2]=n,this[ky].next(this[Rv])},t.prototype[Rv]=function(n,i,o){let s=this[A2];n?s(n):s(null,e?i:o)},t.prototype._nextv=function(n,i,o){this[A2]=o,this[ky].nextv(n,i,this[Ry])},t.prototype._all=function(n,i){this[A2]=i,this[ky].all(n,this[Ry])},t.prototype[Ry]=function(n,i){let o=this[A2];n?o(n):o(null,i.map(r))},t.prototype._seek=function(n,i){this[ky].seek(n,i)},t.prototype._close=function(n){this[ky].close(n)}}h9.DefaultKeyIterator=T2;h9.DefaultValueIterator=nS});var aF=H(dS=>{"use strict";h();var{AbstractIterator:dbe,AbstractKeyIterator:ube,AbstractValueIterator:lbe}=op(),p9=Ud(),_a=Symbol("nut"),aS=Symbol("undefer"),cS=Symbol("factory"),iS=class extends dbe{constructor(e,r){super(e,r),this[_a]=null,this[cS]=()=>e.iterator(r),this.db.defer(()=>this[aS]())}},oS=class extends ube{constructor(e,r){super(e,r),this[_a]=null,this[cS]=()=>e.keys(r),this.db.defer(()=>this[aS]())}},sS=class extends lbe{constructor(e,r){super(e,r),this[_a]=null,this[cS]=()=>e.values(r),this.db.defer(()=>this[aS]())}};for(let t of[iS,oS,sS])t.prototype[aS]=function(){this.db.status==="open"&&(this[_a]=this[cS]())},t.prototype._next=function(e){this[_a]!==null?this[_a].next(e):this.db.status==="opening"?this.db.defer(()=>this._next(e)):this.nextTick(e,new p9("Iterator is not open: cannot call next() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"}))},t.prototype._nextv=function(e,r,n){this[_a]!==null?this[_a].nextv(e,r,n):this.db.status==="opening"?this.db.defer(()=>this._nextv(e,r,n)):this.nextTick(n,new p9("Iterator is not open: cannot call nextv() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"}))},t.prototype._all=function(e,r){this[_a]!==null?this[_a].all(r):this.db.status==="opening"?this.db.defer(()=>this._all(e,r)):this.nextTick(r,new p9("Iterator is not open: cannot call all() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"}))},t.prototype._seek=function(e,r){this[_a]!==null?this[_a]._seek(e,r):this.db.status==="opening"&&this.db.defer(()=>this._seek(e,r))},t.prototype._close=function(e){this[_a]!==null?this[_a].close(e):this.db.status==="opening"?this.db.defer(()=>this._close(e)):this.nextTick(e)};dS.DeferredIterator=iS;dS.DeferredKeyIterator=oS;dS.DeferredValueIterator=sS});var y9=H(dF=>{"use strict";h();var{fromCallback:cF}=_2(),uS=Ud(),{getCallback:fbe,getOptions:hbe}=X3(),lS=Symbol("promise"),qc=Symbol("status"),Bv=Symbol("operations"),I2=Symbol("finishClose"),Mv=Symbol("closeCallbacks"),m9=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[Bv]=[],this[Mv]=[],this[qc]="open",this[I2]=this[I2].bind(this),this.db=e,this.db.attachResource(this),this.nextTick=e.nextTick}get length(){return this[Bv].length}put(e,r,n){if(this[qc]!=="open")throw new uS("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[Bv].push({...s,type:"put",key:e,value:r}),this}_put(e,r,n){}del(e,r){if(this[qc]!=="open")throw new uS("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[Bv].push({...o,type:"del",key:e}),this}_del(e,r){}clear(){if(this[qc]!=="open")throw new uS("Batch is not open: cannot call clear() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"});return this._clear(),this[Bv]=[],this}_clear(){}write(e,r){return r=fbe(e,r),r=cF(r,lS),e=hbe(e),this[qc]!=="open"?this.nextTick(r,new uS("Batch is not open: cannot call write() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"})):this.length===0?this.close(r):(this[qc]="writing",this._write(e,n=>{this[qc]="closing",this[Mv].push(()=>r(n)),n||this.db.emit("batch",this[Bv]),this._close(this[I2])})),r[lS]}_write(e,r){}close(e){return e=cF(e,lS),this[qc]==="closing"?this[Mv].push(e):this[qc]==="closed"?this.nextTick(e):(this[Mv].push(e),this[qc]!=="writing"&&(this[qc]="closing",this._close(this[I2]))),e[lS]}_close(e){this.nextTick(e)}[I2](){this[qc]="closed",this.db.detachResource(this);let e=this[Mv];this[Mv]=[];for(let r of e)r()}};dF.AbstractChainedBatch=m9});var lF=H(uF=>{"use strict";h();var{AbstractChainedBatch:pbe}=y9(),mbe=Ud(),Dv=Symbol("encoded"),g9=class extends pbe{constructor(e){super(e),this[Dv]=[]}_put(e,r,n){this[Dv].push({...n,type:"put",key:e,value:r})}_del(e,r){this[Dv].push({...r,type:"del",key:e})}_clear(){this[Dv]=[]}_write(e,r){this.db.status==="opening"?this.db.defer(()=>this._write(e,r)):this.db.status==="open"?this[Dv].length===0?this.nextTick(r):this.db._batch(this[Dv],e,r):this.nextTick(r,new mbe("Batch is not open: cannot call write() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"}))}};uF.DefaultChainedBatch=g9});var pF=H((oQe,hF)=>{"use strict";h();var fF=Ud(),ybe=Object.prototype.hasOwnProperty,gbe=new Set(["lt","lte","gt","gte"]);hF.exports=function(t,e){let r={};for(let n in t)if(ybe.call(t,n)&&!(n==="keyEncoding"||n==="valueEncoding")){if(n==="start"||n==="end")throw new fF(`The legacy range option '${n}' has been removed`,{code:"LEVEL_LEGACY"});if(n==="encoding")throw new fF("The levelup-style 'encoding' alias has been removed, use 'valueEncoding' instead",{code:"LEVEL_LEGACY"});gbe.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 v9=H((aQe,yF)=>{h();var mF;yF.exports=typeof queueMicrotask=="function"?queueMicrotask.bind(typeof window<"u"?window:globalThis):t=>(mF||(mF=Promise.resolve())).then(t).catch(e=>setTimeout(()=>{throw e},0))});var bF=H((dQe,vF)=>{"use strict";h();var gF=v9();vF.exports=function(t,...e){e.length===0?gF(t):gF(()=>t(...e))}});var wF=H(fS=>{"use strict";h();var{AbstractIterator:vbe,AbstractKeyIterator:bbe,AbstractValueIterator:wbe}=op(),Ov=Symbol("unfix"),qd=Symbol("iterator"),By=Symbol("handleOne"),sp=Symbol("handleMany"),pf=Symbol("callback"),P2=class extends vbe{constructor(e,r,n,i){super(e,r),this[qd]=n,this[Ov]=i,this[By]=this[By].bind(this),this[sp]=this[sp].bind(this),this[pf]=null}[By](e,r,n){let i=this[pf];if(e)return i(e);r!==void 0&&(r=this[Ov](r)),i(e,r,n)}[sp](e,r){let n=this[pf];if(e)return n(e);for(let i of r){let o=i[0];o!==void 0&&(i[0]=this[Ov](o))}n(e,r)}},k2=class extends bbe{constructor(e,r,n,i){super(e,r),this[qd]=n,this[Ov]=i,this[By]=this[By].bind(this),this[sp]=this[sp].bind(this),this[pf]=null}[By](e,r){let n=this[pf];if(e)return n(e);r!==void 0&&(r=this[Ov](r)),n(e,r)}[sp](e,r){let n=this[pf];if(e)return n(e);for(let i=0;i<r.length;i++){let o=r[i];o!==void 0&&(r[i]=this[Ov](o))}n(e,r)}},R2=class extends wbe{constructor(e,r,n){super(e,r),this[qd]=n}};for(let t of[P2,k2])t.prototype._next=function(e){this[pf]=e,this[qd].next(this[By])},t.prototype._nextv=function(e,r,n){this[pf]=n,this[qd].nextv(e,r,this[sp])},t.prototype._all=function(e,r){this[pf]=r,this[qd].all(e,this[sp])};for(let t of[R2])t.prototype._next=function(e){this[qd].next(e)},t.prototype._nextv=function(e,r,n){this[qd].nextv(e,r,n)},t.prototype._all=function(e,r){this[qd].all(e,r)};for(let t of[P2,k2,R2])t.prototype._seek=function(e,r){this[qd].seek(e,r)},t.prototype._close=function(e){this[qd].close(e)};fS.AbstractSublevelIterator=P2;fS.AbstractSublevelKeyIterator=k2;fS.AbstractSublevelValueIterator=R2});var SF=H((hQe,EF)=>{"use strict";h();var b9=Ud(),{Buffer:x9}=$n()||{},{AbstractSublevelIterator:_be,AbstractSublevelKeyIterator:xbe,AbstractSublevelValueIterator:Ebe}=wF(),mf=Symbol("prefix"),_F=Symbol("upperBound"),B2=Symbol("prefixRange"),Za=Symbol("parent"),w9=Symbol("unfix"),xF=new TextEncoder,Sbe={separator:"!"};EF.exports=function({AbstractLevel:t}){class e extends t{static defaults(n){if(typeof n=="string")throw new b9("The subleveldown string shorthand for { separator } has been removed",{code:"LEVEL_LEGACY"});if(n&&n.open)throw new b9("The subleveldown open option has been removed",{code:"LEVEL_LEGACY"});return n==null?Sbe:n.separator?n:{...n,separator:"!"}}constructor(n,i,o){let{separator:s,manifest:a,...d}=e.defaults(o);i=Tbe(i,s);let u=s.charCodeAt(0)+1,c=n[Za]||n;if(!xF.encode(i).every(p=>p>u&&p<127))throw new b9(`Prefix must use bytes > ${u} < 127`,{code:"LEVEL_INVALID_PREFIX"});super(Abe(c,a),d);let l=(n.prefix||"")+s+i+s,m=l.slice(0,-1)+String.fromCharCode(u);this[Za]=c,this[mf]=new hS(l),this[_F]=new hS(m),this[w9]=new E9,this.nextTick=c.nextTick}prefixKey(n,i){if(i==="utf8")return this[mf].utf8+n;if(n.byteLength===0)return this[mf][i];if(i==="view"){let o=this[mf].view,s=new Uint8Array(o.byteLength+n.byteLength);return s.set(o,0),s.set(n,o.byteLength),s}else{let o=this[mf].buffer;return x9.concat([o,n],o.byteLength+n.byteLength)}}[B2](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[mf][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[_F][i]}get prefix(){return this[mf].utf8}get db(){return this[Za]}_open(n,i){this[Za].open({passive:!0},i)}_put(n,i,o,s){this[Za].put(n,i,o,s)}_get(n,i,o){this[Za].get(n,i,o)}_getMany(n,i,o){this[Za].getMany(n,i,o)}_del(n,i,o){this[Za].del(n,i,o)}_batch(n,i,o){this[Za].batch(n,i,o)}_clear(n,i){this[B2](n,n.keyEncoding),this[Za].clear(n,i)}_iterator(n){this[B2](n,n.keyEncoding);let i=this[Za].iterator(n),o=this[w9].get(this[mf].utf8.length,n.keyEncoding);return new _be(this,n,i,o)}_keys(n){this[B2](n,n.keyEncoding);let i=this[Za].keys(n),o=this[w9].get(this[mf].utf8.length,n.keyEncoding);return new xbe(this,n,i,o)}_values(n){this[B2](n,n.keyEncoding);let i=this[Za].values(n);return new Ebe(this,n,i)}}return{AbstractSublevel:e}};var Abe=function(t,e){return{...t.supports,createIfMissing:!1,errorIfExists:!1,events:{},additionalMethods:{},...e,encodings:{utf8:_9(t,"utf8"),buffer:_9(t,"buffer"),view:_9(t,"view")}}},_9=function(t,e){return t.supports.encodings[e]?t.keyEncoding(e).name===e:!1},hS=class{constructor(e){this.utf8=e,this.view=xF.encode(e),this.buffer=x9?x9.from(this.view.buffer,0,this.view.byteLength):{}}},E9=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}},Tbe=function(t,e){let r=0,n=t.length;for(;r<n&&t[r]===e;)r++;for(;n>r&&t[n-1]===e;)n--;return t.slice(r,n)}});var P9=H(I9=>{"use strict";h();var{supports:Ibe}=vK(),{Transcoder:Pbe}=zK(),{EventEmitter:kbe}=Ja(),{fromCallback:ap}=_2(),Ld=Ud(),{AbstractIterator:My}=op(),{DefaultKeyIterator:Rbe,DefaultValueIterator:Bbe}=sF(),{DeferredIterator:Mbe,DeferredKeyIterator:Dbe,DeferredValueIterator:Obe}=aF(),{DefaultChainedBatch:AF}=lF(),{getCallback:Dy,getOptions:cp}=X3(),pS=pF(),cr=Symbol("promise"),yf=Symbol("landed"),Oy=Symbol("resources"),S9=Symbol("closeResources"),M2=Symbol("operations"),D2=Symbol("undefer"),mS=Symbol("deferOpen"),TF=Symbol("options"),Ir=Symbol("status"),Cy=Symbol("defaultOptions"),Cv=Symbol("transcoder"),yS=Symbol("keyEncoding"),A9=Symbol("valueEncoding"),Cbe=()=>{},O2=class extends kbe{constructor(e,r){if(super(),typeof e!="object"||e===null)throw new TypeError("The first argument 'manifest' must be an object");r=cp(r);let{keyEncoding:n,valueEncoding:i,passive:o,...s}=r;this[Oy]=new Set,this[M2]=[],this[mS]=!0,this[TF]=s,this[Ir]="opening",this.supports=Ibe(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[Cv]=new Pbe($be(this)),this[yS]=this[Cv].encoding(n||"utf8"),this[A9]=this[Cv].encoding(i||"utf8");for(let a of this[Cv].encodings())this.supports.encodings[a.commonName]||(this.supports.encodings[a.commonName]=!0);this[Cy]={empty:Object.freeze({}),entry:Object.freeze({keyEncoding:this[yS].commonName,valueEncoding:this[A9].commonName}),key:Object.freeze({keyEncoding:this[yS].commonName})},this.nextTick(()=>{this[mS]&&this.open({passive:!1},Cbe)})}get status(){return this[Ir]}keyEncoding(e){return this[Cv].encoding(e??this[yS])}valueEncoding(e){return this[Cv].encoding(e??this[A9])}open(e,r){r=Dy(e,r),r=ap(r,cr),e={...this[TF],...cp(e)},e.createIfMissing=e.createIfMissing!==!1,e.errorIfExists=!!e.errorIfExists;let n=i=>{this[Ir]==="closing"||this[Ir]==="opening"?this.once(yf,i?()=>n(i):n):this[Ir]!=="open"?r(new Ld("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN",cause:i})):r()};return e.passive?this[Ir]==="opening"?this.once(yf,n):this.nextTick(n):this[Ir]==="closed"||this[mS]?(this[mS]=!1,this[Ir]="opening",this.emit("opening"),this._open(e,i=>{if(i){this[Ir]="closed",this[S9](()=>{this.emit(yf),n(i)}),this[D2]();return}this[Ir]="open",this[D2](),this.emit(yf),this[Ir]==="open"&&this.emit("open"),this[Ir]==="open"&&this.emit("ready"),n()})):this[Ir]==="open"?this.nextTick(n):this.once(yf,()=>this.open(e,r)),r[cr]}_open(e,r){this.nextTick(r)}close(e){e=ap(e,cr);let r=n=>{this[Ir]==="opening"||this[Ir]==="closing"?this.once(yf,n?r(n):r):this[Ir]!=="closed"?e(new Ld("Database is not closed",{code:"LEVEL_DATABASE_NOT_CLOSED",cause:n})):e()};if(this[Ir]==="open"){this[Ir]="closing",this.emit("closing");let n=i=>{this[Ir]="open",this[D2](),this.emit(yf),r(i)};this[S9](()=>{this._close(i=>{if(i)return n(i);this[Ir]="closed",this[D2](),this.emit(yf),this[Ir]==="closed"&&this.emit("closed"),r()})})}else this[Ir]==="closed"?this.nextTick(r):this.once(yf,()=>this.close(e));return e[cr]}[S9](e){if(this[Oy].size===0)return this.nextTick(e);let r=this[Oy].size,n=!0,i=()=>{--r===0&&(n?this.nextTick(e):e())};for(let o of this[Oy])o.close(i);n=!1,this[Oy].clear()}_close(e){this.nextTick(e)}get(e,r,n){if(n=Dy(r,n),n=ap(n,cr),r=cp(r,this[Cy].entry),this[Ir]==="opening")return this.defer(()=>this.get(e,r,n)),n[cr];if($v(this,n))return n[cr];let i=this._checkKey(e);if(i)return this.nextTick(n,i),n[cr];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 Ld("Could not decode value",{code:"LEVEL_DECODE_ERROR",cause:l}))}n(null,c)}),n[cr]}_get(e,r,n){this.nextTick(n,new Error("NotFound"))}getMany(e,r,n){if(n=Dy(r,n),n=ap(n,cr),r=cp(r,this[Cy].entry),this[Ir]==="opening")return this.defer(()=>this.getMany(e,r,n)),n[cr];if($v(this,n))return n[cr];if(!Array.isArray(e))return this.nextTick(n,new TypeError("The first argument 'keys' must be an array")),n[cr];if(e.length===0)return this.nextTick(n,null,[]),n[cr];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<e.length;u++){let c=e[u],l=this._checkKey(c);if(l)return this.nextTick(n,l),n[cr];d[u]=this.prefixKey(i.encode(c),s)}return this._getMany(d,r,(u,c)=>{if(u)return n(u);try{for(let l=0;l<c.length;l++)c[l]!==void 0&&(c[l]=o.decode(c[l]))}catch(l){return n(new Ld(`Could not decode one or more of ${c.length} value(s)`,{code:"LEVEL_DECODE_ERROR",cause:l}))}n(null,c)}),n[cr]}_getMany(e,r,n){this.nextTick(n,null,new Array(e.length).fill(void 0))}put(e,r,n,i){if(i=Dy(n,i),i=ap(i,cr),n=cp(n,this[Cy].entry),this[Ir]==="opening")return this.defer(()=>this.put(e,r,n,i)),i[cr];if($v(this,i))return i[cr];let o=this._checkKey(e)||this._checkValue(r);if(o)return this.nextTick(i,o),i[cr];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[cr]}_put(e,r,n,i){this.nextTick(i)}del(e,r,n){if(n=Dy(r,n),n=ap(n,cr),r=cp(r,this[Cy].key),this[Ir]==="opening")return this.defer(()=>this.del(e,r,n)),n[cr];if($v(this,n))return n[cr];let i=this._checkKey(e);if(i)return this.nextTick(n,i),n[cr];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[cr]}_del(e,r,n){this.nextTick(n)}batch(e,r,n){if(!arguments.length){if(this[Ir]==="opening")return new AF(this);if(this[Ir]!=="open")throw new Ld("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"});return this._chainedBatch()}if(typeof e=="function"?n=e:n=Dy(r,n),n=ap(n,cr),r=cp(r,this[Cy].empty),this[Ir]==="opening")return this.defer(()=>this.batch(e,r,n)),n[cr];if($v(this,n))return n[cr];if(!Array.isArray(e))return this.nextTick(n,new TypeError("The first argument 'operations' must be an array")),n[cr];if(e.length===0)return this.nextTick(n),n[cr];let i=new Array(e.length),{keyEncoding:o,valueEncoding:s,...a}=r;for(let d=0;d<e.length;d++){if(typeof e[d]!="object"||e[d]===null)return this.nextTick(n,new TypeError("A batch operation must be an object")),n[cr];let u=Object.assign({},e[d]);if(u.type!=="put"&&u.type!=="del")return this.nextTick(n,new TypeError("A batch operation must have a type property that is 'put' or 'del'")),n[cr];let c=this._checkKey(u.key);if(c)return this.nextTick(n,c),n[cr];let l=u.sublevel!=null?u.sublevel:this,m=l.keyEncoding(u.keyEncoding||o),p=m.format;if(u.key=l.prefixKey(m.encode(u.key),p),u.keyEncoding=p,u.type==="put"){let g=this._checkValue(u.value);if(g)return this.nextTick(n,g),n[cr];let v=l.valueEncoding(u.valueEncoding||s);u.value=v.encode(u.value),u.valueEncoding=v.format}l!==this&&(u.sublevel=null),i[d]=u}return this._batch(i,a,d=>{if(d)return n(d);this.emit("batch",e),n()}),n[cr]}_batch(e,r,n){this.nextTick(n)}sublevel(e,r){return this._sublevel(e,T9.defaults(r))}_sublevel(e,r){return new T9(this,e,r)}prefixKey(e,r){return e}clear(e,r){if(r=Dy(e,r),r=ap(r,cr),e=cp(e,this[Cy].empty),this[Ir]==="opening")return this.defer(()=>this.clear(e,r)),r[cr];if($v(this,r))return r[cr];let n=e,i=this.keyEncoding(e.keyEncoding);return e=pS(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[cr]}_clear(e,r){this.nextTick(r)}iterator(e){let r=this.keyEncoding(e&&e.keyEncoding),n=this.valueEncoding(e&&e.valueEncoding);if(e=pS(e,r),e.keys=e.keys!==!1,e.values=e.values!==!1,e[My.keyEncoding]=r,e[My.valueEncoding]=n,e.keyEncoding=r.format,e.valueEncoding=n.format,this[Ir]==="opening")return new Mbe(this,e);if(this[Ir]!=="open")throw new Ld("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"});return this._iterator(e)}_iterator(e){return new My(this,e)}keys(e){let r=this.keyEncoding(e&&e.keyEncoding),n=this.valueEncoding(e&&e.valueEncoding);if(e=pS(e,r),e[My.keyEncoding]=r,e[My.valueEncoding]=n,e.keyEncoding=r.format,e.valueEncoding=n.format,this[Ir]==="opening")return new Dbe(this,e);if(this[Ir]!=="open")throw new Ld("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"});return this._keys(e)}_keys(e){return new Rbe(this,e)}values(e){let r=this.keyEncoding(e&&e.keyEncoding),n=this.valueEncoding(e&&e.valueEncoding);if(e=pS(e,r),e[My.keyEncoding]=r,e[My.valueEncoding]=n,e.keyEncoding=r.format,e.valueEncoding=n.format,this[Ir]==="opening")return new Obe(this,e);if(this[Ir]!=="open")throw new Ld("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"});return this._values(e)}_values(e){return new Bbe(this,e)}defer(e){if(typeof e!="function")throw new TypeError("The first argument must be a function");this[M2].push(e)}[D2](){if(this[M2].length===0)return;let e=this[M2];this[M2]=[];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[Oy].add(e)}detachResource(e){this[Oy].delete(e)}_chainedBatch(){return new AF(this)}_checkKey(e){if(e==null)return new Ld("Key cannot be null or undefined",{code:"LEVEL_INVALID_KEY"})}_checkValue(e){if(e==null)return new Ld("Value cannot be null or undefined",{code:"LEVEL_INVALID_VALUE"})}};O2.prototype.nextTick=bF();var{AbstractSublevel:T9}=SF()({AbstractLevel:O2});I9.AbstractLevel=O2;I9.AbstractSublevel=T9;var $v=function(t,e){return t[Ir]!=="open"?(t.nextTick(e,new Ld("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"})),!0):!1},$be=function(t){return Object.keys(t.supports.encodings).filter(e=>!!t.supports.encodings[e])}});var k9=H($y=>{"use strict";h();$y.AbstractLevel=P9().AbstractLevel;$y.AbstractSublevel=P9().AbstractSublevel;$y.AbstractIterator=op().AbstractIterator;$y.AbstractKeyIterator=op().AbstractKeyIterator;$y.AbstractValueIterator=op().AbstractValueIterator;$y.AbstractChainedBatch=y9().AbstractChainedBatch});var PF=H((bQe,IF)=>{h();IF.exports=jbe;var Nbe=v9();function jbe(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?Nbe(p):p()}function l(m,p,g){if(n[m]=g,p&&(a=!0),--o===0||p)c(p);else if(!a&&u<i){let v;s?(v=s[u],u+=1,t[v](function(E,A){l(v,E,A)})):(v=u,u+=1,t[v](function(E,A){l(v,E,A)}))}}u=e,o?s?s.some(function(m,p){return t[m](function(g,v){l(m,g,v)}),p===e-1}):t.some(function(m,p){return m(function(g,v){l(p,g,v)}),p===e-1}):c(null),d=!1}});var R9=H((_Qe,kF)=>{"use strict";h();kF.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 B9=H((EQe,RF)=>{"use strict";h();var Ube=new TextEncoder;RF.exports=function(t){return t instanceof Uint8Array?t:t instanceof ArrayBuffer?new Uint8Array(t):Ube.encode(t)}});var CF=H(OF=>{"use strict";h();var{AbstractIterator:qbe}=k9(),BF=R9(),gS=B9(),Zu=Symbol("cache"),gf=Symbol("finished"),Xa=Symbol("options"),vf=Symbol("currentOptions"),Ny=Symbol("position"),M9=Symbol("location"),Nv=Symbol("first"),MF={},D9=class extends qbe{constructor(e,r,n){super(e,n),this[Zu]=[],this[gf]=this.limit===0,this[Xa]=n,this[vf]={...n},this[Ny]=void 0,this[M9]=r,this[Nv]=!0}_nextv(e,r,n){if(this[Nv]=!1,this[gf])return this.nextTick(n,null,[]);if(this[Zu].length>0)return e=Math.min(e,this[Zu].length),this.nextTick(n,null,this[Zu].splice(0,e));this[Ny]!==void 0&&(this[Xa].reverse?(this[vf].lt=this[Ny],this[vf].lte=void 0):(this[vf].gt=this[Ny],this[vf].gte=void 0));let i;try{i=BF(this[vf])}catch{return this[gf]=!0,this.nextTick(n,null,[])}let o=this.db.db.transaction([this[M9]],"readonly"),s=o.objectStore(this[M9]),a=[];if(this[Xa].reverse){let d=!this[Xa].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[Ny]=l,a.push([this[Xa].keys&&l!==void 0?gS(l):void 0,this[Xa].values&&m!==void 0?gS(m):void 0]),a.length<e?c.continue():DF(o)}else this[gf]=!0}}else{let d,u,c=()=>{if(d===void 0||u===void 0)return;let l=Math.max(d.length,u.length);l===0||e===1/0?this[gf]=!0:this[Ny]=d[l-1],a.length=l;for(let m=0;m<l;m++){let p=d[m],g=u[m];a[m]=[this[Xa].keys&&p!==void 0?gS(p):void 0,this[Xa].values&&g!==void 0?gS(g):void 0]}DF(o)};this[Xa].keys||e<1/0?s.getAllKeys(i,e<1/0?e:void 0).onsuccess=l=>{d=l.target.result,c()}:(d=[],this.nextTick(c)),this[Xa].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[Zu].length>0){let[r,n]=this[Zu].shift();this.nextTick(e,null,r,n)}else if(this[gf])this.nextTick(e);else{let r=Math.min(100,this.limit-this.count);this[Nv]&&(this[Nv]=!1,r=1),this._nextv(r,MF,(n,i)=>{if(n)return e(n);this[Zu]=i,this._next(e)})}}_all(e,r){this[Nv]=!1;let n=this[Zu].splice(0,this[Zu].length),i=this.limit-this.count-n.length;if(i<=0)return this.nextTick(r,null,n);this._nextv(i,MF,(o,s)=>{if(o)return r(o);n.length>0&&(s=n.concat(s)),r(null,s)})}_seek(e,r){this[Nv]=!0,this[Zu]=[],this[gf]=!1,this[Ny]=void 0,this[vf]={...this[Xa]};let n;try{n=BF(this[Xa])}catch{this[gf]=!0;return}n!==null&&!n.includes(e)?this[gf]=!0:this[Xa].reverse?this[vf].lte=e:this[vf].gte=e}};OF.Iterator=D9;function DF(t){typeof t.commit=="function"&&t.commit()}});var NF=H((IQe,$F)=>{"use strict";h();$F.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<i.limit)&&m.continue()})}}});var $9=H(KF=>{"use strict";h();var{AbstractLevel:Lbe}=k9(),jF=Ud(),Kbe=PF(),{fromCallback:Fbe}=_2(),{Iterator:zbe}=CF(),UF=B9(),Vbe=NF(),Hbe=R9(),LF="level-js-",C2=Symbol("idb"),O9=Symbol("namePrefix"),bf=Symbol("location"),C9=Symbol("version"),jy=Symbol("store"),$2=Symbol("onComplete"),qF=Symbol("promise"),vS=class extends Lbe{constructor(e,r,n){if(typeof r=="function"||typeof n=="function")throw new jF("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[bf]=e,this[O9]=i??LF,this[C9]=parseInt(o||1,10),this[C2]=null}get location(){return this[bf]}get namePrefix(){return this[O9]}get version(){return this[C9]}get db(){return this[C2]}get type(){return"browser-level"}_open(e,r){let n=indexedDB.open(this[O9]+this[bf],this[C9]);n.onerror=function(){r(n.error||new Error("unknown error"))},n.onsuccess=()=>{this[C2]=n.result,r()},n.onupgradeneeded=i=>{let o=i.target.result;o.objectStoreNames.contains(this[bf])||o.createObjectStore(this[bf])}}[jy](e){return this[C2].transaction([this[bf]],e).objectStore(this[bf])}[$2](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[jy]("readonly"),o;try{o=i.get(e)}catch(s){return this.nextTick(n,s)}this[$2](o,function(s,a){if(s)return n(s);if(a===void 0)return n(new jF("Entry not found",{code:"LEVEL_NOT_FOUND"}));n(null,UF(a))})}_getMany(e,r,n){let i=this[jy]("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:UF(u))},d.onerror=u=>{u.stopPropagation(),a(d.error)}});Kbe(o,16,n)}_del(e,r,n){let i=this[jy]("readwrite"),o;try{o=i.delete(e)}catch(s){return this.nextTick(n,s)}this[$2](o,n)}_put(e,r,n,i){let o=this[jy]("readwrite"),s;try{s=o.put(r,e)}catch(a){return this.nextTick(i,a)}this[$2](s,i)}_iterator(e){return new zbe(this,this[bf],e)}_batch(e,r,n){let i=this[jy]("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<e.length?l.onsuccess=d:typeof o.commit=="function"&&o.commit()}d()}_clear(e,r){let n,i;try{n=Hbe(e)}catch{return this.nextTick(r)}if(e.limit>=0)return Vbe(this,this[bf],n,e,r);try{let o=this[jy]("readwrite");i=n?o.delete(n):o.clear()}catch(o){return this.nextTick(r,o)}this[$2](i,r)}_close(e){this[C2].close(),this.nextTick(e)}};vS.destroy=function(t,e,r){typeof e=="function"&&(r=e,e=LF),r=Fbe(r,qF);let n=indexedDB.deleteDatabase(e+t);return n.onsuccess=function(){r()},n.onerror=function(i){r(i)},r[qF]};KF.BrowserLevel=vS});var N2=H(FF=>{h();FF.Level=$9().BrowserLevel});var Oi=H((jQe,VF)=>{"use strict";h();VF.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 Xu=H((qQe,j9)=>{"use strict";h();var Gbe=$n(),Jbe=Object.getPrototypeOf(async function(){}).constructor,HF=globalThis.Blob||Gbe.Blob,Ybe=typeof HF<"u"?function(e){return e instanceof HF}:function(e){return!1},N9=class extends Error{constructor(e){if(!Array.isArray(e))throw new TypeError(`Expected input to be an Array, got ${typeof e}`);let r="";for(let n=0;n<e.length;n++)r+=` ${e[n].stack}
`;super(r),this.name="AggregateError",this.errors=e}};j9.exports={AggregateError:N9,kEmptyObject:Object.freeze({}),once(t){let e=!1;return function(...r){e||(e=!0,t.apply(this,r))}},createDeferredPromise:function(){let t,e;return{promise:new Promise((n,i)=>{t=n,e=i}),resolve:t,reject:e}},promisify(t){return new Promise((e,r)=>{t((n,...i)=>n?r(n):e(...i))})},debuglog(){return function(){}},format(t,...e){return t.replace(/%([sdifj])/g,function(...[r,n]){let i=e.shift();return n==="f"?i.toFixed(6):n==="j"?JSON.stringify(i):n==="s"&&typeof i=="object"?`${i.constructor!==Object?i.constructor.name:""} {}`.trim():i.toString()})},inspect(t){switch(typeof t){case"string":if(t.includes("'"))if(t.includes('"')){if(!t.includes("`")&&!t.includes("${"))return`\`${t}\``}else return`"${t}"`;return`'${t}'`;case"number":return isNaN(t)?"NaN":Object.is(t,-0)?String(t):t;case"bigint":return`${String(t)}n`;case"boolean":case"undefined":return String(t);case"object":return"{}"}},types:{isAsyncFunction(t){return t instanceof Jbe},isArrayBufferView(t){return ArrayBuffer.isView(t)}},isBlob:Ybe};j9.exports.promisify.custom=Symbol.for("nodejs.util.promisify.custom")});var wf=H((KQe,wS)=>{"use strict";h();var{AbortController:WF,AbortSignal:Zbe}=typeof self<"u"?self:typeof window<"u"?window:void 0;wS.exports=WF;wS.exports.AbortSignal=Zbe;wS.exports.default=WF});var Vs=H((zQe,YF)=>{"use strict";h();var{format:Xbe,inspect:_S,AggregateError:Qbe}=Xu(),ewe=globalThis.AggregateError||Qbe,twe=Symbol("kIsNodeError"),rwe=["string","function","number","object","Function","Object","boolean","bigint","symbol"],nwe=/^([A-Z][a-z0-9]*)+$/,iwe="__node_internal_",xS={};function qy(t,e){if(!t)throw new xS.ERR_INTERNAL_ASSERTION(e)}function GF(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 owe(t,e,r){if(typeof e=="function")return qy(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 qy(n===r.length,`Code: ${t}; The provided arguments length (${r.length}) does not match the required ones (${n}).`),r.length===0?e:Xbe(e,...r)}function Oo(t,e,r){r||(r=Error);class n extends r{constructor(...o){super(owe(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[twe]=!0,xS[t]=n}function JF(t){let e=iwe+t.name;return Object.defineProperty(t,"name",{value:e}),t}function swe(t,e){if(t&&e&&t!==e){if(Array.isArray(e.errors))return e.errors.push(t),e;let r=new ewe([e,t],e.message);return r.code=e.code,r}return t||e}var U9=class extends Error{constructor(e="The operation was aborted",r=void 0){if(r!==void 0&&typeof r!="object")throw new xS.ERR_INVALID_ARG_TYPE("options","Object",r);super(e,r),this.code="ABORT_ERR",this.name="AbortError"}};Oo("ERR_ASSERTION","%s",Error);Oo("ERR_INVALID_ARG_TYPE",(t,e,r)=>{qy(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)qy(typeof d=="string","All expected entries have to be of type string"),rwe.includes(d)?i.push(d.toLowerCase()):nwe.test(d)?o.push(d):(qy(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=_S(r,{depth:-1});n+=`. Received ${d}`}}else{let d=_S(r,{colors:!1});d.length>25&&(d=`${d.slice(0,25)}...`),n+=`. Received type ${typeof r} (${d})`}return n},TypeError);Oo("ERR_INVALID_ARG_VALUE",(t,e,r="is invalid")=>{let n=_S(e);return n.length>128&&(n=n.slice(0,128)+"..."),`The ${t.includes(".")?"property":"argument"} '${t}' ${r}. Received ${n}`},TypeError);Oo("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);Oo("ERR_MISSING_ARGS",(...t)=>{qy(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);Oo("ERR_OUT_OF_RANGE",(t,e,r)=>{qy(e,'Missing "range" argument');let n;return Number.isInteger(r)&&Math.abs(r)>2**32?n=GF(String(r)):typeof r=="bigint"?(n=String(r),(r>2n**32n||r<-(2n**32n))&&(n=GF(n)),n+="n"):n=_S(r),`The value of "${t}" is out of range. It must be ${e}. Received ${n}`},RangeError);Oo("ERR_MULTIPLE_CALLBACK","Callback called multiple times",Error);Oo("ERR_METHOD_NOT_IMPLEMENTED","The %s method is not implemented",Error);Oo("ERR_STREAM_ALREADY_FINISHED","Cannot call %s after a stream was finished",Error);Oo("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable",Error);Oo("ERR_STREAM_DESTROYED","Cannot call %s after a stream was destroyed",Error);Oo("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError);Oo("ERR_STREAM_PREMATURE_CLOSE","Premature close",Error);Oo("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF",Error);Oo("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event",Error);Oo("ERR_STREAM_WRITE_AFTER_END","write after end",Error);Oo("ERR_UNKNOWN_ENCODING","Unknown encoding: %s",TypeError);YF.exports={AbortError:U9,aggregateTwoErrors:JF(swe),hideStackFrames:JF,codes:xS}});var L2=H((HQe,oz)=>{"use strict";h();var{ArrayIsArray:L9,ArrayPrototypeIncludes:ez,ArrayPrototypeJoin:tz,ArrayPrototypeMap:awe,NumberIsInteger:K9,NumberIsNaN:cwe,NumberMAX_SAFE_INTEGER:dwe,NumberMIN_SAFE_INTEGER:uwe,NumberParseInt:lwe,ObjectPrototypeHasOwnProperty:fwe,RegExpPrototypeExec:rz,String:hwe,StringPrototypeToUpperCase:pwe,StringPrototypeTrim:mwe}=Oi(),{hideStackFrames:Kc,codes:{ERR_SOCKET_BAD_PORT:ywe,ERR_INVALID_ARG_TYPE:Hs,ERR_INVALID_ARG_VALUE:jv,ERR_OUT_OF_RANGE:Ly,ERR_UNKNOWN_SIGNAL:ZF}}=Vs(),{normalizeEncoding:gwe}=Xu(),{isAsyncFunction:vwe,isArrayBufferView:bwe}=Xu().types,XF={};function wwe(t){return t===(t|0)}function _we(t){return t===t>>>0}var xwe=/^[0-7]+$/,Ewe="must be a 32-bit unsigned integer or an octal string";function Swe(t,e,r){if(typeof t>"u"&&(t=r),typeof t=="string"){if(rz(xwe,t)===null)throw new jv(e,t,Ewe);t=lwe(t,8)}return nz(t,e),t}var Awe=Kc((t,e,r=uwe,n=dwe)=>{if(typeof t!="number")throw new Hs(e,"number",t);if(!K9(t))throw new Ly(e,"an integer",t);if(t<r||t>n)throw new Ly(e,`>= ${r} && <= ${n}`,t)}),Twe=Kc((t,e,r=-2147483648,n=2147483647)=>{if(typeof t!="number")throw new Hs(e,"number",t);if(!K9(t))throw new Ly(e,"an integer",t);if(t<r||t>n)throw new Ly(e,`>= ${r} && <= ${n}`,t)}),nz=Kc((t,e,r=!1)=>{if(typeof t!="number")throw new Hs(e,"number",t);if(!K9(t))throw new Ly(e,"an integer",t);let n=r?1:0,i=4294967295;if(t<n||t>i)throw new Ly(e,`>= ${n} && <= ${i}`,t)});function F9(t,e){if(typeof t!="string")throw new Hs(e,"string",t)}function Iwe(t,e,r=void 0,n){if(typeof t!="number")throw new Hs(e,"number",t);if(r!=null&&t<r||n!=null&&t>n||(r!=null||n!=null)&&cwe(t))throw new Ly(e,`${r!=null?`>= ${r}`:""}${r!=null&&n!=null?" && ":""}${n!=null?`<= ${n}`:""}`,t)}var Pwe=Kc((t,e,r)=>{if(!ez(r,t)){let i="must be one of: "+tz(awe(r,o=>typeof o=="string"?`'${o}'`:hwe(o)),", ");throw new jv(e,t,i)}});function iz(t,e){if(typeof t!="boolean")throw new Hs(e,"boolean",t)}function q9(t,e,r){return t==null||!fwe(t,e)?r:t[e]}var kwe=Kc((t,e,r=null)=>{let n=q9(r,"allowArray",!1),i=q9(r,"allowFunction",!1);if(!q9(r,"nullable",!1)&&t===null||!n&&L9(t)||typeof t!="object"&&(!i||typeof t!="function"))throw new Hs(e,"Object",t)}),Rwe=Kc((t,e)=>{if(t!=null&&typeof t!="object"&&typeof t!="function")throw new Hs(e,"a dictionary",t)}),z9=Kc((t,e,r=0)=>{if(!L9(t))throw new Hs(e,"Array",t);if(t.length<r){let n=`must be longer than ${r}`;throw new jv(e,t,n)}});function Bwe(t,e){z9(t,e);for(let r=0;r<t.length;r++)F9(t[r],`${e}[${r}]`)}function Mwe(t,e){z9(t,e);for(let r=0;r<t.length;r++)iz(t[r],`${e}[${r}]`)}function Dwe(t,e="signal"){if(F9(t,e),XF[t]===void 0)throw XF[pwe(t)]!==void 0?new ZF(t+" (signals must use all capital letters)"):new ZF(t)}var Owe=Kc((t,e="buffer")=>{if(!bwe(t))throw new Hs(e,["Buffer","TypedArray","DataView"],t)});function Cwe(t,e){let r=gwe(e),n=t.length;if(r==="hex"&&n%2!==0)throw new jv("encoding",e,`is invalid for data of length ${n}`)}function $we(t,e="Port",r=!0){if(typeof t!="number"&&typeof t!="string"||typeof t=="string"&&mwe(t).length===0||+t!==+t>>>0||t>65535||t===0&&!r)throw new ywe(e,t,r);return t|0}var Nwe=Kc((t,e)=>{if(t!==void 0&&(t===null||typeof t!="object"||!("aborted"in t)))throw new Hs(e,"AbortSignal",t)}),jwe=Kc((t,e)=>{if(typeof t!="function")throw new Hs(e,"Function",t)}),Uwe=Kc((t,e)=>{if(typeof t!="function"||vwe(t))throw new Hs(e,"Function",t)}),qwe=Kc((t,e)=>{if(t!==void 0)throw new Hs(e,"undefined",t)});function Lwe(t,e,r){if(!ez(r,t))throw new Hs(e,`('${tz(r,"|")}')`,t)}var Kwe=/^(?:<[^>]*>)(?:\s*;\s*[^;"\s]+(?:=(")?[^;"\s]*\1)?)*$/;function QF(t,e){if(typeof t>"u"||!rz(Kwe,t))throw new jv(e,t,'must be an array or string of format "</styles.css>; rel=preload; as=style"')}function Fwe(t){if(typeof t=="string")return QF(t,"hints"),t;if(L9(t)){let e=t.length,r="";if(e===0)return r;for(let n=0;n<e;n++){let i=t[n];QF(i,"hints"),r+=i,n!==e-1&&(r+=", ")}return r}throw new jv("hints",t,'must be an array or string of format "</styles.css>; rel=preload; as=style"')}oz.exports={isInt32:wwe,isUint32:_we,parseFileMode:Swe,validateArray:z9,validateStringArray:Bwe,validateBooleanArray:Mwe,validateBoolean:iz,validateBuffer:Owe,validateDictionary:Rwe,validateEncoding:Cwe,validateFunction:jwe,validateInt32:Twe,validateInteger:Awe,validateNumber:Iwe,validateObject:kwe,validateOneOf:Pwe,validatePlainFunction:Uwe,validatePort:$we,validateSignalName:Dwe,validateString:F9,validateUint32:nz,validateUndefined:qwe,validateUnion:Lwe,validateAbortSignal:Nwe,validateLinkHeaderValue:Fwe}});var el=H((GQe,_z)=>{"use strict";h();var{Symbol:ES,SymbolAsyncIterator:sz,SymbolIterator:az,SymbolFor:cz}=Oi(),dz=ES("kDestroyed"),uz=ES("kIsErrored"),V9=ES("kIsReadable"),lz=ES("kIsDisturbed"),zwe=cz("nodejs.webstream.isClosedPromise"),Vwe=cz("nodejs.webstream.controllerErrorFunction");function SS(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 AS(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 Hwe(t){return!!(t&&typeof t.pipe=="function"&&t._readableState&&typeof t.on=="function"&&typeof t.write=="function")}function Qu(t){return t&&(t._readableState||t._writableState||typeof t.write=="function"&&typeof t.on=="function"||typeof t.pipe=="function"&&typeof t.on=="function")}function fz(t){return!!(t&&!Qu(t)&&typeof t.pipeThrough=="function"&&typeof t.getReader=="function"&&typeof t.cancel=="function")}function hz(t){return!!(t&&!Qu(t)&&typeof t.getWriter=="function"&&typeof t.abort=="function")}function pz(t){return!!(t&&!Qu(t)&&typeof t.readable=="object"&&typeof t.writable=="object")}function Wwe(t){return fz(t)||hz(t)||pz(t)}function Gwe(t,e){return t==null?!1:e===!0?typeof t[sz]=="function":e===!1?typeof t[az]=="function":typeof t[sz]=="function"||typeof t[az]=="function"}function TS(t){if(!Qu(t))return null;let e=t._writableState,r=t._readableState,n=e||r;return!!(t.destroyed||t[dz]||n!=null&&n.destroyed)}function mz(t){if(!AS(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 Jwe(t,e){if(!AS(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 Ywe(t){if(!SS(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 yz(t,e){if(!SS(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 gz(t){return t&&t[V9]!=null?t[V9]:typeof t?.readable!="boolean"?null:TS(t)?!1:SS(t)&&t.readable&&!yz(t)}function vz(t){return typeof t?.writable!="boolean"?null:TS(t)?!1:AS(t)&&t.writable&&!mz(t)}function Zwe(t,e){return Qu(t)?TS(t)?!0:!(e?.readable!==!1&&gz(t)||e?.writable!==!1&&vz(t)):null}function Xwe(t){var e,r;return Qu(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 Qwe(t){var e,r;return Qu(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 e1e(t){if(!Qu(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"&&bz(t)?t._closed:null}function bz(t){return typeof t._closed=="boolean"&&typeof t._defaultKeepAlive=="boolean"&&typeof t._removedConnection=="boolean"&&typeof t._removedContLen=="boolean"}function wz(t){return typeof t._sent100=="boolean"&&bz(t)}function t1e(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 r1e(t){if(!Qu(t))return null;let e=t._writableState,r=t._readableState,n=e||r;return!n&&wz(t)||!!(n&&n.autoDestroy&&n.emitClose&&n.closed===!1)}function n1e(t){var e;return!!(t&&((e=t[lz])!==null&&e!==void 0?e:t.readableDidRead||t.readableAborted))}function i1e(t){var e,r,n,i,o,s,a,d,u,c;return!!(t&&((e=(r=(n=(i=(o=(s=t[uz])!==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))}_z.exports={kDestroyed:dz,isDisturbed:n1e,kIsDisturbed:lz,isErrored:i1e,kIsErrored:uz,isReadable:gz,kIsReadable:V9,kIsClosedPromise:zwe,kControllerErrorFunction:Vwe,isClosed:e1e,isDestroyed:TS,isDuplexNodeStream:Hwe,isFinished:Zwe,isIterable:Gwe,isReadableNodeStream:SS,isReadableStream:fz,isReadableEnded:Ywe,isReadableFinished:yz,isReadableErrored:Qwe,isNodeStream:Qu,isWebStream:Wwe,isWritable:vz,isWritableNodeStream:AS,isWritableStream:hz,isWritableEnded:mz,isWritableFinished:Jwe,isWritableErrored:Xwe,isServerRequest:t1e,isServerResponse:wz,willEmitClose:r1e,isTransformStream:pz}});var _f=H((YQe,Y9)=>{h();var dp=fs(),{AbortError:Rz,codes:o1e}=Vs(),{ERR_INVALID_ARG_TYPE:s1e,ERR_STREAM_PREMATURE_CLOSE:xz}=o1e,{kEmptyObject:W9,once:G9}=Xu(),{validateAbortSignal:a1e,validateFunction:c1e,validateObject:d1e,validateBoolean:u1e}=L2(),{Promise:l1e,PromisePrototypeThen:f1e}=Oi(),{isClosed:h1e,isReadable:Ez,isReadableNodeStream:H9,isReadableStream:p1e,isReadableFinished:Sz,isReadableErrored:Az,isWritable:Tz,isWritableNodeStream:Iz,isWritableStream:m1e,isWritableFinished:Pz,isWritableErrored:kz,isNodeStream:y1e,willEmitClose:g1e,kIsClosedPromise:v1e}=el();function b1e(t){return t.setHeader&&typeof t.abort=="function"}var J9=()=>{};function Bz(t,e,r){var n,i;if(arguments.length===2?(r=e,e=W9):e==null?e=W9:d1e(e,"options"),c1e(r,"callback"),a1e(e.signal,"options.signal"),r=G9(r),p1e(t)||m1e(t))return w1e(t,e,r);if(!y1e(t))throw new s1e("stream",["ReadableStream","WritableStream","Stream"],t);let o=(n=e.readable)!==null&&n!==void 0?n:H9(t),s=(i=e.writable)!==null&&i!==void 0?i:Iz(t),a=t._writableState,d=t._readableState,u=()=>{t.writable||m()},c=g1e(t)&&H9(t)===o&&Iz(t)===s,l=Pz(t,!1),m=()=>{l=!0,t.destroyed&&(c=!1),!(c&&(!t.readable||o))&&(!o||p)&&r.call(t)},p=Sz(t,!1),g=()=>{p=!0,t.destroyed&&(c=!1),!(c&&(!t.writable||s))&&(!s||l)&&r.call(t)},v=N=>{r.call(t,N)},E=h1e(t),A=()=>{E=!0;let N=kz(t)||Az(t);if(N&&typeof N!="boolean")return r.call(t,N);if(o&&!p&&H9(t,!0)&&!Sz(t,!1))return r.call(t,new xz);if(s&&!l&&!Pz(t,!1))return r.call(t,new xz);r.call(t)},P=()=>{E=!0;let N=kz(t)||Az(t);if(N&&typeof N!="boolean")return r.call(t,N);r.call(t)},I=()=>{t.req.on("finish",m)};b1e(t)?(t.on("complete",m),c||t.on("abort",A),t.req?I():t.on("request",I)):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",v),t.on("close",A),E?dp.nextTick(A):a!=null&&a.errorEmitted||d!=null&&d.errorEmitted?c||dp.nextTick(P):(!o&&(!c||Ez(t))&&(l||Tz(t)===!1)||!s&&(!c||Tz(t))&&(p||Ez(t)===!1)||d&&t.req&&t.aborted)&&dp.nextTick(P);let $=()=>{r=J9,t.removeListener("aborted",A),t.removeListener("complete",m),t.removeListener("abort",A),t.removeListener("request",I),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",v),t.removeListener("close",A)};if(e.signal&&!E){let N=()=>{let K=r;$(),K.call(t,new Rz(void 0,{cause:e.signal.reason}))};if(e.signal.aborted)dp.nextTick(N);else{let K=r;r=G9((...F)=>{e.signal.removeEventListener("abort",N),K.apply(t,F)}),e.signal.addEventListener("abort",N)}}return $}function w1e(t,e,r){let n=!1,i=J9;if(e.signal)if(i=()=>{n=!0,r.call(t,new Rz(void 0,{cause:e.signal.reason}))},e.signal.aborted)dp.nextTick(i);else{let s=r;r=G9((...a)=>{e.signal.removeEventListener("abort",i),s.apply(t,a)}),e.signal.addEventListener("abort",i)}let o=(...s)=>{n||dp.nextTick(()=>r.apply(t,s))};return f1e(t[v1e].promise,o,o),J9}function _1e(t,e){var r;let n=!1;return e===null&&(e=W9),(r=e)!==null&&r!==void 0&&r.cleanup&&(u1e(e.cleanup,"cleanup"),n=e.cleanup),new l1e((i,o)=>{let s=Bz(t,e,a=>{n&&s(),a?o(a):i()})})}Y9.exports=Bz;Y9.exports.finished=_1e});var Ky=H((XQe,Uz)=>{"use strict";h();var tl=fs(),{aggregateTwoErrors:x1e,codes:{ERR_MULTIPLE_CALLBACK:E1e},AbortError:S1e}=Vs(),{Symbol:Oz}=Oi(),{kDestroyed:A1e,isDestroyed:T1e,isFinished:I1e,isServerRequest:P1e}=el(),Cz=Oz("kDestroy"),Z9=Oz("kConstruct");function $z(t,e,r){t&&(t.stack,e&&!e.errored&&(e.errored=t),r&&!r.errored&&(r.errored=t))}function k1e(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):($z(t,n,r),n&&(n.destroyed=!0),r&&(r.destroyed=!0),i.constructed?Mz(this,t,e):this.once(Cz,function(o){Mz(this,x1e(o,t),e)}),this)}function Mz(t,e,r){let n=!1;function i(o){if(n)return;n=!0;let s=t._readableState,a=t._writableState;$z(o,a,s),a&&(a.closed=!0),s&&(s.closed=!0),typeof r=="function"&&r(o),o?tl.nextTick(R1e,t,o):tl.nextTick(Nz,t)}try{t._destroy(e||null,i)}catch(o){i(o)}}function R1e(t,e){X9(t,e),Nz(t)}function Nz(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 X9(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 B1e(){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 Q9(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?tl.nextTick(X9,t,e):X9(t,e))}function M1e(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(Z9,e),!(t.listenerCount(Z9)>1)&&tl.nextTick(D1e,t)}function D1e(t){let e=!1;function r(n){if(e){Q9(t,n??new E1e);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(Cz,n):n?Q9(t,n,!0):tl.nextTick(O1e,t)}try{t._construct(n=>{tl.nextTick(r,n)})}catch(n){tl.nextTick(r,n)}}function O1e(t){t.emit(Z9)}function Dz(t){return t?.setHeader&&typeof t.abort=="function"}function jz(t){t.emit("close")}function C1e(t,e){t.emit("error",e),tl.nextTick(jz,t)}function $1e(t,e){!t||T1e(t)||(!e&&!I1e(t)&&(e=new S1e),P1e(t)?(t.socket=null,t.destroy(e)):Dz(t)?t.abort():Dz(t.req)?t.req.abort():typeof t.destroy=="function"?t.destroy(e):typeof t.close=="function"?t.close():e?tl.nextTick(C1e,t,e):tl.nextTick(jz,t),t.destroyed||(t[A1e]=!0))}Uz.exports={construct:M1e,destroyer:$1e,destroy:k1e,undestroy:B1e,errorOrDestroy:Q9}});var kS=H((eet,Lz)=>{"use strict";h();var{ArrayIsArray:N1e,ObjectSetPrototypeOf:qz}=Oi(),{EventEmitter:IS}=Ja();function PS(t){IS.call(this,t)}qz(PS.prototype,IS.prototype);qz(PS,IS);PS.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(),IS.listenerCount(this,"error")===0&&this.emit("error",c)}e7(r,"error",d),e7(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 e7(t,e,r){if(typeof t.prependListener=="function")return t.prependListener(e,r);!t._events||!t._events[e]?t.on(e,r):N1e(t._events[e])?t._events[e].unshift(r):t._events[e]=[r,t._events[e]]}Lz.exports={Stream:PS,prependListener:e7}});var K2=H((ret,RS)=>{"use strict";h();var{AbortError:Kz,codes:j1e}=Vs(),{isNodeStream:Fz,isWebStream:U1e,kControllerErrorFunction:q1e}=el(),L1e=_f(),{ERR_INVALID_ARG_TYPE:zz}=j1e,K1e=(t,e)=>{if(typeof t!="object"||!("aborted"in t))throw new zz(e,"AbortSignal",t)};RS.exports.addAbortSignal=function(e,r){if(K1e(e,"signal"),!Fz(r)&&!U1e(r))throw new zz("stream",["ReadableStream","WritableStream","Stream"],r);return RS.exports.addAbortSignalNoValidate(e,r)};RS.exports.addAbortSignalNoValidate=function(t,e){if(typeof t!="object"||!("aborted"in t))return e;let r=Fz(e)?()=>{e.destroy(new Kz(void 0,{cause:t.reason}))}:()=>{e[q1e](new Kz(void 0,{cause:t.reason}))};return t.aborted?r():(t.addEventListener("abort",r),L1e(e,()=>t.removeEventListener("abort",r))),e}});var Wz=H((oet,Hz)=>{"use strict";h();var{StringPrototypeSlice:Vz,SymbolIterator:F1e,TypedArrayPrototypeSet:BS,Uint8Array:z1e}=Oi(),{Buffer:t7}=$n(),{inspect:V1e}=Xu();Hz.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 t7.alloc(0);let r=t7.allocUnsafe(e>>>0),n=this.head,i=0;for(;n;)BS(r,n.data,i),i+=n.data.length,n=n.next;return r}consume(e,r){let n=this.head.data;if(e<n.length){let i=n.slice(0,e);return this.head.data=n.slice(e),i}return e===n.length?this.shift():r?this._getString(e):this._getBuffer(e)}first(){return this.head.data}*[F1e](){for(let e=this.head;e;e=e.next)yield e.data}_getString(e){let r="",n=this.head,i=0;do{let o=n.data;if(e>o.length)r+=o,e-=o.length;else{e===o.length?(r+=o,++i,n.next?this.head=n.next:this.head=this.tail=null):(r+=Vz(o,0,e),this.head=n,n.data=Vz(o,e));break}++i}while((n=n.next)!==null);return this.length-=i,r}_getBuffer(e){let r=t7.allocUnsafe(e),n=e,i=this.head,o=0;do{let s=i.data;if(e>s.length)BS(r,s,n-e),e-=s.length;else{e===s.length?(BS(r,s,n-e),++o,i.next?this.head=i.next:this.head=this.tail=null):(BS(r,new z1e(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 V1e(this,{...r,depth:0,customInspect:!1})}}});var MS=H((aet,Jz)=>{"use strict";h();var{MathFloor:H1e,NumberIsInteger:W1e}=Oi(),{ERR_INVALID_ARG_VALUE:G1e}=Vs().codes;function J1e(t,e,r){return t.highWaterMark!=null?t.highWaterMark:e?t[r]:null}function Gz(t){return t?16:16*1024}function Y1e(t,e,r,n){let i=J1e(e,n,r);if(i!=null){if(!W1e(i)||i<0){let o=n?`options.${r}`:"options.highWaterMark";throw new G1e(o,i)}return H1e(i)}return Gz(t.objectMode)}Jz.exports={getHighWaterMark:Y1e,getDefaultHighWaterMark:Gz}});var dr=H((r7,Zz)=>{h();var DS=$n(),rl=DS.Buffer;function Yz(t,e){for(var r in t)e[r]=t[r]}rl.from&&rl.alloc&&rl.allocUnsafe&&rl.allocUnsafeSlow?Zz.exports=DS:(Yz(DS,r7),r7.Buffer=Fy);function Fy(t,e,r){return rl(t,e,r)}Fy.prototype=Object.create(rl.prototype);Yz(rl,Fy);Fy.from=function(t,e,r){if(typeof t=="number")throw new TypeError("Argument must not be a number");return rl(t,e,r)};Fy.alloc=function(t,e,r){if(typeof t!="number")throw new TypeError("Argument must be a number");var n=rl(t);return e!==void 0?typeof r=="string"?n.fill(e,r):n.fill(e):n.fill(0),n};Fy.allocUnsafe=function(t){if(typeof t!="number")throw new TypeError("Argument must be a number");return rl(t)};Fy.allocUnsafeSlow=function(t){if(typeof t!="number")throw new TypeError("Argument must be a number");return DS.SlowBuffer(t)}});var Uv=H(Qz=>{"use strict";h();var i7=dr().Buffer,Xz=i7.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 Z1e(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 X1e(t){var e=Z1e(t);if(typeof e!="string"&&(i7.isEncoding===Xz||!Xz(t)))throw new Error("Unknown encoding: "+t);return e||t}Qz.StringDecoder=F2;function F2(t){this.encoding=X1e(t);var e;switch(this.encoding){case"utf16le":this.text=i2e,this.end=o2e,e=4;break;case"utf8":this.fillLast=t2e,e=4;break;case"base64":this.text=s2e,this.end=a2e,e=3;break;default:this.write=c2e,this.end=d2e;return}this.lastNeed=0,this.lastTotal=0,this.lastChar=i7.allocUnsafe(e)}F2.prototype.write=function(t){if(t.length===0)return"";var e,r;if(this.lastNeed){if(e=this.fillLast(t),e===void 0)return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r<t.length?e?e+this.text(t,r):this.text(t,r):e||""};F2.prototype.end=n2e;F2.prototype.text=r2e;F2.prototype.fillLast=function(t){if(this.lastNeed<=t.length)return t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,t.length),this.lastNeed-=t.length};function n7(t){return t<=127?0:t>>5===6?2:t>>4===14?3:t>>3===30?4:t>>6===2?-1:-2}function Q1e(t,e,r){var n=e.length-1;if(n<r)return 0;var i=n7(e[n]);return i>=0?(i>0&&(t.lastNeed=i-1),i):--n<r||i===-2?0:(i=n7(e[n]),i>=0?(i>0&&(t.lastNeed=i-2),i):--n<r||i===-2?0:(i=n7(e[n]),i>=0?(i>0&&(i===2?i=0:t.lastNeed=i-3),i):0))}function e2e(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 t2e(t){var e=this.lastTotal-this.lastNeed,r=e2e(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 r2e(t,e){var r=Q1e(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 n2e(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+"\uFFFD":e}function i2e(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 o2e(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 s2e(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 a2e(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+this.lastChar.toString("base64",0,3-this.lastNeed):e}function c2e(t){return t.toString(this.encoding)}function d2e(t){return t&&t.length?this.write(t):""}});var o7=H((het,nV)=>{"use strict";h();var eV=fs(),{PromisePrototypeThen:u2e,SymbolAsyncIterator:tV,SymbolIterator:rV}=Oi(),{Buffer:l2e}=$n(),{ERR_INVALID_ARG_TYPE:f2e,ERR_STREAM_NULL_VALUES:h2e}=Vs().codes;function p2e(t,e,r){let n;if(typeof e=="string"||e instanceof l2e)return new t({objectMode:!0,...r,read(){this.push(e),this.push(null)}});let i;if(e&&e[tV])i=!0,n=e[tV]();else if(e&&e[rV])i=!1,n=e[rV]();else throw new f2e("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){u2e(a(u),()=>eV.nextTick(c,u),l=>eV.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 h2e;if(o.push(l))continue;s=!1}}catch(u){o.destroy(u)}break}}return o}nV.exports=p2e});var z2=H((met,yV)=>{h();var Kd=fs(),{ArrayPrototypeIndexOf:m2e,NumberIsInteger:y2e,NumberIsNaN:g2e,NumberParseInt:v2e,ObjectDefineProperties:sV,ObjectKeys:b2e,ObjectSetPrototypeOf:aV,Promise:w2e,SafeSet:_2e,SymbolAsyncIterator:x2e,Symbol:E2e}=Oi();yV.exports=yr;yr.ReadableState=l7;var{EventEmitter:S2e}=Ja(),{Stream:up,prependListener:A2e}=kS(),{Buffer:s7}=$n(),{addAbortSignal:T2e}=K2(),I2e=_f(),Mr=Xu().debuglog("stream",t=>{Mr=t}),P2e=Wz(),Lv=Ky(),{getHighWaterMark:k2e,getDefaultHighWaterMark:R2e}=MS(),{aggregateTwoErrors:iV,codes:{ERR_INVALID_ARG_TYPE:B2e,ERR_METHOD_NOT_IMPLEMENTED:M2e,ERR_OUT_OF_RANGE:D2e,ERR_STREAM_PUSH_AFTER_EOF:O2e,ERR_STREAM_UNSHIFT_AFTER_END_EVENT:C2e}}=Vs(),{validateObject:$2e}=L2(),zy=E2e("kPaused"),{StringDecoder:cV}=Uv(),N2e=o7();aV(yr.prototype,up.prototype);aV(yr,up);var a7=()=>{},{errorOrDestroy:qv}=Lv;function l7(t,e,r){typeof r!="boolean"&&(r=e instanceof nl()),this.objectMode=!!(t&&t.objectMode),r&&(this.objectMode=this.objectMode||!!(t&&t.readableObjectMode)),this.highWaterMark=t?k2e(this,t,"readableHighWaterMark",r):R2e(!1),this.buffer=new P2e,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[zy]=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 cV(t.encoding),this.encoding=t.encoding)}function yr(t){if(!(this instanceof yr))return new yr(t);let e=this instanceof nl();this._readableState=new l7(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&&T2e(t.signal,this)),up.call(this,t),Lv.construct(this,()=>{this._readableState.needReadable&&OS(this,this._readableState)})}yr.prototype.destroy=Lv.destroy;yr.prototype._undestroy=Lv.undestroy;yr.prototype._destroy=function(t,e){e(t)};yr.prototype[S2e.captureRejectionSymbol]=function(t){this.destroy(t)};yr.prototype.push=function(t,e){return dV(this,t,e,!1)};yr.prototype.unshift=function(t,e){return dV(this,t,e,!0)};function dV(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=s7.from(e,r).toString(i.encoding):(e=s7.from(e,r),r=""))):e instanceof s7?r="":up._isUint8Array(e)?(e=up._uint8ArrayToBuffer(e),r=""):e!=null&&(o=new B2e("chunk",["string","Buffer","Uint8Array"],e))),o)qv(t,o);else if(e===null)i.reading=!1,q2e(t,i);else if(i.objectMode||e&&e.length>0)if(n)if(i.endEmitted)qv(t,new C2e);else{if(i.destroyed||i.errored)return!1;c7(t,i,e,!0)}else if(i.ended)qv(t,new O2e);else{if(i.destroyed||i.errored)return!1;i.reading=!1,i.decoder&&!r?(e=i.decoder.write(e),i.objectMode||e.length!==0?c7(t,i,e,!1):OS(t,i)):c7(t,i,e,!1)}else n||(i.reading=!1,OS(t,i));return!i.ended&&(i.length<i.highWaterMark||i.length===0)}function c7(t,e,r,n){e.flowing&&e.length===0&&!e.sync&&t.listenerCount("data")>0?(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&&CS(t)),OS(t,e)}yr.prototype.isPaused=function(){let t=this._readableState;return t[zy]===!0||t.flowing===!1};yr.prototype.setEncoding=function(t){let e=new cV(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 j2e=1073741824;function U2e(t){if(t>j2e)throw new D2e("size","<= 1GiB",t);return t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++,t}function oV(t,e){return t<=0||e.length===0&&e.ended?0:e.objectMode?1:g2e(t)?e.flowing&&e.length?e.buffer.first().length:e.length:t<=e.length?t:e.ended?e.length:0}yr.prototype.read=function(t){Mr("read",t),t===void 0?t=NaN:y2e(t)||(t=v2e(t,10));let e=this._readableState,r=t;if(t>e.highWaterMark&&(e.highWaterMark=U2e(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?d7(this):CS(this),null;if(t=oV(t,e),t===0&&e.ended)return e.length===0&&d7(this),null;let n=e.needReadable;if(Mr("need readable",n),(e.length===0||e.length-t<e.highWaterMark)&&(n=!0,Mr("length less than watermark",n)),e.ended||e.reading||e.destroyed||e.errored||!e.constructed)n=!1,Mr("reading, ended or constructing",n);else if(n){Mr("do read"),e.reading=!0,e.sync=!0,e.length===0&&(e.needReadable=!0);try{this._read(e.highWaterMark)}catch(o){qv(this,o)}e.sync=!1,e.reading||(t=oV(r,e))}let i;return t>0?i=pV(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&&d7(this)),i!==null&&!e.errorEmitted&&!e.closeEmitted&&(e.dataEmitted=!0,this.emit("data",i)),i};function q2e(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?CS(t):(e.needReadable=!1,e.emittedReadable=!0,uV(t))}}function CS(t){let e=t._readableState;Mr("emitReadable",e.needReadable,e.emittedReadable),e.needReadable=!1,e.emittedReadable||(Mr("emitReadable",e.flowing),e.emittedReadable=!0,Kd.nextTick(uV,t))}function uV(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,fV(t)}function OS(t,e){!e.readingMore&&e.constructed&&(e.readingMore=!0,Kd.nextTick(L2e,t,e))}function L2e(t,e){for(;!e.reading&&!e.ended&&(e.length<e.highWaterMark||e.flowing&&e.length===0);){let r=e.length;if(Mr("maybeReadMore read 0"),t.read(0),r===e.length)break}e.readingMore=!1}yr.prototype._read=function(t){throw new M2e("_read()")};yr.prototype.pipe=function(t,e){let r=this,n=this._readableState;n.pipes.length===1&&(n.multiAwaitDrain||(n.multiAwaitDrain=!0,n.awaitDrainWriters=new _2e(n.awaitDrainWriters?[n.awaitDrainWriters]:[]))),n.pipes.push(t),Mr("pipe count=%d opts=%j",n.pipes.length,e);let o=(!e||e.end!==!1)&&t!==Kd.stdout&&t!==Kd.stderr?a:E;n.endEmitted?Kd.nextTick(o):r.once("end",o),t.on("unpipe",s);function s(A,P){Mr("onunpipe"),A===r&&P&&P.hasUnpiped===!1&&(P.hasUnpiped=!0,c())}function a(){Mr("onend"),t.end()}let d,u=!1;function c(){Mr("cleanup"),t.removeListener("close",g),t.removeListener("finish",v),d&&t.removeListener("drain",d),t.removeListener("error",p),t.removeListener("unpipe",s),r.removeListener("end",a),r.removeListener("end",E),r.removeListener("data",m),u=!0,d&&n.awaitDrainWriters&&(!t._writableState||t._writableState.needDrain)&&d()}function l(){u||(n.pipes.length===1&&n.pipes[0]===t?(Mr("false write response, pause",0),n.awaitDrainWriters=t,n.multiAwaitDrain=!1):n.pipes.length>1&&n.pipes.includes(t)&&(Mr("false write response, pause",n.awaitDrainWriters.size),n.awaitDrainWriters.add(t)),r.pause()),d||(d=K2e(r,t),t.on("drain",d))}r.on("data",m);function m(A){Mr("ondata");let P=t.write(A);Mr("dest.write",P),P===!1&&l()}function p(A){if(Mr("onerror",A),E(),t.removeListener("error",p),t.listenerCount("error")===0){let P=t._writableState||t._readableState;P&&!P.errorEmitted?qv(t,A):t.emit("error",A)}}A2e(t,"error",p);function g(){t.removeListener("finish",v),E()}t.once("close",g);function v(){Mr("onfinish"),t.removeListener("close",g),E()}t.once("finish",v);function E(){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 K2e(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()}}yr.prototype.unpipe=function(t){let e=this._readableState,r={hasUnpiped:!1};if(e.pipes.length===0)return this;if(!t){let i=e.pipes;e.pipes=[],this.pause();for(let o=0;o<i.length;o++)i[o].emit("unpipe",this,{hasUnpiped:!1});return this}let n=m2e(e.pipes,t);return n===-1?this:(e.pipes.splice(n,1),e.pipes.length===0&&this.pause(),t.emit("unpipe",this,r),this)};yr.prototype.on=function(t,e){let r=up.prototype.on.call(this,t,e),n=this._readableState;return t==="data"?(n.readableListening=this.listenerCount("readable")>0,n.flowing!==!1&&this.resume()):t==="readable"&&!n.endEmitted&&!n.readableListening&&(n.readableListening=n.needReadable=!0,n.flowing=!1,n.emittedReadable=!1,Mr("on readable",n.length,n.reading),n.length?CS(this):n.reading||Kd.nextTick(F2e,this)),r};yr.prototype.addListener=yr.prototype.on;yr.prototype.removeListener=function(t,e){let r=up.prototype.removeListener.call(this,t,e);return t==="readable"&&Kd.nextTick(lV,this),r};yr.prototype.off=yr.prototype.removeListener;yr.prototype.removeAllListeners=function(t){let e=up.prototype.removeAllListeners.apply(this,arguments);return(t==="readable"||t===void 0)&&Kd.nextTick(lV,this),e};function lV(t){let e=t._readableState;e.readableListening=t.listenerCount("readable")>0,e.resumeScheduled&&e[zy]===!1?e.flowing=!0:t.listenerCount("data")>0?t.resume():e.readableListening||(e.flowing=null)}function F2e(t){Mr("readable nexttick read 0"),t.read(0)}yr.prototype.resume=function(){let t=this._readableState;return t.flowing||(Mr("resume"),t.flowing=!t.readableListening,z2e(this,t)),t[zy]=!1,this};function z2e(t,e){e.resumeScheduled||(e.resumeScheduled=!0,Kd.nextTick(V2e,t,e))}function V2e(t,e){Mr("resume",e.reading),e.reading||t.read(0),e.resumeScheduled=!1,t.emit("resume"),fV(t),e.flowing&&!e.reading&&t.read(0)}yr.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[zy]=!0,this};function fV(t){let e=t._readableState;for(Mr("flow",e.flowing);e.flowing&&t.read()!==null;);}yr.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=b2e(t);for(let n=1;n<r.length;n++){let i=r[n];this[i]===void 0&&typeof t[i]=="function"&&(this[i]=t[i].bind(t))}return this};yr.prototype[x2e]=function(){return hV(this)};yr.prototype.iterator=function(t){return t!==void 0&&$2e(t,"options"),hV(this,t)};function hV(t,e){typeof t.read!="function"&&(t=yr.wrap(t,{objectMode:!0}));let r=H2e(t,e);return r.stream=t,r}async function*H2e(t,e){let r=a7;function n(s){this===t?(r(),r=a7):r=s}t.on("readable",n);let i,o=I2e(t,{writable:!1},s=>{i=s?iV(i,s):null,r(),r=a7});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 w2e(n)}}}catch(s){throw i=iV(i,s),i}finally{(i||e?.destroyOnReturn!==!1)&&(i===void 0||t._readableState.autoDestroy)?Lv.destroyer(t,null):(t.off("readable",n),o())}}sV(yr.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}}});sV(l7.prototype,{pipesCount:{__proto__:null,get(){return this.pipes.length}},paused:{__proto__:null,get(){return this[zy]!==!1},set(t){this[zy]=!!t}}});yr._fromList=pV;function pV(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 d7(t){let e=t._readableState;Mr("endReadable",e.endEmitted),e.endEmitted||(e.ended=!0,Kd.nextTick(W2e,e,t))}function W2e(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)Kd.nextTick(G2e,e);else if(t.autoDestroy){let r=e._writableState;(!r||r.autoDestroy&&(r.finished||r.writable===!1))&&e.destroy()}}}function G2e(t){t.writable&&!t.writableEnded&&!t.destroyed&&t.end()}yr.from=function(t,e){return N2e(yr,t,e)};var u7;function mV(){return u7===void 0&&(u7={}),u7}yr.fromWeb=function(t,e){return mV().newStreamReadableFromReadableStream(t,e)};yr.toWeb=function(t,e){return mV().newReadableStreamFromStreamReadable(t,e)};yr.wrap=function(t,e){var r,n;return new yr({objectMode:(r=(n=t.readableObjectMode)!==null&&n!==void 0?n:t.objectMode)!==null&&r!==void 0?r:!0,...e,destroy(i,o){Lv.destroyer(t,i),o(i)}}).wrap(t)}});var v7=H((get,PV)=>{h();var Vy=fs(),{ArrayPrototypeSlice:bV,Error:J2e,FunctionPrototypeSymbolHasInstance:wV,ObjectDefineProperty:_V,ObjectDefineProperties:Y2e,ObjectSetPrototypeOf:xV,StringPrototypeToLowerCase:Z2e,Symbol:X2e,SymbolHasInstance:Q2e}=Oi();PV.exports=Vn;Vn.WritableState=W2;var{EventEmitter:e_e}=Ja(),V2=kS().Stream,{Buffer:$S}=$n(),US=Ky(),{addAbortSignal:t_e}=K2(),{getHighWaterMark:r_e,getDefaultHighWaterMark:n_e}=MS(),{ERR_INVALID_ARG_TYPE:i_e,ERR_METHOD_NOT_IMPLEMENTED:o_e,ERR_MULTIPLE_CALLBACK:EV,ERR_STREAM_CANNOT_PIPE:s_e,ERR_STREAM_DESTROYED:H2,ERR_STREAM_ALREADY_FINISHED:a_e,ERR_STREAM_NULL_VALUES:c_e,ERR_STREAM_WRITE_AFTER_END:d_e,ERR_UNKNOWN_ENCODING:SV}=Vs().codes,{errorOrDestroy:Kv}=US;xV(Vn.prototype,V2.prototype);xV(Vn,V2);function p7(){}var Fv=X2e("kOnFinished");function W2(t,e,r){typeof r!="boolean"&&(r=e instanceof nl()),this.objectMode=!!(t&&t.objectMode),r&&(this.objectMode=this.objectMode||!!(t&&t.writableObjectMode)),this.highWaterMark=t?r_e(this,t,"writableHighWaterMark",r):n_e(!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=l_e.bind(void 0,e),this.writecb=null,this.writelen=0,this.afterWriteTickInfo=null,jS(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[Fv]=[]}function jS(t){t.buffered=[],t.bufferedIndex=0,t.allBuffers=!0,t.allNoop=!0}W2.prototype.getBuffer=function(){return bV(this.buffered,this.bufferedIndex)};_V(W2.prototype,"bufferedRequestCount",{__proto__:null,get(){return this.buffered.length-this.bufferedIndex}});function Vn(t){let e=this instanceof nl();if(!e&&!wV(Vn,this))return new Vn(t);this._writableState=new W2(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&&t_e(t.signal,this)),V2.call(this,t),US.construct(this,()=>{let r=this._writableState;r.writing||y7(this,r),g7(this,r)})}_V(Vn,Q2e,{__proto__:null,value:function(t){return wV(this,t)?!0:this!==Vn?!1:t&&t._writableState instanceof W2}});Vn.prototype.pipe=function(){Kv(this,new s_e)};function AV(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"&&!$S.isEncoding(r))throw new SV(r);typeof n!="function"&&(n=p7)}if(e===null)throw new c_e;if(!i.objectMode)if(typeof e=="string")i.decodeStrings!==!1&&(e=$S.from(e,r),r="buffer");else if(e instanceof $S)r="buffer";else if(V2._isUint8Array(e))e=V2._uint8ArrayToBuffer(e),r="buffer";else throw new i_e("chunk",["string","Buffer","Uint8Array"],e);let o;return i.ending?o=new d_e:i.destroyed&&(o=new H2("write")),o?(Vy.nextTick(n,o),Kv(t,o,!0),o):(i.pendingcb++,u_e(t,i,e,r,n))}Vn.prototype.write=function(t,e,r){return AV(this,t,e,r)===!0};Vn.prototype.cork=function(){this._writableState.corked++};Vn.prototype.uncork=function(){let t=this._writableState;t.corked&&(t.corked--,t.writing||y7(this,t))};Vn.prototype.setDefaultEncoding=function(e){if(typeof e=="string"&&(e=Z2e(e)),!$S.isEncoding(e))throw new SV(e);return this._writableState.defaultEncoding=e,this};function u_e(t,e,r,n,i){let o=e.objectMode?1:r.length;e.length+=o;let s=e.length<e.highWaterMark;return s||(e.needDrain=!0),e.writing||e.corked||e.errored||!e.constructed?(e.buffered.push({chunk:r,encoding:n,callback:i}),e.allBuffers&&n!=="buffer"&&(e.allBuffers=!1),e.allNoop&&i!==p7&&(e.allNoop=!1)):(e.writelen=o,e.writecb=i,e.writing=!0,e.sync=!0,t._write(r,n,e.onwrite),e.sync=!1),s&&!e.errored&&!e.destroyed}function gV(t,e,r,n,i,o,s){e.writelen=n,e.writecb=s,e.writing=!0,e.sync=!0,e.destroyed?e.onwrite(new H2("write")):r?t._writev(i,e.onwrite):t._write(i,o,e.onwrite),e.sync=!1}function vV(t,e,r,n){--e.pendingcb,n(r),m7(e),Kv(t,r)}function l_e(t,e){let r=t._writableState,n=r.sync,i=r.writecb;if(typeof i!="function"){Kv(t,new EV);return}r.writing=!1,r.writecb=null,r.length-=r.writelen,r.writelen=0,e?(e.stack,r.errored||(r.errored=e),t._readableState&&!t._readableState.errored&&(t._readableState.errored=e),n?Vy.nextTick(vV,t,r,e,i):vV(t,r,e,i)):(r.buffered.length>r.bufferedIndex&&y7(t,r),n?r.afterWriteTickInfo!==null&&r.afterWriteTickInfo.cb===i?r.afterWriteTickInfo.count++:(r.afterWriteTickInfo={count:1,cb:i,stream:t,state:r},Vy.nextTick(f_e,r.afterWriteTickInfo)):TV(t,r,1,i))}function f_e({stream:t,state:e,count:r,cb:n}){return e.afterWriteTickInfo=null,TV(t,e,r,n)}function TV(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&&m7(e),g7(t,e)}function m7(t){if(t.writing)return;for(let i=t.bufferedIndex;i<t.buffered.length;++i){var e;let{chunk:o,callback:s}=t.buffered[i],a=t.objectMode?1:o.length;t.length-=a,s((e=t.errored)!==null&&e!==void 0?e:new H2("write"))}let r=t[Fv].splice(0);for(let i=0;i<r.length;i++){var n;r[i]((n=t.errored)!==null&&n!==void 0?n:new H2("end"))}jS(t)}function y7(t,e){if(e.corked||e.bufferProcessing||e.destroyed||!e.constructed)return;let{buffered:r,bufferedIndex:n,objectMode:i}=e,o=r.length-n;if(!o)return;let s=n;if(e.bufferProcessing=!0,o>1&&t._writev){e.pendingcb-=o-1;let a=e.allNoop?p7:u=>{for(let c=s;c<r.length;++c)r[c].callback(u)},d=e.allNoop&&s===0?r:bV(r,s);d.allBuffers=e.allBuffers,gV(t,e,!0,e.length,d,"",a),jS(e)}else{do{let{chunk:a,encoding:d,callback:u}=r[s];r[s++]=null;let c=i?1:a.length;gV(t,e,!1,c,a,d,u)}while(s<r.length&&!e.writing);s===r.length?jS(e):s>256?(r.splice(0,s),e.bufferedIndex=0):e.bufferedIndex=s}e.bufferProcessing=!1}Vn.prototype._write=function(t,e,r){if(this._writev)this._writev([{chunk:t,encoding:e}],r);else throw new o_e("_write()")};Vn.prototype._writev=null;Vn.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=AV(this,t,e);o instanceof J2e&&(i=o)}return n.corked&&(n.corked=1,this.uncork()),i||(!n.errored&&!n.ending?(n.ending=!0,g7(this,n,!0),n.ended=!0):n.finished?i=new a_e("end"):n.destroyed&&(i=new H2("end"))),typeof r=="function"&&(i||n.finished?Vy.nextTick(r,i):n[Fv].push(r)),this};function NS(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 h_e(t,e){let r=!1;function n(i){if(r){Kv(t,i??EV());return}if(r=!0,e.pendingcb--,i){let o=e[Fv].splice(0);for(let s=0;s<o.length;s++)o[s](i);Kv(t,i,e.sync)}else NS(e)&&(e.prefinished=!0,t.emit("prefinish"),e.pendingcb++,Vy.nextTick(h7,t,e))}e.sync=!0,e.pendingcb++;try{t._final(n)}catch(i){n(i)}e.sync=!1}function p_e(t,e){!e.prefinished&&!e.finalCalled&&(typeof t._final=="function"&&!e.destroyed?(e.finalCalled=!0,h_e(t,e)):(e.prefinished=!0,t.emit("prefinish")))}function g7(t,e,r){NS(e)&&(p_e(t,e),e.pendingcb===0&&(r?(e.pendingcb++,Vy.nextTick((n,i)=>{NS(i)?h7(n,i):i.pendingcb--},t,e)):NS(e)&&(e.pendingcb++,h7(t,e))))}function h7(t,e){e.pendingcb--,e.finished=!0;let r=e[Fv].splice(0);for(let n=0;n<r.length;n++)r[n]();if(t.emit("finish"),e.autoDestroy){let n=t._readableState;(!n||n.autoDestroy&&(n.endEmitted||n.readable===!1))&&t.destroy()}}Y2e(Vn.prototype,{closed:{__proto__:null,get(){return this._writableState?this._writableState.closed:!1}},destroyed:{__proto__:null,get(){return this._writableState?this._writableState.destroyed:!1},set(t){this._writableState&&(this._writableState.destroyed=t)}},writable:{__proto__:null,get(){let t=this._writableState;return!!t&&t.writable!==!1&&!t.destroyed&&!t.errored&&!t.ending&&!t.ended},set(t){this._writableState&&(this._writableState.writable=!!t)}},writableFinished:{__proto__:null,get(){return this._writableState?this._writableState.finished:!1}},writableObjectMode:{__proto__:null,get(){return this._writableState?this._writableState.objectMode:!1}},writableBuffer:{__proto__:null,get(){return this._writableState&&this._writableState.getBuffer()}},writableEnded:{__proto__:null,get(){return this._writableState?this._writableState.ending:!1}},writableNeedDrain:{__proto__:null,get(){let t=this._writableState;return t?!t.destroyed&&!t.ending&&t.needDrain:!1}},writableHighWaterMark:{__proto__:null,get(){return this._writableState&&this._writableState.highWaterMark}},writableCorked:{__proto__:null,get(){return this._writableState?this._writableState.corked:0}},writableLength:{__proto__:null,get(){return this._writableState&&this._writableState.length}},errored:{__proto__:null,enumerable:!1,get(){return this._writableState?this._writableState.errored:null}},writableAborted:{__proto__:null,enumerable:!1,get:function(){return!!(this._writableState.writable!==!1&&(this._writableState.destroyed||this._writableState.errored)&&!this._writableState.finished)}}});var m_e=US.destroy;Vn.prototype.destroy=function(t,e){let r=this._writableState;return!r.destroyed&&(r.bufferedIndex<r.buffered.length||r[Fv].length)&&Vy.nextTick(m7,r),m_e.call(this,t,e),this};Vn.prototype._undestroy=US.undestroy;Vn.prototype._destroy=function(t,e){e(t)};Vn.prototype[e_e.captureRejectionSymbol]=function(t){this.destroy(t)};var f7;function IV(){return f7===void 0&&(f7={}),f7}Vn.fromWeb=function(t,e){return IV().newStreamWritableFromWritableStream(t,e)};Vn.toWeb=function(t){return IV().newWritableStreamFromStreamWritable(t)}});var qV=H((bet,UV)=>{h();var b7=fs(),y_e=$n(),{isReadable:g_e,isWritable:v_e,isIterable:kV,isNodeStream:b_e,isReadableNodeStream:RV,isWritableNodeStream:BV,isDuplexNodeStream:w_e}=el(),MV=_f(),{AbortError:jV,codes:{ERR_INVALID_ARG_TYPE:__e,ERR_INVALID_RETURN_VALUE:DV}}=Vs(),{destroyer:zv}=Ky(),x_e=nl(),E_e=z2(),{createDeferredPromise:OV}=Xu(),CV=o7(),$V=globalThis.Blob||y_e.Blob,S_e=typeof $V<"u"?function(e){return e instanceof $V}:function(e){return!1},A_e=globalThis.AbortController||wf().AbortController,{FunctionPrototypeCall:NV}=Oi(),Hy=class extends x_e{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)}};UV.exports=function t(e,r){if(w_e(e))return e;if(RV(e))return qS({readable:e});if(BV(e))return qS({writable:e});if(b_e(e))return qS({writable:!1,readable:!1});if(typeof e=="function"){let{value:i,write:o,final:s,destroy:a}=T_e(e);if(kV(i))return CV(Hy,i,{objectMode:!0,write:o,final:s,destroy:a});let d=i?.then;if(typeof d=="function"){let u,c=NV(d,i,l=>{if(l!=null)throw new DV("nully","body",l)},l=>{zv(u,l)});return u=new Hy({objectMode:!0,readable:!1,write:o,final(l){s(async()=>{try{await c,b7.nextTick(l,null)}catch(m){b7.nextTick(l,m)}})},destroy:a})}throw new DV("Iterable, AsyncIterable or AsyncFunction",r,i)}if(S_e(e))return t(e.arrayBuffer());if(kV(e))return CV(Hy,e,{objectMode:!0,writable:!1});if(typeof e?.writable=="object"||typeof e?.readable=="object"){let i=e!=null&&e.readable?RV(e?.readable)?e?.readable:t(e.readable):void 0,o=e!=null&&e.writable?BV(e?.writable)?e?.writable:t(e.writable):void 0;return qS({readable:i,writable:o})}let n=e?.then;if(typeof n=="function"){let i;return NV(n,e,o=>{o!=null&&i.push(o),i.push(null)},o=>{zv(i,o)}),i=new Hy({objectMode:!0,writable:!1,read(){}})}throw new __e(r,["Blob","ReadableStream","WritableStream","Stream","Iterable","AsyncIterable","Function","{ readable, writable } pair","Promise"],e)};function T_e(t){let{promise:e,resolve:r}=OV(),n=new A_e,i=n.signal;return{value:t(async function*(){for(;;){let s=e;e=null;let{chunk:a,done:d,cb:u}=await s;if(b7.nextTick(u),d)return;if(i.aborted)throw new jV(void 0,{cause:i.reason});({promise:e,resolve:r}=OV()),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 qS(t){let e=t.readable&&typeof t.readable.read!="function"?E_e.wrap(t.readable):t.readable,r=t.writable,n=!!g_e(e),i=!!v_e(r),o,s,a,d,u;function c(l){let m=d;d=null,m?m(l):l&&u.destroy(l)}return u=new Hy({readableObjectMode:!!(e!=null&&e.readableObjectMode),writableObjectMode:!!(r!=null&&r.writableObjectMode),readable:n,writable:i}),i&&(MV(r,l=>{i=!1,l&&zv(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&&(MV(e,l=>{n=!1,l&&zv(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 jV),a=null,o=null,s=null,d===null?m(l):(d=m,zv(r,l),zv(e,l))},u}});var nl=H((_et,FV)=>{"use strict";h();var{ObjectDefineProperties:I_e,ObjectGetOwnPropertyDescriptor:xf,ObjectKeys:P_e,ObjectSetPrototypeOf:LV}=Oi();FV.exports=Fd;var x7=z2(),Fc=v7();LV(Fd.prototype,x7.prototype);LV(Fd,x7);{let t=P_e(Fc.prototype);for(let e=0;e<t.length;e++){let r=t[e];Fd.prototype[r]||(Fd.prototype[r]=Fc.prototype[r])}}function Fd(t){if(!(this instanceof Fd))return new Fd(t);x7.call(this,t),Fc.call(this,t),t?(this.allowHalfOpen=t.allowHalfOpen!==!1,t.readable===!1&&(this._readableState.readable=!1,this._readableState.ended=!0,this._readableState.endEmitted=!0),t.writable===!1&&(this._writableState.writable=!1,this._writableState.ending=!0,this._writableState.ended=!0,this._writableState.finished=!0)):this.allowHalfOpen=!0}I_e(Fd.prototype,{writable:{__proto__:null,...xf(Fc.prototype,"writable")},writableHighWaterMark:{__proto__:null,...xf(Fc.prototype,"writableHighWaterMark")},writableObjectMode:{__proto__:null,...xf(Fc.prototype,"writableObjectMode")},writableBuffer:{__proto__:null,...xf(Fc.prototype,"writableBuffer")},writableLength:{__proto__:null,...xf(Fc.prototype,"writableLength")},writableFinished:{__proto__:null,...xf(Fc.prototype,"writableFinished")},writableCorked:{__proto__:null,...xf(Fc.prototype,"writableCorked")},writableEnded:{__proto__:null,...xf(Fc.prototype,"writableEnded")},writableNeedDrain:{__proto__:null,...xf(Fc.prototype,"writableNeedDrain")},destroyed:{__proto__:null,get(){return this._readableState===void 0||this._writableState===void 0?!1:this._readableState.destroyed&&this._writableState.destroyed},set(t){this._readableState&&this._writableState&&(this._readableState.destroyed=t,this._writableState.destroyed=t)}}});var w7;function KV(){return w7===void 0&&(w7={}),w7}Fd.fromWeb=function(t,e){return KV().newStreamDuplexFromReadableWritablePair(t,e)};Fd.toWeb=function(t){return KV().newReadableWritablePairFromDuplex(t)};var _7;Fd.from=function(t){return _7||(_7=qV()),_7(t,"body")}});var A7=H((Eet,VV)=>{"use strict";h();var{ObjectSetPrototypeOf:zV,Symbol:k_e}=Oi();VV.exports=Ef;var{ERR_METHOD_NOT_IMPLEMENTED:R_e}=Vs().codes,S7=nl(),{getHighWaterMark:B_e}=MS();zV(Ef.prototype,S7.prototype);zV(Ef,S7);var G2=k_e("kCallback");function Ef(t){if(!(this instanceof Ef))return new Ef(t);let e=t?B_e(this,t,"readableHighWaterMark",!0):null;e===0&&(t={...t,highWaterMark:null,readableHighWaterMark:e,writableHighWaterMark:t.writableHighWaterMark||0}),S7.call(this,t),this._readableState.sync=!1,this[G2]=null,t&&(typeof t.transform=="function"&&(this._transform=t.transform),typeof t.flush=="function"&&(this._flush=t.flush)),this.on("prefinish",M_e)}function E7(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 M_e(){this._final!==E7&&E7.call(this)}Ef.prototype._final=E7;Ef.prototype._transform=function(t,e,r){throw new R_e("_transform()")};Ef.prototype._write=function(t,e,r){let n=this._readableState,i=this._writableState,o=n.length;this._transform(t,e,(s,a)=>{if(s){r(s);return}a!=null&&this.push(a),i.ended||o===n.length||n.length<n.highWaterMark?r():this[G2]=r})};Ef.prototype._read=function(){if(this[G2]){let t=this[G2];this[G2]=null,t()}}});var I7=H((Tet,WV)=>{"use strict";h();var{ObjectSetPrototypeOf:HV}=Oi();WV.exports=Vv;var T7=A7();HV(Vv.prototype,T7.prototype);HV(Vv,T7);function Vv(t){if(!(this instanceof Vv))return new Vv(t);T7.call(this,t)}Vv.prototype._transform=function(t,e,r){r(null,t)}});var zS=H((Pet,XV)=>{h();var J2=fs(),{ArrayIsArray:D_e,Promise:O_e,SymbolAsyncIterator:C_e}=Oi(),FS=_f(),{once:$_e}=Xu(),N_e=Ky(),GV=nl(),{aggregateTwoErrors:j_e,codes:{ERR_INVALID_ARG_TYPE:C7,ERR_INVALID_RETURN_VALUE:P7,ERR_MISSING_ARGS:U_e,ERR_STREAM_DESTROYED:q_e,ERR_STREAM_PREMATURE_CLOSE:L_e},AbortError:K_e}=Vs(),{validateFunction:F_e,validateAbortSignal:z_e}=L2(),{isIterable:Wy,isReadable:k7,isReadableNodeStream:KS,isNodeStream:JV,isTransformStream:Hv,isWebStream:V_e,isReadableStream:R7,isReadableEnded:H_e}=el(),W_e=globalThis.AbortController||wf().AbortController,B7,M7;function YV(t,e,r){let n=!1;t.on("close",()=>{n=!0});let i=FS(t,{readable:e,writable:r},o=>{n=!o});return{destroy:o=>{n||(n=!0,N_e.destroyer(t,o||new q_e("pipe")))},cleanup:i}}function G_e(t){return F_e(t[t.length-1],"streams[stream.length - 1]"),t.pop()}function D7(t){if(Wy(t))return t;if(KS(t))return J_e(t);throw new C7("val",["Readable","Iterable","AsyncIterable"],t)}async function*J_e(t){M7||(M7=z2()),yield*M7.prototype[C_e].call(t)}async function LS(t,e,r,{end:n}){let i,o=null,s=u=>{if(u&&(i=u),o){let c=o;o=null,c()}},a=()=>new O_e((u,c)=>{i?c(i):o=()=>{i?c(i):u()}});e.on("drain",s);let d=FS(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?j_e(i,u):u)}finally{d(),e.off("drain",s)}}async function O7(t,e,r,{end:n}){Hv(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 Y_e(...t){return ZV(t,$_e(G_e(t)))}function ZV(t,e,r){if(t.length===1&&D_e(t[0])&&(t=t[0]),t.length<2)throw new U_e("streams");let n=new W_e,i=n.signal,o=r?.signal,s=[];z_e(o,"options.signal");function a(){p(new K_e)}o?.addEventListener("abort",a);let d,u,c=[],l=0;function m(P){p(P,--l===0)}function p(P,I){if(P&&(!d||d.code==="ERR_STREAM_PREMATURE_CLOSE")&&(d=P),!(!d&&!I)){for(;c.length;)c.shift()(d);o?.removeEventListener("abort",a),n.abort(),I&&(d||s.forEach($=>$()),J2.nextTick(e,d,u))}}let g;for(let P=0;P<t.length;P++){let I=t[P],$=P<t.length-1,N=P>0,K=$||r?.end!==!1,F=P===t.length-1;if(JV(I)){let U=function(V){V&&V.name!=="AbortError"&&V.code!=="ERR_STREAM_PREMATURE_CLOSE"&&m(V)};var A=U;if(K){let{destroy:V,cleanup:L}=YV(I,$,N);c.push(V),k7(I)&&F&&s.push(L)}I.on("error",U),k7(I)&&F&&s.push(()=>{I.removeListener("error",U)})}if(P===0)if(typeof I=="function"){if(g=I({signal:i}),!Wy(g))throw new P7("Iterable, AsyncIterable or Stream","source",g)}else Wy(I)||KS(I)||Hv(I)?g=I:g=GV.from(I);else if(typeof I=="function"){if(Hv(g)){var v;g=D7((v=g)===null||v===void 0?void 0:v.readable)}else g=D7(g);if(g=I(g,{signal:i}),$){if(!Wy(g,!0))throw new P7("AsyncIterable",`transform[${P-1}]`,g)}else{var E;B7||(B7=I7());let U=new B7({objectMode:!0}),V=(E=g)===null||E===void 0?void 0:E.then;if(typeof V=="function")l++,V.call(g,S=>{u=S,S!=null&&U.write(S),K&&U.end(),J2.nextTick(m)},S=>{U.destroy(S),J2.nextTick(m,S)});else if(Wy(g,!0))l++,LS(g,U,m,{end:K});else if(R7(g)||Hv(g)){let S=g.readable||g;l++,LS(S,U,m,{end:K})}else throw new P7("AsyncIterable or Promise","destination",g);g=U;let{destroy:L,cleanup:T}=YV(g,!1,!0);c.push(L),F&&s.push(T)}}else if(JV(I)){if(KS(g)){l+=2;let U=Z_e(g,I,m,{end:K});k7(I)&&F&&s.push(U)}else if(Hv(g)||R7(g)){let U=g.readable||g;l++,LS(U,I,m,{end:K})}else if(Wy(g))l++,LS(g,I,m,{end:K});else throw new C7("val",["Readable","Iterable","AsyncIterable","ReadableStream","TransformStream"],g);g=I}else if(V_e(I)){if(KS(g))l++,O7(D7(g),I,m,{end:K});else if(R7(g)||Wy(g))l++,O7(g,I,m,{end:K});else if(Hv(g))l++,O7(g.readable,I,m,{end:K});else throw new C7("val",["Readable","Iterable","AsyncIterable","ReadableStream","TransformStream"],g);g=I}else g=GV.from(I)}return(i!=null&&i.aborted||o!=null&&o.aborted)&&J2.nextTick(a),g}function Z_e(t,e,r,{end:n}){let i=!1;if(e.on("close",()=>{i||r(new L_e)}),t.pipe(e,{end:!1}),n){let s=function(){i=!0,e.end()};var o=s;H_e(t)?J2.nextTick(s):t.once("end",s)}else r();return FS(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)}),FS(e,{readable:!1,writable:!0},r)}XV.exports={pipelineImpl:ZV,pipeline:Y_e}});var N7=H((Ret,iH)=>{"use strict";h();var{pipeline:X_e}=zS(),VS=nl(),{destroyer:Q_e}=Ky(),{isNodeStream:HS,isReadable:QV,isWritable:eH,isWebStream:$7,isTransformStream:Gy,isWritableStream:tH,isReadableStream:rH}=el(),{AbortError:exe,codes:{ERR_INVALID_ARG_VALUE:nH,ERR_MISSING_ARGS:txe}}=Vs(),rxe=_f();iH.exports=function(...e){if(e.length===0)throw new txe("streams");if(e.length===1)return VS.from(e[0]);let r=[...e];if(typeof e[0]=="function"&&(e[0]=VS.from(e[0])),typeof e[e.length-1]=="function"){let p=e.length-1;e[p]=VS.from(e[p])}for(let p=0;p<e.length;++p)if(!(!HS(e[p])&&!$7(e[p]))){if(p<e.length-1&&!(QV(e[p])||rH(e[p])||Gy(e[p])))throw new nH(`streams[${p}]`,r[p],"must be readable");if(p>0&&!(eH(e[p])||tH(e[p])||Gy(e[p])))throw new nH(`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=X_e(e,d),l=!!(eH(u)||tH(u)||Gy(u)),m=!!(QV(c)||rH(c)||Gy(c));if(a=new VS({writableObjectMode:!!(u!=null&&u.writableObjectMode),readableObjectMode:!!(c!=null&&c.writableObjectMode),writable:l,readable:m}),l){if(HS(u))a._write=function(g,v,E){u.write(g,v)?E():n=E},a._final=function(g){u.end(),i=g},u.on("drain",function(){if(n){let g=n;n=null,g()}});else if($7(u)){let v=(Gy(u)?u.writable:u).getWriter();a._write=async function(E,A,P){try{await v.ready,v.write(E).catch(()=>{}),P()}catch(I){P(I)}},a._final=async function(E){try{await v.ready,v.close().catch(()=>{}),i=E}catch(A){E(A)}}}let p=Gy(c)?c.readable:c;rxe(p,()=>{if(i){let g=i;i=null,g()}})}if(m){if(HS(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($7(c)){let g=(Gy(c)?c.readable:c).getReader();a._read=async function(){for(;;)try{let{value:v,done:E}=await g.read();if(!a.push(v))return;if(E){a.push(null);return}}catch{return}}}}return a._destroy=function(p,g){!p&&s!==null&&(p=new exe),o=null,n=null,i=null,s===null?g(p):(s=g,HS(c)&&Q_e(c,p))},a}});var fH=H((Met,q7)=>{"use strict";h();var cH=globalThis.AbortController||wf().AbortController,{codes:{ERR_INVALID_ARG_VALUE:nxe,ERR_INVALID_ARG_TYPE:Y2,ERR_MISSING_ARGS:ixe,ERR_OUT_OF_RANGE:oxe},AbortError:il}=Vs(),{validateAbortSignal:Jy,validateInteger:sxe,validateObject:Yy}=L2(),axe=Oi().Symbol("kWeak"),{finished:cxe}=_f(),dxe=N7(),{addAbortSignalNoValidate:uxe}=K2(),{isWritable:lxe,isNodeStream:fxe}=el(),{ArrayPrototypePush:hxe,MathFloor:pxe,Number:mxe,NumberIsNaN:yxe,Promise:oH,PromiseReject:sH,PromisePrototypeThen:gxe,Symbol:dH}=Oi(),WS=dH("kEmpty"),aH=dH("kEof");function vxe(t,e){if(e!=null&&Yy(e,"options"),e?.signal!=null&&Jy(e.signal,"options.signal"),fxe(t)&&!lxe(t))throw new nxe("stream",t,"must be writable");let r=dxe(this,t);return e!=null&&e.signal&&uxe(e.signal,r),r}function GS(t,e){if(typeof t!="function")throw new Y2("fn",["Function","AsyncFunction"],t);e!=null&&Yy(e,"options"),e?.signal!=null&&Jy(e.signal,"options.signal");let r=1;return e?.concurrency!=null&&(r=pxe(e.concurrency)),sxe(r,"concurrency",1),(async function*(){var i,o;let s=new cH,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 v(){g=!0}async function E(){try{for await(let I of a){var A;if(g)return;if(u.aborted)throw new il;try{I=t(I,c)}catch($){I=sH($)}I!==WS&&(typeof((A=I)===null||A===void 0?void 0:A.catch)=="function"&&I.catch(v),d.push(I),m&&(m(),m=null),!g&&d.length&&d.length>=r&&await new oH($=>{p=$}))}d.push(aH)}catch(I){let $=sH(I);gxe($,void 0,v),d.push($)}finally{var P;g=!0,m&&(m(),m=null),e==null||(P=e.signal)===null||P===void 0||P.removeEventListener("abort",l)}}E();try{for(;;){for(;d.length>0;){let A=await d[0];if(A===aH)return;if(u.aborted)throw new il;A!==WS&&(yield A),d.shift(),p&&(p(),p=null)}await new oH(A=>{m=A})}}finally{s.abort(),g=!0,p&&(p(),p=null)}}).call(this)}function bxe(t=void 0){return t!=null&&Yy(t,"options"),t?.signal!=null&&Jy(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 il({cause:t.signal.reason});yield[r++,i]}}).call(this)}async function uH(t,e=void 0){for await(let r of U7.call(this,t,e))return!0;return!1}async function wxe(t,e=void 0){if(typeof t!="function")throw new Y2("fn",["Function","AsyncFunction"],t);return!await uH.call(this,async(...r)=>!await t(...r),e)}async function _xe(t,e){for await(let r of U7.call(this,t,e))return r}async function xxe(t,e){if(typeof t!="function")throw new Y2("fn",["Function","AsyncFunction"],t);async function r(n,i){return await t(n,i),WS}for await(let n of GS.call(this,r,e));}function U7(t,e){if(typeof t!="function")throw new Y2("fn",["Function","AsyncFunction"],t);async function r(n,i){return await t(n,i)?n:WS}return GS.call(this,r,e)}var j7=class extends ixe{constructor(){super("reduce"),this.message="Reduce of an empty stream requires an initial value"}};async function Exe(t,e,r){var n;if(typeof t!="function")throw new Y2("reducer",["Function","AsyncFunction"],t);r!=null&&Yy(r,"options"),r?.signal!=null&&Jy(r.signal,"options.signal");let i=arguments.length>1;if(r!=null&&(n=r.signal)!==null&&n!==void 0&&n.aborted){let u=new il(void 0,{cause:r.signal.reason});throw this.once("error",()=>{}),await cxe(this.destroy(u)),u}let o=new cH,s=o.signal;if(r!=null&&r.signal){let u={once:!0,[axe]: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 il;i?e=await t(e,u,{signal:s}):(e=u,i=!0)}if(!a&&!i)throw new j7}finally{o.abort()}return e}async function Sxe(t){t!=null&&Yy(t,"options"),t?.signal!=null&&Jy(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 il(void 0,{cause:t.signal.reason});hxe(e,n)}return e}function Axe(t,e){let r=GS.call(this,t,e);return(async function*(){for await(let i of r)yield*i}).call(this)}function lH(t){if(t=mxe(t),yxe(t))return 0;if(t<0)throw new oxe("number",">= 0",t);return t}function Txe(t,e=void 0){return e!=null&&Yy(e,"options"),e?.signal!=null&&Jy(e.signal,"options.signal"),t=lH(t),(async function*(){var n;if(e!=null&&(n=e.signal)!==null&&n!==void 0&&n.aborted)throw new il;for await(let o of this){var i;if(e!=null&&(i=e.signal)!==null&&i!==void 0&&i.aborted)throw new il;t--<=0&&(yield o)}}).call(this)}function Ixe(t,e=void 0){return e!=null&&Yy(e,"options"),e?.signal!=null&&Jy(e.signal,"options.signal"),t=lH(t),(async function*(){var n;if(e!=null&&(n=e.signal)!==null&&n!==void 0&&n.aborted)throw new il;for await(let o of this){var i;if(e!=null&&(i=e.signal)!==null&&i!==void 0&&i.aborted)throw new il;if(t-- >0)yield o;else return}}).call(this)}q7.exports.streamReturningOperators={asIndexedPairs:bxe,drop:Txe,filter:U7,flatMap:Axe,map:GS,take:Ixe,compose:vxe};q7.exports.promiseReturningOperators={every:wxe,forEach:xxe,reduce:Exe,toArray:Sxe,some:uH,find:_xe}});var L7=H((Oet,hH)=>{"use strict";h();var{ArrayPrototypePop:Pxe,Promise:kxe}=Oi(),{isIterable:Rxe,isNodeStream:Bxe,isWebStream:Mxe}=el(),{pipelineImpl:Dxe}=zS(),{finished:Oxe}=_f();K7();function Cxe(...t){return new kxe((e,r)=>{let n,i,o=t[t.length-1];if(o&&typeof o=="object"&&!Bxe(o)&&!Rxe(o)&&!Mxe(o)){let s=Pxe(t);n=s.signal,i=s.end}Dxe(t,(s,a)=>{s?r(s):e(a)},{signal:n,end:i})})}hH.exports={finished:Oxe,pipeline:Cxe}});var K7=H(($et,xH)=>{h();var{Buffer:$xe}=$n(),{ObjectDefineProperty:Sf,ObjectKeys:yH,ReflectApply:gH}=Oi(),{promisify:{custom:vH}}=Xu(),{streamReturningOperators:pH,promiseReturningOperators:mH}=fH(),{codes:{ERR_ILLEGAL_CONSTRUCTOR:bH}}=Vs(),Nxe=N7(),{pipeline:wH}=zS(),{destroyer:jxe}=Ky(),_H=_f(),F7=L7(),z7=el(),_i=xH.exports=kS().Stream;_i.isDisturbed=z7.isDisturbed;_i.isErrored=z7.isErrored;_i.isReadable=z7.isReadable;_i.Readable=z2();for(let t of yH(pH)){let r=function(...n){if(new.target)throw bH();return _i.Readable.from(gH(e,this,n))};V7=r;let e=pH[t];Sf(r,"name",{__proto__:null,value:e.name}),Sf(r,"length",{__proto__:null,value:e.length}),Sf(_i.Readable.prototype,t,{__proto__:null,value:r,enumerable:!1,configurable:!0,writable:!0})}var V7;for(let t of yH(mH)){let r=function(...i){if(new.target)throw bH();return gH(e,this,i)};V7=r;let e=mH[t];Sf(r,"name",{__proto__:null,value:e.name}),Sf(r,"length",{__proto__:null,value:e.length}),Sf(_i.Readable.prototype,t,{__proto__:null,value:r,enumerable:!1,configurable:!0,writable:!0})}var V7;_i.Writable=v7();_i.Duplex=nl();_i.Transform=A7();_i.PassThrough=I7();_i.pipeline=wH;var{addAbortSignal:Uxe}=K2();_i.addAbortSignal=Uxe;_i.finished=_H;_i.destroy=jxe;_i.compose=Nxe;Sf(_i,"promises",{__proto__:null,configurable:!0,enumerable:!0,get(){return F7}});Sf(wH,vH,{__proto__:null,enumerable:!0,get(){return F7.pipeline}});Sf(_H,vH,{__proto__:null,enumerable:!0,get(){return F7.finished}});_i.Stream=_i;_i._isUint8Array=function(e){return e instanceof Uint8Array};_i._uint8ArrayToBuffer=function(e){return $xe.from(e.buffer,e.byteOffset,e.byteLength)}});var H7=H((jet,xi)=>{"use strict";h();var qi=K7(),qxe=L7(),Lxe=qi.Readable.destroy;xi.exports=qi.Readable;xi.exports._uint8ArrayToBuffer=qi._uint8ArrayToBuffer;xi.exports._isUint8Array=qi._isUint8Array;xi.exports.isDisturbed=qi.isDisturbed;xi.exports.isErrored=qi.isErrored;xi.exports.isReadable=qi.isReadable;xi.exports.Readable=qi.Readable;xi.exports.Writable=qi.Writable;xi.exports.Duplex=qi.Duplex;xi.exports.Transform=qi.Transform;xi.exports.PassThrough=qi.PassThrough;xi.exports.addAbortSignal=qi.addAbortSignal;xi.exports.finished=qi.finished;xi.exports.destroy=qi.destroy;xi.exports.destroy=Lxe;xi.exports.pipeline=qi.pipeline;xi.exports.compose=qi.compose;Object.defineProperty(qi,"promises",{configurable:!0,enumerable:!0,get(){return qxe}});xi.exports.Stream=qi.Stream;xi.exports.default=xi.exports});var KR=H(($5,tG)=>{h();(function(t,e){typeof $5=="object"&&typeof tG<"u"?e($5):typeof define=="function"&&define.amd?define(["exports"],e):e(t.URI=t.URI||{})})($5,function(t){"use strict";function e(){for(var Q=arguments.length,Y=Array(Q),te=0;te<Q;te++)Y[te]=arguments[te];if(Y.length>1){Y[0]=Y[0].slice(0,-1);for(var re=Y.length-1,ie=1;ie<re;++ie)Y[ie]=Y[ie].slice(1,-1);return Y[re]=Y[re].slice(1),Y.join("")}else return Y[0]}function r(Q){return"(?:"+Q+")"}function n(Q){return Q===void 0?"undefined":Q===null?"null":Object.prototype.toString.call(Q).split(" ").pop().split("]").shift().toLowerCase()}function i(Q){return Q.toUpperCase()}function o(Q){return Q!=null?Q instanceof Array?Q:typeof Q.length!="number"||Q.split||Q.setInterval||Q.call?[Q]:Array.prototype.slice.call(Q):[]}function s(Q,Y){var te=Q;if(Y)for(var re in Y)te[re]=Y[re];return te}function a(Q){var Y="[A-Za-z]",te="[\\x0D]",re="[0-9]",ie="[\\x22]",$e=e(re,"[A-Fa-f]"),Pe="[\\x0A]",Ne="[\\x20]",Tr=r(r("%[EFef]"+$e+"%"+$e+$e+"%"+$e+$e)+"|"+r("%[89A-Fa-f]"+$e+"%"+$e+$e)+"|"+r("%"+$e+$e)),Ut="[\\:\\/\\?\\#\\[\\]\\@]",ut="[\\!\\$\\&\\'\\(\\)\\*\\+\\,\\;\\=]",Yr=e(Ut,ut),cn=Q?"[\\xA0-\\u200D\\u2010-\\u2029\\u202F-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]":"[]",Wr=Q?"[\\uE000-\\uF8FF]":"[]",ar=e(Y,re,"[\\-\\.\\_\\~]",cn),Zr=r(Y+e(Y,re,"[\\+\\-\\.]")+"*"),Br=r(r(Tr+"|"+e(ar,ut,"[\\:]"))+"*"),Ls=r(r("25[0-5]")+"|"+r("2[0-4]"+re)+"|"+r("1"+re+re)+"|"+r("[1-9]"+re)+"|"+re),vi=r(r("25[0-5]")+"|"+r("2[0-4]"+re)+"|"+r("1"+re+re)+"|"+r("0?[1-9]"+re)+"|0?0?"+re),Mi=r(vi+"\\."+vi+"\\."+vi+"\\."+vi),Cr=r($e+"{1,4}"),bi=r(r(Cr+"\\:"+Cr)+"|"+Mi),Di=r(r(Cr+"\\:")+"{6}"+bi),oo=r("\\:\\:"+r(Cr+"\\:")+"{5}"+bi),Ks=r(r(Cr)+"?\\:\\:"+r(Cr+"\\:")+"{4}"+bi),Do=r(r(r(Cr+"\\:")+"{0,1}"+Cr)+"?\\:\\:"+r(Cr+"\\:")+"{3}"+bi),Ga=r(r(r(Cr+"\\:")+"{0,2}"+Cr)+"?\\:\\:"+r(Cr+"\\:")+"{2}"+bi),Jh=r(r(r(Cr+"\\:")+"{0,3}"+Cr)+"?\\:\\:"+Cr+"\\:"+bi),Yh=r(r(r(Cr+"\\:")+"{0,4}"+Cr)+"?\\:\\:"+bi),Fu=r(r(r(Cr+"\\:")+"{0,5}"+Cr)+"?\\:\\:"+Cr),hv=r(r(r(Cr+"\\:")+"{0,6}"+Cr)+"?\\:\\:"),sf=r([Di,oo,Ks,Do,Ga,Jh,Yh,Fu,hv].join("|")),pv=r(r(ar+"|"+Tr)+"+"),ck=r(sf+"\\%25"+pv),yy=r(sf+r("\\%25|\\%(?!"+$e+"{2})")+pv),G0e=r("[vV]"+$e+"+\\."+e(ar,ut,"[\\:]")+"+"),J0e=r("\\["+r(yy+"|"+sf+"|"+G0e)+"\\]"),BL=r(r(Tr+"|"+e(ar,ut))+"*"),a2=r(J0e+"|"+Mi+"(?!"+BL+")|"+BL),c2=r(re+"*"),ML=r(r(Br+"@")+"?"+a2+r("\\:"+c2)+"?"),d2=r(Tr+"|"+e(ar,ut,"[\\:\\@]")),Y0e=r(d2+"*"),DL=r(d2+"+"),Z0e=r(r(Tr+"|"+e(ar,ut,"[\\@]"))+"+"),af=r(r("\\/"+Y0e)+"*"),mv=r("\\/"+r(DL+af)+"?"),dk=r(Z0e+af),$3=r(DL+af),yv="(?!"+d2+")",VYe=r(af+"|"+mv+"|"+dk+"|"+$3+"|"+yv),gv=r(r(d2+"|"+e("[\\/\\?]",Wr))+"*"),u2=r(r(d2+"|[\\/\\?]")+"*"),OL=r(r("\\/\\/"+ML+af)+"|"+mv+"|"+$3+"|"+yv),X0e=r(Zr+"\\:"+OL+r("\\?"+gv)+"?"+r("\\#"+u2)+"?"),Q0e=r(r("\\/\\/"+ML+af)+"|"+mv+"|"+dk+"|"+yv),ege=r(Q0e+r("\\?"+gv)+"?"+r("\\#"+u2)+"?"),HYe=r(X0e+"|"+ege),WYe=r(Zr+"\\:"+OL+r("\\?"+gv)+"?"),GYe="^("+Zr+")\\:"+r(r("\\/\\/("+r("("+Br+")@")+"?("+a2+")"+r("\\:("+c2+")")+"?)")+"?("+af+"|"+mv+"|"+$3+"|"+yv+")")+r("\\?("+gv+")")+"?"+r("\\#("+u2+")")+"?$",JYe="^(){0}"+r(r("\\/\\/("+r("("+Br+")@")+"?("+a2+")"+r("\\:("+c2+")")+"?)")+"?("+af+"|"+mv+"|"+dk+"|"+yv+")")+r("\\?("+gv+")")+"?"+r("\\#("+u2+")")+"?$",YYe="^("+Zr+")\\:"+r(r("\\/\\/("+r("("+Br+")@")+"?("+a2+")"+r("\\:("+c2+")")+"?)")+"?("+af+"|"+mv+"|"+$3+"|"+yv+")")+r("\\?("+gv+")")+"?$",ZYe="^"+r("\\#("+u2+")")+"?$",XYe="^"+r("("+Br+")@")+"?("+a2+")"+r("\\:("+c2+")")+"?$";return{NOT_SCHEME:new RegExp(e("[^]",Y,re,"[\\+\\-\\.]"),"g"),NOT_USERINFO:new RegExp(e("[^\\%\\:]",ar,ut),"g"),NOT_HOST:new RegExp(e("[^\\%\\[\\]\\:]",ar,ut),"g"),NOT_PATH:new RegExp(e("[^\\%\\/\\:\\@]",ar,ut),"g"),NOT_PATH_NOSCHEME:new RegExp(e("[^\\%\\/\\@]",ar,ut),"g"),NOT_QUERY:new RegExp(e("[^\\%]",ar,ut,"[\\:\\@\\/\\?]",Wr),"g"),NOT_FRAGMENT:new RegExp(e("[^\\%]",ar,ut,"[\\:\\@\\/\\?]"),"g"),ESCAPE:new RegExp(e("[^]",ar,ut),"g"),UNRESERVED:new RegExp(ar,"g"),OTHER_CHARS:new RegExp(e("[^\\%]",ar,Yr),"g"),PCT_ENCODED:new RegExp(Tr,"g"),IPV4ADDRESS:new RegExp("^("+Mi+")$"),IPV6ADDRESS:new RegExp("^\\[?("+sf+")"+r(r("\\%25|\\%(?!"+$e+"{2})")+"("+pv+")")+"?\\]?$")}}var d=a(!1),u=a(!0),c=function(){function Q(Y,te){var re=[],ie=!0,$e=!1,Pe=void 0;try{for(var Ne=Y[Symbol.iterator](),Tr;!(ie=(Tr=Ne.next()).done)&&(re.push(Tr.value),!(te&&re.length===te));ie=!0);}catch(Ut){$e=!0,Pe=Ut}finally{try{!ie&&Ne.return&&Ne.return()}finally{if($e)throw Pe}}return re}return function(Y,te){if(Array.isArray(Y))return Y;if(Symbol.iterator in Object(Y))return Q(Y,te);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),l=function(Q){if(Array.isArray(Q)){for(var Y=0,te=Array(Q.length);Y<Q.length;Y++)te[Y]=Q[Y];return te}else return Array.from(Q)},m=2147483647,p=36,g=1,v=26,E=38,A=700,P=72,I=128,$="-",N=/^xn--/,K=/[^\0-\x7E]/,F=/[\x2E\u3002\uFF0E\uFF61]/g,U={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},V=p-g,L=Math.floor,T=String.fromCharCode;function S(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<re;){var ie=Q.charCodeAt(te++);if(ie>=55296&&ie<=56319&&te<re){var $e=Q.charCodeAt(te++);($e&64512)==56320?Y.push(((ie&1023)<<10)+($e&1023)+65536):(Y.push(ie),te--)}else Y.push(ie)}return Y}var w=function(Y){return String.fromCodePoint.apply(String,l(Y))},_=function(Y){return Y-48<10?Y-22:Y-65<26?Y-65:Y-97<26?Y-97:p},x=function(Y,te){return Y+22+75*(Y<26)-((te!=0)<<5)},b=function(Y,te,re){var ie=0;for(Y=re?L(Y/A):Y>>1,Y+=L(Y/te);Y>V*v>>1;ie+=p)Y=L(Y/V);return L(ie+(V+1)*Y/(Y+E))},B=function(Y){var te=[],re=Y.length,ie=0,$e=I,Pe=P,Ne=Y.lastIndexOf($);Ne<0&&(Ne=0);for(var Tr=0;Tr<Ne;++Tr)Y.charCodeAt(Tr)>=128&&S("not-basic"),te.push(Y.charCodeAt(Tr));for(var Ut=Ne>0?Ne+1:0;Ut<re;){for(var ut=ie,Yr=1,cn=p;;cn+=p){Ut>=re&&S("invalid-input");var Wr=_(Y.charCodeAt(Ut++));(Wr>=p||Wr>L((m-ie)/Yr))&&S("overflow"),ie+=Wr*Yr;var ar=cn<=Pe?g:cn>=Pe+v?v:cn-Pe;if(Wr<ar)break;var Zr=p-ar;Yr>L(m/Zr)&&S("overflow"),Yr*=Zr}var Br=te.length+1;Pe=b(ie-ut,Br,ut==0),L(ie/Br)>m-$e&&S("overflow"),$e+=L(ie/Br),ie%=Br,te.splice(ie++,0,$e)}return String.fromCodePoint.apply(String,te)},q=function(Y){var te=[];Y=y(Y);var re=Y.length,ie=I,$e=0,Pe=P,Ne=!0,Tr=!1,Ut=void 0;try{for(var ut=Y[Symbol.iterator](),Yr;!(Ne=(Yr=ut.next()).done);Ne=!0){var cn=Yr.value;cn<128&&te.push(T(cn))}}catch(yy){Tr=!0,Ut=yy}finally{try{!Ne&&ut.return&&ut.return()}finally{if(Tr)throw Ut}}var Wr=te.length,ar=Wr;for(Wr&&te.push($);ar<re;){var Zr=m,Br=!0,Ls=!1,vi=void 0;try{for(var Mi=Y[Symbol.iterator](),Cr;!(Br=(Cr=Mi.next()).done);Br=!0){var bi=Cr.value;bi>=ie&&bi<Zr&&(Zr=bi)}}catch(yy){Ls=!0,vi=yy}finally{try{!Br&&Mi.return&&Mi.return()}finally{if(Ls)throw vi}}var Di=ar+1;Zr-ie>L((m-$e)/Di)&&S("overflow"),$e+=(Zr-ie)*Di,ie=Zr;var oo=!0,Ks=!1,Do=void 0;try{for(var Ga=Y[Symbol.iterator](),Jh;!(oo=(Jh=Ga.next()).done);oo=!0){var Yh=Jh.value;if(Yh<ie&&++$e>m&&S("overflow"),Yh==ie){for(var Fu=$e,hv=p;;hv+=p){var sf=hv<=Pe?g:hv>=Pe+v?v:hv-Pe;if(Fu<sf)break;var pv=Fu-sf,ck=p-sf;te.push(T(x(sf+pv%ck,0))),Fu=L(pv/ck)}te.push(T(x(Fu,0))),Pe=b($e,Di,ar==Wr),$e=0,++ar}}}catch(yy){Ks=!0,Do=yy}finally{try{!oo&&Ga.return&&Ga.return()}finally{if(Ks)throw Do}}++$e,++ie}return te.join("")},M=function(Y){return f(Y,function(te){return N.test(te)?B(te.slice(4).toLowerCase()):te})},j=function(Y){return f(Y,function(te){return K.test(te)?"xn--"+q(te):te})},J={version:"2.1.0",ucs2:{decode:y,encode:w},decode:B,encode:q,toASCII:j,toUnicode:M},Z={};function G(Q){var Y=Q.charCodeAt(0),te=void 0;return Y<16?te="%0"+Y.toString(16).toUpperCase():Y<128?te="%"+Y.toString(16).toUpperCase():Y<2048?te="%"+(Y>>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 W(Q){for(var Y="",te=0,re=Q.length;te<re;){var ie=parseInt(Q.substr(te+1,2),16);if(ie<128)Y+=String.fromCharCode(ie),te+=3;else if(ie>=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 Pe=parseInt(Q.substr(te+4,2),16),Ne=parseInt(Q.substr(te+7,2),16);Y+=String.fromCharCode((ie&15)<<12|(Pe&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=W(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,G).replace(Y.PCT_ENCODED,i)),Q.host!==void 0&&(Q.host=String(Q.host).replace(Y.PCT_ENCODED,te).toLowerCase().replace(Y.NOT_HOST,G).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,G).replace(Y.PCT_ENCODED,i)),Q.query!==void 0&&(Q.query=String(Q.query).replace(Y.PCT_ENCODED,te).replace(Y.NOT_QUERY,G).replace(Y.PCT_ENCODED,i)),Q.fragment!==void 0&&(Q.fragment=String(Q.fragment).replace(Y.PCT_ENCODED,te).replace(Y.NOT_FRAGMENT,G).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 Pe=ie.toLowerCase().split("::").reverse(),Ne=c(Pe,2),Tr=Ne[0],Ut=Ne[1],ut=Ut?Ut.split(":").map(ee):[],Yr=Tr.split(":").map(ee),cn=Y.IPV4ADDRESS.test(Yr[Yr.length-1]),Wr=cn?7:8,ar=Yr.length-Wr,Zr=Array(Wr),Br=0;Br<Wr;++Br)Zr[Br]=ut[Br]||Yr[ar+Br]||"";cn&&(Zr[Wr-1]=ue(Zr[Wr-1],Y));var Ls=Zr.reduce(function(Di,oo,Ks){if(!oo||oo==="0"){var Do=Di[Di.length-1];Do&&Do.index+Do.length===Ks?Do.length++:Di.push({index:Ks,length:1})}return Di},[]),vi=Ls.sort(function(Di,oo){return oo.length-Di.length})[0],Mi=void 0;if(vi&&vi.length>1){var Cr=Zr.slice(0,vi.index),bi=Zr.slice(vi.index+vi.length);Mi=Cr.join(":")+"::"+bi.join(":")}else Mi=Zr.join(":");return $e&&(Mi+="%"+$e),Mi}else return Q}var ce=/^(?:([^:\/?#]+):)?(?:\/\/((?:([^\/?#@]*)@)?(\[[^\/?#\]]+\]|[^\/?#:]*)(?:\:(\d*))?))?([^?#]*)(?:\?([^#]*))?(?:#((?:.|\n|\r)*))?/i,pe="".match(/(){0}/)[1]===void 0;function xe(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,W).toLowerCase())}catch(Pe){te.error=te.error||"Host's domain name can not be converted to ASCII via punycode: "+Pe}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,Pe){return"["+$e+(Pe?"%25"+Pe:"")+"]"})),(typeof Q.port=="number"||typeof Q.port=="string")&&(re.push(":"),re.push(String(Q.port))),re.length?re.join(""):void 0}var le=/^\.\.?\//,ge=/^\/\.(\/|$)/,be=/^\/\.\.(\/|$)/,De=/^\/?(?:.|\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(be))Q=Q.replace(be,"/"),Y.pop();else if(Q==="."||Q==="..")Q="";else{var te=Q.match(De);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,W).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 Pe=Q.path;!Y.absolutePath&&(!ie||!ie.absolutePath)&&(Pe=Ie(Pe)),$e===void 0&&(Pe=Pe.replace(/^\/\//,"/%2F")),re.push(Pe)}return Q.query!==void 0&&(re.push("?"),re.push(Q.query)),Q.fragment!==void 0&&(re.push("#"),re.push(Q.fragment)),re.join("")}function vt(Q,Y){var te=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},re=arguments[3],ie={};return re||(Q=xe(je(Q,te),te),Y=xe(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 Ae(Q,Y,te){var re=s({scheme:"null"},te);return je(vt(xe(Q,re),xe(Y,re),re,!0),re)}function Re(Q,Y){return typeof Q=="string"?Q=je(xe(Q,Y),Y):n(Q)==="object"&&(Q=xe(je(Q,Y),Y)),Q}function kt(Q,Y,te){return typeof Q=="string"?Q=je(xe(Q,te),te):n(Q)==="object"&&(Q=je(Q,te)),typeof Y=="string"?Y=je(xe(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,G)}function Ee(Q,Y){return Q&&Q.toString().replace(!Y||!Y.iri?d.PCT_ENCODED:u.PCT_ENCODED,W)}var Kr={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:Kr.domainHost,parse:Kr.parse,serialize:Kr.serialize};function We(Q){return typeof Q.secure=="boolean"?Q.secure:String(Q.scheme).toLowerCase()==="wss"}var qs={scheme:"ws",domainHost:!0,parse:function(Y,te){var re=Y;return re.secure=We(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===(We(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],Pe=ie[1];Y.path=$e&&$e!=="/"?$e:void 0,Y.query=Pe,Y.resourceName=void 0}return Y.fragment=void 0,Y}},ht={scheme:"wss",domainHost:qs.domainHost,parse:qs.parse,serialize:qs.serialize},Bt={},gi=!0,Tt="[A-Za-z0-9\\-\\.\\_\\~"+(gi?"\\xA0-\\u200D\\u2010-\\u2029\\u202F-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF":"")+"]",Ze="[0-9A-Fa-f]",$c=r(r("%[EFef]"+Ze+"%"+Ze+Ze+"%"+Ze+Ze)+"|"+r("%[89A-Fa-f]"+Ze+"%"+Ze+Ze)+"|"+r("%"+Ze+Ze)),It="[A-Za-z0-9\\!\\$\\%\\'\\*\\+\\-\\^\\_\\`\\{\\|\\}\\~]",Nt="[\\!\\$\\%\\'\\(\\)\\*\\+\\,\\-\\.0-9\\<\\>A-Z\\x5E-\\x7E]",hy=e(Nt,'[\\"\\\\]'),Ot="[\\!\\$\\'\\(\\)\\*\\+\\,\\;\\:\\@]",Wt=new RegExp(Tt,"g"),Nc=new RegExp($c,"g"),Gt=new RegExp(e("[^]",It,"[\\.]",'[\\"]',hy),"g"),Ft=new RegExp(e("[^]",Tt,Ot),"g"),py=Ft;function jt(Q){var Y=W(Q);return Y.match(Wt)?Y:Q}var zt={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,Pe={},Ne=re.query.split("&"),Tr=0,Ut=Ne.length;Tr<Ut;++Tr){var ut=Ne[Tr].split("=");switch(ut[0]){case"to":for(var Yr=ut[1].split(","),cn=0,Wr=Yr.length;cn<Wr;++cn)ie.push(Yr[cn]);break;case"subject":re.subject=Ee(ut[1],te);break;case"body":re.body=Ee(ut[1],te);break;default:$e=!0,Pe[Ee(ut[0],te)]=Ee(ut[1],te);break}}$e&&(re.headers=Pe)}re.query=void 0;for(var ar=0,Zr=ie.length;ar<Zr;++ar){var Br=ie[ar].split("@");if(Br[0]=Ee(Br[0]),te.unicodeSupport)Br[1]=Ee(Br[1],te).toLowerCase();else try{Br[1]=J.toASCII(Ee(Br[1],te).toLowerCase())}catch(Ls){re.error=re.error||"Email address's domain name can not be converted to ASCII via punycode: "+Ls}ie[ar]=Br.join("@")}return re},serialize:function(Y,te){var re=Y,ie=o(Y.to);if(ie){for(var $e=0,Pe=ie.length;$e<Pe;++$e){var Ne=String(ie[$e]),Tr=Ne.lastIndexOf("@"),Ut=Ne.slice(0,Tr).replace(Nc,jt).replace(Nc,i).replace(Gt,G),ut=Ne.slice(Tr+1);try{ut=te.iri?J.toUnicode(ut):J.toASCII(Ee(ut,te).toLowerCase())}catch(ar){re.error=re.error||"Email address's domain name can not be converted to "+(te.iri?"Unicode":"ASCII")+" via punycode: "+ar}ie[$e]=Ut+"@"+ut}re.path=ie.join(",")}var Yr=Y.headers=Y.headers||{};Y.subject&&(Yr.subject=Y.subject),Y.body&&(Yr.body=Y.body);var cn=[];for(var Wr in Yr)Yr[Wr]!==Bt[Wr]&&cn.push(Wr.replace(Nc,jt).replace(Nc,i).replace(Ft,G)+"="+Yr[Wr].replace(Nc,jt).replace(Nc,i).replace(py,G));return cn.length&&(re.query=cn.join("&")),re}},my=/^([^\:]+)\:(.*)/,Vt={scheme:"urn",parse:function(Y,te){var re=Y.path&&Y.path.match(my),ie=Y;if(re){var $e=te.scheme||ie.scheme||"urn",Pe=re[1].toLowerCase(),Ne=re[2],Tr=$e+":"+(te.nid||Pe),Ut=Z[Tr];ie.nid=Pe,ie.nss=Ne,ie.path=void 0,Ut&&(ie=Ut.parse(ie,te))}else ie.error=ie.error||"URN can not be parsed.";return ie},serialize:function(Y,te){var re=te.scheme||Y.scheme||"urn",ie=Y.nid,$e=re+":"+(te.nid||ie),Pe=Z[$e];Pe&&(Y=Pe.serialize(Y,te));var Ne=Y,Tr=Y.nss;return Ne.path=(ie||te.nid)+":"+Tr,Ne}},Jt=/^[0-9A-Fa-f]{8}(?:\-[0-9A-Fa-f]{4}){3}\-[0-9A-Fa-f]{12}$/,Gh={scheme:"urn:uuid",parse:function(Y,te){var re=Y;return re.uuid=re.nss,re.nss=void 0,!te.tolerant&&(!re.uuid||!re.uuid.match(Jt))&&(re.error=re.error||"UUID is not valid."),re},serialize:function(Y,te){var re=Y;return re.nss=(Y.uuid||"").toLowerCase(),re}};Z[Kr.scheme]=Kr,Z[Fe.scheme]=Fe,Z[qs.scheme]=qs,Z[ht.scheme]=ht,Z[zt.scheme]=zt,Z[Vt.scheme]=Vt,Z[Gh.scheme]=Gh,t.SCHEMES=Z,t.pctEncChar=G,t.pctDecChars=W,t.parse=xe,t.removeDotSegments=Ie,t.serialize=je,t.resolveComponents=vt,t.resolve=Ae,t.normalize=Re,t.equal=kt,t.escapeComponent=we,t.unescapeComponent=Ee,Object.defineProperty(t,"__esModule",{value:!0})})});var nG=H((wat,rG)=>{"use strict";h();rG.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 h0=H((_dt,VG)=>{h();var _b=1e3,xb=_b*60,Eb=xb*60,f0=Eb*24,aSe=f0*7,cSe=f0*365.25;VG.exports=function(t,e){e=e||{};var r=typeof t;if(r==="string"&&t.length>0)return dSe(t);if(r==="number"&&isFinite(t))return e.long?lSe(t):uSe(t);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(t))};function dSe(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*cSe;case"weeks":case"week":case"w":return r*aSe;case"days":case"day":case"d":return r*f0;case"hours":case"hour":case"hrs":case"hr":case"h":return r*Eb;case"minutes":case"minute":case"mins":case"min":case"m":return r*xb;case"seconds":case"second":case"secs":case"sec":case"s":return r*_b;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}}}function uSe(t){var e=Math.abs(t);return e>=f0?Math.round(t/f0)+"d":e>=Eb?Math.round(t/Eb)+"h":e>=xb?Math.round(t/xb)+"m":e>=_b?Math.round(t/_b)+"s":t+"ms"}function lSe(t){var e=Math.abs(t);return e>=f0?X5(t,e,f0,"day"):e>=Eb?X5(t,e,Eb,"hour"):e>=xb?X5(t,e,xb,"minute"):e>=_b?X5(t,e,_b,"second"):t+" ms"}function X5(t,e,r,n){var i=e>=r*1.5;return Math.round(t/r)+" "+n+(i?"s":"")}});var gB=H(HG=>{h();HG.Level=$9().BrowserLevel});var XG=H((Zdt,ZG)=>{h();var hSe=typeof globalThis=="object"&&globalThis&&globalThis.Object===Object&&globalThis;ZG.exports=hSe});var eJ=H((Qdt,QG)=>{h();var pSe=XG(),mSe=typeof self=="object"&&self&&self.Object===Object&&self,ySe=pSe||mSe||Function("return this")();QG.exports=ySe});var vB=H((tut,tJ)=>{h();var gSe=eJ(),vSe=gSe.Symbol;tJ.exports=vSe});var oJ=H((nut,iJ)=>{h();var rJ=vB(),nJ=Object.prototype,bSe=nJ.hasOwnProperty,wSe=nJ.toString,N_=rJ?rJ.toStringTag:void 0;function _Se(t){var e=bSe.call(t,N_),r=t[N_];try{t[N_]=void 0;var n=!0}catch{}var i=wSe.call(t);return n&&(e?t[N_]=r:delete t[N_]),i}iJ.exports=_Se});var aJ=H((out,sJ)=>{h();var xSe=Object.prototype,ESe=xSe.toString;function SSe(t){return ESe.call(t)}sJ.exports=SSe});var lJ=H((aut,uJ)=>{h();var cJ=vB(),ASe=oJ(),TSe=aJ(),ISe="[object Null]",PSe="[object Undefined]",dJ=cJ?cJ.toStringTag:void 0;function kSe(t){return t==null?t===void 0?PSe:ISe:dJ&&dJ in Object(t)?ASe(t):TSe(t)}uJ.exports=kSe});var hJ=H((dut,fJ)=>{h();function RSe(t,e){return function(r){return t(e(r))}}fJ.exports=RSe});var mJ=H((lut,pJ)=>{h();var BSe=hJ(),MSe=BSe(Object.getPrototypeOf,Object);pJ.exports=MSe});var gJ=H((hut,yJ)=>{h();function DSe(t){return t!=null&&typeof t=="object"}yJ.exports=DSe});var wJ=H((mut,bJ)=>{h();var OSe=lJ(),CSe=mJ(),$Se=gJ(),NSe="[object Object]",jSe=Function.prototype,USe=Object.prototype,vJ=jSe.toString,qSe=USe.hasOwnProperty,LSe=vJ.call(Object);function KSe(t){if(!$Se(t)||OSe(t)!=NSe)return!1;var e=CSe(t);if(e===null)return!0;var r=qSe.call(e,"constructor")&&e.constructor;return typeof r=="function"&&r instanceof r&&vJ.call(r)==LSe}bJ.exports=KSe});var cc=H((mpt,sZ)=>{"use strict";h();function oZ(t,e){for(let r in e)Object.defineProperty(t,r,{value:e[r],enumerable:!0,configurable:!0});return t}function X8e(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 oZ(t,r)}catch{r.message=t.message,r.stack=t.stack;let i=function(){};return i.prototype=Object.create(Object.getPrototypeOf(t)),oZ(new i,r)}}sZ.exports=X8e});var lX=H((mx,k8)=>{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;g<p.length;g++)if(!Number.isInteger(p[g])||p[g]<0||p[g]>255)return!1;return!0}function i(p,g){return(p&65535)*g+(((p>>>16)*g&65535)<<16)}function o(p,g){return p<<g|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 v=[0,0,0,0];return v[3]+=p[3]+g[3],v[2]+=v[3]>>>16,v[3]&=65535,v[2]+=p[2]+g[2],v[1]+=v[2]>>>16,v[2]&=65535,v[1]+=p[1]+g[1],v[0]+=v[1]>>>16,v[1]&=65535,v[0]+=p[0]+g[0],v[0]&=65535,[v[0]<<16|v[1],v[2]<<16|v[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 v=[0,0,0,0];return v[3]+=p[3]*g[3],v[2]+=v[3]>>>16,v[3]&=65535,v[2]+=p[2]*g[3],v[1]+=v[2]>>>16,v[2]&=65535,v[2]+=p[3]*g[2],v[1]+=v[2]>>>16,v[2]&=65535,v[1]+=p[1]*g[3],v[0]+=v[1]>>>16,v[1]&=65535,v[1]+=p[2]*g[2],v[0]+=v[1]>>>16,v[1]&=65535,v[1]+=p[3]*g[1],v[0]+=v[1]>>>16,v[1]&=65535,v[0]+=p[0]*g[3]+p[1]*g[2]+p[2]*g[1]+p[3]*g[0],v[0]&=65535,[v[0]<<16|v[1],v[2]<<16|v[3]]}function u(p,g){return g%=64,g===32?[p[1],p[0]]:g<32?[p[0]<<g|p[1]>>>32-g,p[1]<<g|p[0]>>>32-g]:(g-=32,[p[1]<<g|p[0]>>>32-g,p[0]<<g|p[1]>>>32-g])}function c(p,g){return g%=64,g===0?p:g<32?[p[0]<<g|p[1]>>>32-g,p[1]<<g]:[p[1]<<g-32,0]}function l(p,g){return[p[0]^g[0],p[1]^g[1]]}function m(p){return p=l(p,[0,p[0]>>>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 v=p.length%4,E=p.length-v,A=g,P=0,I=3432918353,$=461845907,N=0;N<E;N=N+4)P=p[N]|p[N+1]<<8|p[N+2]<<16|p[N+3]<<24,P=i(P,I),P=o(P,15),P=i(P,$),A^=P,A=o(A,13),A=i(A,5)+3864292196;switch(P=0,v){case 3:P^=p[N+2]<<16;case 2:P^=p[N+1]<<8;case 1:P^=p[N],P=i(P,I),P=o(P,15),P=i(P,$),A^=P}return A^=p.length,A=s(A),A>>>0},r.x86.hash128=function(p,g){if(r.inputValidation&&!n(p))return e;g=g||0;for(var v=p.length%16,E=p.length-v,A=g,P=g,I=g,$=g,N=0,K=0,F=0,U=0,V=597399067,L=2869860233,T=951274213,S=2716044179,k=0;k<E;k=k+16)N=p[k]|p[k+1]<<8|p[k+2]<<16|p[k+3]<<24,K=p[k+4]|p[k+5]<<8|p[k+6]<<16|p[k+7]<<24,F=p[k+8]|p[k+9]<<8|p[k+10]<<16|p[k+11]<<24,U=p[k+12]|p[k+13]<<8|p[k+14]<<16|p[k+15]<<24,N=i(N,V),N=o(N,15),N=i(N,L),A^=N,A=o(A,19),A+=P,A=i(A,5)+1444728091,K=i(K,L),K=o(K,16),K=i(K,T),P^=K,P=o(P,17),P+=I,P=i(P,5)+197830471,F=i(F,T),F=o(F,17),F=i(F,S),I^=F,I=o(I,15),I+=$,I=i(I,5)+2530024501,U=i(U,S),U=o(U,18),U=i(U,V),$^=U,$=o($,13),$+=A,$=i($,5)+850148119;switch(N=0,K=0,F=0,U=0,v){case 15:U^=p[k+14]<<16;case 14:U^=p[k+13]<<8;case 13:U^=p[k+12],U=i(U,S),U=o(U,18),U=i(U,V),$^=U;case 12:F^=p[k+11]<<24;case 11:F^=p[k+10]<<16;case 10:F^=p[k+9]<<8;case 9:F^=p[k+8],F=i(F,T),F=o(F,17),F=i(F,S),I^=F;case 8:K^=p[k+7]<<24;case 7:K^=p[k+6]<<16;case 6:K^=p[k+5]<<8;case 5:K^=p[k+4],K=i(K,L),K=o(K,16),K=i(K,T),P^=K;case 4:N^=p[k+3]<<24;case 3:N^=p[k+2]<<16;case 2:N^=p[k+1]<<8;case 1:N^=p[k],N=i(N,V),N=o(N,15),N=i(N,L),A^=N}return A^=p.length,P^=p.length,I^=p.length,$^=p.length,A+=P,A+=I,A+=$,P+=A,I+=A,$+=A,A=s(A),P=s(P),I=s(I),$=s($),A+=P,A+=I,A+=$,P+=A,I+=A,$+=A,("00000000"+(A>>>0).toString(16)).slice(-8)+("00000000"+(P>>>0).toString(16)).slice(-8)+("00000000"+(I>>>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 v=p.length%16,E=p.length-v,A=[0,g],P=[0,g],I=[0,0],$=[0,0],N=[2277735313,289559509],K=[1291169091,658871167],F=0;F<E;F=F+16)I=[p[F+4]|p[F+5]<<8|p[F+6]<<16|p[F+7]<<24,p[F]|p[F+1]<<8|p[F+2]<<16|p[F+3]<<24],$=[p[F+12]|p[F+13]<<8|p[F+14]<<16|p[F+15]<<24,p[F+8]|p[F+9]<<8|p[F+10]<<16|p[F+11]<<24],I=d(I,N),I=u(I,31),I=d(I,K),A=l(A,I),A=u(A,27),A=a(A,P),A=a(d(A,[0,5]),[0,1390208809]),$=d($,K),$=u($,33),$=d($,N),P=l(P,$),P=u(P,31),P=a(P,A),P=a(d(P,[0,5]),[0,944331445]);switch(I=[0,0],$=[0,0],v){case 15:$=l($,c([0,p[F+14]],48));case 14:$=l($,c([0,p[F+13]],40));case 13:$=l($,c([0,p[F+12]],32));case 12:$=l($,c([0,p[F+11]],24));case 11:$=l($,c([0,p[F+10]],16));case 10:$=l($,c([0,p[F+9]],8));case 9:$=l($,[0,p[F+8]]),$=d($,K),$=u($,33),$=d($,N),P=l(P,$);case 8:I=l(I,c([0,p[F+7]],56));case 7:I=l(I,c([0,p[F+6]],48));case 6:I=l(I,c([0,p[F+5]],40));case 5:I=l(I,c([0,p[F+4]],32));case 4:I=l(I,c([0,p[F+3]],24));case 3:I=l(I,c([0,p[F+2]],16));case 2:I=l(I,c([0,p[F+1]],8));case 1:I=l(I,[0,p[F]]),I=d(I,N),I=u(I,31),I=d(I,K),A=l(A,I)}return A=l(A,[0,p.length]),P=l(P,[0,p.length]),A=a(A,P),P=a(P,A),A=m(A),P=m(P),A=a(A,P),P=a(P,A),("00000000"+(A[0]>>>0).toString(16)).slice(-8)+("00000000"+(A[1]>>>0).toString(16)).slice(-8)+("00000000"+(P[0]>>>0).toString(16)).slice(-8)+("00000000"+(P[1]>>>0).toString(16)).slice(-8)},typeof mx<"u"?(typeof k8<"u"&&k8.exports&&(mx=k8.exports=r),mx.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)})(mx)});var hX=H((Rgt,fX)=>{h();fX.exports=lX()});var yX=H((Ugt,mX)=>{"use strict";h();mX.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.length;)e(this.get(r),r,this),r++}map(e){let r=0,n=new Array(this.length);for(;r<this.length;)n[r]=e(this.get(r),r,this),r++;return n}reduce(e,r){let n=0,i=r;for(;n<this.length;){let o=this.get(n);i=e(i,o,n),n++}return i}find(e){let r=0,n,i;for(;r<this.length&&!n;)i=this.get(r),n=e(i),r++;return n?i:void 0}_internalPositionFor(e,r){let n=this._bytePosFor(e,r);if(n>=this._bitArrays.length)return-1;let i=this._bitArrays[n],o=e-n*7;if(!((i&1<<o)>0))return-1;let a=this._bitArrays.slice(0,n).reduce(WAe,0),d=~(4294967295<<o+1),u=pX(i&d);return a+u-1}_bytePosFor(e,r){let n=Math.floor(e/7),i=n+1;for(;!r&&this._bitArrays.length<i;)this._bitArrays.push(0);return n}_setBit(e){let r=this._bytePosFor(e,!1);this._bitArrays[r]|=1<<e-r*7}_unsetBit(e){let r=this._bytePosFor(e,!1);this._bitArrays[r]&=~(1<<e-r*7)}_setInternalPos(e,r,n,i){let o=this._data,s=[r,n];if(i)this._sortData(),o[e]=s;else{if(o.length)if(o[o.length-1][0]>=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(GAe),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),c=o&u;i|=c<<8-r,o=o>>>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(JAe)}};function WAe(t,e){return t+pX(e)}function pX(t){let e=t;return e=e-(e>>1&1431655765),e=(e&858993459)+(e>>2&858993459),(e+(e>>4)&252645135)*16843009>>24}function GAe(t,e){return t[0]-e[0]}function JAe(t){return t[1]}});var B0=H((jvt,VM)=>{"use strict";h();var zM=65536,cTe=4294967295;function dTe(){throw new Error(`Secure random number generation is not supported by this browser.
Use Chrome, Firefox or Internet Explorer 11`)}var uTe=dr().Buffer,C8=globalThis.crypto||globalThis.msCrypto;C8&&C8.getRandomValues?VM.exports=lTe:VM.exports=dTe;function lTe(t,e){if(t>cTe)throw new RangeError("requested too many random bytes");var r=uTe.allocUnsafe(t);if(t>0)if(t>zM)for(var n=0;n<t;n+=zM)C8.getRandomValues(r.slice(n,n+zM));else C8.getRandomValues(r);return typeof e=="function"?D.default.nextTick(function(){e(null,r)}):r}});var ur=H((qvt,HM)=>{h();typeof Object.create=="function"?HM.exports=function(e,r){r&&(e.super_=r,e.prototype=Object.create(r.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:HM.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 WM=H((Kvt,RX)=>{h();RX.exports=Ja().EventEmitter});var GM=H(()=>{h()});var $X=H((Wvt,CX)=>{"use strict";h();function BX(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 MX(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?BX(Object(r),!0).forEach(function(n){fTe(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):BX(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function fTe(t,e,r){return e=OX(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function hTe(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function DX(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,OX(n.key),n)}}function pTe(t,e,r){return e&&DX(t.prototype,e),r&&DX(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function OX(t){var e=mTe(t,"string");return typeof e=="symbol"?e:String(e)}function mTe(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 yTe=$n(),$8=yTe.Buffer,gTe=GM(),JM=gTe.inspect,vTe=JM&&JM.custom||"inspect";function bTe(t,e,r){$8.prototype.copy.call(t,e,r)}CX.exports=function(){function t(){hTe(this,t),this.head=null,this.tail=null,this.length=0}return pTe(t,[{key:"push",value:function(r){var n={data:r,next:null};this.length>0?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 $8.alloc(0);for(var n=$8.allocUnsafe(r>>>0),i=this.head,o=0;i;)bTe(i.data,n,o),o+=i.data.length,i=i.next;return n}},{key:"consume",value:function(r,n){var i;return r<this.head.data.length?(i=this.head.data.slice(0,r),this.head.data=this.head.data.slice(r)):r===this.head.data.length?i=this.shift():i=n?this._getString(r):this._getBuffer(r),i}},{key:"first",value:function(){return this.head.data}},{key:"_getString",value:function(r){var n=this.head,i=1,o=n.data;for(r-=o.length;n=n.next;){var s=n.data,a=r>s.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=$8.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:vTe,value:function(r,n){return JM(this,MX(MX({},n),{},{depth:0,customInspect:!1}))}}]),t}()});var ZM=H((Jvt,jX)=>{"use strict";h();function wTe(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,D.default.nextTick(YM,this,t)):D.default.nextTick(YM,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?D.default.nextTick(N8,r):(r._writableState.errorEmitted=!0,D.default.nextTick(NX,r,o)):D.default.nextTick(NX,r,o):e?(D.default.nextTick(N8,r),e(o)):D.default.nextTick(N8,r)}),this)}function NX(t,e){YM(t,e),N8(t)}function N8(t){t._writableState&&!t._writableState.emitClose||t._readableState&&!t._readableState.emitClose||t.emit("close")}function _Te(){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 YM(t,e){t.emit("error",e)}function xTe(t,e){var r=t._readableState,n=t._writableState;r&&r.autoDestroy||n&&n.autoDestroy?t.destroy(e):t.emit("error",e)}jX.exports={destroy:wTe,undestroy:_Te,errorOrDestroy:xTe}});var M0=H((Zvt,LX)=>{"use strict";h();function ETe(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}var qX={};function nd(t,e,r){r||(r=Error);function n(o,s,a){return typeof e=="string"?e:e(o,s,a)}var i=function(o){ETe(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,qX[t]=i}function UX(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 STe(t,e,r){return t.substr(!r||r<0?0:+r,e.length)===e}function ATe(t,e,r){return(r===void 0||r>t.length)&&(r=t.length),t.substring(r-e.length,r)===e}function TTe(t,e,r){return typeof r!="number"&&(r=0),r+e.length>t.length?!1:t.indexOf(e,r)!==-1}nd("ERR_INVALID_OPT_VALUE",function(t,e){return'The value "'+e+'" is invalid for option "'+t+'"'},TypeError);nd("ERR_INVALID_ARG_TYPE",function(t,e,r){var n;typeof e=="string"&&STe(e,"not ")?(n="must not be",e=e.replace(/^not /,"")):n="must be";var i;if(ATe(t," argument"))i="The ".concat(t," ").concat(n," ").concat(UX(e,"type"));else{var o=TTe(t,".")?"property":"argument";i='The "'.concat(t,'" ').concat(o," ").concat(n," ").concat(UX(e,"type"))}return i+=". Received type ".concat(typeof r),i},TypeError);nd("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF");nd("ERR_METHOD_NOT_IMPLEMENTED",function(t){return"The "+t+" method is not implemented"});nd("ERR_STREAM_PREMATURE_CLOSE","Premature close");nd("ERR_STREAM_DESTROYED",function(t){return"Cannot call "+t+" after a stream was destroyed"});nd("ERR_MULTIPLE_CALLBACK","Callback called multiple times");nd("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable");nd("ERR_STREAM_WRITE_AFTER_END","write after end");nd("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError);nd("ERR_UNKNOWN_ENCODING",function(t){return"Unknown encoding: "+t},TypeError);nd("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event");LX.exports.codes=qX});var XM=H((Qvt,KX)=>{"use strict";h();var ITe=M0().codes.ERR_INVALID_OPT_VALUE;function PTe(t,e,r){return t.highWaterMark!=null?t.highWaterMark:e?t[r]:null}function kTe(t,e,r,n){var i=PTe(e,n,r);if(i!=null){if(!(isFinite(i)&&Math.floor(i)===i)||i<0){var o=n?r:"highWaterMark";throw new ITe(o,i)}return Math.floor(i)}return t.objectMode?16:16*1024}KX.exports={getHighWaterMark:kTe}});var zX=H((tbt,FX)=>{h();FX.exports=RTe;function RTe(t,e){if(QM("noDeprecation"))return t;var r=!1;function n(){if(!r){if(QM("throwDeprecation"))throw new Error(e);QM("traceDeprecation")?console.trace(e):console.warn(e),r=!0}return t.apply(this,arguments)}return n}function QM(t){try{if(!globalThis.localStorage)return!1}catch{return!1}var e=globalThis.localStorage[t];return e==null?!1:String(e).toLowerCase()==="true"}});var q8=H((nbt,YX)=>{"use strict";h();YX.exports=di;function HX(t){var e=this;this.next=null,this.entry=null,this.finish=function(){nIe(e,t)}}var Wb;di.WritableState=vx;var BTe={deprecate:zX()},WX=WM(),U8=$n().Buffer,MTe=(typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function DTe(t){return U8.from(t)}function OTe(t){return U8.isBuffer(t)||t instanceof MTe}var tD=ZM(),CTe=XM(),$Te=CTe.getHighWaterMark,Gp=M0().codes,NTe=Gp.ERR_INVALID_ARG_TYPE,jTe=Gp.ERR_METHOD_NOT_IMPLEMENTED,UTe=Gp.ERR_MULTIPLE_CALLBACK,qTe=Gp.ERR_STREAM_CANNOT_PIPE,LTe=Gp.ERR_STREAM_DESTROYED,KTe=Gp.ERR_STREAM_NULL_VALUES,FTe=Gp.ERR_STREAM_WRITE_AFTER_END,zTe=Gp.ERR_UNKNOWN_ENCODING,Gb=tD.errorOrDestroy;ur()(di,WX);function VTe(){}function vx(t,e,r){Wb=Wb||Jp(),t=t||{},typeof r!="boolean"&&(r=e instanceof Wb),this.objectMode=!!t.objectMode,r&&(this.objectMode=this.objectMode||!!t.writableObjectMode),this.highWaterMark=$Te(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){XTe(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 HX(this)}vx.prototype.getBuffer=function(){for(var e=this.bufferedRequest,r=[];e;)r.push(e),e=e.next;return r};(function(){try{Object.defineProperty(vx.prototype,"buffer",{get:BTe.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch{}})();var j8;typeof Symbol=="function"&&Symbol.hasInstance&&typeof Function.prototype[Symbol.hasInstance]=="function"?(j8=Function.prototype[Symbol.hasInstance],Object.defineProperty(di,Symbol.hasInstance,{value:function(e){return j8.call(this,e)?!0:this!==di?!1:e&&e._writableState instanceof vx}})):j8=function(e){return e instanceof this};function di(t){Wb=Wb||Jp();var e=this instanceof Wb;if(!e&&!j8.call(di,this))return new di(t);this._writableState=new vx(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)),WX.call(this)}di.prototype.pipe=function(){Gb(this,new qTe)};function HTe(t,e){var r=new FTe;Gb(t,r),D.default.nextTick(e,r)}function WTe(t,e,r,n){var i;return r===null?i=new KTe:typeof r!="string"&&!e.objectMode&&(i=new NTe("chunk",["string","Buffer"],r)),i?(Gb(t,i),D.default.nextTick(n,i),!1):!0}di.prototype.write=function(t,e,r){var n=this._writableState,i=!1,o=!n.objectMode&&OTe(t);return o&&!U8.isBuffer(t)&&(t=DTe(t)),typeof e=="function"&&(r=e,e=null),o?e="buffer":e||(e=n.defaultEncoding),typeof r!="function"&&(r=VTe),n.ending?HTe(this,r):(o||WTe(this,n,t,r))&&(n.pendingcb++,i=JTe(this,n,o,t,e,r)),i};di.prototype.cork=function(){this._writableState.corked++};di.prototype.uncork=function(){var t=this._writableState;t.corked&&(t.corked--,!t.writing&&!t.corked&&!t.bufferProcessing&&t.bufferedRequest&&GX(this,t))};di.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 zTe(e);return this._writableState.defaultEncoding=e,this};Object.defineProperty(di.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}});function GTe(t,e,r){return!t.objectMode&&t.decodeStrings!==!1&&typeof e=="string"&&(e=U8.from(e,r)),e}Object.defineProperty(di.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function JTe(t,e,r,n,i,o){if(!r){var s=GTe(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<e.highWaterMark;if(d||(e.needDrain=!0),e.writing||e.corked){var u=e.lastBufferedRequest;e.lastBufferedRequest={chunk:n,encoding:i,isBuf:r,callback:o,next:null},u?u.next=e.lastBufferedRequest:e.bufferedRequest=e.lastBufferedRequest,e.bufferedRequestCount+=1}else eD(t,e,!1,a,n,i,o);return d}function eD(t,e,r,n,i,o,s){e.writelen=n,e.writecb=s,e.writing=!0,e.sync=!0,e.destroyed?e.onwrite(new LTe("write")):r?t._writev(i,e.onwrite):t._write(i,o,e.onwrite),e.sync=!1}function YTe(t,e,r,n,i){--e.pendingcb,r?(D.default.nextTick(i,n),D.default.nextTick(gx,t,e),t._writableState.errorEmitted=!0,Gb(t,n)):(i(n),t._writableState.errorEmitted=!0,Gb(t,n),gx(t,e))}function ZTe(t){t.writing=!1,t.writecb=null,t.length-=t.writelen,t.writelen=0}function XTe(t,e){var r=t._writableState,n=r.sync,i=r.writecb;if(typeof i!="function")throw new UTe;if(ZTe(r),e)YTe(t,r,n,e,i);else{var o=JX(r)||t.destroyed;!o&&!r.corked&&!r.bufferProcessing&&r.bufferedRequest&&GX(t,r),n?D.default.nextTick(VX,t,r,o,i):VX(t,r,o,i)}}function VX(t,e,r,n){r||QTe(t,e),e.pendingcb--,n(),gx(t,e)}function QTe(t,e){e.length===0&&e.needDrain&&(e.needDrain=!1,t.emit("drain"))}function GX(t,e){e.bufferProcessing=!0;var r=e.bufferedRequest;if(t._writev&&r&&r.next){var n=e.bufferedRequestCount,i=new Array(n),o=e.corkedRequestsFree;o.entry=r;for(var s=0,a=!0;r;)i[s]=r,r.isBuf||(a=!1),r=r.next,s+=1;i.allBuffers=a,eD(t,e,!0,e.length,i,"",o.finish),e.pendingcb++,e.lastBufferedRequest=null,o.next?(e.corkedRequestsFree=o.next,o.next=null):e.corkedRequestsFree=new HX(e),e.bufferedRequestCount=0}else{for(;r;){var d=r.chunk,u=r.encoding,c=r.callback,l=e.objectMode?1:d.length;if(eD(t,e,!1,l,d,u,c),r=r.next,e.bufferedRequestCount--,e.writing)break}r===null&&(e.lastBufferedRequest=null)}e.bufferedRequest=r,e.bufferProcessing=!1}di.prototype._write=function(t,e,r){r(new jTe("_write()"))};di.prototype._writev=null;di.prototype.end=function(t,e,r){var n=this._writableState;return typeof t=="function"?(r=t,t=null,e=null):typeof e=="function"&&(r=e,e=null),t!=null&&this.write(t,e),n.corked&&(n.corked=1,this.uncork()),n.ending||rIe(this,n,r),this};Object.defineProperty(di.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}});function JX(t){return t.ending&&t.length===0&&t.bufferedRequest===null&&!t.finished&&!t.writing}function eIe(t,e){t._final(function(r){e.pendingcb--,r&&Gb(t,r),e.prefinished=!0,t.emit("prefinish"),gx(t,e)})}function tIe(t,e){!e.prefinished&&!e.finalCalled&&(typeof t._final=="function"&&!e.destroyed?(e.pendingcb++,e.finalCalled=!0,D.default.nextTick(eIe,t,e)):(e.prefinished=!0,t.emit("prefinish")))}function gx(t,e){var r=JX(e);if(r&&(tIe(t,e),e.pendingcb===0&&(e.finished=!0,t.emit("finish"),e.autoDestroy))){var n=t._readableState;(!n||n.autoDestroy&&n.endEmitted)&&t.destroy()}return r}function rIe(t,e,r){e.ending=!0,gx(t,e),r&&(e.finished?D.default.nextTick(r):t.once("finish",r)),e.ended=!0,t.writable=!1}function nIe(t,e,r){var n=t.entry;for(t.entry=null;n;){var i=n.callback;e.pendingcb--,i(r),n=n.next}e.corkedRequestsFree.next=t}Object.defineProperty(di.prototype,"destroyed",{enumerable:!1,get:function(){return this._writableState===void 0?!1:this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}});di.prototype.destroy=tD.destroy;di.prototype._undestroy=tD.undestroy;di.prototype._destroy=function(t,e){e(t)}});var Jp=H((obt,XX)=>{"use strict";h();var iIe=Object.keys||function(t){var e=[];for(var r in t)e.push(r);return e};XX.exports=_l;var ZX=F8(),nD=q8();ur()(_l,ZX);for(rD=iIe(nD.prototype),L8=0;L8<rD.length;L8++)K8=rD[L8],_l.prototype[K8]||(_l.prototype[K8]=nD.prototype[K8]);var rD,K8,L8;function _l(t){if(!(this instanceof _l))return new _l(t);ZX.call(this,t),nD.call(this,t),this.allowHalfOpen=!0,t&&(t.readable===!1&&(this.readable=!1),t.writable===!1&&(this.writable=!1),t.allowHalfOpen===!1&&(this.allowHalfOpen=!1,this.once("end",oIe)))}Object.defineProperty(_l.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});Object.defineProperty(_l.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}});Object.defineProperty(_l.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}});function oIe(){this._writableState.ended||D.default.nextTick(sIe,this)}function sIe(t){t.end()}Object.defineProperty(_l.prototype,"destroyed",{enumerable:!1,get:function(){return this._readableState===void 0||this._writableState===void 0?!1:this._readableState.destroyed&&this._writableState.destroyed},set:function(e){this._readableState===void 0||this._writableState===void 0||(this._readableState.destroyed=e,this._writableState.destroyed=e)}})});var bx=H((abt,tQ)=>{"use strict";h();var QX=M0().codes.ERR_STREAM_PREMATURE_CLOSE;function aIe(t){var e=!1;return function(){if(!e){e=!0;for(var r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];t.apply(this,n)}}}function cIe(){}function dIe(t){return t.setHeader&&typeof t.abort=="function"}function eQ(t,e,r){if(typeof e=="function")return eQ(t,null,e);e||(e={}),r=aIe(r||cIe);var n=e.readable||e.readable!==!1&&t.readable,i=e.writable||e.writable!==!1&&t.writable,o=function(){t.writable||a()},s=t._writableState&&t._writableState.finished,a=function(){i=!1,s=!0,n||r.call(t)},d=t._readableState&&t._readableState.endEmitted,u=function(){n=!1,d=!0,i||r.call(t)},c=function(g){r.call(t,g)},l=function(){var g;if(n&&!d)return(!t._readableState||!t._readableState.ended)&&(g=new QX),r.call(t,g);if(i&&!s)return(!t._writableState||!t._writableState.ended)&&(g=new QX),r.call(t,g)},m=function(){t.req.on("finish",a)};return dIe(t)?(t.on("complete",a),t.on("abort",l),t.req?m():t.on("request",m)):i&&!t._writableState&&(t.on("end",o),t.on("close",o)),t.on("end",u),t.on("finish",a),e.error!==!1&&t.on("error",c),t.on("close",l),function(){t.removeListener("complete",a),t.removeListener("abort",l),t.removeListener("request",m),t.req&&t.req.removeListener("finish",a),t.removeListener("end",o),t.removeListener("close",o),t.removeListener("finish",a),t.removeListener("end",u),t.removeListener("error",c),t.removeListener("close",l)}}tQ.exports=eQ});var nQ=H((dbt,rQ)=>{"use strict";h();var z8;function Yp(t,e,r){return e=uIe(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function uIe(t){var e=lIe(t,"string");return typeof e=="symbol"?e:String(e)}function lIe(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 fIe=bx(),Zp=Symbol("lastResolve"),D0=Symbol("lastReject"),wx=Symbol("error"),V8=Symbol("ended"),O0=Symbol("lastPromise"),iD=Symbol("handlePromise"),C0=Symbol("stream");function Xp(t,e){return{value:t,done:e}}function hIe(t){var e=t[Zp];if(e!==null){var r=t[C0].read();r!==null&&(t[O0]=null,t[Zp]=null,t[D0]=null,e(Xp(r,!1)))}}function pIe(t){D.default.nextTick(hIe,t)}function mIe(t,e){return function(r,n){t.then(function(){if(e[V8]){r(Xp(void 0,!0));return}e[iD](r,n)},n)}}var yIe=Object.getPrototypeOf(function(){}),gIe=Object.setPrototypeOf((z8={get stream(){return this[C0]},next:function(){var e=this,r=this[wx];if(r!==null)return Promise.reject(r);if(this[V8])return Promise.resolve(Xp(void 0,!0));if(this[C0].destroyed)return new Promise(function(s,a){D.default.nextTick(function(){e[wx]?a(e[wx]):s(Xp(void 0,!0))})});var n=this[O0],i;if(n)i=new Promise(mIe(n,this));else{var o=this[C0].read();if(o!==null)return Promise.resolve(Xp(o,!1));i=new Promise(this[iD])}return this[O0]=i,i}},Yp(z8,Symbol.asyncIterator,function(){return this}),Yp(z8,"return",function(){var e=this;return new Promise(function(r,n){e[C0].destroy(null,function(i){if(i){n(i);return}r(Xp(void 0,!0))})})}),z8),yIe),vIe=function(e){var r,n=Object.create(gIe,(r={},Yp(r,C0,{value:e,writable:!0}),Yp(r,Zp,{value:null,writable:!0}),Yp(r,D0,{value:null,writable:!0}),Yp(r,wx,{value:null,writable:!0}),Yp(r,V8,{value:e._readableState.endEmitted,writable:!0}),Yp(r,iD,{value:function(o,s){var a=n[C0].read();a?(n[O0]=null,n[Zp]=null,n[D0]=null,o(Xp(a,!1))):(n[Zp]=o,n[D0]=s)},writable:!0}),r));return n[O0]=null,fIe(e,function(i){if(i&&i.code!=="ERR_STREAM_PREMATURE_CLOSE"){var o=n[D0];o!==null&&(n[O0]=null,n[Zp]=null,n[D0]=null,o(i)),n[wx]=i;return}var s=n[Zp];s!==null&&(n[O0]=null,n[Zp]=null,n[D0]=null,s(Xp(void 0,!0))),n[V8]=!0}),e.on("readable",pIe.bind(null,n)),n};rQ.exports=vIe});var oQ=H((lbt,iQ)=>{h();iQ.exports=function(){throw new Error("Readable.from is not available in the browser")}});var F8=H((pbt,mQ)=>{"use strict";h();mQ.exports=zr;var Jb;zr.ReadableState=dQ;var hbt=Ja().EventEmitter,cQ=function(e,r){return e.listeners(r).length},xx=WM(),H8=$n().Buffer,bIe=(typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function wIe(t){return H8.from(t)}function _Ie(t){return H8.isBuffer(t)||t instanceof bIe}var oD=GM(),Er;oD&&oD.debuglog?Er=oD.debuglog("stream"):Er=function(){};var xIe=$X(),fD=ZM(),EIe=XM(),SIe=EIe.getHighWaterMark,W8=M0().codes,AIe=W8.ERR_INVALID_ARG_TYPE,TIe=W8.ERR_STREAM_PUSH_AFTER_EOF,IIe=W8.ERR_METHOD_NOT_IMPLEMENTED,PIe=W8.ERR_STREAM_UNSHIFT_AFTER_END_EVENT,Yb,sD,aD;ur()(zr,xx);var _x=fD.errorOrDestroy,cD=["error","close","destroy","pause","resume"];function kIe(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 dQ(t,e,r){Jb=Jb||Jp(),t=t||{},typeof r!="boolean"&&(r=e instanceof Jb),this.objectMode=!!t.objectMode,r&&(this.objectMode=this.objectMode||!!t.readableObjectMode),this.highWaterMark=SIe(this,t,"readableHighWaterMark",r),this.buffer=new xIe,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&&(Yb||(Yb=Uv().StringDecoder),this.decoder=new Yb(t.encoding),this.encoding=t.encoding)}function zr(t){if(Jb=Jb||Jp(),!(this instanceof zr))return new zr(t);var e=this instanceof Jb;this._readableState=new dQ(t,this,e),this.readable=!0,t&&(typeof t.read=="function"&&(this._read=t.read),typeof t.destroy=="function"&&(this._destroy=t.destroy)),xx.call(this)}Object.defineProperty(zr.prototype,"destroyed",{enumerable:!1,get:function(){return this._readableState===void 0?!1:this._readableState.destroyed},set:function(e){this._readableState&&(this._readableState.destroyed=e)}});zr.prototype.destroy=fD.destroy;zr.prototype._undestroy=fD.undestroy;zr.prototype._destroy=function(t,e){e(t)};zr.prototype.push=function(t,e){var r=this._readableState,n;return r.objectMode?n=!0:typeof t=="string"&&(e=e||r.defaultEncoding,e!==r.encoding&&(t=H8.from(t,e),e=""),n=!0),uQ(this,t,e,!1,n)};zr.prototype.unshift=function(t){return uQ(this,t,null,!0,!1)};function uQ(t,e,r,n,i){Er("readableAddChunk",e);var o=t._readableState;if(e===null)o.reading=!1,MIe(t,o);else{var s;if(i||(s=RIe(o,e)),s)_x(t,s);else if(o.objectMode||e&&e.length>0)if(typeof e!="string"&&!o.objectMode&&Object.getPrototypeOf(e)!==H8.prototype&&(e=wIe(e)),n)o.endEmitted?_x(t,new PIe):dD(t,o,e,!0);else if(o.ended)_x(t,new TIe);else{if(o.destroyed)return!1;o.reading=!1,o.decoder&&!r?(e=o.decoder.write(e),o.objectMode||e.length!==0?dD(t,o,e,!1):lD(t,o)):dD(t,o,e,!1)}else n||(o.reading=!1,lD(t,o))}return!o.ended&&(o.length<o.highWaterMark||o.length===0)}function dD(t,e,r,n){e.flowing&&e.length===0&&!e.sync?(e.awaitDrain=0,t.emit("data",r)):(e.length+=e.objectMode?1:r.length,n?e.buffer.unshift(r):e.buffer.push(r),e.needReadable&&G8(t)),lD(t,e)}function RIe(t,e){var r;return!_Ie(e)&&typeof e!="string"&&e!==void 0&&!t.objectMode&&(r=new AIe("chunk",["string","Buffer","Uint8Array"],e)),r}zr.prototype.isPaused=function(){return this._readableState.flowing===!1};zr.prototype.setEncoding=function(t){Yb||(Yb=Uv().StringDecoder);var e=new Yb(t);this._readableState.decoder=e,this._readableState.encoding=this._readableState.decoder.encoding;for(var r=this._readableState.buffer.head,n="";r!==null;)n+=e.write(r.data),r=r.next;return this._readableState.buffer.clear(),n!==""&&this._readableState.buffer.push(n),this._readableState.length=n.length,this};var sQ=1073741824;function BIe(t){return t>=sQ?t=sQ:(t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++),t}function aQ(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=BIe(t)),t<=e.length?t:e.ended?e.length:(e.needReadable=!0,0))}zr.prototype.read=function(t){Er("read",t),t=parseInt(t,10);var e=this._readableState,r=t;if(t!==0&&(e.emittedReadable=!1),t===0&&e.needReadable&&((e.highWaterMark!==0?e.length>=e.highWaterMark:e.length>0)||e.ended))return Er("read: emitReadable",e.length,e.ended),e.length===0&&e.ended?uD(this):G8(this),null;if(t=aQ(t,e),t===0&&e.ended)return e.length===0&&uD(this),null;var n=e.needReadable;Er("need readable",n),(e.length===0||e.length-t<e.highWaterMark)&&(n=!0,Er("length less than watermark",n)),e.ended||e.reading?(n=!1,Er("reading or ended",n)):n&&(Er("do read"),e.reading=!0,e.sync=!0,e.length===0&&(e.needReadable=!0),this._read(e.highWaterMark),e.sync=!1,e.reading||(t=aQ(r,e)));var i;return t>0?i=hQ(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&&uD(this)),i!==null&&this.emit("data",i),i};function MIe(t,e){if(Er("onEofChunk"),!e.ended){if(e.decoder){var r=e.decoder.end();r&&r.length&&(e.buffer.push(r),e.length+=e.objectMode?1:r.length)}e.ended=!0,e.sync?G8(t):(e.needReadable=!1,e.emittedReadable||(e.emittedReadable=!0,lQ(t)))}}function G8(t){var e=t._readableState;Er("emitReadable",e.needReadable,e.emittedReadable),e.needReadable=!1,e.emittedReadable||(Er("emitReadable",e.flowing),e.emittedReadable=!0,D.default.nextTick(lQ,t))}function lQ(t){var e=t._readableState;Er("emitReadable_",e.destroyed,e.length,e.ended),!e.destroyed&&(e.length||e.ended)&&(t.emit("readable"),e.emittedReadable=!1),e.needReadable=!e.flowing&&!e.ended&&e.length<=e.highWaterMark,hD(t)}function lD(t,e){e.readingMore||(e.readingMore=!0,D.default.nextTick(DIe,t,e))}function DIe(t,e){for(;!e.reading&&!e.ended&&(e.length<e.highWaterMark||e.flowing&&e.length===0);){var r=e.length;if(Er("maybeReadMore read 0"),t.read(0),r===e.length)break}e.readingMore=!1}zr.prototype._read=function(t){_x(this,new IIe("_read()"))};zr.prototype.pipe=function(t,e){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=t;break;case 1:n.pipes=[n.pipes,t];break;default:n.pipes.push(t);break}n.pipesCount+=1,Er("pipe count=%d opts=%j",n.pipesCount,e);var i=(!e||e.end!==!1)&&t!==D.default.stdout&&t!==D.default.stderr,o=i?a:v;n.endEmitted?D.default.nextTick(o):r.once("end",o),t.on("unpipe",s);function s(E,A){Er("onunpipe"),E===r&&A&&A.hasUnpiped===!1&&(A.hasUnpiped=!0,c())}function a(){Er("onend"),t.end()}var d=OIe(r);t.on("drain",d);var u=!1;function c(){Er("cleanup"),t.removeListener("close",p),t.removeListener("finish",g),t.removeListener("drain",d),t.removeListener("error",m),t.removeListener("unpipe",s),r.removeListener("end",a),r.removeListener("end",v),r.removeListener("data",l),u=!0,n.awaitDrain&&(!t._writableState||t._writableState.needDrain)&&d()}r.on("data",l);function l(E){Er("ondata");var A=t.write(E);Er("dest.write",A),A===!1&&((n.pipesCount===1&&n.pipes===t||n.pipesCount>1&&pQ(n.pipes,t)!==-1)&&!u&&(Er("false write response, pause",n.awaitDrain),n.awaitDrain++),r.pause())}function m(E){Er("onerror",E),v(),t.removeListener("error",m),cQ(t,"error")===0&&_x(t,E)}kIe(t,"error",m);function p(){t.removeListener("finish",g),v()}t.once("close",p);function g(){Er("onfinish"),t.removeListener("close",p),v()}t.once("finish",g);function v(){Er("unpipe"),r.unpipe(t)}return t.emit("pipe",r),n.flowing||(Er("pipe resume"),r.resume()),t};function OIe(t){return function(){var r=t._readableState;Er("pipeOnDrain",r.awaitDrain),r.awaitDrain&&r.awaitDrain--,r.awaitDrain===0&&cQ(t,"data")&&(r.flowing=!0,hD(t))}}zr.prototype.unpipe=function(t){var e=this._readableState,r={hasUnpiped:!1};if(e.pipesCount===0)return this;if(e.pipesCount===1)return t&&t!==e.pipes?this:(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit("unpipe",this,r),this);if(!t){var n=e.pipes,i=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var o=0;o<i;o++)n[o].emit("unpipe",this,{hasUnpiped:!1});return this}var s=pQ(e.pipes,t);return s===-1?this:(e.pipes.splice(s,1),e.pipesCount-=1,e.pipesCount===1&&(e.pipes=e.pipes[0]),t.emit("unpipe",this,r),this)};zr.prototype.on=function(t,e){var r=xx.prototype.on.call(this,t,e),n=this._readableState;return t==="data"?(n.readableListening=this.listenerCount("readable")>0,n.flowing!==!1&&this.resume()):t==="readable"&&!n.endEmitted&&!n.readableListening&&(n.readableListening=n.needReadable=!0,n.flowing=!1,n.emittedReadable=!1,Er("on readable",n.length,n.reading),n.length?G8(this):n.reading||D.default.nextTick(CIe,this)),r};zr.prototype.addListener=zr.prototype.on;zr.prototype.removeListener=function(t,e){var r=xx.prototype.removeListener.call(this,t,e);return t==="readable"&&D.default.nextTick(fQ,this),r};zr.prototype.removeAllListeners=function(t){var e=xx.prototype.removeAllListeners.apply(this,arguments);return(t==="readable"||t===void 0)&&D.default.nextTick(fQ,this),e};function fQ(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 CIe(t){Er("readable nexttick read 0"),t.read(0)}zr.prototype.resume=function(){var t=this._readableState;return t.flowing||(Er("resume"),t.flowing=!t.readableListening,$Ie(this,t)),t.paused=!1,this};function $Ie(t,e){e.resumeScheduled||(e.resumeScheduled=!0,D.default.nextTick(NIe,t,e))}function NIe(t,e){Er("resume",e.reading),e.reading||t.read(0),e.resumeScheduled=!1,t.emit("resume"),hD(t),e.flowing&&!e.reading&&t.read(0)}zr.prototype.pause=function(){return Er("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(Er("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this};function hD(t){var e=t._readableState;for(Er("flow",e.flowing);e.flowing&&t.read()!==null;);}zr.prototype.wrap=function(t){var e=this,r=this._readableState,n=!1;t.on("end",function(){if(Er("wrapped end"),r.decoder&&!r.ended){var s=r.decoder.end();s&&s.length&&e.push(s)}e.push(null)}),t.on("data",function(s){if(Er("wrapped data"),r.decoder&&(s=r.decoder.write(s)),!(r.objectMode&&s==null)&&!(!r.objectMode&&(!s||!s.length))){var a=e.push(s);a||(n=!0,t.pause())}});for(var i in t)this[i]===void 0&&typeof t[i]=="function"&&(this[i]=function(a){return function(){return t[a].apply(t,arguments)}}(i));for(var o=0;o<cD.length;o++)t.on(cD[o],this.emit.bind(this,cD[o]));return this._read=function(s){Er("wrapped _read",s),n&&(n=!1,t.resume())},this};typeof Symbol=="function"&&(zr.prototype[Symbol.asyncIterator]=function(){return sD===void 0&&(sD=nQ()),sD(this)});Object.defineProperty(zr.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}});Object.defineProperty(zr.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}});Object.defineProperty(zr.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(e){this._readableState&&(this._readableState.flowing=e)}});zr._fromList=hQ;Object.defineProperty(zr.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}});function hQ(t,e){if(e.length===0)return null;var 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 uD(t){var e=t._readableState;Er("endReadable",e.endEmitted),e.endEmitted||(e.ended=!0,D.default.nextTick(jIe,e,t))}function jIe(t,e){if(Er("endReadableNT",t.endEmitted,t.length),!t.endEmitted&&t.length===0&&(t.endEmitted=!0,e.readable=!1,e.emit("end"),t.autoDestroy)){var r=e._writableState;(!r||r.autoDestroy&&r.finished)&&e.destroy()}}typeof Symbol=="function"&&(zr.from=function(t,e){return aD===void 0&&(aD=oQ()),aD(zr,t,e)});function pQ(t,e){for(var r=0,n=t.length;r<n;r++)if(t[r]===e)return r;return-1}});var Z8=H((ybt,gQ)=>{"use strict";h();gQ.exports=Yf;var J8=M0().codes,UIe=J8.ERR_METHOD_NOT_IMPLEMENTED,qIe=J8.ERR_MULTIPLE_CALLBACK,LIe=J8.ERR_TRANSFORM_ALREADY_TRANSFORMING,KIe=J8.ERR_TRANSFORM_WITH_LENGTH_0,Y8=Jp();ur()(Yf,Y8);function FIe(t,e){var r=this._transformState;r.transforming=!1;var n=r.writecb;if(n===null)return this.emit("error",new qIe);r.writechunk=null,r.writecb=null,e!=null&&this.push(e),n(t);var i=this._readableState;i.reading=!1,(i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}function Yf(t){if(!(this instanceof Yf))return new Yf(t);Y8.call(this,t),this._transformState={afterTransform:FIe.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,t&&(typeof t.transform=="function"&&(this._transform=t.transform),typeof t.flush=="function"&&(this._flush=t.flush)),this.on("prefinish",zIe)}function zIe(){var t=this;typeof this._flush=="function"&&!this._readableState.destroyed?this._flush(function(e,r){yQ(t,e,r)}):yQ(this,null,null)}Yf.prototype.push=function(t,e){return this._transformState.needTransform=!1,Y8.prototype.push.call(this,t,e)};Yf.prototype._transform=function(t,e,r){r(new UIe("_transform()"))};Yf.prototype._write=function(t,e,r){var n=this._transformState;if(n.writecb=r,n.writechunk=t,n.writeencoding=e,!n.transforming){var i=this._readableState;(n.needTransform||i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}};Yf.prototype._read=function(t){var e=this._transformState;e.writechunk!==null&&!e.transforming?(e.transforming=!0,this._transform(e.writechunk,e.writeencoding,e.afterTransform)):e.needTransform=!0};Yf.prototype._destroy=function(t,e){Y8.prototype._destroy.call(this,t,function(r){e(r)})};function yQ(t,e,r){if(e)return t.emit("error",e);if(r!=null&&t.push(r),t._writableState.length)throw new KIe;if(t._transformState.transforming)throw new LIe;return t.push(null)}});var pD=H((vbt,bQ)=>{"use strict";h();bQ.exports=Ex;var vQ=Z8();ur()(Ex,vQ);function Ex(t){if(!(this instanceof Ex))return new Ex(t);vQ.call(this,t)}Ex.prototype._transform=function(t,e,r){r(null,t)}});var yD=H((wbt,EQ)=>{"use strict";h();var mD;function VIe(t){var e=!1;return function(){e||(e=!0,t.apply(void 0,arguments))}}var xQ=M0().codes,HIe=xQ.ERR_MISSING_ARGS,WIe=xQ.ERR_STREAM_DESTROYED;function wQ(t){if(t)throw t}function GIe(t){return t.setHeader&&typeof t.abort=="function"}function JIe(t,e,r,n){n=VIe(n);var i=!1;t.on("close",function(){i=!0}),mD===void 0&&(mD=bx()),mD(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,GIe(t))return t.abort();if(typeof t.destroy=="function")return t.destroy();n(s||new WIe("pipe"))}}}function _Q(t){t()}function YIe(t,e){return t.pipe(e)}function ZIe(t){return!t.length||typeof t[t.length-1]!="function"?wQ:t.pop()}function XIe(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];var n=ZIe(e);if(Array.isArray(e[0])&&(e=e[0]),e.length<2)throw new HIe("streams");var i,o=e.map(function(s,a){var d=a<e.length-1,u=a>0;return JIe(s,d,u,function(c){i||(i=c),c&&o.forEach(_Q),!d&&(o.forEach(_Q),n(i))})});return e.reduce(YIe)}EQ.exports=XIe});var X8=H((id,SQ)=>{h();id=SQ.exports=F8();id.Stream=id;id.Readable=id;id.Writable=q8();id.Duplex=Jp();id.Transform=Z8();id.PassThrough=pD();id.finished=bx();id.pipeline=yD()});var gD=H((Ebt,TQ)=>{"use strict";h();var Q8=dr().Buffer,AQ=X8().Transform,QIe=ur();function ePe(t,e){if(!Q8.isBuffer(t)&&typeof t!="string")throw new TypeError(e+" must be a string or a buffer")}function Qp(t){AQ.call(this),this._block=Q8.allocUnsafe(t),this._blockSize=t,this._blockOffset=0,this._length=[0,0,0,0],this._finalized=!1}QIe(Qp,AQ);Qp.prototype._transform=function(t,e,r){var n=null;try{this.update(t,e)}catch(i){n=i}r(n)};Qp.prototype._flush=function(t){var e=null;try{this.push(this.digest())}catch(r){e=r}t(e)};Qp.prototype.update=function(t,e){if(ePe(t,"Data"),this._finalized)throw new Error("Digest already called");Q8.isBuffer(t)||(t=Q8.from(t,e));for(var r=this._block,n=0;this._blockOffset+t.length-n>=this._blockSize;){for(var i=this._blockOffset;i<this._blockSize;)r[i++]=t[n++];this._update(),this._blockOffset=0}for(;n<t.length;)r[this._blockOffset++]=t[n++];for(var o=0,s=t.length*8;s>0;++o)this._length[o]+=s,s=this._length[o]/4294967296|0,s>0&&(this._length[o]-=4294967296*s);return this};Qp.prototype._update=function(){throw new Error("_update is not implemented")};Qp.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};Qp.prototype._digest=function(){throw new Error("_digest is not implemented")};TQ.exports=Qp});var r4=H((Abt,PQ)=>{"use strict";h();var tPe=ur(),IQ=gD(),rPe=dr().Buffer,nPe=new Array(16);function e4(){IQ.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878}tPe(e4,IQ);e4.prototype._update=function(){for(var t=nPe,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=Ss(r,n,i,o,t[0],3614090360,7),o=Ss(o,r,n,i,t[1],3905402710,12),i=Ss(i,o,r,n,t[2],606105819,17),n=Ss(n,i,o,r,t[3],3250441966,22),r=Ss(r,n,i,o,t[4],4118548399,7),o=Ss(o,r,n,i,t[5],1200080426,12),i=Ss(i,o,r,n,t[6],2821735955,17),n=Ss(n,i,o,r,t[7],4249261313,22),r=Ss(r,n,i,o,t[8],1770035416,7),o=Ss(o,r,n,i,t[9],2336552879,12),i=Ss(i,o,r,n,t[10],4294925233,17),n=Ss(n,i,o,r,t[11],2304563134,22),r=Ss(r,n,i,o,t[12],1804603682,7),o=Ss(o,r,n,i,t[13],4254626195,12),i=Ss(i,o,r,n,t[14],2792965006,17),n=Ss(n,i,o,r,t[15],1236535329,22),r=As(r,n,i,o,t[1],4129170786,5),o=As(o,r,n,i,t[6],3225465664,9),i=As(i,o,r,n,t[11],643717713,14),n=As(n,i,o,r,t[0],3921069994,20),r=As(r,n,i,o,t[5],3593408605,5),o=As(o,r,n,i,t[10],38016083,9),i=As(i,o,r,n,t[15],3634488961,14),n=As(n,i,o,r,t[4],3889429448,20),r=As(r,n,i,o,t[9],568446438,5),o=As(o,r,n,i,t[14],3275163606,9),i=As(i,o,r,n,t[3],4107603335,14),n=As(n,i,o,r,t[8],1163531501,20),r=As(r,n,i,o,t[13],2850285829,5),o=As(o,r,n,i,t[2],4243563512,9),i=As(i,o,r,n,t[7],1735328473,14),n=As(n,i,o,r,t[12],2368359562,20),r=Ts(r,n,i,o,t[5],4294588738,4),o=Ts(o,r,n,i,t[8],2272392833,11),i=Ts(i,o,r,n,t[11],1839030562,16),n=Ts(n,i,o,r,t[14],4259657740,23),r=Ts(r,n,i,o,t[1],2763975236,4),o=Ts(o,r,n,i,t[4],1272893353,11),i=Ts(i,o,r,n,t[7],4139469664,16),n=Ts(n,i,o,r,t[10],3200236656,23),r=Ts(r,n,i,o,t[13],681279174,4),o=Ts(o,r,n,i,t[0],3936430074,11),i=Ts(i,o,r,n,t[3],3572445317,16),n=Ts(n,i,o,r,t[6],76029189,23),r=Ts(r,n,i,o,t[9],3654602809,4),o=Ts(o,r,n,i,t[12],3873151461,11),i=Ts(i,o,r,n,t[15],530742520,16),n=Ts(n,i,o,r,t[2],3299628645,23),r=Is(r,n,i,o,t[0],4096336452,6),o=Is(o,r,n,i,t[7],1126891415,10),i=Is(i,o,r,n,t[14],2878612391,15),n=Is(n,i,o,r,t[5],4237533241,21),r=Is(r,n,i,o,t[12],1700485571,6),o=Is(o,r,n,i,t[3],2399980690,10),i=Is(i,o,r,n,t[10],4293915773,15),n=Is(n,i,o,r,t[1],2240044497,21),r=Is(r,n,i,o,t[8],1873313359,6),o=Is(o,r,n,i,t[15],4264355552,10),i=Is(i,o,r,n,t[6],2734768916,15),n=Is(n,i,o,r,t[13],1309151649,21),r=Is(r,n,i,o,t[4],4149444226,6),o=Is(o,r,n,i,t[11],3174756917,10),i=Is(i,o,r,n,t[2],718787259,15),n=Is(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};e4.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=rPe.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 t4(t,e){return t<<e|t>>>32-e}function Ss(t,e,r,n,i,o,s){return t4(t+(e&r|~e&n)+i+o|0,s)+e|0}function As(t,e,r,n,i,o,s){return t4(t+(e&n|r&~n)+i+o|0,s)+e|0}function Ts(t,e,r,n,i,o,s){return t4(t+(e^r^n)+i+o|0,s)+e|0}function Is(t,e,r,n,i,o,s){return t4(t+(r^(e|~n))+i+o|0,s)+e|0}PQ.exports=e4});var i4=H((Ibt,CQ)=>{"use strict";h();var vD=$n().Buffer,iPe=ur(),OQ=gD(),oPe=new Array(16),Sx=[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],Ax=[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],Tx=[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],Ix=[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],Px=[0,1518500249,1859775393,2400959708,2840853838],kx=[1352829926,1548603684,1836072691,2053994217,0];function n4(){OQ.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520}iPe(n4,OQ);n4.prototype._update=function(){for(var t=oPe,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=kQ(r,n,i,o,s,t[Sx[m]],Px[0],Tx[m]),g=DQ(a,d,u,c,l,t[Ax[m]],kx[0],Ix[m])):m<32?(p=RQ(r,n,i,o,s,t[Sx[m]],Px[1],Tx[m]),g=MQ(a,d,u,c,l,t[Ax[m]],kx[1],Ix[m])):m<48?(p=BQ(r,n,i,o,s,t[Sx[m]],Px[2],Tx[m]),g=BQ(a,d,u,c,l,t[Ax[m]],kx[2],Ix[m])):m<64?(p=MQ(r,n,i,o,s,t[Sx[m]],Px[3],Tx[m]),g=RQ(a,d,u,c,l,t[Ax[m]],kx[3],Ix[m])):(p=DQ(r,n,i,o,s,t[Sx[m]],Px[4],Tx[m]),g=kQ(a,d,u,c,l,t[Ax[m]],kx[4],Ix[m])),r=s,s=o,o=$0(i,10),i=n,n=p,a=l,l=c,c=$0(u,10),u=d,d=g}var v=this._b+i+c|0;this._b=this._c+o+l|0,this._c=this._d+s+a|0,this._d=this._e+r+d|0,this._e=this._a+n+u|0,this._a=v};n4.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=vD.alloc?vD.alloc(20):new vD(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 $0(t,e){return t<<e|t>>>32-e}function kQ(t,e,r,n,i,o,s,a){return $0(t+(e^r^n)+o+s|0,a)+i|0}function RQ(t,e,r,n,i,o,s,a){return $0(t+(e&r|~e&n)+o+s|0,a)+i|0}function BQ(t,e,r,n,i,o,s,a){return $0(t+((e|~r)^n)+o+s|0,a)+i|0}function MQ(t,e,r,n,i,o,s,a){return $0(t+(e&n|r&~n)+o+s|0,a)+i|0}function DQ(t,e,r,n,i,o,s,a){return $0(t+(e^(r|~n))+o+s|0,a)+i|0}CQ.exports=n4});var N0=H((kbt,NQ)=>{h();var $Q=dr().Buffer;function o4(t,e){this._block=$Q.alloc(t),this._finalSize=e,this._blockSize=t,this._len=0}o4.prototype.update=function(t,e){typeof t=="string"&&(e=e||"utf8",t=$Q.from(t,e));for(var r=this._block,n=this._blockSize,i=t.length,o=this._len,s=0;s<i;){for(var a=o%n,d=Math.min(i-s,n-a),u=0;u<d;u++)r[a+u]=t[s+u];o+=d,s+=d,o%n===0&&this._update(r)}return this._len+=i,this};o4.prototype.digest=function(t){var e=this._len%this._blockSize;this._block[e]=128,this._block.fill(0,e+1),e>=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};o4.prototype._update=function(){throw new Error("_update must be implemented by subclass")};NQ.exports=o4});var qQ=H((Bbt,UQ)=>{h();var sPe=ur(),jQ=N0(),aPe=dr().Buffer,cPe=[1518500249,1859775393,-1894007588,-899497514],dPe=new Array(80);function Rx(){this.init(),this._w=dPe,jQ.call(this,64,56)}sPe(Rx,jQ);Rx.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function uPe(t){return t<<5|t>>>27}function lPe(t){return t<<30|t>>>2}function fPe(t,e,r,n){return t===0?e&r|~e&n:t===2?e&r|e&n|r&n:e^r^n}Rx.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=uPe(r)+fPe(u,n,i,o)+s+e[d]+cPe[u]|0;s=o,o=i,i=lPe(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};Rx.prototype._hash=function(){var t=aPe.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};UQ.exports=Rx});var FQ=H((Dbt,KQ)=>{h();var hPe=ur(),LQ=N0(),pPe=dr().Buffer,mPe=[1518500249,1859775393,-1894007588,-899497514],yPe=new Array(80);function Bx(){this.init(),this._w=yPe,LQ.call(this,64,56)}hPe(Bx,LQ);Bx.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function gPe(t){return t<<1|t>>>31}function vPe(t){return t<<5|t>>>27}function bPe(t){return t<<30|t>>>2}function wPe(t,e,r,n){return t===0?e&r|~e&n:t===2?e&r|e&n|r&n:e^r^n}Bx.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]=gPe(e[a-3]^e[a-8]^e[a-14]^e[a-16]);for(var d=0;d<80;++d){var u=~~(d/20),c=vPe(r)+wPe(u,n,i,o)+s+e[d]+mPe[u]|0;s=o,o=i,i=bPe(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};Bx.prototype._hash=function(){var t=pPe.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};KQ.exports=Bx});var bD=H((Cbt,VQ)=>{h();var _Pe=ur(),zQ=N0(),xPe=dr().Buffer,EPe=[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],SPe=new Array(64);function Mx(){this.init(),this._w=SPe,zQ.call(this,64,56)}_Pe(Mx,zQ);Mx.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 APe(t,e,r){return r^t&(e^r)}function TPe(t,e,r){return t&e|r&(t|e)}function IPe(t){return(t>>>2|t<<30)^(t>>>13|t<<19)^(t>>>22|t<<10)}function PPe(t){return(t>>>6|t<<26)^(t>>>11|t<<21)^(t>>>25|t<<7)}function kPe(t){return(t>>>7|t<<25)^(t>>>18|t<<14)^t>>>3}function RPe(t){return(t>>>17|t<<15)^(t>>>19|t<<13)^t>>>10}Mx.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]=RPe(e[c-2])+e[c-7]+kPe(e[c-15])+e[c-16]|0;for(var l=0;l<64;++l){var m=u+PPe(s)+APe(s,a,d)+EPe[l]+e[l]|0,p=IPe(r)+TPe(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};Mx.prototype._hash=function(){var t=xPe.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};VQ.exports=Mx});var WQ=H((Nbt,HQ)=>{h();var BPe=ur(),MPe=bD(),DPe=N0(),OPe=dr().Buffer,CPe=new Array(64);function s4(){this.init(),this._w=CPe,DPe.call(this,64,56)}BPe(s4,MPe);s4.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};s4.prototype._hash=function(){var t=OPe.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};HQ.exports=s4});var wD=H((Ubt,eee)=>{h();var $Pe=ur(),QQ=N0(),NPe=dr().Buffer,GQ=[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],jPe=new Array(160);function Dx(){this.init(),this._w=jPe,QQ.call(this,128,112)}$Pe(Dx,QQ);Dx.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 JQ(t,e,r){return r^t&(e^r)}function YQ(t,e,r){return t&e|r&(t|e)}function ZQ(t,e){return(t>>>28|e<<4)^(e>>>2|t<<30)^(e>>>7|t<<25)}function XQ(t,e){return(t>>>14|e<<18)^(t>>>18|e<<14)^(e>>>9|t<<23)}function UPe(t,e){return(t>>>1|e<<31)^(t>>>8|e<<24)^t>>>7}function qPe(t,e){return(t>>>1|e<<31)^(t>>>8|e<<24)^(t>>>7|e<<25)}function LPe(t,e){return(t>>>19|e<<13)^(e>>>29|t<<3)^t>>>6}function KPe(t,e){return(t>>>19|e<<13)^(e>>>29|t<<3)^(t>>>6|e<<26)}function go(t,e){return t>>>0<e>>>0?1:0}Dx.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,v=this._fl|0,E=this._gl|0,A=this._hl|0,P=0;P<32;P+=2)e[P]=t.readInt32BE(P*4),e[P+1]=t.readInt32BE(P*4+4);for(;P<160;P+=2){var I=e[P-30],$=e[P-15*2+1],N=UPe(I,$),K=qPe($,I);I=e[P-2*2],$=e[P-2*2+1];var F=LPe(I,$),U=KPe($,I),V=e[P-7*2],L=e[P-7*2+1],T=e[P-16*2],S=e[P-16*2+1],k=K+L|0,f=N+V+go(k,K)|0;k=k+U|0,f=f+F+go(k,U)|0,k=k+S|0,f=f+T+go(k,S)|0,e[P]=f,e[P+1]=k}for(var y=0;y<160;y+=2){f=e[y],k=e[y+1];var w=YQ(r,n,i),_=YQ(c,l,m),x=ZQ(r,c),b=ZQ(c,r),B=XQ(s,g),q=XQ(g,s),M=GQ[y],j=GQ[y+1],J=JQ(s,a,d),Z=JQ(g,v,E),G=A+q|0,W=u+B+go(G,A)|0;G=G+Z|0,W=W+J+go(G,Z)|0,G=G+j|0,W=W+M+go(G,j)|0,G=G+k|0,W=W+f+go(G,k)|0;var X=b+_|0,ee=x+w+go(X,b)|0;u=d,A=E,d=a,E=v,a=s,v=g,g=p+G|0,s=o+W+go(g,p)|0,o=i,p=m,i=n,m=l,n=r,l=c,c=G+X|0,r=W+ee+go(c,G)|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+v|0,this._gl=this._gl+E|0,this._hl=this._hl+A|0,this._ah=this._ah+r+go(this._al,c)|0,this._bh=this._bh+n+go(this._bl,l)|0,this._ch=this._ch+i+go(this._cl,m)|0,this._dh=this._dh+o+go(this._dl,p)|0,this._eh=this._eh+s+go(this._el,g)|0,this._fh=this._fh+a+go(this._fl,v)|0,this._gh=this._gh+d+go(this._gl,E)|0,this._hh=this._hh+u+go(this._hl,A)|0};Dx.prototype._hash=function(){var t=NPe.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};eee.exports=Dx});var ree=H((Lbt,tee)=>{h();var FPe=ur(),zPe=wD(),VPe=N0(),HPe=dr().Buffer,WPe=new Array(160);function a4(){this.init(),this._w=WPe,VPe.call(this,128,112)}FPe(a4,zPe);a4.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};a4.prototype._hash=function(){var t=HPe.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};tee.exports=a4});var c4=H((Zf,nee)=>{h();var Zf=nee.exports=function(e){e=e.toLowerCase();var r=Zf[e];if(!r)throw new Error(e+" is not supported (we accept pull requests)");return new r};Zf.sha=qQ();Zf.sha1=FQ();Zf.sha224=WQ();Zf.sha256=bD();Zf.sha384=ree();Zf.sha512=wD()});var oee=H((zbt,iee)=>{h();iee.exports=od;var _D=Ja().EventEmitter,GPe=ur();GPe(od,_D);od.Readable=F8();od.Writable=q8();od.Duplex=Jp();od.Transform=Z8();od.PassThrough=pD();od.finished=bx();od.pipeline=yD();od.Stream=od;function od(){_D.call(this)}od.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(),_D.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 Xf=H((Hbt,cee)=>{h();var see=dr().Buffer,aee=oee().Transform,JPe=Uv().StringDecoder,YPe=ur();function iu(t){aee.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}YPe(iu,aee);iu.prototype.update=function(t,e,r){typeof t=="string"&&(t=see.from(t,e));var n=this._update(t);return this.hashMode?this:(r&&(n=this._toString(n,r)),n)};iu.prototype.setAutoPadding=function(){};iu.prototype.getAuthTag=function(){throw new Error("trying to get auth tag in unsupported state")};iu.prototype.setAuthTag=function(){throw new Error("trying to set auth tag in unsupported state")};iu.prototype.setAAD=function(){throw new Error("trying to set aad in unsupported state")};iu.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)}};iu.prototype._flush=function(t){var e;try{this.push(this.__final())}catch(r){e=r}t(e)};iu.prototype._finalOrDigest=function(t){var e=this.__final()||see.alloc(0);return t&&(e=this._toString(e,t,!0)),e};iu.prototype._toString=function(t,e,r){if(this._decoder||(this._decoder=new JPe(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};cee.exports=iu});var Zb=H((Gbt,uee)=>{"use strict";h();var ZPe=ur(),XPe=r4(),QPe=i4(),eke=c4(),dee=Xf();function d4(t){dee.call(this,"digest"),this._hash=t}ZPe(d4,dee);d4.prototype._update=function(t){this._hash.update(t)};d4.prototype._final=function(){return this._hash.digest()};uee.exports=function(e){return e=e.toLowerCase(),e==="md5"?new XPe:e==="rmd160"||e==="ripemd160"?new QPe:new d4(eke(e))}});var hee=H((Ybt,fee)=>{"use strict";h();var tke=ur(),j0=dr().Buffer,lee=Xf(),rke=j0.alloc(128),Xb=64;function u4(t,e){lee.call(this,"digest"),typeof e=="string"&&(e=j0.from(e)),this._alg=t,this._key=e,e.length>Xb?e=t(e):e.length<Xb&&(e=j0.concat([e,rke],Xb));for(var r=this._ipad=j0.allocUnsafe(Xb),n=this._opad=j0.allocUnsafe(Xb),i=0;i<Xb;i++)r[i]=e[i]^54,n[i]=e[i]^92;this._hash=[r]}tke(u4,lee);u4.prototype._update=function(t){this._hash.push(t)};u4.prototype._final=function(){var t=this._alg(j0.concat(this._hash));return this._alg(j0.concat([this._opad,t]))};fee.exports=u4});var xD=H((Xbt,pee)=>{h();var nke=r4();pee.exports=function(t){return new nke().update(t).digest()}});var AD=H((ewt,yee)=>{"use strict";h();var ike=ur(),oke=hee(),mee=Xf(),Ox=dr().Buffer,ske=xD(),ED=i4(),SD=c4(),ake=Ox.alloc(128);function Cx(t,e){mee.call(this,"digest"),typeof e=="string"&&(e=Ox.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 ED:SD(t);e=n.update(e).digest()}else e.length<r&&(e=Ox.concat([e,ake],r));for(var i=this._ipad=Ox.allocUnsafe(r),o=this._opad=Ox.allocUnsafe(r),s=0;s<r;s++)i[s]=e[s]^54,o[s]=e[s]^92;this._hash=t==="rmd160"?new ED:SD(t),this._hash.update(i)}ike(Cx,mee);Cx.prototype._update=function(t){this._hash.update(t)};Cx.prototype._final=function(){var t=this._hash.digest(),e=this._alg==="rmd160"?new ED:SD(this._alg);return e.update(this._opad).update(t).digest()};yee.exports=function(e,r){return e=e.toLowerCase(),e==="rmd160"||e==="ripemd160"?new Cx("rmd160",r):e==="md5"?new oke(ske,r):new Cx(e,r)}});var TD=H((rwt,cke)=>{cke.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 vee=H((nwt,gee)=>{"use strict";h();gee.exports=TD()});var ID=H((owt,bee)=>{h();var dke=Math.pow(2,30)-1;bee.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>dke||e!==e)throw new TypeError("Bad key length")}});var PD=H((awt,_ee)=>{h();var l4;globalThis.process&&globalThis.process.browser?l4="utf-8":globalThis.process&&globalThis.process.version?(wee=parseInt(D.default.version.split(".")[0].slice(1),10),l4=wee>=6?"utf-8":"binary"):l4="utf-8";var wee;_ee.exports=l4});var RD=H((dwt,xee)=>{h();var kD=dr().Buffer;xee.exports=function(t,e,r){if(kD.isBuffer(t))return t;if(typeof t=="string")return kD.from(t,e);if(ArrayBuffer.isView(t))return kD.from(t.buffer);throw new TypeError(r+" must be a string, a Buffer, a typed array or a DataView")}});var BD=H((lwt,Tee)=>{h();var uke=xD(),lke=i4(),fke=c4(),U0=dr().Buffer,hke=ID(),Eee=PD(),See=RD(),pke=U0.alloc(128),f4={md5:16,sha1:20,sha224:28,sha256:32,sha384:48,sha512:64,rmd160:20,ripemd160:20};function Aee(t,e,r){var n=mke(t),i=t==="sha512"||t==="sha384"?128:64;e.length>i?e=n(e):e.length<i&&(e=U0.concat([e,pke],i));for(var o=U0.allocUnsafe(i+f4[t]),s=U0.allocUnsafe(i+f4[t]),a=0;a<i;a++)o[a]=e[a]^54,s[a]=e[a]^92;var d=U0.allocUnsafe(i+r+4);o.copy(d,0,0,i),this.ipad1=d,this.ipad2=o,this.opad=s,this.alg=t,this.blocksize=i,this.hash=n,this.size=f4[t]}Aee.prototype.run=function(t,e){t.copy(e,this.blocksize);var r=this.hash(e);return r.copy(this.opad,this.blocksize),this.hash(this.opad)};function mke(t){function e(n){return fke(t).update(n).digest()}function r(n){return new lke().update(n).digest()}return t==="rmd160"||t==="ripemd160"?r:t==="md5"?uke:e}function yke(t,e,r,n,i){hke(r,n),t=See(t,Eee,"Password"),e=See(e,Eee,"Salt"),i=i||"sha1";var o=new Aee(i,t,e.length),s=U0.allocUnsafe(n),a=U0.allocUnsafe(e.length+4);e.copy(a,0,0,e.length);for(var d=0,u=f4[i],c=Math.ceil(n/u),l=1;l<=c;l++){a.writeUInt32BE(l,e.length);for(var m=o.run(a,o.ipad1),p=m,g=1;g<r;g++){p=o.run(p,o.ipad2);for(var v=0;v<u;v++)m[v]^=p[v]}m.copy(s,d),d+=u}return s}Tee.exports=yke});var Dee=H((hwt,Mee)=>{h();var Ree=dr().Buffer,gke=ID(),Iee=PD(),Pee=BD(),kee=RD(),h4,$x=globalThis.crypto&&globalThis.crypto.subtle,vke={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"},MD=[];function bke(t){if(globalThis.process&&!globalThis.process.browser||!$x||!$x.importKey||!$x.deriveBits)return Promise.resolve(!1);if(MD[t]!==void 0)return MD[t];h4=h4||Ree.alloc(8);var e=Bee(h4,h4,10,128,t).then(function(){return!0}).catch(function(){return!1});return MD[t]=e,e}var q0;function DD(){return q0||(globalThis.process&&globalThis.process.nextTick?q0=globalThis.process.nextTick:globalThis.queueMicrotask?q0=globalThis.queueMicrotask:globalThis.setImmediate?q0=globalThis.setImmediate:q0=globalThis.setTimeout,q0)}function Bee(t,e,r,n,i){return $x.importKey("raw",t,{name:"PBKDF2"},!1,["deriveBits"]).then(function(o){return $x.deriveBits({name:"PBKDF2",salt:e,iterations:r,hash:{name:i}},o,n<<3)}).then(function(o){return Ree.from(o)})}function wke(t,e){t.then(function(r){DD()(function(){e(null,r)})},function(r){DD()(function(){e(r)})})}Mee.exports=function(t,e,r,n,i,o){typeof i=="function"&&(o=i,i=void 0),i=i||"sha1";var s=vke[i.toLowerCase()];if(!s||typeof globalThis.Promise!="function"){DD()(function(){var a;try{a=Pee(t,e,r,n,i)}catch(d){return o(d)}o(null,a)});return}if(gke(r,n),t=kee(t,Iee,"Password"),e=kee(e,Iee,"Salt"),typeof o!="function")throw new Error("No callback provided to pbkdf2");wke(bke(s).then(function(a){return a?Bee(t,e,r,n,s):Pee(t,e,r,n,i)}),o)}});var CD=H(OD=>{h();OD.pbkdf2=Dee();OD.pbkdf2Sync=BD()});var $D=H(sd=>{"use strict";h();sd.readUInt32BE=function(e,r){var n=e[0+r]<<24|e[1+r]<<16|e[2+r]<<8|e[3+r];return n>>>0};sd.writeUInt32BE=function(e,r,n){e[0+n]=r>>>24,e[1+n]=r>>>16&255,e[2+n]=r>>>8&255,e[3+n]=r&255};sd.ip=function(e,r,n,i){for(var o=0,s=0,a=6;a>=0;a-=2){for(var d=0;d<=24;d+=8)o<<=1,o|=r>>>d+a&1;for(var d=0;d<=24;d+=8)o<<=1,o|=e>>>d+a&1}for(var a=6;a>=0;a-=2){for(var d=1;d<=25;d+=8)s<<=1,s|=r>>>d+a&1;for(var d=1;d<=25;d+=8)s<<=1,s|=e>>>d+a&1}n[i+0]=o>>>0,n[i+1]=s>>>0};sd.rip=function(e,r,n,i){for(var o=0,s=0,a=0;a<4;a++)for(var d=24;d>=0;d-=8)o<<=1,o|=r>>>d+a&1,o<<=1,o|=e>>>d+a&1;for(var a=4;a<8;a++)for(var d=24;d>=0;d-=8)s<<=1,s|=r>>>d+a&1,s<<=1,s|=e>>>d+a&1;n[i+0]=o>>>0,n[i+1]=s>>>0};sd.pc1=function(e,r,n,i){for(var o=0,s=0,a=7;a>=5;a--){for(var d=0;d<=24;d+=8)o<<=1,o|=r>>d+a&1;for(var d=0;d<=24;d+=8)o<<=1,o|=e>>d+a&1}for(var d=0;d<=24;d+=8)o<<=1,o|=r>>d+a&1;for(var a=1;a<=3;a++){for(var d=0;d<=24;d+=8)s<<=1,s|=r>>d+a&1;for(var d=0;d<=24;d+=8)s<<=1,s|=e>>d+a&1}for(var d=0;d<=24;d+=8)s<<=1,s|=e>>d+a&1;n[i+0]=o>>>0,n[i+1]=s>>>0};sd.r28shl=function(e,r){return e<<r&268435455|e>>>28-r};var p4=[14,11,17,4,27,23,25,0,13,22,7,18,5,9,16,24,2,20,12,21,1,8,15,26,15,4,25,19,9,1,26,16,5,11,23,8,12,7,17,0,22,3,10,14,6,20,27,24];sd.pc2=function(e,r,n,i){for(var o=0,s=0,a=p4.length>>>1,d=0;d<a;d++)o<<=1,o|=e>>>p4[d]&1;for(var d=a;d<p4.length;d++)s<<=1,s|=r>>>p4[d]&1;n[i+0]=o>>>0,n[i+1]=s>>>0};sd.expand=function(e,r,n){var i=0,o=0;i=(e&1)<<5|e>>>27;for(var s=23;s>=15;s-=4)i<<=6,i|=e>>>s&63;for(var s=11;s>=3;s-=4)o|=e>>>s&63,o<<=6;o|=(e&31)<<1|e>>>31,r[n+0]=i>>>0,r[n+1]=o>>>0};var Oee=[14,0,4,15,13,7,1,4,2,14,15,2,11,13,8,1,3,10,10,6,6,12,12,11,5,9,9,5,0,3,7,8,4,15,1,12,14,8,8,2,13,4,6,9,2,1,11,7,15,5,12,11,9,3,7,14,3,10,10,0,5,6,0,13,15,3,1,13,8,4,14,7,6,15,11,2,3,8,4,14,9,12,7,0,2,1,13,10,12,6,0,9,5,11,10,5,0,13,14,8,7,10,11,1,10,3,4,15,13,4,1,2,5,11,8,6,12,7,6,12,9,0,3,5,2,14,15,9,10,13,0,7,9,0,14,9,6,3,3,4,15,6,5,10,1,2,13,8,12,5,7,14,11,12,4,11,2,15,8,1,13,1,6,10,4,13,9,0,8,6,15,9,3,8,0,7,11,4,1,15,2,14,12,3,5,11,10,5,14,2,7,12,7,13,13,8,14,11,3,5,0,6,6,15,9,0,10,3,1,4,2,7,8,2,5,12,11,1,12,10,4,14,15,9,10,3,6,15,9,0,0,6,12,10,11,1,7,13,13,8,15,9,1,4,3,5,14,11,5,12,2,7,8,2,4,14,2,14,12,11,4,2,1,12,7,4,10,7,11,13,6,1,8,5,5,0,3,15,15,10,13,3,0,9,14,8,9,6,4,11,2,8,1,12,11,7,10,1,13,14,7,2,8,13,15,6,9,15,12,0,5,9,6,10,3,4,0,5,14,3,12,10,1,15,10,4,15,2,9,7,2,12,6,9,8,5,0,6,13,1,3,13,4,14,14,0,7,11,5,3,11,8,9,4,14,3,15,2,5,12,2,9,8,5,12,15,3,10,7,11,0,14,4,1,10,7,1,6,13,0,11,8,6,13,4,13,11,0,2,11,14,7,15,4,0,9,8,1,13,10,3,14,12,3,9,5,7,12,5,2,10,15,6,8,1,6,1,6,4,11,11,13,13,8,12,1,3,4,7,10,14,7,10,9,15,5,6,0,8,15,0,14,5,2,9,3,2,12,13,1,2,15,8,13,4,8,6,10,15,3,11,7,1,4,10,12,9,5,3,6,14,11,5,0,0,14,12,9,7,2,7,2,11,1,4,14,1,7,9,4,12,10,14,8,2,13,0,15,6,12,10,9,13,0,15,3,3,5,5,6,8,11];sd.substitute=function(e,r){for(var n=0,i=0;i<4;i++){var o=e>>>18-i*6&63,s=Oee[i*64+o];n<<=4,n|=s}for(var i=0;i<4;i++){var o=r>>>18-i*6&63,s=Oee[4*64+i*64+o];n<<=4,n|=s}return n>>>0};var Cee=[16,25,12,11,3,20,4,15,31,17,9,6,27,14,1,22,30,24,8,18,0,5,29,23,13,19,2,26,10,21,28,7];sd.permute=function(e){for(var r=0,n=0;n<Cee.length;n++)r<<=1,r|=e>>>Cee[n]&1;return r>>>0};sd.padSplit=function(e,r,n){for(var i=e.toString(2);i.length<r;)i="0"+i;for(var o=[],s=0;s<r;s+=n)o.push(i.slice(s,s+n));return o.join(" ")}});var hc=H((bwt,Nee)=>{h();Nee.exports=$ee;function $ee(t,e){if(!t)throw new Error(e||"Assertion failed")}$ee.equal=function(e,r,n){if(e!=r)throw new Error(n||"Assertion failed: "+e+" != "+r)}});var m4=H((_wt,jee)=>{"use strict";h();var _ke=hc();function ad(t){this.options=t,this.type=this.options.type,this.blockSize=8,this._init(),this.buffer=new Array(this.blockSize),this.bufferOff=0,this.padding=t.padding!==!1}jee.exports=ad;ad.prototype._init=function(){};ad.prototype.update=function(e){return e.length===0?[]:this.type==="decrypt"?this._updateDecrypt(e):this._updateEncrypt(e)};ad.prototype._buffer=function(e,r){for(var n=Math.min(this.buffer.length-this.bufferOff,e.length-r),i=0;i<n;i++)this.buffer[this.bufferOff+i]=e[r+i];return this.bufferOff+=n,n};ad.prototype._flushBuffer=function(e,r){return this._update(this.buffer,0,e,r),this.bufferOff=0,this.blockSize};ad.prototype._updateEncrypt=function(e){var r=0,n=0,i=(this.bufferOff+e.length)/this.blockSize|0,o=new Array(i*this.blockSize);this.bufferOff!==0&&(r+=this._buffer(e,r),this.bufferOff===this.buffer.length&&(n+=this._flushBuffer(o,n)));for(var s=e.length-(e.length-r)%this.blockSize;r<s;r+=this.blockSize)this._update(e,r,o,n),n+=this.blockSize;for(;r<e.length;r++,this.bufferOff++)this.buffer[this.bufferOff]=e[r];return o};ad.prototype._updateDecrypt=function(e){for(var r=0,n=0,i=Math.ceil((this.bufferOff+e.length)/this.blockSize)-1,o=new Array(i*this.blockSize);i>0;i--)r+=this._buffer(e,r),n+=this._flushBuffer(o,n);return r+=this._buffer(e,r),o};ad.prototype.final=function(e){var r;e&&(r=this.update(e));var n;return this.type==="encrypt"?n=this._finalEncrypt():n=this._finalDecrypt(),r?r.concat(n):n};ad.prototype._pad=function(e,r){if(r===0)return!1;for(;r<e.length;)e[r++]=0;return!0};ad.prototype._finalEncrypt=function(){if(!this._pad(this.buffer,this.bufferOff))return[];var e=new Array(this.blockSize);return this._update(this.buffer,0,e,0),e};ad.prototype._unpad=function(e){return e};ad.prototype._finalDecrypt=function(){_ke.equal(this.bufferOff,this.blockSize,"Not enough data to decrypt");var e=new Array(this.blockSize);return this._flushBuffer(e,0),this._unpad(e)}});var ND=H((Ewt,Lee)=>{"use strict";h();var Uee=hc(),xke=ur(),Wi=$D(),qee=m4();function Eke(){this.tmp=new Array(2),this.keys=null}function xl(t){qee.call(this,t);var e=new Eke;this._desState=e,this.deriveKeys(e,t.key)}xke(xl,qee);Lee.exports=xl;xl.create=function(e){return new xl(e)};var Ske=[1,1,2,2,2,2,2,2,1,2,2,2,2,2,2,1];xl.prototype.deriveKeys=function(e,r){e.keys=new Array(16*2),Uee.equal(r.length,this.blockSize,"Invalid key length");var n=Wi.readUInt32BE(r,0),i=Wi.readUInt32BE(r,4);Wi.pc1(n,i,e.tmp,0),n=e.tmp[0],i=e.tmp[1];for(var o=0;o<e.keys.length;o+=2){var s=Ske[o>>>1];n=Wi.r28shl(n,s),i=Wi.r28shl(i,s),Wi.pc2(n,i,e.keys,o)}};xl.prototype._update=function(e,r,n,i){var o=this._desState,s=Wi.readUInt32BE(e,r),a=Wi.readUInt32BE(e,r+4);Wi.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],Wi.writeUInt32BE(n,s,i),Wi.writeUInt32BE(n,a,i+4)};xl.prototype._pad=function(e,r){if(this.padding===!1)return!1;for(var n=e.length-r,i=r;i<e.length;i++)e[i]=n;return!0};xl.prototype._unpad=function(e){if(this.padding===!1)return e;for(var r=e[e.length-1],n=e.length-r;n<e.length;n++)Uee.equal(e[n],r);return e.slice(0,e.length-r)};xl.prototype._encrypt=function(e,r,n,i,o){for(var s=r,a=n,d=0;d<e.keys.length;d+=2){var u=e.keys[d],c=e.keys[d+1];Wi.expand(a,e.tmp,0),u^=e.tmp[0],c^=e.tmp[1];var l=Wi.substitute(u,c),m=Wi.permute(l),p=a;a=(s^m)>>>0,s=p}Wi.rip(a,s,i,o)};xl.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];Wi.expand(s,e.tmp,0),u^=e.tmp[0],c^=e.tmp[1];var l=Wi.substitute(u,c),m=Wi.permute(l),p=s;s=(a^m)>>>0,a=p}Wi.rip(s,a,i,o)}});var Fee=H(Kee=>{"use strict";h();var Ake=hc(),Tke=ur(),y4={};function Ike(t){Ake.equal(t.length,8,"Invalid IV length"),this.iv=new Array(8);for(var e=0;e<this.iv.length;e++)this.iv[e]=t[e]}function Pke(t){function e(o){t.call(this,o),this._cbcInit()}Tke(e,t);for(var r=Object.keys(y4),n=0;n<r.length;n++){var i=r[n];e.prototype[i]=y4[i]}return e.create=function(s){return new e(s)},e}Kee.instantiate=Pke;y4._cbcInit=function(){var e=new Ike(this.options.iv);this._cbcState=e};y4._update=function(e,r,n,i){var o=this._cbcState,s=this.constructor.super_.prototype,a=o.iv;if(this.type==="encrypt"){for(var d=0;d<this.blockSize;d++)a[d]^=e[r+d];s._update.call(this,a,0,n,i);for(var d=0;d<this.blockSize;d++)a[d]=n[i+d]}else{s._update.call(this,e,r,n,i);for(var d=0;d<this.blockSize;d++)n[i+d]^=a[d];for(var d=0;d<this.blockSize;d++)a[d]=e[r+d]}}});var Hee=H((Iwt,Vee)=>{"use strict";h();var kke=hc(),Rke=ur(),zee=m4(),em=ND();function Bke(t,e){kke.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=[em.create({type:"encrypt",key:r}),em.create({type:"decrypt",key:n}),em.create({type:"encrypt",key:i})]:this.ciphers=[em.create({type:"decrypt",key:i}),em.create({type:"encrypt",key:n}),em.create({type:"decrypt",key:r})]}function L0(t){zee.call(this,t);var e=new Bke(this.type,this.options.key);this._edeState=e}Rke(L0,zee);Vee.exports=L0;L0.create=function(e){return new L0(e)};L0.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)};L0.prototype._pad=em.prototype._pad;L0.prototype._unpad=em.prototype._unpad});var Wee=H(Qb=>{"use strict";h();Qb.utils=$D();Qb.Cipher=m4();Qb.DES=ND();Qb.CBC=Fee();Qb.EDE=Hee()});var Yee=H((Bwt,Jee)=>{h();var Gee=Xf(),Qf=Wee(),Mke=ur(),K0=dr().Buffer,Nx={"des-ede3-cbc":Qf.CBC.instantiate(Qf.EDE),"des-ede3":Qf.EDE,"des-ede-cbc":Qf.CBC.instantiate(Qf.EDE),"des-ede":Qf.EDE,"des-cbc":Qf.CBC.instantiate(Qf.DES),"des-ecb":Qf.DES};Nx.des=Nx["des-cbc"];Nx.des3=Nx["des-ede3-cbc"];Jee.exports=g4;Mke(g4,Gee);function g4(t){Gee.call(this);var e=t.mode.toLowerCase(),r=Nx[e],n;t.decrypt?n="decrypt":n="encrypt";var i=t.key;K0.isBuffer(i)||(i=K0.from(i)),(e==="des-ede"||e==="des-ede-cbc")&&(i=K0.concat([i,i.slice(0,8)]));var o=t.iv;K0.isBuffer(o)||(o=K0.from(o)),this._des=r.create({key:i,iv:o,type:n})}g4.prototype._update=function(t){return K0.from(this._des.update(t))};g4.prototype._final=function(){return K0.from(this._des.final())}});var Zee=H(jD=>{h();jD.encrypt=function(t,e){return t._cipher.encryptBlock(e)};jD.decrypt=function(t,e){return t._cipher.decryptBlock(e)}});var ew=H((Cwt,Xee)=>{h();Xee.exports=function(e,r){for(var n=Math.min(e.length,r.length),i=new C.Buffer(n),o=0;o<n;++o)i[o]=e[o]^r[o];return i}});var ete=H(UD=>{h();var Qee=ew();UD.encrypt=function(t,e){var r=Qee(e,t._prev);return t._prev=t._cipher.encryptBlock(r),t._prev};UD.decrypt=function(t,e){var r=t._prev;t._prev=e;var n=t._cipher.decryptBlock(e);return Qee(n,r)}});var nte=H(rte=>{h();var jx=dr().Buffer,Dke=ew();function tte(t,e,r){var n=e.length,i=Dke(e,t._cache);return t._cache=t._cache.slice(n),t._prev=jx.concat([t._prev,r?e:i]),i}rte.encrypt=function(t,e,r){for(var n=jx.allocUnsafe(0),i;e.length;)if(t._cache.length===0&&(t._cache=t._cipher.encryptBlock(t._prev),t._prev=jx.allocUnsafe(0)),t._cache.length<=e.length)i=t._cache.length,n=jx.concat([n,tte(t,e.slice(0,i),r)]),e=e.slice(i);else{n=jx.concat([n,tte(t,e,r)]);break}return n}});var ote=H(ite=>{h();var qD=dr().Buffer;function Oke(t,e,r){var n=t._cipher.encryptBlock(t._prev),i=n[0]^e;return t._prev=qD.concat([t._prev.slice(1),qD.from([r?e:i])]),i}ite.encrypt=function(t,e,r){for(var n=e.length,i=qD.allocUnsafe(n),o=-1;++o<n;)i[o]=Oke(t,e[o],r);return i}});var ate=H(ste=>{h();var v4=dr().Buffer;function Cke(t,e,r){for(var n,i=-1,o=8,s=0,a,d;++i<o;)n=t._cipher.encryptBlock(t._prev),a=e&1<<7-i?128:0,d=n[0]^a,s+=(d&128)>>i%8,t._prev=$ke(t._prev,r?a:d);return s}function $ke(t,e){var r=t.length,n=-1,i=v4.allocUnsafe(t.length);for(t=v4.concat([t,v4.from([e])]);++n<r;)i[n]=t[n]<<1|t[n+1]>>7;return i}ste.encrypt=function(t,e,r){for(var n=e.length,i=v4.allocUnsafe(n),o=-1;++o<n;)i[o]=Cke(t,e[o],r);return i}});var dte=H(cte=>{h();var Nke=ew();function jke(t){return t._prev=t._cipher.encryptBlock(t._prev),t._prev}cte.encrypt=function(t,e){for(;t._cache.length<e.length;)t._cache=C.Buffer.concat([t._cache,jke(t)]);var r=t._cache.slice(0,e.length);return t._cache=t._cache.slice(e.length),Nke(e,r)}});var LD=H((Wwt,ute)=>{h();function Uke(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}}ute.exports=Uke});var FD=H(fte=>{h();var qke=ew(),lte=dr().Buffer,Lke=LD();function Kke(t){var e=t._cipher.encryptBlockRaw(t._prev);return Lke(t._prev),e}var KD=16;fte.encrypt=function(t,e){var r=Math.ceil(e.length/KD),n=t._cache.length;t._cache=lte.concat([t._cache,lte.allocUnsafe(r*KD)]);for(var i=0;i<r;i++){var o=Kke(t),s=n+i*KD;t._cache.writeUInt32BE(o[0],s+0),t._cache.writeUInt32BE(o[1],s+4),t._cache.writeUInt32BE(o[2],s+8),t._cache.writeUInt32BE(o[3],s+12)}var a=t._cache.slice(0,e.length);return t._cache=t._cache.slice(e.length),qke(e,a)}});var zD=H((Zwt,Fke)=>{Fke.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 w4=H((Xwt,hte)=>{h();var zke={ECB:Zee(),CBC:ete(),CFB:nte(),CFB8:ote(),CFB1:ate(),OFB:dte(),CTR:FD(),GCM:FD()},b4=zD();for(VD in b4)b4[VD].module=zke[b4[VD].mode];var VD;hte.exports=b4});var Ux=H((e1t,mte)=>{h();var _4=dr().Buffer;function WD(t){_4.isBuffer(t)||(t=_4.from(t));for(var e=t.length/4|0,r=new Array(e),n=0;n<e;n++)r[n]=t.readUInt32BE(n*4);return r}function HD(t){for(var e=0;e<t.length;t++)t[e]=0}function pte(t,e,r,n,i){for(var o=r[0],s=r[1],a=r[2],d=r[3],u=t[0]^e[0],c=t[1]^e[1],l=t[2]^e[2],m=t[3]^e[3],p,g,v,E,A=4,P=1;P<i;P++)p=o[u>>>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++],v=o[l>>>24]^s[m>>>16&255]^a[u>>>8&255]^d[c&255]^e[A++],E=o[m>>>24]^s[u>>>16&255]^a[c>>>8&255]^d[l&255]^e[A++],u=p,c=g,l=v,m=E;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++],v=(n[l>>>24]<<24|n[m>>>16&255]<<16|n[u>>>8&255]<<8|n[c&255])^e[A++],E=(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,v=v>>>0,E=E>>>0,[p,g,v,E]}var Vke=[0,1,2,4,8,16,32,64,128,27,54],Ni=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 cd(t){this._key=WD(t),this._reset()}cd.blockSize=4*4;cd.keySize=256/8;cd.prototype.blockSize=cd.blockSize;cd.prototype.keySize=cd.keySize;cd.prototype._reset=function(){for(var t=this._key,e=t.length,r=e+6,n=(r+1)*4,i=[],o=0;o<e;o++)i[o]=t[o];for(o=e;o<n;o++){var s=i[o-1];o%e===0?(s=s<<8|s>>>24,s=Ni.SBOX[s>>>24]<<24|Ni.SBOX[s>>>16&255]<<16|Ni.SBOX[s>>>8&255]<<8|Ni.SBOX[s&255],s^=Vke[o/e|0]<<24):e>6&&o%e===4&&(s=Ni.SBOX[s>>>24]<<24|Ni.SBOX[s>>>16&255]<<16|Ni.SBOX[s>>>8&255]<<8|Ni.SBOX[s&255]),i[o]=i[o-e]^s}for(var a=[],d=0;d<n;d++){var u=n-d,c=i[u-(d%4?0:4)];d<4||u<=4?a[d]=c:a[d]=Ni.INV_SUB_MIX[0][Ni.SBOX[c>>>24]]^Ni.INV_SUB_MIX[1][Ni.SBOX[c>>>16&255]]^Ni.INV_SUB_MIX[2][Ni.SBOX[c>>>8&255]]^Ni.INV_SUB_MIX[3][Ni.SBOX[c&255]]}this._nRounds=r,this._keySchedule=i,this._invKeySchedule=a};cd.prototype.encryptBlockRaw=function(t){return t=WD(t),pte(t,this._keySchedule,Ni.SUB_MIX,Ni.SBOX,this._nRounds)};cd.prototype.encryptBlock=function(t){var e=this.encryptBlockRaw(t),r=_4.allocUnsafe(16);return r.writeUInt32BE(e[0],0),r.writeUInt32BE(e[1],4),r.writeUInt32BE(e[2],8),r.writeUInt32BE(e[3],12),r};cd.prototype.decryptBlock=function(t){t=WD(t);var e=t[1];t[1]=t[3],t[3]=e;var r=pte(t,this._invKeySchedule,Ni.INV_SUB_MIX,Ni.INV_SBOX,this._nRounds),n=_4.allocUnsafe(16);return n.writeUInt32BE(r[0],0),n.writeUInt32BE(r[3],4),n.writeUInt32BE(r[2],8),n.writeUInt32BE(r[1],12),n};cd.prototype.scrub=function(){HD(this._keySchedule),HD(this._invKeySchedule),HD(this._key)};mte.exports.AES=cd});var vte=H((r1t,gte)=>{h();var tw=dr().Buffer,Hke=tw.alloc(16,0);function Wke(t){return[t.readUInt32BE(0),t.readUInt32BE(4),t.readUInt32BE(8),t.readUInt32BE(12)]}function yte(t){var e=tw.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 qx(t){this.h=t,this.state=tw.alloc(16,0),this.cache=tw.allocUnsafe(0)}qx.prototype.ghash=function(t){for(var e=-1;++e<t.length;)this.state[e]^=t[e];this._multiply()};qx.prototype._multiply=function(){for(var t=Wke(this.h),e=[0,0,0,0],r,n,i,o=-1;++o<128;){for(n=(this.state[~~(o/8)]&1<<7-o%8)!==0,n&&(e[0]^=t[0],e[1]^=t[1],e[2]^=t[2],e[3]^=t[3]),i=(t[3]&1)!==0,r=3;r>0;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=yte(e)};qx.prototype.update=function(t){this.cache=tw.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)};qx.prototype.final=function(t,e){return this.cache.length&&this.ghash(tw.concat([this.cache,Hke],16)),this.ghash(yte([0,t,0,e])),this.state};gte.exports=qx});var GD=H((i1t,_te)=>{h();var Gke=Ux(),Ba=dr().Buffer,bte=Xf(),Jke=ur(),wte=vte(),Yke=ew(),Zke=LD();function Xke(t,e){var r=0;t.length!==e.length&&r++;for(var n=Math.min(t.length,e.length),i=0;i<n;++i)r+=t[i]^e[i];return r}function Qke(t,e,r){if(e.length===12)return t._finID=Ba.concat([e,Ba.from([0,0,0,1])]),Ba.concat([e,Ba.from([0,0,0,2])]);var n=new wte(r),i=e.length,o=i%16;n.update(e),o&&(o=16-o,n.update(Ba.alloc(o,0))),n.update(Ba.alloc(8,0));var s=i*8,a=Ba.alloc(8);a.writeUIntBE(s,0,8),n.update(a),t._finID=n.state;var d=Ba.from(t._finID);return Zke(d),d}function F0(t,e,r,n){bte.call(this);var i=Ba.alloc(4,0);this._cipher=new Gke.AES(e);var o=this._cipher.encryptBlock(i);this._ghash=new wte(o),r=Qke(this,r,o),this._prev=Ba.from(r),this._cache=Ba.allocUnsafe(0),this._secCache=Ba.allocUnsafe(0),this._decrypt=n,this._alen=0,this._len=0,this._mode=t,this._authTag=null,this._called=!1}Jke(F0,bte);F0.prototype._update=function(t){if(!this._called&&this._alen){var e=16-this._alen%16;e<16&&(e=Ba.alloc(e,0),this._ghash.update(e))}this._called=!0;var r=this._mode.encrypt(this,t);return this._decrypt?this._ghash.update(t):this._ghash.update(r),this._len+=t.length,r};F0.prototype._final=function(){if(this._decrypt&&!this._authTag)throw new Error("Unsupported state or unable to authenticate data");var t=Yke(this._ghash.final(this._alen*8,this._len*8),this._cipher.encryptBlock(this._finID));if(this._decrypt&&Xke(t,this._authTag))throw new Error("Unsupported state or unable to authenticate data");this._authTag=t,this._cipher.scrub()};F0.prototype.getAuthTag=function(){if(this._decrypt||!Ba.isBuffer(this._authTag))throw new Error("Attempting to get auth tag in unsupported state");return this._authTag};F0.prototype.setAuthTag=function(e){if(!this._decrypt)throw new Error("Attempting to set auth tag in unsupported state");this._authTag=e};F0.prototype.setAAD=function(e){if(this._called)throw new Error("Attempting to set AAD in unsupported state");this._ghash.update(e),this._alen+=e.length};_te.exports=F0});var YD=H((s1t,Ete)=>{h();var e9e=Ux(),JD=dr().Buffer,xte=Xf(),t9e=ur();function x4(t,e,r,n){xte.call(this),this._cipher=new e9e.AES(e),this._prev=JD.from(r),this._cache=JD.allocUnsafe(0),this._secCache=JD.allocUnsafe(0),this._decrypt=n,this._mode=t}t9e(x4,xte);x4.prototype._update=function(t){return this._mode.encrypt(this,t,this._decrypt)};x4.prototype._final=function(){this._cipher.scrub()};Ete.exports=x4});var Lx=H((c1t,Ste)=>{h();var z0=dr().Buffer,r9e=r4();function n9e(t,e,r,n){if(z0.isBuffer(t)||(t=z0.from(t,"binary")),e&&(z0.isBuffer(e)||(e=z0.from(e,"binary")),e.length!==8))throw new RangeError("salt should be Buffer with 8 byte length");for(var i=r/8,o=z0.alloc(i),s=z0.alloc(n||0),a=z0.alloc(0);i>0||n>0;){var d=new r9e;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(u<a.length&&n>0){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}}Ste.exports=n9e});var Pte=H(ZD=>{h();var Ate=w4(),i9e=GD(),eh=dr().Buffer,o9e=YD(),Tte=Xf(),s9e=Ux(),a9e=Lx(),c9e=ur();function Kx(t,e,r){Tte.call(this),this._cache=new E4,this._cipher=new s9e.AES(e),this._prev=eh.from(r),this._mode=t,this._autopadding=!0}c9e(Kx,Tte);Kx.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 eh.concat(n)};var d9e=eh.alloc(16,16);Kx.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(d9e))throw this._cipher.scrub(),new Error("data not multiple of block length")};Kx.prototype.setAutoPadding=function(t){return this._autopadding=!!t,this};function E4(){this.cache=eh.allocUnsafe(0)}E4.prototype.add=function(t){this.cache=eh.concat([this.cache,t])};E4.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};E4.prototype.flush=function(){for(var t=16-this.cache.length,e=eh.allocUnsafe(t),r=-1;++r<t;)e.writeUInt8(t,r);return eh.concat([this.cache,e])};function Ite(t,e,r){var n=Ate[t.toLowerCase()];if(!n)throw new TypeError("invalid suite type");if(typeof e=="string"&&(e=eh.from(e)),e.length!==n.key/8)throw new TypeError("invalid key length "+e.length);if(typeof r=="string"&&(r=eh.from(r)),n.mode!=="GCM"&&r.length!==n.iv)throw new TypeError("invalid iv length "+r.length);return n.type==="stream"?new o9e(n.module,e,r):n.type==="auth"?new i9e(n.module,e,r):new Kx(n.module,e,r)}function u9e(t,e){var r=Ate[t.toLowerCase()];if(!r)throw new TypeError("invalid suite type");var n=a9e(e,!1,r.key,r.iv);return Ite(t,n.key,n.iv)}ZD.createCipheriv=Ite;ZD.createCipher=u9e});var Mte=H(XD=>{h();var l9e=GD(),rw=dr().Buffer,kte=w4(),f9e=YD(),Rte=Xf(),h9e=Ux(),p9e=Lx(),m9e=ur();function Fx(t,e,r){Rte.call(this),this._cache=new S4,this._last=void 0,this._cipher=new h9e.AES(e),this._prev=rw.from(r),this._mode=t,this._autopadding=!0}m9e(Fx,Rte);Fx.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 rw.concat(n)};Fx.prototype._final=function(){var t=this._cache.flush();if(this._autopadding)return y9e(this._mode.decrypt(this,t));if(t)throw new Error("data not multiple of block length")};Fx.prototype.setAutoPadding=function(t){return this._autopadding=!!t,this};function S4(){this.cache=rw.allocUnsafe(0)}S4.prototype.add=function(t){this.cache=rw.concat([this.cache,t])};S4.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};S4.prototype.flush=function(){if(this.cache.length)return this.cache};function y9e(t){var e=t[15];if(e<1||e>16)throw new Error("unable to decrypt data");for(var r=-1;++r<e;)if(t[r+(16-e)]!==e)throw new Error("unable to decrypt data");if(e!==16)return t.slice(0,16-e)}function Bte(t,e,r){var n=kte[t.toLowerCase()];if(!n)throw new TypeError("invalid suite type");if(typeof r=="string"&&(r=rw.from(r)),n.mode!=="GCM"&&r.length!==n.iv)throw new TypeError("invalid iv length "+r.length);if(typeof e=="string"&&(e=rw.from(e)),e.length!==n.key/8)throw new TypeError("invalid key length "+e.length);return n.type==="stream"?new f9e(n.module,e,r,!0):n.type==="auth"?new l9e(n.module,e,r,!0):new Fx(n.module,e,r)}function g9e(t,e){var r=kte[t.toLowerCase()];if(!r)throw new TypeError("invalid suite type");var n=p9e(e,!1,r.key,r.iv);return Bte(t,n.key,n.iv)}XD.createDecipher=g9e;XD.createDecipheriv=Bte});var A4=H(ou=>{h();var Dte=Pte(),Ote=Mte(),v9e=zD();function b9e(){return Object.keys(v9e)}ou.createCipher=ou.Cipher=Dte.createCipher;ou.createCipheriv=ou.Cipheriv=Dte.createCipheriv;ou.createDecipher=ou.Decipher=Ote.createDecipher;ou.createDecipheriv=ou.Decipheriv=Ote.createDecipheriv;ou.listCiphers=ou.getCiphers=b9e});var Cte=H(th=>{h();th["des-ecb"]={key:8,iv:0};th["des-cbc"]=th.des={key:8,iv:8};th["des-ede3-cbc"]=th.des3={key:24,iv:8};th["des-ede3"]={key:24,iv:0};th["des-ede-cbc"]={key:16,iv:8};th["des-ede"]={key:16,iv:0}});var qte=H(su=>{h();var $te=Yee(),QD=A4(),tm=w4(),rh=Cte(),Nte=Lx();function w9e(t,e){t=t.toLowerCase();var r,n;if(tm[t])r=tm[t].key,n=tm[t].iv;else if(rh[t])r=rh[t].key*8,n=rh[t].iv;else throw new TypeError("invalid suite type");var i=Nte(e,!1,r,n);return jte(t,i.key,i.iv)}function _9e(t,e){t=t.toLowerCase();var r,n;if(tm[t])r=tm[t].key,n=tm[t].iv;else if(rh[t])r=rh[t].key*8,n=rh[t].iv;else throw new TypeError("invalid suite type");var i=Nte(e,!1,r,n);return Ute(t,i.key,i.iv)}function jte(t,e,r){if(t=t.toLowerCase(),tm[t])return QD.createCipheriv(t,e,r);if(rh[t])return new $te({key:e,iv:r,mode:t});throw new TypeError("invalid suite type")}function Ute(t,e,r){if(t=t.toLowerCase(),tm[t])return QD.createDecipheriv(t,e,r);if(rh[t])return new $te({key:e,iv:r,mode:t,decrypt:!0});throw new TypeError("invalid suite type")}function x9e(){return Object.keys(rh).concat(QD.getCiphers())}su.createCipher=su.Cipher=w9e;su.createCipheriv=su.Cipheriv=jte;su.createDecipher=su.Decipher=_9e;su.createDecipheriv=su.Decipheriv=Ute;su.listCiphers=su.getCiphers=x9e});var eO=H(()=>{h()});var Gi=H((Lte,tO)=>{h();(function(t,e){"use strict";function r(L,T){if(!L)throw new Error(T||"Assertion failed")}function n(L,T){L.super_=T;var S=function(){};S.prototype=T.prototype,L.prototype=new S,L.prototype.constructor=L}function i(L,T,S){if(i.isBN(L))return L;this.negative=0,this.words=null,this.length=0,this.red=null,L!==null&&((T==="le"||T==="be")&&(S=T,T=10),this._init(L||0,T||10,S||"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=eO().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,S){return T.cmp(S)>0?T:S},i.min=function(T,S){return T.cmp(S)<0?T:S},i.prototype._init=function(T,S,k){if(typeof T=="number")return this._initNumber(T,S,k);if(typeof T=="object")return this._initArray(T,S,k);S==="hex"&&(S=16),r(S===(S|0)&&S>=2&&S<=36),T=T.toString().replace(/\s+/g,"");var f=0;T[0]==="-"&&(f++,this.negative=1),f<T.length&&(S===16?this._parseHex(T,f,k):(this._parseBase(T,S,f),k==="le"&&this._initArray(this.toArray(),S,k)))},i.prototype._initNumber=function(T,S,k){T<0&&(this.negative=1,T=-T),T<67108864?(this.words=[T&67108863],this.length=1):T<4503599627370496?(this.words=[T&67108863,T/67108864&67108863],this.length=2):(r(T<9007199254740992),this.words=[T&67108863,T/67108864&67108863,1],this.length=3),k==="le"&&this._initArray(this.toArray(),S,k)},i.prototype._initArray=function(T,S,k){if(r(typeof T.length=="number"),T.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(T.length/3),this.words=new Array(this.length);for(var f=0;f<this.length;f++)this.words[f]=0;var y,w,_=0;if(k==="be")for(f=T.length-1,y=0;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<T.length;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++);return this.strip()};function s(L,T){var S=L.charCodeAt(T);return S>=65&&S<=70?S-55:S>=97&&S<=102?S-87:S-48&15}function a(L,T,S){var k=s(L,S);return S-1>=T&&(k|=s(L,S-1)<<4),k}i.prototype._parseHex=function(T,S,k){this.length=Math.ceil((T.length-S)/6),this.words=new Array(this.length);for(var f=0;f<this.length;f++)this.words[f]=0;var y=0,w=0,_;if(k==="be")for(f=T.length-1;f>=S;f-=2)_=a(T,S,f)<<y,this.words[w]|=_&67108863,y>=18?(y-=18,w+=1,this.words[w]|=_>>>26):y+=8;else{var x=T.length-S;for(f=x%2===0?S+1:S;f<T.length;f+=2)_=a(T,S,f)<<y,this.words[w]|=_&67108863,y>=18?(y-=18,w+=1,this.words[w]|=_>>>26):y+=8}this.strip()};function d(L,T,S,k){for(var f=0,y=Math.min(L.length,S),w=T;w<y;w++){var _=L.charCodeAt(w)-48;f*=k,_>=49?f+=_-49+10:_>=17?f+=_-17+10:f+=_}return f}i.prototype._parseBase=function(T,S,k){this.words=[0],this.length=1;for(var f=0,y=1;y<=67108863;y*=S)f++;f--,y=y/S|0;for(var w=T.length-k,_=w%f,x=Math.min(w,w-_)+k,b=0,B=k;B<x;B+=f)b=d(T,B,B+f,S),this.imuln(y),this.words[0]+b<67108864?this.words[0]+=b:this._iaddn(b);if(_!==0){var q=1;for(b=d(T,B,T.length,S),B=0;B<_;B++)q*=S;this.imuln(q),this.words[0]+b<67108864?this.words[0]+=b:this._iaddn(b)}this.strip()},i.prototype.copy=function(T){T.words=new Array(this.length);for(var S=0;S<this.length;S++)T.words[S]=this.words[S];T.length=this.length,T.negative=this.negative,T.red=this.red},i.prototype.clone=function(){var T=new i(null);return this.copy(T),T},i.prototype._expand=function(T){for(;this.length<T;)this.words[this.length++]=0;return this},i.prototype.strip=function(){for(;this.length>1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},i.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},i.prototype.inspect=function(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"};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,S){T=T||10,S=S|0||1;var k;if(T===16||T==="hex"){k="";for(var f=0,y=0,w=0;w<this.length;w++){var _=this.words[w],x=((_<<f|y)&16777215).toString(16);y=_>>>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%S!==0;)k="0"+k;return this.negative!==0&&(k="-"+k),k}if(T===(T|0)&&T>=2&&T<=36){var b=c[T],B=l[T];k="";var q=this.clone();for(q.negative=0;!q.isZero();){var M=q.modn(B).toString(T);q=q.idivn(B),q.isZero()?k=M+k:k=u[b-M.length]+M+k}for(this.isZero()&&(k="0"+k);k.length%S!==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,S){return r(typeof o<"u"),this.toArrayLike(o,T,S)},i.prototype.toArray=function(T,S){return this.toArrayLike(Array,T,S)},i.prototype.toArrayLike=function(T,S,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=S==="le",_=new T(y),x,b,B=this.clone();if(w){for(b=0;!B.isZero();b++)x=B.andln(255),B.iushrn(8),_[b]=x;for(;b<y;b++)_[b]=0}else{for(b=0;b<y-f;b++)_[b]=0;for(b=0;!B.isZero();b++)x=B.andln(255),B.iushrn(8),_[y-b-1]=x}return _},Math.clz32?i.prototype._countBits=function(T){return 32-Math.clz32(T)}:i.prototype._countBits=function(T){var S=T,k=0;return S>=4096&&(k+=13,S>>>=13),S>=64&&(k+=7,S>>>=7),S>=8&&(k+=4,S>>>=4),S>=2&&(k+=2,S>>>=2),k+S},i.prototype._zeroBits=function(T){if(T===0)return 26;var S=T,k=0;return S&8191||(k+=13,S>>>=13),S&127||(k+=7,S>>>=7),S&15||(k+=4,S>>>=4),S&3||(k+=2,S>>>=2),S&1||k++,k},i.prototype.bitLength=function(){var T=this.words[this.length-1],S=this._countBits(T);return(this.length-1)*26+S};function m(L){for(var T=new Array(L.bitLength()),S=0;S<T.length;S++){var k=S/26|0,f=S%26;T[S]=(L.words[k]&1<<f)>>>f}return T}i.prototype.zeroBits=function(){if(this.isZero())return 0;for(var T=0,S=0;S<this.length;S++){var k=this._zeroBits(this.words[S]);if(T+=k,k!==26)break}return T},i.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},i.prototype.toTwos=function(T){return this.negative!==0?this.abs().inotn(T).iaddn(1):this.clone()},i.prototype.fromTwos=function(T){return this.testn(T-1)?this.notn(T).iaddn(1).ineg():this.clone()},i.prototype.isNeg=function(){return this.negative!==0},i.prototype.neg=function(){return this.clone().ineg()},i.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},i.prototype.iuor=function(T){for(;this.length<T.length;)this.words[this.length++]=0;for(var S=0;S<T.length;S++)this.words[S]=this.words[S]|T.words[S];return this.strip()},i.prototype.ior=function(T){return r((this.negative|T.negative)===0),this.iuor(T)},i.prototype.or=function(T){return this.length>T.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 S;this.length>T.length?S=T:S=this;for(var k=0;k<S.length;k++)this.words[k]=this.words[k]&T.words[k];return this.length=S.length,this.strip()},i.prototype.iand=function(T){return r((this.negative|T.negative)===0),this.iuand(T)},i.prototype.and=function(T){return this.length>T.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 S,k;this.length>T.length?(S=this,k=T):(S=T,k=this);for(var f=0;f<k.length;f++)this.words[f]=S.words[f]^k.words[f];if(this!==S)for(;f<S.length;f++)this.words[f]=S.words[f];return this.length=S.length,this.strip()},i.prototype.ixor=function(T){return r((this.negative|T.negative)===0),this.iuxor(T)},i.prototype.xor=function(T){return this.length>T.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 S=Math.ceil(T/26)|0,k=T%26;this._expand(S),k>0&&S--;for(var f=0;f<S;f++)this.words[f]=~this.words[f]&67108863;return k>0&&(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,S){r(typeof T=="number"&&T>=0);var k=T/26|0,f=T%26;return this._expand(k+1),S?this.words[k]=this.words[k]|1<<f:this.words[k]=this.words[k]&~(1<<f),this.strip()},i.prototype.iadd=function(T){var S;if(this.negative!==0&&T.negative===0)return this.negative=0,S=this.isub(T),this.negative^=1,this._normSign();if(this.negative===0&&T.negative!==0)return T.negative=0,S=this.isub(T),T.negative=1,S._normSign();var k,f;this.length>T.length?(k=this,f=T):(k=T,f=this);for(var y=0,w=0;w<f.length;w++)S=(k.words[w]|0)+(f.words[w]|0)+y,this.words[w]=S&67108863,y=S>>>26;for(;y!==0&&w<k.length;w++)S=(k.words[w]|0)+y,this.words[w]=S&67108863,y=S>>>26;if(this.length=k.length,y!==0)this.words[this.length]=y,this.length++;else if(k!==this)for(;w<k.length;w++)this.words[w]=k.words[w];return this},i.prototype.add=function(T){var S;return T.negative!==0&&this.negative===0?(T.negative=0,S=this.sub(T),T.negative^=1,S):T.negative===0&&this.negative!==0?(this.negative=0,S=T.sub(this),this.negative=1,S):this.length>T.length?this.clone().iadd(T):T.clone().iadd(this)},i.prototype.isub=function(T){if(T.negative!==0){T.negative=0;var S=this.iadd(T);return T.negative=1,S._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;_<y.length;_++)S=(f.words[_]|0)-(y.words[_]|0)+w,w=S>>26,this.words[_]=S&67108863;for(;w!==0&&_<f.length;_++)S=(f.words[_]|0)+w,w=S>>26,this.words[_]=S&67108863;if(w===0&&_<f.length&&f!==this)for(;_<f.length;_++)this.words[_]=f.words[_];return this.length=Math.max(this.length,_),f!==this&&(this.negative=1),this.strip()},i.prototype.sub=function(T){return this.clone().isub(T)};function p(L,T,S){S.negative=T.negative^L.negative;var k=L.length+T.length|0;S.length=k,k=k-1|0;var f=L.words[0]|0,y=T.words[0]|0,w=f*y,_=w&67108863,x=w/67108864|0;S.words[0]=_;for(var b=1;b<k;b++){for(var B=x>>>26,q=x&67108863,M=Math.min(b,T.length-1),j=Math.max(0,b-L.length+1);j<=M;j++){var J=b-j|0;f=L.words[J]|0,y=T.words[j]|0,w=f*y+q,B+=w/67108864|0,q=w&67108863}S.words[b]=q|0,x=B|0}return x!==0?S.words[b]=x|0:S.length--,S.strip()}var g=function(T,S,k){var f=T.words,y=S.words,w=k.words,_=0,x,b,B,q=f[0]|0,M=q&8191,j=q>>>13,J=f[1]|0,Z=J&8191,G=J>>>13,W=f[2]|0,X=W&8191,ee=W>>>13,ue=f[3]|0,ae=ue&8191,ce=ue>>>13,pe=f[4]|0,xe=pe&8191,Ue=pe>>>13,le=f[5]|0,ge=le&8191,be=le>>>13,De=f[6]|0,Ie=De&8191,je=De>>>13,vt=f[7]|0,Ae=vt&8191,Re=vt>>>13,kt=f[8]|0,we=kt&8191,Ee=kt>>>13,Kr=f[9]|0,Fe=Kr&8191,We=Kr>>>13,qs=y[0]|0,ht=qs&8191,Bt=qs>>>13,gi=y[1]|0,Tt=gi&8191,Ze=gi>>>13,$c=y[2]|0,It=$c&8191,Nt=$c>>>13,hy=y[3]|0,Ot=hy&8191,Wt=hy>>>13,Nc=y[4]|0,Gt=Nc&8191,Ft=Nc>>>13,py=y[5]|0,jt=py&8191,zt=py>>>13,my=y[6]|0,Vt=my&8191,Jt=my>>>13,Gh=y[7]|0,Q=Gh&8191,Y=Gh>>>13,te=y[8]|0,re=te&8191,ie=te>>>13,$e=y[9]|0,Pe=$e&8191,Ne=$e>>>13;k.negative=T.negative^S.negative,k.length=19,x=Math.imul(M,ht),b=Math.imul(M,Bt),b=b+Math.imul(j,ht)|0,B=Math.imul(j,Bt);var Tr=(_+x|0)+((b&8191)<<13)|0;_=(B+(b>>>13)|0)+(Tr>>>26)|0,Tr&=67108863,x=Math.imul(Z,ht),b=Math.imul(Z,Bt),b=b+Math.imul(G,ht)|0,B=Math.imul(G,Bt),x=x+Math.imul(M,Tt)|0,b=b+Math.imul(M,Ze)|0,b=b+Math.imul(j,Tt)|0,B=B+Math.imul(j,Ze)|0;var Ut=(_+x|0)+((b&8191)<<13)|0;_=(B+(b>>>13)|0)+(Ut>>>26)|0,Ut&=67108863,x=Math.imul(X,ht),b=Math.imul(X,Bt),b=b+Math.imul(ee,ht)|0,B=Math.imul(ee,Bt),x=x+Math.imul(Z,Tt)|0,b=b+Math.imul(Z,Ze)|0,b=b+Math.imul(G,Tt)|0,B=B+Math.imul(G,Ze)|0,x=x+Math.imul(M,It)|0,b=b+Math.imul(M,Nt)|0,b=b+Math.imul(j,It)|0,B=B+Math.imul(j,Nt)|0;var ut=(_+x|0)+((b&8191)<<13)|0;_=(B+(b>>>13)|0)+(ut>>>26)|0,ut&=67108863,x=Math.imul(ae,ht),b=Math.imul(ae,Bt),b=b+Math.imul(ce,ht)|0,B=Math.imul(ce,Bt),x=x+Math.imul(X,Tt)|0,b=b+Math.imul(X,Ze)|0,b=b+Math.imul(ee,Tt)|0,B=B+Math.imul(ee,Ze)|0,x=x+Math.imul(Z,It)|0,b=b+Math.imul(Z,Nt)|0,b=b+Math.imul(G,It)|0,B=B+Math.imul(G,Nt)|0,x=x+Math.imul(M,Ot)|0,b=b+Math.imul(M,Wt)|0,b=b+Math.imul(j,Ot)|0,B=B+Math.imul(j,Wt)|0;var Yr=(_+x|0)+((b&8191)<<13)|0;_=(B+(b>>>13)|0)+(Yr>>>26)|0,Yr&=67108863,x=Math.imul(xe,ht),b=Math.imul(xe,Bt),b=b+Math.imul(Ue,ht)|0,B=Math.imul(Ue,Bt),x=x+Math.imul(ae,Tt)|0,b=b+Math.imul(ae,Ze)|0,b=b+Math.imul(ce,Tt)|0,B=B+Math.imul(ce,Ze)|0,x=x+Math.imul(X,It)|0,b=b+Math.imul(X,Nt)|0,b=b+Math.imul(ee,It)|0,B=B+Math.imul(ee,Nt)|0,x=x+Math.imul(Z,Ot)|0,b=b+Math.imul(Z,Wt)|0,b=b+Math.imul(G,Ot)|0,B=B+Math.imul(G,Wt)|0,x=x+Math.imul(M,Gt)|0,b=b+Math.imul(M,Ft)|0,b=b+Math.imul(j,Gt)|0,B=B+Math.imul(j,Ft)|0;var cn=(_+x|0)+((b&8191)<<13)|0;_=(B+(b>>>13)|0)+(cn>>>26)|0,cn&=67108863,x=Math.imul(ge,ht),b=Math.imul(ge,Bt),b=b+Math.imul(be,ht)|0,B=Math.imul(be,Bt),x=x+Math.imul(xe,Tt)|0,b=b+Math.imul(xe,Ze)|0,b=b+Math.imul(Ue,Tt)|0,B=B+Math.imul(Ue,Ze)|0,x=x+Math.imul(ae,It)|0,b=b+Math.imul(ae,Nt)|0,b=b+Math.imul(ce,It)|0,B=B+Math.imul(ce,Nt)|0,x=x+Math.imul(X,Ot)|0,b=b+Math.imul(X,Wt)|0,b=b+Math.imul(ee,Ot)|0,B=B+Math.imul(ee,Wt)|0,x=x+Math.imul(Z,Gt)|0,b=b+Math.imul(Z,Ft)|0,b=b+Math.imul(G,Gt)|0,B=B+Math.imul(G,Ft)|0,x=x+Math.imul(M,jt)|0,b=b+Math.imul(M,zt)|0,b=b+Math.imul(j,jt)|0,B=B+Math.imul(j,zt)|0;var Wr=(_+x|0)+((b&8191)<<13)|0;_=(B+(b>>>13)|0)+(Wr>>>26)|0,Wr&=67108863,x=Math.imul(Ie,ht),b=Math.imul(Ie,Bt),b=b+Math.imul(je,ht)|0,B=Math.imul(je,Bt),x=x+Math.imul(ge,Tt)|0,b=b+Math.imul(ge,Ze)|0,b=b+Math.imul(be,Tt)|0,B=B+Math.imul(be,Ze)|0,x=x+Math.imul(xe,It)|0,b=b+Math.imul(xe,Nt)|0,b=b+Math.imul(Ue,It)|0,B=B+Math.imul(Ue,Nt)|0,x=x+Math.imul(ae,Ot)|0,b=b+Math.imul(ae,Wt)|0,b=b+Math.imul(ce,Ot)|0,B=B+Math.imul(ce,Wt)|0,x=x+Math.imul(X,Gt)|0,b=b+Math.imul(X,Ft)|0,b=b+Math.imul(ee,Gt)|0,B=B+Math.imul(ee,Ft)|0,x=x+Math.imul(Z,jt)|0,b=b+Math.imul(Z,zt)|0,b=b+Math.imul(G,jt)|0,B=B+Math.imul(G,zt)|0,x=x+Math.imul(M,Vt)|0,b=b+Math.imul(M,Jt)|0,b=b+Math.imul(j,Vt)|0,B=B+Math.imul(j,Jt)|0;var ar=(_+x|0)+((b&8191)<<13)|0;_=(B+(b>>>13)|0)+(ar>>>26)|0,ar&=67108863,x=Math.imul(Ae,ht),b=Math.imul(Ae,Bt),b=b+Math.imul(Re,ht)|0,B=Math.imul(Re,Bt),x=x+Math.imul(Ie,Tt)|0,b=b+Math.imul(Ie,Ze)|0,b=b+Math.imul(je,Tt)|0,B=B+Math.imul(je,Ze)|0,x=x+Math.imul(ge,It)|0,b=b+Math.imul(ge,Nt)|0,b=b+Math.imul(be,It)|0,B=B+Math.imul(be,Nt)|0,x=x+Math.imul(xe,Ot)|0,b=b+Math.imul(xe,Wt)|0,b=b+Math.imul(Ue,Ot)|0,B=B+Math.imul(Ue,Wt)|0,x=x+Math.imul(ae,Gt)|0,b=b+Math.imul(ae,Ft)|0,b=b+Math.imul(ce,Gt)|0,B=B+Math.imul(ce,Ft)|0,x=x+Math.imul(X,jt)|0,b=b+Math.imul(X,zt)|0,b=b+Math.imul(ee,jt)|0,B=B+Math.imul(ee,zt)|0,x=x+Math.imul(Z,Vt)|0,b=b+Math.imul(Z,Jt)|0,b=b+Math.imul(G,Vt)|0,B=B+Math.imul(G,Jt)|0,x=x+Math.imul(M,Q)|0,b=b+Math.imul(M,Y)|0,b=b+Math.imul(j,Q)|0,B=B+Math.imul(j,Y)|0;var Zr=(_+x|0)+((b&8191)<<13)|0;_=(B+(b>>>13)|0)+(Zr>>>26)|0,Zr&=67108863,x=Math.imul(we,ht),b=Math.imul(we,Bt),b=b+Math.imul(Ee,ht)|0,B=Math.imul(Ee,Bt),x=x+Math.imul(Ae,Tt)|0,b=b+Math.imul(Ae,Ze)|0,b=b+Math.imul(Re,Tt)|0,B=B+Math.imul(Re,Ze)|0,x=x+Math.imul(Ie,It)|0,b=b+Math.imul(Ie,Nt)|0,b=b+Math.imul(je,It)|0,B=B+Math.imul(je,Nt)|0,x=x+Math.imul(ge,Ot)|0,b=b+Math.imul(ge,Wt)|0,b=b+Math.imul(be,Ot)|0,B=B+Math.imul(be,Wt)|0,x=x+Math.imul(xe,Gt)|0,b=b+Math.imul(xe,Ft)|0,b=b+Math.imul(Ue,Gt)|0,B=B+Math.imul(Ue,Ft)|0,x=x+Math.imul(ae,jt)|0,b=b+Math.imul(ae,zt)|0,b=b+Math.imul(ce,jt)|0,B=B+Math.imul(ce,zt)|0,x=x+Math.imul(X,Vt)|0,b=b+Math.imul(X,Jt)|0,b=b+Math.imul(ee,Vt)|0,B=B+Math.imul(ee,Jt)|0,x=x+Math.imul(Z,Q)|0,b=b+Math.imul(Z,Y)|0,b=b+Math.imul(G,Q)|0,B=B+Math.imul(G,Y)|0,x=x+Math.imul(M,re)|0,b=b+Math.imul(M,ie)|0,b=b+Math.imul(j,re)|0,B=B+Math.imul(j,ie)|0;var Br=(_+x|0)+((b&8191)<<13)|0;_=(B+(b>>>13)|0)+(Br>>>26)|0,Br&=67108863,x=Math.imul(Fe,ht),b=Math.imul(Fe,Bt),b=b+Math.imul(We,ht)|0,B=Math.imul(We,Bt),x=x+Math.imul(we,Tt)|0,b=b+Math.imul(we,Ze)|0,b=b+Math.imul(Ee,Tt)|0,B=B+Math.imul(Ee,Ze)|0,x=x+Math.imul(Ae,It)|0,b=b+Math.imul(Ae,Nt)|0,b=b+Math.imul(Re,It)|0,B=B+Math.imul(Re,Nt)|0,x=x+Math.imul(Ie,Ot)|0,b=b+Math.imul(Ie,Wt)|0,b=b+Math.imul(je,Ot)|0,B=B+Math.imul(je,Wt)|0,x=x+Math.imul(ge,Gt)|0,b=b+Math.imul(ge,Ft)|0,b=b+Math.imul(be,Gt)|0,B=B+Math.imul(be,Ft)|0,x=x+Math.imul(xe,jt)|0,b=b+Math.imul(xe,zt)|0,b=b+Math.imul(Ue,jt)|0,B=B+Math.imul(Ue,zt)|0,x=x+Math.imul(ae,Vt)|0,b=b+Math.imul(ae,Jt)|0,b=b+Math.imul(ce,Vt)|0,B=B+Math.imul(ce,Jt)|0,x=x+Math.imul(X,Q)|0,b=b+Math.imul(X,Y)|0,b=b+Math.imul(ee,Q)|0,B=B+Math.imul(ee,Y)|0,x=x+Math.imul(Z,re)|0,b=b+Math.imul(Z,ie)|0,b=b+Math.imul(G,re)|0,B=B+Math.imul(G,ie)|0,x=x+Math.imul(M,Pe)|0,b=b+Math.imul(M,Ne)|0,b=b+Math.imul(j,Pe)|0,B=B+Math.imul(j,Ne)|0;var Ls=(_+x|0)+((b&8191)<<13)|0;_=(B+(b>>>13)|0)+(Ls>>>26)|0,Ls&=67108863,x=Math.imul(Fe,Tt),b=Math.imul(Fe,Ze),b=b+Math.imul(We,Tt)|0,B=Math.imul(We,Ze),x=x+Math.imul(we,It)|0,b=b+Math.imul(we,Nt)|0,b=b+Math.imul(Ee,It)|0,B=B+Math.imul(Ee,Nt)|0,x=x+Math.imul(Ae,Ot)|0,b=b+Math.imul(Ae,Wt)|0,b=b+Math.imul(Re,Ot)|0,B=B+Math.imul(Re,Wt)|0,x=x+Math.imul(Ie,Gt)|0,b=b+Math.imul(Ie,Ft)|0,b=b+Math.imul(je,Gt)|0,B=B+Math.imul(je,Ft)|0,x=x+Math.imul(ge,jt)|0,b=b+Math.imul(ge,zt)|0,b=b+Math.imul(be,jt)|0,B=B+Math.imul(be,zt)|0,x=x+Math.imul(xe,Vt)|0,b=b+Math.imul(xe,Jt)|0,b=b+Math.imul(Ue,Vt)|0,B=B+Math.imul(Ue,Jt)|0,x=x+Math.imul(ae,Q)|0,b=b+Math.imul(ae,Y)|0,b=b+Math.imul(ce,Q)|0,B=B+Math.imul(ce,Y)|0,x=x+Math.imul(X,re)|0,b=b+Math.imul(X,ie)|0,b=b+Math.imul(ee,re)|0,B=B+Math.imul(ee,ie)|0,x=x+Math.imul(Z,Pe)|0,b=b+Math.imul(Z,Ne)|0,b=b+Math.imul(G,Pe)|0,B=B+Math.imul(G,Ne)|0;var vi=(_+x|0)+((b&8191)<<13)|0;_=(B+(b>>>13)|0)+(vi>>>26)|0,vi&=67108863,x=Math.imul(Fe,It),b=Math.imul(Fe,Nt),b=b+Math.imul(We,It)|0,B=Math.imul(We,Nt),x=x+Math.imul(we,Ot)|0,b=b+Math.imul(we,Wt)|0,b=b+Math.imul(Ee,Ot)|0,B=B+Math.imul(Ee,Wt)|0,x=x+Math.imul(Ae,Gt)|0,b=b+Math.imul(Ae,Ft)|0,b=b+Math.imul(Re,Gt)|0,B=B+Math.imul(Re,Ft)|0,x=x+Math.imul(Ie,jt)|0,b=b+Math.imul(Ie,zt)|0,b=b+Math.imul(je,jt)|0,B=B+Math.imul(je,zt)|0,x=x+Math.imul(ge,Vt)|0,b=b+Math.imul(ge,Jt)|0,b=b+Math.imul(be,Vt)|0,B=B+Math.imul(be,Jt)|0,x=x+Math.imul(xe,Q)|0,b=b+Math.imul(xe,Y)|0,b=b+Math.imul(Ue,Q)|0,B=B+Math.imul(Ue,Y)|0,x=x+Math.imul(ae,re)|0,b=b+Math.imul(ae,ie)|0,b=b+Math.imul(ce,re)|0,B=B+Math.imul(ce,ie)|0,x=x+Math.imul(X,Pe)|0,b=b+Math.imul(X,Ne)|0,b=b+Math.imul(ee,Pe)|0,B=B+Math.imul(ee,Ne)|0;var Mi=(_+x|0)+((b&8191)<<13)|0;_=(B+(b>>>13)|0)+(Mi>>>26)|0,Mi&=67108863,x=Math.imul(Fe,Ot),b=Math.imul(Fe,Wt),b=b+Math.imul(We,Ot)|0,B=Math.imul(We,Wt),x=x+Math.imul(we,Gt)|0,b=b+Math.imul(we,Ft)|0,b=b+Math.imul(Ee,Gt)|0,B=B+Math.imul(Ee,Ft)|0,x=x+Math.imul(Ae,jt)|0,b=b+Math.imul(Ae,zt)|0,b=b+Math.imul(Re,jt)|0,B=B+Math.imul(Re,zt)|0,x=x+Math.imul(Ie,Vt)|0,b=b+Math.imul(Ie,Jt)|0,b=b+Math.imul(je,Vt)|0,B=B+Math.imul(je,Jt)|0,x=x+Math.imul(ge,Q)|0,b=b+Math.imul(ge,Y)|0,b=b+Math.imul(be,Q)|0,B=B+Math.imul(be,Y)|0,x=x+Math.imul(xe,re)|0,b=b+Math.imul(xe,ie)|0,b=b+Math.imul(Ue,re)|0,B=B+Math.imul(Ue,ie)|0,x=x+Math.imul(ae,Pe)|0,b=b+Math.imul(ae,Ne)|0,b=b+Math.imul(ce,Pe)|0,B=B+Math.imul(ce,Ne)|0;var Cr=(_+x|0)+((b&8191)<<13)|0;_=(B+(b>>>13)|0)+(Cr>>>26)|0,Cr&=67108863,x=Math.imul(Fe,Gt),b=Math.imul(Fe,Ft),b=b+Math.imul(We,Gt)|0,B=Math.imul(We,Ft),x=x+Math.imul(we,jt)|0,b=b+Math.imul(we,zt)|0,b=b+Math.imul(Ee,jt)|0,B=B+Math.imul(Ee,zt)|0,x=x+Math.imul(Ae,Vt)|0,b=b+Math.imul(Ae,Jt)|0,b=b+Math.imul(Re,Vt)|0,B=B+Math.imul(Re,Jt)|0,x=x+Math.imul(Ie,Q)|0,b=b+Math.imul(Ie,Y)|0,b=b+Math.imul(je,Q)|0,B=B+Math.imul(je,Y)|0,x=x+Math.imul(ge,re)|0,b=b+Math.imul(ge,ie)|0,b=b+Math.imul(be,re)|0,B=B+Math.imul(be,ie)|0,x=x+Math.imul(xe,Pe)|0,b=b+Math.imul(xe,Ne)|0,b=b+Math.imul(Ue,Pe)|0,B=B+Math.imul(Ue,Ne)|0;var bi=(_+x|0)+((b&8191)<<13)|0;_=(B+(b>>>13)|0)+(bi>>>26)|0,bi&=67108863,x=Math.imul(Fe,jt),b=Math.imul(Fe,zt),b=b+Math.imul(We,jt)|0,B=Math.imul(We,zt),x=x+Math.imul(we,Vt)|0,b=b+Math.imul(we,Jt)|0,b=b+Math.imul(Ee,Vt)|0,B=B+Math.imul(Ee,Jt)|0,x=x+Math.imul(Ae,Q)|0,b=b+Math.imul(Ae,Y)|0,b=b+Math.imul(Re,Q)|0,B=B+Math.imul(Re,Y)|0,x=x+Math.imul(Ie,re)|0,b=b+Math.imul(Ie,ie)|0,b=b+Math.imul(je,re)|0,B=B+Math.imul(je,ie)|0,x=x+Math.imul(ge,Pe)|0,b=b+Math.imul(ge,Ne)|0,b=b+Math.imul(be,Pe)|0,B=B+Math.imul(be,Ne)|0;var Di=(_+x|0)+((b&8191)<<13)|0;_=(B+(b>>>13)|0)+(Di>>>26)|0,Di&=67108863,x=Math.imul(Fe,Vt),b=Math.imul(Fe,Jt),b=b+Math.imul(We,Vt)|0,B=Math.imul(We,Jt),x=x+Math.imul(we,Q)|0,b=b+Math.imul(we,Y)|0,b=b+Math.imul(Ee,Q)|0,B=B+Math.imul(Ee,Y)|0,x=x+Math.imul(Ae,re)|0,b=b+Math.imul(Ae,ie)|0,b=b+Math.imul(Re,re)|0,B=B+Math.imul(Re,ie)|0,x=x+Math.imul(Ie,Pe)|0,b=b+Math.imul(Ie,Ne)|0,b=b+Math.imul(je,Pe)|0,B=B+Math.imul(je,Ne)|0;var oo=(_+x|0)+((b&8191)<<13)|0;_=(B+(b>>>13)|0)+(oo>>>26)|0,oo&=67108863,x=Math.imul(Fe,Q),b=Math.imul(Fe,Y),b=b+Math.imul(We,Q)|0,B=Math.imul(We,Y),x=x+Math.imul(we,re)|0,b=b+Math.imul(we,ie)|0,b=b+Math.imul(Ee,re)|0,B=B+Math.imul(Ee,ie)|0,x=x+Math.imul(Ae,Pe)|0,b=b+Math.imul(Ae,Ne)|0,b=b+Math.imul(Re,Pe)|0,B=B+Math.imul(Re,Ne)|0;var Ks=(_+x|0)+((b&8191)<<13)|0;_=(B+(b>>>13)|0)+(Ks>>>26)|0,Ks&=67108863,x=Math.imul(Fe,re),b=Math.imul(Fe,ie),b=b+Math.imul(We,re)|0,B=Math.imul(We,ie),x=x+Math.imul(we,Pe)|0,b=b+Math.imul(we,Ne)|0,b=b+Math.imul(Ee,Pe)|0,B=B+Math.imul(Ee,Ne)|0;var Do=(_+x|0)+((b&8191)<<13)|0;_=(B+(b>>>13)|0)+(Do>>>26)|0,Do&=67108863,x=Math.imul(Fe,Pe),b=Math.imul(Fe,Ne),b=b+Math.imul(We,Pe)|0,B=Math.imul(We,Ne);var Ga=(_+x|0)+((b&8191)<<13)|0;return _=(B+(b>>>13)|0)+(Ga>>>26)|0,Ga&=67108863,w[0]=Tr,w[1]=Ut,w[2]=ut,w[3]=Yr,w[4]=cn,w[5]=Wr,w[6]=ar,w[7]=Zr,w[8]=Br,w[9]=Ls,w[10]=vi,w[11]=Mi,w[12]=Cr,w[13]=bi,w[14]=Di,w[15]=oo,w[16]=Ks,w[17]=Do,w[18]=Ga,_!==0&&(w[19]=_,k.length++),k};Math.imul||(g=p);function v(L,T,S){S.negative=T.negative^L.negative,S.length=L.length+T.length;for(var k=0,f=0,y=0;y<S.length-1;y++){var w=f;f=0;for(var _=k&67108863,x=Math.min(y,T.length-1),b=Math.max(0,y-L.length+1);b<=x;b++){var B=y-b,q=L.words[B]|0,M=T.words[b]|0,j=q*M,J=j&67108863;w=w+(j/67108864|0)|0,J=J+_|0,_=J&67108863,w=w+(J>>>26)|0,f+=w>>>26,w&=67108863}S.words[y]=_,k=w,w=f}return k!==0?S.words[y]=k:S.length--,S.strip()}function E(L,T,S){var k=new A;return k.mulp(L,T,S)}i.prototype.mulTo=function(T,S){var k,f=this.length+T.length;return this.length===10&&T.length===10?k=g(this,T,S):f<63?k=p(this,T,S):f<1024?k=v(this,T,S):k=E(this,T,S),k};function A(L,T){this.x=L,this.y=T}A.prototype.makeRBT=function(T){for(var S=new Array(T),k=i.prototype._countBits(T)-1,f=0;f<T;f++)S[f]=this.revBin(f,k,T);return S},A.prototype.revBin=function(T,S,k){if(T===0||T===k-1)return T;for(var f=0,y=0;y<S;y++)f|=(T&1)<<S-y-1,T>>=1;return f},A.prototype.permute=function(T,S,k,f,y,w){for(var _=0;_<w;_++)f[_]=S[T[_]],y[_]=k[T[_]]},A.prototype.transform=function(T,S,k,f,y,w){this.permute(w,T,S,k,f,y);for(var _=1;_<y;_<<=1)for(var x=_<<1,b=Math.cos(2*Math.PI/x),B=Math.sin(2*Math.PI/x),q=0;q<y;q+=x)for(var M=b,j=B,J=0;J<_;J++){var Z=k[q+J],G=f[q+J],W=k[q+J+_],X=f[q+J+_],ee=M*W-j*X;X=M*X+j*W,W=ee,k[q+J]=Z+W,f[q+J]=G+X,k[q+J+_]=Z-W,f[q+J+_]=G-X,J!==x&&(ee=b*M-B*j,j=b*j+B*M,M=ee)}},A.prototype.guessLen13b=function(T,S){var k=Math.max(S,T)|1,f=k&1,y=0;for(k=k/2|0;k;k=k>>>1)y++;return 1<<y+1+f},A.prototype.conjugate=function(T,S,k){if(!(k<=1))for(var f=0;f<k/2;f++){var y=T[f];T[f]=T[k-f-1],T[k-f-1]=y,y=S[f],S[f]=-S[k-f-1],S[k-f-1]=-y}},A.prototype.normalize13b=function(T,S){for(var k=0,f=0;f<S/2;f++){var y=Math.round(T[2*f+1]/S)*8192+Math.round(T[2*f]/S)+k;T[f]=y&67108863,y<67108864?k=0:k=y/67108864|0}return T},A.prototype.convert13b=function(T,S,k,f){for(var y=0,w=0;w<S;w++)y=y+(T[w]|0),k[2*w]=y&8191,y=y>>>13,k[2*w+1]=y&8191,y=y>>>13;for(w=2*S;w<f;++w)k[w]=0;r(y===0),r((y&-8192)===0)},A.prototype.stub=function(T){for(var S=new Array(T),k=0;k<T;k++)S[k]=0;return S},A.prototype.mulp=function(T,S,k){var f=2*this.guessLen13b(T.length,S.length),y=this.makeRBT(f),w=this.stub(f),_=new Array(f),x=new Array(f),b=new Array(f),B=new Array(f),q=new Array(f),M=new Array(f),j=k.words;j.length=f,this.convert13b(T.words,T.length,_,f),this.convert13b(S.words,S.length,B,f),this.transform(_,w,x,b,f,y),this.transform(B,w,q,M,f,y);for(var J=0;J<f;J++){var Z=x[J]*q[J]-b[J]*M[J];b[J]=x[J]*M[J]+b[J]*q[J],x[J]=Z}return this.conjugate(x,b,f),this.transform(x,b,j,w,f,y),this.conjugate(j,w,f),this.normalize13b(j,f),k.negative=T.negative^S.negative,k.length=T.length+S.length,k.strip()},i.prototype.mul=function(T){var S=new i(null);return S.words=new Array(this.length+T.length),this.mulTo(T,S)},i.prototype.mulf=function(T){var S=new i(null);return S.words=new Array(this.length+T.length),E(this,T,S)},i.prototype.imul=function(T){return this.clone().mulTo(T,this)},i.prototype.imuln=function(T){r(typeof T=="number"),r(T<67108864);for(var S=0,k=0;k<this.length;k++){var f=(this.words[k]|0)*T,y=(f&67108863)+(S&67108863);S>>=26,S+=f/67108864|0,S+=y>>>26,this.words[k]=y&67108863}return S!==0&&(this.words[k]=S,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 S=m(T);if(S.length===0)return new i(1);for(var k=this,f=0;f<S.length&&S[f]===0;f++,k=k.sqr());if(++f<S.length)for(var y=k.sqr();f<S.length;f++,y=y.sqr())S[f]!==0&&(k=k.mul(y));return k},i.prototype.iushln=function(T){r(typeof T=="number"&&T>=0);var S=T%26,k=(T-S)/26,f=67108863>>>26-S<<26-S,y;if(S!==0){var w=0;for(y=0;y<this.length;y++){var _=this.words[y]&f,x=(this.words[y]|0)-_<<S;this.words[y]=x|w,w=_>>>26-S}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<k;y++)this.words[y]=0;this.length+=k}return this.strip()},i.prototype.ishln=function(T){return r(this.negative===0),this.iushln(T)},i.prototype.iushrn=function(T,S,k){r(typeof T=="number"&&T>=0);var f;S?f=(S-S%26)/26:f=0;var y=T%26,w=Math.min((T-y)/26,this.length),_=67108863^67108863>>>y<<y,x=k;if(f-=w,f=Math.max(0,f),x){for(var b=0;b<w;b++)x.words[b]=this.words[b];x.length=w}if(w!==0)if(this.length>w)for(this.length-=w,b=0;b<this.length;b++)this.words[b]=this.words[b+w];else this.words[0]=0,this.length=1;var B=0;for(b=this.length-1;b>=0&&(B!==0||b>=f);b--){var q=this.words[b]|0;this.words[b]=B<<26-y|q>>>y,B=q&_}return x&&B!==0&&(x.words[x.length++]=B),this.length===0&&(this.words[0]=0,this.length=1),this.strip()},i.prototype.ishrn=function(T,S,k){return r(this.negative===0),this.iushrn(T,S,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 S=T%26,k=(T-S)/26,f=1<<S;if(this.length<=k)return!1;var y=this.words[k];return!!(y&f)},i.prototype.imaskn=function(T){r(typeof T=="number"&&T>=0);var S=T%26,k=(T-S)/26;if(r(this.negative===0,"imaskn works only with positive numbers"),this.length<=k)return this;if(S!==0&&k++,this.length=Math.min(k,this.length),S!==0){var f=67108863^67108863>>>S<<S;this.words[this.length-1]&=f}return this.strip()},i.prototype.maskn=function(T){return this.clone().imaskn(T)},i.prototype.iaddn=function(T){return r(typeof T=="number"),r(T<67108864),T<0?this.isubn(-T):this.negative!==0?this.length===1&&(this.words[0]|0)<T?(this.words[0]=T-(this.words[0]|0),this.negative=0,this):(this.negative=0,this.isubn(T),this.negative=1,this):this._iaddn(T)},i.prototype._iaddn=function(T){this.words[0]+=T;for(var S=0;S<this.length&&this.words[S]>=67108864;S++)this.words[S]-=67108864,S===this.length-1?this.words[S+1]=1:this.words[S+1]++;return this.length=Math.max(this.length,S+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 S=0;S<this.length&&this.words[S]<0;S++)this.words[S]+=67108864,this.words[S+1]-=1;return this.strip()},i.prototype.addn=function(T){return this.clone().iaddn(T)},i.prototype.subn=function(T){return this.clone().isubn(T)},i.prototype.iabs=function(){return this.negative=0,this},i.prototype.abs=function(){return this.clone().iabs()},i.prototype._ishlnsubmul=function(T,S,k){var f=T.length+k,y;this._expand(f);var w,_=0;for(y=0;y<T.length;y++){w=(this.words[y+k]|0)+_;var x=(T.words[y]|0)*S;w-=x&67108863,_=(w>>26)-(x/67108864|0),this.words[y+k]=w&67108863}for(;y<this.length-k;y++)w=(this.words[y+k]|0)+_,_=w>>26,this.words[y+k]=w&67108863;if(_===0)return this.strip();for(r(_===-1),_=0,y=0;y<this.length;y++)w=-(this.words[y]|0)+_,_=w>>26,this.words[y]=w&67108863;return this.negative=1,this.strip()},i.prototype._wordDiv=function(T,S){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,b;if(S!=="mod"){b=new i(null),b.length=x+1,b.words=new Array(b.length);for(var B=0;B<b.length;B++)b.words[B]=0}var q=f.clone()._ishlnsubmul(y,1,x);q.negative===0&&(f=q,b&&(b.words[x]=1));for(var M=x-1;M>=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);b&&(b.words[M]=j)}return b&&b.strip(),f.strip(),S!=="div"&&k!==0&&f.iushrn(k),{div:b||null,mod:f}},i.prototype.divmod=function(T,S,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,S),S!=="mod"&&(f=w.div.neg()),S!=="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(),S),S!=="mod"&&(f=w.div.neg()),{div:f,mod:w.mod}):this.negative&T.negative?(w=this.neg().divmod(T.neg(),S),S!=="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?S==="div"?{div:this.divn(T.words[0]),mod:null}:S==="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,S)},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 S=this.divmod(T);if(S.mod.isZero())return S.div;var k=S.div.negative!==0?S.mod.isub(T):S.mod,f=T.ushrn(1),y=T.andln(1),w=k.cmp(f);return w<0||y===1&&w===0?S.div:S.div.negative!==0?S.div.isubn(1):S.div.iaddn(1)},i.prototype.modn=function(T){r(T<=67108863);for(var S=(1<<26)%T,k=0,f=this.length-1;f>=0;f--)k=(S*k+(this.words[f]|0))%T;return k},i.prototype.idivn=function(T){r(T<=67108863);for(var S=0,k=this.length-1;k>=0;k--){var f=(this.words[k]|0)+S*67108864;this.words[k]=f/T|0,S=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 S=this,k=T.clone();S.negative!==0?S=S.umod(T):S=S.clone();for(var f=new i(1),y=new i(0),w=new i(0),_=new i(1),x=0;S.isEven()&&k.isEven();)S.iushrn(1),k.iushrn(1),++x;for(var b=k.clone(),B=S.clone();!S.isZero();){for(var q=0,M=1;!(S.words[0]&M)&&q<26;++q,M<<=1);if(q>0)for(S.iushrn(q);q-- >0;)(f.isOdd()||y.isOdd())&&(f.iadd(b),y.isub(B)),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(b),_.isub(B)),w.iushrn(1),_.iushrn(1);S.cmp(k)>=0?(S.isub(k),f.isub(w),y.isub(_)):(k.isub(S),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 S=this,k=T.clone();S.negative!==0?S=S.umod(T):S=S.clone();for(var f=new i(1),y=new i(0),w=k.clone();S.cmpn(1)>0&&k.cmpn(1)>0;){for(var _=0,x=1;!(S.words[0]&x)&&_<26;++_,x<<=1);if(_>0)for(S.iushrn(_);_-- >0;)f.isOdd()&&f.iadd(w),f.iushrn(1);for(var b=0,B=1;!(k.words[0]&B)&&b<26;++b,B<<=1);if(b>0)for(k.iushrn(b);b-- >0;)y.isOdd()&&y.iadd(w),y.iushrn(1);S.cmp(k)>=0?(S.isub(k),f.isub(y)):(k.isub(S),y.isub(f))}var q;return S.cmpn(1)===0?q=f:q=y,q.cmpn(0)<0&&q.iadd(T),q},i.prototype.gcd=function(T){if(this.isZero())return T.abs();if(T.isZero())return this.abs();var S=this.clone(),k=T.clone();S.negative=0,k.negative=0;for(var f=0;S.isEven()&&k.isEven();f++)S.iushrn(1),k.iushrn(1);do{for(;S.isEven();)S.iushrn(1);for(;k.isEven();)k.iushrn(1);var y=S.cmp(k);if(y<0){var w=S;S=k,k=w}else if(y===0||k.cmpn(1)===0)break;S.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 S=T%26,k=(T-S)/26,f=1<<S;if(this.length<=k)return this._expand(k+1),this.words[k]|=f,this;for(var y=f,w=k;y!==0&&w<this.length;w++){var _=this.words[w]|0;_+=y,y=_>>>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 S=T<0;if(this.negative!==0&&!S)return-1;if(this.negative===0&&S)return 1;this.strip();var k;if(this.length>1)k=1;else{S&&(T=-T),r(T<=67108863,"Number is too big");var f=this.words[0]|0;k=f===T?0:f<T?-1:1}return this.negative!==0?-k|0:k},i.prototype.cmp=function(T){if(this.negative!==0&&T.negative===0)return-1;if(this.negative===0&&T.negative!==0)return 1;var S=this.ucmp(T);return this.negative!==0?-S|0:S},i.prototype.ucmp=function(T){if(this.length>T.length)return 1;if(this.length<T.length)return-1;for(var S=0,k=this.length-1;k>=0;k--){var f=this.words[k]|0,y=T.words[k]|0;if(f!==y){f<y?S=-1:f>y&&(S=1);break}}return S},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 P={k256:null,p224:null,p192:null,p25519:null};function I(L,T){this.name=L,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()}I.prototype._tmp=function(){var T=new i(null);return T.words=new Array(Math.ceil(this.n/13)),T},I.prototype.ireduce=function(T){var S=T,k;do this.split(S,this.tmp),S=this.imulK(S),S=S.iadd(this.tmp),k=S.bitLength();while(k>this.n);var f=k<this.n?-1:S.ucmp(this.p);return f===0?(S.words[0]=0,S.length=1):f>0?S.isub(this.p):S.strip!==void 0?S.strip():S._strip(),S},I.prototype.split=function(T,S){T.iushrn(this.n,0,S)},I.prototype.imulK=function(T){return T.imul(this.k)};function $(){I.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}n($,I),$.prototype.split=function(T,S){for(var k=4194303,f=Math.min(T.length,9),y=0;y<f;y++)S.words[y]=T.words[y];if(S.length=f,T.length<=9){T.words[0]=0,T.length=1;return}var w=T.words[9];for(S.words[S.length++]=w&k,y=10;y<T.length;y++){var _=T.words[y]|0;T.words[y-10]=(_&k)<<4|w>>>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 S=0,k=0;k<T.length;k++){var f=T.words[k]|0;S+=f*977,T.words[k]=S&67108863,S=f*64+(S/67108864|0)}return T.words[T.length-1]===0&&(T.length--,T.words[T.length-1]===0&&T.length--),T};function N(){I.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}n(N,I);function K(){I.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}n(K,I);function F(){I.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}n(F,I),F.prototype.imulK=function(T){for(var S=0,k=0;k<T.length;k++){var f=(T.words[k]|0)*19+S,y=f&67108863;f>>>=26,T.words[k]=y,S=f}return S!==0&&(T.words[T.length++]=S),T},i._prime=function(T){if(P[T])return P[T];var S;if(T==="k256")S=new $;else if(T==="p224")S=new N;else if(T==="p192")S=new K;else if(T==="p25519")S=new F;else throw new Error("Unknown prime "+T);return P[T]=S,S};function U(L){if(typeof L=="string"){var T=i._prime(L);this.m=T.p,this.prime=T}else r(L.gtn(1),"modulus must be greater than 1"),this.m=L,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,S){r((T.negative|S.negative)===0,"red works only with positives"),r(T.red&&T.red===S.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,S){this._verify2(T,S);var k=T.add(S);return k.cmp(this.m)>=0&&k.isub(this.m),k._forceRed(this)},U.prototype.iadd=function(T,S){this._verify2(T,S);var k=T.iadd(S);return k.cmp(this.m)>=0&&k.isub(this.m),k},U.prototype.sub=function(T,S){this._verify2(T,S);var k=T.sub(S);return k.cmpn(0)<0&&k.iadd(this.m),k._forceRed(this)},U.prototype.isub=function(T,S){this._verify2(T,S);var k=T.isub(S);return k.cmpn(0)<0&&k.iadd(this.m),k},U.prototype.shl=function(T,S){return this._verify1(T),this.imod(T.ushln(S))},U.prototype.imul=function(T,S){return this._verify2(T,S),this.imod(T.imul(S))},U.prototype.mul=function(T,S){return this._verify2(T,S),this.imod(T.mul(S))},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 S=this.m.andln(3);if(r(S%2===1),S===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),b=this.m.bitLength();for(b=new i(2*b*b).toRed(this);this.pow(b,x).cmp(_)!==0;)b.redIAdd(_);for(var B=this.pow(b,f),q=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<j);var G=this.pow(B,new i(1).iushln(j-Z-1));q=q.redMul(G),B=G.redSqr(),M=M.redMul(B),j=Z}return q},U.prototype.invm=function(T){var S=T._invmp(this.m);return S.negative!==0?(S.negative=0,this.imod(S).redNeg()):this.imod(S)},U.prototype.pow=function(T,S){if(S.isZero())return new i(1).toRed(this);if(S.cmpn(1)===0)return T.clone();var k=4,f=new Array(1<<k);f[0]=new i(1).toRed(this),f[1]=T;for(var y=2;y<f.length;y++)f[y]=this.mul(f[y-1],T);var w=f[0],_=0,x=0,b=S.bitLength()%26;for(b===0&&(b=26),y=S.length-1;y>=0;y--){for(var B=S.words[y],q=b-1;q>=0;q--){var M=B>>q&1;if(w!==f[0]&&(w=this.sqr(w)),M===0&&_===0){x=0;continue}_<<=1,_|=M,x++,!(x!==k&&(y!==0||q!==0))&&(w=this.mul(w,f[_]),x=0,_=0)}b=26}return w},U.prototype.convertTo=function(T){var S=T.umod(this.m);return S===T?S.clone():S},U.prototype.convertFrom=function(T){var S=T.clone();return S.red=null,S},i.mont=function(T){return new V(T)};function V(L){U.call(this,L),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new i(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}n(V,U),V.prototype.convertTo=function(T){return this.imod(T.ushln(this.shift))},V.prototype.convertFrom=function(T){var S=this.imod(T.mul(this.rinv));return S.red=null,S},V.prototype.imul=function(T,S){if(T.isZero()||S.isZero())return T.words[0]=0,T.length=1,T;var k=T.imul(S),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)},V.prototype.mul=function(T,S){if(T.isZero()||S.isZero())return new i(0)._forceRed(this);var k=T.mul(S),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)},V.prototype.invm=function(T){var S=this.imod(T._invmp(this.m).mul(this.r2));return S._forceRed(this)}})(typeof tO>"u"||tO,Lte)});var T4=H((S1t,iO)=>{h();var rO;iO.exports=function(e){return rO||(rO=new rm(null)),rO.generate(e)};function rm(t){this.rand=t}iO.exports.Rand=rm;rm.prototype.generate=function(e){return this._rand(e)};rm.prototype._rand=function(e){if(this.rand.getBytes)return this.rand.getBytes(e);for(var r=new Uint8Array(e),n=0;n<r.length;n++)r[n]=this.rand.getByte();return r};if(typeof self=="object")self.crypto&&self.crypto.getRandomValues?rm.prototype._rand=function(e){var r=new Uint8Array(e);return self.crypto.getRandomValues(r),r}:self.msCrypto&&self.msCrypto.getRandomValues?rm.prototype._rand=function(e){var r=new Uint8Array(e);return self.msCrypto.getRandomValues(r),r}:typeof window=="object"&&(rm.prototype._rand=function(){throw new Error("Not implemented yet")});else try{if(nO=I4(),typeof nO.randomBytes!="function")throw new Error("Not supported");rm.prototype._rand=function(e){return nO.randomBytes(e)}}catch{}var nO});var oO=H((T1t,Kte)=>{h();var V0=Gi(),E9e=T4();function H0(t){this.rand=t||new E9e.Rand}Kte.exports=H0;H0.create=function(e){return new H0(e)};H0.prototype._randbelow=function(e){var r=e.bitLength(),n=Math.ceil(r/8);do var i=new V0(this.rand.generate(n));while(i.cmp(e)>=0);return i};H0.prototype._randrange=function(e,r){var n=r.sub(e);return e.add(this._randbelow(n))};H0.prototype.test=function(e,r,n){var i=e.bitLength(),o=V0.mont(e),s=new V0(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 V0(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;g<d;g++){if(p=p.redSqr(),p.cmp(s)===0)return!1;if(p.cmp(c)===0)break}if(g===d)return!1}}return l};H0.prototype.getDivisor=function(e,r){var n=e.bitLength(),i=V0.mont(e),o=new V0(1).toRed(i);r||(r=Math.max(1,n/48|0));for(var s=e.subn(1),a=0;!s.testn(a);a++);for(var d=e.shrn(a),u=s.toRed(i);r>0;r--){var c=this._randrange(new V0(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<a;p++){if(m=m.redSqr(),m.cmp(o)===0)return m.fromRed().subn(1).gcd(e);if(m.cmp(u)===0)break}if(p===a)return m=m.redSqr(),m.fromRed().subn(1).gcd(e)}}return!1}});var lO=H((M1t,Vte)=>{h();var S9e=B0();Vte.exports=uO;uO.simpleSieve=cO;uO.fermatTest=dO;var Ko=Gi(),A9e=new Ko(24),T9e=oO(),Fte=new T9e,I9e=new Ko(1),aO=new Ko(2),P9e=new Ko(5),P1t=new Ko(16),k1t=new Ko(8),k9e=new Ko(10),R9e=new Ko(3),R1t=new Ko(7),B9e=new Ko(11),zte=new Ko(4),B1t=new Ko(12),sO=null;function M9e(){if(sO!==null)return sO;var t=1048576,e=[];e[0]=2;for(var r=1,n=3;n<t;n+=2){for(var i=Math.ceil(Math.sqrt(n)),o=0;o<r&&e[o]<=i&&n%e[o]!==0;o++);r!==o&&e[o]<=i||(e[r++]=n)}return sO=e,e}function cO(t){for(var e=M9e(),r=0;r<e.length;r++)if(t.modn(e[r])===0)return t.cmpn(e[r])===0;return!0}function dO(t){var e=Ko.mont(t);return aO.toRed(e).redPow(t.subn(1)).fromRed().cmpn(1)===0}function uO(t,e){if(t<16)return e===2||e===5?new Ko([140,123]):new Ko([140,39]);e=new Ko(e);for(var r,n;;){for(r=new Ko(S9e(Math.ceil(t/8)));r.bitLength()>t;)r.ishrn(1);if(r.isEven()&&r.iadd(I9e),r.testn(1)||r.iadd(aO),e.cmp(aO)){if(!e.cmp(P9e))for(;r.mod(k9e).cmp(R9e);)r.iadd(zte)}else for(;r.mod(A9e).cmp(B9e);)r.iadd(zte);if(n=r.shrn(1),cO(n)&&cO(r)&&dO(n)&&dO(r)&&Fte.test(n)&&Fte.test(r))return r}}});var Hte=H((O1t,D9e)=>{D9e.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 Yte=H((C1t,Jte)=>{h();var dd=Gi(),O9e=oO(),Wte=new O9e,C9e=new dd(24),$9e=new dd(11),N9e=new dd(10),j9e=new dd(3),U9e=new dd(7),Gte=lO(),q9e=B0();Jte.exports=nh;function L9e(t,e){return e=e||"utf8",C.Buffer.isBuffer(t)||(t=new C.Buffer(t,e)),this._pub=new dd(t),this}function K9e(t,e){return e=e||"utf8",C.Buffer.isBuffer(t)||(t=new C.Buffer(t,e)),this._priv=new dd(t),this}var P4={};function F9e(t,e){var r=e.toString("hex"),n=[r,t.toString(16)].join("_");if(n in P4)return P4[n];var i=0;if(t.isEven()||!Gte.simpleSieve||!Gte.fermatTest(t)||!Wte.test(t))return i+=1,r==="02"||r==="05"?i+=8:i+=4,P4[n]=i,i;Wte.test(t.shrn(1))||(i+=2);var o;switch(r){case"02":t.mod(C9e).cmp($9e)&&(i+=8);break;case"05":o=t.mod(N9e),o.cmp(j9e)&&o.cmp(U9e)&&(i+=8);break;default:i+=4}return P4[n]=i,i}function nh(t,e,r){this.setGenerator(e),this.__prime=new dd(t),this._prime=dd.mont(this.__prime),this._primeLen=t.length,this._pub=void 0,this._priv=void 0,this._primeCode=void 0,r?(this.setPublicKey=L9e,this.setPrivateKey=K9e):this._primeCode=8}Object.defineProperty(nh.prototype,"verifyError",{enumerable:!0,get:function(){return typeof this._primeCode!="number"&&(this._primeCode=F9e(this.__prime,this.__gen)),this._primeCode}});nh.prototype.generateKeys=function(){return this._priv||(this._priv=new dd(q9e(this._primeLen))),this._pub=this._gen.toRed(this._prime).redPow(this._priv).fromRed(),this.getPublicKey()};nh.prototype.computeSecret=function(t){t=new dd(t),t=t.toRed(this._prime);var e=t.redPow(this._priv).fromRed(),r=new C.Buffer(e.toArray()),n=this.getPrime();if(r.length<n.length){var i=new C.Buffer(n.length-r.length);i.fill(0),r=C.Buffer.concat([i,r])}return r};nh.prototype.getPublicKey=function(e){return k4(this._pub,e)};nh.prototype.getPrivateKey=function(e){return k4(this._priv,e)};nh.prototype.getPrime=function(t){return k4(this.__prime,t)};nh.prototype.getGenerator=function(t){return k4(this._gen,t)};nh.prototype.setGenerator=function(t,e){return e=e||"utf8",C.Buffer.isBuffer(t)||(t=new C.Buffer(t,e)),this.__gen=t,this._gen=new dd(t),this};function k4(t,e){var r=new C.Buffer(t.toArray());return e?r.toString(e):r}});var Qte=H(nw=>{h();var z9e=lO(),Zte=Hte(),fO=Yte();function V9e(t){var e=new C.Buffer(Zte[t].prime,"hex"),r=new C.Buffer(Zte[t].gen,"hex");return new fO(e,r)}var H9e={binary:!0,hex:!0,base64:!0};function Xte(t,e,r,n){return C.Buffer.isBuffer(e)||H9e[e]===void 0?Xte(t,"binary",e,r):(e=e||"binary",n=n||"binary",r=r||new C.Buffer([2]),C.Buffer.isBuffer(r)||(r=new C.Buffer(r,n)),typeof t=="number"?new fO(z9e(t,r),r,!0):(C.Buffer.isBuffer(t)||(t=new C.Buffer(t,e)),new fO(t,r,!0)))}nw.DiffieHellmanGroup=nw.createDiffieHellmanGroup=nw.getDiffieHellman=V9e;nw.createDiffieHellman=nw.DiffieHellman=Xte});var R4=H((ere,hO)=>{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=eO().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),_<f.length&&(y===16?this._parseHex(f,_,w):(this._parseBase(f,y,_),w==="le"&&this._initArray(this.toArray(),y,w)))},i.prototype._initNumber=function(f,y,w){f<0&&(this.negative=1,f=-f),f<67108864?(this.words=[f&67108863],this.length=1):f<4503599627370496?(this.words=[f&67108863,f/67108864&67108863],this.length=2):(r(f<9007199254740992),this.words=[f&67108863,f/67108864&67108863,1],this.length=3),w==="le"&&this._initArray(this.toArray(),y,w)},i.prototype._initArray=function(f,y,w){if(r(typeof f.length=="number"),f.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(f.length/3),this.words=new Array(this.length);for(var _=0;_<this.length;_++)this.words[_]=0;var x,b,B=0;if(w==="be")for(_=f.length-1,x=0;_>=0;_-=3)b=f[_]|f[_-1]<<8|f[_-2]<<16,this.words[x]|=b<<B&67108863,this.words[x+1]=b>>>26-B&67108863,B+=24,B>=26&&(B-=26,x++);else if(w==="le")for(_=0,x=0;_<f.length;_+=3)b=f[_]|f[_+1]<<8|f[_+2]<<16,this.words[x]|=b<<B&67108863,this.words[x+1]=b>>>26-B&67108863,B+=24,B>=26&&(B-=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;_<this.length;_++)this.words[_]=0;var x=0,b=0,B;if(w==="be")for(_=f.length-1;_>=y;_-=2)B=a(f,y,_)<<x,this.words[b]|=B&67108863,x>=18?(x-=18,b+=1,this.words[b]|=B>>>26):x+=8;else{var q=f.length-y;for(_=q%2===0?y+1:y;_<f.length;_+=2)B=a(f,y,_)<<x,this.words[b]|=B&67108863,x>=18?(x-=18,b+=1,this.words[b]|=B>>>26):x+=8}this._strip()};function d(k,f,y,w){for(var _=0,x=0,b=Math.min(k.length,y),B=f;B<b;B++){var q=k.charCodeAt(B)-48;_*=w,q>=49?x=q-49+10:q>=17?x=q-17+10:x=q,r(q>=0&&x<w,"Invalid character"),_+=x}return _}i.prototype._parseBase=function(f,y,w){this.words=[0],this.length=1;for(var _=0,x=1;x<=67108863;x*=y)_++;_--,x=x/y|0;for(var b=f.length-w,B=b%_,q=Math.min(b,b-B)+w,M=0,j=w;j<q;j+=_)M=d(f,j,j+_,y),this.imuln(x),this.words[0]+M<67108864?this.words[0]+=M:this._iaddn(M);if(B!==0){var J=1;for(M=d(f,j,f.length,y),j=0;j<B;j++)J*=y;this.imuln(J),this.words[0]+M<67108864?this.words[0]+=M:this._iaddn(M)}this._strip()},i.prototype.copy=function(f){f.words=new Array(this.length);for(var y=0;y<this.length;y++)f.words[y]=this.words[y];f.length=this.length,f.negative=this.negative,f.red=this.red};function u(k,f){k.words=f.words,k.length=f.length,k.negative=f.negative,k.red=f.red}if(i.prototype._move=function(f){u(f,this)},i.prototype.clone=function(){var f=new i(null);return this.copy(f),f},i.prototype._expand=function(f){for(;this.length<f;)this.words[this.length++]=0;return this},i.prototype._strip=function(){for(;this.length>1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},i.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},typeof Symbol<"u"&&typeof Symbol.for=="function")try{i.prototype[Symbol.for("nodejs.util.inspect.custom")]=c}catch{i.prototype.inspect=c}else i.prototype.inspect=c;function c(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}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,b=0;b<this.length;b++){var B=this.words[b],q=((B<<_|x)&16777215).toString(16);x=B>>>24-_&16777215,_+=2,_>=26&&(_-=26,b--),x!==0||b!==this.length-1?w=l[6-q.length]+q+w:w=q+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 b=g(f,x),B=y==="le"?"LE":"BE";return this["_toArrayLike"+B](b,_),b},i.prototype._toArrayLikeLE=function(f,y){for(var w=0,_=0,x=0,b=0;x<this.length;x++){var B=this.words[x]<<b|_;f[w++]=B&255,w<f.length&&(f[w++]=B>>8&255),w<f.length&&(f[w++]=B>>16&255),b===6?(w<f.length&&(f[w++]=B>>24&255),_=0,b=0):(_=B>>>24,b+=2)}if(w<f.length)for(f[w++]=_;w<f.length;)f[w++]=0},i.prototype._toArrayLikeBE=function(f,y){for(var w=f.length-1,_=0,x=0,b=0;x<this.length;x++){var B=this.words[x]<<b|_;f[w--]=B&255,w>=0&&(f[w--]=B>>8&255),w>=0&&(f[w--]=B>>16&255),b===6?(w>=0&&(f[w--]=B>>24&255),_=0,b=0):(_=B>>>24,b+=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 v(k){for(var f=new Array(k.bitLength()),y=0;y<f.length;y++){var w=y/26|0,_=y%26;f[y]=k.words[w]>>>_&1}return f}i.prototype.zeroBits=function(){if(this.isZero())return 0;for(var f=0,y=0;y<this.length;y++){var w=this._zeroBits(this.words[y]);if(f+=w,w!==26)break}return f},i.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},i.prototype.toTwos=function(f){return this.negative!==0?this.abs().inotn(f).iaddn(1):this.clone()},i.prototype.fromTwos=function(f){return this.testn(f-1)?this.notn(f).iaddn(1).ineg():this.clone()},i.prototype.isNeg=function(){return this.negative!==0},i.prototype.neg=function(){return this.clone().ineg()},i.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},i.prototype.iuor=function(f){for(;this.length<f.length;)this.words[this.length++]=0;for(var y=0;y<f.length;y++)this.words[y]=this.words[y]|f.words[y];return this._strip()},i.prototype.ior=function(f){return r((this.negative|f.negative)===0),this.iuor(f)},i.prototype.or=function(f){return this.length>f.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;w<y.length;w++)this.words[w]=this.words[w]&f.words[w];return this.length=y.length,this._strip()},i.prototype.iand=function(f){return r((this.negative|f.negative)===0),this.iuand(f)},i.prototype.and=function(f){return this.length>f.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;_<w.length;_++)this.words[_]=y.words[_]^w.words[_];if(this!==y)for(;_<y.length;_++)this.words[_]=y.words[_];return this.length=y.length,this._strip()},i.prototype.ixor=function(f){return r((this.negative|f.negative)===0),this.iuxor(f)},i.prototype.xor=function(f){return this.length>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;_<y;_++)this.words[_]=~this.words[_]&67108863;return w>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,b=0;b<_.length;b++)y=(w.words[b]|0)+(_.words[b]|0)+x,this.words[b]=y&67108863,x=y>>>26;for(;x!==0&&b<w.length;b++)y=(w.words[b]|0)+x,this.words[b]=y&67108863,x=y>>>26;if(this.length=w.length,x!==0)this.words[this.length]=x,this.length++;else if(w!==this)for(;b<w.length;b++)this.words[b]=w.words[b];return this},i.prototype.add=function(f){var y;return f.negative!==0&&this.negative===0?(f.negative=0,y=this.sub(f),f.negative^=1,y):f.negative===0&&this.negative!==0?(this.negative=0,y=f.sub(this),this.negative=1,y):this.length>f.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 b=0,B=0;B<x.length;B++)y=(_.words[B]|0)-(x.words[B]|0)+b,b=y>>26,this.words[B]=y&67108863;for(;b!==0&&B<_.length;B++)y=(_.words[B]|0)+b,b=y>>26,this.words[B]=y&67108863;if(b===0&&B<_.length&&_!==this)for(;B<_.length;B++)this.words[B]=_.words[B];return this.length=Math.max(this.length,B),_!==this&&(this.negative=1),this._strip()},i.prototype.sub=function(f){return this.clone().isub(f)};function E(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,b=_*x,B=b&67108863,q=b/67108864|0;y.words[0]=B;for(var M=1;M<w;M++){for(var j=q>>>26,J=q&67108863,Z=Math.min(M,f.length-1),G=Math.max(0,M-k.length+1);G<=Z;G++){var W=M-G|0;_=k.words[W]|0,x=f.words[G]|0,b=_*x+J,j+=b/67108864|0,J=b&67108863}y.words[M]=J|0,q=j|0}return q!==0?y.words[M]=q|0:y.length--,y._strip()}var A=function(f,y,w){var _=f.words,x=y.words,b=w.words,B=0,q,M,j,J=_[0]|0,Z=J&8191,G=J>>>13,W=_[1]|0,X=W&8191,ee=W>>>13,ue=_[2]|0,ae=ue&8191,ce=ue>>>13,pe=_[3]|0,xe=pe&8191,Ue=pe>>>13,le=_[4]|0,ge=le&8191,be=le>>>13,De=_[5]|0,Ie=De&8191,je=De>>>13,vt=_[6]|0,Ae=vt&8191,Re=vt>>>13,kt=_[7]|0,we=kt&8191,Ee=kt>>>13,Kr=_[8]|0,Fe=Kr&8191,We=Kr>>>13,qs=_[9]|0,ht=qs&8191,Bt=qs>>>13,gi=x[0]|0,Tt=gi&8191,Ze=gi>>>13,$c=x[1]|0,It=$c&8191,Nt=$c>>>13,hy=x[2]|0,Ot=hy&8191,Wt=hy>>>13,Nc=x[3]|0,Gt=Nc&8191,Ft=Nc>>>13,py=x[4]|0,jt=py&8191,zt=py>>>13,my=x[5]|0,Vt=my&8191,Jt=my>>>13,Gh=x[6]|0,Q=Gh&8191,Y=Gh>>>13,te=x[7]|0,re=te&8191,ie=te>>>13,$e=x[8]|0,Pe=$e&8191,Ne=$e>>>13,Tr=x[9]|0,Ut=Tr&8191,ut=Tr>>>13;w.negative=f.negative^y.negative,w.length=19,q=Math.imul(Z,Tt),M=Math.imul(Z,Ze),M=M+Math.imul(G,Tt)|0,j=Math.imul(G,Ze);var Yr=(B+q|0)+((M&8191)<<13)|0;B=(j+(M>>>13)|0)+(Yr>>>26)|0,Yr&=67108863,q=Math.imul(X,Tt),M=Math.imul(X,Ze),M=M+Math.imul(ee,Tt)|0,j=Math.imul(ee,Ze),q=q+Math.imul(Z,It)|0,M=M+Math.imul(Z,Nt)|0,M=M+Math.imul(G,It)|0,j=j+Math.imul(G,Nt)|0;var cn=(B+q|0)+((M&8191)<<13)|0;B=(j+(M>>>13)|0)+(cn>>>26)|0,cn&=67108863,q=Math.imul(ae,Tt),M=Math.imul(ae,Ze),M=M+Math.imul(ce,Tt)|0,j=Math.imul(ce,Ze),q=q+Math.imul(X,It)|0,M=M+Math.imul(X,Nt)|0,M=M+Math.imul(ee,It)|0,j=j+Math.imul(ee,Nt)|0,q=q+Math.imul(Z,Ot)|0,M=M+Math.imul(Z,Wt)|0,M=M+Math.imul(G,Ot)|0,j=j+Math.imul(G,Wt)|0;var Wr=(B+q|0)+((M&8191)<<13)|0;B=(j+(M>>>13)|0)+(Wr>>>26)|0,Wr&=67108863,q=Math.imul(xe,Tt),M=Math.imul(xe,Ze),M=M+Math.imul(Ue,Tt)|0,j=Math.imul(Ue,Ze),q=q+Math.imul(ae,It)|0,M=M+Math.imul(ae,Nt)|0,M=M+Math.imul(ce,It)|0,j=j+Math.imul(ce,Nt)|0,q=q+Math.imul(X,Ot)|0,M=M+Math.imul(X,Wt)|0,M=M+Math.imul(ee,Ot)|0,j=j+Math.imul(ee,Wt)|0,q=q+Math.imul(Z,Gt)|0,M=M+Math.imul(Z,Ft)|0,M=M+Math.imul(G,Gt)|0,j=j+Math.imul(G,Ft)|0;var ar=(B+q|0)+((M&8191)<<13)|0;B=(j+(M>>>13)|0)+(ar>>>26)|0,ar&=67108863,q=Math.imul(ge,Tt),M=Math.imul(ge,Ze),M=M+Math.imul(be,Tt)|0,j=Math.imul(be,Ze),q=q+Math.imul(xe,It)|0,M=M+Math.imul(xe,Nt)|0,M=M+Math.imul(Ue,It)|0,j=j+Math.imul(Ue,Nt)|0,q=q+Math.imul(ae,Ot)|0,M=M+Math.imul(ae,Wt)|0,M=M+Math.imul(ce,Ot)|0,j=j+Math.imul(ce,Wt)|0,q=q+Math.imul(X,Gt)|0,M=M+Math.imul(X,Ft)|0,M=M+Math.imul(ee,Gt)|0,j=j+Math.imul(ee,Ft)|0,q=q+Math.imul(Z,jt)|0,M=M+Math.imul(Z,zt)|0,M=M+Math.imul(G,jt)|0,j=j+Math.imul(G,zt)|0;var Zr=(B+q|0)+((M&8191)<<13)|0;B=(j+(M>>>13)|0)+(Zr>>>26)|0,Zr&=67108863,q=Math.imul(Ie,Tt),M=Math.imul(Ie,Ze),M=M+Math.imul(je,Tt)|0,j=Math.imul(je,Ze),q=q+Math.imul(ge,It)|0,M=M+Math.imul(ge,Nt)|0,M=M+Math.imul(be,It)|0,j=j+Math.imul(be,Nt)|0,q=q+Math.imul(xe,Ot)|0,M=M+Math.imul(xe,Wt)|0,M=M+Math.imul(Ue,Ot)|0,j=j+Math.imul(Ue,Wt)|0,q=q+Math.imul(ae,Gt)|0,M=M+Math.imul(ae,Ft)|0,M=M+Math.imul(ce,Gt)|0,j=j+Math.imul(ce,Ft)|0,q=q+Math.imul(X,jt)|0,M=M+Math.imul(X,zt)|0,M=M+Math.imul(ee,jt)|0,j=j+Math.imul(ee,zt)|0,q=q+Math.imul(Z,Vt)|0,M=M+Math.imul(Z,Jt)|0,M=M+Math.imul(G,Vt)|0,j=j+Math.imul(G,Jt)|0;var Br=(B+q|0)+((M&8191)<<13)|0;B=(j+(M>>>13)|0)+(Br>>>26)|0,Br&=67108863,q=Math.imul(Ae,Tt),M=Math.imul(Ae,Ze),M=M+Math.imul(Re,Tt)|0,j=Math.imul(Re,Ze),q=q+Math.imul(Ie,It)|0,M=M+Math.imul(Ie,Nt)|0,M=M+Math.imul(je,It)|0,j=j+Math.imul(je,Nt)|0,q=q+Math.imul(ge,Ot)|0,M=M+Math.imul(ge,Wt)|0,M=M+Math.imul(be,Ot)|0,j=j+Math.imul(be,Wt)|0,q=q+Math.imul(xe,Gt)|0,M=M+Math.imul(xe,Ft)|0,M=M+Math.imul(Ue,Gt)|0,j=j+Math.imul(Ue,Ft)|0,q=q+Math.imul(ae,jt)|0,M=M+Math.imul(ae,zt)|0,M=M+Math.imul(ce,jt)|0,j=j+Math.imul(ce,zt)|0,q=q+Math.imul(X,Vt)|0,M=M+Math.imul(X,Jt)|0,M=M+Math.imul(ee,Vt)|0,j=j+Math.imul(ee,Jt)|0,q=q+Math.imul(Z,Q)|0,M=M+Math.imul(Z,Y)|0,M=M+Math.imul(G,Q)|0,j=j+Math.imul(G,Y)|0;var Ls=(B+q|0)+((M&8191)<<13)|0;B=(j+(M>>>13)|0)+(Ls>>>26)|0,Ls&=67108863,q=Math.imul(we,Tt),M=Math.imul(we,Ze),M=M+Math.imul(Ee,Tt)|0,j=Math.imul(Ee,Ze),q=q+Math.imul(Ae,It)|0,M=M+Math.imul(Ae,Nt)|0,M=M+Math.imul(Re,It)|0,j=j+Math.imul(Re,Nt)|0,q=q+Math.imul(Ie,Ot)|0,M=M+Math.imul(Ie,Wt)|0,M=M+Math.imul(je,Ot)|0,j=j+Math.imul(je,Wt)|0,q=q+Math.imul(ge,Gt)|0,M=M+Math.imul(ge,Ft)|0,M=M+Math.imul(be,Gt)|0,j=j+Math.imul(be,Ft)|0,q=q+Math.imul(xe,jt)|0,M=M+Math.imul(xe,zt)|0,M=M+Math.imul(Ue,jt)|0,j=j+Math.imul(Ue,zt)|0,q=q+Math.imul(ae,Vt)|0,M=M+Math.imul(ae,Jt)|0,M=M+Math.imul(ce,Vt)|0,j=j+Math.imul(ce,Jt)|0,q=q+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,q=q+Math.imul(Z,re)|0,M=M+Math.imul(Z,ie)|0,M=M+Math.imul(G,re)|0,j=j+Math.imul(G,ie)|0;var vi=(B+q|0)+((M&8191)<<13)|0;B=(j+(M>>>13)|0)+(vi>>>26)|0,vi&=67108863,q=Math.imul(Fe,Tt),M=Math.imul(Fe,Ze),M=M+Math.imul(We,Tt)|0,j=Math.imul(We,Ze),q=q+Math.imul(we,It)|0,M=M+Math.imul(we,Nt)|0,M=M+Math.imul(Ee,It)|0,j=j+Math.imul(Ee,Nt)|0,q=q+Math.imul(Ae,Ot)|0,M=M+Math.imul(Ae,Wt)|0,M=M+Math.imul(Re,Ot)|0,j=j+Math.imul(Re,Wt)|0,q=q+Math.imul(Ie,Gt)|0,M=M+Math.imul(Ie,Ft)|0,M=M+Math.imul(je,Gt)|0,j=j+Math.imul(je,Ft)|0,q=q+Math.imul(ge,jt)|0,M=M+Math.imul(ge,zt)|0,M=M+Math.imul(be,jt)|0,j=j+Math.imul(be,zt)|0,q=q+Math.imul(xe,Vt)|0,M=M+Math.imul(xe,Jt)|0,M=M+Math.imul(Ue,Vt)|0,j=j+Math.imul(Ue,Jt)|0,q=q+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,q=q+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,q=q+Math.imul(Z,Pe)|0,M=M+Math.imul(Z,Ne)|0,M=M+Math.imul(G,Pe)|0,j=j+Math.imul(G,Ne)|0;var Mi=(B+q|0)+((M&8191)<<13)|0;B=(j+(M>>>13)|0)+(Mi>>>26)|0,Mi&=67108863,q=Math.imul(ht,Tt),M=Math.imul(ht,Ze),M=M+Math.imul(Bt,Tt)|0,j=Math.imul(Bt,Ze),q=q+Math.imul(Fe,It)|0,M=M+Math.imul(Fe,Nt)|0,M=M+Math.imul(We,It)|0,j=j+Math.imul(We,Nt)|0,q=q+Math.imul(we,Ot)|0,M=M+Math.imul(we,Wt)|0,M=M+Math.imul(Ee,Ot)|0,j=j+Math.imul(Ee,Wt)|0,q=q+Math.imul(Ae,Gt)|0,M=M+Math.imul(Ae,Ft)|0,M=M+Math.imul(Re,Gt)|0,j=j+Math.imul(Re,Ft)|0,q=q+Math.imul(Ie,jt)|0,M=M+Math.imul(Ie,zt)|0,M=M+Math.imul(je,jt)|0,j=j+Math.imul(je,zt)|0,q=q+Math.imul(ge,Vt)|0,M=M+Math.imul(ge,Jt)|0,M=M+Math.imul(be,Vt)|0,j=j+Math.imul(be,Jt)|0,q=q+Math.imul(xe,Q)|0,M=M+Math.imul(xe,Y)|0,M=M+Math.imul(Ue,Q)|0,j=j+Math.imul(Ue,Y)|0,q=q+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,q=q+Math.imul(X,Pe)|0,M=M+Math.imul(X,Ne)|0,M=M+Math.imul(ee,Pe)|0,j=j+Math.imul(ee,Ne)|0,q=q+Math.imul(Z,Ut)|0,M=M+Math.imul(Z,ut)|0,M=M+Math.imul(G,Ut)|0,j=j+Math.imul(G,ut)|0;var Cr=(B+q|0)+((M&8191)<<13)|0;B=(j+(M>>>13)|0)+(Cr>>>26)|0,Cr&=67108863,q=Math.imul(ht,It),M=Math.imul(ht,Nt),M=M+Math.imul(Bt,It)|0,j=Math.imul(Bt,Nt),q=q+Math.imul(Fe,Ot)|0,M=M+Math.imul(Fe,Wt)|0,M=M+Math.imul(We,Ot)|0,j=j+Math.imul(We,Wt)|0,q=q+Math.imul(we,Gt)|0,M=M+Math.imul(we,Ft)|0,M=M+Math.imul(Ee,Gt)|0,j=j+Math.imul(Ee,Ft)|0,q=q+Math.imul(Ae,jt)|0,M=M+Math.imul(Ae,zt)|0,M=M+Math.imul(Re,jt)|0,j=j+Math.imul(Re,zt)|0,q=q+Math.imul(Ie,Vt)|0,M=M+Math.imul(Ie,Jt)|0,M=M+Math.imul(je,Vt)|0,j=j+Math.imul(je,Jt)|0,q=q+Math.imul(ge,Q)|0,M=M+Math.imul(ge,Y)|0,M=M+Math.imul(be,Q)|0,j=j+Math.imul(be,Y)|0,q=q+Math.imul(xe,re)|0,M=M+Math.imul(xe,ie)|0,M=M+Math.imul(Ue,re)|0,j=j+Math.imul(Ue,ie)|0,q=q+Math.imul(ae,Pe)|0,M=M+Math.imul(ae,Ne)|0,M=M+Math.imul(ce,Pe)|0,j=j+Math.imul(ce,Ne)|0,q=q+Math.imul(X,Ut)|0,M=M+Math.imul(X,ut)|0,M=M+Math.imul(ee,Ut)|0,j=j+Math.imul(ee,ut)|0;var bi=(B+q|0)+((M&8191)<<13)|0;B=(j+(M>>>13)|0)+(bi>>>26)|0,bi&=67108863,q=Math.imul(ht,Ot),M=Math.imul(ht,Wt),M=M+Math.imul(Bt,Ot)|0,j=Math.imul(Bt,Wt),q=q+Math.imul(Fe,Gt)|0,M=M+Math.imul(Fe,Ft)|0,M=M+Math.imul(We,Gt)|0,j=j+Math.imul(We,Ft)|0,q=q+Math.imul(we,jt)|0,M=M+Math.imul(we,zt)|0,M=M+Math.imul(Ee,jt)|0,j=j+Math.imul(Ee,zt)|0,q=q+Math.imul(Ae,Vt)|0,M=M+Math.imul(Ae,Jt)|0,M=M+Math.imul(Re,Vt)|0,j=j+Math.imul(Re,Jt)|0,q=q+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,q=q+Math.imul(ge,re)|0,M=M+Math.imul(ge,ie)|0,M=M+Math.imul(be,re)|0,j=j+Math.imul(be,ie)|0,q=q+Math.imul(xe,Pe)|0,M=M+Math.imul(xe,Ne)|0,M=M+Math.imul(Ue,Pe)|0,j=j+Math.imul(Ue,Ne)|0,q=q+Math.imul(ae,Ut)|0,M=M+Math.imul(ae,ut)|0,M=M+Math.imul(ce,Ut)|0,j=j+Math.imul(ce,ut)|0;var Di=(B+q|0)+((M&8191)<<13)|0;B=(j+(M>>>13)|0)+(Di>>>26)|0,Di&=67108863,q=Math.imul(ht,Gt),M=Math.imul(ht,Ft),M=M+Math.imul(Bt,Gt)|0,j=Math.imul(Bt,Ft),q=q+Math.imul(Fe,jt)|0,M=M+Math.imul(Fe,zt)|0,M=M+Math.imul(We,jt)|0,j=j+Math.imul(We,zt)|0,q=q+Math.imul(we,Vt)|0,M=M+Math.imul(we,Jt)|0,M=M+Math.imul(Ee,Vt)|0,j=j+Math.imul(Ee,Jt)|0,q=q+Math.imul(Ae,Q)|0,M=M+Math.imul(Ae,Y)|0,M=M+Math.imul(Re,Q)|0,j=j+Math.imul(Re,Y)|0,q=q+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,q=q+Math.imul(ge,Pe)|0,M=M+Math.imul(ge,Ne)|0,M=M+Math.imul(be,Pe)|0,j=j+Math.imul(be,Ne)|0,q=q+Math.imul(xe,Ut)|0,M=M+Math.imul(xe,ut)|0,M=M+Math.imul(Ue,Ut)|0,j=j+Math.imul(Ue,ut)|0;var oo=(B+q|0)+((M&8191)<<13)|0;B=(j+(M>>>13)|0)+(oo>>>26)|0,oo&=67108863,q=Math.imul(ht,jt),M=Math.imul(ht,zt),M=M+Math.imul(Bt,jt)|0,j=Math.imul(Bt,zt),q=q+Math.imul(Fe,Vt)|0,M=M+Math.imul(Fe,Jt)|0,M=M+Math.imul(We,Vt)|0,j=j+Math.imul(We,Jt)|0,q=q+Math.imul(we,Q)|0,M=M+Math.imul(we,Y)|0,M=M+Math.imul(Ee,Q)|0,j=j+Math.imul(Ee,Y)|0,q=q+Math.imul(Ae,re)|0,M=M+Math.imul(Ae,ie)|0,M=M+Math.imul(Re,re)|0,j=j+Math.imul(Re,ie)|0,q=q+Math.imul(Ie,Pe)|0,M=M+Math.imul(Ie,Ne)|0,M=M+Math.imul(je,Pe)|0,j=j+Math.imul(je,Ne)|0,q=q+Math.imul(ge,Ut)|0,M=M+Math.imul(ge,ut)|0,M=M+Math.imul(be,Ut)|0,j=j+Math.imul(be,ut)|0;var Ks=(B+q|0)+((M&8191)<<13)|0;B=(j+(M>>>13)|0)+(Ks>>>26)|0,Ks&=67108863,q=Math.imul(ht,Vt),M=Math.imul(ht,Jt),M=M+Math.imul(Bt,Vt)|0,j=Math.imul(Bt,Jt),q=q+Math.imul(Fe,Q)|0,M=M+Math.imul(Fe,Y)|0,M=M+Math.imul(We,Q)|0,j=j+Math.imul(We,Y)|0,q=q+Math.imul(we,re)|0,M=M+Math.imul(we,ie)|0,M=M+Math.imul(Ee,re)|0,j=j+Math.imul(Ee,ie)|0,q=q+Math.imul(Ae,Pe)|0,M=M+Math.imul(Ae,Ne)|0,M=M+Math.imul(Re,Pe)|0,j=j+Math.imul(Re,Ne)|0,q=q+Math.imul(Ie,Ut)|0,M=M+Math.imul(Ie,ut)|0,M=M+Math.imul(je,Ut)|0,j=j+Math.imul(je,ut)|0;var Do=(B+q|0)+((M&8191)<<13)|0;B=(j+(M>>>13)|0)+(Do>>>26)|0,Do&=67108863,q=Math.imul(ht,Q),M=Math.imul(ht,Y),M=M+Math.imul(Bt,Q)|0,j=Math.imul(Bt,Y),q=q+Math.imul(Fe,re)|0,M=M+Math.imul(Fe,ie)|0,M=M+Math.imul(We,re)|0,j=j+Math.imul(We,ie)|0,q=q+Math.imul(we,Pe)|0,M=M+Math.imul(we,Ne)|0,M=M+Math.imul(Ee,Pe)|0,j=j+Math.imul(Ee,Ne)|0,q=q+Math.imul(Ae,Ut)|0,M=M+Math.imul(Ae,ut)|0,M=M+Math.imul(Re,Ut)|0,j=j+Math.imul(Re,ut)|0;var Ga=(B+q|0)+((M&8191)<<13)|0;B=(j+(M>>>13)|0)+(Ga>>>26)|0,Ga&=67108863,q=Math.imul(ht,re),M=Math.imul(ht,ie),M=M+Math.imul(Bt,re)|0,j=Math.imul(Bt,ie),q=q+Math.imul(Fe,Pe)|0,M=M+Math.imul(Fe,Ne)|0,M=M+Math.imul(We,Pe)|0,j=j+Math.imul(We,Ne)|0,q=q+Math.imul(we,Ut)|0,M=M+Math.imul(we,ut)|0,M=M+Math.imul(Ee,Ut)|0,j=j+Math.imul(Ee,ut)|0;var Jh=(B+q|0)+((M&8191)<<13)|0;B=(j+(M>>>13)|0)+(Jh>>>26)|0,Jh&=67108863,q=Math.imul(ht,Pe),M=Math.imul(ht,Ne),M=M+Math.imul(Bt,Pe)|0,j=Math.imul(Bt,Ne),q=q+Math.imul(Fe,Ut)|0,M=M+Math.imul(Fe,ut)|0,M=M+Math.imul(We,Ut)|0,j=j+Math.imul(We,ut)|0;var Yh=(B+q|0)+((M&8191)<<13)|0;B=(j+(M>>>13)|0)+(Yh>>>26)|0,Yh&=67108863,q=Math.imul(ht,Ut),M=Math.imul(ht,ut),M=M+Math.imul(Bt,Ut)|0,j=Math.imul(Bt,ut);var Fu=(B+q|0)+((M&8191)<<13)|0;return B=(j+(M>>>13)|0)+(Fu>>>26)|0,Fu&=67108863,b[0]=Yr,b[1]=cn,b[2]=Wr,b[3]=ar,b[4]=Zr,b[5]=Br,b[6]=Ls,b[7]=vi,b[8]=Mi,b[9]=Cr,b[10]=bi,b[11]=Di,b[12]=oo,b[13]=Ks,b[14]=Do,b[15]=Ga,b[16]=Jh,b[17]=Yh,b[18]=Fu,B!==0&&(b[19]=B,w.length++),w};Math.imul||(A=E);function P(k,f,y){y.negative=f.negative^k.negative,y.length=k.length+f.length;for(var w=0,_=0,x=0;x<y.length-1;x++){var b=_;_=0;for(var B=w&67108863,q=Math.min(x,f.length-1),M=Math.max(0,x-k.length+1);M<=q;M++){var j=x-M,J=k.words[j]|0,Z=f.words[M]|0,G=J*Z,W=G&67108863;b=b+(G/67108864|0)|0,W=W+B|0,B=W&67108863,b=b+(W>>>26)|0,_+=b>>>26,b&=67108863}y.words[x]=B,w=b,b=_}return w!==0?y.words[x]=w:y.length--,y._strip()}function I(k,f,y){return P(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=E(this,f,y):_<1024?w=P(this,f,y):w=I(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;_<f;_++)y[_]=this.revBin(_,w,f);return y},$.prototype.revBin=function(f,y,w){if(f===0||f===w-1)return f;for(var _=0,x=0;x<y;x++)_|=(f&1)<<y-x-1,f>>=1;return _},$.prototype.permute=function(f,y,w,_,x,b){for(var B=0;B<b;B++)_[B]=y[f[B]],x[B]=w[f[B]]},$.prototype.transform=function(f,y,w,_,x,b){this.permute(b,f,y,w,_,x);for(var B=1;B<x;B<<=1)for(var q=B<<1,M=Math.cos(2*Math.PI/q),j=Math.sin(2*Math.PI/q),J=0;J<x;J+=q)for(var Z=M,G=j,W=0;W<B;W++){var X=w[J+W],ee=_[J+W],ue=w[J+W+B],ae=_[J+W+B],ce=Z*ue-G*ae;ae=Z*ae+G*ue,ue=ce,w[J+W]=X+ue,_[J+W]=ee+ae,w[J+W+B]=X-ue,_[J+W+B]=ee-ae,W!==q&&(ce=M*Z-j*G,G=M*G+j*Z,Z=ce)}},$.prototype.guessLen13b=function(f,y){var w=Math.max(y,f)|1,_=w&1,x=0;for(w=w/2|0;w;w=w>>>1)x++;return 1<<x+1+_},$.prototype.conjugate=function(f,y,w){if(!(w<=1))for(var _=0;_<w/2;_++){var x=f[_];f[_]=f[w-_-1],f[w-_-1]=x,x=y[_],y[_]=-y[w-_-1],y[w-_-1]=-x}},$.prototype.normalize13b=function(f,y){for(var w=0,_=0;_<y/2;_++){var x=Math.round(f[2*_+1]/y)*8192+Math.round(f[2*_]/y)+w;f[_]=x&67108863,x<67108864?w=0:w=x/67108864|0}return f},$.prototype.convert13b=function(f,y,w,_){for(var x=0,b=0;b<y;b++)x=x+(f[b]|0),w[2*b]=x&8191,x=x>>>13,w[2*b+1]=x&8191,x=x>>>13;for(b=2*y;b<_;++b)w[b]=0;r(x===0),r((x&-8192)===0)},$.prototype.stub=function(f){for(var y=new Array(f),w=0;w<f;w++)y[w]=0;return y},$.prototype.mulp=function(f,y,w){var _=2*this.guessLen13b(f.length,y.length),x=this.makeRBT(_),b=this.stub(_),B=new Array(_),q=new Array(_),M=new Array(_),j=new Array(_),J=new Array(_),Z=new Array(_),G=w.words;G.length=_,this.convert13b(f.words,f.length,B,_),this.convert13b(y.words,y.length,j,_),this.transform(B,b,q,M,_,x),this.transform(j,b,J,Z,_,x);for(var W=0;W<_;W++){var X=q[W]*J[W]-M[W]*Z[W];M[W]=q[W]*Z[W]+M[W]*J[W],q[W]=X}return this.conjugate(q,M,_),this.transform(q,M,G,b,_,x),this.conjugate(G,b,_),this.normalize13b(G,_),w.negative=f.negative^y.negative,w.length=f.length+y.length,w._strip()},i.prototype.mul=function(f){var y=new i(null);return y.words=new Array(this.length+f.length),this.mulTo(f,y)},i.prototype.mulf=function(f){var y=new i(null);return y.words=new Array(this.length+f.length),I(this,f,y)},i.prototype.imul=function(f){return this.clone().mulTo(f,this)},i.prototype.imuln=function(f){var y=f<0;y&&(f=-f),r(typeof f=="number"),r(f<67108864);for(var w=0,_=0;_<this.length;_++){var x=(this.words[_]|0)*f,b=(x&67108863)+(w&67108863);w>>=26,w+=x/67108864|0,w+=b>>>26,this.words[_]=b&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=v(f);if(y.length===0)return new i(1);for(var w=this,_=0;_<y.length&&y[_]===0;_++,w=w.sqr());if(++_<y.length)for(var x=w.sqr();_<y.length;_++,x=x.sqr())y[_]!==0&&(w=w.mul(x));return w},i.prototype.iushln=function(f){r(typeof f=="number"&&f>=0);var y=f%26,w=(f-y)/26,_=67108863>>>26-y<<26-y,x;if(y!==0){var b=0;for(x=0;x<this.length;x++){var B=this.words[x]&_,q=(this.words[x]|0)-B<<y;this.words[x]=q|b,b=B>>>26-y}b&&(this.words[x]=b,this.length++)}if(w!==0){for(x=this.length-1;x>=0;x--)this.words[x+w]=this.words[x];for(x=0;x<w;x++)this.words[x]=0;this.length+=w}return this._strip()},i.prototype.ishln=function(f){return r(this.negative===0),this.iushln(f)},i.prototype.iushrn=function(f,y,w){r(typeof f=="number"&&f>=0);var _;y?_=(y-y%26)/26:_=0;var x=f%26,b=Math.min((f-x)/26,this.length),B=67108863^67108863>>>x<<x,q=w;if(_-=b,_=Math.max(0,_),q){for(var M=0;M<b;M++)q.words[M]=this.words[M];q.length=b}if(b!==0)if(this.length>b)for(this.length-=b,M=0;M<this.length;M++)this.words[M]=this.words[M+b];else this.words[0]=0,this.length=1;var j=0;for(M=this.length-1;M>=0&&(j!==0||M>=_);M--){var J=this.words[M]|0;this.words[M]=j<<26-x|J>>>x,j=J&B}return q&&j!==0&&(q.words[q.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<<y;if(this.length<=w)return!1;var x=this.words[w];return!!(x&_)},i.prototype.imaskn=function(f){r(typeof f=="number"&&f>=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<<y;this.words[this.length-1]&=_}return this._strip()},i.prototype.maskn=function(f){return this.clone().imaskn(f)},i.prototype.iaddn=function(f){return r(typeof f=="number"),r(f<67108864),f<0?this.isubn(-f):this.negative!==0?this.length===1&&(this.words[0]|0)<=f?(this.words[0]=f-(this.words[0]|0),this.negative=0,this):(this.negative=0,this.isubn(f),this.negative=1,this):this._iaddn(f)},i.prototype._iaddn=function(f){this.words[0]+=f;for(var y=0;y<this.length&&this.words[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<this.length&&this.words[y]<0;y++)this.words[y]+=67108864,this.words[y+1]-=1;return this._strip()},i.prototype.addn=function(f){return this.clone().iaddn(f)},i.prototype.subn=function(f){return this.clone().isubn(f)},i.prototype.iabs=function(){return this.negative=0,this},i.prototype.abs=function(){return this.clone().iabs()},i.prototype._ishlnsubmul=function(f,y,w){var _=f.length+w,x;this._expand(_);var b,B=0;for(x=0;x<f.length;x++){b=(this.words[x+w]|0)+B;var q=(f.words[x]|0)*y;b-=q&67108863,B=(b>>26)-(q/67108864|0),this.words[x+w]=b&67108863}for(;x<this.length-w;x++)b=(this.words[x+w]|0)+B,B=b>>26,this.words[x+w]=b&67108863;if(B===0)return this._strip();for(r(B===-1),B=0,x=0;x<this.length;x++)b=-(this.words[x]|0)+B,B=b>>26,this.words[x]=b&67108863;return this.negative=1,this._strip()},i.prototype._wordDiv=function(f,y){var w=this.length-f.length,_=this.clone(),x=f,b=x.words[x.length-1]|0,B=this._countBits(b);w=26-B,w!==0&&(x=x.ushln(w),_.iushln(w),b=x.words[x.length-1]|0);var q=_.length-x.length,M;if(y!=="mod"){M=new i(null),M.length=q+1,M.words=new Array(M.length);for(var j=0;j<M.length;j++)M.words[j]=0}var J=_.clone()._ishlnsubmul(x,1,q);J.negative===0&&(_=J,M&&(M.words[q]=1));for(var Z=q-1;Z>=0;Z--){var G=(_.words[x.length+Z]|0)*67108864+(_.words[x.length+Z-1]|0);for(G=Math.min(G/b|0,67108863),_._ishlnsubmul(x,G,Z);_.negative!==0;)G--,_.negative=0,_._ishlnsubmul(x,1,Z),_.isZero()||(_.negative^=1);M&&(M.words[Z]=G)}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,b;return this.negative!==0&&f.negative===0?(b=this.neg().divmod(f,y),y!=="mod"&&(_=b.div.neg()),y!=="div"&&(x=b.mod.neg(),w&&x.negative!==0&&x.iadd(f)),{div:_,mod:x}):this.negative===0&&f.negative!==0?(b=this.divmod(f.neg(),y),y!=="mod"&&(_=b.div.neg()),{div:_,mod:b.mod}):this.negative&f.negative?(b=this.neg().divmod(f.neg(),y),y!=="div"&&(x=b.mod.neg(),w&&x.negative!==0&&x.isub(f)),{div:b.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),b=w.cmp(_);return b<0||x===1&&b===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),b=new i(0),B=new i(1),q=0;y.isEven()&&w.isEven();)y.iushrn(1),w.iushrn(1),++q;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 G=0,W=1;!(w.words[0]&W)&&G<26;++G,W<<=1);if(G>0)for(w.iushrn(G);G-- >0;)(b.isOdd()||B.isOdd())&&(b.iadd(M),B.isub(j)),b.iushrn(1),B.iushrn(1);y.cmp(w)>=0?(y.isub(w),_.isub(b),x.isub(B)):(w.isub(y),b.isub(_),B.isub(x))}return{a:b,b:B,gcd:w.iushln(q)}},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),b=w.clone();y.cmpn(1)>0&&w.cmpn(1)>0;){for(var B=0,q=1;!(y.words[0]&q)&&B<26;++B,q<<=1);if(B>0)for(y.iushrn(B);B-- >0;)_.isOdd()&&_.iadd(b),_.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(b),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 b=y;y=w,w=b}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<<y;if(this.length<=w)return this._expand(w+1),this.words[w]|=_,this;for(var x=_,b=w;x!==0&&b<this.length;b++){var B=this.words[b]|0;B+=x,x=B>>>26,B&=67108863,this.words[b]=B}return x!==0&&(this.words[b]=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?-1:1}return this.negative!==0?-w|0:w},i.prototype.cmp=function(f){if(this.negative!==0&&f.negative===0)return-1;if(this.negative===0&&f.negative!==0)return 1;var y=this.ucmp(f);return this.negative!==0?-y|0:y},i.prototype.ucmp=function(f){if(this.length>f.length)return 1;if(this.length<f.length)return-1;for(var y=0,w=this.length-1;w>=0;w--){var _=this.words[w]|0,x=f.words[w]|0;if(_!==x){_<x?y=-1:_>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 K(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()}K.prototype._tmp=function(){var f=new i(null);return f.words=new Array(Math.ceil(this.n/13)),f},K.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 _=w<this.n?-1:y.ucmp(this.p);return _===0?(y.words[0]=0,y.length=1):_>0?y.isub(this.p):y.strip!==void 0?y.strip():y._strip(),y},K.prototype.split=function(f,y){f.iushrn(this.n,0,y)},K.prototype.imulK=function(f){return f.imul(this.k)};function F(){K.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}n(F,K),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 b=f.words[9];for(y.words[y.length++]=b&w,x=10;x<f.length;x++){var B=f.words[x]|0;f.words[x-10]=(B&w)<<4|b>>>22,b=B}b>>>=22,f.words[x-10]=b,b===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<f.length;w++){var _=f.words[w]|0;y+=_*977,f.words[w]=y&67108863,y=_*64+(y/67108864|0)}return f.words[f.length-1]===0&&(f.length--,f.words[f.length-1]===0&&f.length--),f};function U(){K.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}n(U,K);function V(){K.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}n(V,K);function L(){K.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}n(L,K),L.prototype.imulK=function(f){for(var y=0,w=0;w<f.length;w++){var _=(f.words[w]|0)*19+y,x=_&67108863;_>>>=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 V;else if(f==="p25519")y=new L;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 b=new i(1).toRed(this),B=b.redNeg(),q=this.m.subn(1).iushrn(1),M=this.m.bitLength();for(M=new i(2*M*M).toRed(this);this.pow(M,q).cmp(B)!==0;)M.redIAdd(B);for(var j=this.pow(M,_),J=this.pow(f,_.addn(1).iushrn(1)),Z=this.pow(f,_),G=x;Z.cmp(b)!==0;){for(var W=Z,X=0;W.cmp(b)!==0;X++)W=W.redSqr();r(X<G);var ee=this.pow(j,new i(1).iushln(G-X-1));J=J.redMul(ee),j=ee.redSqr(),Z=Z.redMul(j),G=X}return J},T.prototype.invm=function(f){var y=f._invmp(this.m);return y.negative!==0?(y.negative=0,this.imod(y).redNeg()):this.imod(y)},T.prototype.pow=function(f,y){if(y.isZero())return new i(1).toRed(this);if(y.cmpn(1)===0)return f.clone();var w=4,_=new Array(1<<w);_[0]=new i(1).toRed(this),_[1]=f;for(var x=2;x<_.length;x++)_[x]=this.mul(_[x-1],f);var b=_[0],B=0,q=0,M=y.bitLength()%26;for(M===0&&(M=26),x=y.length-1;x>=0;x--){for(var j=y.words[x],J=M-1;J>=0;J--){var Z=j>>J&1;if(b!==_[0]&&(b=this.sqr(b)),Z===0&&B===0){q=0;continue}B<<=1,B|=Z,q++,!(q!==w&&(x!==0||J!==0))&&(b=this.mul(b,_[B]),q=0,B=0)}M=26}return b},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 S(f)};function S(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(S,T),S.prototype.convertTo=function(f){return this.imod(f.ushln(this.shift))},S.prototype.convertFrom=function(f){var y=this.imod(f.mul(this.rinv));return y.red=null,y},S.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),b=x;return x.cmp(this.m)>=0?b=x.isub(this.m):x.cmpn(0)<0&&(b=x.iadd(this.m)),b._forceRed(this)},S.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),b=x;return x.cmp(this.m)>=0?b=x.isub(this.m):x.cmpn(0)<0&&(b=x.iadd(this.m)),b._forceRed(this)},S.prototype.invm=function(f){var y=this.imod(f._invmp(this.m).mul(this.r2));return y._forceRed(this)}})(typeof hO>"u"||hO,ere)});var B4=H((q1t,nre)=>{h();var iw=R4(),W9e=B0();function G9e(t){var e=tre(t),r=e.toRed(iw.mont(t.modulus)).redPow(new iw(t.publicExponent)).fromRed();return{blinder:r,unblinder:e.invm(t.modulus)}}function tre(t){var e=t.modulus.byteLength(),r;do r=new iw(W9e(e));while(r.cmp(t.modulus)>=0||!r.umod(t.prime1)||!r.umod(t.prime2));return r}function rre(t,e){var r=G9e(e),n=e.modulus.byteLength(),i=new iw(t).mul(r.blinder).umod(e.modulus),o=i.toRed(iw.mont(e.prime1)),s=i.toRed(iw.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(C.Buffer,"be",n)}rre.getr=tre;nre.exports=rre});var ire=H((K1t,J9e)=>{J9e.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 <fedor@indutny.com>",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 pO=H(are=>{"use strict";h();var M4=are;function Y9e(t,e){if(Array.isArray(t))return t.slice();if(!t)return[];var r=[];if(typeof t!="string"){for(var n=0;n<t.length;n++)r[n]=t[n]|0;return r}if(e==="hex"){t=t.replace(/[^a-z0-9]+/ig,""),t.length%2!==0&&(t="0"+t);for(var n=0;n<t.length;n+=2)r.push(parseInt(t[n]+t[n+1],16))}else for(var n=0;n<t.length;n++){var i=t.charCodeAt(n),o=i>>8,s=i&255;o?r.push(o,s):r.push(s)}return r}M4.toArray=Y9e;function ore(t){return t.length===1?"0"+t:t}M4.zero2=ore;function sre(t){for(var e="",r=0;r<t.length;r++)e+=ore(t[r].toString(16));return e}M4.toHex=sre;M4.encode=function(e,r){return r==="hex"?sre(e):e}});var pc=H(cre=>{"use strict";h();var au=cre,Z9e=Gi(),X9e=hc(),D4=pO();au.assert=X9e;au.toArray=D4.toArray;au.zero2=D4.zero2;au.toHex=D4.toHex;au.encode=D4.encode;function Q9e(t,e,r){var n=new Array(Math.max(t.bitLength(),r)+1);n.fill(0);for(var i=1<<e+1,o=t.clone(),s=0;s<n.length;s++){var a,d=o.andln(i-1);o.isOdd()?(d>(i>>1)-1?a=(i>>1)-d:a=d,o.isubn(a)):a=0,n[s]=a,o.iushrn(1)}return n}au.getNAF=Q9e;function e7e(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}au.getJSF=e7e;function t7e(t,e,r){var n="_"+e;t.prototype[e]=function(){return this[n]!==void 0?this[n]:this[n]=r.call(this)}}au.cachedProperty=t7e;function r7e(t){return typeof t=="string"?au.toArray(t,"hex"):t}au.parseBytes=r7e;function n7e(t){return new Z9e(t,"hex","le")}au.intFromLE=n7e});var Vx=H((W1t,dre)=>{"use strict";h();var W0=Gi(),zx=pc(),O4=zx.getNAF,i7e=zx.getJSF,C4=zx.assert;function nm(t,e){this.type=t,this.p=new W0(e.p,16),this.red=e.prime?W0.red(e.prime):W0.mont(this.p),this.zero=new W0(0).toRed(this.red),this.one=new W0(1).toRed(this.red),this.two=new W0(2).toRed(this.red),this.n=e.n&&new W0(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))}dre.exports=nm;nm.prototype.point=function(){throw new Error("Not implemented")};nm.prototype.validate=function(){throw new Error("Not implemented")};nm.prototype._fixedNafMul=function(e,r){C4(e.precomputed);var n=e._getDoubles(),i=O4(r,1,this._bitLength),o=(1<<n.step+1)-(n.step%2===0?2:1);o/=3;var s=[],a,d;for(a=0;a<i.length;a+=n.step){d=0;for(var u=a+n.step-1;u>=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<s.length;a++)d=s[a],d===m?l=l.mixedAdd(n.points[a]):d===-m&&(l=l.mixedAdd(n.points[a].neg()));c=c.add(l)}return c.toP()};nm.prototype._wnafMul=function(e,r){var n=4,i=e._getNAFPoints(n);n=i.wnd;for(var o=i.points,s=O4(r,n,this._bitLength),a=this.jpoint(null,null,null),d=s.length-1;d>=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];C4(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};nm.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<i;c++){m=r[c];var p=m._getNAFPoints(e);s[c]=p.wnd,a[c]=p.points}for(c=i-1;c>=1;c-=2){var g=c-1,v=c;if(s[g]!==1||s[v]!==1){d[g]=O4(n[g],s[g],this._bitLength),d[v]=O4(n[v],s[v],this._bitLength),u=Math.max(d[g].length,u),u=Math.max(d[v].length,u);continue}var E=[r[g],null,null,r[v]];r[g].y.cmp(r[v].y)===0?(E[1]=r[g].add(r[v]),E[2]=r[g].toJ().mixedAdd(r[v].neg())):r[g].y.cmp(r[v].y.redNeg())===0?(E[1]=r[g].toJ().mixedAdd(r[v]),E[2]=r[g].add(r[v].neg())):(E[1]=r[g].toJ().mixedAdd(r[v]),E[2]=r[g].toJ().mixedAdd(r[v].neg()));var A=[-3,-1,-5,-7,0,7,5,1,3],P=i7e(n[g],n[v]);for(u=Math.max(P[0].length,u),d[g]=new Array(u),d[v]=new Array(u),l=0;l<u;l++){var I=P[0][l]|0,$=P[1][l]|0;d[g][l]=A[(I+1)*3+($+1)],d[v][l]=0,a[g]=E}}var N=this.jpoint(null,null,null),K=this._wnafT4;for(c=u;c>=0;c--){for(var F=0;c>=0;){var U=!0;for(l=0;l<i;l++)K[l]=d[l][c]|0,K[l]!==0&&(U=!1);if(!U)break;F++,c--}if(c>=0&&F++,N=N.dblp(F),c<0)break;for(l=0;l<i;l++){var V=K[l];V!==0&&(V>0?m=a[l][V-1>>1]:V<0&&(m=a[l][-V-1>>1].neg()),m.type==="affine"?N=N.mixedAdd(m):N=N.add(m))}}for(c=0;c<i;c++)a[c]=null;return o?N:N.toP()};function ud(t,e){this.curve=t,this.type=e,this.precomputed=null}nm.BasePoint=ud;ud.prototype.eq=function(){throw new Error("Not implemented")};ud.prototype.validate=function(){return this.curve.validate(this)};nm.prototype.decodePoint=function(e,r){e=zx.toArray(e,r);var n=this.p.byteLength();if((e[0]===4||e[0]===6||e[0]===7)&&e.length-1===2*n){e[0]===6?C4(e[e.length-1]%2===0):e[0]===7&&C4(e[e.length-1]%2===1);var i=this.point(e.slice(1,1+n),e.slice(1+n,1+2*n));return i}else if((e[0]===2||e[0]===3)&&e.length-1===n)return this.pointFromX(e.slice(1,1+n),e[0]===3);throw new Error("Unknown point format")};ud.prototype.encodeCompressed=function(e){return this.encode(e,!0)};ud.prototype._encode=function(e){var r=this.curve.p.byteLength(),n=this.getX().toArray("be",r);return e?[this.getY().isEven()?2:3].concat(n):[4].concat(n,this.getY().toArray("be",r))};ud.prototype.encode=function(e,r){return zx.encode(this._encode(r),e)};ud.prototype.precompute=function(e){if(this.precomputed)return this;var r={doubles:null,naf:null,beta:null};return r.naf=this._getNAFPoints(8),r.doubles=this._getDoubles(4,e),r.beta=this._getBeta(),this.precomputed=r,this};ud.prototype._hasDoubles=function(e){if(!this.precomputed)return!1;var r=this.precomputed.doubles;return r?r.points.length>=Math.ceil((e.bitLength()+1)/r.step):!1};ud.prototype._getDoubles=function(e,r){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var n=[this],i=this,o=0;o<r;o+=e){for(var s=0;s<e;s++)i=i.dbl();n.push(i)}return{step:e,points:n}};ud.prototype._getNAFPoints=function(e){if(this.precomputed&&this.precomputed.naf)return this.precomputed.naf;for(var r=[this],n=(1<<e)-1,i=n===1?null:this.dbl(),o=1;o<n;o++)r[o]=r[o-1].add(i);return{wnd:e,points:r}};ud.prototype._getBeta=function(){return null};ud.prototype.dblp=function(e){for(var r=this,n=0;n<e;n++)r=r.dbl();return r}});var lre=H((J1t,ure)=>{"use strict";h();var o7e=pc(),ui=Gi(),mO=ur(),ow=Vx(),s7e=o7e.assert;function ld(t){ow.call(this,"short",t),this.a=new ui(t.a,16).toRed(this.red),this.b=new ui(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)}mO(ld,ow);ure.exports=ld;ld.prototype._getEndomorphism=function(e){if(!(!this.zeroA||!this.g||!this.n||this.p.modn(3)!==1)){var r,n;if(e.beta)r=new ui(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 ui(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],s7e(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 ui(a.a,16),b:new ui(a.b,16)}}):s=this._getEndoBasis(n),{beta:r,lambda:n,basis:s}}};ld.prototype._getEndoRoots=function(e){var r=e===this.p?this.red:ui.mont(e),n=new ui(2).toRed(r).redInvm(),i=n.redNeg(),o=new ui(3).toRed(r).redNeg().redSqrt().redMul(n),s=i.redAdd(o).fromRed(),a=i.redSub(o).fromRed();return[s,a]};ld.prototype._getEndoBasis=function(e){for(var r=this.n.ushrn(Math.floor(this.n.bitLength()/2)),n=e,i=this.n.clone(),o=new ui(1),s=new ui(0),a=new ui(0),d=new ui(1),u,c,l,m,p,g,v,E=0,A,P;n.cmpn(0)!==0;){var I=i.div(n);A=i.sub(I.mul(n)),P=a.sub(I.mul(o));var $=d.sub(I.mul(s));if(!l&&A.cmp(r)<0)u=v.neg(),c=o,l=A.neg(),m=P;else if(l&&++E===2)break;v=A,i=n,n=A,a=o,o=P,d=s,s=$}p=A.neg(),g=P;var N=l.sqr().add(m.sqr()),K=p.sqr().add(g.sqr());return K.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}]};ld.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}};ld.prototype.pointFromX=function(e,r){e=new ui(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)};ld.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};ld.prototype._endoWnafMulAdd=function(e,r,n){for(var i=this._endoWnafT1,o=this._endoWnafT2,s=0;s<e.length;s++){var a=this._endoSplit(r[s]),d=e[s],u=d._getBeta();a.k1.negative&&(a.k1.ineg(),d=d.neg(!0)),a.k2.negative&&(a.k2.ineg(),u=u.neg(!0)),i[s*2]=d,i[s*2+1]=u,o[s*2]=a.k1,o[s*2+1]=a.k2}for(var c=this._wnafMulAdd(1,i,o,s*2,n),l=0;l<s*2;l++)i[l]=null,o[l]=null;return c};function vo(t,e,r,n){ow.BasePoint.call(this,t,"affine"),e===null&&r===null?(this.x=null,this.y=null,this.inf=!0):(this.x=new ui(e,16),this.y=new ui(r,16),n&&(this.x.forceRed(this.curve.red),this.y.forceRed(this.curve.red)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.inf=!1)}mO(vo,ow.BasePoint);ld.prototype.point=function(e,r,n){return new vo(this,e,r,n)};ld.prototype.pointFromJSON=function(e,r){return vo.fromJSON(this,e,r)};vo.prototype._getBeta=function(){if(this.curve.endo){var e=this.precomputed;if(e&&e.beta)return e.beta;var r=this.curve.point(this.x.redMul(this.curve.endo.beta),this.y);if(e){var n=this.curve,i=function(o){return n.point(o.x.redMul(n.endo.beta),o.y)};e.beta=r,r.precomputed={beta:null,naf:e.naf&&{wnd:e.naf.wnd,points:e.naf.points.map(i)},doubles:e.doubles&&{step:e.doubles.step,points:e.doubles.points.map(i)}}}return r}};vo.prototype.toJSON=function(){return this.precomputed?[this.x,this.y,this.precomputed&&{doubles:this.precomputed.doubles&&{step:this.precomputed.doubles.step,points:this.precomputed.doubles.points.slice(1)},naf:this.precomputed.naf&&{wnd:this.precomputed.naf.wnd,points:this.precomputed.naf.points.slice(1)}}]:[this.x,this.y]};vo.fromJSON=function(e,r,n){typeof r=="string"&&(r=JSON.parse(r));var i=e.point(r[0],r[1],n);if(!r[2])return i;function o(a){return e.point(a[0],a[1],n)}var s=r[2];return i.precomputed={beta:null,doubles:s.doubles&&{step:s.doubles.step,points:[i].concat(s.doubles.points.map(o))},naf:s.naf&&{wnd:s.naf.wnd,points:[i].concat(s.naf.points.map(o))}},i};vo.prototype.inspect=function(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" y: "+this.y.fromRed().toString(16,2)+">"};vo.prototype.isInfinity=function(){return this.inf};vo.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)};vo.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)};vo.prototype.getX=function(){return this.x.fromRed()};vo.prototype.getY=function(){return this.y.fromRed()};vo.prototype.mul=function(e){return e=new ui(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)};vo.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)};vo.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)};vo.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)};vo.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};vo.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 Fo(t,e,r,n){ow.BasePoint.call(this,t,"jacobian"),e===null&&r===null&&n===null?(this.x=this.curve.one,this.y=this.curve.one,this.z=new ui(0)):(this.x=new ui(e,16),this.y=new ui(r,16),this.z=new ui(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}mO(Fo,ow.BasePoint);ld.prototype.jpoint=function(e,r,n){return new Fo(this,e,r,n)};Fo.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)};Fo.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)};Fo.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)),v=this.z.redMul(e.z).redMul(d);return this.curve.jpoint(p,g,v)};Fo.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)};Fo.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<e;r++)n=n.dbl();return n}var i=this.curve.a,o=this.curve.tinv,s=this.x,a=this.y,d=this.z,u=d.redSqr().redSqr(),c=a.redAdd(a);for(r=0;r<e;r++){var l=s.redSqr(),m=c.redSqr(),p=m.redSqr(),g=l.redAdd(l).redIAdd(l).redIAdd(i.redMul(u)),v=s.redMul(m),E=g.redSqr().redISub(v.redAdd(v)),A=v.redISub(E),P=g.redMul(A);P=P.redIAdd(P).redISub(p);var I=c.redMul(d);r+1<e&&(u=u.redMul(p)),s=E,d=I,c=P}return this.curve.jpoint(s,c.redMul(o),d)};Fo.prototype.dbl=function(){return this.isInfinity()?this:this.curve.zeroA?this._zeroDbl():this.curve.threeA?this._threeDbl():this._dbl()};Fo.prototype._zeroDbl=function(){var e,r,n;if(this.zOne){var i=this.x.redSqr(),o=this.y.redSqr(),s=o.redSqr(),a=this.x.redAdd(o).redSqr().redISub(i).redISub(s);a=a.redIAdd(a);var d=i.redAdd(i).redIAdd(i),u=d.redSqr().redISub(a).redISub(a),c=s.redIAdd(s);c=c.redIAdd(c),c=c.redIAdd(c),e=u,r=d.redMul(a.redISub(u)).redISub(c),n=this.y.redAdd(this.y)}else{var l=this.x.redSqr(),m=this.y.redSqr(),p=m.redSqr(),g=this.x.redAdd(m).redSqr().redISub(l).redISub(p);g=g.redIAdd(g);var v=l.redAdd(l).redIAdd(l),E=v.redSqr(),A=p.redIAdd(p);A=A.redIAdd(A),A=A.redIAdd(A),e=E.redISub(g).redISub(g),r=v.redMul(g.redISub(e)).redISub(A),n=this.y.redMul(this.z),n=n.redIAdd(n)}return this.curve.jpoint(e,r,n)};Fo.prototype._threeDbl=function(){var e,r,n;if(this.zOne){var i=this.x.redSqr(),o=this.y.redSqr(),s=o.redSqr(),a=this.x.redAdd(o).redSqr().redISub(i).redISub(s);a=a.redIAdd(a);var d=i.redAdd(i).redIAdd(i).redIAdd(this.curve.a),u=d.redSqr().redISub(a).redISub(a);e=u;var c=s.redIAdd(s);c=c.redIAdd(c),c=c.redIAdd(c),r=d.redMul(a.redISub(u)).redISub(c),n=this.y.redAdd(this.y)}else{var l=this.z.redSqr(),m=this.y.redSqr(),p=this.x.redMul(m),g=this.x.redSub(l).redMul(this.x.redAdd(l));g=g.redAdd(g).redIAdd(g);var v=p.redIAdd(p);v=v.redIAdd(v);var E=v.redAdd(v);e=g.redSqr().redISub(E),n=this.y.redAdd(this.z).redSqr().redISub(m).redISub(l);var A=m.redSqr();A=A.redIAdd(A),A=A.redIAdd(A),A=A.redIAdd(A),r=g.redMul(v.redISub(e)).redISub(A)}return this.curve.jpoint(e,r,n)};Fo.prototype._dbl=function(){var e=this.curve.a,r=this.x,n=this.y,i=this.z,o=i.redSqr().redSqr(),s=r.redSqr(),a=n.redSqr(),d=s.redAdd(s).redIAdd(s).redIAdd(e.redMul(o)),u=r.redAdd(r);u=u.redIAdd(u);var c=u.redMul(a),l=d.redSqr().redISub(c.redAdd(c)),m=c.redISub(l),p=a.redSqr();p=p.redIAdd(p),p=p.redIAdd(p),p=p.redIAdd(p);var g=d.redMul(m).redISub(p),v=n.redAdd(n).redMul(i);return this.curve.jpoint(l,g,v)};Fo.prototype.trpl=function(){if(!this.curve.zeroA)return this.dbl().add(this);var e=this.x.redSqr(),r=this.y.redSqr(),n=this.z.redSqr(),i=r.redSqr(),o=e.redAdd(e).redIAdd(e),s=o.redSqr(),a=this.x.redAdd(r).redSqr().redISub(e).redISub(i);a=a.redIAdd(a),a=a.redAdd(a).redIAdd(a),a=a.redISub(s);var d=a.redSqr(),u=i.redIAdd(i);u=u.redIAdd(u),u=u.redIAdd(u),u=u.redIAdd(u);var c=o.redIAdd(a).redSqr().redISub(s).redISub(d).redISub(u),l=r.redMul(c);l=l.redIAdd(l),l=l.redIAdd(l);var m=this.x.redMul(d).redISub(l);m=m.redIAdd(m),m=m.redIAdd(m);var p=this.y.redMul(c.redMul(u.redISub(c)).redISub(a.redMul(d)));p=p.redIAdd(p),p=p.redIAdd(p),p=p.redIAdd(p);var g=this.z.redAdd(a).redSqr().redISub(n).redISub(d);return this.curve.jpoint(m,p,g)};Fo.prototype.mul=function(e,r){return e=new ui(e,r),this.curve._wnafMul(this,e)};Fo.prototype.eq=function(e){if(e.type==="affine")return this.eq(e.toJ());if(this===e)return!0;var r=this.z.redSqr(),n=e.z.redSqr();if(this.x.redMul(n).redISub(e.x.redMul(r)).cmpn(0)!==0)return!1;var i=r.redMul(this.z),o=n.redMul(e.z);return this.y.redMul(o).redISub(e.y.redMul(i)).cmpn(0)===0};Fo.prototype.eqXToP=function(e){var r=this.z.redSqr(),n=e.toRed(this.curve.red).redMul(r);if(this.x.cmp(n)===0)return!0;for(var i=e.clone(),o=this.curve.redN.redMul(r);;){if(i.iadd(this.curve.n),i.cmp(this.curve.p)>=0)return!1;if(n.redIAdd(o),this.x.cmp(n)===0)return!0}};Fo.prototype.inspect=function(){return this.isInfinity()?"<EC JPoint Infinity>":"<EC JPoint x: "+this.x.toString(16,2)+" y: "+this.y.toString(16,2)+" z: "+this.z.toString(16,2)+">"};Fo.prototype.isInfinity=function(){return this.z.cmpn(0)===0}});var pre=H((Z1t,hre)=>{"use strict";h();var sw=Gi(),fre=ur(),$4=Vx(),a7e=pc();function aw(t){$4.call(this,"mont",t),this.a=new sw(t.a,16).toRed(this.red),this.b=new sw(t.b,16).toRed(this.red),this.i4=new sw(4).toRed(this.red).redInvm(),this.two=new sw(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}fre(aw,$4);hre.exports=aw;aw.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 bo(t,e,r){$4.BasePoint.call(this,t,"projective"),e===null&&r===null?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new sw(e,16),this.z=new sw(r,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}fre(bo,$4.BasePoint);aw.prototype.decodePoint=function(e,r){return this.point(a7e.toArray(e,r),1)};aw.prototype.point=function(e,r){return new bo(this,e,r)};aw.prototype.pointFromJSON=function(e){return bo.fromJSON(this,e)};bo.prototype.precompute=function(){};bo.prototype._encode=function(){return this.getX().toArray("be",this.curve.p.byteLength())};bo.fromJSON=function(e,r){return new bo(e,r[0],r[1]||e.one)};bo.prototype.inspect=function(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" z: "+this.z.fromRed().toString(16,2)+">"};bo.prototype.isInfinity=function(){return this.z.cmpn(0)===0};bo.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)};bo.prototype.add=function(){throw new Error("Not supported on Montgomery curve")};bo.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)};bo.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};bo.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")};bo.prototype.jumlAdd=function(){throw new Error("Not supported on Montgomery curve")};bo.prototype.eq=function(e){return this.getX().cmp(e.getX())===0};bo.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this};bo.prototype.getX=function(){return this.normalize(),this.x.fromRed()}});var gre=H((Q1t,yre)=>{"use strict";h();var c7e=pc(),ih=Gi(),mre=ur(),N4=Vx(),d7e=c7e.assert;function El(t){this.twisted=(t.a|0)!==1,this.mOneA=this.twisted&&(t.a|0)===-1,this.extended=this.mOneA,N4.call(this,"edwards",t),this.a=new ih(t.a,16).umod(this.red.m),this.a=this.a.toRed(this.red),this.c=new ih(t.c,16).toRed(this.red),this.c2=this.c.redSqr(),this.d=new ih(t.d,16).toRed(this.red),this.dd=this.d.redAdd(this.d),d7e(!this.twisted||this.c.fromRed().cmpn(1)===0),this.oneC=(t.c|0)===1}mre(El,N4);yre.exports=El;El.prototype._mulA=function(e){return this.mOneA?e.redNeg():this.a.redMul(e)};El.prototype._mulC=function(e){return this.oneC?e:this.c.redMul(e)};El.prototype.jpoint=function(e,r,n,i){return this.point(e,r,n,i)};El.prototype.pointFromX=function(e,r){e=new ih(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)};El.prototype.pointFromY=function(e,r){e=new ih(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)};El.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 Tn(t,e,r,n,i){N4.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 ih(e,16),this.y=new ih(r,16),this.z=n?new ih(n,16):this.curve.one,this.t=i&&new ih(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()))))}mre(Tn,N4.BasePoint);El.prototype.pointFromJSON=function(e){return Tn.fromJSON(this,e)};El.prototype.point=function(e,r,n,i){return new Tn(this,e,r,n,i)};Tn.fromJSON=function(e,r){return new Tn(e,r[0],r[1],r[2])};Tn.prototype.inspect=function(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" y: "+this.y.fromRed().toString(16,2)+" z: "+this.z.fromRed().toString(16,2)+">"};Tn.prototype.isInfinity=function(){return this.x.cmpn(0)===0&&(this.y.cmp(this.z)===0||this.zOne&&this.y.cmp(this.curve.c)===0)};Tn.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)};Tn.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)};Tn.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()};Tn.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)};Tn.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)};Tn.prototype.add=function(e){return this.isInfinity()?e:e.isInfinity()?this:this.curve.extended?this._extAdd(e):this._projAdd(e)};Tn.prototype.mul=function(e){return this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve._wnafMul(this,e)};Tn.prototype.mulAdd=function(e,r,n){return this.curve._wnafMulAdd(1,[this,r],[e,n],2,!1)};Tn.prototype.jmulAdd=function(e,r,n){return this.curve._wnafMulAdd(1,[this,r],[e,n],2,!0)};Tn.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};Tn.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())};Tn.prototype.getX=function(){return this.normalize(),this.x.fromRed()};Tn.prototype.getY=function(){return this.normalize(),this.y.fromRed()};Tn.prototype.eq=function(e){return this===e||this.getX().cmp(e.getX())===0&&this.getY().cmp(e.getY())===0};Tn.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}};Tn.prototype.toP=Tn.prototype.normalize;Tn.prototype.mixedAdd=Tn.prototype.add});var yO=H(vre=>{"use strict";h();var j4=vre;j4.base=Vx();j4.short=lre();j4.mont=pre();j4.edwards=gre()});var cu=H(bn=>{"use strict";h();var u7e=hc(),l7e=ur();bn.inherits=l7e;function f7e(t,e){return(t.charCodeAt(e)&64512)!==55296||e<0||e+1>=t.length?!1:(t.charCodeAt(e+1)&64512)===56320}function h7e(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<t.length;i+=2)r.push(parseInt(t[i]+t[i+1],16))}else for(var n=0,i=0;i<t.length;i++){var o=t.charCodeAt(i);o<128?r[n++]=o:o<2048?(r[n++]=o>>6|192,r[n++]=o&63|128):f7e(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<t.length;i++)r[i]=t[i]|0;return r}bn.toArray=h7e;function p7e(t){for(var e="",r=0;r<t.length;r++)e+=wre(t[r].toString(16));return e}bn.toHex=p7e;function bre(t){var e=t>>>24|t>>>8&65280|t<<8&16711680|(t&255)<<24;return e>>>0}bn.htonl=bre;function m7e(t,e){for(var r="",n=0;n<t.length;n++){var i=t[n];e==="little"&&(i=bre(i)),r+=_re(i.toString(16))}return r}bn.toHex32=m7e;function wre(t){return t.length===1?"0"+t:t}bn.zero2=wre;function _re(t){return t.length===7?"0"+t:t.length===6?"00"+t:t.length===5?"000"+t:t.length===4?"0000"+t:t.length===3?"00000"+t:t.length===2?"000000"+t:t.length===1?"0000000"+t:t}bn.zero8=_re;function y7e(t,e,r,n){var i=r-e;u7e(i%4===0);for(var o=new Array(i/4),s=0,a=e;s<o.length;s++,a+=4){var d;n==="big"?d=t[a]<<24|t[a+1]<<16|t[a+2]<<8|t[a+3]:d=t[a+3]<<24|t[a+2]<<16|t[a+1]<<8|t[a],o[s]=d>>>0}return o}bn.join32=y7e;function g7e(t,e){for(var r=new Array(t.length*4),n=0,i=0;n<t.length;n++,i+=4){var o=t[n];e==="big"?(r[i]=o>>>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}bn.split32=g7e;function v7e(t,e){return t>>>e|t<<32-e}bn.rotr32=v7e;function b7e(t,e){return t<<e|t>>>32-e}bn.rotl32=b7e;function w7e(t,e){return t+e>>>0}bn.sum32=w7e;function _7e(t,e,r){return t+e+r>>>0}bn.sum32_3=_7e;function x7e(t,e,r,n){return t+e+r+n>>>0}bn.sum32_4=x7e;function E7e(t,e,r,n,i){return t+e+r+n+i>>>0}bn.sum32_5=E7e;function S7e(t,e,r,n){var i=t[e],o=t[e+1],s=n+o>>>0,a=(s<n?1:0)+r+i;t[e]=a>>>0,t[e+1]=s}bn.sum64=S7e;function A7e(t,e,r,n){var i=e+n>>>0,o=(i<e?1:0)+t+r;return o>>>0}bn.sum64_hi=A7e;function T7e(t,e,r,n){var i=e+n;return i>>>0}bn.sum64_lo=T7e;function I7e(t,e,r,n,i,o,s,a){var d=0,u=e;u=u+n>>>0,d+=u<e?1:0,u=u+o>>>0,d+=u<o?1:0,u=u+a>>>0,d+=u<a?1:0;var c=t+r+i+s+d;return c>>>0}bn.sum64_4_hi=I7e;function P7e(t,e,r,n,i,o,s,a){var d=e+n+o+a;return d>>>0}bn.sum64_4_lo=P7e;function k7e(t,e,r,n,i,o,s,a,d,u){var c=0,l=e;l=l+n>>>0,c+=l<e?1:0,l=l+o>>>0,c+=l<o?1:0,l=l+a>>>0,c+=l<a?1:0,l=l+u>>>0,c+=l<u?1:0;var m=t+r+i+s+d+c;return m>>>0}bn.sum64_5_hi=k7e;function R7e(t,e,r,n,i,o,s,a,d,u){var c=e+n+o+a+u;return c>>>0}bn.sum64_5_lo=R7e;function B7e(t,e,r){var n=e<<32-r|t>>>r;return n>>>0}bn.rotr64_hi=B7e;function M7e(t,e,r){var n=t<<32-r|e>>>r;return n>>>0}bn.rotr64_lo=M7e;function D7e(t,e,r){return t>>>r}bn.shr64_hi=D7e;function O7e(t,e,r){var n=t<<32-r|e>>>r;return n>>>0}bn.shr64_lo=O7e});var cw=H(Ere=>{"use strict";h();var xre=cu(),C7e=hc();function U4(){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}Ere.BlockHash=U4;U4.prototype.update=function(e,r){if(e=xre.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=xre.join32(e,0,e.length-n,this.endian);for(var i=0;i<e.length;i+=this._delta32)this._update(e,i,i+this._delta32)}return this};U4.prototype.digest=function(e){return this.update(this._pad()),C7e(this.pending===null),this._digest(e)};U4.prototype._pad=function(){var e=this.pendingTotal,r=this._delta8,n=r-(e+this.padLength)%r,i=new Array(n+this.padLength);i[0]=128;for(var o=1;o<n;o++)i[o]=0;if(e<<=3,this.endian==="big"){for(var s=8;s<this.padLength;s++)i[o++]=0;i[o++]=0,i[o++]=0,i[o++]=0,i[o++]=0,i[o++]=e>>>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<this.padLength;s++)i[o++]=0;return i}});var gO=H(oh=>{"use strict";h();var $7e=cu(),Sl=$7e.rotr32;function N7e(t,e,r,n){if(t===0)return Sre(e,r,n);if(t===1||t===3)return Tre(e,r,n);if(t===2)return Are(e,r,n)}oh.ft_1=N7e;function Sre(t,e,r){return t&e^~t&r}oh.ch32=Sre;function Are(t,e,r){return t&e^t&r^e&r}oh.maj32=Are;function Tre(t,e,r){return t^e^r}oh.p32=Tre;function j7e(t){return Sl(t,2)^Sl(t,13)^Sl(t,22)}oh.s0_256=j7e;function U7e(t){return Sl(t,6)^Sl(t,11)^Sl(t,25)}oh.s1_256=U7e;function q7e(t){return Sl(t,7)^Sl(t,18)^t>>>3}oh.g0_256=q7e;function L7e(t){return Sl(t,17)^Sl(t,19)^t>>>10}oh.g1_256=L7e});var kre=H((d2t,Pre)=>{"use strict";h();var dw=cu(),K7e=cw(),F7e=gO(),vO=dw.rotl32,Hx=dw.sum32,z7e=dw.sum32_5,V7e=F7e.ft_1,Ire=K7e.BlockHash,H7e=[1518500249,1859775393,2400959708,3395469782];function Al(){if(!(this instanceof Al))return new Al;Ire.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}dw.inherits(Al,Ire);Pre.exports=Al;Al.blockSize=512;Al.outSize=160;Al.hmacStrength=80;Al.padLength=64;Al.prototype._update=function(e,r){for(var n=this.W,i=0;i<16;i++)n[i]=e[r+i];for(;i<n.length;i++)n[i]=vO(n[i-3]^n[i-8]^n[i-14]^n[i-16],1);var o=this.h[0],s=this.h[1],a=this.h[2],d=this.h[3],u=this.h[4];for(i=0;i<n.length;i++){var c=~~(i/20),l=z7e(vO(o,5),V7e(c,s,a,d),u,n[i],H7e[c]);u=d,d=a,a=vO(s,30),s=o,o=l}this.h[0]=Hx(this.h[0],o),this.h[1]=Hx(this.h[1],s),this.h[2]=Hx(this.h[2],a),this.h[3]=Hx(this.h[3],d),this.h[4]=Hx(this.h[4],u)};Al.prototype._digest=function(e){return e==="hex"?dw.toHex32(this.h,"big"):dw.split32(this.h,"big")}});var bO=H((l2t,Bre)=>{"use strict";h();var uw=cu(),W7e=cw(),lw=gO(),G7e=hc(),du=uw.sum32,J7e=uw.sum32_4,Y7e=uw.sum32_5,Z7e=lw.ch32,X7e=lw.maj32,Q7e=lw.s0_256,eRe=lw.s1_256,tRe=lw.g0_256,rRe=lw.g1_256,Rre=W7e.BlockHash,nRe=[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 Tl(){if(!(this instanceof Tl))return new Tl;Rre.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=nRe,this.W=new Array(64)}uw.inherits(Tl,Rre);Bre.exports=Tl;Tl.blockSize=512;Tl.outSize=256;Tl.hmacStrength=192;Tl.padLength=64;Tl.prototype._update=function(e,r){for(var n=this.W,i=0;i<16;i++)n[i]=e[r+i];for(;i<n.length;i++)n[i]=J7e(rRe(n[i-2]),n[i-7],tRe(n[i-15]),n[i-16]);var o=this.h[0],s=this.h[1],a=this.h[2],d=this.h[3],u=this.h[4],c=this.h[5],l=this.h[6],m=this.h[7];for(G7e(this.k.length===n.length),i=0;i<n.length;i++){var p=Y7e(m,eRe(u),Z7e(u,c,l),this.k[i],n[i]),g=du(Q7e(o),X7e(o,s,a));m=l,l=c,c=u,u=du(d,p),d=a,a=s,s=o,o=du(p,g)}this.h[0]=du(this.h[0],o),this.h[1]=du(this.h[1],s),this.h[2]=du(this.h[2],a),this.h[3]=du(this.h[3],d),this.h[4]=du(this.h[4],u),this.h[5]=du(this.h[5],c),this.h[6]=du(this.h[6],l),this.h[7]=du(this.h[7],m)};Tl.prototype._digest=function(e){return e==="hex"?uw.toHex32(this.h,"big"):uw.split32(this.h,"big")}});var Ore=H((h2t,Dre)=>{"use strict";h();var wO=cu(),Mre=bO();function sh(){if(!(this instanceof sh))return new sh;Mre.call(this),this.h=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]}wO.inherits(sh,Mre);Dre.exports=sh;sh.blockSize=512;sh.outSize=224;sh.hmacStrength=192;sh.padLength=64;sh.prototype._digest=function(e){return e==="hex"?wO.toHex32(this.h.slice(0,7),"big"):wO.split32(this.h.slice(0,7),"big")}});var EO=H((m2t,jre)=>{"use strict";h();var Ma=cu(),iRe=cw(),oRe=hc(),Il=Ma.rotr64_hi,Pl=Ma.rotr64_lo,Cre=Ma.shr64_hi,$re=Ma.shr64_lo,im=Ma.sum64,_O=Ma.sum64_hi,xO=Ma.sum64_lo,sRe=Ma.sum64_4_hi,aRe=Ma.sum64_4_lo,cRe=Ma.sum64_5_hi,dRe=Ma.sum64_5_lo,Nre=iRe.BlockHash,uRe=[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 uu(){if(!(this instanceof uu))return new uu;Nre.call(this),this.h=[1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209],this.k=uRe,this.W=new Array(160)}Ma.inherits(uu,Nre);jre.exports=uu;uu.blockSize=1024;uu.outSize=512;uu.hmacStrength=192;uu.padLength=128;uu.prototype._prepareBlock=function(e,r){for(var n=this.W,i=0;i<32;i++)n[i]=e[r+i];for(;i<n.length;i+=2){var o=_Re(n[i-4],n[i-3]),s=xRe(n[i-4],n[i-3]),a=n[i-14],d=n[i-13],u=bRe(n[i-30],n[i-29]),c=wRe(n[i-30],n[i-29]),l=n[i-32],m=n[i-31];n[i]=sRe(o,s,a,d,u,c,l,m),n[i+1]=aRe(o,s,a,d,u,c,l,m)}};uu.prototype._update=function(e,r){this._prepareBlock(e,r);var n=this.W,i=this.h[0],o=this.h[1],s=this.h[2],a=this.h[3],d=this.h[4],u=this.h[5],c=this.h[6],l=this.h[7],m=this.h[8],p=this.h[9],g=this.h[10],v=this.h[11],E=this.h[12],A=this.h[13],P=this.h[14],I=this.h[15];oRe(this.k.length===n.length);for(var $=0;$<n.length;$+=2){var N=P,K=I,F=gRe(m,p),U=vRe(m,p),V=lRe(m,p,g,v,E,A),L=fRe(m,p,g,v,E,A),T=this.k[$],S=this.k[$+1],k=n[$],f=n[$+1],y=cRe(N,K,F,U,V,L,T,S,k,f),w=dRe(N,K,F,U,V,L,T,S,k,f);N=mRe(i,o),K=yRe(i,o),F=hRe(i,o,s,a,d,u),U=pRe(i,o,s,a,d,u);var _=_O(N,K,F,U),x=xO(N,K,F,U);P=E,I=A,E=g,A=v,g=m,v=p,m=_O(c,l,y,w),p=xO(l,l,y,w),c=d,l=u,d=s,u=a,s=i,a=o,i=_O(y,w,_,x),o=xO(y,w,_,x)}im(this.h,0,i,o),im(this.h,2,s,a),im(this.h,4,d,u),im(this.h,6,c,l),im(this.h,8,m,p),im(this.h,10,g,v),im(this.h,12,E,A),im(this.h,14,P,I)};uu.prototype._digest=function(e){return e==="hex"?Ma.toHex32(this.h,"big"):Ma.split32(this.h,"big")};function lRe(t,e,r,n,i){var o=t&r^~t&i;return o<0&&(o+=4294967296),o}function fRe(t,e,r,n,i,o){var s=e&n^~e&o;return s<0&&(s+=4294967296),s}function hRe(t,e,r,n,i){var o=t&r^t&i^r&i;return o<0&&(o+=4294967296),o}function pRe(t,e,r,n,i,o){var s=e&n^e&o^n&o;return s<0&&(s+=4294967296),s}function mRe(t,e){var r=Il(t,e,28),n=Il(e,t,2),i=Il(e,t,7),o=r^n^i;return o<0&&(o+=4294967296),o}function yRe(t,e){var r=Pl(t,e,28),n=Pl(e,t,2),i=Pl(e,t,7),o=r^n^i;return o<0&&(o+=4294967296),o}function gRe(t,e){var r=Il(t,e,14),n=Il(t,e,18),i=Il(e,t,9),o=r^n^i;return o<0&&(o+=4294967296),o}function vRe(t,e){var r=Pl(t,e,14),n=Pl(t,e,18),i=Pl(e,t,9),o=r^n^i;return o<0&&(o+=4294967296),o}function bRe(t,e){var r=Il(t,e,1),n=Il(t,e,8),i=Cre(t,e,7),o=r^n^i;return o<0&&(o+=4294967296),o}function wRe(t,e){var r=Pl(t,e,1),n=Pl(t,e,8),i=$re(t,e,7),o=r^n^i;return o<0&&(o+=4294967296),o}function _Re(t,e){var r=Il(t,e,19),n=Il(e,t,29),i=Cre(t,e,6),o=r^n^i;return o<0&&(o+=4294967296),o}function xRe(t,e){var r=Pl(t,e,19),n=Pl(e,t,29),i=$re(t,e,6),o=r^n^i;return o<0&&(o+=4294967296),o}});var Lre=H((g2t,qre)=>{"use strict";h();var SO=cu(),Ure=EO();function ah(){if(!(this instanceof ah))return new ah;Ure.call(this),this.h=[3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]}SO.inherits(ah,Ure);qre.exports=ah;ah.blockSize=1024;ah.outSize=384;ah.hmacStrength=192;ah.padLength=128;ah.prototype._digest=function(e){return e==="hex"?SO.toHex32(this.h.slice(0,12),"big"):SO.split32(this.h.slice(0,12),"big")}});var Kre=H(fw=>{"use strict";h();fw.sha1=kre();fw.sha224=Ore();fw.sha256=bO();fw.sha384=Lre();fw.sha512=EO()});var Gre=H(Wre=>{"use strict";h();var G0=cu(),ERe=cw(),q4=G0.rotl32,Fre=G0.sum32,Wx=G0.sum32_3,zre=G0.sum32_4,Hre=ERe.BlockHash;function kl(){if(!(this instanceof kl))return new kl;Hre.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.endian="little"}G0.inherits(kl,Hre);Wre.ripemd160=kl;kl.blockSize=512;kl.outSize=160;kl.hmacStrength=192;kl.padLength=64;kl.prototype._update=function(e,r){for(var n=this.h[0],i=this.h[1],o=this.h[2],s=this.h[3],a=this.h[4],d=n,u=i,c=o,l=s,m=a,p=0;p<80;p++){var g=Fre(q4(zre(n,Vre(p,i,o,s),e[TRe[p]+r],SRe(p)),PRe[p]),a);n=a,a=s,s=q4(o,10),o=i,i=g,g=Fre(q4(zre(d,Vre(79-p,u,c,l),e[IRe[p]+r],ARe(p)),kRe[p]),m),d=m,m=l,l=q4(c,10),c=u,u=g}g=Wx(this.h[1],o,l),this.h[1]=Wx(this.h[2],s,m),this.h[2]=Wx(this.h[3],a,d),this.h[3]=Wx(this.h[4],n,u),this.h[4]=Wx(this.h[0],i,c),this.h[0]=g};kl.prototype._digest=function(e){return e==="hex"?G0.toHex32(this.h,"little"):G0.split32(this.h,"little")};function Vre(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 SRe(t){return t<=15?0:t<=31?1518500249:t<=47?1859775393:t<=63?2400959708:2840853838}function ARe(t){return t<=15?1352829926:t<=31?1548603684:t<=47?1836072691:t<=63?2053994217:0}var TRe=[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],IRe=[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],PRe=[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],kRe=[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 Yre=H((E2t,Jre)=>{"use strict";h();var RRe=cu(),BRe=hc();function hw(t,e,r){if(!(this instanceof hw))return new hw(t,e,r);this.Hash=t,this.blockSize=t.blockSize/8,this.outSize=t.outSize/8,this.inner=null,this.outer=null,this._init(RRe.toArray(e,r))}Jre.exports=hw;hw.prototype._init=function(e){e.length>this.blockSize&&(e=new this.Hash().update(e).digest()),BRe(e.length<=this.blockSize);for(var r=e.length;r<this.blockSize;r++)e.push(0);for(r=0;r<e.length;r++)e[r]^=54;for(this.inner=new this.Hash().update(e),r=0;r<e.length;r++)e[r]^=106;this.outer=new this.Hash().update(e)};hw.prototype.update=function(e,r){return this.inner.update(e,r),this};hw.prototype.digest=function(e){return this.outer.update(this.inner.digest()),this.outer.digest(e)}});var L4=H(Zre=>{h();var zo=Zre;zo.utils=cu();zo.common=cw();zo.sha=Kre();zo.ripemd=Gre();zo.hmac=Yre();zo.sha1=zo.sha.sha1;zo.sha256=zo.sha.sha256;zo.sha224=zo.sha.sha224;zo.sha384=zo.sha.sha384;zo.sha512=zo.sha.sha512;zo.ripemd160=zo.ripemd.ripemd160});var Qre=H((I2t,Xre)=>{h();Xre.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 K4=H(rne=>{"use strict";h();var TO=rne,om=L4(),AO=yO(),MRe=pc(),ene=MRe.assert;function tne(t){t.type==="short"?this.curve=new AO.short(t):t.type==="edwards"?this.curve=new AO.edwards(t):this.curve=new AO.mont(t),this.g=this.curve.g,this.n=this.curve.n,this.hash=t.hash,ene(this.g.validate(),"Invalid curve"),ene(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}TO.PresetCurve=tne;function sm(t,e){Object.defineProperty(TO,t,{configurable:!0,enumerable:!0,get:function(){var r=new tne(e);return Object.defineProperty(TO,t,{configurable:!0,enumerable:!0,value:r}),r}})}sm("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:om.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]});sm("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:om.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]});sm("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:om.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]});sm("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:om.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"]});sm("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:om.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"]});sm("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:om.sha256,gRed:!1,g:["9"]});sm("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:om.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});var IO;try{IO=Qre()}catch{IO=void 0}sm("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:om.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",IO]})});var one=H((B2t,ine)=>{"use strict";h();var DRe=L4(),J0=pO(),nne=hc();function am(t){if(!(this instanceof am))return new am(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=J0.toArray(t.entropy,t.entropyEnc||"hex"),r=J0.toArray(t.nonce,t.nonceEnc||"hex"),n=J0.toArray(t.pers,t.persEnc||"hex");nne(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(e,r,n)}ine.exports=am;am.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.V.length;o++)this.K[o]=0,this.V[o]=1;this._update(i),this._reseed=1,this.reseedInterval=281474976710656};am.prototype._hmac=function(){return new DRe.hmac(this.hash,this.K)};am.prototype._update=function(e){var r=this._hmac().update(this.V).update([0]);e&&(r=r.update(e)),this.K=r.digest(),this.V=this._hmac().update(this.V).digest(),e&&(this.K=this._hmac().update(this.V).update([1]).update(e).digest(),this.V=this._hmac().update(this.V).digest())};am.prototype.reseed=function(e,r,n,i){typeof r!="string"&&(i=n,n=r,r=null),e=J0.toArray(e,r),n=J0.toArray(n,i),nne(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(e.concat(n||[])),this._reseed=1};am.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=J0.toArray(n,i||"hex"),this._update(n));for(var o=[];o.length<e;)this.V=this._hmac().update(this.V).digest(),o=o.concat(this.V);var s=o.slice(0,e);return this._update(n),this._reseed++,J0.encode(s,r)}});var ane=H((D2t,sne)=>{"use strict";h();var ORe=Gi(),CRe=pc(),PO=CRe.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)}sne.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 ORe(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"?PO(e.x,"Need x coordinate"):(this.ec.curve.type==="short"||this.ec.curve.type==="edwards")&&PO(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()||PO(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"<Key priv: "+(this.priv&&this.priv.toString(16,2))+" pub: "+(this.pub&&this.pub.inspect())+" >"}});var une=H((C2t,dne)=>{"use strict";h();var F4=Gi(),BO=pc(),$Re=BO.assert;function z4(t,e){if(t instanceof z4)return t;this._importDER(t,e)||($Re(t.r&&t.s,"Signature without r or s"),this.r=new F4(t.r,16),this.s=new F4(t.s,16),t.recoveryParam===void 0?this.recoveryParam=null:this.recoveryParam=t.recoveryParam)}dne.exports=z4;function NRe(){this.place=0}function kO(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<n;o++,s++)i<<=8,i|=t[s],i>>>=0;return i<=127?!1:(e.place=s,i)}function cne(t){for(var e=0,r=t.length-1;!t[e]&&!(t[e+1]&128)&&e<r;)e++;return e===0?t:t.slice(e)}z4.prototype._importDER=function(e,r){e=BO.toArray(e,r);var n=new NRe;if(e[n.place++]!==48)return!1;var i=kO(e,n);if(i===!1||i+n.place!==e.length||e[n.place++]!==2)return!1;var o=kO(e,n);if(o===!1)return!1;var s=e.slice(n.place,o+n.place);if(n.place+=o,e[n.place++]!==2)return!1;var a=kO(e,n);if(a===!1||e.length!==a+n.place)return!1;var d=e.slice(n.place,a+n.place);if(s[0]===0)if(s[1]&128)s=s.slice(1);else return!1;if(d[0]===0)if(d[1]&128)d=d.slice(1);else return!1;return this.r=new F4(s),this.s=new F4(d),this.recoveryParam=null,!0};function RO(t,e){if(e<128){t.push(e);return}var r=1+(Math.log(e)/Math.LN2>>>3);for(t.push(r|128);--r;)t.push(e>>>(r<<3)&255);t.push(e)}z4.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=cne(r),n=cne(n);!n[0]&&!(n[1]&128);)n=n.slice(1);var i=[2];RO(i,r.length),i=i.concat(r),i.push(2),RO(i,n.length);var o=i.concat(n),s=[48];return RO(s,o.length),s=s.concat(o),BO.encode(s,e)}});var pne=H((N2t,hne)=>{"use strict";h();var Y0=Gi(),lne=one(),jRe=pc(),MO=K4(),URe=T4(),fne=jRe.assert,DO=ane(),V4=une();function fd(t){if(!(this instanceof fd))return new fd(t);typeof t=="string"&&(fne(Object.prototype.hasOwnProperty.call(MO,t),"Unknown curve "+t),t=MO[t]),t instanceof MO.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}hne.exports=fd;fd.prototype.keyPair=function(e){return new DO(this,e)};fd.prototype.keyFromPrivate=function(e,r){return DO.fromPrivate(this,e,r)};fd.prototype.keyFromPublic=function(e,r){return DO.fromPublic(this,e,r)};fd.prototype.genKeyPair=function(e){e||(e={});for(var r=new lne({hash:this.hash,pers:e.pers,persEnc:e.persEnc||"utf8",entropy:e.entropy||URe(this.hash.hmacStrength),entropyEnc:e.entropy&&e.entropyEnc||"utf8",nonce:this.n.toArray()}),n=this.n.byteLength(),i=this.n.sub(new Y0(2));;){var o=new Y0(r.generate(n));if(!(o.cmp(i)>0))return o.iaddn(1),this.keyFromPrivate(o)}};fd.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};fd.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 Y0(e,16));for(var o=this.n.byteLength(),s=r.getPrivate().toArray("be",o),a=e.toArray("be",o),d=new lne({hash:this.hash,entropy:s,nonce:a,pers:i.pers,persEnc:i.persEnc||"utf8"}),u=this.n.sub(new Y0(1)),c=0;;c++){var l=i.k?i.k(c):new Y0(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 v=l.invm(this.n).mul(g.mul(r.getPrivate()).iadd(e));if(v=v.umod(this.n),v.cmpn(0)!==0){var E=(m.getY().isOdd()?1:0)|(p.cmp(g)!==0?2:0);return i.canonical&&v.cmp(this.nh)>0&&(v=this.n.sub(v),E^=1),new V4({r:g,s:v,recoveryParam:E})}}}}}};fd.prototype.verify=function(e,r,n,i){e=this._truncateToN(new Y0(e,16)),n=this.keyFromPublic(n,i),r=new V4(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)};fd.prototype.recoverPubKey=function(t,e,r,n){fne((3&r)===r,"The recovery param is more than two bits"),e=new V4(e,n);var i=this.n,o=new Y0(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)};fd.prototype.getKeyRecoveryParam=function(t,e,r,n){if(e=new V4(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 vne=H((U2t,gne)=>{"use strict";h();var Gx=pc(),yne=Gx.assert,mne=Gx.parseBytes,pw=Gx.cachedProperty;function wo(t,e){this.eddsa=t,this._secret=mne(e.secret),t.isPoint(e.pub)?this._pub=e.pub:this._pubBytes=mne(e.pub)}wo.fromPublic=function(e,r){return r instanceof wo?r:new wo(e,{pub:r})};wo.fromSecret=function(e,r){return r instanceof wo?r:new wo(e,{secret:r})};wo.prototype.secret=function(){return this._secret};pw(wo,"pubBytes",function(){return this.eddsa.encodePoint(this.pub())});pw(wo,"pub",function(){return this._pubBytes?this.eddsa.decodePoint(this._pubBytes):this.eddsa.g.mul(this.priv())});pw(wo,"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});pw(wo,"priv",function(){return this.eddsa.decodeInt(this.privBytes())});pw(wo,"hash",function(){return this.eddsa.hash().update(this.secret()).digest()});pw(wo,"messagePrefix",function(){return this.hash().slice(this.eddsa.encodingLength)});wo.prototype.sign=function(e){return yne(this._secret,"KeyPair can only verify"),this.eddsa.sign(e,this)};wo.prototype.verify=function(e,r){return this.eddsa.verify(e,r,this)};wo.prototype.getSecret=function(e){return yne(this._secret,"KeyPair is public only"),Gx.encode(this.secret(),e)};wo.prototype.getPublic=function(e){return Gx.encode(this.pubBytes(),e)};gne.exports=wo});var wne=H((L2t,bne)=>{"use strict";h();var qRe=Gi(),H4=pc(),LRe=H4.assert,W4=H4.cachedProperty,KRe=H4.parseBytes;function Z0(t,e){this.eddsa=t,typeof e!="object"&&(e=KRe(e)),Array.isArray(e)&&(e={R:e.slice(0,t.encodingLength),S:e.slice(t.encodingLength)}),LRe(e.R&&e.S,"Signature without R or S"),t.isPoint(e.R)&&(this._R=e.R),e.S instanceof qRe&&(this._S=e.S),this._Rencoded=Array.isArray(e.R)?e.R:e.Rencoded,this._Sencoded=Array.isArray(e.S)?e.S:e.Sencoded}W4(Z0,"S",function(){return this.eddsa.decodeInt(this.Sencoded())});W4(Z0,"R",function(){return this.eddsa.decodePoint(this.Rencoded())});W4(Z0,"Rencoded",function(){return this.eddsa.encodePoint(this.R())});W4(Z0,"Sencoded",function(){return this.eddsa.encodeInt(this.S())});Z0.prototype.toBytes=function(){return this.Rencoded().concat(this.Sencoded())};Z0.prototype.toHex=function(){return H4.encode(this.toBytes(),"hex").toUpperCase()};bne.exports=Z0});var Ane=H((F2t,Sne)=>{"use strict";h();var FRe=L4(),zRe=K4(),mw=pc(),VRe=mw.assert,xne=mw.parseBytes,Ene=vne(),_ne=wne();function Da(t){if(VRe(t==="ed25519","only tested with ed25519 so far"),!(this instanceof Da))return new Da(t);t=zRe[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=FRe.sha512}Sne.exports=Da;Da.prototype.sign=function(e,r){e=xne(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})};Da.prototype.verify=function(e,r,n){e=xne(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)};Da.prototype.hashInt=function(){for(var e=this.hash(),r=0;r<arguments.length;r++)e.update(arguments[r]);return mw.intFromLE(e.digest()).umod(this.curve.n)};Da.prototype.keyFromPublic=function(e){return Ene.fromPublic(this,e)};Da.prototype.keyFromSecret=function(e){return Ene.fromSecret(this,e)};Da.prototype.makeSignature=function(e){return e instanceof _ne?e:new _ne(this,e)};Da.prototype.encodePoint=function(e){var r=e.getY().toArray("le",this.encodingLength);return r[this.encodingLength-1]|=e.getX().isOdd()?128:0,r};Da.prototype.decodePoint=function(e){e=mw.parseBytes(e);var r=e.length-1,n=e.slice(0,r).concat(e[r]&-129),i=(e[r]&128)!==0,o=mw.intFromLE(n);return this.curve.pointFromY(o,i)};Da.prototype.encodeInt=function(e){return e.toArray("le",this.encodingLength)};Da.prototype.decodeInt=function(e){return mw.intFromLE(e)};Da.prototype.isPoint=function(e){return e instanceof this.pointClass}});var G4=H(Tne=>{"use strict";h();var X0=Tne;X0.version=ire().version;X0.utils=pc();X0.rand=T4();X0.curve=yO();X0.curves=K4();X0.ec=pne();X0.eddsa=Ane()});var Y4=H((W2t,Ine)=>{"use strict";h();var J4=$n(),yw=J4.Buffer,hd={},pd;for(pd in J4)J4.hasOwnProperty(pd)&&(pd==="SlowBuffer"||pd==="Buffer"||(hd[pd]=J4[pd]));var gw=hd.Buffer={};for(pd in yw)yw.hasOwnProperty(pd)&&(pd==="allocUnsafe"||pd==="allocUnsafeSlow"||(gw[pd]=yw[pd]));hd.Buffer.prototype=yw.prototype;(!gw.from||gw.from===Uint8Array.from)&&(gw.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 yw(t,e,r)});gw.alloc||(gw.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=yw(t);return!e||e.length===0?n.fill(0):typeof r=="string"?n.fill(e,r):n.fill(e),n});if(!hd.kStringMaxLength)try{hd.kStringMaxLength=D.default.binding("buffer").kStringMaxLength}catch{}hd.constants||(hd.constants={MAX_LENGTH:hd.kMaxLength},hd.kStringMaxLength&&(hd.constants.MAX_STRING_LENGTH=hd.kStringMaxLength));Ine.exports=hd});var Z4=H(Pne=>{"use strict";h();var HRe=ur();function md(t){this._reporterState={obj:null,path:[],options:t||{},errors:[]}}Pne.Reporter=md;md.prototype.isError=function(e){return e instanceof vw};md.prototype.save=function(){let e=this._reporterState;return{obj:e.obj,pathLen:e.path.length}};md.prototype.restore=function(e){let r=this._reporterState;r.obj=e.obj,r.path=r.path.slice(0,e.pathLen)};md.prototype.enterKey=function(e){return this._reporterState.path.push(e)};md.prototype.exitKey=function(e){let r=this._reporterState;r.path=r.path.slice(0,e-1)};md.prototype.leaveKey=function(e,r,n){let i=this._reporterState;this.exitKey(e),i.obj!==null&&(i.obj[r]=n)};md.prototype.path=function(){return this._reporterState.path.join("/")};md.prototype.enterObject=function(){let e=this._reporterState,r=e.obj;return e.obj={},r};md.prototype.leaveObject=function(e){let r=this._reporterState,n=r.obj;return r.obj=e,n};md.prototype.error=function(e){let r,n=this._reporterState,i=e instanceof vw;if(i?r=e:r=new vw(n.path.map(function(o){return"["+JSON.stringify(o)+"]"}).join(""),e.message||e,e.stack),!n.options.partial)throw r;return i||n.errors.push(r),r};md.prototype.wrapResult=function(e){let r=this._reporterState;return r.options.partial?{result:this.isError(e)?null:e,errors:r.errors}:e};function vw(t,e){this.path=t,this.rethrow(e)}HRe(vw,Error);vw.prototype.rethrow=function(e){if(this.message=e+" at: "+(this.path||"(shallow)"),Error.captureStackTrace&&Error.captureStackTrace(this,vw),!this.stack)try{throw new Error(this.message)}catch(r){this.stack=r.stack}return this}});var _w=H(OO=>{"use strict";h();var WRe=ur(),X4=Z4().Reporter,bw=Y4().Buffer;function yd(t,e){if(X4.call(this,e),!bw.isBuffer(t)){this.error("Input not Buffer");return}this.base=t,this.offset=0,this.length=t.length}WRe(yd,X4);OO.DecoderBuffer=yd;yd.isDecoderBuffer=function(e){return e instanceof yd?!0:typeof e=="object"&&bw.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"};yd.prototype.save=function(){return{offset:this.offset,reporter:X4.prototype.save.call(this)}};yd.prototype.restore=function(e){let r=new yd(this.base);return r.offset=e.offset,r.length=this.offset,this.offset=e.offset,X4.prototype.restore.call(this,e.reporter),r};yd.prototype.isEmpty=function(){return this.offset===this.length};yd.prototype.readUInt8=function(e){return this.offset+1<=this.length?this.base.readUInt8(this.offset++,!0):this.error(e||"DecoderBuffer overrun")};yd.prototype.skip=function(e,r){if(!(this.offset+e<=this.length))return this.error(r||"DecoderBuffer overrun");let n=new yd(this.base);return n._reporterState=this._reporterState,n.offset=this.offset,n.length=this.offset+e,this.offset+=e,n};yd.prototype.raw=function(e){return this.base.slice(e?e.offset:this.offset,this.length)};function ww(t,e){if(Array.isArray(t))this.length=0,this.value=t.map(function(r){return ww.isEncoderBuffer(r)||(r=new ww(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=bw.byteLength(t);else if(bw.isBuffer(t))this.value=t,this.length=t.length;else return e.error("Unsupported type: "+typeof t)}OO.EncoderBuffer=ww;ww.isEncoderBuffer=function(e){return e instanceof ww?!0:typeof e=="object"&&e.constructor.name==="EncoderBuffer"&&typeof e.length=="number"&&typeof e.join=="function"};ww.prototype.join=function(e,r){return e||(e=bw.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):bw.isBuffer(this.value)&&this.value.copy(e,r),r+=this.length)),e}});var Q4=H((Q2t,Rne)=>{"use strict";h();var GRe=Z4().Reporter,JRe=_w().EncoderBuffer,YRe=_w().DecoderBuffer,na=hc(),kne=["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"],ZRe=["key","obj","use","optional","explicit","implicit","def","choice","any","contains"].concat(kne),XRe=["_peekTag","_decodeTag","_use","_decodeStr","_decodeObjid","_decodeTime","_decodeNull","_decodeInt","_decodeBool","_decodeList","_encodeComposite","_encodeStr","_encodeObjid","_encodeTime","_encodeNull","_encodeInt","_encodeBool"];function hn(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())}Rne.exports=hn;var QRe=["enc","parent","children","tag","args","reverseArgs","choice","optional","any","obj","use","alteredUse","key","default","explicit","implicit","contains"];hn.prototype.clone=function(){let e=this._baseState,r={};QRe.forEach(function(i){r[i]=e[i]});let n=new this.constructor(r.parent);return n._baseState=r,n};hn.prototype._wrap=function(){let e=this._baseState;ZRe.forEach(function(r){this[r]=function(){let i=new this.constructor(this);return e.children.push(i),i[r].apply(i,arguments)}},this)};hn.prototype._init=function(e){let r=this._baseState;na(r.parent===null),e.call(this),r.children=r.children.filter(function(n){return n._baseState.parent===this},this),na.equal(r.children.length,1,"Root node can have only one child")};hn.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&&(na(r.children===null),r.children=n,n.forEach(function(i){i._baseState.parent=this},this)),e.length!==0&&(na(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}))};XRe.forEach(function(t){hn.prototype[t]=function(){let r=this._baseState;throw new Error(t+" not implemented for encoding: "+r.enc)}});kne.forEach(function(t){hn.prototype[t]=function(){let r=this._baseState,n=Array.prototype.slice.call(arguments);return na(r.tag===null),r.tag=t,this._useArgs(n),this}});hn.prototype.use=function(e){na(e);let r=this._baseState;return na(r.use===null),r.use=e,this};hn.prototype.optional=function(){let e=this._baseState;return e.optional=!0,this};hn.prototype.def=function(e){let r=this._baseState;return na(r.default===null),r.default=e,r.optional=!0,this};hn.prototype.explicit=function(e){let r=this._baseState;return na(r.explicit===null&&r.implicit===null),r.explicit=e,this};hn.prototype.implicit=function(e){let r=this._baseState;return na(r.explicit===null&&r.implicit===null),r.implicit=e,this};hn.prototype.obj=function(){let e=this._baseState,r=Array.prototype.slice.call(arguments);return e.obj=!0,r.length!==0&&this._useArgs(r),this};hn.prototype.key=function(e){let r=this._baseState;return na(r.key===null),r.key=e,this};hn.prototype.any=function(){let e=this._baseState;return e.any=!0,this};hn.prototype.choice=function(e){let r=this._baseState;return na(r.choice===null),r.choice=e,this._useArgs(Object.keys(e).map(function(n){return e[n]})),this};hn.prototype.contains=function(e){let r=this._baseState;return na(r.use===null),r.contains=e,this};hn.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 YRe(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};hn.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)};hn.prototype._getUse=function(e,r){let n=this._baseState;return n.useDecoder=this._use(e,r),na(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};hn.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")};hn.prototype._createEncoderBuffer=function(e){return new JRe(e,this.reporter)};hn.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};hn.prototype._encodeValue=function(e,r,n){let i=this._baseState;if(i.parent===null)return i.children[0]._encode(e,r||new GRe);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};hn.prototype._encodeChoice=function(e,r){let n=this._baseState,i=n.choice[e.type];return i||na(!1,e.type+" not found in "+JSON.stringify(Object.keys(n.choice))),i._encode(e.value,r)};hn.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)};hn.prototype._isNumstr=function(e){return/^[0-9 ]*$/.test(e)};hn.prototype._isPrintstr=function(e){return/^[A-Za-z0-9 '()+,-./:=?]*$/.test(e)}});var eA=H(Q0=>{"use strict";h();function Bne(t){let e={};return Object.keys(t).forEach(function(r){(r|0)==r&&(r=r|0);let n=t[r];e[n]=r}),e}Q0.tagClass={0:"universal",1:"application",2:"context",3:"private"};Q0.tagClassByName=Bne(Q0.tagClass);Q0.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"};Q0.tagByName=Bne(Q0.tag)});var $O=H((n_t,One)=>{"use strict";h();var eBe=ur(),ch=Y4().Buffer,Mne=Q4(),CO=eA();function Dne(t){this.enc="der",this.name=t.name,this.entity=t,this.tree=new lu,this.tree._init(t.body)}One.exports=Dne;Dne.prototype.encode=function(e,r){return this.tree._encode(e,r).join()};function lu(t){Mne.call(this,"der",t)}eBe(lu,Mne);lu.prototype._encodeComposite=function(e,r,n,i){let o=tBe(e,r,n,this.reporter);if(i.length<128){let d=ch.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=ch.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])};lu.prototype._encodeStr=function(e,r){if(r==="bitstr")return this._createEncoderBuffer([e.unused|0,e.data]);if(r==="bmpstr"){let n=ch.alloc(e.length*2);for(let i=0;i<e.length;i++)n.writeUInt16BE(e.charCodeAt(i),i*2);return this._createEncoderBuffer(n)}else return r==="numstr"?this._isNumstr(e)?this._createEncoderBuffer(e):this.reporter.error("Encoding of string type: numstr supports only digits and space"):r==="printstr"?this._isPrintstr(e)?this._createEncoderBuffer(e):this.reporter.error("Encoding of string type: printstr supports only latin upper and lower case letters, digits, space, apostrophe, left and rigth parenthesis, plus sign, comma, hyphen, dot, slash, colon, equal sign, question mark"):/str$/.test(r)?this._createEncoderBuffer(e):r==="objDesc"?this._createEncoderBuffer(e):this.reporter.error("Encoding of string type: "+r+" unsupported")};lu.prototype._encodeObjid=function(e,r,n){if(typeof e=="string"){if(!r)return this.reporter.error("string objid given, but no values map found");if(!r.hasOwnProperty(e))return this.reporter.error("objid not found in values map");e=r[e].split(/[\s.]+/g);for(let a=0;a<e.length;a++)e[a]|=0}else if(Array.isArray(e)){e=e.slice();for(let a=0;a<e.length;a++)e[a]|=0}if(!Array.isArray(e))return this.reporter.error("objid() should be either array or string, got: "+JSON.stringify(e));if(!n){if(e[1]>=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<e.length;a++){let d=e[a];for(i++;d>=128;d>>=7)i++}let o=ch.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 gd(t){return t<10?"0"+t:t}lu.prototype._encodeTime=function(e,r){let n,i=new Date(e);return r==="gentime"?n=[gd(i.getUTCFullYear()),gd(i.getUTCMonth()+1),gd(i.getUTCDate()),gd(i.getUTCHours()),gd(i.getUTCMinutes()),gd(i.getUTCSeconds()),"Z"].join(""):r==="utctime"?n=[gd(i.getUTCFullYear()%100),gd(i.getUTCMonth()+1),gd(i.getUTCDate()),gd(i.getUTCHours()),gd(i.getUTCMinutes()),gd(i.getUTCSeconds()),"Z"].join(""):this.reporter.error("Encoding "+r+" time is not supported yet"),this._encodeStr(n,"octstr")};lu.prototype._encodeNull=function(){return this._createEncoderBuffer("")};lu.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"&&!ch.isBuffer(e)){let o=e.toArray();!e.sign&&o[0]&128&&o.unshift(0),e=ch.from(o)}if(ch.isBuffer(e)){let o=e.length;e.length===0&&o++;let s=ch.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(ch.from(i))};lu.prototype._encodeBool=function(e){return this._createEncoderBuffer(e?255:0)};lu.prototype._use=function(e,r){return typeof e=="function"&&(e=e(r)),e._getEncoder("der").tree};lu.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<s.length;o++)if(s[o]!==i.defaultBuffer[o])return!1;return!0};function tBe(t,e,r,n){let i;if(t==="seqof"?t="seq":t==="setof"&&(t="set"),CO.tagByName.hasOwnProperty(t))i=CO.tagByName[t];else if(typeof t=="number"&&(t|0)===t)i=t;else return n.error("Unknown tag: "+t);return i>=31?n.error("Multi-octet tag encoding unsupported"):(e||(i|=32),i|=CO.tagClassByName[r||"universal"]<<6,i)}});var $ne=H((o_t,Cne)=>{"use strict";h();var rBe=ur(),NO=$O();function jO(t){NO.call(this,t),this.enc="pem"}rBe(jO,NO);Cne.exports=jO;jO.prototype.encode=function(e,r){let i=NO.prototype.encode.call(this,e).toString("base64"),o=["-----BEGIN "+r.label+"-----"];for(let s=0;s<i.length;s+=64)o.push(i.slice(s,s+64));return o.push("-----END "+r.label+"-----"),o.join(`
`)}});var UO=H(jne=>{"use strict";h();var Nne=jne;Nne.der=$O();Nne.pem=$ne()});var LO=H((d_t,zne)=>{"use strict";h();var nBe=ur(),iBe=Gi(),Une=_w().DecoderBuffer,Lne=Q4(),qne=eA();function Kne(t){this.enc="der",this.name=t.name,this.entity=t,this.tree=new mc,this.tree._init(t.body)}zne.exports=Kne;Kne.prototype.decode=function(e,r){return Une.isDecoderBuffer(e)||(e=new Une(e,r)),this.tree._decode(e,r)};function mc(t){Lne.call(this,"der",t)}nBe(mc,Lne);mc.prototype._peekTag=function(e,r,n){if(e.isEmpty())return!1;let i=e.save(),o=qO(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)};mc.prototype._decodeTag=function(e,r,n){let i=qO(e,'Failed to decode tag of "'+r+'"');if(e.isError(i))return i;let o=Fne(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+'"'))};mc.prototype._skipUntilEnd=function(e,r){for(;;){let n=qO(e,r);if(e.isError(n))return n;let i=Fne(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}};mc.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};mc.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<n.length/2;o++)i+=String.fromCharCode(n.readUInt16BE(o*2));return i}else if(r==="numstr"){let n=e.raw().toString("ascii");return this._isNumstr(n)?n:e.error("Decoding of string type: numstr unsupported characters")}else{if(r==="octstr")return e.raw();if(r==="objDesc")return e.raw();if(r==="printstr"){let n=e.raw().toString("ascii");return this._isPrintstr(n)?n:e.error("Decoding of string type: printstr unsupported characters")}else return/str$/.test(r)?e.raw().toString():e.error("Decoding of string type: "+r+" unsupported")}};mc.prototype._decodeObjid=function(e,r,n){let i,o=[],s=0,a=0;for(;!e.isEmpty();)a=e.readUInt8(),s<<=7,s|=a&127,a&128||(o.push(s),s=0);a&128&&o.push(s);let d=o[0]/40|0,u=o[0]%40;if(n?i=o:i=[d,u].concat(o.slice(1)),r){let c=r[i.join(" ")];c===void 0&&(c=r[i.join(".")]),c!==void 0&&(i=c)}return i};mc.prototype._decodeTime=function(e,r){let n=e.raw().toString(),i,o,s,a,d,u;if(r==="gentime")i=n.slice(0,4)|0,o=n.slice(4,6)|0,s=n.slice(6,8)|0,a=n.slice(8,10)|0,d=n.slice(10,12)|0,u=n.slice(12,14)|0;else if(r==="utctime")i=n.slice(0,2)|0,o=n.slice(2,4)|0,s=n.slice(4,6)|0,a=n.slice(6,8)|0,d=n.slice(8,10)|0,u=n.slice(10,12)|0,i<70?i=2e3+i:i=1900+i;else return e.error("Decoding "+r+" time is not supported yet");return Date.UTC(i,o-1,s,a,d,u,0)};mc.prototype._decodeNull=function(){return null};mc.prototype._decodeBool=function(e){let r=e.readUInt8();return e.isError(r)?r:r!==0};mc.prototype._decodeInt=function(e,r){let n=e.raw(),i=new iBe(n);return r&&(i=r[i.toString(10)]||i),i};mc.prototype._use=function(e,r){return typeof e=="function"&&(e=e(r)),e._getDecoder("der").tree};function qO(t,e){let r=t.readUInt8(e);if(t.isError(r))return r;let n=qne.tagClass[r>>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=qne.tag[r];return{cls:n,primitive:i,tag:r,tagStr:o}}function Fne(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<i;o++){n<<=8;let s=t.readUInt8(r);if(t.isError(s))return s;n|=s}return n}});var Hne=H((l_t,Vne)=>{"use strict";h();var oBe=ur(),sBe=Y4().Buffer,KO=LO();function FO(t){KO.call(this,t),this.enc="pem"}oBe(FO,KO);Vne.exports=FO;FO.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<n.length;c++){let l=n[c].match(o);if(l!==null&&l[2]===i)if(s===-1){if(l[1]!=="BEGIN")break;s=c}else{if(l[1]!=="END")break;a=c;break}}if(s===-1||a===-1)throw new Error("PEM section not found for: "+i);let d=n.slice(s+1,a).join("");d.replace(/[^a-z0-9+/=]+/gi,"");let u=sBe.from(d,"base64");return KO.prototype.decode.call(this,u,r)}});var zO=H(Gne=>{"use strict";h();var Wne=Gne;Wne.der=LO();Wne.pem=Hne()});var Yne=H(Jne=>{"use strict";h();var aBe=UO(),cBe=zO(),dBe=ur(),uBe=Jne;uBe.define=function(e,r){return new xw(e,r)};function xw(t,e){this.name=t,this.body=e,this.decoders={},this.encoders={}}xw.prototype._createNamed=function(e){let r=this.name;function n(i){this._initNamed(i,r)}return dBe(n,e),n.prototype._initNamed=function(o,s){e.call(this,o,s)},new n(this)};xw.prototype._getDecoder=function(e){return e=e||"der",this.decoders.hasOwnProperty(e)||(this.decoders[e]=this._createNamed(cBe[e])),this.decoders[e]};xw.prototype.decode=function(e,r,n){return this._getDecoder(r).decode(e,n)};xw.prototype._getEncoder=function(e){return e=e||"der",this.encoders.hasOwnProperty(e)||(this.encoders[e]=this._createNamed(aBe[e])),this.encoders[e]};xw.prototype.encode=function(e,r,n){return this._getEncoder(r).encode(e,n)}});var Xne=H(Zne=>{"use strict";h();var tA=Zne;tA.Reporter=Z4().Reporter;tA.DecoderBuffer=_w().DecoderBuffer;tA.EncoderBuffer=_w().EncoderBuffer;tA.Node=Q4()});var tie=H(eie=>{"use strict";h();var Qne=eie;Qne._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};Qne.der=eA()});var VO=H(rie=>{"use strict";h();var Ew=rie;Ew.bignum=Gi();Ew.define=Yne().define;Ew.base=Xne();Ew.constants=tie();Ew.decoders=zO();Ew.encoders=UO()});var sie=H((E_t,oie)=>{"use strict";h();var fu=VO(),nie=fu.define("Time",function(){this.choice({utcTime:this.utctime(),generalTime:this.gentime()})}),lBe=fu.define("AttributeTypeValue",function(){this.seq().obj(this.key("type").objid(),this.key("value").any())}),HO=fu.define("AlgorithmIdentifier",function(){this.seq().obj(this.key("algorithm").objid(),this.key("parameters").optional(),this.key("curve").objid().optional())}),fBe=fu.define("SubjectPublicKeyInfo",function(){this.seq().obj(this.key("algorithm").use(HO),this.key("subjectPublicKey").bitstr())}),hBe=fu.define("RelativeDistinguishedName",function(){this.setof(lBe)}),pBe=fu.define("RDNSequence",function(){this.seqof(hBe)}),iie=fu.define("Name",function(){this.choice({rdnSequence:this.use(pBe)})}),mBe=fu.define("Validity",function(){this.seq().obj(this.key("notBefore").use(nie),this.key("notAfter").use(nie))}),yBe=fu.define("Extension",function(){this.seq().obj(this.key("extnID").objid(),this.key("critical").bool().def(!1),this.key("extnValue").octstr())}),gBe=fu.define("TBSCertificate",function(){this.seq().obj(this.key("version").explicit(0).int().optional(),this.key("serialNumber").int(),this.key("signature").use(HO),this.key("issuer").use(iie),this.key("validity").use(mBe),this.key("subject").use(iie),this.key("subjectPublicKeyInfo").use(fBe),this.key("issuerUniqueID").implicit(1).bitstr().optional(),this.key("subjectUniqueID").implicit(2).bitstr().optional(),this.key("extensions").explicit(3).seqof(yBe).optional())}),vBe=fu.define("X509Certificate",function(){this.seq().obj(this.key("tbsCertificate").use(gBe),this.key("signatureAlgorithm").use(HO),this.key("signatureValue").bitstr())});oie.exports=vBe});var cie=H(pu=>{"use strict";h();var hu=VO();pu.certificate=sie();var bBe=hu.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())});pu.RSAPrivateKey=bBe;var wBe=hu.define("RSAPublicKey",function(){this.seq().obj(this.key("modulus").int(),this.key("publicExponent").int())});pu.RSAPublicKey=wBe;var _Be=hu.define("SubjectPublicKeyInfo",function(){this.seq().obj(this.key("algorithm").use(aie),this.key("subjectPublicKey").bitstr())});pu.PublicKey=_Be;var aie=hu.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())}),xBe=hu.define("PrivateKeyInfo",function(){this.seq().obj(this.key("version").int(),this.key("algorithm").use(aie),this.key("subjectPrivateKey").octstr())});pu.PrivateKey=xBe;var EBe=hu.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())});pu.EncryptedPrivateKey=EBe;var SBe=hu.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())});pu.DSAPrivateKey=SBe;pu.DSAparam=hu.define("DSAparam",function(){this.int()});var ABe=hu.define("ECPrivateKey",function(){this.seq().obj(this.key("version").int(),this.key("privateKey").octstr(),this.key("parameters").optional().explicit(0).use(TBe),this.key("publicKey").optional().explicit(1).bitstr())});pu.ECPrivateKey=ABe;var TBe=hu.define("ECParameters",function(){this.choice({namedCurve:this.objid()})});pu.signature=hu.define("signature",function(){this.seq().obj(this.key("r").int(),this.key("s").int())})});var die=H((I_t,IBe)=>{IBe.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 lie=H((P_t,uie)=>{h();var PBe=/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,kBe=/^-----BEGIN ((?:.*? KEY)|CERTIFICATE)-----/m,RBe=/^-----BEGIN ((?:.*? KEY)|CERTIFICATE)-----([0-9A-z\n\r+/=]+)-----END \1-----$/m,BBe=Lx(),MBe=A4(),rA=dr().Buffer;uie.exports=function(t,e){var r=t.toString(),n=r.match(PBe),i;if(n){var s="aes"+n[1],a=rA.from(n[2],"hex"),d=rA.from(n[3].replace(/[\r\n]/g,""),"base64"),u=BBe(e,a.slice(0,8),parseInt(n[1],10)).key,c=[],l=MBe.createDecipheriv(s,u,a);c.push(l.update(d)),c.push(l.final()),i=rA.concat(c)}else{var o=r.match(RBe);i=rA.from(o[2].replace(/[\r\n]/g,""),"base64")}var m=r.match(kBe)[1];return{tag:m,data:i}}});var Jx=H((R_t,hie)=>{h();var Oa=cie(),DBe=die(),OBe=lie(),CBe=A4(),$Be=CD(),WO=dr().Buffer;hie.exports=fie;function fie(t){var e;typeof t=="object"&&!WO.isBuffer(t)&&(e=t.passphrase,t=t.key),typeof t=="string"&&(t=WO.from(t));var r=OBe(t,e),n=r.tag,i=r.data,o,s;switch(n){case"CERTIFICATE":s=Oa.certificate.decode(i,"der").tbsCertificate.subjectPublicKeyInfo;case"PUBLIC KEY":switch(s||(s=Oa.PublicKey.decode(i,"der")),o=s.algorithm.algorithm.join("."),o){case"1.2.840.113549.1.1.1":return Oa.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=Oa.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=Oa.EncryptedPrivateKey.decode(i,"der"),i=NBe(i,e);case"PRIVATE KEY":switch(s=Oa.PrivateKey.decode(i,"der"),o=s.algorithm.algorithm.join("."),o){case"1.2.840.113549.1.1.1":return Oa.RSAPrivateKey.decode(s.subjectPrivateKey,"der");case"1.2.840.10045.2.1":return{curve:s.algorithm.curve,privateKey:Oa.ECPrivateKey.decode(s.subjectPrivateKey,"der").privateKey};case"1.2.840.10040.4.1":return s.algorithm.params.priv_key=Oa.DSAparam.decode(s.subjectPrivateKey,"der"),{type:"dsa",params:s.algorithm.params};default:throw new Error("unknown key id "+o)}case"RSA PUBLIC KEY":return Oa.RSAPublicKey.decode(i,"der");case"RSA PRIVATE KEY":return Oa.RSAPrivateKey.decode(i,"der");case"DSA PRIVATE KEY":return{type:"dsa",params:Oa.DSAPrivateKey.decode(i,"der")};case"EC PRIVATE KEY":return i=Oa.ECPrivateKey.decode(i,"der"),{curve:i.parameters.value,privateKey:i.privateKey};default:throw new Error("unknown key type "+n)}}fie.signature=Oa.signature;function NBe(t,e){var r=t.algorithm.decrypt.kde.kdeparams.salt,n=parseInt(t.algorithm.decrypt.kde.kdeparams.iters.toString(),10),i=DBe[t.algorithm.decrypt.cipher.algo.join(".")],o=t.algorithm.decrypt.cipher.iv,s=t.subjectPrivateKey,a=parseInt(i.split("-")[1],10)/8,d=$Be.pbkdf2Sync(e,r,n,a,"sha1"),u=CBe.createDecipheriv(i,d,o),c=[];return c.push(u.update(s)),c.push(u.final()),WO.concat(c)}});var GO=H((M_t,jBe)=>{jBe.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 yie=H((D_t,iA)=>{"use strict";h();var ks=dr().Buffer,eg=AD(),UBe=B4(),qBe=G4().ec,nA=R4(),LBe=Jx(),KBe=GO(),FBe=1;function zBe(t,e,r,n,i){var o=LBe(e);if(o.curve){if(n!=="ecdsa"&&n!=="ecdsa/rsa")throw new Error("wrong private key type");return VBe(t,o)}else if(o.type==="dsa"){if(n!=="dsa")throw new Error("wrong private key type");return HBe(t,o,r)}if(n!=="rsa"&&n!=="ecdsa/rsa")throw new Error("wrong private key type");if(e.padding!==void 0&&e.padding!==FBe)throw new Error("illegal or unsupported padding mode");t=ks.concat([i,t]);for(var s=o.modulus.byteLength(),a=[0,1];t.length+a.length+1<s;)a.push(255);a.push(0);for(var d=-1;++d<t.length;)a.push(t[d]);var u=UBe(a,o);return u}function VBe(t,e){var r=KBe[e.curve.join(".")];if(!r)throw new Error("unknown curve "+e.curve.join("."));var n=new qBe(r),i=n.keyFromPrivate(e.privateKey),o=i.sign(t);return ks.from(o.toDER())}function HBe(t,e,r){for(var n=e.params.priv_key,i=e.params.p,o=e.params.q,s=e.params.g,a=new nA(0),d,u=JO(t,o).mod(o),c=!1,l=pie(n,o,t,r);c===!1;)d=mie(o,l,r),a=JBe(s,d,i,o),c=d.invm(o).imul(u.add(n.mul(a))).mod(o),c.cmpn(0)===0&&(c=!1,a=new nA(0));return WBe(a,c)}function WBe(t,e){t=t.toArray(),e=e.toArray(),t[0]&128&&(t=[0].concat(t)),e[0]&128&&(e=[0].concat(e));var r=t.length+e.length+4,n=[48,r,2,t.length];return n=n.concat(t,[2,e.length],e),ks.from(n)}function pie(t,e,r,n){if(t=ks.from(t.toArray()),t.length<e.byteLength()){var i=ks.alloc(e.byteLength()-t.length);t=ks.concat([i,t])}var o=r.length,s=GBe(r,e),a=ks.alloc(o);a.fill(1);var d=ks.alloc(o);return d=eg(n,d).update(a).update(ks.from([0])).update(t).update(s).digest(),a=eg(n,d).update(a).digest(),d=eg(n,d).update(a).update(ks.from([1])).update(t).update(s).digest(),a=eg(n,d).update(a).digest(),{k:d,v:a}}function JO(t,e){var r=new nA(t),n=(t.length<<3)-e.bitLength();return n>0&&r.ishrn(n),r}function GBe(t,e){t=JO(t,e),t=t.mod(e);var r=ks.from(t.toArray());if(r.length<e.byteLength()){var n=ks.alloc(e.byteLength()-r.length);r=ks.concat([n,r])}return r}function mie(t,e,r){var n,i;do{for(n=ks.alloc(0);n.length*8<t.bitLength();)e.v=eg(r,e.k).update(e.v).digest(),n=ks.concat([n,e.v]);i=JO(n,t),e.k=eg(r,e.k).update(e.v).update(ks.from([0])).digest(),e.v=eg(r,e.k).update(e.v).digest()}while(i.cmp(t)!==-1);return i}function JBe(t,e,r,n){return t.toRed(nA.mont(r)).redPow(e).fromRed().mod(n)}iA.exports=zBe;iA.exports.getKey=pie;iA.exports.makeKey=mie});var wie=H((C_t,bie)=>{"use strict";h();var YO=dr().Buffer,Yx=R4(),YBe=G4().ec,vie=Jx(),ZBe=GO();function XBe(t,e,r,n,i){var o=vie(r);if(o.type==="ec"){if(n!=="ecdsa"&&n!=="ecdsa/rsa")throw new Error("wrong public key type");return QBe(t,e,o)}else if(o.type==="dsa"){if(n!=="dsa")throw new Error("wrong public key type");return eMe(t,e,o)}if(n!=="rsa"&&n!=="ecdsa/rsa")throw new Error("wrong public key type");e=YO.concat([i,e]);for(var s=o.modulus.byteLength(),a=[1],d=0;e.length+a.length+2<s;)a.push(255),d+=1;a.push(0);for(var u=-1;++u<e.length;)a.push(e[u]);a=YO.from(a);var c=Yx.mont(o.modulus);t=new Yx(t).toRed(c),t=t.redPow(new Yx(o.publicExponent)),t=YO.from(t.fromRed().toArray());var l=d<8?1:0;for(s=Math.min(t.length,a.length),t.length!==a.length&&(l=1),u=-1;++u<s;)l|=t[u]^a[u];return l===0}function QBe(t,e,r){var n=ZBe[r.data.algorithm.curve.join(".")];if(!n)throw new Error("unknown curve "+r.data.algorithm.curve.join("."));var i=new YBe(n),o=r.data.subjectPrivateKey.data;return i.verify(e,t,o)}function eMe(t,e,r){var n=r.data.p,i=r.data.q,o=r.data.g,s=r.data.pub_key,a=vie.signature.decode(t,"der"),d=a.s,u=a.r;gie(d,i),gie(u,i);var c=Yx.mont(n),l=d.invm(i),m=o.toRed(c).redPow(new Yx(e).mul(l).mod(i)).fromRed().mul(s.toRed(c).redPow(u.mul(l).mod(i)).fromRed()).mod(n).mod(i);return m.cmp(u)===0}function gie(t,e){if(t.cmpn(0)<=0)throw new Error("invalid sig");if(t.cmp(e)>=0)throw new Error("invalid sig")}bie.exports=XBe});var Tie=H((N_t,Aie)=>{"use strict";h();var oA=dr().Buffer,Eie=Zb(),sA=X8(),Sie=ur(),tMe=yie(),rMe=wie(),tg=TD();Object.keys(tg).forEach(function(t){tg[t].id=oA.from(tg[t].id,"hex"),tg[t.toLowerCase()]=tg[t]});function Zx(t){sA.Writable.call(this);var e=tg[t];if(!e)throw new Error("Unknown message digest");this._hashType=e.hash,this._hash=Eie(e.hash),this._tag=e.id,this._signType=e.sign}Sie(Zx,sA.Writable);Zx.prototype._write=function(e,r,n){this._hash.update(e),n()};Zx.prototype.update=function(e,r){return this._hash.update(typeof e=="string"?oA.from(e,r):e),this};Zx.prototype.sign=function(e,r){this.end();var n=this._hash.digest(),i=tMe(n,e,this._hashType,this._signType,this._tag);return r?i.toString(r):i};function Xx(t){sA.Writable.call(this);var e=tg[t];if(!e)throw new Error("Unknown message digest");this._hash=Eie(e.hash),this._tag=e.id,this._signType=e.sign}Sie(Xx,sA.Writable);Xx.prototype._write=function(e,r,n){this._hash.update(e),n()};Xx.prototype.update=function(e,r){return this._hash.update(typeof e=="string"?oA.from(e,r):e),this};Xx.prototype.verify=function(e,r,n){var i=typeof r=="string"?oA.from(r,n):r;this.end();var o=this._hash.digest();return rMe(i,o,e,this._signType,this._tag)};function _ie(t){return new Zx(t)}function xie(t){return new Xx(t)}Aie.exports={Sign:_ie,Verify:xie,createSign:_ie,createVerify:xie}});var Pie=H((U_t,Iie)=>{h();var nMe=G4(),iMe=Gi();Iie.exports=function(e){return new rg(e)};var yc={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}};yc.p224=yc.secp224r1;yc.p256=yc.secp256r1=yc.prime256v1;yc.p192=yc.secp192r1=yc.prime192v1;yc.p384=yc.secp384r1;yc.p521=yc.secp521r1;function rg(t){this.curveType=yc[t],this.curveType||(this.curveType={name:t}),this.curve=new nMe.ec(this.curveType.name),this.keys=void 0}rg.prototype.generateKeys=function(t,e){return this.keys=this.curve.genKeyPair(),this.getPublicKey(t,e)};rg.prototype.computeSecret=function(t,e,r){e=e||"utf8",C.Buffer.isBuffer(t)||(t=new C.Buffer(t,e));var n=this.curve.keyFromPublic(t).getPublic(),i=n.mul(this.keys.getPrivate()).getX();return ZO(i,r,this.curveType.byteLength)};rg.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),ZO(r,t)};rg.prototype.getPrivateKey=function(t){return ZO(this.keys.getPrivate(),t)};rg.prototype.setPublicKey=function(t,e){return e=e||"utf8",C.Buffer.isBuffer(t)||(t=new C.Buffer(t,e)),this.keys._importPublic(t),this};rg.prototype.setPrivateKey=function(t,e){e=e||"utf8",C.Buffer.isBuffer(t)||(t=new C.Buffer(t,e));var r=new iMe(t);return r=r.toString(16),this.keys=this.curve.genKeyPair(),this.keys._importPrivate(r),this};function ZO(t,e,r){Array.isArray(t)||(t=t.toArray());var n=new C.Buffer(t);if(r&&n.length<r){var i=new C.Buffer(r-n.length);i.fill(0),n=C.Buffer.concat([i,n])}return e?n.toString(e):n}});var QO=H((L_t,kie)=>{h();var oMe=Zb(),XO=dr().Buffer;kie.exports=function(t,e){for(var r=XO.alloc(0),n=0,i;r.length<e;)i=sMe(n++),r=XO.concat([r,oMe("sha1").update(t).update(i).digest()]);return r.slice(0,e)};function sMe(t){var e=XO.allocUnsafe(4);return e.writeUInt32BE(t,0),e}});var eC=H((F_t,Rie)=>{h();Rie.exports=function(e,r){for(var n=e.length,i=-1;++i<n;)e[i]^=r[i];return e}});var tC=H((V_t,Mie)=>{h();var Bie=Gi(),aMe=dr().Buffer;function cMe(t,e){return aMe.from(t.toRed(Bie.mont(e.modulus)).redPow(new Bie(e.publicExponent)).fromRed().toArray())}Mie.exports=cMe});var $ie=H((W_t,Cie)=>{h();var dMe=Jx(),rC=B0(),uMe=Zb(),Die=QO(),Oie=eC(),nC=Gi(),lMe=tC(),fMe=B4(),mu=dr().Buffer;Cie.exports=function(e,r,n){var i;e.padding?i=e.padding:n?i=1:i=4;var o=dMe(e),s;if(i===4)s=hMe(o,r);else if(i===1)s=pMe(o,r,n);else if(i===3){if(s=new nC(r),s.cmp(o.modulus)>=0)throw new Error("data too long for modulus")}else throw new Error("unknown padding");return n?fMe(s,o):lMe(s,o)};function hMe(t,e){var r=t.modulus.byteLength(),n=e.length,i=uMe("sha1").update(mu.alloc(0)).digest(),o=i.length,s=2*o;if(n>r-s-2)throw new Error("message too long");var a=mu.alloc(r-n-s-2),d=r-o-1,u=rC(o),c=Oie(mu.concat([i,a,mu.alloc(1,1),e],d),Die(u,d)),l=Oie(u,Die(c,o));return new nC(mu.concat([mu.alloc(1),l,c],r))}function pMe(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=mu.alloc(i-n-3,255):o=mMe(i-n-3),new nC(mu.concat([mu.from([0,r?1:2]),o,mu.alloc(1),e],i))}function mMe(t){for(var e=mu.allocUnsafe(t),r=0,n=rC(t*2),i=0,o;r<t;)i===n.length&&(n=rC(t*2),i=0),o=n[i++],o&&(e[r++]=o);return e}});var Lie=H((J_t,qie)=>{h();var yMe=Jx(),Nie=QO(),jie=eC(),Uie=Gi(),gMe=B4(),vMe=Zb(),bMe=tC(),Qx=dr().Buffer;qie.exports=function(e,r,n){var i;e.padding?i=e.padding:n?i=1:i=4;var o=yMe(e),s=o.modulus.byteLength();if(r.length>s||new Uie(r).cmp(o.modulus)>=0)throw new Error("decryption error");var a;n?a=bMe(new Uie(r),o):a=gMe(r,o);var d=Qx.alloc(s-a.length);if(a=Qx.concat([d,a],s),i===4)return wMe(o,a);if(i===1)return _Me(o,a,n);if(i===3)return a;throw new Error("unknown padding")};function wMe(t,e){var r=t.modulus.byteLength(),n=vMe("sha1").update(Qx.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=jie(o,Nie(s,i)),d=jie(s,Nie(a,r-i-1));if(xMe(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 _Me(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 xMe(t,e){t=Qx.from(t),e=Qx.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<n;)r+=t[i]^e[i];return r}});var Kie=H(ng=>{h();ng.publicEncrypt=$ie();ng.privateDecrypt=Lie();ng.privateEncrypt=function(e,r){return ng.publicEncrypt(e,r,!0)};ng.publicDecrypt=function(e,r){return ng.privateDecrypt(e,r,!0)}});var Xie=H(eE=>{"use strict";h();function Fie(){throw new Error(`secure random number generation not supported by this browser
use chrome, FireFox or Internet Explorer 11`)}var Vie=dr(),zie=B0(),Hie=Vie.Buffer,Wie=Vie.kMaxLength,iC=globalThis.crypto||globalThis.msCrypto,Gie=Math.pow(2,32)-1;function Jie(t,e){if(typeof t!="number"||t!==t)throw new TypeError("offset must be a number");if(t>Gie||t<0)throw new TypeError("offset must be a uint32");if(t>Wie||t>e)throw new RangeError("offset out of range")}function Yie(t,e,r){if(typeof t!="number"||t!==t)throw new TypeError("size must be a number");if(t>Gie||t<0)throw new TypeError("size must be a uint32");if(t+e>r||t>Wie)throw new RangeError("buffer too small")}iC&&iC.getRandomValues||!D.default.browser?(eE.randomFill=EMe,eE.randomFillSync=SMe):(eE.randomFill=Fie,eE.randomFillSync=Fie);function EMe(t,e,r,n){if(!Hie.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 Jie(e,t.length),Yie(r,e,t.length),Zie(t,e,r,n)}function Zie(t,e,r,n){if(D.default.browser){var i=t.buffer,o=new Uint8Array(i,e,r);if(iC.getRandomValues(o),n){D.default.nextTick(function(){n(null,t)});return}return t}if(n){zie(r,function(a,d){if(a)return n(a);d.copy(t,e),n(null,t)});return}var s=zie(r);return s.copy(t,e),t}function SMe(t,e,r){if(typeof e>"u"&&(e=0),!Hie.isBuffer(t)&&!(t instanceof globalThis.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');return Jie(e,t.length),r===void 0&&(r=t.length-e),Yie(r,e,t.length),Zie(t,e,r)}});var I4=H(lr=>{"use strict";h();lr.randomBytes=lr.rng=lr.pseudoRandomBytes=lr.prng=B0();lr.createHash=lr.Hash=Zb();lr.createHmac=lr.Hmac=AD();var AMe=vee(),TMe=Object.keys(AMe),IMe=["sha1","sha224","sha256","sha384","sha512","md5","rmd160"].concat(TMe);lr.getHashes=function(){return IMe};var Qie=CD();lr.pbkdf2=Qie.pbkdf2;lr.pbkdf2Sync=Qie.pbkdf2Sync;var Rl=qte();lr.Cipher=Rl.Cipher;lr.createCipher=Rl.createCipher;lr.Cipheriv=Rl.Cipheriv;lr.createCipheriv=Rl.createCipheriv;lr.Decipher=Rl.Decipher;lr.createDecipher=Rl.createDecipher;lr.Decipheriv=Rl.Decipheriv;lr.createDecipheriv=Rl.createDecipheriv;lr.getCiphers=Rl.getCiphers;lr.listCiphers=Rl.listCiphers;var tE=Qte();lr.DiffieHellmanGroup=tE.DiffieHellmanGroup;lr.createDiffieHellmanGroup=tE.createDiffieHellmanGroup;lr.getDiffieHellman=tE.getDiffieHellman;lr.createDiffieHellman=tE.createDiffieHellman;lr.DiffieHellman=tE.DiffieHellman;var aA=Tie();lr.createSign=aA.createSign;lr.Sign=aA.Sign;lr.createVerify=aA.createVerify;lr.Verify=aA.Verify;lr.createECDH=Pie();var cA=Kie();lr.publicEncrypt=cA.publicEncrypt;lr.privateEncrypt=cA.privateEncrypt;lr.publicDecrypt=cA.publicDecrypt;lr.privateDecrypt=cA.privateDecrypt;var eoe=Xie();lr.randomFill=eoe.randomFill;lr.randomFillSync=eoe.randomFillSync;lr.createCredentials=function(){throw new Error(["sorry, createCredentials is not implemented yet","we accept pull requests","https://github.com/crypto-browserify/crypto-browserify"].join(`
`))};lr.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 yu=H(fr=>{"use strict";h();Object.defineProperty(fr,"__esModule",{value:!0});fr.setBigUint64=fr.Hash=fr.equalBytes=fr.ensureBytes=fr.checkOpts=fr.concatBytes=fr.toBytes=fr.bytesToUtf8=fr.utf8ToBytes=fr.asyncLoop=fr.nextTick=fr.hexToBytes=fr.bytesToHex=fr.isLE=fr.createView=fr.u32=fr.u16=fr.u8=void 0;var sC=t=>t instanceof Uint8Array,PMe=t=>new Uint8Array(t.buffer,t.byteOffset,t.byteLength);fr.u8=PMe;var kMe=t=>new Uint16Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/2));fr.u16=kMe;var RMe=t=>new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4));fr.u32=RMe;var BMe=t=>new DataView(t.buffer,t.byteOffset,t.byteLength);fr.createView=BMe;fr.isLE=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!fr.isLE)throw new Error("Non little-endian hardware is not supported");var MMe=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function DMe(t){if(!sC(t))throw new Error("Uint8Array expected");let e="";for(let r=0;r<t.length;r++)e+=MMe[t[r]];return e}fr.bytesToHex=DMe;function OMe(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);let e=t.length;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);let r=new Uint8Array(e/2);for(let n=0;n<r.length;n++){let i=n*2,o=t.slice(i,i+2),s=Number.parseInt(o,16);if(Number.isNaN(s)||s<0)throw new Error("Invalid byte sequence");r[n]=s}return r}fr.hexToBytes=OMe;var CMe=async()=>{};fr.nextTick=CMe;async function $Me(t,e,r){let n=Date.now();for(let i=0;i<t;i++){r(i);let o=Date.now()-n;o>=0&&o<e||(await(0,fr.nextTick)(),n+=o)}}fr.asyncLoop=$Me;function toe(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}fr.utf8ToBytes=toe;function NMe(t){return new TextDecoder().decode(t)}fr.bytesToUtf8=NMe;function jMe(t){if(typeof t=="string"&&(t=toe(t)),!sC(t))throw new Error(`expected Uint8Array, got ${typeof t}`);return t}fr.toBytes=jMe;function UMe(...t){let e=new Uint8Array(t.reduce((n,i)=>n+i.length,0)),r=0;return t.forEach(n=>{if(!sC(n))throw new Error("Uint8Array expected");e.set(n,r),r+=n.length}),e}fr.concatBytes=UMe;var qMe=t=>Object.prototype.toString.call(t)==="[object Object]"&&t.constructor===Object;function LMe(t,e){if(e!==void 0&&(typeof e!="object"||!qMe(e)))throw new Error("options must be object or undefined");return Object.assign(t,e)}fr.checkOpts=LMe;function KMe(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`)}fr.ensureBytes=KMe;function FMe(t,e){if(t.length!==e.length)throw new Error("equalBytes: Different size of Uint8Arrays");let r=!0;for(let n=0;n<t.length;n++)r&&(r=t[n]===e[n]);return r}fr.equalBytes=FMe;var oC=class{};fr.Hash=oC;function zMe(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)}fr.setBigUint64=zMe});var rE=H(Rs=>{"use strict";h();Object.defineProperty(Rs,"__esModule",{value:!0});Rs.AEAD_TAG_LENGTH=Rs.XCHACHA20_NONCE_LENGTH=Rs.CURVE25519_PUBLIC_KEY_SIZE=Rs.ETH_PUBLIC_KEY_SIZE=Rs.UNCOMPRESSED_PUBLIC_KEY_SIZE=Rs.COMPRESSED_PUBLIC_KEY_SIZE=Rs.SECRET_KEY_LENGTH=void 0;Rs.SECRET_KEY_LENGTH=32;Rs.COMPRESSED_PUBLIC_KEY_SIZE=33;Rs.UNCOMPRESSED_PUBLIC_KEY_SIZE=65;Rs.ETH_PUBLIC_KEY_SIZE=64;Rs.CURVE25519_PUBLIC_KEY_SIZE=32;Rs.XCHACHA20_NONCE_LENGTH=24;Rs.AEAD_TAG_LENGTH=16});var ig=H(Ln=>{"use strict";h();Object.defineProperty(Ln,"__esModule",{value:!0});Ln.ephemeralKeySize=Ln.symmetricNonceLength=Ln.symmetricAlgorithm=Ln.isHkdfKeyCompressed=Ln.isEphemeralKeyCompressed=Ln.ellipticCurve=Ln.ECIES_CONFIG=void 0;var dA=rE(),VMe=function(){function t(){this.ellipticCurve="secp256k1",this.isEphemeralKeyCompressed=!1,this.isHkdfKeyCompressed=!1,this.symmetricAlgorithm="aes-256-gcm",this.symmetricNonceLength=16}return t}();Ln.ECIES_CONFIG=new VMe;var HMe=function(){return Ln.ECIES_CONFIG.ellipticCurve};Ln.ellipticCurve=HMe;var WMe=function(){return Ln.ECIES_CONFIG.isEphemeralKeyCompressed};Ln.isEphemeralKeyCompressed=WMe;var GMe=function(){return Ln.ECIES_CONFIG.isHkdfKeyCompressed};Ln.isHkdfKeyCompressed=GMe;var JMe=function(){return Ln.ECIES_CONFIG.symmetricAlgorithm};Ln.symmetricAlgorithm=JMe;var YMe=function(){return Ln.ECIES_CONFIG.symmetricNonceLength};Ln.symmetricNonceLength=YMe;var ZMe=function(){var t={secp256k1:Ln.ECIES_CONFIG.isEphemeralKeyCompressed?dA.COMPRESSED_PUBLIC_KEY_SIZE:dA.UNCOMPRESSED_PUBLIC_KEY_SIZE,x25519:dA.CURVE25519_PUBLIC_KEY_SIZE,ed25519:dA.CURVE25519_PUBLIC_KEY_SIZE};if(Ln.ECIES_CONFIG.ellipticCurve in t)return t[Ln.ECIES_CONFIG.ellipticCurve];throw new Error("Not implemented")};Ln.ephemeralKeySize=ZMe});var roe=H(uA=>{"use strict";h();Object.defineProperty(uA,"__esModule",{value:!0});uA.crypto=void 0;uA.crypto=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0});var aC=H(Sw=>{"use strict";h();Object.defineProperty(Sw,"__esModule",{value:!0});Sw.getWebcryptoSubtle=Sw.randomBytes=void 0;var og=roe();function XMe(t=32){if(og.crypto&&typeof og.crypto.getRandomValues=="function")return og.crypto.getRandomValues(new Uint8Array(t));throw new Error("crypto.getRandomValues must be defined")}Sw.randomBytes=XMe;function QMe(){if(og.crypto&&typeof og.crypto.subtle=="object"&&og.crypto.subtle!=null)return og.crypto.subtle;throw new Error("crypto.subtle must be defined")}Sw.getWebcryptoSubtle=QMe});var dC=H(ia=>{"use strict";h();Object.defineProperty(ia,"__esModule",{value:!0});ia.output=ia.exists=ia.hash=ia.bytes=ia.bool=ia.number=void 0;function lA(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`Wrong positive integer: ${t}`)}ia.number=lA;function noe(t){if(typeof t!="boolean")throw new Error(`Expected boolean, not ${t}`)}ia.bool=noe;function eDe(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}function cC(t,...e){if(!eDe(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}`)}ia.bytes=cC;function ioe(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");lA(t.outputLen),lA(t.blockLen)}ia.hash=ioe;function ooe(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}ia.exists=ooe;function soe(t,e){cC(t);let r=e.outputLen;if(t.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}ia.output=soe;var tDe={number:lA,bool:noe,bytes:cC,hash:ioe,exists:ooe,output:soe};ia.default=tDe});var aoe=H(fA=>{"use strict";h();Object.defineProperty(fA,"__esModule",{value:!0});fA.crypto=void 0;fA.crypto=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0});var cm=H(hr=>{"use strict";h();Object.defineProperty(hr,"__esModule",{value:!0});hr.randomBytes=hr.wrapXOFConstructorWithOpts=hr.wrapConstructorWithOpts=hr.wrapConstructor=hr.checkOpts=hr.Hash=hr.concatBytes=hr.toBytes=hr.utf8ToBytes=hr.asyncLoop=hr.nextTick=hr.hexToBytes=hr.bytesToHex=hr.isLE=hr.rotr=hr.createView=hr.u32=hr.u8=void 0;var uC=aoe(),rDe=t=>new Uint8Array(t.buffer,t.byteOffset,t.byteLength);hr.u8=rDe;var nDe=t=>new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4));hr.u32=nDe;function fC(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}var iDe=t=>new DataView(t.buffer,t.byteOffset,t.byteLength);hr.createView=iDe;var oDe=(t,e)=>t<<32-e|t>>>e;hr.rotr=oDe;hr.isLE=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!hr.isLE)throw new Error("Non little-endian hardware is not supported");var sDe=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function aDe(t){if(!fC(t))throw new Error("Uint8Array expected");let e="";for(let r=0;r<t.length;r++)e+=sDe[t[r]];return e}hr.bytesToHex=aDe;var dh={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function coe(t){if(t>=dh._0&&t<=dh._9)return t-dh._0;if(t>=dh._A&&t<=dh._F)return t-(dh._A-10);if(t>=dh._a&&t<=dh._f)return t-(dh._a-10)}function cDe(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<r;i++,o+=2){let s=coe(t.charCodeAt(o)),a=coe(t.charCodeAt(o+1));if(s===void 0||a===void 0){let d=t[o]+t[o+1];throw new Error('hex string expected, got non-hex character "'+d+'" at index '+o)}n[i]=s*16+a}return n}hr.hexToBytes=cDe;var dDe=async()=>{};hr.nextTick=dDe;async function uDe(t,e,r){let n=Date.now();for(let i=0;i<t;i++){r(i);let o=Date.now()-n;o>=0&&o<e||(await(0,hr.nextTick)(),n+=o)}}hr.asyncLoop=uDe;function doe(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}hr.utf8ToBytes=doe;function hA(t){if(typeof t=="string"&&(t=doe(t)),!fC(t))throw new Error(`expected Uint8Array, got ${typeof t}`);return t}hr.toBytes=hA;function lDe(...t){let e=0;for(let n=0;n<t.length;n++){let i=t[n];if(!fC(i))throw new Error("Uint8Array expected");e+=i.length}let r=new Uint8Array(e);for(let n=0,i=0;n<t.length;n++){let o=t[n];r.set(o,i),i+=o.length}return r}hr.concatBytes=lDe;var lC=class{clone(){return this._cloneInto()}};hr.Hash=lC;var fDe={}.toString;function hDe(t,e){if(e!==void 0&&fDe.call(e)!=="[object Object]")throw new Error("Options should be object or undefined");return Object.assign(t,e)}hr.checkOpts=hDe;function pDe(t){let e=n=>t().update(hA(n)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}hr.wrapConstructor=pDe;function mDe(t){let e=(n,i)=>t(i).update(hA(n)).digest(),r=t({});return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=n=>t(n),e}hr.wrapConstructorWithOpts=mDe;function yDe(t){let e=(n,i)=>t(i).update(hA(n)).digest(),r=t({});return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=n=>t(n),e}hr.wrapXOFConstructorWithOpts=yDe;function gDe(t=32){if(uC.crypto&&typeof uC.crypto.getRandomValues=="function")return uC.crypto.getRandomValues(new Uint8Array(t));throw new Error("crypto.getRandomValues must be defined")}hr.randomBytes=gDe});var mC=H(pA=>{"use strict";h();Object.defineProperty(pA,"__esModule",{value:!0});pA.SHA2=void 0;var hC=dC(),nE=cm();function vDe(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 pC=class extends nE.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,nE.createView)(this.buffer)}update(e){(0,hC.exists)(this);let{view:r,buffer:n,blockLen:i}=this;e=(0,nE.toBytes)(e);let o=e.length;for(let s=0;s<o;){let a=Math.min(i-this.pos,o-s);if(a===i){let d=(0,nE.createView)(e);for(;i<=o-s;s+=i)this.process(d,s);continue}n.set(e.subarray(s,s+a),this.pos),this.pos+=a,s+=a,this.pos===i&&(this.process(r,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){(0,hC.exists)(this),(0,hC.output)(e,this),this.finished=!0;let{buffer:r,view:n,blockLen:i,isLE:o}=this,{pos:s}=this;r[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>i-s&&(this.process(n,0),s=0);for(let l=s;l<i;l++)r[l]=0;vDe(n,i-8,BigInt(this.length*8),o),this.process(n,0);let a=(0,nE.createView)(e),d=this.outputLen;if(d%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let u=d/4,c=this.get();if(u>c.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;l<u;l++)a.setUint32(4*l,c[l],o)}digest(){let{buffer:e,outputLen:r}=this;this.digestInto(e);let n=e.slice(0,r);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());let{blockLen:r,buffer:n,length:i,finished:o,destroyed:s,pos:a}=this;return e.length=i,e.pos=a,e.finished=o,e.destroyed=s,i%r&&e.buffer.set(n),e}};pA.SHA2=pC});var Boe=H(Mt=>{"use strict";h();Object.defineProperty(Mt,"__esModule",{value:!0});Mt.add5L=Mt.add5H=Mt.add4H=Mt.add4L=Mt.add3H=Mt.add3L=Mt.add=Mt.rotlBL=Mt.rotlBH=Mt.rotlSL=Mt.rotlSH=Mt.rotr32L=Mt.rotr32H=Mt.rotrBL=Mt.rotrBH=Mt.rotrSL=Mt.rotrSH=Mt.shrSL=Mt.shrSH=Mt.toBig=Mt.split=Mt.fromBig=void 0;var mA=BigInt(2**32-1),yC=BigInt(32);function gC(t,e=!1){return e?{h:Number(t&mA),l:Number(t>>yC&mA)}:{h:Number(t>>yC&mA)|0,l:Number(t&mA)|0}}Mt.fromBig=gC;function uoe(t,e=!1){let r=new Uint32Array(t.length),n=new Uint32Array(t.length);for(let i=0;i<t.length;i++){let{h:o,l:s}=gC(t[i],e);[r[i],n[i]]=[o,s]}return[r,n]}Mt.split=uoe;var loe=(t,e)=>BigInt(t>>>0)<<yC|BigInt(e>>>0);Mt.toBig=loe;var foe=(t,e,r)=>t>>>r;Mt.shrSH=foe;var hoe=(t,e,r)=>t<<32-r|e>>>r;Mt.shrSL=hoe;var poe=(t,e,r)=>t>>>r|e<<32-r;Mt.rotrSH=poe;var moe=(t,e,r)=>t<<32-r|e>>>r;Mt.rotrSL=moe;var yoe=(t,e,r)=>t<<64-r|e>>>r-32;Mt.rotrBH=yoe;var goe=(t,e,r)=>t>>>r-32|e<<64-r;Mt.rotrBL=goe;var voe=(t,e)=>e;Mt.rotr32H=voe;var boe=(t,e)=>t;Mt.rotr32L=boe;var woe=(t,e,r)=>t<<r|e>>>32-r;Mt.rotlSH=woe;var _oe=(t,e,r)=>e<<r|t>>>32-r;Mt.rotlSL=_oe;var xoe=(t,e,r)=>e<<r-32|t>>>64-r;Mt.rotlBH=xoe;var Eoe=(t,e,r)=>t<<r-32|e>>>64-r;Mt.rotlBL=Eoe;function Soe(t,e,r,n){let i=(e>>>0)+(n>>>0);return{h:t+r+(i/2**32|0)|0,l:i|0}}Mt.add=Soe;var Aoe=(t,e,r)=>(t>>>0)+(e>>>0)+(r>>>0);Mt.add3L=Aoe;var Toe=(t,e,r,n)=>e+r+n+(t/2**32|0)|0;Mt.add3H=Toe;var Ioe=(t,e,r,n)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0);Mt.add4L=Ioe;var Poe=(t,e,r,n,i)=>e+r+n+i+(t/2**32|0)|0;Mt.add4H=Poe;var koe=(t,e,r,n,i)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0)+(i>>>0);Mt.add5L=koe;var Roe=(t,e,r,n,i,o)=>e+r+n+i+o+(t/2**32|0)|0;Mt.add5H=Roe;var bDe={fromBig:gC,split:uoe,toBig:loe,shrSH:foe,shrSL:hoe,rotrSH:poe,rotrSL:moe,rotrBH:yoe,rotrBL:goe,rotr32H:voe,rotr32L:boe,rotlSH:woe,rotlSL:_oe,rotlBH:xoe,rotlBL:Eoe,add:Soe,add3L:Aoe,add3H:Toe,add4L:Ioe,add4H:Poe,add5H:Roe,add5L:koe};Mt.default=bDe});var Moe=H(vd=>{"use strict";h();Object.defineProperty(vd,"__esModule",{value:!0});vd.sha384=vd.sha512_256=vd.sha512_224=vd.sha512=vd.SHA512=void 0;var wDe=mC(),pr=Boe(),yA=cm(),[_De,xDe]=pr.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))),dm=new Uint32Array(80),um=new Uint32Array(80),sg=class extends wDe.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:v,Hl:E}=this;return[e,r,n,i,o,s,a,d,u,c,l,m,p,g,v,E]}set(e,r,n,i,o,s,a,d,u,c,l,m,p,g,v,E){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=v|0,this.Hl=E|0}process(e,r){for(let I=0;I<16;I++,r+=4)dm[I]=e.getUint32(r),um[I]=e.getUint32(r+=4);for(let I=16;I<80;I++){let $=dm[I-15]|0,N=um[I-15]|0,K=pr.default.rotrSH($,N,1)^pr.default.rotrSH($,N,8)^pr.default.shrSH($,N,7),F=pr.default.rotrSL($,N,1)^pr.default.rotrSL($,N,8)^pr.default.shrSL($,N,7),U=dm[I-2]|0,V=um[I-2]|0,L=pr.default.rotrSH(U,V,19)^pr.default.rotrBH(U,V,61)^pr.default.shrSH(U,V,6),T=pr.default.rotrSL(U,V,19)^pr.default.rotrBL(U,V,61)^pr.default.shrSL(U,V,6),S=pr.default.add4L(F,T,um[I-7],um[I-16]),k=pr.default.add4H(S,K,L,dm[I-7],dm[I-16]);dm[I]=k|0,um[I]=S|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:v,Gl:E,Hh:A,Hl:P}=this;for(let I=0;I<80;I++){let $=pr.default.rotrSH(l,m,14)^pr.default.rotrSH(l,m,18)^pr.default.rotrBH(l,m,41),N=pr.default.rotrSL(l,m,14)^pr.default.rotrSL(l,m,18)^pr.default.rotrBL(l,m,41),K=l&p^~l&v,F=m&g^~m&E,U=pr.default.add5L(P,N,F,xDe[I],um[I]),V=pr.default.add5H(U,A,$,K,_De[I],dm[I]),L=U|0,T=pr.default.rotrSH(n,i,28)^pr.default.rotrBH(n,i,34)^pr.default.rotrBH(n,i,39),S=pr.default.rotrSL(n,i,28)^pr.default.rotrBL(n,i,34)^pr.default.rotrBL(n,i,39),k=n&o^n&a^o&a,f=i&s^i&d^s&d;A=v|0,P=E|0,v=p|0,E=g|0,p=l|0,g=m|0,{h:l,l:m}=pr.default.add(u|0,c|0,V|0,L|0),u=a|0,c=d|0,a=o|0,d=s|0,o=n|0,s=i|0;let y=pr.default.add3L(L,S,f);n=pr.default.add3H(y,V,T,k),i=y|0}({h:n,l:i}=pr.default.add(this.Ah|0,this.Al|0,n|0,i|0)),{h:o,l:s}=pr.default.add(this.Bh|0,this.Bl|0,o|0,s|0),{h:a,l:d}=pr.default.add(this.Ch|0,this.Cl|0,a|0,d|0),{h:u,l:c}=pr.default.add(this.Dh|0,this.Dl|0,u|0,c|0),{h:l,l:m}=pr.default.add(this.Eh|0,this.El|0,l|0,m|0),{h:p,l:g}=pr.default.add(this.Fh|0,this.Fl|0,p|0,g|0),{h:v,l:E}=pr.default.add(this.Gh|0,this.Gl|0,v|0,E|0),{h:A,l:P}=pr.default.add(this.Hh|0,this.Hl|0,A|0,P|0),this.set(n,i,o,s,a,d,u,c,l,m,p,g,v,E,A,P)}roundClean(){dm.fill(0),um.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)}};vd.SHA512=sg;var vC=class extends sg{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}},bC=class extends sg{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}},wC=class extends sg{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}};vd.sha512=(0,yA.wrapConstructor)(()=>new sg);vd.sha512_224=(0,yA.wrapConstructor)(()=>new vC);vd.sha512_256=(0,yA.wrapConstructor)(()=>new bC);vd.sha384=(0,yA.wrapConstructor)(()=>new wC)});var gu=H(Zt=>{"use strict";h();Object.defineProperty(Zt,"__esModule",{value:!0});Zt.validateObject=Zt.createHmacDrbg=Zt.bitMask=Zt.bitSet=Zt.bitGet=Zt.bitLen=Zt.utf8ToBytes=Zt.equalBytes=Zt.concatBytes=Zt.ensureBytes=Zt.numberToVarBytesBE=Zt.numberToBytesLE=Zt.numberToBytesBE=Zt.bytesToNumberLE=Zt.bytesToNumberBE=Zt.hexToBytes=Zt.hexToNumber=Zt.numberToHexUnpadded=Zt.bytesToHex=Zt.isBytes=void 0;var Coe=BigInt(0),gA=BigInt(1),EDe=BigInt(2);function Aw(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}Zt.isBytes=Aw;var SDe=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function xC(t){if(!Aw(t))throw new Error("Uint8Array expected");let e="";for(let r=0;r<t.length;r++)e+=SDe[t[r]];return e}Zt.bytesToHex=xC;function $oe(t){let e=t.toString(16);return e.length&1?`0${e}`:e}Zt.numberToHexUnpadded=$oe;function EC(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return BigInt(t===""?"0":`0x${t}`)}Zt.hexToNumber=EC;var uh={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function Doe(t){if(t>=uh._0&&t<=uh._9)return t-uh._0;if(t>=uh._A&&t<=uh._F)return t-(uh._A-10);if(t>=uh._a&&t<=uh._f)return t-(uh._a-10)}function vA(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<r;i++,o+=2){let s=Doe(t.charCodeAt(o)),a=Doe(t.charCodeAt(o+1));if(s===void 0||a===void 0){let d=t[o]+t[o+1];throw new Error('hex string expected, got non-hex character "'+d+'" at index '+o)}n[i]=s*16+a}return n}Zt.hexToBytes=vA;function ADe(t){return EC(xC(t))}Zt.bytesToNumberBE=ADe;function TDe(t){if(!Aw(t))throw new Error("Uint8Array expected");return EC(xC(Uint8Array.from(t).reverse()))}Zt.bytesToNumberLE=TDe;function Noe(t,e){return vA(t.toString(16).padStart(e*2,"0"))}Zt.numberToBytesBE=Noe;function IDe(t,e){return Noe(t,e).reverse()}Zt.numberToBytesLE=IDe;function PDe(t){return vA($oe(t))}Zt.numberToVarBytesBE=PDe;function kDe(t,e,r){let n;if(typeof e=="string")try{n=vA(e)}catch(o){throw new Error(`${t} must be valid hex string, got "${e}". Cause: ${o}`)}else if(Aw(e))n=Uint8Array.from(e);else throw new Error(`${t} must be hex string or Uint8Array`);let i=n.length;if(typeof r=="number"&&i!==r)throw new Error(`${t} expected ${r} bytes, got ${i}`);return n}Zt.ensureBytes=kDe;function joe(...t){let e=0;for(let i=0;i<t.length;i++){let o=t[i];if(!Aw(o))throw new Error("Uint8Array expected");e+=o.length}let r=new Uint8Array(e),n=0;for(let i=0;i<t.length;i++){let o=t[i];r.set(o,n),n+=o.length}return r}Zt.concatBytes=joe;function RDe(t,e){if(t.length!==e.length)return!1;let r=0;for(let n=0;n<t.length;n++)r|=t[n]^e[n];return r===0}Zt.equalBytes=RDe;function BDe(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}Zt.utf8ToBytes=BDe;function MDe(t){let e;for(e=0;t>Coe;t>>=gA,e+=1);return e}Zt.bitLen=MDe;function DDe(t,e){return t>>BigInt(e)&gA}Zt.bitGet=DDe;var ODe=(t,e,r)=>t|(r?gA:Coe)<<BigInt(e);Zt.bitSet=ODe;var CDe=t=>(EDe<<BigInt(t-1))-gA;Zt.bitMask=CDe;var _C=t=>new Uint8Array(t),Ooe=t=>Uint8Array.from(t);function $De(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=_C(t),i=_C(t),o=0,s=()=>{n.fill(1),i.fill(0),o=0},a=(...l)=>r(i,n,...l),d=(l=_C())=>{i=a(Ooe([0]),l),n=a(),l.length!==0&&(i=a(Ooe([1]),l),n=a())},u=()=>{if(o++>=1e3)throw new Error("drbg: tried 1000 values");let l=0,m=[];for(;l<e;){n=a();let p=n.slice();m.push(p),l+=n.length}return joe(...m)};return(l,m)=>{s(),d(l);let p;for(;!(p=m(u()));)d();return s(),p}}Zt.createHmacDrbg=$De;var NDe={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"||Aw(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 jDe(t,e,r={}){let n=(i,o,s)=>{let a=NDe[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}Zt.validateObject=jDe});var fm=H(Xt=>{"use strict";h();Object.defineProperty(Xt,"__esModule",{value:!0});Xt.mapHashToField=Xt.getMinHashLength=Xt.getFieldBytesLength=Xt.hashToPrivateScalar=Xt.FpSqrtEven=Xt.FpSqrtOdd=Xt.Field=Xt.nLength=Xt.FpIsSquare=Xt.FpDiv=Xt.FpInvertBatch=Xt.FpPow=Xt.validateField=Xt.isNegativeLE=Xt.FpSqrt=Xt.tonelliShanks=Xt.invert=Xt.pow2=Xt.pow=Xt.mod=void 0;var vc=gu(),Ji=BigInt(0),wn=BigInt(1),lm=BigInt(2),UDe=BigInt(3),SC=BigInt(4),Uoe=BigInt(5),qoe=BigInt(8),qDe=BigInt(9),LDe=BigInt(16);function gc(t,e){let r=t%e;return r>=Ji?r:e+r}Xt.mod=gc;function Loe(t,e,r){if(r<=Ji||e<Ji)throw new Error("Expected power/modulo > 0");if(r===wn)return Ji;let n=wn;for(;e>Ji;)e&wn&&(n=n*t%r),t=t*t%r,e>>=wn;return n}Xt.pow=Loe;function KDe(t,e,r){let n=t;for(;e-- >Ji;)n*=n,n%=r;return n}Xt.pow2=KDe;function bA(t,e){if(t===Ji||e<=Ji)throw new Error(`invert: expected positive integers, got n=${t} mod=${e}`);let r=gc(t,e),n=e,i=Ji,o=wn,s=wn,a=Ji;for(;r!==Ji;){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!==wn)throw new Error("invert: does not exist");return gc(i,e)}Xt.invert=bA;function Koe(t){let e=(t-wn)/lm,r,n,i;for(r=t-wn,n=0;r%lm===Ji;r/=lm,n++);for(i=lm;i<t&&Loe(i,e,t)!==t-wn;i++);if(n===1){let s=(t+wn)/SC;return function(d,u){let c=d.pow(u,s);if(!d.eql(d.sqr(c),u))throw new Error("Cannot find square root");return c}}let o=(r+wn)/lm;return function(a,d){if(a.pow(d,e)===a.neg(a.ONE))throw new Error("Cannot find square root");let u=n,c=a.pow(a.mul(a.ONE,i),r),l=a.pow(d,o),m=a.pow(d,r);for(;!a.eql(m,a.ONE);){if(a.eql(m,a.ZERO))return a.ZERO;let p=1;for(let v=a.sqr(m);p<u&&!a.eql(v,a.ONE);p++)v=a.sqr(v);let g=a.pow(c,wn<<BigInt(u-p-1));c=a.sqr(g),l=a.mul(l,g),m=a.mul(m,c),u=p}return l}}Xt.tonelliShanks=Koe;function Foe(t){if(t%SC===UDe){let e=(t+wn)/SC;return function(n,i){let o=n.pow(i,e);if(!n.eql(n.sqr(o),i))throw new Error("Cannot find square root");return o}}if(t%qoe===Uoe){let e=(t-Uoe)/qoe;return function(n,i){let o=n.mul(i,lm),s=n.pow(o,e),a=n.mul(i,s),d=n.mul(n.mul(a,lm),s),u=n.mul(a,n.sub(d,n.ONE));if(!n.eql(n.sqr(u),i))throw new Error("Cannot find square root");return u}}return t%LDe,Koe(t)}Xt.FpSqrt=Foe;var FDe=(t,e)=>(gc(t,e)&wn)===wn;Xt.isNegativeLE=FDe;var zDe=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function VDe(t){let e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},r=zDe.reduce((n,i)=>(n[i]="function",n),e);return(0,vc.validateObject)(t,r)}Xt.validateField=VDe;function zoe(t,e,r){if(r<Ji)throw new Error("Expected power > 0");if(r===Ji)return t.ONE;if(r===wn)return e;let n=t.ONE,i=e;for(;r>Ji;)r&wn&&(n=t.mul(n,i)),i=t.sqr(i),r>>=wn;return n}Xt.FpPow=zoe;function Voe(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}Xt.FpInvertBatch=Voe;function HDe(t,e,r){return t.mul(e,typeof r=="bigint"?bA(r,t.ORDER):t.inv(r))}Xt.FpDiv=HDe;function WDe(t){let e=(t.ORDER-wn)/lm;return r=>{let n=t.pow(r,e);return t.eql(n,t.ZERO)||t.eql(n,t.ONE)}}Xt.FpIsSquare=WDe;function AC(t,e){let r=e!==void 0?e:t.toString(2).length,n=Math.ceil(r/8);return{nBitLength:r,nByteLength:n}}Xt.nLength=AC;function GDe(t,e,r=!1,n={}){if(t<=Ji)throw new Error(`Expected Field ORDER > 0, got ${t}`);let{nBitLength:i,nByteLength:o}=AC(t,e);if(o>2048)throw new Error("Field lengths over 2048 bytes are not supported");let s=Foe(t),a=Object.freeze({ORDER:t,BITS:i,BYTES:o,MASK:(0,vc.bitMask)(i),ZERO:Ji,ONE:wn,create:d=>gc(d,t),isValid:d=>{if(typeof d!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof d}`);return Ji<=d&&d<t},is0:d=>d===Ji,isOdd:d=>(d&wn)===wn,neg:d=>gc(-d,t),eql:(d,u)=>d===u,sqr:d=>gc(d*d,t),add:(d,u)=>gc(d+u,t),sub:(d,u)=>gc(d-u,t),mul:(d,u)=>gc(d*u,t),pow:(d,u)=>zoe(a,d,u),div:(d,u)=>gc(d*bA(u,t),t),sqrN:d=>d*d,addN:(d,u)=>d+u,subN:(d,u)=>d-u,mulN:(d,u)=>d*u,inv:d=>bA(d,t),sqrt:n.sqrt||(d=>s(a,d)),invertBatch:d=>Voe(a,d),cmov:(d,u,c)=>c?u:d,toBytes:d=>r?(0,vc.numberToBytesLE)(d,o):(0,vc.numberToBytesBE)(d,o),fromBytes:d=>{if(d.length!==o)throw new Error(`Fp.fromBytes: expected ${o}, got ${d.length}`);return r?(0,vc.bytesToNumberLE)(d):(0,vc.bytesToNumberBE)(d)}});return Object.freeze(a)}Xt.Field=GDe;function JDe(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)}Xt.FpSqrtOdd=JDe;function YDe(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}Xt.FpSqrtEven=YDe;function ZDe(t,e,r=!1){t=(0,vc.ensureBytes)("privateHash",t);let n=t.length,i=AC(e).nByteLength+8;if(i<24||n<i||n>1024)throw new Error(`hashToPrivateScalar: expected ${i}-1024 bytes of input, got ${n}`);let o=r?(0,vc.bytesToNumberLE)(t):(0,vc.bytesToNumberBE)(t);return gc(o,e-wn)+wn}Xt.hashToPrivateScalar=ZDe;function TC(t){if(typeof t!="bigint")throw new Error("field order must be bigint");let e=t.toString(2).length;return Math.ceil(e/8)}Xt.getFieldBytesLength=TC;function Hoe(t){let e=TC(t);return e+Math.ceil(e/2)}Xt.getMinHashLength=Hoe;function XDe(t,e,r=!1){let n=t.length,i=TC(e),o=Hoe(e);if(n<16||n<o||n>1024)throw new Error(`expected ${o}-1024 bytes of input, got ${n}`);let s=r?(0,vc.bytesToNumberBE)(t):(0,vc.bytesToNumberLE)(t),a=gc(s,e-wn)+wn;return r?(0,vc.numberToBytesLE)(a,i):(0,vc.numberToBytesBE)(a,i)}Xt.mapHashToField=XDe});var PC=H(Tw=>{"use strict";h();Object.defineProperty(Tw,"__esModule",{value:!0});Tw.validateBasic=Tw.wNAF=void 0;var Woe=fm(),QDe=gu(),eOe=BigInt(0),IC=BigInt(1);function tOe(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>eOe;)o&IC&&(s=s.add(a)),a=a.double(),o>>=IC;return s},precomputeWindow(i,o){let{windows:s,windowSize:a}=n(o),d=[],u=i,c=u;for(let l=0;l<s;l++){c=u,d.push(c);for(let m=1;m<a;m++)c=c.add(u),d.push(c);u=c.double()}return d},wNAF(i,o,s){let{windows:a,windowSize:d}=n(i),u=t.ZERO,c=t.BASE,l=BigInt(2**i-1),m=2**i,p=BigInt(i);for(let g=0;g<a;g++){let v=g*d,E=Number(s&l);s>>=p,E>d&&(E-=m,s+=IC);let A=v,P=v+Math.abs(E)-1,I=g%2!==0,$=E<0;E===0?c=c.add(r(I,o[A])):u=u.add(r($,o[P]))}return{p:u,f:c}},wNAFCached(i,o,s,a){let d=i._WINDOW_SIZE||1,u=o.get(i);return u||(u=this.precomputeWindow(i,d),d!==1&&o.set(i,a(u))),this.wNAF(d,u,s)}}}Tw.wNAF=tOe;function rOe(t){return(0,Woe.validateField)(t.Fp),(0,QDe.validateObject)(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...(0,Woe.nLength)(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}Tw.validateBasic=rOe});var Joe=H(_A=>{"use strict";h();Object.defineProperty(_A,"__esModule",{value:!0});_A.twistedEdwards=void 0;var nOe=fm(),lh=gu(),hm=gu(),Goe=PC(),vu=BigInt(0),bc=BigInt(1),wA=BigInt(2),iOe=BigInt(8),oOe={zip215:!0};function sOe(t){let e=(0,Goe.validateBasic)(t);return lh.validateObject(t,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}function aOe(t){let e=sOe(t),{Fp:r,n,prehash:i,hash:o,randomBytes:s,nByteLength:a,h:d}=e,u=wA<<BigInt(a*8)-bc,c=r.create,l=e.uvRatio||((x,b)=>{try{return{isValid:!0,value:r.sqrt(x*r.inv(b))}}catch{return{isValid:!1,value:vu}}}),m=e.adjustScalarBytes||(x=>x),p=e.domain||((x,b,B)=>{if(b.length||B)throw new Error("Contexts/pre-hash are not supported");return x}),g=x=>typeof x=="bigint"&&vu<x,v=(x,b)=>g(x)&&g(b)&&x<b,E=x=>x===vu||v(x,u);function A(x,b){if(v(x,b))return x;throw new Error(`Expected valid scalar < ${b}, got ${typeof x} ${x}`)}function P(x){return x===vu?x:A(x,n)}let I=new Map;function $(x){if(!(x instanceof N))throw new Error("ExtendedPoint expected")}class N{constructor(b,B,q,M){if(this.ex=b,this.ey=B,this.ez=q,this.et=M,!E(b))throw new Error("x required");if(!E(B))throw new Error("y required");if(!E(q))throw new Error("z required");if(!E(M))throw new Error("t required")}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(b){if(b instanceof N)throw new Error("extended point not allowed");let{x:B,y:q}=b||{};if(!E(B)||!E(q))throw new Error("invalid affine point");return new N(B,q,bc,c(B*q))}static normalizeZ(b){let B=r.invertBatch(b.map(q=>q.ez));return b.map((q,M)=>q.toAffine(B[M])).map(N.fromAffine)}_setWindowSize(b){this._WINDOW_SIZE=b,I.delete(this)}assertValidity(){let{a:b,d:B}=e;if(this.is0())throw new Error("bad point: ZERO");let{ex:q,ey:M,ez:j,et:J}=this,Z=c(q*q),G=c(M*M),W=c(j*j),X=c(W*W),ee=c(Z*b),ue=c(W*c(ee+G)),ae=c(X+c(B*c(Z*G)));if(ue!==ae)throw new Error("bad point: equation left != right (1)");let ce=c(q*M),pe=c(j*J);if(ce!==pe)throw new Error("bad point: equation left != right (2)")}equals(b){$(b);let{ex:B,ey:q,ez:M}=this,{ex:j,ey:J,ez:Z}=b,G=c(B*Z),W=c(j*M),X=c(q*Z),ee=c(J*M);return G===W&&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:b}=e,{ex:B,ey:q,ez:M}=this,j=c(B*B),J=c(q*q),Z=c(wA*c(M*M)),G=c(b*j),W=B+q,X=c(c(W*W)-j-J),ee=G+J,ue=ee-Z,ae=G-J,ce=c(X*ue),pe=c(ee*ae),xe=c(X*ae),Ue=c(ue*ee);return new N(ce,pe,Ue,xe)}add(b){$(b);let{a:B,d:q}=e,{ex:M,ey:j,ez:J,et:Z}=this,{ex:G,ey:W,ez:X,et:ee}=b;if(B===BigInt(-1)){let vt=c((j-M)*(W+G)),Ae=c((j+M)*(W-G)),Re=c(Ae-vt);if(Re===vu)return this.double();let kt=c(J*wA*ee),we=c(Z*wA*X),Ee=we+kt,Kr=Ae+vt,Fe=we-kt,We=c(Ee*Re),qs=c(Kr*Fe),ht=c(Ee*Fe),Bt=c(Re*Kr);return new N(We,qs,Bt,ht)}let ue=c(M*G),ae=c(j*W),ce=c(Z*q*ee),pe=c(J*X),xe=c((M+j)*(G+W)-ue-ae),Ue=pe-ce,le=pe+ce,ge=c(ae-B*ue),be=c(xe*Ue),De=c(le*ge),Ie=c(xe*ge),je=c(Ue*le);return new N(be,De,je,Ie)}subtract(b){return this.add(b.negate())}wNAF(b){return U.wNAFCached(this,I,b,N.normalizeZ)}multiply(b){let{p:B,f:q}=this.wNAF(A(b,n));return N.normalizeZ([B,q])[0]}multiplyUnsafe(b){let B=P(b);return B===vu?F:this.equals(F)||B===bc?this:this.equals(K)?this.wNAF(B).p:U.unsafeLadder(this,B)}isSmallOrder(){return this.multiplyUnsafe(d).is0()}isTorsionFree(){return U.unsafeLadder(this,n).is0()}toAffine(b){let{ex:B,ey:q,ez:M}=this,j=this.is0();b==null&&(b=j?iOe:r.inv(M));let J=c(B*b),Z=c(q*b),G=c(M*b);if(j)return{x:vu,y:bc};if(G!==bc)throw new Error("invZ was invalid");return{x:J,y:Z}}clearCofactor(){let{h:b}=e;return b===bc?this:this.multiplyUnsafe(b)}static fromHex(b,B=!1){let{d:q,a:M}=e,j=r.BYTES;b=(0,hm.ensureBytes)("pointHex",b,j);let J=b.slice(),Z=b[j-1];J[j-1]=Z&-129;let G=lh.bytesToNumberLE(J);G===vu||(B?A(G,u):A(G,r.ORDER));let W=c(G*G),X=c(W-bc),ee=c(q*W-M),{isValid:ue,value:ae}=l(X,ee);if(!ue)throw new Error("Point.fromHex: invalid y coordinate");let ce=(ae&bc)===bc,pe=(Z&128)!==0;if(!B&&ae===vu&&pe)throw new Error("Point.fromHex: x=0 and x_0=1");return pe!==ce&&(ae=c(-ae)),N.fromAffine({x:ae,y:G})}static fromPrivateKey(b){return T(b).point}toRawBytes(){let{x:b,y:B}=this.toAffine(),q=lh.numberToBytesLE(B,r.BYTES);return q[q.length-1]|=b&bc?128:0,q}toHex(){return lh.bytesToHex(this.toRawBytes())}}N.BASE=new N(e.Gx,e.Gy,bc,c(e.Gx*e.Gy)),N.ZERO=new N(vu,bc,bc,vu);let{BASE:K,ZERO:F}=N,U=(0,Goe.wNAF)(N,a*8);function V(x){return(0,nOe.mod)(x,n)}function L(x){return V(lh.bytesToNumberLE(x))}function T(x){let b=a;x=(0,hm.ensureBytes)("private key",x,b);let B=(0,hm.ensureBytes)("hashed private key",o(x),2*b),q=m(B.slice(0,b)),M=B.slice(b,2*b),j=L(q),J=K.multiply(j),Z=J.toRawBytes();return{head:q,prefix:M,scalar:j,point:J,pointBytes:Z}}function S(x){return T(x).pointBytes}function k(x=new Uint8Array,...b){let B=lh.concatBytes(...b);return L(o(p(B,(0,hm.ensureBytes)("context",x),!!i)))}function f(x,b,B={}){x=(0,hm.ensureBytes)("message",x),i&&(x=i(x));let{prefix:q,scalar:M,pointBytes:j}=T(b),J=k(B.context,q,x),Z=K.multiply(J).toRawBytes(),G=k(B.context,Z,j,x),W=V(J+G*M);P(W);let X=lh.concatBytes(Z,lh.numberToBytesLE(W,r.BYTES));return(0,hm.ensureBytes)("result",X,a*2)}let y=oOe;function w(x,b,B,q=y){let{context:M,zip215:j}=q,J=r.BYTES;x=(0,hm.ensureBytes)("signature",x,2*J),b=(0,hm.ensureBytes)("message",b),i&&(b=i(b));let Z=lh.bytesToNumberLE(x.slice(J,2*J)),G,W,X;try{G=N.fromHex(B,j),W=N.fromHex(x.slice(0,J),j),X=K.multiplyUnsafe(Z)}catch{return!1}if(!j&&G.isSmallOrder())return!1;let ee=k(M,W.toRawBytes(),G.toRawBytes(),b);return W.add(G.multiplyUnsafe(ee)).subtract(X).clearCofactor().equals(N.ZERO)}return K._setWindowSize(8),{CURVE:e,getPublicKey:S,sign:f,verify:w,ExtendedPoint:N,utils:{getExtendedPublicKey:T,randomPrivateKey:()=>s(r.BYTES),precompute(x=8,b=N.BASE){return b._setWindowSize(x),b.multiply(BigInt(3)),b}}}}_A.twistedEdwards=aOe});var Zoe=H(xA=>{"use strict";h();Object.defineProperty(xA,"__esModule",{value:!0});xA.montgomery=void 0;var Yoe=fm(),Iw=gu(),iE=BigInt(0),kC=BigInt(1);function cOe(t){return(0,Iw.validateObject)(t,{a:"bigint"},{montgomeryBits:"isSafeInteger",nByteLength:"isSafeInteger",adjustScalarBytes:"function",domain:"function",powPminus2:"function",Gu:"bigint"}),Object.freeze({...t})}function dOe(t){let e=cOe(t),{P:r}=e,n=I=>(0,Yoe.mod)(I,r),i=e.montgomeryBits,o=Math.ceil(i/8),s=e.nByteLength,a=e.adjustScalarBytes||(I=>I),d=e.powPminus2||(I=>(0,Yoe.pow)(I,r-BigInt(2),r));function u(I,$,N){let K=n(I*($-N));return $=n($-K),N=n(N+K),[$,N]}function c(I){if(typeof I=="bigint"&&iE<=I&&I<r)return I;throw new Error("Expected valid scalar 0 < scalar < CURVE.P")}let l=(e.a-BigInt(2))/BigInt(4);function m(I,$){let N=c(I),K=c($),F=N,U=kC,V=iE,L=N,T=kC,S=iE,k;for(let y=BigInt(i-1);y>=iE;y--){let w=K>>y&kC;S^=w,k=u(S,U,L),U=k[0],L=k[1],k=u(S,V,T),V=k[0],T=k[1],S=w;let _=U+V,x=n(_*_),b=U-V,B=n(b*b),q=x-B,M=L+T,j=L-T,J=n(j*_),Z=n(M*b),G=J+Z,W=J-Z;L=n(G*G),T=n(F*n(W*W)),U=n(x*B),V=n(q*(x+n(l*q)))}k=u(S,U,L),U=k[0],L=k[1],k=u(S,V,T),V=k[0],T=k[1];let f=d(V);return n(U*f)}function p(I){return(0,Iw.numberToBytesLE)(n(I),o)}function g(I){let $=(0,Iw.ensureBytes)("u coordinate",I,o);return s===32&&($[31]&=127),(0,Iw.bytesToNumberLE)($)}function v(I){let $=(0,Iw.ensureBytes)("scalar",I),N=$.length;if(N!==o&&N!==s)throw new Error(`Expected ${o} or ${s} bytes, got ${N}`);return(0,Iw.bytesToNumberLE)(a($))}function E(I,$){let N=g($),K=v(I),F=m(N,K);if(F===iE)throw new Error("Invalid private or public key received");return p(F)}let A=p(e.Gu);function P(I){return E(I,A)}return{scalarMult:E,scalarMultBase:P,getSharedSecret:(I,$)=>E(I,$),getPublicKey:I=>P(I),utils:{randomPrivateKey:()=>e.randomBytes(e.nByteLength)},GuBytes:A}}xA.montgomery=dOe});var MC=H(bd=>{"use strict";h();Object.defineProperty(bd,"__esModule",{value:!0});bd.createHasher=bd.isogenyMap=bd.hash_to_field=bd.expand_message_xof=bd.expand_message_xmd=void 0;var uOe=fm(),wc=gu();function lOe(t){if((0,wc.isBytes)(t))return t;if(typeof t=="string")return(0,wc.utf8ToBytes)(t);throw new Error("DST must be Uint8Array or string")}var fOe=wc.bytesToNumberBE;function pm(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 hOe(t,e){let r=new Uint8Array(t.length);for(let n=0;n<t.length;n++)r[n]=t[n]^e[n];return r}function oE(t){if(!(0,wc.isBytes)(t))throw new Error("Uint8Array expected")}function BC(t){if(!Number.isSafeInteger(t))throw new Error("number expected")}function Xoe(t,e,r,n){oE(t),oE(e),BC(r),e.length>255&&(e=n((0,wc.concatBytes)((0,wc.utf8ToBytes)("H2C-OVERSIZE-DST-"),e)));let{outputLen:i,blockLen:o}=n,s=Math.ceil(r/i);if(s>255)throw new Error("Invalid xmd length");let a=(0,wc.concatBytes)(e,pm(e.length,1)),d=pm(0,o),u=pm(r,2),c=new Array(s),l=n((0,wc.concatBytes)(d,t,u,pm(0,1),a));c[0]=n((0,wc.concatBytes)(l,pm(1,1),a));for(let p=1;p<=s;p++){let g=[hOe(l,c[p-1]),pm(p+1,1),a];c[p]=n((0,wc.concatBytes)(...g))}return(0,wc.concatBytes)(...c).slice(0,r)}bd.expand_message_xmd=Xoe;function Qoe(t,e,r,n,i){if(oE(t),oE(e),BC(r),e.length>255){let o=Math.ceil(2*n/8);e=i.create({dkLen:o}).update((0,wc.utf8ToBytes)("H2C-OVERSIZE-DST-")).update(e).digest()}if(r>65535||e.length>255)throw new Error("expand_message_xof: invalid lenInBytes");return i.create({dkLen:r}).update(t).update(pm(r,2)).update(e).update(pm(e.length,1)).digest()}bd.expand_message_xof=Qoe;function RC(t,e,r){(0,wc.validateObject)(r,{DST:"stringOrUint8Array",p:"bigint",m:"isSafeInteger",k:"isSafeInteger",hash:"hash"});let{p:n,k:i,m:o,hash:s,expand:a,DST:d}=r;oE(t),BC(e);let u=lOe(d),c=n.toString(2).length,l=Math.ceil((c+i)/8),m=e*o*l,p;if(a==="xmd")p=Xoe(t,u,m,s);else if(a==="xof")p=Qoe(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 v=0;v<e;v++){let E=new Array(o);for(let A=0;A<o;A++){let P=l*(A+v*o),I=p.subarray(P,P+l);E[A]=(0,uOe.mod)(fOe(I),n)}g[v]=E}return g}bd.hash_to_field=RC;function pOe(t,e){let r=e.map(n=>Array.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}}}bd.isogenyMap=pOe;function mOe(t,e,r){if(typeof e!="function")throw new Error("mapToCurve() must be defined");return{hashToCurve(n,i){let o=RC(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=RC(n,1,{...r,DST:r.encodeDST,...i}),s=t.fromAffine(e(o[0])).clearCofactor();return s.assertValidity(),s}}}bd.createHasher=mOe});var fse=H(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 SA=Moe(),sE=cm(),NC=Joe(),yOe=Zoe(),nn=fm(),ag=gu(),sse=MC(),aE=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),CC=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),gOe=BigInt(0),Bl=BigInt(1),EA=BigInt(2),vOe=BigInt(5),ese=BigInt(10),bOe=BigInt(20),wOe=BigInt(40),tse=BigInt(80);function ase(t){let e=aE,n=t*t%e*t%e,i=(0,nn.pow2)(n,EA,e)*n%e,o=(0,nn.pow2)(i,Bl,e)*t%e,s=(0,nn.pow2)(o,vOe,e)*o%e,a=(0,nn.pow2)(s,ese,e)*s%e,d=(0,nn.pow2)(a,bOe,e)*a%e,u=(0,nn.pow2)(d,wOe,e)*d%e,c=(0,nn.pow2)(u,tse,e)*u%e,l=(0,nn.pow2)(c,tse,e)*u%e,m=(0,nn.pow2)(l,ese,e)*s%e;return{pow_p_5_8:(0,nn.pow2)(m,EA,e)*t%e,b2:n}}function cse(t){return t[0]&=248,t[31]&=127,t[31]|=64,t}function jC(t,e){let r=aE,n=(0,nn.mod)(e*e*e,r),i=(0,nn.mod)(n*n*e,r),o=ase(t*i).pow_p_5_8,s=(0,nn.mod)(t*n*o,r),a=(0,nn.mod)(e*s*s,r),d=s,u=(0,nn.mod)(s*CC,r),c=a===t,l=a===(0,nn.mod)(-t,r),m=a===(0,nn.mod)(-t*CC,r);return c&&(s=d),(l||m)&&(s=u),(0,nn.isNegativeLE)(s,r)&&(s=(0,nn.mod)(-s,r)),{isValid:c||l,value:s}}Ct.ED25519_TORSION_SUBGROUP=["0100000000000000000000000000000000000000000000000000000000000000","c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac037a","0000000000000000000000000000000000000000000000000000000000000080","26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc05","ecffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f","26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc85","0000000000000000000000000000000000000000000000000000000000000000","c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac03fa"];var qe=(0,nn.Field)(aE,void 0,!0),cE={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:qe,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:BigInt(8),Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:SA.sha512,randomBytes:sE.randomBytes,adjustScalarBytes:cse,uvRatio:jC};Ct.ed25519=(0,NC.twistedEdwards)(cE);function dse(t,e,r){if(e.length>255)throw new Error("Context is too big");return(0,sE.concatBytes)((0,sE.utf8ToBytes)("SigEd25519 no Ed25519 collisions"),new Uint8Array([r?1:0,e.length]),e,t)}Ct.ed25519ctx=(0,NC.twistedEdwards)({...cE,domain:dse});Ct.ed25519ph=(0,NC.twistedEdwards)({...cE,domain:dse,prehash:SA.sha512});Ct.x25519=(0,yOe.montgomery)({P:aE,a:BigInt(486662),montgomeryBits:255,nByteLength:32,Gu:BigInt(9),powPminus2:t=>{let e=aE,{pow_p_5_8:r,b2:n}=ase(t);return(0,nn.mod)((0,nn.pow2)(r,BigInt(3),e)*n,e)},adjustScalarBytes:cse,randomBytes:sE.randomBytes});function use(t){let{y:e}=Ct.ed25519.ExtendedPoint.fromHex(t),r=BigInt(1);return qe.toBytes(qe.create((r+e)*qe.inv(r-e)))}Ct.edwardsToMontgomeryPub=use;Ct.edwardsToMontgomery=use;function _Oe(t){let e=cE.hash(t.subarray(0,32));return cE.adjustScalarBytes(e).subarray(0,32)}Ct.edwardsToMontgomeryPriv=_Oe;var xOe=(qe.ORDER+BigInt(3))/BigInt(8),EOe=qe.pow(EA,xOe),rse=qe.sqrt(qe.neg(qe.ONE)),SOe=(qe.ORDER-BigInt(5))/BigInt(8),nse=BigInt(486662);function AOe(t){let e=qe.sqr(t);e=qe.mul(e,EA);let r=qe.add(e,qe.ONE),n=qe.neg(nse),i=qe.sqr(r),o=qe.mul(i,r),s=qe.mul(e,nse);s=qe.mul(s,n),s=qe.add(s,i),s=qe.mul(s,n);let a=qe.sqr(o);i=qe.sqr(a),a=qe.mul(a,o),a=qe.mul(a,s),i=qe.mul(i,a);let d=qe.pow(i,SOe);d=qe.mul(d,a);let u=qe.mul(d,rse);i=qe.sqr(d),i=qe.mul(i,o);let c=qe.eql(i,s),l=qe.cmov(u,d,c),m=qe.mul(n,e),p=qe.mul(d,t);p=qe.mul(p,EOe);let g=qe.mul(p,rse),v=qe.mul(s,e);i=qe.sqr(p),i=qe.mul(i,o);let E=qe.eql(i,v),A=qe.cmov(g,p,E);i=qe.sqr(l),i=qe.mul(i,o);let P=qe.eql(i,s),I=qe.cmov(m,n,P),$=qe.cmov(A,l,P),N=qe.isOdd($);return $=qe.cmov($,qe.neg($),P!==N),{xMn:I,xMd:r,yMn:$,yMd:Bl}}var TOe=(0,nn.FpSqrtEven)(qe,qe.neg(BigInt(486664)));function IOe(t){let{xMn:e,xMd:r,yMn:n,yMd:i}=AOe(t),o=qe.mul(e,i);o=qe.mul(o,TOe);let s=qe.mul(r,n),a=qe.sub(e,r),d=qe.add(e,r),u=qe.mul(s,d),c=qe.eql(u,qe.ZERO);o=qe.cmov(o,qe.ZERO,c),s=qe.cmov(s,qe.ONE,c),a=qe.cmov(a,qe.ONE,c),d=qe.cmov(d,qe.ONE,c);let l=qe.invertBatch([s,d]);return{x:qe.mul(o,l[0]),y:qe.mul(a,l[1])}}var lse=(0,sse.createHasher)(Ct.ed25519.ExtendedPoint,t=>IOe(t[0]),{DST:"edwards25519_XMD:SHA-512_ELL2_RO_",encodeDST:"edwards25519_XMD:SHA-512_ELL2_NU_",p:qe.ORDER,m:1,k:128,expand:"xmd",hash:SA.sha512});Ct.hashToCurve=lse.hashToCurve;Ct.encodeToCurve=lse.encodeToCurve;function DC(t){if(!(t instanceof bu))throw new Error("RistrettoPoint expected")}var $C=CC,POe=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),kOe=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),ROe=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),BOe=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952"),ise=t=>jC(Bl,t),MOe=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),OC=t=>Ct.ed25519.CURVE.Fp.create((0,ag.bytesToNumberLE)(t)&MOe);function ose(t){let{d:e}=Ct.ed25519.CURVE,r=Ct.ed25519.CURVE.Fp.ORDER,n=Ct.ed25519.CURVE.Fp.create,i=n($C*t*t),o=n((i+Bl)*ROe),s=BigInt(-1),a=n((s-e*i)*n(i+e)),{isValid:d,value:u}=jC(o,a),c=n(u*t);(0,nn.isNegativeLE)(c,r)||(c=n(-c)),d||(u=c),d||(s=i);let l=n(s*(i-Bl)*BOe-a),m=u*u,p=n((u+u)*a),g=n(l*POe),v=n(Bl-m),E=n(Bl+m);return new Ct.ed25519.ExtendedPoint(n(p*E),n(v*g),n(g*E),n(p*v))}var bu=class t{constructor(e){this.ep=e}static fromAffine(e){return new t(Ct.ed25519.ExtendedPoint.fromAffine(e))}static hashToCurve(e){e=(0,ag.ensureBytes)("ristrettoHash",e,64);let r=OC(e.slice(0,32)),n=ose(r),i=OC(e.slice(32,64)),o=ose(i);return new t(n.add(o))}static fromHex(e){e=(0,ag.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=OC(e);if(!(0,ag.equalBytes)((0,ag.numberToBytesLE)(a,32),e)||(0,nn.isNegativeLE)(a,i))throw new Error(s);let d=o(a*a),u=o(Bl+r*d),c=o(Bl-r*d),l=o(u*u),m=o(c*c),p=o(r*n*l-m),{isValid:g,value:v}=ise(o(p*m)),E=o(v*c),A=o(v*E*p),P=o((a+a)*E);(0,nn.isNegativeLE)(P,i)&&(P=o(-P));let I=o(u*A),$=o(P*I);if(!g||(0,nn.isNegativeLE)($,i)||I===gOe)throw new Error(s);return new t(new Ct.ed25519.ExtendedPoint(P,I,Bl,$))}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}=ise(s(a*u)),l=s(c*a),m=s(c*d),p=s(l*m*i),g;if((0,nn.isNegativeLE)(i*p,o)){let E=s(r*$C),A=s(e*$C);e=E,r=A,g=s(l*kOe)}else g=m;(0,nn.isNegativeLE)(e*p,o)&&(r=s(-r));let v=s((n-r)*g);return(0,nn.isNegativeLE)(v,o)&&(v=s(-v)),(0,ag.numberToBytesLE)(v,32)}toHex(){return(0,ag.bytesToHex)(this.toRawBytes())}toString(){return this.toHex()}equals(e){DC(e);let{ex:r,ey:n}=this.ep,{ex:i,ey:o}=e.ep,s=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 DC(e),new t(this.ep.add(e.ep))}subtract(e){return DC(e),new t(this.ep.subtract(e.ep))}multiply(e){return new t(this.ep.multiply(e))}multiplyUnsafe(e){return new t(this.ep.multiplyUnsafe(e))}double(){return new t(this.ep.double())}negate(){return new t(this.ep.negate())}};Ct.RistrettoPoint=(bu.BASE||(bu.BASE=new bu(Ct.ed25519.ExtendedPoint.BASE)),bu.ZERO||(bu.ZERO=new bu(Ct.ed25519.ExtendedPoint.ZERO)),bu);var DOe=(t,e)=>{let r=e.DST,n=typeof r=="string"?(0,sE.utf8ToBytes)(r):r,i=(0,sse.expand_message_xmd)(t,n,64,SA.sha512);return bu.hashToCurve(i)};Ct.hashToRistretto255=DOe;Ct.hash_to_ristretto255=Ct.hashToRistretto255});var hse=H(Pw=>{"use strict";h();Object.defineProperty(Pw,"__esModule",{value:!0});Pw.sha224=Pw.sha256=void 0;var OOe=mC(),wd=cm(),COe=(t,e,r)=>t&e^~t&r,$Oe=(t,e,r)=>t&e^t&r^e&r,NOe=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]),mm=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),ym=new Uint32Array(64),AA=class extends OOe.SHA2{constructor(){super(64,32,8,!1),this.A=mm[0]|0,this.B=mm[1]|0,this.C=mm[2]|0,this.D=mm[3]|0,this.E=mm[4]|0,this.F=mm[5]|0,this.G=mm[6]|0,this.H=mm[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)ym[l]=e.getUint32(r,!1);for(let l=16;l<64;l++){let m=ym[l-15],p=ym[l-2],g=(0,wd.rotr)(m,7)^(0,wd.rotr)(m,18)^m>>>3,v=(0,wd.rotr)(p,17)^(0,wd.rotr)(p,19)^p>>>10;ym[l]=v+ym[l-7]+g+ym[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,wd.rotr)(a,6)^(0,wd.rotr)(a,11)^(0,wd.rotr)(a,25),p=c+m+COe(a,d,u)+NOe[l]+ym[l]|0,v=((0,wd.rotr)(n,2)^(0,wd.rotr)(n,13)^(0,wd.rotr)(n,22))+$Oe(n,i,o)|0;c=u,u=d,d=a,a=s+p|0,s=o,o=i,i=n,n=p+v|0}n=n+this.A|0,i=i+this.B|0,o=o+this.C|0,s=s+this.D|0,a=a+this.E|0,d=d+this.F|0,u=u+this.G|0,c=c+this.H|0,this.set(n,i,o,s,a,d,u,c)}roundClean(){ym.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}},UC=class extends AA{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}};Pw.sha256=(0,wd.wrapConstructor)(()=>new AA);Pw.sha224=(0,wd.wrapConstructor)(()=>new UC)});var LC=H(Yi=>{"use strict";h();Object.defineProperty(Yi,"__esModule",{value:!0});Yi.mapToCurveSimpleSWU=Yi.SWUFpSqrtRatio=Yi.weierstrass=Yi.weierstrassPoints=Yi.DER=void 0;var kw=fm(),Gn=gu(),Ml=gu(),qC=PC();function jOe(t){let e=(0,qC.validateBasic)(t);Gn.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:UOe,hexToBytes:qOe}=Gn;Yi.DER={Err:class extends Error{constructor(e=""){super(e)}},_parseInt(t){let{Err:e}=Yi.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:UOe(n),l:t.subarray(r+2)}},toSig(t){let{Err:e}=Yi.DER,r=typeof t=="string"?qOe(t):t;if(!Gn.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}=Yi.DER._parseInt(r.subarray(2)),{d:s,l:a}=Yi.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 wu=BigInt(0),li=BigInt(1),gm=BigInt(2),TA=BigInt(3),pse=BigInt(4);function mse(t){let e=jOe(t),{Fp:r}=e,n=e.toBytes||((g,v,E)=>{let A=v.toAffine();return Gn.concatBytes(Uint8Array.from([4]),r.toBytes(A.x),r.toBytes(A.y))}),i=e.fromBytes||(g=>{let v=g.subarray(1),E=r.fromBytes(v.subarray(0,r.BYTES)),A=r.fromBytes(v.subarray(r.BYTES,2*r.BYTES));return{x:E,y:A}});function o(g){let{a:v,b:E}=e,A=r.sqr(g),P=r.mul(A,g);return r.add(r.add(P,r.mul(g,v)),E)}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"&&wu<g&&g<e.n}function a(g){if(!s(g))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function d(g){let{allowedPrivateKeyLengths:v,nByteLength:E,wrapPrivateKey:A,n:P}=e;if(v&&typeof g!="bigint"){if(Gn.isBytes(g)&&(g=Gn.bytesToHex(g)),typeof g!="string"||!v.includes(g.length))throw new Error("Invalid key");g=g.padStart(E*2,"0")}let I;try{I=typeof g=="bigint"?g:Gn.bytesToNumberBE((0,Ml.ensureBytes)("private key",g,E))}catch{throw new Error(`private key must be ${E} bytes, hex or bigint, not ${typeof g}`)}return A&&(I=kw.mod(I,P)),a(I),I}let u=new Map;function c(g){if(!(g instanceof l))throw new Error("ProjectivePoint expected")}class l{constructor(v,E,A){if(this.px=v,this.py=E,this.pz=A,v==null||!r.isValid(v))throw new Error("x required");if(E==null||!r.isValid(E))throw new Error("y required");if(A==null||!r.isValid(A))throw new Error("z required")}static fromAffine(v){let{x:E,y:A}=v||{};if(!v||!r.isValid(E)||!r.isValid(A))throw new Error("invalid affine point");if(v instanceof l)throw new Error("projective point not allowed");let P=I=>r.eql(I,r.ZERO);return P(E)&&P(A)?l.ZERO:new l(E,A,r.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(v){let E=r.invertBatch(v.map(A=>A.pz));return v.map((A,P)=>A.toAffine(E[P])).map(l.fromAffine)}static fromHex(v){let E=l.fromAffine(i((0,Ml.ensureBytes)("pointHex",v)));return E.assertValidity(),E}static fromPrivateKey(v){return l.BASE.multiply(d(v))}_setWindowSize(v){this._WINDOW_SIZE=v,u.delete(this)}assertValidity(){if(this.is0()){if(e.allowInfinityPoint&&!r.is0(this.py))return;throw new Error("bad point: ZERO")}let{x:v,y:E}=this.toAffine();if(!r.isValid(v)||!r.isValid(E))throw new Error("bad point: x or y not FE");let A=r.sqr(E),P=o(v);if(!r.eql(A,P))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){let{y:v}=this.toAffine();if(r.isOdd)return!r.isOdd(v);throw new Error("Field doesn't support isOdd")}equals(v){c(v);let{px:E,py:A,pz:P}=this,{px:I,py:$,pz:N}=v,K=r.eql(r.mul(E,N),r.mul(I,P)),F=r.eql(r.mul(A,N),r.mul($,P));return K&&F}negate(){return new l(this.px,r.neg(this.py),this.pz)}double(){let{a:v,b:E}=e,A=r.mul(E,TA),{px:P,py:I,pz:$}=this,N=r.ZERO,K=r.ZERO,F=r.ZERO,U=r.mul(P,P),V=r.mul(I,I),L=r.mul($,$),T=r.mul(P,I);return T=r.add(T,T),F=r.mul(P,$),F=r.add(F,F),N=r.mul(v,F),K=r.mul(A,L),K=r.add(N,K),N=r.sub(V,K),K=r.add(V,K),K=r.mul(N,K),N=r.mul(T,N),F=r.mul(A,F),L=r.mul(v,L),T=r.sub(U,L),T=r.mul(v,T),T=r.add(T,F),F=r.add(U,U),U=r.add(F,U),U=r.add(U,L),U=r.mul(U,T),K=r.add(K,U),L=r.mul(I,$),L=r.add(L,L),U=r.mul(L,T),N=r.sub(N,U),F=r.mul(L,V),F=r.add(F,F),F=r.add(F,F),new l(N,K,F)}add(v){c(v);let{px:E,py:A,pz:P}=this,{px:I,py:$,pz:N}=v,K=r.ZERO,F=r.ZERO,U=r.ZERO,V=e.a,L=r.mul(e.b,TA),T=r.mul(E,I),S=r.mul(A,$),k=r.mul(P,N),f=r.add(E,A),y=r.add(I,$);f=r.mul(f,y),y=r.add(T,S),f=r.sub(f,y),y=r.add(E,P);let w=r.add(I,N);return y=r.mul(y,w),w=r.add(T,k),y=r.sub(y,w),w=r.add(A,P),K=r.add($,N),w=r.mul(w,K),K=r.add(S,k),w=r.sub(w,K),U=r.mul(V,y),K=r.mul(L,k),U=r.add(K,U),K=r.sub(S,U),U=r.add(S,U),F=r.mul(K,U),S=r.add(T,T),S=r.add(S,T),k=r.mul(V,k),y=r.mul(L,y),S=r.add(S,k),k=r.sub(T,k),k=r.mul(V,k),y=r.add(y,k),T=r.mul(S,y),F=r.add(F,T),T=r.mul(w,y),K=r.mul(f,K),K=r.sub(K,T),T=r.mul(f,S),U=r.mul(w,U),U=r.add(U,T),new l(K,F,U)}subtract(v){return this.add(v.negate())}is0(){return this.equals(l.ZERO)}wNAF(v){return p.wNAFCached(this,u,v,E=>{let A=r.invertBatch(E.map(P=>P.pz));return E.map((P,I)=>P.toAffine(A[I])).map(l.fromAffine)})}multiplyUnsafe(v){let E=l.ZERO;if(v===wu)return E;if(a(v),v===li)return this;let{endo:A}=e;if(!A)return p.unsafeLadder(this,v);let{k1neg:P,k1:I,k2neg:$,k2:N}=A.splitScalar(v),K=E,F=E,U=this;for(;I>wu||N>wu;)I&li&&(K=K.add(U)),N&li&&(F=F.add(U)),U=U.double(),I>>=li,N>>=li;return P&&(K=K.negate()),$&&(F=F.negate()),F=new l(r.mul(F.px,A.beta),F.py,F.pz),K.add(F)}multiply(v){a(v);let E=v,A,P,{endo:I}=e;if(I){let{k1neg:$,k1:N,k2neg:K,k2:F}=I.splitScalar(E),{p:U,f:V}=this.wNAF(N),{p:L,f:T}=this.wNAF(F);U=p.constTimeNegate($,U),L=p.constTimeNegate(K,L),L=new l(r.mul(L.px,I.beta),L.py,L.pz),A=U.add(L),P=V.add(T)}else{let{p:$,f:N}=this.wNAF(E);A=$,P=N}return l.normalizeZ([A,P])[0]}multiplyAndAddUnsafe(v,E,A){let P=l.BASE,I=(N,K)=>K===wu||K===li||!N.equals(P)?N.multiplyUnsafe(K):N.multiply(K),$=I(this,E).add(I(v,A));return $.is0()?void 0:$}toAffine(v){let{px:E,py:A,pz:P}=this,I=this.is0();v==null&&(v=I?r.ONE:r.inv(P));let $=r.mul(E,v),N=r.mul(A,v),K=r.mul(P,v);if(I)return{x:r.ZERO,y:r.ZERO};if(!r.eql(K,r.ONE))throw new Error("invZ was invalid");return{x:$,y:N}}isTorsionFree(){let{h:v,isTorsionFree:E}=e;if(v===li)return!0;if(E)return E(l,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:v,clearCofactor:E}=e;return v===li?this:E?E(l,this):this.multiplyUnsafe(e.h)}toRawBytes(v=!0){return this.assertValidity(),n(l,this,v)}toHex(v=!0){return Gn.bytesToHex(this.toRawBytes(v))}}l.BASE=new l(e.Gx,e.Gy,r.ONE),l.ZERO=new l(r.ZERO,r.ONE,r.ZERO);let m=e.nBitLength,p=(0,qC.wNAF)(l,e.endo?Math.ceil(m/2):m);return{CURVE:e,ProjectivePoint:l,normPrivateKeyToScalar:d,weierstrassEquation:o,isWithinCurveOrder:s}}Yi.weierstrassPoints=mse;function LOe(t){let e=(0,qC.validateBasic)(t);return Gn.validateObject(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function KOe(t){let e=LOe(t),{Fp:r,n}=e,i=r.BYTES+1,o=2*r.BYTES+1;function s(y){return wu<y&&y<r.ORDER}function a(y){return kw.mod(y,n)}function d(y){return kw.invert(y,n)}let{ProjectivePoint:u,normPrivateKeyToScalar:c,weierstrassEquation:l,isWithinCurveOrder:m}=mse({...e,toBytes(y,w,_){let x=w.toAffine(),b=r.toBytes(x.x),B=Gn.concatBytes;return _?B(Uint8Array.from([w.hasEvenY()?2:3]),b):B(Uint8Array.from([4]),b,r.toBytes(x.y))},fromBytes(y){let w=y.length,_=y[0],x=y.subarray(1);if(w===i&&(_===2||_===3)){let b=Gn.bytesToNumberBE(x);if(!s(b))throw new Error("Point is not on curve");let B=l(b),q=r.sqrt(B),M=(q&li)===li;return(_&1)===1!==M&&(q=r.neg(q)),{x:b,y:q}}else if(w===o&&_===4){let b=r.fromBytes(x.subarray(0,r.BYTES)),B=r.fromBytes(x.subarray(r.BYTES,2*r.BYTES));return{x:b,y:B}}else throw new Error(`Point of length ${w} was invalid. Expected ${i} compressed bytes or ${o} uncompressed bytes`)}}),p=y=>Gn.bytesToHex(Gn.numberToBytesBE(y,e.nByteLength));function g(y){let w=n>>li;return y>w}function v(y){return g(y)?a(-y):y}let E=(y,w,_)=>Gn.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,Ml.ensureBytes)("compactSignature",w,_*2),new A(E(w,0,_),E(w,_,2*_))}static fromDER(w){let{r:_,s:x}=Yi.DER.toSig((0,Ml.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:b}=this,B=F((0,Ml.ensureBytes)("msgHash",w));if(b==null||![0,1,2,3].includes(b))throw new Error("recovery id invalid");let q=b===2||b===3?_+e.n:_;if(q>=r.ORDER)throw new Error("recovery id 2 or 3 invalid");let M=b&1?"03":"02",j=u.fromHex(M+p(q)),J=d(q),Z=a(-B*J),G=a(x*J),W=u.BASE.multiplyAndAddUnsafe(j,Z,G);if(!W)throw new Error("point at infinify");return W.assertValidity(),W}hasHighS(){return g(this.s)}normalizeS(){return this.hasHighS()?new A(this.r,a(-this.s),this.recovery):this}toDERRawBytes(){return Gn.hexToBytes(this.toDERHex())}toDERHex(){return Yi.DER.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Gn.hexToBytes(this.toCompactHex())}toCompactHex(){return p(this.r)+p(this.s)}}let P={isValidPrivateKey(y){try{return c(y),!0}catch{return!1}},normPrivateKeyToScalar:c,randomPrivateKey:()=>{let y=kw.getMinHashLength(e.n);return kw.mapHashToField(e.randomBytes(y),e.n)},precompute(y=8,w=u.BASE){return w._setWindowSize(y),w.multiply(BigInt(3)),w}};function I(y,w=!0){return u.fromPrivateKey(y).toRawBytes(w)}function $(y){let w=Gn.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 K=e.bits2int||function(y){let w=Gn.bytesToNumberBE(y),_=y.length*8-e.nBitLength;return _>0?w>>BigInt(_):w},F=e.bits2int_modN||function(y){return a(K(y))},U=Gn.bitMask(e.nBitLength);function V(y){if(typeof y!="bigint")throw new Error("bigint expected");if(!(wu<=y&&y<U))throw new Error(`bigint expected < 2^${e.nBitLength}`);return Gn.numberToBytesBE(y,e.nByteLength)}function L(y,w,_=T){if(["recovered","canonical"].some(ee=>ee in _))throw new Error("sign() legacy options not supported");let{hash:x,randomBytes:b}=e,{lowS:B,prehash:q,extraEntropy:M}=_;B==null&&(B=!0),y=(0,Ml.ensureBytes)("msgHash",y),q&&(y=(0,Ml.ensureBytes)("prehashed msgHash",x(y)));let j=F(y),J=c(w),Z=[V(J),V(j)];if(M!=null){let ee=M===!0?b(r.BYTES):M;Z.push((0,Ml.ensureBytes)("extraEntropy",ee))}let G=Gn.concatBytes(...Z),W=j;function X(ee){let ue=K(ee);if(!m(ue))return;let ae=d(ue),ce=u.BASE.multiply(ue).toAffine(),pe=a(ce.x);if(pe===wu)return;let xe=a(ae*a(W+pe*J));if(xe===wu)return;let Ue=(ce.x===pe?0:2)|Number(ce.y&li),le=xe;return B&&g(xe)&&(le=v(xe),Ue^=1),new A(pe,le,Ue)}return{seed:G,k2sig:X}}let T={lowS:e.lowS,prehash:!1},S={lowS:e.lowS,prehash:!1};function k(y,w,_=T){let{seed:x,k2sig:b}=L(y,w,_),B=e;return Gn.createHmacDrbg(B.hash.outputLen,B.nByteLength,B.hmac)(x,b)}u.BASE._setWindowSize(8);function f(y,w,_,x=S){let b=y;if(w=(0,Ml.ensureBytes)("msgHash",w),_=(0,Ml.ensureBytes)("publicKey",_),"strict"in x)throw new Error("options.strict was renamed to lowS");let{lowS:B,prehash:q}=x,M,j;try{if(typeof b=="string"||Gn.isBytes(b))try{M=A.fromDER(b)}catch(ce){if(!(ce instanceof Yi.DER.Err))throw ce;M=A.fromCompact(b)}else if(typeof b=="object"&&typeof b.r=="bigint"&&typeof b.s=="bigint"){let{r:ce,s:pe}=b;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(B&&M.hasHighS())return!1;q&&(w=e.hash(w));let{r:J,s:Z}=M,G=F(w),W=d(Z),X=a(G*W),ee=a(J*W),ue=u.BASE.multiplyAndAddUnsafe(j,X,ee)?.toAffine();return ue?a(ue.x)===J:!1}return{CURVE:e,getPublicKey:I,getSharedSecret:N,sign:k,verify:f,ProjectivePoint:u,Signature:A,utils:P}}Yi.weierstrass=KOe;function yse(t,e){let r=t.ORDER,n=wu;for(let g=r-li;g%gm===wu;g/=gm)n+=li;let i=n,o=gm<<i-li-li,s=o*gm,a=(r-li)/s,d=(a-li)/gm,u=s-li,c=o,l=t.pow(e,a),m=t.pow(e,(a+li)/gm),p=(g,v)=>{let E=l,A=t.pow(v,u),P=t.sqr(A);P=t.mul(P,v);let I=t.mul(g,P);I=t.pow(I,d),I=t.mul(I,A),A=t.mul(I,v),P=t.mul(I,g);let $=t.mul(P,A);I=t.pow($,c);let N=t.eql(I,t.ONE);A=t.mul(P,m),I=t.mul($,E),P=t.cmov(A,P,N),$=t.cmov(I,$,N);for(let K=i;K>li;K--){let F=K-gm;F=gm<<F-li;let U=t.pow($,F),V=t.eql(U,t.ONE);A=t.mul(P,E),E=t.mul(E,E),U=t.mul($,E),P=t.cmov(A,P,V),$=t.cmov(U,$,V)}return{isValid:N,value:P}};if(t.ORDER%pse===TA){let g=(t.ORDER-TA)/pse,v=t.sqrt(t.neg(e));p=(E,A)=>{let P=t.sqr(A),I=t.mul(E,A);P=t.mul(P,I);let $=t.pow(P,g);$=t.mul($,I);let N=t.mul($,v),K=t.mul(t.sqr($),A),F=t.eql(K,E),U=t.cmov(N,$,F);return{isValid:F,value:U}}}return p}Yi.SWUFpSqrtRatio=yse;function FOe(t,e){if(kw.validateField(t),!t.isValid(e.A)||!t.isValid(e.B)||!t.isValid(e.Z))throw new Error("mapToCurveSimpleSWU: invalid opts");let r=yse(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}}}Yi.mapToCurveSimpleSWU=FOe});var vse=H(cg=>{"use strict";h();Object.defineProperty(cg,"__esModule",{value:!0});cg.hmac=cg.HMAC=void 0;var IA=dC(),gse=cm(),dE=class extends gse.Hash{constructor(e,r){super(),this.finished=!1,this.destroyed=!1,(0,IA.hash)(e);let n=(0,gse.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;s<o.length;s++)o[s]^=54;this.iHash.update(o),this.oHash=e.create();for(let s=0;s<o.length;s++)o[s]^=106;this.oHash.update(o),o.fill(0)}update(e){return(0,IA.exists)(this),this.iHash.update(e),this}digestInto(e){(0,IA.exists)(this),(0,IA.bytes)(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){let e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));let{oHash:r,iHash:n,finished:i,destroyed:o,blockLen:s,outputLen:a}=this;return e=e,e.finished=i,e.destroyed=o,e.blockLen=s,e.outputLen=a,e.oHash=r._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}};cg.HMAC=dE;var zOe=(t,e,r)=>new dE(t,e).update(r).digest();cg.hmac=zOe;cg.hmac.create=(t,e)=>new dE(t,e)});var _se=H(Rw=>{"use strict";h();Object.defineProperty(Rw,"__esModule",{value:!0});Rw.createCurve=Rw.getHash=void 0;var VOe=vse(),bse=cm(),HOe=LC();function wse(t){return{hash:t,hmac:(e,...r)=>(0,VOe.hmac)(t,e,(0,bse.concatBytes)(...r)),randomBytes:bse.randomBytes}}Rw.getHash=wse;function WOe(t,e){let r=n=>(0,HOe.weierstrass)({...t,...wse(n)});return Object.freeze({...r(e),create:r})}Rw.createCurve=WOe});var Mse=H(Ca=>{"use strict";h();Object.defineProperty(Ca,"__esModule",{value:!0});Ca.encodeToCurve=Ca.hashToCurve=Ca.schnorr=Ca.secp256k1=void 0;var PA=hse(),GOe=cm(),_o=fm(),JOe=LC(),Bs=gu(),Sse=MC(),YOe=_se(),MA=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),kA=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),Ase=BigInt(1),RA=BigInt(2),xse=(t,e)=>(t+e/RA)/e;function Tse(t){let e=MA,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,_o.pow2)(c,r,e)*c%e,m=(0,_o.pow2)(l,r,e)*c%e,p=(0,_o.pow2)(m,RA,e)*u%e,g=(0,_o.pow2)(p,i,e)*p%e,v=(0,_o.pow2)(g,o,e)*g%e,E=(0,_o.pow2)(v,a,e)*v%e,A=(0,_o.pow2)(E,d,e)*E%e,P=(0,_o.pow2)(A,a,e)*v%e,I=(0,_o.pow2)(P,r,e)*c%e,$=(0,_o.pow2)(I,s,e)*g%e,N=(0,_o.pow2)($,n,e)*u%e,K=(0,_o.pow2)(N,RA,e);if(!vm.eql(vm.sqr(K),t))throw new Error("Cannot find square root");return K}var vm=(0,_o.Field)(MA,void 0,void 0,{sqrt:Tse});Ca.secp256k1=(0,YOe.createCurve)({a:BigInt(0),b:BigInt(7),Fp:vm,n:kA,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:t=>{let e=kA,r=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-Ase*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),o=r,s=BigInt("0x100000000000000000000000000000000"),a=xse(o*t,e),d=xse(-n*t,e),u=(0,_o.mod)(t-a*r-d*i,e),c=(0,_o.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}}}},PA.sha256);var DA=BigInt(0),Ise=t=>typeof t=="bigint"&&DA<t&&t<MA,ZOe=t=>typeof t=="bigint"&&DA<t&&t<kA,Ese={};function BA(t,...e){let r=Ese[t];if(r===void 0){let n=(0,PA.sha256)(Uint8Array.from(t,i=>i.charCodeAt(0)));r=(0,Bs.concatBytes)(n,n),Ese[t]=r}return(0,PA.sha256)((0,Bs.concatBytes)(r,...e))}var VC=t=>t.toRawBytes(!0).slice(1),FC=t=>(0,Bs.numberToBytesBE)(t,32),KC=t=>(0,_o.mod)(t,MA),uE=t=>(0,_o.mod)(t,kA),HC=Ca.secp256k1.ProjectivePoint,XOe=(t,e,r)=>HC.BASE.multiplyAndAddUnsafe(t,e,r);function zC(t){let e=Ca.secp256k1.utils.normPrivateKeyToScalar(t),r=HC.fromPrivateKey(e);return{scalar:r.hasEvenY()?e:uE(-e),bytes:VC(r)}}function Pse(t){if(!Ise(t))throw new Error("bad x: need 0 < x < p");let e=KC(t*t),r=KC(e*t+BigInt(7)),n=Tse(r);n%RA!==DA&&(n=KC(-n));let i=new HC(t,n,Ase);return i.assertValidity(),i}function kse(...t){return uE((0,Bs.bytesToNumberBE)(BA("BIP0340/challenge",...t)))}function QOe(t){return zC(t).bytes}function eCe(t,e,r=(0,GOe.randomBytes)(32)){let n=(0,Bs.ensureBytes)("message",t),{bytes:i,scalar:o}=zC(e),s=(0,Bs.ensureBytes)("auxRand",r,32),a=FC(o^(0,Bs.bytesToNumberBE)(BA("BIP0340/aux",s))),d=BA("BIP0340/nonce",a,i,n),u=uE((0,Bs.bytesToNumberBE)(d));if(u===DA)throw new Error("sign failed: k is zero");let{bytes:c,scalar:l}=zC(u),m=kse(c,i,n),p=new Uint8Array(64);if(p.set(c,0),p.set(FC(uE(l+m*o)),32),!Rse(p,n,i))throw new Error("sign: Invalid signature produced");return p}function Rse(t,e,r){let n=(0,Bs.ensureBytes)("signature",t,64),i=(0,Bs.ensureBytes)("message",e),o=(0,Bs.ensureBytes)("publicKey",r,32);try{let s=Pse((0,Bs.bytesToNumberBE)(o)),a=(0,Bs.bytesToNumberBE)(n.subarray(0,32));if(!Ise(a))return!1;let d=(0,Bs.bytesToNumberBE)(n.subarray(32,64));if(!ZOe(d))return!1;let u=kse(FC(a),VC(s),i),c=XOe(s,d,uE(-u));return!(!c||!c.hasEvenY()||c.toAffine().x!==a)}catch{return!1}}Ca.schnorr={getPublicKey:QOe,sign:eCe,verify:Rse,utils:{randomPrivateKey:Ca.secp256k1.utils.randomPrivateKey,lift_x:Pse,pointToBytes:VC,numberToBytesBE:Bs.numberToBytesBE,bytesToNumberBE:Bs.bytesToNumberBE,taggedHash:BA,mod:_o.mod}};var tCe=(0,Sse.isogenyMap)(vm,[["0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa8c7","0x7d3d4c80bc321d5b9f315cea7fd44c5d595d2fc0bf63b92dfff1044f17c6581","0x534c328d23f234e6e2a413deca25caece4506144037c40314ecbd0b53d9dd262","0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa88c"],["0xd35771193d94918a9ca34ccbb7b640dd86cd409542f8487d9fe6b745781eb49b","0xedadc6f64383dc1df7c4b2d51b54225406d36b641f5e41bbc52a56612a8c6d14","0x0000000000000000000000000000000000000000000000000000000000000001"],["0x4bda12f684bda12f684bda12f684bda12f684bda12f684bda12f684b8e38e23c","0xc75e0c32d5cb7c0fa9d0a54b12a0a6d5647ab046d686da6fdffc90fc201d71a3","0x29a6194691f91a73715209ef6512e576722830a201be2018a765e85a9ecee931","0x2f684bda12f684bda12f684bda12f684bda12f684bda12f684bda12f38e38d84"],["0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffff93b","0x7a06534bb8bdb49fd5e9e6632722c2989467c1bfc8e8d978dfb425d2685c2573","0x6484aa716545ca2cf3a70c3fa8fe337e0a3d21162f0d6299a7bf8192bfd2a76f","0x0000000000000000000000000000000000000000000000000000000000000001"]].map(t=>t.map(e=>BigInt(e)))),rCe=(0,JOe.mapToCurveSimpleSWU)(vm,{A:BigInt("0x3f8731abdd661adca08a5558f0f5d272e953d363cb6f0e5d405447c01a444533"),B:BigInt("1771"),Z:vm.create(BigInt("-11"))}),Bse=(0,Sse.createHasher)(Ca.secp256k1.ProjectivePoint,t=>{let{x:e,y:r}=rCe(vm.create(t[0]));return tCe(e,r)},{DST:"secp256k1_XMD:SHA-256_SSWU_RO_",encodeDST:"secp256k1_XMD:SHA-256_SSWU_NU_",p:vm.ORDER,m:1,k:128,expand:"xmd",hash:PA.sha256});Ca.hashToCurve=Bse.hashToCurve;Ca.encodeToCurve=Bse.encodeToCurve});var WC=H(Bw=>{"use strict";h();Object.defineProperty(Bw,"__esModule",{value:!0});Bw.decodeHex=Bw.remove0x=void 0;var nCe=yu();function Dse(t){return t.startsWith("0x")||t.startsWith("0X")?t.slice(2):t}Bw.remove0x=Dse;function iCe(t){return(0,nCe.hexToBytes)(Dse(t))}Bw.decodeHex=iCe});var JC=H(oa=>{"use strict";h();Object.defineProperty(oa,"__esModule",{value:!0});oa.output=oa.exists=oa.hash=oa.bytes=oa.bool=oa.number=void 0;function OA(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`Wrong positive integer: ${t}`)}oa.number=OA;function Ose(t){if(typeof t!="boolean")throw new Error(`Expected boolean, not ${t}`)}oa.bool=Ose;function GC(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}`)}oa.bytes=GC;function Cse(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("hash must be wrapped by utils.wrapConstructor");OA(t.outputLen),OA(t.blockLen)}oa.hash=Cse;function $se(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")}oa.exists=$se;function Nse(t,e){GC(t);let r=e.outputLen;if(t.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}oa.output=Nse;var oCe={number:OA,bool:Ose,bytes:GC,hash:Cse,exists:$se,output:Nse};oa.default=oCe});var Use=H(Mw=>{"use strict";h();Object.defineProperty(Mw,"__esModule",{value:!0});Mw.poly1305=Mw.wrapConstructorWithKey=void 0;var CA=yu(),YC=JC(),Vo=(t,e)=>t[e++]&255|(t[e++]&255)<<8,ZC=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,CA.toBytes)(e),(0,CA.ensureBytes)(e,32);let r=Vo(e,0),n=Vo(e,2),i=Vo(e,4),o=Vo(e,6),s=Vo(e,8),a=Vo(e,10),d=Vo(e,12),u=Vo(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]=Vo(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],v=s[8],E=s[9],A=Vo(e,r+0),P=Vo(e,r+2),I=Vo(e,r+4),$=Vo(e,r+6),N=Vo(e,r+8),K=Vo(e,r+10),F=Vo(e,r+12),U=Vo(e,r+14),V=o[0]+(A&8191),L=o[1]+((A>>>13|P<<3)&8191),T=o[2]+((P>>>10|I<<6)&8191),S=o[3]+((I>>>7|$<<9)&8191),k=o[4]+(($>>>4|N<<12)&8191),f=o[5]+(N>>>1&8191),y=o[6]+((N>>>14|K<<2)&8191),w=o[7]+((K>>>11|F<<5)&8191),_=o[8]+((F>>>8|U<<8)&8191),x=o[9]+(U>>>5|i),b=0,B=b+V*a+L*(5*E)+T*(5*v)+S*(5*g)+k*(5*p);b=B>>>13,B&=8191,B+=f*(5*m)+y*(5*l)+w*(5*c)+_*(5*u)+x*(5*d),b+=B>>>13,B&=8191;let q=b+V*d+L*a+T*(5*E)+S*(5*v)+k*(5*g);b=q>>>13,q&=8191,q+=f*(5*p)+y*(5*m)+w*(5*l)+_*(5*c)+x*(5*u),b+=q>>>13,q&=8191;let M=b+V*u+L*d+T*a+S*(5*E)+k*(5*v);b=M>>>13,M&=8191,M+=f*(5*g)+y*(5*p)+w*(5*m)+_*(5*l)+x*(5*c),b+=M>>>13,M&=8191;let j=b+V*c+L*u+T*d+S*a+k*(5*E);b=j>>>13,j&=8191,j+=f*(5*v)+y*(5*g)+w*(5*p)+_*(5*m)+x*(5*l),b+=j>>>13,j&=8191;let J=b+V*l+L*c+T*u+S*d+k*a;b=J>>>13,J&=8191,J+=f*(5*E)+y*(5*v)+w*(5*g)+_*(5*p)+x*(5*m),b+=J>>>13,J&=8191;let Z=b+V*m+L*l+T*c+S*u+k*d;b=Z>>>13,Z&=8191,Z+=f*a+y*(5*E)+w*(5*v)+_*(5*g)+x*(5*p),b+=Z>>>13,Z&=8191;let G=b+V*p+L*m+T*l+S*c+k*u;b=G>>>13,G&=8191,G+=f*d+y*a+w*(5*E)+_*(5*v)+x*(5*g),b+=G>>>13,G&=8191;let W=b+V*g+L*p+T*m+S*l+k*c;b=W>>>13,W&=8191,W+=f*u+y*d+w*a+_*(5*E)+x*(5*v),b+=W>>>13,W&=8191;let X=b+V*v+L*g+T*p+S*m+k*l;b=X>>>13,X&=8191,X+=f*c+y*u+w*d+_*a+x*(5*E),b+=X>>>13,X&=8191;let ee=b+V*E+L*v+T*g+S*p+k*m;b=ee>>>13,ee&=8191,ee+=f*l+y*c+w*u+_*d+x*a,b+=ee>>>13,ee&=8191,b=(b<<2)+b|0,b=b+B|0,B=b&8191,b=b>>>13,q+=b,o[0]=B,o[1]=q,o[2]=M,o[3]=j,o[4]=J,o[5]=Z,o[6]=G,o[7]=W,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){YC.default.exists(this);let{buffer:r,blockLen:n}=this;e=(0,CA.toBytes)(e);let i=e.length;for(let o=0;o<i;){let s=Math.min(n-this.pos,i-o);if(s===n){for(;n<=i-o;o+=n)this.process(e,o);continue}r.set(e.subarray(o,o+s),this.pos),this.pos+=s,o+=s,this.pos===n&&(this.process(r,0,!1),this.pos=0)}return this}destroy(){this.h.fill(0),this.r.fill(0),this.buffer.fill(0),this.pad.fill(0)}digestInto(e){YC.default.exists(this),YC.default.output(e,this),this.finished=!0;let{buffer:r,h:n}=this,{pos:i}=this;if(i){for(r[i++]=1;i<16;i++)r[i]=0;this.process(r,0,!0)}this.finalize();let o=0;for(let s=0;s<8;s++)e[o++]=n[s]>>>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 jse(t){let e=(n,i)=>t(i).update((0,CA.toBytes)(n)).digest(),r=t(new Uint8Array(32));return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=n=>t(n),e}Mw.wrapConstructorWithKey=jse;Mw.poly1305=jse(t=>new ZC(t))});var qse=H(NA=>{"use strict";h();Object.defineProperty(NA,"__esModule",{value:!0});NA.salsaBasic=void 0;var Dl=JC(),Ol=yu(),sCe=(0,Ol.utf8ToBytes)("expand 16-byte k"),aCe=(0,Ol.utf8ToBytes)("expand 32-byte k"),cCe=(0,Ol.u32)(sCe),dCe=(0,Ol.u32)(aCe),$A=t=>!(t.byteOffset%4),uCe=t=>{let{core:e,rounds:r,counterRight:n,counterLen:i,allow128bitKeys:o,extendNonceFn:s,blockLen:a}=(0,Ol.checkOpts)({rounds:20,counterRight:!1,counterLen:8,allow128bitKeys:!0,blockLen:64},t);Dl.default.number(i),Dl.default.number(r),Dl.default.number(a),Dl.default.bool(n),Dl.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(Dl.default.bytes(u),Dl.default.bytes(c),Dl.default.bytes(l),m||(m=new Uint8Array(l.length)),Dl.default.bytes(m),Dl.default.number(p),p<0||p>=2**32-1)throw new Error("Salsa/ChaCha: counter overflow");if(m.length<l.length)throw new Error(`Salsa/ChaCha: output (${m.length}) is shorter than data (${l.length})`);let g=[],v,E;if(u.length===32)$A(u)?v=u:(v=u.slice(),g.push(v)),E=dCe;else if(u.length===16&&o)v=new Uint8Array(32),v.set(u),v.set(u,16),E=cCe,g.push(v);else throw new Error(`Salsa/ChaCha: invalid 32-byte key, got length=${u.length}`);if($A(c)||(c=c.slice(),g.push(c)),s){if(c.length<=16)throw new Error("Salsa/ChaCha: extended nonce must be bigger than 16 bytes");v=s(E,v,c.subarray(0,16),new Uint8Array(32)),g.push(v),c=c.subarray(16)}let A=16-i;if(c.length!==A)throw new Error(`Salsa/ChaCha: nonce must be ${A} or 16 bytes`);if(A!==12){let V=new Uint8Array(12);V.set(c,n?0:12-c.length),g.push(c=V)}let P=new Uint8Array(a),I=(0,Ol.u32)(P),$=(0,Ol.u32)(v),N=(0,Ol.u32)(c),K=$A(l)&&(0,Ol.u32)(l),F=$A(m)&&(0,Ol.u32)(m);g.push(I);let U=l.length;for(let V=0,L=p;V<U;L++){if(e(E,$,N,I,L,r),L>=2**32-1)throw new Error("Salsa/ChaCha: counter overflow");let T=Math.min(a,U-V);if(T===a&&F&&K){let S=V/4;if(V%4!==0)throw new Error("Salsa/ChaCha: invalid block position");for(let k=0;k<d;k++)F[S+k]=K[S+k]^I[k];V+=a;continue}for(let S=0;S<T;S++)m[V+S]=l[V+S]^P[S];V+=T}for(let V=0;V<g.length;V++)g[V].fill(0);return m}};NA.salsaBasic=uCe});var zse=H(Kn=>{"use strict";h();Object.defineProperty(Kn,"__esModule",{value:!0});Kn.xchacha20poly1305=Kn.chacha20poly1305=Kn._poly1305_aead=Kn.chacha12=Kn.chacha8=Kn.xchacha20=Kn.chacha20=Kn.chacha20orig=Kn.hchacha=void 0;var _u=yu(),lCe=Use(),lE=qse(),et=(t,e)=>t<<e|t>>>32-e;function fE(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],v=e[5],E=e[6],A=e[7],P=i,I=r[0],$=r[1],N=r[2],K=s,F=a,U=d,V=u,L=c,T=l,S=m,k=p,f=g,y=v,w=E,_=A,x=P,b=I,B=$,q=N;for(let j=0;j<o;j+=2)K=K+L|0,x=et(x^K,16),f=f+x|0,L=et(L^f,12),K=K+L|0,x=et(x^K,8),f=f+x|0,L=et(L^f,7),F=F+T|0,b=et(b^F,16),y=y+b|0,T=et(T^y,12),F=F+T|0,b=et(b^F,8),y=y+b|0,T=et(T^y,7),U=U+S|0,B=et(B^U,16),w=w+B|0,S=et(S^w,12),U=U+S|0,B=et(B^U,8),w=w+B|0,S=et(S^w,7),V=V+k|0,q=et(q^V,16),_=_+q|0,k=et(k^_,12),V=V+k|0,q=et(q^V,8),_=_+q|0,k=et(k^_,7),K=K+T|0,q=et(q^K,16),w=w+q|0,T=et(T^w,12),K=K+T|0,q=et(q^K,8),w=w+q|0,T=et(T^w,7),F=F+S|0,x=et(x^F,16),_=_+x|0,S=et(S^_,12),F=F+S|0,x=et(x^F,8),_=_+x|0,S=et(S^_,7),U=U+k|0,b=et(b^U,16),f=f+b|0,k=et(k^f,12),U=U+k|0,b=et(b^U,8),f=f+b|0,k=et(k^f,7),V=V+L|0,B=et(B^V,16),y=y+B|0,L=et(L^y,12),V=V+L|0,B=et(B^V,8),y=y+B|0,L=et(L^y,7);let M=0;n[M++]=s+K|0,n[M++]=a+F|0,n[M++]=d+U|0,n[M++]=u+V|0,n[M++]=c+L|0,n[M++]=l+T|0,n[M++]=m+S|0,n[M++]=p+k|0,n[M++]=g+f|0,n[M++]=v+y|0,n[M++]=E+w|0,n[M++]=A+_|0,n[M++]=P+x|0,n[M++]=I+b|0,n[M++]=$+B|0,n[M++]=N+q|0}function Fse(t,e,r,n){let i=(0,_u.u32)(e),o=(0,_u.u32)(r),s=(0,_u.u32)(n),a=t[0],d=t[1],u=t[2],c=t[3],l=i[0],m=i[1],p=i[2],g=i[3],v=i[4],E=i[5],A=i[6],P=i[7],I=o[0],$=o[1],N=o[2],K=o[3];for(let F=0;F<20;F+=2)a=a+l|0,I=et(I^a,16),v=v+I|0,l=et(l^v,12),a=a+l|0,I=et(I^a,8),v=v+I|0,l=et(l^v,7),d=d+m|0,$=et($^d,16),E=E+$|0,m=et(m^E,12),d=d+m|0,$=et($^d,8),E=E+$|0,m=et(m^E,7),u=u+p|0,N=et(N^u,16),A=A+N|0,p=et(p^A,12),u=u+p|0,N=et(N^u,8),A=A+N|0,p=et(p^A,7),c=c+g|0,K=et(K^c,16),P=P+K|0,g=et(g^P,12),c=c+g|0,K=et(K^c,8),P=P+K|0,g=et(g^P,7),a=a+m|0,K=et(K^a,16),A=A+K|0,m=et(m^A,12),a=a+m|0,K=et(K^a,8),A=A+K|0,m=et(m^A,7),d=d+p|0,I=et(I^d,16),P=P+I|0,p=et(p^P,12),d=d+p|0,I=et(I^d,8),P=P+I|0,p=et(p^P,7),u=u+g|0,$=et($^u,16),v=v+$|0,g=et(g^v,12),u=u+g|0,$=et($^u,8),v=v+$|0,g=et(g^v,7),c=c+l|0,N=et(N^c,16),E=E+N|0,l=et(l^E,12),c=c+l|0,N=et(N^c,8),E=E+N|0,l=et(l^E,7);return s[0]=a,s[1]=d,s[2]=u,s[3]=c,s[4]=I,s[5]=$,s[6]=N,s[7]=K,n}Kn.hchacha=Fse;Kn.chacha20orig=(0,lE.salsaBasic)({core:fE,counterRight:!1,counterLen:8});Kn.chacha20=(0,lE.salsaBasic)({core:fE,counterRight:!1,counterLen:4,allow128bitKeys:!1});Kn.xchacha20=(0,lE.salsaBasic)({core:fE,counterRight:!1,counterLen:8,extendNonceFn:Fse,allow128bitKeys:!1});Kn.chacha8=(0,lE.salsaBasic)({core:fE,counterRight:!1,counterLen:4,rounds:8});Kn.chacha12=(0,lE.salsaBasic)({core:fE,counterRight:!1,counterLen:4,rounds:12});var fCe=new Uint8Array(16),Lse=(t,e)=>{t.update(e);let r=e.length%16;r&&t.update(fCe.subarray(r))},Kse=(t,e,r,n,i)=>{let o=t(e,r,new Uint8Array(32)),s=lCe.poly1305.create(o);i&&Lse(s,i),Lse(s,n);let a=new Uint8Array(16),d=(0,_u.createView)(a);(0,_u.setBigUint64)(d,0,BigInt(i?i.length:0),!0),(0,_u.setBigUint64)(d,8,BigInt(n.length),!0),s.update(a);let u=s.digest();return o.fill(0),u},hCe=t=>(e,r,n)=>((0,_u.ensureBytes)(e,32),(0,_u.ensureBytes)(r),{tagLength:16,encrypt:(o,s)=>{let a=o.length,d=a+16;s?(0,_u.ensureBytes)(s,d):s=new Uint8Array(d),t(e,r,o,s,1);let u=Kse(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,_u.ensureBytes)(s,d):s=new Uint8Array(d);let u=o.subarray(0,-16),c=o.subarray(-16),l=Kse(t,e,r,u,n);if(!(0,_u.equalBytes)(c,l))throw new Error("invalid tag");return t(e,r,u,s,1),s}});Kn._poly1305_aead=hCe;Kn.chacha20poly1305=(0,Kn._poly1305_aead)(Kn.chacha20);Kn.xchacha20poly1305=(0,Kn._poly1305_aead)(Kn.xchacha20)});var hE=H(Ho=>{"use strict";h();Object.defineProperty(Ho,"__esModule",{value:!0});Ho.output=Ho.exists=Ho.hash=Ho.bytes=Ho.bool=Ho.number=Ho.isBytes=void 0;function jA(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`positive integer expected, not ${t}`)}Ho.number=jA;function Vse(t){if(typeof t!="boolean")throw new Error(`boolean expected, not ${t}`)}Ho.bool=Vse;function Hse(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}Ho.isBytes=Hse;function XC(t,...e){if(!Hse(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}`)}Ho.bytes=XC;function Wse(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");jA(t.outputLen),jA(t.blockLen)}Ho.hash=Wse;function Gse(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")}Ho.exists=Gse;function Jse(t,e){XC(t);let r=e.outputLen;if(t.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}Ho.output=Jse;var pCe={number:jA,bool:Vse,bytes:XC,hash:Wse,exists:Gse,output:Jse};Ho.default=pCe});var Yse=H(UA=>{"use strict";h();Object.defineProperty(UA,"__esModule",{value:!0});UA.crypto=void 0;UA.crypto=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0});var pE=H(gt=>{"use strict";h();Object.defineProperty(gt,"__esModule",{value:!0});gt.randomBytes=gt.wrapXOFConstructorWithOpts=gt.wrapConstructorWithOpts=gt.wrapConstructor=gt.checkOpts=gt.Hash=gt.concatBytes=gt.toBytes=gt.utf8ToBytes=gt.asyncLoop=gt.nextTick=gt.hexToBytes=gt.bytesToHex=gt.byteSwap32=gt.byteSwapIfBE=gt.byteSwap=gt.isLE=gt.rotl=gt.rotr=gt.createView=gt.u32=gt.u8=gt.isBytes=void 0;var QC=Yse(),t$=hE();function mCe(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}gt.isBytes=mCe;var yCe=t=>new Uint8Array(t.buffer,t.byteOffset,t.byteLength);gt.u8=yCe;var gCe=t=>new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4));gt.u32=gCe;var vCe=t=>new DataView(t.buffer,t.byteOffset,t.byteLength);gt.createView=vCe;var bCe=(t,e)=>t<<32-e|t>>>e;gt.rotr=bCe;var wCe=(t,e)=>t<<e|t>>>32-e>>>0;gt.rotl=wCe;gt.isLE=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;var _Ce=t=>t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255;gt.byteSwap=_Ce;gt.byteSwapIfBE=gt.isLE?t=>t:t=>(0,gt.byteSwap)(t);function xCe(t){for(let e=0;e<t.length;e++)t[e]=(0,gt.byteSwap)(t[e])}gt.byteSwap32=xCe;var ECe=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function SCe(t){(0,t$.bytes)(t);let e="";for(let r=0;r<t.length;r++)e+=ECe[t[r]];return e}gt.bytesToHex=SCe;var fh={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function Zse(t){if(t>=fh._0&&t<=fh._9)return t-fh._0;if(t>=fh._A&&t<=fh._F)return t-(fh._A-10);if(t>=fh._a&&t<=fh._f)return t-(fh._a-10)}function ACe(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<r;i++,o+=2){let s=Zse(t.charCodeAt(o)),a=Zse(t.charCodeAt(o+1));if(s===void 0||a===void 0){let d=t[o]+t[o+1];throw new Error('hex string expected, got non-hex character "'+d+'" at index '+o)}n[i]=s*16+a}return n}gt.hexToBytes=ACe;var TCe=async()=>{};gt.nextTick=TCe;async function ICe(t,e,r){let n=Date.now();for(let i=0;i<t;i++){r(i);let o=Date.now()-n;o>=0&&o<e||(await(0,gt.nextTick)(),n+=o)}}gt.asyncLoop=ICe;function Xse(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}gt.utf8ToBytes=Xse;function qA(t){return typeof t=="string"&&(t=Xse(t)),(0,t$.bytes)(t),t}gt.toBytes=qA;function PCe(...t){let e=0;for(let n=0;n<t.length;n++){let i=t[n];(0,t$.bytes)(i),e+=i.length}let r=new Uint8Array(e);for(let n=0,i=0;n<t.length;n++){let o=t[n];r.set(o,i),i+=o.length}return r}gt.concatBytes=PCe;var e$=class{clone(){return this._cloneInto()}};gt.Hash=e$;var kCe={}.toString;function RCe(t,e){if(e!==void 0&&kCe.call(e)!=="[object Object]")throw new Error("Options should be object or undefined");return Object.assign(t,e)}gt.checkOpts=RCe;function BCe(t){let e=n=>t().update(qA(n)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}gt.wrapConstructor=BCe;function MCe(t){let e=(n,i)=>t(i).update(qA(n)).digest(),r=t({});return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=n=>t(n),e}gt.wrapConstructorWithOpts=MCe;function DCe(t){let e=(n,i)=>t(i).update(qA(n)).digest(),r=t({});return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=n=>t(n),e}gt.wrapXOFConstructorWithOpts=DCe;function OCe(t=32){if(QC.crypto&&typeof QC.crypto.getRandomValues=="function")return QC.crypto.getRandomValues(new Uint8Array(t));throw new Error("crypto.getRandomValues must be defined")}gt.randomBytes=OCe});var eae=H(dg=>{"use strict";h();Object.defineProperty(dg,"__esModule",{value:!0});dg.hmac=dg.HMAC=void 0;var LA=hE(),Qse=pE(),mE=class extends Qse.Hash{constructor(e,r){super(),this.finished=!1,this.destroyed=!1,(0,LA.hash)(e);let n=(0,Qse.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;s<o.length;s++)o[s]^=54;this.iHash.update(o),this.oHash=e.create();for(let s=0;s<o.length;s++)o[s]^=106;this.oHash.update(o),o.fill(0)}update(e){return(0,LA.exists)(this),this.iHash.update(e),this}digestInto(e){(0,LA.exists)(this),(0,LA.bytes)(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){let e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));let{oHash:r,iHash:n,finished:i,destroyed:o,blockLen:s,outputLen:a}=this;return e=e,e.finished=i,e.destroyed=o,e.blockLen=s,e.outputLen=a,e.oHash=r._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}};dg.HMAC=mE;var CCe=(t,e,r)=>new mE(t,e).update(r).digest();dg.hmac=CCe;dg.hmac.create=(t,e)=>new mE(t,e)});var sae=H(bm=>{"use strict";h();Object.defineProperty(bm,"__esModule",{value:!0});bm.hkdf=bm.expand=bm.extract=void 0;var n$=hE(),tae=pE(),nae=eae();function iae(t,e,r){return(0,n$.hash)(t),r===void 0&&(r=new Uint8Array(t.outputLen)),(0,nae.hmac)(t,(0,tae.toBytes)(r),(0,tae.toBytes)(e))}bm.extract=iae;var r$=new Uint8Array([0]),rae=new Uint8Array;function oae(t,e,r,n=32){if((0,n$.hash)(t),(0,n$.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=rae);let o=new Uint8Array(i*t.outputLen),s=nae.hmac.create(t,e),a=s._cloneInto(),d=new Uint8Array(s.outputLen);for(let u=0;u<i;u++)r$[0]=u+1,a.update(u===0?rae:d).update(r).update(r$).digestInto(d),o.set(d,t.outputLen*u),s._cloneInto(a);return s.destroy(),a.destroy(),d.fill(0),r$.fill(0),o.slice(0,n)}bm.expand=oae;var $Ce=(t,e,r,n,i)=>oae(t,iae(t,e,r),n,i);bm.hkdf=$Ce});var aae=H(wm=>{"use strict";h();Object.defineProperty(wm,"__esModule",{value:!0});wm.HashMD=wm.Maj=wm.Chi=void 0;var i$=hE(),yE=pE();function NCe(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 jCe=(t,e,r)=>t&e^~t&r;wm.Chi=jCe;var UCe=(t,e,r)=>t&e^t&r^e&r;wm.Maj=UCe;var o$=class extends yE.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,yE.createView)(this.buffer)}update(e){(0,i$.exists)(this);let{view:r,buffer:n,blockLen:i}=this;e=(0,yE.toBytes)(e);let o=e.length;for(let s=0;s<o;){let a=Math.min(i-this.pos,o-s);if(a===i){let d=(0,yE.createView)(e);for(;i<=o-s;s+=i)this.process(d,s);continue}n.set(e.subarray(s,s+a),this.pos),this.pos+=a,s+=a,this.pos===i&&(this.process(r,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){(0,i$.exists)(this),(0,i$.output)(e,this),this.finished=!0;let{buffer:r,view:n,blockLen:i,isLE:o}=this,{pos:s}=this;r[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>i-s&&(this.process(n,0),s=0);for(let l=s;l<i;l++)r[l]=0;NCe(n,i-8,BigInt(this.length*8),o),this.process(n,0);let a=(0,yE.createView)(e),d=this.outputLen;if(d%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let u=d/4,c=this.get();if(u>c.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;l<u;l++)a.setUint32(4*l,c[l],o)}digest(){let{buffer:e,outputLen:r}=this;this.digestInto(e);let n=e.slice(0,r);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());let{blockLen:r,buffer:n,length:i,finished:o,destroyed:s,pos:a}=this;return e.length=i,e.pos=a,e.finished=o,e.destroyed=s,i%r&&e.buffer.set(n),e}};wm.HashMD=o$});var cae=H(Dw=>{"use strict";h();Object.defineProperty(Dw,"__esModule",{value:!0});Dw.sha224=Dw.sha256=void 0;var s$=aae(),_d=pE(),qCe=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]),_m=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),xm=new Uint32Array(64),KA=class extends s$.HashMD{constructor(){super(64,32,8,!1),this.A=_m[0]|0,this.B=_m[1]|0,this.C=_m[2]|0,this.D=_m[3]|0,this.E=_m[4]|0,this.F=_m[5]|0,this.G=_m[6]|0,this.H=_m[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)xm[l]=e.getUint32(r,!1);for(let l=16;l<64;l++){let m=xm[l-15],p=xm[l-2],g=(0,_d.rotr)(m,7)^(0,_d.rotr)(m,18)^m>>>3,v=(0,_d.rotr)(p,17)^(0,_d.rotr)(p,19)^p>>>10;xm[l]=v+xm[l-7]+g+xm[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,_d.rotr)(a,6)^(0,_d.rotr)(a,11)^(0,_d.rotr)(a,25),p=c+m+(0,s$.Chi)(a,d,u)+qCe[l]+xm[l]|0,v=((0,_d.rotr)(n,2)^(0,_d.rotr)(n,13)^(0,_d.rotr)(n,22))+(0,s$.Maj)(n,i,o)|0;c=u,u=d,d=a,a=s+p|0,s=o,o=i,i=n,n=p+v|0}n=n+this.A|0,i=i+this.B|0,o=o+this.C|0,s=s+this.D|0,a=a+this.E|0,d=d+this.F|0,u=u+this.G|0,c=c+this.H|0,this.set(n,i,o,s,a,d,u,c)}roundClean(){xm.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}},a$=class extends KA{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}};Dw.sha256=(0,_d.wrapConstructor)(()=>new KA);Dw.sha224=(0,_d.wrapConstructor)(()=>new a$)});var lae=H(FA=>{"use strict";h();Object.defineProperty(FA,"__esModule",{value:!0});FA.aes256gcm=void 0;var dae=yu(),uae=I4(),c$=rE();function LCe(t,e,r){var n=function(o){var s=(0,uae.createCipheriv)("aes-256-gcm",t,e);r&&s.setAAD(r);var a=s.update(o),d=s.final();return(0,dae.concatBytes)(a,d,s.getAuthTag())},i=function(o){var s=o.subarray(0,o.length-c$.AEAD_TAG_LENGTH),a=o.subarray(-c$.AEAD_TAG_LENGTH),d=(0,uae.createDecipheriv)("aes-256-gcm",t,e);r&&d.setAAD(r),d.setAuthTag(a);var u=d.update(s),c=d.final();return(0,dae.concatBytes)(u,c)};return{tagLength:c$.AEAD_TAG_LENGTH,encrypt:n,decrypt:i}}FA.aes256gcm=LCe});var d$=H(Em=>{"use strict";h();Object.defineProperty(Em,"__esModule",{value:!0});Em.deriveKey=Em.aesDecrypt=Em.aesEncrypt=void 0;var KCe=zse(),hae=yu(),FCe=aC(),zCe=sae(),VCe=cae(),fae=ig(),zA=rE(),HCe=lae();function WCe(t,e){return pae(!0,t,e)}Em.aesEncrypt=WCe;function GCe(t,e){return pae(!1,t,e)}Em.aesDecrypt=GCe;function JCe(t){return(0,zCe.hkdf)(VCe.sha256,t,void 0,void 0,32)}Em.deriveKey=JCe;function pae(t,e,r){var n=(0,fae.symmetricAlgorithm)(),i=t?YCe:ZCe;if(n==="aes-256-gcm")return i(HCe.aes256gcm,e,r,(0,fae.symmetricNonceLength)());if(n==="xchacha20")return i(KCe.xchacha20poly1305,e,r,zA.XCHACHA20_NONCE_LENGTH);throw new Error("Not implemented")}function YCe(t,e,r,n){var i=(0,FCe.randomBytes)(n),o=t(e,i),s=o.encrypt(r),a=s.subarray(0,s.length-zA.AEAD_TAG_LENGTH),d=s.subarray(-zA.AEAD_TAG_LENGTH);return(0,hae.concatBytes)(i,d,a)}function ZCe(t,e,r,n){var i=n+zA.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,hae.concatBytes)(a,s);return d.decrypt(u)}});var vae=H(Ms=>{"use strict";h();Object.defineProperty(Ms,"__esModule",{value:!0});Ms.hexToPublicKey=Ms.convertPublicKeyFormat=Ms.getSharedPoint=Ms.getSharedKey=Ms.getPublicKey=Ms.isValidPrivateKey=Ms.getValidSecret=void 0;var XCe=yu(),QCe=aC(),mae=fse(),e$e=Mse(),u$=ig(),yae=rE(),t$e=WC(),r$e=d$();function n$e(){var t;do t=(0,QCe.randomBytes)(yae.SECRET_KEY_LENGTH);while(!gae(t));return t}Ms.getValidSecret=n$e;function gae(t){return gE(function(e){return e.utils.isValidPrivateKey(t)},function(){return!0},function(){return!0})}Ms.isValidPrivateKey=gae;function i$e(t){return gE(function(e){return e.getPublicKey(t)},function(e){return e.getPublicKey(t)},function(e){return e.getPublicKey(t)})}Ms.getPublicKey=i$e;function o$e(t,e){return(0,r$e.deriveKey)((0,XCe.concatBytes)(t,e))}Ms.getSharedKey=o$e;function s$e(t,e,r){return gE(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()})}Ms.getSharedPoint=s$e;function a$e(t,e){return gE(function(r){return r.getSharedSecret(BigInt(1),t,e)},function(){return t},function(){return t})}Ms.convertPublicKeyFormat=a$e;function c$e(t){var e=(0,t$e.decodeHex)(t);return gE(function(){if(e.length===yae.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})}Ms.hexToPublicKey=c$e;function gE(t,e,r){if((0,u$.ellipticCurve)()==="secp256k1")return t(e$e.secp256k1);if((0,u$.ellipticCurve)()==="x25519")return e(mae.x25519);if((0,u$.ellipticCurve)()==="ed25519")return r(mae.ed25519);throw new Error("Not implemented")}});var VA=H(hh=>{"use strict";h();var d$e=hh&&hh.__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]}),l$=hh&&hh.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&d$e(e,t,r)};Object.defineProperty(hh,"__esModule",{value:!0});l$(vae(),hh);l$(WC(),hh);l$(d$(),hh)});var h$=H(WA=>{"use strict";h();Object.defineProperty(WA,"__esModule",{value:!0});WA.PublicKey=void 0;var f$=yu(),u$e=ig(),HA=VA(),l$e=function(){function t(e){this.data=(0,HA.convertPublicKeyFormat)(e,!0)}return t.fromHex=function(e){return new t((0,HA.hexToPublicKey)(e))},Object.defineProperty(t.prototype,"uncompressed",{get:function(){return C.Buffer.from((0,HA.convertPublicKeyFormat)(this.data,!1))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"compressed",{get:function(){return C.Buffer.from(this.data)},enumerable:!1,configurable:!0}),t.prototype.toHex=function(e){return e===void 0&&(e=!0),e?(0,f$.bytesToHex)(this.data):(0,f$.bytesToHex)(this.uncompressed)},t.prototype.decapsulate=function(e){var r,n;return(0,u$e.isHkdfKeyCompressed)()?(r=this.data,n=e.multiply(this,!0)):(r=this.uncompressed,n=e.multiply(this,!1)),(0,HA.getSharedKey)(r,n)},t.prototype.equals=function(e){return(0,f$.equalBytes)(this.data,e.data)},t}();WA.PublicKey=l$e});var wae=H(GA=>{"use strict";h();Object.defineProperty(GA,"__esModule",{value:!0});GA.PrivateKey=void 0;var bae=yu(),f$e=ig(),Ow=VA(),h$e=h$(),p$e=function(){function t(e){var r=e===void 0?(0,Ow.getValidSecret)():e;if(!(0,Ow.isValidPrivateKey)(r))throw new Error("Invalid private key");this.data=r,this.publicKey=new h$e.PublicKey((0,Ow.getPublicKey)(r))}return t.fromHex=function(e){return new t((0,Ow.decodeHex)(e))},Object.defineProperty(t.prototype,"secret",{get:function(){return C.Buffer.from(this.data)},enumerable:!1,configurable:!0}),t.prototype.toHex=function(){return(0,bae.bytesToHex)(this.data)},t.prototype.encapsulate=function(e){var r,n;return(0,f$e.isHkdfKeyCompressed)()?(r=this.publicKey.compressed,n=this.multiply(e,!0)):(r=this.publicKey.uncompressed,n=this.multiply(e,!1)),(0,Ow.getSharedKey)(r,n)},t.prototype.multiply=function(e,r){return r===void 0&&(r=!1),(0,Ow.getSharedPoint)(this.data,e.compressed,r)},t.prototype.equals=function(e){return(0,bae.equalBytes)(this.data,e.data)},t}();GA.PrivateKey=p$e});var p$=H(Cw=>{"use strict";h();Object.defineProperty(Cw,"__esModule",{value:!0});Cw.PublicKey=Cw.PrivateKey=void 0;var m$e=wae();Object.defineProperty(Cw,"PrivateKey",{enumerable:!0,get:function(){return m$e.PrivateKey}});var y$e=h$();Object.defineProperty(Cw,"PublicKey",{enumerable:!0,get:function(){return y$e.PublicKey}})});var Eae=H($a=>{"use strict";h();Object.defineProperty($a,"__esModule",{value:!0});$a.utils=$a.PublicKey=$a.PrivateKey=$a.ECIES_CONFIG=$a.decrypt=$a.encrypt=void 0;var g$e=yu(),_ae=ig(),$w=p$(),ug=VA();function v$e(t,e){var r=new $w.PrivateKey,n=t instanceof Uint8Array?new $w.PublicKey(t):$w.PublicKey.fromHex(t),i=r.encapsulate(n),o=(0,ug.aesEncrypt)(i,e),s;return(0,_ae.isEphemeralKeyCompressed)()?s=r.publicKey.compressed:s=r.publicKey.uncompressed,C.Buffer.from((0,g$e.concatBytes)(s,o))}$a.encrypt=v$e;function b$e(t,e){var r=t instanceof Uint8Array?new $w.PrivateKey(t):$w.PrivateKey.fromHex(t),n=(0,_ae.ephemeralKeySize)(),i=new $w.PublicKey(e.subarray(0,n)),o=e.subarray(n),s=i.decapsulate(r);return C.Buffer.from((0,ug.aesDecrypt)(s,o))}$a.decrypt=b$e;var w$e=ig();Object.defineProperty($a,"ECIES_CONFIG",{enumerable:!0,get:function(){return w$e.ECIES_CONFIG}});var xae=p$();Object.defineProperty($a,"PrivateKey",{enumerable:!0,get:function(){return xae.PrivateKey}});Object.defineProperty($a,"PublicKey",{enumerable:!0,get:function(){return xae.PublicKey}});$a.utils={aesDecrypt:ug.aesDecrypt,aesEncrypt:ug.aesEncrypt,decodeHex:ug.decodeHex,getValidSecret:ug.getValidSecret,remove0x:ug.remove0x}});var Jn=H(($Et,Sae)=>{"use strict";h();Sae.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 Ds=H((jEt,y$)=>{"use strict";h();var _$e=$n(),{kResistStopPropagation:x$e,SymbolDispose:E$e}=Jn(),S$e=globalThis.AbortSignal||wf().AbortSignal,A$e=globalThis.AbortController||wf().AbortController,T$e=Object.getPrototypeOf(async function(){}).constructor,Aae=globalThis.Blob||_$e.Blob,I$e=typeof Aae<"u"?function(e){return e instanceof Aae}:function(e){return!1},Tae=(t,e)=>{if(t!==void 0&&(t===null||typeof t!="object"||!("aborted"in t)))throw new ERR_INVALID_ARG_TYPE(e,"AbortSignal",t)},P$e=(t,e)=>{if(typeof t!="function")throw new ERR_INVALID_ARG_TYPE(e,"Function",t)},m$=class extends Error{constructor(e){if(!Array.isArray(e))throw new TypeError(`Expected input to be an Array, got ${typeof e}`);let r="";for(let n=0;n<e.length;n++)r+=` ${e[n].stack}
`;super(r),this.name="AggregateError",this.errors=e}};y$.exports={AggregateError:m$,kEmptyObject:Object.freeze({}),once(t){let e=!1;return function(...r){e||(e=!0,t.apply(this,r))}},createDeferredPromise:function(){let t,e;return{promise:new Promise((n,i)=>{t=n,e=i}),resolve:t,reject:e}},promisify(t){return new Promise((e,r)=>{t((n,...i)=>n?r(n):e(...i))})},debuglog(){return function(){}},format(t,...e){return t.replace(/%([sdifj])/g,function(...[r,n]){let i=e.shift();return n==="f"?i.toFixed(6):n==="j"?JSON.stringify(i):n==="s"&&typeof i=="object"?`${i.constructor!==Object?i.constructor.name:""} {}`.trim():i.toString()})},inspect(t){switch(typeof t){case"string":if(t.includes("'"))if(t.includes('"')){if(!t.includes("`")&&!t.includes("${"))return`\`${t}\``}else return`"${t}"`;return`'${t}'`;case"number":return isNaN(t)?"NaN":Object.is(t,-0)?String(t):t;case"bigint":return`${String(t)}n`;case"boolean":case"undefined":return String(t);case"object":return"{}"}},types:{isAsyncFunction(t){return t instanceof T$e},isArrayBufferView(t){return ArrayBuffer.isView(t)}},isBlob:I$e,deprecate(t,e){return t},addAbortListener:Ja().addAbortListener||function(e,r){if(e===void 0)throw new ERR_INVALID_ARG_TYPE("signal","AbortSignal",e);Tae(e,"signal"),P$e(r,"listener");let n;return e.aborted?queueMicrotask(()=>r()):(e.addEventListener("abort",r,{__proto__:null,once:!0,[x$e]:!0}),n=()=>{e.removeEventListener("abort",r)}),{__proto__:null,[E$e](){var i;(i=n)===null||i===void 0||i()}}},AbortSignalAny:S$e.any||function(e){if(e.length===1)return e[0];let r=new A$e,n=()=>r.abort();return e.forEach(i=>{Tae(i,"signals"),i.addEventListener("abort",n,{once:!0})}),r.signal.addEventListener("abort",()=>{e.forEach(i=>i.removeEventListener("abort",n))},{once:!0}),r.signal}};y$.exports.promisify.custom=Symbol.for("nodejs.util.promisify.custom")});var sa=H((qEt,kae)=>{"use strict";h();var{format:k$e,inspect:JA,AggregateError:R$e}=Ds(),B$e=globalThis.AggregateError||R$e,M$e=Symbol("kIsNodeError"),D$e=["string","function","number","object","Function","Object","boolean","bigint","symbol"],O$e=/^([A-Z][a-z0-9]*)+$/,C$e="__node_internal_",YA={};function lg(t,e){if(!t)throw new YA.ERR_INTERNAL_ASSERTION(e)}function Iae(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 $$e(t,e,r){if(typeof e=="function")return lg(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 lg(n===r.length,`Code: ${t}; The provided arguments length (${r.length}) does not match the required ones (${n}).`),r.length===0?e:k$e(e,...r)}function Wo(t,e,r){r||(r=Error);class n extends r{constructor(...o){super($$e(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[M$e]=!0,YA[t]=n}function Pae(t){let e=C$e+t.name;return Object.defineProperty(t,"name",{value:e}),t}function N$e(t,e){if(t&&e&&t!==e){if(Array.isArray(e.errors))return e.errors.push(t),e;let r=new B$e([e,t],e.message);return r.code=e.code,r}return t||e}var g$=class extends Error{constructor(e="The operation was aborted",r=void 0){if(r!==void 0&&typeof r!="object")throw new YA.ERR_INVALID_ARG_TYPE("options","Object",r);super(e,r),this.code="ABORT_ERR",this.name="AbortError"}};Wo("ERR_ASSERTION","%s",Error);Wo("ERR_INVALID_ARG_TYPE",(t,e,r)=>{lg(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)lg(typeof d=="string","All expected entries have to be of type string"),D$e.includes(d)?i.push(d.toLowerCase()):O$e.test(d)?o.push(d):(lg(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=JA(r,{depth:-1});n+=`. Received ${d}`}}else{let d=JA(r,{colors:!1});d.length>25&&(d=`${d.slice(0,25)}...`),n+=`. Received type ${typeof r} (${d})`}return n},TypeError);Wo("ERR_INVALID_ARG_VALUE",(t,e,r="is invalid")=>{let n=JA(e);return n.length>128&&(n=n.slice(0,128)+"..."),`The ${t.includes(".")?"property":"argument"} '${t}' ${r}. Received ${n}`},TypeError);Wo("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);Wo("ERR_MISSING_ARGS",(...t)=>{lg(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);Wo("ERR_OUT_OF_RANGE",(t,e,r)=>{lg(e,'Missing "range" argument');let n;return Number.isInteger(r)&&Math.abs(r)>2**32?n=Iae(String(r)):typeof r=="bigint"?(n=String(r),(r>2n**32n||r<-(2n**32n))&&(n=Iae(n)),n+="n"):n=JA(r),`The value of "${t}" is out of range. It must be ${e}. Received ${n}`},RangeError);Wo("ERR_MULTIPLE_CALLBACK","Callback called multiple times",Error);Wo("ERR_METHOD_NOT_IMPLEMENTED","The %s method is not implemented",Error);Wo("ERR_STREAM_ALREADY_FINISHED","Cannot call %s after a stream was finished",Error);Wo("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable",Error);Wo("ERR_STREAM_DESTROYED","Cannot call %s after a stream was destroyed",Error);Wo("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError);Wo("ERR_STREAM_PREMATURE_CLOSE","Premature close",Error);Wo("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF",Error);Wo("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event",Error);Wo("ERR_STREAM_WRITE_AFTER_END","write after end",Error);Wo("ERR_UNKNOWN_ENCODING","Unknown encoding: %s",TypeError);kae.exports={AbortError:g$,aggregateTwoErrors:Pae(N$e),hideStackFrames:Pae,codes:YA}});var jw=H((KEt,Uae)=>{"use strict";h();var{ArrayIsArray:b$,ArrayPrototypeIncludes:Dae,ArrayPrototypeJoin:Oae,ArrayPrototypeMap:j$e,NumberIsInteger:w$,NumberIsNaN:U$e,NumberMAX_SAFE_INTEGER:q$e,NumberMIN_SAFE_INTEGER:L$e,NumberParseInt:K$e,ObjectPrototypeHasOwnProperty:F$e,RegExpPrototypeExec:Cae,String:z$e,StringPrototypeToUpperCase:V$e,StringPrototypeTrim:H$e}=Jn(),{hideStackFrames:xd,codes:{ERR_SOCKET_BAD_PORT:W$e,ERR_INVALID_ARG_TYPE:Os,ERR_INVALID_ARG_VALUE:Nw,ERR_OUT_OF_RANGE:fg,ERR_UNKNOWN_SIGNAL:Rae}}=sa(),{normalizeEncoding:G$e}=Ds(),{isAsyncFunction:J$e,isArrayBufferView:Y$e}=Ds().types,Bae={};function Z$e(t){return t===(t|0)}function X$e(t){return t===t>>>0}var Q$e=/^[0-7]+$/,eNe="must be a 32-bit unsigned integer or an octal string";function tNe(t,e,r){if(typeof t>"u"&&(t=r),typeof t=="string"){if(Cae(Q$e,t)===null)throw new Nw(e,t,eNe);t=K$e(t,8)}return $ae(t,e),t}var rNe=xd((t,e,r=L$e,n=q$e)=>{if(typeof t!="number")throw new Os(e,"number",t);if(!w$(t))throw new fg(e,"an integer",t);if(t<r||t>n)throw new fg(e,`>= ${r} && <= ${n}`,t)}),nNe=xd((t,e,r=-2147483648,n=2147483647)=>{if(typeof t!="number")throw new Os(e,"number",t);if(!w$(t))throw new fg(e,"an integer",t);if(t<r||t>n)throw new fg(e,`>= ${r} && <= ${n}`,t)}),$ae=xd((t,e,r=!1)=>{if(typeof t!="number")throw new Os(e,"number",t);if(!w$(t))throw new fg(e,"an integer",t);let n=r?1:0,i=4294967295;if(t<n||t>i)throw new fg(e,`>= ${n} && <= ${i}`,t)});function _$(t,e){if(typeof t!="string")throw new Os(e,"string",t)}function iNe(t,e,r=void 0,n){if(typeof t!="number")throw new Os(e,"number",t);if(r!=null&&t<r||n!=null&&t>n||(r!=null||n!=null)&&U$e(t))throw new fg(e,`${r!=null?`>= ${r}`:""}${r!=null&&n!=null?" && ":""}${n!=null?`<= ${n}`:""}`,t)}var oNe=xd((t,e,r)=>{if(!Dae(r,t)){let i="must be one of: "+Oae(j$e(r,o=>typeof o=="string"?`'${o}'`:z$e(o)),", ");throw new Nw(e,t,i)}});function Nae(t,e){if(typeof t!="boolean")throw new Os(e,"boolean",t)}function v$(t,e,r){return t==null||!F$e(t,e)?r:t[e]}var sNe=xd((t,e,r=null)=>{let n=v$(r,"allowArray",!1),i=v$(r,"allowFunction",!1);if(!v$(r,"nullable",!1)&&t===null||!n&&b$(t)||typeof t!="object"&&(!i||typeof t!="function"))throw new Os(e,"Object",t)}),aNe=xd((t,e)=>{if(t!=null&&typeof t!="object"&&typeof t!="function")throw new Os(e,"a dictionary",t)}),ZA=xd((t,e,r=0)=>{if(!b$(t))throw new Os(e,"Array",t);if(t.length<r){let n=`must be longer than ${r}`;throw new Nw(e,t,n)}});function cNe(t,e){ZA(t,e);for(let r=0;r<t.length;r++)_$(t[r],`${e}[${r}]`)}function dNe(t,e){ZA(t,e);for(let r=0;r<t.length;r++)Nae(t[r],`${e}[${r}]`)}function uNe(t,e){ZA(t,e);for(let r=0;r<t.length;r++){let n=t[r],i=`${e}[${r}]`;if(n==null)throw new Os(i,"AbortSignal",n);jae(n,i)}}function lNe(t,e="signal"){if(_$(t,e),Bae[t]===void 0)throw Bae[V$e(t)]!==void 0?new Rae(t+" (signals must use all capital letters)"):new Rae(t)}var fNe=xd((t,e="buffer")=>{if(!Y$e(t))throw new Os(e,["Buffer","TypedArray","DataView"],t)});function hNe(t,e){let r=G$e(e),n=t.length;if(r==="hex"&&n%2!==0)throw new Nw("encoding",e,`is invalid for data of length ${n}`)}function pNe(t,e="Port",r=!0){if(typeof t!="number"&&typeof t!="string"||typeof t=="string"&&H$e(t).length===0||+t!==+t>>>0||t>65535||t===0&&!r)throw new W$e(e,t,r);return t|0}var jae=xd((t,e)=>{if(t!==void 0&&(t===null||typeof t!="object"||!("aborted"in t)))throw new Os(e,"AbortSignal",t)}),mNe=xd((t,e)=>{if(typeof t!="function")throw new Os(e,"Function",t)}),yNe=xd((t,e)=>{if(typeof t!="function"||J$e(t))throw new Os(e,"Function",t)}),gNe=xd((t,e)=>{if(t!==void 0)throw new Os(e,"undefined",t)});function vNe(t,e,r){if(!Dae(r,t))throw new Os(e,`('${Oae(r,"|")}')`,t)}var bNe=/^(?:<[^>]*>)(?:\s*;\s*[^;"\s]+(?:=(")?[^;"\s]*\1)?)*$/;function Mae(t,e){if(typeof t>"u"||!Cae(bNe,t))throw new Nw(e,t,'must be an array or string of format "</styles.css>; rel=preload; as=style"')}function wNe(t){if(typeof t=="string")return Mae(t,"hints"),t;if(b$(t)){let e=t.length,r="";if(e===0)return r;for(let n=0;n<e;n++){let i=t[n];Mae(i,"hints"),r+=i,n!==e-1&&(r+=", ")}return r}throw new Nw("hints",t,'must be an array or string of format "</styles.css>; rel=preload; as=style"')}Uae.exports={isInt32:Z$e,isUint32:X$e,parseFileMode:tNe,validateArray:ZA,validateStringArray:cNe,validateBooleanArray:dNe,validateAbortSignalArray:uNe,validateBoolean:Nae,validateBuffer:fNe,validateDictionary:aNe,validateEncoding:hNe,validateFunction:mNe,validateInt32:nNe,validateInteger:rNe,validateNumber:iNe,validateObject:sNe,validateOneOf:oNe,validatePlainFunction:yNe,validatePort:pNe,validateSignalName:lNe,validateString:_$,validateUint32:$ae,validateUndefined:gNe,validateUnion:vNe,validateAbortSignal:jae,validateLinkHeaderValue:wNe}});var $l=H((zEt,ece)=>{"use strict";h();var{SymbolAsyncIterator:qae,SymbolIterator:Lae,SymbolFor:hg}=Jn(),Kae=hg("nodejs.stream.destroyed"),Fae=hg("nodejs.stream.errored"),x$=hg("nodejs.stream.readable"),E$=hg("nodejs.stream.writable"),zae=hg("nodejs.stream.disturbed"),_Ne=hg("nodejs.webstream.isClosedPromise"),xNe=hg("nodejs.webstream.controllerErrorFunction");function XA(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 QA(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 ENe(t){return!!(t&&typeof t.pipe=="function"&&t._readableState&&typeof t.on=="function"&&typeof t.write=="function")}function Cl(t){return t&&(t._readableState||t._writableState||typeof t.write=="function"&&typeof t.on=="function"||typeof t.pipe=="function"&&typeof t.on=="function")}function Vae(t){return!!(t&&!Cl(t)&&typeof t.pipeThrough=="function"&&typeof t.getReader=="function"&&typeof t.cancel=="function")}function Hae(t){return!!(t&&!Cl(t)&&typeof t.getWriter=="function"&&typeof t.abort=="function")}function Wae(t){return!!(t&&!Cl(t)&&typeof t.readable=="object"&&typeof t.writable=="object")}function SNe(t){return Vae(t)||Hae(t)||Wae(t)}function ANe(t,e){return t==null?!1:e===!0?typeof t[qae]=="function":e===!1?typeof t[Lae]=="function":typeof t[qae]=="function"||typeof t[Lae]=="function"}function eT(t){if(!Cl(t))return null;let e=t._writableState,r=t._readableState,n=e||r;return!!(t.destroyed||t[Kae]||n!=null&&n.destroyed)}function Gae(t){if(!QA(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 TNe(t,e){if(!QA(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 INe(t){if(!XA(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 Jae(t,e){if(!XA(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 Yae(t){return t&&t[x$]!=null?t[x$]:typeof t?.readable!="boolean"?null:eT(t)?!1:XA(t)&&t.readable&&!Jae(t)}function Zae(t){return t&&t[E$]!=null?t[E$]:typeof t?.writable!="boolean"?null:eT(t)?!1:QA(t)&&t.writable&&!Gae(t)}function PNe(t,e){return Cl(t)?eT(t)?!0:!(e?.readable!==!1&&Yae(t)||e?.writable!==!1&&Zae(t)):null}function kNe(t){var e,r;return Cl(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 RNe(t){var e,r;return Cl(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 BNe(t){if(!Cl(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"&&Xae(t)?t._closed:null}function Xae(t){return typeof t._closed=="boolean"&&typeof t._defaultKeepAlive=="boolean"&&typeof t._removedConnection=="boolean"&&typeof t._removedContLen=="boolean"}function Qae(t){return typeof t._sent100=="boolean"&&Xae(t)}function MNe(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 DNe(t){if(!Cl(t))return null;let e=t._writableState,r=t._readableState,n=e||r;return!n&&Qae(t)||!!(n&&n.autoDestroy&&n.emitClose&&n.closed===!1)}function ONe(t){var e;return!!(t&&((e=t[zae])!==null&&e!==void 0?e:t.readableDidRead||t.readableAborted))}function CNe(t){var e,r,n,i,o,s,a,d,u,c;return!!(t&&((e=(r=(n=(i=(o=(s=t[Fae])!==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))}ece.exports={isDestroyed:eT,kIsDestroyed:Kae,isDisturbed:ONe,kIsDisturbed:zae,isErrored:CNe,kIsErrored:Fae,isReadable:Yae,kIsReadable:x$,kIsClosedPromise:_Ne,kControllerErrorFunction:xNe,kIsWritable:E$,isClosed:BNe,isDuplexNodeStream:ENe,isFinished:PNe,isIterable:ANe,isReadableNodeStream:XA,isReadableStream:Vae,isReadableEnded:INe,isReadableFinished:Jae,isReadableErrored:RNe,isNodeStream:Cl,isWebStream:SNe,isWritable:Zae,isWritableNodeStream:QA,isWritableStream:Hae,isWritableEnded:Gae,isWritableFinished:TNe,isWritableErrored:kNe,isServerRequest:MNe,isServerResponse:Qae,willEmitClose:DNe,isTransformStream:Wae}});var ph=H((HEt,P$)=>{h();var Sm=fs(),{AbortError:dce,codes:$Ne}=sa(),{ERR_INVALID_ARG_TYPE:NNe,ERR_STREAM_PREMATURE_CLOSE:tce}=$Ne,{kEmptyObject:A$,once:T$}=Ds(),{validateAbortSignal:jNe,validateFunction:UNe,validateObject:qNe,validateBoolean:LNe}=jw(),{Promise:KNe,PromisePrototypeThen:FNe,SymbolDispose:uce}=Jn(),{isClosed:zNe,isReadable:rce,isReadableNodeStream:S$,isReadableStream:VNe,isReadableFinished:nce,isReadableErrored:ice,isWritable:oce,isWritableNodeStream:sce,isWritableStream:HNe,isWritableFinished:ace,isWritableErrored:cce,isNodeStream:WNe,willEmitClose:GNe,kIsClosedPromise:JNe}=$l(),Uw;function YNe(t){return t.setHeader&&typeof t.abort=="function"}var I$=()=>{};function lce(t,e,r){var n,i;if(arguments.length===2?(r=e,e=A$):e==null?e=A$:qNe(e,"options"),UNe(r,"callback"),jNe(e.signal,"options.signal"),r=T$(r),VNe(t)||HNe(t))return ZNe(t,e,r);if(!WNe(t))throw new NNe("stream",["ReadableStream","WritableStream","Stream"],t);let o=(n=e.readable)!==null&&n!==void 0?n:S$(t),s=(i=e.writable)!==null&&i!==void 0?i:sce(t),a=t._writableState,d=t._readableState,u=()=>{t.writable||m()},c=GNe(t)&&S$(t)===o&&sce(t)===s,l=ace(t,!1),m=()=>{l=!0,t.destroyed&&(c=!1),!(c&&(!t.readable||o))&&(!o||p)&&r.call(t)},p=nce(t,!1),g=()=>{p=!0,t.destroyed&&(c=!1),!(c&&(!t.writable||s))&&(!s||l)&&r.call(t)},v=N=>{r.call(t,N)},E=zNe(t),A=()=>{E=!0;let N=cce(t)||ice(t);if(N&&typeof N!="boolean")return r.call(t,N);if(o&&!p&&S$(t,!0)&&!nce(t,!1))return r.call(t,new tce);if(s&&!l&&!ace(t,!1))return r.call(t,new tce);r.call(t)},P=()=>{E=!0;let N=cce(t)||ice(t);if(N&&typeof N!="boolean")return r.call(t,N);r.call(t)},I=()=>{t.req.on("finish",m)};YNe(t)?(t.on("complete",m),c||t.on("abort",A),t.req?I():t.on("request",I)):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",v),t.on("close",A),E?Sm.nextTick(A):a!=null&&a.errorEmitted||d!=null&&d.errorEmitted?c||Sm.nextTick(P):(!o&&(!c||rce(t))&&(l||oce(t)===!1)||!s&&(!c||oce(t))&&(p||rce(t)===!1)||d&&t.req&&t.aborted)&&Sm.nextTick(P);let $=()=>{r=I$,t.removeListener("aborted",A),t.removeListener("complete",m),t.removeListener("abort",A),t.removeListener("request",I),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",v),t.removeListener("close",A)};if(e.signal&&!E){let N=()=>{let K=r;$(),K.call(t,new dce(void 0,{cause:e.signal.reason}))};if(e.signal.aborted)Sm.nextTick(N);else{Uw=Uw||Ds().addAbortListener;let K=Uw(e.signal,N),F=r;r=T$((...U)=>{K[uce](),F.apply(t,U)})}}return $}function ZNe(t,e,r){let n=!1,i=I$;if(e.signal)if(i=()=>{n=!0,r.call(t,new dce(void 0,{cause:e.signal.reason}))},e.signal.aborted)Sm.nextTick(i);else{Uw=Uw||Ds().addAbortListener;let s=Uw(e.signal,i),a=r;r=T$((...d)=>{s[uce](),a.apply(t,d)})}let o=(...s)=>{n||Sm.nextTick(()=>r.apply(t,s))};return FNe(t[JNe].promise,o,o),I$}function XNe(t,e){var r;let n=!1;return e===null&&(e=A$),(r=e)!==null&&r!==void 0&&r.cleanup&&(LNe(e.cleanup,"cleanup"),n=e.cleanup),new KNe((i,o)=>{let s=lce(t,e,a=>{n&&s(),a?o(a):i()})})}P$.exports=lce;P$.exports.finished=XNe});var pg=H((GEt,bce)=>{"use strict";h();var Nl=fs(),{aggregateTwoErrors:QNe,codes:{ERR_MULTIPLE_CALLBACK:eje},AbortError:tje}=sa(),{Symbol:pce}=Jn(),{kIsDestroyed:rje,isDestroyed:nje,isFinished:ije,isServerRequest:oje}=$l(),mce=pce("kDestroy"),k$=pce("kConstruct");function yce(t,e,r){t&&(t.stack,e&&!e.errored&&(e.errored=t),r&&!r.errored&&(r.errored=t))}function sje(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):(yce(t,n,r),n&&(n.destroyed=!0),r&&(r.destroyed=!0),i.constructed?fce(this,t,e):this.once(mce,function(o){fce(this,QNe(o,t),e)}),this)}function fce(t,e,r){let n=!1;function i(o){if(n)return;n=!0;let s=t._readableState,a=t._writableState;yce(o,a,s),a&&(a.closed=!0),s&&(s.closed=!0),typeof r=="function"&&r(o),o?Nl.nextTick(aje,t,o):Nl.nextTick(gce,t)}try{t._destroy(e||null,i)}catch(o){i(o)}}function aje(t,e){R$(t,e),gce(t)}function gce(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 R$(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 cje(){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 B$(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?Nl.nextTick(R$,t,e):R$(t,e))}function dje(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(k$,e),!(t.listenerCount(k$)>1)&&Nl.nextTick(uje,t)}function uje(t){let e=!1;function r(n){if(e){B$(t,n??new eje);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(mce,n):n?B$(t,n,!0):Nl.nextTick(lje,t)}try{t._construct(n=>{Nl.nextTick(r,n)})}catch(n){Nl.nextTick(r,n)}}function lje(t){t.emit(k$)}function hce(t){return t?.setHeader&&typeof t.abort=="function"}function vce(t){t.emit("close")}function fje(t,e){t.emit("error",e),Nl.nextTick(vce,t)}function hje(t,e){!t||nje(t)||(!e&&!ije(t)&&(e=new tje),oje(t)?(t.socket=null,t.destroy(e)):hce(t)?t.abort():hce(t.req)?t.req.abort():typeof t.destroy=="function"?t.destroy(e):typeof t.close=="function"?t.close():e?Nl.nextTick(fje,t,e):Nl.nextTick(vce,t),t.destroyed||(t[rje]=!0))}bce.exports={construct:dje,destroyer:hje,destroy:sje,undestroy:cje,errorOrDestroy:B$}});var nT=H((YEt,_ce)=>{"use strict";h();var{ArrayIsArray:pje,ObjectSetPrototypeOf:wce}=Jn(),{EventEmitter:tT}=Ja();function rT(t){tT.call(this,t)}wce(rT.prototype,tT.prototype);wce(rT,tT);rT.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(),tT.listenerCount(this,"error")===0&&this.emit("error",c)}M$(r,"error",d),M$(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 M$(t,e,r){if(typeof t.prependListener=="function")return t.prependListener(e,r);!t._events||!t._events[e]?t.on(e,r):pje(t._events[e])?t._events[e].unshift(r):t._events[e]=[r,t._events[e]]}_ce.exports={Stream:rT,prependListener:M$}});var vE=H((XEt,iT)=>{"use strict";h();var{SymbolDispose:mje}=Jn(),{AbortError:xce,codes:yje}=sa(),{isNodeStream:Ece,isWebStream:gje,kControllerErrorFunction:vje}=$l(),bje=ph(),{ERR_INVALID_ARG_TYPE:Sce}=yje,D$,wje=(t,e)=>{if(typeof t!="object"||!("aborted"in t))throw new Sce(e,"AbortSignal",t)};iT.exports.addAbortSignal=function(e,r){if(wje(e,"signal"),!Ece(r)&&!gje(r))throw new Sce("stream",["ReadableStream","WritableStream","Stream"],r);return iT.exports.addAbortSignalNoValidate(e,r)};iT.exports.addAbortSignalNoValidate=function(t,e){if(typeof t!="object"||!("aborted"in t))return e;let r=Ece(e)?()=>{e.destroy(new xce(void 0,{cause:t.reason}))}:()=>{e[vje](new xce(void 0,{cause:t.reason}))};if(t.aborted)r();else{D$=D$||Ds().addAbortListener;let n=D$(t,r);bje(e,n[mje])}return e}});var Ice=H((t6t,Tce)=>{"use strict";h();var{StringPrototypeSlice:Ace,SymbolIterator:_je,TypedArrayPrototypeSet:oT,Uint8Array:xje}=Jn(),{Buffer:O$}=$n(),{inspect:Eje}=Ds();Tce.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 O$.alloc(0);let r=O$.allocUnsafe(e>>>0),n=this.head,i=0;for(;n;)oT(r,n.data,i),i+=n.data.length,n=n.next;return r}consume(e,r){let n=this.head.data;if(e<n.length){let i=n.slice(0,e);return this.head.data=n.slice(e),i}return e===n.length?this.shift():r?this._getString(e):this._getBuffer(e)}first(){return this.head.data}*[_je](){for(let e=this.head;e;e=e.next)yield e.data}_getString(e){let r="",n=this.head,i=0;do{let o=n.data;if(e>o.length)r+=o,e-=o.length;else{e===o.length?(r+=o,++i,n.next?this.head=n.next:this.head=this.tail=null):(r+=Ace(o,0,e),this.head=n,n.data=Ace(o,e));break}++i}while((n=n.next)!==null);return this.length-=i,r}_getBuffer(e){let r=O$.allocUnsafe(e),n=e,i=this.head,o=0;do{let s=i.data;if(e>s.length)oT(r,s,n-e),e-=s.length;else{e===s.length?(oT(r,s,n-e),++o,i.next?this.head=i.next:this.head=this.tail=null):(oT(r,new xje(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 Eje(this,{...r,depth:0,customInspect:!1})}}});var bE=H((n6t,Bce)=>{"use strict";h();var{MathFloor:Sje,NumberIsInteger:Aje}=Jn(),{validateInteger:Tje}=jw(),{ERR_INVALID_ARG_VALUE:Ije}=sa().codes,Pce=16*1024,kce=16;function Pje(t,e,r){return t.highWaterMark!=null?t.highWaterMark:e?t[r]:null}function Rce(t){return t?kce:Pce}function kje(t,e){Tje(e,"value",0),t?kce=e:Pce=e}function Rje(t,e,r,n){let i=Pje(e,n,r);if(i!=null){if(!Aje(i)||i<0){let o=n?`options.${r}`:"options.highWaterMark";throw new Ije(o,i)}return Sje(i)}return Rce(t.objectMode)}Bce.exports={getHighWaterMark:Rje,getDefaultHighWaterMark:Rce,setDefaultHighWaterMark:kje}});var C$=H((o6t,Cce)=>{"use strict";h();var Mce=fs(),{PromisePrototypeThen:Bje,SymbolAsyncIterator:Dce,SymbolIterator:Oce}=Jn(),{Buffer:Mje}=$n(),{ERR_INVALID_ARG_TYPE:Dje,ERR_STREAM_NULL_VALUES:Oje}=sa().codes;function Cje(t,e,r){let n;if(typeof e=="string"||e instanceof Mje)return new t({objectMode:!0,...r,read(){this.push(e),this.push(null)}});let i;if(e&&e[Dce])i=!0,n=e[Dce]();else if(e&&e[Oce])i=!1,n=e[Oce]();else throw new Dje("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){Bje(a(u),()=>Mce.nextTick(c,u),l=>Mce.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 Oje;if(o.push(l))continue;s=!1}}catch(u){o.destroy(u)}break}}return o}Cce.exports=Cje});var _E=H((a6t,Qce)=>{h();var xu=fs(),{ArrayPrototypeIndexOf:$je,NumberIsInteger:Nje,NumberIsNaN:jje,NumberParseInt:Uje,ObjectDefineProperties:F$,ObjectKeys:qje,ObjectSetPrototypeOf:jce,Promise:Uce,SafeSet:Lje,SymbolAsyncDispose:Kje,SymbolAsyncIterator:Fje,Symbol:zje}=Jn();Qce.exports=mr;mr.ReadableState=dT;var{EventEmitter:Vje}=Ja(),{Stream:Am,prependListener:Hje}=nT(),{Buffer:$$}=$n(),{addAbortSignal:Wje}=vE(),qce=ph(),Or=Ds().debuglog("stream",t=>{Or=t}),Gje=Ice(),Kw=pg(),{getHighWaterMark:Jje,getDefaultHighWaterMark:Yje}=bE(),{aggregateTwoErrors:$ce,codes:{ERR_INVALID_ARG_TYPE:Zje,ERR_METHOD_NOT_IMPLEMENTED:Xje,ERR_OUT_OF_RANGE:Qje,ERR_STREAM_PUSH_AFTER_EOF:eUe,ERR_STREAM_UNSHIFT_AFTER_END_EVENT:tUe},AbortError:rUe}=sa(),{validateObject:nUe}=jw(),mg=zje("kPaused"),{StringDecoder:Lce}=Uv(),iUe=C$();jce(mr.prototype,Am.prototype);jce(mr,Am);var N$=()=>{},{errorOrDestroy:qw}=Kw,Lw=1,oUe=2,Kce=4,wE=8,Fce=16,sT=32,aT=64,zce=128,sUe=256,aUe=512,cUe=1024,L$=2048,K$=4096,dUe=8192,uUe=16384,lUe=32768,Vce=65536,fUe=1<<17,hUe=1<<18;function Zi(t){return{enumerable:!1,get(){return(this.state&t)!==0},set(e){e?this.state|=t:this.state&=~t}}}F$(dT.prototype,{objectMode:Zi(Lw),ended:Zi(oUe),endEmitted:Zi(Kce),reading:Zi(wE),constructed:Zi(Fce),sync:Zi(sT),needReadable:Zi(aT),emittedReadable:Zi(zce),readableListening:Zi(sUe),resumeScheduled:Zi(aUe),errorEmitted:Zi(cUe),emitClose:Zi(L$),autoDestroy:Zi(K$),destroyed:Zi(dUe),closed:Zi(uUe),closeEmitted:Zi(lUe),multiAwaitDrain:Zi(Vce),readingMore:Zi(fUe),dataEmitted:Zi(hUe)});function dT(t,e,r){typeof r!="boolean"&&(r=e instanceof jl()),this.state=L$|K$|Fce|sT,t&&t.objectMode&&(this.state|=Lw),r&&t&&t.readableObjectMode&&(this.state|=Lw),this.highWaterMark=t?Jje(this,t,"readableHighWaterMark",r):Yje(!1),this.buffer=new Gje,this.length=0,this.pipes=[],this.flowing=null,this[mg]=null,t&&t.emitClose===!1&&(this.state&=~L$),t&&t.autoDestroy===!1&&(this.state&=~K$),this.errored=null,this.defaultEncoding=t&&t.defaultEncoding||"utf8",this.awaitDrainWriters=null,this.decoder=null,this.encoding=null,t&&t.encoding&&(this.decoder=new Lce(t.encoding),this.encoding=t.encoding)}function mr(t){if(!(this instanceof mr))return new mr(t);let e=this instanceof jl();this._readableState=new dT(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&&Wje(t.signal,this)),Am.call(this,t),Kw.construct(this,()=>{this._readableState.needReadable&&cT(this,this._readableState)})}mr.prototype.destroy=Kw.destroy;mr.prototype._undestroy=Kw.undestroy;mr.prototype._destroy=function(t,e){e(t)};mr.prototype[Vje.captureRejectionSymbol]=function(t){this.destroy(t)};mr.prototype[Kje]=function(){let t;return this.destroyed||(t=this.readableEnded?null:new rUe,this.destroy(t)),new Uce((e,r)=>qce(this,n=>n&&n!==t?r(n):e(null)))};mr.prototype.push=function(t,e){return Hce(this,t,e,!1)};mr.prototype.unshift=function(t,e){return Hce(this,t,e,!0)};function Hce(t,e,r,n){Or("readableAddChunk",e);let i=t._readableState,o;if(i.state&Lw||(typeof e=="string"?(r=r||i.defaultEncoding,i.encoding!==r&&(n&&i.encoding?e=$$.from(e,r).toString(i.encoding):(e=$$.from(e,r),r=""))):e instanceof $$?r="":Am._isUint8Array(e)?(e=Am._uint8ArrayToBuffer(e),r=""):e!=null&&(o=new Zje("chunk",["string","Buffer","Uint8Array"],e))),o)qw(t,o);else if(e===null)i.state&=~wE,yUe(t,i);else if(i.state&Lw||e&&e.length>0)if(n)if(i.state&Kce)qw(t,new tUe);else{if(i.destroyed||i.errored)return!1;j$(t,i,e,!0)}else if(i.ended)qw(t,new eUe);else{if(i.destroyed||i.errored)return!1;i.state&=~wE,i.decoder&&!r?(e=i.decoder.write(e),i.objectMode||e.length!==0?j$(t,i,e,!1):cT(t,i)):j$(t,i,e,!1)}else n||(i.state&=~wE,cT(t,i));return!i.ended&&(i.length<i.highWaterMark||i.length===0)}function j$(t,e,r,n){e.flowing&&e.length===0&&!e.sync&&t.listenerCount("data")>0?(e.state&Vce?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&aT&&uT(t)),cT(t,e)}mr.prototype.isPaused=function(){let t=this._readableState;return t[mg]===!0||t.flowing===!1};mr.prototype.setEncoding=function(t){let e=new Lce(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 pUe=1073741824;function mUe(t){if(t>pUe)throw new Qje("size","<= 1GiB",t);return t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++,t}function Nce(t,e){return t<=0||e.length===0&&e.ended?0:e.state&Lw?1:jje(t)?e.flowing&&e.length?e.buffer.first().length:e.length:t<=e.length?t:e.ended?e.length:0}mr.prototype.read=function(t){Or("read",t),t===void 0?t=NaN:Nje(t)||(t=Uje(t,10));let e=this._readableState,r=t;if(t>e.highWaterMark&&(e.highWaterMark=mUe(t)),t!==0&&(e.state&=~zce),t===0&&e.needReadable&&((e.highWaterMark!==0?e.length>=e.highWaterMark:e.length>0)||e.ended))return Or("read: emitReadable",e.length,e.ended),e.length===0&&e.ended?U$(this):uT(this),null;if(t=Nce(t,e),t===0&&e.ended)return e.length===0&&U$(this),null;let n=(e.state&aT)!==0;if(Or("need readable",n),(e.length===0||e.length-t<e.highWaterMark)&&(n=!0,Or("length less than watermark",n)),e.ended||e.reading||e.destroyed||e.errored||!e.constructed)n=!1,Or("reading, ended or constructing",n);else if(n){Or("do read"),e.state|=wE|sT,e.length===0&&(e.state|=aT);try{this._read(e.highWaterMark)}catch(o){qw(this,o)}e.state&=~sT,e.reading||(t=Nce(r,e))}let i;return t>0?i=Zce(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&&U$(this)),i!==null&&!e.errorEmitted&&!e.closeEmitted&&(e.dataEmitted=!0,this.emit("data",i)),i};function yUe(t,e){if(Or("onEofChunk"),!e.ended){if(e.decoder){let r=e.decoder.end();r&&r.length&&(e.buffer.push(r),e.length+=e.objectMode?1:r.length)}e.ended=!0,e.sync?uT(t):(e.needReadable=!1,e.emittedReadable=!0,Wce(t))}}function uT(t){let e=t._readableState;Or("emitReadable",e.needReadable,e.emittedReadable),e.needReadable=!1,e.emittedReadable||(Or("emitReadable",e.flowing),e.emittedReadable=!0,xu.nextTick(Wce,t))}function Wce(t){let e=t._readableState;Or("emitReadable_",e.destroyed,e.length,e.ended),!e.destroyed&&!e.errored&&(e.length||e.ended)&&(t.emit("readable"),e.emittedReadable=!1),e.needReadable=!e.flowing&&!e.ended&&e.length<=e.highWaterMark,Jce(t)}function cT(t,e){!e.readingMore&&e.constructed&&(e.readingMore=!0,xu.nextTick(gUe,t,e))}function gUe(t,e){for(;!e.reading&&!e.ended&&(e.length<e.highWaterMark||e.flowing&&e.length===0);){let r=e.length;if(Or("maybeReadMore read 0"),t.read(0),r===e.length)break}e.readingMore=!1}mr.prototype._read=function(t){throw new Xje("_read()")};mr.prototype.pipe=function(t,e){let r=this,n=this._readableState;n.pipes.length===1&&(n.multiAwaitDrain||(n.multiAwaitDrain=!0,n.awaitDrainWriters=new Lje(n.awaitDrainWriters?[n.awaitDrainWriters]:[]))),n.pipes.push(t),Or("pipe count=%d opts=%j",n.pipes.length,e);let o=(!e||e.end!==!1)&&t!==xu.stdout&&t!==xu.stderr?a:E;n.endEmitted?xu.nextTick(o):r.once("end",o),t.on("unpipe",s);function s(A,P){Or("onunpipe"),A===r&&P&&P.hasUnpiped===!1&&(P.hasUnpiped=!0,c())}function a(){Or("onend"),t.end()}let d,u=!1;function c(){Or("cleanup"),t.removeListener("close",g),t.removeListener("finish",v),d&&t.removeListener("drain",d),t.removeListener("error",p),t.removeListener("unpipe",s),r.removeListener("end",a),r.removeListener("end",E),r.removeListener("data",m),u=!0,d&&n.awaitDrainWriters&&(!t._writableState||t._writableState.needDrain)&&d()}function l(){u||(n.pipes.length===1&&n.pipes[0]===t?(Or("false write response, pause",0),n.awaitDrainWriters=t,n.multiAwaitDrain=!1):n.pipes.length>1&&n.pipes.includes(t)&&(Or("false write response, pause",n.awaitDrainWriters.size),n.awaitDrainWriters.add(t)),r.pause()),d||(d=vUe(r,t),t.on("drain",d))}r.on("data",m);function m(A){Or("ondata");let P=t.write(A);Or("dest.write",P),P===!1&&l()}function p(A){if(Or("onerror",A),E(),t.removeListener("error",p),t.listenerCount("error")===0){let P=t._writableState||t._readableState;P&&!P.errorEmitted?qw(t,A):t.emit("error",A)}}Hje(t,"error",p);function g(){t.removeListener("finish",v),E()}t.once("close",g);function v(){Or("onfinish"),t.removeListener("close",g),E()}t.once("finish",v);function E(){Or("unpipe"),r.unpipe(t)}return t.emit("pipe",r),t.writableNeedDrain===!0?l():n.flowing||(Or("pipe resume"),r.resume()),t};function vUe(t,e){return function(){let n=t._readableState;n.awaitDrainWriters===e?(Or("pipeOnDrain",1),n.awaitDrainWriters=null):n.multiAwaitDrain&&(Or("pipeOnDrain",n.awaitDrainWriters.size),n.awaitDrainWriters.delete(e)),(!n.awaitDrainWriters||n.awaitDrainWriters.size===0)&&t.listenerCount("data")&&t.resume()}}mr.prototype.unpipe=function(t){let e=this._readableState,r={hasUnpiped:!1};if(e.pipes.length===0)return this;if(!t){let i=e.pipes;e.pipes=[],this.pause();for(let o=0;o<i.length;o++)i[o].emit("unpipe",this,{hasUnpiped:!1});return this}let n=$je(e.pipes,t);return n===-1?this:(e.pipes.splice(n,1),e.pipes.length===0&&this.pause(),t.emit("unpipe",this,r),this)};mr.prototype.on=function(t,e){let r=Am.prototype.on.call(this,t,e),n=this._readableState;return t==="data"?(n.readableListening=this.listenerCount("readable")>0,n.flowing!==!1&&this.resume()):t==="readable"&&!n.endEmitted&&!n.readableListening&&(n.readableListening=n.needReadable=!0,n.flowing=!1,n.emittedReadable=!1,Or("on readable",n.length,n.reading),n.length?uT(this):n.reading||xu.nextTick(bUe,this)),r};mr.prototype.addListener=mr.prototype.on;mr.prototype.removeListener=function(t,e){let r=Am.prototype.removeListener.call(this,t,e);return t==="readable"&&xu.nextTick(Gce,this),r};mr.prototype.off=mr.prototype.removeListener;mr.prototype.removeAllListeners=function(t){let e=Am.prototype.removeAllListeners.apply(this,arguments);return(t==="readable"||t===void 0)&&xu.nextTick(Gce,this),e};function Gce(t){let e=t._readableState;e.readableListening=t.listenerCount("readable")>0,e.resumeScheduled&&e[mg]===!1?e.flowing=!0:t.listenerCount("data")>0?t.resume():e.readableListening||(e.flowing=null)}function bUe(t){Or("readable nexttick read 0"),t.read(0)}mr.prototype.resume=function(){let t=this._readableState;return t.flowing||(Or("resume"),t.flowing=!t.readableListening,wUe(this,t)),t[mg]=!1,this};function wUe(t,e){e.resumeScheduled||(e.resumeScheduled=!0,xu.nextTick(_Ue,t,e))}function _Ue(t,e){Or("resume",e.reading),e.reading||t.read(0),e.resumeScheduled=!1,t.emit("resume"),Jce(t),e.flowing&&!e.reading&&t.read(0)}mr.prototype.pause=function(){return Or("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(Or("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState[mg]=!0,this};function Jce(t){let e=t._readableState;for(Or("flow",e.flowing);e.flowing&&t.read()!==null;);}mr.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=>{qw(this,n)}),t.on("close",()=>{this.destroy()}),t.on("destroy",()=>{this.destroy()}),this._read=()=>{e&&t.resume&&(e=!1,t.resume())};let r=qje(t);for(let n=1;n<r.length;n++){let i=r[n];this[i]===void 0&&typeof t[i]=="function"&&(this[i]=t[i].bind(t))}return this};mr.prototype[Fje]=function(){return Yce(this)};mr.prototype.iterator=function(t){return t!==void 0&&nUe(t,"options"),Yce(this,t)};function Yce(t,e){typeof t.read!="function"&&(t=mr.wrap(t,{objectMode:!0}));let r=xUe(t,e);return r.stream=t,r}async function*xUe(t,e){let r=N$;function n(s){this===t?(r(),r=N$):r=s}t.on("readable",n);let i,o=qce(t,{writable:!1},s=>{i=s?$ce(i,s):null,r(),r=N$});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 Uce(n)}}}catch(s){throw i=$ce(i,s),i}finally{(i||e?.destroyOnReturn!==!1)&&(i===void 0||t._readableState.autoDestroy)?Kw.destroyer(t,null):(t.off("readable",n),o())}}F$(mr.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}}});F$(dT.prototype,{pipesCount:{__proto__:null,get(){return this.pipes.length}},paused:{__proto__:null,get(){return this[mg]!==!1},set(t){this[mg]=!!t}}});mr._fromList=Zce;function Zce(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 U$(t){let e=t._readableState;Or("endReadable",e.endEmitted),e.endEmitted||(e.ended=!0,xu.nextTick(EUe,e,t))}function EUe(t,e){if(Or("endReadableNT",t.endEmitted,t.length),!t.errored&&!t.closeEmitted&&!t.endEmitted&&t.length===0){if(t.endEmitted=!0,e.emit("end"),e.writable&&e.allowHalfOpen===!1)xu.nextTick(SUe,e);else if(t.autoDestroy){let r=e._writableState;(!r||r.autoDestroy&&(r.finished||r.writable===!1))&&e.destroy()}}}function SUe(t){t.writable&&!t.writableEnded&&!t.destroyed&&t.end()}mr.from=function(t,e){return iUe(mr,t,e)};var q$;function Xce(){return q$===void 0&&(q$={}),q$}mr.fromWeb=function(t,e){return Xce().newStreamReadableFromReadableStream(t,e)};mr.toWeb=function(t,e){return Xce().newReadableStreamFromStreamReadable(t,e)};mr.wrap=function(t,e){var r,n;return new mr({objectMode:(r=(n=t.readableObjectMode)!==null&&n!==void 0?n:t.objectMode)!==null&&r!==void 0?r:!0,...e,destroy(i,o){Kw.destroyer(t,i),o(i)}}).wrap(t)}});var mT=H((d6t,lde)=>{h();var yg=fs(),{ArrayPrototypeSlice:rde,Error:AUe,FunctionPrototypeSymbolHasInstance:nde,ObjectDefineProperty:ide,ObjectDefineProperties:TUe,ObjectSetPrototypeOf:ode,StringPrototypeToLowerCase:IUe,Symbol:PUe,SymbolHasInstance:kUe}=Jn();lde.exports=Yn;Yn.WritableState=SE;var{EventEmitter:RUe}=Ja(),xE=nT().Stream,{Buffer:lT}=$n(),pT=pg(),{addAbortSignal:BUe}=vE(),{getHighWaterMark:MUe,getDefaultHighWaterMark:DUe}=bE(),{ERR_INVALID_ARG_TYPE:OUe,ERR_METHOD_NOT_IMPLEMENTED:CUe,ERR_MULTIPLE_CALLBACK:sde,ERR_STREAM_CANNOT_PIPE:$Ue,ERR_STREAM_DESTROYED:EE,ERR_STREAM_ALREADY_FINISHED:NUe,ERR_STREAM_NULL_VALUES:jUe,ERR_STREAM_WRITE_AFTER_END:UUe,ERR_UNKNOWN_ENCODING:ade}=sa().codes,{errorOrDestroy:Fw}=pT;ode(Yn.prototype,xE.prototype);ode(Yn,xE);function H$(){}var zw=PUe("kOnFinished");function SE(t,e,r){typeof r!="boolean"&&(r=e instanceof jl()),this.objectMode=!!(t&&t.objectMode),r&&(this.objectMode=this.objectMode||!!(t&&t.writableObjectMode)),this.highWaterMark=t?MUe(this,t,"writableHighWaterMark",r):DUe(!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=LUe.bind(void 0,e),this.writecb=null,this.writelen=0,this.afterWriteTickInfo=null,hT(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[zw]=[]}function hT(t){t.buffered=[],t.bufferedIndex=0,t.allBuffers=!0,t.allNoop=!0}SE.prototype.getBuffer=function(){return rde(this.buffered,this.bufferedIndex)};ide(SE.prototype,"bufferedRequestCount",{__proto__:null,get(){return this.buffered.length-this.bufferedIndex}});function Yn(t){let e=this instanceof jl();if(!e&&!nde(Yn,this))return new Yn(t);this._writableState=new SE(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&&BUe(t.signal,this)),xE.call(this,t),pT.construct(this,()=>{let r=this._writableState;r.writing||G$(this,r),J$(this,r)})}ide(Yn,kUe,{__proto__:null,value:function(t){return nde(this,t)?!0:this!==Yn?!1:t&&t._writableState instanceof SE}});Yn.prototype.pipe=function(){Fw(this,new $Ue)};function cde(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"&&!lT.isEncoding(r))throw new ade(r);typeof n!="function"&&(n=H$)}if(e===null)throw new jUe;if(!i.objectMode)if(typeof e=="string")i.decodeStrings!==!1&&(e=lT.from(e,r),r="buffer");else if(e instanceof lT)r="buffer";else if(xE._isUint8Array(e))e=xE._uint8ArrayToBuffer(e),r="buffer";else throw new OUe("chunk",["string","Buffer","Uint8Array"],e);let o;return i.ending?o=new UUe:i.destroyed&&(o=new EE("write")),o?(yg.nextTick(n,o),Fw(t,o,!0),o):(i.pendingcb++,qUe(t,i,e,r,n))}Yn.prototype.write=function(t,e,r){return cde(this,t,e,r)===!0};Yn.prototype.cork=function(){this._writableState.corked++};Yn.prototype.uncork=function(){let t=this._writableState;t.corked&&(t.corked--,t.writing||G$(this,t))};Yn.prototype.setDefaultEncoding=function(e){if(typeof e=="string"&&(e=IUe(e)),!lT.isEncoding(e))throw new ade(e);return this._writableState.defaultEncoding=e,this};function qUe(t,e,r,n,i){let o=e.objectMode?1:r.length;e.length+=o;let s=e.length<e.highWaterMark;return s||(e.needDrain=!0),e.writing||e.corked||e.errored||!e.constructed?(e.buffered.push({chunk:r,encoding:n,callback:i}),e.allBuffers&&n!=="buffer"&&(e.allBuffers=!1),e.allNoop&&i!==H$&&(e.allNoop=!1)):(e.writelen=o,e.writecb=i,e.writing=!0,e.sync=!0,t._write(r,n,e.onwrite),e.sync=!1),s&&!e.errored&&!e.destroyed}function ede(t,e,r,n,i,o,s){e.writelen=n,e.writecb=s,e.writing=!0,e.sync=!0,e.destroyed?e.onwrite(new EE("write")):r?t._writev(i,e.onwrite):t._write(i,o,e.onwrite),e.sync=!1}function tde(t,e,r,n){--e.pendingcb,n(r),W$(e),Fw(t,r)}function LUe(t,e){let r=t._writableState,n=r.sync,i=r.writecb;if(typeof i!="function"){Fw(t,new sde);return}r.writing=!1,r.writecb=null,r.length-=r.writelen,r.writelen=0,e?(e.stack,r.errored||(r.errored=e),t._readableState&&!t._readableState.errored&&(t._readableState.errored=e),n?yg.nextTick(tde,t,r,e,i):tde(t,r,e,i)):(r.buffered.length>r.bufferedIndex&&G$(t,r),n?r.afterWriteTickInfo!==null&&r.afterWriteTickInfo.cb===i?r.afterWriteTickInfo.count++:(r.afterWriteTickInfo={count:1,cb:i,stream:t,state:r},yg.nextTick(KUe,r.afterWriteTickInfo)):dde(t,r,1,i))}function KUe({stream:t,state:e,count:r,cb:n}){return e.afterWriteTickInfo=null,dde(t,e,r,n)}function dde(t,e,r,n){for(!e.ending&&!t.destroyed&&e.length===0&&e.needDrain&&(e.needDrain=!1,t.emit("drain"));r-- >0;)e.pendingcb--,n();e.destroyed&&W$(e),J$(t,e)}function W$(t){if(t.writing)return;for(let i=t.bufferedIndex;i<t.buffered.length;++i){var e;let{chunk:o,callback:s}=t.buffered[i],a=t.objectMode?1:o.length;t.length-=a,s((e=t.errored)!==null&&e!==void 0?e:new EE("write"))}let r=t[zw].splice(0);for(let i=0;i<r.length;i++){var n;r[i]((n=t.errored)!==null&&n!==void 0?n:new EE("end"))}hT(t)}function G$(t,e){if(e.corked||e.bufferProcessing||e.destroyed||!e.constructed)return;let{buffered:r,bufferedIndex:n,objectMode:i}=e,o=r.length-n;if(!o)return;let s=n;if(e.bufferProcessing=!0,o>1&&t._writev){e.pendingcb-=o-1;let a=e.allNoop?H$:u=>{for(let c=s;c<r.length;++c)r[c].callback(u)},d=e.allNoop&&s===0?r:rde(r,s);d.allBuffers=e.allBuffers,ede(t,e,!0,e.length,d,"",a),hT(e)}else{do{let{chunk:a,encoding:d,callback:u}=r[s];r[s++]=null;let c=i?1:a.length;ede(t,e,!1,c,a,d,u)}while(s<r.length&&!e.writing);s===r.length?hT(e):s>256?(r.splice(0,s),e.bufferedIndex=0):e.bufferedIndex=s}e.bufferProcessing=!1}Yn.prototype._write=function(t,e,r){if(this._writev)this._writev([{chunk:t,encoding:e}],r);else throw new CUe("_write()")};Yn.prototype._writev=null;Yn.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=cde(this,t,e);o instanceof AUe&&(i=o)}return n.corked&&(n.corked=1,this.uncork()),i||(!n.errored&&!n.ending?(n.ending=!0,J$(this,n,!0),n.ended=!0):n.finished?i=new NUe("end"):n.destroyed&&(i=new EE("end"))),typeof r=="function"&&(i||n.finished?yg.nextTick(r,i):n[zw].push(r)),this};function fT(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 FUe(t,e){let r=!1;function n(i){if(r){Fw(t,i??sde());return}if(r=!0,e.pendingcb--,i){let o=e[zw].splice(0);for(let s=0;s<o.length;s++)o[s](i);Fw(t,i,e.sync)}else fT(e)&&(e.prefinished=!0,t.emit("prefinish"),e.pendingcb++,yg.nextTick(V$,t,e))}e.sync=!0,e.pendingcb++;try{t._final(n)}catch(i){n(i)}e.sync=!1}function zUe(t,e){!e.prefinished&&!e.finalCalled&&(typeof t._final=="function"&&!e.destroyed?(e.finalCalled=!0,FUe(t,e)):(e.prefinished=!0,t.emit("prefinish")))}function J$(t,e,r){fT(e)&&(zUe(t,e),e.pendingcb===0&&(r?(e.pendingcb++,yg.nextTick((n,i)=>{fT(i)?V$(n,i):i.pendingcb--},t,e)):fT(e)&&(e.pendingcb++,V$(t,e))))}function V$(t,e){e.pendingcb--,e.finished=!0;let r=e[zw].splice(0);for(let n=0;n<r.length;n++)r[n]();if(t.emit("finish"),e.autoDestroy){let n=t._readableState;(!n||n.autoDestroy&&(n.endEmitted||n.readable===!1))&&t.destroy()}}TUe(Yn.prototype,{closed:{__proto__:null,get(){return this._writableState?this._writableState.closed:!1}},destroyed:{__proto__:null,get(){return this._writableState?this._writableState.destroyed:!1},set(t){this._writableState&&(this._writableState.destroyed=t)}},writable:{__proto__:null,get(){let t=this._writableState;return!!t&&t.writable!==!1&&!t.destroyed&&!t.errored&&!t.ending&&!t.ended},set(t){this._writableState&&(this._writableState.writable=!!t)}},writableFinished:{__proto__:null,get(){return this._writableState?this._writableState.finished:!1}},writableObjectMode:{__proto__:null,get(){return this._writableState?this._writableState.objectMode:!1}},writableBuffer:{__proto__:null,get(){return this._writableState&&this._writableState.getBuffer()}},writableEnded:{__proto__:null,get(){return this._writableState?this._writableState.ending:!1}},writableNeedDrain:{__proto__:null,get(){let t=this._writableState;return t?!t.destroyed&&!t.ending&&t.needDrain:!1}},writableHighWaterMark:{__proto__:null,get(){return this._writableState&&this._writableState.highWaterMark}},writableCorked:{__proto__:null,get(){return this._writableState?this._writableState.corked:0}},writableLength:{__proto__:null,get(){return this._writableState&&this._writableState.length}},errored:{__proto__:null,enumerable:!1,get(){return this._writableState?this._writableState.errored:null}},writableAborted:{__proto__:null,enumerable:!1,get:function(){return!!(this._writableState.writable!==!1&&(this._writableState.destroyed||this._writableState.errored)&&!this._writableState.finished)}}});var VUe=pT.destroy;Yn.prototype.destroy=function(t,e){let r=this._writableState;return!r.destroyed&&(r.bufferedIndex<r.buffered.length||r[zw].length)&&yg.nextTick(W$,r),VUe.call(this,t,e),this};Yn.prototype._undestroy=pT.undestroy;Yn.prototype._destroy=function(t,e){e(t)};Yn.prototype[RUe.captureRejectionSymbol]=function(t){this.destroy(t)};var z$;function ude(){return z$===void 0&&(z$={}),z$}Yn.fromWeb=function(t,e){return ude().newStreamWritableFromWritableStream(t,e)};Yn.toWeb=function(t){return ude().newWritableStreamFromStreamWritable(t)}});var Tde=H((l6t,Ade)=>{h();var Y$=fs(),HUe=$n(),{isReadable:WUe,isWritable:GUe,isIterable:fde,isNodeStream:JUe,isReadableNodeStream:hde,isWritableNodeStream:pde,isDuplexNodeStream:YUe,isReadableStream:mde,isWritableStream:yde}=$l(),gde=ph(),{AbortError:Ede,codes:{ERR_INVALID_ARG_TYPE:ZUe,ERR_INVALID_RETURN_VALUE:vde}}=sa(),{destroyer:Hw}=pg(),XUe=jl(),Sde=_E(),QUe=mT(),{createDeferredPromise:bde}=Ds(),wde=C$(),_de=globalThis.Blob||HUe.Blob,eqe=typeof _de<"u"?function(e){return e instanceof _de}:function(e){return!1},tqe=globalThis.AbortController||wf().AbortController,{FunctionPrototypeCall:xde}=Jn(),Tm=class extends XUe{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)}};Ade.exports=function t(e,r){if(YUe(e))return e;if(hde(e))return Vw({readable:e});if(pde(e))return Vw({writable:e});if(JUe(e))return Vw({writable:!1,readable:!1});if(mde(e))return Vw({readable:Sde.fromWeb(e)});if(yde(e))return Vw({writable:QUe.fromWeb(e)});if(typeof e=="function"){let{value:i,write:o,final:s,destroy:a}=rqe(e);if(fde(i))return wde(Tm,i,{objectMode:!0,write:o,final:s,destroy:a});let d=i?.then;if(typeof d=="function"){let u,c=xde(d,i,l=>{if(l!=null)throw new vde("nully","body",l)},l=>{Hw(u,l)});return u=new Tm({objectMode:!0,readable:!1,write:o,final(l){s(async()=>{try{await c,Y$.nextTick(l,null)}catch(m){Y$.nextTick(l,m)}})},destroy:a})}throw new vde("Iterable, AsyncIterable or AsyncFunction",r,i)}if(eqe(e))return t(e.arrayBuffer());if(fde(e))return wde(Tm,e,{objectMode:!0,writable:!1});if(mde(e?.readable)&&yde(e?.writable))return Tm.fromWeb(e);if(typeof e?.writable=="object"||typeof e?.readable=="object"){let i=e!=null&&e.readable?hde(e?.readable)?e?.readable:t(e.readable):void 0,o=e!=null&&e.writable?pde(e?.writable)?e?.writable:t(e.writable):void 0;return Vw({readable:i,writable:o})}let n=e?.then;if(typeof n=="function"){let i;return xde(n,e,o=>{o!=null&&i.push(o),i.push(null)},o=>{Hw(i,o)}),i=new Tm({objectMode:!0,writable:!1,read(){}})}throw new ZUe(r,["Blob","ReadableStream","WritableStream","Stream","Iterable","AsyncIterable","Function","{ readable, writable } pair","Promise"],e)};function rqe(t){let{promise:e,resolve:r}=bde(),n=new tqe,i=n.signal;return{value:t(async function*(){for(;;){let s=e;e=null;let{chunk:a,done:d,cb:u}=await s;if(Y$.nextTick(u),d)return;if(i.aborted)throw new Ede(void 0,{cause:i.reason});({promise:e,resolve:r}=bde()),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 Vw(t){let e=t.readable&&typeof t.readable.read!="function"?Sde.wrap(t.readable):t.readable,r=t.writable,n=!!WUe(e),i=!!GUe(r),o,s,a,d,u;function c(l){let m=d;d=null,m?m(l):l&&u.destroy(l)}return u=new Tm({readableObjectMode:!!(e!=null&&e.readableObjectMode),writableObjectMode:!!(r!=null&&r.writableObjectMode),readable:n,writable:i}),i&&(gde(r,l=>{i=!1,l&&Hw(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&&(gde(e,l=>{n=!1,l&&Hw(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 Ede),a=null,o=null,s=null,d===null?m(l):(d=m,Hw(r,l),Hw(e,l))},u}});var jl=H((h6t,kde)=>{"use strict";h();var{ObjectDefineProperties:nqe,ObjectGetOwnPropertyDescriptor:mh,ObjectKeys:iqe,ObjectSetPrototypeOf:Ide}=Jn();kde.exports=Eu;var Q$=_E(),Ed=mT();Ide(Eu.prototype,Q$.prototype);Ide(Eu,Q$);{let t=iqe(Ed.prototype);for(let e=0;e<t.length;e++){let r=t[e];Eu.prototype[r]||(Eu.prototype[r]=Ed.prototype[r])}}function Eu(t){if(!(this instanceof Eu))return new Eu(t);Q$.call(this,t),Ed.call(this,t),t?(this.allowHalfOpen=t.allowHalfOpen!==!1,t.readable===!1&&(this._readableState.readable=!1,this._readableState.ended=!0,this._readableState.endEmitted=!0),t.writable===!1&&(this._writableState.writable=!1,this._writableState.ending=!0,this._writableState.ended=!0,this._writableState.finished=!0)):this.allowHalfOpen=!0}nqe(Eu.prototype,{writable:{__proto__:null,...mh(Ed.prototype,"writable")},writableHighWaterMark:{__proto__:null,...mh(Ed.prototype,"writableHighWaterMark")},writableObjectMode:{__proto__:null,...mh(Ed.prototype,"writableObjectMode")},writableBuffer:{__proto__:null,...mh(Ed.prototype,"writableBuffer")},writableLength:{__proto__:null,...mh(Ed.prototype,"writableLength")},writableFinished:{__proto__:null,...mh(Ed.prototype,"writableFinished")},writableCorked:{__proto__:null,...mh(Ed.prototype,"writableCorked")},writableEnded:{__proto__:null,...mh(Ed.prototype,"writableEnded")},writableNeedDrain:{__proto__:null,...mh(Ed.prototype,"writableNeedDrain")},destroyed:{__proto__:null,get(){return this._readableState===void 0||this._writableState===void 0?!1:this._readableState.destroyed&&this._writableState.destroyed},set(t){this._readableState&&this._writableState&&(this._readableState.destroyed=t,this._writableState.destroyed=t)}}});var Z$;function Pde(){return Z$===void 0&&(Z$={}),Z$}Eu.fromWeb=function(t,e){return Pde().newStreamDuplexFromReadableWritablePair(t,e)};Eu.toWeb=function(t){return Pde().newReadableWritablePairFromDuplex(t)};var X$;Eu.from=function(t){return X$||(X$=Tde()),X$(t,"body")}});var rN=H((m6t,Bde)=>{"use strict";h();var{ObjectSetPrototypeOf:Rde,Symbol:oqe}=Jn();Bde.exports=yh;var{ERR_METHOD_NOT_IMPLEMENTED:sqe}=sa().codes,tN=jl(),{getHighWaterMark:aqe}=bE();Rde(yh.prototype,tN.prototype);Rde(yh,tN);var AE=oqe("kCallback");function yh(t){if(!(this instanceof yh))return new yh(t);let e=t?aqe(this,t,"readableHighWaterMark",!0):null;e===0&&(t={...t,highWaterMark:null,readableHighWaterMark:e,writableHighWaterMark:t.writableHighWaterMark||0}),tN.call(this,t),this._readableState.sync=!1,this[AE]=null,t&&(typeof t.transform=="function"&&(this._transform=t.transform),typeof t.flush=="function"&&(this._flush=t.flush)),this.on("prefinish",cqe)}function eN(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 cqe(){this._final!==eN&&eN.call(this)}yh.prototype._final=eN;yh.prototype._transform=function(t,e,r){throw new sqe("_transform()")};yh.prototype._write=function(t,e,r){let n=this._readableState,i=this._writableState,o=n.length;this._transform(t,e,(s,a)=>{if(s){r(s);return}a!=null&&this.push(a),i.ended||o===n.length||n.length<n.highWaterMark?r():this[AE]=r})};yh.prototype._read=function(){if(this[AE]){let t=this[AE];this[AE]=null,t()}}});var iN=H((g6t,Dde)=>{"use strict";h();var{ObjectSetPrototypeOf:Mde}=Jn();Dde.exports=Ww;var nN=rN();Mde(Ww.prototype,nN.prototype);Mde(Ww,nN);function Ww(t){if(!(this instanceof Ww))return new Ww(t);nN.call(this,t)}Ww.prototype._transform=function(t,e,r){r(null,t)}});var bT=H((b6t,jde)=>{h();var TE=fs(),{ArrayIsArray:dqe,Promise:uqe,SymbolAsyncIterator:lqe,SymbolDispose:fqe}=Jn(),vT=ph(),{once:hqe}=Ds(),pqe=pg(),Ode=jl(),{aggregateTwoErrors:mqe,codes:{ERR_INVALID_ARG_TYPE:hN,ERR_INVALID_RETURN_VALUE:oN,ERR_MISSING_ARGS:yqe,ERR_STREAM_DESTROYED:gqe,ERR_STREAM_PREMATURE_CLOSE:vqe},AbortError:bqe}=sa(),{validateFunction:wqe,validateAbortSignal:_qe}=jw(),{isIterable:gg,isReadable:sN,isReadableNodeStream:gT,isNodeStream:Cde,isTransformStream:Gw,isWebStream:xqe,isReadableStream:aN,isReadableFinished:Eqe}=$l(),Sqe=globalThis.AbortController||wf().AbortController,cN,dN,uN;function $de(t,e,r){let n=!1;t.on("close",()=>{n=!0});let i=vT(t,{readable:e,writable:r},o=>{n=!o});return{destroy:o=>{n||(n=!0,pqe.destroyer(t,o||new gqe("pipe")))},cleanup:i}}function Aqe(t){return wqe(t[t.length-1],"streams[stream.length - 1]"),t.pop()}function lN(t){if(gg(t))return t;if(gT(t))return Tqe(t);throw new hN("val",["Readable","Iterable","AsyncIterable"],t)}async function*Tqe(t){dN||(dN=_E()),yield*dN.prototype[lqe].call(t)}async function yT(t,e,r,{end:n}){let i,o=null,s=u=>{if(u&&(i=u),o){let c=o;o=null,c()}},a=()=>new uqe((u,c)=>{i?c(i):o=()=>{i?c(i):u()}});e.on("drain",s);let d=vT(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?mqe(i,u):u)}finally{d(),e.off("drain",s)}}async function fN(t,e,r,{end:n}){Gw(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 Iqe(...t){return Nde(t,hqe(Aqe(t)))}function Nde(t,e,r){if(t.length===1&&dqe(t[0])&&(t=t[0]),t.length<2)throw new yqe("streams");let n=new Sqe,i=n.signal,o=r?.signal,s=[];_qe(o,"options.signal");function a(){g(new bqe)}uN=uN||Ds().addAbortListener;let d;o&&(d=uN(o,a));let u,c,l=[],m=0;function p(I){g(I,--m===0)}function g(I,$){var N;if(I&&(!u||u.code==="ERR_STREAM_PREMATURE_CLOSE")&&(u=I),!(!u&&!$)){for(;l.length;)l.shift()(u);(N=d)===null||N===void 0||N[fqe](),n.abort(),$&&(u||s.forEach(K=>K()),TE.nextTick(e,u,c))}}let v;for(let I=0;I<t.length;I++){let $=t[I],N=I<t.length-1,K=I>0,F=N||r?.end!==!1,U=I===t.length-1;if(Cde($)){let V=function(L){L&&L.name!=="AbortError"&&L.code!=="ERR_STREAM_PREMATURE_CLOSE"&&p(L)};var P=V;if(F){let{destroy:L,cleanup:T}=$de($,N,K);l.push(L),sN($)&&U&&s.push(T)}$.on("error",V),sN($)&&U&&s.push(()=>{$.removeListener("error",V)})}if(I===0)if(typeof $=="function"){if(v=$({signal:i}),!gg(v))throw new oN("Iterable, AsyncIterable or Stream","source",v)}else gg($)||gT($)||Gw($)?v=$:v=Ode.from($);else if(typeof $=="function"){if(Gw(v)){var E;v=lN((E=v)===null||E===void 0?void 0:E.readable)}else v=lN(v);if(v=$(v,{signal:i}),N){if(!gg(v,!0))throw new oN("AsyncIterable",`transform[${I-1}]`,v)}else{var A;cN||(cN=iN());let V=new cN({objectMode:!0}),L=(A=v)===null||A===void 0?void 0:A.then;if(typeof L=="function")m++,L.call(v,k=>{c=k,k!=null&&V.write(k),F&&V.end(),TE.nextTick(p)},k=>{V.destroy(k),TE.nextTick(p,k)});else if(gg(v,!0))m++,yT(v,V,p,{end:F});else if(aN(v)||Gw(v)){let k=v.readable||v;m++,yT(k,V,p,{end:F})}else throw new oN("AsyncIterable or Promise","destination",v);v=V;let{destroy:T,cleanup:S}=$de(v,!1,!0);l.push(T),U&&s.push(S)}}else if(Cde($)){if(gT(v)){m+=2;let V=Pqe(v,$,p,{end:F});sN($)&&U&&s.push(V)}else if(Gw(v)||aN(v)){let V=v.readable||v;m++,yT(V,$,p,{end:F})}else if(gg(v))m++,yT(v,$,p,{end:F});else throw new hN("val",["Readable","Iterable","AsyncIterable","ReadableStream","TransformStream"],v);v=$}else if(xqe($)){if(gT(v))m++,fN(lN(v),$,p,{end:F});else if(aN(v)||gg(v))m++,fN(v,$,p,{end:F});else if(Gw(v))m++,fN(v.readable,$,p,{end:F});else throw new hN("val",["Readable","Iterable","AsyncIterable","ReadableStream","TransformStream"],v);v=$}else v=Ode.from($)}return(i!=null&&i.aborted||o!=null&&o.aborted)&&TE.nextTick(a),v}function Pqe(t,e,r,{end:n}){let i=!1;if(e.on("close",()=>{i||r(new vqe)}),t.pipe(e,{end:!1}),n){let s=function(){i=!0,e.end()};var o=s;Eqe(t)?TE.nextTick(s):t.once("end",s)}else r();return vT(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)}),vT(e,{readable:!1,writable:!0},r)}jde.exports={pipelineImpl:Nde,pipeline:Iqe}});var mN=H((_6t,zde)=>{"use strict";h();var{pipeline:kqe}=bT(),wT=jl(),{destroyer:Rqe}=pg(),{isNodeStream:_T,isReadable:Ude,isWritable:qde,isWebStream:pN,isTransformStream:vg,isWritableStream:Lde,isReadableStream:Kde}=$l(),{AbortError:Bqe,codes:{ERR_INVALID_ARG_VALUE:Fde,ERR_MISSING_ARGS:Mqe}}=sa(),Dqe=ph();zde.exports=function(...e){if(e.length===0)throw new Mqe("streams");if(e.length===1)return wT.from(e[0]);let r=[...e];if(typeof e[0]=="function"&&(e[0]=wT.from(e[0])),typeof e[e.length-1]=="function"){let p=e.length-1;e[p]=wT.from(e[p])}for(let p=0;p<e.length;++p)if(!(!_T(e[p])&&!pN(e[p]))){if(p<e.length-1&&!(Ude(e[p])||Kde(e[p])||vg(e[p])))throw new Fde(`streams[${p}]`,r[p],"must be readable");if(p>0&&!(qde(e[p])||Lde(e[p])||vg(e[p])))throw new Fde(`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=kqe(e,d),l=!!(qde(u)||Lde(u)||vg(u)),m=!!(Ude(c)||Kde(c)||vg(c));if(a=new wT({writableObjectMode:!!(u!=null&&u.writableObjectMode),readableObjectMode:!!(c!=null&&c.readableObjectMode),writable:l,readable:m}),l){if(_T(u))a._write=function(g,v,E){u.write(g,v)?E():n=E},a._final=function(g){u.end(),i=g},u.on("drain",function(){if(n){let g=n;n=null,g()}});else if(pN(u)){let v=(vg(u)?u.writable:u).getWriter();a._write=async function(E,A,P){try{await v.ready,v.write(E).catch(()=>{}),P()}catch(I){P(I)}},a._final=async function(E){try{await v.ready,v.close().catch(()=>{}),i=E}catch(A){E(A)}}}let p=vg(c)?c.readable:c;Dqe(p,()=>{if(i){let g=i;i=null,g()}})}if(m){if(_T(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(pN(c)){let g=(vg(c)?c.readable:c).getReader();a._read=async function(){for(;;)try{let{value:v,done:E}=await g.read();if(!a.push(v))return;if(E){a.push(null);return}}catch{return}}}}return a._destroy=function(p,g){!p&&s!==null&&(p=new Bqe),o=null,n=null,i=null,s===null?g(p):(s=g,_T(c)&&Rqe(c,p))},a}});var eue=H((E6t,vN)=>{"use strict";h();var Oqe=globalThis.AbortController||wf().AbortController,{codes:{ERR_INVALID_ARG_VALUE:Cqe,ERR_INVALID_ARG_TYPE:IE,ERR_MISSING_ARGS:$qe,ERR_OUT_OF_RANGE:Nqe},AbortError:Ul}=sa(),{validateAbortSignal:bg,validateInteger:Vde,validateObject:wg}=jw(),jqe=Jn().Symbol("kWeak"),Uqe=Jn().Symbol("kResistStopPropagation"),{finished:qqe}=ph(),Lqe=mN(),{addAbortSignalNoValidate:Kqe}=vE(),{isWritable:Fqe,isNodeStream:zqe}=$l(),{deprecate:Vqe}=Ds(),{ArrayPrototypePush:Hqe,Boolean:Wqe,MathFloor:Hde,Number:Gqe,NumberIsNaN:Jqe,Promise:Wde,PromiseReject:Gde,PromiseResolve:Yqe,PromisePrototypeThen:Jde,Symbol:Zde}=Jn(),xT=Zde("kEmpty"),Yde=Zde("kEof");function Zqe(t,e){if(e!=null&&wg(e,"options"),e?.signal!=null&&bg(e.signal,"options.signal"),zqe(t)&&!Fqe(t))throw new Cqe("stream",t,"must be writable");let r=Lqe(this,t);return e!=null&&e.signal&&Kqe(e.signal,r),r}function ET(t,e){if(typeof t!="function")throw new IE("fn",["Function","AsyncFunction"],t);e!=null&&wg(e,"options"),e?.signal!=null&&bg(e.signal,"options.signal");let r=1;e?.concurrency!=null&&(r=Hde(e.concurrency));let n=r-1;return e?.highWaterMark!=null&&(n=Hde(e.highWaterMark)),Vde(r,"options.concurrency",1),Vde(n,"options.highWaterMark",0),n+=r,(async function*(){let o=Ds().AbortSignalAny([e?.signal].filter(Wqe)),s=this,a=[],d={signal:o},u,c,l=!1,m=0;function p(){l=!0,g()}function g(){m-=1,v()}function v(){c&&!l&&m<r&&a.length<n&&(c(),c=null)}async function E(){try{for await(let A of s){if(l)return;if(o.aborted)throw new Ul;try{if(A=t(A,d),A===xT)continue;A=Yqe(A)}catch(P){A=Gde(P)}m+=1,Jde(A,g,p),a.push(A),u&&(u(),u=null),!l&&(a.length>=n||m>=r)&&await new Wde(P=>{c=P})}a.push(Yde)}catch(A){let P=Gde(A);Jde(P,g,p),a.push(P)}finally{l=!0,u&&(u(),u=null)}}E();try{for(;;){for(;a.length>0;){let A=await a[0];if(A===Yde)return;if(o.aborted)throw new Ul;A!==xT&&(yield A),a.shift(),v()}await new Wde(A=>{u=A})}}finally{l=!0,c&&(c(),c=null)}}).call(this)}function Xqe(t=void 0){return t!=null&&wg(t,"options"),t?.signal!=null&&bg(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 Ul({cause:t.signal.reason});yield[r++,i]}}).call(this)}async function Xde(t,e=void 0){for await(let r of gN.call(this,t,e))return!0;return!1}async function Qqe(t,e=void 0){if(typeof t!="function")throw new IE("fn",["Function","AsyncFunction"],t);return!await Xde.call(this,async(...r)=>!await t(...r),e)}async function eLe(t,e){for await(let r of gN.call(this,t,e))return r}async function tLe(t,e){if(typeof t!="function")throw new IE("fn",["Function","AsyncFunction"],t);async function r(n,i){return await t(n,i),xT}for await(let n of ET.call(this,r,e));}function gN(t,e){if(typeof t!="function")throw new IE("fn",["Function","AsyncFunction"],t);async function r(n,i){return await t(n,i)?n:xT}return ET.call(this,r,e)}var yN=class extends $qe{constructor(){super("reduce"),this.message="Reduce of an empty stream requires an initial value"}};async function rLe(t,e,r){var n;if(typeof t!="function")throw new IE("reducer",["Function","AsyncFunction"],t);r!=null&&wg(r,"options"),r?.signal!=null&&bg(r.signal,"options.signal");let i=arguments.length>1;if(r!=null&&(n=r.signal)!==null&&n!==void 0&&n.aborted){let u=new Ul(void 0,{cause:r.signal.reason});throw this.once("error",()=>{}),await qqe(this.destroy(u)),u}let o=new Oqe,s=o.signal;if(r!=null&&r.signal){let u={once:!0,[jqe]:this,[Uqe]:!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 Ul;i?e=await t(e,u,{signal:s}):(e=u,i=!0)}if(!a&&!i)throw new yN}finally{o.abort()}return e}async function nLe(t){t!=null&&wg(t,"options"),t?.signal!=null&&bg(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 Ul(void 0,{cause:t.signal.reason});Hqe(e,n)}return e}function iLe(t,e){let r=ET.call(this,t,e);return(async function*(){for await(let i of r)yield*i}).call(this)}function Qde(t){if(t=Gqe(t),Jqe(t))return 0;if(t<0)throw new Nqe("number",">= 0",t);return t}function oLe(t,e=void 0){return e!=null&&wg(e,"options"),e?.signal!=null&&bg(e.signal,"options.signal"),t=Qde(t),(async function*(){var n;if(e!=null&&(n=e.signal)!==null&&n!==void 0&&n.aborted)throw new Ul;for await(let o of this){var i;if(e!=null&&(i=e.signal)!==null&&i!==void 0&&i.aborted)throw new Ul;t--<=0&&(yield o)}}).call(this)}function sLe(t,e=void 0){return e!=null&&wg(e,"options"),e?.signal!=null&&bg(e.signal,"options.signal"),t=Qde(t),(async function*(){var n;if(e!=null&&(n=e.signal)!==null&&n!==void 0&&n.aborted)throw new Ul;for await(let o of this){var i;if(e!=null&&(i=e.signal)!==null&&i!==void 0&&i.aborted)throw new Ul;if(t-- >0&&(yield o),t<=0)return}}).call(this)}vN.exports.streamReturningOperators={asIndexedPairs:Vqe(Xqe,"readable.asIndexedPairs will be removed in a future version."),drop:oLe,filter:gN,flatMap:iLe,map:ET,take:sLe,compose:Zqe};vN.exports.promiseReturningOperators={every:Qqe,forEach:tLe,reduce:rLe,toArray:nLe,some:Xde,find:eLe}});var bN=H((A6t,tue)=>{"use strict";h();var{ArrayPrototypePop:aLe,Promise:cLe}=Jn(),{isIterable:dLe,isNodeStream:uLe,isWebStream:lLe}=$l(),{pipelineImpl:fLe}=bT(),{finished:hLe}=ph();wN();function pLe(...t){return new cLe((e,r)=>{let n,i,o=t[t.length-1];if(o&&typeof o=="object"&&!uLe(o)&&!dLe(o)&&!lLe(o)){let s=aLe(t);n=s.signal,i=s.end}fLe(t,(s,a)=>{s?r(s):e(a)},{signal:n,end:i})})}tue.exports={finished:hLe,pipeline:pLe}});var wN=H((I6t,uue)=>{h();var{Buffer:mLe}=$n(),{ObjectDefineProperty:gh,ObjectKeys:iue,ReflectApply:oue}=Jn(),{promisify:{custom:sue}}=Ds(),{streamReturningOperators:rue,promiseReturningOperators:nue}=eue(),{codes:{ERR_ILLEGAL_CONSTRUCTOR:aue}}=sa(),yLe=mN(),{setDefaultHighWaterMark:gLe,getDefaultHighWaterMark:vLe}=bE(),{pipeline:cue}=bT(),{destroyer:bLe}=pg(),due=ph(),_N=bN(),PE=$l(),On=uue.exports=nT().Stream;On.isDestroyed=PE.isDestroyed;On.isDisturbed=PE.isDisturbed;On.isErrored=PE.isErrored;On.isReadable=PE.isReadable;On.isWritable=PE.isWritable;On.Readable=_E();for(let t of iue(rue)){let r=function(...n){if(new.target)throw aue();return On.Readable.from(oue(e,this,n))};xN=r;let e=rue[t];gh(r,"name",{__proto__:null,value:e.name}),gh(r,"length",{__proto__:null,value:e.length}),gh(On.Readable.prototype,t,{__proto__:null,value:r,enumerable:!1,configurable:!0,writable:!0})}var xN;for(let t of iue(nue)){let r=function(...i){if(new.target)throw aue();return oue(e,this,i)};xN=r;let e=nue[t];gh(r,"name",{__proto__:null,value:e.name}),gh(r,"length",{__proto__:null,value:e.length}),gh(On.Readable.prototype,t,{__proto__:null,value:r,enumerable:!1,configurable:!0,writable:!0})}var xN;On.Writable=mT();On.Duplex=jl();On.Transform=rN();On.PassThrough=iN();On.pipeline=cue;var{addAbortSignal:wLe}=vE();On.addAbortSignal=wLe;On.finished=due;On.destroy=bLe;On.compose=yLe;On.setDefaultHighWaterMark=gLe;On.getDefaultHighWaterMark=vLe;gh(On,"promises",{__proto__:null,configurable:!0,enumerable:!0,get(){return _N}});gh(cue,sue,{__proto__:null,enumerable:!0,get(){return _N.pipeline}});gh(due,sue,{__proto__:null,enumerable:!0,get(){return _N.finished}});On.Stream=On;On._isUint8Array=function(e){return e instanceof Uint8Array};On._uint8ArrayToBuffer=function(e){return mLe.from(e.buffer,e.byteOffset,e.byteLength)}});var ST=H((k6t,Ai)=>{"use strict";h();var Xi=wN(),_Le=bN(),xLe=Xi.Readable.destroy;Ai.exports=Xi.Readable;Ai.exports._uint8ArrayToBuffer=Xi._uint8ArrayToBuffer;Ai.exports._isUint8Array=Xi._isUint8Array;Ai.exports.isDisturbed=Xi.isDisturbed;Ai.exports.isErrored=Xi.isErrored;Ai.exports.isReadable=Xi.isReadable;Ai.exports.Readable=Xi.Readable;Ai.exports.Writable=Xi.Writable;Ai.exports.Duplex=Xi.Duplex;Ai.exports.Transform=Xi.Transform;Ai.exports.PassThrough=Xi.PassThrough;Ai.exports.addAbortSignal=Xi.addAbortSignal;Ai.exports.finished=Xi.finished;Ai.exports.destroy=Xi.destroy;Ai.exports.destroy=xLe;Ai.exports.pipeline=Xi.pipeline;Ai.exports.compose=Xi.compose;Object.defineProperty(Xi,"promises",{configurable:!0,enumerable:!0,get(){return _Le}});Ai.exports.Stream=Xi.Stream;Ai.exports.default=Ai.exports});var pue=H((IN,PN)=>{h();(function(t,e){typeof IN=="object"&&typeof PN<"u"?PN.exports=e():typeof define=="function"&&define.amd?define(e):(t=t||self,t.JSBI=e())})(IN,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(V){return typeof V}:function(V){return V&&typeof Symbol=="function"&&V.constructor===Symbol&&V!==Symbol.prototype?"symbol":typeof V},r(U)}function n(U,V){if(!(U instanceof V))throw new TypeError("Cannot call a class as a function")}function i(U,V){for(var L,T=0;T<V.length;T++)L=V[T],L.enumerable=L.enumerable||!1,L.configurable=!0,"value"in L&&(L.writable=!0),Object.defineProperty(U,L.key,L)}function o(U,V,L){return V&&i(U.prototype,V),L&&i(U,L),Object.defineProperty(U,"prototype",{writable:!1}),U}function s(U,V){if(typeof V!="function"&&V!==null)throw new TypeError("Super expression must either be null or a function");U.prototype=Object.create(V&&V.prototype,{constructor:{value:U,writable:!0,configurable:!0}}),Object.defineProperty(U,"prototype",{writable:!1}),V&&d(U,V)}function a(U){return a=Object.setPrototypeOf?Object.getPrototypeOf:function(V){return V.__proto__||Object.getPrototypeOf(V)},a(U)}function d(U,V){return d=Object.setPrototypeOf||function(L,T){return L.__proto__=T,L},d(U,V)}function u(){if(typeof Reflect>"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,V,L){var T=[null];T.push.apply(T,V);var S=Function.bind.apply(U,T),k=new S;return L&&d(k,L.prototype),k},c.apply(null,arguments)}function l(U){return Function.toString.call(U).indexOf("[native code]")!==-1}function m(U){var V=typeof Map=="function"?new Map:void 0;return m=function(L){function T(){return c(L,arguments,a(this).constructor)}if(L===null||!l(L))return L;if(typeof L!="function")throw new TypeError("Super expression must either be null or a function");if(typeof V<"u"){if(V.has(L))return V.get(L);V.set(L,T)}return T.prototype=Object.create(L.prototype,{constructor:{value:T,enumerable:!1,writable:!0,configurable:!0}}),d(T,L)},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,V){if(V&&(typeof V=="object"||typeof V=="function"))return V;if(V!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return p(U)}function v(U){var V=u();return function(){var L,T=a(U);if(V){var S=a(this).constructor;L=Reflect.construct(T,arguments,S)}else L=T.apply(this,arguments);return g(this,L)}}function E(U,V){return A(U)||P(U,V)||I(U,V)||N()}function A(U){if(Array.isArray(U))return U}function P(U,V){var L=U==null?null:typeof Symbol<"u"&&U[Symbol.iterator]||U["@@iterator"];if(L!=null){var T,S,k=[],f=!0,y=!1;try{for(L=L.call(U);!(f=(T=L.next()).done)&&(k.push(T.value),!(V&&k.length===V));f=!0);}catch(w){y=!0,S=w}finally{try{f||L.return==null||L.return()}finally{if(y)throw S}}return k}}function I(U,V){if(U){if(typeof U=="string")return $(U,V);var L=Object.prototype.toString.call(U).slice(8,-1);return L==="Object"&&U.constructor&&(L=U.constructor.name),L==="Map"||L==="Set"?Array.from(U):L==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(L)?$(U,V):void 0}}function $(U,V){(V==null||V>U.length)&&(V=U.length);for(var L=0,T=Array(V);L<V;L++)T[L]=U[L];return T}function N(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function K(U,V){var L=typeof Symbol<"u"&&U[Symbol.iterator]||U["@@iterator"];if(!L){if(Array.isArray(U)||(L=I(U))||V&&U&&typeof U.length=="number"){L&&(U=L);var T=0,S=function(){};return{s:S,n:function(){return T>=U.length?{done:!0}:{done:!1,value:U[T++]}},e:function(w){throw w},f:S}}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(){L=L.call(U)},n:function(){var w=L.next();return f=w.done,w},e:function(w){y=!0,k=w},f:function(){try{f||L.return==null||L.return()}finally{if(y)throw k}}}}var F=function(U){var V=Math.abs,L=Math.max,T=Math.floor;function S(f,y){var w;if(n(this,S),w=k.call(this,f),w.sign=y,Object.setPrototypeOf(p(w),S.prototype),f>S.__kMaxLength)throw new RangeError("Maximum BigInt size exceeded");return w}s(S,U);var k=v(S);return o(S,[{key:"toDebugString",value:function(){var f,y=["BigInt["],w=K(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=0<arguments.length&&arguments[0]!==void 0?arguments[0]:10;if(2>f||36<f)throw new RangeError("toString() radix argument must be between 2 and 36");return this.length===0?"0":f&f-1?S.__toStringGeneric(this,f,!1):S.__toStringBasePowerOfTwo(this,f)}},{key:"valueOf",value:function(){throw new Error("Convert JSBI instances to native numbers using `toNumber`.")}},{key:"__copy",value:function(){for(var f=new S(this.length,this.sign),y=0;y<this.length;y++)f[y]=this[y];return f}},{key:"__trim",value:function(){for(var f=this.length,y=this[f-1];y===0;)f--,y=this[f-1],this.pop();return f===0&&(this.sign=!1),this}},{key:"__initializeDigits",value:function(){for(var f=0;f<this.length;f++)this[f]=0}},{key:"__clzmsd",value:function(){return S.__clz30(this.__digit(this.length-1))}},{key:"__inplaceMultiplyAdd",value:function(f,y,w){w>this.length&&(w=this.length);for(var _=32767&f,x=f>>>15,b=0,B=y,q=0;q<w;q++){var M=this.__digit(q),j=32767&M,J=M>>>15,Z=S.__imul(j,_),G=S.__imul(j,x),W=S.__imul(J,_),X=S.__imul(J,x),ee=B+Z+b;b=ee>>>30,ee&=1073741823,ee+=((32767&G)<<15)+((32767&W)<<15),b+=ee>>>30,B=X+(G>>>15)+(W>>>15),this.__setDigit(q,1073741823&ee)}if(b!==0||B!==0)throw new Error("implementation bug")}},{key:"__inplaceAdd",value:function(f,y,w){for(var _,x=0,b=0;b<w;b++)_=this.__halfDigit(y+b)+f.__halfDigit(b)+x,x=_>>>15,this.__setHalfDigit(y+b,32767&_);return x}},{key:"__inplaceSub",value:function(f,y,w){var _=0;if(1&y){y>>=1;for(var x=this.__digit(y),b=32767&x,B=0;B<w-1>>>1;B++){var q=f.__digit(B),M=(x>>>15)-(32767&q)-_;_=1&M>>>15,this.__setDigit(y+B,(32767&M)<<15|32767&b),x=this.__digit(y+B+1),b=(32767&x)-(q>>>15)-_,_=1&b>>>15}var j=f.__digit(B),J=(x>>>15)-(32767&j)-_;if(_=1&J>>>15,this.__setDigit(y+B,(32767&J)<<15|32767&b),y+B+1>=this.length)throw new RangeError("out of bounds");!(1&w)&&(x=this.__digit(y+B+1),b=(32767&x)-(j>>>15)-_,_=1&b>>>15,this.__setDigit(y+f.length,1073709056&x|32767&b))}else{y>>=1;for(var Z=0;Z<f.length-1;Z++){var G=this.__digit(y+Z),W=f.__digit(Z),X=(32767&G)-(32767&W)-_;_=1&X>>>15;var ee=(G>>>15)-(W>>>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 S.__zero();if(S.__isOneDigitInt(f))return 0>f?S.__oneDigit(-f,!0):S.__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 S.__fromDouble(f)}if(typeof f=="string"){var w=S.__fromString(f);if(w===null)throw new SyntaxError("Cannot convert "+f+" to a BigInt");return w}if(typeof f=="boolean")return f===!0?S.__oneDigit(1,!1):S.__zero();if(r(f)==="object"){if(f.constructor===S)return f;var _=S.__toPrimitive(f);return S.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=S.__clz30(_),b=30*y-x;if(1024<b)return f.sign?-1/0:1/0;var B=b-1,q=_,M=y-1,j=x+3,J=j===32?0:q<<j;J>>>=12;var Z=j-12,G=12<=j?0:q<<20+j,W=20+j;for(0<Z&&0<M&&(M--,q=f.__digit(M),J|=q>>>30-Z,G=q<<Z+2,W=Z+2);0<W&&0<M;)M--,q=f.__digit(M),G|=30<=W?q<<W-30:q>>>30-W,W-=30;var X=S.__decideRounding(f,W,M,q);if((X===1||X===0&&(1&G)==1)&&(G=G+1>>>0,G===0&&(J++,J>>>20!=0&&(J=0,B++,1023<B))))return f.sign?-1/0:1/0;var ee=f.sign?-2147483648:0;return B=B+1023<<20,S.__kBitConversionInts[1]=ee|B|J,S.__kBitConversionInts[0]=G,S.__kBitConversionDouble[0]}},{key:"unaryMinus",value:function(f){if(f.length===0)return f;var y=f.__copy();return y.sign=!f.sign,y}},{key:"bitwiseNot",value:function(f){return f.sign?S.__absoluteSubOne(f).__trim():S.__absoluteAddOne(f,!0)}},{key:"exponentiate",value:function(f,y){if(y.sign)throw new RangeError("Exponent must be positive");if(y.length===0)return S.__oneDigit(1,!1);if(f.length===0)return f;if(f.length===1&&f.__digit(0)===1)return f.sign&&!(1&y.__digit(0))?S.unaryMinus(f):f;if(1<y.length)throw new RangeError("BigInt too big");var w=y.__unsignedDigit(0);if(w===1)return f;if(w>=S.__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,b=new S(_,x);b.__initializeDigits();var B=1<<w%30;return b.__setDigit(_-1,B),b}var q=null,M=f;for(1&w&&(q=f),w>>=1;w!==0;w>>=1)M=S.multiply(M,M),1&w&&(q===null?q=M:q=S.multiply(q,M));return q}},{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 S(w,f.sign!==y.sign);_.__initializeDigits();for(var x=0;x<f.length;x++)S.__multiplyAccumulate(y,f.__digit(x),_,x);return _.__trim()}},{key:"divide",value:function(f,y){if(y.length===0)throw new RangeError("Division by zero");if(0>S.__absoluteCompare(f,y))return S.__zero();var w,_=f.sign!==y.sign,x=y.__unsignedDigit(0);if(y.length===1&&32767>=x){if(x===1)return _===f.sign?f:S.unaryMinus(f);w=S.__absoluteDivSmall(f,x,null)}else w=S.__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>S.__absoluteCompare(y,w))return y;var _=w.__unsignedDigit(0);if(w.length===1&&32767>=_){if(_===1)return S.__zero();var x=S.__absoluteModSmall(y,_);return x===0?S.__zero():S.__oneDigit(x,y.sign)}var b=S.__absoluteDivLarge(y,w,!1,!0);return b.sign=y.sign,b.__trim()}},{key:"add",value:function(f,y){var w=f.sign;return w===y.sign?S.__absoluteAdd(f,y,w):0<=S.__absoluteCompare(f,y)?S.__absoluteSub(f,y,w):S.__absoluteSub(y,f,!w)}},{key:"subtract",value:function(f,y){var w=f.sign;return w===y.sign?0<=S.__absoluteCompare(f,y)?S.__absoluteSub(f,y,w):S.__absoluteSub(y,f,!w):S.__absoluteAdd(f,y,w)}},{key:"leftShift",value:function(f,y){return y.length===0||f.length===0?f:y.sign?S.__rightShiftByAbsolute(f,y):S.__leftShiftByAbsolute(f,y)}},{key:"signedRightShift",value:function(f,y){return y.length===0||f.length===0?f:y.sign?S.__leftShiftByAbsolute(f,y):S.__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>S.__compareToBigInt(f,y)}},{key:"lessThanOrEqual",value:function(f,y){return 0>=S.__compareToBigInt(f,y)}},{key:"greaterThan",value:function(f,y){return 0<S.__compareToBigInt(f,y)}},{key:"greaterThanOrEqual",value:function(f,y){return 0<=S.__compareToBigInt(f,y)}},{key:"equal",value:function(f,y){if(f.sign!==y.sign||f.length!==y.length)return!1;for(var w=0;w<f.length;w++)if(f.__digit(w)!==y.__digit(w))return!1;return!0}},{key:"notEqual",value:function(f,y){return!S.equal(f,y)}},{key:"bitwiseAnd",value:function(f,y){if(!f.sign&&!y.sign)return S.__absoluteAnd(f,y).__trim();if(f.sign&&y.sign){var w=L(f.length,y.length)+1,_=S.__absoluteSubOne(f,w),x=S.__absoluteSubOne(y);return _=S.__absoluteOr(_,x,_),S.__absoluteAddOne(_,!0,_).__trim()}if(f.sign){var b=[y,f];f=b[0],y=b[1]}return S.__absoluteAndNot(f,S.__absoluteSubOne(y)).__trim()}},{key:"bitwiseXor",value:function(f,y){if(!f.sign&&!y.sign)return S.__absoluteXor(f,y).__trim();if(f.sign&&y.sign){var w=L(f.length,y.length),_=S.__absoluteSubOne(f,w),x=S.__absoluteSubOne(y);return S.__absoluteXor(_,x,_).__trim()}var b=L(f.length,y.length)+1;if(f.sign){var B=[y,f];f=B[0],y=B[1]}var q=S.__absoluteSubOne(y,b);return q=S.__absoluteXor(q,f,q),S.__absoluteAddOne(q,!0,q).__trim()}},{key:"bitwiseOr",value:function(f,y){var w=L(f.length,y.length);if(!f.sign&&!y.sign)return S.__absoluteOr(f,y).__trim();if(f.sign&&y.sign){var _=S.__absoluteSubOne(f,w),x=S.__absoluteSubOne(y);return _=S.__absoluteAnd(_,x,_),S.__absoluteAddOne(_,!0,_).__trim()}if(f.sign){var b=[y,f];f=b[0],y=b[1]}var B=S.__absoluteSubOne(y,w);return B=S.__absoluteAndNot(B,f,B),S.__absoluteAddOne(B,!0,B).__trim()}},{key:"asIntN",value:function(f,y){if(y.length===0)return y;if(f=T(f),0>f)throw new RangeError("Invalid value: not (convertible to) a safe integer");if(f===0)return S.__zero();if(f>=S.__kMaxLengthBits)return y;var w=0|(f+29)/30;if(y.length<w)return y;var _=y.__unsignedDigit(w-1),x=1<<(f-1)%30;if(y.length===w&&_<x)return y;if((_&x)!==x)return S.__truncateToNBits(f,y);if(!y.sign)return S.__truncateAndSubFromPowerOfTwo(f,y,!0);if(!(_&x-1)){for(var b=w-2;0<=b;b--)if(y.__digit(b)!==0)return S.__truncateAndSubFromPowerOfTwo(f,y,!1);return y.length===w&&_===x?y:S.__truncateToNBits(f,y)}return S.__truncateAndSubFromPowerOfTwo(f,y,!1)}},{key:"asUintN",value:function(f,y){if(y.length===0)return y;if(f=T(f),0>f)throw new RangeError("Invalid value: not (convertible to) a safe integer");if(f===0)return S.__zero();if(y.sign){if(f>S.__kMaxLengthBits)throw new RangeError("BigInt too big");return S.__truncateAndSubFromPowerOfTwo(f,y,!1)}if(f>=S.__kMaxLengthBits)return y;var w=0|(f+29)/30;if(y.length<w)return y;var _=f%30;if(y.length==w){if(_===0)return y;var x=y.__digit(w-1);if(!(x>>>_))return y}return S.__truncateToNBits(f,y)}},{key:"ADD",value:function(f,y){if(f=S.__toPrimitive(f),y=S.__toPrimitive(y),typeof f=="string")return typeof y!="string"&&(y=y.toString()),f+y;if(typeof y=="string")return f.toString()+y;if(f=S.__toNumeric(f),y=S.__toNumeric(y),S.__isBigInt(f)&&S.__isBigInt(y))return S.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 S.__compare(f,y,0)}},{key:"LE",value:function(f,y){return S.__compare(f,y,1)}},{key:"GT",value:function(f,y){return S.__compare(f,y,2)}},{key:"GE",value:function(f,y){return S.__compare(f,y,3)}},{key:"EQ",value:function(f,y){for(;;){if(S.__isBigInt(f))return S.__isBigInt(y)?S.equal(f,y):S.EQ(y,f);if(typeof f=="number"){if(S.__isBigInt(y))return S.__equalToNumber(y,f);if(r(y)!=="object")return f==y;y=S.__toPrimitive(y)}else if(typeof f=="string"){if(S.__isBigInt(y))return f=S.__fromString(f),f!==null&&S.equal(f,y);if(r(y)!=="object")return f==y;y=S.__toPrimitive(y)}else if(typeof f=="boolean"){if(S.__isBigInt(y))return S.__equalToNumber(y,+f);if(r(y)!=="object")return f==y;y=S.__toPrimitive(y)}else if(r(f)==="symbol"){if(S.__isBigInt(y))return!1;if(r(y)!=="object")return f==y;y=S.__toPrimitive(y)}else if(r(f)==="object"){if(r(y)==="object"&&y.constructor!==S)return f==y;f=S.__toPrimitive(f)}else return f==y}}},{key:"NE",value:function(f,y){return!S.EQ(f,y)}},{key:"DataViewGetBigInt64",value:function(f,y){var w=2<arguments.length&&arguments[2]!==void 0&&arguments[2];return S.asIntN(64,S.DataViewGetBigUint64(f,y,w))}},{key:"DataViewGetBigUint64",value:function(f,y){var w=2<arguments.length&&arguments[2]!==void 0&&arguments[2],_=w?[4,0]:[0,4],x=E(_,2),b=x[0],B=x[1],q=f.getUint32(y+b,w),M=f.getUint32(y+B,w),j=new S(3,!1);return j.__setDigit(0,1073741823&M),j.__setDigit(1,(268435455&q)<<2|M>>>30),j.__setDigit(2,q>>>28),j.__trim()}},{key:"DataViewSetBigInt64",value:function(f,y,w){var _=3<arguments.length&&arguments[3]!==void 0&&arguments[3];S.DataViewSetBigUint64(f,y,w,_)}},{key:"DataViewSetBigUint64",value:function(f,y,w){var _=3<arguments.length&&arguments[3]!==void 0&&arguments[3];w=S.asUintN(64,w);var x=0,b=0;if(0<w.length&&(b=w.__digit(0),1<w.length)){var B=w.__digit(1);b|=B<<30,x=B>>>2,2<w.length&&(x|=w.__digit(2)<<28)}var q=_?[4,0]:[0,4],M=E(q,2),j=M[0],J=M[1];f.setUint32(y+j,x,_),f.setUint32(y+J,b,_)}},{key:"__zero",value:function(){return new S(0,!1)}},{key:"__oneDigit",value:function(f,y){var w=new S(1,y);return w.__setDigit(0,f),w}},{key:"__decideRounding",value:function(f,y,w,_){if(0<y)return-1;var x;if(0>y)x=-y-1;else{if(w===0)return-1;w--,_=f.__digit(w),x=29}var b=1<<x;if(!(_&b))return-1;if(b-=1,(_&b)!=0)return 1;for(;0<w;)if(w--,f.__digit(w)!==0)return 1;return 0}},{key:"__fromDouble",value:function(f){S.__kBitConversionDouble[0]=f;var y,w=2047&S.__kBitConversionInts[1]>>>20,_=w-1023,x=(0|_/30)+1,b=new S(x,0>f),B=1048575&S.__kBitConversionInts[1]|1048576,q=S.__kBitConversionInts[0],M=20,j=_%30,J=0;if(j<M){var Z=M-j;J=Z+32,y=B>>>Z,B=B<<32-Z|q>>>Z,q<<=32-Z}else if(j===M)J=32,y=B,B=q,q=0;else{var G=j-M;J=32-G,y=B<<G|q>>>32-G,B=q<<G,q=0}b.__setDigit(x-1,y);for(var W=x-2;0<=W;W--)0<J?(J-=30,y=B>>>2,B=B<<30|q>>>2,q<<=30):y=0,b.__setDigit(W,y);return b.__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=1<arguments.length&&arguments[1]!==void 0?arguments[1]:0,w=0,_=f.length,x=0;if(x===_)return S.__zero();for(var b=f.charCodeAt(x);S.__isWhitespace(b);){if(++x===_)return S.__zero();b=f.charCodeAt(x)}if(b===43){if(++x===_)return null;b=f.charCodeAt(x),w=1}else if(b===45){if(++x===_)return null;b=f.charCodeAt(x),w=-1}if(y===0){if(y=10,b===48){if(++x===_)return S.__zero();if(b=f.charCodeAt(x),b===88||b===120){if(y=16,++x===_)return null;b=f.charCodeAt(x)}else if(b===79||b===111){if(y=8,++x===_)return null;b=f.charCodeAt(x)}else if(b===66||b===98){if(y=2,++x===_)return null;b=f.charCodeAt(x)}}}else if(y===16&&b===48){if(++x===_)return S.__zero();if(b=f.charCodeAt(x),b===88||b===120){if(++x===_)return null;b=f.charCodeAt(x)}}if(w!==0&&y!==10)return null;for(;b===48;){if(++x===_)return S.__zero();b=f.charCodeAt(x)}var B=_-x,q=S.__kMaxBitsPerChar[y],M=S.__kBitsPerCharTableMultiplier-1;if(B>1073741824/q)return null;var j=q*B+M>>>S.__kBitsPerCharTableShift,J=new S(0|(j+29)/30,!1),Z=10>y?y:10,G=10<y?y-10:0;if(y&y-1){J.__initializeDigits();var pe=!1,xe=0;do{for(var Ue,le=0,ge=1;;){if(Ue=void 0,b-48>>>0<Z)Ue=b-48;else if((32|b)-97>>>0<G)Ue=(32|b)-87;else{pe=!0;break}var be=ge*y;if(1073741823<be)break;if(ge=be,le=le*y+Ue,xe++,++x===_){pe=!0;break}b=f.charCodeAt(x)}M=30*S.__kBitsPerCharTableMultiplier-1;var De=0|(q*xe+M>>>S.__kBitsPerCharTableShift)/30;J.__inplaceMultiplyAdd(ge,le,De)}while(!pe)}else{q>>=S.__kBitsPerCharTableShift;var W=[],X=[],ee=!1;do{for(var ue,ae=0,ce=0;;){if(ue=void 0,b-48>>>0<Z)ue=b-48;else if((32|b)-97>>>0<G)ue=(32|b)-87;else{ee=!0;break}if(ce+=q,ae=ae<<q|ue,++x===_){ee=!0;break}if(b=f.charCodeAt(x),30<ce+q)break}W.push(ae),X.push(ce)}while(!ee);S.__fillFromParts(J,W,X)}if(x!==_){if(!S.__isWhitespace(b))return null;for(x++;x<_;x++)if(b=f.charCodeAt(x),!S.__isWhitespace(b))return null}return J.sign=w===-1,J.__trim()}},{key:"__fillFromParts",value:function(f,y,w){for(var _=0,x=0,b=0,B=y.length-1;0<=B;B--){var q=y[B],M=w[B];x|=q<<b,b+=M,b===30?(f.__setDigit(_++,x),b=0,x=0):30<b&&(f.__setDigit(_++,1073741823&x),b-=30,x=q>>>M-b)}if(x!==0){if(_>=f.length)throw new Error("implementation bug");f.__setDigit(_++,x)}for(;_<f.length;_++)f.__setDigit(_,0)}},{key:"__toStringBasePowerOfTwo",value:function(f,y){var w=f.length,_=y-1;_=(85&_>>>1)+(85&_),_=(51&_>>>2)+(51&_),_=(15&_>>>4)+(15&_);var x=_,b=y-1,B=f.__digit(w-1),q=S.__clz30(B),M=0|(30*w-q+x-1)/x;if(f.sign&&M++,268435456<M)throw new Error("string too long");for(var j=Array(M),J=M-1,Z=0,G=0,W=0;W<w-1;W++){var X=f.__digit(W),ee=(Z|X<<G)&b;j[J--]=S.__kConversionChars[ee];var ue=x-G;for(Z=X>>>ue,G=30-ue;G>=x;)j[J--]=S.__kConversionChars[Z&b],Z>>>=x,G-=x}var ae=(Z|B<<G)&b;for(j[J--]=S.__kConversionChars[ae],Z=B>>>x-G;Z!==0;)j[J--]=S.__kConversionChars[Z&b],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 b=30*_-S.__clz30(f.__digit(_-1)),B=S.__kMaxBitsPerChar[y],q=B-1,M=b*S.__kBitsPerCharTableMultiplier;M+=q-1,M=0|M/q;var j,J,Z=M+1>>1,G=S.exponentiate(S.__oneDigit(y,!1),S.__oneDigit(Z,!1)),W=G.__unsignedDigit(0);if(G.length===1&&32767>=W){j=new S(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/W),ee=0|X%W;J=ee.toString(y)}else{var ae=S.__absoluteDivLarge(f,G,!0,!0);j=ae.quotient;var ce=ae.remainder.__trim();J=S.__toStringGeneric(ce,y,!0)}j.__trim();for(var pe=S.__toStringGeneric(j,y,!0);J.length<Z;)J="0"+J;return w===!1&&f.sign&&(pe="-"+pe),pe+J}},{key:"__unequalSign",value:function(f){return f?-1:1}},{key:"__absoluteGreater",value:function(f){return f?-1:1}},{key:"__absoluteLess",value:function(f){return f?1:-1}},{key:"__compareToBigInt",value:function(f,y){var w=f.sign;if(w!==y.sign)return S.__unequalSign(w);var _=S.__absoluteCompare(f,y);return 0<_?S.__absoluteGreater(w):0>_?S.__absoluteLess(w):0}},{key:"__compareToNumber",value:function(f,y){if(S.__isOneDigitInt(y)){var w=f.sign,_=0>y;if(w!==_)return S.__unequalSign(w);if(f.length===0){if(_)throw new Error("implementation bug");return y===0?0:-1}if(1<f.length)return S.__absoluteGreater(w);var x=V(y),b=f.__unsignedDigit(0);return b>x?S.__absoluteGreater(w):b<x?S.__absoluteLess(w):0}return S.__compareToDouble(f,y)}},{key:"__compareToDouble",value:function(f,y){if(y!==y)return y;if(y===1/0)return-1;if(y===-1/0)return 1;var w=f.sign;if(w!==0>y)return S.__unequalSign(w);if(y===0)throw new Error("implementation bug: should be handled elsewhere");if(f.length===0)return-1;S.__kBitConversionDouble[0]=y;var _=2047&S.__kBitConversionInts[1]>>>20;if(_==2047)throw new Error("implementation bug: handled elsewhere");var x=_-1023;if(0>x)return S.__absoluteGreater(w);var b=f.length,B=f.__digit(b-1),q=S.__clz30(B),M=30*b-q,j=x+1;if(M<j)return S.__absoluteLess(w);if(M>j)return S.__absoluteGreater(w);var J=1048576|1048575&S.__kBitConversionInts[1],Z=S.__kBitConversionInts[0],G=20,W=29-q;if(W!==(0|(M-1)%30))throw new Error("implementation bug");var X,ee=0;if(W<G){var ue=G-W;ee=ue+32,X=J>>>ue,J=J<<32-ue|Z>>>ue,Z<<=32-ue}else if(W===G)ee=32,X=J,J=Z,Z=0;else{var ae=W-G;ee=32-ae,X=J<<ae|Z>>>32-ae,J=Z<<ae,Z=0}if(B>>>=0,X>>>=0,B>X)return S.__absoluteGreater(w);if(B<X)return S.__absoluteLess(w);for(var ce=b-2;0<=ce;ce--){0<ee?(ee-=30,X=J>>>2,J=J<<30|Z>>>2,Z<<=30):X=0;var pe=f.__unsignedDigit(ce);if(pe>X)return S.__absoluteGreater(w);if(pe<X)return S.__absoluteLess(w)}if(J!==0||Z!==0){if(ee===0)throw new Error("implementation bug");return S.__absoluteLess(w)}return 0}},{key:"__equalToNumber",value:function(f,y){return S.__isOneDigitInt(y)?y===0?f.length===0:f.length===1&&f.sign===0>y&&f.__unsignedDigit(0)===V(y):S.__compareToDouble(f,y)===0}},{key:"__comparisonResultToBool",value:function(f,y){return y===0?0>f:y===1?0>=f:y===2?0<f:y===3?0<=f:void 0}},{key:"__compare",value:function(f,y,w){if(f=S.__toPrimitive(f),y=S.__toPrimitive(y),typeof f=="string"&&typeof y=="string")switch(w){case 0:return f<y;case 1:return f<=y;case 2:return f>y;case 3:return f>=y}if(S.__isBigInt(f)&&typeof y=="string")return y=S.__fromString(y),y!==null&&S.__comparisonResultToBool(S.__compareToBigInt(f,y),w);if(typeof f=="string"&&S.__isBigInt(y))return f=S.__fromString(f),f!==null&&S.__comparisonResultToBool(S.__compareToBigInt(f,y),w);if(f=S.__toNumeric(f),y=S.__toNumeric(y),S.__isBigInt(f)){if(S.__isBigInt(y))return S.__comparisonResultToBool(S.__compareToBigInt(f,y),w);if(typeof y!="number")throw new Error("implementation bug");return S.__comparisonResultToBool(S.__compareToNumber(f,y),w)}if(typeof f!="number")throw new Error("implementation bug");if(S.__isBigInt(y))return S.__comparisonResultToBool(S.__compareToNumber(y,f),2^w);if(typeof y!="number")throw new Error("implementation bug");return w===0?f<y:w===1?f<=y:w===2?f>y:w===3?f>=y:void 0}},{key:"__absoluteAdd",value:function(f,y,w){if(f.length<y.length)return S.__absoluteAdd(y,f,w);if(f.length===0)return f;if(y.length===0)return f.sign===w?f:S.unaryMinus(f);var _=f.length;(f.__clzmsd()===0||y.length===f.length&&y.__clzmsd()===0)&&_++;for(var x,b=new S(_,w),B=0,q=0;q<y.length;q++)x=f.__digit(q)+y.__digit(q)+B,B=x>>>30,b.__setDigit(q,1073741823&x);for(;q<f.length;q++){var M=f.__digit(q)+B;B=M>>>30,b.__setDigit(q,1073741823&M)}return q<b.length&&b.__setDigit(q,B),b.__trim()}},{key:"__absoluteSub",value:function(f,y,w){if(f.length===0)return f;if(y.length===0)return f.sign===w?f:S.unaryMinus(f);for(var _,x=new S(f.length,w),b=0,B=0;B<y.length;B++)_=f.__digit(B)-y.__digit(B)-b,b=1&_>>>30,x.__setDigit(B,1073741823&_);for(;B<f.length;B++){var q=f.__digit(B)-b;b=1&q>>>30,x.__setDigit(B,1073741823&q)}return x.__trim()}},{key:"__absoluteAddOne",value:function(f,y){var w=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null,_=f.length;w===null?w=new S(_,y):w.sign=y;for(var x,b=1,B=0;B<_;B++)x=f.__digit(B)+b,b=x>>>30,w.__setDigit(B,1073741823&x);return b!==0&&w.__setDigitGrow(_,1),w}},{key:"__absoluteSubOne",value:function(f,y){var w=f.length;y=y||w;for(var _,x=new S(y,!1),b=1,B=0;B<w;B++)_=f.__digit(B)-b,b=1&_>>>30,x.__setDigit(B,1073741823&_);if(b!==0)throw new Error("implementation bug");for(var q=w;q<y;q++)x.__setDigit(q,0);return x}},{key:"__absoluteAnd",value:function(f,y){var w=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null,_=f.length,x=y.length,b=x;if(_<x){b=_;var B=f,q=_;f=y,_=x,y=B,x=q}var M=b;w===null?w=new S(M,!1):M=w.length;for(var j=0;j<b;j++)w.__setDigit(j,f.__digit(j)&y.__digit(j));for(;j<M;j++)w.__setDigit(j,0);return w}},{key:"__absoluteAndNot",value:function(f,y){var w=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null,_=f.length,x=y.length,b=x;_<x&&(b=_);var B=_;w===null?w=new S(B,!1):B=w.length;for(var q=0;q<b;q++)w.__setDigit(q,f.__digit(q)&~y.__digit(q));for(;q<_;q++)w.__setDigit(q,f.__digit(q));for(;q<B;q++)w.__setDigit(q,0);return w}},{key:"__absoluteOr",value:function(f,y){var w=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null,_=f.length,x=y.length,b=x;if(_<x){b=_;var B=f,q=_;f=y,_=x,y=B,x=q}var M=_;w===null?w=new S(M,!1):M=w.length;for(var j=0;j<b;j++)w.__setDigit(j,f.__digit(j)|y.__digit(j));for(;j<_;j++)w.__setDigit(j,f.__digit(j));for(;j<M;j++)w.__setDigit(j,0);return w}},{key:"__absoluteXor",value:function(f,y){var w=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null,_=f.length,x=y.length,b=x;if(_<x){b=_;var B=f,q=_;f=y,_=x,y=B,x=q}var M=_;w===null?w=new S(M,!1):M=w.length;for(var j=0;j<b;j++)w.__setDigit(j,f.__digit(j)^y.__digit(j));for(;j<_;j++)w.__setDigit(j,f.__digit(j));for(;j<M;j++)w.__setDigit(j,0);return w}},{key:"__absoluteCompare",value:function(f,y){var w=f.length-y.length;if(w!=0)return w;for(var _=f.length-1;0<=_&&f.__digit(_)===y.__digit(_);)_--;return 0>_?0:f.__unsignedDigit(_)>y.__unsignedDigit(_)?1:-1}},{key:"__multiplyAccumulate",value:function(f,y,w,_){if(y!==0){for(var x=32767&y,b=y>>>15,B=0,q=0,M=0;M<f.length;M++,_++){var j=w.__digit(_),J=f.__digit(M),Z=32767&J,G=J>>>15,W=S.__imul(Z,x),X=S.__imul(Z,b),ee=S.__imul(G,x),ue=S.__imul(G,b);j+=q+W+B,B=j>>>30,j&=1073741823,j+=((32767&X)<<15)+((32767&ee)<<15),B+=j>>>30,q=ue+(X>>>15)+(ee>>>15),w.__setDigit(_,1073741823&j)}for(;B!==0||q!==0;_++){var ae=w.__digit(_);ae+=B+q,q=0,B=ae>>>30,w.__setDigit(_,1073741823&ae)}}}},{key:"__internalMultiplyAdd",value:function(f,y,w,_,x){for(var b=w,B=0,q=0;q<_;q++){var M=f.__digit(q),j=S.__imul(32767&M,y),J=S.__imul(M>>>15,y),Z=j+((32767&J)<<15)+B+b;b=Z>>>30,B=J>>>15,x.__setDigit(q,1073741823&Z)}if(x.length>_)for(x.__setDigit(_++,b+B);_<x.length;)x.__setDigit(_++,0);else if(b+B!==0)throw new Error("implementation bug")}},{key:"__absoluteDivSmall",value:function(f,y){var w=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;w===null&&(w=new S(f.length,!1));for(var _=0,x=2*f.length-1;0<=x;x-=2){var b=(_<<15|f.__halfDigit(x))>>>0,B=0|b/y;_=0|b%y,b=(_<<15|f.__halfDigit(x-1))>>>0;var q=0|b/y;_=0|b%y,w.__setDigit(x>>>1,B<<15|q)}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(),b=y.length,B=f.__halfDigitLength()-x,q=null;w&&(q=new S(B+2>>>1,!1),q.__initializeDigits());var M=new S(x+2>>>1,!1);M.__initializeDigits();var j=S.__clz15(y.__halfDigit(x-1));0<j&&(y=S.__specialLeftShift(y,j,0));for(var J=S.__specialLeftShift(f,j,1),Z=y.__halfDigit(x-1),G=0,W=B;0<=W;W--){var X=32767,ee=J.__halfDigit(W+x);if(ee!==Z){var ue=(ee<<15|J.__halfDigit(W+x-1))>>>0;X=0|ue/Z;for(var ae=0|ue%Z,ce=y.__halfDigit(x-2),pe=J.__halfDigit(W+x-2);S.__imul(X,ce)>>>0>(ae<<16|pe)>>>0&&(X--,ae+=Z,!(32767<ae)););}S.__internalMultiplyAdd(y,X,0,b,M);var xe=J.__inplaceSub(M,W,x+1);xe!==0&&(xe=J.__inplaceAdd(y,W,x),J.__setHalfDigit(W+x,32767&J.__halfDigit(W+x)+xe),X--),w&&(1&W?G=X<<15:q.__setDigit(W>>>1,G|X))}if(_)return J.__inplaceRightShift(j),w?{quotient:q,remainder:J}:J;if(w)return q;throw new Error("unreachable")}},{key:"__clz15",value:function(f){return S.__clz30(f)-15}},{key:"__specialLeftShift",value:function(f,y,w){var _=f.length,x=new S(_+w,!1);if(y===0){for(var b=0;b<_;b++)x.__setDigit(b,f.__digit(b));return 0<w&&x.__setDigit(_,0),x}for(var B,q=0,M=0;M<_;M++)B=f.__digit(M),x.__setDigit(M,1073741823&B<<y|q),q=B>>>30-y;return 0<w&&x.__setDigit(_,q),x}},{key:"__leftShiftByAbsolute",value:function(f,y){var w=S.__toShiftAmount(y);if(0>w)throw new RangeError("BigInt too big");var _=0|w/30,x=w%30,b=f.length,B=x!==0&&f.__digit(b-1)>>>30-x!=0,q=b+_+(B?1:0),M=new S(q,f.sign);if(x===0){for(var j=0;j<_;j++)M.__setDigit(j,0);for(;j<q;j++)M.__setDigit(j,f.__digit(j-_))}else{for(var J=0,Z=0;Z<_;Z++)M.__setDigit(Z,0);for(var G,W=0;W<b;W++)G=f.__digit(W),M.__setDigit(W+_,1073741823&G<<x|J),J=G>>>30-x;if(B)M.__setDigit(b+_,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=S.__toShiftAmount(y);if(0>x)return S.__rightShiftByMaximum(_);var b=0|x/30,B=x%30,q=w-b;if(0>=q)return S.__rightShiftByMaximum(_);var M=!1;if(_){if(f.__digit(b)&(1<<B)-1)M=!0;else for(var j=0;j<b;j++)if(f.__digit(j)!==0){M=!0;break}}if(M&&B===0){var J=f.__digit(w-1);!~J&&q++}var Z=new S(q,_);if(B===0){Z.__setDigit(q-1,0);for(var G=b;G<w;G++)Z.__setDigit(G-b,f.__digit(G))}else{for(var W,X=f.__digit(b)>>>B,ee=w-b-1,ue=0;ue<ee;ue++)W=f.__digit(ue+b+1),Z.__setDigit(ue,1073741823&W<<30-B|X),X=W>>>B;Z.__setDigit(ee,X)}return M&&(Z=S.__absoluteAddOne(Z,!0,Z)),Z.__trim()}},{key:"__rightShiftByMaximum",value:function(f){return f?S.__oneDigit(1,!0):S.__zero()}},{key:"__toShiftAmount",value:function(f){if(1<f.length)return-1;var y=f.__unsignedDigit(0);return y>S.__kMaxLengthBits?-1:y}},{key:"__toPrimitive",value:function(f){var y=1<arguments.length&&arguments[1]!==void 0?arguments[1]:"default";if(r(f)!=="object"||f.constructor===S)return f;if(typeof Symbol<"u"&&r(Symbol.toPrimitive)==="symbol"){var w=f[Symbol.toPrimitive];if(w){var _=w(y);if(r(_)!=="object")return _;throw new TypeError("Cannot convert object to primitive value")}}var x=f.valueOf;if(x){var b=x.call(f);if(r(b)!=="object")return b}var B=f.toString;if(B){var q=B.call(f);if(r(q)!=="object")return q}throw new TypeError("Cannot convert object to primitive value")}},{key:"__toNumeric",value:function(f){return S.__isBigInt(f)?f:+f}},{key:"__isBigInt",value:function(f){return r(f)==="object"&&f!==null&&f.constructor===S}},{key:"__truncateToNBits",value:function(f,y){for(var w=0|(f+29)/30,_=new S(w,y.sign),x=w-1,b=0;b<x;b++)_.__setDigit(b,y.__digit(b));var B=y.__digit(x);if(f%30!=0){var q=32-f%30;B=B<<q>>>q}return _.__setDigit(x,B),_.__trim()}},{key:"__truncateAndSubFromPowerOfTwo",value:function(f,y,w){for(var _=Math.min,x,b=0|(f+29)/30,B=new S(b,w),q=0,M=b-1,j=0,J=_(M,y.length);q<J;q++)x=0-y.__digit(q)-j,j=1&x>>>30,B.__setDigit(q,1073741823&x);for(;q<M;q++)B.__setDigit(q,0|1073741823&-j);var Z,G=M<y.length?y.__digit(M):0,W=f%30;if(W===0)Z=0-G-j,Z&=1073741823;else{var X=32-W;G=G<<X>>>X;var ee=1<<32-X;Z=ee-G-j,Z&=ee-1}return B.__setDigit(M,Z),B.__trim()}},{key:"__digitPow",value:function(f,y){for(var w=1;0<y;)1&y&&(w*=f),y>>>=1,f*=f;return w}},{key:"__isOneDigitInt",value:function(f){return(1073741823&f)===f}}]),S}(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<<F.__kBitsPerCharTableShift,F.__kConversionChars=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"],F.__kBitConversionBuffer=new ArrayBuffer(8),F.__kBitConversionDouble=new Float64Array(F.__kBitConversionBuffer),F.__kBitConversionInts=new Int32Array(F.__kBitConversionBuffer),F.__clz30=e?function(U){return e(U)-2}:function(U){var V=Math.LN2,L=Math.log;return U===0?30:0|29-(0|L(U>>>0)/V)},F.__imul=t||function(U,V){return 0|U*V},F})});var f6=H(Hr=>{"use strict";h();Object.defineProperty(Hr,"__esModule",{value:!0});Hr.regexpCode=Hr.getEsmExportName=Hr.getProperty=Hr.safeStringify=Hr.stringify=Hr.strConcat=Hr.addCodeArg=Hr.str=Hr._=Hr.nil=Hr._Code=Hr.Name=Hr.IDENTIFIER=Hr._CodeOrName=void 0;var u6=class{};Hr._CodeOrName=u6;Hr.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var qg=class extends u6{constructor(e){if(super(),!Hr.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}}};Hr.Name=qg;var Id=class extends u6{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 qg&&(r[n.str]=(r[n.str]||0)+1),r),{})}};Hr._Code=Id;Hr.nil=new Id("");function cfe(t,...e){let r=[t[0]],n=0;for(;n<e.length;)jj(r,e[n]),r.push(t[++n]);return new Id(r)}Hr._=cfe;var Nj=new Id("+");function dfe(t,...e){let r=[l6(t[0])],n=0;for(;n<e.length;)r.push(Nj),jj(r,e[n]),r.push(Nj,l6(t[++n]));return _Ke(r),new Id(r)}Hr.str=dfe;function jj(t,e){e instanceof Id?t.push(...e._items):e instanceof qg?t.push(e):t.push(SKe(e))}Hr.addCodeArg=jj;function _Ke(t){let e=1;for(;e<t.length-1;){if(t[e]===Nj){let r=xKe(t[e-1],t[e+1]);if(r!==void 0){t.splice(e-1,3,r);continue}t[e++]="+"}e++}}function xKe(t,e){if(e==='""')return t;if(t==='""')return e;if(typeof t=="string")return e instanceof qg||t[t.length-1]!=='"'?void 0:typeof e!="string"?`${t.slice(0,-1)}${e}"`:e[0]==='"'?t.slice(0,-1)+e.slice(1):void 0;if(typeof e=="string"&&e[0]==='"'&&!(t instanceof qg))return`"${t}${e.slice(1)}`}function EKe(t,e){return e.emptyStr()?t:t.emptyStr()?e:dfe`${t}${e}`}Hr.strConcat=EKe;function SKe(t){return typeof t=="number"||typeof t=="boolean"||t===null?t:l6(Array.isArray(t)?t.join(","):t)}function AKe(t){return new Id(l6(t))}Hr.stringify=AKe;function l6(t){return JSON.stringify(t).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}Hr.safeStringify=l6;function TKe(t){return typeof t=="string"&&Hr.IDENTIFIER.test(t)?new Id(`.${t}`):cfe`[${t}]`}Hr.getProperty=TKe;function IKe(t){if(typeof t=="string"&&Hr.IDENTIFIER.test(t))return new Id(`${t}`);throw new Error(`CodeGen: invalid export name: ${t}, use explicit $id name mapping`)}Hr.getEsmExportName=IKe;function PKe(t){return new Id(t.toString())}Hr.regexpCode=PKe});var Kj=H(fa=>{"use strict";h();Object.defineProperty(fa,"__esModule",{value:!0});fa.ValueScope=fa.ValueScopeName=fa.Scope=fa.varKinds=fa.UsedValueState=void 0;var La=f6(),Uj=class extends Error{constructor(e){super(`CodeGen: "code" for ${e} not defined`),this.value=e.value}},qj;(function(t){t[t.Started=0]="Started",t[t.Completed=1]="Completed"})(qj=fa.UsedValueState||(fa.UsedValueState={}));fa.varKinds={const:new La.Name("const"),let:new La.Name("let"),var:new La.Name("var")};var bI=class{constructor({prefixes:e,parent:r}={}){this._names={},this._prefixes=e,this._parent=r}toName(e){return e instanceof La.Name?e:this.name(e)}name(e){return new La.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}}};fa.Scope=bI;var wI=class extends La.Name{constructor(e,r){super(r),this.prefix=e}setValue(e,{property:r,itemIndex:n}){this.value=e,this.scopePath=(0,La._)`.${new La.Name(r)}[${n}]`}};fa.ValueScopeName=wI;var kKe=(0,La._)`\n`,Lj=class extends bI{constructor(e){super(e),this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?kKe:La.nil}}get(){return this._scope}name(e){return new wI(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,La._)`${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=La.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,qj.Started);let c=r(u);if(c){let l=this.opts.es5?fa.varKinds.var:fa.varKinds.const;o=(0,La._)`${o}${l} ${u} = ${c};${this.opts._n}`}else if(c=i?.(u))o=(0,La._)`${o}${c}${this.opts._n}`;else throw new Uj(u);d.set(u,qj.Completed)})}return o}};fa.ValueScope=Lj});var tr=H(vr=>{"use strict";h();Object.defineProperty(vr,"__esModule",{value:!0});vr.or=vr.and=vr.not=vr.CodeGen=vr.operators=vr.varKinds=vr.ValueScopeName=vr.ValueScope=vr.Scope=vr.Name=vr.regexpCode=vr.stringify=vr.getProperty=vr.nil=vr.strConcat=vr.str=vr._=void 0;var jr=f6(),Ru=Kj(),Vm=f6();Object.defineProperty(vr,"_",{enumerable:!0,get:function(){return Vm._}});Object.defineProperty(vr,"str",{enumerable:!0,get:function(){return Vm.str}});Object.defineProperty(vr,"strConcat",{enumerable:!0,get:function(){return Vm.strConcat}});Object.defineProperty(vr,"nil",{enumerable:!0,get:function(){return Vm.nil}});Object.defineProperty(vr,"getProperty",{enumerable:!0,get:function(){return Vm.getProperty}});Object.defineProperty(vr,"stringify",{enumerable:!0,get:function(){return Vm.stringify}});Object.defineProperty(vr,"regexpCode",{enumerable:!0,get:function(){return Vm.regexpCode}});Object.defineProperty(vr,"Name",{enumerable:!0,get:function(){return Vm.Name}});var SI=Kj();Object.defineProperty(vr,"Scope",{enumerable:!0,get:function(){return SI.Scope}});Object.defineProperty(vr,"ValueScope",{enumerable:!0,get:function(){return SI.ValueScope}});Object.defineProperty(vr,"ValueScopeName",{enumerable:!0,get:function(){return SI.ValueScopeName}});Object.defineProperty(vr,"varKinds",{enumerable:!0,get:function(){return SI.varKinds}});vr.operators={GT:new jr._Code(">"),GTE:new jr._Code(">="),LT:new jr._Code("<"),LTE:new jr._Code("<="),EQ:new jr._Code("==="),NEQ:new jr._Code("!=="),NOT:new jr._Code("!"),OR:new jr._Code("||"),AND:new jr._Code("&&"),ADD:new jr._Code("+")};var Bh=class{optimizeNodes(){return this}optimizeNames(e,r){return this}},Fj=class extends Bh{constructor(e,r,n){super(),this.varKind=e,this.name=r,this.rhs=n}render({es5:e,_n:r}){let n=e?Ru.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=_1(this.rhs,e,r)),this}get names(){return this.rhs instanceof jr._CodeOrName?this.rhs.names:{}}},_I=class extends Bh{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 jr.Name&&!e[this.lhs.str]&&!this.sideEffects))return this.rhs=_1(this.rhs,e,r),this}get names(){let e=this.lhs instanceof jr.Name?{}:{...this.lhs.names};return EI(e,this.rhs)}},zj=class extends _I{constructor(e,r,n,i){super(e,n,i),this.op=r}render({_n:e}){return`${this.lhs} ${this.op}= ${this.rhs};`+e}},Vj=class extends Bh{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`${this.label}:`+e}},Hj=class extends Bh{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`break${this.label?` ${this.label}`:""};`+e}},Wj=class extends Bh{constructor(e){super(),this.error=e}render({_n:e}){return`throw ${this.error};`+e}get names(){return this.error.names}},Gj=class extends Bh{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=_1(this.code,e,r),this}get names(){return this.code instanceof jr._CodeOrName?this.code.names:{}}},h6=class extends Bh{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)||(RKe(e,o.names),n.splice(i,1))}return n.length>0?this:void 0}get names(){return this.nodes.reduce((e,r)=>Fg(e,r.names),{})}},Mh=class extends h6{render(e){return"{"+e._n+super.render(e)+"}"+e._n}},Jj=class extends h6{},w1=class extends Mh{};w1.kind="else";var Lg=class t extends Mh{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 w1(n):n}if(r)return e===!1?r instanceof t?r:r.nodes:this.nodes.length?this:new t(ufe(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=_1(this.condition,e,r),this}get names(){let e=super.names;return EI(e,this.condition),this.else&&Fg(e,this.else.names),e}};Lg.kind="if";var Kg=class extends Mh{};Kg.kind="for";var Yj=class extends Kg{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=_1(this.iteration,e,r),this}get names(){return Fg(super.names,this.iteration.names)}},Zj=class extends Kg{constructor(e,r,n,i){super(),this.varKind=e,this.name=r,this.from=n,this.to=i}render(e){let r=e.es5?Ru.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=EI(super.names,this.from);return EI(e,this.to)}},xI=class extends Kg{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=_1(this.iterable,e,r),this}get names(){return Fg(super.names,this.iterable.names)}},p6=class extends Mh{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)}};p6.kind="func";var m6=class extends h6{render(e){return"return "+super.render(e)}};m6.kind="return";var Xj=class extends Mh{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&&Fg(e,this.catch.names),this.finally&&Fg(e,this.finally.names),e}},y6=class extends Mh{constructor(e){super(),this.error=e}render(e){return`catch(${this.error})`+super.render(e)}};y6.kind="catch";var g6=class extends Mh{render(e){return"finally"+super.render(e)}};g6.kind="finally";var Qj=class{constructor(e,r={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...r,_n:r.lines?`
`:""},this._extScope=e,this._scope=new Ru.Scope({parent:e}),this._nodes=[new Jj]}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 Fj(e,o,n)),o}const(e,r,n){return this._def(Ru.varKinds.const,e,r,n)}let(e,r,n){return this._def(Ru.varKinds.let,e,r,n)}var(e,r,n){return this._def(Ru.varKinds.var,e,r,n)}assign(e,r,n){return this._leafNode(new _I(e,r,n))}add(e,r){return this._leafNode(new zj(e,vr.operators.ADD,r))}code(e){return typeof e=="function"?e():e!==jr.nil&&this._leafNode(new Gj(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,jr.addCodeArg)(r,i));return r.push("}"),new jr._Code(r)}if(e,r,n){if(this._blockNode(new Lg(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 Lg(e))}else(){return this._elseNode(new w1)}endIf(){return this._endBlockNode(Lg,w1)}_for(e,r){return this._blockNode(e),r&&this.code(r).endFor(),this}for(e,r){return this._for(new Yj(e),r)}forRange(e,r,n,i,o=this.opts.es5?Ru.varKinds.var:Ru.varKinds.let){let s=this._scope.toName(e);return this._for(new Zj(o,s,r,n),()=>i(s))}forOf(e,r,n,i=Ru.varKinds.const){let o=this._scope.toName(e);if(this.opts.es5){let s=r instanceof jr.Name?r:this.var("_arr",r);return this.forRange("_i",0,(0,jr._)`${s}.length`,a=>{this.var(o,(0,jr._)`${s}[${a}]`),n(o)})}return this._for(new xI("of",i,o,r),()=>n(o))}forIn(e,r,n,i=this.opts.es5?Ru.varKinds.var:Ru.varKinds.const){if(this.opts.ownProperties)return this.forOf(e,(0,jr._)`Object.keys(${r})`,n);let o=this._scope.toName(e);return this._for(new xI("in",i,o,r),()=>n(o))}endFor(){return this._endBlockNode(Kg)}label(e){return this._leafNode(new Vj(e))}break(e){return this._leafNode(new Hj(e))}return(e){let r=new m6;if(this._blockNode(r),this.code(e),r.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(m6)}try(e,r,n){if(!r&&!n)throw new Error('CodeGen: "try" without "catch" and "finally"');let i=new Xj;if(this._blockNode(i),this.code(e),r){let o=this.name("e");this._currNode=i.catch=new y6(o),r(o)}return n&&(this._currNode=i.finally=new g6,this.code(n)),this._endBlockNode(y6,g6)}throw(e){return this._leafNode(new Wj(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=jr.nil,n,i){return this._blockNode(new p6(e,r,n)),i&&this.code(i).endFunc(),this}endFunc(){return this._endBlockNode(p6)}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 Lg))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}};vr.CodeGen=Qj;function Fg(t,e){for(let r in e)t[r]=(t[r]||0)+(e[r]||0);return t}function EI(t,e){return e instanceof jr._CodeOrName?Fg(t,e.names):t}function _1(t,e,r){if(t instanceof jr.Name)return n(t);if(!i(t))return t;return new jr._Code(t._items.reduce((o,s)=>(s instanceof jr.Name&&(s=n(s)),s instanceof jr._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 jr._Code&&o._items.some(s=>s instanceof jr.Name&&e[s.str]===1&&r[s.str]!==void 0)}}function RKe(t,e){for(let r in e)t[r]=(t[r]||0)-(e[r]||0)}function ufe(t){return typeof t=="boolean"||typeof t=="number"||t===null?!t:(0,jr._)`!${eU(t)}`}vr.not=ufe;var BKe=lfe(vr.operators.AND);function MKe(...t){return t.reduce(BKe)}vr.and=MKe;var DKe=lfe(vr.operators.OR);function OKe(...t){return t.reduce(DKe)}vr.or=OKe;function lfe(t){return(e,r)=>e===jr.nil?r:r===jr.nil?e:(0,jr._)`${eU(e)} ${t} ${eU(r)}`}function eU(t){return t instanceof jr.Name?t:(0,jr._)`(${t})`}});var Rr=H(br=>{"use strict";h();Object.defineProperty(br,"__esModule",{value:!0});br.checkStrictMode=br.getErrorPath=br.Type=br.useFunc=br.setEvaluated=br.evaluatedPropsToName=br.mergeEvaluated=br.eachItem=br.unescapeJsonPointer=br.escapeJsonPointer=br.escapeFragment=br.unescapeFragment=br.schemaRefOrVal=br.schemaHasRulesButRef=br.schemaHasRules=br.checkUnknownRules=br.alwaysValidSchema=br.toHash=void 0;var Sn=tr(),CKe=f6();function $Ke(t){let e={};for(let r of t)e[r]=!0;return e}br.toHash=$Ke;function NKe(t,e){return typeof e=="boolean"?e:Object.keys(e).length===0?!0:(pfe(t,e),!mfe(e,t.self.RULES.all))}br.alwaysValidSchema=NKe;function pfe(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]||bfe(t,`unknown keyword: "${o}"`)}br.checkUnknownRules=pfe;function mfe(t,e){if(typeof t=="boolean")return!t;for(let r in t)if(e[r])return!0;return!1}br.schemaHasRules=mfe;function jKe(t,e){if(typeof t=="boolean")return!t;for(let r in t)if(r!=="$ref"&&e.all[r])return!0;return!1}br.schemaHasRulesButRef=jKe;function UKe({topSchemaRef:t,schemaPath:e},r,n,i){if(!i){if(typeof r=="number"||typeof r=="boolean")return r;if(typeof r=="string")return(0,Sn._)`${r}`}return(0,Sn._)`${t}${e}${(0,Sn.getProperty)(n)}`}br.schemaRefOrVal=UKe;function qKe(t){return yfe(decodeURIComponent(t))}br.unescapeFragment=qKe;function LKe(t){return encodeURIComponent(tU(t))}br.escapeFragment=LKe;function tU(t){return typeof t=="number"?`${t}`:t.replace(/~/g,"~0").replace(/\//g,"~1")}br.escapeJsonPointer=tU;function yfe(t){return t.replace(/~1/g,"/").replace(/~0/g,"~")}br.unescapeJsonPointer=yfe;function KKe(t,e){if(Array.isArray(t))for(let r of t)e(r);else e(t)}br.eachItem=KKe;function ffe({mergeNames:t,mergeToName:e,mergeValues:r,resultToName:n}){return(i,o,s,a)=>{let d=s===void 0?o:s instanceof Sn.Name?(o instanceof Sn.Name?t(i,o,s):e(i,o,s),s):o instanceof Sn.Name?(e(i,s,o),o):r(o,s);return a===Sn.Name&&!(d instanceof Sn.Name)?n(i,d):d}}br.mergeEvaluated={props:ffe({mergeNames:(t,e,r)=>t.if((0,Sn._)`${r} !== true && ${e} !== undefined`,()=>{t.if((0,Sn._)`${e} === true`,()=>t.assign(r,!0),()=>t.assign(r,(0,Sn._)`${r} || {}`).code((0,Sn._)`Object.assign(${r}, ${e})`))}),mergeToName:(t,e,r)=>t.if((0,Sn._)`${r} !== true`,()=>{e===!0?t.assign(r,!0):(t.assign(r,(0,Sn._)`${r} || {}`),rU(t,r,e))}),mergeValues:(t,e)=>t===!0?!0:{...t,...e},resultToName:gfe}),items:ffe({mergeNames:(t,e,r)=>t.if((0,Sn._)`${r} !== true && ${e} !== undefined`,()=>t.assign(r,(0,Sn._)`${e} === true ? true : ${r} > ${e} ? ${r} : ${e}`)),mergeToName:(t,e,r)=>t.if((0,Sn._)`${r} !== true`,()=>t.assign(r,e===!0?!0:(0,Sn._)`${r} > ${e} ? ${r} : ${e}`)),mergeValues:(t,e)=>t===!0?!0:Math.max(t,e),resultToName:(t,e)=>t.var("items",e)})};function gfe(t,e){if(e===!0)return t.var("props",!0);let r=t.var("props",(0,Sn._)`{}`);return e!==void 0&&rU(t,r,e),r}br.evaluatedPropsToName=gfe;function rU(t,e,r){Object.keys(r).forEach(n=>t.assign((0,Sn._)`${e}${(0,Sn.getProperty)(n)}`,!0))}br.setEvaluated=rU;var hfe={};function FKe(t,e){return t.scopeValue("func",{ref:e,code:hfe[e.code]||(hfe[e.code]=new CKe._Code(e.code))})}br.useFunc=FKe;var vfe;(function(t){t[t.Num=0]="Num",t[t.Str=1]="Str"})(vfe=br.Type||(br.Type={}));function zKe(t,e,r){if(t instanceof Sn.Name){let n=e===vfe.Num;return r?n?(0,Sn._)`"[" + ${t} + "]"`:(0,Sn._)`"['" + ${t} + "']"`:n?(0,Sn._)`"/" + ${t}`:(0,Sn._)`"/" + ${t}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,Sn.getProperty)(t).toString():"/"+tU(t)}br.getErrorPath=zKe;function bfe(t,e,r=t.opts.strictSchema){if(r){if(e=`strict mode: ${e}`,r===!0)throw new Error(e);t.self.logger.warn(e)}}br.checkStrictMode=bfe});var Pd=H(nU=>{"use strict";h();Object.defineProperty(nU,"__esModule",{value:!0});var $s=tr(),VKe={data:new $s.Name("data"),valCxt:new $s.Name("valCxt"),instancePath:new $s.Name("instancePath"),parentData:new $s.Name("parentData"),parentDataProperty:new $s.Name("parentDataProperty"),rootData:new $s.Name("rootData"),dynamicAnchors:new $s.Name("dynamicAnchors"),vErrors:new $s.Name("vErrors"),errors:new $s.Name("errors"),this:new $s.Name("this"),self:new $s.Name("self"),scope:new $s.Name("scope"),json:new $s.Name("json"),jsonPos:new $s.Name("jsonPos"),jsonLen:new $s.Name("jsonLen"),jsonPart:new $s.Name("jsonPart")};nU.default=VKe});var v6=H(Ns=>{"use strict";h();Object.defineProperty(Ns,"__esModule",{value:!0});Ns.extendErrors=Ns.resetErrorsCount=Ns.reportExtraError=Ns.reportError=Ns.keyword$DataError=Ns.keywordError=void 0;var qr=tr(),AI=Rr(),ha=Pd();Ns.keywordError={message:({keyword:t})=>(0,qr.str)`must pass "${t}" keyword validation`};Ns.keyword$DataError={message:({keyword:t,schemaType:e})=>e?(0,qr.str)`"${t}" keyword must be ${e} ($data)`:(0,qr.str)`"${t}" keyword is invalid ($data)`};function HKe(t,e=Ns.keywordError,r,n){let{it:i}=t,{gen:o,compositeRule:s,allErrors:a}=i,d=xfe(t,e,r);n??(s||a)?wfe(o,d):_fe(i,(0,qr._)`[${d}]`)}Ns.reportError=HKe;function WKe(t,e=Ns.keywordError,r){let{it:n}=t,{gen:i,compositeRule:o,allErrors:s}=n,a=xfe(t,e,r);wfe(i,a),o||s||_fe(n,ha.default.vErrors)}Ns.reportExtraError=WKe;function GKe(t,e){t.assign(ha.default.errors,e),t.if((0,qr._)`${ha.default.vErrors} !== null`,()=>t.if(e,()=>t.assign((0,qr._)`${ha.default.vErrors}.length`,e),()=>t.assign(ha.default.vErrors,null)))}Ns.resetErrorsCount=GKe;function JKe({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,ha.default.errors,a=>{t.const(s,(0,qr._)`${ha.default.vErrors}[${a}]`),t.if((0,qr._)`${s}.instancePath === undefined`,()=>t.assign((0,qr._)`${s}.instancePath`,(0,qr.strConcat)(ha.default.instancePath,o.errorPath))),t.assign((0,qr._)`${s}.schemaPath`,(0,qr.str)`${o.errSchemaPath}/${e}`),o.opts.verbose&&(t.assign((0,qr._)`${s}.schema`,r),t.assign((0,qr._)`${s}.data`,n))})}Ns.extendErrors=JKe;function wfe(t,e){let r=t.const("err",e);t.if((0,qr._)`${ha.default.vErrors} === null`,()=>t.assign(ha.default.vErrors,(0,qr._)`[${r}]`),(0,qr._)`${ha.default.vErrors}.push(${r})`),t.code((0,qr._)`${ha.default.errors}++`)}function _fe(t,e){let{gen:r,validateName:n,schemaEnv:i}=t;i.$async?r.throw((0,qr._)`new ${t.ValidationError}(${e})`):(r.assign((0,qr._)`${n}.errors`,e),r.return(!1))}var zg={keyword:new qr.Name("keyword"),schemaPath:new qr.Name("schemaPath"),params:new qr.Name("params"),propertyName:new qr.Name("propertyName"),message:new qr.Name("message"),schema:new qr.Name("schema"),parentSchema:new qr.Name("parentSchema")};function xfe(t,e,r){let{createErrors:n}=t.it;return n===!1?(0,qr._)`{}`:YKe(t,e,r)}function YKe(t,e,r={}){let{gen:n,it:i}=t,o=[ZKe(i,r),XKe(t,r)];return QKe(t,e,o),n.object(...o)}function ZKe({errorPath:t},{instancePath:e}){let r=e?(0,qr.str)`${t}${(0,AI.getErrorPath)(e,AI.Type.Str)}`:t;return[ha.default.instancePath,(0,qr.strConcat)(ha.default.instancePath,r)]}function XKe({keyword:t,it:{errSchemaPath:e}},{schemaPath:r,parentSchema:n}){let i=n?e:(0,qr.str)`${e}/${t}`;return r&&(i=(0,qr.str)`${i}${(0,AI.getErrorPath)(r,AI.Type.Str)}`),[zg.schemaPath,i]}function QKe(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([zg.keyword,i],[zg.params,typeof e=="function"?e(t):e||(0,qr._)`{}`]),d.messages&&n.push([zg.message,typeof r=="function"?r(t):r]),d.verbose&&n.push([zg.schema,s],[zg.parentSchema,(0,qr._)`${c}${l}`],[ha.default.data,o]),u&&n.push([zg.propertyName,u])}});var Sfe=H(x1=>{"use strict";h();Object.defineProperty(x1,"__esModule",{value:!0});x1.boolOrEmptySchema=x1.topBoolOrEmptySchema=void 0;var eFe=v6(),tFe=tr(),rFe=Pd(),nFe={message:"boolean schema is false"};function iFe(t){let{gen:e,schema:r,validateName:n}=t;r===!1?Efe(t,!1):typeof r=="object"&&r.$async===!0?e.return(rFe.default.data):(e.assign((0,tFe._)`${n}.errors`,null),e.return(!0))}x1.topBoolOrEmptySchema=iFe;function oFe(t,e){let{gen:r,schema:n}=t;n===!1?(r.var(e,!1),Efe(t)):r.var(e,!0)}x1.boolOrEmptySchema=oFe;function Efe(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,eFe.reportError)(i,nFe,void 0,e)}});var iU=H(E1=>{"use strict";h();Object.defineProperty(E1,"__esModule",{value:!0});E1.getRules=E1.isJSONType=void 0;var sFe=["string","number","integer","boolean","null","object","array"],aFe=new Set(sFe);function cFe(t){return typeof t=="string"&&aFe.has(t)}E1.isJSONType=cFe;function dFe(){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:{}}}E1.getRules=dFe});var oU=H(Hm=>{"use strict";h();Object.defineProperty(Hm,"__esModule",{value:!0});Hm.shouldUseRule=Hm.shouldUseGroup=Hm.schemaHasRulesForType=void 0;function uFe({schema:t,self:e},r){let n=e.RULES.types[r];return n&&n!==!0&&Afe(t,n)}Hm.schemaHasRulesForType=uFe;function Afe(t,e){return e.rules.some(r=>Tfe(t,r))}Hm.shouldUseGroup=Afe;function Tfe(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))}Hm.shouldUseRule=Tfe});var w6=H(ss=>{"use strict";h();Object.defineProperty(ss,"__esModule",{value:!0});ss.reportTypeError=ss.checkDataTypes=ss.checkDataType=ss.coerceAndCheckDataType=ss.getJSONTypes=ss.getSchemaTypes=ss.DataType=void 0;var lFe=iU(),fFe=oU(),hFe=v6(),sr=tr(),Ife=Rr(),b6;(function(t){t[t.Correct=0]="Correct",t[t.Wrong=1]="Wrong"})(b6=ss.DataType||(ss.DataType={}));function pFe(t){let e=Pfe(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}ss.getSchemaTypes=pFe;function Pfe(t){let e=Array.isArray(t)?t:t?[t]:[];if(e.every(lFe.isJSONType))return e;throw new Error("type must be JSONType or JSONType[]: "+e.join(","))}ss.getJSONTypes=Pfe;function mFe(t,e){let{gen:r,data:n,opts:i}=t,o=yFe(e,i.coerceTypes),s=e.length>0&&!(o.length===0&&e.length===1&&(0,fFe.schemaHasRulesForType)(t,e[0]));if(s){let a=aU(e,n,i.strictNumbers,b6.Wrong);r.if(a,()=>{o.length?gFe(t,e,o):cU(t)})}return s}ss.coerceAndCheckDataType=mFe;var kfe=new Set(["string","number","integer","boolean","null"]);function yFe(t,e){return e?t.filter(r=>kfe.has(r)||e==="array"&&r==="array"):[]}function gFe(t,e,r){let{gen:n,data:i,opts:o}=t,s=n.let("dataType",(0,sr._)`typeof ${i}`),a=n.let("coerced",(0,sr._)`undefined`);o.coerceTypes==="array"&&n.if((0,sr._)`${s} == 'object' && Array.isArray(${i}) && ${i}.length == 1`,()=>n.assign(i,(0,sr._)`${i}[0]`).assign(s,(0,sr._)`typeof ${i}`).if(aU(e,i,o.strictNumbers),()=>n.assign(a,i))),n.if((0,sr._)`${a} !== undefined`);for(let u of r)(kfe.has(u)||u==="array"&&o.coerceTypes==="array")&&d(u);n.else(),cU(t),n.endIf(),n.if((0,sr._)`${a} !== undefined`,()=>{n.assign(i,a),vFe(t,a)});function d(u){switch(u){case"string":n.elseIf((0,sr._)`${s} == "number" || ${s} == "boolean"`).assign(a,(0,sr._)`"" + ${i}`).elseIf((0,sr._)`${i} === null`).assign(a,(0,sr._)`""`);return;case"number":n.elseIf((0,sr._)`${s} == "boolean" || ${i} === null
|| (${s} == "string" && ${i} && ${i} == +${i})`).assign(a,(0,sr._)`+${i}`);return;case"integer":n.elseIf((0,sr._)`${s} === "boolean" || ${i} === null
|| (${s} === "string" && ${i} && ${i} == +${i} && !(${i} % 1))`).assign(a,(0,sr._)`+${i}`);return;case"boolean":n.elseIf((0,sr._)`${i} === "false" || ${i} === 0 || ${i} === null`).assign(a,!1).elseIf((0,sr._)`${i} === "true" || ${i} === 1`).assign(a,!0);return;case"null":n.elseIf((0,sr._)`${i} === "" || ${i} === 0 || ${i} === false`),n.assign(a,null);return;case"array":n.elseIf((0,sr._)`${s} === "string" || ${s} === "number"
|| ${s} === "boolean" || ${i} === null`).assign(a,(0,sr._)`[${i}]`)}}}function vFe({gen:t,parentData:e,parentDataProperty:r},n){t.if((0,sr._)`${e} !== undefined`,()=>t.assign((0,sr._)`${e}[${r}]`,n))}function sU(t,e,r,n=b6.Correct){let i=n===b6.Correct?sr.operators.EQ:sr.operators.NEQ,o;switch(t){case"null":return(0,sr._)`${e} ${i} null`;case"array":o=(0,sr._)`Array.isArray(${e})`;break;case"object":o=(0,sr._)`${e} && typeof ${e} == "object" && !Array.isArray(${e})`;break;case"integer":o=s((0,sr._)`!(${e} % 1) && !isNaN(${e})`);break;case"number":o=s();break;default:return(0,sr._)`typeof ${e} ${i} ${t}`}return n===b6.Correct?o:(0,sr.not)(o);function s(a=sr.nil){return(0,sr.and)((0,sr._)`typeof ${e} == "number"`,a,r?(0,sr._)`isFinite(${e})`:sr.nil)}}ss.checkDataType=sU;function aU(t,e,r,n){if(t.length===1)return sU(t[0],e,r,n);let i,o=(0,Ife.toHash)(t);if(o.array&&o.object){let s=(0,sr._)`typeof ${e} != "object"`;i=o.null?s:(0,sr._)`!${e} || ${s}`,delete o.null,delete o.array,delete o.object}else i=sr.nil;o.number&&delete o.integer;for(let s in o)i=(0,sr.and)(i,sU(s,e,r,n));return i}ss.checkDataTypes=aU;var bFe={message:({schema:t})=>`must be ${t}`,params:({schema:t,schemaValue:e})=>typeof t=="string"?(0,sr._)`{type: ${t}}`:(0,sr._)`{type: ${e}}`};function cU(t){let e=wFe(t);(0,hFe.reportError)(e,bFe)}ss.reportTypeError=cU;function wFe(t){let{gen:e,data:r,schema:n}=t,i=(0,Ife.schemaRefOrVal)(t,n,"type");return{gen:e,keyword:"type",data:r,schema:n.type,schemaCode:i,schemaValue:i,parentSchema:n,params:{},it:t}}});var Bfe=H(TI=>{"use strict";h();Object.defineProperty(TI,"__esModule",{value:!0});TI.assignDefaults=void 0;var S1=tr(),_Fe=Rr();function xFe(t,e){let{properties:r,items:n}=t.schema;if(e==="object"&&r)for(let i in r)Rfe(t,i,r[i].default);else e==="array"&&Array.isArray(n)&&n.forEach((i,o)=>Rfe(t,o,i.default))}TI.assignDefaults=xFe;function Rfe(t,e,r){let{gen:n,compositeRule:i,data:o,opts:s}=t;if(r===void 0)return;let a=(0,S1._)`${o}${(0,S1.getProperty)(e)}`;if(i){(0,_Fe.checkStrictMode)(t,`default is ignored for: ${a}`);return}let d=(0,S1._)`${a} === undefined`;s.useDefaults==="empty"&&(d=(0,S1._)`${d} || ${a} === null || ${a} === ""`),n.if(d,(0,S1._)`${a} = ${(0,S1.stringify)(r)}`)}});var kd=H(gn=>{"use strict";h();Object.defineProperty(gn,"__esModule",{value:!0});gn.validateUnion=gn.validateArray=gn.usePattern=gn.callValidateCode=gn.schemaProperties=gn.allSchemaProperties=gn.noPropertyInData=gn.propertyInData=gn.isOwnProperty=gn.hasPropFunc=gn.reportMissingProp=gn.checkMissingProp=gn.checkReportMissingProp=void 0;var Cn=tr(),dU=Rr(),Wm=Pd(),EFe=Rr();function SFe(t,e){let{gen:r,data:n,it:i}=t;r.if(lU(r,n,e,i.opts.ownProperties),()=>{t.setParams({missingProperty:(0,Cn._)`${e}`},!0),t.error()})}gn.checkReportMissingProp=SFe;function AFe({gen:t,data:e,it:{opts:r}},n,i){return(0,Cn.or)(...n.map(o=>(0,Cn.and)(lU(t,e,o,r.ownProperties),(0,Cn._)`${i} = ${o}`)))}gn.checkMissingProp=AFe;function TFe(t,e){t.setParams({missingProperty:e},!0),t.error()}gn.reportMissingProp=TFe;function Mfe(t){return t.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,Cn._)`Object.prototype.hasOwnProperty`})}gn.hasPropFunc=Mfe;function uU(t,e,r){return(0,Cn._)`${Mfe(t)}.call(${e}, ${r})`}gn.isOwnProperty=uU;function IFe(t,e,r,n){let i=(0,Cn._)`${e}${(0,Cn.getProperty)(r)} !== undefined`;return n?(0,Cn._)`${i} && ${uU(t,e,r)}`:i}gn.propertyInData=IFe;function lU(t,e,r,n){let i=(0,Cn._)`${e}${(0,Cn.getProperty)(r)} === undefined`;return n?(0,Cn.or)(i,(0,Cn.not)(uU(t,e,r))):i}gn.noPropertyInData=lU;function Dfe(t){return t?Object.keys(t).filter(e=>e!=="__proto__"):[]}gn.allSchemaProperties=Dfe;function PFe(t,e){return Dfe(e).filter(r=>!(0,dU.alwaysValidSchema)(t,e[r]))}gn.schemaProperties=PFe;function kFe({schemaCode:t,data:e,it:{gen:r,topSchemaRef:n,schemaPath:i,errorPath:o},it:s},a,d,u){let c=u?(0,Cn._)`${t}, ${e}, ${n}${i}`:e,l=[[Wm.default.instancePath,(0,Cn.strConcat)(Wm.default.instancePath,o)],[Wm.default.parentData,s.parentData],[Wm.default.parentDataProperty,s.parentDataProperty],[Wm.default.rootData,Wm.default.rootData]];s.opts.dynamicRef&&l.push([Wm.default.dynamicAnchors,Wm.default.dynamicAnchors]);let m=(0,Cn._)`${c}, ${r.object(...l)}`;return d!==Cn.nil?(0,Cn._)`${a}.call(${d}, ${m})`:(0,Cn._)`${a}(${m})`}gn.callValidateCode=kFe;var RFe=(0,Cn._)`new RegExp`;function BFe({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,Cn._)`${i.code==="new RegExp"?RFe:(0,EFe.useFunc)(t,i)}(${r}, ${n})`})}gn.usePattern=BFe;function MFe(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,Cn._)`${r}.length`);e.forRange("i",0,d,u=>{t.subschema({keyword:n,dataProp:u,dataPropType:dU.Type.Num},o),e.if((0,Cn.not)(o),a)})}}gn.validateArray=MFe;function DFe(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,dU.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,Cn._)`${s} || ${a}`),t.mergeValidEvaluated(c,a)||e.if((0,Cn.not)(s))})),t.result(s,()=>t.reset(),()=>t.error(!0))}gn.validateUnion=DFe});var $fe=H(ef=>{"use strict";h();Object.defineProperty(ef,"__esModule",{value:!0});ef.validateKeywordUsage=ef.validSchemaType=ef.funcKeywordCode=ef.macroKeywordCode=void 0;var pa=tr(),Vg=Pd(),OFe=kd(),CFe=v6();function $Fe(t,e){let{gen:r,keyword:n,schema:i,parentSchema:o,it:s}=t,a=e.macro.call(s.self,i,o,s),d=Cfe(r,n,a);s.opts.validateSchema!==!1&&s.self.validateSchema(a,!0);let u=r.name("valid");t.subschema({schema:a,schemaPath:pa.nil,errSchemaPath:`${s.errSchemaPath}/${n}`,topSchemaRef:d,compositeRule:!0},u),t.pass(u,()=>t.error(!0))}ef.macroKeywordCode=$Fe;function NFe(t,e){var r;let{gen:n,keyword:i,schema:o,parentSchema:s,$data:a,it:d}=t;UFe(d,e);let u=!a&&e.compile?e.compile.call(d.self,o,s,d):e.validate,c=Cfe(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)v(),e.modifying&&Ofe(t),E(()=>t.error());else{let A=e.async?p():g();e.modifying&&Ofe(t),E(()=>jFe(t,A))}}function p(){let A=n.let("ruleErrs",null);return n.try(()=>v((0,pa._)`await `),P=>n.assign(l,!1).if((0,pa._)`${P} instanceof ${d.ValidationError}`,()=>n.assign(A,(0,pa._)`${P}.errors`),()=>n.throw(P))),A}function g(){let A=(0,pa._)`${c}.errors`;return n.assign(A,null),v(pa.nil),A}function v(A=e.async?(0,pa._)`await `:pa.nil){let P=d.opts.passContext?Vg.default.this:Vg.default.self,I=!("compile"in e&&!a||e.schema===!1);n.assign(l,(0,pa._)`${A}${(0,OFe.callValidateCode)(t,c,P,I)}`,e.modifying)}function E(A){var P;n.if((0,pa.not)((P=e.valid)!==null&&P!==void 0?P:l),A)}}ef.funcKeywordCode=NFe;function Ofe(t){let{gen:e,data:r,it:n}=t;e.if(n.parentData,()=>e.assign(r,(0,pa._)`${n.parentData}[${n.parentDataProperty}]`))}function jFe(t,e){let{gen:r}=t;r.if((0,pa._)`Array.isArray(${e})`,()=>{r.assign(Vg.default.vErrors,(0,pa._)`${Vg.default.vErrors} === null ? ${e} : ${Vg.default.vErrors}.concat(${e})`).assign(Vg.default.errors,(0,pa._)`${Vg.default.vErrors}.length`),(0,CFe.extendErrors)(t)},()=>t.error())}function UFe({schemaEnv:t},e){if(e.async&&!t.$async)throw new Error("async keyword in sync schema")}function Cfe(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,pa.stringify)(r)})}function qFe(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")}ef.validSchemaType=qFe;function LFe({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)}}ef.validateKeywordUsage=LFe});var jfe=H(Gm=>{"use strict";h();Object.defineProperty(Gm,"__esModule",{value:!0});Gm.extendSubschemaMode=Gm.extendSubschemaData=Gm.getSubschema=void 0;var tf=tr(),Nfe=Rr();function KFe(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,tf._)`${t.schemaPath}${(0,tf.getProperty)(e)}`,errSchemaPath:`${t.errSchemaPath}/${e}`}:{schema:a[r],schemaPath:(0,tf._)`${t.schemaPath}${(0,tf.getProperty)(e)}${(0,tf.getProperty)(r)}`,errSchemaPath:`${t.errSchemaPath}/${e}/${(0,Nfe.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')}Gm.getSubschema=KFe;function FFe(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,tf._)`${e.data}${(0,tf.getProperty)(r)}`,!0);d(m),t.errorPath=(0,tf.str)`${u}${(0,Nfe.getErrorPath)(r,n,l.jsPropertySyntax)}`,t.parentDataProperty=(0,tf._)`${r}`,t.dataPathArr=[...c,t.parentDataProperty]}if(i!==void 0){let u=i instanceof tf.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]}}Gm.extendSubschemaData=FFe;function zFe(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}Gm.extendSubschemaMode=zFe});var fU=H((j8t,Ufe)=>{"use strict";h();Ufe.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 Lfe=H((q8t,qfe)=>{"use strict";h();var Jm=qfe.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(){};II(e,n,i,t,"",t)};Jm.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0};Jm.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};Jm.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};Jm.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 II(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 Jm.arrayKeywords)for(var m=0;m<l.length;m++)II(t,e,r,l[m],i+"/"+c+"/"+m,o,i,c,n,m)}else if(c in Jm.propsKeywords){if(l&&typeof l=="object")for(var p in l)II(t,e,r,l[p],i+"/"+c+"/"+VFe(p),o,i,c,n,p)}else(c in Jm.keywords||t.allKeys&&!(c in Jm.skipKeywords))&&II(t,e,r,l,i+"/"+c,o,i,c,n)}r(n,i,o,s,a,d,u)}}function VFe(t){return t.replace(/~/g,"~0").replace(/\//g,"~1")}});var _6=H(Ka=>{"use strict";h();Object.defineProperty(Ka,"__esModule",{value:!0});Ka.getSchemaRefs=Ka.resolveUrl=Ka.normalizeId=Ka._getFullPath=Ka.getFullPath=Ka.inlineRef=void 0;var HFe=Rr(),WFe=fU(),GFe=Lfe(),JFe=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);function YFe(t,e=!0){return typeof t=="boolean"?!0:e===!0?!hU(t):e?Kfe(t)<=e:!1}Ka.inlineRef=YFe;var ZFe=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function hU(t){for(let e in t){if(ZFe.has(e))return!0;let r=t[e];if(Array.isArray(r)&&r.some(hU)||typeof r=="object"&&hU(r))return!0}return!1}function Kfe(t){let e=0;for(let r in t){if(r==="$ref")return 1/0;if(e++,!JFe.has(r)&&(typeof t[r]=="object"&&(0,HFe.eachItem)(t[r],n=>e+=Kfe(n)),e===1/0))return 1/0}return e}function Ffe(t,e="",r){r!==!1&&(e=A1(e));let n=t.parse(e);return zfe(t,n)}Ka.getFullPath=Ffe;function zfe(t,e){return t.serialize(e).split("#")[0]+"#"}Ka._getFullPath=zfe;var XFe=/#\/?$/;function A1(t){return t?t.replace(XFe,""):""}Ka.normalizeId=A1;function QFe(t,e,r){return r=A1(r),t.resolve(e,r)}Ka.resolveUrl=QFe;var eze=/^[a-z_][-a-z0-9._]*$/i;function tze(t,e){if(typeof t=="boolean")return{};let{schemaId:r,uriResolver:n}=this.opts,i=A1(t[r]||e),o={"":i},s=Ffe(n,i,!1),a={},d=new Set;return GFe(t,{allKeys:!0},(l,m,p,g)=>{if(g===void 0)return;let v=s+m,E=o[g];typeof l[r]=="string"&&(E=A.call(this,l[r])),P.call(this,l.$anchor),P.call(this,l.$dynamicAnchor),o[m]=E;function A(I){let $=this.opts.uriResolver.resolve;if(I=A1(E?$(E,I):I),d.has(I))throw c(I);d.add(I);let N=this.refs[I];return typeof N=="string"&&(N=this.refs[N]),typeof N=="object"?u(l,N.schema,I):I!==A1(v)&&(I[0]==="#"?(u(l,a[I],I),a[I]=l):this.refs[I]=v),I}function P(I){if(typeof I=="string"){if(!eze.test(I))throw new Error(`invalid anchor "${I}"`);A.call(this,`#${I}`)}}}),a;function u(l,m,p){if(m!==void 0&&!WFe(l,m))throw c(p)}function c(l){return new Error(`reference "${l}" resolves to more than one schema`)}}Ka.getSchemaRefs=tze});var S6=H(Ym=>{"use strict";h();Object.defineProperty(Ym,"__esModule",{value:!0});Ym.getData=Ym.KeywordCxt=Ym.validateFunctionCode=void 0;var Jfe=Sfe(),Vfe=w6(),mU=oU(),PI=w6(),rze=Bfe(),E6=$fe(),pU=jfe(),ft=tr(),$t=Pd(),nze=_6(),Dh=Rr(),x6=v6();function ize(t){if(Xfe(t)&&(Qfe(t),Zfe(t))){aze(t);return}Yfe(t,()=>(0,Jfe.topBoolOrEmptySchema)(t))}Ym.validateFunctionCode=ize;function Yfe({gen:t,validateName:e,schema:r,schemaEnv:n,opts:i},o){i.code.es5?t.func(e,(0,ft._)`${$t.default.data}, ${$t.default.valCxt}`,n.$async,()=>{t.code((0,ft._)`"use strict"; ${Hfe(r,i)}`),sze(t,i),t.code(o)}):t.func(e,(0,ft._)`${$t.default.data}, ${oze(i)}`,n.$async,()=>t.code(Hfe(r,i)).code(o))}function oze(t){return(0,ft._)`{${$t.default.instancePath}="", ${$t.default.parentData}, ${$t.default.parentDataProperty}, ${$t.default.rootData}=${$t.default.data}${t.dynamicRef?(0,ft._)`, ${$t.default.dynamicAnchors}={}`:ft.nil}}={}`}function sze(t,e){t.if($t.default.valCxt,()=>{t.var($t.default.instancePath,(0,ft._)`${$t.default.valCxt}.${$t.default.instancePath}`),t.var($t.default.parentData,(0,ft._)`${$t.default.valCxt}.${$t.default.parentData}`),t.var($t.default.parentDataProperty,(0,ft._)`${$t.default.valCxt}.${$t.default.parentDataProperty}`),t.var($t.default.rootData,(0,ft._)`${$t.default.valCxt}.${$t.default.rootData}`),e.dynamicRef&&t.var($t.default.dynamicAnchors,(0,ft._)`${$t.default.valCxt}.${$t.default.dynamicAnchors}`)},()=>{t.var($t.default.instancePath,(0,ft._)`""`),t.var($t.default.parentData,(0,ft._)`undefined`),t.var($t.default.parentDataProperty,(0,ft._)`undefined`),t.var($t.default.rootData,$t.default.data),e.dynamicRef&&t.var($t.default.dynamicAnchors,(0,ft._)`{}`)})}function aze(t){let{schema:e,opts:r,gen:n}=t;Yfe(t,()=>{r.$comment&&e.$comment&&the(t),fze(t),n.let($t.default.vErrors,null),n.let($t.default.errors,0),r.unevaluated&&cze(t),ehe(t),mze(t)})}function cze(t){let{gen:e,validateName:r}=t;t.evaluated=e.const("evaluated",(0,ft._)`${r}.evaluated`),e.if((0,ft._)`${t.evaluated}.dynamicProps`,()=>e.assign((0,ft._)`${t.evaluated}.props`,(0,ft._)`undefined`)),e.if((0,ft._)`${t.evaluated}.dynamicItems`,()=>e.assign((0,ft._)`${t.evaluated}.items`,(0,ft._)`undefined`))}function Hfe(t,e){let r=typeof t=="object"&&t[e.schemaId];return r&&(e.code.source||e.code.process)?(0,ft._)`/*# sourceURL=${r} */`:ft.nil}function dze(t,e){if(Xfe(t)&&(Qfe(t),Zfe(t))){uze(t,e);return}(0,Jfe.boolOrEmptySchema)(t,e)}function Zfe({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 Xfe(t){return typeof t.schema!="boolean"}function uze(t,e){let{schema:r,gen:n,opts:i}=t;i.$comment&&r.$comment&&the(t),hze(t),pze(t);let o=n.const("_errs",$t.default.errors);ehe(t,o),n.var(e,(0,ft._)`${o} === ${$t.default.errors}`)}function Qfe(t){(0,Dh.checkUnknownRules)(t),lze(t)}function ehe(t,e){if(t.opts.jtd)return Wfe(t,[],!1,e);let r=(0,Vfe.getSchemaTypes)(t.schema),n=(0,Vfe.coerceAndCheckDataType)(t,r);Wfe(t,r,!n,e)}function lze(t){let{schema:e,errSchemaPath:r,opts:n,self:i}=t;e.$ref&&n.ignoreKeywordsWithRef&&(0,Dh.schemaHasRulesButRef)(e,i.RULES)&&i.logger.warn(`$ref: keywords ignored in schema at path "${r}"`)}function fze(t){let{schema:e,opts:r}=t;e.default!==void 0&&r.useDefaults&&r.strictSchema&&(0,Dh.checkStrictMode)(t,"default is ignored in the schema root")}function hze(t){let e=t.schema[t.opts.schemaId];e&&(t.baseId=(0,nze.resolveUrl)(t.opts.uriResolver,t.baseId,e))}function pze(t){if(t.schema.$async&&!t.schemaEnv.$async)throw new Error("async schema in sync schema")}function the({gen:t,schemaEnv:e,schema:r,errSchemaPath:n,opts:i}){let o=r.$comment;if(i.$comment===!0)t.code((0,ft._)`${$t.default.self}.logger.log(${o})`);else if(typeof i.$comment=="function"){let s=(0,ft.str)`${n}/$comment`,a=t.scopeValue("root",{ref:e.root});t.code((0,ft._)`${$t.default.self}.opts.$comment(${o}, ${s}, ${a}.schema)`)}}function mze(t){let{gen:e,schemaEnv:r,validateName:n,ValidationError:i,opts:o}=t;r.$async?e.if((0,ft._)`${$t.default.errors} === 0`,()=>e.return($t.default.data),()=>e.throw((0,ft._)`new ${i}(${$t.default.vErrors})`)):(e.assign((0,ft._)`${n}.errors`,$t.default.vErrors),o.unevaluated&&yze(t),e.return((0,ft._)`${$t.default.errors} === 0`))}function yze({gen:t,evaluated:e,props:r,items:n}){r instanceof ft.Name&&t.assign((0,ft._)`${e}.props`,r),n instanceof ft.Name&&t.assign((0,ft._)`${e}.items`,n)}function Wfe(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,Dh.schemaHasRulesButRef)(o,c))){i.block(()=>nhe(t,"$ref",c.all.$ref.definition));return}d.jtd||gze(t,e),i.block(()=>{for(let m of c.rules)l(m);l(c.post)});function l(m){(0,mU.shouldUseGroup)(o,m)&&(m.type?(i.if((0,PI.checkDataType)(m.type,s,d.strictNumbers)),Gfe(t,m),e.length===1&&e[0]===m.type&&r&&(i.else(),(0,PI.reportTypeError)(t)),i.endIf()):Gfe(t,m),a||i.if((0,ft._)`${$t.default.errors} === ${n||0}`))}}function Gfe(t,e){let{gen:r,schema:n,opts:{useDefaults:i}}=t;i&&(0,rze.assignDefaults)(t,e.type),r.block(()=>{for(let o of e.rules)(0,mU.shouldUseRule)(n,o)&&nhe(t,o.keyword,o.definition,e.type)})}function gze(t,e){t.schemaEnv.meta||!t.opts.strictTypes||(vze(t,e),t.opts.allowUnionTypes||bze(t,e),wze(t,t.dataTypes))}function vze(t,e){if(e.length){if(!t.dataTypes.length){t.dataTypes=e;return}e.forEach(r=>{rhe(t.dataTypes,r)||yU(t,`type "${r}" not allowed by context "${t.dataTypes.join(",")}"`)}),xze(t,e)}}function bze(t,e){e.length>1&&!(e.length===2&&e.includes("null"))&&yU(t,"use allowUnionTypes to allow union type keyword")}function wze(t,e){let r=t.self.RULES.all;for(let n in r){let i=r[n];if(typeof i=="object"&&(0,mU.shouldUseRule)(t.schema,i)){let{type:o}=i.definition;o.length&&!o.some(s=>_ze(e,s))&&yU(t,`missing type "${o.join(",")}" for keyword "${n}"`)}}}function _ze(t,e){return t.includes(e)||e==="number"&&t.includes("integer")}function rhe(t,e){return t.includes(e)||e==="integer"&&t.includes("number")}function xze(t,e){let r=[];for(let n of t.dataTypes)rhe(e,n)?r.push(n):e.includes("integer")&&n==="number"&&r.push("integer");t.dataTypes=r}function yU(t,e){let r=t.schemaEnv.baseId+t.errSchemaPath;e+=` at "${r}" (strictTypes)`,(0,Dh.checkStrictMode)(t,e,t.opts.strictTypes)}var kI=class{constructor(e,r,n){if((0,E6.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,Dh.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",ihe(this.$data,e));else if(this.schemaCode=this.schemaValue,!(0,E6.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",$t.default.errors))}result(e,r,n){this.failResult((0,ft.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,ft.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,ft._)`${r} !== undefined && (${(0,ft.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?x6.reportExtraError:x6.reportError)(this,this.def.error,r)}$dataError(){(0,x6.reportError)(this,this.def.$dataError||x6.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0,x6.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=ft.nil){this.gen.block(()=>{this.check$data(e,n),r()})}check$data(e=ft.nil,r=ft.nil){if(!this.$data)return;let{gen:n,schemaCode:i,schemaType:o,def:s}=this;n.if((0,ft.or)((0,ft._)`${i} === undefined`,r)),e!==ft.nil&&n.assign(e,!0),(o.length||s.validateSchema)&&(n.elseIf(this.invalid$data()),this.$dataError(),e!==ft.nil&&n.assign(e,!1)),n.else()}invalid$data(){let{gen:e,schemaCode:r,schemaType:n,def:i,it:o}=this;return(0,ft.or)(s(),a());function s(){if(n.length){if(!(r instanceof ft.Name))throw new Error("ajv implementation error");let d=Array.isArray(n)?n:[n];return(0,ft._)`${(0,PI.checkDataTypes)(d,r,o.opts.strictNumbers,PI.DataType.Wrong)}`}return ft.nil}function a(){if(i.validateSchema){let d=e.scopeValue("validate$data",{ref:i.validateSchema});return(0,ft._)`!${d}(${r})`}return ft.nil}}subschema(e,r){let n=(0,pU.getSubschema)(this.it,e);(0,pU.extendSubschemaData)(n,this.it,e),(0,pU.extendSubschemaMode)(n,e);let i={...this.it,...n,items:void 0,props:void 0};return dze(i,r),i}mergeEvaluated(e,r){let{it:n,gen:i}=this;n.opts.unevaluated&&(n.props!==!0&&e.props!==void 0&&(n.props=Dh.mergeEvaluated.props(i,e.props,n.props,r)),n.items!==!0&&e.items!==void 0&&(n.items=Dh.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,ft.Name)),!0}};Ym.KeywordCxt=kI;function nhe(t,e,r,n){let i=new kI(t,r,e);"code"in r?r.code(i,n):i.$data&&r.validate?(0,E6.funcKeywordCode)(i,r):"macro"in r?(0,E6.macroKeywordCode)(i,r):(r.compile||r.validate)&&(0,E6.funcKeywordCode)(i,r)}var Eze=/^\/(?:[^~]|~0|~1)*$/,Sze=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function ihe(t,{dataLevel:e,dataNames:r,dataPathArr:n}){let i,o;if(t==="")return $t.default.rootData;if(t[0]==="/"){if(!Eze.test(t))throw new Error(`Invalid JSON-pointer: ${t}`);i=t,o=$t.default.rootData}else{let u=Sze.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,ft._)`${o}${(0,ft.getProperty)((0,Dh.unescapeJsonPointer)(u))}`,s=(0,ft._)`${s} && ${o}`);return s;function d(u,c){return`Cannot access ${u} ${c} levels up, current level is ${e}`}}Ym.getData=ihe});var RI=H(vU=>{"use strict";h();Object.defineProperty(vU,"__esModule",{value:!0});var gU=class extends Error{constructor(e){super("validation failed"),this.errors=e,this.ajv=this.validation=!0}};vU.default=gU});var BI=H(_U=>{"use strict";h();Object.defineProperty(_U,"__esModule",{value:!0});var bU=_6(),wU=class extends Error{constructor(e,r,n,i){super(i||`can't resolve reference ${n} from id ${r}`),this.missingRef=(0,bU.resolveUrl)(e,r,n),this.missingSchema=(0,bU.normalizeId)((0,bU.getFullPath)(e,this.missingRef))}};_U.default=wU});var A6=H(Rd=>{"use strict";h();Object.defineProperty(Rd,"__esModule",{value:!0});Rd.resolveSchema=Rd.getCompilingSchema=Rd.resolveRef=Rd.compileSchema=Rd.SchemaEnv=void 0;var Bu=tr(),Aze=RI(),Hg=Pd(),Mu=_6(),ohe=Rr(),Tze=S6(),T1=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,Mu.normalizeId)(n?.[e.schemaId||"$id"]),this.schemaPath=e.schemaPath,this.localRefs=e.localRefs,this.meta=e.meta,this.$async=n?.$async,this.refs={}}};Rd.SchemaEnv=T1;function EU(t){let e=she.call(this,t);if(e)return e;let r=(0,Mu.getFullPath)(this.opts.uriResolver,t.root.baseId),{es5:n,lines:i}=this.opts.code,{ownProperties:o}=this.opts,s=new Bu.CodeGen(this.scope,{es5:n,lines:i,ownProperties:o}),a;t.$async&&(a=s.scopeValue("Error",{ref:Aze.default,code:(0,Bu._)`require("ajv/dist/runtime/validation_error").default`}));let d=s.scopeName("validate");t.validateName=d;let u={gen:s,allErrors:this.opts.allErrors,data:Hg.default.data,parentData:Hg.default.parentData,parentDataProperty:Hg.default.parentDataProperty,dataNames:[Hg.default.data],dataPathArr:[Bu.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:s.scopeValue("schema",this.opts.code.source===!0?{ref:t.schema,code:(0,Bu.stringify)(t.schema)}:{ref:t.schema}),validateName:d,ValidationError:a,schema:t.schema,schemaEnv:t,rootId:r,baseId:t.baseId||r,schemaPath:Bu.nil,errSchemaPath:t.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0,Bu._)`""`,opts:this.opts,self:this},c;try{this._compilations.add(t),(0,Tze.validateFunctionCode)(u),s.optimize(this.opts.code.optimize);let l=s.toString();c=`${s.scopeRefs(Hg.default.scope)}return ${l}`,this.opts.code.process&&(c=this.opts.code.process(c,t));let p=new Function(`${Hg.default.self}`,`${Hg.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:v}=u;p.evaluated={props:g instanceof Bu.Name?void 0:g,items:v instanceof Bu.Name?void 0:v,dynamicProps:g instanceof Bu.Name,dynamicItems:v instanceof Bu.Name},p.source&&(p.source.evaluated=(0,Bu.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)}}Rd.compileSchema=EU;function Ize(t,e,r){var n;r=(0,Mu.resolveUrl)(this.opts.uriResolver,e,r);let i=t.refs[r];if(i)return i;let o=Rze.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 T1({schema:s,schemaId:a,root:t,baseId:e}))}if(o!==void 0)return t.refs[r]=Pze.call(this,o)}Rd.resolveRef=Ize;function Pze(t){return(0,Mu.inlineRef)(t.schema,this.opts.inlineRefs)?t.schema:t.validate?t:EU.call(this,t)}function she(t){for(let e of this._compilations)if(kze(e,t))return e}Rd.getCompilingSchema=she;function kze(t,e){return t.schema===e.schema&&t.root===e.root&&t.baseId===e.baseId}function Rze(t,e){let r;for(;typeof(r=this.refs[e])=="string";)e=r;return r||this.schemas[e]||MI.call(this,t,e)}function MI(t,e){let r=this.opts.uriResolver.parse(e),n=(0,Mu._getFullPath)(this.opts.uriResolver,r),i=(0,Mu.getFullPath)(this.opts.uriResolver,t.baseId,void 0);if(Object.keys(t.schema).length>0&&n===i)return xU.call(this,r,t);let o=(0,Mu.normalizeId)(n),s=this.refs[o]||this.schemas[o];if(typeof s=="string"){let a=MI.call(this,t,s);return typeof a?.schema!="object"?void 0:xU.call(this,r,a)}if(typeof s?.schema=="object"){if(s.validate||EU.call(this,s),o===(0,Mu.normalizeId)(e)){let{schema:a}=s,{schemaId:d}=this.opts,u=a[d];return u&&(i=(0,Mu.resolveUrl)(this.opts.uriResolver,i,u)),new T1({schema:a,schemaId:d,root:t,baseId:i})}return xU.call(this,r,s)}}Rd.resolveSchema=MI;var Bze=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function xU(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,ohe.unescapeFragment)(a)];if(d===void 0)return;r=d;let u=typeof r=="object"&&r[this.opts.schemaId];!Bze.has(a)&&u&&(e=(0,Mu.resolveUrl)(this.opts.uriResolver,e,u))}let o;if(typeof r!="boolean"&&r.$ref&&!(0,ohe.schemaHasRulesButRef)(r,this.RULES)){let a=(0,Mu.resolveUrl)(this.opts.uriResolver,e,r.$ref);o=MI.call(this,n,a)}let{schemaId:s}=this.opts;if(o=o||new T1({schema:r,schemaId:s,root:n,baseId:e}),o.schema!==o.root.schema)return o}});var ahe=H((X8t,Mze)=>{Mze.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 dhe=H(SU=>{"use strict";h();Object.defineProperty(SU,"__esModule",{value:!0});var che=KR();che.code='require("ajv/dist/runtime/uri").default';SU.default=che});var ghe=H(as=>{"use strict";h();Object.defineProperty(as,"__esModule",{value:!0});as.CodeGen=as.Name=as.nil=as.stringify=as.str=as._=as.KeywordCxt=void 0;var Dze=S6();Object.defineProperty(as,"KeywordCxt",{enumerable:!0,get:function(){return Dze.KeywordCxt}});var I1=tr();Object.defineProperty(as,"_",{enumerable:!0,get:function(){return I1._}});Object.defineProperty(as,"str",{enumerable:!0,get:function(){return I1.str}});Object.defineProperty(as,"stringify",{enumerable:!0,get:function(){return I1.stringify}});Object.defineProperty(as,"nil",{enumerable:!0,get:function(){return I1.nil}});Object.defineProperty(as,"Name",{enumerable:!0,get:function(){return I1.Name}});Object.defineProperty(as,"CodeGen",{enumerable:!0,get:function(){return I1.CodeGen}});var Oze=RI(),phe=BI(),Cze=iU(),T6=A6(),$ze=tr(),I6=_6(),DI=w6(),TU=Rr(),uhe=ahe(),Nze=dhe(),mhe=(t,e)=>new RegExp(t,e);mhe.code="new RegExp";var jze=["removeAdditional","useDefaults","coerceTypes"],Uze=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),qze={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."},Lze={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},lhe=200;function Kze(t){var e,r,n,i,o,s,a,d,u,c,l,m,p,g,v,E,A,P,I,$,N,K,F,U,V;let L=t.strict,T=(e=t.code)===null||e===void 0?void 0:e.optimize,S=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:mhe,f=(i=t.uriResolver)!==null&&i!==void 0?i:Nze.default;return{strictSchema:(s=(o=t.strictSchema)!==null&&o!==void 0?o:L)!==null&&s!==void 0?s:!0,strictNumbers:(d=(a=t.strictNumbers)!==null&&a!==void 0?a:L)!==null&&d!==void 0?d:!0,strictTypes:(c=(u=t.strictTypes)!==null&&u!==void 0?u:L)!==null&&c!==void 0?c:"log",strictTuples:(m=(l=t.strictTuples)!==null&&l!==void 0?l:L)!==null&&m!==void 0?m:"log",strictRequired:(g=(p=t.strictRequired)!==null&&p!==void 0?p:L)!==null&&g!==void 0?g:!1,code:t.code?{...t.code,optimize:S,regExp:k}:{optimize:S,regExp:k},loopRequired:(v=t.loopRequired)!==null&&v!==void 0?v:lhe,loopEnum:(E=t.loopEnum)!==null&&E!==void 0?E:lhe,meta:(A=t.meta)!==null&&A!==void 0?A:!0,messages:(P=t.messages)!==null&&P!==void 0?P:!0,inlineRefs:(I=t.inlineRefs)!==null&&I!==void 0?I:!0,schemaId:($=t.schemaId)!==null&&$!==void 0?$:"$id",addUsedSchema:(N=t.addUsedSchema)!==null&&N!==void 0?N:!0,validateSchema:(K=t.validateSchema)!==null&&K!==void 0?K:!0,validateFormats:(F=t.validateFormats)!==null&&F!==void 0?F:!0,unicodeRegExp:(U=t.unicodeRegExp)!==null&&U!==void 0?U:!0,int32range:(V=t.int32range)!==null&&V!==void 0?V:!0,uriResolver:f}}var P6=class{constructor(e={}){this.schemas={},this.refs={},this.formats={},this._compilations=new Set,this._loading={},this._cache=new Map,e=this.opts={...e,...Kze(e)};let{es5:r,lines:n}=this.opts.code;this.scope=new $ze.ValueScope({scope:{},prefixes:Uze,es5:r,lines:n}),this.logger=Gze(e.logger);let i=e.validateFormats;e.validateFormats=!1,this.RULES=(0,Cze.getRules)(),fhe.call(this,qze,e,"NOT SUPPORTED"),fhe.call(this,Lze,e,"DEPRECATED","warn"),this._metaOpts=Hze.call(this),e.formats&&zze.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),e.keywords&&Vze.call(this,e.keywords),typeof e.meta=="object"&&this.addMetaSchema(e.meta),Fze.call(this),e.validateFormats=i}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){let{$data:e,meta:r,schemaId:n}=this.opts,i=uhe;n==="id"&&(i={...uhe},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 phe.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,I6.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=hhe.call(this,e))=="string";)e=r;if(r===void 0){let{schemaId:n}=this.opts,i=new T6.SchemaEnv({schema:{},schemaId:n});if(r=T6.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=hhe.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,I6.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(Yze.call(this,n,r),!r)return(0,TU.eachItem)(n,o=>AU.call(this,o)),this;Xze.call(this,r);let i={...r,type:(0,DI.getJSONTypes)(r.type),schemaType:(0,DI.getJSONTypes)(r.schemaType)};return(0,TU.eachItem)(n,i.type.length===0?o=>AU.call(this,o,i):o=>i.type.forEach(s=>AU.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]=yhe(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,I6.normalizeId)(s||n);let u=I6.getSchemaRefs.call(this,e,n);return d=new T6.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):T6.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{T6.compileSchema.call(this,e)}finally{this.opts=r}}};as.default=P6;P6.ValidationError=Oze.default;P6.MissingRefError=phe.default;function fhe(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 hhe(t){return t=(0,I6.normalizeId)(t),this.schemas[t]||this.refs[t]}function Fze(){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 zze(){for(let t in this.opts.formats){let e=this.opts.formats[t];e&&this.addFormat(t,e)}}function Vze(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 Hze(){let t={...this.opts};for(let e of jze)delete t[e];return t}var Wze={log(){},warn(){},error(){}};function Gze(t){if(t===!1)return Wze;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 Jze=/^[a-z_$][a-z0-9_$:-]*$/i;function Yze(t,e){let{RULES:r}=this;if((0,TU.eachItem)(t,n=>{if(r.keywords[n])throw new Error(`Keyword ${n} is already defined`);if(!Jze.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 AU(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,DI.getJSONTypes)(e.type),schemaType:(0,DI.getJSONTypes)(e.schemaType)}};e.before?Zze.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 Zze(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 Xze(t){let{metaSchema:e}=t;e!==void 0&&(t.$data&&this.opts.$data&&(e=yhe(e)),t.validateSchema=this.compile(e,!0))}var Qze={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function yhe(t){return{anyOf:[t,Qze]}}});var vhe=H(IU=>{"use strict";h();Object.defineProperty(IU,"__esModule",{value:!0});var eVe={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};IU.default=eVe});var $I=H(Wg=>{"use strict";h();Object.defineProperty(Wg,"__esModule",{value:!0});Wg.callRef=Wg.getValidate=void 0;var tVe=BI(),bhe=kd(),Fa=tr(),P1=Pd(),whe=A6(),OI=Rr(),rVe={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=whe.resolveRef.call(d,u,i,r);if(c===void 0)throw new tVe.default(n.opts.uriResolver,i,r);if(c instanceof whe.SchemaEnv)return m(c);return p(c);function l(){if(o===u)return CI(t,s,o,o.$async);let g=e.scopeValue("root",{ref:u});return CI(t,(0,Fa._)`${g}.validate`,u,u.$async)}function m(g){let v=_he(t,g);CI(t,v,g,g.$async)}function p(g){let v=e.scopeValue("schema",a.code.source===!0?{ref:g,code:(0,Fa.stringify)(g)}:{ref:g}),E=e.name("valid"),A=t.subschema({schema:g,dataTypes:[],schemaPath:Fa.nil,topSchemaRef:v,errSchemaPath:r},E);t.mergeEvaluated(A),t.ok(E)}}};function _he(t,e){let{gen:r}=t;return e.validate?r.scopeValue("validate",{ref:e.validate}):(0,Fa._)`${r.scopeValue("wrapper",{ref:e})}.validate`}Wg.getValidate=_he;function CI(t,e,r,n){let{gen:i,it:o}=t,{allErrors:s,schemaEnv:a,opts:d}=o,u=d.passContext?P1.default.this:Fa.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,Fa._)`await ${(0,bhe.callValidateCode)(t,e,u)}`),p(e),s||i.assign(g,!0)},v=>{i.if((0,Fa._)`!(${v} instanceof ${o.ValidationError})`,()=>i.throw(v)),m(v),s||i.assign(g,!1)}),t.ok(g)}function l(){t.result((0,bhe.callValidateCode)(t,e,u),()=>p(e),()=>m(e))}function m(g){let v=(0,Fa._)`${g}.errors`;i.assign(P1.default.vErrors,(0,Fa._)`${P1.default.vErrors} === null ? ${v} : ${P1.default.vErrors}.concat(${v})`),i.assign(P1.default.errors,(0,Fa._)`${P1.default.vErrors}.length`)}function p(g){var v;if(!o.opts.unevaluated)return;let E=(v=r?.validate)===null||v===void 0?void 0:v.evaluated;if(o.props!==!0)if(E&&!E.dynamicProps)E.props!==void 0&&(o.props=OI.mergeEvaluated.props(i,E.props,o.props));else{let A=i.var("props",(0,Fa._)`${g}.evaluated.props`);o.props=OI.mergeEvaluated.props(i,A,o.props,Fa.Name)}if(o.items!==!0)if(E&&!E.dynamicItems)E.items!==void 0&&(o.items=OI.mergeEvaluated.items(i,E.items,o.items));else{let A=i.var("items",(0,Fa._)`${g}.evaluated.items`);o.items=OI.mergeEvaluated.items(i,A,o.items,Fa.Name)}}}Wg.callRef=CI;Wg.default=rVe});var xhe=H(PU=>{"use strict";h();Object.defineProperty(PU,"__esModule",{value:!0});var nVe=vhe(),iVe=$I(),oVe=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",nVe.default,iVe.default];PU.default=oVe});var Ehe=H(kU=>{"use strict";h();Object.defineProperty(kU,"__esModule",{value:!0});var NI=tr(),Zm=NI.operators,jI={maximum:{okStr:"<=",ok:Zm.LTE,fail:Zm.GT},minimum:{okStr:">=",ok:Zm.GTE,fail:Zm.LT},exclusiveMaximum:{okStr:"<",ok:Zm.LT,fail:Zm.GTE},exclusiveMinimum:{okStr:">",ok:Zm.GT,fail:Zm.LTE}},sVe={message:({keyword:t,schemaCode:e})=>(0,NI.str)`must be ${jI[t].okStr} ${e}`,params:({keyword:t,schemaCode:e})=>(0,NI._)`{comparison: ${jI[t].okStr}, limit: ${e}}`},aVe={keyword:Object.keys(jI),type:"number",schemaType:"number",$data:!0,error:sVe,code(t){let{keyword:e,data:r,schemaCode:n}=t;t.fail$data((0,NI._)`${r} ${jI[e].fail} ${n} || isNaN(${r})`)}};kU.default=aVe});var She=H(RU=>{"use strict";h();Object.defineProperty(RU,"__esModule",{value:!0});var k6=tr(),cVe={message:({schemaCode:t})=>(0,k6.str)`must be multiple of ${t}`,params:({schemaCode:t})=>(0,k6._)`{multipleOf: ${t}}`},dVe={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:cVe,code(t){let{gen:e,data:r,schemaCode:n,it:i}=t,o=i.opts.multipleOfPrecision,s=e.let("res"),a=o?(0,k6._)`Math.abs(Math.round(${s}) - ${s}) > 1e-${o}`:(0,k6._)`${s} !== parseInt(${s})`;t.fail$data((0,k6._)`(${n} === 0 || (${s} = ${r}/${n}, ${a}))`)}};RU.default=dVe});var The=H(BU=>{"use strict";h();Object.defineProperty(BU,"__esModule",{value:!0});function Ahe(t){let e=t.length,r=0,n=0,i;for(;n<e;)r++,i=t.charCodeAt(n++),i>=55296&&i<=56319&&n<e&&(i=t.charCodeAt(n),(i&64512)===56320&&n++);return r}BU.default=Ahe;Ahe.code='require("ajv/dist/runtime/ucs2length").default'});var Ihe=H(MU=>{"use strict";h();Object.defineProperty(MU,"__esModule",{value:!0});var Gg=tr(),uVe=Rr(),lVe=The(),fVe={message({keyword:t,schemaCode:e}){let r=t==="maxLength"?"more":"fewer";return(0,Gg.str)`must NOT have ${r} than ${e} characters`},params:({schemaCode:t})=>(0,Gg._)`{limit: ${t}}`},hVe={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:fVe,code(t){let{keyword:e,data:r,schemaCode:n,it:i}=t,o=e==="maxLength"?Gg.operators.GT:Gg.operators.LT,s=i.opts.unicode===!1?(0,Gg._)`${r}.length`:(0,Gg._)`${(0,uVe.useFunc)(t.gen,lVe.default)}(${r})`;t.fail$data((0,Gg._)`${s} ${o} ${n}`)}};MU.default=hVe});var Phe=H(DU=>{"use strict";h();Object.defineProperty(DU,"__esModule",{value:!0});var pVe=kd(),UI=tr(),mVe={message:({schemaCode:t})=>(0,UI.str)`must match pattern "${t}"`,params:({schemaCode:t})=>(0,UI._)`{pattern: ${t}}`},yVe={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:mVe,code(t){let{data:e,$data:r,schema:n,schemaCode:i,it:o}=t,s=o.opts.unicodeRegExp?"u":"",a=r?(0,UI._)`(new RegExp(${i}, ${s}))`:(0,pVe.usePattern)(t,n);t.fail$data((0,UI._)`!${a}.test(${e})`)}};DU.default=yVe});var khe=H(OU=>{"use strict";h();Object.defineProperty(OU,"__esModule",{value:!0});var R6=tr(),gVe={message({keyword:t,schemaCode:e}){let r=t==="maxProperties"?"more":"fewer";return(0,R6.str)`must NOT have ${r} than ${e} properties`},params:({schemaCode:t})=>(0,R6._)`{limit: ${t}}`},vVe={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:gVe,code(t){let{keyword:e,data:r,schemaCode:n}=t,i=e==="maxProperties"?R6.operators.GT:R6.operators.LT;t.fail$data((0,R6._)`Object.keys(${r}).length ${i} ${n}`)}};OU.default=vVe});var Rhe=H(CU=>{"use strict";h();Object.defineProperty(CU,"__esModule",{value:!0});var B6=kd(),M6=tr(),bVe=Rr(),wVe={message:({params:{missingProperty:t}})=>(0,M6.str)`must have required property '${t}'`,params:({params:{missingProperty:t}})=>(0,M6._)`{missingProperty: ${t}}`},_Ve={keyword:"required",type:"object",schemaType:"array",$data:!0,error:wVe,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 v of r)if(p?.[v]===void 0&&!g.has(v)){let E=s.schemaEnv.baseId+s.errSchemaPath,A=`required property "${v}" is not defined at "${E}" (strictRequired)`;(0,bVe.checkStrictMode)(s,A,s.opts.strictRequired)}}function u(){if(d||o)t.block$data(M6.nil,l);else for(let p of r)(0,B6.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,B6.checkMissingProp)(t,r,p)),(0,B6.reportMissingProp)(t,p),e.else()}function l(){e.forOf("prop",n,p=>{t.setParams({missingProperty:p}),e.if((0,B6.noPropertyInData)(e,i,p,a.ownProperties),()=>t.error())})}function m(p,g){t.setParams({missingProperty:p}),e.forOf(p,n,()=>{e.assign(g,(0,B6.propertyInData)(e,i,p,a.ownProperties)),e.if((0,M6.not)(g),()=>{t.error(),e.break()})},M6.nil)}}};CU.default=_Ve});var Bhe=H($U=>{"use strict";h();Object.defineProperty($U,"__esModule",{value:!0});var D6=tr(),xVe={message({keyword:t,schemaCode:e}){let r=t==="maxItems"?"more":"fewer";return(0,D6.str)`must NOT have ${r} than ${e} items`},params:({schemaCode:t})=>(0,D6._)`{limit: ${t}}`},EVe={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:xVe,code(t){let{keyword:e,data:r,schemaCode:n}=t,i=e==="maxItems"?D6.operators.GT:D6.operators.LT;t.fail$data((0,D6._)`${r}.length ${i} ${n}`)}};$U.default=EVe});var qI=H(NU=>{"use strict";h();Object.defineProperty(NU,"__esModule",{value:!0});var Mhe=fU();Mhe.code='require("ajv/dist/runtime/equal").default';NU.default=Mhe});var Dhe=H(UU=>{"use strict";h();Object.defineProperty(UU,"__esModule",{value:!0});var jU=w6(),cs=tr(),SVe=Rr(),AVe=qI(),TVe={message:({params:{i:t,j:e}})=>(0,cs.str)`must NOT have duplicate items (items ## ${e} and ${t} are identical)`,params:({params:{i:t,j:e}})=>(0,cs._)`{i: ${t}, j: ${e}}`},IVe={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:TVe,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,jU.getSchemaTypes)(o.items):[];t.block$data(d,c,(0,cs._)`${s} === false`),t.ok(d);function c(){let g=e.let("i",(0,cs._)`${r}.length`),v=e.let("j");t.setParams({i:g,j:v}),e.assign(d,!0),e.if((0,cs._)`${g} > 1`,()=>(l()?m:p)(g,v))}function l(){return u.length>0&&!u.some(g=>g==="object"||g==="array")}function m(g,v){let E=e.name("item"),A=(0,jU.checkDataTypes)(u,E,a.opts.strictNumbers,jU.DataType.Wrong),P=e.const("indices",(0,cs._)`{}`);e.for((0,cs._)`;${g}--;`,()=>{e.let(E,(0,cs._)`${r}[${g}]`),e.if(A,(0,cs._)`continue`),u.length>1&&e.if((0,cs._)`typeof ${E} == "string"`,(0,cs._)`${E} += "_"`),e.if((0,cs._)`typeof ${P}[${E}] == "number"`,()=>{e.assign(v,(0,cs._)`${P}[${E}]`),t.error(),e.assign(d,!1).break()}).code((0,cs._)`${P}[${E}] = ${g}`)})}function p(g,v){let E=(0,SVe.useFunc)(e,AVe.default),A=e.name("outer");e.label(A).for((0,cs._)`;${g}--;`,()=>e.for((0,cs._)`${v} = ${g}; ${v}--;`,()=>e.if((0,cs._)`${E}(${r}[${g}], ${r}[${v}])`,()=>{t.error(),e.assign(d,!1).break(A)})))}}};UU.default=IVe});var Ohe=H(LU=>{"use strict";h();Object.defineProperty(LU,"__esModule",{value:!0});var qU=tr(),PVe=Rr(),kVe=qI(),RVe={message:"must be equal to constant",params:({schemaCode:t})=>(0,qU._)`{allowedValue: ${t}}`},BVe={keyword:"const",$data:!0,error:RVe,code(t){let{gen:e,data:r,$data:n,schemaCode:i,schema:o}=t;n||o&&typeof o=="object"?t.fail$data((0,qU._)`!${(0,PVe.useFunc)(e,kVe.default)}(${r}, ${i})`):t.fail((0,qU._)`${o} !== ${r}`)}};LU.default=BVe});var Che=H(KU=>{"use strict";h();Object.defineProperty(KU,"__esModule",{value:!0});var O6=tr(),MVe=Rr(),DVe=qI(),OVe={message:"must be equal to one of the allowed values",params:({schemaCode:t})=>(0,O6._)`{allowedValues: ${t}}`},CVe={keyword:"enum",schemaType:"array",$data:!0,error:OVe,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,MVe.useFunc)(e,DVe.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,O6.or)(...i.map((g,v)=>m(p,v)))}t.pass(c);function l(){e.assign(c,!1),e.forOf("v",o,p=>e.if((0,O6._)`${u()}(${r}, ${p})`,()=>e.assign(c,!0).break()))}function m(p,g){let v=i[g];return typeof v=="object"&&v!==null?(0,O6._)`${u()}(${r}, ${p}[${g}])`:(0,O6._)`${r} === ${v}`}}};KU.default=CVe});var $he=H(FU=>{"use strict";h();Object.defineProperty(FU,"__esModule",{value:!0});var $Ve=Ehe(),NVe=She(),jVe=Ihe(),UVe=Phe(),qVe=khe(),LVe=Rhe(),KVe=Bhe(),FVe=Dhe(),zVe=Ohe(),VVe=Che(),HVe=[$Ve.default,NVe.default,jVe.default,UVe.default,qVe.default,LVe.default,KVe.default,FVe.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},zVe.default,VVe.default];FU.default=HVe});var VU=H(C6=>{"use strict";h();Object.defineProperty(C6,"__esModule",{value:!0});C6.validateAdditionalItems=void 0;var Jg=tr(),zU=Rr(),WVe={message:({params:{len:t}})=>(0,Jg.str)`must NOT have more than ${t} items`,params:({params:{len:t}})=>(0,Jg._)`{limit: ${t}}`},GVe={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:WVe,code(t){let{parentSchema:e,it:r}=t,{items:n}=e;if(!Array.isArray(n)){(0,zU.checkStrictMode)(r,'"additionalItems" is ignored when "items" is not an array of schemas');return}Nhe(t,n)}};function Nhe(t,e){let{gen:r,schema:n,data:i,keyword:o,it:s}=t;s.items=!0;let a=r.const("len",(0,Jg._)`${i}.length`);if(n===!1)t.setParams({len:e.length}),t.pass((0,Jg._)`${a} <= ${e.length}`);else if(typeof n=="object"&&!(0,zU.alwaysValidSchema)(s,n)){let u=r.var("valid",(0,Jg._)`${a} <= ${e.length}`);r.if((0,Jg.not)(u),()=>d(u)),t.ok(u)}function d(u){r.forRange("i",e.length,a,c=>{t.subschema({keyword:o,dataProp:c,dataPropType:zU.Type.Num},u),s.allErrors||r.if((0,Jg.not)(u),()=>r.break())})}}C6.validateAdditionalItems=Nhe;C6.default=GVe});var HU=H($6=>{"use strict";h();Object.defineProperty($6,"__esModule",{value:!0});$6.validateTuple=void 0;var jhe=tr(),LI=Rr(),JVe=kd(),YVe={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(t){let{schema:e,it:r}=t;if(Array.isArray(e))return Uhe(t,"additionalItems",e);r.items=!0,!(0,LI.alwaysValidSchema)(r,e)&&t.ok((0,JVe.validateArray)(t))}};function Uhe(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=LI.mergeEvaluated.items(n,r.length,a.items));let d=n.name("valid"),u=n.const("len",(0,jhe._)`${o}.length`);r.forEach((l,m)=>{(0,LI.alwaysValidSchema)(a,l)||(n.if((0,jhe._)`${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,v=g===l.minItems&&(g===l.maxItems||l[e]===!1);if(m.strictTuples&&!v){let E=`"${s}" is ${g}-tuple, but minItems or maxItems/${e} are not specified or different at path "${p}"`;(0,LI.checkStrictMode)(a,E,m.strictTuples)}}}$6.validateTuple=Uhe;$6.default=YVe});var qhe=H(WU=>{"use strict";h();Object.defineProperty(WU,"__esModule",{value:!0});var ZVe=HU(),XVe={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:t=>(0,ZVe.validateTuple)(t,"items")};WU.default=XVe});var Khe=H(GU=>{"use strict";h();Object.defineProperty(GU,"__esModule",{value:!0});var Lhe=tr(),QVe=Rr(),eHe=kd(),tHe=VU(),rHe={message:({params:{len:t}})=>(0,Lhe.str)`must NOT have more than ${t} items`,params:({params:{len:t}})=>(0,Lhe._)`{limit: ${t}}`},nHe={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:rHe,code(t){let{schema:e,parentSchema:r,it:n}=t,{prefixItems:i}=r;n.items=!0,!(0,QVe.alwaysValidSchema)(n,e)&&(i?(0,tHe.validateAdditionalItems)(t,i):t.ok((0,eHe.validateArray)(t)))}};GU.default=nHe});var Fhe=H(JU=>{"use strict";h();Object.defineProperty(JU,"__esModule",{value:!0});var Bd=tr(),KI=Rr(),iHe={message:({params:{min:t,max:e}})=>e===void 0?(0,Bd.str)`must contain at least ${t} valid item(s)`:(0,Bd.str)`must contain at least ${t} and no more than ${e} valid item(s)`,params:({params:{min:t,max:e}})=>e===void 0?(0,Bd._)`{minContains: ${t}}`:(0,Bd._)`{minContains: ${t}, maxContains: ${e}}`},oHe={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:iHe,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,Bd._)`${i}.length`);if(t.setParams({min:s,max:a}),a===void 0&&s===0){(0,KI.checkStrictMode)(o,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(a!==void 0&&s>a){(0,KI.checkStrictMode)(o,'"minContains" > "maxContains" is always invalid'),t.fail();return}if((0,KI.alwaysValidSchema)(o,r)){let v=(0,Bd._)`${c} >= ${s}`;a!==void 0&&(v=(0,Bd._)`${v} && ${c} <= ${a}`),t.pass(v);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,Bd._)`${i}.length > 0`,m)):(e.let(l,!1),m()),t.result(l,()=>t.reset());function m(){let v=e.name("_valid"),E=e.let("count",0);p(v,()=>e.if(v,()=>g(E)))}function p(v,E){e.forRange("i",0,c,A=>{t.subschema({keyword:"contains",dataProp:A,dataPropType:KI.Type.Num,compositeRule:!0},v),E()})}function g(v){e.code((0,Bd._)`${v}++`),a===void 0?e.if((0,Bd._)`${v} >= ${s}`,()=>e.assign(l,!0).break()):(e.if((0,Bd._)`${v} > ${a}`,()=>e.assign(l,!1).break()),s===1?e.assign(l,!0):e.if((0,Bd._)`${v} >= ${s}`,()=>e.assign(l,!0)))}}};JU.default=oHe});var FI=H(rf=>{"use strict";h();Object.defineProperty(rf,"__esModule",{value:!0});rf.validateSchemaDeps=rf.validatePropertyDeps=rf.error=void 0;var YU=tr(),sHe=Rr(),N6=kd();rf.error={message:({params:{property:t,depsCount:e,deps:r}})=>{let n=e===1?"property":"properties";return(0,YU.str)`must have ${n} ${r} when property ${t} is present`},params:({params:{property:t,depsCount:e,deps:r,missingProperty:n}})=>(0,YU._)`{property: ${t},
missingProperty: ${n},
depsCount: ${e},
deps: ${r}}`};var aHe={keyword:"dependencies",type:"object",schemaType:"object",error:rf.error,code(t){let[e,r]=cHe(t);zhe(t,e),Vhe(t,r)}};function cHe({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 zhe(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,N6.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,N6.checkReportMissingProp)(t,u)}):(r.if((0,YU._)`${d} && (${(0,N6.checkMissingProp)(t,a,o)})`),(0,N6.reportMissingProp)(t,o),r.else())}}rf.validatePropertyDeps=zhe;function Vhe(t,e=t.schema){let{gen:r,data:n,keyword:i,it:o}=t,s=r.name("valid");for(let a in e)(0,sHe.alwaysValidSchema)(o,e[a])||(r.if((0,N6.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))}rf.validateSchemaDeps=Vhe;rf.default=aHe});var Whe=H(ZU=>{"use strict";h();Object.defineProperty(ZU,"__esModule",{value:!0});var Hhe=tr(),dHe=Rr(),uHe={message:"property name must be valid",params:({params:t})=>(0,Hhe._)`{propertyName: ${t.propertyName}}`},lHe={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:uHe,code(t){let{gen:e,schema:r,data:n,it:i}=t;if((0,dHe.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,Hhe.not)(o),()=>{t.error(!0),i.allErrors||e.break()})}),t.ok(o)}};ZU.default=lHe});var QU=H(XU=>{"use strict";h();Object.defineProperty(XU,"__esModule",{value:!0});var zI=kd(),Du=tr(),fHe=Pd(),VI=Rr(),hHe={message:"must NOT have additional properties",params:({params:t})=>(0,Du._)`{additionalProperty: ${t.additionalProperty}}`},pHe={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:hHe,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,VI.alwaysValidSchema)(s,r))return;let u=(0,zI.allSchemaProperties)(n.properties),c=(0,zI.allSchemaProperties)(n.patternProperties);l(),t.ok((0,Du._)`${o} === ${fHe.default.errors}`);function l(){e.forIn("key",i,E=>{!u.length&&!c.length?g(E):e.if(m(E),()=>g(E))})}function m(E){let A;if(u.length>8){let P=(0,VI.schemaRefOrVal)(s,n.properties,"properties");A=(0,zI.isOwnProperty)(e,P,E)}else u.length?A=(0,Du.or)(...u.map(P=>(0,Du._)`${E} === ${P}`)):A=Du.nil;return c.length&&(A=(0,Du.or)(A,...c.map(P=>(0,Du._)`${(0,zI.usePattern)(t,P)}.test(${E})`))),(0,Du.not)(A)}function p(E){e.code((0,Du._)`delete ${i}[${E}]`)}function g(E){if(d.removeAdditional==="all"||d.removeAdditional&&r===!1){p(E);return}if(r===!1){t.setParams({additionalProperty:E}),t.error(),a||e.break();return}if(typeof r=="object"&&!(0,VI.alwaysValidSchema)(s,r)){let A=e.name("valid");d.removeAdditional==="failing"?(v(E,A,!1),e.if((0,Du.not)(A),()=>{t.reset(),p(E)})):(v(E,A),a||e.if((0,Du.not)(A),()=>e.break()))}}function v(E,A,P){let I={keyword:"additionalProperties",dataProp:E,dataPropType:VI.Type.Str};P===!1&&Object.assign(I,{compositeRule:!0,createErrors:!1,allErrors:!1}),t.subschema(I,A)}}};XU.default=pHe});var Yhe=H(tq=>{"use strict";h();Object.defineProperty(tq,"__esModule",{value:!0});var mHe=S6(),Ghe=kd(),eq=Rr(),Jhe=QU(),yHe={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&&Jhe.default.code(new mHe.KeywordCxt(o,Jhe.default,"additionalProperties"));let s=(0,Ghe.allSchemaProperties)(r);for(let l of s)o.definedProperties.add(l);o.opts.unevaluated&&s.length&&o.props!==!0&&(o.props=eq.mergeEvaluated.props(e,(0,eq.toHash)(s),o.props));let a=s.filter(l=>!(0,eq.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,Ghe.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)}}};tq.default=yHe});var epe=H(rq=>{"use strict";h();Object.defineProperty(rq,"__esModule",{value:!0});var Zhe=kd(),HI=tr(),Xhe=Rr(),Qhe=Rr(),gHe={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,Zhe.allSchemaProperties)(r),d=a.filter(v=>(0,Xhe.alwaysValidSchema)(o,r[v]));if(a.length===0||d.length===a.length&&(!o.opts.unevaluated||o.props===!0))return;let u=s.strictSchema&&!s.allowMatchingProperties&&i.properties,c=e.name("valid");o.props!==!0&&!(o.props instanceof HI.Name)&&(o.props=(0,Qhe.evaluatedPropsToName)(e,o.props));let{props:l}=o;m();function m(){for(let v of a)u&&p(v),o.allErrors?g(v):(e.var(c,!0),g(v),e.if(c))}function p(v){for(let E in u)new RegExp(v).test(E)&&(0,Xhe.checkStrictMode)(o,`property ${E} matches pattern ${v} (use allowMatchingProperties)`)}function g(v){e.forIn("key",n,E=>{e.if((0,HI._)`${(0,Zhe.usePattern)(t,v)}.test(${E})`,()=>{let A=d.includes(v);A||t.subschema({keyword:"patternProperties",schemaProp:v,dataProp:E,dataPropType:Qhe.Type.Str},c),o.opts.unevaluated&&l!==!0?e.assign((0,HI._)`${l}[${E}]`,!0):!A&&!o.allErrors&&e.if((0,HI.not)(c),()=>e.break())})})}}};rq.default=gHe});var tpe=H(nq=>{"use strict";h();Object.defineProperty(nq,"__esModule",{value:!0});var vHe=Rr(),bHe={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(t){let{gen:e,schema:r,it:n}=t;if((0,vHe.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"}};nq.default=bHe});var rpe=H(iq=>{"use strict";h();Object.defineProperty(iq,"__esModule",{value:!0});var wHe=kd(),_He={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:wHe.validateUnion,error:{message:"must match a schema in anyOf"}};iq.default=_He});var npe=H(oq=>{"use strict";h();Object.defineProperty(oq,"__esModule",{value:!0});var WI=tr(),xHe=Rr(),EHe={message:"must match exactly one schema in oneOf",params:({params:t})=>(0,WI._)`{passingSchemas: ${t.passing}}`},SHe={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:EHe,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,xHe.alwaysValidSchema)(i,c)?e.var(d,!0):m=t.subschema({keyword:"oneOf",schemaProp:l,compositeRule:!0},d),l>0&&e.if((0,WI._)`${d} && ${s}`).assign(s,!1).assign(a,(0,WI._)`[${a}, ${l}]`).else(),e.if(d,()=>{e.assign(s,!0),e.assign(a,l),m&&t.mergeEvaluated(m,WI.Name)})})}}};oq.default=SHe});var ipe=H(sq=>{"use strict";h();Object.defineProperty(sq,"__esModule",{value:!0});var AHe=Rr(),THe={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,AHe.alwaysValidSchema)(n,o))return;let a=t.subschema({keyword:"allOf",schemaProp:s},i);t.ok(i),t.mergeEvaluated(a)})}};sq.default=THe});var ape=H(aq=>{"use strict";h();Object.defineProperty(aq,"__esModule",{value:!0});var GI=tr(),spe=Rr(),IHe={message:({params:t})=>(0,GI.str)`must match "${t.ifClause}" schema`,params:({params:t})=>(0,GI._)`{failingKeyword: ${t.ifClause}}`},PHe={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:IHe,code(t){let{gen:e,parentSchema:r,it:n}=t;r.then===void 0&&r.else===void 0&&(0,spe.checkStrictMode)(n,'"if" without "then" and "else" is ignored');let i=ope(n,"then"),o=ope(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,GI.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,GI._)`${c}`):t.setParams({ifClause:c})}}}};function ope(t,e){let r=t.schema[e];return r!==void 0&&!(0,spe.alwaysValidSchema)(t,r)}aq.default=PHe});var cpe=H(cq=>{"use strict";h();Object.defineProperty(cq,"__esModule",{value:!0});var kHe=Rr(),RHe={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:t,parentSchema:e,it:r}){e.if===void 0&&(0,kHe.checkStrictMode)(r,`"${t}" without "if" is ignored`)}};cq.default=RHe});var dpe=H(dq=>{"use strict";h();Object.defineProperty(dq,"__esModule",{value:!0});var BHe=VU(),MHe=qhe(),DHe=HU(),OHe=Khe(),CHe=Fhe(),$He=FI(),NHe=Whe(),jHe=QU(),UHe=Yhe(),qHe=epe(),LHe=tpe(),KHe=rpe(),FHe=npe(),zHe=ipe(),VHe=ape(),HHe=cpe();function WHe(t=!1){let e=[LHe.default,KHe.default,FHe.default,zHe.default,VHe.default,HHe.default,NHe.default,jHe.default,$He.default,UHe.default,qHe.default];return t?e.push(MHe.default,OHe.default):e.push(BHe.default,DHe.default),e.push(CHe.default),e}dq.default=WHe});var lq=H(j6=>{"use strict";h();Object.defineProperty(j6,"__esModule",{value:!0});j6.dynamicAnchor=void 0;var uq=tr(),GHe=Pd(),upe=A6(),JHe=$I(),YHe={keyword:"$dynamicAnchor",schemaType:"string",code:t=>lpe(t,t.schema)};function lpe(t,e){let{gen:r,it:n}=t;n.schemaEnv.root.dynamicAnchors[e]=!0;let i=(0,uq._)`${GHe.default.dynamicAnchors}${(0,uq.getProperty)(e)}`,o=n.errSchemaPath==="#"?n.validateName:ZHe(t);r.if((0,uq._)`!${i}`,()=>r.assign(i,o))}j6.dynamicAnchor=lpe;function ZHe(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 upe.SchemaEnv({schema:r,schemaId:d,root:i,baseId:o,localRefs:s,meta:a});return upe.compileSchema.call(n,u),(0,JHe.getValidate)(t,u)}j6.default=YHe});var fq=H(U6=>{"use strict";h();Object.defineProperty(U6,"__esModule",{value:!0});U6.dynamicRef=void 0;var fpe=tr(),XHe=Pd(),hpe=$I(),QHe={keyword:"$dynamicRef",schemaType:"string",code:t=>ppe(t,t.schema)};function ppe(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,fpe._)`${XHe.default.dynamicAnchors}${(0,fpe.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,hpe.callRef)(t,d),r.let(u,!0)}):()=>(0,hpe.callRef)(t,d)}}U6.dynamicRef=ppe;U6.default=QHe});var mpe=H(hq=>{"use strict";h();Object.defineProperty(hq,"__esModule",{value:!0});var eWe=lq(),tWe=Rr(),rWe={keyword:"$recursiveAnchor",schemaType:"boolean",code(t){t.schema?(0,eWe.dynamicAnchor)(t,""):(0,tWe.checkStrictMode)(t.it,"$recursiveAnchor: false is ignored")}};hq.default=rWe});var ype=H(pq=>{"use strict";h();Object.defineProperty(pq,"__esModule",{value:!0});var nWe=fq(),iWe={keyword:"$recursiveRef",schemaType:"string",code:t=>(0,nWe.dynamicRef)(t,t.schema)};pq.default=iWe});var gpe=H(mq=>{"use strict";h();Object.defineProperty(mq,"__esModule",{value:!0});var oWe=lq(),sWe=fq(),aWe=mpe(),cWe=ype(),dWe=[oWe.default,sWe.default,aWe.default,cWe.default];mq.default=dWe});var bpe=H(yq=>{"use strict";h();Object.defineProperty(yq,"__esModule",{value:!0});var vpe=FI(),uWe={keyword:"dependentRequired",type:"object",schemaType:"object",error:vpe.error,code:t=>(0,vpe.validatePropertyDeps)(t)};yq.default=uWe});var wpe=H(gq=>{"use strict";h();Object.defineProperty(gq,"__esModule",{value:!0});var lWe=FI(),fWe={keyword:"dependentSchemas",type:"object",schemaType:"object",code:t=>(0,lWe.validateSchemaDeps)(t)};gq.default=fWe});var _pe=H(vq=>{"use strict";h();Object.defineProperty(vq,"__esModule",{value:!0});var hWe=Rr(),pWe={keyword:["maxContains","minContains"],type:"array",schemaType:"number",code({keyword:t,parentSchema:e,it:r}){e.contains===void 0&&(0,hWe.checkStrictMode)(r,`"${t}" without "contains" is ignored`)}};vq.default=pWe});var xpe=H(bq=>{"use strict";h();Object.defineProperty(bq,"__esModule",{value:!0});var mWe=bpe(),yWe=wpe(),gWe=_pe(),vWe=[mWe.default,yWe.default,gWe.default];bq.default=vWe});var Spe=H(wq=>{"use strict";h();Object.defineProperty(wq,"__esModule",{value:!0});var Xm=tr(),Epe=Rr(),bWe=Pd(),wWe={message:"must NOT have unevaluated properties",params:({params:t})=>(0,Xm._)`{unevaluatedProperty: ${t.unevaluatedProperty}}`},_We={keyword:"unevaluatedProperties",type:"object",schemaType:["boolean","object"],trackErrors:!0,error:wWe,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 Xm.Name?e.if((0,Xm._)`${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,Xm._)`${i} === ${bWe.default.errors}`);function d(l){if(r===!1){t.setParams({unevaluatedProperty:l}),t.error(),s||e.break();return}if(!(0,Epe.alwaysValidSchema)(o,r)){let m=e.name("valid");t.subschema({keyword:"unevaluatedProperties",dataProp:l,dataPropType:Epe.Type.Str},m),s||e.if((0,Xm.not)(m),()=>e.break())}}function u(l,m){return(0,Xm._)`!${l} || !${l}[${m}]`}function c(l,m){let p=[];for(let g in l)l[g]===!0&&p.push((0,Xm._)`${m} !== ${g}`);return(0,Xm.and)(...p)}}};wq.default=_We});var Tpe=H(_q=>{"use strict";h();Object.defineProperty(_q,"__esModule",{value:!0});var Yg=tr(),Ape=Rr(),xWe={message:({params:{len:t}})=>(0,Yg.str)`must NOT have more than ${t} items`,params:({params:{len:t}})=>(0,Yg._)`{limit: ${t}}`},EWe={keyword:"unevaluatedItems",type:"array",schemaType:["boolean","object"],error:xWe,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,Yg._)`${n}.length`);if(r===!1)t.setParams({len:o}),t.fail((0,Yg._)`${s} > ${o}`);else if(typeof r=="object"&&!(0,Ape.alwaysValidSchema)(i,r)){let d=e.var("valid",(0,Yg._)`${s} <= ${o}`);e.if((0,Yg.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:Ape.Type.Num},d),i.allErrors||e.if((0,Yg.not)(d),()=>e.break())})}}};_q.default=EWe});var Ipe=H(xq=>{"use strict";h();Object.defineProperty(xq,"__esModule",{value:!0});var SWe=Spe(),AWe=Tpe(),TWe=[SWe.default,AWe.default];xq.default=TWe});var Ppe=H(Eq=>{"use strict";h();Object.defineProperty(Eq,"__esModule",{value:!0});var Ri=tr(),IWe={message:({schemaCode:t})=>(0,Ri.str)`must match format "${t}"`,params:({schemaCode:t})=>(0,Ri._)`{format: ${t}}`},PWe={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:IWe,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}),v=r.const("fDef",(0,Ri._)`${g}[${s}]`),E=r.let("fType"),A=r.let("format");r.if((0,Ri._)`typeof ${v} == "object" && !(${v} instanceof RegExp)`,()=>r.assign(E,(0,Ri._)`${v}.type || "string"`).assign(A,(0,Ri._)`${v}.validate`),()=>r.assign(E,(0,Ri._)`"string"`).assign(A,v)),t.fail$data((0,Ri.or)(P(),I()));function P(){return d.strictSchema===!1?Ri.nil:(0,Ri._)`${s} && !${A}`}function I(){let $=c.$async?(0,Ri._)`(${v}.async ? await ${A}(${n}) : ${A}(${n}))`:(0,Ri._)`${A}(${n})`,N=(0,Ri._)`(typeof ${A} == "function" ? ${$} : ${A}.test(${n}))`;return(0,Ri._)`${A} && ${A} !== true && ${E} === ${e} && !${N}`}}function p(){let g=l.formats[o];if(!g){P();return}if(g===!0)return;let[v,E,A]=I(g);v===e&&t.pass($());function P(){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 I(N){let K=N instanceof RegExp?(0,Ri.regexpCode)(N):d.code.formats?(0,Ri._)`${d.code.formats}${(0,Ri.getProperty)(o)}`:void 0,F=r.scopeValue("formats",{key:o,ref:N,code:K});return typeof N=="object"&&!(N instanceof RegExp)?[N.type||"string",N.validate,(0,Ri._)`${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,Ri._)`await ${A}(${n})`}return typeof E=="function"?(0,Ri._)`${A}(${n})`:(0,Ri._)`${A}.test(${n})`}}}};Eq.default=PWe});var kpe=H(Sq=>{"use strict";h();Object.defineProperty(Sq,"__esModule",{value:!0});var kWe=Ppe(),RWe=[kWe.default];Sq.default=RWe});var Rpe=H(k1=>{"use strict";h();Object.defineProperty(k1,"__esModule",{value:!0});k1.contentVocabulary=k1.metadataVocabulary=void 0;k1.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];k1.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]});var Mpe=H(Aq=>{"use strict";h();Object.defineProperty(Aq,"__esModule",{value:!0});var BWe=xhe(),MWe=$he(),DWe=dpe(),OWe=gpe(),CWe=xpe(),$We=Ipe(),NWe=kpe(),Bpe=Rpe(),jWe=[OWe.default,BWe.default,MWe.default,(0,DWe.default)(!0),NWe.default,Bpe.metadataVocabulary,Bpe.contentVocabulary,CWe.default,$We.default];Aq.default=jWe});var Dpe=H(q6=>{"use strict";h();Object.defineProperty(q6,"__esModule",{value:!0});q6.DiscrError=void 0;var UWe;(function(t){t.Tag="tag",t.Mapping="mapping"})(UWe=q6.DiscrError||(q6.DiscrError={}))});var Cpe=H(Iq=>{"use strict";h();Object.defineProperty(Iq,"__esModule",{value:!0});var R1=tr(),Tq=Dpe(),Ope=A6(),qWe=Rr(),LWe={message:({params:{discrError:t,tagName:e}})=>t===Tq.DiscrError.Tag?`tag "${e}" must be string`:`value of tag "${e}" must be in oneOf`,params:({params:{discrError:t,tag:e,tagName:r}})=>(0,R1._)`{error: ${t}, tag: ${r}, tagValue: ${e}}`},KWe={keyword:"discriminator",type:"object",schemaType:"object",error:LWe,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,R1._)`${r}${(0,R1.getProperty)(a)}`);e.if((0,R1._)`typeof ${u} == "string"`,()=>c(),()=>t.error(!1,{discrError:Tq.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,R1._)`${u} === ${g}`),e.assign(d,l(p[g]));e.else(),t.error(!1,{discrError:Tq.DiscrError.Mapping,tag:u,tagName:a}),e.endIf()}function l(p){let g=e.name("valid"),v=t.subschema({keyword:"oneOf",schemaProp:p},g);return t.mergeEvaluated(v,R1.Name),g}function m(){var p;let g={},v=A(i),E=!0;for(let $=0;$<s.length;$++){let N=s[$];N?.$ref&&!(0,qWe.schemaHasRulesButRef)(N,o.self.RULES)&&(N=Ope.resolveRef.call(o.self,o.schemaEnv.root,o.baseId,N?.$ref),N instanceof Ope.SchemaEnv&&(N=N.schema));let K=(p=N?.properties)===null||p===void 0?void 0:p[a];if(typeof K!="object")throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${a}"`);E=E&&(v||A(N)),P(K,$)}if(!E)throw new Error(`discriminator: "${a}" must be required`);return g;function A({required:$}){return Array.isArray($)&&$.includes(a)}function P($,N){if($.const)I($.const,N);else if($.enum)for(let K of $.enum)I(K,N);else throw new Error(`discriminator: "properties/${a}" must have "const" or "enum"`)}function I($,N){if(typeof $!="string"||$ in g)throw new Error(`discriminator: "${a}" values must be unique strings`);g[$]=N}}}};Iq.default=KWe});var $pe=H((ZAt,FWe)=>{FWe.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 Npe=H((XAt,zWe)=>{zWe.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 jpe=H((QAt,VWe)=>{VWe.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 Upe=H((eTt,HWe)=>{HWe.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 qpe=H((tTt,WWe)=>{WWe.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 Lpe=H((rTt,GWe)=>{GWe.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 Kpe=H((nTt,JWe)=>{JWe.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 Fpe=H((iTt,YWe)=>{YWe.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 zpe=H(Pq=>{"use strict";h();Object.defineProperty(Pq,"__esModule",{value:!0});var ZWe=$pe(),XWe=Npe(),QWe=jpe(),eGe=Upe(),tGe=qpe(),rGe=Lpe(),nGe=Kpe(),iGe=Fpe(),oGe=["/properties"];function sGe(t){return[ZWe,XWe,QWe,eGe,tGe,e(this,rGe),nGe,e(this,iGe)].forEach(r=>this.addMetaSchema(r,void 0,!1)),this;function e(r,n){return t?r.$dataMetaSchema(n,oGe):n}}Pq.default=sGe});var Rq=H((ti,Vpe)=>{"use strict";h();Object.defineProperty(ti,"__esModule",{value:!0});ti.MissingRefError=ti.ValidationError=ti.CodeGen=ti.Name=ti.nil=ti.stringify=ti.str=ti._=ti.KeywordCxt=void 0;var aGe=ghe(),cGe=Mpe(),dGe=Cpe(),uGe=zpe(),kq="https://json-schema.org/draft/2020-12/schema",JI=class extends aGe.default{constructor(e={}){super({...e,dynamicRef:!0,next:!0,unevaluated:!0})}_addVocabularies(){super._addVocabularies(),cGe.default.forEach(e=>this.addVocabulary(e)),this.opts.discriminator&&this.addKeyword(dGe.default)}_addDefaultMetaSchema(){super._addDefaultMetaSchema();let{$data:e,meta:r}=this.opts;r&&(uGe.default.call(this,e),this.refs["http://json-schema.org/schema"]=kq)}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(kq)?kq:void 0)}};Vpe.exports=ti=JI;Object.defineProperty(ti,"__esModule",{value:!0});ti.default=JI;var lGe=S6();Object.defineProperty(ti,"KeywordCxt",{enumerable:!0,get:function(){return lGe.KeywordCxt}});var B1=tr();Object.defineProperty(ti,"_",{enumerable:!0,get:function(){return B1._}});Object.defineProperty(ti,"str",{enumerable:!0,get:function(){return B1.str}});Object.defineProperty(ti,"stringify",{enumerable:!0,get:function(){return B1.stringify}});Object.defineProperty(ti,"nil",{enumerable:!0,get:function(){return B1.nil}});Object.defineProperty(ti,"Name",{enumerable:!0,get:function(){return B1.Name}});Object.defineProperty(ti,"CodeGen",{enumerable:!0,get:function(){return B1.CodeGen}});var fGe=RI();Object.defineProperty(ti,"ValidationError",{enumerable:!0,get:function(){return fGe.default}});var hGe=BI();Object.defineProperty(ti,"MissingRefError",{enumerable:!0,get:function(){return hGe.default}})});var Uye=H((eMt,tL)=>{"use strict";h();var RJe=Object.prototype.hasOwnProperty,ga="~";function Z6(){}Object.create&&(Z6.prototype=Object.create(null),new Z6().__proto__||(ga=!1));function BJe(t,e,r){this.fn=t,this.context=e,this.once=r||!1}function jye(t,e,r,n,i){if(typeof r!="function")throw new TypeError("The listener must be a function");var o=new BJe(r,n||t,i),s=ga?ga+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 PP(t,e){--t._eventsCount===0?t._events=new Z6:delete t._events[e]}function js(){this._events=new Z6,this._eventsCount=0}js.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(ga?n.slice(1):n);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(r)):e};js.prototype.listeners=function(e){var r=ga?ga+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<o;i++)s[i]=n[i].fn;return s};js.prototype.listenerCount=function(e){var r=ga?ga+e:e,n=this._events[r];return n?n.fn?1:n.length:0};js.prototype.emit=function(e,r,n,i,o,s){var a=ga?ga+e:e;if(!this._events[a])return!1;var d=this._events[a],u=arguments.length,c,l;if(d.fn){switch(d.once&&this.removeListener(e,d.fn,void 0,!0),u){case 1:return d.fn.call(d.context),!0;case 2:return d.fn.call(d.context,r),!0;case 3:return d.fn.call(d.context,r,n),!0;case 4:return d.fn.call(d.context,r,n,i),!0;case 5:return d.fn.call(d.context,r,n,i,o),!0;case 6:return d.fn.call(d.context,r,n,i,o,s),!0}for(l=1,c=new Array(u-1);l<u;l++)c[l-1]=arguments[l];d.fn.apply(d.context,c)}else{var m=d.length,p;for(l=0;l<m;l++)switch(d[l].once&&this.removeListener(e,d[l].fn,void 0,!0),u){case 1:d[l].fn.call(d[l].context);break;case 2:d[l].fn.call(d[l].context,r);break;case 3:d[l].fn.call(d[l].context,r,n);break;case 4:d[l].fn.call(d[l].context,r,n,i);break;default:if(!c)for(p=1,c=new Array(u-1);p<u;p++)c[p-1]=arguments[p];d[l].fn.apply(d[l].context,c)}}return!0};js.prototype.on=function(e,r,n){return jye(this,e,r,n,!1)};js.prototype.once=function(e,r,n){return jye(this,e,r,n,!0)};js.prototype.removeListener=function(e,r,n,i){var o=ga?ga+e:e;if(!this._events[o])return this;if(!r)return PP(this,o),this;var s=this._events[o];if(s.fn)s.fn===r&&(!i||s.once)&&(!n||s.context===n)&&PP(this,o);else{for(var a=0,d=[],u=s.length;a<u;a++)(s[a].fn!==r||i&&!s[a].once||n&&s[a].context!==n)&&d.push(s[a]);d.length?this._events[o]=d.length===1?d[0]:d:PP(this,o)}return this};js.prototype.removeAllListeners=function(e){var r;return e?(r=ga?ga+e:e,this._events[r]&&PP(this,r)):(this._events=new Z6,this._eventsCount=0),this};js.prototype.off=js.prototype.removeListener;js.prototype.addListener=js.prototype.on;js.prefixed=ga;js.EventEmitter=js;typeof tL<"u"&&(tL.exports=js)});var g0e=H(JP=>{"use strict";h();Object.defineProperty(JP,"__esModule",{value:!0});JP.ReadableWebToNodeStream=void 0;var lYe=X8(),mL=class extends lYe.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()}};JP.ReadableWebToNodeStream=mL});h();h();h();h();var Zh=qt(tK(),1);h();h();h();h();function Kge(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var i=0;i<t.length;i++){var o=t.charAt(i),s=o.charCodeAt(0);if(r[s]!==255)throw new TypeError(o+" is ambiguous");r[s]=i}var a=t.length,d=t.charAt(0),u=Math.log(a)/Math.log(256),c=Math.log(256)/Math.log(a);function l(g){if(g instanceof Uint8Array||(ArrayBuffer.isView(g)?g=new Uint8Array(g.buffer,g.byteOffset,g.byteLength):Array.isArray(g)&&(g=Uint8Array.from(g))),!(g instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(g.length===0)return"";for(var v=0,E=0,A=0,P=g.length;A!==P&&g[A]===0;)A++,v++;for(var I=(P-A)*c+1>>>0,$=new Uint8Array(I);A!==P;){for(var N=g[A],K=0,F=I-1;(N!==0||K<E)&&F!==-1;F--,K++)N+=256*$[F]>>>0,$[F]=N%a>>>0,N=N/a>>>0;if(N!==0)throw new Error("Non-zero carry");E=K,A++}for(var U=I-E;U!==I&&$[U]===0;)U++;for(var V=d.repeat(v);U<I;++U)V+=t.charAt($[U]);return V}function m(g){if(typeof g!="string")throw new TypeError("Expected String");if(g.length===0)return new Uint8Array;var v=0;if(g[v]!==" "){for(var E=0,A=0;g[v]===d;)E++,v++;for(var P=(g.length-v)*u+1>>>0,I=new Uint8Array(P);g[v];){var $=r[g.charCodeAt(v)];if($===255)return;for(var N=0,K=P-1;($!==0||N<A)&&K!==-1;K--,N++)$+=a*I[K]>>>0,I[K]=$%256>>>0,$=$/256>>>0;if($!==0)throw new Error("Non-zero carry");A=N,v++}if(g[v]!==" "){for(var F=P-A;F!==P&&I[F]===0;)F++;for(var U=new Uint8Array(E+(P-F)),V=E;F!==P;)U[V++]=I[F++];return U}}}function p(g){var v=m(g);if(v)return v;throw new Error(`Non-${e} character`)}return{encode:l,decodeUnsafe:m,decode:p}}var Fge=Kge,zge=Fge,rK=zge;h();var yZe=new Uint8Array(0);var nK=(t,e)=>{if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let r=0;r<t.byteLength;r++)if(t[r]!==e[r])return!1;return!0},jd=t=>{if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new Error("Unknown type, must be binary type")};h();var Tk=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")}},Ik=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 oK(this,e)}},Pk=class{constructor(e){this.decoders=e}or(e){return oK(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`)}},oK=(t,e)=>new Pk({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}}),kk=class{constructor(e,r,n,i){this.name=e,this.prefix=r,this.baseEncode=n,this.baseDecode=i,this.encoder=new Tk(e,r,n),this.decoder=new Ik(e,r,i)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},sK=({name:t,prefix:e,encode:r,decode:n})=>new kk(t,e,r,n),Rk=({prefix:t,name:e,alphabet:r})=>{let{encode:n,decode:i}=rK(r,e);return sK({prefix:t,name:e,encode:n,decode:o=>jd(i(o))})},Vge=(t,e,r,n)=>{let i={};for(let c=0;c<e.length;++c)i[e[c]]=c;let o=t.length;for(;t[o-1]==="=";)--o;let s=new Uint8Array(o*r/8|0),a=0,d=0,u=0;for(let c=0;c<o;++c){let l=i[t[c]];if(l===void 0)throw new SyntaxError(`Non-${n} character`);d=d<<r|l,a+=r,a>=8&&(a-=8,s[u++]=255&d>>a)}if(a>=r||255&d<<8-a)throw new SyntaxError("Unexpected end of data");return s},Hge=(t,e,r)=>{let n=e[e.length-1]==="=",i=(1<<r)-1,o="",s=0,a=0;for(let d=0;d<t.length;++d)for(a=a<<8|t[d],s+=8;s>r;)s-=r,o+=e[i&a>>s];if(s&&(o+=e[i&a<<r-s]),n)for(;o.length*r&7;)o+="=";return o},Fs=({name:t,prefix:e,bitsPerChar:r,alphabet:n})=>sK({prefix:e,name:t,encode(i){return Hge(i,n,r)},decode(i){return Vge(i,n,r,t)}});var l2=Fs({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),AZe=Fs({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),TZe=Fs({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),IZe=Fs({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),PZe=Fs({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),kZe=Fs({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),RZe=Fs({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),BZe=Fs({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Bk=Fs({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});h();var ba=Rk({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),CZe=Rk({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});h();var UZe=Fs({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),qZe=Fs({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),zs=Fs({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),LZe=Fs({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});h();function aK(t){return t.byteOffset!==0||t.byteLength!==t.buffer.byteLength}function cK(t){return typeof t!="object"||t===null?!1:typeof t[Symbol.asyncIterator]=="function"}function Xh(t){let r=Object.prototype.toString.call(t).match(/\s([a-zA-Z0-9]+)/),[n,i]=r;return i}var f2=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},dK=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)}},K3=new TextEncoder,wy=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(!cK(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 zs.baseDecode(this.data).buffer;case"BufferSource":{if(Xh(this.data)==="ArrayBuffer")return this.data;if(ArrayBuffer.isView(this.data))return aK(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 f2(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 Bk.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 zs.baseEncode(e)}case"BufferSource":{let e=this.toUint8Array();return zs.baseEncode(e)}case"Object":{let e=JSON.stringify(this.data),r=K3.encode(e);return zs.baseEncode(r)}case"String":{let e=K3.encode(this.data);return zs.baseEncode(e)}case"Uint8Array":return zs.baseEncode(this.data);default:throw new TypeError(`Conversion from ${this.format} to Base64Url is not supported.`)}}toBlobAsync(){var e,r,n,i;return f2(this,void 0,void 0,function*(){switch(this.format){case"AsyncIterable":{let d=[];try{for(var o=!0,s=dK(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<this.data.length;n++)r+=e[this.data[n]];return r}default:throw new TypeError(`Conversion from ${this.format} to Hex is not supported.`)}}toMultibase(){switch(this.format){case"Base58Btc":return`z${this.data}`;default:throw new TypeError(`Conversion from ${this.format} to Multibase is not supported.`)}}toObject(){switch(this.format){case"Base64Url":{let e=zs.baseDecode(this.data),r=wy.decode(e);return JSON.parse(r)}case"String":return JSON.parse(this.data);case"Uint8Array":{let e=wy.decode(this.data);return JSON.parse(e)}default:throw new TypeError(`Conversion from ${this.format} to Object is not supported.`)}}toObjectAsync(){return f2(this,void 0,void 0,function*(){switch(this.format){case"AsyncIterable":{let e=yield this.toStringAsync();return JSON.parse(e)}default:throw new TypeError(`Asynchronous conversion from ${this.format} to Object is not supported.`)}})}toString(){switch(this.format){case"ArrayBuffer":return wy.decode(this.data);case"Base64Url":{let e=zs.baseDecode(this.data);return wy.decode(e)}case"Object":return JSON.stringify(this.data);case"Uint8Array":return wy.decode(this.data);default:throw new TypeError(`Conversion from ${this.format} to String is not supported.`)}}toStringAsync(){var e,r,n,i;return f2(this,void 0,void 0,function*(){switch(this.format){case"AsyncIterable":{let d="";try{for(var o=!0,s=dK(this.data),a;a=yield s.next(),e=a.done,!e;o=!0){i=a.value,o=!1;let u=i;typeof u=="string"?d+=u:d+=wy.decode(u,{stream:!0})}}catch(u){r={error:u}}finally{try{!o&&!e&&(n=s.return)&&(yield n.call(s))}finally{if(r)throw r.error}}return d+=wy.decode(void 0,{stream:!1}),d}default:throw new TypeError(`Asynchronous conversion from ${this.format} to String is not supported.`)}})}toUint8Array(){switch(this.format){case"ArrayBuffer":return new Uint8Array(this.data);case"Base32Z":return Bk.baseDecode(this.data);case"Base58Btc":return ba.baseDecode(this.data);case"Base64Url":return zs.baseDecode(this.data);case"BufferSource":{let e=Xh(this.data);if(e==="Uint8Array")return this.data;if(e==="ArrayBuffer")return new Uint8Array(this.data);if(ArrayBuffer.isView(this.data))return new Uint8Array(this.data.buffer,this.data.byteOffset,this.data.byteLength);throw new TypeError(`${this.format} value is not of type: ArrayBuffer, DataView, or TypedArray.`)}case"Hex":{let e=new Uint8Array(this.data.length/2);for(let r=0;r<this.data.length;r+=2){let n=parseInt(this.data.substring(r,r+2),16);if(isNaN(n))throw new TypeError("Input is not a valid hexadecimal string.");e[r/2]=n}return e}case"Object":{let e=JSON.stringify(this.data);return K3.encode(e)}case"String":return K3.encode(this.data);default:throw new TypeError(`Conversion from ${this.format} to Uint8Array is not supported.`)}}toUint8ArrayAsync(){return f2(this,void 0,void 0,function*(){switch(this.format){case"AsyncIterable":{let e=yield this.toArrayBufferAsync();return new Uint8Array(e)}default:throw new TypeError(`Asynchronous conversion from ${this.format} to Uint8Array is not supported.`)}})}};h();h();h();var lf={};Fr(lf,{decode:()=>_v,encodeTo:()=>_y,encodingLength:()=>xy});h();h();var Wge=fK,uK=128,Gge=127,Jge=~Gge,Yge=Math.pow(2,31);function fK(t,e,r){e=e||[],r=r||0;for(var n=r;t>=Yge;)e[r++]=t&255|uK,t/=128;for(;t&Jge;)e[r++]=t&255|uK,t>>>=7;return e[r]=t|0,fK.bytes=r-n+1,e}var Zge=Mk,Xge=128,lK=127;function Mk(t,n){var r=0,n=n||0,i=0,o=n,s,a=t.length;do{if(o>=a)throw Mk.bytes=0,new RangeError("Could not decode varint");s=t[o++],r+=i<28?(s&lK)<<i:(s&lK)*Math.pow(2,i),i+=7}while(s>=Xge);return Mk.bytes=o-n,r}var Qge=Math.pow(2,7),eve=Math.pow(2,14),tve=Math.pow(2,21),rve=Math.pow(2,28),nve=Math.pow(2,35),ive=Math.pow(2,42),ove=Math.pow(2,49),sve=Math.pow(2,56),ave=Math.pow(2,63),cve=function(t){return t<Qge?1:t<eve?2:t<tve?3:t<rve?4:t<nve?5:t<ive?6:t<ove?7:t<sve?8:t<ave?9:10},dve={encode:Wge,decode:Zge,encodingLength:cve},uve=dve,h2=uve;var _v=(t,e=0)=>[h2.decode(t,e),h2.decode.bytes],_y=(t,e,r=0)=>(h2.encode(t,e,r),e),xy=t=>h2.encodingLength(t);h();var Ey=(t,e)=>{let r=e.byteLength,n=xy(t),i=n+xy(r),o=new Uint8Array(i+r);return _y(t,o,0),_y(r,o,n),o.set(e,i),new xv(t,r,e,o)},F3=t=>{let e=jd(t),[r,n]=_v(e),[i,o]=_v(e.subarray(n)),s=e.subarray(n+o);if(s.byteLength!==i)throw new Error("Incorrect length");return new xv(r,i,s,e)},hK=(t,e)=>{if(t===e)return!0;{let r=e;return t.code===r.code&&t.size===r.size&&r.bytes instanceof Uint8Array&&nK(t.bytes,r.bytes)}},xv=class{constructor(e,r,n,i){this.code=e,this.size=r,this.digest=n,this.bytes=i}};h();var pK=(t,e)=>{let{bytes:r,version:n}=t;switch(n){case 0:return fve(r,Dk(t),e||ba.encoder);default:return hve(r,Dk(t),e||l2.encoder)}};var mK=new WeakMap,Dk=t=>{let e=mK.get(t);if(e==null){let r=new Map;return mK.set(t,r),r}return e},$r=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!==m2)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==pve)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=Ey(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&&hK(e.multihash,n.multihash)}toString(e){return pK(this,e)}toJSON(){return{"/":pK(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||yK(n,i,o.bytes))}else if(r[mve]===!0){let{version:n,multihash:i,code:o}=r,s=F3(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!==m2)throw new Error(`Version 0 CID must use dag-pb (code: ${m2}) block encoding`);return new t(e,r,n,n.bytes)}case 1:{let i=yK(e,r,n.bytes);return new t(e,r,n,i)}default:throw new Error("Invalid version")}}static createV0(e){return t.create(0,m2,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=jd(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 xv(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]=_v(e.subarray(r));return r+=m,l},i=n(),o=m2;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]=lve(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 Dk(o).set(n,e),o}},lve=(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 l2.prefix:{let r=e||l2;return[l2.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)]}}},fve=(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},hve=(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},m2=112,pve=18,yK=(t,e,r)=>{let n=xy(t),i=n+xy(e),o=new Uint8Array(i+r.byteLength);return _y(t,o,0),_y(e,o,n),o.set(r,i),o},mve=Symbol.for("@ipld/js-cid/CID");h();var Ck=({name:t,code:e,encode:r})=>new Ok(t,e,r),Ok=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?Ey(this.code,r):r.then(n=>Ey(this.code,n))}else throw Error("Unknown type, must be binary type")}};h();var ii=class t{static addPrefix(e){var r;let{code:n,data:i,name:o}=e;if(!(o?!n:n))throw new Error("Either 'name' or 'code' must be defined, but not both.");if(n=t.codeToName.has(n)?n:t.nameToCode.get(o),n===void 0)throw new Error(`Unsupported multicodec: ${(r=e.name)!==null&&r!==void 0?r:e.code}`);let s=lf.encodingLength(n),a=new Uint8Array(s+i.byteLength);return a.set(i,s),lf.encodeTo(n,a),a}static getCodeFromData(e){let{prefixedData:r}=e,[n,i]=lf.decode(r);return n}static getCodeFromName(e){let{name:r}=e,n=t.nameToCode.get(r);if(n===void 0)throw new Error(`Unsupported multicodec: ${r}`);return n}static getNameFromCode(e){let{code:r}=e,n=t.codeToName.get(r);if(n===void 0)throw new Error(`Unsupported multicodec: ${r}`);return n}static registerCodec(e){t.codeToName.set(e.code,e.name),t.nameToCode.set(e.name,e.code)}static removePrefix(e){let{prefixedData:r}=e,[n,i]=lf.decode(r),o=t.codeToName.get(n);if(o===void 0)throw new Error(`Unsupported multicodec: ${n}`);return{code:n,data:r.slice(i),name:o}}};ii.codeToName=new Map;ii.nameToCode=new Map;ii.registerCodec({code:237,name:"ed25519-pub"});ii.registerCodec({code:4864,name:"ed25519-priv"});ii.registerCodec({code:236,name:"x25519-pub"});ii.registerCodec({code:4866,name:"x25519-priv"});ii.registerCodec({code:231,name:"secp256k1-pub"});ii.registerCodec({code:4865,name:"secp256k1-priv"});h();function $k(t){Object.keys(t).forEach(e=>{t[e]===void 0?delete t[e]:typeof t[e]=="object"&&$k(t[e])})}h();var zF=qt(N2(),1),Lc=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},j2=class{constructor({db:e,location:r="DATASTORE"}={}){this.store=e??new zF.Level(r)}clear(){return Lc(this,void 0,void 0,function*(){yield this.store.clear()})}close(){return Lc(this,void 0,void 0,function*(){yield this.store.close()})}delete(e){return Lc(this,void 0,void 0,function*(){yield this.store.del(e)})}get(e){return Lc(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 Lc(this,void 0,void 0,function*(){yield this.store.put(e,r)})}},Uy=class{constructor(){this.store=new Map}clear(){return Lc(this,void 0,void 0,function*(){this.store.clear()})}close(){return Lc(this,void 0,void 0,function*(){})}delete(e){return Lc(this,void 0,void 0,function*(){return this.store.delete(e)})}get(e){return Lc(this,void 0,void 0,function*(){return this.store.get(e)})}has(e){return Lc(this,void 0,void 0,function*(){return this.store.has(e)})}list(){return Lc(this,void 0,void 0,function*(){return Array.from(this.store.values())})}set(e,r){return Lc(this,void 0,void 0,function*(){this.store.set(e,r)})}};h();var U2=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},q2=function(t){return this instanceof q2?(this.v=t,this):new q2(t)},Wbe=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,v){o.push([m,p,g,v])>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 q2?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])}},bS=class t{static asAsyncIterator(e){return Wbe(this,arguments,function*(){let n=e.getReader();try{for(;;){let{done:i,value:o}=yield q2(n.read());if(i)break;yield yield q2(o)}}finally{n.releaseLock()}})}static consumeToArrayBuffer({readableStream:e}){return U2(this,void 0,void 0,function*(){let r=t.asAsyncIterator(e);return yield de.asyncIterable(r).toArrayBufferAsync()})}static consumeToBlob({readableStream:e}){return U2(this,void 0,void 0,function*(){let r=t.asAsyncIterator(e);return yield de.asyncIterable(r).toBlobAsync()})}static consumeToBytes({readableStream:e}){return U2(this,void 0,void 0,function*(){let r=t.asAsyncIterator(e);return yield de.asyncIterable(r).toUint8ArrayAsync()})}static consumeToJson({readableStream:e}){return U2(this,void 0,void 0,function*(){let r=t.asAsyncIterator(e);return yield de.asyncIterable(r).toObjectAsync()})}static consumeToText({readableStream:e}){return U2(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<a;m++)d[m]=Math.floor(Math.random()*l)+u}else d=new Uint8Array(a);o.enqueue(d),i<=0&&o.close()}return new ReadableStream({start(a){o=a,s()},pull(){s()}})}static isReadable({readableStream:e}){if(!t.isReadableStream(e)||e.locked)return!1;try{return e.getReader().releaseLock(),!0}catch{return!1}}static isReadableStream(e){return typeof e=="object"&&e!==null&&"getReader"in e&&typeof e.getReader=="function"}static isStream(e){return t.isReadableStream(e)||t.isWritableStream(e)||t.isTransformStream(e)}static isTransformStream(e){return typeof e=="object"&&e!==null&&"readable"in e&&typeof e.readable=="object"&&"writable"in e&&typeof e.writable=="object"}static isWritableStream(e){return typeof e=="object"&&e!==null&&"getWriter"in e&&typeof e.getWriter=="function"&&"abort"in e&&typeof e.abort=="function"}};h();var EH=qt(H7(),1);var Kxe=qt(H7(),1),Z2=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},Af=class t{static consumeToArrayBuffer({readable:e}){return Z2(this,void 0,void 0,function*(){return yield de.asyncIterable(e).toArrayBufferAsync()})}static consumeToBlob({readable:e}){return Z2(this,void 0,void 0,function*(){return yield de.asyncIterable(e).toBlobAsync()})}static consumeToBytes({readable:e}){return Z2(this,void 0,void 0,function*(){return yield de.asyncIterable(e).toUint8ArrayAsync()})}static consumeToJson({readable:e}){return Z2(this,void 0,void 0,function*(){return yield de.asyncIterable(e).toObjectAsync()})}static consumeToText({readable:e}){return Z2(this,void 0,void 0,function*(){return yield de.asyncIterable(e).toStringAsync()})}static fromWebReadable({readableStream:e,readableOptions:r}){if(!bS.isReadableStream(e))throw new TypeError("NodeStream.fromWebReadable: 'readableStream' is not a Web ReadableStream.");let n=e.getReader(),i=!1,o=new EH.Readable(Object.assign(Object.assign({},r),{read:function(){n.read().then(({done:s,value:a})=>{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 Zy;(function(t){t.authentication="authentication",t.assertionMethod="assertionMethod",t.keyAgreement="keyAgreement",t.capabilityInvocation="capabilityInvocation",t.capabilityDelegation="capabilityDelegation"})(Zy||(Zy={}));h();var Hn={"@context":"https://w3id.org/did-resolution/v1",didResolutionMetadata:{},didDocument:null,didDocumentMetadata:{}};h();var rr=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}};rr.METHOD_PATTERN="([a-z0-9]+)";rr.PCT_ENCODED_PATTERN="(?:%[0-9a-fA-F]{2})";rr.ID_CHAR_PATTERN=`(?:[a-zA-Z0-9._-]|${rr.PCT_ENCODED_PATTERN})`;rr.METHOD_ID_PATTERN=`((?:${rr.ID_CHAR_PATTERN}*:)*(${rr.ID_CHAR_PATTERN}+))`;rr.PATH_PATTERN="(/[^#?]*)?";rr.QUERY_PATTERN="([?][^#]*)?";rr.FRAGMENT_PATTERN="(#.*)?";rr.DID_URI_PATTERN=new RegExp(`^did:(?<method>${rr.METHOD_PATTERN}):(?<id>${rr.METHOD_ID_PATTERN})(?<path>${rr.PATH_PATTERN})(?<query>${rr.QUERY_PATTERN})(?<fragment>${rr.FRAGMENT_PATTERN})$`);h();var st=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)}},Qe;(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"})(Qe||(Qe={}));h();h();h();h();h();h();h();h();function lp(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`Wrong positive integer: ${t}`)}function Fxe(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}function Tf(t,...e){if(!Fxe(t))throw new Error("Expected Uint8Array");if(e.length>0&&!e.includes(t.length))throw new Error(`Expected Uint8Array of length ${e}, not of length=${t.length}`)}function JS(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");lp(t.outputLen),lp(t.blockLen)}function Wv(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 SH(t,e){Tf(t);let r=e.outputLen;if(t.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}h();h();var Gv=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function W7(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}var Pf=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),zd=(t,e)=>t<<32-e|t>>>e,zxe=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!zxe)throw new Error("Non little-endian hardware is not supported");var Vxe=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function G7(t){if(!W7(t))throw new Error("Uint8Array expected");let e="";for(let r=0;r<t.length;r++)e+=Vxe[t[r]];return e}var If={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function AH(t){if(t>=If._0&&t<=If._9)return t-If._0;if(t>=If._A&&t<=If._F)return t-(If._A-10);if(t>=If._a&&t<=If._f)return t-(If._a-10)}function TH(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<r;i++,o+=2){let s=AH(t.charCodeAt(o)),a=AH(t.charCodeAt(o+1));if(s===void 0||a===void 0){let d=t[o]+t[o+1];throw new Error('hex string expected, got non-hex character "'+d+'" at index '+o)}n[i]=s*16+a}return n}var Hxe=async()=>{};async function IH(t,e,r){let n=Date.now();for(let i=0;i<t;i++){r(i);let o=Date.now()-n;o>=0&&o<e||(await Hxe(),n+=o)}}function X2(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}function fp(t){if(typeof t=="string"&&(t=X2(t)),!W7(t))throw new Error(`expected Uint8Array, got ${typeof t}`);return t}function Xy(...t){let e=0;for(let n=0;n<t.length;n++){let i=t[n];if(!W7(i))throw new Error("Uint8Array expected");e+=i.length}let r=new Uint8Array(e);for(let n=0,i=0;n<t.length;n++){let o=t[n];r.set(o,i),i+=o.length}return r}var Jv=class{clone(){return this._cloneInto()}},Wxe={}.toString;function PH(t,e){if(e!==void 0&&Wxe.call(e)!=="[object Object]")throw new Error("Options should be object or undefined");return Object.assign(t,e)}function Yv(t){let e=n=>t().update(fp(n)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function kf(t=32){if(Gv&&typeof Gv.getRandomValues=="function")return Gv.getRandomValues(new Uint8Array(t));throw new Error("crypto.getRandomValues must be defined")}function Gxe(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 hp=class extends Jv{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=Pf(this.buffer)}update(e){Wv(this);let{view:r,buffer:n,blockLen:i}=this;e=fp(e);let o=e.length;for(let s=0;s<o;){let a=Math.min(i-this.pos,o-s);if(a===i){let d=Pf(e);for(;i<=o-s;s+=i)this.process(d,s);continue}n.set(e.subarray(s,s+a),this.pos),this.pos+=a,s+=a,this.pos===i&&(this.process(r,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Wv(this),SH(e,this),this.finished=!0;let{buffer:r,view:n,blockLen:i,isLE:o}=this,{pos:s}=this;r[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>i-s&&(this.process(n,0),s=0);for(let l=s;l<i;l++)r[l]=0;Gxe(n,i-8,BigInt(this.length*8),o),this.process(n,0);let a=Pf(e),d=this.outputLen;if(d%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let u=d/4,c=this.get();if(u>c.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;l<u;l++)a.setUint32(4*l,c[l],o)}digest(){let{buffer:e,outputLen:r}=this;this.digestInto(e);let n=e.slice(0,r);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());let{blockLen:r,buffer:n,length:i,finished:o,destroyed:s,pos:a}=this;return e.length=i,e.pos=a,e.finished=o,e.destroyed=s,i%r&&e.buffer.set(n),e}};var Jxe=(t,e,r)=>t&e^~t&r,Yxe=(t,e,r)=>t&e^t&r^e&r,Zxe=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]),pp=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),mp=new Uint32Array(64),J7=class extends hp{constructor(){super(64,32,8,!1),this.A=pp[0]|0,this.B=pp[1]|0,this.C=pp[2]|0,this.D=pp[3]|0,this.E=pp[4]|0,this.F=pp[5]|0,this.G=pp[6]|0,this.H=pp[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)mp[l]=e.getUint32(r,!1);for(let l=16;l<64;l++){let m=mp[l-15],p=mp[l-2],g=zd(m,7)^zd(m,18)^m>>>3,v=zd(p,17)^zd(p,19)^p>>>10;mp[l]=v+mp[l-7]+g+mp[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=zd(a,6)^zd(a,11)^zd(a,25),p=c+m+Jxe(a,d,u)+Zxe[l]+mp[l]|0,v=(zd(n,2)^zd(n,13)^zd(n,22))+Yxe(n,i,o)|0;c=u,u=d,d=a,a=s+p|0,s=o,o=i,i=n,n=p+v|0}n=n+this.A|0,i=i+this.B|0,o=o+this.C|0,s=s+this.D|0,a=a+this.E|0,d=d+this.F|0,u=u+this.G|0,c=c+this.H|0,this.set(n,i,o,s,a,d,u,c)}roundClean(){mp.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var ps=Yv(()=>new J7);var Xxe=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},Zv=class{static digest({data:e}){return Xxe(this,void 0,void 0,function*(){return ps(e)})}};h();var Wn=class{};var Qxe=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},yp=class extends Wn{digest({algorithm:e,data:r}){return Qxe(this,void 0,void 0,function*(){switch(e){case"SHA-256":return yield Zv.digest({data:r})}})}};h();h();h();h();var ZS={};Fr(ZS,{bitGet:()=>sEe,bitLen:()=>oEe,bitMask:()=>Q2,bitSet:()=>aEe,bytesToHex:()=>Bf,bytesToNumberBE:()=>Mf,bytesToNumberLE:()=>Hd,concatBytes:()=>Of,createHmacDrbg:()=>X7,ensureBytes:()=>Bn,equalBytes:()=>nEe,hexToBytes:()=>Qy,hexToNumber:()=>Z7,isBytes:()=>Vd,numberToBytesBE:()=>xa,numberToBytesLE:()=>Df,numberToHexUnpadded:()=>MH,numberToVarBytesBE:()=>rEe,utf8ToBytes:()=>iEe,validateObject:()=>zc});h();var BH=BigInt(0),YS=BigInt(1),eEe=BigInt(2);function Vd(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}var tEe=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function Bf(t){if(!Vd(t))throw new Error("Uint8Array expected");let e="";for(let r=0;r<t.length;r++)e+=tEe[t[r]];return e}function MH(t){let e=t.toString(16);return e.length&1?`0${e}`:e}function Z7(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return BigInt(t===""?"0":`0x${t}`)}var Rf={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function kH(t){if(t>=Rf._0&&t<=Rf._9)return t-Rf._0;if(t>=Rf._A&&t<=Rf._F)return t-(Rf._A-10);if(t>=Rf._a&&t<=Rf._f)return t-(Rf._a-10)}function Qy(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<r;i++,o+=2){let s=kH(t.charCodeAt(o)),a=kH(t.charCodeAt(o+1));if(s===void 0||a===void 0){let d=t[o]+t[o+1];throw new Error('hex string expected, got non-hex character "'+d+'" at index '+o)}n[i]=s*16+a}return n}function Mf(t){return Z7(Bf(t))}function Hd(t){if(!Vd(t))throw new Error("Uint8Array expected");return Z7(Bf(Uint8Array.from(t).reverse()))}function xa(t,e){return Qy(t.toString(16).padStart(e*2,"0"))}function Df(t,e){return xa(t,e).reverse()}function rEe(t){return Qy(MH(t))}function Bn(t,e,r){let n;if(typeof e=="string")try{n=Qy(e)}catch(o){throw new Error(`${t} must be valid hex string, got "${e}". Cause: ${o}`)}else if(Vd(e))n=Uint8Array.from(e);else throw new Error(`${t} must be hex string or Uint8Array`);let i=n.length;if(typeof r=="number"&&i!==r)throw new Error(`${t} expected ${r} bytes, got ${i}`);return n}function Of(...t){let e=0;for(let i=0;i<t.length;i++){let o=t[i];if(!Vd(o))throw new Error("Uint8Array expected");e+=o.length}let r=new Uint8Array(e),n=0;for(let i=0;i<t.length;i++){let o=t[i];r.set(o,n),n+=o.length}return r}function nEe(t,e){if(t.length!==e.length)return!1;let r=0;for(let n=0;n<t.length;n++)r|=t[n]^e[n];return r===0}function iEe(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}function oEe(t){let e;for(e=0;t>BH;t>>=YS,e+=1);return e}function sEe(t,e){return t>>BigInt(e)&YS}var aEe=(t,e,r)=>t|(r?YS:BH)<<BigInt(e),Q2=t=>(eEe<<BigInt(t-1))-YS,Y7=t=>new Uint8Array(t),RH=t=>Uint8Array.from(t);function X7(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=Y7(t),i=Y7(t),o=0,s=()=>{n.fill(1),i.fill(0),o=0},a=(...l)=>r(i,n,...l),d=(l=Y7())=>{i=a(RH([0]),l),n=a(),l.length!==0&&(i=a(RH([1]),l),n=a())},u=()=>{if(o++>=1e3)throw new Error("drbg: tried 1000 values");let l=0,m=[];for(;l<e;){n=a();let p=n.slice();m.push(p),l+=n.length}return Of(...m)};return(l,m)=>{s(),d(l);let p;for(;!(p=m(u()));)d();return s(),p}}var cEe={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"||Vd(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 zc(t,e,r={}){let n=(i,o,s)=>{let a=cEe[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),Nn=BigInt(1),e0=BigInt(2),dEe=BigInt(3),Q7=BigInt(4),DH=BigInt(5),OH=BigInt(8),uEe=BigInt(9),lEe=BigInt(16);function Xr(t,e){let r=t%e;return r>=Li?r:e+r}function eR(t,e,r){if(r<=Li||e<Li)throw new Error("Expected power/modulo > 0");if(r===Nn)return Li;let n=Nn;for(;e>Li;)e&Nn&&(n=n*t%r),t=t*t%r,e>>=Nn;return n}function Mn(t,e,r){let n=t;for(;e-- >Li;)n*=n,n%=r;return n}function XS(t,e){if(t===Li||e<=Li)throw new Error(`invert: expected positive integers, got n=${t} mod=${e}`);let r=Xr(t,e),n=e,i=Li,o=Nn,s=Nn,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!==Nn)throw new Error("invert: does not exist");return Xr(i,e)}function fEe(t){let e=(t-Nn)/e0,r,n,i;for(r=t-Nn,n=0;r%e0===Li;r/=e0,n++);for(i=e0;i<t&&eR(i,e,t)!==t-Nn;i++);if(n===1){let s=(t+Nn)/Q7;return function(d,u){let c=d.pow(u,s);if(!d.eql(d.sqr(c),u))throw new Error("Cannot find square root");return c}}let o=(r+Nn)/e0;return function(a,d){if(a.pow(d,e)===a.neg(a.ONE))throw new Error("Cannot find square root");let u=n,c=a.pow(a.mul(a.ONE,i),r),l=a.pow(d,o),m=a.pow(d,r);for(;!a.eql(m,a.ONE);){if(a.eql(m,a.ZERO))return a.ZERO;let p=1;for(let v=a.sqr(m);p<u&&!a.eql(v,a.ONE);p++)v=a.sqr(v);let g=a.pow(c,Nn<<BigInt(u-p-1));c=a.sqr(g),l=a.mul(l,g),m=a.mul(m,c),u=p}return l}}function hEe(t){if(t%Q7===dEe){let e=(t+Nn)/Q7;return function(n,i){let o=n.pow(i,e);if(!n.eql(n.sqr(o),i))throw new Error("Cannot find square root");return o}}if(t%OH===DH){let e=(t-DH)/OH;return function(n,i){let o=n.mul(i,e0),s=n.pow(o,e),a=n.mul(i,s),d=n.mul(n.mul(a,e0),s),u=n.mul(a,n.sub(d,n.ONE));if(!n.eql(n.sqr(u),i))throw new Error("Cannot find square root");return u}}return t%lEe,fEe(t)}var CH=(t,e)=>(Xr(t,e)&Nn)===Nn,pEe=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function tR(t){let e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},r=pEe.reduce((n,i)=>(n[i]="function",n),e);return zc(t,r)}function mEe(t,e,r){if(r<Li)throw new Error("Expected power > 0");if(r===Li)return t.ONE;if(r===Nn)return e;let n=t.ONE,i=e;for(;r>Li;)r&Nn&&(n=t.mul(n,i)),i=t.sqr(i),r>>=Nn;return n}function yEe(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 rR(t,e){let r=e!==void 0?e:t.toString(2).length,n=Math.ceil(r/8);return{nBitLength:r,nByteLength:n}}function Xv(t,e,r=!1,n={}){if(t<=Li)throw new Error(`Expected Field ORDER > 0, got ${t}`);let{nBitLength:i,nByteLength:o}=rR(t,e);if(o>2048)throw new Error("Field lengths over 2048 bytes are not supported");let s=hEe(t),a=Object.freeze({ORDER:t,BITS:i,BYTES:o,MASK:Q2(i),ZERO:Li,ONE:Nn,create:d=>Xr(d,t),isValid:d=>{if(typeof d!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof d}`);return Li<=d&&d<t},is0:d=>d===Li,isOdd:d=>(d&Nn)===Nn,neg:d=>Xr(-d,t),eql:(d,u)=>d===u,sqr:d=>Xr(d*d,t),add:(d,u)=>Xr(d+u,t),sub:(d,u)=>Xr(d-u,t),mul:(d,u)=>Xr(d*u,t),pow:(d,u)=>mEe(a,d,u),div:(d,u)=>Xr(d*XS(u,t),t),sqrN:d=>d*d,addN:(d,u)=>d+u,subN:(d,u)=>d-u,mulN:(d,u)=>d*u,inv:d=>XS(d,t),sqrt:n.sqrt||(d=>s(a,d)),invertBatch:d=>yEe(a,d),cmov:(d,u,c)=>c?u:d,toBytes:d=>r?Df(d,o):xa(d,o),fromBytes:d=>{if(d.length!==o)throw new Error(`Fp.fromBytes: expected ${o}, got ${d.length}`);return r?Hd(d):Mf(d)}});return Object.freeze(a)}function $H(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 NH(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 nR(t){let e=NH(t);return e+Math.ceil(e/2)}function jH(t,e,r=!1){let n=t.length,i=NH(e),o=nR(e);if(n<16||n<o||n>1024)throw new Error(`expected ${o}-1024 bytes of input, got ${n}`);let s=r?Mf(t):Hd(t),a=Xr(s,e-Nn)+Nn;return r?Df(a,i):xa(a,i)}h();h();var vEe=BigInt(0),iR=BigInt(1);function QS(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>vEe;)o&iR&&(s=s.add(a)),a=a.double(),o>>=iR;return s},precomputeWindow(i,o){let{windows:s,windowSize:a}=n(o),d=[],u=i,c=u;for(let l=0;l<s;l++){c=u,d.push(c);for(let m=1;m<a;m++)c=c.add(u),d.push(c);u=c.double()}return d},wNAF(i,o,s){let{windows:a,windowSize:d}=n(i),u=t.ZERO,c=t.BASE,l=BigInt(2**i-1),m=2**i,p=BigInt(i);for(let g=0;g<a;g++){let v=g*d,E=Number(s&l);s>>=p,E>d&&(E-=m,s+=iR);let A=v,P=v+Math.abs(E)-1,I=g%2!==0,$=E<0;E===0?c=c.add(r(I,o[A])):u=u.add(r($,o[P]))}return{p:u,f:c}},wNAFCached(i,o,s,a){let d=i._WINDOW_SIZE||1,u=o.get(i);return u||(u=this.precomputeWindow(i,d),d!==1&&o.set(i,a(u))),this.wNAF(d,u,s)}}}function e_(t){return tR(t.Fp),zc(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...rR(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}function bEe(t){let e=e_(t);zc(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:wEe,hexToBytes:_Ee}=ZS,t0={Err:class extends Error{constructor(e=""){super(e)}},_parseInt(t){let{Err:e}=t0;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:wEe(n),l:t.subarray(r+2)}},toSig(t){let{Err:e}=t0,r=typeof t=="string"?_Ee(t):t;if(!Vd(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}=t0._parseInt(r.subarray(2)),{d:s,l:a}=t0._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}`}},Cf=BigInt(0),Vc=BigInt(1),Ktt=BigInt(2),UH=BigInt(3),Ftt=BigInt(4);function xEe(t){let e=bEe(t),{Fp:r}=e,n=e.toBytes||((g,v,E)=>{let A=v.toAffine();return Of(Uint8Array.from([4]),r.toBytes(A.x),r.toBytes(A.y))}),i=e.fromBytes||(g=>{let v=g.subarray(1),E=r.fromBytes(v.subarray(0,r.BYTES)),A=r.fromBytes(v.subarray(r.BYTES,2*r.BYTES));return{x:E,y:A}});function o(g){let{a:v,b:E}=e,A=r.sqr(g),P=r.mul(A,g);return r.add(r.add(P,r.mul(g,v)),E)}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"&&Cf<g&&g<e.n}function a(g){if(!s(g))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function d(g){let{allowedPrivateKeyLengths:v,nByteLength:E,wrapPrivateKey:A,n:P}=e;if(v&&typeof g!="bigint"){if(Vd(g)&&(g=Bf(g)),typeof g!="string"||!v.includes(g.length))throw new Error("Invalid key");g=g.padStart(E*2,"0")}let I;try{I=typeof g=="bigint"?g:Mf(Bn("private key",g,E))}catch{throw new Error(`private key must be ${E} bytes, hex or bigint, not ${typeof g}`)}return A&&(I=Xr(I,P)),a(I),I}let u=new Map;function c(g){if(!(g instanceof l))throw new Error("ProjectivePoint expected")}class l{constructor(v,E,A){if(this.px=v,this.py=E,this.pz=A,v==null||!r.isValid(v))throw new Error("x required");if(E==null||!r.isValid(E))throw new Error("y required");if(A==null||!r.isValid(A))throw new Error("z required")}static fromAffine(v){let{x:E,y:A}=v||{};if(!v||!r.isValid(E)||!r.isValid(A))throw new Error("invalid affine point");if(v instanceof l)throw new Error("projective point not allowed");let P=I=>r.eql(I,r.ZERO);return P(E)&&P(A)?l.ZERO:new l(E,A,r.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(v){let E=r.invertBatch(v.map(A=>A.pz));return v.map((A,P)=>A.toAffine(E[P])).map(l.fromAffine)}static fromHex(v){let E=l.fromAffine(i(Bn("pointHex",v)));return E.assertValidity(),E}static fromPrivateKey(v){return l.BASE.multiply(d(v))}_setWindowSize(v){this._WINDOW_SIZE=v,u.delete(this)}assertValidity(){if(this.is0()){if(e.allowInfinityPoint&&!r.is0(this.py))return;throw new Error("bad point: ZERO")}let{x:v,y:E}=this.toAffine();if(!r.isValid(v)||!r.isValid(E))throw new Error("bad point: x or y not FE");let A=r.sqr(E),P=o(v);if(!r.eql(A,P))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){let{y:v}=this.toAffine();if(r.isOdd)return!r.isOdd(v);throw new Error("Field doesn't support isOdd")}equals(v){c(v);let{px:E,py:A,pz:P}=this,{px:I,py:$,pz:N}=v,K=r.eql(r.mul(E,N),r.mul(I,P)),F=r.eql(r.mul(A,N),r.mul($,P));return K&&F}negate(){return new l(this.px,r.neg(this.py),this.pz)}double(){let{a:v,b:E}=e,A=r.mul(E,UH),{px:P,py:I,pz:$}=this,N=r.ZERO,K=r.ZERO,F=r.ZERO,U=r.mul(P,P),V=r.mul(I,I),L=r.mul($,$),T=r.mul(P,I);return T=r.add(T,T),F=r.mul(P,$),F=r.add(F,F),N=r.mul(v,F),K=r.mul(A,L),K=r.add(N,K),N=r.sub(V,K),K=r.add(V,K),K=r.mul(N,K),N=r.mul(T,N),F=r.mul(A,F),L=r.mul(v,L),T=r.sub(U,L),T=r.mul(v,T),T=r.add(T,F),F=r.add(U,U),U=r.add(F,U),U=r.add(U,L),U=r.mul(U,T),K=r.add(K,U),L=r.mul(I,$),L=r.add(L,L),U=r.mul(L,T),N=r.sub(N,U),F=r.mul(L,V),F=r.add(F,F),F=r.add(F,F),new l(N,K,F)}add(v){c(v);let{px:E,py:A,pz:P}=this,{px:I,py:$,pz:N}=v,K=r.ZERO,F=r.ZERO,U=r.ZERO,V=e.a,L=r.mul(e.b,UH),T=r.mul(E,I),S=r.mul(A,$),k=r.mul(P,N),f=r.add(E,A),y=r.add(I,$);f=r.mul(f,y),y=r.add(T,S),f=r.sub(f,y),y=r.add(E,P);let w=r.add(I,N);return y=r.mul(y,w),w=r.add(T,k),y=r.sub(y,w),w=r.add(A,P),K=r.add($,N),w=r.mul(w,K),K=r.add(S,k),w=r.sub(w,K),U=r.mul(V,y),K=r.mul(L,k),U=r.add(K,U),K=r.sub(S,U),U=r.add(S,U),F=r.mul(K,U),S=r.add(T,T),S=r.add(S,T),k=r.mul(V,k),y=r.mul(L,y),S=r.add(S,k),k=r.sub(T,k),k=r.mul(V,k),y=r.add(y,k),T=r.mul(S,y),F=r.add(F,T),T=r.mul(w,y),K=r.mul(f,K),K=r.sub(K,T),T=r.mul(f,S),U=r.mul(w,U),U=r.add(U,T),new l(K,F,U)}subtract(v){return this.add(v.negate())}is0(){return this.equals(l.ZERO)}wNAF(v){return p.wNAFCached(this,u,v,E=>{let A=r.invertBatch(E.map(P=>P.pz));return E.map((P,I)=>P.toAffine(A[I])).map(l.fromAffine)})}multiplyUnsafe(v){let E=l.ZERO;if(v===Cf)return E;if(a(v),v===Vc)return this;let{endo:A}=e;if(!A)return p.unsafeLadder(this,v);let{k1neg:P,k1:I,k2neg:$,k2:N}=A.splitScalar(v),K=E,F=E,U=this;for(;I>Cf||N>Cf;)I&Vc&&(K=K.add(U)),N&Vc&&(F=F.add(U)),U=U.double(),I>>=Vc,N>>=Vc;return P&&(K=K.negate()),$&&(F=F.negate()),F=new l(r.mul(F.px,A.beta),F.py,F.pz),K.add(F)}multiply(v){a(v);let E=v,A,P,{endo:I}=e;if(I){let{k1neg:$,k1:N,k2neg:K,k2:F}=I.splitScalar(E),{p:U,f:V}=this.wNAF(N),{p:L,f:T}=this.wNAF(F);U=p.constTimeNegate($,U),L=p.constTimeNegate(K,L),L=new l(r.mul(L.px,I.beta),L.py,L.pz),A=U.add(L),P=V.add(T)}else{let{p:$,f:N}=this.wNAF(E);A=$,P=N}return l.normalizeZ([A,P])[0]}multiplyAndAddUnsafe(v,E,A){let P=l.BASE,I=(N,K)=>K===Cf||K===Vc||!N.equals(P)?N.multiplyUnsafe(K):N.multiply(K),$=I(this,E).add(I(v,A));return $.is0()?void 0:$}toAffine(v){let{px:E,py:A,pz:P}=this,I=this.is0();v==null&&(v=I?r.ONE:r.inv(P));let $=r.mul(E,v),N=r.mul(A,v),K=r.mul(P,v);if(I)return{x:r.ZERO,y:r.ZERO};if(!r.eql(K,r.ONE))throw new Error("invZ was invalid");return{x:$,y:N}}isTorsionFree(){let{h:v,isTorsionFree:E}=e;if(v===Vc)return!0;if(E)return E(l,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:v,clearCofactor:E}=e;return v===Vc?this:E?E(l,this):this.multiplyUnsafe(e.h)}toRawBytes(v=!0){return this.assertValidity(),n(l,this,v)}toHex(v=!0){return Bf(this.toRawBytes(v))}}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=QS(l,e.endo?Math.ceil(m/2):m);return{CURVE:e,ProjectivePoint:l,normPrivateKeyToScalar:d,weierstrassEquation:o,isWithinCurveOrder:s}}function EEe(t){let e=e_(t);return zc(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function qH(t){let e=EEe(t),{Fp:r,n}=e,i=r.BYTES+1,o=2*r.BYTES+1;function s(y){return Cf<y&&y<r.ORDER}function a(y){return Xr(y,n)}function d(y){return XS(y,n)}let{ProjectivePoint:u,normPrivateKeyToScalar:c,weierstrassEquation:l,isWithinCurveOrder:m}=xEe({...e,toBytes(y,w,_){let x=w.toAffine(),b=r.toBytes(x.x),B=Of;return _?B(Uint8Array.from([w.hasEvenY()?2:3]),b):B(Uint8Array.from([4]),b,r.toBytes(x.y))},fromBytes(y){let w=y.length,_=y[0],x=y.subarray(1);if(w===i&&(_===2||_===3)){let b=Mf(x);if(!s(b))throw new Error("Point is not on curve");let B=l(b),q=r.sqrt(B),M=(q&Vc)===Vc;return(_&1)===1!==M&&(q=r.neg(q)),{x:b,y:q}}else if(w===o&&_===4){let b=r.fromBytes(x.subarray(0,r.BYTES)),B=r.fromBytes(x.subarray(r.BYTES,2*r.BYTES));return{x:b,y:B}}else throw new Error(`Point of length ${w} was invalid. Expected ${i} compressed bytes or ${o} uncompressed bytes`)}}),p=y=>Bf(xa(y,e.nByteLength));function g(y){let w=n>>Vc;return y>w}function v(y){return g(y)?a(-y):y}let E=(y,w,_)=>Mf(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=Bn("compactSignature",w,_*2),new A(E(w,0,_),E(w,_,2*_))}static fromDER(w){let{r:_,s:x}=t0.toSig(Bn("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:b}=this,B=F(Bn("msgHash",w));if(b==null||![0,1,2,3].includes(b))throw new Error("recovery id invalid");let q=b===2||b===3?_+e.n:_;if(q>=r.ORDER)throw new Error("recovery id 2 or 3 invalid");let M=b&1?"03":"02",j=u.fromHex(M+p(q)),J=d(q),Z=a(-B*J),G=a(x*J),W=u.BASE.multiplyAndAddUnsafe(j,Z,G);if(!W)throw new Error("point at infinify");return W.assertValidity(),W}hasHighS(){return g(this.s)}normalizeS(){return this.hasHighS()?new A(this.r,a(-this.s),this.recovery):this}toDERRawBytes(){return Qy(this.toDERHex())}toDERHex(){return t0.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Qy(this.toCompactHex())}toCompactHex(){return p(this.r)+p(this.s)}}let P={isValidPrivateKey(y){try{return c(y),!0}catch{return!1}},normPrivateKeyToScalar:c,randomPrivateKey:()=>{let y=nR(e.n);return jH(e.randomBytes(y),e.n)},precompute(y=8,w=u.BASE){return w._setWindowSize(y),w.multiply(BigInt(3)),w}};function I(y,w=!0){return u.fromPrivateKey(y).toRawBytes(w)}function $(y){let w=Vd(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 K=e.bits2int||function(y){let w=Mf(y),_=y.length*8-e.nBitLength;return _>0?w>>BigInt(_):w},F=e.bits2int_modN||function(y){return a(K(y))},U=Q2(e.nBitLength);function V(y){if(typeof y!="bigint")throw new Error("bigint expected");if(!(Cf<=y&&y<U))throw new Error(`bigint expected < 2^${e.nBitLength}`);return xa(y,e.nByteLength)}function L(y,w,_=T){if(["recovered","canonical"].some(ee=>ee in _))throw new Error("sign() legacy options not supported");let{hash:x,randomBytes:b}=e,{lowS:B,prehash:q,extraEntropy:M}=_;B==null&&(B=!0),y=Bn("msgHash",y),q&&(y=Bn("prehashed msgHash",x(y)));let j=F(y),J=c(w),Z=[V(J),V(j)];if(M!=null){let ee=M===!0?b(r.BYTES):M;Z.push(Bn("extraEntropy",ee))}let G=Of(...Z),W=j;function X(ee){let ue=K(ee);if(!m(ue))return;let ae=d(ue),ce=u.BASE.multiply(ue).toAffine(),pe=a(ce.x);if(pe===Cf)return;let xe=a(ae*a(W+pe*J));if(xe===Cf)return;let Ue=(ce.x===pe?0:2)|Number(ce.y&Vc),le=xe;return B&&g(xe)&&(le=v(xe),Ue^=1),new A(pe,le,Ue)}return{seed:G,k2sig:X}}let T={lowS:e.lowS,prehash:!1},S={lowS:e.lowS,prehash:!1};function k(y,w,_=T){let{seed:x,k2sig:b}=L(y,w,_),B=e;return X7(B.hash.outputLen,B.nByteLength,B.hmac)(x,b)}u.BASE._setWindowSize(8);function f(y,w,_,x=S){let b=y;if(w=Bn("msgHash",w),_=Bn("publicKey",_),"strict"in x)throw new Error("options.strict was renamed to lowS");let{lowS:B,prehash:q}=x,M,j;try{if(typeof b=="string"||Vd(b))try{M=A.fromDER(b)}catch(ce){if(!(ce instanceof t0.Err))throw ce;M=A.fromCompact(b)}else if(typeof b=="object"&&typeof b.r=="bigint"&&typeof b.s=="bigint"){let{r:ce,s:pe}=b;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(B&&M.hasHighS())return!1;q&&(w=e.hash(w));let{r:J,s:Z}=M,G=F(w),W=d(Z),X=a(G*W),ee=a(J*W),ue=u.BASE.multiplyAndAddUnsafe(j,X,ee)?.toAffine();return ue?a(ue.x)===J:!1}return{CURVE:e,getPublicKey:I,getSharedSecret:N,sign:k,verify:f,ProjectivePoint:u,Signature:A,utils:P}}h();h();var e5=class extends Jv{constructor(e,r){super(),this.finished=!1,this.destroyed=!1,JS(e);let n=fp(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;s<o.length;s++)o[s]^=54;this.iHash.update(o),this.oHash=e.create();for(let s=0;s<o.length;s++)o[s]^=106;this.oHash.update(o),o.fill(0)}update(e){return Wv(this),this.iHash.update(e),this}digestInto(e){Wv(this),Tf(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){let e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));let{oHash:r,iHash:n,finished:i,destroyed:o,blockLen:s,outputLen:a}=this;return e=e,e.finished=i,e.destroyed=o,e.blockLen=s,e.outputLen=a,e.oHash=r._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},gp=(t,e,r)=>new e5(t,e).update(r).digest();gp.create=(t,e)=>new e5(t,e);function SEe(t){return{hash:t,hmac:(e,...r)=>gp(t,e,Xy(...r)),randomBytes:kf}}function t5(t,e){let r=n=>qH({...t,...SEe(n)});return Object.freeze({...r(e),create:r})}var FH=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),LH=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),AEe=BigInt(1),oR=BigInt(2),KH=(t,e)=>(t+e/oR)/e;function TEe(t){let e=FH,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=Mn(c,r,e)*c%e,m=Mn(l,r,e)*c%e,p=Mn(m,oR,e)*u%e,g=Mn(p,i,e)*p%e,v=Mn(g,o,e)*g%e,E=Mn(v,a,e)*v%e,A=Mn(E,d,e)*E%e,P=Mn(A,a,e)*v%e,I=Mn(P,r,e)*c%e,$=Mn(I,s,e)*g%e,N=Mn($,n,e)*u%e,K=Mn(N,oR,e);if(!sR.eql(sR.sqr(K),t))throw new Error("Cannot find square root");return K}var sR=Xv(FH,void 0,void 0,{sqrt:TEe}),Ea=t5({a:BigInt(0),b:BigInt(7),Fp:sR,n:LH,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:t=>{let e=LH,r=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-AEe*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),o=r,s=BigInt("0x100000000000000000000000000000000"),a=KH(o*t,e),d=KH(-n*t,e),u=Xr(t-a*r-d*i,e),c=Xr(-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}}}},ps),irt=BigInt(0);var ort=Ea.ProjectivePoint;h();h();function zH(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 IEe=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(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="urn:jwk:";function nt({jwk:t}){return IEe(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}`);$k(r);let n=zH(r),i=de.string(n).toUint8Array(),o=yield Zv.digest({data:i});return de.uint8Array(o).toBase64Url()})}function Sa(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 vp(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 n0(t){return!(!t||typeof t!="object"||!("kty"in t&&"k"in t)||t.kty!=="oct"||typeof t.k!="string")}function Aa(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 bp(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 Qv(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 Co=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},PEe=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.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]]);return r},_r=class t{static adjustSignatureToLowS({signature:e}){return Co(this,void 0,void 0,function*(){let r=Ea.Signature.fromCompact(e);return r.hasHighS()?r.normalizeS().toCompactRawBytes():e})}static bytesToPrivateKey({privateKeyBytes:e}){return Co(this,void 0,void 0,function*(){let r=yield t.getCurvePoint({keyBytes:e}),n={kty:"EC",crv:"secp256k1",d:de.uint8Array(e).toBase64Url(),x:de.uint8Array(r.x).toBase64Url(),y:de.uint8Array(r.y).toBase64Url()};return n.kid=yield nt({jwk:n}),n})}static bytesToPublicKey({publicKeyBytes:e}){return Co(this,void 0,void 0,function*(){let r=yield t.getCurvePoint({keyBytes:e}),n={kty:"EC",crv:"secp256k1",x:de.uint8Array(r.x).toBase64Url(),y:de.uint8Array(r.y).toBase64Url()};return n.kid=yield nt({jwk:n}),n})}static compressPublicKey({publicKeyBytes:e}){return Co(this,void 0,void 0,function*(){return Ea.ProjectivePoint.fromHex(e).toRawBytes(!0)})}static computePublicKey({key:e}){return Co(this,void 0,void 0,function*(){let r=yield t.privateKeyToBytes({privateKey:e}),n=yield t.getCurvePoint({keyBytes:r}),i={kty:"EC",crv:"secp256k1",x:de.uint8Array(n.x).toBase64Url(),y:de.uint8Array(n.y).toBase64Url()};return i.kid=yield nt({jwk:i}),i})}static convertDerToCompactSignature({derSignature:e}){return Co(this,void 0,void 0,function*(){return Ea.Signature.fromDER(e).toCompactRawBytes()})}static decompressPublicKey({publicKeyBytes:e}){return Co(this,void 0,void 0,function*(){return Ea.ProjectivePoint.fromHex(e).toRawBytes(!1)})}static generateKey(){return Co(this,void 0,void 0,function*(){let e=Ea.utils.randomPrivateKey(),r=yield t.bytesToPrivateKey({privateKeyBytes:e});return r.kid=yield nt({jwk:r}),r})}static getPublicKey({key:e}){var r;return Co(this,void 0,void 0,function*(){if(!(Sa(e)&&e.crv==="secp256k1"))throw new Error("Secp256k1: The provided key is not a secp256k1 private JWK.");let{d:n}=e,i=PEe(e,["d"]);return(r=i.kid)!==null&&r!==void 0||(i.kid=yield nt({jwk:i})),i})}static privateKeyToBytes({privateKey:e}){return Co(this,void 0,void 0,function*(){if(!Sa(e))throw new Error("Secp256k1: The provided key is not a valid EC private key.");return de.base64Url(e.d).toUint8Array()})}static publicKeyToBytes({publicKey:e}){return Co(this,void 0,void 0,function*(){if(!(vp(e)&&e.y))throw new Error("Secp256k1: The provided key is not a valid EC public key.");let r=new Uint8Array([4]),n=de.base64Url(e.x).toUint8Array(),i=de.base64Url(e.y).toUint8Array();return new Uint8Array([...r,...n,...i])})}static sharedSecret({privateKeyA:e,publicKeyB:r}){return Co(this,void 0,void 0,function*(){if("x"in e&&"x"in r&&e.x===r.x)throw new Error("Secp256k1: ECDH shared secret cannot be computed from a single key pair's public and private keys.");let n=yield t.privateKeyToBytes({privateKey:e}),i=yield t.publicKeyToBytes({publicKey:r});return Ea.getSharedSecret(n,i,!0).slice(1)})}static sign({data:e,key:r}){return Co(this,void 0,void 0,function*(){let n=yield t.privateKeyToBytes({privateKey:r}),i=ps(e);return Ea.sign(i,n).toCompactRawBytes()})}static validatePrivateKey({privateKeyBytes:e}){return Co(this,void 0,void 0,function*(){return Ea.utils.isValidPrivateKey(e)})}static validatePublicKey({publicKeyBytes:e}){return Co(this,void 0,void 0,function*(){try{Ea.ProjectivePoint.fromHex(e).assertValidity()}catch{return!1}return!0})}static verify({key:e,signature:r,data:n}){return Co(this,void 0,void 0,function*(){let i=yield t.publicKeyToBytes({publicKey:e}),o=ps(n);return Ea.verify(r,o,i,{lowS:!1})})}static getCurvePoint({keyBytes:e}){return Co(this,void 0,void 0,function*(){e.byteLength===32&&(e=Ea.getPublicKey(e));let r=Ea.ProjectivePoint.fromHex(e),n=xa(r.x,32),i=xa(r.y,32);return{x:n,y:i}})}};h();h();var VH=Xv(BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff")),kEe=VH.create(BigInt("-3")),REe=BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),$f=t5({a:kEe,b:REe,Fp:VH,n:BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),Gx:BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),Gy:BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5"),h:BigInt(1),lowS:!1},ps),Ws=$f;var $o=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},BEe=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.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]]);return r},Dr=class t{static adjustSignatureToLowS({signature:e}){return $o(this,void 0,void 0,function*(){let r=Ws.Signature.fromCompact(e);return r.hasHighS()?r.normalizeS().toCompactRawBytes():e})}static bytesToPrivateKey({privateKeyBytes:e}){return $o(this,void 0,void 0,function*(){let r=yield t.getCurvePoint({keyBytes:e}),n={kty:"EC",crv:"P-256",d:de.uint8Array(e).toBase64Url(),x:de.uint8Array(r.x).toBase64Url(),y:de.uint8Array(r.y).toBase64Url()};return n.kid=yield nt({jwk:n}),n})}static bytesToPublicKey({publicKeyBytes:e}){return $o(this,void 0,void 0,function*(){let r=yield t.getCurvePoint({keyBytes:e}),n={kty:"EC",crv:"P-256",x:de.uint8Array(r.x).toBase64Url(),y:de.uint8Array(r.y).toBase64Url()};return n.kid=yield nt({jwk:n}),n})}static compressPublicKey({publicKeyBytes:e}){return $o(this,void 0,void 0,function*(){return Ws.ProjectivePoint.fromHex(e).toRawBytes(!0)})}static computePublicKey({key:e}){return $o(this,void 0,void 0,function*(){let r=yield t.privateKeyToBytes({privateKey:e}),n=yield t.getCurvePoint({keyBytes:r}),i={kty:"EC",crv:"P-256",x:de.uint8Array(n.x).toBase64Url(),y:de.uint8Array(n.y).toBase64Url()};return i.kid=yield nt({jwk:i}),i})}static convertDerToCompactSignature({derSignature:e}){return $o(this,void 0,void 0,function*(){return Ws.Signature.fromDER(e).toCompactRawBytes()})}static decompressPublicKey({publicKeyBytes:e}){return $o(this,void 0,void 0,function*(){return Ws.ProjectivePoint.fromHex(e).toRawBytes(!1)})}static generateKey(){return $o(this,void 0,void 0,function*(){let e=Ws.utils.randomPrivateKey(),r=yield t.bytesToPrivateKey({privateKeyBytes:e});return r.kid=yield nt({jwk:r}),r})}static getPublicKey({key:e}){var r;return $o(this,void 0,void 0,function*(){if(!(Sa(e)&&e.crv==="P-256"))throw new Error("Secp256r1: The provided key is not a 'P-256' private JWK.");let{d:n}=e,i=BEe(e,["d"]);return(r=i.kid)!==null&&r!==void 0||(i.kid=yield nt({jwk:i})),i})}static privateKeyToBytes({privateKey:e}){return $o(this,void 0,void 0,function*(){if(!Sa(e))throw new Error("Secp256r1: The provided key is not a valid EC private key.");return de.base64Url(e.d).toUint8Array()})}static publicKeyToBytes({publicKey:e}){return $o(this,void 0,void 0,function*(){if(!(vp(e)&&e.y))throw new Error("Secp256r1: The provided key is not a valid EC public key.");let r=new Uint8Array([4]),n=de.base64Url(e.x).toUint8Array(),i=de.base64Url(e.y).toUint8Array();return new Uint8Array([...r,...n,...i])})}static sharedSecret({privateKeyA:e,publicKeyB:r}){return $o(this,void 0,void 0,function*(){if("x"in e&&"x"in r&&e.x===r.x)throw new Error("Secp256r1: ECDH shared secret cannot be computed from a single key pair's public and private keys.");let n=yield t.privateKeyToBytes({privateKey:e}),i=yield t.publicKeyToBytes({publicKey:r});return Ws.getSharedSecret(n,i,!0).slice(1)})}static sign({data:e,key:r}){return $o(this,void 0,void 0,function*(){let n=yield t.privateKeyToBytes({privateKey:r}),i=ps(e);return Ws.sign(i,n).toCompactRawBytes()})}static validatePrivateKey({privateKeyBytes:e}){return $o(this,void 0,void 0,function*(){return Ws.utils.isValidPrivateKey(e)})}static validatePublicKey({publicKeyBytes:e}){return $o(this,void 0,void 0,function*(){try{Ws.ProjectivePoint.fromHex(e).assertValidity()}catch{return!1}return!0})}static verify({key:e,signature:r,data:n}){return $o(this,void 0,void 0,function*(){let i=yield t.publicKeyToBytes({publicKey:e}),o=ps(n);return Ws.verify(r,o,i,{lowS:!1})})}static getCurvePoint({keyBytes:e}){return $o(this,void 0,void 0,function*(){e.byteLength===32&&(e=Ws.getPublicKey(e));let r=Ws.ProjectivePoint.fromHex(e),n=xa(r.x,32),i=xa(r.y,32);return{x:n,y:i}})}};var t_=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},wp=class extends Wn{computePublicKey({key:e}){return t_(this,void 0,void 0,function*(){if(!Sa(e))throw new TypeError("Invalid key provided. Must be an elliptic curve (EC) private key.");switch(e.crv){case"secp256k1":{let r=yield _r.computePublicKey({key:e});return r.alg="ES256K",r}case"P-256":{let r=yield Dr.computePublicKey({key:e});return r.alg="ES256",r}default:throw new Error(`Unsupported curve: ${e.crv}`)}})}generateKey({algorithm:e}){return t_(this,void 0,void 0,function*(){switch(e){case"ES256K":case"secp256k1":{let r=yield _r.generateKey();return r.alg="ES256K",r}case"ES256":case"secp256r1":{let r=yield Dr.generateKey();return r.alg="ES256",r}}})}getPublicKey({key:e}){return t_(this,void 0,void 0,function*(){if(!Sa(e))throw new TypeError("Invalid key provided. Must be an elliptic curve (EC) private key.");switch(e.crv){case"secp256k1":{let r=yield _r.getPublicKey({key:e});return r.alg="ES256K",r}case"P-256":{let r=yield Dr.getPublicKey({key:e});return r.alg="ES256",r}default:throw new Error(`Unsupported curve: ${e.crv}`)}})}sign({key:e,data:r}){return t_(this,void 0,void 0,function*(){if(!Sa(e))throw new TypeError("Invalid key provided. Must be an elliptic curve (EC) private key.");switch(e.crv){case"secp256k1":return yield _r.sign({key:e,data:r});case"P-256":return yield Dr.sign({key:e,data:r});default:throw new Error(`Unsupported curve: ${e.crv}`)}})}verify({key:e,signature:r,data:n}){return t_(this,void 0,void 0,function*(){if(!vp(e))throw new TypeError("Invalid key provided. Must be an elliptic curve (EC) public key.");switch(e.crv){case"secp256k1":return yield _r.verify({key:e,signature:r,data:n});case"P-256":return yield Dr.verify({key:e,signature:r,data:n});default:throw new Error(`Unsupported curve: ${e.crv}`)}})}};h();h();h();h();h();var r5=BigInt(4294967295),aR=BigInt(32);function HH(t,e=!1){return e?{h:Number(t&r5),l:Number(t>>aR&r5)}:{h:Number(t>>aR&r5)|0,l:Number(t&r5)|0}}function MEe(t,e=!1){let r=new Uint32Array(t.length),n=new Uint32Array(t.length);for(let i=0;i<t.length;i++){let{h:o,l:s}=HH(t[i],e);[r[i],n[i]]=[o,s]}return[r,n]}var DEe=(t,e)=>BigInt(t>>>0)<<aR|BigInt(e>>>0),OEe=(t,e,r)=>t>>>r,CEe=(t,e,r)=>t<<32-r|e>>>r,$Ee=(t,e,r)=>t>>>r|e<<32-r,NEe=(t,e,r)=>t<<32-r|e>>>r,jEe=(t,e,r)=>t<<64-r|e>>>r-32,UEe=(t,e,r)=>t>>>r-32|e<<64-r,qEe=(t,e)=>e,LEe=(t,e)=>t,KEe=(t,e,r)=>t<<r|e>>>32-r,FEe=(t,e,r)=>e<<r|t>>>32-r,zEe=(t,e,r)=>e<<r-32|t>>>64-r,VEe=(t,e,r)=>t<<r-32|e>>>64-r;function HEe(t,e,r,n){let i=(e>>>0)+(n>>>0);return{h:t+r+(i/2**32|0)|0,l:i|0}}var WEe=(t,e,r)=>(t>>>0)+(e>>>0)+(r>>>0),GEe=(t,e,r,n)=>e+r+n+(t/2**32|0)|0,JEe=(t,e,r,n)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0),YEe=(t,e,r,n,i)=>e+r+n+i+(t/2**32|0)|0,ZEe=(t,e,r,n,i)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0)+(i>>>0),XEe=(t,e,r,n,i,o)=>e+r+n+i+o+(t/2**32|0)|0;var QEe={fromBig:HH,split:MEe,toBig:DEe,shrSH:OEe,shrSL:CEe,rotrSH:$Ee,rotrSL:NEe,rotrBH:jEe,rotrBL:UEe,rotr32H:qEe,rotr32L:LEe,rotlSH:KEe,rotlSL:FEe,rotlBH:zEe,rotlBL:VEe,add:HEe,add3L:WEe,add3H:GEe,add4L:JEe,add4H:YEe,add5H:XEe,add5L:ZEe},nr=QEe;var[e6e,t6e]=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))),_p=new Uint32Array(80),xp=new Uint32Array(80),cR=class extends hp{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:v,Hl:E}=this;return[e,r,n,i,o,s,a,d,u,c,l,m,p,g,v,E]}set(e,r,n,i,o,s,a,d,u,c,l,m,p,g,v,E){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=v|0,this.Hl=E|0}process(e,r){for(let I=0;I<16;I++,r+=4)_p[I]=e.getUint32(r),xp[I]=e.getUint32(r+=4);for(let I=16;I<80;I++){let $=_p[I-15]|0,N=xp[I-15]|0,K=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=_p[I-2]|0,V=xp[I-2]|0,L=nr.rotrSH(U,V,19)^nr.rotrBH(U,V,61)^nr.shrSH(U,V,6),T=nr.rotrSL(U,V,19)^nr.rotrBL(U,V,61)^nr.shrSL(U,V,6),S=nr.add4L(F,T,xp[I-7],xp[I-16]),k=nr.add4H(S,K,L,_p[I-7],_p[I-16]);_p[I]=k|0,xp[I]=S|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:v,Gl:E,Hh:A,Hl:P}=this;for(let I=0;I<80;I++){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),K=l&p^~l&v,F=m&g^~m&E,U=nr.add5L(P,N,F,t6e[I],xp[I]),V=nr.add5H(U,A,$,K,e6e[I],_p[I]),L=U|0,T=nr.rotrSH(n,i,28)^nr.rotrBH(n,i,34)^nr.rotrBH(n,i,39),S=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=v|0,P=E|0,v=p|0,E=g|0,p=l|0,g=m|0,{h:l,l:m}=nr.add(u|0,c|0,V|0,L|0),u=a|0,c=d|0,a=o|0,d=s|0,o=n|0,s=i|0;let y=nr.add3L(L,S,f);n=nr.add3H(y,V,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:v,l:E}=nr.add(this.Gh|0,this.Gl|0,v|0,E|0),{h:A,l:P}=nr.add(this.Hh|0,this.Hl|0,A|0,P|0),this.set(n,i,o,s,a,d,u,c,l,m,p,g,v,E,A,P)}roundClean(){_p.fill(0),xp.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 Ep=Yv(()=>new cR);h();var Wd=BigInt(0),Qa=BigInt(1),n5=BigInt(2),r6e=BigInt(8),n6e={zip215:!0};function i6e(t){let e=e_(t);return zc(t,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}function i5(t){let e=i6e(t),{Fp:r,n,prehash:i,hash:o,randomBytes:s,nByteLength:a,h:d}=e,u=n5<<BigInt(a*8)-Qa,c=r.create,l=e.uvRatio||((x,b)=>{try{return{isValid:!0,value:r.sqrt(x*r.inv(b))}}catch{return{isValid:!1,value:Wd}}}),m=e.adjustScalarBytes||(x=>x),p=e.domain||((x,b,B)=>{if(b.length||B)throw new Error("Contexts/pre-hash are not supported");return x}),g=x=>typeof x=="bigint"&&Wd<x,v=(x,b)=>g(x)&&g(b)&&x<b,E=x=>x===Wd||v(x,u);function A(x,b){if(v(x,b))return x;throw new Error(`Expected valid scalar < ${b}, got ${typeof x} ${x}`)}function P(x){return x===Wd?x:A(x,n)}let I=new Map;function $(x){if(!(x instanceof N))throw new Error("ExtendedPoint expected")}class N{constructor(b,B,q,M){if(this.ex=b,this.ey=B,this.ez=q,this.et=M,!E(b))throw new Error("x required");if(!E(B))throw new Error("y required");if(!E(q))throw new Error("z required");if(!E(M))throw new Error("t required")}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(b){if(b instanceof N)throw new Error("extended point not allowed");let{x:B,y:q}=b||{};if(!E(B)||!E(q))throw new Error("invalid affine point");return new N(B,q,Qa,c(B*q))}static normalizeZ(b){let B=r.invertBatch(b.map(q=>q.ez));return b.map((q,M)=>q.toAffine(B[M])).map(N.fromAffine)}_setWindowSize(b){this._WINDOW_SIZE=b,I.delete(this)}assertValidity(){let{a:b,d:B}=e;if(this.is0())throw new Error("bad point: ZERO");let{ex:q,ey:M,ez:j,et:J}=this,Z=c(q*q),G=c(M*M),W=c(j*j),X=c(W*W),ee=c(Z*b),ue=c(W*c(ee+G)),ae=c(X+c(B*c(Z*G)));if(ue!==ae)throw new Error("bad point: equation left != right (1)");let ce=c(q*M),pe=c(j*J);if(ce!==pe)throw new Error("bad point: equation left != right (2)")}equals(b){$(b);let{ex:B,ey:q,ez:M}=this,{ex:j,ey:J,ez:Z}=b,G=c(B*Z),W=c(j*M),X=c(q*Z),ee=c(J*M);return G===W&&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:b}=e,{ex:B,ey:q,ez:M}=this,j=c(B*B),J=c(q*q),Z=c(n5*c(M*M)),G=c(b*j),W=B+q,X=c(c(W*W)-j-J),ee=G+J,ue=ee-Z,ae=G-J,ce=c(X*ue),pe=c(ee*ae),xe=c(X*ae),Ue=c(ue*ee);return new N(ce,pe,Ue,xe)}add(b){$(b);let{a:B,d:q}=e,{ex:M,ey:j,ez:J,et:Z}=this,{ex:G,ey:W,ez:X,et:ee}=b;if(B===BigInt(-1)){let vt=c((j-M)*(W+G)),Ae=c((j+M)*(W-G)),Re=c(Ae-vt);if(Re===Wd)return this.double();let kt=c(J*n5*ee),we=c(Z*n5*X),Ee=we+kt,Kr=Ae+vt,Fe=we-kt,We=c(Ee*Re),qs=c(Kr*Fe),ht=c(Ee*Fe),Bt=c(Re*Kr);return new N(We,qs,Bt,ht)}let ue=c(M*G),ae=c(j*W),ce=c(Z*q*ee),pe=c(J*X),xe=c((M+j)*(G+W)-ue-ae),Ue=pe-ce,le=pe+ce,ge=c(ae-B*ue),be=c(xe*Ue),De=c(le*ge),Ie=c(xe*ge),je=c(Ue*le);return new N(be,De,je,Ie)}subtract(b){return this.add(b.negate())}wNAF(b){return U.wNAFCached(this,I,b,N.normalizeZ)}multiply(b){let{p:B,f:q}=this.wNAF(A(b,n));return N.normalizeZ([B,q])[0]}multiplyUnsafe(b){let B=P(b);return B===Wd?F:this.equals(F)||B===Qa?this:this.equals(K)?this.wNAF(B).p:U.unsafeLadder(this,B)}isSmallOrder(){return this.multiplyUnsafe(d).is0()}isTorsionFree(){return U.unsafeLadder(this,n).is0()}toAffine(b){let{ex:B,ey:q,ez:M}=this,j=this.is0();b==null&&(b=j?r6e:r.inv(M));let J=c(B*b),Z=c(q*b),G=c(M*b);if(j)return{x:Wd,y:Qa};if(G!==Qa)throw new Error("invZ was invalid");return{x:J,y:Z}}clearCofactor(){let{h:b}=e;return b===Qa?this:this.multiplyUnsafe(b)}static fromHex(b,B=!1){let{d:q,a:M}=e,j=r.BYTES;b=Bn("pointHex",b,j);let J=b.slice(),Z=b[j-1];J[j-1]=Z&-129;let G=Hd(J);G===Wd||(B?A(G,u):A(G,r.ORDER));let W=c(G*G),X=c(W-Qa),ee=c(q*W-M),{isValid:ue,value:ae}=l(X,ee);if(!ue)throw new Error("Point.fromHex: invalid y coordinate");let ce=(ae&Qa)===Qa,pe=(Z&128)!==0;if(!B&&ae===Wd&&pe)throw new Error("Point.fromHex: x=0 and x_0=1");return pe!==ce&&(ae=c(-ae)),N.fromAffine({x:ae,y:G})}static fromPrivateKey(b){return T(b).point}toRawBytes(){let{x:b,y:B}=this.toAffine(),q=Df(B,r.BYTES);return q[q.length-1]|=b&Qa?128:0,q}toHex(){return Bf(this.toRawBytes())}}N.BASE=new N(e.Gx,e.Gy,Qa,c(e.Gx*e.Gy)),N.ZERO=new N(Wd,Qa,Qa,Wd);let{BASE:K,ZERO:F}=N,U=QS(N,a*8);function V(x){return Xr(x,n)}function L(x){return V(Hd(x))}function T(x){let b=a;x=Bn("private key",x,b);let B=Bn("hashed private key",o(x),2*b),q=m(B.slice(0,b)),M=B.slice(b,2*b),j=L(q),J=K.multiply(j),Z=J.toRawBytes();return{head:q,prefix:M,scalar:j,point:J,pointBytes:Z}}function S(x){return T(x).pointBytes}function k(x=new Uint8Array,...b){let B=Of(...b);return L(o(p(B,Bn("context",x),!!i)))}function f(x,b,B={}){x=Bn("message",x),i&&(x=i(x));let{prefix:q,scalar:M,pointBytes:j}=T(b),J=k(B.context,q,x),Z=K.multiply(J).toRawBytes(),G=k(B.context,Z,j,x),W=V(J+G*M);P(W);let X=Of(Z,Df(W,r.BYTES));return Bn("result",X,a*2)}let y=n6e;function w(x,b,B,q=y){let{context:M,zip215:j}=q,J=r.BYTES;x=Bn("signature",x,2*J),b=Bn("message",b),i&&(b=i(b));let Z=Hd(x.slice(J,2*J)),G,W,X;try{G=N.fromHex(B,j),W=N.fromHex(x.slice(0,J),j),X=K.multiplyUnsafe(Z)}catch{return!1}if(!j&&G.isSmallOrder())return!1;let ee=k(M,W.toRawBytes(),G.toRawBytes(),b);return W.add(G.multiplyUnsafe(ee)).subtract(X).clearCofactor().equals(N.ZERO)}return K._setWindowSize(8),{CURVE:e,getPublicKey:S,sign:f,verify:w,ExtendedPoint:N,utils:{getExtendedPublicKey:T,randomPrivateKey:()=>s(r.BYTES),precompute(x=8,b=N.BASE){return b._setWindowSize(x),b.multiply(BigInt(3)),b}}}}h();var r_=BigInt(0),dR=BigInt(1);function o6e(t){return zc(t,{a:"bigint"},{montgomeryBits:"isSafeInteger",nByteLength:"isSafeInteger",adjustScalarBytes:"function",domain:"function",powPminus2:"function",Gu:"bigint"}),Object.freeze({...t})}function WH(t){let e=o6e(t),{P:r}=e,n=I=>Xr(I,r),i=e.montgomeryBits,o=Math.ceil(i/8),s=e.nByteLength,a=e.adjustScalarBytes||(I=>I),d=e.powPminus2||(I=>eR(I,r-BigInt(2),r));function u(I,$,N){let K=n(I*($-N));return $=n($-K),N=n(N+K),[$,N]}function c(I){if(typeof I=="bigint"&&r_<=I&&I<r)return I;throw new Error("Expected valid scalar 0 < scalar < CURVE.P")}let l=(e.a-BigInt(2))/BigInt(4);function m(I,$){let N=c(I),K=c($),F=N,U=dR,V=r_,L=N,T=dR,S=r_,k;for(let y=BigInt(i-1);y>=r_;y--){let w=K>>y&dR;S^=w,k=u(S,U,L),U=k[0],L=k[1],k=u(S,V,T),V=k[0],T=k[1],S=w;let _=U+V,x=n(_*_),b=U-V,B=n(b*b),q=x-B,M=L+T,j=L-T,J=n(j*_),Z=n(M*b),G=J+Z,W=J-Z;L=n(G*G),T=n(F*n(W*W)),U=n(x*B),V=n(q*(x+n(l*q)))}k=u(S,U,L),U=k[0],L=k[1],k=u(S,V,T),V=k[0],T=k[1];let f=d(V);return n(U*f)}function p(I){return Df(n(I),o)}function g(I){let $=Bn("u coordinate",I,o);return s===32&&($[31]&=127),Hd($)}function v(I){let $=Bn("scalar",I),N=$.length;if(N!==o&&N!==s)throw new Error(`Expected ${o} or ${s} bytes, got ${N}`);return Hd(a($))}function E(I,$){let N=g($),K=v(I),F=m(N,K);if(F===r_)throw new Error("Invalid private or public key received");return p(F)}let A=p(e.Gu);function P(I){return E(I,A)}return{scalarMult:E,scalarMultBase:P,getSharedSecret:(I,$)=>E(I,$),getPublicKey:I=>P(I),utils:{randomPrivateKey:()=>e.randomBytes(e.nByteLength)},GuBytes:A}}var n_=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),GH=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),ant=BigInt(0),s6e=BigInt(1),uR=BigInt(2),a6e=BigInt(5),JH=BigInt(10),c6e=BigInt(20),d6e=BigInt(40),YH=BigInt(80);function ZH(t){let e=n_,n=t*t%e*t%e,i=Mn(n,uR,e)*n%e,o=Mn(i,s6e,e)*t%e,s=Mn(o,a6e,e)*o%e,a=Mn(s,JH,e)*s%e,d=Mn(a,c6e,e)*a%e,u=Mn(d,d6e,e)*d%e,c=Mn(u,YH,e)*u%e,l=Mn(c,YH,e)*u%e,m=Mn(l,JH,e)*s%e;return{pow_p_5_8:Mn(m,uR,e)*t%e,b2:n}}function XH(t){return t[0]&=248,t[31]&=127,t[31]|=64,t}function u6e(t,e){let r=n_,n=Xr(e*e*e,r),i=Xr(n*n*e,r),o=ZH(t*i).pow_p_5_8,s=Xr(t*n*o,r),a=Xr(e*s*s,r),d=s,u=Xr(s*GH,r),c=a===t,l=a===Xr(-t,r),m=a===Xr(-t*GH,r);return c&&(s=d),(l||m)&&(s=u),CH(s,r)&&(s=Xr(-s,r)),{isValid:c||l,value:s}}var Hc=Xv(n_,void 0,!0),i_={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:Hc,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:BigInt(8),Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:Ep,randomBytes:kf,adjustScalarBytes:XH,uvRatio:u6e},Wc=i5(i_);function QH(t,e,r){if(e.length>255)throw new Error("Context is too big");return Xy(X2("SigEd25519 no Ed25519 collisions"),new Uint8Array([r?1:0,e.length]),e,t)}var cnt=i5({...i_,domain:QH}),dnt=i5({...i_,domain:QH,prehash:Ep}),i0=WH({P:n_,a:BigInt(486662),montgomeryBits:255,nByteLength:32,Gu:BigInt(9),powPminus2:t=>{let e=n_,{pow_p_5_8:r,b2:n}=ZH(t);return Xr(Mn(r,BigInt(3),e)*n,e)},adjustScalarBytes:XH,randomBytes:kf});function eW(t){let{y:e}=Wc.ExtendedPoint.fromHex(t),r=BigInt(1);return Hc.toBytes(Hc.create((r+e)*Hc.inv(r-e)))}function tW(t){let e=i_.hash(t.subarray(0,32));return i_.adjustScalarBytes(e).subarray(0,32)}var l6e=(Hc.ORDER+BigInt(3))/BigInt(8),unt=Hc.pow(uR,l6e),lnt=Hc.sqrt(Hc.neg(Hc.ONE)),fnt=(Hc.ORDER-BigInt(5))/BigInt(8),hnt=BigInt(486662);var pnt=$H(Hc,Hc.neg(BigInt(486664)));var mnt=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),ynt=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),gnt=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),vnt=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952");var bnt=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");var Gc=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},f6e=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.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]]);return r},Yt=class t{static bytesToPrivateKey({privateKeyBytes:e}){return Gc(this,void 0,void 0,function*(){let r=Wc.getPublicKey(e),n={crv:"Ed25519",d:de.uint8Array(e).toBase64Url(),kty:"OKP",x:de.uint8Array(r).toBase64Url()};return n.kid=yield nt({jwk:n}),n})}static bytesToPublicKey({publicKeyBytes:e}){return Gc(this,void 0,void 0,function*(){let r={kty:"OKP",crv:"Ed25519",x:de.uint8Array(e).toBase64Url()};return r.kid=yield nt({jwk:r}),r})}static computePublicKey({key:e}){return Gc(this,void 0,void 0,function*(){let r=yield t.privateKeyToBytes({privateKey:e}),n=Wc.getPublicKey(r),i={kty:"OKP",crv:"Ed25519",x:de.uint8Array(n).toBase64Url()};return i.kid=yield nt({jwk:i}),i})}static convertPrivateKeyToX25519({privateKey:e}){return Gc(this,void 0,void 0,function*(){let r=yield t.privateKeyToBytes({privateKey:e}),n=tW(r),i=i0.getPublicKey(n),o={kty:"OKP",crv:"X25519",d:de.uint8Array(n).toBase64Url(),x:de.uint8Array(i).toBase64Url()};return o.kid=yield nt({jwk:o}),o})}static convertPublicKeyToX25519({publicKey:e}){return Gc(this,void 0,void 0,function*(){let r=yield t.publicKeyToBytes({publicKey:e});if(!(yield t.validatePublicKey({publicKeyBytes:r})))throw new Error("Ed25519: Invalid public key.");let i=eW(r),o={kty:"OKP",crv:"X25519",x:de.uint8Array(i).toBase64Url()};return o.kid=yield nt({jwk:o}),o})}static generateKey(){return Gc(this,void 0,void 0,function*(){let e=Wc.utils.randomPrivateKey(),r=yield t.bytesToPrivateKey({privateKeyBytes:e});return r.kid=yield nt({jwk:r}),r})}static getPublicKey({key:e}){var r;return Gc(this,void 0,void 0,function*(){if(!(Aa(e)&&e.crv==="Ed25519"))throw new Error("Ed25519: The provided key is not an Ed25519 private JWK.");let{d:n}=e,i=f6e(e,["d"]);return(r=i.kid)!==null&&r!==void 0||(i.kid=yield nt({jwk:i})),i})}static privateKeyToBytes({privateKey:e}){return Gc(this,void 0,void 0,function*(){if(!Aa(e))throw new Error("Ed25519: The provided key is not a valid OKP private key.");return de.base64Url(e.d).toUint8Array()})}static publicKeyToBytes({publicKey:e}){return Gc(this,void 0,void 0,function*(){if(!bp(e))throw new Error("Ed25519: The provided key is not a valid OKP public key.");return de.base64Url(e.x).toUint8Array()})}static sign({key:e,data:r}){return Gc(this,void 0,void 0,function*(){let n=yield t.privateKeyToBytes({privateKey:e});return Wc.sign(r,n)})}static validatePublicKey({publicKeyBytes:e}){return Gc(this,void 0,void 0,function*(){try{Wc.ExtendedPoint.fromHex(e).assertValidity()}catch{return!1}return!0})}static verify({key:e,signature:r,data:n}){return Gc(this,void 0,void 0,function*(){let i=yield t.publicKeyToBytes({publicKey:e});return Wc.verify(r,n,i)})}};var o_=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},eb=class extends Wn{computePublicKey({key:e}){return o_(this,void 0,void 0,function*(){if(!Aa(e))throw new TypeError("Invalid key provided. Must be an octet key pair (OKP) private key.");switch(e.crv){case"Ed25519":{let r=yield Yt.computePublicKey({key:e});return r.alg="EdDSA",r}default:throw new Error(`Unsupported curve: ${e.crv}`)}})}generateKey({algorithm:e}){return o_(this,void 0,void 0,function*(){switch(e){case"Ed25519":{let r=yield Yt.generateKey();return r.alg="EdDSA",r}}})}getPublicKey({key:e}){return o_(this,void 0,void 0,function*(){if(!Aa(e))throw new TypeError("Invalid key provided. Must be an octet key pair (OKP) private key.");switch(e.crv){case"Ed25519":{let r=yield Yt.getPublicKey({key:e});return r.alg="EdDSA",r}default:throw new Error(`Unsupported curve: ${e.crv}`)}})}sign({key:e,data:r}){return o_(this,void 0,void 0,function*(){if(!Aa(e))throw new TypeError("Invalid key provided. Must be an octet key pair (OKP) private key.");switch(e.crv){case"Ed25519":return yield Yt.sign({key:e,data:r});default:throw new Error(`Unsupported curve: ${e.crv}`)}})}verify({key:e,signature:r,data:n}){return o_(this,void 0,void 0,function*(){if(!bp(e))throw new TypeError("Invalid key provided. Must be an octet key pair (OKP) public key.");switch(e.crv){case"Ed25519":return yield Yt.verify({key:e,signature:r,data:n});default:throw new Error(`Unsupported curve: ${e.crv}`)}})}};var Nf=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},lR={Ed25519:{implementation:eb,names:["Ed25519"]},secp256k1:{implementation:wp,names:["ES256K","secp256k1"]},secp256r1:{implementation:wp,names:["ES256","secp256r1"]},"SHA-256":{implementation:yp,names:["SHA-256"]}},xr=class{constructor(e){var r;this._algorithmInstances=new Map,this._keyStore=(r=e?.keyStore)!==null&&r!==void 0?r:new Uy}digest({algorithm:e,data:r}){return Nf(this,void 0,void 0,function*(){return yield this.getAlgorithm({algorithm:e}).digest({algorithm:e,data:r})})}exportKey({keyUri:e}){return Nf(this,void 0,void 0,function*(){return yield this.getPrivateKey({keyUri:e})})}generateKey({algorithm:e}){return Nf(this,void 0,void 0,function*(){let n=yield this.getAlgorithm({algorithm:e}).generateKey({algorithm:e});if(n?.kid===void 0)throw new Error("Generated key is missing a required property: kid");let i=`${r0}${n.kid}`;return yield this._keyStore.set(i,n),i})}getKeyUri({key:e}){return Nf(this,void 0,void 0,function*(){let r=yield nt({jwk:e});return`${r0}${r}`})}getPublicKey({keyUri:e}){return Nf(this,void 0,void 0,function*(){let r=yield this.getPrivateKey({keyUri:e}),n=this.getAlgorithmName({key:r});return yield this.getAlgorithm({algorithm:n}).getPublicKey({key:r})})}importKey({key:e}){var r;return Nf(this,void 0,void 0,function*(){if(!Qv(e))throw new TypeError("Invalid key provided. Must be a private key in JWK format.");let n=structuredClone(e);(r=n.kid)!==null&&r!==void 0||(n.kid=yield nt({jwk:n}));let i=yield this.getKeyUri({key:n});return yield this._keyStore.set(i,n),i})}sign({keyUri:e,data:r}){return Nf(this,void 0,void 0,function*(){let n=yield this.getPrivateKey({keyUri:e}),i=this.getAlgorithmName({key:n});return this.getAlgorithm({algorithm:i}).sign({data:r,key:n})})}verify({key:e,signature:r,data:n}){return Nf(this,void 0,void 0,function*(){let i=this.getAlgorithmName({key:e});return this.getAlgorithm({algorithm:i}).verify({key:e,signature:r,data:n})})}getAlgorithm({algorithm:e}){var r;let n=(r=lR[e])===null||r===void 0?void 0:r.implementation;if(!n)throw new Error(`Algorithm not supported: ${e}`);return this._algorithmInstances.has(n)||this._algorithmInstances.set(n,new n),this._algorithmInstances.get(n)}getAlgorithmName({key:e}){let r=e.alg,n=e.crv;for(let i in lR){let o=lR[i];if(r&&o.names.includes(r))return i;if(n&&o.names.includes(n))return i}throw new Error(`Unable to determine algorithm based on provided input: alg=${r}, crv=${n}`)}getPrivateKey({keyUri:e}){return Nf(this,void 0,void 0,function*(){let r=yield this._keyStore.get(e);if(!r)throw new Error(`Key not found: ${e}`);return r})}};var Ei={};Fr(Ei,{checkRequiredProperty:()=>h6e,checkValidProperty:()=>p6e,getJoseSignatureAlgorithmFromPublicKey:()=>m6e,isWebCryptoSupported:()=>y6e,randomBytes:()=>g6e,randomUuid:()=>v6e});h();function h6e(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 p6e(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 m6e(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 y6e(){return!!(globalThis.crypto&&globalThis.crypto.subtle)}function g6e(t){return kf(t)}function v6e(){return Gv.randomUUID()}h();h();h();h();var s_=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;h();var jf=t=>new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4));function rW(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}var nW=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),b6e=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!b6e)throw new Error("Non little-endian hardware is not supported");function o5(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}function s5(t){if(typeof t=="string")t=o5(t);else if(rW(t))t=t.slice();else throw new Error(`expected Uint8Array, got ${typeof t}`);return t}var w6e=t=>Object.prototype.toString.call(t)==="[object Object]"&&t.constructor===Object;function iW(t,e){if(e!==void 0&&(typeof e!="object"||!w6e(e)))throw new Error("options must be object or undefined");return Object.assign(t,e)}function o0(t,e){if(!rW(t))throw new Error("Uint8Array expected");if(typeof e=="number"&&t.length!==e)throw new Error(`Uint8Array length ${e} expected`)}function oW(t,e){if(t.length!==e.length)return!1;let r=0;for(let n=0;n<t.length;n++)r|=t[n]^e[n];return r===0}var fR=(t,e)=>(Object.assign(e,t),e);function hR(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 a_(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`wrong positive integer: ${t}`)}function pR(t){if(typeof t!="boolean")throw new Error(`boolean expected, not ${t}`)}function _6e(t){return t!=null&&typeof t=="object"&&(t instanceof Uint8Array||t.constructor.name==="Uint8Array")}function tb(t,...e){if(!_6e(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 mR(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 sW(t,e){tb(t);let r=e.outputLen;if(t.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}function Gs(){if(s_&&typeof s_.subtle=="object"&&s_.subtle!=null)return s_.subtle;throw new Error("crypto.subtle must be defined")}h();h();var c_=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},x6e=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.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]]);return r},a5=96,aW=[128,192,256],c5=[96,104,112,120,128],Jc=class{static bytesToPrivateKey({privateKeyBytes:e}){return c_(this,void 0,void 0,function*(){let r={k:de.uint8Array(e).toBase64Url(),kty:"oct"};return r.kid=yield nt({jwk:r}),r})}static decrypt({key:e,data:r,iv:n,additionalData:i,tagLength:o}){return c_(this,void 0,void 0,function*(){if(n.byteLength!==a5/8)throw new TypeError(`The initialization vector must be ${a5} bits in length`);if(o&&!c5.includes(o))throw new RangeError(`The tag length is invalid: Must be ${c5.join(", ")} bits`);let s=Gs(),a=yield s.importKey("jwk",e,{name:"AES-GCM"},!0,["decrypt"]),d=Object.assign(Object.assign({name:"AES-GCM",iv:n},o&&{tagLength:o}),i&&{additionalData:i}),u=yield s.decrypt(d,a,r);return new Uint8Array(u)})}static encrypt({data:e,iv:r,key:n,additionalData:i,tagLength:o}){return c_(this,void 0,void 0,function*(){if(r.byteLength!==a5/8)throw new TypeError(`The initialization vector must be ${a5} bits in length`);if(o&&!c5.includes(o))throw new RangeError(`The tag length is invalid: Must be ${c5.join(", ")} bits`);let s=Gs(),a=yield s.importKey("jwk",n,{name:"AES-GCM"},!0,["encrypt"]),d=Object.assign(Object.assign({name:"AES-GCM",iv:r},o&&{tagLength:o}),i&&{additionalData:i}),u=yield s.encrypt(d,a,e);return new Uint8Array(u)})}static generateKey({length:e}){return c_(this,void 0,void 0,function*(){if(!aW.includes(e))throw new RangeError(`The key length is invalid: Must be ${aW.join(", ")} bits`);let r=Gs(),n=yield r.generateKey({name:"AES-GCM",length:e},!0,["encrypt"]),i=yield r.exportKey("jwk",n),{ext:o,key_ops:s}=i,a=x6e(i,["ext","key_ops"]);return a.kid=yield nt({jwk:a}),a})}static privateKeyToBytes({privateKey:e}){return c_(this,void 0,void 0,function*(){if(!n0(e))throw new Error("AesGcm: The provided key is not a valid oct private key.");return de.base64Url(e.k).toUint8Array()})}};var yR=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},d5=class extends Wn{decrypt(e){return yR(this,void 0,void 0,function*(){return Jc.decrypt(e)})}encrypt(e){return yR(this,void 0,void 0,function*(){return Jc.encrypt(e)})}generateKey({algorithm:e}){return yR(this,void 0,void 0,function*(){let r={A128GCM:128,A192GCM:192,A256GCM:256}[e],n=yield Jc.generateKey({length:r});return n.alg=e,n})}};h();h();h();h();h();h();var Sp=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},E6e=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.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]]);return r},ol=class t{static bytesToPrivateKey({privateKeyBytes:e}){return Sp(this,void 0,void 0,function*(){let r=i0.getPublicKey(e),n={kty:"OKP",crv:"X25519",d:de.uint8Array(e).toBase64Url(),x:de.uint8Array(r).toBase64Url()};return n.kid=yield nt({jwk:n}),n})}static bytesToPublicKey({publicKeyBytes:e}){return Sp(this,void 0,void 0,function*(){let r={kty:"OKP",crv:"X25519",x:de.uint8Array(e).toBase64Url()};return r.kid=yield nt({jwk:r}),r})}static computePublicKey({key:e}){return Sp(this,void 0,void 0,function*(){let r=yield t.privateKeyToBytes({privateKey:e}),n=i0.getPublicKey(r),i={kty:"OKP",crv:"X25519",x:de.uint8Array(n).toBase64Url()};return i.kid=yield nt({jwk:i}),i})}static generateKey(){return Sp(this,void 0,void 0,function*(){let e=i0.utils.randomPrivateKey(),r=yield t.bytesToPrivateKey({privateKeyBytes:e});return r.kid=yield nt({jwk:r}),r})}static getPublicKey({key:e}){var r;return Sp(this,void 0,void 0,function*(){if(!(Aa(e)&&e.crv==="X25519"))throw new Error("X25519: The provided key is not an X25519 private JWK.");let{d:n}=e,i=E6e(e,["d"]);return(r=i.kid)!==null&&r!==void 0||(i.kid=yield nt({jwk:i})),i})}static privateKeyToBytes({privateKey:e}){return Sp(this,void 0,void 0,function*(){if(!Aa(e))throw new Error("X25519: The provided key is not a valid OKP private key.");return de.base64Url(e.d).toUint8Array()})}static publicKeyToBytes({publicKey:e}){return Sp(this,void 0,void 0,function*(){if(!bp(e))throw new Error("X25519: The provided key is not a valid OKP public key.");return de.base64Url(e.x).toUint8Array()})}static sharedSecret({privateKeyA:e,publicKeyB:r}){return Sp(this,void 0,void 0,function*(){if("x"in e&&"x"in r&&e.x===r.x)throw new Error("X25519: ECDH shared secret cannot be computed from a single key pair's public and private keys.");let n=yield t.privateKeyToBytes({privateKey:e}),i=yield t.publicKeyToBytes({publicKey:r});return i0.getSharedSecret(n,i)})}};h();h();h();var No=(t,e)=>t[e++]&255|(t[e++]&255)<<8,gR=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=s5(e),o0(e,32);let r=No(e,0),n=No(e,2),i=No(e,4),o=No(e,6),s=No(e,8),a=No(e,10),d=No(e,12),u=No(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]=No(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],v=s[8],E=s[9],A=No(e,r+0),P=No(e,r+2),I=No(e,r+4),$=No(e,r+6),N=No(e,r+8),K=No(e,r+10),F=No(e,r+12),U=No(e,r+14),V=o[0]+(A&8191),L=o[1]+((A>>>13|P<<3)&8191),T=o[2]+((P>>>10|I<<6)&8191),S=o[3]+((I>>>7|$<<9)&8191),k=o[4]+(($>>>4|N<<12)&8191),f=o[5]+(N>>>1&8191),y=o[6]+((N>>>14|K<<2)&8191),w=o[7]+((K>>>11|F<<5)&8191),_=o[8]+((F>>>8|U<<8)&8191),x=o[9]+(U>>>5|i),b=0,B=b+V*a+L*(5*E)+T*(5*v)+S*(5*g)+k*(5*p);b=B>>>13,B&=8191,B+=f*(5*m)+y*(5*l)+w*(5*c)+_*(5*u)+x*(5*d),b+=B>>>13,B&=8191;let q=b+V*d+L*a+T*(5*E)+S*(5*v)+k*(5*g);b=q>>>13,q&=8191,q+=f*(5*p)+y*(5*m)+w*(5*l)+_*(5*c)+x*(5*u),b+=q>>>13,q&=8191;let M=b+V*u+L*d+T*a+S*(5*E)+k*(5*v);b=M>>>13,M&=8191,M+=f*(5*g)+y*(5*p)+w*(5*m)+_*(5*l)+x*(5*c),b+=M>>>13,M&=8191;let j=b+V*c+L*u+T*d+S*a+k*(5*E);b=j>>>13,j&=8191,j+=f*(5*v)+y*(5*g)+w*(5*p)+_*(5*m)+x*(5*l),b+=j>>>13,j&=8191;let J=b+V*l+L*c+T*u+S*d+k*a;b=J>>>13,J&=8191,J+=f*(5*E)+y*(5*v)+w*(5*g)+_*(5*p)+x*(5*m),b+=J>>>13,J&=8191;let Z=b+V*m+L*l+T*c+S*u+k*d;b=Z>>>13,Z&=8191,Z+=f*a+y*(5*E)+w*(5*v)+_*(5*g)+x*(5*p),b+=Z>>>13,Z&=8191;let G=b+V*p+L*m+T*l+S*c+k*u;b=G>>>13,G&=8191,G+=f*d+y*a+w*(5*E)+_*(5*v)+x*(5*g),b+=G>>>13,G&=8191;let W=b+V*g+L*p+T*m+S*l+k*c;b=W>>>13,W&=8191,W+=f*u+y*d+w*a+_*(5*E)+x*(5*v),b+=W>>>13,W&=8191;let X=b+V*v+L*g+T*p+S*m+k*l;b=X>>>13,X&=8191,X+=f*c+y*u+w*d+_*a+x*(5*E),b+=X>>>13,X&=8191;let ee=b+V*E+L*v+T*g+S*p+k*m;b=ee>>>13,ee&=8191,ee+=f*l+y*c+w*u+_*d+x*a,b+=ee>>>13,ee&=8191,b=(b<<2)+b|0,b=b+B|0,B=b&8191,b=b>>>13,q+=b,o[0]=B,o[1]=q,o[2]=M,o[3]=j,o[4]=J,o[5]=Z,o[6]=G,o[7]=W,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){mR(this);let{buffer:r,blockLen:n}=this;e=s5(e);let i=e.length;for(let o=0;o<i;){let s=Math.min(n-this.pos,i-o);if(s===n){for(;n<=i-o;o+=n)this.process(e,o);continue}r.set(e.subarray(o,o+s),this.pos),this.pos+=s,o+=s,this.pos===n&&(this.process(r,0,!1),this.pos=0)}return this}destroy(){this.h.fill(0),this.r.fill(0),this.buffer.fill(0),this.pad.fill(0)}digestInto(e){mR(this),sW(e,this),this.finished=!0;let{buffer:r,h:n}=this,{pos:i}=this;if(i){for(r[i++]=1;i<16;i++)r[i]=0;this.process(r,0,!0)}this.finalize();let o=0;for(let s=0;s<8;s++)e[o++]=n[s]>>>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 S6e(t){let e=(n,i)=>t(i).update(s5(n)).digest(),r=t(new Uint8Array(32));return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=n=>t(n),e}var cW=S6e(t=>new gR(t));h();var A6e=o5("expand 16-byte k"),T6e=o5("expand 32-byte k"),I6e=jf(A6e),P6e=jf(T6e);function Xe(t,e){return t<<e|t>>>32-e}function vR(t){return t.byteOffset%4===0}var u5=64,k6e=16,uW=2**32-1,dW=new Uint32Array;function R6e(t,e,r,n,i,o,s,a){let d=i.length,u=new Uint8Array(u5),c=jf(u),l=vR(i)&&vR(o),m=l?jf(i):dW,p=l?jf(o):dW;for(let g=0;g<d;s++){if(t(e,r,n,c,s,a),s>=uW)throw new Error("arx: counter overflow");let v=Math.min(u5,d-g);if(l&&v===u5){let E=g/4;if(g%4!==0)throw new Error("arx: invalid block position");for(let A=0,P;A<k6e;A++)P=E+A,p[P]=m[P]^c[A];g+=u5;continue}for(let E=0,A;E<v;E++)A=g+E,o[A]=i[A]^u[E];g+=v}}function bR(t,e){let{allowShortKeys:r,extendNonceFn:n,counterLength:i,counterRight:o,rounds:s}=iW({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},e);if(typeof t!="function")throw new Error("core must be a function");return a_(i),a_(s),pR(o),pR(r),(a,d,u,c,l=0)=>{tb(a),tb(d),tb(u);let m=u.length;if(c||(c=new Uint8Array(m)),tb(c),a_(l),l<0||l>=uW)throw new Error("arx: counter overflow");if(c.length<m)throw new Error(`arx: output (${c.length}) is shorter than data (${m})`);let p=[],g=a.length,v,E;if(g===32)v=a.slice(),p.push(v),E=P6e;else if(g===16&&r)v=new Uint8Array(32),v.set(a),v.set(a,16),E=I6e,p.push(v);else throw new Error(`arx: invalid 32-byte key, got length=${g}`);vR(d)||(d=d.slice(),p.push(d));let A=jf(v);if(n){if(d.length!==24)throw new Error("arx: extended nonce must be 24 bytes");n(E,A,jf(d.subarray(0,16)),A),d=d.subarray(16)}let P=16-i;if(P!==d.length)throw new Error(`arx: nonce must be ${P} or 16 bytes`);if(P!==12){let $=new Uint8Array(12);$.set(d,o?0:12-d.length),d=$,p.push(d)}let I=jf(d);for(R6e(t,E,A,I,u,c,l,s);p.length>0;)p.pop().fill(0);return c}}function hW(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],v=e[5],E=e[6],A=e[7],P=i,I=r[0],$=r[1],N=r[2],K=s,F=a,U=d,V=u,L=c,T=l,S=m,k=p,f=g,y=v,w=E,_=A,x=P,b=I,B=$,q=N;for(let j=0;j<o;j+=2)K=K+L|0,x=Xe(x^K,16),f=f+x|0,L=Xe(L^f,12),K=K+L|0,x=Xe(x^K,8),f=f+x|0,L=Xe(L^f,7),F=F+T|0,b=Xe(b^F,16),y=y+b|0,T=Xe(T^y,12),F=F+T|0,b=Xe(b^F,8),y=y+b|0,T=Xe(T^y,7),U=U+S|0,B=Xe(B^U,16),w=w+B|0,S=Xe(S^w,12),U=U+S|0,B=Xe(B^U,8),w=w+B|0,S=Xe(S^w,7),V=V+k|0,q=Xe(q^V,16),_=_+q|0,k=Xe(k^_,12),V=V+k|0,q=Xe(q^V,8),_=_+q|0,k=Xe(k^_,7),K=K+T|0,q=Xe(q^K,16),w=w+q|0,T=Xe(T^w,12),K=K+T|0,q=Xe(q^K,8),w=w+q|0,T=Xe(T^w,7),F=F+S|0,x=Xe(x^F,16),_=_+x|0,S=Xe(S^_,12),F=F+S|0,x=Xe(x^F,8),_=_+x|0,S=Xe(S^_,7),U=U+k|0,b=Xe(b^U,16),f=f+b|0,k=Xe(k^f,12),U=U+k|0,b=Xe(b^U,8),f=f+b|0,k=Xe(k^f,7),V=V+L|0,B=Xe(B^V,16),y=y+B|0,L=Xe(L^y,12),V=V+L|0,B=Xe(B^V,8),y=y+B|0,L=Xe(L^y,7);let M=0;n[M++]=s+K|0,n[M++]=a+F|0,n[M++]=d+U|0,n[M++]=u+V|0,n[M++]=c+L|0,n[M++]=l+T|0,n[M++]=m+S|0,n[M++]=p+k|0,n[M++]=g+f|0,n[M++]=v+y|0,n[M++]=E+w|0,n[M++]=A+_|0,n[M++]=P+x|0,n[M++]=I+b|0,n[M++]=$+B|0,n[M++]=N+q|0}function B6e(t,e,r,n){let i=t[0],o=t[1],s=t[2],a=t[3],d=e[0],u=e[1],c=e[2],l=e[3],m=e[4],p=e[5],g=e[6],v=e[7],E=r[0],A=r[1],P=r[2],I=r[3];for(let N=0;N<20;N+=2)i=i+d|0,E=Xe(E^i,16),m=m+E|0,d=Xe(d^m,12),i=i+d|0,E=Xe(E^i,8),m=m+E|0,d=Xe(d^m,7),o=o+u|0,A=Xe(A^o,16),p=p+A|0,u=Xe(u^p,12),o=o+u|0,A=Xe(A^o,8),p=p+A|0,u=Xe(u^p,7),s=s+c|0,P=Xe(P^s,16),g=g+P|0,c=Xe(c^g,12),s=s+c|0,P=Xe(P^s,8),g=g+P|0,c=Xe(c^g,7),a=a+l|0,I=Xe(I^a,16),v=v+I|0,l=Xe(l^v,12),a=a+l|0,I=Xe(I^a,8),v=v+I|0,l=Xe(l^v,7),i=i+u|0,I=Xe(I^i,16),g=g+I|0,u=Xe(u^g,12),i=i+u|0,I=Xe(I^i,8),g=g+I|0,u=Xe(u^g,7),o=o+c|0,E=Xe(E^o,16),v=v+E|0,c=Xe(c^v,12),o=o+c|0,E=Xe(E^o,8),v=v+E|0,c=Xe(c^v,7),s=s+l|0,A=Xe(A^s,16),m=m+A|0,l=Xe(l^m,12),s=s+l|0,A=Xe(A^s,8),m=m+A|0,l=Xe(l^m,7),a=a+d|0,P=Xe(P^a,16),p=p+P|0,d=Xe(d^p,12),a=a+d|0,P=Xe(P^a,8),p=p+P|0,d=Xe(d^p,7);let $=0;n[$++]=i,n[$++]=o,n[$++]=s,n[$++]=a,n[$++]=E,n[$++]=A,n[$++]=P,n[$++]=I}var M6e=bR(hW,{counterRight:!1,counterLength:4,allowShortKeys:!1}),pW=bR(hW,{counterRight:!1,counterLength:8,extendNonceFn:B6e,allowShortKeys:!1});var D6e=new Uint8Array(16),lW=(t,e)=>{t.update(e);let r=e.length%16;r&&t.update(D6e.subarray(r))},O6e=new Uint8Array(32);function fW(t,e,r,n,i){let o=t(e,r,O6e),s=cW.create(o);i&&lW(s,i),lW(s,n);let a=new Uint8Array(16),d=nW(a);hR(d,0,BigInt(i?i.length:0),!0),hR(d,8,BigInt(n.length),!0),s.update(a);let u=s.digest();return o.fill(0),u}var mW=t=>(e,r,n)=>(o0(e,32),o0(r),{encrypt:(o,s)=>{let a=o.length,d=a+16;s?o0(s,d):s=new Uint8Array(d),t(e,r,o,s,1);let u=fW(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?o0(s,d):s=new Uint8Array(d);let u=o.subarray(0,-16),c=o.subarray(-16),l=fW(t,e,r,u,n);if(!oW(c,l))throw new Error("invalid tag");return t(e,r,u,s,1),s}}),Fit=fR({blockSize:64,nonceLength:12,tagLength:16},mW(M6e)),C6e=fR({blockSize:64,nonceLength:24,tagLength:16},mW(pW));h();var p5={};Fr(p5,{extractDidFragment:()=>Ta,getServices:()=>N6e,getVerificationMethodByKey:()=>j6e,getVerificationMethodTypes:()=>wR,getVerificationMethods:()=>d_,getVerificationRelationshipsById:()=>_R,isDidService:()=>yW,isDidVerificationMethod:()=>l5,isDwnDidService:()=>U6e,keyBytesToMultibaseId:()=>f5,multibaseIdToKeyBytes:()=>h5});h();var $6e=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(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 Ta(t){if(typeof t=="string"&&t.length!==0)return t.split("#").pop()}function N6e({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 j6e(t){return $6e(this,arguments,void 0,function*({didDocument:e,publicKeyJwk:r,publicKeyMultibase:n}){let i=d_({didDocument:e});for(let o of i)if(r&&o.publicKeyJwk){if((yield nt({jwk:r}))===(yield nt({jwk:o.publicKeyJwk})))return o}else if(n&&o.publicKeyMultibase&&n===o.publicKeyMultibase)return o;return null})}function d_({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(l5))!==null&&r!==void 0?r:[]),Object.keys(Zy).forEach(i=>{var o,s;n.push(...(s=(o=t[i])===null||o===void 0?void 0:o.filter(l5))!==null&&s!==void 0?s:[])}),n}function wR({didDocument:t}){let r=d_({didDocument:t}).map(n=>n.type);return[...new Set(r)]}function _R({didDocument:t,methodId:e}){let r=[];return Object.keys(Zy).forEach(n=>{if(Array.isArray(t[n])){let i=t[n],o=Ta(e);i.some(a=>{let d=Ta(a)===o,u=l5(a)&&Ta(a.id)===o;return d||u})&&r.push(n)}}),r}function yW(t){return!t||typeof t!="object"||t===null?!1:"id"in t&&"type"in t&&"serviceEndpoint"in t}function U6e(t){if(!yW(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 l5(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 f5({keyBytes:t,multicodecCode:e,multicodecName:r}){let n=ii.addPrefix({code:e,data:t,name:r}),i=de.uint8Array(n).toBase58Btc();return de.base58Btc(i).toMultibase()}function h5({multibaseKeyId:t}){try{let e=de.multibase(t).toBase58Btc(),r=de.base58Btc(e).toUint8Array(),{code:n,data:i,name:o}=ii.removePrefix({prefixedData:r});return{keyBytes:i,multicodecCode:n,multicodecName:o}}catch{throw new st(Qe.InvalidDid,`Invalid multibase identifier: ${t}`)}}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())})},Ki=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 u_(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 u_(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 Ta(d.id)===((u=Ta(e?.methodId))!==null&&u!==void 0?u:Ta((c=this.document.assertionMethod)===null||c===void 0?void 0:c[0]))});if(!(n&&n.publicKeyJwk))throw new st(Qe.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:Ei.getJoseSignatureAlgorithmFromPublicKey(o),keyId:n.id,sign(d){return u_(this,arguments,void 0,function*({data:u}){return yield s.sign({data:u,keyUri:i})})},verify(d){return u_(this,arguments,void 0,function*({data:u,signature:c}){return yield s.verify({data:u,key:o,signature:c})})}}})}static import(e){return u_(this,arguments,void 0,function*({portableDid:r,keyManager:n=new xr}){var i;let o=d_({didDocument:r.document});if(o.length===0)throw new st(Qe.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 xR="0123456789abcdef",vW=[],gW=[];for(let t=0;t<256;t++)vW[t]=xR[t>>4&15]+xR[t&15],t<16&&(t<10?gW[48+t]=t:gW[87+t]=t);var ER=t=>{let e=t.length,r="",n=0;for(;n<e;)r+=vW[t[n++]];return r};var bW=(t,e=0)=>{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 wW="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",q6e=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(l_=0;l_<wW.length;l_++)q6e[wW.charCodeAt(l_)]=l_;var l_;var L6e=new TextDecoder,SR=(t,e)=>e?new TextDecoder(e).decode(t):L6e.decode(t),K6e=new TextEncoder,Yc=t=>K6e.encode(t);var _W=typeof window<"u"?window:self,xW=_W.crypto||_W.msCrypto||{},Got=xW.subtle||xW.webkitSubtle;h();function rb(t){let e=t<0?1:0;return t=Math.abs(Number(t||1)),Math.floor(Math.log10(t))+1+e}function m5(t){return ArrayBuffer.isView(t)?"arraybufferview":Array.isArray(t)?"array":t instanceof Number?"number":t instanceof Boolean?"boolean":t instanceof Set?"set":t instanceof Map?"map":t instanceof String?"string":t instanceof ArrayBuffer?"arraybuffer":typeof t}function Qr(t,e,r){let n=[],i=null;return Qr._encode(n,t),i=bW(n),Qr.bytes=i.length,ArrayBuffer.isView(e)?(e.set(i,r),e):i}Qr.bytes=-1;Qr._floatConversionDetected=!1;Qr._encode=function(t,e){if(e!=null)switch(m5(e)){case"object":Qr.dict(t,e);break;case"map":Qr.dictMap(t,e);break;case"array":Qr.list(t,e);break;case"set":Qr.listSet(t,e);break;case"string":Qr.string(t,e);break;case"number":Qr.number(t,e);break;case"boolean":Qr.number(t,e);break;case"arraybufferview":Qr.buffer(t,new Uint8Array(e.buffer,e.byteOffset,e.byteLength));break;case"arraybuffer":Qr.buffer(t,new Uint8Array(e));break}};var y5=new Uint8Array([101]),EW=new Uint8Array([100]),SW=new Uint8Array([108]);Qr.buffer=function(t,e){t.push(Yc(e.length+":"),e)};Qr.string=function(t,e){t.push(Yc(Yc(e).byteLength+":"+e))};Qr.number=function(t,e){if(Number.isInteger(e))return t.push(Yc("i"+BigInt(e)+"e"));let r=2147483648,n=e/r<<0,i=e%r<<0,o=n*r+i;t.push(Yc("i"+o+"e")),o!==e&&!Qr._floatConversionDetected&&(Qr._floatConversionDetected=!0,console.warn('WARNING: Possible data corruption detected with value "'+e+'":','Bencoding only defines support for integers, value was converted to "'+o+'"'),console.trace())};Qr.dict=function(t,e){t.push(EW);let r=0,n,i=Object.keys(e).sort(),o=i.length;for(;r<o;r++)n=i[r],e[n]!=null&&(Qr.string(t,n),Qr._encode(t,e[n]));t.push(y5)};Qr.dictMap=function(t,e){t.push(EW);let r=Array.from(e.keys()).sort();for(let n of r)e.get(n)!=null&&(ArrayBuffer.isView(n)?Qr._encode(t,n):Qr.string(t,String(n)),Qr._encode(t,e.get(n)));t.push(y5)};Qr.list=function(t,e){let r=0,n=e.length;for(t.push(SW);r<n;r++)e[r]!=null&&Qr._encode(t,e[r]);t.push(y5)};Qr.listSet=function(t,e){t.push(SW);for(let r of e)r!=null&&Qr._encode(t,r);t.push(y5)};var AW=Qr;h();var F6e=105,z6e=58,V6e=100,H6e=108,AR=101;function TW(t,e,r){let n=0,i=1;for(let o=e;o<r;o++){let s=t[o];if(s<58&&s>=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 Pt(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),Pt.position=0,Pt.encoding=n||null,Pt.data=ArrayBuffer.isView(t)?new Uint8Array(t.slice(e,r)):Yc(t),Pt.bytes=Pt.data.length,Pt.next())}Pt.bytes=0;Pt.position=0;Pt.data=null;Pt.encoding=null;Pt.next=function(){switch(Pt.data[Pt.position]){case V6e:return Pt.dictionary();case H6e:return Pt.list();case F6e:return Pt.integer();default:return Pt.buffer()}};Pt.find=function(t){let e=Pt.position,r=Pt.data.length,n=Pt.data;for(;e<r;){if(n[e]===t)return e;e++}throw new Error('Invalid data: Missing delimiter "'+String.fromCharCode(t)+'" [0x'+t.toString(16)+"]")};Pt.dictionary=function(){Pt.position++;let t={};for(;Pt.data[Pt.position]!==AR;){let e=Pt.buffer(),r=SR(e);r.includes("\uFFFD")&&(r=ER(e)),t[r]=Pt.next()}return Pt.position++,t};Pt.list=function(){Pt.position++;let t=[];for(;Pt.data[Pt.position]!==AR;)t.push(Pt.next());return Pt.position++,t};Pt.integer=function(){let t=Pt.find(AR),e=TW(Pt.data,Pt.position+1,t);return Pt.position+=t+1-Pt.position,e};Pt.buffer=function(){let t=Pt.find(z6e),e=TW(Pt.data,Pt.position,t),r=++t+e;return Pt.position=r,Pt.encoding?SR(Pt.data.slice(t,r)):Pt.data.slice(t,r)};var IW=Pt;h();function W6e(t){let e=2;for(let r of t)e+=g5(r);return e}function G6e(t){let e=2;for(let[r,n]of t){let i=Yc(r).byteLength;e+=rb(i)+1+i,e+=g5(n)}return e}function J6e(t){let e=2,r=Object.keys(t);for(let n=0;n<r.length;n++){let i=Yc(r[n]).byteLength;e+=rb(i)+1+i,e+=g5(t[r[n]])}return e}function Y6e(t){let e=Yc(t).byteLength;return rb(e)+1+e}function Z6e(t){let e=t.byteLength-t.byteOffset;return rb(e)+1+e}function g5(t){if(t==null)return 0;let r=m5(t);switch(r){case"arraybufferview":return Z6e(t);case"string":return Y6e(t);case"array":case"set":return W6e(t);case"number":return 1+rb(Math.floor(t))+1;case"bigint":return 1+t.toString().length+1;case"object":return J6e(t);case"map":return G6e(t);default:throw new TypeError(`Unsupported value of type "${r}"`)}}var TR=g5;var X6e=TR,nb={encode:AW,decode:IW,byteLength:TR,encodingLength:X6e};h();h();var Q6e=/^(\d{1,3}\.){3,3}\d{1,3}$/;var e3e=/^(::)?(((\d{1,3}\.){3}(\d{1,3}){1})?([0-9a-f]){0,4}:{0,2}){1,8}(::)?$/i;var Gd={name:"v4",size:4,isFormat:t=>Q6e.test(t),encode(t,e,r){r=~~r,e=e||new Uint8Array(r+4);let n=t.length,i=0;for(let o=0;o<n;){let s=t.charCodeAt(o++);s===46?(e[r++]=i,i=0):i=i*10+(s-48)}return e[r]=i,e},decode(t,e){return e=~~e,`${t[e++]}.${t[e++]}.${t[e++]}.${t[e]}`}},Uf={name:"v6",size:16,isFormat:t=>t.length>0&&e3e.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<t.length;u++){let c=t.charCodeAt(u);c===58?(a?i!==-1?(r<n&&(e[r]=0),r<n-1&&(e[r+1]=0),r+=2):r<n&&(i=r):(d===!0?(r<n&&(e[r]=s),r++):(r<n&&(e[r]=o>>8),r<n-1&&(e[r+1]=o&255),r+=2),o=0,s=0),a=!0,d=!1):c===46?(r<n&&(e[r]=s),r++,s=0,o=0,a=!1,d=!0):(a=!1,c>=97?c-=87:c>=65?c-=55:(c-=48,s=s*10+c),o=(o<<4)+c)}if(a===!1)d===!0?(r<n&&(e[r]=s),r++):(r<n&&(e[r]=o>>8),r<n-1&&(e[r+1]=o&255),r+=2);else if(i===0)r<n&&(e[r]=0),r<n-1&&(e[r+1]=0),r+=2;else if(i!==-1){r+=2;for(let u=Math.min(r-1,n-1);u>=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]=r<n&&r>i?e[--r]:0;else for(;r<n;)e[r++]=0;return e},decode(t,e){e=~~e;let r="";for(let n=0;n<16;n+=2)n!==0&&(r+=":"),r+=(t[e+n]<<8|t[e+n+1]).toString(16);return r.replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}};function PW(t){if(Gd.isFormat(t))return Gd.size;if(Uf.isFormat(t))return Uf.size;throw Error(`Invalid ip address: ${t}`)}function kW(t){return PW(t)===Gd.size?1:2}function RW(t,e,r){r=~~r;let n=PW(t);return typeof e=="function"&&(e=e(r+n)),n===Gd.size?Gd.encode(t,e,r):Uf.encode(t,e,r)}function BW(t,e,r){if(e=~~e,r=r||t.length-e,r===Gd.size)return Gd.decode(t,e,r);if(r===Uf.size)return Uf.decode(t,e,r);throw Error(`Invalid buffer size needs to be ${Gd.size} for v4 or ${Uf.size} for v6.`)}h();function f_(t){switch(t){case 1:return"A";case 10:return"NULL";case 28:return"AAAA";case 18:return"AFSDB";case 42:return"APL";case 257:return"CAA";case 60:return"CDNSKEY";case 59:return"CDS";case 37:return"CERT";case 5:return"CNAME";case 49:return"DHCID";case 32769:return"DLV";case 39:return"DNAME";case 48:return"DNSKEY";case 43:return"DS";case 55:return"HIP";case 13:return"HINFO";case 45:return"IPSECKEY";case 25:return"KEY";case 36:return"KX";case 29:return"LOC";case 15:return"MX";case 35:return"NAPTR";case 2:return"NS";case 47:return"NSEC";case 50:return"NSEC3";case 51:return"NSEC3PARAM";case 12:return"PTR";case 46:return"RRSIG";case 17:return"RP";case 24:return"SIG";case 6:return"SOA";case 99:return"SPF";case 33:return"SRV";case 44:return"SSHFP";case 32768:return"TA";case 249:return"TKEY";case 52:return"TLSA";case 250:return"TSIG";case 16:return"TXT";case 252:return"AXFR";case 251:return"IXFR";case 41:return"OPT";case 255:return"ANY"}return"UNKNOWN_"+t}function ib(t){switch(t.toUpperCase()){case"A":return 1;case"NULL":return 10;case"AAAA":return 28;case"AFSDB":return 18;case"APL":return 42;case"CAA":return 257;case"CDNSKEY":return 60;case"CDS":return 59;case"CERT":return 37;case"CNAME":return 5;case"DHCID":return 49;case"DLV":return 32769;case"DNAME":return 39;case"DNSKEY":return 48;case"DS":return 43;case"HIP":return 55;case"HINFO":return 13;case"IPSECKEY":return 45;case"KEY":return 25;case"KX":return 36;case"LOC":return 29;case"MX":return 15;case"NAPTR":return 35;case"NS":return 2;case"NSEC":return 47;case"NSEC3":return 50;case"NSEC3PARAM":return 51;case"PTR":return 12;case"RRSIG":return 46;case"RP":return 17;case"SIG":return 24;case"SOA":return 6;case"SPF":return 99;case"SRV":return 33;case"SSHFP":return 44;case"TA":return 32768;case"TKEY":return 249;case"TLSA":return 52;case"TSIG":return 250;case"TXT":return 16;case"AXFR":return 252;case"IXFR":return 251;case"OPT":return 41;case"ANY":return 255;case"*":return 255}return t.toUpperCase().startsWith("UNKNOWN_")?parseInt(t.slice(8)):0}h();function MW(t){switch(t){case 0:return"NOERROR";case 1:return"FORMERR";case 2:return"SERVFAIL";case 3:return"NXDOMAIN";case 4:return"NOTIMP";case 5:return"REFUSED";case 6:return"YXDOMAIN";case 7:return"YXRRSET";case 8:return"NXRRSET";case 9:return"NOTAUTH";case 10:return"NOTZONE";case 11:return"RCODE_11";case 12:return"RCODE_12";case 13:return"RCODE_13";case 14:return"RCODE_14";case 15:return"RCODE_15"}return"RCODE_"+t}h();function DW(t){switch(t){case 0:return"QUERY";case 1:return"IQUERY";case 2:return"STATUS";case 3:return"OPCODE_3";case 4:return"NOTIFY";case 5:return"UPDATE";case 6:return"OPCODE_6";case 7:return"OPCODE_7";case 8:return"OPCODE_8";case 9:return"OPCODE_9";case 10:return"OPCODE_10";case 11:return"OPCODE_11";case 12:return"OPCODE_12";case 13:return"OPCODE_13";case 14:return"OPCODE_14";case 15:return"OPCODE_15"}return"OPCODE_"+t}h();function IR(t){switch(t){case 1:return"IN";case 2:return"CS";case 3:return"CH";case 4:return"HS";case 255:return"ANY"}return"UNKNOWN_"+t}function PR(t){switch(t.toUpperCase()){case"IN":return 1;case"CS":return 2;case"CH":return 3;case"HS":return 4;case"ANY":return 255}return 0}h();function OW(t){switch(t){case 1:return"LLQ";case 2:return"UL";case 3:return"NSID";case 5:return"DAU";case 6:return"DHU";case 7:return"N3U";case 8:return"CLIENT_SUBNET";case 9:return"EXPIRE";case 10:return"COOKIE";case 11:return"TCP_KEEPALIVE";case 12:return"PADDING";case 13:return"CHAIN";case 14:return"KEY_TAG";case 26946:return"DEVICEID"}return t<0?null:`OPTION_${t}`}function kR(t){if(typeof t=="number")return t;if(!t)return-1;switch(t.toUpperCase()){case"OPTION_0":return 0;case"LLQ":return 1;case"UL":return 2;case"NSID":return 3;case"OPTION_4":return 4;case"DAU":return 5;case"DHU":return 6;case"N3U":return 7;case"CLIENT_SUBNET":return 8;case"EXPIRE":return 9;case"COOKIE":return 10;case"TCP_KEEPALIVE":return 11;case"PADDING":return 12;case"CHAIN":return 13;case"KEY_TAG":return 14;case"DEVICEID":return 26946;case"OPTION_65535":return 65535}let e=t.match(/_(\d+)$/);return e?parseInt(e[1],10):-1}h();h();function RR(t){let e=0,r=t.length;for(let n=0;n<r;n+=1){let i=t.charCodeAt(n);if(i<=127)e+=1;else if(i<=2047)e+=2;else if((i&63488)!==55296)e+=3;else{let o=n+1;o===r||i>=56320||(t.charCodeAt(o)&64512)!==56320?e+=3:(n=o,e+=4)}}return e}function ob(t,e,r){let n=t.length;r==null&&(r=0),e===void 0&&(e=new Uint8Array(RR(t)+r));let i=r;for(let o=0;o<n;o+=1){let s=t.charCodeAt(o);if(s<=127)e[i++]=s;else if(s<=2047)e[i++]=192|(s&1984)>>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 ob.bytes=i-r,e}ob.bytes=0;function sb(t,e,r){let n="";e==null&&(e=0),r==null&&(r=t.length);for(let i=e;i<r;){let o=t[i++],s;if(o<=128)s=o;else if(o>191&&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 sb.bytes=r-e,n}sb.bytes=0;var Ap=t=>t instanceof Uint8Array;function qf(t){return typeof t=="string"?RR(t):t.byteLength}function v5(t){return t instanceof Uint8Array?t:Array.isArray(t)?new Uint8Array(t):ob(t)}function b5(t,e,r){if(typeof e!="string")throw new Error("unknown input type");return ob(e,t,r),ob.bytes}var h_={},CW=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}`;CW[s]=a,h_[a]=s,h_[`${r}${i}`]=s,h_[`${e}${o}`]=s,h_[`${r}${o}`]=s}}function $W(t,e,r){let n="";for(let i=e;i<r;){let o=t[i++];n+=CW[o]}return n}function BR(t){return t.length>>>1}function NW(t,e,r,n){let i=0;for(;r<n;){let o=e.substr(i,2),s=h_[o];if(s===void 0)return;t[r++]=s,i+=2}return t}var c3e=Math.pow(2,24),d3e=Math.pow(2,16),u3e=Math.pow(2,8),sl=(t,e)=>t[e]*c3e+t[e+1]*d3e+t[e+2]*u3e+t[e+3],ir=(t,e)=>t[e]<<8|t[e+1],al=(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),pt=(t,e,r)=>(t[r]=e>>8,t[r+1]=e&255,r+2);function Ia(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:l3e(t,e,r,n,i)}function l3e(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||i<t.length)&&(t=new Uint8Array(t.buffer,t.byteOffset+n,o)),e.set(t,r),o}var h3e=0,jW=32768,DR=32768,p3e=~DR,qW=32768,m3e=~qW;function vn({bytes:t=0,encode:e,decode:r,encodingLength:n}){return e.bytes=t,r.bytes=t,{encode:e,decode:r,encodingLength:n||(()=>t)}}var it=vn({encode(t,e,r){e||(e=new Uint8Array(it.encodingLength(t))),r||(r=0);let n=r,i=t.replace(/^\.|\.$/gm,"");if(i.length){let o=i.split(".");for(let s=0;s<o.length;s++){let a=b5(e,o[s],r+1);e[r]=a,r+=a+1}}return e[r++]=0,it.encode.bytes=r-n,e},decode(t,e){e||(e=0);let r=[],n=e,i=0,o=0,s=!1;for(;;){if(e>=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(sb(t,e,e+a)),e+=a,o+=s?0:a}}return it.decode.bytes=o,r.length===0?".":r.join(".")},encodingLength(t){return t==="."||t===".."?1:qf(t.replace(/^\.|\.$/gm,""))+2}}),Fi=vn({encode(t,e,r){e||(e=new Uint8Array(Fi.encodingLength(t))),r||(r=0);let n=b5(e,t,r+1);return e[r]=n,Fi.encode.bytes=n+1,e},decode(t,e){e||(e=0);let r=t[e],n=sb(t,e+1,e+1+r);return Fi.decode.bytes=r+1,n},encodingLength(t){return qf(t)+1}}),ab=vn({bytes:12,encode(t,e,r){e||(e=new Uint8Array(ab.encodingLength(t))),r||(r=0);let n=(t.flags||0)&32767,i=t.type==="response"?jW:h3e;return pt(e,t.id||0,r),pt(e,n|i,r+2),pt(e,t.questions.length,r+4),pt(e,t.answers.length,r+6),pt(e,t.authorities.length,r+8),pt(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&jW?"response":"query",flags:r&32767,flag_qr:(r>>15&1)===1,opcode:DW(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:MW(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}}),_5=vn({encode(t,e,r){e||(e=new Uint8Array(_5.encodingLength(t))),r||(r=0);let n=t.length;return pt(e,n,r),Ia(t,e,r+2,0,n),_5.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 _5.decode.bytes=r+2,n},encodingLength(t){return t.length+2}}),x5=vn({encode(t,e,r){return e||(e=new Uint8Array(x5.encodingLength(t))),r||(r=0),it.encode(t,e,r+2),pt(e,it.encode.bytes,r),x5.encode.bytes=it.encode.bytes+2,e},decode(t,e){e||(e=0);let r=ir(t,e),n=it.decode(t,e+2);return x5.decode.bytes=r+2,n},encodingLength(t){return it.encodingLength(t)+2}}),E5=vn({encode(t,e,r){e||(e=new Uint8Array(E5.encodingLength(t))),r||(r=0);let n=r;return r+=2,it.encode(t.mname,e,r),r+=it.encode.bytes,it.encode(t.rname,e,r),r+=it.encode.bytes,al(e,t.serial||0,r),r+=4,al(e,t.refresh||0,r),r+=4,al(e,t.retry||0,r),r+=4,al(e,t.expire||0,r),r+=4,al(e,t.minimum||0,r),r+=4,pt(e,r-n-2,n),E5.encode.bytes=r-n,e},decode(t,e){e||(e=0);let r=e,n={};return e+=2,n.mname=it.decode(t,e),e+=it.decode.bytes,n.rname=it.decode(t,e),e+=it.decode.bytes,n.serial=sl(t,e),e+=4,n.refresh=sl(t,e),e+=4,n.retry=sl(t,e),e+=4,n.expire=sl(t,e),e+=4,n.minimum=sl(t,e),e+=4,E5.decode.bytes=e-r,n},encodingLength(t){return 22+it.encodingLength(t.mname)+it.encodingLength(t.rname)}}),S5=vn({encode(t,e,r){Array.isArray(t)||(t=[t]);for(let i=0;i<t.length;i++)if(typeof t[i]=="string"&&(t[i]=v5(t[i])),!Ap(t[i]))throw new Error("Must be a Buffer");e||(e=new Uint8Array(S5.encodingLength(t))),r||(r=0);let n=r;return r+=2,t.forEach(function(i){e[r++]=i.length,Ia(i,e,r,0,i.length),r+=i.length}),pt(e,r-n-2,n),S5.encode.bytes=r-n,e},decode(t,e){e||(e=0);let r=e,n=ir(t,e);e+=2;let i=[];for(;n>0;){let o=t[e++];if(--n,n<o)throw new Error("Buffer overflow");i.push(t.slice(e,e+o)),e+=o,n-=o}return S5.decode.bytes=e-r,i},encodingLength(t){Array.isArray(t)||(t=[t]);let e=2;return t.forEach(function(r){typeof r=="string"?e+=qf(r)+1:e+=r.length+1}),e}}),A5=vn({encode(t,e,r){e||(e=new Uint8Array(A5.encodingLength(t))),r||(r=0),typeof t=="string"&&(t=v5(t)),t||(t=new Uint8Array(0));let n=r;r+=2;let i=t.length;return Ia(t,e,r,0,i),r+=i,pt(e,r-n-2,n),A5.encode.bytes=r-n,e},decode(t,e){e||(e=0);let r=e,n=ir(t,e);e+=2;let i=t.slice(e,e+n);return e+=n,A5.decode.bytes=e-r,i},encodingLength(t){return t?(Ap(t)?t.length:qf(t))+2:2}}),T5=vn({encode(t,e,r){e||(e=new Uint8Array(T5.encodingLength(t))),r||(r=0);let n=r;return r+=2,Fi.encode(t.cpu,e,r),r+=Fi.encode.bytes,Fi.encode(t.os,e,r),r+=Fi.encode.bytes,pt(e,r-n-2,n),T5.encode.bytes=r-n,e},decode(t,e){e||(e=0);let r=e,n={};return e+=2,n.cpu=Fi.decode(t,e),e+=Fi.decode.bytes,n.os=Fi.decode(t,e),e+=Fi.decode.bytes,T5.decode.bytes=e-r,n},encodingLength(t){return Fi.encodingLength(t.cpu)+Fi.encodingLength(t.os)+2}}),ub=vn({encode(t,e,r){return e||(e=new Uint8Array(ub.encodingLength(t))),r||(r=0),it.encode(t,e,r+2),pt(e,it.encode.bytes,r),ub.encode.bytes=it.encode.bytes+2,e},decode(t,e){e||(e=0);let r=it.decode(t,e+2);return ub.decode.bytes=it.decode.bytes+2,r},encodingLength(t){return it.encodingLength(t)+2}}),I5=vn({encode(t,e,r){e||(e=new Uint8Array(I5.encodingLength(t))),r||(r=0),pt(e,t.priority||0,r+2),pt(e,t.weight||0,r+4),pt(e,t.port||0,r+6),it.encode(t.target,e,r+8);let n=it.encode.bytes+6;return pt(e,n,r),I5.encode.bytes=n+2,e},decode(t,e){e||(e=0);let r=ir(t,e),n={};return n.priority=ir(t,e+2),n.weight=ir(t,e+4),n.port=ir(t,e+6),n.target=it.decode(t,e+8),I5.decode.bytes=r+2,n},encodingLength(t){return 8+it.encodingLength(t.target)}}),Tp=vn({encode(t,e,r){let n=Tp.encodingLength(t);return e||(e=new Uint8Array(Tp.encodingLength(t))),r||(r=0),t.issuerCritical&&(t.flags=Tp.ISSUER_CRITICAL),pt(e,n-2,r),r+=2,e[r]=t.flags||0,r+=1,Fi.encode(t.tag,e,r),r+=Fi.encode.bytes,b5(e,t.value,r),r+=qf(t.value),Tp.encode.bytes=n,e},decode(t,e){e||(e=0);let r=ir(t,e);e+=2;let n=e,i={};return i.flags=t[e],e+=1,i.tag=Fi.decode(t,e),e+=Fi.decode.bytes,i.value=sb(t,e,n+r),i.issuerCritical=!!(i.flags&Tp.ISSUER_CRITICAL),Tp.decode.bytes=r+2,i},encodingLength(t){return Fi.encodingLength(t.tag)+Fi.encodingLength(t.value)+2}});Tp.ISSUER_CRITICAL=128;var P5=vn({encode(t,e,r){e||(e=new Uint8Array(P5.encodingLength(t))),r||(r=0);let n=r;return r+=2,pt(e,t.preference||0,r),r+=2,it.encode(t.exchange,e,r),r+=it.encode.bytes,pt(e,r-n-2,n),P5.encode.bytes=r-n,e},decode(t,e){e||(e=0);let r=e,n={};return e+=2,n.preference=ir(t,e),e+=2,n.exchange=it.decode(t,e),e+=it.decode.bytes,P5.decode.bytes=e-r,n},encodingLength(t){return 4+it.encodingLength(t.exchange)}}),LW=vn({encode(t,e,r){return e||(e=new Uint8Array(LW.encodingLength(t))),r||(r=0),pt(e,4,r),r+=2,Gd.encode(t,e,r),e},decode(t,e){return e||(e=0),e+=2,Gd.decode(t,e)},bytes:6}),k5=vn({encode(t,e,r){return e||(e=new Uint8Array(k5.encodingLength(t))),r||(r=0),pt(e,16,r),r+=2,Uf.encode(t,e,r),k5.encode.bytes=18,e},decode(t,e){e||(e=0),e+=2;let r=Uf.decode(t,e);return k5.decode.bytes=18,r},bytes:18}),UW=t=>new Uint8Array(t),Lf=vn({encode(t,e,r){e||(e=new Uint8Array(Lf.encodingLength(t))),r||(r=0);let n=r,i=kR(t.code);if(pt(e,i,r),r+=2,t.data)pt(e,t.data.length,r),r+=2,Ia(t.data,e,r),r+=t.data.length;else switch(i){case 8:{let o=t.sourcePrefixLength||0,s=t.family||kW(t.ip,UW),a=RW(t.ip,UW),d=Math.ceil(o/8);pt(e,d+4,r),r+=2,pt(e,s,r),r+=2,e[r++]=o,e[r++]=t.scopePrefixLength||0,Ia(a,e,r,0,d),r+=d}break;case 11:t.timeout?(pt(e,2,r),r+=2,pt(e,t.timeout,r),r+=2):(pt(e,0,r),r+=2);break;case 12:{let o=t.length||0;pt(e,o,r),r+=2,e.fill(0,r,r+o),r+=o}break;case 14:{let o=t.tags.length*2;pt(e,o,r),r+=2;for(let s of t.tags)pt(e,s,r),r+=2}break;default:throw new Error(`Unknown roption code: ${t.code}`)}return Lf.encode.bytes=r-n,e},decode(t,e){e||(e=0);let r={};r.code=ir(t,e),r.type=OW(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);Ia(t,i,0,e,e+n-4),r.ip=BW(i)}break;case 11:n>0&&(r.timeout=ir(t,e),e+=2);break;case 14:r.tags=[];for(let i=0;i<n;i+=2)r.tags.push(ir(t,e)),e+=2}return Lf.decode.bytes=n+4,r},encodingLength(t){if(t.data)return t.data.length+4;switch(kR(t.code)){case 8:{let r=t.sourcePrefixLength||0;return Math.ceil(r/8)+8}case 11:return typeof t.timeout=="number"?6:4;case 12:return t.length+4;case 14:return 4+t.tags.length*2}throw new Error(`Unknown roption code: ${t.code}`)}}),Ip=vn({encode(t,e,r){e||(e=new Uint8Array(Ip.encodingLength(t))),r||(r=0);let n=r,i=db(t,Lf);return pt(e,i,r),r=b_(t,Lf,e,r+2),Ip.encode.bytes=r-n,e},decode(t,e){e||(e=0);let r=e,n=[],i=ir(t,e);e+=2;let o=0;for(;i>0;)n[o++]=Lf.decode(t,e),e+=Lf.decode.bytes,i-=Lf.decode.bytes;return Ip.decode.bytes=e-r,n},encodingLength(t){return 2+db(t||[],Lf)}}),cl=vn({encode(t,e,r){e||(e=new Uint8Array(cl.encodingLength(t))),r||(r=0);let n=r,i=t.key;if(!Ap(i))throw new Error("Key must be a Buffer");return r+=2,pt(e,t.flags,r),r+=2,e[r]=cl.PROTOCOL_DNSSEC,r+=1,e[r]=t.algorithm,r+=1,Ia(i,e,r,0,i.length),r+=i.length,cl.encode.bytes=r-n,pt(e,cl.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]!==cl.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,cl.decode.bytes=e-r,n},encodingLength(t){return 6+qf(t.key)}});cl.PROTOCOL_DNSSEC=3;cl.ZONE_KEY=128;cl.SECURE_ENTRYPOINT=32768;var p_=vn({encode(t,e,r){e||(e=new Uint8Array(p_.encodingLength(t))),r||(r=0);let n=r,i=t.signature;if(!Ap(i))throw new Error("Signature must be a Buffer");return r+=2,pt(e,ib(t.typeCovered),r),r+=2,e[r]=t.algorithm,r+=1,e[r]=t.labels,r+=1,al(e,t.originalTTL,r),r+=4,al(e,t.expiration,r),r+=4,al(e,t.inception,r),r+=4,pt(e,t.keyTag,r),r+=2,it.encode(t.signersName,e,r),r+=it.encode.bytes,Ia(i,e,r,0,i.length),r+=i.length,p_.encode.bytes=r-n,pt(e,p_.encode.bytes-2,n),e},decode(t,e){e||(e=0);let r=e,n={},i=ir(t,e);return e+=2,n.typeCovered=f_(ir(t,e)),e+=2,n.algorithm=t[e],e+=1,n.labels=t[e],e+=1,n.originalTTL=sl(t,e),e+=4,n.expiration=sl(t,e),e+=4,n.inception=sl(t,e),e+=4,n.keyTag=ir(t,e),e+=2,n.signersName=it.decode(t,e),e+=it.decode.bytes,n.signature=t.slice(e,r+i+2),e+=n.signature.length,p_.decode.bytes=e-r,n},encodingLength(t){return 20+it.encodingLength(t.signersName)+qf(t.signature)}}),m_=vn({encode(t,e,r){e||(e=new Uint8Array(m_.encodingLength(t))),r||(r=0);let n=r;return r+=2,it.encode(t.mbox||".",e,r),r+=it.encode.bytes,it.encode(t.txt||".",e,r),r+=it.encode.bytes,m_.encode.bytes=r-n,pt(e,m_.encode.bytes-2,n),e},decode(t,e){e||(e=0);let r=e,n={};return e+=2,n.mbox=it.decode(t,e)||".",e+=it.decode.bytes,n.txt=it.decode(t,e)||".",e+=it.decode.bytes,m_.decode.bytes=e-r,n},encodingLength(t){return 2+it.encodingLength(t.mbox||".")+it.encodingLength(t.txt||".")}}),ec=vn({encode(t,e,r){e||(e=new Uint8Array(ec.encodingLength(t))),r||(r=0);let n=r,i=[];for(let o=0;o<t.length;o++){let s=ib(t[o]);i[s>>8]===void 0&&(i[s>>8]=[]),i[s>>8][s>>3&31]|=1<<7-(s&7)}for(let o=0;o<i.length;o++)if(i[o]!==void 0){let s=v5(i[o]);e[r]=o,r+=1,e[r]=s.length,r+=1,Ia(s,e,r,0,s.length),r+=s.length}return ec.encode.bytes=r-n,e},decode(t,e,r){e||(e=0);let n=e,i=[];for(;e-n<r;){let o=t[e];e+=1;let s=t[e];e+=1;for(let a=0;a<s;a++){let d=t[e+a];for(let u=0;u<8;u++)if(d&1<<7-u){let c=f_(o<<8|a<<3|u);i.push(c)}}e+=s}return ec.decode.bytes=e-n,i},encodingLength(t){let e=[];for(let n=0;n<t.length;n++){let i=ib(t[n]);e[i>>8]=Math.max(e[i>>8]||0,i&255)}let r=0;for(let n=0;n<e.length;n++)e[n]!==void 0&&(r+=2+Math.ceil((e[n]+1)/8));return r}}),y_=vn({encode(t,e,r){e||(e=new Uint8Array(y_.encodingLength(t))),r||(r=0);let n=r;return r+=2,it.encode(t.nextDomain,e,r),r+=it.encode.bytes,ec.encode(t.rrtypes,e,r),r+=ec.encode.bytes,y_.encode.bytes=r-n,pt(e,y_.encode.bytes-2,n),e},decode(t,e){e||(e=0);let r=e,n={},i=ir(t,e);return e+=2,n.nextDomain=it.decode(t,e),e+=it.decode.bytes,n.rrtypes=ec.decode(t,e,i-(e-r)),e+=ec.decode.bytes,y_.decode.bytes=e-r,n},encodingLength(t){return 2+it.encodingLength(t.nextDomain)+ec.encodingLength(t.rrtypes)}}),g_=vn({encode(t,e,r){e||(e=new Uint8Array(g_.encodingLength(t))),r||(r=0);let n=r,i=t.salt;if(!Ap(i))throw new Error("salt must be a Buffer");let o=t.nextDomain;if(!Ap(o))throw new Error("nextDomain must be a Buffer");return r+=2,e[r]=t.algorithm,r+=1,e[r]=t.flags,r+=1,pt(e,t.iterations,r),r+=2,e[r]=i.length,r+=1,Ia(i,e,r,0,i.length),r+=i.length,e[r]=o.length,r+=1,Ia(o,e,r,0,o.length),r+=o.length,ec.encode(t.rrtypes,e,r),r+=ec.encode.bytes,g_.encode.bytes=r-n,pt(e,g_.encode.bytes-2,n),e},decode(t,e){e||(e=0);let r=e,n={},i=ir(t,e);e+=2,n.algorithm=t[e],e+=1,n.flags=t[e],e+=1,n.iterations=ir(t,e),e+=2;let o=t[e];e+=1,n.salt=t.slice(e,e+o),e+=o;let s=t[e];return e+=1,n.nextDomain=t.slice(e,e+s),e+=s,n.rrtypes=ec.decode(t,e,i-(e-r)),e+=ec.decode.bytes,g_.decode.bytes=e-r,n},encodingLength(t){return 8+t.salt.length+t.nextDomain.length+ec.encodingLength(t.rrtypes)}}),v_=vn({encode(t,e,r){e||(e=new Uint8Array(v_.encodingLength(t))),r||(r=0);let n=r,i=t.digest;if(!Ap(i))throw new Error("Digest must be a Buffer");return r+=2,pt(e,t.keyTag,r),r+=2,e[r]=t.algorithm,r+=1,e[r]=t.digestType,r+=1,Ia(i,e,r,0,i.length),r+=i.length,v_.encode.bytes=r-n,pt(e,v_.encode.bytes-2,n),e},decode(t,e){e||(e=0);let r=e,n={},i=ir(t,e);return e+=2,n.keyTag=ir(t,e),e+=2,n.algorithm=t[e],e+=1,n.digestType=t[e],e+=1,n.digest=t.slice(e,r+i+2),e+=n.digest.length,v_.decode.bytes=e-r,n},encodingLength(t){return 6+qf(t.digest)}}),cb=vn({encode(t,e,r){e||(e=new Uint8Array(cb.encodingLength(t))),r||(r=0);let n=r;r+=2,e[r]=t.algorithm,r+=1,e[r]=t.hash,r+=1;let i=BR(t.fingerprint),o=OR(t.hash);if(i!==o)throw new Error(`Invalid length of fingerprint "${t.fingerprint}" for hashType=${t.hash}: ${i} != ${o}`);return NW(e,t.fingerprint,r,r+=i),cb.encode.bytes=r-n,pt(e,cb.encode.bytes-2,n),e},decode(t,e){e||(e=0);let r=e,n={};e+=2,n.algorithm=t[e],e+=1,n.hash=t[e],e+=1;let i=OR(n.hash);return n.fingerprint=$W(t,e,e+i),e+=i,cb.decode.bytes=e-r,n},encodingLength(t){return 4+BR(t.fingerprint)}});function OR(t){if(t===1)return 20;if(t===2)return 32;throw new Error(`Invalid hashType=${t}, supported=1,2`)}cb.getFingerprintLengthForHashType=OR;function MR(t){switch(t.toUpperCase()){case"A":return LW;case"PTR":return ub;case"CNAME":return ub;case"DNAME":return ub;case"TXT":return S5;case"NULL":return A5;case"AAAA":return k5;case"SRV":return I5;case"HINFO":return T5;case"CAA":return Tp;case"NS":return x5;case"SOA":return E5;case"MX":return P5;case"OPT":return Ip;case"DNSKEY":return cl;case"RRSIG":return p_;case"RP":return m_;case"NSEC":return y_;case"NSEC3":return g_;case"SSHFP":return cb;case"DS":return v_}return _5}var Zc=vn({encode(t,e,r){e||(e=new Uint8Array(Zc.encodingLength(t))),r||(r=0);let n=r;if(it.encode(t.name,e,r),r+=it.encode.bytes,pt(e,ib(t.type),r),t.type.toUpperCase()==="OPT"){if(t.name!==".")throw new Error("OPT name must be root.");pt(e,t.udpPayloadSize||4096,r+2),e[r+4]=t.extendedRcode||0,e[r+5]=t.ednsVersion||0,pt(e,t.flags||0,r+6),r+=8,Ip.encode(t.options||[],e,r),r+=Ip.encode.bytes}else{let i=PR(t.class===void 0?"IN":t.class);t.flush&&(i|=DR),pt(e,i,r+2),al(e,t.ttl||0,r+4),r+=8;let o=MR(t.type);o.encode(t.data,e,r),r+=o.encode.bytes}return Zc.encode.bytes=r-n,e},decode(t,e){e||(e=0);let r={},n=e;if(r.name=it.decode(t,e),e+=it.decode.bytes,r.type=f_(ir(t,e)),r.type==="OPT")r.udpPayloadSize=ir(t,e+2),r.extendedRcode=t[e+4],r.ednsVersion=t[e+5],r.flags=ir(t,e+6),r.flag_do=(r.flags>>15&1)===1,r.options=Ip.decode(t,e+8),e+=8+Ip.decode.bytes;else{let i=ir(t,e+2);r.ttl=sl(t,e+4),r.class=IR(i&p3e),r.flush=!!(i&DR);let o=MR(r.type);r.data=o.decode(t,e+8),e+=8+o.decode.bytes}return Zc.decode.bytes=e-n,r},encodingLength(t){let e=t.data!==null&&t.data!==void 0?t.data:t.options;return it.encodingLength(t.name)+8+MR(t.type).encodingLength(e)}}),lb=vn({encode(t,e,r){e||(e=new Uint8Array(lb.encodingLength(t))),r||(r=0);let n=r;return it.encode(t.name,e,r),r+=it.encode.bytes,pt(e,ib(t.type),r),r+=2,pt(e,PR(t.class===void 0?"IN":t.class),r),r+=2,lb.encode.bytes=r-n,t},decode(t,e){e||(e=0);let r=e,n={};return n.name=it.decode(t,e),e+=it.decode.bytes,n.type=f_(ir(t,e)),e+=2,n.class=IR(ir(t,e)),e+=2,!!(n.class&qW)&&(n.class&=m3e),lb.decode.bytes=e-r,n},encodingLength(t){return it.encodingLength(t.name)+4}});var D5=1024;var jo={encode:function(t,e,r){let n=!e;n&&(e=new Uint8Array(y3e(t))),r||(r=0);let i=r;return t.questions||(t.questions=[]),t.answers||(t.answers=[]),t.authorities||(t.authorities=[]),t.additionals||(t.additionals=[]),ab.encode(t,e,r),r+=ab.encode.bytes,r=b_(t.questions,lb,e,r),r=b_(t.answers,Zc,e,r),r=b_(t.authorities,Zc,e,r),r=b_(t.additionals,Zc,e,r),jo.encode.bytes=r-i,n&&s0.bytes!==e.length?e.slice(0,s0.bytes):e},decode:function(t,e){e||(e=0);let r=e,n=ab.decode(t,e);return e+=ab.decode.bytes,e=w5(n.questions,lb,t,e),e=w5(n.answers,Zc,t,e),e=w5(n.authorities,Zc,t,e),e=w5(n.additionals,Zc,t,e),jo.decode.bytes=e-r,n},encodingLength:function(t){return ab.encodingLength(t)+db(t.questions||[],lb)+db(t.answers||[],Zc)+db(t.authorities||[],Zc)+db(t.additionals||[],Zc)}};jo.encode.bytes=0;jo.decode.bytes=0;function R5(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 B5={encode:function(t,e,r){return e=jo.encode(R5(t,"query"),e,r),B5.encode.bytes=jo.encode.bytes,e},decode:function(t,e){let r=jo.decode(t,e);return B5.decode.bytes=jo.decode.bytes,r.questions&&(r.question=r.questions[0],delete r.questions),r},encodingLength:function(t){return jo.encodingLength(R5(t,"query"))}};B5.encode.bytes=0;B5.decode.bytes=0;var M5={encode:function(t,e,r){return e=jo.encode(R5(t,"response"),e,r),M5.encode.bytes=jo.encode.bytes,e},decode:function(t,e){let r=jo.decode(t,e);return M5.decode.bytes=jo.decode.bytes,r.questions&&(r.question=r.questions[0],delete r.questions),r},encodingLength:function(t){return jo.encodingLength(R5(t,"response"))}};M5.encode.bytes=0;M5.decode.bytes=0;var s0=jo.encode,fb=jo.decode,y3e=jo.encodingLength;function KW(t){let e=s0(t),r=new Uint8Array(2+e.byteLength);return pt(r,e.byteLength),Ia(e,r,2,0,e.length),KW.bytes=r.byteLength,r}KW.bytes=0;function FW(t){let e=ir(t,0);if(t.byteLength<e+2)return null;let r=fb(t.slice(2));return FW.bytes=fb.bytes,r}FW.bytes=0;function db(t,e){let r=0;for(let n=0;n<t.length;n++)r+=e.encodingLength(t[n]);return r}function b_(t,e,r,n){for(let i=0;i<t.length;i++)e.encode(t[i],r,n),n+=e.encode.bytes;return n}function w5(t,e,r,n){for(let i=0;i<t.length;i++)t[i]=e.decode(r,n),n+=e.decode.bytes;return n}h();var zW=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},Xc=class{static getSigningMethod(e){return zW(this,void 0,void 0,function*(){throw new Error("Not implemented: Classes extending DidMethod must implement getSigningMethod()")})}static resolve(e,r){return zW(this,void 0,void 0,function*(){throw new Error("Not implemented: Classes extending DidMethod must implement resolve()")})}};var uo=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},VW=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.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]]);return r},HW="https://diddht.tbddev.org",g3e=0,Pp=7200,O5=";",Js=",",CR;(function(t){t[t.Discoverable=0]="Discoverable",t[t.Organization=1]="Organization",t[t.Government=2]="Government",t[t.Corporation=3]="Corporation",t[t.LocalBusiness=4]="LocalBusiness",t[t.SoftwarePackage=5]="SoftwarePackage",t[t.WebApp=6]="WebApp",t[t.FinancialInstitution=7]="FinancialInstitution"})(CR||(CR={}));var Ys;(function(t){t[t.Ed25519=0]="Ed25519",t[t.secp256k1=1]="secp256k1",t[t.secp256r1=2]="secp256r1",t[t.X25519=3]="X25519"})(Ys||(Ys={}));var $R;(function(t){t.authentication="auth",t.assertionMethod="asm",t.capabilityDelegation="del",t.capabilityInvocation="inv",t.keyAgreement="agm"})($R||($R={}));var GW={Ed25519:Ys.Ed25519,ES256K:Ys.secp256k1,ES256:Ys.secp256r1,"P-256":Ys.secp256r1,secp256k1:Ys.secp256k1,secp256r1:Ys.secp256r1,X25519:Ys.X25519},WW={[Ys.Ed25519]:"Ed25519",[Ys.secp256k1]:"ES256K",[Ys.secp256r1]:"ES256",[Ys.X25519]:"ECDH-ES+A256KW"},Qc=class t extends Xc{static create(){return uo(this,arguments,void 0,function*({keyManager:e=new xr,options:r={}}={}){var n,i,o,s,a,d,u,c,l,m,p;if(!((n=r.verificationMethods)===null||n===void 0)&&n.some(N=>!(N.algorithm in GW)))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 v=yield e.generateKey({algorithm:"Ed25519"}),E=yield e.getPublicKey({keyUri:v}),A=yield co.identityKeyToIdentifier({identityKey:E}),P=Object.assign(Object.assign({id:A},r.alsoKnownAs&&{alsoKnownAs:r.alsoKnownAs}),r.controllers&&{controller:r.controllers}),I=[...(s=r.verificationMethods)!==null&&s!==void 0?s:[]];I?.some(N=>{var K;return((K=N.id)===null||K===void 0?void 0:K.split("#").pop())==="0"})||I.unshift({algorithm:"Ed25519",id:"0",purposes:["authentication","assertionMethod","capabilityDelegation","capabilityInvocation"]});for(let N of I){let K=N.id&&N.id.split("#").pop()==="0"?v:yield e.generateKey({algorithm:N.algorithm}),F=yield e.getPublicKey({keyUri:K}),U=(d=(a=N.id)!==null&&a!==void 0?a:F.kid)!==null&&d!==void 0?d:yield nt({jwk:F});U=`${A}#${Ta(U)}`,(u=P.verificationMethod)!==null&&u!==void 0||(P.verificationMethod=[]),P.verificationMethod.push({id:U,type:"JsonWebKey",controller:(c=N.controller)!==null&&c!==void 0?c:A,publicKeyJwk:F});for(let V of(l=N.purposes)!==null&&l!==void 0?l:[])P[V]||(P[V]=[]),P[V].push(U)}(m=r.services)===null||m===void 0||m.forEach(N=>{var K;(K=P.service)!==null&&K!==void 0||(P.service=[]),N.id=`${A}#${N.id.split("#").pop()}`,P.service.push(N)});let $=new Ki({uri:A,document:P,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 uo(this,arguments,void 0,function*({portableDid:r,keyManager:n=new xr}){var i;let o=rr.parse(r.uri);if(o?.method!==t.methodName)throw new st(Qe.MethodNotSupported,"Method not supported");let s=yield Ki.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 st(Qe.InvalidDidDocument,"DID document must contain an Identity Key");return s})}static getSigningMethod(e){return uo(this,arguments,void 0,function*({didDocument:r,methodId:n="#0"}){var i;let o=rr.parse(r.id);if(o&&o.method!==this.methodName)throw new st(Qe.MethodNotSupported,`Method not supported: ${o.method}`);let s=(i=r.verificationMethod)===null||i===void 0?void 0:i.find(a=>{var d,u;return Ta(a.id)===((d=Ta(n))!==null&&d!==void 0?d:Ta((u=r.assertionMethod)===null||u===void 0?void 0:u[0]))});if(!(s&&s.publicKeyJwk))throw new st(Qe.InternalError,"A verification method intended for signing could not be determined from the DID Document");return s})}static publish(e){return uo(this,arguments,void 0,function*({did:r,gatewayUri:n=HW}){return yield C5.put({did:r,gatewayUri:n})})}static resolve(e){return uo(this,arguments,void 0,function*(r,n={}){var i;let o=(i=n?.gatewayUri)!==null&&i!==void 0?i:HW;try{yield co.identifierToIdentityKey({didUri:r});let{didDocument:s,didDocumentMetadata:a}=yield C5.get({didUri:r,gatewayUri:o});return Object.assign(Object.assign({},Hn),{didDocument:s,didDocumentMetadata:a})}catch(s){if(!(s instanceof st))throw new Error(s);return Object.assign(Object.assign({},Hn),{didResolutionMetadata:Object.assign({error:s.code},s.message&&{errorMessage:s.message})})}})}};Qc.methodName="dht";var C5=class t{static get(e){return uo(this,arguments,void 0,function*({didUri:r,gatewayUri:n}){let i=co.identifierToIdentityKeyBytes({didUri:r}),o=yield t.pkarrGet({gatewayUri:n,publicKeyBytes:i}),s=yield co.parseBep44GetMessage({bep44Message:o}),a=yield t.fromDnsPacket({didUri:r,dnsPacket:s});return a.didDocumentMetadata.versionId=o.seq.toString(),a})}static put(e){return uo(this,arguments,void 0,function*({did:r,gatewayUri:n}){let i=yield t.toDnsPacket({didDocument:r.document,didMetadata:r.metadata,authoritativeGatewayUris:[n]}),o=yield co.createBep44PutMessage({dnsPacket:i,publicKeyBytes:co.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 uo(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 st(Qe.NotFound,`Pkarr record not found for: ${i}`)}catch(u){throw u instanceof st?u:new st(Qe.InternalError,`Failed to fetch Pkarr record: ${u.message}`)}let a=yield s.arrayBuffer();if(!a)throw new st(Qe.NotFound,`Pkarr record not found for: ${i}`);if(a.byteLength<72)throw new st(Qe.InvalidDidDocumentLength,`Pkarr response must be at least 72 bytes but got: ${a.byteLength}`);if(a.byteLength>1072)throw new st(Qe.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 uo(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 st(Qe.InternalError,`Failed to put Pkarr record for identifier ${i}: ${d.message}`)}return a.ok})}static fromDnsPacket(e){return uo(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=co.parseTxtDataToString(c.data);a.alsoKnownAs=m.split(Js);break}case l.startsWith("cnt"):{let m=co.parseTxtDataToString(c.data);a.controller=m.includes(Js)?m.split(Js):m;break}case l.startsWith("k"):{let{id:m,t:p,k:g,c:v,a:E}=co.parseTxtDataToObject(c.data),A=de.base64Url(g).toUint8Array(),P=Ys[Number(p)],I=yield co.keyConverter(P).bytesToPublicKey({publicKeyBytes:A});I.alg=E||WW[Number(p)];let $=l==="k0"?"0":m!==void 0?m:yield nt({jwk:I});(o=a.verificationMethod)!==null&&o!==void 0||(a.verificationMethod=[]);let N=`${r}#${$}`;a.verificationMethod.push({id:N,type:"JsonWebKey",controller:v??r,publicKeyJwk:I}),u.set(l,N);break}case l.startsWith("s"):{let m=co.parseTxtDataToObject(c.data),{id:p,t:g,se:v}=m,E=VW(m,["id","t","se"]),A=v.includes(Js)?v.split(Js):[v],P=Object.fromEntries(Object.entries(E).map(([I,$])=>[I,$.includes(Js)?$.split(Js):$]));(s=a.service)!==null&&s!==void 0||(a.service=[]),a.service.push(Object.assign(Object.assign({},P),{id:`${r}#${p}`,type:g,serviceEndpoint:A}));break}case l.startsWith("typ"):{let{id:m}=co.parseTxtDataToObject(c.data);d.types=m.split(Js).map(p=>Number(p));break}case l.startsWith("did"):{let m=P=>P.split(Js).map(I=>u.get(I)).filter(I=>typeof I=="string"),{auth:p,asm:g,del:v,inv:E,agm:A}=co.parseTxtDataToObject(c.data);p&&(a.authentication=m(p)),g&&(a.assertionMethod=m(g)),v&&(a.capabilityDelegation=m(v)),E&&(a.capabilityInvocation=m(E)),A&&(a.keyAgreement=m(A));break}}}return{didDocument:a,didDocumentMetadata:d,didResolutionMetadata:{}}})}static toDnsPacket(e){return uo(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=[],v=[];if(o!==void 0){let{signature:P,previousDid:I}=o;yield co.validatePreviousDidProof({newDid:r.id,previousDidProof:o}),l.push({type:"TXT",name:"_prv._did.",ttl:Pp,data:`id=${I};s=${P}`})}if(r.alsoKnownAs&&l.push({type:"TXT",name:"_aka._did.",ttl:Pp,data:r.alsoKnownAs.join(Js)}),r.controller){let P=Array.isArray(r.controller)?r.controller.join(Js):r.controller;l.push({type:"TXT",name:"_cnt._did.",ttl:Pp,data:P})}for(let[P,I]of(a=(s=r.verificationMethod)===null||s===void 0?void 0:s.entries())!==null&&a!==void 0?a:[]){let $=`k${P}`;v.push($);let N=I.id.split("#").pop();p.set(N,$);let K=I.publicKeyJwk;if(!(K?.crv&&K.crv in GW))throw new st(Qe.InvalidPublicKeyType,`Verification method '${I.id}' contains an unsupported key type: ${(d=K?.crv)!==null&&d!==void 0?d:"undefined"}`);let F=Ys[K.crv],U=yield co.keyConverter(K.crv).publicKeyToBytes({publicKey:K}),V=de.uint8Array(U).toBase64Url(),L=[`t=${F}`,`k=${V}`];N!=="0"&&(yield nt({jwk:K}))!==N&&L.unshift(`id=${N}`),K.alg!==WW[F]&&L.push(`a=${K.alg}`),I.controller!==r.id&&L.push(`c=${I.controller}`),l.push({type:"TXT",name:`_${$}._did.`,ttl:Pp,data:L.join(O5)})}(u=r.service)===null||u===void 0||u.forEach((P,I)=>{let $=`s${I}`;g.push($);let{id:N,type:K,serviceEndpoint:F}=P,U=VW(P,["id","type","serviceEndpoint"]);N=Ta(N),F=Array.isArray(F)?F.join(","):F;let L=Object.entries(Object.assign({id:N,t:K,se:F},U)).map(([S,k])=>`${S}=${k}`).join(O5),T=co.chunkDataIfNeeded(L);l.push({type:"TXT",name:`_${$}._did.`,ttl:Pp,data:T})});let E=[`v=${g3e}`];if(v.length&&E.push(`vm=${v.join(Js)}`),Object.keys(Zy).forEach(P=>{var I;let $=(I=r[P])===null||I===void 0?void 0:I.map(N=>p.get(N.split("#").pop()));if($){let N=$R[P];E.push(`${N}=${$.join(Js)}`)}}),g.length&&E.push(`svc=${g.join(Js)}`),!((c=n.types)===null||c===void 0)&&c.length){let I=n.types.map($=>typeof $=="string"?CR[$]:$);l.push({type:"TXT",name:"_typ._did.",ttl:Pp,data:`id=${I.join(Js)}`})}l.push({type:"TXT",name:"_did."+t.getUniqueDidSuffix(r.id)+".",ttl:Pp,data:E.join(O5)});for(let P of i||[])m.push({type:"NS",name:"_did."+t.getUniqueDidSuffix(r.id)+".",ttl:Pp,data:P+"."});return{id:0,type:"response",flags:D5,answers:[...l,...m]}})}static getUniqueDidSuffix(e){return e.split(":")[2]}},co=class t{static createBep44PutMessage(e){return uo(this,arguments,void 0,function*({dnsPacket:r,publicKeyBytes:n,signer:i}){let o=Math.ceil(Date.now()/1e3),s=s0(r),a=nb.encode({seq:o,v:s}).subarray(1,-1);if(a.length>1e3)throw new st(Qe.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 uo(this,arguments,void 0,function*({didUri:r}){let n=t.identifierToIdentityKeyBytes({didUri:r});return yield Yt.bytesToPublicKey({publicKeyBytes:n})})}static identifierToIdentityKeyBytes({didUri:e}){let r=rr.parse(e);if(!r)throw new st(Qe.InvalidDid,`Invalid DID URI: ${e}`);if(r.method!==Qc.methodName)throw new st(Qe.MethodNotSupported,`Method not supported: ${r.method}`);let n;try{n=de.base32Z(r.id).toUint8Array()}catch{throw new st(Qe.InvalidPublicKey,"Failed to decode method-specific identifier")}if(n.length!==32)throw new st(Qe.InvalidPublicKeyLength,`Invalid public key length: ${n.length}`);return n}static identityKeyToIdentifier(e){return uo(this,arguments,void 0,function*({identityKey:r}){let n=yield Yt.publicKeyToBytes({publicKey:r}),i=de.uint8Array(n).toBase32Z();return`did:${Qc.methodName}:${i}`})}static keyConverter(e){let n={Ed25519:Yt,"P-256":{publicKeyToBytes:i=>uo(this,[i],void 0,function*({publicKey:o}){let s=yield Dr.publicKeyToBytes({publicKey:o});return yield Dr.compressPublicKey({publicKeyBytes:s})}),bytesToPublicKey:Dr.bytesToPublicKey,privateKeyToBytes:Dr.privateKeyToBytes,bytesToPrivateKey:Dr.bytesToPrivateKey},secp256k1:{publicKeyToBytes:i=>uo(this,[i],void 0,function*({publicKey:o}){let s=yield _r.publicKeyToBytes({publicKey:o});return yield _r.compressPublicKey({publicKeyBytes:s})}),bytesToPublicKey:_r.bytesToPublicKey,privateKeyToBytes:_r.privateKeyToBytes,bytesToPrivateKey:_r.bytesToPrivateKey},X25519:ol}[e];if(!n)throw new st(Qe.InvalidPublicKeyType,`Unsupported curve: ${e}`);return n}static parseBep44GetMessage(e){return uo(this,arguments,void 0,function*({bep44Message:r}){let n=yield Yt.bytesToPublicKey({publicKeyBytes:r.k}),i=nb.encode({seq:r.seq,v:r.v}).subarray(1,-1);if(!(yield Yt.verify({key:n,signature:r.sig,data:i})))throw new st(Qe.InvalidSignature,"Invalid signature for DHT BEP44 message");return fb(r.v)})}static parseTxtDataToObject(e){return this.parseTxtDataToString(e).split(O5).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 st(Qe.InternalError,"Pkarr returned DNS TXT record with invalid data type")}static validatePreviousDidProof(e){return uo(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 Yt.verify({key:i,data:o,signature:s})))throw new st(Qe.InvalidPreviousDidProof,"The previous DID proof is invalid.")})}static chunkDataIfNeeded(e){if(e.length<=255)return e;let r=[];for(let n=0;n<e.length;n+=255)r.push(e.slice(n,n+255));return r}};h();h();h();h();h();var Dn={DeltaExceedsMaximumSize:"DeltaExceedsMaximumSize",DidDocumentPublicKeyIdDuplicated:"DidDocumentPublicKeyIdDuplicated",DidDocumentPublicKeyMissingOrIncorrectType:"DidDocumentPublicKeyMissingOrIncorrectType",DidDocumentServiceIdDuplicated:"DidDocumentServiceIdDuplicated",DidSuffixIncorrectLength:"DidSuffixIncorrectLength",EncodedStringIncorrectEncoding:"EncodedStringIncorrectEncoding",IdNotUsingBase64UrlCharacterSet:"IdNotUsingBase64UrlCharacterSet",IdTooLong:"IdTooLong",JwkEs256kMissingOrInvalidCrv:"JwkEs256kMissingOrInvalidCrv",JwkEs256kMissingOrInvalidKty:"JwkEs256kMissingOrInvalidKty",JwkEs256kHasIncorrectLengthOfX:"JwkEs256kHasIncorrectLengthOfX",JwkEs256kHasIncorrectLengthOfY:"JwkEs256kHasIncorrectLengthOfY",JwkEs256kHasIncorrectLengthOfD:"JwkEs256kHasIncorrectLengthOfD",MultihashStringNotAMultihash:"MultihashStringNotAMultihash",MultihashUnsupportedHashAlgorithm:"MultihashUnsupportedHashAlgorithm",PublicKeyJwkEs256kHasUnexpectedProperty:"PublicKeyJwkEs256kHasUnexpectedProperty",PublicKeyPurposeDuplicated:"PublicKeyPurposeDuplicated",ServiceEndpointCannotBeAnArray:"ServiceEndpointCannotBeAnArray",ServiceEndpointStringNotValidUri:"ServiceEndpointStringNotValidUri",ServiceTypeTooLong:"ServiceTypeTooLong"};h();var un=class extends Error{constructor(e,r){super(`${e}: ${r}`),this.code=e,Object.setPrototypeOf(this,new.target.prototype)}};var LR={};Fr(LR,{base64:()=>E3e,base64pad:()=>S3e,base64url:()=>pb,base64urlpad:()=>A3e});h();h();h();function v3e(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var i=0;i<t.length;i++){var o=t.charAt(i),s=o.charCodeAt(0);if(r[s]!==255)throw new TypeError(o+" is ambiguous");r[s]=i}var a=t.length,d=t.charAt(0),u=Math.log(a)/Math.log(256),c=Math.log(256)/Math.log(a);function l(g){if(g instanceof Uint8Array||(ArrayBuffer.isView(g)?g=new Uint8Array(g.buffer,g.byteOffset,g.byteLength):Array.isArray(g)&&(g=Uint8Array.from(g))),!(g instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(g.length===0)return"";for(var v=0,E=0,A=0,P=g.length;A!==P&&g[A]===0;)A++,v++;for(var I=(P-A)*c+1>>>0,$=new Uint8Array(I);A!==P;){for(var N=g[A],K=0,F=I-1;(N!==0||K<E)&&F!==-1;F--,K++)N+=256*$[F]>>>0,$[F]=N%a>>>0,N=N/a>>>0;if(N!==0)throw new Error("Non-zero carry");E=K,A++}for(var U=I-E;U!==I&&$[U]===0;)U++;for(var V=d.repeat(v);U<I;++U)V+=t.charAt($[U]);return V}function m(g){if(typeof g!="string")throw new TypeError("Expected String");if(g.length===0)return new Uint8Array;var v=0;if(g[v]!==" "){for(var E=0,A=0;g[v]===d;)E++,v++;for(var P=(g.length-v)*u+1>>>0,I=new Uint8Array(P);g[v];){var $=r[g.charCodeAt(v)];if($===255)return;for(var N=0,K=P-1;($!==0||N<A)&&K!==-1;K--,N++)$+=a*I[K]>>>0,I[K]=$%256>>>0,$=$/256>>>0;if($!==0)throw new Error("Non-zero carry");A=N,v++}if(g[v]!==" "){for(var F=P-A;F!==P&&I[F]===0;)F++;for(var U=new Uint8Array(E+(P-F)),V=E;F!==P;)U[V++]=I[F++];return U}}}function p(g){var v=m(g);if(v)return v;throw new Error(`Non-${e} character`)}return{encode:l,decodeUnsafe:m,decode:p}}var b3e=v3e,w3e=b3e,JW=w3e;h();var Gst=new Uint8Array(0);var YW=(t,e)=>{if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let r=0;r<t.byteLength;r++)if(t[r]!==e[r])return!1;return!0},Kf=t=>{if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new Error("Unknown type, must be binary type")};var ZW=t=>new TextEncoder().encode(t),XW=t=>new TextDecoder().decode(t);h();var NR=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")}},jR=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 eG(this,e)}},UR=class{constructor(e){this.decoders=e}or(e){return eG(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`)}},eG=(t,e)=>new UR({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}}),qR=class{constructor(e,r,n,i){this.name=e,this.prefix=r,this.baseEncode=n,this.baseDecode=i,this.encoder=new NR(e,r,n),this.decoder=new jR(e,r,i)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},hb=({name:t,prefix:e,encode:r,decode:n})=>new qR(t,e,r,n),kp=({prefix:t,name:e,alphabet:r})=>{let{encode:n,decode:i}=JW(r,e);return hb({prefix:t,name:e,encode:n,decode:o=>Kf(i(o))})},_3e=(t,e,r,n)=>{let i={};for(let c=0;c<e.length;++c)i[e[c]]=c;let o=t.length;for(;t[o-1]==="=";)--o;let s=new Uint8Array(o*r/8|0),a=0,d=0,u=0;for(let c=0;c<o;++c){let l=i[t[c]];if(l===void 0)throw new SyntaxError(`Non-${n} character`);d=d<<r|l,a+=r,a>=8&&(a-=8,s[u++]=255&d>>a)}if(a>=r||255&d<<8-a)throw new SyntaxError("Unexpected end of data");return s},x3e=(t,e,r)=>{let n=e[e.length-1]==="=",i=(1<<r)-1,o="",s=0,a=0;for(let d=0;d<t.length;++d)for(a=a<<8|t[d],s+=8;s>r;)s-=r,o+=e[i&a>>s];if(s&&(o+=e[i&a<<r-s]),n)for(;o.length*r&7;)o+="=";return o},oi=({name:t,prefix:e,bitsPerChar:r,alphabet:n})=>hb({prefix:e,name:t,encode(i){return x3e(i,n,r)},decode(i){return _3e(i,n,r,t)}});var E3e=oi({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),S3e=oi({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),pb=oi({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),A3e=oi({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Pa=class t{static encode(e){return pb.baseEncode(e)}static decodeAsBytes(e,r){if(!t.isBase64UrlString(e))throw new un(Dn.EncodedStringIncorrectEncoding,`Given ${r} must be base64url string.`);return pb.baseDecode(e)}static decodeAsString(e,r){let n=t.decodeAsBytes(e,r);return t.bytesToString(n)}static isBase64UrlString(e){return/^[A-Za-z0-9_-]+$/.test(e)}static stringToBytes(e){return new TextEncoder().encode(e)}static bytesToString(e){return new TextDecoder().decode(e)}};h();var lG=qt(KR(),1);h();h();var FR;(function(t){t.Public="public",t.Private="private"})(FR||(FR={}));var tc=FR;var zi=class{static validateEs256kOperationKey(e,r){let n=new Set(["kty","crv","x","y"]);r===tc.Private&&n.add("d");for(let i in e)if(!n.has(i))throw new un(Dn.PublicKeyJwkEs256kHasUnexpectedProperty,`SECP256K1 JWK key has unexpected property '${i}'.`);if(e.crv!=="secp256k1")throw new un(Dn.JwkEs256kMissingOrInvalidCrv,`SECP256K1 JWK 'crv' property must be 'secp256k1' but got '${e.crv}.'`);if(e.kty!=="EC")throw new un(Dn.JwkEs256kMissingOrInvalidKty,`SECP256K1 JWK 'kty' property must be 'EC' but got '${e.kty}.'`);if(e.x.length!==43)throw new un(Dn.JwkEs256kHasIncorrectLengthOfX,"SECP256K1 JWK 'x' property must be 43 bytes.");if(e.y.length!==43)throw new un(Dn.JwkEs256kHasIncorrectLengthOfY,"SECP256K1 JWK 'y' property must be 43 bytes.");if(r===tc.Private&&(e.d===void 0||e.d.length!==43))throw new un(Dn.JwkEs256kHasIncorrectLengthOfD,"SECP256K1 JWK 'd' property must be 43 bytes.")}static validateId(e){if(e.length>50)throw new un(Dn.IdTooLong,`Key ID length ${e.length} exceed max allowed length of 50.`);if(!Pa.isBase64UrlString(e))throw new un(Dn.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 un(Dn.PublicKeyPurposeDuplicated,`Public key purpose '${n}' already specified.`);r.add(n)}}};h();var w_=class{};w_.hashAlgorithmInMultihashCode=18;w_.maxCanonicalizedDeltaSizeInBytes=1e3;var Zs=w_;h();var iG=qt(nG(),1);var Jd=class t{static canonicalizeAsBytes(e){let r=t.removeAllUndefinedProperties(e),n=iG.default(r);return Pa.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();h();h();h();var T3e=aG,oG=128,I3e=127,P3e=~I3e,k3e=Math.pow(2,31);function aG(t,e,r){e=e||[],r=r||0;for(var n=r;t>=k3e;)e[r++]=t&255|oG,t/=128;for(;t&P3e;)e[r++]=t&255|oG,t>>>=7;return e[r]=t|0,aG.bytes=r-n+1,e}var R3e=zR,B3e=128,sG=127;function zR(t,n){var r=0,n=n||0,i=0,o=n,s,a=t.length;do{if(o>=a)throw zR.bytes=0,new RangeError("Could not decode varint");s=t[o++],r+=i<28?(s&sG)<<i:(s&sG)*Math.pow(2,i),i+=7}while(s>=B3e);return zR.bytes=o-n,r}var M3e=Math.pow(2,7),D3e=Math.pow(2,14),O3e=Math.pow(2,21),C3e=Math.pow(2,28),$3e=Math.pow(2,35),N3e=Math.pow(2,42),j3e=Math.pow(2,49),U3e=Math.pow(2,56),q3e=Math.pow(2,63),L3e=function(t){return t<M3e?1:t<D3e?2:t<O3e?3:t<C3e?4:t<$3e?5:t<N3e?6:t<j3e?7:t<U3e?8:t<q3e?9:10},K3e={encode:T3e,decode:R3e,encodingLength:L3e},F3e=K3e,__=F3e;var x_=(t,e=0)=>[__.decode(t,e),__.decode.bytes],mb=(t,e,r=0)=>(__.encode(t,e,r),e),yb=t=>__.encodingLength(t);var a0=(t,e)=>{let r=e.byteLength,n=yb(t),i=n+yb(r),o=new Uint8Array(i+r);return mb(t,o,0),mb(r,o,n),o.set(e,i),new gb(t,r,e,o)},j5=t=>{let e=Kf(t),[r,n]=x_(e),[i,o]=x_(e.subarray(n)),s=e.subarray(n+o);if(s.byteLength!==i)throw new Error("Incorrect length");return new gb(r,i,s,e)},cG=(t,e)=>{if(t===e)return!0;{let r=e;return t.code===r.code&&t.size===r.size&&r.bytes instanceof Uint8Array&&YW(t.bytes,r.bytes)}},gb=class{constructor(e,r,n,i){this.code=e,this.size=r,this.digest=n,this.bytes=i}};var WR={};Fr(WR,{sha256:()=>S_,sha512:()=>z3e});h();h();var HR=({name:t,code:e,encode:r})=>new VR(t,e,r),VR=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?a0(this.code,r):r.then(n=>a0(this.code,n))}else throw Error("Unknown type, must be binary type")}};var uG=t=>async e=>new Uint8Array(await crypto.subtle.digest(t,e)),S_=HR({name:"sha2-256",code:18,encode:uG("SHA-256")}),z3e=HR({name:"sha2-512",code:19,encode:uG("SHA-512")});var A_=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(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 hash(e,r){return A_(this,void 0,void 0,function*(){let n;switch(r){case 18:n=(yield S_.digest(e)).bytes;break;default:throw new un(Dn.MultihashUnsupportedHashAlgorithm,`Hash algorithm defined in multihash code ${r} is not supported.`)}return n})}static hashAsNonMultihashBytes(e,r){return A_(this,void 0,void 0,function*(){let n;switch(r){case 18:n=yield S_.encode(e);break;default:throw new un(Dn.MultihashUnsupportedHashAlgorithm,`Hash algorithm defined in multihash code ${r} is not supported.`)}return n})}static canonicalizeThenHashThenEncode(e,r){return A_(this,void 0,void 0,function*(){let n=Jd.canonicalizeAsBytes(e);return yield t.hashThenEncode(n,r)})}static canonicalizeThenDoubleHashThenEncode(e,r){return A_(this,void 0,void 0,function*(){let n=Jd.canonicalizeAsBytes(e),i=yield t.hashAsNonMultihashBytes(n,r);return yield t.hashThenEncode(i,r)})}static hashThenEncode(e,r){return A_(this,void 0,void 0,function*(){let n=yield t.hash(e,r);return Pa.encode(n)})}static validateEncodedHashComputedUsingSupportedHashAlgorithm(e,r){let n,i=Pa.decodeAsBytes(e,r);try{n=j5(i)}catch{throw new un(Dn.MultihashStringNotAMultihash,`Given ${r} string '${e}' is not a multihash after decoding.`)}let o=Zs.hashAlgorithmInMultihashCode;if(o!==n.code)throw new un(Dn.MultihashUnsupportedHashAlgorithm,`Given ${r} uses unsupported multihash algorithm with code ${n.code}, should use ${o} or change IonSdkConfig to desired hashing algorithm.`)}};h();var GR;(function(t){t.Create="create",t.Update="update",t.Deactivate="deactivate",t.Recover="recover"})(GR||(GR={}));var T_=GR;h();var JR;(function(t){t.Replace="replace",t.AddPublicKeys="add-public-keys",t.RemovePublicKeys="remove-public-keys",t.AddServices="add-services",t.RemoveServices="remove-services"})(JR||(JR={}));var c0=JR;var U5=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},dl=class t{static createCreateRequest(e){return U5(this,void 0,void 0,function*(){let r=e.recoveryKey,n=e.updateKey,i=e.document.publicKeys,o=e.document.services;zi.validateEs256kOperationKey(r,tc.Public),zi.validateEs256kOperationKey(n,tc.Public),t.validateDidDocumentKeys(i),t.validateServices(o);let s=Zs.hashAlgorithmInMultihashCode,a=[{action:c0.Replace,document:e.document}],d={updateCommitment:yield lo.canonicalizeThenDoubleHashThenEncode(n,s),patches:a};t.validateDeltaSize(d);let c={deltaHash:yield lo.canonicalizeThenHashThenEncode(d,s),recoveryCommitment:yield lo.canonicalizeThenDoubleHashThenEncode(r,s)};return{type:T_.Create,suffixData:c,delta:d}})}static createDeactivateRequest(e){return U5(this,void 0,void 0,function*(){t.validateDidSuffix(e.didSuffix),zi.validateEs256kOperationKey(e.recoveryPublicKey,tc.Public);let r=Zs.hashAlgorithmInMultihashCode,n=yield lo.canonicalizeThenHashThenEncode(e.recoveryPublicKey,r),i={didSuffix:e.didSuffix,recoveryKey:e.recoveryPublicKey},o=yield e.signer.sign({alg:"ES256K"},i);return{type:T_.Deactivate,didSuffix:e.didSuffix,revealValue:n,signedData:o}})}static createRecoverRequest(e){return U5(this,void 0,void 0,function*(){t.validateDidSuffix(e.didSuffix),zi.validateEs256kOperationKey(e.recoveryPublicKey,tc.Public),zi.validateEs256kOperationKey(e.nextRecoveryPublicKey,tc.Public),zi.validateEs256kOperationKey(e.nextUpdatePublicKey,tc.Public),t.validateDidDocumentKeys(e.document.publicKeys),t.validateServices(e.document.services);let r=Zs.hashAlgorithmInMultihashCode,n=yield lo.canonicalizeThenHashThenEncode(e.recoveryPublicKey,r),i=[{action:c0.Replace,document:e.document}],o=yield lo.canonicalizeThenDoubleHashThenEncode(e.nextUpdatePublicKey,r),s={patches:i,updateCommitment:o},a=yield lo.canonicalizeThenHashThenEncode(s,r),u={recoveryCommitment:yield lo.canonicalizeThenDoubleHashThenEncode(e.nextRecoveryPublicKey,r),recoveryKey:e.recoveryPublicKey,deltaHash:a},c=yield e.signer.sign({alg:"ES256K"},u);return{type:T_.Recover,didSuffix:e.didSuffix,revealValue:n,delta:s,signedData:c}})}static createUpdateRequest(e){return U5(this,void 0,void 0,function*(){if(t.validateDidSuffix(e.didSuffix),zi.validateEs256kOperationKey(e.updatePublicKey,tc.Public),zi.validateEs256kOperationKey(e.nextUpdatePublicKey,tc.Public),t.validateServices(e.servicesToAdd),t.validateDidDocumentKeys(e.publicKeysToAdd),e.idsOfServicesToRemove!==void 0)for(let g of e.idsOfServicesToRemove)zi.validateId(g);if(e.idsOfPublicKeysToRemove!==void 0)for(let g of e.idsOfPublicKeysToRemove)zi.validateId(g);let r=[],n=e.servicesToAdd;if(n!==void 0&&n.length>0){let g={action:c0.AddServices,services:n};r.push(g)}let i=e.idsOfServicesToRemove;if(i!==void 0&&i.length>0){let g={action:c0.RemoveServices,ids:i};r.push(g)}let o=e.publicKeysToAdd;if(o!==void 0&&o.length>0){let g={action:c0.AddPublicKeys,publicKeys:o};r.push(g)}let s=e.idsOfPublicKeysToRemove;if(s!==void 0&&s.length>0){let g={action:c0.RemovePublicKeys,ids:s};r.push(g)}let a=Zs.hashAlgorithmInMultihashCode,d=yield lo.canonicalizeThenHashThenEncode(e.updatePublicKey,a),u=yield lo.canonicalizeThenDoubleHashThenEncode(e.nextUpdatePublicKey,a),c={patches:r,updateCommitment:u},l=yield lo.canonicalizeThenHashThenEncode(c,a),m={updateKey:e.updatePublicKey,deltaHash:l},p=yield e.signer.sign({alg:"ES256K"},m);return{type:T_.Update,didSuffix:e.didSuffix,revealValue:d,delta:c,signedData:p}})}static validateDidSuffix(e){lo.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 un(Dn.DidDocumentPublicKeyMissingOrIncorrectType,"DID Document key 'publicKeyJwk' property is not a non-array object.");if(zi.validateId(n.id),r.has(n.id))throw new un(Dn.DidDocumentPublicKeyIdDuplicated,`DID Document key with ID '${n.id}' already exists.`);r.add(n.id),zi.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 un(Dn.DidDocumentServiceIdDuplicated,"Service id has to be unique");r.add(n.id)}}}static validateService(e){zi.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 un(Dn.ServiceTypeTooLong,n)}if(Array.isArray(e.serviceEndpoint)){let n="Service endpoint value cannot be an array.";throw new un(Dn.ServiceEndpointCannotBeAnArray,n)}if(typeof e.serviceEndpoint=="string"&&lG.parse(e.serviceEndpoint).error!==void 0)throw new un(Dn.ServiceEndpointStringNotValidUri,`Service endpoint string '${e.serviceEndpoint}' is not a URI.`)}static validateDeltaSize(e){let r=Jd.canonicalizeAsBytes(e);if(r.length>Zs.maxCanonicalizedDeltaSizeInBytes){let n=`Delta of ${r.length} bytes exceeded limit of ${Zs.maxCanonicalizedDeltaSizeInBytes} bytes.`;throw new un(Dn.DeltaExceedsMaximumSize,n)}}};var fG=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},Rp=class t{static createLongFormDid(e){return fG(this,void 0,void 0,function*(){let r=yield dl.createCreateRequest(e),n=yield t.computeDidUniqueSuffix(r.suffixData),i;Zs.network===void 0||Zs.network==="mainnet"?i=`did:ion:${n}`:i=`did:ion:${Zs.network}:${n}`;let o={suffixData:r.suffixData,delta:r.delta},s=Jd.canonicalizeAsBytes(o),a=Pa.encode(s);return`${i}:${a}`})}static computeDidUniqueSuffix(e){return fG(this,void 0,void 0,function*(){let r=Jd.canonicalizeAsBytes(e),n=yield lo.hash(r,Zs.hashAlgorithmInMultihashCode);return Pa.encode(n)})}};h();h();var Uo=2n**255n-19n,vb=2n**252n+27742317777372353535851937790883648493n,YR=0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51an,ZR=0x6666666666666666666666666666666666666666666666666666666666666658n,q5={a:-1n,d:37095705934669439343138083508754565189542113879843219016388785533085940283555n,p:Uo,n:vb,h:8,Gx:YR,Gy:ZR},Xs=(t="")=>{throw new Error(t)},gG=t=>typeof t=="string",F5=(t,e)=>!(t instanceof Uint8Array)||typeof e=="number"&&e>0&&t.length!==e?Xs("Uint8Array expected"):t,bb=t=>new Uint8Array(t),wb=(t,e)=>F5(gG(t)?QR(t):bb(t),e),mt=(t,e=Uo)=>{let r=t%e;return r>=0n?r:e+r},hG=t=>t instanceof ll?t:Xs("Point expected"),pG,ll=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,mt(e.x*e.y))}static fromHex(e,r=!0){let{d:n}=q5;e=wb(e,32);let i=e.slice();i[31]=e[31]&-129;let o=eB(i);o===0n||(r&&!(0n<o&&o<Uo)&&Xs("bad y coord 1"),!r&&!(0n<o&&o<2n**256n)&&Xs("bad y coord 2"));let s=mt(o*o),a=mt(s-1n),d=mt(n*s+1n),{isValid:u,value:c}=H3e(a,d);u||Xs("bad y coordinate 3");let l=(c&1n)===1n;return(e[31]&128)!==0!==l&&(c=mt(-c)),new t(c,o,1n,mt(c*o))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}equals(e){let{ex:r,ey:n,ez:i}=this,{ex:o,ey:s,ez:a}=hG(e),d=mt(r*a),u=mt(o*i),c=mt(n*a),l=mt(s*i);return d===u&&c===l}is0(){return this.equals(L5)}negate(){return new t(mt(-this.ex),this.ey,this.ez,mt(-this.et))}double(){let{ex:e,ey:r,ez:n}=this,{a:i}=q5,o=mt(e*e),s=mt(r*r),a=mt(2n*mt(n*n)),d=mt(i*o),u=e+r,c=mt(mt(u*u)-o-s),l=d+s,m=l-a,p=d-s,g=mt(c*m),v=mt(l*p),E=mt(c*p),A=mt(m*l);return new t(g,v,A,E)}add(e){let{ex:r,ey:n,ez:i,et:o}=this,{ex:s,ey:a,ez:d,et:u}=hG(e),{a:c,d:l}=q5,m=mt(r*s),p=mt(n*a),g=mt(o*l*u),v=mt(i*d),E=mt((r+n)*(s+a)-m-p),A=mt(v-g),P=mt(v+g),I=mt(p-c*m),$=mt(E*A),N=mt(P*I),K=mt(E*I),F=mt(A*P);return new t($,N,F,K)}mul(e,r=!0){if(e===0n)return r===!0?Xs("cannot multiply by 0"):L5;if(typeof e=="bigint"&&0n<e&&e<vb||Xs("invalid scalar, must be < L"),!r&&this.is0()||e===1n)return this;if(this.equals(Bp))return Z3e(e).p;let n=L5,i=Bp;for(let o=this;e>0n;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(q5.h),!1)}isSmallOrder(){return this.clearCofactor().is0()}isTorsionFree(){let e=this.mul(vb/2n,!1).double();return vb%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=wG(n);return mt(n*i)!==1n&&Xs("invalid inverse"),{x:mt(e*i),y:mt(r*i)}}toRawBytes(){let{x:e,y:r}=this.toAffine(),n=bG(r);return n[31]|=e&1n?128:0,n}toHex(){return XR(this.toRawBytes())}};ll.BASE=new ll(YR,ZR,1n,mt(YR*ZR));ll.ZERO=new ll(0n,1n,1n,0n);var{BASE:Bp,ZERO:L5}=ll,vG=(t,e)=>t.toString(16).padStart(e,"0"),XR=t=>Array.from(t).map(e=>vG(e,2)).join(""),QR=t=>{let e=t.length;(!gG(t)||e%2)&&Xs("hex invalid 1");let r=bb(e/2);for(let n=0;n<r.length;n++){let i=n*2,o=t.slice(i,i+2),s=Number.parseInt(o,16);(Number.isNaN(s)||s<0)&&Xs("hex invalid 2"),r[n]=s}return r},bG=t=>QR(vG(t,32*2)).reverse(),eB=t=>BigInt("0x"+XR(bb(F5(t)).reverse())),P_=(...t)=>{let e=bb(t.reduce((n,i)=>n+F5(i).length,0)),r=0;return t.forEach(n=>{e.set(n,r),r+=n.length}),e},wG=(t,e=Uo)=>{(t===0n||e<=0n)&&Xs("no inverse n="+t+" mod="+e);let r=mt(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?mt(i,e):Xs("no inverse")},ul=(t,e)=>{let r=t;for(;e-- >0n;)r*=r,r%=Uo;return r},V3e=t=>{let r=t*t%Uo*t%Uo,n=ul(r,2n)*r%Uo,i=ul(n,1n)*t%Uo,o=ul(i,5n)*i%Uo,s=ul(o,10n)*o%Uo,a=ul(s,20n)*s%Uo,d=ul(a,40n)*a%Uo,u=ul(d,80n)*d%Uo,c=ul(u,80n)*d%Uo,l=ul(c,10n)*o%Uo;return{pow_p_5_8:ul(l,2n)*t%Uo,b2:r}},mG=19681161376707505956807079304988542015446066515923890162744021073123829784752n,H3e=(t,e)=>{let r=mt(e*e*e),n=mt(r*r*e),i=V3e(t*n).pow_p_5_8,o=mt(t*r*i),s=mt(e*o*o),a=o,d=mt(o*mG),u=s===t,c=s===mt(-t),l=s===mt(-t*mG);return u&&(o=a),(c||l)&&(o=d),(mt(o)&1n)===1n&&(o=mt(-o)),{isValid:u||c,value:o}},K5=t=>mt(eB(t),vb),I_,tB=(...t)=>z5.sha512Async(...t),_G=(...t)=>typeof I_=="function"?I_(...t):Xs("etc.sha512Sync not set"),xG=t=>{let e=t.slice(0,32);e[0]&=248,e[31]&=127,e[31]|=64;let r=t.slice(32,64),n=K5(e),i=Bp.mul(n),o=i.toRawBytes();return{head:e,prefix:r,scalar:n,point:i,pointBytes:o}},rB=t=>tB(wb(t,32)).then(xG),W3e=t=>xG(_G(wb(t,32))),nB=t=>rB(t).then(e=>e.pointBytes);function EG(t,e){return t?tB(e.hashable).then(e.finish):e.finish(_G(e.hashable))}var G3e=(t,e,r)=>{let{pointBytes:n,scalar:i}=t,o=K5(e),s=Bp.mul(o).toRawBytes();return{hashable:P_(s,n,r),finish:u=>{let c=mt(o+K5(u)*i,vb);return F5(P_(s,bG(c)),64)}}},SG=async(t,e)=>{let r=wb(t),n=await rB(e),i=await tB(n.prefix,r);return EG(!0,G3e(n,i,r))};var J3e=(t,e,r)=>{e=wb(e),t=wb(t,64);let n=ll.fromHex(r,!1),i=ll.fromHex(t.slice(0,32),!1),o=eB(t.slice(32,64)),s=Bp.mul(o,!1);return{hashable:P_(i.toRawBytes(),n.toRawBytes(),e),finish:u=>{let c=K5(u);return i.add(n.mul(c,!1)).add(s.negate()).clearCofactor().is0()}}},AG=async(t,e,r)=>EG(!0,J3e(t,e,r));var yG=()=>typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0,z5={bytesToHex:XR,hexToBytes:QR,concatBytes:P_,mod:mt,invert:wG,randomBytes:t=>{let e=yG();return e||Xs("crypto.getRandomValues must be defined"),e.getRandomValues(bb(t))},sha512Async:async(...t)=>{let e=yG();e||Xs("crypto.subtle or etc.sha512Async must be defined");let r=P_(...t);return bb(await e.subtle.digest("SHA-512",r.buffer))},sha512Sync:void 0};Object.defineProperties(z5,{sha512Sync:{configurable:!1,get(){return I_},set(t){I_||(I_=t)}}});var iB={getExtendedPublicKeyAsync:rB,getExtendedPublicKey:W3e,randomPrivateKey:()=>z5.randomBytes(32),precompute(t=8,e=Bp){return e.multiply(3n),e}},d0=8,Y3e=()=>{let t=[],e=256/d0+1,r=Bp,n=r;for(let i=0;i<e;i++){n=r,t.push(n);for(let o=1;o<2**(d0-1);o++)n=n.add(r),t.push(n);r=n.double()}return t},Z3e=t=>{let e=pG||(pG=Y3e()),r=(c,l)=>{let m=l.negate();return c?m:l},n=L5,i=Bp,o=1+256/d0,s=2**(d0-1),a=BigInt(2**d0-1),d=2**d0,u=BigInt(d0);for(let c=0;c<o;c++){let l=c*s,m=Number(t&a);t>>=u,m>s&&(m-=d,t+=1n);let p=l,g=l+Math.abs(m)-1,v=c%2!==0,E=m<0;m===0?i=i.add(r(v,e[p])):n=n.add(r(E,e[g]))}return{p:n,f:i}};h();var aB=2n**256n,Mp=aB-0x1000003d1n,Vi=aB-0x14551231950b75fc4402da1732fc9bebfn,MG=0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798n,DG=0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8n,OG={p:Mp,n:Vi,a:0n,b:7n,Gx:MG,Gy:DG},ms=32,IG=t=>He(He(t*t)*t+OG.b),ln=(t="")=>{throw new Error(t)},G5=t=>typeof t=="bigint",CG=t=>typeof t=="string",oB=t=>G5(t)&&0n<t&&t<Mp,B_=t=>G5(t)&&0n<t&&t<Vi,$G=(t,e)=>!(t instanceof Uint8Array)||typeof e=="number"&&e>0&&t.length!==e?ln("Uint8Array expected"):t,rc=t=>new Uint8Array(t),zf=(t,e)=>$G(CG(t)?D_(t):rc(t),e),He=(t,e=Mp)=>{let r=t%e;return r>=0n?r:e+r},PG=t=>t instanceof ys?t:ln("Point expected"),kG,ys=class t{constructor(e,r,n){this.px=e,this.py=r,this.pz=n}static fromAffine(e){return new t(e.x,e.y,1n)}static fromHex(e){e=zf(e);let r,n=e[0],i=e.subarray(1),o=H5(i,0,ms),s=e.length;if(s===33&&[2,3].includes(n)){oB(o)||ln("Point hex invalid: x not FE");let a=X3e(IG(o)),d=(a&1n)===1n;(n&1)===1!==d&&(a=He(-a)),r=new t(o,a,1n)}return s===65&&n===4&&(r=new t(o,H5(i,ms,2*ms),1n)),r?r.ok():ln("Point is not on curve")}static fromPrivateKey(e){return Ff.mul(W5(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}=PG(e),d=He(r*a),u=He(o*i),c=He(n*a),l=He(s*i);return d===u&&c===l}negate(){return new t(this.px,He(-this.py),this.pz)}double(){return this.add(this)}add(e){let{px:r,py:n,pz:i}=this,{px:o,py:s,pz:a}=PG(e),{a:d,b:u}=OG,c=0n,l=0n,m=0n,p=He(u*3n),g=He(r*o),v=He(n*s),E=He(i*a),A=He(r+n),P=He(o+s);A=He(A*P),P=He(g+v),A=He(A-P),P=He(r+i);let I=He(o+a);return P=He(P*I),I=He(g+E),P=He(P-I),I=He(n+i),c=He(s+a),I=He(I*c),c=He(v+E),I=He(I-c),m=He(d*P),c=He(p*E),m=He(c+m),c=He(v-m),m=He(v+m),l=He(c*m),v=He(g+g),v=He(v+g),E=He(d*E),P=He(p*P),v=He(v+E),E=He(g-E),E=He(d*E),P=He(P+E),g=He(v*P),l=He(l+g),g=He(I*P),c=He(A*c),c=He(c-g),g=He(A*v),m=He(I*m),m=He(m+g),new t(c,l,m)}mul(e,r=!0){if(!r&&e===0n)return V5;if(B_(e)||ln("invalid scalar"),this.equals(Ff))return nSe(e).p;let n=V5,i=Ff;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(V5))return{x:0n,y:0n};if(n===1n)return{x:e,y:r};let i=C_(n);return He(n*i)!==1n&&ln("invalid inverse"),{x:He(e*i),y:He(r*i)}}assertValidity(){let{x:e,y:r}=this.aff();return(!oB(e)||!oB(r))&&ln("Point invalid: x or y"),He(r*r)===IG(e)?this:ln("Point invalid: not on curve")}multiply(e){return this.mul(e)}aff(){return this.toAffine()}ok(){return this.assertValidity()}toHex(e=!0){let{x:r,y:n}=this.aff();return(e?(n&1n)===0n?"02":"03":"04")+k_(r)+(e?"":k_(n))}toRawBytes(e=!0){return D_(this.toHex(e))}};ys.BASE=new ys(MG,DG,1n);ys.ZERO=new ys(0n,1n,0n);var{BASE:Ff,ZERO:V5}=ys,NG=(t,e)=>t.toString(16).padStart(e,"0"),cB=t=>Array.from(t).map(e=>NG(e,2)).join(""),D_=t=>{let e=t.length;(!CG(t)||e%2)&&ln("hex invalid 1");let r=rc(e/2);for(let n=0;n<r.length;n++){let i=n*2,o=t.slice(i,i+2),s=Number.parseInt(o,16);(Number.isNaN(s)||s<0)&&ln("hex invalid 2"),r[n]=s}return r},O_=t=>BigInt("0x"+(cB(t)||"0")),H5=(t,e,r)=>O_(t.slice(e,r)),J5=t=>G5(t)&&t>=0n&&t<aB?D_(NG(t,2*ms)):ln("bigint expected"),k_=t=>cB(J5(t)),sB=(...t)=>{let e=rc(t.reduce((n,i)=>n+$G(i).length,0)),r=0;return t.forEach(n=>{e.set(n,r),r+=n.length}),e},C_=(t,e=Mp)=>{(t===0n||e<=0n)&&ln("no inverse n="+t+" mod="+e);let r=He(t,e),n=e,i=0n,o=1n,s=1n,a=0n;for(;r!==0n;){let d=n/r,u=n%r,c=i-s*d,l=o-a*d;n=r,r=u,i=s,o=a,s=c,a=l}return n===1n?He(i,e):ln("no inverse")},X3e=t=>{let e=1n;for(let r=t,n=(Mp+1n)/4n;n>0n;n>>=1n)n&1n&&(e=e*r%Mp),r=r*r%Mp;return He(e*e)===t?e:ln("sqrt invalid")},W5=t=>(G5(t)||(t=O_(zf(t,ms))),B_(t)?t:ln("private key out of range")),dB=t=>t>Vi>>1n;function $_(t,e=!0){return ys.fromPrivateKey(t).toRawBytes(e)}var M_=class t{constructor(e,r,n){this.r=e,this.s=r,this.recovery=n,this.assertValidity()}static fromCompact(e){return e=zf(e,64),new t(H5(e,0,ms),H5(e,ms,2*ms))}assertValidity(){return B_(this.r)&&B_(this.s)?this:ln()}addRecoveryBit(e){return new t(this.r,this.s,e)}hasHighS(){return dB(this.s)}recoverPublicKey(e){let{r,s:n,recovery:i}=this;[0,1,2,3].includes(i)||ln("recovery id invalid");let o=uB(zf(e,32)),s=i===2||i===3?r+Vi:r;s>=Mp&&ln("q.x invalid");let a=i&1?"03":"02",d=ys.fromHex(a+k_(s)),u=C_(s,Vi),c=He(-o*u,Vi),l=He(n*u,Vi);return Ff.mulAddQUns(d,c,l)}toCompactRawBytes(){return D_(this.toCompactHex())}toCompactHex(){return k_(this.r)+k_(this.s)}},jG=t=>{let e=t.length*8-256,r=O_(t);return e>0?r>>BigInt(e):r},uB=t=>He(jG(t),Vi),RG=t=>J5(t),BG=()=>typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0,R_,UG={lowS:!0},Q3e={lowS:!0};function eSe(t,e,r=UG){["der","recovered","canonical"].some(l=>l in r)&&ln("sign() legacy options not supported");let{lowS:n}=r;n==null&&(n=!0);let i=uB(zf(t)),o=RG(i),s=W5(e),a=[RG(s),o],d=r.extraEntropy;if(d){d===!0&&(d=Dp.randomBytes(ms));let l=zf(d);l.length!==ms&&ln(),a.push(l)}let u=i,c=l=>{let m=jG(l);if(!B_(m))return;let p=C_(m,Vi),g=Ff.mul(m).aff(),v=He(g.x,Vi);if(v===0n)return;let E=He(p*He(u+He(s*v,Vi),Vi),Vi);if(E===0n)return;let A=E,P=(g.x===v?0:2)|Number(g.y&1n);return n&&dB(E)&&(A=He(-E,Vi),P^=1),new M_(v,A,P)};return{seed:sB(...a),k2sig:c}}function tSe(t){let e=rc(ms),r=rc(ms),n=0,i=()=>{e.fill(1),r.fill(0),n=0},o="drbg: tried 1000 values";if(t){let s=(...u)=>Dp.hmacSha256Async(r,e,...u),a=async(u=rc())=>{r=await s(rc([0]),u),e=await s(),u.length!==0&&(r=await s(rc([1]),u),e=await s())},d=async()=>(n++>=1e3&&ln(o),e=await s(),e);return async(u,c)=>{i(),await a(u);let l;for(;!(l=c(await d()));)await a();return i(),l}}else{let s=(...u)=>{let c=R_;return c||ln("etc.hmacSha256Sync not set"),c(r,e,...u)},a=(u=rc())=>{r=s(rc([0]),u),e=s(),u.length!==0&&(r=s(rc([1]),u),e=s())},d=()=>(n++>=1e3&&ln(o),e=s(),e);return(u,c)=>{i(),a(u);let l;for(;!(l=c(d()));)a();return i(),l}}}async function lB(t,e,r=UG){let{seed:n,k2sig:i}=eSe(t,e,r);return tSe(!0)(n,i)}function qG(t,e,r,n=Q3e){let{lowS:i}=n;i==null&&(i=!0),"strict"in n&&ln("verify() legacy options not supported");let o,s,a,d=t&&typeof t=="object"&&"r"in t;!d&&zf(t).length!==2*ms&&ln("signature must be 64 bytes");try{o=d?new M_(t.r,t.s).assertValidity():M_.fromCompact(t),s=uB(zf(e,ms)),a=r instanceof ys?r.ok():ys.fromHex(r)}catch{return!1}if(!o)return!1;let{r:u,s:c}=o;if(i&&dB(c))return!1;let l;try{let p=C_(c,Vi),g=He(s*p,Vi),v=He(u*p,Vi);l=Ff.mulAddQUns(a,g,v).aff()}catch{return!1}return l?He(l.x,Vi)===u:!1}function LG(t){t=zf(t);let e=ms+8;(t.length<e||t.length>1024)&&ln("expected proper params");let r=He(O_(t),Vi-1n)+1n;return J5(r)}var Dp={hexToBytes:D_,bytesToHex:cB,concatBytes:sB,bytesToNumberBE:O_,numberToBytesBE:J5,mod:He,invert:C_,hmacSha256Async:async(t,...e)=>{let r=BG();if(!r)return ln("etc.hmacSha256Async not set");let n=r.subtle,i=await n.importKey("raw",t,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]);return rc(await n.sign("HMAC",i,sB(...e)))},hmacSha256Sync:R_,hashToPrivateKey:LG,randomBytes:t=>{let e=BG();return e||ln("crypto.getRandomValues must be defined"),e.getRandomValues(rc(t))}},Y5={normPrivateKeyToScalar:W5,isValidPrivateKey:t=>{try{return!!W5(t)}catch{return!1}},randomPrivateKey:()=>LG(Dp.randomBytes(ms+8)),precompute(t=8,e=Ff){return e.multiply(3n),e}};Object.defineProperties(Dp,{hmacSha256Sync:{configurable:!1,get(){return R_},set(t){R_||(R_=t)}}});var u0=8,rSe=()=>{let t=[],e=256/u0+1,r=Ff,n=r;for(let i=0;i<e;i++){n=r,t.push(n);for(let o=1;o<2**(u0-1);o++)n=n.add(r),t.push(n);r=n.double()}return t},nSe=t=>{let e=kG||(kG=rSe()),r=(c,l)=>{let m=l.negate();return c?m:l},n=V5,i=Ff,o=1+256/u0,s=2**(u0-1),a=BigInt(2**u0-1),d=2**u0,u=BigInt(u0);for(let c=0;c<o;c++){let l=c*s,m=Number(t&a);t>>=u,m>s&&(m-=d,t+=1n);let p=l,g=l+Math.abs(m)-1,v=c%2!==0,E=m<0;m===0?i=i.add(r(v,e[p])):n=n.add(r(E,e[g]))}return{p:n,f:i}};h();var KG;(function(t){t.Mainnet="mainnet",t.Testnet="test"})(KG||(KG={}));h();var FG;(function(t){t.Authentication="authentication",t.AssertionMethod="assertionMethod",t.CapabilityInvocation="capabilityInvocation",t.CapabilityDelegation="capabilityDelegation",t.KeyAgreement="keyAgreement"})(FG||(FG={}));h();var Op=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},fl;(function(t){t.Ed25519="Ed25519",t.secp256k1="secp256k1",t.secp256r1="secp256r1",t.X25519="X25519"})(fl||(fl={}));var iSe={Ed25519:fl.Ed25519,ES256K:fl.secp256k1,ES256:fl.secp256r1,"P-256":fl.secp256r1,secp256k1:fl.secp256k1,secp256r1:fl.secp256r1},zG="https://ion.tbd.engineering",hB=class t extends Xc{static create(){return Op(this,arguments,void 0,function*({keyManager:e=new xr,options:r={}}={}){var n,i,o,s,a,d,u;if(!((n=r.verificationMethods)===null||n===void 0)&&n.some(N=>!(N.algorithm in iSe)))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 K=yield e.generateKey({algorithm:N.algorithm}),F=yield e.getPublicKey({keyUri:K});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:fl.secp256k1}),g=yield e.getPublicKey({keyUri:p}),v=yield e.generateKey({algorithm:fl.secp256k1}),E=yield e.getPublicKey({keyUri:v}),A=yield l0.computeLongFormDidUri({recoveryKey:g,updateKey:E,services:(d=r.services)!==null&&d!==void 0?d:[],verificationMethods:m}),{didDocument:P,didResolutionMetadata:I}=yield t.resolve(A,{gatewayUri:r.gatewayUri});if(P===null)throw new Error(`Unable to resolve DID during creation: ${I?.error}`);let $=new Ki({uri:A,document:P,metadata:{published:!1,canonicalId:A.split(":",3).join(":"),recoveryKey:g,updateKey:E},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 Op(this,arguments,void 0,function*({didDocument:r,methodId:n}){var i;let o=rr.parse(r.id);if(o&&o.method!==this.methodName)throw new st(Qe.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 st(Qe.InternalError,"A verification method intended for signing could not be determined from the DID Document");return s})}static import(e){return Op(this,arguments,void 0,function*({portableDid:r,keyManager:n=new xr}){let i=rr.parse(r.uri);if(i?.method!==t.methodName)throw new st(Qe.MethodNotSupported,"Method not supported");return yield Ki.import({portableDid:r,keyManager:n})})}static publish(e){return Op(this,arguments,void 0,function*({did:r,gatewayUri:n=zG}){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:_R({didDocument:r.document,methodId:c.id})})))!==null&&o!==void 0?o:[],d=yield l0.createIonDocument({services:(s=r.document.service)!==null&&s!==void 0?s:[],verificationMethods:a}),u=yield l0.constructCreateRequest({ionDocument:d,recoveryKey:r.metadata.recoveryKey,updateKey:r.metadata.updateKey});try{let c=l0.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:Qe.InternalError,errorMessage:`Failed to publish DID document for: ${r.uri}`}}}})}static resolve(e){return Op(this,arguments,void 0,function*(r,n={}){var i,o;let s=rr.parse(r);if(!s)return Object.assign(Object.assign({},Hn),{didResolutionMetadata:{error:"invalidDid"}});if(s.method!==t.methodName)return Object.assign(Object.assign({},Hn),{didResolutionMetadata:{error:"methodNotSupported"}});let a=(i=n?.gatewayUri)!==null&&i!==void 0?i:zG;try{let d=l0.appendPathToUrl({baseUrl:a,path:`/identifiers/${r}`}),u=yield fetch(d);if(!u.ok)throw new st(Qe.NotFound,`Unable to find DID document for: ${r}`);let{didDocument:c,didDocumentMetadata:l}=yield u.json();return Object.assign(Object.assign(Object.assign({},Hn),c&&{didDocument:c}),{didDocumentMetadata:Object.assign({published:(o=l?.method)===null||o===void 0?void 0:o.published},l)})}catch(d){if(!(d instanceof st))throw new Error(d);return Object.assign(Object.assign({},Hn),{didResolutionMetadata:Object.assign({error:d.code},d.message&&{errorMessage:d.message})})}})}};hB.methodName="ion";var l0=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 Op(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 Rp.createLongFormDid({document:s,recoveryKey:a,updateKey:d})})}static constructCreateRequest(e){return Op(this,arguments,void 0,function*({ionDocument:r,recoveryKey:n,updateKey:i}){return yield dl.createCreateRequest({document:r,recoveryKey:t.normalizeJwk(n),updateKey:t.normalizeJwk(i)})})}static createIonDocument(e){return Op(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 nt({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 Z5=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},Cp=class t extends Xc{static create(){return Z5(this,arguments,void 0,function*({keyManager:e=new xr,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 Ki({uri:l,document:p,metadata:{},keyManager:e})})}static getSigningMethod(e){return Z5(this,arguments,void 0,function*({didDocument:r}){var n;let i=rr.parse(r.id);if(i&&i.method!==this.methodName)throw new st(Qe.MethodNotSupported,`Method not supported: ${i.method}`);let[o]=(n=r.verificationMethod)!==null&&n!==void 0?n:[];if(!(o&&o.publicKeyJwk))throw new st(Qe.InternalError,"A verification method intended for signing could not be determined from the DID Document");return o})}static import(e){return Z5(this,arguments,void 0,function*({portableDid:r,keyManager:n=new xr}){let i=rr.parse(r.uri);if(i?.method!==t.methodName)throw new st(Qe.MethodNotSupported,"Method not supported");let o=yield Ki.import({portableDid:r,keyManager:n});if(o.document.verificationMethod.length!==1)throw new st(Qe.InvalidDidDocument,"DID document must contain exactly one verification method");return o})}static resolve(e,r){return Z5(this,void 0,void 0,function*(){let n=rr.parse(e),i;try{i=de.base64Url(n.id).toObject()}catch{}if(!n||!i)return Object.assign(Object.assign({},Hn),{didResolutionMetadata:{error:"invalidDid"}});if(n.method!==t.methodName)return Object.assign(Object.assign({},Hn),{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({},Hn),{didDocument:o})})}};Cp.methodName="jwk";h();var Yd=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},Vf;(function(t){t.Ed25519="Ed25519",t.secp256k1="secp256k1",t.secp256r1="secp256r1",t.X25519="X25519"})(Vf||(Vf={}));var pB={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"},oSe={Ed25519:Vf.Ed25519,ES256K:Vf.secp256k1,ES256:Vf.secp256r1,"P-256":Vf.secp256r1,secp256k1:Vf.secp256k1,secp256r1:Vf.secp256r1,X25519:Vf.X25519},mB=class t extends Xc{static create(){return Yd(this,arguments,void 0,function*({keyManager:e=new xr,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 ka.publicKeyToMultibaseId({publicKey:u}),l=`did:${t.methodName}:${c}`,p=(yield t.resolve(l,r)).didDocument;return new Ki({uri:l,document:p,metadata:{},keyManager:e})})}static getSigningMethod(e){return Yd(this,arguments,void 0,function*({didDocument:r}){var n;let i=rr.parse(r.id);if(i&&i.method!==this.methodName)throw new st(Qe.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 st(Qe.InternalError,"A verification method intended for signing could not be determined from the DID Document");return s})}static import(e){return Yd(this,arguments,void 0,function*({portableDid:r,keyManager:n=new xr}){let i=rr.parse(r.uri);if(i?.method!==t.methodName)throw new st(Qe.MethodNotSupported,"Method not supported");let o=yield Ki.import({portableDid:r,keyManager:n});if(o.document.verificationMethod.length!==1)throw new st(Qe.InvalidDidDocument,"DID document must contain exactly one verification method");return o})}static resolve(e,r){return Yd(this,void 0,void 0,function*(){try{let n=yield t.createDocument({didUri:e,options:r});return Object.assign(Object.assign({},Hn),{didDocument:n})}catch(n){if(!(n instanceof st))throw new Error(n);return Object.assign(Object.assign({},Hn),{didResolutionMetadata:Object.assign({error:n.code},n.message&&{errorMessage:n.message})})}})}static createDocument(e){return Yd(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=rr.parse(r);if(!u)throw new st(Qe.InvalidDid,`Invalid DID URI: ${r}`);let c=u.id;if(u.method!==t.methodName)throw new st(Qe.MethodNotSupported,`Method not supported: ${u.method}`);if(!t.validateIdentifier(u))throw new st(Qe.InvalidDid,`Invalid DID URI: ${r}`);let l=yield t.createSignatureMethod({didUri:r,multibaseValue:c,options:{enableExperimentalPublicKeyTypes:s,publicKeyFormat:a}});if(d.id=u.uri,d.verificationMethod=[l],d.authentication=[l.id],d.assertionMethod=[l.id],d.capabilityInvocation=[l.id],d.capabilityDelegation=[l.id],o===!0){let g=a==="Ed25519VerificationKey2020"?"X25519KeyAgreementKey2020":"JsonWebKey2020",v=yield this.createEncryptionMethod({didUri:r,multibaseValue:c,options:{enableExperimentalPublicKeyTypes:s,publicKeyFormat:g}});d.verificationMethod.push(v),d.keyAgreement=[v.id]}let m=[i];return wR({didDocument:d}).forEach(g=>{let v=pB[g];m.push(v)}),d["@context"]=m,d})}static createEncryptionMethod(e){return Yd(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=ka.MULTICODEC_PUBLIC_KEY_LENGTH[u];if(c!==l)throw new st(Qe.InvalidPublicKeyLength,`Expected ${c} bytes. Actual: ${l}`);let m=f5({keyBytes:d,multicodecCode:u});a.id=`${r}#${m}`;try{new URL(a.id)}catch{throw new st(Qe.InvalidDidUrl,"Verification Method ID is not a valid DID URL.")}if(!(s in pB))throw new st(Qe.UnsupportedPublicKeyType,`Unsupported format: ${s}`);if(o===!1&&!["Multikey","JsonWebKey2020","X25519KeyAgreementKey2020"].includes(s))throw new st(Qe.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 ka.multicodecToJwk({code:u});a.publicKeyJwk=yield ka.keyConverter(g).bytesToPublicKey({publicKeyBytes:d})}return a})}static createSignatureMethod(e){return Yd(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}=h5({multibaseKeyId:n}),l=d.byteLength,m=ka.MULTICODEC_PUBLIC_KEY_LENGTH[u];if(l!==m)throw new st(Qe.InvalidPublicKeyLength,`Expected ${l} bytes. Actual: ${m}`);let p=!1;switch(c){case"secp256k1-pub":p=yield _r.validatePublicKey({publicKeyBytes:d});break;case"ed25519-pub":p=yield Yt.validatePublicKey({publicKeyBytes:d});break;case"x25519-pub":p=!0;break}if(!p)throw new st(Qe.InvalidPublicKey,"Invalid public key detected.");a.id=`${r}#${n}`;try{new URL(a.id)}catch{throw new st(Qe.InvalidDidUrl,"Verification Method ID is not a valid DID URL.")}if(!(s in pB))throw new st(Qe.UnsupportedPublicKeyType,`Unsupported format: ${s}`);if(o===!1&&!["Multikey","JsonWebKey2020","Ed25519VerificationKey2020"].includes(s))throw new st(Qe.InvalidPublicKeyType,`Specified '${s}' without setting enableExperimentalPublicKeyTypes to true.`);if(a.type=s,a.controller=r,s==="Ed25519VerificationKey2020"&&(a.publicKeyMultibase=n),s==="JsonWebKey2020"){let{crv:v}=yield ka.multicodecToJwk({code:u});a.publicKeyJwk=yield ka.keyConverter(v).bytesToPublicKey({publicKeyBytes:d})}return a})}static deriveEncryptionKey(e){return Yd(this,arguments,void 0,function*({multibaseValue:r}){let n={keyBytes:new Uint8Array,multicodecCode:0},{keyBytes:i,multicodecCode:o}=h5({multibaseKeyId:r});if(o===237){let s=yield ka.keyConverter("Ed25519").bytesToPublicKey({publicKeyBytes:i}),a=yield Yt.convertPublicKeyToX25519({publicKey:s});n={keyBytes:yield ka.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&&Xh(n)==="String"&&n.startsWith("z")}};mB.methodName="key";var ka=class t{static jwkToMulticodec(e){return Yd(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:ii.getCodeFromName({name:o}),name:o}})}static keyCompressor(e){let n={"P-256":Dr.compressPublicKey,secp256k1:_r.compressPublicKey}[e];if(!n)throw new st(Qe.InvalidPublicKeyType,`Unsupported curve: ${e}`);return n}static keyConverter(e){let n={Ed25519:Yt,"P-256":Dr,secp256k1:_r,X25519:ol}[e];if(!n)throw new st(Qe.InvalidPublicKeyType,`Unsupported curve: ${e}`);return n}static multicodecToJwk(e){return Yd(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?ii.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 Yd(this,arguments,void 0,function*({publicKey:r}){var n;if(!(r?.crv&&r.crv in oSe))throw new st(Qe.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 f5({keyBytes:i,multicodecName:o})})}};ka.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"};ka.MULTICODEC_PUBLIC_KEY_LENGTH={231:33,236:32,237:32};ka.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 sSe=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},yB=class t extends Xc{static resolve(e,r){return sSe(this,void 0,void 0,function*(){let n=rr.parse(e);if(!n)return Object.assign(Object.assign({},Hn),{didResolutionMetadata:{error:"invalidDid"}});if(n.method!==t.methodName)return Object.assign(Object.assign({},Hn),{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({},Hn),{didDocument:a})}catch{return Object.assign(Object.assign({},Hn),{didResolutionMetadata:{error:"notFound"}})}})}};yB.methodName="web";h();var WG=qt(h0(),1),GG=qt(gB(),1),fSe=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},p0=class{constructor({db:e,location:r="DATA/DID_RESOLVERCACHE",ttl:n="15m"}={}){this.cache=e??new GG.Level(r),this.ttl=(0,WG.default)(n)}get(e){return fSe(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 JG={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 YG=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},Sb=class{constructor({cache:e,didResolvers:r}){this.didResolvers=new Map,this.cache=e||JG;for(let n of r)this.didResolvers.set(n.methodName,n)}resolve(e,r){return YG(this,void 0,void 0,function*(){let n=rr.parse(e);if(!n)return Object.assign(Object.assign({},Hn),{didResolutionMetadata:{error:Qe.InvalidDid,errorMessage:`Invalid DID URI: ${e}`}});let i=this.didResolvers.get(n.method);if(!i)return Object.assign(Object.assign({},Hn),{didResolutionMetadata:{error:Qe.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 YG(this,void 0,void 0,function*(){let n=rr.parse(e);if(!n)return{dereferencingMetadata:{error:Qe.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:Qe.NotFound},contentStream:null,contentMetadata:{}}})}};h();h();h();h();h();h();var MJ=qt(wJ(),1);h();var bB=new TextEncoder,FSe=new TextDecoder,Ye=class t{static base64UrlToBytes(e){return zs.baseDecode(e)}static base64UrlToObject(e){let r=zs.baseDecode(e);return t.bytesToObject(r)}static bytesToBase64Url(e){return zs.baseEncode(e)}static bytesToString(e){return FSe.decode(e)}static bytesToObject(e){let r=t.bytesToString(e);return JSON.parse(r)}static objectToBytes(e){let r=JSON.stringify(e);return bB.encode(r)}static stringToBase64Url(e){let r=bB.encode(e);return zs.baseEncode(r)}static stringToBytes(e){return bB.encode(e)}};h();h();h();h();var se=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 Q5=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(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 _J(t){if(t.kty!=="OKP"||t.crv!=="Ed25519")throw new se(ne.Ed25519InvalidJwk,"invalid jwk. kty MUST be OKP. crv MUST be Ed25519")}function xJ(t){return{alg:"EdDSA",kty:"OKP",crv:"Ed25519",x:Ye.bytesToBase64Url(t)}}var wB={sign:(t,e)=>Q5(void 0,void 0,void 0,function*(){_J(e);let r=Ye.base64UrlToBytes(e.d);return SG(t,r)}),verify:(t,e,r)=>Q5(void 0,void 0,void 0,function*(){_J(r);let n=Ye.base64UrlToBytes(r.x);return AG(e,t,n)}),generateKeyPair:()=>Q5(void 0,void 0,void 0,function*(){let t=iB.randomPrivateKey(),e=yield nB(t),r=Ye.bytesToBase64Url(t),n=xJ(e),i=Object.assign(Object.assign({},n),{d:r});return{publicJwk:n,privateJwk:i}}),publicKeyToJwk:t=>Q5(void 0,void 0,void 0,function*(){return xJ(t)})};h();h();var EJ=t=>async e=>new Uint8Array(await crypto.subtle.digest(t,e)),gs=Ck({name:"sha2-256",code:18,encode:EJ("SHA-256")}),Iut=Ck({name:"sha2-512",code:19,encode:EJ("SHA-512")});var $p=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},zSe=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.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]]);return r},Ci=class t{static validateKey(e){if(e.kty!=="EC"||e.crv!=="secp256k1")throw new se(ne.Secp256k1KeyNotValid,"Invalid SECP256K1 JWK: `kty` MUST be `EC`. `crv` MUST be `secp256k1`")}static publicKeyToJwk(e){return $p(this,void 0,void 0,function*(){let r;e.byteLength===33?r=ys.fromHex(e).toRawBytes(!1):r=e;let n=Ye.bytesToBase64Url(r.subarray(1,33)),i=Ye.bytesToBase64Url(r.subarray(33,65));return{alg:"ES256K",kty:"EC",crv:"secp256k1",x:n,y:i}})}static privateKeyToJwk(e){return $p(this,void 0,void 0,function*(){let r=yield t.getPublicKey(e),n=yield t.publicKeyToJwk(r);return n.d=Ye.bytesToBase64Url(e),n})}static publicJwkToBytes(e){let r=Ye.base64UrlToBytes(e.x),n=Ye.base64UrlToBytes(e.y);return ys.fromAffine({x:Dp.bytesToNumberBE(r),y:Dp.bytesToNumberBE(n)}).toRawBytes(!0)}static privateJwkToBytes(e){return Ye.base64UrlToBytes(e.d)}static sign(e,r){return $p(this,void 0,void 0,function*(){t.validateKey(r);let n=yield gs.encode(e),i=t.privateJwkToBytes(r);return(yield lB(n,i)).toCompactRawBytes()})}static verify(e,r,n){return $p(this,void 0,void 0,function*(){t.validateKey(n);let i=t.publicJwkToBytes(n),o=yield gs.encode(e);return qG(r,o,i)})}static generateKeyPair(){return $p(this,void 0,void 0,function*(){let e=Y5.randomPrivateKey(),r=$_(e,!1),n=Ye.bytesToBase64Url(e),i=yield t.publicKeyToJwk(r),o=Object.assign(Object.assign({},i),{d:n});return{publicJwk:i,privateJwk:o}})}static generateKeyPairRaw(){return $p(this,void 0,void 0,function*(){let e=Y5.randomPrivateKey();return{publicKey:$_(e,!0),privateKey:e}})}static getPublicKey(e){return $p(this,void 0,void 0,function*(){return $_(e,!0)})}static getPublicJwk(e){return $p(this,void 0,void 0,function*(){let{d:r}=e;return zSe(e,["d"])})}};h();h();h();h();h();h();function Ab(t){return globalThis.Buffer!=null?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):t}function e8(t=0){return globalThis.Buffer?.allocUnsafe!=null?Ab(globalThis.Buffer.allocUnsafe(t)):new Uint8Array(t)}h();h();h();h();var _B={};Fr(_B,{base10:()=>VSe});h();var VSe=kp({prefix:"9",name:"base10",alphabet:"0123456789"});var xB={};Fr(xB,{base16:()=>HSe,base16upper:()=>WSe});h();var HSe=oi({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),WSe=oi({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var EB={};Fr(EB,{base2:()=>GSe});h();var GSe=oi({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var SB={};Fr(SB,{base256emoji:()=>QSe});h();var SJ=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}"),JSe=SJ.reduce((t,e,r)=>(t[r]=e,t),[]),YSe=SJ.reduce((t,e,r)=>(t[e.codePointAt(0)]=r,t),[]);function ZSe(t){return t.reduce((e,r)=>(e+=JSe[r],e),"")}function XSe(t){let e=[];for(let r of t){let n=YSe[r.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(n)}return new Uint8Array(e)}var QSe=hb({prefix:"\u{1F680}",name:"base256emoji",encode:ZSe,decode:XSe});var AB={};Fr(AB,{base32:()=>Tb,base32hex:()=>n5e,base32hexpad:()=>o5e,base32hexpadupper:()=>s5e,base32hexupper:()=>i5e,base32pad:()=>t5e,base32padupper:()=>r5e,base32upper:()=>e5e,base32z:()=>a5e});h();var Tb=oi({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),e5e=oi({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),t5e=oi({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),r5e=oi({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),n5e=oi({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),i5e=oi({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),o5e=oi({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),s5e=oi({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),a5e=oi({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var TB={};Fr(TB,{base36:()=>c5e,base36upper:()=>d5e});h();var c5e=kp({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),d5e=kp({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var IB={};Fr(IB,{base58btc:()=>hl,base58flickr:()=>u5e});h();var hl=kp({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),u5e=kp({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var PB={};Fr(PB,{base8:()=>l5e});h();var l5e=oi({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var kB={};Fr(kB,{identity:()=>f5e});h();var f5e=hb({prefix:"\0",name:"identity",encode:t=>XW(t),decode:t=>ZW(t)});h();var hlt=new TextEncoder,plt=new TextDecoder;h();var RB={};Fr(RB,{identity:()=>g5e});h();var AJ=0,m5e="identity",TJ=Kf,y5e=t=>a0(AJ,TJ(t)),g5e={code:AJ,name:m5e,encode:TJ,digest:y5e};h();h();h();var IJ=(t,e)=>{let{bytes:r,version:n}=t;switch(n){case 0:return b5e(r,BB(t),e||hl.encoder);default:return w5e(r,BB(t),e||Tb.encoder)}};var PJ=new WeakMap,BB=t=>{let e=PJ.get(t);if(e==null){let r=new Map;return PJ.set(t,r),r}return e},m0=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!==j_)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==_5e)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=a0(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&&cG(e.multihash,n.multihash)}toString(e){return IJ(this,e)}toJSON(){return{"/":IJ(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||kJ(n,i,o.bytes))}else if(r[x5e]===!0){let{version:n,multihash:i,code:o}=r,s=j5(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!==j_)throw new Error(`Version 0 CID must use dag-pb (code: ${j_}) block encoding`);return new t(e,r,n,n.bytes)}case 1:{let i=kJ(e,r,n.bytes);return new t(e,r,n,i)}default:throw new Error("Invalid version")}}static createV0(e){return t.create(0,j_,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=Kf(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 gb(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]=x_(e.subarray(r));return r+=m,l},i=n(),o=j_;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]=v5e(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 BB(o).set(n,e),o}},v5e=(t,e)=>{switch(t[0]){case"Q":{let r=e||hl;return[hl.prefix,r.decode(`${hl.prefix}${t}`)]}case hl.prefix:{let r=e||hl;return[hl.prefix,r.decode(t)]}case Tb.prefix:{let r=e||Tb;return[Tb.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)]}}},b5e=(t,e,r)=>{let{prefix:n}=r;if(n!==hl.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},w5e=(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},j_=112,_5e=18,kJ=(t,e,r)=>{let n=yb(t),i=n+yb(e),o=new Uint8Array(i+r.byteLength);return mb(t,o,0),mb(e,o,n),o.set(r,i),o},x5e=Symbol.for("@ipld/js-cid/CID");h();var MB={...kB,...EB,...PB,..._B,...xB,...AB,...TB,...IB,...LR,...SB},Olt={...WR,...RB};function BJ(t,e,r,n){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:n}}}var RJ=BJ("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),DB=BJ("ascii","a",t=>{let e="a";for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r]);return e},t=>{t=t.substring(1);let e=e8(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),E5e={utf8:RJ,"utf-8":RJ,hex:MB.base16,latin1:DB,ascii:DB,binary:DB,...MB},t8=E5e;function U_(t,e="utf8"){let r=t8[e];if(r==null)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?Ab(globalThis.Buffer.from(t,"utf-8")):r.decoder.decode(`${r.prefix}${t}`)}h();function OB(t,e="utf8"){let r=t8[e];if(r==null)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(t.buffer,t.byteOffset,t.byteLength).toString("utf8"):r.encoder.encode(t).substring(1)}h();var r8=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},S5e={toString:OB,fromString:U_},Np=class t{static validateKey(e){if(e.kty!=="EC"||e.crv!=="P-256")throw new se(ne.Secp256r1KeyNotValid,"Invalid SECP256R1 JWK: `kty` MUST be `EC`. `crv` MUST be `P-256`")}static publicKeyToJwk(e){return r8(this,void 0,void 0,function*(){let r;e.byteLength===33?r=$f.ProjectivePoint.fromHex(e).toRawBytes(!1):r=e;let n=Ye.bytesToBase64Url(r.subarray(1,33)),i=Ye.bytesToBase64Url(r.subarray(33,65));return{alg:"ES256",kty:"EC",crv:"P-256",x:n,y:i}})}static privateJwkToBytes(e){return Ye.base64UrlToBytes(e.d)}static sign(e,r){return r8(this,void 0,void 0,function*(){t.validateKey(r);let n=yield gs.encode(e),i=t.privateJwkToBytes(r);return Promise.resolve($f.sign(n,i).toCompactRawBytes())})}static verify(e,r,n){return r8(this,void 0,void 0,function*(){t.validateKey(n);let i;r.length===64?i=$f.Signature.fromCompact(r):i=$f.Signature.fromDER(r);let o=yield gs.encode(e),s=$f.ProjectivePoint.fromAffine({x:t.bytesToBigInt(Ye.base64UrlToBytes(n.x)),y:t.bytesToBigInt(Ye.base64UrlToBytes(n.y))}).toRawBytes(!1);return $f.verify(i,o,s)})}static generateKeyPair(){return r8(this,void 0,void 0,function*(){let e=$f.utils.randomPrivateKey(),r=Ws.getPublicKey(e,!1),n=Ye.bytesToBase64Url(e),i=yield t.publicKeyToJwk(r),o=Object.assign(Object.assign({},i),{d:n});return{publicJwk:i,privateJwk:o}})}static bytesToBigInt(e){return BigInt("0x"+S5e.toString(e,"base16"))}};var Ib={Ed25519:wB,secp256k1:{sign:Ci.sign,verify:Ci.verify,generateKeyPair:Ci.generateKeyPair,publicKeyToJwk:Ci.publicKeyToJwk},"P-256":{sign:Np.sign,verify:Np.verify,generateKeyPair:Np.generateKeyPair,publicKeyToJwk:Np.publicKeyToJwk}};var A5e=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},Pb=class{constructor(e){var r,n;if(e.keyId===void 0&&e.privateJwk.kid===void 0)throw new se(ne.PrivateKeySignerUnableToDeduceKeyId,"Unable to deduce the key ID");if(e.algorithm===void 0&&e.privateJwk.alg===void 0)throw new se(ne.PrivateKeySignerUnableToDeduceAlgorithm,"Unable to deduce the signature algorithm");if(this.keyId=(r=e.keyId)!==null&&r!==void 0?r:e.privateJwk.kid,this.algorithm=(n=e.algorithm)!==null&&n!==void 0?n:e.privateJwk.alg,this.privateJwk=e.privateJwk,this.signatureAlgorithm=Ib[e.privateJwk.crv],!this.signatureAlgorithm)throw new se(ne.PrivateKeySignerUnsupportedCurve,`Unsupported crv ${e.privateJwk.crv}, crv must be one of ${Object.keys(Ib)}`)}sign(e){return A5e(this,void 0,void 0,function*(){return yield this.signatureAlgorithm.sign(e,this.privateJwk)})}};var T5e=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},en=class t{static getKid(e){let{kid:r}=Ye.base64UrlToObject(e.protected);return r}static getSignerDid(e){let r=t.getKid(e);return t.extractDid(r)}static verifySignature(e,r,n){return T5e(this,void 0,void 0,function*(){let i=Ib[n.crv];if(!i)throw new se(ne.JwsVerifySignatureUnsupportedCrv,`unsupported crv. crv must be one of ${Object.keys(Ib)}`);let o=Ye.stringToBytes(`${r.protected}.${e}`),s=Ye.base64UrlToBytes(r.signature);return yield i.verify(o,s,n)})}static decodePlainObjectPayload(e){let r;try{r=Ye.base64UrlToObject(e.payload)}catch{throw new se(ne.JwsDecodePlainObjectPayloadInvalid,"payload is not a JSON object")}if(!(0,MJ.default)(r))throw new se(ne.JwsDecodePlainObjectPayloadInvalid,"signed payload must be a plain object");return r}static extractDid(e){let[r]=e.split("#");return r}static createSigners(e){return e.map(n=>t.createSigner(n))}static createSigner(e){let r=e.keyPair.privateJwk,n=e.keyId;return new Pb({privateJwk:r,keyId:n})}};h();h();var q_=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,OJ=new Set,CB=typeof D.default=="object"&&D.default?D.default:{},CJ=(t,e,r,n)=>{typeof CB.emitWarning=="function"?CB.emitWarning(t,e,r,n):console.error(`[${r}] ${e}: ${t}`)},n8=globalThis.AbortController,DJ=globalThis.AbortSignal;if(typeof n8>"u"){DJ=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(n,i){this._onabort.push(i)}},n8=class{constructor(){e()}signal=new DJ;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=CB.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",e=()=>{t&&(t=!1,CJ("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 I5e=t=>!OJ.has(t),Oft=Symbol("type"),jp=t=>t&&t===Math.floor(t)&&t>0&&isFinite(t),$J=t=>jp(t)?t<=Math.pow(2,8)?Uint8Array:t<=Math.pow(2,16)?Uint16Array:t<=Math.pow(2,32)?Uint32Array:t<=Number.MAX_SAFE_INTEGER?kb:null:null,kb=class extends Array{constructor(e){super(e),this.fill(0)}},$B=class t{heap;length;static#c=!1;static create(e){let r=$J(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]}},i8=class t{#c;#l;#v;#p;#k;ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#n;#m;#i;#r;#e;#d;#f;#a;#o;#y;#s;#x;#E;#g;#b;#A;#u;static unsafeExposeInternals(e){return{starts:e.#E,ttls:e.#g,sizes:e.#x,keyMap:e.#i,keyList:e.#r,valList:e.#e,next:e.#d,prev:e.#f,get head(){return e.#a},get tail(){return e.#o},free:e.#y,isBackgroundFetch:r=>e.#t(r),backgroundFetch:(r,n,i,o)=>e.#M(r,n,i,o),moveToTail:r=>e.#P(r),indexes:r=>e.#w(r),rindexes:r=>e.#_(r),isStale:r=>e.#h(r)}}get max(){return this.#c}get maxSize(){return this.#l}get calculatedSize(){return this.#m}get size(){return this.#n}get fetchMethod(){return this.#k}get dispose(){return this.#v}get disposeAfter(){return this.#p}constructor(e){let{max:r=0,ttl:n,ttlResolution:i=1,ttlAutopurge:o,updateAgeOnGet:s,updateAgeOnHas:a,allowStale:d,dispose:u,disposeAfter:c,noDisposeOnSet:l,noUpdateTTL:m,maxSize:p=0,maxEntrySize:g=0,sizeCalculation:v,fetchMethod:E,noDeleteOnFetchRejection:A,noDeleteOnStaleGet:P,allowStaleOnFetchRejection:I,allowStaleOnFetchAbort:$,ignoreFetchAbort:N}=e;if(r!==0&&!jp(r))throw new TypeError("max option must be a nonnegative integer");let K=r?$J(r):Array;if(!K)throw new Error("invalid max value: "+r);if(this.#c=r,this.#l=p,this.maxEntrySize=g||this.#l,this.sizeCalculation=v,this.sizeCalculation){if(!this.#l&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!="function")throw new TypeError("sizeCalculation set to non-function")}if(E!==void 0&&typeof E!="function")throw new TypeError("fetchMethod must be a function if specified");if(this.#k=E,this.#A=!!E,this.#i=new Map,this.#r=new Array(r).fill(void 0),this.#e=new Array(r).fill(void 0),this.#d=new K(r),this.#f=new K(r),this.#a=0,this.#o=0,this.#y=$B.create(r),this.#n=0,this.#m=0,typeof u=="function"&&(this.#v=u),typeof c=="function"?(this.#p=c,this.#s=[]):(this.#p=void 0,this.#s=void 0),this.#b=!!this.#v,this.#u=!!this.#p,this.noDisposeOnSet=!!l,this.noUpdateTTL=!!m,this.noDeleteOnFetchRejection=!!A,this.allowStaleOnFetchRejection=!!I,this.allowStaleOnFetchAbort=!!$,this.ignoreFetchAbort=!!N,this.maxEntrySize!==0){if(this.#l!==0&&!jp(this.#l))throw new TypeError("maxSize must be a positive integer if specified");if(!jp(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#j()}if(this.allowStale=!!d,this.noDeleteOnStaleGet=!!P,this.updateAgeOnGet=!!s,this.updateAgeOnHas=!!a,this.ttlResolution=jp(i)||i===0?i:1,this.ttlAutopurge=!!o,this.ttl=n||0,this.ttl){if(!jp(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#D()}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";I5e(F)&&(OJ.add(F),CJ("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}#D(){let e=new kb(this.#c),r=new kb(this.#c);this.#g=e,this.#E=r,this.#O=(o,s,a=q_.now())=>{if(r[o]=s!==0?a:0,e[o]=s,s!==0&&this.ttlAutopurge){let d=setTimeout(()=>{this.#h(o)&&this.delete(this.#r[o])},s+1);d.unref&&d.unref()}},this.#T=o=>{r[o]=e[o]!==0?q_.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=q_.now();if(this.ttlResolution>0){n=o;let s=setTimeout(()=>n=0,this.ttlResolution);s.unref&&s.unref()}return o};this.getRemainingTTL=o=>{let s=this.#i.get(o);if(s===void 0)return 0;let a=e[s],d=r[s];if(a===0||d===0)return 1/0;let u=(n||i())-d;return a-u},this.#h=o=>e[o]!==0&&r[o]!==0&&(n||i())-r[o]>e[o]}#T=()=>{};#S=()=>{};#O=()=>{};#h=()=>!1;#j(){let e=new kb(this.#c);this.#m=0,this.#x=e,this.#I=r=>{this.#m-=e[r],e[r]=0},this.#C=(r,n,i,o)=>{if(this.#t(n))return 0;if(!jp(i))if(o){if(typeof o!="function")throw new TypeError("sizeCalculation must be a function");if(i=o(n,r),!jp(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.#B(!0)}this.#m+=e[r],i&&(i.entrySize=n,i.totalCalculatedSize=this.#m)}}#I=e=>{};#R=(e,r,n)=>{};#C=(e,r,n,i)=>{if(n||i)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#w({allowStale:e=this.allowStale}={}){if(this.#n)for(let r=this.#o;!(!this.#$(r)||((e||!this.#h(r))&&(yield r),r===this.#a));)r=this.#f[r]}*#_({allowStale:e=this.allowStale}={}){if(this.#n)for(let r=this.#a;!(!this.#$(r)||((e||!this.#h(r))&&(yield r),r===this.#o));)r=this.#d[r]}#$(e){return e!==void 0&&this.#i.get(this.#r[e])===e}*entries(){for(let e of this.#w())this.#e[e]!==void 0&&this.#r[e]!==void 0&&!this.#t(this.#e[e])&&(yield[this.#r[e],this.#e[e]])}*rentries(){for(let e of this.#_())this.#e[e]!==void 0&&this.#r[e]!==void 0&&!this.#t(this.#e[e])&&(yield[this.#r[e],this.#e[e]])}*keys(){for(let e of this.#w()){let r=this.#r[e];r!==void 0&&!this.#t(this.#e[e])&&(yield r)}}*rkeys(){for(let e of this.#_()){let r=this.#r[e];r!==void 0&&!this.#t(this.#e[e])&&(yield r)}}*values(){for(let e of this.#w())this.#e[e]!==void 0&&!this.#t(this.#e[e])&&(yield this.#e[e])}*rvalues(){for(let e of this.#_())this.#e[e]!==void 0&&!this.#t(this.#e[e])&&(yield this.#e[e])}[Symbol.iterator](){return this.entries()}find(e,r={}){for(let n of this.#w()){let i=this.#e[n],o=this.#t(i)?i.__staleWhileFetching:i;if(o!==void 0&&e(o,this.#r[n],this))return this.get(this.#r[n],r)}}forEach(e,r=this){for(let n of this.#w()){let i=this.#e[n],o=this.#t(i)?i.__staleWhileFetching:i;o!==void 0&&e.call(r,o,this.#r[n],this)}}rforEach(e,r=this){for(let n of this.#_()){let i=this.#e[n],o=this.#t(i)?i.__staleWhileFetching:i;o!==void 0&&e.call(r,o,this.#r[n],this)}}purgeStale(){let e=!1;for(let r of this.#_({allowStale:!0}))this.#h(r)&&(this.delete(this.#r[r]),e=!0);return e}dump(){let e=[];for(let r of this.#w({allowStale:!0})){let n=this.#r[r],i=this.#e[r],o=this.#t(i)?i.__staleWhileFetching:i;if(o===void 0||n===void 0)continue;let s={value:o};if(this.#g&&this.#E){s.ttl=this.#g[r];let a=q_.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=q_.now()-i}this.set(r,n.value,n)}}set(e,r,n={}){if(r===void 0)return this.delete(e),this;let{ttl:i=this.ttl,start:o,noDisposeOnSet:s=this.noDisposeOnSet,sizeCalculation:a=this.sizeCalculation,status:d}=n,{noUpdateTTL:u=this.noUpdateTTL}=n,c=this.#C(e,r,n.size||0,a);if(this.maxEntrySize&&c>this.maxEntrySize)return d&&(d.set="miss",d.maxEntrySizeExceeded=!0),this.delete(e),this;let l=this.#n===0?void 0:this.#i.get(e);if(l===void 0)l=this.#n===0?this.#o:this.#y.length!==0?this.#y.pop():this.#n===this.#c?this.#B(!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.#P(l);let m=this.#e[l];if(r!==m){if(this.#A&&this.#t(m)?m.__abortController.abort(new Error("replaced")):s||(this.#b&&this.#v?.(m,e,"set"),this.#u&&this.#s?.push([m,e,"set"])),this.#I(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.#D(),this.#g&&(u||this.#O(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.#B(!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)}}}#B(e){let r=this.#a,n=this.#r[r],i=this.#e[r];return this.#A&&this.#t(i)?i.__abortController.abort(new Error("evicted")):(this.#b||this.#u)&&(this.#b&&this.#v?.(i,n,"evict"),this.#u&&this.#s?.push([i,n,"evict"])),this.#I(r),e&&(this.#r[r]=void 0,this.#e[r]=void 0,this.#y.push(r)),this.#n===1?(this.#a=this.#o=0,this.#y.length=0):this.#a=this.#d[r],this.#i.delete(n),this.#n--,r}has(e,r={}){let{updateAgeOnHas:n=this.updateAgeOnHas,status:i}=r,o=this.#i.get(e);if(o!==void 0){let s=this.#e[o];if(this.#t(s)&&s.__staleWhileFetching===void 0)return!1;if(this.#h(o))i&&(i.has="stale",this.#S(i,o));else return n&&this.#T(o),i&&(i.has="hit",this.#S(i,o)),!0}else i&&(i.has="miss");return!1}peek(e,r={}){let{allowStale:n=this.allowStale}=r,i=this.#i.get(e);if(i!==void 0&&(n||!this.#h(i))){let o=this.#e[i];return this.#t(o)?o.__staleWhileFetching:o}}#M(e,r,n,i){let o=r===void 0?void 0:this.#e[r];if(this.#t(o))return o;let s=new n8,{signal:a}=n;a?.addEventListener("abort",()=>s.abort(a.reason),{signal:s.signal});let d={signal:s.signal,options:n,context:i},u=(v,E=!1)=>{let{aborted:A}=s.signal,P=n.ignoreFetchAbort&&v!==void 0;if(n.status&&(A&&!E?(n.status.fetchAborted=!0,n.status.fetchError=s.signal.reason,P&&(n.status.fetchAbortIgnored=!0)):n.status.fetchResolved=!0),A&&!P&&!E)return l(s.signal.reason);let I=p;return this.#e[r]===p&&(v===void 0?I.__staleWhileFetching?this.#e[r]=I.__staleWhileFetching:this.delete(e):(n.status&&(n.status.fetchUpdated=!0),this.set(e,v,d.options))),v},c=v=>(n.status&&(n.status.fetchRejected=!0,n.status.fetchError=v),l(v)),l=v=>{let{aborted:E}=s.signal,A=E&&n.allowStaleOnFetchAbort,P=A||n.allowStaleOnFetchRejection,I=P||n.noDeleteOnFetchRejection,$=p;if(this.#e[r]===p&&(!I||$.__staleWhileFetching===void 0?this.delete(e):A||(this.#e[r]=$.__staleWhileFetching)),P)return n.status&&$.__staleWhileFetching!==void 0&&(n.status.returnedStale=!0),$.__staleWhileFetching;if($.__returned===$)throw v},m=(v,E)=>{let A=this.#k?.(e,o,d);A&&A instanceof Promise&&A.then(P=>v(P),E),s.signal.addEventListener("abort",()=>{(!n.ignoreFetchAbort||n.allowStaleOnFetchAbort)&&(v(),n.allowStaleOnFetchAbort&&(v=P=>u(P,!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 n8}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:v,forceRefresh:E=!1,status:A,signal:P}=r;if(!this.#A)return A&&(A.fetch="get"),this.get(e,{allowStale:n,updateAgeOnGet:i,noDeleteOnStaleGet:o,status:A});let I={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:P},$=this.#i.get(e);if($===void 0){A&&(A.fetch="miss");let N=this.#M(e,$,I,v);return N.__returned=N}else{let N=this.#e[$];if(this.#t(N)){let L=n&&N.__staleWhileFetching!==void 0;return A&&(A.fetch="inflight",L&&(A.returnedStale=!0)),L?N.__staleWhileFetching:N.__returned=N}let K=this.#h($);if(!E&&!K)return A&&(A.fetch="hit"),this.#P($),i&&this.#T($),A&&this.#S(A,$),N;let F=this.#M(e,$,I,v),V=F.__staleWhileFetching!==void 0&&n;return A&&(A.fetch=K?"stale":"refresh",V&&K&&(A.returnedStale=!0)),V?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.#P(a),i&&this.#T(a),d))}else s&&(s.get="miss")}#N(e,r){this.#f[r]=e,this.#d[e]=r}#P(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.#I(n);let i=this.#e[n];this.#t(i)?i.__abortController.abort(new Error("deleted")):(this.#b||this.#u)&&(this.#b&&this.#v?.(i,e,"delete"),this.#u&&this.#s?.push([i,e,"delete"])),this.#i.delete(e),this.#r[n]=void 0,this.#e[n]=void 0,n===this.#o?this.#o=this.#f[n]:n===this.#a?this.#a=this.#d[n]:(this.#d[this.#f[n]]=this.#d[n],this.#f[this.#d[n]]=this.#f[n]),this.#n--,this.#y.push(n)}}if(this.#u&&this.#s?.length){let n=this.#s,i;for(;i=n?.shift();)this.#p?.(...i)}return r}clear(){for(let e of this.#_({allowStale:!0})){let r=this.#e[e];if(this.#t(r))r.__abortController.abort(new Error("deleted"));else{let n=this.#r[e];this.#b&&this.#v?.(r,n,"delete"),this.#u&&this.#s?.push([r,n,"delete"])}}if(this.#i.clear(),this.#e.fill(void 0),this.#r.fill(void 0),this.#g&&this.#E&&(this.#g.fill(0),this.#E.fill(0)),this.#x&&this.#x.fill(0),this.#a=0,this.#o=0,this.#y.length=0,this.#m=0,this.#n=0,this.#u&&this.#s){let e=this.#s,r;for(;r=e?.shift();)this.#p?.(...r)}}};var NJ=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},o8=class{constructor(e){this.timeToLiveInSeconds=e,this.cache=new i8({max:1e5,ttl:e*1e3})}set(e,r){return NJ(this,void 0,void 0,function*(){try{this.cache.set(e,r)}catch{}})}get(e){return NJ(this,void 0,void 0,function*(){return this.cache.get(e)})}};h();var qB={};Fr(qB,{Authorization:()=>P5e,AuthorizationDelegatedGrant:()=>k5e,AuthorizationOwner:()=>M5e,Definitions:()=>F5e,EventsFilter:()=>U5e,EventsGet:()=>q5e,EventsQuery:()=>L5e,EventsSubscribe:()=>K5e,GeneralJwk:()=>z5e,GeneralJws:()=>V5e,GenericSignaturePayload:()=>l8e,JwkVerificationMethod:()=>H5e,MessagesGet:()=>G5e,NumberRangeFilter:()=>J5e,PaginationCursor:()=>Y5e,PermissionGrantData:()=>Z5e,PermissionRequestData:()=>X5e,PermissionRevocationData:()=>Q5e,PermissionsDefinitions:()=>e8e,PermissionsScopes:()=>t8e,ProtocolDefinition:()=>r8e,ProtocolRuleSet:()=>o8e,ProtocolsConfigure:()=>s8e,ProtocolsQuery:()=>a8e,PublicJwk:()=>u8e,RecordsDelete:()=>D5e,RecordsFilter:()=>d8e,RecordsQuery:()=>O5e,RecordsRead:()=>c8e,RecordsSubscribe:()=>C5e,RecordsWrite:()=>$5e,RecordsWriteDataEncoded:()=>N5e,RecordsWriteSignaturePayload:()=>f8e,RecordsWriteUnidentified:()=>j5e,StringRangeFilter:()=>h8e});h();var P5e=qn;var v0=new RegExp("^[A-Za-z0-9_-]+$","u");function rn(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:i=t,dynamicAnchors:o={}}={}){let s=null,a=0,d=rn.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 rn.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(!v0.test(p))return rn.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 rn.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 rn.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 E=p.length;for(let A=0;A<E;A++){let P=p[A],I=a;if(a===I)if(P&&typeof P=="object"&&!Array.isArray(P)){if(P.protected!==void 0){let N=P.protected,K=a;if(a===a)if(typeof N=="string"){if(!v0.test(N))return rn.errors=[{instancePath:e+"/signatures/"+A+"/protected",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 rn.errors=[{instancePath:e+"/signatures/"+A+"/protected",schemaPath:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/base64url/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var l=K===a}else var l=!0;if(l)if(P.signature!==void 0){let N=P.signature,K=a;if(a===a)if(typeof N=="string"){if(!v0.test(N))return rn.errors=[{instancePath:e+"/signatures/"+A+"/signature",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 rn.errors=[{instancePath:e+"/signatures/"+A+"/signature",schemaPath:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/base64url/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var l=K===a}else var l=!0}else return rn.errors=[{instancePath:e+"/signatures/"+A,schemaPath:"#/properties/signatures/items/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var c=I===a;if(!c)break}}}else return rn.errors=[{instancePath:e+"/signatures",schemaPath:"#/properties/signatures/type",keyword:"type",params:{type:"array"},message:"must be array"}],!1;var u=g===a}else var u=!0}}else return rn.errors=[{instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;return rn.errors=s,a===0}rn.evaluated={props:!0,dynamicProps:!1,dynamicItems:!1};function qn(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:i=t,dynamicAnchors:o={}}={}){let s=null,a=0,d=qn.evaluated;if(d.dynamicProps&&(d.props=void 0),d.dynamicItems&&(d.items=void 0),a===0)if(t&&typeof t=="object"&&!Array.isArray(t)){let u=a;for(let c in t)if(c!=="signature"){return qn.errors=[{instancePath:e,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:c},message:"must NOT have additional properties"}],!1;break}u===a&&t.signature!==void 0&&(rn(t.signature,{instancePath:e+"/signature",parentData:t,parentDataProperty:"signature",rootData:i,dynamicAnchors:o})||(s=s===null?rn.errors:s.concat(rn.errors),a=s.length))}else return qn.errors=[{instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;return qn.errors=s,a===0}qn.evaluated={props:!0,dynamicProps:!1,dynamicItems:!1};var k5e=ho;var Up={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://identity.foundation/dwn/json-schemas/records-write-unidentified.json",type:"object",required:["descriptor"],properties:{recordId:{type:"string"},contextId:{type:"string",pattern:"^[a-zA-Z0-9]+(/[a-zA-Z0-9]+)*$"},attestation:{$ref:"https://identity.foundation/dwn/json-schemas/general-jws.json"},authorization:{$ref:"https://identity.foundation/dwn/json-schemas/authorization-owner.json"},encryption:{type:"object",properties:{algorithm:{type:"string",enum:["A256CTR"]},initializationVector:{$ref:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/base64url"},keyEncryption:{type:"array",minItems:1,items:{type:"object",properties:{rootKeyId:{type:"string"},derivationScheme:{type:"string",enum:["dataFormats","protocolContext","protocolPath","schemas"]},derivedPublicKey:{$ref:"https://identity.foundation/dwn/json-schemas/public-jwk.json"},algorithm:{type:"string",enum:["ECIES-ES256K"]},encryptedKey:{$ref:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/base64url"},initializationVector:{$ref:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/base64url"},ephemeralPublicKey:{$ref:"https://identity.foundation/dwn/json-schemas/public-jwk.json"},messageAuthenticationCode:{$ref:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/base64url"}},additionalProperties:!1,required:["rootKeyId","derivationScheme","algorithm","encryptedKey","initializationVector","ephemeralPublicKey","messageAuthenticationCode"]}}},additionalProperties:!1,required:["algorithm","initializationVector","keyEncryption"]},descriptor:{type:"object",properties:{interface:{enum:["Records"],type:"string"},method:{enum:["Write"],type:"string"},recipient:{$ref:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/did"},protocol:{type:"string"},protocolPath:{type:"string",pattern:"^[a-zA-Z]+(/[a-zA-Z]+)*$"},schema:{type:"string"},tags:{type:"object",minProperties:1,maxProperties:10,additionalProperties:{oneOf:[{type:"string"},{type:"number"},{type:"boolean"},{type:"array",minItems:1,maxItems:10,items:{type:"string"}},{type:"array",minItems:1,maxItems:10,items:{type:"number"}}]}},parentId:{type:"string"},dataCid:{type:"string"},dataSize:{type:"number"},dateCreated:{$ref:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/date-time"},messageTimestamp:{$ref:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/date-time"},published:{type:"boolean"},datePublished:{$ref:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/date-time"},dataFormat:{type:"string"}},additionalProperties:!1,required:["interface","method","dataCid","dataSize","dateCreated","messageTimestamp","dataFormat"],dependencies:{parentId:["protocol"]},allOf:[{$comment:"rule defining `published` and `datePublished` relationship",anyOf:[{properties:{published:{type:"boolean",enum:[!0]}},required:["published","datePublished"]},{properties:{published:{type:"boolean",enum:[!1]}},not:{required:["datePublished"]}},{allOf:[{not:{required:["published"]}},{not:{required:["datePublished"]}}]}]}]}},$comment:"rule defining `protocol` and `contextId` relationship",anyOf:[{properties:{descriptor:{type:"object",required:["protocol","protocolPath"]}},required:["contextId"]},{allOf:[{not:{required:["contextId"]}},{properties:{descriptor:{type:"object",not:{required:["protocol"]}}}},{properties:{descriptor:{type:"object",not:{required:["protocolPath"]}}}}]}]};var R5e=new RegExp("^[a-zA-Z0-9]+(/[a-zA-Z0-9]+)*$","u"),b0=new RegExp("^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_.:%-]*)*)(/[^#?]*)?([?][^#]*)?(#.*)?$","u"),B5e=new RegExp("^[a-zA-Z]+(/[a-zA-Z]+)*$","u"),Un=new RegExp("^\\d{4}-[0-1]\\d-[0-3]\\dT(?:[0-2]\\d:[0-5]\\d:[0-5]\\d|23:59:60)\\.\\d{6}Z$","u");var Rb={validate:ed};function ml(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:i=t,dynamicAnchors:o={}}={}){let s=null,a=0,d=ml.evaluated;if(d.dynamicProps&&(d.props=void 0),d.dynamicItems&&(d.items=void 0),a===0)if(t&&typeof t=="object"&&!Array.isArray(t)){let c=a;for(let l in t)if(!(l==="signature"||l==="authorDelegatedGrant"||l==="ownerSignature"||l==="ownerDelegatedGrant")){return ml.errors=[{instancePath:e,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:l},message:"must NOT have additional properties"}],!1;break}if(c===a){let l;if(t.ownerSignature!==void 0&&t.signature===void 0&&(l="signature"))return ml.errors=[{instancePath:e,schemaPath:"#/dependencies",keyword:"dependencies",params:{property:"ownerSignature",missingProperty:l,depsCount:1,deps:"signature"},message:"must have property signature when property ownerSignature is present"}],!1;if(t.signature!==void 0){let m=a;rn(t.signature,{instancePath:e+"/signature",parentData:t,parentDataProperty:"signature",rootData:i,dynamicAnchors:o})||(s=s===null?rn.errors:s.concat(rn.errors),a=s.length);var u=m===a}else var u=!0;if(u){if(t.authorDelegatedGrant!==void 0){let m=a;Rb.validate(t.authorDelegatedGrant,{instancePath:e+"/authorDelegatedGrant",parentData:t,parentDataProperty:"authorDelegatedGrant",rootData:i,dynamicAnchors:o})||(s=s===null?Rb.validate.errors:s.concat(Rb.validate.errors),a=s.length);var u=m===a}else var u=!0;if(u){if(t.ownerSignature!==void 0){let m=a;rn(t.ownerSignature,{instancePath:e+"/ownerSignature",parentData:t,parentDataProperty:"ownerSignature",rootData:i,dynamicAnchors:o})||(s=s===null?rn.errors:s.concat(rn.errors),a=s.length);var u=m===a}else var u=!0;if(u)if(t.ownerDelegatedGrant!==void 0){let m=a;Rb.validate(t.ownerDelegatedGrant,{instancePath:e+"/ownerDelegatedGrant",parentData:t,parentDataProperty:"ownerDelegatedGrant",rootData:i,dynamicAnchors:o})||(s=s===null?Rb.validate.errors:s.concat(Rb.validate.errors),a=s.length);var u=m===a}else var u=!0}}}}else return ml.errors=[{instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;return ml.errors=s,a===0}ml.evaluated={props:!0,dynamicProps:!1,dynamicItems:!1};var ZJ={$id:"https://identity.foundation/dwn/json-schemas/general-jwk.json",$schema:"https://json-schema.org/draft/2020-12/schema",type:"object",required:["kty"],properties:{alg:{type:"string"},kid:{type:"string"},kty:{enum:["EC","RSA","oct","OKP"]},crv:{type:"string"},use:{type:"string"},key_ops:{type:"string"},x5u:{type:"string"},x5c:{type:"string"},x5t:{type:"string"},"x5t#S256":{type:"string"}},oneOf:[{properties:{kty:{const:"EC"},crv:{type:"string"},x:{type:"string"},y:{type:"string"},d:{type:"string"}},required:["crv","x"]},{properties:{kty:{const:"OKP"},crv:{type:"string"},x:{type:"string"},d:{type:"string"}},required:["crv","x"]},{properties:{kty:{const:"RSA"},n:{type:"string"},e:{type:"string"},d:{type:"string"},p:{type:"string"},q:{type:"string"},dp:{type:"string"},dq:{type:"string"},qi:{type:"string"},oth:{type:"object"}},required:["n","e"]},{properties:{kty:{const:"oct"},k:{type:"string"}},required:["k"]}]};function tn(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:i=t,dynamicAnchors:o={}}={}){let s=null,a=0,d=tn.evaluated;d.dynamicProps&&(d.props=void 0),d.dynamicItems&&(d.items=void 0);let u=a,c=a,l=!1,m=null,p=a;if(t&&typeof t=="object"&&!Array.isArray(t)){let f;if(t.crv===void 0&&(f="crv")||t.x===void 0&&(f="x")){let y={instancePath:e,schemaPath:"https://identity.foundation/dwn/json-schemas/general-jwk.json/oneOf/0/required",keyword:"required",params:{missingProperty:f},message:"must have required property '"+f+"'"};s===null?s=[y]:s.push(y),a++}else{if(t.kty!==void 0){let y=a;if(t.kty!=="EC"){let w={instancePath:e+"/kty",schemaPath:"https://identity.foundation/dwn/json-schemas/general-jwk.json/oneOf/0/properties/kty/const",keyword:"const",params:{allowedValue:"EC"},message:"must be equal to constant"};s===null?s=[w]:s.push(w),a++}var g=y===a}else var g=!0;if(g){if(t.crv!==void 0){let y=a;if(typeof t.crv!="string"){let _={instancePath:e+"/crv",schemaPath:"https://identity.foundation/dwn/json-schemas/general-jwk.json/oneOf/0/properties/crv/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[_]:s.push(_),a++}var g=y===a}else var g=!0;if(g){if(t.x!==void 0){let y=a;if(typeof t.x!="string"){let _={instancePath:e+"/x",schemaPath:"https://identity.foundation/dwn/json-schemas/general-jwk.json/oneOf/0/properties/x/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[_]:s.push(_),a++}var g=y===a}else var g=!0;if(g){if(t.y!==void 0){let y=a;if(typeof t.y!="string"){let _={instancePath:e+"/y",schemaPath:"https://identity.foundation/dwn/json-schemas/general-jwk.json/oneOf/0/properties/y/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[_]:s.push(_),a++}var g=y===a}else var g=!0;if(g)if(t.d!==void 0){let y=a;if(typeof t.d!="string"){let _={instancePath:e+"/d",schemaPath:"https://identity.foundation/dwn/json-schemas/general-jwk.json/oneOf/0/properties/d/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[_]:s.push(_),a++}var g=y===a}else var g=!0}}}}}var P=p===a;if(P){l=!0,m=0;var v={};v.kty=!0,v.crv=!0,v.x=!0,v.y=!0,v.d=!0}let E=a;if(t&&typeof t=="object"&&!Array.isArray(t)){let f;if(t.crv===void 0&&(f="crv")||t.x===void 0&&(f="x")){let y={instancePath:e,schemaPath:"https://identity.foundation/dwn/json-schemas/general-jwk.json/oneOf/1/required",keyword:"required",params:{missingProperty:f},message:"must have required property '"+f+"'"};s===null?s=[y]:s.push(y),a++}else{if(t.kty!==void 0){let y=a;if(t.kty!=="OKP"){let w={instancePath:e+"/kty",schemaPath:"https://identity.foundation/dwn/json-schemas/general-jwk.json/oneOf/1/properties/kty/const",keyword:"const",params:{allowedValue:"OKP"},message:"must be equal to constant"};s===null?s=[w]:s.push(w),a++}var A=y===a}else var A=!0;if(A){if(t.crv!==void 0){let y=a;if(typeof t.crv!="string"){let _={instancePath:e+"/crv",schemaPath:"https://identity.foundation/dwn/json-schemas/general-jwk.json/oneOf/1/properties/crv/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[_]:s.push(_),a++}var A=y===a}else var A=!0;if(A){if(t.x!==void 0){let y=a;if(typeof t.x!="string"){let _={instancePath:e+"/x",schemaPath:"https://identity.foundation/dwn/json-schemas/general-jwk.json/oneOf/1/properties/x/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[_]:s.push(_),a++}var A=y===a}else var A=!0;if(A)if(t.d!==void 0){let y=a;if(typeof t.d!="string"){let _={instancePath:e+"/d",schemaPath:"https://identity.foundation/dwn/json-schemas/general-jwk.json/oneOf/1/properties/d/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[_]:s.push(_),a++}var A=y===a}else var A=!0}}}}var P=E===a;if(P&&l)l=!1,m=[m,1];else{P&&(l=!0,m=1,v!==!0&&(v=v||{},v.kty=!0,v.crv=!0,v.x=!0,v.d=!0));let f=a;if(t&&typeof t=="object"&&!Array.isArray(t)){let w;if(t.n===void 0&&(w="n")||t.e===void 0&&(w="e")){let _={instancePath:e,schemaPath:"https://identity.foundation/dwn/json-schemas/general-jwk.json/oneOf/2/required",keyword:"required",params:{missingProperty:w},message:"must have required property '"+w+"'"};s===null?s=[_]:s.push(_),a++}else{if(t.kty!==void 0){let _=a;if(t.kty!=="RSA"){let x={instancePath:e+"/kty",schemaPath:"https://identity.foundation/dwn/json-schemas/general-jwk.json/oneOf/2/properties/kty/const",keyword:"const",params:{allowedValue:"RSA"},message:"must be equal to constant"};s===null?s=[x]:s.push(x),a++}var I=_===a}else var I=!0;if(I){if(t.n!==void 0){let _=a;if(typeof t.n!="string"){let b={instancePath:e+"/n",schemaPath:"https://identity.foundation/dwn/json-schemas/general-jwk.json/oneOf/2/properties/n/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[b]:s.push(b),a++}var I=_===a}else var I=!0;if(I){if(t.e!==void 0){let _=a;if(typeof t.e!="string"){let b={instancePath:e+"/e",schemaPath:"https://identity.foundation/dwn/json-schemas/general-jwk.json/oneOf/2/properties/e/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[b]:s.push(b),a++}var I=_===a}else var I=!0;if(I){if(t.d!==void 0){let _=a;if(typeof t.d!="string"){let b={instancePath:e+"/d",schemaPath:"https://identity.foundation/dwn/json-schemas/general-jwk.json/oneOf/2/properties/d/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[b]:s.push(b),a++}var I=_===a}else var I=!0;if(I){if(t.p!==void 0){let _=a;if(typeof t.p!="string"){let b={instancePath:e+"/p",schemaPath:"https://identity.foundation/dwn/json-schemas/general-jwk.json/oneOf/2/properties/p/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[b]:s.push(b),a++}var I=_===a}else var I=!0;if(I){if(t.q!==void 0){let _=a;if(typeof t.q!="string"){let b={instancePath:e+"/q",schemaPath:"https://identity.foundation/dwn/json-schemas/general-jwk.json/oneOf/2/properties/q/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[b]:s.push(b),a++}var I=_===a}else var I=!0;if(I){if(t.dp!==void 0){let _=a;if(typeof t.dp!="string"){let b={instancePath:e+"/dp",schemaPath:"https://identity.foundation/dwn/json-schemas/general-jwk.json/oneOf/2/properties/dp/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[b]:s.push(b),a++}var I=_===a}else var I=!0;if(I){if(t.dq!==void 0){let _=a;if(typeof t.dq!="string"){let b={instancePath:e+"/dq",schemaPath:"https://identity.foundation/dwn/json-schemas/general-jwk.json/oneOf/2/properties/dq/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[b]:s.push(b),a++}var I=_===a}else var I=!0;if(I){if(t.qi!==void 0){let _=a;if(typeof t.qi!="string"){let b={instancePath:e+"/qi",schemaPath:"https://identity.foundation/dwn/json-schemas/general-jwk.json/oneOf/2/properties/qi/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[b]:s.push(b),a++}var I=_===a}else var I=!0;if(I)if(t.oth!==void 0){let _=t.oth,x=a;if(!(_&&typeof _=="object"&&!Array.isArray(_))){let B={instancePath:e+"/oth",schemaPath:"https://identity.foundation/dwn/json-schemas/general-jwk.json/oneOf/2/properties/oth/type",keyword:"type",params:{type:"object"},message:"must be object"};s===null?s=[B]:s.push(B),a++}var I=x===a}else var I=!0}}}}}}}}}}var P=f===a;if(P&&l)l=!1,m=[m,2];else{P&&(l=!0,m=2,v!==!0&&(v=v||{},v.kty=!0,v.n=!0,v.e=!0,v.d=!0,v.p=!0,v.q=!0,v.dp=!0,v.dq=!0,v.qi=!0,v.oth=!0));let w=a;if(t&&typeof t=="object"&&!Array.isArray(t)){let x;if(t.k===void 0&&(x="k")){let b={instancePath:e,schemaPath:"https://identity.foundation/dwn/json-schemas/general-jwk.json/oneOf/3/required",keyword:"required",params:{missingProperty:x},message:"must have required property '"+x+"'"};s===null?s=[b]:s.push(b),a++}else{if(t.kty!==void 0){let b=a;if(t.kty!=="oct"){let B={instancePath:e+"/kty",schemaPath:"https://identity.foundation/dwn/json-schemas/general-jwk.json/oneOf/3/properties/kty/const",keyword:"const",params:{allowedValue:"oct"},message:"must be equal to constant"};s===null?s=[B]:s.push(B),a++}var $=b===a}else var $=!0;if($)if(t.k!==void 0){let b=a;if(typeof t.k!="string"){let q={instancePath:e+"/k",schemaPath:"https://identity.foundation/dwn/json-schemas/general-jwk.json/oneOf/3/properties/k/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[q]:s.push(q),a++}var $=b===a}else var $=!0}}var P=w===a;P&&l?(l=!1,m=[m,3]):P&&(l=!0,m=3,v!==!0&&(v=v||{},v.kty=!0,v.k=!0))}}if(l)a=c,s!==null&&(c?s.length=c:s=null);else{let f={instancePath:e,schemaPath:"https://identity.foundation/dwn/json-schemas/general-jwk.json/oneOf",keyword:"oneOf",params:{passingSchemas:m},message:"must match exactly one schema in oneOf"};return s===null?s=[f]:s.push(f),a++,tn.errors=s,!1}if(a===u)if(t&&typeof t=="object"&&!Array.isArray(t)){let f;if(t.kty===void 0&&(f="kty"))return tn.errors=[{instancePath:e,schemaPath:"https://identity.foundation/dwn/json-schemas/general-jwk.json/required",keyword:"required",params:{missingProperty:f},message:"must have required property '"+f+"'"}],!1;if(v!==!0&&(v=v||{},v.alg=!0,v.kid=!0,v.kty=!0,v.crv=!0,v.use=!0,v.key_ops=!0,v.x5u=!0,v.x5c=!0,v.x5t=!0,v["x5t#S256"]=!0),t.alg!==void 0){let y=a;if(typeof t.alg!="string")return tn.errors=[{instancePath:e+"/alg",schemaPath:"https://identity.foundation/dwn/json-schemas/general-jwk.json/properties/alg/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var N=y===a}else var N=!0;if(N){if(t.kid!==void 0){let y=a;if(typeof t.kid!="string")return tn.errors=[{instancePath:e+"/kid",schemaPath:"https://identity.foundation/dwn/json-schemas/general-jwk.json/properties/kid/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var N=y===a}else var N=!0;if(N){if(t.kty!==void 0){let y=t.kty,w=a;if(!(y==="EC"||y==="RSA"||y==="oct"||y==="OKP"))return tn.errors=[{instancePath:e+"/kty",schemaPath:"https://identity.foundation/dwn/json-schemas/general-jwk.json/properties/kty/enum",keyword:"enum",params:{allowedValues:ZJ.properties.kty.enum},message:"must be equal to one of the allowed values"}],!1;var N=w===a}else var N=!0;if(N){if(t.crv!==void 0){let y=a;if(typeof t.crv!="string")return tn.errors=[{instancePath:e+"/crv",schemaPath:"https://identity.foundation/dwn/json-schemas/general-jwk.json/properties/crv/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var N=y===a}else var N=!0;if(N){if(t.use!==void 0){let y=a;if(typeof t.use!="string")return tn.errors=[{instancePath:e+"/use",schemaPath:"https://identity.foundation/dwn/json-schemas/general-jwk.json/properties/use/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var N=y===a}else var N=!0;if(N){if(t.key_ops!==void 0){let y=a;if(typeof t.key_ops!="string")return tn.errors=[{instancePath:e+"/key_ops",schemaPath:"https://identity.foundation/dwn/json-schemas/general-jwk.json/properties/key_ops/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var N=y===a}else var N=!0;if(N){if(t.x5u!==void 0){let y=a;if(typeof t.x5u!="string")return tn.errors=[{instancePath:e+"/x5u",schemaPath:"https://identity.foundation/dwn/json-schemas/general-jwk.json/properties/x5u/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var N=y===a}else var N=!0;if(N){if(t.x5c!==void 0){let y=a;if(typeof t.x5c!="string")return tn.errors=[{instancePath:e+"/x5c",schemaPath:"https://identity.foundation/dwn/json-schemas/general-jwk.json/properties/x5c/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var N=y===a}else var N=!0;if(N){if(t.x5t!==void 0){let y=a;if(typeof t.x5t!="string")return tn.errors=[{instancePath:e+"/x5t",schemaPath:"https://identity.foundation/dwn/json-schemas/general-jwk.json/properties/x5t/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var N=y===a}else var N=!0;if(N)if(t["x5t#S256"]!==void 0){let y=a;if(typeof t["x5t#S256"]!="string")return tn.errors=[{instancePath:e+"/x5t#S256",schemaPath:"https://identity.foundation/dwn/json-schemas/general-jwk.json/properties/x5t%23S256/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var N=y===a}else var N=!0}}}}}}}}}else return tn.errors=[{instancePath:e,schemaPath:"https://identity.foundation/dwn/json-schemas/general-jwk.json/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var K=u===a;if(K){let f=a,y=a,w=a,_=!1,x=a,b=a,B=!1,q=a;if(t&&typeof t=="object"&&!Array.isArray(t)){let le;if(t.d===void 0&&(le="d")){let ge={};s===null?s=[ge]:s.push(ge),a++}}var F=q===a;if(B=B||F,B)a=b,s!==null&&(b?s.length=b:s=null);else{let le={};s===null?s=[le]:s.push(le),a++}if(a===x)if(t&&typeof t=="object"&&!Array.isArray(t)){if(t.kty!==void 0&&t.kty!=="EC"){let le={};s===null?s=[le]:s.push(le),a++}}else{let le={};s===null?s=[le]:s.push(le),a++}var S=x===a;if(_=_||S,S){var U={};U.kty=!0}let M=a,j=a,J=!1,Z=a;if(t&&typeof t=="object"&&!Array.isArray(t)){let le;if(t.d===void 0&&(le="d")){let ge={};s===null?s=[ge]:s.push(ge),a++}}var V=Z===a;if(J=J||V,J)a=j,s!==null&&(j?s.length=j:s=null);else{let le={};s===null?s=[le]:s.push(le),a++}if(a===M)if(t&&typeof t=="object"&&!Array.isArray(t)){if(t.kty!==void 0&&t.kty!=="OKP"){let le={};s===null?s=[le]:s.push(le),a++}}else{let le={};s===null?s=[le]:s.push(le),a++}var S=M===a;_=_||S,S&&U!==!0&&(U=U||{},U.kty=!0);let G=a,W=a,X=!1,ee=a;if(t&&typeof t=="object"&&!Array.isArray(t)){let le;if(t.d===void 0&&(le="d")){let ge={};s===null?s=[ge]:s.push(ge),a++}}var L=ee===a;X=X||L;let ue=a;if(t&&typeof t=="object"&&!Array.isArray(t)){let le;if(t.p===void 0&&(le="p")){let ge={};s===null?s=[ge]:s.push(ge),a++}}var L=ue===a;X=X||L;let ae=a;if(t&&typeof t=="object"&&!Array.isArray(t)){let le;if(t.q===void 0&&(le="q")){let ge={};s===null?s=[ge]:s.push(ge),a++}}var L=ae===a;X=X||L;let ce=a;if(t&&typeof t=="object"&&!Array.isArray(t)){let le;if(t.dp===void 0&&(le="dp")){let ge={};s===null?s=[ge]:s.push(ge),a++}}var L=ce===a;X=X||L;let pe=a;if(t&&typeof t=="object"&&!Array.isArray(t)){let le;if(t.dq===void 0&&(le="dq")){let ge={};s===null?s=[ge]:s.push(ge),a++}}var L=pe===a;X=X||L;let xe=a;if(t&&typeof t=="object"&&!Array.isArray(t)){let le;if(t.qi===void 0&&(le="qi")){let ge={};s===null?s=[ge]:s.push(ge),a++}}var L=xe===a;X=X||L;let Ue=a;if(t&&typeof t=="object"&&!Array.isArray(t)){let le;if(t.oth===void 0&&(le="oth")){let ge={};s===null?s=[ge]:s.push(ge),a++}}var L=Ue===a;if(X=X||L,X)a=W,s!==null&&(W?s.length=W:s=null);else{let le={};s===null?s=[le]:s.push(le),a++}if(a===G)if(t&&typeof t=="object"&&!Array.isArray(t)){if(t.kty!==void 0){let le=a;if(t.kty!=="RSA"){let ge={};s===null?s=[ge]:s.push(ge),a++}var T=le===a}else var T=!0;if(T)if(t.oth!==void 0){let le=t.oth,ge=a;if(!(le&&typeof le=="object"&&!Array.isArray(le))){let De={};s===null?s=[De]:s.push(De),a++}var T=ge===a}else var T=!0}else{let le={};s===null?s=[le]:s.push(le),a++}var S=G===a;if(_=_||S,S&&U!==!0&&(U=U||{},U.kty=!0,U.d=!0,U.p=!0,U.q=!0,U.dp=!0,U.dq=!0,U.qi=!0,U.oth=!0),_)a=w,s!==null&&(w?s.length=w:s=null);else{let le={};s===null?s=[le]:s.push(le),a++}var k=y===a;if(k)return tn.errors=[{instancePath:e,schemaPath:"#/not",keyword:"not",params:{},message:"must NOT be valid"}],!1;a=f,s!==null&&(f?s.length=f:s=null)}return tn.errors=s,d.props=v,a===0}tn.evaluated={dynamicProps:!0,dynamicItems:!1};var UB=Object.prototype.hasOwnProperty;function Ke(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:i=t,dynamicAnchors:o={}}={}){let s=null,a=0,d=Ke.evaluated;d.dynamicProps&&(d.props=void 0),d.dynamicItems&&(d.items=void 0);let u=a,c=!1,l=a;if(t&&typeof t=="object"&&!Array.isArray(t)){let M;if(t.contextId===void 0&&(M="contextId")){let j={instancePath:e,schemaPath:"#/anyOf/0/required",keyword:"required",params:{missingProperty:M},message:"must have required property '"+M+"'"};s===null?s=[j]:s.push(j),a++}else if(t.descriptor!==void 0){let j=t.descriptor;if(a===a)if(j&&typeof j=="object"&&!Array.isArray(j)){let Z;if(j.protocol===void 0&&(Z="protocol")||j.protocolPath===void 0&&(Z="protocolPath")){let G={instancePath:e+"/descriptor",schemaPath:"#/anyOf/0/properties/descriptor/required",keyword:"required",params:{missingProperty:Z},message:"must have required property '"+Z+"'"};s===null?s=[G]:s.push(G),a++}}else{let Z={instancePath:e+"/descriptor",schemaPath:"#/anyOf/0/properties/descriptor/type",keyword:"type",params:{type:"object"},message:"must be object"};s===null?s=[Z]:s.push(Z),a++}}}var N=l===a;if(c=c||N,N){var m={};m.descriptor=!0}let p=a,g=a,v=a,E=a;if(t&&typeof t=="object"&&!Array.isArray(t)){let M;if(t.contextId===void 0&&(M="contextId")){let j={};s===null?s=[j]:s.push(j),a++}}var A=E===a;if(A){let M={instancePath:e,schemaPath:"#/anyOf/1/allOf/0/not",keyword:"not",params:{},message:"must NOT be valid"};s===null?s=[M]:s.push(M),a++}else a=v,s!==null&&(v?s.length=v:s=null);var P=g===a;if(P){let M=a;if(t&&typeof t=="object"&&!Array.isArray(t)&&t.descriptor!==void 0){let J=t.descriptor;if(!(J&&typeof J=="object"&&!Array.isArray(J))){let W={instancePath:e+"/descriptor",schemaPath:"#/anyOf/1/allOf/1/properties/descriptor/type",keyword:"type",params:{type:"object"},message:"must be object"};s===null?s=[W]:s.push(W),a++}let Z=a,G=a;if(J&&typeof J=="object"&&!Array.isArray(J)){let W;if(J.protocol===void 0&&(W="protocol")){let X={};s===null?s=[X]:s.push(X),a++}}var I=G===a;if(I){let W={instancePath:e+"/descriptor",schemaPath:"#/anyOf/1/allOf/1/properties/descriptor/not",keyword:"not",params:{},message:"must NOT be valid"};s===null?s=[W]:s.push(W),a++}else a=Z,s!==null&&(Z?s.length=Z:s=null)}var P=M===a;if(P){let J=a;if(t&&typeof t=="object"&&!Array.isArray(t)&&t.descriptor!==void 0){let G=t.descriptor;if(!(G&&typeof G=="object"&&!Array.isArray(G))){let ee={instancePath:e+"/descriptor",schemaPath:"#/anyOf/1/allOf/2/properties/descriptor/type",keyword:"type",params:{type:"object"},message:"must be object"};s===null?s=[ee]:s.push(ee),a++}let W=a,X=a;if(G&&typeof G=="object"&&!Array.isArray(G)){let ee;if(G.protocolPath===void 0&&(ee="protocolPath")){let ue={};s===null?s=[ue]:s.push(ue),a++}}var $=X===a;if($){let ee={instancePath:e+"/descriptor",schemaPath:"#/anyOf/1/allOf/2/properties/descriptor/not",keyword:"not",params:{},message:"must NOT be valid"};s===null?s=[ee]:s.push(ee),a++}else a=W,s!==null&&(W?s.length=W:s=null)}var P=J===a}}var N=p===a;if(c=c||N,N&&m!==!0&&(m=m||{},m.descriptor=!0),c)a=u,s!==null&&(u?s.length=u:s=null);else{let M={instancePath:e,schemaPath:"#/anyOf",keyword:"anyOf",params:{},message:"must match a schema in anyOf"};return s===null?s=[M]:s.push(M),a++,Ke.errors=s,!1}if(a===0)if(t&&typeof t=="object"&&!Array.isArray(t)){let M;if(t.descriptor===void 0&&(M="descriptor"))return Ke.errors=[{instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:M},message:"must have required property '"+M+"'"}],!1;if(m!==!0&&(m=m||{},m.recordId=!0,m.contextId=!0,m.attestation=!0,m.authorization=!0,m.encryption=!0,m.descriptor=!0),t.recordId!==void 0){let j=a;if(typeof t.recordId!="string")return Ke.errors=[{instancePath:e+"/recordId",schemaPath:"#/properties/recordId/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var K=j===a}else var K=!0;if(K){if(t.contextId!==void 0){let j=t.contextId,J=a;if(a===J)if(typeof j=="string"){if(!R5e.test(j))return Ke.errors=[{instancePath:e+"/contextId",schemaPath:"#/properties/contextId/pattern",keyword:"pattern",params:{pattern:"^[a-zA-Z0-9]+(/[a-zA-Z0-9]+)*$"},message:'must match pattern "^[a-zA-Z0-9]+(/[a-zA-Z0-9]+)*$"'}],!1}else return Ke.errors=[{instancePath:e+"/contextId",schemaPath:"#/properties/contextId/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var K=J===a}else var K=!0;if(K){if(t.attestation!==void 0){let j=a;rn(t.attestation,{instancePath:e+"/attestation",parentData:t,parentDataProperty:"attestation",rootData:i,dynamicAnchors:o})||(s=s===null?rn.errors:s.concat(rn.errors),a=s.length);var K=j===a}else var K=!0;if(K){if(t.authorization!==void 0){let j=a;ml(t.authorization,{instancePath:e+"/authorization",parentData:t,parentDataProperty:"authorization",rootData:i,dynamicAnchors:o})||(s=s===null?ml.errors:s.concat(ml.errors),a=s.length);var K=j===a}else var K=!0;if(K){if(t.encryption!==void 0){let j=t.encryption,J=a;if(a===J)if(j&&typeof j=="object"&&!Array.isArray(j)){let G;if(j.algorithm===void 0&&(G="algorithm")||j.initializationVector===void 0&&(G="initializationVector")||j.keyEncryption===void 0&&(G="keyEncryption"))return Ke.errors=[{instancePath:e+"/encryption",schemaPath:"#/properties/encryption/required",keyword:"required",params:{missingProperty:G},message:"must have required property '"+G+"'"}],!1;{let W=a;for(let X in j)if(!(X==="algorithm"||X==="initializationVector"||X==="keyEncryption")){return Ke.errors=[{instancePath:e+"/encryption",schemaPath:"#/properties/encryption/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:X},message:"must NOT have additional properties"}],!1;break}if(W===a){if(j.algorithm!==void 0){let X=j.algorithm,ee=a;if(typeof X!="string")return Ke.errors=[{instancePath:e+"/encryption/algorithm",schemaPath:"#/properties/encryption/properties/algorithm/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;if(X!=="A256CTR")return Ke.errors=[{instancePath:e+"/encryption/algorithm",schemaPath:"#/properties/encryption/properties/algorithm/enum",keyword:"enum",params:{allowedValues:Up.properties.encryption.properties.algorithm.enum},message:"must be equal to one of the allowed values"}],!1;var F=ee===a}else var F=!0;if(F){if(j.initializationVector!==void 0){let X=j.initializationVector,ee=a;if(a===a)if(typeof X=="string"){if(!v0.test(X))return Ke.errors=[{instancePath:e+"/encryption/initializationVector",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 Ke.errors=[{instancePath:e+"/encryption/initializationVector",schemaPath:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/base64url/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var F=ee===a}else var F=!0;if(F)if(j.keyEncryption!==void 0){let X=j.keyEncryption,ee=a;if(a===ee)if(Array.isArray(X)){if(X.length<1)return Ke.errors=[{instancePath:e+"/encryption/keyEncryption",schemaPath:"#/properties/encryption/properties/keyEncryption/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"}],!1;{var U=!0;let ae=X.length;for(let ce=0;ce<ae;ce++){let pe=X[ce],xe=a;if(a===xe)if(pe&&typeof pe=="object"&&!Array.isArray(pe)){let le;if(pe.rootKeyId===void 0&&(le="rootKeyId")||pe.derivationScheme===void 0&&(le="derivationScheme")||pe.algorithm===void 0&&(le="algorithm")||pe.encryptedKey===void 0&&(le="encryptedKey")||pe.initializationVector===void 0&&(le="initializationVector")||pe.ephemeralPublicKey===void 0&&(le="ephemeralPublicKey")||pe.messageAuthenticationCode===void 0&&(le="messageAuthenticationCode"))return Ke.errors=[{instancePath:e+"/encryption/keyEncryption/"+ce,schemaPath:"#/properties/encryption/properties/keyEncryption/items/required",keyword:"required",params:{missingProperty:le},message:"must have required property '"+le+"'"}],!1;{let ge=a;for(let be in pe)if(!(be==="rootKeyId"||be==="derivationScheme"||be==="derivedPublicKey"||be==="algorithm"||be==="encryptedKey"||be==="initializationVector"||be==="ephemeralPublicKey"||be==="messageAuthenticationCode")){return Ke.errors=[{instancePath:e+"/encryption/keyEncryption/"+ce,schemaPath:"#/properties/encryption/properties/keyEncryption/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:be},message:"must NOT have additional properties"}],!1;break}if(ge===a){if(pe.rootKeyId!==void 0){let be=a;if(typeof pe.rootKeyId!="string")return Ke.errors=[{instancePath:e+"/encryption/keyEncryption/"+ce+"/rootKeyId",schemaPath:"#/properties/encryption/properties/keyEncryption/items/properties/rootKeyId/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var V=be===a}else var V=!0;if(V){if(pe.derivationScheme!==void 0){let be=pe.derivationScheme,De=a;if(typeof be!="string")return Ke.errors=[{instancePath:e+"/encryption/keyEncryption/"+ce+"/derivationScheme",schemaPath:"#/properties/encryption/properties/keyEncryption/items/properties/derivationScheme/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;if(!(be==="dataFormats"||be==="protocolContext"||be==="protocolPath"||be==="schemas"))return Ke.errors=[{instancePath:e+"/encryption/keyEncryption/"+ce+"/derivationScheme",schemaPath:"#/properties/encryption/properties/keyEncryption/items/properties/derivationScheme/enum",keyword:"enum",params:{allowedValues:Up.properties.encryption.properties.keyEncryption.items.properties.derivationScheme.enum},message:"must be equal to one of the allowed values"}],!1;var V=De===a}else var V=!0;if(V){if(pe.derivedPublicKey!==void 0){let be=a;tn(pe.derivedPublicKey,{instancePath:e+"/encryption/keyEncryption/"+ce+"/derivedPublicKey",parentData:pe,parentDataProperty:"derivedPublicKey",rootData:i,dynamicAnchors:o})||(s=s===null?tn.errors:s.concat(tn.errors),a=s.length);var V=be===a}else var V=!0;if(V){if(pe.algorithm!==void 0){let be=pe.algorithm,De=a;if(typeof be!="string")return Ke.errors=[{instancePath:e+"/encryption/keyEncryption/"+ce+"/algorithm",schemaPath:"#/properties/encryption/properties/keyEncryption/items/properties/algorithm/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;if(be!=="ECIES-ES256K")return Ke.errors=[{instancePath:e+"/encryption/keyEncryption/"+ce+"/algorithm",schemaPath:"#/properties/encryption/properties/keyEncryption/items/properties/algorithm/enum",keyword:"enum",params:{allowedValues:Up.properties.encryption.properties.keyEncryption.items.properties.algorithm.enum},message:"must be equal to one of the allowed values"}],!1;var V=De===a}else var V=!0;if(V){if(pe.encryptedKey!==void 0){let be=pe.encryptedKey,De=a;if(a===a)if(typeof be=="string"){if(!v0.test(be))return Ke.errors=[{instancePath:e+"/encryption/keyEncryption/"+ce+"/encryptedKey",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 Ke.errors=[{instancePath:e+"/encryption/keyEncryption/"+ce+"/encryptedKey",schemaPath:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/base64url/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var V=De===a}else var V=!0;if(V){if(pe.initializationVector!==void 0){let be=pe.initializationVector,De=a;if(a===a)if(typeof be=="string"){if(!v0.test(be))return Ke.errors=[{instancePath:e+"/encryption/keyEncryption/"+ce+"/initializationVector",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 Ke.errors=[{instancePath:e+"/encryption/keyEncryption/"+ce+"/initializationVector",schemaPath:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/base64url/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var V=De===a}else var V=!0;if(V){if(pe.ephemeralPublicKey!==void 0){let be=a;tn(pe.ephemeralPublicKey,{instancePath:e+"/encryption/keyEncryption/"+ce+"/ephemeralPublicKey",parentData:pe,parentDataProperty:"ephemeralPublicKey",rootData:i,dynamicAnchors:o})||(s=s===null?tn.errors:s.concat(tn.errors),a=s.length);var V=be===a}else var V=!0;if(V)if(pe.messageAuthenticationCode!==void 0){let be=pe.messageAuthenticationCode,De=a;if(a===a)if(typeof be=="string"){if(!v0.test(be))return Ke.errors=[{instancePath:e+"/encryption/keyEncryption/"+ce+"/messageAuthenticationCode",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 Ke.errors=[{instancePath:e+"/encryption/keyEncryption/"+ce+"/messageAuthenticationCode",schemaPath:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/base64url/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var V=De===a}else var V=!0}}}}}}}}}else return Ke.errors=[{instancePath:e+"/encryption/keyEncryption/"+ce,schemaPath:"#/properties/encryption/properties/keyEncryption/items/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var U=xe===a;if(!U)break}}}else return Ke.errors=[{instancePath:e+"/encryption/keyEncryption",schemaPath:"#/properties/encryption/properties/keyEncryption/type",keyword:"type",params:{type:"array"},message:"must be array"}],!1;var F=ee===a}else var F=!0}}}}else return Ke.errors=[{instancePath:e+"/encryption",schemaPath:"#/properties/encryption/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var K=J===a}else var K=!0;if(K)if(t.descriptor!==void 0){let j=t.descriptor,J=a,Z=a,G=!1,W=a;if(j&&typeof j=="object"&&!Array.isArray(j)){let le;if(j.published===void 0&&(le="published")||j.datePublished===void 0&&(le="datePublished")){let ge={instancePath:e+"/descriptor",schemaPath:"#/properties/descriptor/allOf/0/anyOf/0/required",keyword:"required",params:{missingProperty:le},message:"must have required property '"+le+"'"};s===null?s=[ge]:s.push(ge),a++}else if(j.published!==void 0){let ge=j.published;if(typeof ge!="boolean"){let be={instancePath:e+"/descriptor/published",schemaPath:"#/properties/descriptor/allOf/0/anyOf/0/properties/published/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};s===null?s=[be]:s.push(be),a++}if(ge!==!0){let be={instancePath:e+"/descriptor/published",schemaPath:"#/properties/descriptor/allOf/0/anyOf/0/properties/published/enum",keyword:"enum",params:{allowedValues:Up.properties.descriptor.allOf[0].anyOf[0].properties.published.enum},message:"must be equal to one of the allowed values"};s===null?s=[be]:s.push(be),a++}}}var y=W===a;if(G=G||y,y){var L={};L.published=!0}let X=a,ee=a,ue=a;if(j&&typeof j=="object"&&!Array.isArray(j)){let le;if(j.datePublished===void 0&&(le="datePublished")){let ge={};s===null?s=[ge]:s.push(ge),a++}}var T=ue===a;if(T){let le={instancePath:e+"/descriptor",schemaPath:"#/properties/descriptor/allOf/0/anyOf/1/not",keyword:"not",params:{},message:"must NOT be valid"};s===null?s=[le]:s.push(le),a++}else a=ee,s!==null&&(ee?s.length=ee:s=null);if(a===X&&j&&typeof j=="object"&&!Array.isArray(j)&&j.published!==void 0){let le=j.published;if(typeof le!="boolean"){let ge={instancePath:e+"/descriptor/published",schemaPath:"#/properties/descriptor/allOf/0/anyOf/1/properties/published/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};s===null?s=[ge]:s.push(ge),a++}if(le!==!1){let ge={instancePath:e+"/descriptor/published",schemaPath:"#/properties/descriptor/allOf/0/anyOf/1/properties/published/enum",keyword:"enum",params:{allowedValues:Up.properties.descriptor.allOf[0].anyOf[1].properties.published.enum},message:"must be equal to one of the allowed values"};s===null?s=[ge]:s.push(ge),a++}}var y=X===a;G=G||y,y&&L!==!0&&(L=L||{},L.published=!0);let ae=a,ce=a,pe=a,xe=a;if(j&&typeof j=="object"&&!Array.isArray(j)){let le;if(j.published===void 0&&(le="published")){let ge={};s===null?s=[ge]:s.push(ge),a++}}var S=xe===a;if(S){let le={instancePath:e+"/descriptor",schemaPath:"#/properties/descriptor/allOf/0/anyOf/2/allOf/0/not",keyword:"not",params:{},message:"must NOT be valid"};s===null?s=[le]:s.push(le),a++}else a=pe,s!==null&&(pe?s.length=pe:s=null);var k=ce===a;if(k){let le=a,ge=a,be=a;if(j&&typeof j=="object"&&!Array.isArray(j)){let Ie;if(j.datePublished===void 0&&(Ie="datePublished")){let je={};s===null?s=[je]:s.push(je),a++}}var f=be===a;if(f){let Ie={instancePath:e+"/descriptor",schemaPath:"#/properties/descriptor/allOf/0/anyOf/2/allOf/1/not",keyword:"not",params:{},message:"must NOT be valid"};s===null?s=[Ie]:s.push(Ie),a++}else a=ge,s!==null&&(ge?s.length=ge:s=null);var k=le===a}var y=ae===a;if(G=G||y,G)a=Z,s!==null&&(Z?s.length=Z:s=null);else{let le={instancePath:e+"/descriptor",schemaPath:"#/properties/descriptor/allOf/0/anyOf",keyword:"anyOf",params:{},message:"must match a schema in anyOf"};return s===null?s=[le]:s.push(le),a++,Ke.errors=s,!1}if(a===J)if(j&&typeof j=="object"&&!Array.isArray(j)){let le;if(j.interface===void 0&&(le="interface")||j.method===void 0&&(le="method")||j.dataCid===void 0&&(le="dataCid")||j.dataSize===void 0&&(le="dataSize")||j.dateCreated===void 0&&(le="dateCreated")||j.messageTimestamp===void 0&&(le="messageTimestamp")||j.dataFormat===void 0&&(le="dataFormat"))return Ke.errors=[{instancePath:e+"/descriptor",schemaPath:"#/properties/descriptor/required",keyword:"required",params:{missingProperty:le},message:"must have required property '"+le+"'"}],!1;{let ge=a;for(let be in j)if(!UB.call(Up.properties.descriptor.properties,be)){return Ke.errors=[{instancePath:e+"/descriptor",schemaPath:"#/properties/descriptor/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:be},message:"must NOT have additional properties"}],!1;break}if(ge===a){let be;if(j.parentId!==void 0&&j.protocol===void 0&&(be="protocol"))return Ke.errors=[{instancePath:e+"/descriptor",schemaPath:"#/properties/descriptor/dependencies",keyword:"dependencies",params:{property:"parentId",missingProperty:be,depsCount:1,deps:"protocol"},message:"must have property protocol when property parentId is present"}],!1;if(j.interface!==void 0){let De=j.interface,Ie=a;if(typeof De!="string")return Ke.errors=[{instancePath:e+"/descriptor/interface",schemaPath:"#/properties/descriptor/properties/interface/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;if(De!=="Records")return Ke.errors=[{instancePath:e+"/descriptor/interface",schemaPath:"#/properties/descriptor/properties/interface/enum",keyword:"enum",params:{allowedValues:Up.properties.descriptor.properties.interface.enum},message:"must be equal to one of the allowed values"}],!1;var w=Ie===a}else var w=!0;if(w){if(j.method!==void 0){let De=j.method,Ie=a;if(typeof De!="string")return Ke.errors=[{instancePath:e+"/descriptor/method",schemaPath:"#/properties/descriptor/properties/method/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;if(De!=="Write")return Ke.errors=[{instancePath:e+"/descriptor/method",schemaPath:"#/properties/descriptor/properties/method/enum",keyword:"enum",params:{allowedValues:Up.properties.descriptor.properties.method.enum},message:"must be equal to one of the allowed values"}],!1;var w=Ie===a}else var w=!0;if(w){if(j.recipient!==void 0){let De=j.recipient,Ie=a;if(a===a)if(typeof De=="string"){if(!b0.test(De))return Ke.errors=[{instancePath:e+"/descriptor/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 Ke.errors=[{instancePath:e+"/descriptor/recipient",schemaPath:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/did/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var w=Ie===a}else var w=!0;if(w){if(j.protocol!==void 0){let De=a;if(typeof j.protocol!="string")return Ke.errors=[{instancePath:e+"/descriptor/protocol",schemaPath:"#/properties/descriptor/properties/protocol/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var w=De===a}else var w=!0;if(w){if(j.protocolPath!==void 0){let De=j.protocolPath,Ie=a;if(a===Ie)if(typeof De=="string"){if(!B5e.test(De))return Ke.errors=[{instancePath:e+"/descriptor/protocolPath",schemaPath:"#/properties/descriptor/properties/protocolPath/pattern",keyword:"pattern",params:{pattern:"^[a-zA-Z]+(/[a-zA-Z]+)*$"},message:'must match pattern "^[a-zA-Z]+(/[a-zA-Z]+)*$"'}],!1}else return Ke.errors=[{instancePath:e+"/descriptor/protocolPath",schemaPath:"#/properties/descriptor/properties/protocolPath/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var w=Ie===a}else var w=!0;if(w){if(j.schema!==void 0){let De=a;if(typeof j.schema!="string")return Ke.errors=[{instancePath:e+"/descriptor/schema",schemaPath:"#/properties/descriptor/properties/schema/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var w=De===a}else var w=!0;if(w){if(j.tags!==void 0){let De=j.tags,Ie=a;if(a===Ie)if(De&&typeof De=="object"&&!Array.isArray(De)){if(Object.keys(De).length>10)return Ke.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(De).length<1)return Ke.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 vt in De){let Ae=De[vt],Re=a,kt=a,we=!1,Ee=null,Kr=a;if(typeof Ae!="string"){let We={instancePath:e+"/descriptor/tags/"+vt.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=[We]:s.push(We),a++}var _=Kr===a;_&&(we=!0,Ee=0);let Fe=a;if(!(typeof Ae=="number"&&isFinite(Ae))){let We={instancePath:e+"/descriptor/tags/"+vt.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=[We]:s.push(We),a++}var _=Fe===a;if(_&&we)we=!1,Ee=[Ee,1];else{_&&(we=!0,Ee=1);let We=a;if(typeof Ae!="boolean"){let ht={instancePath:e+"/descriptor/tags/"+vt.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=[ht]:s.push(ht),a++}var _=We===a;if(_&&we)we=!1,Ee=[Ee,2];else{_&&(we=!0,Ee=2);let ht=a;if(a===ht)if(Array.isArray(Ae))if(Ae.length>10){let gi={instancePath:e+"/descriptor/tags/"+vt.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=[gi]:s.push(gi),a++}else if(Ae.length<1){let gi={instancePath:e+"/descriptor/tags/"+vt.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=[gi]:s.push(gi),a++}else{var x=!0;let gi=Ae.length;for(let Tt=0;Tt<gi;Tt++){let Ze=a;if(typeof Ae[Tt]!="string"){let It={instancePath:e+"/descriptor/tags/"+vt.replace(/~/g,"~0").replace(/\//g,"~1")+"/"+Tt,schemaPath:"#/properties/descriptor/properties/tags/additionalProperties/oneOf/3/items/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[It]:s.push(It),a++}var x=Ze===a;if(!x)break}}else{let gi={instancePath:e+"/descriptor/tags/"+vt.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/descriptor/properties/tags/additionalProperties/oneOf/3/type",keyword:"type",params:{type:"array"},message:"must be array"};s===null?s=[gi]:s.push(gi),a++}var _=ht===a;if(_&&we)we=!1,Ee=[Ee,3];else{if(_){we=!0,Ee=3;var b=!0}let gi=a;if(a===gi)if(Array.isArray(Ae))if(Ae.length>10){let Ze={instancePath:e+"/descriptor/tags/"+vt.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(Ae.length<1){let Ze={instancePath:e+"/descriptor/tags/"+vt.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 B=!0;let Ze=Ae.length;for(let $c=0;$c<Ze;$c++){let It=Ae[$c],Nt=a;if(!(typeof It=="number"&&isFinite(It))){let Ot={instancePath:e+"/descriptor/tags/"+vt.replace(/~/g,"~0").replace(/\//g,"~1")+"/"+$c,schemaPath:"#/properties/descriptor/properties/tags/additionalProperties/oneOf/4/items/type",keyword:"type",params:{type:"number"},message:"must be number"};s===null?s=[Ot]:s.push(Ot),a++}var B=Nt===a;if(!B)break}}else{let Ze={instancePath:e+"/descriptor/tags/"+vt.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/descriptor/properties/tags/additionalProperties/oneOf/4/type",keyword:"type",params:{type:"array"},message:"must be array"};s===null?s=[Ze]:s.push(Ze),a++}var _=gi===a;_&&we?(we=!1,Ee=[Ee,4]):_&&(we=!0,Ee=4,b!==!0&&(b=!0))}}}if(we)a=kt,s!==null&&(kt?s.length=kt:s=null);else{let We={instancePath:e+"/descriptor/tags/"+vt.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/descriptor/properties/tags/additionalProperties/oneOf",keyword:"oneOf",params:{passingSchemas:Ee},message:"must match exactly one schema in oneOf"};return s===null?s=[We]:s.push(We),a++,Ke.errors=s,!1}var q=Re===a;if(!q)break}}else return Ke.errors=[{instancePath:e+"/descriptor/tags",schemaPath:"#/properties/descriptor/properties/tags/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var w=Ie===a}else var w=!0;if(w){if(j.parentId!==void 0){let De=a;if(typeof j.parentId!="string")return Ke.errors=[{instancePath:e+"/descriptor/parentId",schemaPath:"#/properties/descriptor/properties/parentId/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var w=De===a}else var w=!0;if(w){if(j.dataCid!==void 0){let De=a;if(typeof j.dataCid!="string")return Ke.errors=[{instancePath:e+"/descriptor/dataCid",schemaPath:"#/properties/descriptor/properties/dataCid/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var w=De===a}else var w=!0;if(w){if(j.dataSize!==void 0){let De=j.dataSize,Ie=a;if(!(typeof De=="number"&&isFinite(De)))return Ke.errors=[{instancePath:e+"/descriptor/dataSize",schemaPath:"#/properties/descriptor/properties/dataSize/type",keyword:"type",params:{type:"number"},message:"must be number"}],!1;var w=Ie===a}else var w=!0;if(w){if(j.dateCreated!==void 0){let De=j.dateCreated,Ie=a;if(a===a)if(typeof De=="string"){if(!Un.test(De))return Ke.errors=[{instancePath:e+"/descriptor/dateCreated",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 Ke.errors=[{instancePath:e+"/descriptor/dateCreated",schemaPath:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/date-time/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var w=Ie===a}else var w=!0;if(w){if(j.messageTimestamp!==void 0){let De=j.messageTimestamp,Ie=a;if(a===a)if(typeof De=="string"){if(!Un.test(De))return Ke.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 Ke.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 w=Ie===a}else var w=!0;if(w){if(j.published!==void 0){let De=a;if(typeof j.published!="boolean")return Ke.errors=[{instancePath:e+"/descriptor/published",schemaPath:"#/properties/descriptor/properties/published/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"}],!1;var w=De===a}else var w=!0;if(w){if(j.datePublished!==void 0){let De=j.datePublished,Ie=a;if(a===a)if(typeof De=="string"){if(!Un.test(De))return Ke.errors=[{instancePath:e+"/descriptor/datePublished",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 Ke.errors=[{instancePath:e+"/descriptor/datePublished",schemaPath:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/date-time/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var w=Ie===a}else var w=!0;if(w)if(j.dataFormat!==void 0){let De=a;if(typeof j.dataFormat!="string")return Ke.errors=[{instancePath:e+"/descriptor/dataFormat",schemaPath:"#/properties/descriptor/properties/dataFormat/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var w=De===a}else var w=!0}}}}}}}}}}}}}}}}else return Ke.errors=[{instancePath:e+"/descriptor",schemaPath:"#/properties/descriptor/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var K=J===a}else var K=!0}}}}}else return Ke.errors=[{instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;return Ke.errors=s,d.props=m,a===0}Ke.evaluated={dynamicProps:!0,dynamicItems:!1};function ed(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:i=t,dynamicAnchors:o={}}={}){let s=null,a=0,d=ed.evaluated;if(d.dynamicProps&&(d.props=void 0),d.dynamicItems&&(d.items=void 0),!Ke(t,{instancePath:e,parentData:r,parentDataProperty:n,rootData:i,dynamicAnchors:o}))s=s===null?Ke.errors:s.concat(Ke.errors),a=s.length;else var u=Ke.evaluated.props;if(a===0)if(t&&typeof t=="object"&&!Array.isArray(t)){let l;if(t.recordId===void 0&&(l="recordId")||t.authorization===void 0&&(l="authorization")||t.encodedData===void 0&&(l="encodedData"))return ed.errors=[{instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:l},message:"must have required property '"+l+"'"}],!1;if(u!==!0&&(u=u||{},u.encodedData=!0),t.encodedData!==void 0){let m=a;if(typeof t.encodedData!="string")return ed.errors=[{instancePath:e+"/encodedData",schemaPath:"#/properties/encodedData/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var c=m===a}else var c=!0;if(c&&u!==!0){for(let m in t)if(!u||!u[m]){return ed.errors=[{instancePath:e,schemaPath:"#/unevaluatedProperties",keyword:"unevaluatedProperties",params:{unevaluatedProperty:m},message:"must NOT have unevaluated properties"}],!1;break}}}else return ed.errors=[{instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;return ed.errors=s,a===0}ed.evaluated={props:!0,dynamicProps:!1,dynamicItems:!1};function ho(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:i=t,dynamicAnchors:o={}}={}){let s=null,a=0,d=ho.evaluated;if(d.dynamicProps&&(d.props=void 0),d.dynamicItems&&(d.items=void 0),a===0)if(t&&typeof t=="object"&&!Array.isArray(t)){let c=a;for(let l in t)if(!(l==="signature"||l==="authorDelegatedGrant")){return ho.errors=[{instancePath:e,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:l},message:"must NOT have additional properties"}],!1;break}if(c===a){if(t.signature!==void 0){let l=a;rn(t.signature,{instancePath:e+"/signature",parentData:t,parentDataProperty:"signature",rootData:i,dynamicAnchors:o})||(s=s===null?rn.errors:s.concat(rn.errors),a=s.length);var u=l===a}else var u=!0;if(u)if(t.authorDelegatedGrant!==void 0){let l=a;ed(t.authorDelegatedGrant,{instancePath:e+"/authorDelegatedGrant",parentData:t,parentDataProperty:"authorDelegatedGrant",rootData:i,dynamicAnchors:o})||(s=s===null?ed.errors:s.concat(ed.errors),a=s.length);var u=l===a}else var u=!0}}else return ho.errors=[{instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;return ho.errors=s,a===0}ho.evaluated={props:!0,dynamicProps:!1,dynamicItems:!1};var M5e=ml,D5e=fo,jJ={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://identity.foundation/dwn/json-schemas/records-delete.json",type:"object",additionalProperties:!1,required:["authorization","descriptor"],properties:{authorization:{$ref:"https://identity.foundation/dwn/json-schemas/authorization-delegated-grant.json"},descriptor:{type:"object",additionalProperties:!1,required:["interface","method","messageTimestamp","recordId","prune"],properties:{interface:{enum:["Records"],type:"string"},method:{enum:["Delete"],type:"string"},messageTimestamp:{$ref:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/date-time"},recordId:{type:"string"},prune:{type:"boolean"}}}}};function fo(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:i=t,dynamicAnchors:o={}}={}){let s=null,a=0,d=fo.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.authorization===void 0&&(l="authorization")||t.descriptor===void 0&&(l="descriptor"))return fo.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 fo.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;ho(t.authorization,{instancePath:e+"/authorization",parentData:t,parentDataProperty:"authorization",rootData:i,dynamicAnchors:o})||(s=s===null?ho.errors:s.concat(ho.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 E;if(p.interface===void 0&&(E="interface")||p.method===void 0&&(E="method")||p.messageTimestamp===void 0&&(E="messageTimestamp")||p.recordId===void 0&&(E="recordId")||p.prune===void 0&&(E="prune"))return fo.errors=[{instancePath:e+"/descriptor",schemaPath:"#/properties/descriptor/required",keyword:"required",params:{missingProperty:E},message:"must have required property '"+E+"'"}],!1;{let A=a;for(let P in p)if(!(P==="interface"||P==="method"||P==="messageTimestamp"||P==="recordId"||P==="prune")){return fo.errors=[{instancePath:e+"/descriptor",schemaPath:"#/properties/descriptor/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:P},message:"must NOT have additional properties"}],!1;break}if(A===a){if(p.interface!==void 0){let P=p.interface,I=a;if(typeof P!="string")return fo.errors=[{instancePath:e+"/descriptor/interface",schemaPath:"#/properties/descriptor/properties/interface/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;if(P!=="Records")return fo.errors=[{instancePath:e+"/descriptor/interface",schemaPath:"#/properties/descriptor/properties/interface/enum",keyword:"enum",params:{allowedValues:jJ.properties.descriptor.properties.interface.enum},message:"must be equal to one of the allowed values"}],!1;var c=I===a}else var c=!0;if(c){if(p.method!==void 0){let P=p.method,I=a;if(typeof P!="string")return fo.errors=[{instancePath:e+"/descriptor/method",schemaPath:"#/properties/descriptor/properties/method/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;if(P!=="Delete")return fo.errors=[{instancePath:e+"/descriptor/method",schemaPath:"#/properties/descriptor/properties/method/enum",keyword:"enum",params:{allowedValues:jJ.properties.descriptor.properties.method.enum},message:"must be equal to one of the allowed values"}],!1;var c=I===a}else var c=!0;if(c){if(p.messageTimestamp!==void 0){let P=p.messageTimestamp,I=a;if(a===a)if(typeof P=="string"){if(!Un.test(P))return fo.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 fo.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=I===a}else var c=!0;if(c){if(p.recordId!==void 0){let P=a;if(typeof p.recordId!="string")return fo.errors=[{instancePath:e+"/descriptor/recordId",schemaPath:"#/properties/descriptor/properties/recordId/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var c=P===a}else var c=!0;if(c)if(p.prune!==void 0){let P=a;if(typeof p.prune!="boolean")return fo.errors=[{instancePath:e+"/descriptor/prune",schemaPath:"#/properties/descriptor/properties/prune/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"}],!1;var c=P===a}else var c=!0}}}}}}else return fo.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 fo.errors=[{instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;return fo.errors=s,a===0}fo.evaluated={props:!0,dynamicProps:!1,dynamicItems:!1};var O5e=fn,NB={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://identity.foundation/dwn/json-schemas/records-query.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:["Query"],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"},pagination:{type:"object",additionalProperties:!1,properties:{limit:{type:"number",minimum:1},cursor:{$ref:"https://identity.foundation/dwn/json-schemas/pagination-cursor.json"}}},dateSort:{enum:["createdAscending","createdDescending","publishedAscending","publishedDescending"],type:"string"}}}}},a8={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://identity.foundation/dwn/json-schemas/pagination-cursor.json",type:"object",minProperties:1,additionalProperties:!1,required:["messageCid","value"],properties:{messageCid:{type:"string"},value:{type:["string","number"]}}},UJ={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://identity.foundation/dwn/json-schemas/records-filter.json",type:"object",minProperties:1,additionalProperties:!1,properties:{protocol:{type:"string"},protocolPath:{type:"string"},author:{$ref:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/did"},attester:{$ref:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/did"},recipient:{$ref:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/did"},contextId:{type:"string"},schema:{type:"string"},tags:{type:"object",minProperties:1,additionalProperties:{oneOf:[{type:"string"},{type:"number"},{type:"boolean"},{type:"object",minProperties:1,additionalProperties:!1,properties:{startsWith:{type:"string"}}},{$ref:"https://identity.foundation/dwn/json-schemas/string-range-filter.json"},{$ref:"https://identity.foundation/dwn/json-schemas/number-range-filter.json"}]}},recordId:{type:"string"},parentId:{type:"string"},published:{type:"boolean"},dataFormat:{type:"string"},dataSize:{$ref:"https://identity.foundation/dwn/json-schemas/number-range-filter.json"},dataCid:{type:"string"},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 Je(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:i=t,dynamicAnchors:o={}}={}){let s=null,a=0,d=Je.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 Je.errors=[{instancePath:e,schemaPath:"#/minProperties",keyword:"minProperties",params:{limit:1},message:"must NOT have fewer than 1 properties"}],!1;{let M=a;for(let j in t)if(!UB.call(UJ.properties,j)){return Je.errors=[{instancePath:e,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:j},message:"must NOT have additional properties"}],!1;break}if(M===a){if(t.datePublished!==void 0){let j=a,J=a,Z=!1,G=null,W=a;if(t&&typeof t=="object"&&!Array.isArray(t)){let ae;if(t.published===void 0&&(ae="published")){let ce={instancePath:e,schemaPath:"#/dependencies/datePublished/oneOf/0/required",keyword:"required",params:{missingProperty:ae},message:"must have required property '"+ae+"'"};s===null?s=[ce]:s.push(ce),a++}else if(t.published!==void 0&&t.published!==!0){let ce={instancePath:e+"/published",schemaPath:"#/dependencies/datePublished/oneOf/0/properties/published/enum",keyword:"enum",params:{allowedValues:UJ.dependencies.datePublished.oneOf[0].properties.published.enum},message:"must be equal to one of the allowed values"};s===null?s=[ce]:s.push(ce),a++}}var l=W===a;if(l){Z=!0,G=0;var u={};u.published=!0}let X=a,ee=a,ue=a;if(t&&typeof t=="object"&&!Array.isArray(t)){let ae;if(t.published===void 0&&(ae="published")){let ce={};s===null?s=[ce]:s.push(ce),a++}}var c=ue===a;if(c){let ae={instancePath:e,schemaPath:"#/dependencies/datePublished/oneOf/1/not",keyword:"not",params:{},message:"must NOT be valid"};s===null?s=[ae]:s.push(ae),a++}else a=ee,s!==null&&(ee?s.length=ee:s=null);var l=X===a;if(l&&Z?(Z=!1,G=[G,1]):l&&(Z=!0,G=1),Z)a=J,s!==null&&(J?s.length=J:s=null);else{let ae={instancePath:e,schemaPath:"#/dependencies/datePublished/oneOf",keyword:"oneOf",params:{passingSchemas:G},message:"must match exactly one schema in oneOf"};return s===null?s=[ae]:s.push(ae),a++,Je.errors=s,!1}var m=j===a}else var m=!0;if(m){if(t.protocol!==void 0){let j=a;if(typeof t.protocol!="string")return Je.errors=[{instancePath:e+"/protocol",schemaPath:"#/properties/protocol/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var p=j===a}else var p=!0;if(p){if(t.protocolPath!==void 0){let j=a;if(typeof t.protocolPath!="string")return Je.errors=[{instancePath:e+"/protocolPath",schemaPath:"#/properties/protocolPath/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var p=j===a}else var p=!0;if(p){if(t.author!==void 0){let j=t.author,J=a;if(a===a)if(typeof j=="string"){if(!b0.test(j))return Je.errors=[{instancePath:e+"/author",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 Je.errors=[{instancePath:e+"/author",schemaPath:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/did/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var p=J===a}else var p=!0;if(p){if(t.attester!==void 0){let j=t.attester,J=a;if(a===a)if(typeof j=="string"){if(!b0.test(j))return Je.errors=[{instancePath:e+"/attester",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 Je.errors=[{instancePath:e+"/attester",schemaPath:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/did/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var p=J===a}else var p=!0;if(p){if(t.recipient!==void 0){let j=t.recipient,J=a;if(a===a)if(typeof j=="string"){if(!b0.test(j))return Je.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 Je.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=J===a}else var p=!0;if(p){if(t.contextId!==void 0){let j=a;if(typeof t.contextId!="string")return Je.errors=[{instancePath:e+"/contextId",schemaPath:"#/properties/contextId/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var p=j===a}else var p=!0;if(p){if(t.schema!==void 0){let j=a;if(typeof t.schema!="string")return Je.errors=[{instancePath:e+"/schema",schemaPath:"#/properties/schema/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var p=j===a}else var p=!0;if(p){if(t.tags!==void 0){let j=t.tags,J=a;if(a===J)if(j&&typeof j=="object"&&!Array.isArray(j)){if(Object.keys(j).length<1)return Je.errors=[{instancePath:e+"/tags",schemaPath:"#/properties/tags/minProperties",keyword:"minProperties",params:{limit:1},message:"must NOT have fewer than 1 properties"}],!1;for(let G in j){let W=j[G],X=a,ee=a,ue=!1,ae=null,ce=a;if(typeof W!="string"){let xe={instancePath:e+"/tags/"+G.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/tags/additionalProperties/oneOf/0/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[xe]:s.push(xe),a++}var g=ce===a;g&&(ue=!0,ae=0);let pe=a;if(!(typeof W=="number"&&isFinite(W))){let xe={instancePath:e+"/tags/"+G.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/tags/additionalProperties/oneOf/1/type",keyword:"type",params:{type:"number"},message:"must be number"};s===null?s=[xe]:s.push(xe),a++}var g=pe===a;if(g&&ue)ue=!1,ae=[ae,1];else{g&&(ue=!0,ae=1);let xe=a;if(typeof W!="boolean"){let le={instancePath:e+"/tags/"+G.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/tags/additionalProperties/oneOf/2/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};s===null?s=[le]:s.push(le),a++}var g=xe===a;if(g&&ue)ue=!1,ae=[ae,2];else{g&&(ue=!0,ae=2);let le=a;if(a===le)if(W&&typeof W=="object"&&!Array.isArray(W))if(Object.keys(W).length<1){let be={instancePath:e+"/tags/"+G.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/tags/additionalProperties/oneOf/3/minProperties",keyword:"minProperties",params:{limit:1},message:"must NOT have fewer than 1 properties"};s===null?s=[be]:s.push(be),a++}else{let be=a;for(let De in W)if(De!=="startsWith"){let Ie={instancePath:e+"/tags/"+G.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/tags/additionalProperties/oneOf/3/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:De},message:"must NOT have additional properties"};s===null?s=[Ie]:s.push(Ie),a++;break}if(be===a&&W.startsWith!==void 0&&typeof W.startsWith!="string"){let De={instancePath:e+"/tags/"+G.replace(/~/g,"~0").replace(/\//g,"~1")+"/startsWith",schemaPath:"#/properties/tags/additionalProperties/oneOf/3/properties/startsWith/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[De]:s.push(De),a++}}else{let be={instancePath:e+"/tags/"+G.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/tags/additionalProperties/oneOf/3/type",keyword:"type",params:{type:"object"},message:"must be object"};s===null?s=[be]:s.push(be),a++}var g=le===a;if(g&&ue)ue=!1,ae=[ae,3];else{if(g){ue=!0,ae=3;var v=!0}let be=a;if(a===a)if(W&&typeof W=="object"&&!Array.isArray(W))if(Object.keys(W).length<1){let je={instancePath:e+"/tags/"+G.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"https://identity.foundation/dwn/json-schemas/string-range-filter.json/minProperties",keyword:"minProperties",params:{limit:1},message:"must NOT have fewer than 1 properties"};s===null?s=[je]:s.push(je),a++}else{let je=a;for(let vt in W)if(!(vt==="gt"||vt==="gte"||vt==="lt"||vt==="lte")){let Ae={instancePath:e+"/tags/"+G.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"https://identity.foundation/dwn/json-schemas/string-range-filter.json/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:vt},message:"must NOT have additional properties"};s===null?s=[Ae]:s.push(Ae),a++;break}if(je===a){if(W.gt!==void 0){let vt=a,Ae=a,Re=a;if(W&&typeof W=="object"&&!Array.isArray(W)){let kt;if(W.gte===void 0&&(kt="gte")){let we={};s===null?s=[we]:s.push(we),a++}}var E=Re===a;if(E){let kt={instancePath:e+"/tags/"+G.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"https://identity.foundation/dwn/json-schemas/string-range-filter.json/dependencies/gt/not",keyword:"not",params:{},message:"must NOT be valid"};s===null?s=[kt]:s.push(kt),a++}else a=Ae,s!==null&&(Ae?s.length=Ae:s=null);var A=vt===a}else var A=!0;if(A){if(W.gte!==void 0){let vt=a,Ae=a,Re=a;if(W&&typeof W=="object"&&!Array.isArray(W)){let we;if(W.gt===void 0&&(we="gt")){let Ee={};s===null?s=[Ee]:s.push(Ee),a++}}var P=Re===a;if(P){let we={instancePath:e+"/tags/"+G.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"https://identity.foundation/dwn/json-schemas/string-range-filter.json/dependencies/gte/not",keyword:"not",params:{},message:"must NOT be valid"};s===null?s=[we]:s.push(we),a++}else a=Ae,s!==null&&(Ae?s.length=Ae:s=null);var A=vt===a}else var A=!0;if(A){if(W.lt!==void 0){let vt=a,Ae=a,Re=a;if(W&&typeof W=="object"&&!Array.isArray(W)){let we;if(W.lte===void 0&&(we="lte")){let Ee={};s===null?s=[Ee]:s.push(Ee),a++}}var I=Re===a;if(I){let we={instancePath:e+"/tags/"+G.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"https://identity.foundation/dwn/json-schemas/string-range-filter.json/dependencies/lt/not",keyword:"not",params:{},message:"must NOT be valid"};s===null?s=[we]:s.push(we),a++}else a=Ae,s!==null&&(Ae?s.length=Ae:s=null);var A=vt===a}else var A=!0;if(A){if(W.lte!==void 0){let vt=a,Ae=a,Re=a;if(W&&typeof W=="object"&&!Array.isArray(W)){let we;if(W.lt===void 0&&(we="lt")){let Ee={};s===null?s=[Ee]:s.push(Ee),a++}}var $=Re===a;if($){let we={instancePath:e+"/tags/"+G.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"https://identity.foundation/dwn/json-schemas/string-range-filter.json/dependencies/lte/not",keyword:"not",params:{},message:"must NOT be valid"};s===null?s=[we]:s.push(we),a++}else a=Ae,s!==null&&(Ae?s.length=Ae:s=null);var A=vt===a}else var A=!0;if(A){if(W.gt!==void 0){let vt=a;if(typeof W.gt!="string"){let Ae={instancePath:e+"/tags/"+G.replace(/~/g,"~0").replace(/\//g,"~1")+"/gt",schemaPath:"https://identity.foundation/dwn/json-schemas/string-range-filter.json/properties/gt/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[Ae]:s.push(Ae),a++}var N=vt===a}else var N=!0;if(N){if(W.gte!==void 0){let vt=a;if(typeof W.gte!="string"){let Re={instancePath:e+"/tags/"+G.replace(/~/g,"~0").replace(/\//g,"~1")+"/gte",schemaPath:"https://identity.foundation/dwn/json-schemas/string-range-filter.json/properties/gte/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[Re]:s.push(Re),a++}var N=vt===a}else var N=!0;if(N){if(W.lt!==void 0){let vt=a;if(typeof W.lt!="string"){let Re={instancePath:e+"/tags/"+G.replace(/~/g,"~0").replace(/\//g,"~1")+"/lt",schemaPath:"https://identity.foundation/dwn/json-schemas/string-range-filter.json/properties/lt/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[Re]:s.push(Re),a++}var N=vt===a}else var N=!0;if(N)if(W.lte!==void 0){let vt=a;if(typeof W.lte!="string"){let Re={instancePath:e+"/tags/"+G.replace(/~/g,"~0").replace(/\//g,"~1")+"/lte",schemaPath:"https://identity.foundation/dwn/json-schemas/string-range-filter.json/properties/lte/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[Re]:s.push(Re),a++}var N=vt===a}else var N=!0}}}}}}}}else{let je={instancePath:e+"/tags/"+G.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"https://identity.foundation/dwn/json-schemas/string-range-filter.json/type",keyword:"type",params:{type:"object"},message:"must be object"};s===null?s=[je]:s.push(je),a++}var g=be===a;if(g&&ue)ue=!1,ae=[ae,4];else{g&&(ue=!0,ae=4,v!==!0&&(v=!0));let je=a;if(a===a)if(W&&typeof W=="object"&&!Array.isArray(W))if(Object.keys(W).length<1){let Re={instancePath:e+"/tags/"+G.replace(/~/g,"~0").replace(/\//g,"~1"),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"};s===null?s=[Re]:s.push(Re),a++}else{let Re=a;for(let kt in W)if(!(kt==="gt"||kt==="gte"||kt==="lt"||kt==="lte")){let we={instancePath:e+"/tags/"+G.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"https://identity.foundation/dwn/json-schemas/number-range-filter.json/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:kt},message:"must NOT have additional properties"};s===null?s=[we]:s.push(we),a++;break}if(Re===a){if(W.gt!==void 0){let kt=a,we=a,Ee=a;if(W&&typeof W=="object"&&!Array.isArray(W)){let Kr;if(W.gte===void 0&&(Kr="gte")){let Fe={};s===null?s=[Fe]:s.push(Fe),a++}}var K=Ee===a;if(K){let Kr={instancePath:e+"/tags/"+G.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"https://identity.foundation/dwn/json-schemas/number-range-filter.json/dependencies/gt/not",keyword:"not",params:{},message:"must NOT be valid"};s===null?s=[Kr]:s.push(Kr),a++}else a=we,s!==null&&(we?s.length=we:s=null);var F=kt===a}else var F=!0;if(F){if(W.gte!==void 0){let kt=a,we=a,Ee=a;if(W&&typeof W=="object"&&!Array.isArray(W)){let Fe;if(W.gt===void 0&&(Fe="gt")){let We={};s===null?s=[We]:s.push(We),a++}}var U=Ee===a;if(U){let Fe={instancePath:e+"/tags/"+G.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"https://identity.foundation/dwn/json-schemas/number-range-filter.json/dependencies/gte/not",keyword:"not",params:{},message:"must NOT be valid"};s===null?s=[Fe]:s.push(Fe),a++}else a=we,s!==null&&(we?s.length=we:s=null);var F=kt===a}else var F=!0;if(F){if(W.lt!==void 0){let kt=a,we=a,Ee=a;if(W&&typeof W=="object"&&!Array.isArray(W)){let Fe;if(W.lte===void 0&&(Fe="lte")){let We={};s===null?s=[We]:s.push(We),a++}}var V=Ee===a;if(V){let Fe={instancePath:e+"/tags/"+G.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"https://identity.foundation/dwn/json-schemas/number-range-filter.json/dependencies/lt/not",keyword:"not",params:{},message:"must NOT be valid"};s===null?s=[Fe]:s.push(Fe),a++}else a=we,s!==null&&(we?s.length=we:s=null);var F=kt===a}else var F=!0;if(F){if(W.lte!==void 0){let kt=a,we=a,Ee=a;if(W&&typeof W=="object"&&!Array.isArray(W)){let Fe;if(W.lt===void 0&&(Fe="lt")){let We={};s===null?s=[We]:s.push(We),a++}}var L=Ee===a;if(L){let Fe={instancePath:e+"/tags/"+G.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"https://identity.foundation/dwn/json-schemas/number-range-filter.json/dependencies/lte/not",keyword:"not",params:{},message:"must NOT be valid"};s===null?s=[Fe]:s.push(Fe),a++}else a=we,s!==null&&(we?s.length=we:s=null);var F=kt===a}else var F=!0;if(F){if(W.gt!==void 0){let kt=W.gt,we=a;if(!(typeof kt=="number"&&isFinite(kt))){let Ee={instancePath:e+"/tags/"+G.replace(/~/g,"~0").replace(/\//g,"~1")+"/gt",schemaPath:"https://identity.foundation/dwn/json-schemas/number-range-filter.json/properties/gt/type",keyword:"type",params:{type:"number"},message:"must be number"};s===null?s=[Ee]:s.push(Ee),a++}var T=we===a}else var T=!0;if(T){if(W.gte!==void 0){let kt=W.gte,we=a;if(!(typeof kt=="number"&&isFinite(kt))){let Kr={instancePath:e+"/tags/"+G.replace(/~/g,"~0").replace(/\//g,"~1")+"/gte",schemaPath:"https://identity.foundation/dwn/json-schemas/number-range-filter.json/properties/gte/type",keyword:"type",params:{type:"number"},message:"must be number"};s===null?s=[Kr]:s.push(Kr),a++}var T=we===a}else var T=!0;if(T){if(W.lt!==void 0){let kt=W.lt,we=a;if(!(typeof kt=="number"&&isFinite(kt))){let Kr={instancePath:e+"/tags/"+G.replace(/~/g,"~0").replace(/\//g,"~1")+"/lt",schemaPath:"https://identity.foundation/dwn/json-schemas/number-range-filter.json/properties/lt/type",keyword:"type",params:{type:"number"},message:"must be number"};s===null?s=[Kr]:s.push(Kr),a++}var T=we===a}else var T=!0;if(T)if(W.lte!==void 0){let kt=W.lte,we=a;if(!(typeof kt=="number"&&isFinite(kt))){let Kr={instancePath:e+"/tags/"+G.replace(/~/g,"~0").replace(/\//g,"~1")+"/lte",schemaPath:"https://identity.foundation/dwn/json-schemas/number-range-filter.json/properties/lte/type",keyword:"type",params:{type:"number"},message:"must be number"};s===null?s=[Kr]:s.push(Kr),a++}var T=we===a}else var T=!0}}}}}}}}else{let Re={instancePath:e+"/tags/"+G.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"https://identity.foundation/dwn/json-schemas/number-range-filter.json/type",keyword:"type",params:{type:"object"},message:"must be object"};s===null?s=[Re]:s.push(Re),a++}var g=je===a;g&&ue?(ue=!1,ae=[ae,5]):g&&(ue=!0,ae=5,v!==!0&&(v=!0))}}}}if(ue)a=ee,s!==null&&(ee?s.length=ee:s=null);else{let xe={instancePath:e+"/tags/"+G.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/tags/additionalProperties/oneOf",keyword:"oneOf",params:{passingSchemas:ae},message:"must match exactly one schema in oneOf"};return s===null?s=[xe]:s.push(xe),a++,Je.errors=s,!1}var S=X===a;if(!S)break}}else return Je.errors=[{instancePath:e+"/tags",schemaPath:"#/properties/tags/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var p=J===a}else var p=!0;if(p){if(t.recordId!==void 0){let j=a;if(typeof t.recordId!="string")return Je.errors=[{instancePath:e+"/recordId",schemaPath:"#/properties/recordId/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var p=j===a}else var p=!0;if(p){if(t.parentId!==void 0){let j=a;if(typeof t.parentId!="string")return Je.errors=[{instancePath:e+"/parentId",schemaPath:"#/properties/parentId/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var p=j===a}else var p=!0;if(p){if(t.published!==void 0){let j=a;if(typeof t.published!="boolean")return Je.errors=[{instancePath:e+"/published",schemaPath:"#/properties/published/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"}],!1;var p=j===a}else var p=!0;if(p){if(t.dataFormat!==void 0){let j=a;if(typeof t.dataFormat!="string")return Je.errors=[{instancePath:e+"/dataFormat",schemaPath:"#/properties/dataFormat/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var p=j===a}else var p=!0;if(p){if(t.dataSize!==void 0){let j=t.dataSize,J=a;if(a===a)if(j&&typeof j=="object"&&!Array.isArray(j)){if(Object.keys(j).length<1)return Je.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 W=a;for(let X in j)if(!(X==="gt"||X==="gte"||X==="lt"||X==="lte")){return Je.errors=[{instancePath:e+"/dataSize",schemaPath:"https://identity.foundation/dwn/json-schemas/number-range-filter.json/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:X},message:"must NOT have additional properties"}],!1;break}if(W===a){if(j.gt!==void 0){let X=a,ee=a,ue=a;if(j&&typeof j=="object"&&!Array.isArray(j)){let ae;if(j.gte===void 0&&(ae="gte")){let ce={};s===null?s=[ce]:s.push(ce),a++}}var k=ue===a;if(k)return Je.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=ee,s!==null&&(ee?s.length=ee:s=null);var f=X===a}else var f=!0;if(f){if(j.gte!==void 0){let X=a,ee=a,ue=a;if(j&&typeof j=="object"&&!Array.isArray(j)){let ce;if(j.gt===void 0&&(ce="gt")){let pe={};s===null?s=[pe]:s.push(pe),a++}}var y=ue===a;if(y)return Je.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=ee,s!==null&&(ee?s.length=ee:s=null);var f=X===a}else var f=!0;if(f){if(j.lt!==void 0){let X=a,ee=a,ue=a;if(j&&typeof j=="object"&&!Array.isArray(j)){let ce;if(j.lte===void 0&&(ce="lte")){let pe={};s===null?s=[pe]:s.push(pe),a++}}var w=ue===a;if(w)return Je.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=ee,s!==null&&(ee?s.length=ee:s=null);var f=X===a}else var f=!0;if(f){if(j.lte!==void 0){let X=a,ee=a,ue=a;if(j&&typeof j=="object"&&!Array.isArray(j)){let ce;if(j.lt===void 0&&(ce="lt")){let pe={};s===null?s=[pe]:s.push(pe),a++}}var _=ue===a;if(_)return Je.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=ee,s!==null&&(ee?s.length=ee:s=null);var f=X===a}else var f=!0;if(f){if(j.gt!==void 0){let X=j.gt,ee=a;if(!(typeof X=="number"&&isFinite(X)))return Je.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 x=ee===a}else var x=!0;if(x){if(j.gte!==void 0){let X=j.gte,ee=a;if(!(typeof X=="number"&&isFinite(X)))return Je.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 x=ee===a}else var x=!0;if(x){if(j.lt!==void 0){let X=j.lt,ee=a;if(!(typeof X=="number"&&isFinite(X)))return Je.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 x=ee===a}else var x=!0;if(x)if(j.lte!==void 0){let X=j.lte,ee=a;if(!(typeof X=="number"&&isFinite(X)))return Je.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 x=ee===a}else var x=!0}}}}}}}}}else return Je.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=J===a}else var p=!0;if(p){if(t.dataCid!==void 0){let j=a;if(typeof t.dataCid!="string")return Je.errors=[{instancePath:e+"/dataCid",schemaPath:"#/properties/dataCid/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var p=j===a}else var p=!0;if(p){if(t.dateCreated!==void 0){let j=t.dateCreated,J=a;if(a===J)if(j&&typeof j=="object"&&!Array.isArray(j)){if(Object.keys(j).length<1)return Je.errors=[{instancePath:e+"/dateCreated",schemaPath:"#/properties/dateCreated/minProperties",keyword:"minProperties",params:{limit:1},message:"must NOT have fewer than 1 properties"}],!1;{let G=a;for(let W in j)if(!(W==="from"||W==="to")){return Je.errors=[{instancePath:e+"/dateCreated",schemaPath:"#/properties/dateCreated/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:W},message:"must NOT have additional properties"}],!1;break}if(G===a){if(j.from!==void 0){let W=j.from,X=a;if(a===a)if(typeof W=="string"){if(!Un.test(W))return Je.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 Je.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 b=X===a}else var b=!0;if(b)if(j.to!==void 0){let W=j.to,X=a;if(a===a)if(typeof W=="string"){if(!Un.test(W))return Je.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 Je.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 b=X===a}else var b=!0}}}else return Je.errors=[{instancePath:e+"/dateCreated",schemaPath:"#/properties/dateCreated/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var p=J===a}else var p=!0;if(p){if(t.datePublished!==void 0){let j=t.datePublished,J=a;if(a===J)if(j&&typeof j=="object"&&!Array.isArray(j)){if(Object.keys(j).length<1)return Je.errors=[{instancePath:e+"/datePublished",schemaPath:"#/properties/datePublished/minProperties",keyword:"minProperties",params:{limit:1},message:"must NOT have fewer than 1 properties"}],!1;{let G=a;for(let W in j)if(!(W==="from"||W==="to")){return Je.errors=[{instancePath:e+"/datePublished",schemaPath:"#/properties/datePublished/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:W},message:"must NOT have additional properties"}],!1;break}if(G===a){if(j.from!==void 0){let W=j.from,X=a;if(a===a)if(typeof W=="string"){if(!Un.test(W))return Je.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 Je.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 B=X===a}else var B=!0;if(B)if(j.to!==void 0){let W=j.to,X=a;if(a===a)if(typeof W=="string"){if(!Un.test(W))return Je.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 Je.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 B=X===a}else var B=!0}}}else return Je.errors=[{instancePath:e+"/datePublished",schemaPath:"#/properties/datePublished/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var p=J===a}else var p=!0;if(p)if(t.dateUpdated!==void 0){let j=t.dateUpdated,J=a;if(a===J)if(j&&typeof j=="object"&&!Array.isArray(j)){if(Object.keys(j).length<1)return Je.errors=[{instancePath:e+"/dateUpdated",schemaPath:"#/properties/dateUpdated/minProperties",keyword:"minProperties",params:{limit:1},message:"must NOT have fewer than 1 properties"}],!1;{let G=a;for(let W in j)if(!(W==="from"||W==="to")){return Je.errors=[{instancePath:e+"/dateUpdated",schemaPath:"#/properties/dateUpdated/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:W},message:"must NOT have additional properties"}],!1;break}if(G===a){if(j.from!==void 0){let W=j.from,X=a;if(a===a)if(typeof W=="string"){if(!Un.test(W))return Je.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 Je.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 q=X===a}else var q=!0;if(q)if(j.to!==void 0){let W=j.to,X=a;if(a===a)if(typeof W=="string"){if(!Un.test(W))return Je.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 Je.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 q=X===a}else var q=!0}}}else return Je.errors=[{instancePath:e+"/dateUpdated",schemaPath:"#/properties/dateUpdated/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var p=J===a}else var p=!0}}}}}}}}}}}}}}}}}}}else return Je.errors=[{instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;return Je.errors=s,a===0}Je.evaluated={props:!0,dynamicProps:!1,dynamicItems:!1};function fn(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:i=t,dynamicAnchors:o={}}={}){let s=null,a=0,d=fn.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.descriptor===void 0&&(p="descriptor"))return fn.errors=[{instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:p},message:"must have required property '"+p+"'"}],!1;{let g=a;for(let v in t)if(!(v==="authorization"||v==="descriptor")){return fn.errors=[{instancePath:e,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:v},message:"must NOT have additional properties"}],!1;break}if(g===a){if(t.authorization!==void 0){let v=a;ho(t.authorization,{instancePath:e+"/authorization",parentData:t,parentDataProperty:"authorization",rootData:i,dynamicAnchors:o})||(s=s===null?ho.errors:s.concat(ho.errors),a=s.length);var u=v===a}else var u=!0;if(u)if(t.descriptor!==void 0){let v=t.descriptor,E=a;if(a===E)if(v&&typeof v=="object"&&!Array.isArray(v)){let P;if(v.interface===void 0&&(P="interface")||v.method===void 0&&(P="method")||v.messageTimestamp===void 0&&(P="messageTimestamp")||v.filter===void 0&&(P="filter"))return fn.errors=[{instancePath:e+"/descriptor",schemaPath:"#/properties/descriptor/required",keyword:"required",params:{missingProperty:P},message:"must have required property '"+P+"'"}],!1;{let I=a;for(let $ in v)if(!($==="interface"||$==="method"||$==="messageTimestamp"||$==="filter"||$==="pagination"||$==="dateSort")){return fn.errors=[{instancePath:e+"/descriptor",schemaPath:"#/properties/descriptor/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:$},message:"must NOT have additional properties"}],!1;break}if(I===a){if(v.interface!==void 0){let $=v.interface,N=a;if(typeof $!="string")return fn.errors=[{instancePath:e+"/descriptor/interface",schemaPath:"#/properties/descriptor/properties/interface/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;if($!=="Records")return fn.errors=[{instancePath:e+"/descriptor/interface",schemaPath:"#/properties/descriptor/properties/interface/enum",keyword:"enum",params:{allowedValues:NB.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(v.method!==void 0){let $=v.method,N=a;if(typeof $!="string")return fn.errors=[{instancePath:e+"/descriptor/method",schemaPath:"#/properties/descriptor/properties/method/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;if($!=="Query")return fn.errors=[{instancePath:e+"/descriptor/method",schemaPath:"#/properties/descriptor/properties/method/enum",keyword:"enum",params:{allowedValues:NB.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(v.messageTimestamp!==void 0){let $=v.messageTimestamp,N=a;if(a===a)if(typeof $=="string"){if(!Un.test($))return fn.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 fn.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(v.filter!==void 0){let $=a;Je(v.filter,{instancePath:e+"/descriptor/filter",parentData:v,parentDataProperty:"filter",rootData:i,dynamicAnchors:o})||(s=s===null?Je.errors:s.concat(Je.errors),a=s.length);var c=$===a}else var c=!0;if(c){if(v.pagination!==void 0){let $=v.pagination,N=a;if(a===N)if($&&typeof $=="object"&&!Array.isArray($)){let F=a;for(let U in $)if(!(U==="limit"||U==="cursor")){return fn.errors=[{instancePath:e+"/descriptor/pagination",schemaPath:"#/properties/descriptor/properties/pagination/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:U},message:"must NOT have additional properties"}],!1;break}if(F===a){if($.limit!==void 0){let U=$.limit,V=a;if(a===V)if(typeof U=="number"&&isFinite(U)){if(U<1||isNaN(U))return fn.errors=[{instancePath:e+"/descriptor/pagination/limit",schemaPath:"#/properties/descriptor/properties/pagination/properties/limit/minimum",keyword:"minimum",params:{comparison:">=",limit:1},message:"must be >= 1"}],!1}else return fn.errors=[{instancePath:e+"/descriptor/pagination/limit",schemaPath:"#/properties/descriptor/properties/pagination/properties/limit/type",keyword:"type",params:{type:"number"},message:"must be number"}],!1;var l=V===a}else var l=!0;if(l)if($.cursor!==void 0){let U=$.cursor,V=a;if(a===a)if(U&&typeof U=="object"&&!Array.isArray(U)){if(Object.keys(U).length<1)return fn.errors=[{instancePath:e+"/descriptor/pagination/cursor",schemaPath:"https://identity.foundation/dwn/json-schemas/pagination-cursor.json/minProperties",keyword:"minProperties",params:{limit:1},message:"must NOT have fewer than 1 properties"}],!1;{let S;if(U.messageCid===void 0&&(S="messageCid")||U.value===void 0&&(S="value"))return fn.errors=[{instancePath:e+"/descriptor/pagination/cursor",schemaPath:"https://identity.foundation/dwn/json-schemas/pagination-cursor.json/required",keyword:"required",params:{missingProperty:S},message:"must have required property '"+S+"'"}],!1;{let k=a;for(let f in U)if(!(f==="messageCid"||f==="value")){return fn.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 fn.errors=[{instancePath:e+"/descriptor/pagination/cursor/messageCid",schemaPath:"https://identity.foundation/dwn/json-schemas/pagination-cursor.json/properties/messageCid/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var 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 fn.errors=[{instancePath:e+"/descriptor/pagination/cursor/value",schemaPath:"https://identity.foundation/dwn/json-schemas/pagination-cursor.json/properties/value/type",keyword:"type",params:{type:a8.properties.value.type},message:"must be string,number"}],!1;var m=y===a}else var m=!0}}}}else return fn.errors=[{instancePath:e+"/descriptor/pagination/cursor",schemaPath:"https://identity.foundation/dwn/json-schemas/pagination-cursor.json/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var l=V===a}else var l=!0}}else return fn.errors=[{instancePath:e+"/descriptor/pagination",schemaPath:"#/properties/descriptor/properties/pagination/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var c=N===a}else var c=!0;if(c)if(v.dateSort!==void 0){let $=v.dateSort,N=a;if(typeof $!="string")return fn.errors=[{instancePath:e+"/descriptor/dateSort",schemaPath:"#/properties/descriptor/properties/dateSort/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;if(!($==="createdAscending"||$==="createdDescending"||$==="publishedAscending"||$==="publishedDescending"))return fn.errors=[{instancePath:e+"/descriptor/dateSort",schemaPath:"#/properties/descriptor/properties/dateSort/enum",keyword:"enum",params:{allowedValues:NB.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 fn.errors=[{instancePath:e+"/descriptor",schemaPath:"#/properties/descriptor/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var u=E===a}else var u=!0}}}else return fn.errors=[{instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;return fn.errors=s,a===0}fn.evaluated={props:!0,dynamicProps:!1,dynamicItems:!1};var C5e=vs,qJ={$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 vs(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:i=t,dynamicAnchors:o={}}={}){let s=null,a=0,d=vs.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 vs.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 vs.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;ho(t.authorization,{instancePath:e+"/authorization",parentData:t,parentDataProperty:"authorization",rootData:i,dynamicAnchors:o})||(s=s===null?ho.errors:s.concat(ho.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 E;if(p.interface===void 0&&(E="interface")||p.method===void 0&&(E="method")||p.messageTimestamp===void 0&&(E="messageTimestamp")||p.filter===void 0&&(E="filter"))return vs.errors=[{instancePath:e+"/descriptor",schemaPath:"#/properties/descriptor/required",keyword:"required",params:{missingProperty:E},message:"must have required property '"+E+"'"}],!1;{let A=a;for(let P in p)if(!(P==="interface"||P==="method"||P==="messageTimestamp"||P==="filter")){return vs.errors=[{instancePath:e+"/descriptor",schemaPath:"#/properties/descriptor/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:P},message:"must NOT have additional properties"}],!1;break}if(A===a){if(p.interface!==void 0){let P=p.interface,I=a;if(typeof P!="string")return vs.errors=[{instancePath:e+"/descriptor/interface",schemaPath:"#/properties/descriptor/properties/interface/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;if(P!=="Records")return vs.errors=[{instancePath:e+"/descriptor/interface",schemaPath:"#/properties/descriptor/properties/interface/enum",keyword:"enum",params:{allowedValues:qJ.properties.descriptor.properties.interface.enum},message:"must be equal to one of the allowed values"}],!1;var c=I===a}else var c=!0;if(c){if(p.method!==void 0){let P=p.method,I=a;if(typeof P!="string")return vs.errors=[{instancePath:e+"/descriptor/method",schemaPath:"#/properties/descriptor/properties/method/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;if(P!=="Subscribe")return vs.errors=[{instancePath:e+"/descriptor/method",schemaPath:"#/properties/descriptor/properties/method/enum",keyword:"enum",params:{allowedValues:qJ.properties.descriptor.properties.method.enum},message:"must be equal to one of the allowed values"}],!1;var c=I===a}else var c=!0;if(c){if(p.messageTimestamp!==void 0){let P=p.messageTimestamp,I=a;if(a===a)if(typeof P=="string"){if(!Un.test(P))return vs.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 vs.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=I===a}else var c=!0;if(c)if(p.filter!==void 0){let P=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=P===a}else var c=!0}}}}}else return vs.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 vs.errors=[{instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;return vs.errors=s,a===0}vs.evaluated={props:!0,dynamicProps:!1,dynamicItems:!1};var $5e=y0;function y0(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:i=t,dynamicAnchors:o={}}={}){let s=null,a=0,d=y0.evaluated;if(d.dynamicProps&&(d.props=void 0),d.dynamicItems&&(d.items=void 0),!Ke(t,{instancePath:e,parentData:r,parentDataProperty:n,rootData:i,dynamicAnchors:o}))s=s===null?Ke.errors:s.concat(Ke.errors),a=s.length;else var u=Ke.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 y0.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 y0.errors=[{instancePath:e,schemaPath:"#/unevaluatedProperties",keyword:"unevaluatedProperties",params:{unevaluatedProperty:l},message:"must NOT have unevaluated properties"}],!1;break}}}else return y0.errors=[{instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;return y0.errors=s,a===0}y0.evaluated={props:!0,dynamicProps:!1,dynamicItems:!1};var N5e=ed,j5e=Ke,U5e=lt,s8={$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 lt(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:i=t,dynamicAnchors:o={}}={}){let s=null,a=0,d=lt.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 lt.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(!UB.call(s8.properties,U)){return lt.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,V=a,L=!1,T=null,S=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:s8.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=S===a;if(l){L=!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&&L?(L=!1,T=[T,1]):l&&(L=!0,T=1),L)a=V,s!==null&&(V?s.length=V: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++,lt.errors=s,!1}var m=U===a}else var m=!0;if(m){if(t.interface!==void 0){let U=t.interface,V=a;if(typeof U!="string")return lt.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 lt.errors=[{instancePath:e+"/interface",schemaPath:"#/properties/interface/enum",keyword:"enum",params:{allowedValues:s8.properties.interface.enum},message:"must be equal to one of the allowed values"}],!1;var p=V===a}else var p=!0;if(p){if(t.method!==void 0){let U=t.method,V=a;if(typeof U!="string")return lt.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 lt.errors=[{instancePath:e+"/method",schemaPath:"#/properties/method/enum",keyword:"enum",params:{allowedValues:s8.properties.method.enum},message:"must be equal to one of the allowed values"}],!1;var p=V===a}else var p=!0;if(p){if(t.protocol!==void 0){let U=a;if(typeof t.protocol!="string")return lt.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 lt.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,V=a;if(a===a)if(typeof U=="string"){if(!b0.test(U))return lt.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 lt.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=V===a}else var p=!0;if(p){if(t.contextId!==void 0){let U=a;if(typeof t.contextId!="string")return lt.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 lt.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 lt.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 lt.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 lt.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,V=a;if(a===a)if(U&&typeof U=="object"&&!Array.isArray(U)){if(Object.keys(U).length<1)return lt.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 S=a;for(let k in U)if(!(k==="gt"||k==="gte"||k==="lt"||k==="lte")){return lt.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(S===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 lt.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 v=k===a}else var v=!0;if(v){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 E=y===a;if(E)return lt.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 v=k===a}else var v=!0;if(v){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 lt.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 v=k===a}else var v=!0;if(v){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 P=y===a;if(P)return lt.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 v=k===a}else var v=!0;if(v){if(U.gt!==void 0){let k=U.gt,f=a;if(!(typeof k=="number"&&isFinite(k)))return lt.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 I=f===a}else var I=!0;if(I){if(U.gte!==void 0){let k=U.gte,f=a;if(!(typeof k=="number"&&isFinite(k)))return lt.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 I=f===a}else var I=!0;if(I){if(U.lt!==void 0){let k=U.lt,f=a;if(!(typeof k=="number"&&isFinite(k)))return lt.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 I=f===a}else var I=!0;if(I)if(U.lte!==void 0){let k=U.lte,f=a;if(!(typeof k=="number"&&isFinite(k)))return lt.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 I=f===a}else var I=!0}}}}}}}}}else return lt.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=V===a}else var p=!0;if(p){if(t.dateCreated!==void 0){let U=t.dateCreated,V=a;if(a===V)if(U&&typeof U=="object"&&!Array.isArray(U)){if(Object.keys(U).length<1)return lt.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 S in U)if(!(S==="from"||S==="to")){return lt.errors=[{instancePath:e+"/dateCreated",schemaPath:"#/properties/dateCreated/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:S},message:"must NOT have additional properties"}],!1;break}if(T===a){if(U.from!==void 0){let S=U.from,k=a;if(a===a)if(typeof S=="string"){if(!Un.test(S))return lt.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 lt.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 S=U.to,k=a;if(a===a)if(typeof S=="string"){if(!Un.test(S))return lt.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 lt.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 lt.errors=[{instancePath:e+"/dateCreated",schemaPath:"#/properties/dateCreated/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var p=V===a}else var p=!0;if(p){if(t.datePublished!==void 0){let U=t.datePublished,V=a;if(a===V)if(U&&typeof U=="object"&&!Array.isArray(U)){if(Object.keys(U).length<1)return lt.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 S in U)if(!(S==="from"||S==="to")){return lt.errors=[{instancePath:e+"/datePublished",schemaPath:"#/properties/datePublished/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:S},message:"must NOT have additional properties"}],!1;break}if(T===a){if(U.from!==void 0){let S=U.from,k=a;if(a===a)if(typeof S=="string"){if(!Un.test(S))return lt.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 lt.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 S=U.to,k=a;if(a===a)if(typeof S=="string"){if(!Un.test(S))return lt.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 lt.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 lt.errors=[{instancePath:e+"/datePublished",schemaPath:"#/properties/datePublished/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var p=V===a}else var p=!0;if(p)if(t.dateUpdated!==void 0){let U=t.dateUpdated,V=a;if(a===V)if(U&&typeof U=="object"&&!Array.isArray(U)){if(Object.keys(U).length<1)return lt.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 S in U)if(!(S==="from"||S==="to")){return lt.errors=[{instancePath:e+"/dateUpdated",schemaPath:"#/properties/dateUpdated/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:S},message:"must NOT have additional properties"}],!1;break}if(T===a){if(U.from!==void 0){let S=U.from,k=a;if(a===a)if(typeof S=="string"){if(!Un.test(S))return lt.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 lt.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 K=k===a}else var K=!0;if(K)if(U.to!==void 0){let S=U.to,k=a;if(a===a)if(typeof S=="string"){if(!Un.test(S))return lt.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 lt.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 K=k===a}else var K=!0}}}else return lt.errors=[{instancePath:e+"/dateUpdated",schemaPath:"#/properties/dateUpdated/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var p=V===a}else var p=!0}}}}}}}}}}}}}}}}else return lt.errors=[{instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;return lt.errors=s,a===0}lt.evaluated={props:!0,dynamicProps:!1,dynamicItems:!1};var q5e=Si,LJ={$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 Si(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:i=t,dynamicAnchors:o={}}={}){let s=null,a=0,d=Si.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 Si.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 Si.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;qn(t.authorization,{instancePath:e+"/authorization",parentData:t,parentDataProperty:"authorization",rootData:i,dynamicAnchors:o})||(s=s===null?qn.errors:s.concat(qn.errors),a=s.length);var u=g===a}else var u=!0;if(u)if(t.descriptor!==void 0){let g=t.descriptor,v=a;if(a===v)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 Si.errors=[{instancePath:e+"/descriptor",schemaPath:"#/properties/descriptor/required",keyword:"required",params:{missingProperty:A},message:"must have required property '"+A+"'"}],!1;{let P=a;for(let I in g)if(!(I==="interface"||I==="method"||I==="messageTimestamp"||I==="cursor")){return Si.errors=[{instancePath:e+"/descriptor",schemaPath:"#/properties/descriptor/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:I},message:"must NOT have additional properties"}],!1;break}if(P===a){if(g.interface!==void 0){let I=g.interface,$=a;if(typeof I!="string")return Si.errors=[{instancePath:e+"/descriptor/interface",schemaPath:"#/properties/descriptor/properties/interface/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;if(I!=="Events")return Si.errors=[{instancePath:e+"/descriptor/interface",schemaPath:"#/properties/descriptor/properties/interface/enum",keyword:"enum",params:{allowedValues:LJ.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 I=g.method,$=a;if(typeof I!="string")return Si.errors=[{instancePath:e+"/descriptor/method",schemaPath:"#/properties/descriptor/properties/method/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;if(I!=="Get")return Si.errors=[{instancePath:e+"/descriptor/method",schemaPath:"#/properties/descriptor/properties/method/enum",keyword:"enum",params:{allowedValues:LJ.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 I=a;if(typeof g.messageTimestamp!="string")return Si.errors=[{instancePath:e+"/descriptor/messageTimestamp",schemaPath:"#/properties/descriptor/properties/messageTimestamp/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var c=I===a}else var c=!0;if(c)if(g.cursor!==void 0){let I=g.cursor,$=a;if(a===a)if(I&&typeof I=="object"&&!Array.isArray(I)){if(Object.keys(I).length<1)return Si.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(I.messageCid===void 0&&(F="messageCid")||I.value===void 0&&(F="value"))return Si.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 V in I)if(!(V==="messageCid"||V==="value")){return Si.errors=[{instancePath:e+"/descriptor/cursor",schemaPath:"https://identity.foundation/dwn/json-schemas/pagination-cursor.json/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:V},message:"must NOT have additional properties"}],!1;break}if(U===a){if(I.messageCid!==void 0){let V=a;if(typeof I.messageCid!="string")return Si.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=V===a}else var l=!0;if(l)if(I.value!==void 0){let V=I.value,L=a;if(typeof V!="string"&&!(typeof V=="number"&&isFinite(V)))return Si.errors=[{instancePath:e+"/descriptor/cursor/value",schemaPath:"https://identity.foundation/dwn/json-schemas/pagination-cursor.json/properties/value/type",keyword:"type",params:{type:a8.properties.value.type},message:"must be string,number"}],!1;var l=L===a}else var l=!0}}}}else return Si.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 Si.errors=[{instancePath:e+"/descriptor",schemaPath:"#/properties/descriptor/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var u=v===a}else var u=!0}}}else return Si.errors=[{instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;return Si.errors=s,a===0}Si.evaluated={props:!0,dynamicProps:!1,dynamicItems:!1};var L5e=jn,KJ={$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 jn(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:i=t,dynamicAnchors:o={}}={}){let s=null,a=0,d=jn.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 jn.errors=[{instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:p},message:"must have required property '"+p+"'"}],!1;{let g=a;for(let v in t)if(!(v==="authorization"||v==="descriptor")){return jn.errors=[{instancePath:e,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:v},message:"must NOT have additional properties"}],!1;break}if(g===a){if(t.authorization!==void 0){let v=a;qn(t.authorization,{instancePath:e+"/authorization",parentData:t,parentDataProperty:"authorization",rootData:i,dynamicAnchors:o})||(s=s===null?qn.errors:s.concat(qn.errors),a=s.length);var u=v===a}else var u=!0;if(u)if(t.descriptor!==void 0){let v=t.descriptor,E=a;if(a===E)if(v&&typeof v=="object"&&!Array.isArray(v)){let P;if(v.interface===void 0&&(P="interface")||v.method===void 0&&(P="method")||v.messageTimestamp===void 0&&(P="messageTimestamp")||v.filters===void 0&&(P="filters"))return jn.errors=[{instancePath:e+"/descriptor",schemaPath:"#/properties/descriptor/required",keyword:"required",params:{missingProperty:P},message:"must have required property '"+P+"'"}],!1;{let I=a;for(let $ in v)if(!($==="interface"||$==="method"||$==="messageTimestamp"||$==="filters"||$==="cursor")){return jn.errors=[{instancePath:e+"/descriptor",schemaPath:"#/properties/descriptor/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:$},message:"must NOT have additional properties"}],!1;break}if(I===a){if(v.interface!==void 0){let $=v.interface,N=a;if(typeof $!="string")return jn.errors=[{instancePath:e+"/descriptor/interface",schemaPath:"#/properties/descriptor/properties/interface/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;if($!=="Events")return jn.errors=[{instancePath:e+"/descriptor/interface",schemaPath:"#/properties/descriptor/properties/interface/enum",keyword:"enum",params:{allowedValues:KJ.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(v.method!==void 0){let $=v.method,N=a;if(typeof $!="string")return jn.errors=[{instancePath:e+"/descriptor/method",schemaPath:"#/properties/descriptor/properties/method/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;if($!=="Query")return jn.errors=[{instancePath:e+"/descriptor/method",schemaPath:"#/properties/descriptor/properties/method/enum",keyword:"enum",params:{allowedValues:KJ.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(v.messageTimestamp!==void 0){let $=v.messageTimestamp,N=a;if(a===a)if(typeof $=="string"){if(!Un.test($))return jn.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 jn.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(v.filters!==void 0){let $=v.filters,N=a;if(a===N)if(Array.isArray($)){if($.length<1)return jn.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<F;U++){let V=a;lt($[U],{instancePath:e+"/descriptor/filters/"+U,parentData:$,parentDataProperty:U,rootData:i,dynamicAnchors:o})||(s=s===null?lt.errors:s.concat(lt.errors),a=s.length);var l=V===a;if(!l)break}}}else return jn.errors=[{instancePath:e+"/descriptor/filters",schemaPath:"#/properties/descriptor/properties/filters/type",keyword:"type",params:{type:"array"},message:"must be array"}],!1;var c=N===a}else var c=!0;if(c)if(v.cursor!==void 0){let $=v.cursor,N=a;if(a===a)if($&&typeof $=="object"&&!Array.isArray($)){if(Object.keys($).length<1)return jn.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 U;if($.messageCid===void 0&&(U="messageCid")||$.value===void 0&&(U="value"))return jn.errors=[{instancePath:e+"/descriptor/cursor",schemaPath:"https://identity.foundation/dwn/json-schemas/pagination-cursor.json/required",keyword:"required",params:{missingProperty:U},message:"must have required property '"+U+"'"}],!1;{let V=a;for(let L in $)if(!(L==="messageCid"||L==="value")){return jn.errors=[{instancePath:e+"/descriptor/cursor",schemaPath:"https://identity.foundation/dwn/json-schemas/pagination-cursor.json/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:L},message:"must NOT have additional properties"}],!1;break}if(V===a){if($.messageCid!==void 0){let L=a;if(typeof $.messageCid!="string")return jn.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 m=L===a}else var m=!0;if(m)if($.value!==void 0){let L=$.value,T=a;if(typeof L!="string"&&!(typeof L=="number"&&isFinite(L)))return jn.errors=[{instancePath:e+"/descriptor/cursor/value",schemaPath:"https://identity.foundation/dwn/json-schemas/pagination-cursor.json/properties/value/type",keyword:"type",params:{type:a8.properties.value.type},message:"must be string,number"}],!1;var m=T===a}else var m=!0}}}}else return jn.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=N===a}else var c=!0}}}}}}else return jn.errors=[{instancePath:e+"/descriptor",schemaPath:"#/properties/descriptor/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var u=E===a}else var u=!0}}}else return jn.errors=[{instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;return jn.errors=s,a===0}jn.evaluated={props:!0,dynamicProps:!1,dynamicItems:!1};var K5e=bs,FJ={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://identity.foundation/dwn/json-schemas/events-subscribe.json",type:"object",additionalProperties:!1,required:["descriptor","authorization"],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:["Subscribe"],type:"string"},messageTimestamp:{type:"string"},filters:{type:"array",items:{$ref:"https://identity.foundation/dwn/json-schemas/events-filter.json"}}}}}};function bs(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:i=t,dynamicAnchors:o={}}={}){let s=null,a=0,d=bs.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.descriptor===void 0&&(m="descriptor")||t.authorization===void 0&&(m="authorization"))return bs.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 bs.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;qn(t.authorization,{instancePath:e+"/authorization",parentData:t,parentDataProperty:"authorization",rootData:i,dynamicAnchors:o})||(s=s===null?qn.errors:s.concat(qn.errors),a=s.length);var u=g===a}else var u=!0;if(u)if(t.descriptor!==void 0){let g=t.descriptor,v=a;if(a===v)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")||g.filters===void 0&&(A="filters"))return bs.errors=[{instancePath:e+"/descriptor",schemaPath:"#/properties/descriptor/required",keyword:"required",params:{missingProperty:A},message:"must have required property '"+A+"'"}],!1;{let P=a;for(let I in g)if(!(I==="interface"||I==="method"||I==="messageTimestamp"||I==="filters")){return bs.errors=[{instancePath:e+"/descriptor",schemaPath:"#/properties/descriptor/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:I},message:"must NOT have additional properties"}],!1;break}if(P===a){if(g.interface!==void 0){let I=g.interface,$=a;if(typeof I!="string")return bs.errors=[{instancePath:e+"/descriptor/interface",schemaPath:"#/properties/descriptor/properties/interface/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;if(I!=="Events")return bs.errors=[{instancePath:e+"/descriptor/interface",schemaPath:"#/properties/descriptor/properties/interface/enum",keyword:"enum",params:{allowedValues:FJ.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 I=g.method,$=a;if(typeof I!="string")return bs.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 bs.errors=[{instancePath:e+"/descriptor/method",schemaPath:"#/properties/descriptor/properties/method/enum",keyword:"enum",params:{allowedValues:FJ.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 I=a;if(typeof g.messageTimestamp!="string")return bs.errors=[{instancePath:e+"/descriptor/messageTimestamp",schemaPath:"#/properties/descriptor/properties/messageTimestamp/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var c=I===a}else var c=!0;if(c)if(g.filters!==void 0){let I=g.filters,$=a;if(a===$)if(Array.isArray(I)){var l=!0;let K=I.length;for(let F=0;F<K;F++){let U=a;lt(I[F],{instancePath:e+"/descriptor/filters/"+F,parentData:I,parentDataProperty:F,rootData:i,dynamicAnchors:o})||(s=s===null?lt.errors:s.concat(lt.errors),a=s.length);var l=U===a;if(!l)break}}else return bs.errors=[{instancePath:e+"/descriptor/filters",schemaPath:"#/properties/descriptor/properties/filters/type",keyword:"type",params:{type:"array"},message:"must be array"}],!1;var c=$===a}else var c=!0}}}}}else return bs.errors=[{instancePath:e+"/descriptor",schemaPath:"#/properties/descriptor/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var u=v===a}else var u=!0}}}else return bs.errors=[{instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;return bs.errors=s,a===0}bs.evaluated={props:!0,dynamicProps:!1,dynamicItems:!1};var F5e=L_;function L_(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:i=t,dynamicAnchors:o={}}={}){let s=null,a=0,d=L_.evaluated;return d.dynamicProps&&(d.props=void 0),d.dynamicItems&&(d.items=void 0),t&&typeof t=="object"&&!Array.isArray(t)?(L_.errors=s,a===0):(L_.errors=[{instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1)}L_.evaluated={dynamicProps:!1,dynamicItems:!1};var z5e=qo;function qo(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:i=t,dynamicAnchors:o={}}={}){let s=null,a=0,d=qo.evaluated;d.dynamicProps&&(d.props=void 0),d.dynamicItems&&(d.items=void 0);let u=a,c=!1,l=null,m=a;if(t&&typeof t=="object"&&!Array.isArray(t)){let N;if(t.crv===void 0&&(N="crv")||t.x===void 0&&(N="x")){let K={instancePath:e,schemaPath:"#/oneOf/0/required",keyword:"required",params:{missingProperty:N},message:"must have required property '"+N+"'"};s===null?s=[K]:s.push(K),a++}else{if(t.kty!==void 0){let K=a;if(t.kty!=="EC"){let F={instancePath:e+"/kty",schemaPath:"#/oneOf/0/properties/kty/const",keyword:"const",params:{allowedValue:"EC"},message:"must be equal to constant"};s===null?s=[F]:s.push(F),a++}var p=K===a}else var p=!0;if(p){if(t.crv!==void 0){let K=a;if(typeof t.crv!="string"){let U={instancePath:e+"/crv",schemaPath:"#/oneOf/0/properties/crv/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[U]:s.push(U),a++}var p=K===a}else var p=!0;if(p){if(t.x!==void 0){let K=a;if(typeof t.x!="string"){let U={instancePath:e+"/x",schemaPath:"#/oneOf/0/properties/x/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[U]:s.push(U),a++}var p=K===a}else var p=!0;if(p){if(t.y!==void 0){let K=a;if(typeof t.y!="string"){let U={instancePath:e+"/y",schemaPath:"#/oneOf/0/properties/y/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[U]:s.push(U),a++}var p=K===a}else var p=!0;if(p)if(t.d!==void 0){let K=a;if(typeof t.d!="string"){let U={instancePath:e+"/d",schemaPath:"#/oneOf/0/properties/d/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[U]:s.push(U),a++}var p=K===a}else var p=!0}}}}}var A=m===a;if(A){c=!0,l=0;var g={};g.kty=!0,g.crv=!0,g.x=!0,g.y=!0,g.d=!0}let v=a;if(t&&typeof t=="object"&&!Array.isArray(t)){let N;if(t.crv===void 0&&(N="crv")||t.x===void 0&&(N="x")){let K={instancePath:e,schemaPath:"#/oneOf/1/required",keyword:"required",params:{missingProperty:N},message:"must have required property '"+N+"'"};s===null?s=[K]:s.push(K),a++}else{if(t.kty!==void 0){let K=a;if(t.kty!=="OKP"){let F={instancePath:e+"/kty",schemaPath:"#/oneOf/1/properties/kty/const",keyword:"const",params:{allowedValue:"OKP"},message:"must be equal to constant"};s===null?s=[F]:s.push(F),a++}var E=K===a}else var E=!0;if(E){if(t.crv!==void 0){let K=a;if(typeof t.crv!="string"){let U={instancePath:e+"/crv",schemaPath:"#/oneOf/1/properties/crv/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[U]:s.push(U),a++}var E=K===a}else var E=!0;if(E){if(t.x!==void 0){let K=a;if(typeof t.x!="string"){let U={instancePath:e+"/x",schemaPath:"#/oneOf/1/properties/x/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[U]:s.push(U),a++}var E=K===a}else var E=!0;if(E)if(t.d!==void 0){let K=a;if(typeof t.d!="string"){let U={instancePath:e+"/d",schemaPath:"#/oneOf/1/properties/d/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[U]:s.push(U),a++}var E=K===a}else var E=!0}}}}var A=v===a;if(A&&c)c=!1,l=[l,1];else{A&&(c=!0,l=1,g!==!0&&(g=g||{},g.kty=!0,g.crv=!0,g.x=!0,g.d=!0));let N=a;if(t&&typeof t=="object"&&!Array.isArray(t)){let F;if(t.n===void 0&&(F="n")||t.e===void 0&&(F="e")){let U={instancePath:e,schemaPath:"#/oneOf/2/required",keyword:"required",params:{missingProperty:F},message:"must have required property '"+F+"'"};s===null?s=[U]:s.push(U),a++}else{if(t.kty!==void 0){let U=a;if(t.kty!=="RSA"){let V={instancePath:e+"/kty",schemaPath:"#/oneOf/2/properties/kty/const",keyword:"const",params:{allowedValue:"RSA"},message:"must be equal to constant"};s===null?s=[V]:s.push(V),a++}var P=U===a}else var P=!0;if(P){if(t.n!==void 0){let U=a;if(typeof t.n!="string"){let L={instancePath:e+"/n",schemaPath:"#/oneOf/2/properties/n/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[L]:s.push(L),a++}var P=U===a}else var P=!0;if(P){if(t.e!==void 0){let U=a;if(typeof t.e!="string"){let L={instancePath:e+"/e",schemaPath:"#/oneOf/2/properties/e/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[L]:s.push(L),a++}var P=U===a}else var P=!0;if(P){if(t.d!==void 0){let U=a;if(typeof t.d!="string"){let L={instancePath:e+"/d",schemaPath:"#/oneOf/2/properties/d/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[L]:s.push(L),a++}var P=U===a}else var P=!0;if(P){if(t.p!==void 0){let U=a;if(typeof t.p!="string"){let L={instancePath:e+"/p",schemaPath:"#/oneOf/2/properties/p/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[L]:s.push(L),a++}var P=U===a}else var P=!0;if(P){if(t.q!==void 0){let U=a;if(typeof t.q!="string"){let L={instancePath:e+"/q",schemaPath:"#/oneOf/2/properties/q/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[L]:s.push(L),a++}var P=U===a}else var P=!0;if(P){if(t.dp!==void 0){let U=a;if(typeof t.dp!="string"){let L={instancePath:e+"/dp",schemaPath:"#/oneOf/2/properties/dp/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[L]:s.push(L),a++}var P=U===a}else var P=!0;if(P){if(t.dq!==void 0){let U=a;if(typeof t.dq!="string"){let L={instancePath:e+"/dq",schemaPath:"#/oneOf/2/properties/dq/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[L]:s.push(L),a++}var P=U===a}else var P=!0;if(P){if(t.qi!==void 0){let U=a;if(typeof t.qi!="string"){let L={instancePath:e+"/qi",schemaPath:"#/oneOf/2/properties/qi/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[L]:s.push(L),a++}var P=U===a}else var P=!0;if(P)if(t.oth!==void 0){let U=t.oth,V=a;if(!(U&&typeof U=="object"&&!Array.isArray(U))){let T={instancePath:e+"/oth",schemaPath:"#/oneOf/2/properties/oth/type",keyword:"type",params:{type:"object"},message:"must be object"};s===null?s=[T]:s.push(T),a++}var P=V===a}else var P=!0}}}}}}}}}}var A=N===a;if(A&&c)c=!1,l=[l,2];else{A&&(c=!0,l=2,g!==!0&&(g=g||{},g.kty=!0,g.n=!0,g.e=!0,g.d=!0,g.p=!0,g.q=!0,g.dp=!0,g.dq=!0,g.qi=!0,g.oth=!0));let F=a;if(t&&typeof t=="object"&&!Array.isArray(t)){let V;if(t.k===void 0&&(V="k")){let L={instancePath:e,schemaPath:"#/oneOf/3/required",keyword:"required",params:{missingProperty:V},message:"must have required property '"+V+"'"};s===null?s=[L]:s.push(L),a++}else{if(t.kty!==void 0){let L=a;if(t.kty!=="oct"){let T={instancePath:e+"/kty",schemaPath:"#/oneOf/3/properties/kty/const",keyword:"const",params:{allowedValue:"oct"},message:"must be equal to constant"};s===null?s=[T]:s.push(T),a++}var I=L===a}else var I=!0;if(I)if(t.k!==void 0){let L=a;if(typeof t.k!="string"){let S={instancePath:e+"/k",schemaPath:"#/oneOf/3/properties/k/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[S]:s.push(S),a++}var I=L===a}else var I=!0}}var A=F===a;A&&c?(c=!1,l=[l,3]):A&&(c=!0,l=3,g!==!0&&(g=g||{},g.kty=!0,g.k=!0))}}if(c)a=u,s!==null&&(u?s.length=u:s=null);else{let N={instancePath:e,schemaPath:"#/oneOf",keyword:"oneOf",params:{passingSchemas:l},message:"must match exactly one schema in oneOf"};return s===null?s=[N]:s.push(N),a++,qo.errors=s,!1}if(a===0)if(t&&typeof t=="object"&&!Array.isArray(t)){let N;if(t.kty===void 0&&(N="kty"))return qo.errors=[{instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:N},message:"must have required property '"+N+"'"}],!1;if(g!==!0&&(g=g||{},g.alg=!0,g.kid=!0,g.kty=!0,g.crv=!0,g.use=!0,g.key_ops=!0,g.x5u=!0,g.x5c=!0,g.x5t=!0,g["x5t#S256"]=!0),t.alg!==void 0){let K=a;if(typeof t.alg!="string")return qo.errors=[{instancePath:e+"/alg",schemaPath:"#/properties/alg/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var $=K===a}else var $=!0;if($){if(t.kid!==void 0){let K=a;if(typeof t.kid!="string")return qo.errors=[{instancePath:e+"/kid",schemaPath:"#/properties/kid/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var $=K===a}else var $=!0;if($){if(t.kty!==void 0){let K=t.kty,F=a;if(!(K==="EC"||K==="RSA"||K==="oct"||K==="OKP"))return qo.errors=[{instancePath:e+"/kty",schemaPath:"#/properties/kty/enum",keyword:"enum",params:{allowedValues:ZJ.properties.kty.enum},message:"must be equal to one of the allowed values"}],!1;var $=F===a}else var $=!0;if($){if(t.crv!==void 0){let K=a;if(typeof t.crv!="string")return qo.errors=[{instancePath:e+"/crv",schemaPath:"#/properties/crv/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var $=K===a}else var $=!0;if($){if(t.use!==void 0){let K=a;if(typeof t.use!="string")return qo.errors=[{instancePath:e+"/use",schemaPath:"#/properties/use/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var $=K===a}else var $=!0;if($){if(t.key_ops!==void 0){let K=a;if(typeof t.key_ops!="string")return qo.errors=[{instancePath:e+"/key_ops",schemaPath:"#/properties/key_ops/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var $=K===a}else var $=!0;if($){if(t.x5u!==void 0){let K=a;if(typeof t.x5u!="string")return qo.errors=[{instancePath:e+"/x5u",schemaPath:"#/properties/x5u/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var $=K===a}else var $=!0;if($){if(t.x5c!==void 0){let K=a;if(typeof t.x5c!="string")return qo.errors=[{instancePath:e+"/x5c",schemaPath:"#/properties/x5c/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var $=K===a}else var $=!0;if($){if(t.x5t!==void 0){let K=a;if(typeof t.x5t!="string")return qo.errors=[{instancePath:e+"/x5t",schemaPath:"#/properties/x5t/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var $=K===a}else var $=!0;if($)if(t["x5t#S256"]!==void 0){let K=a;if(typeof t["x5t#S256"]!="string")return qo.errors=[{instancePath:e+"/x5t#S256",schemaPath:"#/properties/x5t%23S256/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var $=K===a}else var $=!0}}}}}}}}}else return qo.errors=[{instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;return qo.errors=s,d.props=g,a===0}qo.evaluated={dynamicProps:!0,dynamicItems:!1};var V5e=rn,H5e=Zd,W5e={$id:"https://identity.foundation/dwn/json-schemas/jwk-verification-method.json",$schema:"https://json-schema.org/draft/2020-12/schema",type:"object",additionalProperties:!1,required:["id","type","controller","publicKeyJwk"],properties:{id:{type:"string"},type:{enum:["JsonWebKey","JsonWebKey2020"]},controller:{$ref:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/did"},publicKeyJwk:{$ref:"https://identity.foundation/dwn/json-schemas/public-jwk.json"}}};function Zd(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:i=t,dynamicAnchors:o={}}={}){let s=null,a=0,d=Zd.evaluated;if(d.dynamicProps&&(d.props=void 0),d.dynamicItems&&(d.items=void 0),a===0)if(t&&typeof t=="object"&&!Array.isArray(t)){let c;if(t.id===void 0&&(c="id")||t.type===void 0&&(c="type")||t.controller===void 0&&(c="controller")||t.publicKeyJwk===void 0&&(c="publicKeyJwk"))return Zd.errors=[{instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:c},message:"must have required property '"+c+"'"}],!1;{let l=a;for(let m in t)if(!(m==="id"||m==="type"||m==="controller"||m==="publicKeyJwk")){return Zd.errors=[{instancePath:e,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:m},message:"must NOT have additional properties"}],!1;break}if(l===a){if(t.id!==void 0){let m=a;if(typeof t.id!="string")return Zd.errors=[{instancePath:e+"/id",schemaPath:"#/properties/id/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var u=m===a}else var u=!0;if(u){if(t.type!==void 0){let m=t.type,p=a;if(!(m==="JsonWebKey"||m==="JsonWebKey2020"))return Zd.errors=[{instancePath:e+"/type",schemaPath:"#/properties/type/enum",keyword:"enum",params:{allowedValues:W5e.properties.type.enum},message:"must be equal to one of the allowed values"}],!1;var u=p===a}else var u=!0;if(u){if(t.controller!==void 0){let m=t.controller,p=a;if(a===a)if(typeof m=="string"){if(!b0.test(m))return Zd.errors=[{instancePath:e+"/controller",schemaPath:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/did/pattern",keyword:"pattern",params:{pattern:"^did:([a-z0-9]+):((?:(?:[a-zA-Z0-9._-]|(?:%[0-9a-fA-F]{2}))*:)*((?:[a-zA-Z0-9._-]|(?:%[0-9a-fA-F]{2}))+))((;[a-zA-Z0-9_.:%-]+=[a-zA-Z0-9_.:%-]*)*)(/[^#?]*)?([?][^#]*)?(#.*)?$"},message:'must match pattern "^did:([a-z0-9]+):((?:(?:[a-zA-Z0-9._-]|(?:%[0-9a-fA-F]{2}))*:)*((?:[a-zA-Z0-9._-]|(?:%[0-9a-fA-F]{2}))+))((;[a-zA-Z0-9_.:%-]+=[a-zA-Z0-9_.:%-]*)*)(/[^#?]*)?([?][^#]*)?(#.*)?$"'}],!1}else return Zd.errors=[{instancePath:e+"/controller",schemaPath:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/did/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var u=p===a}else var u=!0;if(u)if(t.publicKeyJwk!==void 0){let m=a;tn(t.publicKeyJwk,{instancePath:e+"/publicKeyJwk",parentData:t,parentDataProperty:"publicKeyJwk",rootData:i,dynamicAnchors:o})||(s=s===null?tn.errors:s.concat(tn.errors),a=s.length);var u=m===a}else var u=!0}}}}}else return Zd.errors=[{instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;return Zd.errors=s,a===0}Zd.evaluated={props:!0,dynamicProps:!1,dynamicItems:!1};var G5e=Hi,zJ={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://identity.foundation/dwn/json-schemas/messages-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:["Messages"],type:"string"},method:{enum:["Get"],type:"string"},messageTimestamp:{$ref:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/date-time"},messageCids:{type:"array",items:{type:"string"},minItems:1}}}}};function Hi(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:i=t,dynamicAnchors:o={}}={}){let s=null,a=0,d=Hi.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 Hi.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 Hi.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;qn(t.authorization,{instancePath:e+"/authorization",parentData:t,parentDataProperty:"authorization",rootData:i,dynamicAnchors:o})||(s=s===null?qn.errors:s.concat(qn.errors),a=s.length);var u=g===a}else var u=!0;if(u)if(t.descriptor!==void 0){let g=t.descriptor,v=a;if(a===v)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 Hi.errors=[{instancePath:e+"/descriptor",schemaPath:"#/properties/descriptor/required",keyword:"required",params:{missingProperty:A},message:"must have required property '"+A+"'"}],!1;{let P=a;for(let I in g)if(!(I==="interface"||I==="method"||I==="messageTimestamp"||I==="messageCids")){return Hi.errors=[{instancePath:e+"/descriptor",schemaPath:"#/properties/descriptor/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:I},message:"must NOT have additional properties"}],!1;break}if(P===a){if(g.interface!==void 0){let I=g.interface,$=a;if(typeof I!="string")return Hi.errors=[{instancePath:e+"/descriptor/interface",schemaPath:"#/properties/descriptor/properties/interface/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;if(I!=="Messages")return Hi.errors=[{instancePath:e+"/descriptor/interface",schemaPath:"#/properties/descriptor/properties/interface/enum",keyword:"enum",params:{allowedValues:zJ.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 I=g.method,$=a;if(typeof I!="string")return Hi.errors=[{instancePath:e+"/descriptor/method",schemaPath:"#/properties/descriptor/properties/method/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;if(I!=="Get")return Hi.errors=[{instancePath:e+"/descriptor/method",schemaPath:"#/properties/descriptor/properties/method/enum",keyword:"enum",params:{allowedValues:zJ.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 I=g.messageTimestamp,$=a;if(a===a)if(typeof I=="string"){if(!Un.test(I))return Hi.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 Hi.errors=[{instancePath:e+"/descriptor/messageTimestamp",schemaPath:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/date-time/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var c=$===a}else var c=!0;if(c)if(g.messageCids!==void 0){let I=g.messageCids,$=a;if(a===$)if(Array.isArray(I)){if(I.length<1)return Hi.errors=[{instancePath:e+"/descriptor/messageCids",schemaPath:"#/properties/descriptor/properties/messageCids/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"}],!1;{var l=!0;let K=I.length;for(let F=0;F<K;F++){let U=a;if(typeof I[F]!="string")return Hi.errors=[{instancePath:e+"/descriptor/messageCids/"+F,schemaPath:"#/properties/descriptor/properties/messageCids/items/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var l=U===a;if(!l)break}}}else return Hi.errors=[{instancePath:e+"/descriptor/messageCids",schemaPath:"#/properties/descriptor/properties/messageCids/type",keyword:"type",params:{type:"array"},message:"must be array"}],!1;var c=$===a}else var c=!0}}}}}else return Hi.errors=[{instancePath:e+"/descriptor",schemaPath:"#/properties/descriptor/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var u=v===a}else var u=!0}}}else return Hi.errors=[{instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;return Hi.errors=s,a===0}Hi.evaluated={props:!0,dynamicProps:!1,dynamicItems:!1};var J5e=Qs;function Qs(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:i=t,dynamicAnchors:o={}}={}){let s=null,a=0,d=Qs.evaluated;if(d.dynamicProps&&(d.props=void 0),d.dynamicItems&&(d.items=void 0),a===0)if(t&&typeof t=="object"&&!Array.isArray(t)){if(Object.keys(t).length<1)return Qs.errors=[{instancePath:e,schemaPath:"#/minProperties",keyword:"minProperties",params:{limit:1},message:"must NOT have fewer than 1 properties"}],!1;{let v=a;for(let E in t)if(!(E==="gt"||E==="gte"||E==="lt"||E==="lte")){return Qs.errors=[{instancePath:e,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:E},message:"must NOT have additional properties"}],!1;break}if(v===a){if(t.gt!==void 0){let E=a,A=a,P=a;if(t&&typeof t=="object"&&!Array.isArray(t)){let I;if(t.gte===void 0&&(I="gte")){let $={};s===null?s=[$]:s.push($),a++}}var u=P===a;if(u)return Qs.errors=[{instancePath:e,schemaPath:"#/dependencies/gt/not",keyword:"not",params:{},message:"must NOT be valid"}],!1;a=A,s!==null&&(A?s.length=A:s=null);var c=E===a}else var c=!0;if(c){if(t.gte!==void 0){let E=a,A=a,P=a;if(t&&typeof t=="object"&&!Array.isArray(t)){let $;if(t.gt===void 0&&($="gt")){let N={};s===null?s=[N]:s.push(N),a++}}var l=P===a;if(l)return Qs.errors=[{instancePath:e,schemaPath:"#/dependencies/gte/not",keyword:"not",params:{},message:"must NOT be valid"}],!1;a=A,s!==null&&(A?s.length=A:s=null);var c=E===a}else var c=!0;if(c){if(t.lt!==void 0){let E=a,A=a,P=a;if(t&&typeof t=="object"&&!Array.isArray(t)){let $;if(t.lte===void 0&&($="lte")){let N={};s===null?s=[N]:s.push(N),a++}}var m=P===a;if(m)return Qs.errors=[{instancePath:e,schemaPath:"#/dependencies/lt/not",keyword:"not",params:{},message:"must NOT be valid"}],!1;a=A,s!==null&&(A?s.length=A:s=null);var c=E===a}else var c=!0;if(c){if(t.lte!==void 0){let E=a,A=a,P=a;if(t&&typeof t=="object"&&!Array.isArray(t)){let $;if(t.lt===void 0&&($="lt")){let N={};s===null?s=[N]:s.push(N),a++}}var p=P===a;if(p)return Qs.errors=[{instancePath:e,schemaPath:"#/dependencies/lte/not",keyword:"not",params:{},message:"must NOT be valid"}],!1;a=A,s!==null&&(A?s.length=A:s=null);var c=E===a}else var c=!0;if(c){if(t.gt!==void 0){let E=t.gt,A=a;if(!(typeof E=="number"&&isFinite(E)))return Qs.errors=[{instancePath:e+"/gt",schemaPath:"#/properties/gt/type",keyword:"type",params:{type:"number"},message:"must be number"}],!1;var g=A===a}else var g=!0;if(g){if(t.gte!==void 0){let E=t.gte,A=a;if(!(typeof E=="number"&&isFinite(E)))return Qs.errors=[{instancePath:e+"/gte",schemaPath:"#/properties/gte/type",keyword:"type",params:{type:"number"},message:"must be number"}],!1;var g=A===a}else var g=!0;if(g){if(t.lt!==void 0){let E=t.lt,A=a;if(!(typeof E=="number"&&isFinite(E)))return Qs.errors=[{instancePath:e+"/lt",schemaPath:"#/properties/lt/type",keyword:"type",params:{type:"number"},message:"must be number"}],!1;var g=A===a}else var g=!0;if(g)if(t.lte!==void 0){let E=t.lte,A=a;if(!(typeof E=="number"&&isFinite(E)))return Qs.errors=[{instancePath:e+"/lte",schemaPath:"#/properties/lte/type",keyword:"type",params:{type:"number"},message:"must be number"}],!1;var g=A===a}else var g=!0}}}}}}}}}else return Qs.errors=[{instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;return Qs.errors=s,a===0}Qs.evaluated={props:!0,dynamicProps:!1,dynamicItems:!1};var Y5e=pl;function pl(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:i=t,dynamicAnchors:o={}}={}){let s=null,a=0,d=pl.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 pl.errors=[{instancePath:e,schemaPath:"#/minProperties",keyword:"minProperties",params:{limit:1},message:"must NOT have fewer than 1 properties"}],!1;{let c;if(t.messageCid===void 0&&(c="messageCid")||t.value===void 0&&(c="value"))return pl.errors=[{instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:c},message:"must have required property '"+c+"'"}],!1;{let l=a;for(let m in t)if(!(m==="messageCid"||m==="value")){return pl.errors=[{instancePath:e,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:m},message:"must NOT have additional properties"}],!1;break}if(l===a){if(t.messageCid!==void 0){let m=a;if(typeof t.messageCid!="string")return pl.errors=[{instancePath:e+"/messageCid",schemaPath:"#/properties/messageCid/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var u=m===a}else var u=!0;if(u)if(t.value!==void 0){let m=t.value,p=a;if(typeof m!="string"&&!(typeof m=="number"&&isFinite(m)))return pl.errors=[{instancePath:e+"/value",schemaPath:"#/properties/value/type",keyword:"type",params:{type:a8.properties.value.type},message:"must be string,number"}],!1;var u=p===a}else var u=!0}}}}else return pl.errors=[{instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;return pl.errors=s,a===0}pl.evaluated={props:!0,dynamicProps:!1,dynamicItems:!1};var Z5e=ws;var XJ={type:"object",additionalProperties:!1,properties:{publication:{enum:["Required","Prohibited"],type:"string"}}};function w0(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:i=t,dynamicAnchors:o={}}={}){let s=null,a=0,d=w0.evaluated;d.dynamicProps&&(d.props=void 0),d.dynamicItems&&(d.items=void 0);let u=a,c=!1,l=null,m=a;if(a===a)if(t&&typeof t=="object"&&!Array.isArray(t)){if(t.interface!==void 0){let U=a;if(t.interface!=="Protocols"){let V={instancePath:e+"/interface",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/protocols-query-scope/properties/interface/const",keyword:"const",params:{allowedValue:"Protocols"},message:"must be equal to constant"};s===null?s=[V]:s.push(V),a++}var g=U===a}else var g=!0;if(g)if(t.method!==void 0){let U=a;if(t.method!=="Query"){let L={instancePath:e+"/method",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/protocols-query-scope/properties/method/const",keyword:"const",params:{allowedValue:"Query"},message:"must be equal to constant"};s===null?s=[L]:s.push(L),a++}var g=U===a}else var g=!0}else{let U={instancePath:e,schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/protocols-query-scope/type",keyword:"type",params:{type:"object"},message:"must be object"};s===null?s=[U]:s.push(U),a++}var I=m===a;if(I){c=!0,l=0;var v={};v.interface=!0,v.method=!0}let E=a;if(a===a)if(t&&typeof t=="object"&&!Array.isArray(t)){let U;if(t.interface===void 0&&(U="interface")||t.method===void 0&&(U="method")){let V={instancePath:e,schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-read-scope/required",keyword:"required",params:{missingProperty:U},message:"must have required property '"+U+"'"};s===null?s=[V]:s.push(V),a++}else{if(t.interface!==void 0){let V=a;if(t.interface!=="Records"){let L={instancePath:e+"/interface",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-read-scope/properties/interface/const",keyword:"const",params:{allowedValue:"Records"},message:"must be equal to constant"};s===null?s=[L]:s.push(L),a++}var P=V===a}else var P=!0;if(P){if(t.method!==void 0){let V=a;if(t.method!=="Read"){let T={instancePath:e+"/method",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-read-scope/properties/method/const",keyword:"const",params:{allowedValue:"Read"},message:"must be equal to constant"};s===null?s=[T]:s.push(T),a++}var P=V===a}else var P=!0;if(P){if(t.schema!==void 0){let V=a;if(typeof t.schema!="string"){let T={instancePath:e+"/schema",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-read-scope/properties/schema/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[T]:s.push(T),a++}var P=V===a}else var P=!0;if(P){if(t.protocol!==void 0){let V=a;if(typeof t.protocol!="string"){let T={instancePath:e+"/protocol",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-read-scope/properties/protocol/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[T]:s.push(T),a++}var P=V===a}else var P=!0;if(P){if(t.contextId!==void 0){let V=a;if(typeof t.contextId!="string"){let T={instancePath:e+"/contextId",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-read-scope/properties/contextId/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[T]:s.push(T),a++}var P=V===a}else var P=!0;if(P)if(t.protocolPath!==void 0){let V=a;if(typeof t.protocolPath!="string"){let T={instancePath:e+"/protocolPath",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-read-scope/properties/protocolPath/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[T]:s.push(T),a++}var P=V===a}else var P=!0}}}}}}else{let U={instancePath:e,schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-read-scope/type",keyword:"type",params:{type:"object"},message:"must be object"};s===null?s=[U]:s.push(U),a++}var I=E===a;if(I&&c)c=!1,l=[l,1];else{I&&(c=!0,l=1,v!==!0&&(v=v||{},v.interface=!0,v.method=!0,v.schema=!0,v.protocol=!0,v.contextId=!0,v.protocolPath=!0));let U=a;if(a===a)if(t&&typeof t=="object"&&!Array.isArray(t)){let T;if(t.interface===void 0&&(T="interface")||t.method===void 0&&(T="method")){let S={instancePath:e,schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-delete-scope/required",keyword:"required",params:{missingProperty:T},message:"must have required property '"+T+"'"};s===null?s=[S]:s.push(S),a++}else{if(t.interface!==void 0){let S=a;if(t.interface!=="Records"){let k={instancePath:e+"/interface",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-delete-scope/properties/interface/const",keyword:"const",params:{allowedValue:"Records"},message:"must be equal to constant"};s===null?s=[k]:s.push(k),a++}var $=S===a}else var $=!0;if($){if(t.method!==void 0){let S=a;if(t.method!=="Delete"){let f={instancePath:e+"/method",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-delete-scope/properties/method/const",keyword:"const",params:{allowedValue:"Delete"},message:"must be equal to constant"};s===null?s=[f]:s.push(f),a++}var $=S===a}else var $=!0;if($){if(t.protocol!==void 0){let S=a;if(typeof t.protocol!="string"){let f={instancePath:e+"/protocol",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-delete-scope/properties/protocol/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[f]:s.push(f),a++}var $=S===a}else var $=!0;if($)if(t.schema!==void 0){let S=a;if(typeof t.schema!="string"){let f={instancePath:e+"/schema",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-delete-scope/properties/schema/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[f]:s.push(f),a++}var $=S===a}else var $=!0}}}}else{let T={instancePath:e,schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-delete-scope/type",keyword:"type",params:{type:"object"},message:"must be object"};s===null?s=[T]:s.push(T),a++}var I=U===a;if(I&&c)c=!1,l=[l,2];else{I&&(c=!0,l=2,v!==!0&&(v=v||{},v.interface=!0,v.method=!0,v.protocol=!0,v.schema=!0));let T=a;if(a===a)if(t&&typeof t=="object"&&!Array.isArray(t)){let f;if(t.interface===void 0&&(f="interface")||t.method===void 0&&(f="method")){let y={instancePath:e,schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-write-scope/required",keyword:"required",params:{missingProperty:f},message:"must have required property '"+f+"'"};s===null?s=[y]:s.push(y),a++}else{if(t.interface!==void 0){let y=a;if(t.interface!=="Records"){let w={instancePath:e+"/interface",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-write-scope/properties/interface/const",keyword:"const",params:{allowedValue:"Records"},message:"must be equal to constant"};s===null?s=[w]:s.push(w),a++}var N=y===a}else var N=!0;if(N){if(t.method!==void 0){let y=a;if(t.method!=="Write"){let _={instancePath:e+"/method",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-write-scope/properties/method/const",keyword:"const",params:{allowedValue:"Write"},message:"must be equal to constant"};s===null?s=[_]:s.push(_),a++}var N=y===a}else var N=!0;if(N){if(t.schema!==void 0){let y=a;if(typeof t.schema!="string"){let _={instancePath:e+"/schema",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-write-scope/properties/schema/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[_]:s.push(_),a++}var N=y===a}else var N=!0;if(N){if(t.protocol!==void 0){let y=a;if(typeof t.protocol!="string"){let _={instancePath:e+"/protocol",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-write-scope/properties/protocol/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[_]:s.push(_),a++}var N=y===a}else var N=!0;if(N){if(t.contextId!==void 0){let y=a;if(typeof t.contextId!="string"){let _={instancePath:e+"/contextId",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-write-scope/properties/contextId/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[_]:s.push(_),a++}var N=y===a}else var N=!0;if(N)if(t.protocolPath!==void 0){let y=a;if(typeof t.protocolPath!="string"){let _={instancePath:e+"/protocolPath",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-write-scope/properties/protocolPath/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[_]:s.push(_),a++}var N=y===a}else var N=!0}}}}}}else{let f={instancePath:e,schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-write-scope/type",keyword:"type",params:{type:"object"},message:"must be object"};s===null?s=[f]:s.push(f),a++}var I=T===a;if(I&&c)c=!1,l=[l,3];else{I&&(c=!0,l=3,v!==!0&&(v=v||{},v.interface=!0,v.method=!0,v.schema=!0,v.protocol=!0,v.contextId=!0,v.protocolPath=!0));let f=a;if(a===a)if(t&&typeof t=="object"&&!Array.isArray(t)){let _;if(t.interface===void 0&&(_="interface")||t.method===void 0&&(_="method")){let x={instancePath:e,schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-query-scope/required",keyword:"required",params:{missingProperty:_},message:"must have required property '"+_+"'"};s===null?s=[x]:s.push(x),a++}else{if(t.interface!==void 0){let x=a;if(t.interface!=="Records"){let b={instancePath:e+"/interface",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-query-scope/properties/interface/const",keyword:"const",params:{allowedValue:"Records"},message:"must be equal to constant"};s===null?s=[b]:s.push(b),a++}var K=x===a}else var K=!0;if(K){if(t.method!==void 0){let x=a;if(t.method!=="Query"){let B={instancePath:e+"/method",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-query-scope/properties/method/const",keyword:"const",params:{allowedValue:"Query"},message:"must be equal to constant"};s===null?s=[B]:s.push(B),a++}var K=x===a}else var K=!0;if(K)if(t.protocol!==void 0){let x=a;if(typeof t.protocol!="string"){let B={instancePath:e+"/protocol",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-query-scope/properties/protocol/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[B]:s.push(B),a++}var K=x===a}else var K=!0}}}else{let _={instancePath:e,schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-query-scope/type",keyword:"type",params:{type:"object"},message:"must be object"};s===null?s=[_]:s.push(_),a++}var I=f===a;if(I&&c)c=!1,l=[l,4];else{I&&(c=!0,l=4,v!==!0&&(v=v||{},v.interface=!0,v.method=!0,v.protocol=!0));let _=a;if(a===a)if(t&&typeof t=="object"&&!Array.isArray(t)){let B;if(t.interface===void 0&&(B="interface")||t.method===void 0&&(B="method")){let q={instancePath:e,schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-subscribe-scope/required",keyword:"required",params:{missingProperty:B},message:"must have required property '"+B+"'"};s===null?s=[q]:s.push(q),a++}else{if(t.interface!==void 0){let q=a;if(t.interface!=="Records"){let M={instancePath:e+"/interface",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-subscribe-scope/properties/interface/const",keyword:"const",params:{allowedValue:"Records"},message:"must be equal to constant"};s===null?s=[M]:s.push(M),a++}var F=q===a}else var F=!0;if(F){if(t.method!==void 0){let q=a;if(t.method!=="Subscribe"){let j={instancePath:e+"/method",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-subscribe-scope/properties/method/const",keyword:"const",params:{allowedValue:"Subscribe"},message:"must be equal to constant"};s===null?s=[j]:s.push(j),a++}var F=q===a}else var F=!0;if(F)if(t.protocol!==void 0){let q=a;if(typeof t.protocol!="string"){let j={instancePath:e+"/protocol",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-subscribe-scope/properties/protocol/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[j]:s.push(j),a++}var F=q===a}else var F=!0}}}else{let B={instancePath:e,schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-subscribe-scope/type",keyword:"type",params:{type:"object"},message:"must be object"};s===null?s=[B]:s.push(B),a++}var I=_===a;I&&c?(c=!1,l=[l,5]):I&&(c=!0,l=5,v!==!0&&(v=v||{},v.interface=!0,v.method=!0,v.protocol=!0))}}}}if(c)a=u,s!==null&&(u?s.length=u:s=null);else{let U={instancePath:e,schemaPath:"#/oneOf",keyword:"oneOf",params:{passingSchemas:l},message:"must match exactly one schema in oneOf"};return s===null?s=[U]:s.push(U),a++,w0.errors=s,!1}return w0.errors=s,d.props=v,a===0}w0.evaluated={dynamicProps:!0,dynamicItems:!1};function ws(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:i=t,dynamicAnchors:o={}}={}){let s=null,a=0,d=ws.evaluated;if(d.dynamicProps&&(d.props=void 0),d.dynamicItems&&(d.items=void 0),a===0)if(t&&typeof t=="object"&&!Array.isArray(t)){let c;if(t.dateExpires===void 0&&(c="dateExpires")||t.scope===void 0&&(c="scope"))return ws.errors=[{instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:c},message:"must have required property '"+c+"'"}],!1;{let l=a;for(let m in t)if(!(m==="description"||m==="dateExpires"||m==="requestId"||m==="delegated"||m==="scope"||m==="conditions")){return ws.errors=[{instancePath:e,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:m},message:"must NOT have additional properties"}],!1;break}if(l===a){if(t.description!==void 0){let m=a;if(typeof t.description!="string")return ws.errors=[{instancePath:e+"/description",schemaPath:"#/properties/description/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var u=m===a}else var u=!0;if(u){if(t.dateExpires!==void 0){let m=t.dateExpires,p=a;if(a===a)if(typeof m=="string"){if(!Un.test(m))return ws.errors=[{instancePath:e+"/dateExpires",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 ws.errors=[{instancePath:e+"/dateExpires",schemaPath:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/date-time/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var u=p===a}else var u=!0;if(u){if(t.requestId!==void 0){let m=a;if(typeof t.requestId!="string")return ws.errors=[{instancePath:e+"/requestId",schemaPath:"#/properties/requestId/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var u=m===a}else var u=!0;if(u){if(t.delegated!==void 0){let m=a;if(typeof t.delegated!="boolean")return ws.errors=[{instancePath:e+"/delegated",schemaPath:"#/properties/delegated/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"}],!1;var u=m===a}else var u=!0;if(u){if(t.scope!==void 0){let m=a;w0(t.scope,{instancePath:e+"/scope",parentData:t,parentDataProperty:"scope",rootData:i,dynamicAnchors:o})||(s=s===null?w0.errors:s.concat(w0.errors),a=s.length);var u=m===a}else var u=!0;if(u)if(t.conditions!==void 0){let m=t.conditions,p=a;if(a===a)if(m&&typeof m=="object"&&!Array.isArray(m)){let E=a;for(let A in m)if(A!=="publication"){return ws.errors=[{instancePath:e+"/conditions",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/defs.json#/$defs/conditions/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:A},message:"must NOT have additional properties"}],!1;break}if(E===a&&m.publication!==void 0){let A=m.publication;if(typeof A!="string")return ws.errors=[{instancePath:e+"/conditions/publication",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/defs.json#/$defs/conditions/properties/publication/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;if(!(A==="Required"||A==="Prohibited"))return ws.errors=[{instancePath:e+"/conditions/publication",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/defs.json#/$defs/conditions/properties/publication/enum",keyword:"enum",params:{allowedValues:XJ.properties.publication.enum},message:"must be equal to one of the allowed values"}],!1}}else return ws.errors=[{instancePath:e+"/conditions",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/defs.json#/$defs/conditions/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var u=p===a}else var u=!0}}}}}}}else return ws.errors=[{instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;return ws.errors=s,a===0}ws.evaluated={props:!0,dynamicProps:!1,dynamicItems:!1};var X5e=nc;function _0(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:i=t,dynamicAnchors:o={}}={}){let s=null,a=0,d=_0.evaluated;d.dynamicProps&&(d.props=void 0),d.dynamicItems&&(d.items=void 0);let u=a,c=!1,l=null,m=a;if(a===a)if(t&&typeof t=="object"&&!Array.isArray(t)){if(t.interface!==void 0){let U=a;if(t.interface!=="Protocols"){let V={instancePath:e+"/interface",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/protocols-query-scope/properties/interface/const",keyword:"const",params:{allowedValue:"Protocols"},message:"must be equal to constant"};s===null?s=[V]:s.push(V),a++}var g=U===a}else var g=!0;if(g)if(t.method!==void 0){let U=a;if(t.method!=="Query"){let L={instancePath:e+"/method",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/protocols-query-scope/properties/method/const",keyword:"const",params:{allowedValue:"Query"},message:"must be equal to constant"};s===null?s=[L]:s.push(L),a++}var g=U===a}else var g=!0}else{let U={instancePath:e,schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/protocols-query-scope/type",keyword:"type",params:{type:"object"},message:"must be object"};s===null?s=[U]:s.push(U),a++}var I=m===a;if(I){c=!0,l=0;var v={};v.interface=!0,v.method=!0}let E=a;if(a===a)if(t&&typeof t=="object"&&!Array.isArray(t)){let U;if(t.interface===void 0&&(U="interface")||t.method===void 0&&(U="method")){let V={instancePath:e,schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-read-scope/required",keyword:"required",params:{missingProperty:U},message:"must have required property '"+U+"'"};s===null?s=[V]:s.push(V),a++}else{if(t.interface!==void 0){let V=a;if(t.interface!=="Records"){let L={instancePath:e+"/interface",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-read-scope/properties/interface/const",keyword:"const",params:{allowedValue:"Records"},message:"must be equal to constant"};s===null?s=[L]:s.push(L),a++}var P=V===a}else var P=!0;if(P){if(t.method!==void 0){let V=a;if(t.method!=="Read"){let T={instancePath:e+"/method",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-read-scope/properties/method/const",keyword:"const",params:{allowedValue:"Read"},message:"must be equal to constant"};s===null?s=[T]:s.push(T),a++}var P=V===a}else var P=!0;if(P){if(t.schema!==void 0){let V=a;if(typeof t.schema!="string"){let T={instancePath:e+"/schema",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-read-scope/properties/schema/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[T]:s.push(T),a++}var P=V===a}else var P=!0;if(P){if(t.protocol!==void 0){let V=a;if(typeof t.protocol!="string"){let T={instancePath:e+"/protocol",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-read-scope/properties/protocol/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[T]:s.push(T),a++}var P=V===a}else var P=!0;if(P){if(t.contextId!==void 0){let V=a;if(typeof t.contextId!="string"){let T={instancePath:e+"/contextId",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-read-scope/properties/contextId/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[T]:s.push(T),a++}var P=V===a}else var P=!0;if(P)if(t.protocolPath!==void 0){let V=a;if(typeof t.protocolPath!="string"){let T={instancePath:e+"/protocolPath",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-read-scope/properties/protocolPath/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[T]:s.push(T),a++}var P=V===a}else var P=!0}}}}}}else{let U={instancePath:e,schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-read-scope/type",keyword:"type",params:{type:"object"},message:"must be object"};s===null?s=[U]:s.push(U),a++}var I=E===a;if(I&&c)c=!1,l=[l,1];else{I&&(c=!0,l=1,v!==!0&&(v=v||{},v.interface=!0,v.method=!0,v.schema=!0,v.protocol=!0,v.contextId=!0,v.protocolPath=!0));let U=a;if(a===a)if(t&&typeof t=="object"&&!Array.isArray(t)){let T;if(t.interface===void 0&&(T="interface")||t.method===void 0&&(T="method")){let S={instancePath:e,schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-delete-scope/required",keyword:"required",params:{missingProperty:T},message:"must have required property '"+T+"'"};s===null?s=[S]:s.push(S),a++}else{if(t.interface!==void 0){let S=a;if(t.interface!=="Records"){let k={instancePath:e+"/interface",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-delete-scope/properties/interface/const",keyword:"const",params:{allowedValue:"Records"},message:"must be equal to constant"};s===null?s=[k]:s.push(k),a++}var $=S===a}else var $=!0;if($){if(t.method!==void 0){let S=a;if(t.method!=="Delete"){let f={instancePath:e+"/method",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-delete-scope/properties/method/const",keyword:"const",params:{allowedValue:"Delete"},message:"must be equal to constant"};s===null?s=[f]:s.push(f),a++}var $=S===a}else var $=!0;if($){if(t.protocol!==void 0){let S=a;if(typeof t.protocol!="string"){let f={instancePath:e+"/protocol",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-delete-scope/properties/protocol/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[f]:s.push(f),a++}var $=S===a}else var $=!0;if($)if(t.schema!==void 0){let S=a;if(typeof t.schema!="string"){let f={instancePath:e+"/schema",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-delete-scope/properties/schema/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[f]:s.push(f),a++}var $=S===a}else var $=!0}}}}else{let T={instancePath:e,schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-delete-scope/type",keyword:"type",params:{type:"object"},message:"must be object"};s===null?s=[T]:s.push(T),a++}var I=U===a;if(I&&c)c=!1,l=[l,2];else{I&&(c=!0,l=2,v!==!0&&(v=v||{},v.interface=!0,v.method=!0,v.protocol=!0,v.schema=!0));let T=a;if(a===a)if(t&&typeof t=="object"&&!Array.isArray(t)){let f;if(t.interface===void 0&&(f="interface")||t.method===void 0&&(f="method")){let y={instancePath:e,schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-write-scope/required",keyword:"required",params:{missingProperty:f},message:"must have required property '"+f+"'"};s===null?s=[y]:s.push(y),a++}else{if(t.interface!==void 0){let y=a;if(t.interface!=="Records"){let w={instancePath:e+"/interface",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-write-scope/properties/interface/const",keyword:"const",params:{allowedValue:"Records"},message:"must be equal to constant"};s===null?s=[w]:s.push(w),a++}var N=y===a}else var N=!0;if(N){if(t.method!==void 0){let y=a;if(t.method!=="Write"){let _={instancePath:e+"/method",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-write-scope/properties/method/const",keyword:"const",params:{allowedValue:"Write"},message:"must be equal to constant"};s===null?s=[_]:s.push(_),a++}var N=y===a}else var N=!0;if(N){if(t.schema!==void 0){let y=a;if(typeof t.schema!="string"){let _={instancePath:e+"/schema",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-write-scope/properties/schema/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[_]:s.push(_),a++}var N=y===a}else var N=!0;if(N){if(t.protocol!==void 0){let y=a;if(typeof t.protocol!="string"){let _={instancePath:e+"/protocol",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-write-scope/properties/protocol/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[_]:s.push(_),a++}var N=y===a}else var N=!0;if(N){if(t.contextId!==void 0){let y=a;if(typeof t.contextId!="string"){let _={instancePath:e+"/contextId",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-write-scope/properties/contextId/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[_]:s.push(_),a++}var N=y===a}else var N=!0;if(N)if(t.protocolPath!==void 0){let y=a;if(typeof t.protocolPath!="string"){let _={instancePath:e+"/protocolPath",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-write-scope/properties/protocolPath/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[_]:s.push(_),a++}var N=y===a}else var N=!0}}}}}}else{let f={instancePath:e,schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-write-scope/type",keyword:"type",params:{type:"object"},message:"must be object"};s===null?s=[f]:s.push(f),a++}var I=T===a;if(I&&c)c=!1,l=[l,3];else{I&&(c=!0,l=3,v!==!0&&(v=v||{},v.interface=!0,v.method=!0,v.schema=!0,v.protocol=!0,v.contextId=!0,v.protocolPath=!0));let f=a;if(a===a)if(t&&typeof t=="object"&&!Array.isArray(t)){let _;if(t.interface===void 0&&(_="interface")||t.method===void 0&&(_="method")){let x={instancePath:e,schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-query-scope/required",keyword:"required",params:{missingProperty:_},message:"must have required property '"+_+"'"};s===null?s=[x]:s.push(x),a++}else{if(t.interface!==void 0){let x=a;if(t.interface!=="Records"){let b={instancePath:e+"/interface",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-query-scope/properties/interface/const",keyword:"const",params:{allowedValue:"Records"},message:"must be equal to constant"};s===null?s=[b]:s.push(b),a++}var K=x===a}else var K=!0;if(K){if(t.method!==void 0){let x=a;if(t.method!=="Query"){let B={instancePath:e+"/method",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-query-scope/properties/method/const",keyword:"const",params:{allowedValue:"Query"},message:"must be equal to constant"};s===null?s=[B]:s.push(B),a++}var K=x===a}else var K=!0;if(K)if(t.protocol!==void 0){let x=a;if(typeof t.protocol!="string"){let B={instancePath:e+"/protocol",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-query-scope/properties/protocol/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[B]:s.push(B),a++}var K=x===a}else var K=!0}}}else{let _={instancePath:e,schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-query-scope/type",keyword:"type",params:{type:"object"},message:"must be object"};s===null?s=[_]:s.push(_),a++}var I=f===a;if(I&&c)c=!1,l=[l,4];else{I&&(c=!0,l=4,v!==!0&&(v=v||{},v.interface=!0,v.method=!0,v.protocol=!0));let _=a;if(a===a)if(t&&typeof t=="object"&&!Array.isArray(t)){let B;if(t.interface===void 0&&(B="interface")||t.method===void 0&&(B="method")){let q={instancePath:e,schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-subscribe-scope/required",keyword:"required",params:{missingProperty:B},message:"must have required property '"+B+"'"};s===null?s=[q]:s.push(q),a++}else{if(t.interface!==void 0){let q=a;if(t.interface!=="Records"){let M={instancePath:e+"/interface",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-subscribe-scope/properties/interface/const",keyword:"const",params:{allowedValue:"Records"},message:"must be equal to constant"};s===null?s=[M]:s.push(M),a++}var F=q===a}else var F=!0;if(F){if(t.method!==void 0){let q=a;if(t.method!=="Subscribe"){let j={instancePath:e+"/method",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-subscribe-scope/properties/method/const",keyword:"const",params:{allowedValue:"Subscribe"},message:"must be equal to constant"};s===null?s=[j]:s.push(j),a++}var F=q===a}else var F=!0;if(F)if(t.protocol!==void 0){let q=a;if(typeof t.protocol!="string"){let j={instancePath:e+"/protocol",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-subscribe-scope/properties/protocol/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[j]:s.push(j),a++}var F=q===a}else var F=!0}}}else{let B={instancePath:e,schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-subscribe-scope/type",keyword:"type",params:{type:"object"},message:"must be object"};s===null?s=[B]:s.push(B),a++}var I=_===a;I&&c?(c=!1,l=[l,5]):I&&(c=!0,l=5,v!==!0&&(v=v||{},v.interface=!0,v.method=!0,v.protocol=!0))}}}}if(c)a=u,s!==null&&(u?s.length=u:s=null);else{let U={instancePath:e,schemaPath:"#/oneOf",keyword:"oneOf",params:{passingSchemas:l},message:"must match exactly one schema in oneOf"};return s===null?s=[U]:s.push(U),a++,_0.errors=s,!1}return _0.errors=s,d.props=v,a===0}_0.evaluated={dynamicProps:!0,dynamicItems:!1};function nc(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:i=t,dynamicAnchors:o={}}={}){let s=null,a=0,d=nc.evaluated;if(d.dynamicProps&&(d.props=void 0),d.dynamicItems&&(d.items=void 0),a===0)if(t&&typeof t=="object"&&!Array.isArray(t)){let c;if(t.delegated===void 0&&(c="delegated")||t.scope===void 0&&(c="scope"))return nc.errors=[{instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:c},message:"must have required property '"+c+"'"}],!1;{let l=a;for(let m in t)if(!(m==="description"||m==="delegated"||m==="scope"||m==="conditions")){return nc.errors=[{instancePath:e,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:m},message:"must NOT have additional properties"}],!1;break}if(l===a){if(t.description!==void 0){let m=a;if(typeof t.description!="string")return nc.errors=[{instancePath:e+"/description",schemaPath:"#/properties/description/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var u=m===a}else var u=!0;if(u){if(t.delegated!==void 0){let m=a;if(typeof t.delegated!="boolean")return nc.errors=[{instancePath:e+"/delegated",schemaPath:"#/properties/delegated/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"}],!1;var u=m===a}else var u=!0;if(u){if(t.scope!==void 0){let m=a;_0(t.scope,{instancePath:e+"/scope",parentData:t,parentDataProperty:"scope",rootData:i,dynamicAnchors:o})||(s=s===null?_0.errors:s.concat(_0.errors),a=s.length);var u=m===a}else var u=!0;if(u)if(t.conditions!==void 0){let m=t.conditions,p=a;if(a===a)if(m&&typeof m=="object"&&!Array.isArray(m)){let E=a;for(let A in m)if(A!=="publication"){return nc.errors=[{instancePath:e+"/conditions",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/defs.json#/$defs/conditions/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:A},message:"must NOT have additional properties"}],!1;break}if(E===a&&m.publication!==void 0){let A=m.publication;if(typeof A!="string")return nc.errors=[{instancePath:e+"/conditions/publication",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/defs.json#/$defs/conditions/properties/publication/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;if(!(A==="Required"||A==="Prohibited"))return nc.errors=[{instancePath:e+"/conditions/publication",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/defs.json#/$defs/conditions/properties/publication/enum",keyword:"enum",params:{allowedValues:XJ.properties.publication.enum},message:"must be equal to one of the allowed values"}],!1}}else return nc.errors=[{instancePath:e+"/conditions",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/defs.json#/$defs/conditions/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var u=p===a}else var u=!0}}}}}else return nc.errors=[{instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;return nc.errors=s,a===0}nc.evaluated={props:!0,dynamicProps:!1,dynamicItems:!1};var Q5e=g0;function g0(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:i=t,dynamicAnchors:o={}}={}){let s=null,a=0,d=g0.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 u=a;for(let c in t)if(c!=="description"){return g0.errors=[{instancePath:e,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:c},message:"must NOT have additional properties"}],!1;break}if(u===a&&t.description!==void 0&&typeof t.description!="string")return g0.errors=[{instancePath:e+"/description",schemaPath:"#/properties/description/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1}else return g0.errors=[{instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;return g0.errors=s,a===0}g0.evaluated={props:!0,dynamicProps:!1,dynamicItems:!1};var e8e=K_;function K_(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:i=t,dynamicAnchors:o={}}={}){let s=null,a=0,d=K_.evaluated;return d.dynamicProps&&(d.props=void 0),d.dynamicItems&&(d.items=void 0),t&&typeof t=="object"&&!Array.isArray(t)?(K_.errors=s,a===0):(K_.errors=[{instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1)}K_.evaluated={dynamicProps:!1,dynamicItems:!1};var t8e=F_;function F_(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:i=t,dynamicAnchors:o={}}={}){let s=null,a=0,d=F_.evaluated;return d.dynamicProps&&(d.props=void 0),d.dynamicItems&&(d.items=void 0),t&&typeof t=="object"&&!Array.isArray(t)?(F_.errors=s,a===0):(F_.errors=[{instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1)}F_.evaluated={dynamicProps:!1,dynamicItems:!1};var r8e=$i;var VJ=new RegExp(".*","u"),Bb={$id:"https://identity.foundation/dwn/json-schemas/protocol-rule-set.json",$schema:"https://json-schema.org/draft/2020-12/schema",type:"object",additionalProperties:!1,properties:{$encryption:{type:"object",additionalProperties:!1,properties:{rootKeyId:{type:"string"},publicKeyJwk:{$ref:"https://identity.foundation/dwn/json-schemas/public-jwk.json"}},required:["rootKeyId","publicKeyJwk"]},$actions:{type:"array",minItems:1,items:{type:"object",oneOf:[{required:["who","can"],additionalProperties:!1,properties:{who:{type:"string",enum:["anyone","author","recipient"]},of:{type:"string"},can:{type:"array",minItems:1,items:{type:"string",enum:["co-delete","co-prune","co-update","create","delete","prune","read","update"]}}}},{required:["role","can"],properties:{role:{$comment:"Must be the protocol path of a role record type",type:"string"},can:{type:"array",minItems:1,items:{type:"string",enum:["co-delete","co-update","create","delete","query","subscribe","read","update"]}}}}]}},$role:{$comment:"When `true`, this turns a record into `role` that may be used within a context/sub-context",type:"boolean"},$size:{type:"object",additionalProperties:!1,properties:{min:{type:"number",minimum:0},max:{type:"number",minimum:0}}},$tags:{type:"object",minProperties:1,properties:{$requiredTags:{type:"array",items:{type:"string"}},$allowUndefinedTags:{type:"boolean"}},patternProperties:{"^(?!\\$requiredTags$|\\$allowUndefinedTags$).*$":{type:"object",additionalProperties:!1,properties:{type:{enum:["string","number","integer","boolean","array"]},items:{type:"object",properties:{type:{enum:["string","number","integer"]}},patternProperties:{"^(enum|minimum|maximum|exclusiveMinimum|exclusiveMaximum|minLength|maxLength)$":{}}},contains:{type:"object",properties:{type:{enum:["string","number","integer"]}},patternProperties:{"^(enum|minimum|maximum|exclusiveMinimum|exclusiveMaximum|minLength|maxLength)$":{}}}},patternProperties:{"^(enum|minimum|maximum|exclusiveMinimum|exclusiveMaximum|minLength|maxLength|minItems|maxItems|uniqueItems|minContains|maxContains)$":{}}}}}},patternProperties:{"^[^$].*$":{$ref:"https://identity.foundation/dwn/json-schemas/protocol-rule-set.json"}}},HJ=new RegExp("^[^$].*$","u"),n8e=new RegExp("^(?!\\$requiredTags$|\\$allowUndefinedTags$).*$","u"),i8e=new RegExp("^(enum|minimum|maximum|exclusiveMinimum|exclusiveMaximum|minLength|maxLength|minItems|maxItems|uniqueItems|minContains|maxContains)$","u"),WJ=new RegExp("^(enum|minimum|maximum|exclusiveMinimum|exclusiveMaximum|minLength|maxLength)$","u"),jB={validate:Pr};function Pr(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:i=t,dynamicAnchors:o={}}={}){let s=null,a=0,d=Pr.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 S=a;for(let k in t)if(!(k==="$encryption"||k==="$actions"||k==="$role"||k==="$size"||k==="$tags"||HJ.test(k))){return Pr.errors=[{instancePath:e,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:k},message:"must NOT have additional properties"}],!1;break}if(S===a){if(t.$encryption!==void 0){let k=t.$encryption,f=a;if(a===f)if(k&&typeof k=="object"&&!Array.isArray(k)){let y;if(k.rootKeyId===void 0&&(y="rootKeyId")||k.publicKeyJwk===void 0&&(y="publicKeyJwk"))return Pr.errors=[{instancePath:e+"/$encryption",schemaPath:"#/properties/%24encryption/required",keyword:"required",params:{missingProperty:y},message:"must have required property '"+y+"'"}],!1;{let w=a;for(let _ in k)if(!(_==="rootKeyId"||_==="publicKeyJwk")){return Pr.errors=[{instancePath:e+"/$encryption",schemaPath:"#/properties/%24encryption/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:_},message:"must NOT have additional properties"}],!1;break}if(w===a){if(k.rootKeyId!==void 0){let _=a;if(typeof k.rootKeyId!="string")return Pr.errors=[{instancePath:e+"/$encryption/rootKeyId",schemaPath:"#/properties/%24encryption/properties/rootKeyId/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var u=_===a}else var u=!0;if(u)if(k.publicKeyJwk!==void 0){let _=a;tn(k.publicKeyJwk,{instancePath:e+"/$encryption/publicKeyJwk",parentData:k,parentDataProperty:"publicKeyJwk",rootData:i,dynamicAnchors:o})||(s=s===null?tn.errors:s.concat(tn.errors),a=s.length);var u=_===a}else var u=!0}}}else return Pr.errors=[{instancePath:e+"/$encryption",schemaPath:"#/properties/%24encryption/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var c=f===a}else var c=!0;if(c){if(t.$actions!==void 0){let k=t.$actions,f=a;if(a===f)if(Array.isArray(k)){if(k.length<1)return Pr.errors=[{instancePath:e+"/$actions",schemaPath:"#/properties/%24actions/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"}],!1;{var l=!0;let w=k.length;for(let _=0;_<w;_++){let x=k[_],b=a;if(!(x&&typeof x=="object"&&!Array.isArray(x)))return Pr.errors=[{instancePath:e+"/$actions/"+_,schemaPath:"#/properties/%24actions/items/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;let B=a,q=!1,M=null,j=a;if(x&&typeof x=="object"&&!Array.isArray(x)){let G;if(x.who===void 0&&(G="who")||x.can===void 0&&(G="can")){let W={instancePath:e+"/$actions/"+_,schemaPath:"#/properties/%24actions/items/oneOf/0/required",keyword:"required",params:{missingProperty:G},message:"must have required property '"+G+"'"};s===null?s=[W]:s.push(W),a++}else{let W=a;for(let X in x)if(!(X==="who"||X==="of"||X==="can")){let ee={instancePath:e+"/$actions/"+_,schemaPath:"#/properties/%24actions/items/oneOf/0/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:X},message:"must NOT have additional properties"};s===null?s=[ee]:s.push(ee),a++;break}if(W===a){if(x.who!==void 0){let X=x.who,ee=a;if(typeof X!="string"){let ue={instancePath:e+"/$actions/"+_+"/who",schemaPath:"#/properties/%24actions/items/oneOf/0/properties/who/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[ue]:s.push(ue),a++}if(!(X==="anyone"||X==="author"||X==="recipient")){let ue={instancePath:e+"/$actions/"+_+"/who",schemaPath:"#/properties/%24actions/items/oneOf/0/properties/who/enum",keyword:"enum",params:{allowedValues:Bb.properties.$actions.items.oneOf[0].properties.who.enum},message:"must be equal to one of the allowed values"};s===null?s=[ue]:s.push(ue),a++}var m=ee===a}else var m=!0;if(m){if(x.of!==void 0){let X=a;if(typeof x.of!="string"){let ue={instancePath:e+"/$actions/"+_+"/of",schemaPath:"#/properties/%24actions/items/oneOf/0/properties/of/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[ue]:s.push(ue),a++}var m=X===a}else var m=!0;if(m)if(x.can!==void 0){let X=x.can,ee=a;if(a===ee)if(Array.isArray(X))if(X.length<1){let ae={instancePath:e+"/$actions/"+_+"/can",schemaPath:"#/properties/%24actions/items/oneOf/0/properties/can/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"};s===null?s=[ae]:s.push(ae),a++}else{var p=!0;let ae=X.length;for(let ce=0;ce<ae;ce++){let pe=X[ce],xe=a;if(typeof pe!="string"){let le={instancePath:e+"/$actions/"+_+"/can/"+ce,schemaPath:"#/properties/%24actions/items/oneOf/0/properties/can/items/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[le]:s.push(le),a++}if(!(pe==="co-delete"||pe==="co-prune"||pe==="co-update"||pe==="create"||pe==="delete"||pe==="prune"||pe==="read"||pe==="update")){let le={instancePath:e+"/$actions/"+_+"/can/"+ce,schemaPath:"#/properties/%24actions/items/oneOf/0/properties/can/items/enum",keyword:"enum",params:{allowedValues:Bb.properties.$actions.items.oneOf[0].properties.can.items.enum},message:"must be equal to one of the allowed values"};s===null?s=[le]:s.push(le),a++}var p=xe===a;if(!p)break}}else{let ae={instancePath:e+"/$actions/"+_+"/can",schemaPath:"#/properties/%24actions/items/oneOf/0/properties/can/type",keyword:"type",params:{type:"array"},message:"must be array"};s===null?s=[ae]:s.push(ae),a++}var m=ee===a}else var m=!0}}}}var A=j===a;if(A){q=!0,M=0;var g=!0}let J=a;if(x&&typeof x=="object"&&!Array.isArray(x)){let G;if(x.role===void 0&&(G="role")||x.can===void 0&&(G="can")){let W={instancePath:e+"/$actions/"+_,schemaPath:"#/properties/%24actions/items/oneOf/1/required",keyword:"required",params:{missingProperty:G},message:"must have required property '"+G+"'"};s===null?s=[W]:s.push(W),a++}else{if(x.role!==void 0){let W=a;if(typeof x.role!="string"){let X={instancePath:e+"/$actions/"+_+"/role",schemaPath:"#/properties/%24actions/items/oneOf/1/properties/role/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[X]:s.push(X),a++}var v=W===a}else var v=!0;if(v)if(x.can!==void 0){let W=x.can,X=a;if(a===X)if(Array.isArray(W))if(W.length<1){let ue={instancePath:e+"/$actions/"+_+"/can",schemaPath:"#/properties/%24actions/items/oneOf/1/properties/can/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"};s===null?s=[ue]:s.push(ue),a++}else{var E=!0;let ue=W.length;for(let ae=0;ae<ue;ae++){let ce=W[ae],pe=a;if(typeof ce!="string"){let Ue={instancePath:e+"/$actions/"+_+"/can/"+ae,schemaPath:"#/properties/%24actions/items/oneOf/1/properties/can/items/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[Ue]:s.push(Ue),a++}if(!(ce==="co-delete"||ce==="co-update"||ce==="create"||ce==="delete"||ce==="query"||ce==="subscribe"||ce==="read"||ce==="update")){let Ue={instancePath:e+"/$actions/"+_+"/can/"+ae,schemaPath:"#/properties/%24actions/items/oneOf/1/properties/can/items/enum",keyword:"enum",params:{allowedValues:Bb.properties.$actions.items.oneOf[1].properties.can.items.enum},message:"must be equal to one of the allowed values"};s===null?s=[Ue]:s.push(Ue),a++}var E=pe===a;if(!E)break}}else{let ue={instancePath:e+"/$actions/"+_+"/can",schemaPath:"#/properties/%24actions/items/oneOf/1/properties/can/type",keyword:"type",params:{type:"array"},message:"must be array"};s===null?s=[ue]:s.push(ue),a++}var v=X===a}else var v=!0}}var A=J===a;if(A&&q?(q=!1,M=[M,1]):A&&(q=!0,M=1,g!==!0&&(g=g||{},g.role=!0,g.can=!0)),q)a=B,s!==null&&(B?s.length=B:s=null);else{let G={instancePath:e+"/$actions/"+_,schemaPath:"#/properties/%24actions/items/oneOf",keyword:"oneOf",params:{passingSchemas:M},message:"must match exactly one schema in oneOf"};return s===null?s=[G]:s.push(G),a++,Pr.errors=s,!1}var l=b===a;if(!l)break}}}else return Pr.errors=[{instancePath:e+"/$actions",schemaPath:"#/properties/%24actions/type",keyword:"type",params:{type:"array"},message:"must be array"}],!1;var c=f===a}else var c=!0;if(c){if(t.$role!==void 0){let k=a;if(typeof t.$role!="boolean")return Pr.errors=[{instancePath:e+"/$role",schemaPath:"#/properties/%24role/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"}],!1;var c=k===a}else var c=!0;if(c){if(t.$size!==void 0){let k=t.$size,f=a;if(a===f)if(k&&typeof k=="object"&&!Array.isArray(k)){let w=a;for(let _ in k)if(!(_==="min"||_==="max")){return Pr.errors=[{instancePath:e+"/$size",schemaPath:"#/properties/%24size/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:_},message:"must NOT have additional properties"}],!1;break}if(w===a){if(k.min!==void 0){let _=k.min,x=a;if(a===x)if(typeof _=="number"&&isFinite(_)){if(_<0||isNaN(_))return Pr.errors=[{instancePath:e+"/$size/min",schemaPath:"#/properties/%24size/properties/min/minimum",keyword:"minimum",params:{comparison:">=",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 P=x===a}else var P=!0;if(P)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 P=x===a}else var P=!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 I=!0;let x=w.length;for(let b=0;b<x;b++){let B=a;if(typeof w[b]!="string")return Pr.errors=[{instancePath:e+"/$tags/$requiredTags/"+b,schemaPath:"#/properties/%24tags/properties/%24requiredTags/items/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var I=B===a;if(!I)break}}else return Pr.errors=[{instancePath:e+"/$tags/$requiredTags",schemaPath:"#/properties/%24tags/properties/%24requiredTags/type",keyword:"type",params:{type:"array"},message:"must be array"}],!1;var $=_===a}else var $=!0;if($){if(k.$allowUndefinedTags!==void 0){let w=a;if(typeof k.$allowUndefinedTags!="boolean")return Pr.errors=[{instancePath:e+"/$tags/$allowUndefinedTags",schemaPath:"#/properties/%24tags/properties/%24allowUndefinedTags/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"}],!1;var $=w===a}else var $=!0;if($){var N={};N.$requiredTags=!0,N.$allowUndefinedTags=!0;for(let w in k)if(n8e.test(w)){let _=k[w];if(a===a)if(_&&typeof _=="object"&&!Array.isArray(_)){let b=a;for(let B in _)if(!(B==="type"||B==="items"||B==="contains"||i8e.test(B))){return Pr.errors=[{instancePath:e+"/$tags/"+w.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/%24tags/patternProperties/%5E(%3F!%5C%24requiredTags%24%7C%5C%24allowUndefinedTags%24).*%24/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:B},message:"must NOT have additional properties"}],!1;break}if(b===a){if(_.type!==void 0){let B=_.type,q=a;if(!(B==="string"||B==="number"||B==="integer"||B==="boolean"||B==="array"))return Pr.errors=[{instancePath:e+"/$tags/"+w.replace(/~/g,"~0").replace(/\//g,"~1")+"/type",schemaPath:"#/properties/%24tags/patternProperties/%5E(%3F!%5C%24requiredTags%24%7C%5C%24allowUndefinedTags%24).*%24/properties/type/enum",keyword:"enum",params:{allowedValues:Bb.properties.$tags.patternProperties["^(?!\\$requiredTags$|\\$allowUndefinedTags$).*$"].properties.type.enum},message:"must be equal to one of the allowed values"}],!1;var K=q===a}else var K=!0;if(K){if(_.items!==void 0){let B=_.items,q=a;if(a===q)if(B&&typeof B=="object"&&!Array.isArray(B)){if(B.type!==void 0){let j=B.type,J=a;if(!(j==="string"||j==="number"||j==="integer"))return Pr.errors=[{instancePath:e+"/$tags/"+w.replace(/~/g,"~0").replace(/\//g,"~1")+"/items/type",schemaPath:"#/properties/%24tags/patternProperties/%5E(%3F!%5C%24requiredTags%24%7C%5C%24allowUndefinedTags%24).*%24/properties/items/properties/type/enum",keyword:"enum",params:{allowedValues:Bb.properties.$tags.patternProperties["^(?!\\$requiredTags$|\\$allowUndefinedTags$).*$"].properties.items.properties.type.enum},message:"must be equal to one of the allowed values"}],!1;var F=J===a}else var F=!0;if(F){var U={};U.type=!0;for(let j in B)WJ.test(j)&&(U[j]=!0)}}else return Pr.errors=[{instancePath:e+"/$tags/"+w.replace(/~/g,"~0").replace(/\//g,"~1")+"/items",schemaPath:"#/properties/%24tags/patternProperties/%5E(%3F!%5C%24requiredTags%24%7C%5C%24allowUndefinedTags%24).*%24/properties/items/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var K=q===a}else var K=!0;if(K)if(_.contains!==void 0){let B=_.contains,q=a;if(a===q)if(B&&typeof B=="object"&&!Array.isArray(B)){if(B.type!==void 0){let j=B.type,J=a;if(!(j==="string"||j==="number"||j==="integer"))return Pr.errors=[{instancePath:e+"/$tags/"+w.replace(/~/g,"~0").replace(/\//g,"~1")+"/contains/type",schemaPath:"#/properties/%24tags/patternProperties/%5E(%3F!%5C%24requiredTags%24%7C%5C%24allowUndefinedTags%24).*%24/properties/contains/properties/type/enum",keyword:"enum",params:{allowedValues:Bb.properties.$tags.patternProperties["^(?!\\$requiredTags$|\\$allowUndefinedTags$).*$"].properties.contains.properties.type.enum},message:"must be equal to one of the allowed values"}],!1;var V=J===a}else var V=!0;if(V){var L={};L.type=!0;for(let j in B)WJ.test(j)&&(L[j]=!0)}}else return Pr.errors=[{instancePath:e+"/$tags/"+w.replace(/~/g,"~0").replace(/\//g,"~1")+"/contains",schemaPath:"#/properties/%24tags/patternProperties/%5E(%3F!%5C%24requiredTags%24%7C%5C%24allowUndefinedTags%24).*%24/properties/contains/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var K=q===a}else var K=!0}}}else return Pr.errors=[{instancePath:e+"/$tags/"+w.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/%24tags/patternProperties/%5E(%3F!%5C%24requiredTags%24%7C%5C%24allowUndefinedTags%24).*%24/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;N[w]=!0}}}}else return Pr.errors=[{instancePath:e+"/$tags",schemaPath:"#/properties/%24tags/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var c=f===a}else var c=!0;if(c){var T=!0;for(let k in t)if(HJ.test(k)){let f=a;jB.validate(t[k],{instancePath:e+"/"+k.replace(/~/g,"~0").replace(/\//g,"~1"),parentData:t,parentDataProperty:k,rootData:i,dynamicAnchors:o})||(s=s===null?jB.validate.errors:s.concat(jB.validate.errors),a=s.length);var T=f===a;if(!T)break}}}}}}}}else return Pr.errors=[{instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;return Pr.errors=s,a===0}Pr.evaluated={props:!0,dynamicProps:!1,dynamicItems:!1};function $i(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:i=t,dynamicAnchors:o={}}={}){let s=null,a=0,d=$i.evaluated;if(d.dynamicProps&&(d.props=void 0),d.dynamicItems&&(d.items=void 0),a===0)if(t&&typeof t=="object"&&!Array.isArray(t)){let g;if(t.protocol===void 0&&(g="protocol")||t.published===void 0&&(g="published")||t.types===void 0&&(g="types")||t.structure===void 0&&(g="structure"))return $i.errors=[{instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:g},message:"must have required property '"+g+"'"}],!1;{let v=a;for(let E in t)if(!(E==="protocol"||E==="published"||E==="types"||E==="structure")){return $i.errors=[{instancePath:e,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:E},message:"must NOT have additional properties"}],!1;break}if(v===a){if(t.protocol!==void 0){let E=a;if(typeof t.protocol!="string")return $i.errors=[{instancePath:e+"/protocol",schemaPath:"#/properties/protocol/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var u=E===a}else var u=!0;if(u){if(t.published!==void 0){let E=a;if(typeof t.published!="boolean")return $i.errors=[{instancePath:e+"/published",schemaPath:"#/properties/published/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"}],!1;var u=E===a}else var u=!0;if(u){if(t.types!==void 0){let E=t.types,A=a;if(a===A)if(E&&typeof E=="object"&&!Array.isArray(E)){var c={};for(let I in E)if(VJ.test(I)){let $=E[I];if(a===a)if($&&typeof $=="object"&&!Array.isArray($)){let K=a;for(let F in $)if(!(F==="schema"||F==="dataFormats")){return $i.errors=[{instancePath:e+"/types/"+I.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/types/patternProperties/.*/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:F},message:"must NOT have additional properties"}],!1;break}if(K===a){if($.schema!==void 0){let F=a;if(typeof $.schema!="string")return $i.errors=[{instancePath:e+"/types/"+I.replace(/~/g,"~0").replace(/\//g,"~1")+"/schema",schemaPath:"#/properties/types/patternProperties/.*/properties/schema/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var l=F===a}else var l=!0;if(l)if($.dataFormats!==void 0){let F=$.dataFormats,U=a;if(a===U)if(Array.isArray(F)){if(F.length<1)return $i.errors=[{instancePath:e+"/types/"+I.replace(/~/g,"~0").replace(/\//g,"~1")+"/dataFormats",schemaPath:"#/properties/types/patternProperties/.*/properties/dataFormats/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"}],!1;{var m=!0;let L=F.length;for(let T=0;T<L;T++){let S=a;if(typeof F[T]!="string")return $i.errors=[{instancePath:e+"/types/"+I.replace(/~/g,"~0").replace(/\//g,"~1")+"/dataFormats/"+T,schemaPath:"#/properties/types/patternProperties/.*/properties/dataFormats/items/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var m=S===a;if(!m)break}}}else return $i.errors=[{instancePath:e+"/types/"+I.replace(/~/g,"~0").replace(/\//g,"~1")+"/dataFormats",schemaPath:"#/properties/types/patternProperties/.*/properties/dataFormats/type",keyword:"type",params:{type:"array"},message:"must be array"}],!1;var l=U===a}else var l=!0}}else return $i.errors=[{instancePath:e+"/types/"+I.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/types/patternProperties/.*/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;c[I]=!0}}else return $i.errors=[{instancePath:e+"/types",schemaPath:"#/properties/types/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var u=A===a}else var u=!0;if(u)if(t.structure!==void 0){let E=t.structure,A=a;if(a===A)if(E&&typeof E=="object"&&!Array.isArray(E)){var p={};for(let I in E)VJ.test(I)&&(Pr(E[I],{instancePath:e+"/structure/"+I.replace(/~/g,"~0").replace(/\//g,"~1"),parentData:E,parentDataProperty:I,rootData:i,dynamicAnchors:o})||(s=s===null?Pr.errors:s.concat(Pr.errors),a=s.length),p[I]=!0)}else return $i.errors=[{instancePath:e+"/structure",schemaPath:"#/properties/structure/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var u=A===a}else var u=!0}}}}}else return $i.errors=[{instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;return $i.errors=s,a===0}$i.evaluated={props:!0,dynamicProps:!1,dynamicItems:!1};var o8e=Pr,s8e=_s,GJ={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://identity.foundation/dwn/json-schemas/protocols-configure.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","definition"],properties:{interface:{enum:["Protocols"],type:"string"},method:{enum:["Configure"],type:"string"},messageTimestamp:{$ref:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/date-time"},definition:{$ref:"https://identity.foundation/dwn/json-schemas/protocol-definition.json"}}}}};function _s(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:i=t,dynamicAnchors:o={}}={}){let s=null,a=0,d=_s.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.authorization===void 0&&(l="authorization")||t.descriptor===void 0&&(l="descriptor"))return _s.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 _s.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;qn(t.authorization,{instancePath:e+"/authorization",parentData:t,parentDataProperty:"authorization",rootData:i,dynamicAnchors:o})||(s=s===null?qn.errors:s.concat(qn.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 E;if(p.interface===void 0&&(E="interface")||p.method===void 0&&(E="method")||p.messageTimestamp===void 0&&(E="messageTimestamp")||p.definition===void 0&&(E="definition"))return _s.errors=[{instancePath:e+"/descriptor",schemaPath:"#/properties/descriptor/required",keyword:"required",params:{missingProperty:E},message:"must have required property '"+E+"'"}],!1;{let A=a;for(let P in p)if(!(P==="interface"||P==="method"||P==="messageTimestamp"||P==="definition")){return _s.errors=[{instancePath:e+"/descriptor",schemaPath:"#/properties/descriptor/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:P},message:"must NOT have additional properties"}],!1;break}if(A===a){if(p.interface!==void 0){let P=p.interface,I=a;if(typeof P!="string")return _s.errors=[{instancePath:e+"/descriptor/interface",schemaPath:"#/properties/descriptor/properties/interface/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;if(P!=="Protocols")return _s.errors=[{instancePath:e+"/descriptor/interface",schemaPath:"#/properties/descriptor/properties/interface/enum",keyword:"enum",params:{allowedValues:GJ.properties.descriptor.properties.interface.enum},message:"must be equal to one of the allowed values"}],!1;var c=I===a}else var c=!0;if(c){if(p.method!==void 0){let P=p.method,I=a;if(typeof P!="string")return _s.errors=[{instancePath:e+"/descriptor/method",schemaPath:"#/properties/descriptor/properties/method/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;if(P!=="Configure")return _s.errors=[{instancePath:e+"/descriptor/method",schemaPath:"#/properties/descriptor/properties/method/enum",keyword:"enum",params:{allowedValues:GJ.properties.descriptor.properties.method.enum},message:"must be equal to one of the allowed values"}],!1;var c=I===a}else var c=!0;if(c){if(p.messageTimestamp!==void 0){let P=p.messageTimestamp,I=a;if(a===a)if(typeof P=="string"){if(!Un.test(P))return _s.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 _s.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=I===a}else var c=!0;if(c)if(p.definition!==void 0){let P=a;$i(p.definition,{instancePath:e+"/descriptor/definition",parentData:p,parentDataProperty:"definition",rootData:i,dynamicAnchors:o})||(s=s===null?$i.errors:s.concat($i.errors),a=s.length);var c=P===a}else var c=!0}}}}}else return _s.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 _s.errors=[{instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;return _s.errors=s,a===0}_s.evaluated={props:!0,dynamicProps:!1,dynamicItems:!1};var a8e=si,JJ={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://identity.foundation/dwn/json-schemas/protocols-query.json",type:"object",additionalProperties:!1,required:["descriptor"],properties:{authorization:{$ref:"https://identity.foundation/dwn/json-schemas/authorization.json"},descriptor:{type:"object",additionalProperties:!1,required:["interface","method","messageTimestamp"],properties:{interface:{enum:["Protocols"],type:"string"},method:{enum:["Query"],type:"string"},messageTimestamp:{$ref:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/date-time"},filter:{type:"object",minProperties:1,additionalProperties:!1,properties:{protocol:{type:"string"},recipient:{$ref:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/did"}}}}}}};function si(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:i=t,dynamicAnchors:o={}}={}){let s=null,a=0,d=si.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.descriptor===void 0&&(m="descriptor"))return si.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 si.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;qn(t.authorization,{instancePath:e+"/authorization",parentData:t,parentDataProperty:"authorization",rootData:i,dynamicAnchors:o})||(s=s===null?qn.errors:s.concat(qn.errors),a=s.length);var u=g===a}else var u=!0;if(u)if(t.descriptor!==void 0){let g=t.descriptor,v=a;if(a===v)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 si.errors=[{instancePath:e+"/descriptor",schemaPath:"#/properties/descriptor/required",keyword:"required",params:{missingProperty:A},message:"must have required property '"+A+"'"}],!1;{let P=a;for(let I in g)if(!(I==="interface"||I==="method"||I==="messageTimestamp"||I==="filter")){return si.errors=[{instancePath:e+"/descriptor",schemaPath:"#/properties/descriptor/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:I},message:"must NOT have additional properties"}],!1;break}if(P===a){if(g.interface!==void 0){let I=g.interface,$=a;if(typeof I!="string")return si.errors=[{instancePath:e+"/descriptor/interface",schemaPath:"#/properties/descriptor/properties/interface/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;if(I!=="Protocols")return si.errors=[{instancePath:e+"/descriptor/interface",schemaPath:"#/properties/descriptor/properties/interface/enum",keyword:"enum",params:{allowedValues:JJ.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 I=g.method,$=a;if(typeof I!="string")return si.errors=[{instancePath:e+"/descriptor/method",schemaPath:"#/properties/descriptor/properties/method/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;if(I!=="Query")return si.errors=[{instancePath:e+"/descriptor/method",schemaPath:"#/properties/descriptor/properties/method/enum",keyword:"enum",params:{allowedValues:JJ.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 I=g.messageTimestamp,$=a;if(a===a)if(typeof I=="string"){if(!Un.test(I))return si.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 si.errors=[{instancePath:e+"/descriptor/messageTimestamp",schemaPath:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/date-time/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var c=$===a}else var c=!0;if(c)if(g.filter!==void 0){let I=g.filter,$=a;if(a===$)if(I&&typeof I=="object"&&!Array.isArray(I)){if(Object.keys(I).length<1)return si.errors=[{instancePath:e+"/descriptor/filter",schemaPath:"#/properties/descriptor/properties/filter/minProperties",keyword:"minProperties",params:{limit:1},message:"must NOT have fewer than 1 properties"}],!1;{let K=a;for(let F in I)if(!(F==="protocol"||F==="recipient")){return si.errors=[{instancePath:e+"/descriptor/filter",schemaPath:"#/properties/descriptor/properties/filter/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:F},message:"must NOT have additional properties"}],!1;break}if(K===a){if(I.protocol!==void 0){let F=a;if(typeof I.protocol!="string")return si.errors=[{instancePath:e+"/descriptor/filter/protocol",schemaPath:"#/properties/descriptor/properties/filter/properties/protocol/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var l=F===a}else var l=!0;if(l)if(I.recipient!==void 0){let F=I.recipient,U=a;if(a===a)if(typeof F=="string"){if(!b0.test(F))return si.errors=[{instancePath:e+"/descriptor/filter/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 si.errors=[{instancePath:e+"/descriptor/filter/recipient",schemaPath:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/did/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var l=U===a}else var l=!0}}}else return si.errors=[{instancePath:e+"/descriptor/filter",schemaPath:"#/properties/descriptor/properties/filter/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var c=$===a}else var c=!0}}}}}else return si.errors=[{instancePath:e+"/descriptor",schemaPath:"#/properties/descriptor/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var u=v===a}else var u=!0}}}else return si.errors=[{instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;return si.errors=s,a===0}si.evaluated={props:!0,dynamicProps:!1,dynamicItems:!1};var c8e=xs,YJ={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://identity.foundation/dwn/json-schemas/records-read.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:["Read"],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 xs(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:i=t,dynamicAnchors:o={}}={}){let s=null,a=0,d=xs.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 xs.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 xs.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;ho(t.authorization,{instancePath:e+"/authorization",parentData:t,parentDataProperty:"authorization",rootData:i,dynamicAnchors:o})||(s=s===null?ho.errors:s.concat(ho.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 E;if(p.interface===void 0&&(E="interface")||p.method===void 0&&(E="method")||p.messageTimestamp===void 0&&(E="messageTimestamp")||p.filter===void 0&&(E="filter"))return xs.errors=[{instancePath:e+"/descriptor",schemaPath:"#/properties/descriptor/required",keyword:"required",params:{missingProperty:E},message:"must have required property '"+E+"'"}],!1;{let A=a;for(let P in p)if(!(P==="interface"||P==="method"||P==="messageTimestamp"||P==="filter")){return xs.errors=[{instancePath:e+"/descriptor",schemaPath:"#/properties/descriptor/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:P},message:"must NOT have additional properties"}],!1;break}if(A===a){if(p.interface!==void 0){let P=p.interface,I=a;if(typeof P!="string")return xs.errors=[{instancePath:e+"/descriptor/interface",schemaPath:"#/properties/descriptor/properties/interface/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;if(P!=="Records")return xs.errors=[{instancePath:e+"/descriptor/interface",schemaPath:"#/properties/descriptor/properties/interface/enum",keyword:"enum",params:{allowedValues:YJ.properties.descriptor.properties.interface.enum},message:"must be equal to one of the allowed values"}],!1;var c=I===a}else var c=!0;if(c){if(p.method!==void 0){let P=p.method,I=a;if(typeof P!="string")return xs.errors=[{instancePath:e+"/descriptor/method",schemaPath:"#/properties/descriptor/properties/method/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;if(P!=="Read")return xs.errors=[{instancePath:e+"/descriptor/method",schemaPath:"#/properties/descriptor/properties/method/enum",keyword:"enum",params:{allowedValues:YJ.properties.descriptor.properties.method.enum},message:"must be equal to one of the allowed values"}],!1;var c=I===a}else var c=!0;if(c){if(p.messageTimestamp!==void 0){let P=p.messageTimestamp,I=a;if(a===a)if(typeof P=="string"){if(!Un.test(P))return xs.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 xs.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=I===a}else var c=!0;if(c)if(p.filter!==void 0){let P=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=P===a}else var c=!0}}}}}else return xs.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 xs.errors=[{instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;return xs.errors=s,a===0}xs.evaluated={props:!0,dynamicProps:!1,dynamicItems:!1};var d8e=Je,u8e=tn,l8e=Xd;function Xd(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:i=t,dynamicAnchors:o={}}={}){let s=null,a=0,d=Xd.evaluated;if(d.dynamicProps&&(d.props=void 0),d.dynamicItems&&(d.items=void 0),a===0)if(t&&typeof t=="object"&&!Array.isArray(t)){let c;if(t.descriptorCid===void 0&&(c="descriptorCid"))return Xd.errors=[{instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:c},message:"must have required property '"+c+"'"}],!1;{let l=a;for(let m in t)if(!(m==="descriptorCid"||m==="delegatedGrantId"||m==="permissionGrantId"||m==="protocolRole")){return Xd.errors=[{instancePath:e,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:m},message:"must NOT have additional properties"}],!1;break}if(l===a){if(t.descriptorCid!==void 0){let m=a;if(typeof t.descriptorCid!="string")return Xd.errors=[{instancePath:e+"/descriptorCid",schemaPath:"#/properties/descriptorCid/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var u=m===a}else var u=!0;if(u){if(t.delegatedGrantId!==void 0){let m=a;if(typeof t.delegatedGrantId!="string")return Xd.errors=[{instancePath:e+"/delegatedGrantId",schemaPath:"#/properties/delegatedGrantId/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var u=m===a}else var u=!0;if(u){if(t.permissionGrantId!==void 0){let m=a;if(typeof t.permissionGrantId!="string")return Xd.errors=[{instancePath:e+"/permissionGrantId",schemaPath:"#/properties/permissionGrantId/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var u=m===a}else var u=!0;if(u)if(t.protocolRole!==void 0){let m=a;if(typeof t.protocolRole!="string")return Xd.errors=[{instancePath:e+"/protocolRole",schemaPath:"#/properties/protocolRole/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var u=m===a}else var u=!0}}}}}else return Xd.errors=[{instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;return Xd.errors=s,a===0}Xd.evaluated={props:!0,dynamicProps:!1,dynamicItems:!1};var f8e=ea;function ea(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:i=t,dynamicAnchors:o={}}={}){let s=null,a=0,d=ea.evaluated;if(d.dynamicProps&&(d.props=void 0),d.dynamicItems&&(d.items=void 0),a===0)if(t&&typeof t=="object"&&!Array.isArray(t)){let c;if(t.descriptorCid===void 0&&(c="descriptorCid")||t.recordId===void 0&&(c="recordId"))return ea.errors=[{instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:c},message:"must have required property '"+c+"'"}],!1;{let l=a;for(let m in t)if(!(m==="descriptorCid"||m==="recordId"||m==="contextId"||m==="attestationCid"||m==="encryptionCid"||m==="delegatedGrantId"||m==="permissionGrantId"||m==="protocolRole")){return ea.errors=[{instancePath:e,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:m},message:"must NOT have additional properties"}],!1;break}if(l===a){if(t.descriptorCid!==void 0){let m=a;if(typeof t.descriptorCid!="string")return ea.errors=[{instancePath:e+"/descriptorCid",schemaPath:"#/properties/descriptorCid/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var u=m===a}else var u=!0;if(u){if(t.recordId!==void 0){let m=a;if(typeof t.recordId!="string")return ea.errors=[{instancePath:e+"/recordId",schemaPath:"#/properties/recordId/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var u=m===a}else var u=!0;if(u){if(t.contextId!==void 0){let m=a;if(typeof t.contextId!="string")return ea.errors=[{instancePath:e+"/contextId",schemaPath:"#/properties/contextId/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var u=m===a}else var u=!0;if(u){if(t.attestationCid!==void 0){let m=a;if(typeof t.attestationCid!="string")return ea.errors=[{instancePath:e+"/attestationCid",schemaPath:"#/properties/attestationCid/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var u=m===a}else var u=!0;if(u){if(t.encryptionCid!==void 0){let m=a;if(typeof t.encryptionCid!="string")return ea.errors=[{instancePath:e+"/encryptionCid",schemaPath:"#/properties/encryptionCid/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var u=m===a}else var u=!0;if(u){if(t.delegatedGrantId!==void 0){let m=a;if(typeof t.delegatedGrantId!="string")return ea.errors=[{instancePath:e+"/delegatedGrantId",schemaPath:"#/properties/delegatedGrantId/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var u=m===a}else var u=!0;if(u){if(t.permissionGrantId!==void 0){let m=a;if(typeof t.permissionGrantId!="string")return ea.errors=[{instancePath:e+"/permissionGrantId",schemaPath:"#/properties/permissionGrantId/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var u=m===a}else var u=!0;if(u)if(t.protocolRole!==void 0){let m=a;if(typeof t.protocolRole!="string")return ea.errors=[{instancePath:e+"/protocolRole",schemaPath:"#/properties/protocolRole/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var u=m===a}else var u=!0}}}}}}}}}else return ea.errors=[{instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;return ea.errors=s,a===0}ea.evaluated={props:!0,dynamicProps:!1,dynamicItems:!1};var h8e=ta;function ta(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:i=t,dynamicAnchors:o={}}={}){let s=null,a=0,d=ta.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 ta.errors=[{instancePath:e,schemaPath:"#/minProperties",keyword:"minProperties",params:{limit:1},message:"must NOT have fewer than 1 properties"}],!1;{let v=a;for(let E in t)if(!(E==="gt"||E==="gte"||E==="lt"||E==="lte")){return ta.errors=[{instancePath:e,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:E},message:"must NOT have additional properties"}],!1;break}if(v===a){if(t.gt!==void 0){let E=a,A=a,P=a;if(t&&typeof t=="object"&&!Array.isArray(t)){let I;if(t.gte===void 0&&(I="gte")){let $={};s===null?s=[$]:s.push($),a++}}var u=P===a;if(u)return ta.errors=[{instancePath:e,schemaPath:"#/dependencies/gt/not",keyword:"not",params:{},message:"must NOT be valid"}],!1;a=A,s!==null&&(A?s.length=A:s=null);var c=E===a}else var c=!0;if(c){if(t.gte!==void 0){let E=a,A=a,P=a;if(t&&typeof t=="object"&&!Array.isArray(t)){let $;if(t.gt===void 0&&($="gt")){let N={};s===null?s=[N]:s.push(N),a++}}var l=P===a;if(l)return ta.errors=[{instancePath:e,schemaPath:"#/dependencies/gte/not",keyword:"not",params:{},message:"must NOT be valid"}],!1;a=A,s!==null&&(A?s.length=A:s=null);var c=E===a}else var c=!0;if(c){if(t.lt!==void 0){let E=a,A=a,P=a;if(t&&typeof t=="object"&&!Array.isArray(t)){let $;if(t.lte===void 0&&($="lte")){let N={};s===null?s=[N]:s.push(N),a++}}var m=P===a;if(m)return ta.errors=[{instancePath:e,schemaPath:"#/dependencies/lt/not",keyword:"not",params:{},message:"must NOT be valid"}],!1;a=A,s!==null&&(A?s.length=A:s=null);var c=E===a}else var c=!0;if(c){if(t.lte!==void 0){let E=a,A=a,P=a;if(t&&typeof t=="object"&&!Array.isArray(t)){let $;if(t.lt===void 0&&($="lt")){let N={};s===null?s=[N]:s.push(N),a++}}var p=P===a;if(p)return ta.errors=[{instancePath:e,schemaPath:"#/dependencies/lte/not",keyword:"not",params:{},message:"must NOT be valid"}],!1;a=A,s!==null&&(A?s.length=A:s=null);var c=E===a}else var c=!0;if(c){if(t.gt!==void 0){let E=a;if(typeof t.gt!="string")return ta.errors=[{instancePath:e+"/gt",schemaPath:"#/properties/gt/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var g=E===a}else var g=!0;if(g){if(t.gte!==void 0){let E=a;if(typeof t.gte!="string")return ta.errors=[{instancePath:e+"/gte",schemaPath:"#/properties/gte/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var g=E===a}else var g=!0;if(g){if(t.lt!==void 0){let E=a;if(typeof t.lt!="string")return ta.errors=[{instancePath:e+"/lt",schemaPath:"#/properties/lt/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var g=E===a}else var g=!0;if(g)if(t.lte!==void 0){let E=a;if(typeof t.lte!="string")return ta.errors=[{instancePath:e+"/lte",schemaPath:"#/properties/lte/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var g=E===a}else var g=!0}}}}}}}}}else return ta.errors=[{instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;return ta.errors=s,a===0}ta.evaluated={props:!0,dynamicProps:!1,dynamicItems:!1};function Hf(t,e){let r=qB[t];if(!r)throw new se(ne.SchemaValidatorSchemaNotFound,`schema for ${t} not found.`);if(r(e),!r.errors)return;let[n]=r.errors,{instancePath:i,message:o,keyword:s}=n;if(i||(i=t),s==="additionalProperties"){let a=n.params.additionalProperty;throw new se(ne.SchemaValidatorAdditionalPropertyNotAllowed,`${o}: ${i}: ${a}`)}if(s==="unevaluatedProperties"){let a=n.params.unevaluatedProperty;throw new se(ne.SchemaValidatorUnevaluatedPropertyNotAllowed,`${o}: ${i}: ${a}`)}throw new se(ne.SchemaValidatorFailure,`${i}: ${o}`)}var LB=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},x0=class t{constructor(e){this.cache=e||new o8(600)}static get singleton(){return t._singleton===void 0&&(t._singleton=new t),t._singleton}static verifySignatures(e,r){return LB(this,void 0,void 0,function*(){return yield t.singleton.verifySignatures(e,r)})}verifySignatures(e,r){return LB(this,void 0,void 0,function*(){let n=[];for(let i of e.signatures){let o,s=en.getKid(i),a=`${i.protected}.${e.payload}.${i.signature}`,d=yield this.cache.get(a);if(d===void 0){let c=yield t.getPublicKey(s,r);o=yield en.verifySignature(e.payload,i,c),yield this.cache.set(a,o)}else o=d;let u=en.extractDid(s);if(o)n.push(u);else throw new se(ne.GeneralJwsVerifierInvalidSignature,`Signature verification failed for ${u}`)}return{signers:n}})}static getPublicKey(e,r){return LB(this,void 0,void 0,function*(){let n=en.extractDid(e),{didDocument:i}=yield r.resolve(n),{verificationMethod:o=[]}=i||{},s;for(let d of o)if(e.endsWith(d.id)){s=d;break}if(!s)throw new se(ne.GeneralJwsVerifierGetPublicKeyNotFound,"public key needed to verify signature not found in DID Document");Hf("JwkVerificationMethod",s);let{publicKeyJwk:a}=s;return a})}};h();h();var S0={};Fr(S0,{code:()=>Y_,decode:()=>Z8e,encode:()=>Y8e,name:()=>J8e});h();h();h();h();var p8e=["string","number","bigint","symbol"],m8e=["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 QJ(t){if(t===null)return"null";if(t===void 0)return"undefined";if(t===!0||t===!1)return"boolean";let e=typeof t;if(p8e.includes(e))return e;if(e==="function")return"Function";if(Array.isArray(t))return"Array";if(y8e(t))return"Buffer";let r=g8e(t);return r||"Object"}function y8e(t){return t&&t.constructor&&t.constructor.isBuffer&&t.constructor.isBuffer.call(null,t)}function g8e(t){let e=Object.prototype.toString.call(t).slice(8,-1);if(m8e.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.major<e.major?-1:this.major>e.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 Mb=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",v8e=new TextDecoder,b8e=new TextEncoder;function c8(t){return Mb&&globalThis.Buffer.isBuffer(t)}function KB(t){return t instanceof Uint8Array?c8(t)?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):t:Uint8Array.from(t)}var nY=Mb?(t,e,r)=>r-e>64?globalThis.Buffer.from(t.subarray(e,r)).toString("utf8"):tY(t,e,r):(t,e,r)=>r-e>64?v8e.decode(t.subarray(e,r)):tY(t,e,r),iY=Mb?t=>t.length>64?globalThis.Buffer.from(t):eY(t):t=>t.length>64?b8e.encode(t):eY(t),yl=t=>Uint8Array.from(t),Db=Mb?(t,e,r)=>c8(t)?new Uint8Array(t.subarray(e,r)):t.slice(e,r):(t,e,r)=>t.slice(e,r),oY=Mb?(t,e)=>(t=t.map(r=>r instanceof Uint8Array?r:globalThis.Buffer.from(r)),KB(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},sY=Mb?t=>globalThis.Buffer.allocUnsafe(t):t=>new Uint8Array(t);function aY(t,e){if(c8(t)&&c8(e))return t.compare(e);for(let r=0;r<t.length;r++)if(t[r]!==e[r])return t[r]<e[r]?-1:1;return 0}function eY(t,e=1/0){let r,n=t.length,i=null,o=[];for(let s=0;s<n;++s){if(r=t.charCodeAt(s),r>55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}else if(s+1===n){(e-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&o.push(239,191,189),i=r;continue}r=(i-55296<<10|r-56320)+65536}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;o.push(r)}else if(r<2048){if((e-=2)<0)break;o.push(r>>6|192,r&63|128)}else if(r<65536){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<1114112){if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,r&63|128)}else throw new Error("Invalid code point")}return o}function tY(t,e,r){let n=[];for(;e<r;){let i=t[e],o=null,s=i>239?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 w8e(n)}var rY=4096;function w8e(t){let e=t.length;if(e<=rY)return String.fromCharCode.apply(String,t);let r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=rY));return r}var _8e=256,z_=class{constructor(e=_8e){this.chunkSize=e,this.cursor=0,this.maxCursor=-1,this.chunks=[],this._initReuseChunk=null}reset(){this.cursor=0,this.maxCursor=-1,this.chunks.length&&(this.chunks=[]),this._initReuseChunk!==null&&(this.chunks.push(this._initReuseChunk),this.maxCursor=this._initReuseChunk.length-1)}push(e){let r=this.chunks[this.chunks.length-1];if(this.cursor+e.length<=this.maxCursor+1){let i=r.length-(this.maxCursor-this.cursor)-1;r.set(e,i)}else{if(r){let i=r.length-(this.maxCursor-this.cursor)-1;i<r.length&&(this.chunks[this.chunks.length-1]=r.subarray(0,i),this.maxCursor=this.cursor-1)}e.length<64&&e.length<this.chunkSize?(r=sY(this.chunkSize),this.chunks.push(r),this.maxCursor+=r.length,this._initReuseChunk===null&&(this._initReuseChunk=r),r.set(e,0)):(this.chunks.push(e),this.maxCursor+=e.length)}this.cursor+=e.length}toBytes(e=!1){let r;if(this.chunks.length===1){let n=this.chunks[0];e&&this.cursor>n.length/2?(r=this.cursor===n.length?n:n.subarray(0,this.cursor),this._initReuseChunk=null,this.chunks=[]):r=Db(n,0,this.cursor)}else r=oY(this.chunks,this.cursor);return e&&this.reset(),r}};h();var Lt="CBOR decode error:",FB="CBOR encode error:",V_=[];V_[23]=1;V_[24]=2;V_[25]=3;V_[26]=5;V_[27]=9;function Wf(t,e,r){if(t.length-e<r)throw new Error(`${Lt} not enough data for type`)}h();h();var po=[24,256,65536,4294967296,BigInt("18446744073709551616")];function ic(t,e,r){Wf(t,e,1);let n=t[e];if(r.strict===!0&&n<po[0])throw new Error(`${Lt} integer encoded in more bytes than necessary (strict decode)`);return n}function oc(t,e,r){Wf(t,e,2);let n=t[e]<<8|t[e+1];if(r.strict===!0&&n<po[1])throw new Error(`${Lt} integer encoded in more bytes than necessary (strict decode)`);return n}function sc(t,e,r){Wf(t,e,4);let n=t[e]*16777216+(t[e+1]<<16)+(t[e+2]<<8)+t[e+3];if(r.strict===!0&&n<po[2])throw new Error(`${Lt} integer encoded in more bytes than necessary (strict decode)`);return n}function ac(t,e,r){Wf(t,e,8);let n=t[e]*16777216+(t[e+1]<<16)+(t[e+2]<<8)+t[e+3],i=t[e+4]*16777216+(t[e+5]<<16)+(t[e+6]<<8)+t[e+7],o=(BigInt(n)<<BigInt(32))+BigInt(i);if(r.strict===!0&&o<po[3])throw new Error(`${Lt} integer encoded in more bytes than necessary (strict decode)`);if(o<=Number.MAX_SAFE_INTEGER)return Number(o);if(r.allowBigInt===!0)return o;throw new Error(`${Lt} integers outside of the safe integer range are not supported`)}function cY(t,e,r,n){return new ze(he.uint,ic(t,e+1,n),2)}function dY(t,e,r,n){return new ze(he.uint,oc(t,e+1,n),3)}function uY(t,e,r,n){return new ze(he.uint,sc(t,e+1,n),5)}function lY(t,e,r,n){return new ze(he.uint,ac(t,e+1,n),9)}function td(t,e){return Lo(t,0,e.value)}function Lo(t,e,r){if(r<po[0]){let n=Number(r);t.push([e|n])}else if(r<po[1]){let n=Number(r);t.push([e|24,n])}else if(r<po[2]){let n=Number(r);t.push([e|25,n>>>8,n&255])}else if(r<po[3]){let n=Number(r);t.push([e|26,n>>>24&255,n>>>16&255,n>>>8&255,n&255])}else{let n=BigInt(r);if(n<po[4]){let i=[e|27,0,0,0,0,0,0,0],o=Number(n&BigInt(4294967295)),s=Number(n>>BigInt(32)&BigInt(4294967295));i[8]=o&255,o=o>>8,i[7]=o&255,o=o>>8,i[6]=o&255,o=o>>8,i[5]=o&255,i[4]=s&255,s=s>>8,i[3]=s&255,s=s>>8,i[2]=s&255,s=s>>8,i[1]=s&255,t.push(i)}else throw new Error(`${Lt} encountered BigInt larger than allowable range`)}}td.encodedSize=function(e){return Lo.encodedSize(e.value)};Lo.encodedSize=function(e){return e<po[0]?1:e<po[1]?2:e<po[2]?3:e<po[3]?5:9};td.compareTokens=function(e,r){return e.value<r.value?-1:e.value>r.value?1:0};h();function fY(t,e,r,n){return new ze(he.negint,-1-ic(t,e+1,n),2)}function hY(t,e,r,n){return new ze(he.negint,-1-oc(t,e+1,n),3)}function pY(t,e,r,n){return new ze(he.negint,-1-sc(t,e+1,n),5)}var zB=BigInt(-1),mY=BigInt(1);function yY(t,e,r,n){let i=ac(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(`${Lt} integers outside of the safe integer range are not supported`);return new ze(he.negint,zB-BigInt(i),9)}function d8(t,e){let r=e.value,n=typeof r=="bigint"?r*zB-mY:r*-1-1;Lo(t,e.type.majorEncoded,n)}d8.encodedSize=function(e){let r=e.value,n=typeof r=="bigint"?r*zB-mY:r*-1-1;return n<po[0]?1:n<po[1]?2:n<po[2]?3:n<po[3]?5:9};d8.compareTokens=function(e,r){return e.value<r.value?1:e.value>r.value?-1:0};h();function H_(t,e,r,n){Wf(t,e,r+n);let i=Db(t,e+r,e+r+n);return new ze(he.bytes,i,r+n)}function gY(t,e,r,n){return H_(t,e,1,r)}function vY(t,e,r,n){return H_(t,e,2,ic(t,e+1,n))}function bY(t,e,r,n){return H_(t,e,3,oc(t,e+1,n))}function wY(t,e,r,n){return H_(t,e,5,sc(t,e+1,n))}function _Y(t,e,r,n){let i=ac(t,e+1,n);if(typeof i=="bigint")throw new Error(`${Lt} 64-bit integer bytes lengths not supported`);return H_(t,e,9,i)}function u8(t){return t.encodedBytes===void 0&&(t.encodedBytes=t.type===he.string?iY(t.value):t.value),t.encodedBytes}function Ob(t,e){let r=u8(e);Lo(t,e.type.majorEncoded,r.length),t.push(r)}Ob.encodedSize=function(e){let r=u8(e);return Lo.encodedSize(r.length)+r.length};Ob.compareTokens=function(e,r){return E8e(u8(e),u8(r))};function E8e(t,e){return t.length<e.length?-1:t.length>e.length?1:aY(t,e)}h();function W_(t,e,r,n,i){let o=r+n;Wf(t,e,o);let s=new ze(he.string,nY(t,e+r,e+o),o);return i.retainStringBytes===!0&&(s.byteValue=Db(t,e+r,e+o)),s}function xY(t,e,r,n){return W_(t,e,1,r,n)}function EY(t,e,r,n){return W_(t,e,2,ic(t,e+1,n),n)}function SY(t,e,r,n){return W_(t,e,3,oc(t,e+1,n),n)}function AY(t,e,r,n){return W_(t,e,5,sc(t,e+1,n),n)}function TY(t,e,r,n){let i=ac(t,e+1,n);if(typeof i=="bigint")throw new Error(`${Lt} 64-bit integer string lengths not supported`);return W_(t,e,9,i,n)}var IY=Ob;h();function Cb(t,e,r,n){return new ze(he.array,n,r)}function PY(t,e,r,n){return Cb(t,e,1,r)}function kY(t,e,r,n){return Cb(t,e,2,ic(t,e+1,n))}function RY(t,e,r,n){return Cb(t,e,3,oc(t,e+1,n))}function BY(t,e,r,n){return Cb(t,e,5,sc(t,e+1,n))}function MY(t,e,r,n){let i=ac(t,e+1,n);if(typeof i=="bigint")throw new Error(`${Lt} 64-bit integer array lengths not supported`);return Cb(t,e,9,i)}function DY(t,e,r,n){if(n.allowIndefinite===!1)throw new Error(`${Lt} indefinite length items not allowed`);return Cb(t,e,1,1/0)}function l8(t,e){Lo(t,he.array.majorEncoded,e.value)}l8.compareTokens=td.compareTokens;l8.encodedSize=function(e){return Lo.encodedSize(e.value)};h();function $b(t,e,r,n){return new ze(he.map,n,r)}function OY(t,e,r,n){return $b(t,e,1,r)}function CY(t,e,r,n){return $b(t,e,2,ic(t,e+1,n))}function $Y(t,e,r,n){return $b(t,e,3,oc(t,e+1,n))}function NY(t,e,r,n){return $b(t,e,5,sc(t,e+1,n))}function jY(t,e,r,n){let i=ac(t,e+1,n);if(typeof i=="bigint")throw new Error(`${Lt} 64-bit integer map lengths not supported`);return $b(t,e,9,i)}function UY(t,e,r,n){if(n.allowIndefinite===!1)throw new Error(`${Lt} indefinite length items not allowed`);return $b(t,e,1,1/0)}function f8(t,e){Lo(t,he.map.majorEncoded,e.value)}f8.compareTokens=td.compareTokens;f8.encodedSize=function(e){return Lo.encodedSize(e.value)};h();function qY(t,e,r,n){return new ze(he.tag,r,1)}function LY(t,e,r,n){return new ze(he.tag,ic(t,e+1,n),2)}function KY(t,e,r,n){return new ze(he.tag,oc(t,e+1,n),3)}function FY(t,e,r,n){return new ze(he.tag,sc(t,e+1,n),5)}function zY(t,e,r,n){return new ze(he.tag,ac(t,e+1,n),9)}function h8(t,e){Lo(t,he.tag.majorEncoded,e.value)}h8.compareTokens=td.compareTokens;h8.encodedSize=function(e){return Lo.encodedSize(e.value)};h();var k8e=20,R8e=21,B8e=22,M8e=23;function VY(t,e,r,n){if(n.allowUndefined===!1)throw new Error(`${Lt} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new ze(he.null,null,1):new ze(he.undefined,void 0,1)}function HY(t,e,r,n){if(n.allowIndefinite===!1)throw new Error(`${Lt} indefinite length items not allowed`);return new ze(he.break,void 0,1)}function VB(t,e,r){if(r){if(r.allowNaN===!1&&Number.isNaN(t))throw new Error(`${Lt} NaN values are not supported`);if(r.allowInfinity===!1&&(t===1/0||t===-1/0))throw new Error(`${Lt} Infinity values are not supported`)}return new ze(he.float,t,e)}function WY(t,e,r,n){return VB(HB(t,e+1),3,n)}function GY(t,e,r,n){return VB(WB(t,e+1),5,n)}function JY(t,e,r,n){return VB(QY(t,e+1),9,n)}function p8(t,e,r){let n=e.value;if(n===!1)t.push([he.float.majorEncoded|k8e]);else if(n===!0)t.push([he.float.majorEncoded|R8e]);else if(n===null)t.push([he.float.majorEncoded|B8e]);else if(n===void 0)t.push([he.float.majorEncoded|M8e]);else{let i,o=!1;(!r||r.float64!==!0)&&(ZY(n),i=HB(Qd,1),n===i||Number.isNaN(n)?(Qd[0]=249,t.push(Qd.slice(0,3)),o=!0):(XY(n),i=WB(Qd,1),n===i&&(Qd[0]=250,t.push(Qd.slice(0,5)),o=!0))),o||(D8e(n),i=QY(Qd,1),Qd[0]=251,t.push(Qd.slice(0,9)))}}p8.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){ZY(n);let i=HB(Qd,1);if(n===i||Number.isNaN(n))return 3;if(XY(n),i=WB(Qd,1),n===i)return 5}return 9};var YY=new ArrayBuffer(9),rd=new DataView(YY,1),Qd=new Uint8Array(YY,0);function ZY(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 HB(t,e){if(t.length-e<2)throw new Error(`${Lt} 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 XY(t){rd.setFloat32(0,t,!1)}function WB(t,e){if(t.length-e<4)throw new Error(`${Lt} not enough data for float32`);let r=(t.byteOffset||0)+e;return new DataView(t.buffer,r,4).getFloat32(0,!1)}function D8e(t){rd.setFloat64(0,t,!1)}function QY(t,e){if(t.length-e<8)throw new Error(`${Lt} not enough data for float64`);let r=(t.byteOffset||0)+e;return new DataView(t.buffer,r,8).getFloat64(0,!1)}p8.compareTokens=td.compareTokens;function Gr(t,e,r){throw new Error(`${Lt} encountered invalid minor (${r}) for major ${t[e]>>>5}`)}function m8(t){return()=>{throw new Error(`${Lt} ${t}`)}}var Be=[];for(let t=0;t<=23;t++)Be[t]=Gr;Be[24]=cY;Be[25]=dY;Be[26]=uY;Be[27]=lY;Be[28]=Gr;Be[29]=Gr;Be[30]=Gr;Be[31]=Gr;for(let t=32;t<=55;t++)Be[t]=Gr;Be[56]=fY;Be[57]=hY;Be[58]=pY;Be[59]=yY;Be[60]=Gr;Be[61]=Gr;Be[62]=Gr;Be[63]=Gr;for(let t=64;t<=87;t++)Be[t]=gY;Be[88]=vY;Be[89]=bY;Be[90]=wY;Be[91]=_Y;Be[92]=Gr;Be[93]=Gr;Be[94]=Gr;Be[95]=m8("indefinite length bytes/strings are not supported");for(let t=96;t<=119;t++)Be[t]=xY;Be[120]=EY;Be[121]=SY;Be[122]=AY;Be[123]=TY;Be[124]=Gr;Be[125]=Gr;Be[126]=Gr;Be[127]=m8("indefinite length bytes/strings are not supported");for(let t=128;t<=151;t++)Be[t]=PY;Be[152]=kY;Be[153]=RY;Be[154]=BY;Be[155]=MY;Be[156]=Gr;Be[157]=Gr;Be[158]=Gr;Be[159]=DY;for(let t=160;t<=183;t++)Be[t]=OY;Be[184]=CY;Be[185]=$Y;Be[186]=NY;Be[187]=jY;Be[188]=Gr;Be[189]=Gr;Be[190]=Gr;Be[191]=UY;for(let t=192;t<=215;t++)Be[t]=qY;Be[216]=LY;Be[217]=KY;Be[218]=FY;Be[219]=zY;Be[220]=Gr;Be[221]=Gr;Be[222]=Gr;Be[223]=Gr;for(let t=224;t<=243;t++)Be[t]=m8("simple values are not supported");Be[244]=Gr;Be[245]=Gr;Be[246]=Gr;Be[247]=VY;Be[248]=m8("simple values are not supported");Be[249]=WY;Be[250]=GY;Be[251]=JY;Be[252]=Gr;Be[253]=Gr;Be[254]=Gr;Be[255]=HY;var eu=[];for(let t=0;t<24;t++)eu[t]=new ze(he.uint,t,1);for(let t=-1;t>=-24;t--)eu[31-t]=new ze(he.negint,t,1);eu[64]=new ze(he.bytes,new Uint8Array(0),1);eu[96]=new ze(he.string,"",1);eu[128]=new ze(he.array,0,1);eu[160]=new ze(he.map,0,1);eu[244]=new ze(he.false,!1,1);eu[245]=new ze(he.true,!0,1);eu[246]=new ze(he.null,null,1);function eZ(t){switch(t.type){case he.false:return yl([244]);case he.true:return yl([245]);case he.null:return yl([246]);case he.bytes:return t.value.length?void 0:yl([64]);case he.string:return t.value===""?yl([96]):void 0;case he.array:return t.value===0?yl([128]):void 0;case he.map:return t.value===0?yl([160]):void 0;case he.uint:return t.value<24?yl([Number(t.value)]):void 0;case he.negint:if(t.value>=-24)return yl([31-Number(t.value)])}}var C8e={float64:!1,mapSorter:j8e,quickEncodeToken:eZ};function $8e(){let t=[];return t[he.uint.major]=td,t[he.negint.major]=d8,t[he.bytes.major]=Ob,t[he.string.major]=IY,t[he.array.major]=l8,t[he.map.major]=f8,t[he.tag.major]=h8,t[he.float.major]=p8,t}var tZ=$8e(),GB=new z_,g8=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(`${FB} object contains circular references`);return new t(r,e)}},qp={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)},Lp={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?qp.true:qp.false},null(t,e,r,n){return qp.null},undefined(t,e,r,n){return qp.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?[qp.emptyArray,new ze(he.break)]:qp.emptyArray;n=g8.createCheck(n,t);let i=[],o=0;for(let s of t)i[o++]=y8(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?[qp.emptyMap,new ze(he.break)]:qp.emptyMap;n=g8.createCheck(n,t);let a=[],d=0;for(let u of o)a[d++]=[y8(u,r,n),y8(i?t.get(u):t[u],r,n)];return N8e(a,r),r.addBreakTokens?[new ze(he.map,s),a,new ze(he.break)]:[new ze(he.map,s),a]}};Lp.Map=Lp.Object;Lp.Buffer=Lp.Uint8Array;for(let t of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))Lp[`${t}Array`]=Lp.DataView;function y8(t,e={},r){let n=QJ(t),i=e&&e.typeEncoders&&e.typeEncoders[n]||Lp[n];if(typeof i=="function"){let s=i(t,n,e,r);if(s!=null)return s}let o=Lp[n];if(!o)throw new Error(`${FB} unsupported type: ${n}`);return o(t,n,e,r)}function N8e(t,e){e.mapSorter&&t.sort(e.mapSorter)}function j8e(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=tZ[i].compareTokens(r,n);return o===0&&console.warn("WARNING: complex key types used, CBOR key sorting guarantees are gone"),o}function rZ(t,e,r,n){if(Array.isArray(e))for(let i of e)rZ(t,i,r,n);else r[e.type.major](t,e,n)}function U8e(t,e,r){let n=y8(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 z_(s);if(o(a,n,r),a.chunks.length!==1)throw new Error(`Unexpected error: pre-calculated length for ${n} was wrong`);return KB(a.chunks[0])}}return GB.reset(),rZ(GB,n,e,r),GB.toBytes(!0)}function JB(t,e){return e=Object.assign({},C8e,e),U8e(t,tZ,e)}h();var q8e={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},YB=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=eu[e];if(r===void 0){let n=Be[e];if(!n)throw new Error(`${Lt} 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}},G_=Symbol.for("DONE"),v8=Symbol.for("BREAK");function L8e(t,e,r){let n=[];for(let i=0;i<t.value;i++){let o=J_(e,r);if(o===v8){if(t.value===1/0)break;throw new Error(`${Lt} got unexpected break to lengthed array`)}if(o===G_)throw new Error(`${Lt} found array but not enough entries (got ${i}, expected ${t.value})`);n[i]=o}return n}function K8e(t,e,r){let n=r.useMaps===!0,i=n?void 0:{},o=n?new Map:void 0;for(let s=0;s<t.value;s++){let a=J_(e,r);if(a===v8){if(t.value===1/0)break;throw new Error(`${Lt} got unexpected break to lengthed map`)}if(a===G_)throw new Error(`${Lt} found map but not enough entries (got ${s} [no key], expected ${t.value})`);if(n!==!0&&typeof a!="string")throw new Error(`${Lt} non-string keys not supported (got ${typeof a})`);if(r.rejectDuplicateMapKeys===!0&&(n&&o.has(a)||!n&&a in i))throw new Error(`${Lt} found repeat map key "${a}"`);let d=J_(e,r);if(d===G_)throw new Error(`${Lt} found map but not enough entries (got ${s} [no value], expected ${t.value})`);n?o.set(a,d):i[a]=d}return n?o:i}function J_(t,e){if(t.done())return G_;let r=t.next();if(r.type===he.break)return v8;if(r.type.terminal)return r.value;if(r.type===he.array)return L8e(r,t,e);if(r.type===he.map)return K8e(r,t,e);if(r.type===he.tag){if(e.tags&&typeof e.tags[r.value]=="function"){let n=J_(t,e);return e.tags[r.value](n)}throw new Error(`${Lt} tag not supported (${r.value})`)}throw new Error("unsupported")}function ZB(t,e){if(!(t instanceof Uint8Array))throw new Error(`${Lt} data to decode must be a Uint8Array`);e=Object.assign({},q8e,e);let r=e.tokenizer||new YB(t,e),n=J_(r,e);if(n===G_)throw new Error(`${Lt} did not find any content to decode`);if(n===v8)throw new Error(`${Lt} got unexpected break`);if(!r.done())throw new Error(`${Lt} too many terminals, data makes no sense`);return n}var nZ=42;function z8e(t){if(t.asCID!==t&&t["/"]!==t.bytes)return null;let e=m0.asCID(t);if(!e)return null;let r=new Uint8Array(e.bytes.byteLength+1);return r.set(e.bytes,1),[new ze(he.tag,nZ),new ze(he.bytes,r)]}function V8e(){throw new Error("`undefined` is not supported by the IPLD Data Model and cannot be encoded")}function H8e(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 W8e={float64:!0,typeEncoders:{Object:z8e,undefined:V8e,number:H8e}};function G8e(t){if(t[0]!==0)throw new Error("Invalid CID for CBOR tag 42; expected leading 0x00");return m0.decode(t.subarray(1))}var iZ={allowIndefinite:!1,coerceUndefinedToNull:!0,allowNaN:!1,allowInfinity:!1,allowBigInt:!0,strict:!0,useMaps:!1,rejectDuplicateMapKeys:!0,tags:[]};iZ.tags[nZ]=G8e;var J8e="dag-cbor",Y_=113,Y8e=t=>JB(t,W8e),Z8e=t=>ZB(t,iZ);h();var Kp=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},b8=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)}},mo=function(t){return this instanceof mo?(this.v=t,this):new mo(t)},w8=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,v){o.push([m,p,g,v])>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 mo?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])}},Z_=class{open(){return Kp(this,void 0,void 0,function*(){})}close(){return Kp(this,void 0,void 0,function*(){})}put(e,r,n){return Kp(this,void 0,void 0,function*(){return e})}get(e,r){return Kp(this,void 0,void 0,function*(){return new Uint8Array})}has(e,r){return Kp(this,void 0,void 0,function*(){return!1})}delete(e,r){return Kp(this,void 0,void 0,function*(){})}isEmpty(e){return Kp(this,void 0,void 0,function*(){return!0})}putMany(e,r){return w8(this,arguments,function*(){var i,o,s,a;try{for(var d=!0,u=b8(e),c;c=yield mo(u.next()),i=c.done,!i;d=!0){a=c.value,d=!1;let l=a;yield mo(this.put(l.cid,l.block,r)),yield yield mo(l.cid)}}catch(l){o={error:l}}finally{try{!d&&!i&&(s=u.return)&&(yield mo(s.call(u)))}finally{if(o)throw o.error}}})}getMany(e,r){return w8(this,arguments,function*(){var i,o,s,a;try{for(var d=!0,u=b8(e),c;c=yield mo(u.next()),i=c.done,!i;d=!0){a=c.value,d=!1;let l=a;yield yield mo({cid:l,block:yield mo(this.get(l,r))})}}catch(l){o={error:l}}finally{try{!d&&!i&&(s=u.return)&&(yield mo(s.call(u)))}finally{if(o)throw o.error}}})}getAll(e){return w8(this,arguments,function*(){var n,i,o,s;let a=this.db.iterator({keys:!0,keyEncoding:"buffer"},e);try{for(var d=!0,u=b8(a),c;c=yield mo(u.next()),n=c.done,!n;d=!0){s=c.value,d=!1;let[l,m]=s;yield yield mo({cid:$r.decode(l),block:m})}}catch(l){i={error:l}}finally{try{!d&&!n&&(o=u.return)&&(yield mo(o.call(u)))}finally{if(i)throw i.error}}})}deleteMany(e,r){return w8(this,arguments,function*(){var i,o,s,a;try{for(var d=!0,u=b8(e),c;c=yield mo(u.next()),i=c.done,!i;d=!0){a=c.value,d=!1;let l=a;yield mo(this.delete(l,r)),yield yield mo(l)}}catch(l){o={error:l}}finally{try{!d&&!i&&(s=u.return)&&(yield mo(s.call(u)))}finally{if(o)throw o.error}}})}clear(){return Kp(this,void 0,void 0,function*(){})}};h();var aTe=qt(cc(),1);h();h();h();function Q8e(t){return t[Symbol.asyncIterator]!=null}function e4e(t,e=1){return e=Number(e),Q8e(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 X_=e4e;async function*Q_(t,e=1){for await(let r of X_(t,e)){let n=r.map(async i=>i().then(o=>({ok:!0,value:o}),o=>({ok:!1,err:o})));for(let i=0;i<n.length;i++){let o=await n[i];if(o.ok)yield o.value;else throw o.err}}}h();h();h();h();function Fp(t){return globalThis.Buffer!=null?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):t}function Gf(t=0){return globalThis.Buffer?.alloc!=null?Fp(globalThis.Buffer.alloc(t)):new Uint8Array(t)}function dc(t=0){return globalThis.Buffer?.allocUnsafe!=null?Fp(globalThis.Buffer.allocUnsafe(t)):new Uint8Array(t)}h();function ex(t,e){if(globalThis.Buffer!=null)return Fp(globalThis.Buffer.concat(t,e));e==null&&(e=t.reduce((i,o)=>i+o.length,0));let r=dc(e),n=0;for(let i of t)r.set(i,n),n+=i.length;return Fp(r)}h();function aZ(t,e){if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let r=0;r<t.byteLength;r++)if(t[r]!==e[r])return!1;return!0}var dZ=Symbol.for("@achingbrain/uint8arraylist");function cZ(t,e){if(e==null||e<0)throw new RangeError("index is out of bounds");let r=0;for(let n of t){let i=r+n.byteLength;if(e<i)return{buf:n,index:e-r};r=i}throw new RangeError("index is out of bounds")}function _8(t){return!!t?.[dZ]}var Nb=class t{bufs;length;[dZ]=!0;constructor(...e){this.bufs=[],this.length=0,e.length>0&&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(_8(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(_8(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=cZ(this.bufs,e);return r.buf[r.index]}set(e,r){let n=cZ(this.bufs,e);n.buf[n.index]=r}write(e,r=0){if(e instanceof Uint8Array)for(let n=0;n<e.length;n++)this.set(r+n,e[n]);else if(_8(e))for(let n=0;n<e.length;n++)this.set(r+n,e.get(n));else throw new Error("Could not write value, must be an Uint8Array or a Uint8ArrayList")}consume(e){if(e=Math.trunc(e),!(Number.isNaN(e)||e<=0)){if(e===this.byteLength){this.bufs=[],this.length=0;return}for(;this.bufs.length>0;)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 ex(n,i)}subarray(e,r){let{bufs:n,length:i}=this._subList(e,r);return n.length===1?n[0]:ex(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<this.bufs.length;o++){let s=this.bufs[o],a=i,d=a+s.byteLength;if(i=d,e>=d)continue;let u=e>=a&&e<d,c=r>a&&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(!_8(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<o;l++)s[l]=-1;for(let l=0;l<i;l++)s[n[l]]=l;let a=s,d=this.byteLength-n.byteLength,u=n.byteLength-1,c;for(let l=r;l<=d;l+=c){c=0;for(let m=u;m>=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=dc(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=Gf(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=Gf(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=Gf(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=dc(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=Gf(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=Gf(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=Gf(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=Gf(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=Gf(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;r<this.bufs.length;r++)if(!aZ(this.bufs[r],e.bufs[r]))return!1;return!0}static fromUint8Arrays(e,r){let n=new t;return n.bufs=e,r==null&&(r=e.reduce((i,o)=>i+o.byteLength,0)),n.length=r,n}};var t4e=262144,uZ=(t={})=>{let e=t.chunkSize??t4e;return async function*(n){let i=new Nb,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 Nb,o=0;else{let d=new Nb;d.append(i.sublist(e)),i=d,o-=e}(!s||o>0)&&(yield i.subarray(0,o))}};h();var T0={};Fr(T0,{code:()=>sx,createLink:()=>BZ,createNode:()=>RZ,decode:()=>Jf,encode:()=>lc,name:()=>X4e,prepare:()=>uc,validate:()=>lM});h();h();var oM={};Fr(oM,{base32:()=>qb,base32hex:()=>h4e,base32hexpad:()=>m4e,base32hexpadupper:()=>y4e,base32hexupper:()=>p4e,base32pad:()=>l4e,base32padupper:()=>f4e,base32upper:()=>u4e,base32z:()=>g4e});h();h();var jb={};Fr(jb,{coerce:()=>gl,empty:()=>lZ,equals:()=>XB,fromHex:()=>n4e,fromString:()=>QB,isBinary:()=>i4e,toHex:()=>r4e,toString:()=>eM});h();var lZ=new Uint8Array(0);function r4e(t){return t.reduce((e,r)=>e+r.toString(16).padStart(2,"0"),"")}function n4e(t){let e=t.match(/../g);return e!=null?new Uint8Array(e.map(r=>parseInt(r,16))):lZ}function XB(t,e){if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let r=0;r<t.byteLength;r++)if(t[r]!==e[r])return!1;return!0}function gl(t){if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new Error("Unknown type, must be binary type")}function i4e(t){return t instanceof ArrayBuffer||ArrayBuffer.isView(t)}function QB(t){return new TextEncoder().encode(t)}function eM(t){return new TextDecoder().decode(t)}h();function o4e(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var i=0;i<t.length;i++){var o=t.charAt(i),s=o.charCodeAt(0);if(r[s]!==255)throw new TypeError(o+" is ambiguous");r[s]=i}var a=t.length,d=t.charAt(0),u=Math.log(a)/Math.log(256),c=Math.log(256)/Math.log(a);function l(g){if(g instanceof Uint8Array||(ArrayBuffer.isView(g)?g=new Uint8Array(g.buffer,g.byteOffset,g.byteLength):Array.isArray(g)&&(g=Uint8Array.from(g))),!(g instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(g.length===0)return"";for(var v=0,E=0,A=0,P=g.length;A!==P&&g[A]===0;)A++,v++;for(var I=(P-A)*c+1>>>0,$=new Uint8Array(I);A!==P;){for(var N=g[A],K=0,F=I-1;(N!==0||K<E)&&F!==-1;F--,K++)N+=256*$[F]>>>0,$[F]=N%a>>>0,N=N/a>>>0;if(N!==0)throw new Error("Non-zero carry");E=K,A++}for(var U=I-E;U!==I&&$[U]===0;)U++;for(var V=d.repeat(v);U<I;++U)V+=t.charAt($[U]);return V}function m(g){if(typeof g!="string")throw new TypeError("Expected String");if(g.length===0)return new Uint8Array;var v=0;if(g[v]!==" "){for(var E=0,A=0;g[v]===d;)E++,v++;for(var P=(g.length-v)*u+1>>>0,I=new Uint8Array(P);g[v];){var $=r[g.charCodeAt(v)];if($===255)return;for(var N=0,K=P-1;($!==0||N<A)&&K!==-1;K--,N++)$+=a*I[K]>>>0,I[K]=$%256>>>0,$=$/256>>>0;if($!==0)throw new Error("Non-zero carry");A=N,v++}if(g[v]!==" "){for(var F=P-A;F!==P&&I[F]===0;)F++;for(var U=new Uint8Array(E+(P-F)),V=E;F!==P;)U[V++]=I[F++];return U}}}function p(g){var v=m(g);if(v)return v;throw new Error(`Non-${e} character`)}return{encode:l,decodeUnsafe:m,decode:p}}var s4e=o4e,a4e=s4e,fZ=a4e;var tM=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")}},rM=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 hZ(this,e)}},nM=class{decoders;constructor(e){this.decoders=e}or(e){return hZ(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 hZ(t,e){return new nM({...t.decoders??{[t.prefix]:t},...e.decoders??{[e.prefix]:e}})}var iM=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 tM(e,r,n),this.decoder=new rM(e,r,i)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function Ub({name:t,prefix:e,encode:r,decode:n}){return new iM(t,e,r,n)}function zp({name:t,prefix:e,alphabet:r}){let{encode:n,decode:i}=fZ(r,t);return Ub({prefix:e,name:t,encode:n,decode:o=>gl(i(o))})}function c4e(t,e,r,n){let i={};for(let c=0;c<e.length;++c)i[e[c]]=c;let o=t.length;for(;t[o-1]==="=";)--o;let s=new Uint8Array(o*r/8|0),a=0,d=0,u=0;for(let c=0;c<o;++c){let l=i[t[c]];if(l===void 0)throw new SyntaxError(`Non-${n} character`);d=d<<r|l,a+=r,a>=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 d4e(t,e,r){let n=e[e.length-1]==="=",i=(1<<r)-1,o="",s=0,a=0;for(let d=0;d<t.length;++d)for(a=a<<8|t[d],s+=8;s>r;)s-=r,o+=e[i&a>>s];if(s!==0&&(o+=e[i&a<<r-s]),n)for(;o.length*r&7;)o+="=";return o}function ai({name:t,prefix:e,bitsPerChar:r,alphabet:n}){return Ub({prefix:e,name:t,encode(i){return d4e(i,n,r)},decode(i){return c4e(i,n,r,t)}})}var qb=ai({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),u4e=ai({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),l4e=ai({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),f4e=ai({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),h4e=ai({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),p4e=ai({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),m4e=ai({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),y4e=ai({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),g4e=ai({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var sM={};Fr(sM,{base58btc:()=>vl,base58flickr:()=>v4e});h();var vl=zp({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),v4e=zp({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});h();h();h();var b4e=yZ,pZ=128,w4e=127,_4e=~w4e,x4e=Math.pow(2,31);function yZ(t,e,r){e=e||[],r=r||0;for(var n=r;t>=x4e;)e[r++]=t&255|pZ,t/=128;for(;t&_4e;)e[r++]=t&255|pZ,t>>>=7;return e[r]=t|0,yZ.bytes=r-n+1,e}var E4e=aM,S4e=128,mZ=127;function aM(t,n){var r=0,n=n||0,i=0,o=n,s,a=t.length;do{if(o>=a)throw aM.bytes=0,new RangeError("Could not decode varint");s=t[o++],r+=i<28?(s&mZ)<<i:(s&mZ)*Math.pow(2,i),i+=7}while(s>=S4e);return aM.bytes=o-n,r}var A4e=Math.pow(2,7),T4e=Math.pow(2,14),I4e=Math.pow(2,21),P4e=Math.pow(2,28),k4e=Math.pow(2,35),R4e=Math.pow(2,42),B4e=Math.pow(2,49),M4e=Math.pow(2,56),D4e=Math.pow(2,63),O4e=function(t){return t<A4e?1:t<T4e?2:t<I4e?3:t<P4e?4:t<k4e?5:t<R4e?6:t<B4e?7:t<M4e?8:t<D4e?9:10},C4e={encode:b4e,decode:E4e,encodingLength:O4e},$4e=C4e,tx=$4e;function rx(t,e=0){return[tx.decode(t,e),tx.decode.bytes]}function Lb(t,e,r=0){return tx.encode(t,e,r),e}function Kb(t){return tx.encodingLength(t)}function A0(t,e){let r=e.byteLength,n=Kb(t),i=n+Kb(r),o=new Uint8Array(i+r);return Lb(t,o,0),Lb(r,o,n),o.set(e,i),new Fb(t,r,e,o)}function gZ(t){let e=gl(t),[r,n]=rx(e),[i,o]=rx(e.subarray(n)),s=e.subarray(n+o);if(s.byteLength!==i)throw new Error("Incorrect length");return new Fb(r,i,s,e)}function vZ(t,e){if(t===e)return!0;{let r=e;return t.code===r.code&&t.size===r.size&&r.bytes instanceof Uint8Array&&XB(t.bytes,r.bytes)}}var Fb=class{code;size;digest;bytes;constructor(e,r,n,i){this.code=e,this.size=r,this.digest=n,this.bytes=i}};h();function bZ(t,e){let{bytes:r,version:n}=t;switch(n){case 0:return j4e(r,cM(t),e??vl.encoder);default:return U4e(r,cM(t),e??qb.encoder)}}var wZ=new WeakMap;function cM(t){let e=wZ.get(t);if(e==null){let r=new Map;return wZ.set(t,r),r}return e}var Ra=class t{code;version;multihash;bytes;"/";constructor(e,r,n,i){this.code=r,this.version=e,this.multihash=n,this.bytes=i,this["/"]=i}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:e,multihash:r}=this;if(e!==ix)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==q4e)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=A0(e,r);return t.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(e){return t.equals(this,e)}static equals(e,r){let n=r;return n!=null&&e.code===n.code&&e.version===n.version&&vZ(e.multihash,n.multihash)}toString(e){return bZ(this,e)}toJSON(){return{"/":bZ(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(e){if(e==null)return null;let r=e;if(r instanceof t)return r;if(r["/"]!=null&&r["/"]===r.bytes||r.asCID===r){let{version:n,code:i,multihash:o,bytes:s}=r;return new t(n,i,o,s??_Z(n,i,o.bytes))}else if(r[L4e]===!0){let{version:n,multihash:i,code:o}=r,s=gZ(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!==ix)throw new Error(`Version 0 CID must use dag-pb (code: ${ix}) block encoding`);return new t(e,r,n,n.bytes)}case 1:{let i=_Z(e,r,n.bytes);return new t(e,r,n,i)}default:throw new Error("Invalid version")}}static createV0(e){return t.create(0,ix,e)}static createV1(e,r){return t.create(1,e,r)}static decode(e){let[r,n]=t.decodeFirst(e);if(n.length!==0)throw new Error("Incorrect length");return r}static decodeFirst(e){let r=t.inspectBytes(e),n=r.size-r.multihashSize,i=gl(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 Fb(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]=rx(e.subarray(r));return r+=m,l},i=n(),o=ix;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]=N4e(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 cM(o).set(n,e),o}};function N4e(t,e){switch(t[0]){case"Q":{let r=e??vl;return[vl.prefix,r.decode(`${vl.prefix}${t}`)]}case vl.prefix:{let r=e??vl;return[vl.prefix,r.decode(t)]}case qb.prefix:{let r=e??qb;return[qb.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 j4e(t,e,r){let{prefix:n}=r;if(n!==vl.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 U4e(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 ix=112,q4e=18;function _Z(t,e,r){let n=Kb(t),i=n+Kb(e),o=new Uint8Array(i+r.byteLength);return Lb(t,o,0),Lb(e,o,n),o.set(r,i),o}var L4e=Symbol.for("@ipld/js-cid/CID");h();var K4e=new TextDecoder;function dM(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)<<n:(i&127)*2**n,i<128)break}return[r,e]}function E8(t,e){let r;[r,e]=dM(t,e);let n=e+r;if(r<0||n<0)throw new Error("protobuf: invalid length");if(n>t.length)throw new Error("protobuf: unexpected end of data");return[t.subarray(e,n),n]}function xZ(t,e){let r;return[r,e]=dM(t,e),[r&7,r>>3,e]}function F4e(t){let e={},r=t.length,n=0;for(;n<r;){let i,o;if([i,o,n]=xZ(t,n),o===1){if(e.Hash)throw new Error("protobuf: (PBLink) duplicate Hash section");if(i!==2)throw new Error(`protobuf: (PBLink) wrong wireType (${i}) for Hash`);if(e.Name!==void 0)throw new Error("protobuf: (PBLink) invalid order, found Name before Hash");if(e.Tsize!==void 0)throw new Error("protobuf: (PBLink) invalid order, found Tsize before Hash");[e.Hash,n]=E8(t,n)}else if(o===2){if(e.Name!==void 0)throw new Error("protobuf: (PBLink) duplicate Name section");if(i!==2)throw new Error(`protobuf: (PBLink) wrong wireType (${i}) for Name`);if(e.Tsize!==void 0)throw new Error("protobuf: (PBLink) invalid order, found Tsize before Name");let s;[s,n]=E8(t,n),e.Name=K4e.decode(s)}else if(o===3){if(e.Tsize!==void 0)throw new Error("protobuf: (PBLink) duplicate Tsize section");if(i!==0)throw new Error(`protobuf: (PBLink) wrong wireType (${i}) for Tsize`);[e.Tsize,n]=dM(t,n)}else throw new Error(`protobuf: (PBLink) invalid fieldNumber, expected 1, 2 or 3, got ${o}`)}if(n>r)throw new Error("protobuf: (PBLink) unexpected end of data");return e}function EZ(t){let e=t.length,r=0,n,i=!1,o;for(;r<e;){let a,d;if([a,d,r]=xZ(t,r),a!==2)throw new Error(`protobuf: (PBNode) invalid wireType, expected 2, got ${a}`);if(d===1){if(o)throw new Error("protobuf: (PBNode) duplicate Data section");[o,r]=E8(t,r),n&&(i=!0)}else if(d===2){if(i)throw new Error("protobuf: (PBNode) duplicate Links section");n||(n=[]);let u;[u,r]=E8(t,r),n.push(F4e(u))}else throw new Error(`protobuf: (PBNode) invalid fieldNumber, expected 1 or 2, got ${d}`)}if(r>e)throw new Error("protobuf: (PBNode) unexpected end of data");let s={};return o&&(s.Data=o),s.Links=n||[],s}h();var AZ=new TextEncoder,SZ=2**32,z4e=2**31;function V4e(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=ox(e,r,t.Tsize)-1,e[r]=24}if(typeof t.Name=="string"){let n=AZ.encode(t.Name);r-=n.length,e.set(n,r),r=ox(e,r,n.length)-1,e[r]=18}return t.Hash&&(r-=t.Hash.length,e.set(t.Hash,r),r=ox(e,r,t.Hash.length)-1,e[r]=10),e.length-r}function TZ(t){let e=W4e(t),r=new Uint8Array(e),n=e;if(t.Data&&(n-=t.Data.length,r.set(t.Data,n),n=ox(r,n,t.Data.length)-1,r[n]=10),t.Links)for(let i=t.Links.length-1;i>=0;i--){let o=V4e(t.Links[i],r.subarray(0,n));n-=o,n=ox(r,n,o)-1,r[n]=18}return r}function H4e(t){let e=0;if(t.Hash){let r=t.Hash.length;e+=1+r+zb(r)}if(typeof t.Name=="string"){let r=AZ.encode(t.Name).length;e+=1+r+zb(r)}return typeof t.Tsize=="number"&&(e+=1+zb(t.Tsize)),e}function W4e(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=H4e(r);e+=1+n+zb(n)}return e}function ox(t,e,r){e-=zb(r);let n=e;for(;r>=z4e;)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((G4e(t)+6)/7)}function G4e(t){let e=0;return t>=SZ&&(t=Math.floor(t/SZ),e=32),t>=65536&&(t>>>=16,e+=16),t>=256&&(t>>>=8,e+=8),e+J4e[t]}var J4e=[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 Y4e=["Data","Links"],Z4e=["Hash","Name","Tsize"],uM=new TextEncoder;function PZ(t,e){if(t===e)return 0;let r=t.Name?uM.encode(t.Name):[],n=e.Name?uM.encode(e.Name):[],i=r.length,o=n.length;for(let s=0,a=Math.min(i,o);s<a;++s)if(r[s]!==n[s]){i=r[s],o=n[s];break}return i<o?-1:o<i?1:0}function IZ(t,e){return!Object.keys(t).some(r=>!e.includes(r))}function kZ(t){if(typeof t.asCID=="object"){let r=Ra.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=Ra.asCID(t.Hash);try{r||(typeof t.Hash=="string"?r=Ra.parse(t.Hash):t.Hash instanceof Uint8Array&&(r=Ra.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 uc(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=uM.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(kZ),e.Links.sort(PZ);else throw new TypeError("Invalid DAG-PB form");else e.Links=[];return e}function lM(t){if(!t||typeof t!="object"||Array.isArray(t)||t instanceof Uint8Array||t["/"]&&t["/"]===t.bytes)throw new TypeError("Invalid DAG-PB form");if(!IZ(t,Y4e))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;e<t.Links.length;e++){let r=t.Links[e];if(!r||typeof r!="object"||Array.isArray(r)||r instanceof Uint8Array||r["/"]&&r["/"]===r.bytes)throw new TypeError("Invalid DAG-PB form (bad link)");if(!IZ(r,Z4e))throw new TypeError("Invalid DAG-PB form (extraneous properties on link)");if(r.Hash===void 0)throw new TypeError("Invalid DAG-PB form (link must have a Hash)");if(r.Hash==null||!r.Hash["/"]||r.Hash["/"]!==r.Hash.bytes)throw new TypeError("Invalid DAG-PB form (link Hash must be a CID)");if(r.Name!==void 0&&typeof r.Name!="string")throw new TypeError("Invalid DAG-PB form (link Name must be a string)");if(r.Tsize!==void 0){if(typeof r.Tsize!="number"||r.Tsize%1!==0)throw new TypeError("Invalid DAG-PB form (link Tsize must be an integer)");if(r.Tsize<0)throw new TypeError("Invalid DAG-PB form (link Tsize cannot be negative)")}if(e>0&&PZ(r,t.Links[e-1])===-1)throw new TypeError("Invalid DAG-PB form (links must be sorted by Name bytes)")}}function RZ(t,e=[]){return uc({Data:t,Links:e})}function BZ(t,e,r){return kZ({Hash:r,Name:t,Tsize:e})}function MZ(t){return t instanceof ArrayBuffer?new Uint8Array(t,0,t.byteLength):t}var X4e="dag-pb",sx=112;function lc(t){lM(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),TZ(e)}function Jf(t){let e=MZ(t),r=EZ(e),n={};return r.Data&&(n.Data=r.Data),r.Links&&(n.Links=r.Links.map(i=>{let o={};try{o.Hash=Ra.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 NM=qt(cc(),1);h();h();h();h();h();var Q4e=Math.pow(2,7),eAe=Math.pow(2,14),tAe=Math.pow(2,21),DZ=Math.pow(2,28),OZ=Math.pow(2,35),CZ=Math.pow(2,42),$Z=Math.pow(2,49),ra=128,Vp=127;function ax(t){if(t<Q4e)return 1;if(t<eAe)return 2;if(t<tAe)return 3;if(t<DZ)return 4;if(t<OZ)return 5;if(t<CZ)return 6;if(t<$Z)return 7;if(Number.MAX_SAFE_INTEGER!=null&&t>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function NZ(t,e,r=0){switch(ax(t)){case 8:e[r++]=t&255|ra,t/=128;case 7:e[r++]=t&255|ra,t/=128;case 6:e[r++]=t&255|ra,t/=128;case 5:e[r++]=t&255|ra,t/=128;case 4:e[r++]=t&255|ra,t>>>=7;case 3:e[r++]=t&255|ra,t>>>=7;case 2:e[r++]=t&255|ra,t>>>=7;case 1:{e[r++]=t&255,t>>>=7;break}default:throw new Error("unreachable")}return e}function jZ(t,e){let r=t[e],n=0;if(n+=r&Vp,r<ra||(r=t[e+1],n+=(r&Vp)<<7,r<ra)||(r=t[e+2],n+=(r&Vp)<<14,r<ra)||(r=t[e+3],n+=(r&Vp)<<21,r<ra)||(r=t[e+4],n+=(r&Vp)*DZ,r<ra)||(r=t[e+5],n+=(r&Vp)*OZ,r<ra)||(r=t[e+6],n+=(r&Vp)*CZ,r<ra)||(r=t[e+7],n+=(r&Vp)*$Z,r<ra))return n;throw new RangeError("Could not decode varint")}h();var fM=new Float32Array([-0]),Hp=new Uint8Array(fM.buffer);function UZ(t,e,r){fM[0]=t,e[r]=Hp[0],e[r+1]=Hp[1],e[r+2]=Hp[2],e[r+3]=Hp[3]}function qZ(t,e){return Hp[0]=t[e],Hp[1]=t[e+1],Hp[2]=t[e+2],Hp[3]=t[e+3],fM[0]}var hM=new Float64Array([-0]),Es=new Uint8Array(hM.buffer);function LZ(t,e,r){hM[0]=t,e[r]=Es[0],e[r+1]=Es[1],e[r+2]=Es[2],e[r+3]=Es[3],e[r+4]=Es[4],e[r+5]=Es[5],e[r+6]=Es[6],e[r+7]=Es[7]}function KZ(t,e){return Es[0]=t[e],Es[1]=t[e+1],Es[2]=t[e+2],Es[3]=t[e+3],Es[4]=t[e+4],Es[5]=t[e+5],Es[6]=t[e+6],Es[7]=t[e+7],hM[0]}h();var rAe=BigInt(Number.MAX_SAFE_INTEGER),nAe=BigInt(Number.MIN_SAFE_INTEGER),fc=class t{lo;hi;constructor(e,r){this.lo=e|0,this.hi=r|0}toNumber(e=!1){if(!e&&this.hi>>>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 I0;if(e<rAe&&e>nAe)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>FZ&&(i=0n,++n>FZ&&(n=0n))),new t(Number(i),Number(n))}static fromNumber(e){if(e===0)return I0;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):I0}},I0=new fc(0,0);I0.toBigInt=function(){return 0n};I0.zzEncode=I0.zzDecode=function(){return this};I0.length=function(){return 1};var FZ=4294967296n;h();function zZ(t){let e=0,r=0;for(let n=0;n<t.length;++n)r=t.charCodeAt(n),r<128?e+=1:r<2048?e+=2:(r&64512)===55296&&(t.charCodeAt(n+1)&64512)===56320?(++n,e+=4):e+=3;return e}function VZ(t,e,r){if(r-e<1)return"";let i,o=[],s=0,a;for(;e<r;)a=t[e++],a<128?o[s++]=a:a>191&&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 pM(t,e,r){let n=r,i,o;for(let s=0;s<t.length;++s)i=t.charCodeAt(s),i<128?e[r++]=i:i<2048?(e[r++]=i>>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 tu(t,e){return RangeError(`index out of range: ${t.pos} + ${e??1} > ${t.len}`)}function S8(t,e){return(t[e-4]|t[e-3]<<8|t[e-2]<<16|t[e-1]<<24)>>>0}var mM=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,tu(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 tu(this,4);return S8(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw tu(this,4);return S8(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw tu(this,4);let e=qZ(this.buf,this.pos);return this.pos+=4,e}double(){if(this.pos+8>this.len)throw tu(this,4);let e=KZ(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 tu(this,e);return this.pos+=e,r===n?new Uint8Array(0):this.buf.subarray(r,n)}string(){let e=this.bytes();return VZ(e,0,e.length)}skip(e){if(typeof e=="number"){if(this.pos+e>this.len)throw tu(this,e);this.pos+=e}else do if(this.pos>=this.len)throw tu(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 fc(0,0),r=0;if(this.len-this.pos>4){for(;r<4;++r)if(e.lo=(e.lo|(this.buf[this.pos]&127)<<r*7)>>>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 tu(this);if(e.lo=(e.lo|(this.buf[this.pos]&127)<<r*7)>>>0,this.buf[this.pos++]<128)return e}return e.lo=(e.lo|(this.buf[this.pos++]&127)<<r*7)>>>0,e}if(this.len-this.pos>4){for(;r<5;++r)if(e.hi=(e.hi|(this.buf[this.pos]&127)<<r*7+3)>>>0,this.buf[this.pos++]<128)return e}else for(;r<5;++r){if(this.pos>=this.len)throw tu(this);if(e.hi=(e.hi|(this.buf[this.pos]&127)<<r*7+3)>>>0,this.buf[this.pos++]<128)return e}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw tu(this,8);let e=S8(this.buf,this.pos+=4),r=S8(this.buf,this.pos+=4);return new fc(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=jZ(this.buf,this.pos);return this.pos+=ax(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 yM(t){return new mM(t instanceof Uint8Array?t:t.subarray())}function cx(t,e,r){let n=yM(t);return e.decode(n,void 0,r)}h();h();h();h();h();var gM={};Fr(gM,{base10:()=>iAe});h();var iAe=zp({prefix:"9",name:"base10",alphabet:"0123456789"});var vM={};Fr(vM,{base16:()=>oAe,base16upper:()=>sAe});h();var oAe=ai({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),sAe=ai({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var bM={};Fr(bM,{base2:()=>aAe});h();var aAe=ai({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var wM={};Fr(wM,{base256emoji:()=>fAe});h();var WZ=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}"),cAe=WZ.reduce((t,e,r)=>(t[r]=e,t),[]),dAe=WZ.reduce((t,e,r)=>(t[e.codePointAt(0)]=r,t),[]);function uAe(t){return t.reduce((e,r)=>(e+=cAe[r],e),"")}function lAe(t){let e=[];for(let r of t){let n=dAe[r.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(n)}return new Uint8Array(e)}var fAe=Ub({prefix:"\u{1F680}",name:"base256emoji",encode:uAe,decode:lAe});var _M={};Fr(_M,{base36:()=>hAe,base36upper:()=>pAe});h();var hAe=zp({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),pAe=zp({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var xM={};Fr(xM,{base64:()=>mAe,base64pad:()=>yAe,base64url:()=>gAe,base64urlpad:()=>vAe});h();var mAe=ai({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),yAe=ai({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),gAe=ai({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),vAe=ai({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var EM={};Fr(EM,{base8:()=>bAe});h();var bAe=ai({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var SM={};Fr(SM,{identity:()=>wAe});h();var wAe=Ub({prefix:"\0",name:"identity",encode:t=>eM(t),decode:t=>QB(t)});h();var iyt=new TextEncoder,oyt=new TextDecoder;h();var AM={};Fr(AM,{identity:()=>AAe});h();var GZ=0,EAe="identity",JZ=gl;function SAe(t){return A0(GZ,JZ(t))}var AAe={code:GZ,name:EAe,encode:JZ,digest:SAe};var IM={};Fr(IM,{sha256:()=>TAe,sha512:()=>IAe});h();h();function P0({name:t,code:e,encode:r}){return new TM(t,e,r)}var TM=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?A0(this.code,r):r.then(n=>A0(this.code,n))}else throw Error("Unknown type, must be binary type")}};function ZZ(t){return async e=>new Uint8Array(await crypto.subtle.digest(t,e))}var TAe=P0({name:"sha2-256",code:18,encode:ZZ("SHA-256")}),IAe=P0({name:"sha2-512",code:19,encode:ZZ("SHA-512")});h();h();h();h();h();h();var PM={...SM,...bM,...EM,...gM,...vM,...oM,..._M,...sM,...xM,...wM},kyt={...IM,...AM};function QZ(t,e,r,n){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:n}}}var XZ=QZ("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),kM=QZ("ascii","a",t=>{let e="a";for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r]);return e},t=>{t=t.substring(1);let e=dc(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),PAe={utf8:XZ,"utf-8":XZ,hex:PM.base16,latin1:kM,ascii:kM,binary:kM,...PM},eX=PAe;function A8(t,e="utf8"){let r=eX[e];if(r==null)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?Fp(globalThis.Buffer.from(t,"utf-8")):r.decoder.decode(`${r.prefix}${t}`)}h();function RM(t){let e=t??8192,r=e>>>1,n,i=e;return function(s){if(s<1||s>r)return dc(s);i+s>e&&(n=dc(e),i=0);let a=n.subarray(i,i+=s);return i&7&&(i=(i|7)+1),a}}var k0=class{fn;len;next;val;constructor(e,r,n){this.fn=e,this.len=r,this.next=void 0,this.val=n}};function BM(){}var DM=class{head;tail;len;next;constructor(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}},kAe=RM();function RAe(t){return globalThis.Buffer!=null?dc(t):kAe(t)}var ux=class{len;head;tail;states;constructor(){this.len=0,this.head=new k0(BM,0,0),this.tail=this.head,this.states=null}_push(e,r,n){return this.tail=this.tail.next=new k0(e,r,n),this.len+=r,this}uint32(e){return this.len+=(this.tail=this.tail.next=new OM((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(T8,10,fc.fromNumber(e)):this.uint32(e)}sint32(e){return this.uint32((e<<1^e>>31)>>>0)}uint64(e){let r=fc.fromBigInt(e);return this._push(T8,r.length(),r)}uint64Number(e){return this._push(NZ,ax(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=fc.fromBigInt(e).zzEncode();return this._push(T8,r.length(),r)}sint64Number(e){let r=fc.fromNumber(e).zzEncode();return this._push(T8,r.length(),r)}sint64String(e){return this.sint64(BigInt(e))}bool(e){return this._push(MM,1,e?1:0)}fixed32(e){return this._push(dx,4,e>>>0)}sfixed32(e){return this.fixed32(e)}fixed64(e){let r=fc.fromBigInt(e);return this._push(dx,4,r.lo)._push(dx,4,r.hi)}fixed64Number(e){let r=fc.fromNumber(e);return this._push(dx,4,r.lo)._push(dx,4,r.hi)}fixed64String(e){return this.fixed64(BigInt(e))}sfixed64(e){return this.fixed64(e)}sfixed64Number(e){return this.fixed64Number(e)}sfixed64String(e){return this.fixed64String(e)}float(e){return this._push(UZ,4,e)}double(e){return this._push(LZ,8,e)}bytes(e){let r=e.length>>>0;return r===0?this._push(MM,1,0):this.uint32(r)._push(MAe,r,e)}string(e){let r=zZ(e);return r!==0?this.uint32(r)._push(pM,r,e):this._push(MM,1,0)}fork(){return this.states=new DM(this),this.head=this.tail=new k0(BM,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 k0(BM,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=RAe(this.len),n=0;for(;e!=null;)e.fn(e.val,r,n),n+=e.len,e=e.next;return r}};function MM(t,e,r){e[r]=t&255}function BAe(t,e,r){for(;t>127;)e[r++]=t&127|128,t>>>=7;e[r]=t}var OM=class extends k0{next;constructor(e,r){super(BAe,e,r),this.next=void 0}};function T8(t,e,r){for(;t.hi!==0;)e[r++]=t.lo&127|128,t.lo=(t.lo>>>7|t.hi<<25)>>>0,t.hi>>>=7;for(;t.lo>127;)e[r++]=t.lo&127|128,t.lo=t.lo>>>7;e[r++]=t.lo}function dx(t,e,r){e[r]=t&255,e[r+1]=t>>>8&255,e[r+2]=t>>>16&255,e[r+3]=t>>>24}function MAe(t,e,r){e.set(t,r)}globalThis.Buffer!=null&&(ux.prototype.bytes=function(t){let e=t.length>>>0;return this.uint32(e),e>0&&this._push(DAe,e,t),this},ux.prototype.string=function(t){let e=globalThis.Buffer.byteLength(t);return this.uint32(e),e>0&&this._push(OAe,e,t),this});function DAe(t,e,r){e.set(t,r)}function OAe(t,e,r){t.length<40?pM(t,e,r):e.utf8Write!=null?e.utf8Write(t,r):e.set(A8(t),r)}function CM(){return new ux}function lx(t,e){let r=CM();return e.encode(t,r,{lengthDelimited:!1}),r.finish()}h();h();var Vb;(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"})(Vb||(Vb={}));function I8(t,e,r,n){return{name:t,type:e,encode:r,decode:n}}function $M(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 I8("enum",Vb.VARINT,r,n)}h();function fx(t,e){return I8("message",Vb.LENGTH_DELIMITED,t,e)}var ru;(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=()=>$M(r)}(e=t.DataType||(t.DataType={}));let n;t.codec=()=>(n==null&&(n=fx((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),P8.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<a;){let d=i.uint32();switch(d>>>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=P8.codec().decode(i,i.uint32());break;default:i.skipType(d&7);break}}return s})),n),t.encode=i=>lx(i,t.codec()),t.decode=i=>cx(i,t.codec())})(ru||(ru={}));var P8;(function(t){let e;t.codec=()=>(e==null&&(e=fx((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<o;){let s=r.uint32();switch(s>>>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=>lx(r,t.codec()),t.decode=r=>cx(r,t.codec())})(P8||(P8={}));var tX;(function(t){let e;t.codec=()=>(e==null&&(e=fx((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<o;){let s=r.uint32();switch(s>>>3){case 1:i.MimeType=r.string();break;default:r.skipType(s&7);break}}return i})),e),t.encode=r=>lx(r,t.codec()),t.decode=r=>cx(r,t.codec())})(tX||(tX={}));var rX={Raw:"raw",Directory:"directory",File:"file",Metadata:"metadata",Symlink:"symlink",HAMTShard:"hamt-sharded-directory"},CAe=["directory","hamt-sharded-directory"],nX=parseInt("0644",8),iX=parseInt("0755",8),yo=class t{static unmarshal(e){let r=ru.decode(e),n=new t({type:rX[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(rX).includes(r))throw(0,NM.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()?iX:nX:this._mode=e&4095}get mode(){return this._mode}isDirectory(){return CAe.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=ru.DataType.Raw;break;case"directory":e=ru.DataType.Directory;break;case"file":e=ru.DataType.File;break;case"metadata":e=ru.DataType.Metadata;break;case"symlink":e=ru.DataType.Symlink;break;case"hamt-sharded-directory":e=ru.DataType.HAMTShard;break;default:throw(0,NM.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===nX&&!this.isDirectory()&&(n=void 0),n===iX&&this.isDirectory()&&(n=void 0));let i;return this.mtime!=null&&(i={Seconds:this.mtime.secs,FractionalNanoseconds:this.mtime.nsecs}),ru.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 Hb={};Fr(Hb,{code:()=>Wp,decode:()=>jAe,encode:()=>NAe,name:()=>$Ae});h();var $Ae="raw",Wp=85,NAe=t=>jd(t),jAe=t=>jd(t);h();var ci=class extends Event{constructor(e,r){super(e),this.detail=r}};h();var nu=async(t,e,r)=>{r.codec==null&&(r.codec=T0);let n=await gs.digest(t),i=$r.create(r.cidVersion,r.codec.code,n);return await e.put(i,t,r),i};function oX(t){return async function*(r,n){let i=0n;for await(let o of r.content)yield async()=>{let s,a={codec:T0,cidVersion:t.cidVersion,onProgress:t.onProgress};t.rawLeaves?(a.codec=Hb,a.cidVersion=1):(s=new yo({type:t.leafType,data:o}),o=lc({Data:s.marshal(),Links:[]}));let d=await nu(o,n,a);return i+=BigInt(o.byteLength),t.onProgress?.(new ci("unixfs:importer:progress:file:write",{bytesWritten:i,cid:d,path:r.path})),{cid:d,unixfs:s,size:BigInt(o.length),block:o}}}}h();var jM=qt(cc(),1);h();var sX=async(t,e,r)=>{let n=new yo({type:"directory",mtime:t.mtime,mode:t.mode}),i=lc(uc({Data:n.marshal()})),o=await nu(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*UAe(t,e,r){let n=-1,i;for await(let o of Q_(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 aX(t){return t.single===!0}var qAe=(t,e,r)=>async function(i){if(i.length===1&&aX(i[0])&&r.reduceSingleLeafToSelf){let c=i[0],l=c.block;return aX(c)&&(t.mtime!==void 0||t.mode!==void 0)&&(c.unixfs=new yo({type:"file",mtime:t.mtime,mode:t.mode,data:c.block}),l={Data:c.unixfs.marshal(),Links:[]},c.block=lc(uc(l)),c.cid=await nu(c.block,e,{...r,cidVersion:r.cidVersion}),c.size=BigInt(c.block.length)),r.onProgress?.(new ci("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 yo({type:"file",mtime:t.mtime,mode:t.mode}),s=i.filter(c=>c.cid.code===Wp&&c.size>0||c.unixfs!=null&&c.unixfs.data==null&&c.unixfs.fileSize()>0n?!0:!!c.unixfs?.data?.length).map(c=>c.cid.code===Wp?(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=lc(uc(a)),u=await nu(d,e,r);return r.onProgress?.(new ci("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}},cX=async(t,e,r)=>r.layout(UAe(t,e,r),qAe(t,e,r));function LAe(t){return Symbol.iterator in t}function KAe(t){return Symbol.asyncIterator in t}function FAe(t){try{if(t instanceof Uint8Array)return async function*(){yield t}();if(LAe(t))return async function*(){yield*t}();if(KAe(t))return t}catch{throw(0,jM.default)(new Error("Content was invalid"),"ERR_INVALID_CONTENT")}throw(0,jM.default)(new Error("Content was invalid"),"ERR_INVALID_CONTENT")}function dX(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("/")),zAe(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(FAe(i.content)))){let u=BigInt(d.byteLength);a+=u,t.onProgress?.(new ci("unixfs:importer:progress:file:read",{bytesRead:a,chunkSize:u,path:i.path})),yield d}}(),originalPath:o};yield async()=>cX(s,n,t)}else if(i.path!=null){let s={path:i.path,mtime:i.mtime,mode:i.mode,originalPath:o};yield async()=>sX(s,n,t)}else throw new Error("Import candidate must have content or path or both")}}}function zAe(t){return t.content!=null}h();var UM=qt(cc(),1);var uX=()=>async function*(e){for await(let r of e){if(r.length===void 0)throw(0,UM.default)(new Error("Content was invalid"),"ERR_INVALID_CONTENT");if(typeof r=="string"||r instanceof String)yield U_(r.toString());else if(Array.isArray(r))yield Uint8Array.from(r);else if(r instanceof Uint8Array)yield r;else throw(0,UM.default)(new Error("Content was invalid"),"ERR_INVALID_CONTENT")}};h();h();var VAe=174;function qM(t){let e=t?.maxChildrenPerNode??VAe;return async function r(n,i){let o=[];for await(let s of X_(n,e))o.push(await i(s));return o.length>1?r(o,i):o[0]}}h();h();h();h();h();h();var bl=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}},hx=$r.parse("QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn"),px=$r.parse("zdj7WbTaiJT1fgatdet9Ei9iDB5hdCxkbVyhyh8YTUnXMiwYi");var R0=class extends bl{_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?px.bytes.byteLength:hx.bytes.byteLength));return this.nodeSize}async*flush(e){let r=[];for(let[d,u]of this._children.entries()){let c=u;if(u instanceof bl)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 yo({type:"directory",mtime:this.mtime,mode:this.mode}),i={Data:n.marshal(),Links:r},o=lc(uc(i)),s=await nu(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 R8=qt(hX(),1);function HAe(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 Ogt=P0({name:"murmur3-32",code:35,encode:t=>HAe(R8.default.x86.hash32(t))}),B8=P0({name:"murmur3-128",code:34,encode:t=>jb.fromHex(R8.default.x64.hash128(t))}),Cgt=P0({name:"murmur3-x64-64",code:34,encode:t=>jb.fromHex(R8.default.x64.hash128(t)).subarray(0,8)});h();h();var gX=qt(yX(),1);var wl=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 gX.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 vX(this,e,r)}toJSON(){return this.serialize(ZAe,XAe)}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"?A8(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(YAe);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 YAe(t){return!!t}function ZAe(t,e){return t.key}function XAe(t){return t}async function vX(t,e,r){let n=[];for(let i of t._children.compactArray())if(i instanceof wl)await vX(i,e,r);else{let o=await e(i);n.push({bitField:t._children.bitField(),children:o})}return r(n)}h();h();var QAe=[255,254,252,248,240,224,192,128],eTe=[1,3,7,15,31,63,127,255],M8=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=tTe(i,o-s,s);n=(n<<s)+a,r-=s,this._currentBitPos-=s,this._currentBitPos<0&&(this._currentBitPos=7,this._currentBytePos--)}return n}untake(e){for(this._currentBitPos+=e;this._currentBitPos>7;)this._currentBitPos-=8,this._currentBytePos+=1}_haveBits(){return this._currentBytePos>=0}};function tTe(t,e,r){let n=rTe(e,r);return(t&n)>>>e}function rTe(t,e){return QAe[t]&eTe[Math.min(e+t-1,7)]}function bX(t){function e(r){return r instanceof D8?r:new D8(r,t)}return e}var D8=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._availableBits<r;)await this._produceMoreBits();let n=0;for(;r>0;){let i=this._buffers[this._currentBufferIndex],o=Math.min(i.availableBits(),r),s=i.take(o);n=(n<<o)+s,r-=o,this._availableBits-=o,i.availableBits()===0&&this._currentBufferIndex++}return n}untake(e){let r=e;for(;r>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?ex([this._value,Uint8Array.from([this._depth])]):this._value,r=await this._hashFn(e),n=new M8(r);this._buffers.push(n),this._availableBits+=n.availableBits()}};function O8(t){if(t==null||t.hashFn==null)throw new Error("please define an options.hashFn");let e={bits:t.bits??8,hash:bX(t.hashFn)};return new wl(e)}async function nTe(t){return(await B8.encode(t)).slice(0,8).reverse()}var wX=BigInt(34),LM=class extends bl{_bucket;constructor(e,r){super(e,r),this._bucket=O8({hashFn:nTe,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=EX(this._bucket,this,this.options),this.nodeSize)}async*flush(e){for await(let r of xX(this._bucket,e,this,this.options))yield{...r,path:this.path}}},_X=LM;async function*xX(t,e,r,n){let i=t._children,o=[],s=0n;for(let p=0;p<i.length;p++){let g=i.get(p);if(g==null)continue;let v=p.toString(16).toUpperCase().padStart(2,"0");if(g instanceof wl){let E;for await(let A of xX(g,e,null,n))E=A;if(E==null)throw new Error("Could not flush sharded directory, no subshard found");o.push({Name:v,Tsize:Number(E.size),Hash:E.cid}),s+=E.size}else if(iTe(g.value)){let E=g.value,A;for await(let I of E.flush(e))A=I,yield A;if(A==null)throw new Error("Did not flush dir");let P=v+g.key;o.push({Name:P,Tsize:Number(A.size),Hash:A.cid}),s+=A.size}else{let E=g.value;if(E.cid==null)continue;let A=v+g.key,P=E.size;o.push({Name:A,Tsize:Number(P),Hash:E.cid}),s+=BigInt(P??0)}}let a=Uint8Array.from(i.bitField().reverse()),d=new yo({type:"hamt-sharded-directory",data:a,fanout:BigInt(t.tableSize()),hashType:wX,mtime:r?.mtime,mode:r?.mode}),u={Data:d.marshal(),Links:o},c=lc(uc(u)),l=await nu(c,e,n),m=BigInt(c.byteLength)+s;yield{cid:l,unixfs:d,size:m}}function iTe(t){return typeof t.flush=="function"}function EX(t,e,r){let n=t._children,i=[];for(let d=0;d<n.length;d++){let u=n.get(d);if(u==null)continue;let c=d.toString(16).toUpperCase().padStart(2,"0");if(u instanceof wl){let l=EX(u,null,r);i.push({Name:c,Tsize:Number(l),Hash:r.cidVersion===0?hx:px})}else if(typeof u.value.flush=="function"){let m=u.value.nodeSize();i.push({Name:c+u.key,Tsize:Number(m),Hash:r.cidVersion===0?hx:px})}else{let l=u.value;if(l.cid==null)continue;let m=c+u.key,p=l.size;i.push({Name:m,Tsize:Number(p),Hash:l.cid})}}let o=Uint8Array.from(n.bitField().reverse()),s=new yo({type:"hamt-sharded-directory",data:o,fanout:BigInt(t.tableSize()),hashType:wX,mtime:e?.mtime,mode:e?.mode});return lc(uc({Data:s.marshal(),Links:i})).length}async function KM(t,e,r,n){let i=e;e instanceof R0&&e.estimateNodeSize()>r&&(i=await oTe(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 KM(i,o,r,n)}return i}async function oTe(t,e){let r=new _X({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 SX=(t="")=>(t.trim().match(/([^\\/]|\\\/)+/g)??[]).filter(Boolean);async function sTe(t,e,r){let n=SX(t.path??""),i=n.length-1,o=e,s="";for(let a=0;a<n.length;a++){let d=n[a];s+=`${s!==""?"/":""}${d}`;let u=a===i;if(o.dirty=!0,o.cid=void 0,o.size=void 0,u)await o.put(d,t),e=await KM(null,o,r.shardSplitThresholdBytes,r);else{let c=await o.get(d);(c==null||!(c instanceof bl))&&(c=new R0({root:!1,dir:!0,parent:o,parentKey:d,path:s,dirty:!0,flat:!0,mtime:c?.unixfs?.mtime,mode:c?.unixfs?.mode},r)),await o.put(d,c),o=c}}return e}async function*AX(t,e){if(!(t instanceof bl)){t.unixfs?.isDirectory()===!0&&(yield t);return}yield*t.flush(e)}function TX(t){return async function*(r,n){let i=new R0({root:!0,dir:!0,path:"",dirty:!0,flat:!0},t),o,s=!1;for await(let a of r){if(a==null)continue;let d=`${a.originalPath??""}`.split("/")[0];d!=null&&d!==""&&(o==null?(o=d,s=!0):o!==d&&(s=!1)),i=await sTe(a,i,t),(a.unixfs==null||!a.unixfs.isDirectory())&&(yield a)}if(t.wrapWithDirectory||s&&i.childCount()>1)yield*AX(i,n);else for await(let a of i.eachChildSeries())a!=null&&(yield*AX(a.child,n))}}async function*yx(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??uZ(),p=r.chunkValidator??uX(),g=r.dagBuilder??dX({chunker:m,chunkValidator:p,wrapWithDirectory:i,layout:r.layout??qM(),bufferImporter:r.bufferImporter??oX({cidVersion:s,rawLeaves:a,leafType:d,onProgress:r.onProgress}),blockWriteConcurrency:c,reduceSingleLeafToSelf:l,cidVersion:s,onProgress:r.onProgress}),v=r.treeBuilder??TX({wrapWithDirectory:i,shardSplitThresholdBytes:o,cidVersion:s,onProgress:r.onProgress});for await(let E of v(Q_(g(n,e),u),e))yield{cid:E.cid,path:E.path,unixfs:E.unixfs,size:E.size}}var FM=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},IX=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)}},PX={[gs.code]:gs},kX={[Y_]:S0},An=class{static computeCid(e,r=Y_,n=gs.code){return FM(this,void 0,void 0,function*(){let i=kX[r];if(!i)throw new se(ne.ComputeCidCodecNotSupported,`codec [${r}] not supported`);let o=PX[n];if(!o)throw new se(ne.ComputeCidMultihashNotSupported,`multihash code [${n}] not supported`);let s=i.encode(e),a=yield o.digest(s);return(yield $r.createV1(i.code,a)).toString()})}static parseCid(e){let r=$r.parse(e).toV1();if(!kX[r.code])throw new se(ne.ParseCidCodecNotSupported,`codec [${r.code}] not supported`);if(!PX[r.multihash.code])throw new se(ne.ParseCidMultihashNotSupported,`multihash code [${r.multihash.code}] not supported`);return r}static computeDagPbCidFromBytes(e){var r,n,i,o;return FM(this,void 0,void 0,function*(){let s=yx([{content:e}],new Z_,{cidVersion:1}),a;try{for(var d=!0,u=IX(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 FM(this,void 0,void 0,function*(){let s=yx([{content:e}],new Z_,{cidVersion:1}),a;try{for(var d=!0,u=IX(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 TT=qt(I4(),1),Im=qt(Eae(),1),EN=qt(ST(),1),AT=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})};Im.ECIES_CONFIG.isEphemeralKeyCompressed=!0;var vh=class t{static aes256CtrEncrypt(e,r,n){return AT(this,void 0,void 0,function*(){let i=TT.createCipheriv("aes-256-ctr",e,r),o=new EN.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 AT(this,void 0,void 0,function*(){let i=TT.createDecipheriv("aes-256-ctr",e,r),o=new EN.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 AT(this,void 0,void 0,function*(){let n=C.Buffer.from(e),i=C.Buffer.from(r),o=Im.encrypt(n,i),s=0,a=t.isEphemeralKeyCompressed?33:65,d=o.subarray(s,a);s=a,a+=Im.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 AT(this,void 0,void 0,function*(){let r=C.Buffer.from(e.privateKey),n=C.Buffer.concat([e.ephemeralPublicKey,e.initializationVector,e.messageAuthenticationCode,e.ciphertext]);return Im.decrypt(r,n)})}static get isEphemeralKeyCompressed(){return Im.ECIES_CONFIG.isEphemeralKeyCompressed}},_g;(function(t){t.Aes256Ctr="A256CTR",t.EciesSecp256k1="ECIES-ES256K"})(_g||(_g={}));h();var lue=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(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 t{constructor(e){this.jws=e}static create(e,r=[]){return lue(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 lue(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 IT=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function kE(){if(IT&&typeof IT.subtle=="object"&&IT.subtle!=null)return IT.subtle;throw new Error("crypto.subtle must be defined")}h();function ELe(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}function RE(t,...e){if(!ELe(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 fue={async encrypt(t,e,r,n){let i=kE(),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=kE(),o=await i.importKey("raw",t,e,!0,["decrypt"]),s=await i.decrypt(r,o,n);return new Uint8Array(s)}},ql={CBC:"AES-CBC",CTR:"AES-CTR",GCM:"AES-GCM"};function SLe(t,e,r){if(t===ql.CBC)return{name:ql.CBC,iv:e};if(t===ql.CTR)return{name:ql.CTR,counter:e,length:64};if(t===ql.GCM)return r?{name:ql.GCM,iv:e,additionalData:r}:{name:ql.GCM,iv:e};throw new Error("unknown aes block mode")}function SN(t){return(e,r,n)=>{RE(e),RE(r);let i={name:t,length:e.length*8},o=SLe(t,r,n);return{encrypt(s){return RE(s),fue.encrypt(e,i,o,s)},decrypt(s){return RE(s),fue.decrypt(e,i,o,s)}}}}var z6t=SN(ql.CBC),V6t=SN(ql.CTR),H6t=SN(ql.GCM);var PT=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},Qi;(function(t){t.DataFormats="dataFormats",t.ProtocolContext="protocolContext",t.ProtocolPath="protocolPath",t.Schemas="schemas"})(Qi||(Qi={}));var Eg=class t{static derivePrivateKey(e,r){var n;return PT(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 PT(this,void 0,void 0,function*(){let n=yield t.derivePrivateKey(e,r);return yield Ci.getPublicJwk(n.derivedPrivateKey)})}static derivePrivateKeyBytes(e,r){return PT(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 PT(this,void 0,void 0,function*(){let{hashAlgorithm:r,initialKeyMaterial:n,info:i,keyLengthInBytes:o}=e,a=yield kE().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 se(ne.HdKeyDerivationPathInvalid,`Invalid key derivation path: ${e}`)}};h();h();function BE(t,e){return t>e?1:t<e?-1:0}h();function ME(t){if(typeof t!="object")return!1;for(let e in t)return!1;return!0}function _n(t){Object.keys(t).forEach(e=>{t[e]===void 0?delete t[e]:typeof t[e]=="object"&&_n(t[e])})}var Ll=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},ve=class t{static validateJsonSchema(e){let r=e.descriptor.interface,n=e.descriptor.method,i=r+n;Hf(i,e)}static getSigner(e){return e.authorization===void 0?void 0:en.getSignerDid(e.authorization.signature.signatures[0])}static getCid(e){return Ll(this,void 0,void 0,function*(){let r=Object.assign({},e);return r.encodedData&&delete r.encodedData,yield An.computeCid(r)})}static compareCid(e,r){return Ll(this,void 0,void 0,function*(){let n=yield t.getCid(e),i=yield t.getCid(r);return BE(n,i)})}static createAuthorization(e){return Ll(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 Ll(this,void 0,void 0,function*(){let i=yield An.computeCid(e),o=Object.assign({descriptorCid:i},n);_n(o);let s=Ye.objectToBytes(o);return(yield xg.create(s,[r])).getJws()})}static getNewestMessage(e){return Ll(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 Ll(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 Ll(this,void 0,void 0,function*(){return(yield t.compareMessageTimestamp(e,r))>0})}static isOlder(e,r){return Ll(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 Ll(this,void 0,void 0,function*(){return e.descriptor.messageTimestamp>r.descriptor.messageTimestamp?1:e.descriptor.messageTimestamp<r.descriptor.messageTimestamp?-1:t.compareCid(e,r)})}static validateSignatureStructure(e,r,n="GenericSignaturePayload"){return Ll(this,void 0,void 0,function*(){if(e.signatures.length!==1)throw new se(ne.AuthenticationMoreThanOneSignatureNotSupported,"expected no more than 1 signature for authorization purpose");let i=en.decodePlainObjectPayload(e);Hf(n,i);let{descriptorCid:o}=i,s=yield An.computeCid(r);if(o!==s)throw new se(ne.AuthenticateDescriptorCidMismatch,`provided descriptorCid ${o} does not match expected CID ${s}`);return i})}};h();var ALe=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},xo=class t{static parse(e){return ALe(this,void 0,void 0,function*(){return new t(e)})}constructor(e){this.id=e.recordId,this.grantor=ve.getSigner(e),this.grantee=e.descriptor.recipient,this.dateGranted=e.descriptor.dateCreated;let r=e.encodedData,n=Ye.base64UrlToObject(r);this.dateExpires=n.dateExpires,this.delegated=n.delegated,this.description=n.description,this.requestId=n.requestId,this.scope=n.scope,this.conditions=n.conditions}};h();h();var Eo;(function(t){t.CreatedAscending="createdAscending",t.CreatedDescending="createdDescending",t.PublishedAscending="publishedAscending",t.PublishedDescending="publishedDescending"})(Eo||(Eo={}));h();var TLe=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.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]]);return r},Zn=class{static matchAnyFilter(e,r){if(r.length===0)return!0;for(let n of r)if(this.matchFilter(e,n))return!0;return!1}static matchFilter(e,r){for(let n in r){let i=r[n],o=e[n];if(o===void 0||!(Array.isArray(o)?this.matchAnyIndexValue(i,o):this.matchIndexValue(i,o)))return!1}return!0}static matchAnyIndexValue(e,r){for(let n of r)if(this.matchIndexValue(e,n))return!0;return!1}static matchIndexValue(e,r){if(typeof e=="object"){if(Array.isArray(e)){if(this.matchOneOf(e,r))return!0}else if(this.matchRange(e,r))return!0}else if(r===e)return!0;return!1}static matchOneOf(e,r){for(let n of e)if(r===n)return!0;return!1}static matchRange(e,r){return!(e.lt!==void 0&&r>=e.lt||e.lte!==void 0&&r>e.lte||e.gt!==void 0&&r<=e.gt||e.gte!==void 0&&r<e.gte)}static isEqualFilter(e){return typeof e!="object"}static isRangeFilter(e){return typeof e=="object"&&!Array.isArray(e)?"gt"in e||"lt"in e||"lte"in e||"gte"in e:!1}static isOneOfFilter(e){return!!(typeof e=="object"&&Array.isArray(e))}static convertRangeCriterion(e){let r;return e.to!==void 0&&e.from!==void 0?r={gte:e.from,lt:e.to}:e.to!==void 0?r={lt:e.to}:e.from!==void 0&&(r={gte:e.from}),r}static constructPrefixFilterAsRangeFilter(e){return{gte:e,lt:e+"\uFFFF"}}},kT=class{static reduceFilter(e){if(Object.keys(e).length<=1)return e;let{recordId:n,attester:i,parentId:o,recipient:s,contextId:a,author:d,protocolPath:u,schema:c,protocol:l}=e,m=TLe(e,["recordId","attester","parentId","recipient","contextId","author","protocolPath","schema","protocol"]);if(n!==void 0)return{recordId:n};if(i!==void 0)return{attester:i};if(o!==void 0)return{parentId:o};if(s!==void 0)return{recipient:s};if(a!==void 0)return{contextId:a};if(u!==void 0)return{protocolPath:u};if(c!==void 0)return{schema:c};if(l!==void 0)return{protocol:l};let g=Object.keys(m)[0],v={};return v[g]=e[g],v}};h();var Oe;(function(t){t.Events="Events",t.Messages="Messages",t.Protocols="Protocols",t.Records="Records"})(Oe||(Oe={}));var Se;(function(t){t.Configure="Configure",t.Create="Create",t.Get="Get",t.Grant="Grant",t.Query="Query",t.Read="Read",t.Request="Request",t.Revoke="Revoke",t.Write="Write",t.Delete="Delete",t.Subscribe="Subscribe"})(Se||(Se={}));h();function Na(t){let e;try{e=Su(t)}catch{e=void 0}if(t!==e)throw new se(ne.UrlProtocolNotNormalized,`Protocol URI ${t} must be normalized.`)}function Su(t){return hue(t)}function Sd(t){let e;try{e=bh(t)}catch{e=void 0}if(t!==e)throw new se(ne.UrlSchemaNotNormalized,`Schema URI ${t} must be normalized.`)}function bh(t){return hue(t)}function hue(t){let e;/^[^:]+:(\/{2})?[^\/].*/.test(t)?e=t:e=`http://${t}`;try{let r=new URL(e);return r.search="",r.hash="",ILe(r.href)}catch{throw new se(ne.UrlProtocolNotNormalizable,"Could not normalize protocol URI")}}function ILe(t){return t.endsWith("/")?t.slice(0,-1):t}var AN=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},PLe=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.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]]);return r},yt=class t{static isRecordsWrite(e){return e.descriptor.interface===Oe.Records&&e.descriptor.method===Se.Write}static getAuthor(e){let r;return e.authorization.authorDelegatedGrant!==void 0?r=ve.getSigner(e.authorization.authorDelegatedGrant):r=ve.getSigner(e),r}static decrypt(e,r,n){return AN(this,void 0,void 0,function*(){let{encryption:i}=e,o=i.keyEncryption.find(v=>v.rootKeyId===r.rootKeyId&&v.derivationScheme===r.derivationScheme);if(o===void 0)throw new se(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 vh.eciesSecp256k1Decrypt({ciphertext:d,ephemeralPublicKey:u,initializationVector:c,messageAuthenticationCode:l,privateKey:a}),p=Ye.base64UrlToBytes(i.initializationVector);return yield vh.aes256CtrDecrypt(m,p,n)})}static constructKeyDerivationPath(e,r){let n=r.descriptor,i=r.contextId,o;return e===Qi.DataFormats?o=t.constructKeyDerivationPathUsingDataFormatsScheme(n.schema,n.dataFormat):e===Qi.ProtocolPath?o=t.constructKeyDerivationPathUsingProtocolPathScheme(n):e===Qi.ProtocolContext?o=t.constructKeyDerivationPathUsingProtocolContextScheme(i):o=t.constructKeyDerivationPathUsingSchemasScheme(n.schema),o}static constructKeyDerivationPathUsingDataFormatsScheme(e,r){return e!==void 0?[Qi.DataFormats,e,r]:[Qi.DataFormats,r]}static constructKeyDerivationPathUsingProtocolPathScheme(e){if(e.protocol===void 0)throw new se(ne.RecordsProtocolPathDerivationSchemeMissingProtocol,"Unable to construct key derivation path using `protocols` scheme because `protocol` is missing.");let r=e.protocolPath.split("/");return[Qi.ProtocolPath,e.protocol,...r]}static constructKeyDerivationPathUsingProtocolContextScheme(e){if(e===void 0)throw new se(ne.RecordsProtocolContextDerivationSchemeMissingContextId,"Unable to construct key derivation path using `protocolContext` scheme because `contextId` is missing.");let r=e.split("/")[0];return[Qi.ProtocolContext,r]}static constructKeyDerivationPathUsingSchemasScheme(e){if(e===void 0)throw new se(ne.RecordsSchemasDerivationSchemeMissingSchema,"Unable to construct key derivation path using `schemas` scheme because `schema` is missing.");return[Qi.Schemas,e]}static derivePrivateKey(e,r){var n;return AN(this,void 0,void 0,function*(){if(e.derivedPrivateKey.crv!=="secp256k1")throw new se(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 Eg.derivePrivateKeyBytes(s,o)})}static validateAncestorKeyAndDescentKeyDerivationPathsMatch(e,r){for(let n=0;n<e.length;n++){let i=e[n],o=r[n];if(i!==o)throw new se(ne.RecordsInvalidAncestorKeyDerivationSegment,`Ancestor key derivation segment '${i}' mismatches against the descendant key derivation segment '${o}'.`)}}static getParentContextFromOfContextId(e){if(e===void 0)return;let r=e.lastIndexOf("/");return r===-1?"":e.substring(0,r)}static normalizeFilter(e){let r;e.protocol===void 0?r=void 0:r=Su(e.protocol);let n;e.schema===void 0?n=void 0:n=bh(e.schema);let i=Object.assign(Object.assign({},e),{protocol:r,schema:n});return _n(i),i}static isStartsWithFilter(e){return typeof e=="object"&&"startsWith"in e&&typeof e.startsWith=="string"}static buildTagIndexes(e){let r={};for(let n in e){let i=e[n];r[`tag.${n}`]=i}return r}static convertTagsFilter(e){let r={};for(let n in e){let i=e[n];r[`tag.${n}`]=this.isStartsWithFilter(i)?Zn.constructPrefixFilterAsRangeFilter(i.startsWith):i}return r}static convertFilter(e,r){let{tags:n}=e,i=PLe(e,["tags"]),o={};n!==void 0&&(o=Object.assign({},this.convertTagsFilter(n)));let s=Object.assign(Object.assign({},i),o),{dateCreated:a,datePublished:d,dateUpdated:u,contextId:c}=e,l=a?Zn.convertRangeCriterion(a):void 0;l&&(s.dateCreated=l);let m=d?Zn.convertRangeCriterion(d):void 0;m&&(s.published=!0,s.datePublished=m),s.published!==!0&&(r===Eo.PublishedAscending||r===Eo.PublishedDescending)&&(s.published=!0);let p=u?Zn.convertRangeCriterion(u):void 0;p&&(s.messageTimestamp=p,delete s.dateUpdated);let g=c?Zn.constructPrefixFilterAsRangeFilter(c):void 0;return g&&(s.contextId=g),s}static validateDelegatedGrantReferentialIntegrity(e,r,n){var i,o;return AN(this,void 0,void 0,function*(){let s=r?.delegatedGrantId!==void 0,a=((i=e.authorization)===null||i===void 0?void 0:i.authorDelegatedGrant)!==void 0;if(s!==a)throw new se(ne.RecordsAuthorDelegatedGrantAndIdExistenceMismatch,`delegatedGrantId in message (author) signature and authorDelegatedGrant must both exist or be undefined. delegatedGrantId in message (author) signature defined: ${s}, authorDelegatedGrant defined: ${a}`);if(a){let c=e.authorization.authorDelegatedGrant;if((yield xo.parse(c)).delegated!==!0)throw new se(ne.RecordsAuthorDelegatedGrantNotADelegatedGrant,"The owner delegated grant given is not a delegated grant.");let m=c.descriptor.recipient,p=ve.getSigner(e);if(m!==p)throw new se(ne.RecordsAuthorDelegatedGrantGrantedToAndOwnerSignatureMismatch,`grantedTo ${m} in author delegated grant must be the same as the signer ${p} of the message signature.`);let g=yield ve.getCid(c);if(g!==r.delegatedGrantId)throw new se(ne.RecordsAuthorDelegatedGrantCidMismatch,`CID of the author delegated grant ${g} must be the same as the delegatedGrantId ${r.delegatedGrantId} in the message signature.`)}let d=n?.delegatedGrantId!==void 0,u=((o=e.authorization)===null||o===void 0?void 0:o.ownerDelegatedGrant)!==void 0;if(d!==u)throw new se(ne.RecordsOwnerDelegatedGrantAndIdExistenceMismatch,`delegatedGrantId in owner signature and ownerDelegatedGrant must both exist or be undefined. delegatedGrantId in owner signature defined: ${d}, ownerDelegatedGrant defined: ${u}`);if(u){let c=e.authorization.ownerDelegatedGrant;if((yield xo.parse(c)).delegated!==!0)throw new se(ne.RecordsOwnerDelegatedGrantNotADelegatedGrant,"The owner delegated grant given is not a delegated grant.");let m=c.descriptor.recipient,p=en.getSignerDid(e.authorization.ownerSignature.signatures[0]);if(m!==p)throw new se(ne.RecordsOwnerDelegatedGrantGrantedToAndOwnerSignatureMismatch,`grantedTo ${m} in owner delegated grant must be the same as the signer ${p} of the owner signature.`);let g=yield ve.getCid(c);if(g!==n.delegatedGrantId)throw new se(ne.RecordsOwnerDelegatedGrantCidMismatch,`CID of the owner delegated grant ${g} must be the same as the delegatedGrantId ${n.delegatedGrantId} in the owner signature.`)}})}static shouldProtocolAuthorize(e){return e.protocolRole!==void 0}static filterIncludesPublishedRecords(e){return e.datePublished!==void 0||e.published!==!1}static filterIncludesUnpublishedRecords(e){return e.datePublished===void 0&&e.published===void 0?!0:e.published===!1}};h();h();var TN=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},wh=class t{static performBaseValidation(e){return TN(this,void 0,void 0,function*(){let{incomingMessage:r,expectedGrantor:n,expectedGrantee:i,permissionGrant:o,messageStore:s}=e,a=r.descriptor;t.verifyExpectedGrantorAndGrantee(n,i,o);let d=n;yield t.verifyGrantActive(d,a.messageTimestamp,o,s),yield t.verifyGrantScopeInterfaceAndMethod(a.interface,a.method,o)})}static verifyExpectedGrantorAndGrantee(e,r,n){let i=n.grantee;if(r!==i)throw new se(ne.GrantAuthorizationNotGrantedToAuthor,`Permission grant is granted to ${i}, but need to be granted to ${r}`);let o=n.grantor;if(e!==o)throw new se(ne.GrantAuthorizationNotGrantedForTenant,`Permission grant is granted by ${o}, but need to be granted by ${e}`)}static verifyGrantActive(e,r,n,i){return TN(this,void 0,void 0,function*(){if(r<n.dateGranted)throw new se(ne.GrantAuthorizationGrantNotYetActive,"The message has a timestamp before the associated permission grant becomes active");if(r>=n.dateExpires)throw new se(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 ve.getOldestMessage(s);if(a!==void 0&&a.descriptor.messageTimestamp<=r)throw new se(ne.GrantAuthorizationGrantRevoked,`Permission grant with CID ${n.id} has been revoked`)})}static verifyGrantScopeInterfaceAndMethod(e,r,n){return TN(this,void 0,void 0,function*(){if(e!==n.scope.interface)throw new se(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 se(ne.GrantAuthorizationMethodMismatch,`DWN Method of incoming message is outside the scope of permission grant with ID ${n.id}`)})}};h();var DE;(function(t){t.Required="Required",t.Prohibited="Prohibited"})(DE||(DE={}));var RT=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},Go=class t{static authorizeWrite(e){return RT(this,void 0,void 0,function*(){let{recordsWriteMessage:r,expectedGrantor:n,expectedGrantee:i,permissionGrant:o,messageStore:s}=e;yield wh.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 RT(this,void 0,void 0,function*(){let{recordsReadMessage:r,recordsWriteMessageToBeRead:n,expectedGrantor:i,expectedGrantee:o,permissionGrant:s,messageStore:a}=e;yield wh.performBaseValidation({incomingMessage:r,expectedGrantor:i,expectedGrantee:o,permissionGrant:s,messageStore:a}),t.verifyScope(n,s.scope)})}static authorizeQueryOrSubscribe(e){return RT(this,void 0,void 0,function*(){let{incomingMessage:r,expectedGrantor:n,expectedGrantee:i,permissionGrant:o,messageStore:s}=e;yield wh.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 se(ne.RecordsGrantAuthorizationQueryOrSubscribeProtocolScopeMismatch,`Grant protocol scope ${d} does not match protocol in message ${u}`)})}static authorizeDelete(e){return RT(this,void 0,void 0,function*(){let{recordsDeleteMessage:r,recordsWriteToDelete:n,expectedGrantor:i,expectedGrantee:o,permissionGrant:s,messageStore:a}=e;yield wh.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 se(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 se(ne.RecordsGrantAuthorizationScopeMissingProtocol,"Grant for protocol record must specify protocol in its scope");if(r.protocol!==e.descriptor.protocol)throw new se(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 se(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 se(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 se(ne.RecordsGrantAuthorizationScopeSchema,`Record does not have schema in permission grant scope with schema '${r.schema}'`)}static verifyConditions(e,r){if(r?.publication===DE.Required&&!e.descriptor.published)throw new se(ne.RecordsGrantAuthorizationConditionPublicationRequired,"Permission grant requires message to be published");if(r?.publication===DE.Prohibited&&e.descriptor.published)throw new se(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=qt(pue(),1),CN={};function Yl(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))}En(e,t),En(`${e}.prototype`,t.prototype)}function En(t,e){let r=`%${t}%`;if(CN[r]!==void 0)throw new Error(`intrinsic ${t} already exists`);CN[r]=e}function _e(t){return CN[t]}var mue,yue,dt="slot-epochNanoSeconds",Fl="slot-timezone-identifier",Te="slot-year",ke="slot-month",Ce="slot-day",wt="slot-hour",_t="slot-minute",xt="slot-second",Et="slot-millisecond",St="slot-microsecond",At="slot-nanosecond",oe="slot-calendar",Zue="slot-date-brand",Xue="slot-year-month-brand",Que="slot-month-day-brand",To="slot-cached-instant",Nr="slot-time-zone",Jo="slot-years",ji="slot-months",Cs="slot-weeks",Yo="slot-days",Zo="slot-hours",Xo="slot-minutes",Qo="slot-seconds",es="slot-milliseconds",ts="slot-microseconds",rs="slot-nanoseconds",xn="slot-calendar-identifier",ele=new WeakMap,$N=Symbol.for("@@Temporal__GetSlots");(mue=globalThis)[$N]||(mue[$N]=function(e){return ele.get(e)});var lj=globalThis[$N],NN=Symbol.for("@@Temporal__CreateSlots");(yue=globalThis)[NN]||(yue[NN]=function(e){ele.set(e,Object.create(null))});var Zl=globalThis[NN];function Pi(t,...e){if(!t||typeof t!="object")return!1;let r=lj(t);return!!r&&e.every(n=>n in r)}function R(t,e){let r=lj(t)?.[e];if(r===void 0)throw new TypeError(`Missing internal slot ${e}`);return r}function Rt(t,e,r){let n=lj(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 gue=/\.[-A-Za-z_]|\.\.[-A-Za-z._]{1,12}|\.[-A-Za-z_][-A-Za-z._]{0,12}|[A-Za-z_][-A-Za-z._]{0,13}/,ZE=new RegExp("(?:"+[`(?:${gue.source})(?:\\/(?:${gue.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("|")+")"),tle=/(?:[+\u2212-]\d{6}|\d{4})/,$T=/(?:0[1-9]|1[0-2])/,jN=/(?:0[1-9]|[12]\d|3[01])/,kLe=new RegExp(`(${tle.source})(?:-(${$T.source})-(${jN.source})|(${$T.source})(${jN.source}))`),rle=/(\d{2})(?::(\d{2})(?::(\d{2})(?:[.,](\d{1,9}))?)?|(\d{2})(?:(\d{2})(?:[.,](\d{1,9}))?)?)?/,nle=/([+\u2212-])([01][0-9]|2[0-3])(?::?([0-5][0-9])(?::?([0-5][0-9])(?:[.,](\d{1,9}))?)?)?/,ile=new RegExp(`([zZ])|${nle.source}?`),Nm=/\[(!)?([a-z_][a-z0-9_-]*)=([A-Za-z0-9]+(?:-[A-Za-z0-9]+)*)\]/g,RLe=new RegExp([`^${kLe.source}`,`(?:(?:T|\\s+)${rle.source}(?:${ile.source})?)?`,`(?:\\[!?(${ZE.source})\\])?`,`((?:${Nm.source})*)$`].join(""),"i"),BLe=new RegExp([`^T?${rle.source}`,`(?:${ile.source})?`,`(?:\\[!?${ZE.source}\\])?`,`((?:${Nm.source})*)$`].join(""),"i"),MLe=new RegExp(`^(${tle.source})-?(${$T.source})(?:\\[!?${ZE.source}\\])?((?:${Nm.source})*)$`),DLe=new RegExp(`^(?:--)?(${$T.source})-?(${jN.source})(?:\\[!?${ZE.source}\\])?((?:${Nm.source})*)$`),kN=/(\d+)(?:[.,](\d{1,9}))?/,OLe=new RegExp(`(?:${kN.source}H)?(?:${kN.source}M)?(?:${kN.source}S)?`),CLe=new RegExp(`^([+\u2212-])?P${/(?:(\d+)Y)?(?:(\d+)M)?(?:(\d+)W)?(?:(\d+)D)?/.source}(?:T(?!$)${OLe.source})?$`,"i"),$Le=Array.prototype.includes,ole=Array.prototype.push,sle=globalThis.Intl.DateTimeFormat,NLe=Math.min,jLe=Math.max,sn=Math.abs,da=Math.floor,o1=Math.sign,Tg=Math.trunc,XT=Number.isNaN,ns=Number.isFinite,ULe=Number,XE=String,qLe=Number.MAX_SAFE_INTEGER,Po=Object.create,LLe=Object.getOwnPropertyDescriptor,QT=Reflect.apply,KLe=Reflect.ownKeys,Rn=z.default.BigInt(0),p1=z.default.BigInt(1),zl=z.default.BigInt(60),ale=z.default.BigInt(24),Ar=z.default.BigInt(1e3),Ec=z.default.BigInt(1e6),Vl=z.default.BigInt(1e9),FLe=z.default.BigInt(-1),cle=z.default.multiply(z.default.BigInt(3600),Vl),dle=z.default.multiply(zl,Vl),Wl=z.default.multiply(cle,ale),jE=z.default.multiply(z.default.BigInt(-86400),z.default.BigInt(1e17)),s1=z.default.multiply(z.default.BigInt(86400),z.default.BigInt(1e17)),NT=-271821,jT=275760,Xw=z.default.multiply(z.default.BigInt(-388152),z.default.BigInt(1e13)),zLe=z.default.multiply(Wl,z.default.BigInt(3660)),ule=z.default.multiply(Wl,z.default.BigInt(366)),lle=z.default.multiply(Wl,z.default.BigInt(14)),VLe=["iso8601","hebrew","islamic","islamic-umalqura","islamic-tbla","islamic-civil","islamic-rgsa","islamicc","persian","ethiopic","ethioaa","coptic","chinese","dangi","roc","indian","buddhist","japanese","gregory"];function xc(t){return z.default.equal(t,Rn)}function kr(t,e){let r=t[e];if(r!==void 0)return r}function Ge(t,e,r){let n=arguments.length>2?r:[];return QT(t,e,n)}function an(t){return typeof t=="object"&&t!==null||typeof t=="function"}function a1(t){if(typeof t=="bigint")throw new TypeError("Cannot convert BigInt to number");return ULe(t)}function Xn(t){let e=a1(t);if(XT(e)||e===0)return 0;if(!ns(e))return e;let r=da(sn(e));return r===0?0:o1(e)*r}function qa(t){if(typeof t!="number"||XT(t)||!ns(t))return!1;let e=sn(t);return da(e)===e}function os(t){if(typeof t=="symbol")throw new TypeError("Cannot convert a Symbol value to a String");return XE(t)}function gr(t){let e=a1(t);if(e===0)return 0;if(XT(e)||!ns(e))throw new RangeError("invalid number value");let r=Tg(e);return r===0?0:r}function vue(t,e){let r=gr(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 Ii(t){let e=a1(t);if(!ns(e))throw new RangeError("infinity is out of range");if(!qa(e))throw new RangeError(`unsupported fractional value ${t}`);return e===0?0:e}function Fn(t,e){return{quotient:z.default.divide(t,e),remainder:z.default.remainder(t,e)}}function UT(t){return z.default.lessThan(t,Rn)}function bue(t){return xc(t)?0:UT(t)?-1:1}function Au(t){return z.default.lessThan(t,Rn)?z.default.multiply(t,FLe):t}var wue=new Map([["year",gr],["month",vue],["monthCode",os],["day",vue],["hour",gr],["minute",gr],["second",gr],["millisecond",gr],["microsecond",gr],["nanosecond",gr],["years",Ii],["months",Ii],["weeks",Ii],["days",Ii],["hours",Ii],["minutes",Ii],["seconds",Ii],["milliseconds",Ii],["microseconds",Ii],["nanoseconds",Ii],["era",os],["eraYear",Xn],["offset",os]]),HLe=new Map([["hour",0],["minute",0],["second",0],["millisecond",0],["microsecond",0],["nanosecond",0]]),QE=[["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"]],qT=new Map(QE.map(t=>[t[0],t[1]])),WLe=new Map(QE.map(([t,e])=>[e,t])),_ue=QE.map(([,t])=>t),xue=Array.from(qT.keys()).sort(),Eue=new Map;function fle(t){let e=Eue.get(t);return e===void 0&&(e=new sle("en-us",{timeZone:XE(t),hour12:!1,era:"short",year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"}),Eue.set(t,e)),e}function Sue(t){if(t==null)throw new TypeError(`Expected object not ${t}`);return Object(t)}function Qw(t,e,r,n){if(e==null)return;let i=KLe(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 hi(t){return Pi(t,dt)&&!Pi(t,Nr,oe)}function _c(t){return Pi(t,Fl)}function In(t){return Pi(t,xn)}function Pn(t){return Pi(t,Jo,ji,Yo,Zo,Xo,Qo,es,ts,rs)}function Ht(t){return Pi(t,Zue)}function kn(t){return Pi(t,wt,_t,xt,Et,St,At)&&!Pi(t,Te,ke,Ce)}function bt(t){return Pi(t,Te,ke,Ce,wt,_t,xt,Et,St,At)}function Sr(t){return Pi(t,Xue)}function Ti(t){return Pi(t,Que)}function Le(t){return Pi(t,dt,Nr,oe)}function m1(t){if(Pi(t,oe)||Pi(t,Nr))throw new TypeError("with() does not support a calendar or timeZone property");if(kn(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 GLe(t){let{ianaName:e,offset:r,z:n}=function(o){if(new RegExp(`^${ZE.source}$`,"i").test(o))return{ianaName:o};try{let s=Xl(o);if(s.z||s.offset||s.ianaName)return s}catch{}throw new RangeError(`Invalid time zone: ${o}`)}(t);return e?xj(e):n?"UTC":lI(Bm(r))}function fj(t,e){return e==="never"?"":hj(no(t),e)}function hj(t,e){return e==="never"||e==="auto"&&t==="iso8601"?"":`[${e==="critical"?"!":""}u-ca=${t}]`}function Xl(t){let e=RLe.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=Xn(r),i=Xn(e[2]||e[4]),o=Xn(e[3]||e[5]),s=Xn(e[6]),a=e[6]!==void 0,d=Xn(e[7]||e[10]),u=Xn(e[8]||e[11]);u===60&&(u=59);let c=(e[9]||e[12])+"000000000",l=Xn(c.slice(0,3)),m=Xn(c.slice(3,6)),p=Xn(c.slice(6,9)),g,v=!1;if(e[13])g=void 0,v=!0;else if(e[14]&&e[15]){let I=e[14]==="-"||e[14]==="\u2212"?"-":"+",$=e[15]||"00",N=e[16]||"00",K=e[17]||"00",F=e[18]||"0";if(g=`${I}${$}:${N}`,+F){for(;F.endsWith("0");)F=F.slice(0,-1);g+=`:${K}.${F}`}else+K&&(g+=`:${K}`);g==="-00:00"&&(g="+00:00")}let E=e[19],A=e[20],P;for(let[,I,$,N]of A.matchAll(Nm))if($==="u-ca")P===void 0&&(P=N);else if(I==="!")throw new RangeError(`Unrecognized annotation: !${$}=${N}`);return Aj(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:E,offset:g,z:v,calendar:P}}function pj(t){let e=MLe.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=Xn(s),n=Xn(e[2]);let a=e[3];for(let[,d,u,c]of a.matchAll(Nm))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}=Xl(t),s)throw new RangeError("Z designator not supported for PlainYearMonth")}return{year:r,month:n,calendar:i,referenceISODay:o}}function mj(t){let e=DLe.exec(t),r,n,i,o;if(e){r=Xn(e[1]),n=Xn(e[2]);let s=e[3];for(let[,a,d,u]of s.matchAll(Nm))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}=Xl(t),s)throw new RangeError("Z designator not supported for PlainMonthDay")}return{month:r,day:n,calendar:i,referenceISOYear:o}}function JLe(t){let{year:e,month:r,day:n,hour:i,minute:o,second:s,millisecond:a,microsecond:d,nanosecond:u,offset:c,z:l}=function(v){let E=Xl(v);if(!E.z&&!E.offset)throw new RangeError("Temporal.Instant requires a time zone offset");return E}(t);if(!l&&!c)throw new RangeError("Temporal.Instant requires a time zone offset");let m=l?0:Bm(c);({year:e,month:r,day:n,hour:i,minute:o,second:s,millisecond:a,microsecond:d,nanosecond:u}=Ej(e,r,n,i,o,s,a,d,u-m));let p=Mm(e,r,n,i,o,s,a,d,u);if(p===null)throw new RangeError("DateTime outside of supported range");return p}function LT(t,e,r,n){let i=t,o=e,s=r;switch(n){case"reject":Gl(i,o,s);break;case"constrain":({year:i,month:o,day:s}=kle(i,o,s))}return{year:i,month:o,day:s}}function eI(t,e,r,n,i,o,s){let a=t,d=e,u=r,c=n,l=i,m=o;switch(s){case"reject":hI(a,d,u,c,l,m);break;case"constrain":({hour:a,minute:d,second:u,millisecond:c,microsecond:l,nanosecond:m}=function(g,v,E,A,P,I){let $=ca(g,0,23),N=ca(v,0,59),K=ca(E,0,59),F=ca(A,0,999),U=ca(P,0,999),V=ca(I,0,999);return{hour:$,minute:N,second:K,millisecond:F,microsecond:U,nanosecond:V}}(a,d,u,c,l,m))}return{hour:a,minute:d,second:u,millisecond:c,microsecond:l,nanosecond:m}}function Ng(t){if(!an(t))return function(g){let v=CLe.exec(g);if(!v)throw new RangeError(`invalid duration: ${g}`);if(v.slice(2).every(_=>_===void 0))throw new RangeError(`invalid duration: ${g}`);let E=v[1]==="-"||v[1]==="\u2212"?-1:1,A=v[2]===void 0?0:gr(v[2])*E,P=v[3]===void 0?0:gr(v[3])*E,I=v[4]===void 0?0:gr(v[4])*E,$=v[5]===void 0?0:gr(v[5])*E,N=v[6]===void 0?0:gr(v[6])*E,K=v[7],F=v[8],U=v[9],V=v[10],L=v[11],T=0,S=0,k=0;if(K!==void 0){if(F??U??V??L)throw new RangeError("only the smallest unit can be fractional");k=3600*Xn((K+"000000000").slice(0,9))*E}else if(T=F===void 0?0:gr(F)*E,U!==void 0){if(V??L)throw new RangeError("only the smallest unit can be fractional");k=60*Xn((U+"000000000").slice(0,9))*E}else S=V===void 0?0:gr(V)*E,L!==void 0&&(k=Xn((L+"000000000").slice(0,9))*E);let f=k%1e3,y=Tg(k/1e3)%1e3,w=Tg(k/1e6)%1e3;return S+=Tg(k/1e9)%60,T+=Tg(k/6e10),WT(A,P,I,$,N,T,S,w,y,f),{years:A,months:P,weeks:I,days:$,hours:N,minutes:T,seconds:S,milliseconds:w,microseconds:y,nanoseconds:f}}(os(t));if(Pn(t))return{years:R(t,Jo),months:R(t,ji),weeks:R(t,Cs),days:R(t,Yo),hours:R(t,Zo),minutes:R(t,Xo),seconds:R(t,Qo),milliseconds:R(t,es),microseconds:R(t,ts),nanoseconds:R(t,rs)};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(!an(g))throw new TypeError("invalid duration-like");let v={years:void 0,months:void 0,weeks:void 0,days:void 0,hours:void 0,minutes:void 0,seconds:void 0,milliseconds:void 0,microseconds:void 0,nanoseconds:void 0},E=!1;for(let A of xue){let P=g[A];P!==void 0&&(E=!0,v[A]=Ii(P))}if(!E)throw new TypeError("invalid duration-like");return v}(t);for(let p of xue){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 WT(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 zn(t){return t===void 0?"constrain":Om(t,"overflow",["constrain","reject"],"constrain")}function c1(t){return t===void 0?"compatible":Om(t,"disambiguation",["compatible","earlier","later","reject"],"compatible")}function Iu(t,e){return Om(t,"roundingMode",["ceil","floor","expand","trunc","halfCeil","halfFloor","halfExpand","halfTrunc","halfEven"],e)}function KT(t,e){return t===void 0?e:Om(t,"offset",["prefer","use","ignore","reject"],e)}function e6(t){return Om(t,"calendarName",["auto","always","never","critical"],"auto")}function y1(t){let e=t.roundingIncrement;if(e===void 0)return 1;if(e=a1(e),!ns(e))throw new RangeError("roundingIncrement must be finite");let r=Tg(e);if(r<1||r>1e9)throw new RangeError(`roundingIncrement must be at least 1 and at most 1e9, not ${e}`);return r}function g1(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 t6(t){let e=t.fractionalSecondDigits;if(e===void 0)return"auto";if(typeof e!="number"){if(os(e)!=="auto")throw new RangeError(`fractionalSecondDigits must be 'auto' or 0 through 9, not ${e}`);return"auto"}let r=da(e);if(!ns(r)||r<0||r>9)throw new RangeError(`fractionalSecondDigits must be 'auto' or 0 through 9, not ${e}`);return r}function r6(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 Bg=Symbol("~required~");function ua(t,e,r,n,i=[]){let o=[];for(let[,u,c]of QE)r!=="datetime"&&r!==c||o.push(u);o.push(...i);let s=n;s===Bg?s=void 0:s!==void 0&&o.push(s);let a=[...o];for(let u of o){let c=WLe.get(u);c!==void 0&&a.push(c)}let d=Om(t,e,a,s);if(d===void 0&&n===Bg)throw new RangeError(`${e} is required`);return qT.has(d)?qT.get(d):d}function MT(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",v=!1;if(an(e)){if(Le(e)||Ht(e))return e;if(bt(e))return u1(e);l=s6(e);let E=Qn(l,["day","hour","microsecond","millisecond","minute","month","monthCode","nanosecond","second","year"]);E.push("timeZone","offset");let A=Dt(e,E,[]),P=Po(null);P.overflow="constrain",{year:r,month:n,day:i,hour:o,minute:s,second:a,millisecond:d,microsecond:u,nanosecond:c}=n6(l,A,P),p=A.offset,p===void 0&&(g="wall"),m=A.timeZone,m!==void 0&&(m=Io(m))}else{let E,A;if({year:r,month:n,day:i,hour:o,minute:s,second:a,millisecond:d,microsecond:u,nanosecond:c,calendar:l,ianaName:E,offset:p,z:A}=Xl(os(e)),E)m=Io(E),A?g="exact":p||(g="wall"),v=!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"),!Ph(l))throw new RangeError(`invalid calendar identifier ${l}`);l=Jl(l)}return m===void 0?Ac(r,n,i,l):eo(zT(r,n,i,o,s,a,d,u,c,g,g==="option"?Bm(p):0,m,"compatible","reject",v),m,l)}function UN(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 qT.get(c);return"nanosecond"}function Mg(t,e){return _ue.indexOf(t)>_ue.indexOf(e)?e:t}function Dt(t,e,r,{emptySourceErrorMessage:n}={emptySourceErrorMessage:"no supported properties found"}){let i=Po(null),o=!1;e.sort();for(let s of e){let a=t[s];if(a!==void 0)o=!0,wue.has(s)&&(a=wue.get(s)(a)),i[s]=a;else if(r!=="partial"){if($Le.call(r,s))throw new TypeError(`required property '${s}' missing or undefined`);a=HLe.get(s),i[s]=a}}if(r==="partial"&&!o)throw new TypeError(n);return i}function FT(t,e="complete"){let r=["hour","microsecond","millisecond","minute","nanosecond","second"],n=Dt(t,r,"partial",{emptySourceErrorMessage:"invalid time-like"}),i={};for(let o of r){let s=LLe(n,o);s!==void 0?i[o]=s.value:e==="complete"&&(i[o]=0)}return i}function Ur(t,e){let r=t;if(an(r)){if(Ht(r))return r;if(Le(r)&&(zn(e),r=Ua(R(r,Nr),R(r,To),R(r,oe))),bt(r))return zn(e),Ac(R(r,Te),R(r,ke),R(r,Ce),R(r,oe));let d=s6(r);return Th(d,Dt(r,Qn(d,["day","month","monthCode","year"]),[]),e)}zn(e);let{year:n,month:i,day:o,calendar:s,z:a}=function(u){return Xl(u)}(os(r));if(a)throw new RangeError("Z designator not supported for PlainDate");if(s||(s="iso8601"),!Ph(s))throw new RangeError(`invalid calendar identifier ${s}`);return s=Jl(s),Ac(n,i,o,s)}function n6(t,e,r){let{hour:n,minute:i,second:o,millisecond:s,microsecond:a,nanosecond:d}=FT(e),u=zn(r),c=Th(t,e,r),l=R(c,Te),m=R(c,ke),p=R(c,Ce);return{hour:n,minute:i,second:o,millisecond:s,microsecond:a,nanosecond:d}=eI(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 Ig(t,e){let r,n,i,o,s,a,d,u,c,l;if(an(t)){if(bt(t))return t;if(Le(t))return zn(e),Ua(R(t,Nr),R(t,To),R(t,oe));if(Ht(t))return zn(e),aa(R(t,Te),R(t,ke),R(t,Ce),0,0,0,0,0,0,R(t,oe));l=s6(t);let m=Dt(t,Qn(l,["day","hour","microsecond","millisecond","minute","month","monthCode","nanosecond","second","year"]),[]);({year:r,month:n,day:i,hour:o,minute:s,second:a,millisecond:d,microsecond:u,nanosecond:c}=n6(l,m,e))}else{let m;if(zn(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 Xl(g)}(os(t)),m)throw new RangeError("Z designator not supported for PlainDateTime");if(Aj(r,n,i,o,s,a,d,u,c),l||(l="iso8601"),!Ph(l))throw new RangeError(`invalid calendar identifier ${l}`);l=Jl(l)}return aa(r,n,i,o,s,a,d,u,c,l)}function e1(t){if(Pn(t))return t;let{years:e,months:r,weeks:n,days:i,hours:o,minutes:s,seconds:a,milliseconds:d,microseconds:u,nanoseconds:c}=Ng(t);return new(_e("%Temporal.Duration%"))(e,r,n,i,o,s,a,d,u,c)}function Tu(t){if(hi(t))return t;if(Le(t))return new(_e("%Temporal.Instant%"))(R(t,dt));let e=JLe(os(t));return new(_e("%Temporal.Instant%"))(e)}function Aue(t,e){let r=t;if(an(r)){if(Ti(r))return r;let a,d;if(Pi(r,oe))a=R(r,oe),d=!1;else{let c=r.calendar;d=c===void 0,c===void 0&&(c="iso8601"),a=la(c)}let u=Dt(r,Qn(a,["day","month","monthCode","year"]),[]);return d&&u.month!==void 0&&u.monthCode===void 0&&u.year===void 0&&(u.year=1972),d1(a,u,e)}zn(e);let{month:n,day:i,referenceISOYear:o,calendar:s}=mj(os(r));if(s===void 0&&(s="iso8601"),!Ph(s))throw new RangeError(`invalid calendar identifier ${s}`);return s=Jl(s),o===void 0?(Gl(1972,n,i),UE(n,i,s)):d1(s,UE(n,i,s,o))}function xh(t,e="constrain"){let r,n,i,o,s,a,d=t;if(an(d)){if(kn(d))return d;if(Le(d)&&(d=Ua(R(d,Nr),R(d,To),R(d,oe))),bt(d))return new(_e("%Temporal.PlainTime%"))(R(d,wt),R(d,_t),R(d,xt),R(d,Et),R(d,St),R(d,At));({hour:r,minute:n,second:i,millisecond:o,microsecond:s,nanosecond:a}=FT(d)),{hour:r,minute:n,second:i,millisecond:o,microsecond:s,nanosecond:a}=eI(r,n,i,o,s,a,e)}else({hour:r,minute:n,second:i,millisecond:o,microsecond:s,nanosecond:a}=function(c){let l=BLe.exec(c),m,p,g,v,E,A,P;if(l){m=Xn(l[1]),p=Xn(l[2]||l[5]),g=Xn(l[3]||l[6]),g===60&&(g=59);let I=(l[4]||l[7])+"000000000";v=Xn(I.slice(0,3)),E=Xn(I.slice(3,6)),A=Xn(I.slice(6,9)),P=l[14];for(let[,$,N,K]of P.matchAll(Nm))if(N!=="u-ca"&&$==="!")throw new RangeError(`Unrecognized annotation: !${N}=${K}`);if(l[8])throw new RangeError("Z designator not supported for PlainTime")}else{let I,$;if({hasTime:$,hour:m,minute:p,second:g,millisecond:v,microsecond:E,nanosecond:A,z:I}=Xl(c),!$)throw new RangeError(`time is missing in string: ${c}`);if(I)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:v,microsecond:E,nanosecond:A};try{let{month:I,day:$}=mj(c);Gl(1972,I,$)}catch{try{let{year:I,month:$}=pj(c);Gl(I,$,1)}catch{return{hour:m,minute:p,second:g,millisecond:v,microsecond:E,nanosecond:A}}}throw new RangeError(`invalid ISO 8601 time-only string ${c}; may need a T prefix`)}(os(d))),hI(r,n,i,o,s,a);return new(_e("%Temporal.PlainTime%"))(r,n,i,o,s,a)}function OE(t,e){if(an(t)){if(Sr(t))return t;let s=s6(t);return Og(s,Dt(t,Qn(s,["month","monthCode","year"]),[]),e)}zn(e);let{year:r,month:n,referenceISODay:i,calendar:o}=pj(os(t));if(o===void 0&&(o="iso8601"),!Ph(o))throw new RangeError(`invalid calendar identifier ${o}`);return o=Jl(o),i===void 0?(Gl(r,n,1),qE(r,n,o)):Og(o,qE(r,n,o,i))}function zT(t,e,r,n,i,o,s,a,d,u,c,l,m,p,g){let v=new(_e("%Temporal.PlainDateTime%"))(t,e,r,n,i,o,s,a,d);if(u==="wall"||p==="ignore")return R(is(l,v,m),dt);if(u==="exact"||p==="use"){let A=Mm(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 E=VT(l,v);for(let A of E){let P=Pu(l,A),I=z.default.toNumber(ja(z.default.BigInt(P),dle,"halfExpand"));if(P===c||g&&I===c)return R(A,dt)}if(p==="reject"){let A=lI(c),P=_c(l)?R(l,Fl):"time zone";throw new RangeError(`Offset ${A} is invalid for ${v.toString()} in ${P}`)}return R(_le(E,l,v,m),dt)}function CE(t,e){let r,n,i,o,s,a,d,u,c,l,m,p,g,v,E=!1,A="option";if(an(t)){if(Le(t))return t;p=s6(t);let I=Qn(p,["day","hour","microsecond","millisecond","minute","month","monthCode","nanosecond","second","year"]);I.push("timeZone","offset");let $=Dt(t,I,["timeZone"]);l=Io($.timeZone),m=$.offset,m===void 0&&(A="wall"),g=c1(e),v=KT(e,"reject"),{year:r,month:n,day:i,hour:o,minute:s,second:a,millisecond:d,microsecond:u,nanosecond:c}=n6(p,$,e)}else{let I,$;if({year:r,month:n,day:i,hour:o,minute:s,second:a,millisecond:d,microsecond:u,nanosecond:c,ianaName:I,offset:m,z:$,calendar:p}=function(K){let F=Xl(K);if(!F.ianaName)throw new RangeError("Temporal.ZonedDateTime requires a time zone ID in brackets");return F}(os(t)),l=Io(I),$?A="exact":m||(A="wall"),p||(p="iso8601"),!Ph(p))throw new RangeError(`invalid calendar identifier ${p}`);p=Jl(p),E=!0,g=c1(e),v=KT(e,"reject"),zn(e)}let P=0;return A==="option"&&(P=Bm(m)),eo(zT(r,n,i,o,s,a,d,u,c,A,P,l,g,v,E),l,p)}function hle(t,e,r,n,i){Gl(e,r,n),Rle(e,r,n),Zl(t),Rt(t,Te,e),Rt(t,ke,r),Rt(t,Ce,n),Rt(t,oe,i),Rt(t,Zue,!0)}function Ac(t,e,r,n="iso8601"){let i=_e("%Temporal.PlainDate%"),o=Po(i.prototype);return hle(o,t,e,r,n),o}function ple(t,e,r,n,i,o,s,a,d,u,c){Aj(e,r,n,i,o,s,a,d,u),Ble(e,r,n,i,o,s,a,d,u),Zl(t),Rt(t,Te,e),Rt(t,ke,r),Rt(t,Ce,n),Rt(t,wt,i),Rt(t,_t,o),Rt(t,xt,s),Rt(t,Et,a),Rt(t,St,d),Rt(t,At,u),Rt(t,oe,c)}function aa(t,e,r,n,i,o,s,a,d,u="iso8601"){let c=_e("%Temporal.PlainDateTime%"),l=Po(c.prototype);return ple(l,t,e,r,n,i,o,s,a,d,u),l}function mle(t,e,r,n,i){Gl(i,e,r),Rle(i,e,r),Zl(t),Rt(t,ke,e),Rt(t,Ce,r),Rt(t,Te,i),Rt(t,oe,n),Rt(t,Que,!0)}function UE(t,e,r="iso8601",n=1972){let i=_e("%Temporal.PlainMonthDay%"),o=Po(i.prototype);return mle(o,t,e,r,n),o}function yle(t,e,r,n,i){Gl(e,r,i),function(s,a){ro(s,NT,jT),s===NT?ro(a,4,12):s===jT&&ro(a,1,9)}(e,r),Zl(t),Rt(t,Te,e),Rt(t,ke,r),Rt(t,Ce,i),Rt(t,oe,n),Rt(t,Xue,!0)}function qE(t,e,r="iso8601",n=1){let i=_e("%Temporal.PlainYearMonth%"),o=Po(i.prototype);return yle(o,t,e,r,n),o}function gle(t,e,r,n){Ag(e),Zl(t),Rt(t,dt,e),Rt(t,Nr,r),Rt(t,oe,n);let i=new(_e("%Temporal.Instant%"))(R(t,dt));Rt(t,To,i)}function eo(t,e,r="iso8601"){let n=_e("%Temporal.ZonedDateTime%"),i=Po(n.prototype);return gle(i,t,e,r),i}function Qn(t,e){if(typeof t=="string"){let i=new(_e("%Temporal.Calendar%"))(t);return Ge(_e("%Temporal.Calendar.prototype.fields%"),i,[e])}let r=Ge(kr(t,"fields"),t,[e]),n=[];for(let i of r){if(typeof i!="string")throw new TypeError("bad return from calendar.fields()");ole.call(n,i)}return n}function Dg(t,e,r){if(typeof t=="string"){let i=new(_e("%Temporal.Calendar%"))(t);return Ge(_e("%Temporal.Calendar.prototype.mergeFields%"),i,[e,r])}let n=Ge(kr(t,"mergeFields"),t,[e,r]);if(!an(n))throw new TypeError("bad return from calendar.mergeFields()");return n}function to(t,e,r,n,i){let o=i;if(typeof t=="string"){let a=new(_e("%Temporal.Calendar%"))(t);return Ge(_e("%Temporal.Calendar.prototype.dateAdd%"),a,[e,r,n])}o===void 0&&(o=kr(t,"dateAdd"));let s=QT(o,t,[e,r,n]);if(!Ht(s))throw new TypeError("invalid result");return s}function Rm(t,e,r,n,i){let o=i;if(typeof t=="string"){let a=new(_e("%Temporal.Calendar%"))(t);return Ge(_e("%Temporal.Calendar.prototype.dateUntil%"),a,[e,r,n])}o===void 0&&(o=kr(t,"dateUntil"));let s=QT(o,t,[e,r,n]);if(!Pn(s))throw new TypeError("invalid result");return s}function tI(t,e){if(typeof t=="string"){let n=new(_e("%Temporal.Calendar%"))(t);return Ge(_e("%Temporal.Calendar.prototype.year%"),n,[e])}let r=Ge(kr(t,"year"),t,[e]);if(typeof r!="number")throw new TypeError("calendar year result must be an integer");if(!qa(r))throw new RangeError("calendar year result must be an integer");return r}function rI(t,e){if(typeof t=="string"){let n=new(_e("%Temporal.Calendar%"))(t);return Ge(_e("%Temporal.Calendar.prototype.month%"),n,[e])}let r=Ge(kr(t,"month"),t,[e]);if(typeof r!="number")throw new TypeError("calendar month result must be a positive integer");if(!qa(r)||r<1)throw new RangeError("calendar month result must be a positive integer");return r}function i6(t,e){if(typeof t=="string"){let n=new(_e("%Temporal.Calendar%"))(t);return Ge(_e("%Temporal.Calendar.prototype.monthCode%"),n,[e])}let r=Ge(kr(t,"monthCode"),t,[e]);if(typeof r!="string")throw new TypeError("calendar monthCode result must be a string");return r}function o6(t,e){if(typeof t=="string"){let n=new(_e("%Temporal.Calendar%"))(t);return Ge(_e("%Temporal.Calendar.prototype.day%"),n,[e])}let r=Ge(kr(t,"day"),t,[e]);if(typeof r!="number")throw new TypeError("calendar day result must be a positive integer");if(!qa(r)||r<1)throw new RangeError("calendar day result must be a positive integer");return r}function nI(t,e){if(typeof t=="string"){let n=new(_e("%Temporal.Calendar%"))(t);return Ge(_e("%Temporal.Calendar.prototype.era%"),n,[e])}let r=Ge(kr(t,"era"),t,[e]);if(r===void 0)return r;if(typeof r!="string")throw new TypeError("calendar era result must be a string or undefined");return r}function iI(t,e){if(typeof t=="string"){let n=new(_e("%Temporal.Calendar%"))(t);return Ge(_e("%Temporal.Calendar.prototype.eraYear%"),n,[e])}let r=Ge(kr(t,"eraYear"),t,[e]);if(r===void 0)return r;if(typeof r!="number")throw new TypeError("calendar eraYear result must be an integer or undefined");if(!qa(r))throw new RangeError("calendar eraYear result must be an integer or undefined");return r}function yj(t,e){if(typeof t=="string"){let n=new(_e("%Temporal.Calendar%"))(t);return Ge(_e("%Temporal.Calendar.prototype.dayOfWeek%"),n,[e])}let r=Ge(kr(t,"dayOfWeek"),t,[e]);if(typeof r!="number")throw new TypeError("calendar dayOfWeek result must be a positive integer");if(!qa(r)||r<1)throw new RangeError("calendar dayOfWeek result must be a positive integer");return r}function gj(t,e){if(typeof t=="string"){let n=new(_e("%Temporal.Calendar%"))(t);return Ge(_e("%Temporal.Calendar.prototype.dayOfYear%"),n,[e])}let r=Ge(kr(t,"dayOfYear"),t,[e]);if(typeof r!="number")throw new TypeError("calendar dayOfYear result must be a positive integer");if(!qa(r)||r<1)throw new RangeError("calendar dayOfYear result must be a positive integer");return r}function vj(t,e){if(typeof t=="string"){let n=new(_e("%Temporal.Calendar%"))(t);return Ge(_e("%Temporal.Calendar.prototype.weekOfYear%"),n,[e])}let r=Ge(kr(t,"weekOfYear"),t,[e]);if(typeof r!="number")throw new TypeError("calendar weekOfYear result must be a positive integer");if(!qa(r)||r<1)throw new RangeError("calendar weekOfYear result must be a positive integer");return r}function bj(t,e){if(typeof t=="string"){let n=new(_e("%Temporal.Calendar%"))(t);return Ge(_e("%Temporal.Calendar.prototype.yearOfWeek%"),n,[e])}let r=Ge(kr(t,"yearOfWeek"),t,[e]);if(typeof r!="number")throw new TypeError("calendar yearOfWeek result must be an integer");if(!qa(r))throw new RangeError("calendar yearOfWeek result must be an integer");return r}function wj(t,e){if(typeof t=="string"){let n=new(_e("%Temporal.Calendar%"))(t);return Ge(_e("%Temporal.Calendar.prototype.daysInWeek%"),n,[e])}let r=Ge(kr(t,"daysInWeek"),t,[e]);if(typeof r!="number")throw new TypeError("calendar daysInWeek result must be a positive integer");if(!qa(r)||r<1)throw new RangeError("calendar daysInWeek result must be a positive integer");return r}function oI(t,e){if(typeof t=="string"){let n=new(_e("%Temporal.Calendar%"))(t);return Ge(_e("%Temporal.Calendar.prototype.daysInMonth%"),n,[e])}let r=Ge(kr(t,"daysInMonth"),t,[e]);if(typeof r!="number")throw new TypeError("calendar daysInMonth result must be a positive integer");if(!qa(r)||r<1)throw new RangeError("calendar daysInMonth result must be a positive integer");return r}function sI(t,e){if(typeof t=="string"){let n=new(_e("%Temporal.Calendar%"))(t);return Ge(_e("%Temporal.Calendar.prototype.daysInYear%"),n,[e])}let r=Ge(kr(t,"daysInYear"),t,[e]);if(typeof r!="number")throw new TypeError("calendar daysInYear result must be a positive integer");if(!qa(r)||r<1)throw new RangeError("calendar daysInYear result must be a positive integer");return r}function aI(t,e){if(typeof t=="string"){let n=new(_e("%Temporal.Calendar%"))(t);return Ge(_e("%Temporal.Calendar.prototype.monthsInYear%"),n,[e])}let r=Ge(kr(t,"monthsInYear"),t,[e]);if(typeof r!="number")throw new TypeError("calendar monthsInYear result must be a positive integer");if(!qa(r)||r<1)throw new RangeError("calendar monthsInYear result must be a positive integer");return r}function cI(t,e){if(typeof t=="string"){let n=new(_e("%Temporal.Calendar%"))(t);return Ge(_e("%Temporal.Calendar.prototype.inLeapYear%"),n,[e])}let r=Ge(kr(t,"inLeapYear"),t,[e]);if(typeof r!="boolean")throw new TypeError("calendar inLeapYear result must be a boolean");return r}function la(t){if(an(t)){if(Pi(t,oe))return R(t,oe);if(!function(i){return!!In(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=os(t);if(Ph(e))return Jl(e);let r;try{({calendar:r}=Xl(e))}catch{try{({calendar:r}=pj(e))}catch{({calendar:r}=mj(e))}}if(r||(r="iso8601"),!Ph(r))throw new RangeError(`invalid calendar identifier ${r}`);return Jl(r)}function s6(t){if(Pi(t,oe))return R(t,oe);let{calendar:e}=t;return e===void 0?"iso8601":la(e)}function no(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 v1(t){return an(t)?t:new(_e("%Temporal.Calendar%"))(t)}function a6(t,e){return t===e?!0:no(t)===no(e)}function dI(t,e,r){if(t===e)return;let n=no(t),i=no(e);if(n!==i)throw new RangeError(`cannot ${r} of ${n} and ${i} calendars`)}function vle(t,e){if(t===e)return e;let r=no(t),n=no(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(_e("%Temporal.Calendar%"))(t);return Ge(_e("%Temporal.Calendar.prototype.dateFromFields%"),o,[e,r])}let i=Ge(n??kr(t,"dateFromFields"),t,[e,r]);if(!Ht(i))throw new TypeError("invalid result");return i}function Og(t,e,r){if(typeof t=="string"){let i=new(_e("%Temporal.Calendar%"))(t);return Ge(_e("%Temporal.Calendar.prototype.yearMonthFromFields%"),i,[e,r])}let n=Ge(kr(t,"yearMonthFromFields"),t,[e,r]);if(!Sr(n))throw new TypeError("invalid result");return n}function d1(t,e,r){if(typeof t=="string"){let i=new(_e("%Temporal.Calendar%"))(t);return Ge(_e("%Temporal.Calendar.prototype.monthDayFromFields%"),i,[e,r])}let n=Ge(kr(t,"monthDayFromFields"),t,[e,r]);if(!Ti(n))throw new TypeError("invalid result");return n}function Io(t){if(an(t)){if(Le(t))return R(t,Nr);if(!function(r){return!!_c(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 GLe(os(t))}function LE(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 ble(t){return an(t)?t:new(_e("%Temporal.TimeZone%"))(t)}function wle(t,e){return t===e?!0:LE(t)===LE(e)}function u1(t){return Ac(R(t,Te),R(t,ke),R(t,Ce),R(t,oe))}function _j(t){return new(_e("%Temporal.PlainTime%"))(R(t,wt),R(t,_t),R(t,xt),R(t,Et),R(t,St),R(t,At))}function Pu(t,e,r){if(typeof t=="string"){let i=new(_e("%Temporal.TimeZone%"))(t);return Ge(_e("%Temporal.TimeZone.prototype.getOffsetNanosecondsFor%"),i,[e])}let n=Ge(r??kr(t,"getOffsetNanosecondsFor"),t,[e]);if(typeof n!="number")throw new TypeError("bad return from getOffsetNanosecondsFor");if(!qa(n)||sn(n)>=864e11)throw new RangeError("out-of-range return from getOffsetNanosecondsFor");return n}function qN(t,e){return lI(Pu(t,e))}function Ua(t,e,r){let n=R(e,dt),i=Pu(t,e),{year:o,month:s,day:a,hour:d,minute:u,second:c,millisecond:l,microsecond:m,nanosecond:p}=Ele(n);return{year:o,month:s,day:a,hour:d,minute:u,second:c,millisecond:l,microsecond:m,nanosecond:p}=Ej(o,s,a,d,u,c,l,m,p+i),aa(o,s,a,d,u,c,l,m,p,r)}function is(t,e,r){return _le(VT(t,e),t,e,r)}function _le(t,e,r,n){let i=_e("%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,ke),d=R(r,Ce),u=R(r,wt),c=R(r,_t),l=R(r,xt),m=R(r,Et),p=R(r,St),g=R(r,At),v=Mm(s,a,d,u,c,l,m,p,g);if(v===null)throw new RangeError("DateTime outside of supported range");let E=new i(z.default.subtract(v,Wl)),A=new i(z.default.add(v,Wl)),P=Pu(e,E),I=Pu(e,A)-P;switch(n){case"earlier":{let $=R(r,oe),N=_e("%Temporal.PlainDateTime%"),K=zN(s,a,d,u,c,l,m,p,g,$,0,0,0,0,0,0,0,0,0,-I,void 0);return VT(e,new N(K.year,K.month,K.day,K.hour,K.minute,K.second,K.millisecond,K.microsecond,K.nanosecond,$))[0]}case"compatible":case"later":{let $=R(r,oe),N=_e("%Temporal.PlainDateTime%"),K=zN(s,a,d,u,c,l,m,p,g,$,0,0,0,0,0,0,0,0,0,I,void 0),F=VT(e,new N(K.year,K.month,K.day,K.hour,K.minute,K.second,K.millisecond,K.microsecond,K.nanosecond,$));return F[F.length-1]}case"reject":throw new RangeError("no such instant found")}}function VT(t,e,r){if(typeof t=="string"){let o=new(_e("%Temporal.TimeZone%"))(t);return Ge(_e("%Temporal.TimeZone.prototype.getPossibleInstantsFor%"),o,[e])}let n=Ge(r??kr(t,"getPossibleInstantsFor"),t,[e]),i=[];for(let o of n){if(!hi(o))throw new TypeError("bad return from getPossibleInstantsFor");ole.call(i,o)}return i}function jg(t){let e;return t<0||t>9999?e=(t<0?"-":"+")+`000000${sn(t)}`.slice(-6):e=`0000${t}`.slice(-4),e}function yn(t){return`00${t}`.slice(-2)}function uI(t,e,r,n,i){if(i==="minute")return"";let o=`:${yn(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 Tue(t,e,r){let n=e;n===void 0&&(n="UTC");let i=Ua(n,t,"iso8601"),o=jg(R(i,Te)),s=yn(R(i,ke)),a=yn(R(i,Ce)),d=yn(R(i,wt)),u=yn(R(i,_t)),c=uI(R(i,xt),R(i,Et),R(i,St),R(i,At),r),l="Z";return e!==void 0&&(l=xle(Pu(n,t))),`${o}-${s}-${a}T${d}:${u}${c}${l}`}function RN(t,e="auto",r){function n(V){return V<=qLe?V.toString(10):z.default.BigInt(V).toString(10)}let i=R(t,Jo),o=R(t,ji),s=R(t,Cs),a=R(t,Yo),d=R(t,Zo),u=R(t,Xo),c=R(t,Qo),l=R(t,es),m=R(t,ts),p=R(t,rs),g=Hl(i,o,s,a,d,u,c,l,m,p);if(r){let{unit:V,increment:L,roundingMode:T}=r;({seconds:c,milliseconds:l,microseconds:m,nanoseconds:p}=Ih(0,0,0,0,0,0,c,l,m,p,L,V,T))}let v=[];i&&v.push(`${n(sn(i))}Y`),o&&v.push(`${n(sn(o))}M`),s&&v.push(`${n(sn(s))}W`),a&&v.push(`${n(sn(a))}D`);let E=[];d&&E.push(`${n(sn(d))}H`),u&&E.push(`${n(sn(u))}M`);let A=[],P,I,$,N,K=l1(0,0,0,c,l,m,p,0);({quotient:K,remainder:P}=Fn(K,Ar)),{quotient:K,remainder:I}=Fn(K,Ar),{quotient:N,remainder:$}=Fn(K,Ar);let F=1e6*sn(z.default.toNumber($))+1e3*sn(z.default.toNumber(I))+sn(z.default.toNumber(P)),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,Rn)&&!A.length&&e==="auto"||A.unshift(Au(N).toString()),A.length&&E.push(`${A.join("")}S`),E.length&&E.unshift("T"),v.length||E.length?`${g<0?"-":""}P${v.join("")}${E.join("")}`:"PT0S"}function Iue(t,e="auto"){return`${jg(R(t,Te))}-${yn(R(t,ke))}-${yn(R(t,Ce))}${fj(R(t,oe),e)}`}function Pue(t,e,r="auto",n){let i=R(t,Te),o=R(t,ke),s=R(t,Ce),a=R(t,wt),d=R(t,_t),u=R(t,xt),c=R(t,Et),l=R(t,St),m=R(t,At);if(n){let{unit:p,increment:g,roundingMode:v}=n;({year:i,month:o,day:s,hour:a,minute:d,second:u,millisecond:c,microsecond:l,nanosecond:m}=kj(i,o,s,a,d,u,c,l,m,g,p,v))}return`${jg(i)}-${yn(o)}-${yn(s)}T${yn(a)}:${yn(d)}${uI(u,c,l,m,e)}${fj(R(t,oe),r)}`}function kue(t,e="auto"){let r=`${yn(R(t,ke))}-${yn(R(t,Ce))}`,n=no(R(t,oe));(e==="always"||e==="critical"||n!=="iso8601")&&(r=`${jg(R(t,Te))}-${r}`);let i=hj(n,e);return i&&(r+=i),r}function Rue(t,e="auto"){let r=`${jg(R(t,Te))}-${yn(R(t,ke))}`,n=no(R(t,oe));(e==="always"||e==="critical"||n!=="iso8601")&&(r+=`-${yn(R(t,Ce))}`);let i=hj(n,e);return i&&(r+=i),r}function Bue(t,e,r="auto",n="auto",i="auto",o){let s=R(t,To);if(o){let{unit:c,increment:l,roundingMode:m}=o,p=GT(R(t,dt),l,c,m);s=new(_e("%Temporal.Instant%"))(p)}let a=R(t,Nr),d=Ua(a,s,"iso8601"),u=`${jg(R(d,Te))}-${yn(R(d,ke))}-${yn(R(d,Ce))}T${yn(R(d,wt))}:${yn(R(d,_t))}${uI(R(d,xt),R(d,Et),R(d,St),R(d,At),e)}`;return i!=="never"&&(u+=xle(Pu(a,s))),n!=="never"&&(u+=`[${n==="critical"?"!":""}${LE(a)}]`),u+=fj(R(t,oe),r),u}function Zw(t){return jle.test(XE(t))}function Bm(t){let e=jle.exec(XE(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 xj(t){return Zw(t)?lI(Bm(t)):fle(XE(t)).resolvedOptions().timeZone}function Eh(t,e){let{year:r,month:n,day:i,hour:o,minute:s,second:a,millisecond:d,microsecond:u,nanosecond:c}=Sle(t,e),l=r%400,m=(r-l)/400,p=z.default.multiply(z.default.BigInt(146097),Wl),g=Mm(l,n,i,o,s,a,d,u,c),v=z.default.add(g,z.default.multiply(p,z.default.BigInt(m)));return z.default.toNumber(z.default.subtract(v,e))}function lI(t){let e=t<0?"-":"+",r=sn(t),n=r%1e9,i=da(r/1e9)%60,o=da(r/6e10)%60,s=yn(da(r/36e11)),a=yn(o),d=yn(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 xle(t){let e=z.default.toNumber(ja(z.default.BigInt(t),dle,"halfExpand")),r=e<0?"-":"+";e=sn(e);let n=e/6e10%60;return`${r}${yn(da(e/36e11))}:${yn(n)}`}function Mm(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(XT(c))return null;let l=z.default.multiply(z.default.BigInt(c),Ec);return l=z.default.add(l,z.default.multiply(z.default.BigInt(a),Ar)),l=z.default.add(l,z.default.BigInt(d)),z.default.lessThan(l,jE)||z.default.greaterThan(l,s1)?null:l}function Ele(t){let{quotient:e,remainder:r}=Fn(t,Ec),n=z.default.toNumber(e),i=z.default.toNumber(r);i<0&&(i+=1e6,n-=1);let o=da(i/1e3)%1e3,s=i%1e3,a=new Date(n);return{epochMilliseconds:n,year:a.getUTCFullYear(),month:a.getUTCMonth()+1,day:a.getUTCDate(),hour:a.getUTCHours(),minute:a.getUTCMinutes(),second:a.getUTCSeconds(),millisecond:a.getUTCMilliseconds(),microsecond:o,nanosecond:s}}function Sle(t,e){let{epochMilliseconds:r,millisecond:n,microsecond:i,nanosecond:o}=Ele(e),{year:s,month:a,day:d,hour:u,minute:c,second:l}=function(p,g){let v=fle(p).format(new Date(g));return function(A){let P=A.split(/[^\w]+/);if(P.length!==7)throw new RangeError(`expected 7 parts in "${A}`);let I=+P[0],$=+P[1],N=+P[2],K=P[3].toUpperCase();if(K==="B"||K==="BC")N=1-N;else if(K!=="A"&&K!=="AD")throw new RangeError(`Unknown era ${K} in "${A}`);let F=+P[4];F===24&&(F=0);let U=+P[5],V=+P[6];if(!(ns(N)&&ns(I)&&ns($)&&ns(F)&&ns(U)&&ns(V)))throw new RangeError(`Invalid number in "${A}`);return{year:N,month:I,day:$,hour:F,minute:U,second:V}}(v)}(t,r);return Ej(s,a,d,u,c,l,n,i,o)}function Mue(t,e){return z.default.lessThan(t,e)?e:t}function Ale(){return z.default.add(Bj(),zLe)}function Tle(t,e){if(z.default.lessThan(e,Xw))return Tle(t,Xw);let r=z.default.add(e,ule),n=Mue(Ale(),r),i=Mue(Xw,e),o=Eh(t,i),s=i,a=o;for(;o===a&&z.default.lessThan(z.default.BigInt(i),n);){if(s=z.default.add(i,lle),z.default.greaterThan(s,s1))return null;a=Eh(t,s),o===a&&(i=s)}return o===a?null:Ule(d=>Eh(t,d),i,s,o,a)}function LN(t,e){let r=Ale(),n=z.default.greaterThan(e,r),i=n?z.default.subtract(e,ule):Xw;if(t==="Africa/Casablanca"||t==="Africa/El_Aaiun"){let u=R(Tu("2088-01-01T00Z"),dt);if(z.default.lessThan(u,e))return LN(t,u)}let o=z.default.subtract(e,p1);if(z.default.lessThan(o,Xw))return null;let s=Eh(t,o),a=o,d=s;for(;s===d&&z.default.greaterThan(o,i);){if(a=z.default.subtract(o,lle),z.default.lessThan(a,Xw))return null;d=Eh(t,a),s===d&&(o=a)}if(s===d){if(n){let u=z.default.subtract(r,Wl);return LN(t,u)}return null}return Ule(u=>Eh(t,u),a,o,d,s)}function Dm(t){return t===void 0?!1:t%4==0&&(t%100!=0||t%400==0)}function Sh(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]}[Dm(t)?"leapyear":"standard"][e-1]}function KN(t,e,r){let n=e+(e<3?10:-2),i=t-(e<3?1:0),o=da(i/100),s=i-100*o,a=(r+da(2.6*n-.2)+(s+da(s/4))+(da(o/4)-2*o))%7;return a+(a<=0?7:0)}function HT(t,e,r){let n=r;for(let i=e-1;i>0;i--)n+=Sh(t,i);return n}function Due(t,e,r){let n=HT(t,e,r),i=KN(t,e,r)||7,o=KN(t,1,1),s=da((n-i+10)/7);return s<1?o===5||o===6&&Dm(t-1)?{week:53,year:t-1}:{week:52,year:t-1}:s===53&&(Dm(t)?366:365)-n<4-i?{week:1,year:t+1}:{week:s,year:t}}function Hl(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 DT(t,e){let r=t,n=e;if(!ns(r)||!ns(n))throw new RangeError("infinity is out of range");return n-=1,r+=da(n/12),n%=12,n<0&&(n+=12),n+=1,{year:r,month:n}}function fI(t,e,r){let n=t,i=e,o=r;if(!ns(o))throw new RangeError("infinity is out of range");({year:n,month:i}=DT(n,i));let s=146097;if(sn(o)>s){let u=Tg(o/s);n+=400*u,o-=u*s}let a=0,d=i>2?n:n-1;for(;a=Dm(d)?366:365,o<-a;)n-=1,d-=1,o+=a;for(d+=1;a=Dm(d)?366:365,o>a;)n+=1,d+=1,o-=a;for(;o<1;)({year:n,month:i}=DT(n,i-1)),o+=Sh(n,i);for(;o>Sh(n,i);)o-=Sh(n,i),{year:n,month:i}=DT(n,i+1);return{year:n,month:i,day:o}}function Ej(t,e,r,n,i,o,s,a,d){let{deltaDays:u,hour:c,minute:l,second:m,millisecond:p,microsecond:g,nanosecond:v}=_h(n,i,o,s,a,d),{year:E,month:A,day:P}=fI(t,e,r+u);return{year:E,month:A,day:P,hour:c,minute:l,second:m,millisecond:p,microsecond:g,nanosecond:v}}function _h(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}=Sg(m,Ar),l=z.default.add(l,s),{quotient:s,remainder:l}=Sg(l,Ar),c=z.default.add(c,s),{quotient:s,remainder:c}=Sg(c,Ar),u=z.default.add(u,s),{quotient:s,remainder:u}=Sg(u,zl),d=z.default.add(d,s),{quotient:s,remainder:d}=Sg(d,zl),a=z.default.add(a,s),{quotient:s,remainder:a}=Sg(a,ale),{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 l1(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,zl)),m=z.default.add(z.default.BigInt(n),z.default.multiply(l,zl)),p=z.default.add(z.default.BigInt(i),z.default.multiply(m,Ar)),g=z.default.add(z.default.BigInt(o),z.default.multiply(p,Ar));return z.default.add(z.default.BigInt(u),z.default.multiply(g,Ar))}function Sj(t,e){let r=_e("%Temporal.Instant%"),n=o1(z.default.toNumber(t)),i=z.default.BigInt(t),o=864e11;if(n===0)return{days:0,nanoseconds:Rn,dayLengthNs:o};if(!Le(e)){let I;return{quotient:I,remainder:i}=Fn(i,z.default.BigInt(o)),{days:z.default.toNumber(I),nanoseconds:i,dayLengthNs:o}}let s=R(e,dt),a=R(e,To),d=z.default.add(s,i),u=new r(d),c=R(e,Nr),l=R(e,oe),m=Ua(c,a,l),p=Ua(c,u,l),{days:g}=Pj(R(m,Te),R(m,ke),R(m,Ce),R(m,wt),R(m,_t),R(m,xt),R(m,Et),R(m,St),R(m,At),R(p,Te),R(p,ke),R(p,Ce),R(p,wt),R(p,_t),R(p,xt),R(p,Et),R(p,St),R(p,At),l,"day",Po(null)),v=Sc(a,c,l,0,0,0,g,0,0,0,0,0,0),E=z.default.BigInt(g);if(n===1)for(;z.default.greaterThan(E,Rn)&&z.default.greaterThan(v,d);)E=z.default.subtract(E,p1),v=Sc(a,c,l,0,0,0,z.default.toNumber(E),0,0,0,0,0,0);i=z.default.subtract(d,v);let A=!1,P=new r(v);do{let I=Sc(P,c,l,0,0,0,n,0,0,0,0,0,0),$=R(P,dt);o=z.default.toNumber(z.default.subtract(I,$)),A=z.default.greaterThanOrEqual(z.default.multiply(z.default.subtract(i,z.default.BigInt(o)),z.default.BigInt(n)),Rn),A&&(i=z.default.subtract(i,z.default.BigInt(o)),P=new r(I),E=z.default.add(E,z.default.BigInt(n)))}while(A);if(!xc(E)&&bue(E)!==n)throw new RangeError("Time zone or calendar converted nanoseconds into a number of days with the opposite sign");if(!xc(i)&&bue(i)!==n)throw UT(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(Au(i),Au(z.default.BigInt(o))))throw new Error("assert not reached");return{days:z.default.toNumber(E),nanoseconds:i,dayLengthNs:sn(o)}}function Td(t,e,r,n,i,o,s,a,d){let u=Ile(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 Ile(t,e,r,n,i,o,s,a,d){let u,c,l,m,p,g,v=t;if(Le(d)){let F=Sc(R(d,To),R(d,Nr),R(d,oe),0,0,0,v,e,r,n,i,o,s),U=R(d,dt);u=z.default.subtract(F,U)}else u=l1(v,e,r,n,i,o,s,0);a==="year"||a==="month"||a==="week"||a==="day"?{days:v,nanoseconds:u}=Sj(u,d):v=0;let E=z.default.lessThan(u,Rn)?-1:1;switch(u=Au(u),c=l=m=p=g=Rn,a){case"year":case"month":case"week":case"day":case"hour":({quotient:c,remainder:u}=Fn(u,Ar)),{quotient:l,remainder:c}=Fn(c,Ar),{quotient:m,remainder:l}=Fn(l,Ar),{quotient:p,remainder:m}=Fn(m,zl),{quotient:g,remainder:p}=Fn(p,zl);break;case"minute":({quotient:c,remainder:u}=Fn(u,Ar)),{quotient:l,remainder:c}=Fn(c,Ar),{quotient:m,remainder:l}=Fn(l,Ar),{quotient:p,remainder:m}=Fn(m,zl);break;case"second":({quotient:c,remainder:u}=Fn(u,Ar)),{quotient:l,remainder:c}=Fn(c,Ar),{quotient:m,remainder:l}=Fn(l,Ar);break;case"millisecond":({quotient:c,remainder:u}=Fn(u,Ar)),{quotient:l,remainder:c}=Fn(c,Ar);break;case"microsecond":({quotient:c,remainder:u}=Fn(u,Ar));break;case"nanosecond":break;default:throw new Error("assert not reached")}let A=z.default.toNumber(g)*E,P=z.default.toNumber(p)*E,I=z.default.toNumber(m)*E,$=z.default.toNumber(l)*E,N=z.default.toNumber(c)*E,K=z.default.toNumber(u)*E;for(let F of[v,A,P,I,$,N,K])if(!ns(F))return E===1?"positive overflow":"negative overflow";return{days:v,hours:A,minutes:P,seconds:I,milliseconds:$,microseconds:N,nanoseconds:K}}function BT(t,e,r,n,i,o){let s=_e("%Temporal.Duration%"),a=Hl(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,oe));let v=new s(a),E=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 P,I;for(typeof u!="string"&&(P=kr(u,"dateAdd"),I=kr(u,"dateUntil"));!xc(l);){let $=to(u,c,v,void 0,P),N=Po(null);N.largestUnit="month";let K=Rm(u,c,$,N,I),F=z.default.BigInt(R(K,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 P=typeof u!="string"?kr(u,"dateAdd"):void 0;for(;!xc(l);){let I;({relativeTo:c,days:I}=Ao(u,c,v,P)),g=z.default.add(g,z.default.BigInt(I)),l=z.default.subtract(l,d)}for(;!xc(m);){let I;({relativeTo:c,days:I}=Ao(u,c,E,P)),g=z.default.add(g,z.default.BigInt(I)),m=z.default.subtract(m,d)}break}default:{if(xc(l)&&xc(m)&&xc(p))break;if(!u)throw new RangeError("a starting point is required for balancing calendar units");let P=typeof u!="string"?kr(u,"dateAdd"):void 0;for(;!xc(l);){let I;({relativeTo:c,days:I}=Ao(u,c,v,P)),g=z.default.add(g,z.default.BigInt(I)),l=z.default.subtract(l,d)}for(;!xc(m);){let I;({relativeTo:c,days:I}=Ao(u,c,E,P)),g=z.default.add(g,z.default.BigInt(I)),m=z.default.subtract(m,d)}for(;!xc(p);){let I;({relativeTo:c,days:I}=Ao(u,c,A,P)),g=z.default.add(g,z.default.BigInt(I)),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 Oue(t,e,r,n,i){if(Le(t)){let o=R(t,To),s=R(t,Nr),a=R(t,oe),d=Pu(s,o),u=Sc(o,s,a,e,r,n,i,0,0,0,0,0,0);return Pu(s,new(_e("%Temporal.Instant%"))(u))-d}return 0}function Ple(t){return new(_e("%Temporal.Duration%"))(-R(t,Jo),-R(t,ji),-R(t,Cs),-R(t,Yo),-R(t,Zo),-R(t,Xo),-R(t,Qo),-R(t,es),-R(t,ts),-R(t,rs))}function ca(t,e,r){return NLe(r,jLe(e,t))}function kle(t,e,r){let n=ca(e,1,12);return{year:t,month:n,day:ca(r,1,Sh(t,n))}}function ro(t,e,r){if(t<e||t>r)throw new RangeError(`value out of range: ${e} <= ${t} <= ${r}`)}function Gl(t,e,r){ro(e,1,12),ro(r,1,Sh(t,e))}function Rle(t,e,r){Ble(t,e,r,12,0,0,0,0,0)}function hI(t,e,r,n,i,o){ro(t,0,23),ro(e,0,59),ro(r,0,59),ro(n,0,999),ro(i,0,999),ro(o,0,999)}function Aj(t,e,r,n,i,o,s,a,d){Gl(t,e,r),hI(n,i,o,s,a,d)}function Ble(t,e,r,n,i,o,s,a,d){if(ro(t,NT,jT),t===NT&&Mm(t,e,r+1,n,i,o,s,a,d-1)==null||t===jT&&Mm(t,e,r-1,n,i,o,s,a,d+1)==null)throw new RangeError("DateTime outside of supported range")}function Ag(t){if(z.default.lessThan(t,jE)||z.default.greaterThan(t,s1))throw new RangeError("Instant outside of supported range")}function WT(t,e,r,n,i,o,s,a,d,u){let c=Hl(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(!ns(l))throw new RangeError("infinite values not allowed as duration fields");let m=o1(l);if(m!==0&&m!==c)throw new RangeError("mixed-sign values not allowed as duration fields")}}function Tj(t,e,r,n,i,o,s){switch(s){case"year":case"month":{let a=-km(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=Pg(t,e,r,c,0,0,0,"constrain"),m=-km(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=Pg(t,e,r,c,p,0,0,"constrain"),m=-km(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=Pg(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-(Sh(u.year,u.month)-u.day):u.day+(Sh(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;km(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=HT(a.year,a.month,a.day)-HT(d.year,d.month,d.day);for(let m=d.year;m<a.year;++m)c+=Dm(m)?366:365;let l=0;return s==="week"&&(l=da(c/7),c%=7),l*=u,c*=u,{years:0,months:0,weeks:l,days:c}}default:throw new Error("assert not reached")}}function Mle(t,e,r,n,i,o,s,a,d,u,c,l){let m=s-t,p=a-e,g=d-r,v=u-n,E=c-i,A=l-o,P=Hl(0,0,0,0,m,p,g,v,E,A);m*=P,p*=P,g*=P,v*=P,E*=P,A*=P;let I=0;if({deltaDays:I,hour:m,minute:p,second:g,millisecond:v,microsecond:E,nanosecond:A}=_h(m,p,g,v,E,A),I!=0)throw new Error("assertion failure in DifferenceTime: _bt_.[[Days]] should be 0");return m*=P,p*=P,g*=P,v*=P,E*=P,A*=P,{hours:m,minutes:p,seconds:g,milliseconds:v,microseconds:E,nanoseconds:A}}function Ij(t,e,r,n,i,o){let s=z.default.subtract(e,t),a=0,d=0,u=z.default.toNumber(z.default.remainder(s,Ar)),c=z.default.toNumber(z.default.remainder(z.default.divide(s,Ar),Ar)),l=z.default.toNumber(z.default.remainder(z.default.divide(s,Ec),Ar)),m=z.default.toNumber(z.default.divide(s,Vl));return{hours:a,minutes:d,seconds:m,milliseconds:l,microseconds:c,nanoseconds:u}=Ih(0,0,0,0,0,0,m,l,c,u,r,n,o),Td(0,a,d,m,l,c,u,i)}function Pj(t,e,r,n,i,o,s,a,d,u,c,l,m,p,g,v,E,A,P,I,$){let N=t,K=e,F=r,{hours:U,minutes:V,seconds:L,milliseconds:T,microseconds:S,nanoseconds:k}=Mle(n,i,o,s,a,d,m,p,g,v,E,A),f=Hl(0,0,0,0,U,V,L,T,S,k);km(u,c,l,N,K,F)===-f&&({year:N,month:K,day:F}=fI(N,K,F-f),{hours:U,minutes:V,seconds:L,milliseconds:T,microseconds:S,nanoseconds:k}=Td(-f,U,V,L,T,S,k,I));let y=Ac(N,K,F,P),w=Ac(u,c,l,P),_=Mg("day",I),x=jm($);x.largestUnit=_;let{years:b,months:B,weeks:q,days:M}=Rm(P,y,w,x);return{days:M,hours:U,minutes:V,seconds:L,milliseconds:T,microseconds:S,nanoseconds:k}=Td(M,U,V,L,T,S,k,I),{years:b,months:B,weeks:q,days:M,hours:U,minutes:V,seconds:L,milliseconds:T,microseconds:S,nanoseconds:k}}function Dle(t,e,r,n,i,o){let s=z.default.subtract(e,t);if(z.default.equal(s,Rn))return{years:0,months:0,weeks:0,days:0,hours:0,minutes:0,seconds:0,milliseconds:0,microseconds:0,nanoseconds:0};let a=_e("%Temporal.Instant%"),d=new a(t),u=new a(e),c=Ua(r,d,n),l=Ua(r,u,n),{years:m,months:p,weeks:g,days:v}=Pj(R(c,Te),R(c,ke),R(c,Ce),R(c,wt),R(c,_t),R(c,xt),R(c,Et),R(c,St),R(c,At),R(l,Te),R(l,ke),R(l,Ce),R(l,wt),R(l,_t),R(l,xt),R(l,Et),R(l,St),R(l,At),n,i,o),E=Sc(d,r,n,m,p,g,0,0,0,0,0,0,0),A=z.default.subtract(e,E),P=eo(E,r,n);({nanoseconds:A,days:v}=Sj(A,P));let{hours:I,minutes:$,seconds:N,milliseconds:K,microseconds:F,nanoseconds:U}=Td(0,0,0,0,0,0,z.default.toNumber(A),"hour");return{years:m,months:p,weeks:g,days:v,hours:I,minutes:$,seconds:N,milliseconds:K,microseconds:F,nanoseconds:U}}function b1(t,e,r,n,i,o){let s=QE.reduce((p,g)=>{let v=g[0],E=g[1],A=g[2];return r!=="datetime"&&A!==r||n.includes(E)||p.push(E,v),p},[]),a=ua(e,"largestUnit",r,"auto");if(n.includes(a))throw new RangeError(`largestUnit must be one of ${s.join(", ")}, not ${a}`);let d=y1(e),u=Iu(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=ua(e,"smallestUnit",r,i);if(n.includes(c))throw new RangeError(`smallestUnit must be one of ${s.join(", ")}, not ${c}`);let l=Mg(o,c);if(a==="auto"&&(a=l),Mg(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&&g1(d,m,!1),{largestUnit:a,roundingIncrement:d,roundingMode:u,smallestUnit:c}}function Cue(t,e,r,n){let i=t==="since"?-1:1,o=Tu(r),s=b1(t,jm(n),"time",[],"nanosecond","second"),a=R(e,dt),d=R(o,dt),{hours:u,minutes:c,seconds:l,milliseconds:m,microseconds:p,nanoseconds:g}=Ij(a,d,s.roundingIncrement,s.smallestUnit,s.largestUnit,s.roundingMode);return new(_e("%Temporal.Duration%"))(0,0,0,0,i*u,i*c,i*l,i*m,i*p,i*g)}function $ue(t,e,r,n){let i=t==="since"?-1:1,o=Ur(r),s=R(e,oe);dI(s,R(o,oe),"compute difference between dates");let a=jm(n),d=b1(t,a,"date",[],"day","day");a.largestUnit=d.largestUnit;let{years:u,months:c,weeks:l,days:m}=Rm(s,e,o,a);return d.smallestUnit==="day"&&d.roundingIncrement===1||({years:u,months:c,weeks:l,days:m}=Ih(u,c,l,m,0,0,0,0,0,0,d.roundingIncrement,d.smallestUnit,d.roundingMode,e)),new(_e("%Temporal.Duration%"))(i*u,i*c,i*l,i*m,0,0,0,0,0,0)}function Nue(t,e,r,n){let i=t==="since"?-1:1,o=Ig(r),s=R(e,oe);dI(s,R(o,oe),"compute difference between dates");let a=jm(n),d=b1(t,a,"datetime",[],"nanosecond","day"),{years:u,months:c,weeks:l,days:m,hours:p,minutes:g,seconds:v,milliseconds:E,microseconds:A,nanoseconds:P}=Pj(R(e,Te),R(e,ke),R(e,Ce),R(e,wt),R(e,_t),R(e,xt),R(e,Et),R(e,St),R(e,At),R(o,Te),R(o,ke),R(o,Ce),R(o,wt),R(o,_t),R(o,xt),R(o,Et),R(o,St),R(o,At),s,d.largestUnit,a),I=u1(e);return{years:u,months:c,weeks:l,days:m,hours:p,minutes:g,seconds:v,milliseconds:E,microseconds:A,nanoseconds:P}=Ih(u,c,l,m,p,g,v,E,A,P,d.roundingIncrement,d.smallestUnit,d.roundingMode,I),{days:m,hours:p,minutes:g,seconds:v,milliseconds:E,microseconds:A,nanoseconds:P}=Td(m,p,g,v,E,A,P,d.largestUnit),new(_e("%Temporal.Duration%"))(i*u,i*c,i*l,i*m,i*p,i*g,i*v,i*E,i*A,i*P)}function jue(t,e,r,n){let i=t==="since"?-1:1,o=xh(r),s=b1(t,jm(n),"time",[],"nanosecond","hour"),{hours:a,minutes:d,seconds:u,milliseconds:c,microseconds:l,nanoseconds:m}=Mle(R(e,wt),R(e,_t),R(e,xt),R(e,Et),R(e,St),R(e,At),R(o,wt),R(o,_t),R(o,xt),R(o,Et),R(o,St),R(o,At));return{hours:a,minutes:d,seconds:u,milliseconds:c,microseconds:l,nanoseconds:m}=Ih(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}=Td(0,a,d,u,c,l,m,s.largestUnit),new(_e("%Temporal.Duration%"))(0,0,0,0,i*a,i*d,i*u,i*c,i*l,i*m)}function Uue(t,e,r,n){let i=t==="since"?-1:1,o=OE(r),s=R(e,oe);dI(s,R(o,oe),"compute difference between months");let a=jm(n),d=b1(t,a,"date",["week","day"],"month","year");a.largestUnit=d.largestUnit;let u=Qn(s,["monthCode","year"]),c=Dt(e,u,[]);c.day=1;let l=Th(s,c),m=Dt(o,u,[]);m.day=1;let p=Th(s,m),{years:g,months:v}=Rm(s,l,p,a);return d.smallestUnit==="month"&&d.roundingIncrement===1||({years:g,months:v}=Ih(g,v,0,0,0,0,0,0,0,0,d.roundingIncrement,d.smallestUnit,d.roundingMode,l)),new(_e("%Temporal.Duration%"))(i*g,i*v,0,0,0,0,0,0,0,0)}function que(t,e,r,n){let i=t==="since"?-1:1,o=CE(r),s=R(e,oe);dI(s,R(o,oe),"compute difference between dates");let a=jm(n),d=b1(t,a,"datetime",[],"nanosecond","hour");a.largestUnit=d.largestUnit;let u=R(e,dt),c=R(o,dt),l,m,p,g,v,E,A,P,I,$;if(d.largestUnit!=="year"&&d.largestUnit!=="month"&&d.largestUnit!=="week"&&d.largestUnit!=="day")l=0,m=0,p=0,g=0,{hours:v,minutes:E,seconds:A,milliseconds:P,microseconds:I,nanoseconds:$}=Ij(u,c,d.roundingIncrement,d.smallestUnit,d.largestUnit,d.roundingMode);else{let N=R(e,Nr);if(!wle(N,R(o,Nr)))throw new RangeError("When calculating difference between time zones, largestUnit must be 'hours' or smaller because day lengths can vary between time zones due to DST or time zone offset changes.");({years:l,months:m,weeks:p,days:g,hours:v,minutes:E,seconds:A,milliseconds:P,microseconds:I,nanoseconds:$}=Dle(u,c,N,s,d.largestUnit,a)),{years:l,months:m,weeks:p,days:g,hours:v,minutes:E,seconds:A,milliseconds:P,microseconds:I,nanoseconds:$}=Ih(l,m,p,g,v,E,A,P,I,$,d.roundingIncrement,d.smallestUnit,d.roundingMode,e),{years:l,months:m,weeks:p,days:g,hours:v,minutes:E,seconds:A,milliseconds:P,microseconds:I,nanoseconds:$}=Nle(l,m,p,g,v,E,A,P,I,$,d.roundingIncrement,d.smallestUnit,d.roundingMode,e)}return new(_e("%Temporal.Duration%"))(i*l,i*m,i*p,i*g,i*v,i*E,i*A,i*P,i*I,i*$)}function Pg(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}=DT(d,u),{year:d,month:u,day:c}=LT(d,u,c,a),m+=7*l,c+=m,{year:d,month:u,day:c}=fI(d,u,c),{year:d,month:u,day:c}}function Ole(t,e,r,n,i,o,s,a,d,u,c,l){let m=t,p=e,g=r,v=n,E=i,A=o;m+=s,p+=a,g+=d,v+=u,E+=c,A+=l;let P=0;return{deltaDays:P,hour:m,minute:p,second:g,millisecond:v,microsecond:E,nanosecond:A}=_h(m,p,g,v,E,A),{deltaDays:P,hour:m,minute:p,second:g,millisecond:v,microsecond:E,nanosecond:A}}function Cle(t,e,r,n,i,o,s,a,d,u,c,l,m,p,g,v,E,A,P,I,$){let N=Mg(UN(t,e,r,n,i,o,s,a,d,u),UN(c,l,m,p,g,v,E,A,P,I)),K,F,U,V,L,T,S,k,f,y;if($)if(Ht($)){let w=_e("%Temporal.Duration%"),_=R($,oe),x=new w(t,e,r,n,0,0,0,0,0,0),b=new w(c,l,m,p,0,0,0,0,0,0),B=typeof _!="string"?kr(_,"dateAdd"):void 0,q=to(_,$,x,void 0,B),M=to(_,q,b,void 0,B),j=Mg("day",N),J=Po(null);J.largestUnit=j,{years:K,months:F,weeks:U,days:V}=Rm(_,$,M,J),{days:V,hours:L,minutes:T,seconds:S,milliseconds:k,microseconds:f,nanoseconds:y}=Td(V,z.default.add(z.default.BigInt(i),z.default.BigInt(g)),z.default.add(z.default.BigInt(o),z.default.BigInt(v)),z.default.add(z.default.BigInt(s),z.default.BigInt(E)),z.default.add(z.default.BigInt(a),z.default.BigInt(A)),z.default.add(z.default.BigInt(d),z.default.BigInt(P)),z.default.add(z.default.BigInt(u),z.default.BigInt(I)),N)}else{let w=_e("%Temporal.Instant%"),_=R($,Nr),x=R($,oe),b=Sc(R($,To),_,x,t,e,r,n,i,o,s,a,d,u),B=Sc(new w(b),_,x,c,l,m,p,g,v,E,A,P,I);N!=="year"&&N!=="month"&&N!=="week"&&N!=="day"?(K=0,F=0,U=0,V=0,{hours:L,minutes:T,seconds:S,milliseconds:k,microseconds:f,nanoseconds:y}=Ij(R($,dt),B,1,"nanosecond",N,"halfExpand")):{years:K,months:F,weeks:U,days:V,hours:L,minutes:T,seconds:S,milliseconds:k,microseconds:f,nanoseconds:y}=Dle(R($,dt),B,_,x,N,Po(null))}else{if(N==="year"||N==="month"||N==="week")throw new RangeError("relativeTo is required for years, months, or weeks arithmetic");K=F=U=0,{days:V,hours:L,minutes:T,seconds:S,milliseconds:k,microseconds:f,nanoseconds:y}=Td(n+p,z.default.add(z.default.BigInt(i),z.default.BigInt(g)),z.default.add(z.default.BigInt(o),z.default.BigInt(v)),z.default.add(z.default.BigInt(s),z.default.BigInt(E)),z.default.add(z.default.BigInt(a),z.default.BigInt(A)),z.default.add(z.default.BigInt(d),z.default.BigInt(P)),z.default.add(z.default.BigInt(u),z.default.BigInt(I)),N)}return WT(K,F,U,V,L,T,S,k,f,y),{years:K,months:F,weeks:U,days:V,hours:L,minutes:T,seconds:S,milliseconds:k,microseconds:f,nanoseconds:y}}function FN(t,e,r,n,i,o,s){let a=Rn;a=z.default.add(a,z.default.BigInt(s)),a=z.default.add(a,z.default.multiply(z.default.BigInt(o),Ar)),a=z.default.add(a,z.default.multiply(z.default.BigInt(i),Ec)),a=z.default.add(a,z.default.multiply(z.default.BigInt(n),Vl)),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 Ag(d),d}function zN(t,e,r,n,i,o,s,a,d,u,c,l,m,p,g,v,E,A,P,I,$){let N=p,{deltaDays:K,hour:F,minute:U,second:V,millisecond:L,microsecond:T,nanosecond:S}=Ole(n,i,o,s,a,d,g,v,E,A,P,I);N+=K;let k=_e("%Temporal.Duration%"),f=to(u,Ac(t,e,r,u),new k(c,l,m,N,0,0,0,0,0,0),$);return{year:R(f,Te),month:R(f,ke),day:R(f,Ce),hour:F,minute:U,second:V,millisecond:L,microsecond:T,nanosecond:S}}function Sc(t,e,r,n,i,o,s,a,d,u,c,l,m,p){let g=_e("%Temporal.Duration%");if(Hl(n,i,o,s,0,0,0,0,0,0)===0)return FN(R(t,dt),a,d,u,c,l,m);let v=Ua(e,t,r),E=to(r,Ac(R(v,Te),R(v,ke),R(v,Ce),r),new g(n,i,o,s,0,0,0,0,0,0),p),A=aa(R(E,Te),R(E,ke),R(E,Ce),R(v,wt),R(v,_t),R(v,xt),R(v,Et),R(v,St),R(v,At),r);return FN(R(is(e,A,"compatible"),dt),a,d,u,c,l,m)}function Lue(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}=Ng(r),v=MT(Qt(n));return{years:o,months:s,weeks:a,days:d,hours:u,minutes:c,seconds:l,milliseconds:m,microseconds:p,nanoseconds:g}=Cle(R(e,Jo),R(e,ji),R(e,Cs),R(e,Yo),R(e,Zo),R(e,Xo),R(e,Qo),R(e,es),R(e,ts),R(e,rs),i*o,i*s,i*a,i*d,i*u,i*c,i*l,i*m,i*p,i*g,v),new(_e("%Temporal.Duration%"))(o,s,a,d,u,c,l,m,p,g)}function Kue(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=Ng(m);for(let v of p)if(g[v]!==0)throw new RangeError(`Duration field ${v} not supported by Temporal.Instant. Try Temporal.ZonedDateTime instead.`);return g}(r,["years","months","weeks","days"]),c=FN(R(e,dt),n*i,n*o,n*s,n*a,n*d,n*u);return new(_e("%Temporal.Instant%"))(c)}function Fue(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}=Ng(r),v=Qt(n),E=R(e,oe),{year:A,month:P,day:I,hour:$,minute:N,second:K,millisecond:F,microsecond:U,nanosecond:V}=zN(R(e,Te),R(e,ke),R(e,Ce),R(e,wt),R(e,_t),R(e,xt),R(e,Et),R(e,St),R(e,At),E,i*o,i*s,i*a,i*d,i*u,i*c,i*l,i*m,i*p,i*g,v);return aa(A,P,I,$,N,K,F,U,V,E)}function zue(t,e,r){let n=t==="subtract"?-1:1,{hours:i,minutes:o,seconds:s,milliseconds:a,microseconds:d,nanoseconds:u}=Ng(r),{hour:c,minute:l,second:m,millisecond:p,microsecond:g,nanosecond:v}=Ole(R(e,wt),R(e,_t),R(e,xt),R(e,Et),R(e,St),R(e,At),n*i,n*o,n*s,n*a,n*d,n*u);return{hour:c,minute:l,second:m,millisecond:p,microsecond:g,nanosecond:v}=eI(c,l,m,p,g,v,"reject"),new(_e("%Temporal.PlainTime%"))(c,l,m,p,g,v)}function Vue(t,e,r,n){let i=Ng(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}=Td(d,u,c,l,m,p,g,"day"));let v=Qt(n),E=R(e,oe),A=Qn(E,["monthCode","year"]),P=Dt(e,A,[]),I=Po(null);Qw(I,P,[]),P.day=1;let $=Th(E,P),N=Hl(o,s,a,d,0,0,0,0,0,0),K=kr(E,"dateAdd"),F=_e("%Temporal.Duration%");if(N<0){let L=to(E,$,new F(0,1,0,0,0,0,0,0,0,0),void 0,K),T=to(E,L,new F(0,0,0,-1,0,0,0,0,0,0),void 0,K);I.day=o6(E,T),$=Th(E,I)}let U=new F(o,s,a,d,0,0,0,0,0,0),V=jm(v);return Og(E,Dt(to(E,$,U,v,K),A,[]),V)}function Hue(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}=Ng(r),v=Qt(n),E=R(e,Nr),A=R(e,oe);return eo(Sc(R(e,To),E,A,i*o,i*s,i*a,i*d,i*u,i*c,i*l,i*m,i*p,i*g,v),E,A)}function ja(t,e,r){if(z.default.equal(e,p1))return t;let{quotient:n,remainder:i}=Fn(t,e);if(z.default.equal(i,Rn))return t;let o=z.default.lessThan(i,Rn)?-1:1,s=Au(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(Au(n),z.default.BigInt(2)))===1)&&(n=z.default.add(n,z.default.BigInt(o)))}return z.default.multiply(n,e)}function GT(t,e,r,n){let{remainder:i}=Sg(t,Wl),o=z.default.subtract(t,i),s=ja(i,z.default.BigInt(qle[r]*e),n);return z.default.add(o,s)}function kj(t,e,r,n,i,o,s,a,d,u,c,l,m=864e11){let{deltaDays:p,hour:g,minute:v,second:E,millisecond:A,microsecond:P,nanosecond:I}=Rj(n,i,o,s,a,d,u,c,l,m),{year:$,month:N,day:K}=fI(t,e,r+p);return{year:$,month:N,day:K,hour:g,minute:v,second:E,millisecond:A,microsecond:P,nanosecond:I}}function Rj(t,e,r,n,i,o,s,a,d,u=864e11){let c=Rn;switch(a){case"day":case"hour":c=z.default.BigInt(t);case"minute":c=z.default.add(z.default.multiply(c,zl),z.default.BigInt(e));case"second":c=z.default.add(z.default.multiply(c,zl),z.default.BigInt(r));case"millisecond":c=z.default.add(z.default.multiply(c,Ar),z.default.BigInt(n));case"microsecond":c=z.default.add(z.default.multiply(c,Ar),z.default.BigInt(i));case"nanosecond":c=z.default.add(z.default.multiply(c,Ar),z.default.BigInt(o))}let l=a==="day"?u:qle[a],m=ja(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 _h(p,0,0,0,0,0);case"minute":return _h(t,p,0,0,0,0);case"second":return _h(t,e,p,0,0,0);case"millisecond":return _h(t,e,r,p,0,0);case"microsecond":return _h(t,e,r,n,p,0);case"nanosecond":return _h(t,e,r,n,i,p);default:throw new Error(`Invalid unit ${a}`)}}function OT(t,e){return Tj(R(t,Te),R(t,ke),R(t,Ce),R(e,Te),R(e,ke),R(e,Ce),"day").days}function Ao(t,e,r,n){let i=to(t,e,r,void 0,n);return{relativeTo:i,days:OT(e,i)}}function $le(t,e,r,n,i){let o=R(t,Nr),s=R(t,oe);return eo(Sc(R(t,To),o,s,e,r,n,i,0,0,0,0,0,0),o,s)}function Nle(t,e,r,n,i,o,s,a,d,u,c,l,m,p){let g=t,v=e,E=r,A=n,P=i,I=o,$=s,N=a,K=d,F=u;if(!Le(p)||l==="year"||l==="month"||l==="week"||l==="day"||l==="nanosecond"&&c===1)return{years:g,months:v,weeks:E,days:A,hours:P,minutes:I,seconds:$,milliseconds:N,microseconds:K,nanoseconds:F};let U=l1(0,P,I,$,N,K,F,0),V=o1(z.default.toNumber(U)),L=R(p,Nr),T=R(p,oe),S=Sc(R(p,To),L,T,g,v,E,A,0,0,0,0,0,0),k=Sc(new(_e("%Temporal.Instant%"))(S),L,T,0,0,0,V,0,0,0,0,0,0),f=z.default.subtract(k,S);return z.default.greaterThanOrEqual(z.default.multiply(z.default.subtract(U,f),z.default.BigInt(V)),Rn)&&({years:g,months:v,weeks:E,days:A}=Cle(g,v,E,A,0,0,0,0,0,0,0,0,0,V,0,0,0,0,0,0,p),U=GT(z.default.subtract(U,f),c,l,m),{hours:P,minutes:I,seconds:$,milliseconds:N,microseconds:K,nanoseconds:F}=Td(0,0,0,0,0,0,z.default.toNumber(U),"hour")),{years:g,months:v,weeks:E,days:A,hours:P,minutes:I,seconds:$,milliseconds:N,microseconds:K,nanoseconds:F}}function Ih(t,e,r,n,i,o,s,a,d,u,c,l,m,p){let g=t,v=e,E=r,A=n,P=i,I=o,$=s,N=a,K=d,F=z.default.BigInt(u),U=_e("%Temporal.Duration%"),V,L,T,S,k=p;if(k){if(Le(k))L=k,k=Ur(k);else if(!Ht(k))throw new TypeError("starting point must be PlainDate or ZonedDateTime");V=R(k,oe)}if(l==="year"||l==="month"||l==="week"||l==="day"){let f,y,w;F=l1(0,P,I,$,N,K,u,0),L&&(f=$le(L,g,v,E,A)),{days:y,nanoseconds:F,dayLengthNs:w}=Sj(F,f),T=z.default.BigInt(w),A+=y,P=I=$=N=K=0}switch(l){case"year":{if(!V)throw new RangeError("A starting point is required for years rounding");let f=new U(g),y=typeof V!="string"?kr(V,"dateAdd"):void 0,w=to(V,k,f,void 0,y),_=to(V,k,new U(g,v,E),void 0,y);k=w,A+=OT(w,_);let x=to(V,k,new U(0,0,0,A),void 0,y),b=Po(null);b.largestUnit="year";let B=Rm(V,k,x,b).years;g+=B;let q=k;k=to(V,k,new U(B),void 0,y),A-=OT(q,k);let M=new U(A<0?-1:1),{days:j}=Ao(V,k,M,y);j=sn(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=ja(F,z.default.multiply(J,z.default.BigInt(c)),m);S=Kl(F,J),g=z.default.toNumber(z.default.divide(Z,J)),F=Rn,v=E=A=0;break}case"month":{if(!V)throw new RangeError("A starting point is required for months rounding");let f=new U(g,v),y=typeof V!="string"?kr(V,"dateAdd"):void 0,w=to(V,k,f,void 0,y),_=to(V,k,new U(g,v,E),void 0,y);k=w,A+=OT(w,_);let x=o1(A),b=new U(0,A<0?-1:1),B;for({relativeTo:k,days:B}=Ao(V,k,b,y);sn(A)>=sn(B);)v+=x,A-=B,{relativeTo:k,days:B}=Ao(V,k,b,y);B=sn(B);let q=z.default.multiply(z.default.BigInt(B),T);F=z.default.add(z.default.add(z.default.multiply(q,z.default.BigInt(v)),z.default.multiply(z.default.BigInt(A),T)),F);let M=ja(F,z.default.multiply(q,z.default.BigInt(c)),m);S=Kl(F,q),v=z.default.toNumber(z.default.divide(M,q)),F=Rn,E=A=0;break}case"week":{if(!V)throw new RangeError("A starting point is required for weeks rounding");let f=o1(A),y=new U(0,0,A<0?-1:1),w=typeof V!="string"?kr(V,"dateAdd"):void 0,_;for({relativeTo:k,days:_}=Ao(V,k,y,w);sn(A)>=sn(_);)E+=f,A-=_,{relativeTo:k,days:_}=Ao(V,k,y,w);_=sn(_);let x=z.default.multiply(z.default.BigInt(_),T);F=z.default.add(z.default.add(z.default.multiply(x,z.default.BigInt(E)),z.default.multiply(z.default.BigInt(A),T)),F);let b=ja(F,z.default.multiply(x,z.default.BigInt(c)),m);S=Kl(F,x),E=z.default.toNumber(z.default.divide(b,x)),F=Rn,A=0;break}case"day":{let f=T;F=z.default.add(z.default.multiply(f,z.default.BigInt(A)),F);let y=ja(F,z.default.multiply(f,z.default.BigInt(c)),m);S=Kl(F,f),A=z.default.toNumber(z.default.divide(y,f)),F=Rn;break}case"hour":{let y=z.default.multiply(z.default.BigInt(P),z.default.BigInt(36e11));y=z.default.add(y,z.default.multiply(z.default.BigInt(I),z.default.BigInt(6e10))),y=z.default.add(y,z.default.multiply(z.default.BigInt($),Vl)),y=z.default.add(y,z.default.multiply(z.default.BigInt(N),Ec)),y=z.default.add(y,z.default.multiply(z.default.BigInt(K),Ar)),y=z.default.add(y,F),S=Kl(y,z.default.BigInt(36e11));let w=ja(y,z.default.BigInt(36e11*c),m);P=z.default.toNumber(z.default.divide(w,z.default.BigInt(36e11))),F=Rn,I=$=N=K=0;break}case"minute":{let y=z.default.multiply(z.default.BigInt(I),z.default.BigInt(6e10));y=z.default.add(y,z.default.multiply(z.default.BigInt($),Vl)),y=z.default.add(y,z.default.multiply(z.default.BigInt(N),Ec)),y=z.default.add(y,z.default.multiply(z.default.BigInt(K),Ar)),y=z.default.add(y,F),S=Kl(y,z.default.BigInt(6e10));let w=ja(y,z.default.BigInt(6e10*c),m);I=z.default.toNumber(z.default.divide(w,z.default.BigInt(6e10))),F=Rn,$=N=K=0;break}case"second":{let y=z.default.multiply(z.default.BigInt($),Vl);y=z.default.add(y,z.default.multiply(z.default.BigInt(N),Ec)),y=z.default.add(y,z.default.multiply(z.default.BigInt(K),Ar)),y=z.default.add(y,F),S=Kl(y,z.default.BigInt(1e9));let w=ja(y,z.default.BigInt(1e9*c),m);$=z.default.toNumber(z.default.divide(w,z.default.BigInt(1e9))),F=Rn,N=K=0;break}case"millisecond":{let y=z.default.multiply(z.default.BigInt(N),Ec);y=z.default.add(y,z.default.multiply(z.default.BigInt(K),Ar)),y=z.default.add(y,F),S=Kl(y,z.default.BigInt(1e6));let w=ja(y,z.default.BigInt(1e6*c),m);N=z.default.toNumber(z.default.divide(w,z.default.BigInt(1e6))),F=Rn,K=0;break}case"microsecond":{let y=z.default.multiply(z.default.BigInt(K),Ar);y=z.default.add(y,F),S=Kl(y,z.default.BigInt(1e3));let w=ja(y,z.default.BigInt(1e3*c),m);K=z.default.toNumber(z.default.divide(w,z.default.BigInt(1e3))),F=Rn;break}case"nanosecond":S=z.default.toNumber(F),F=ja(z.default.BigInt(F),z.default.BigInt(c),m)}return{years:g,months:v,weeks:E,days:A,hours:P,minutes:I,seconds:$,milliseconds:N,microseconds:K,nanoseconds:z.default.toNumber(F),total:S}}function km(t,e,r,n,i,o){for(let[s,a]of[[t,n],[e,i],[r,o]])if(s!==a)return kg(s-a);return 0}function Sg(t,e){let{quotient:r,remainder:n}=Fn(t,e);return z.default.lessThan(n,Rn)&&(r=z.default.subtract(r,p1),n=z.default.add(n,e)),{quotient:r,remainder:n}}function t1(t,e){let{quotient:r,remainder:n}=Fn(t,e);return xc(n)||!UT(t)==!UT(e)?r:z.default.subtract(r,p1)}function Kl(t,e){let{quotient:r,remainder:n}=Fn(t,e);return z.default.toNumber(r)+z.default.toNumber(n)/z.default.toNumber(e)}function JT(t){let e=$E(t);return globalThis.BigInt!==void 0?globalThis.BigInt(e.toString(10)):e}function $E(t){let e=t;if(typeof t=="object"){let r=t[Symbol.toPrimitive];r&&typeof r=="function"&&(e=QT(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 Bj=(()=>{let t=z.default.BigInt(Date.now()%1e6);return()=>{let e=z.default.BigInt(Date.now()),r=z.default.add(z.default.multiply(e,Ec),t);return t=z.default.remainder(e,Ec),z.default.greaterThan(r,s1)?s1:z.default.lessThan(r,jE)?jE:r}})();function Pm(){return new sle().resolvedOptions().timeZone}function kg(t){return t<0?-1:t>0?1:t}function Qt(t){if(t===void 0)return Po(null);if(an(t)&&t!==null)return t;throw new TypeError("Options parameter must be an object, not "+(t===null?"null":typeof t))}function f1(t,e){let r=Po(null);return r[t]=e,r}function jm(t){let e=Po(null);return Qw(e,Qt(t),[]),e}function Om(t,e,r,n){let i=t[e];if(i!==void 0){if(i=os(i),!r.includes(i))throw new RangeError(`${e} must be one of ${r.join(", ")}, not ${i}`);return i}return n}function Ph(t){return VLe.includes(Jl(t))}function Jl(t){return t.replace(/[A-Z]/g,e=>{let r=e.charCodeAt(0);return String.fromCharCode(r+32)})}var jle=new RegExp(`^${nle.source}$`);function Ule(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),p1);){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 qle={hour:36e11,minute:6e10,second:1e9,millisecond:1e6,microsecond:1e3,nanosecond:1},Lle=Symbol("date"),Kle=Symbol("ym"),Fle=Symbol("md"),zle=Symbol("time"),Vle=Symbol("datetime"),Hle=Symbol("instant"),r1=Symbol("original"),Yw=Symbol("timezone"),Ad=Symbol("calendar-id"),Wle=Symbol("locale"),VN=Symbol("options"),NE=t=>({value:t,enumerable:!0,writable:!1,configurable:!0}),n1=globalThis.Intl.DateTimeFormat,kh=Object.assign,YLe=Object.prototype.hasOwnProperty,ZLe=Reflect.apply;function Jw(t,e){let r=t[e];return typeof r=="function"&&(r=new n1(t[Wle],r(t[VN])),t[e]=r),r}function Cg(t,e={}){if(!(this instanceof Cg))return new Cg(t,e);let r=e!==void 0,n=r?kh({},e):{},i=new n1(t,n),o=i.resolvedOptions();if(r){let s=kh({},o);for(let a in s)ZLe(YLe,n,[a])||delete s[a];this[VN]=s}else this[VN]=n;this[Wle]=o.locale,this[r1]=i,this[Yw]=o.timeZone,this[Ad]=o.calendar,this[Lle]=tKe,this[Kle]=QLe,this[Fle]=eKe,this[zle]=XLe,this[Vle]=rKe,this[Hle]=nKe}Object.defineProperty(Cg,"name",{writable:!0,value:"DateTimeFormat"}),Cg.supportedLocalesOf=function(t,e){return n1.supportedLocalesOf(t,e)};var BN={resolvedOptions:NE(function(){return this[r1].resolvedOptions()}),format:NE(function(e,...r){let{instant:n,formatter:i}=i1(e,this);return n&&i?i.format(n.epochMilliseconds):this[r1].format(e,...r)}),formatRange:NE(function(e,r){if(h1(e)||h1(r)){if(!Gle(e,r))throw new TypeError("Intl.DateTimeFormat.formatRange accepts two values of the same type");let{instant:n,formatter:i}=i1(e,this),{instant:o,formatter:s}=i1(r,this);if(n&&o&&i&&s&&i===s)return i.formatRange(n.epochMilliseconds,o.epochMilliseconds)}return this[r1].formatRange(e,r)})};"formatToParts"in n1.prototype&&(BN.formatToParts=NE(function(e,...r){let{instant:n,formatter:i}=i1(e,this);return n&&i?i.formatToParts(n.epochMilliseconds):this[r1].formatToParts(e,...r)})),"formatRangeToParts"in n1.prototype&&(BN.formatRangeToParts=NE(function(e,r){if(h1(e)||h1(r)){if(!Gle(e,r))throw new TypeError("Intl.DateTimeFormat.formatRangeToParts accepts two values of the same type");let{instant:n,formatter:i}=i1(e,this),{instant:o,formatter:s}=i1(r,this);if(n&&o&&i&&s&&i===s)return i.formatRangeToParts(n.epochMilliseconds,o.epochMilliseconds)}return this[r1].formatRangeToParts(e,r)})),Cg.prototype=Object.create(n1.prototype,BN),Object.defineProperty(Cg,"prototype",{writable:!1,enumerable:!1,configurable:!1});var Rh=Cg;function c6(t={},e={}){let r=kh({},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 XLe(t){let e=c6(t,{year:!1,month:!1,day:!1,weekday:!1,timeZoneName:!1,dateStyle:!1});return Dj(e)||(e=kh({},e,{hour:"numeric",minute:"numeric",second:"numeric"})),e}function QLe(t){let e=c6(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=kh(e,{year:"numeric",month:"numeric"})),e}function eKe(t){let e=c6(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=kh({},e,{month:"numeric",day:"numeric"})),e}function tKe(t){let e=c6(t,{hour:!1,minute:!1,second:!1,dayPeriod:!1,timeZoneName:!1,timeStyle:!1});return Mj(e)||(e=kh({},e,{year:"numeric",month:"numeric",day:"numeric"})),e}function rKe(t){let e=c6(t,{timeZoneName:!1});return Dj(e)||Mj(e)||(e=kh({},e,{year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"})),e}function nKe(t){let e=t;return Dj(e)||Mj(e)||(e=kh({},e,{year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"})),e}function Mj(t){return"year"in t||"month"in t||"day"in t||"weekday"in t||"dateStyle"in t}function Dj(t){return"hour"in t||"minute"in t||"second"in t||"timeStyle"in t||"dayPeriod"in t}function h1(t){return Ht(t)||kn(t)||bt(t)||Le(t)||Sr(t)||Ti(t)||hi(t)}function Gle(t,e){return!(!h1(t)||!h1(e))&&!(kn(t)&&!kn(e))&&!(Ht(t)&&!Ht(e))&&!(bt(t)&&!bt(e))&&!(Le(t)&&!Le(e))&&!(Sr(t)&&!Sr(e))&&!(Ti(t)&&!Ti(e))&&!(hi(t)&&!hi(e))}function i1(t,e){let r=_e("%Temporal.PlainDateTime%");if(kn(t)){let n=new r(1970,1,1,R(t,wt),R(t,_t),R(t,xt),R(t,Et),R(t,St),R(t,At),e[Ad]);return{instant:is(e[Yw],n,"compatible"),formatter:Jw(e,zle)}}if(Sr(t)){let n=R(t,Te),i=R(t,ke),o=R(t,Ce),s=no(R(t,oe));if(s!==e[Ad])throw new RangeError(`cannot format PlainYearMonth with calendar ${s} in locale with calendar ${e[Ad]}`);let a=new r(n,i,o,12,0,0,0,0,0,s);return{instant:is(e[Yw],a,"compatible"),formatter:Jw(e,Kle)}}if(Ti(t)){let n=R(t,Te),i=R(t,ke),o=R(t,Ce),s=no(R(t,oe));if(s!==e[Ad])throw new RangeError(`cannot format PlainMonthDay with calendar ${s} in locale with calendar ${e[Ad]}`);let a=new r(n,i,o,12,0,0,0,0,0,s);return{instant:is(e[Yw],a,"compatible"),formatter:Jw(e,Fle)}}if(Ht(t)){let n=R(t,Te),i=R(t,ke),o=R(t,Ce),s=no(R(t,oe));if(s!=="iso8601"&&s!==e[Ad])throw new RangeError(`cannot format PlainDate with calendar ${s} in locale with calendar ${e[Ad]}`);let a=new r(n,i,o,12,0,0,0,0,0,e[Ad]);return{instant:is(e[Yw],a,"compatible"),formatter:Jw(e,Lle)}}if(bt(t)){let n=R(t,Te),i=R(t,ke),o=R(t,Ce),s=R(t,wt),a=R(t,_t),d=R(t,xt),u=R(t,Et),c=R(t,St),l=R(t,At),m=no(R(t,oe));if(m!=="iso8601"&&m!==e[Ad])throw new RangeError(`cannot format PlainDateTime with calendar ${m} in locale with calendar ${e[Ad]}`);let p=t;return m==="iso8601"&&(p=new r(n,i,o,s,a,d,u,c,l,e[Ad])),{instant:is(e[Yw],p,"compatible"),formatter:Jw(e,Vle)}}if(Le(t))throw new TypeError("Temporal.ZonedDateTime not supported in DateTimeFormat methods. Use toLocaleString() instead.");return hi(t)?{instant:t,formatter:Jw(e,Hle)}:{}}var tSt=Object.freeze({__proto__:null,DateTimeFormat:Rh}),KE=class t{constructor(e){if(arguments.length<1)throw new TypeError("missing argument: epochNanoseconds is required");let r=$E(e);Ag(r),Zl(this),Rt(this,dt,r)}get epochSeconds(){if(!hi(this))throw new TypeError("invalid receiver");let e=R(this,dt);return z.default.toNumber(t1(e,Vl))}get epochMilliseconds(){if(!hi(this))throw new TypeError("invalid receiver");let e=z.default.BigInt(R(this,dt));return z.default.toNumber(t1(e,Ec))}get epochMicroseconds(){if(!hi(this))throw new TypeError("invalid receiver");return JT(t1(z.default.BigInt(R(this,dt)),Ar))}get epochNanoseconds(){if(!hi(this))throw new TypeError("invalid receiver");return JT(z.default.BigInt(R(this,dt)))}add(e){if(!hi(this))throw new TypeError("invalid receiver");return Kue("add",this,e)}subtract(e){if(!hi(this))throw new TypeError("invalid receiver");return Kue("subtract",this,e)}until(e,r){if(!hi(this))throw new TypeError("invalid receiver");return Cue("until",this,e,r)}since(e,r){if(!hi(this))throw new TypeError("invalid receiver");return Cue("since",this,e,r)}round(e){if(!hi(this))throw new TypeError("invalid receiver");if(e===void 0)throw new TypeError("options parameter is required");let r=typeof e=="string"?f1("smallestUnit",e):Qt(e),n=y1(r),i=Iu(r,"halfExpand"),o=ua(r,"smallestUnit","time",Bg);g1(n,{hour:24,minute:1440,second:86400,millisecond:864e5,microsecond:864e8,nanosecond:864e11}[o],!0);let s=GT(R(this,dt),n,o,i);return new t(s)}equals(e){if(!hi(this))throw new TypeError("invalid receiver");let r=Tu(e),n=R(this,dt),i=R(r,dt);return z.default.equal(z.default.BigInt(n),z.default.BigInt(i))}toString(e){if(!hi(this))throw new TypeError("invalid receiver");let r=Qt(e),n=t6(r),i=Iu(r,"trunc"),o=ua(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=Io(s));let{precision:a,unit:d,increment:u}=r6(o,n),c=GT(R(this,dt),u,d,i);return Tue(new t(c),s,a)}toJSON(){if(!hi(this))throw new TypeError("invalid receiver");return Tue(this,void 0,"auto")}toLocaleString(e,r){if(!hi(this))throw new TypeError("invalid receiver");return new Rh(e,r).format(this)}valueOf(){throw new TypeError("use compare() or equals() to compare Temporal.Instant")}toZonedDateTime(e){if(!hi(this))throw new TypeError("invalid receiver");if(!an(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=la(r),i=e.timeZone;if(i===void 0)throw new TypeError("missing timeZone property in toZonedDateTime");let o=Io(i);return eo(R(this,dt),o,n)}toZonedDateTimeISO(e){if(!hi(this))throw new TypeError("invalid receiver");let r=Io(e);return eo(R(this,dt),r,"iso8601")}static fromEpochSeconds(e){let r=a1(e),n=z.default.multiply(z.default.BigInt(r),Vl);return Ag(n),new t(n)}static fromEpochMilliseconds(e){let r=a1(e),n=z.default.multiply(z.default.BigInt(r),Ec);return Ag(n),new t(n)}static fromEpochMicroseconds(e){let r=$E(e),n=z.default.multiply(r,Ar);return Ag(n),new t(n)}static fromEpochNanoseconds(e){let r=$E(e);return Ag(r),new t(r)}static from(e){return hi(e)?new t(R(e,dt)):Tu(e)}static compare(e,r){let n=Tu(e),i=Tu(r),o=R(n,dt),s=R(i,dt);return z.default.lessThan(o,s)?-1:z.default.greaterThan(o,s)?1:0}};Yl(KE,"Temporal.Instant");var Jle=Array.prototype.includes,iKe=Array.prototype.push,oKe=globalThis.Intl.DateTimeFormat,sKe=Array.prototype.sort,aKe=Math.abs,cKe=Math.floor,MN=Object.create,HN=Object.entries,Yle=Set,Wue=Reflect.ownKeys,So=Set.prototype.add,Zle=Set.prototype.values,mn={},pn=class{constructor(e){if(arguments.length<1)throw new RangeError("missing argument: id is required");let r=os(e);if(!Ph(r))throw new RangeError(`invalid calendar identifier ${r}`);Zl(this),Rt(this,xn,Jl(r))}get id(){if(!In(this))throw new TypeError("invalid receiver");return R(this,xn)}dateFromFields(e,r){if(!In(this))throw new TypeError("invalid receiver");if(!an(e))throw new TypeError("invalid fields");let n=Qt(r),i=R(this,xn);return mn[i].dateFromFields(e,n,i)}yearMonthFromFields(e,r){if(!In(this))throw new TypeError("invalid receiver");if(!an(e))throw new TypeError("invalid fields");let n=Qt(r),i=R(this,xn);return mn[i].yearMonthFromFields(e,n,i)}monthDayFromFields(e,r){if(!In(this))throw new TypeError("invalid receiver");if(!an(e))throw new TypeError("invalid fields");let n=Qt(r),i=R(this,xn);return mn[i].monthDayFromFields(e,n,i)}fields(e){if(!In(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),iKe.call(r,i)}return mn[R(this,xn)].fields(r)}mergeFields(e,r){if(!In(this))throw new TypeError("invalid receiver");let n=Sue(e),i=MN(null);Qw(i,n,[],[void 0]);let o=Sue(r),s=MN(null);Qw(s,o,[],[void 0]);let a=Wue(s),d=mn[R(this,xn)].fieldKeysToIgnore(a),u=MN(null),c=Wue(i);for(let l of c){let m;m=Ge(Jle,d,[l])?s[l]:i[l],m!==void 0&&(u[l]=m)}return Qw(u,s,[]),u}dateAdd(e,r,n){if(!In(this))throw new TypeError("invalid receiver");let i=Ur(e),o=e1(r),s=zn(Qt(n)),{days:a}=Td(R(o,Yo),R(o,Zo),R(o,Xo),R(o,Qo),R(o,es),R(o,ts),R(o,rs),"day"),d=R(this,xn);return mn[d].dateAdd(i,R(o,Jo),R(o,ji),R(o,Cs),a,s,d)}dateUntil(e,r,n){if(!In(this))throw new TypeError("invalid receiver");let i=Ur(e),o=Ur(r),s=ua(Qt(n),"largestUnit","date","auto");s==="auto"&&(s="day");let{years:a,months:d,weeks:u,days:c}=mn[R(this,xn)].dateUntil(i,o,s);return new(_e("%Temporal.Duration%"))(a,d,u,c,0,0,0,0,0,0)}year(e){let r=e;if(!In(this))throw new TypeError("invalid receiver");return Sr(r)||(r=Ur(r)),mn[R(this,xn)].year(r)}month(e){let r=e;if(!In(this))throw new TypeError("invalid receiver");if(Ti(r))throw new TypeError("use monthCode on PlainMonthDay instead");return Sr(r)||(r=Ur(r)),mn[R(this,xn)].month(r)}monthCode(e){let r=e;if(!In(this))throw new TypeError("invalid receiver");return Sr(r)||Ti(r)||(r=Ur(r)),mn[R(this,xn)].monthCode(r)}day(e){let r=e;if(!In(this))throw new TypeError("invalid receiver");return Ti(r)||(r=Ur(r)),mn[R(this,xn)].day(r)}era(e){let r=e;if(!In(this))throw new TypeError("invalid receiver");return Sr(r)||(r=Ur(r)),mn[R(this,xn)].era(r)}eraYear(e){let r=e;if(!In(this))throw new TypeError("invalid receiver");return Sr(r)||(r=Ur(r)),mn[R(this,xn)].eraYear(r)}dayOfWeek(e){if(!In(this))throw new TypeError("invalid receiver");let r=Ur(e);return mn[R(this,xn)].dayOfWeek(r)}dayOfYear(e){if(!In(this))throw new TypeError("invalid receiver");let r=Ur(e);return mn[R(this,xn)].dayOfYear(r)}weekOfYear(e){if(!In(this))throw new TypeError("invalid receiver");let r=Ur(e);return mn[R(this,xn)].weekOfYear(r)}yearOfWeek(e){if(!In(this))throw new TypeError("invalid receiver");let r=Ur(e);return mn[R(this,xn)].yearOfWeek(r)}daysInWeek(e){if(!In(this))throw new TypeError("invalid receiver");let r=Ur(e);return mn[R(this,xn)].daysInWeek(r)}daysInMonth(e){let r=e;if(!In(this))throw new TypeError("invalid receiver");return Sr(r)||(r=Ur(r)),mn[R(this,xn)].daysInMonth(r)}daysInYear(e){let r=e;if(!In(this))throw new TypeError("invalid receiver");return Sr(r)||(r=Ur(r)),mn[R(this,xn)].daysInYear(r)}monthsInYear(e){let r=e;if(!In(this))throw new TypeError("invalid receiver");return Sr(r)||(r=Ur(r)),mn[R(this,xn)].monthsInYear(r)}inLeapYear(e){let r=e;if(!In(this))throw new TypeError("invalid receiver");return Sr(r)||(r=Ur(r)),mn[R(this,xn)].inLeapYear(r)}toString(){if(!In(this))throw new TypeError("invalid receiver");return R(this,xn)}toJSON(){if(!In(this))throw new TypeError("invalid receiver");return R(this,xn)}static from(e){return v1(la(e))}};function Oj(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 Ah(t,e=!1){return`M${t.toString().padStart(2,"0")}${e?"L":""}`}function CT(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"&&ro(n,1,r),e==="constrain"&&(n=ca(n,1,r)),i=Ah(n)}else{let o=Oj(i);if(n!==void 0&&n!==o)throw new RangeError(`monthCode ${i} and month ${n} must match if both are present`);if(i!==Ah(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}}Yl(pn,"Temporal.Calendar"),En("Temporal.Calendar.from",pn.from),En("Temporal.Calendar.prototype.dateAdd",pn.prototype.dateAdd),En("Temporal.Calendar.prototype.dateFromFields",pn.prototype.dateFromFields),En("Temporal.Calendar.prototype.dateUntil",pn.prototype.dateUntil),En("Temporal.Calendar.prototype.day",pn.prototype.day),En("Temporal.Calendar.prototype.dayOfWeek",pn.prototype.dayOfWeek),En("Temporal.Calendar.prototype.dayOfYear",pn.prototype.dayOfYear),En("Temporal.Calendar.prototype.daysInMonth",pn.prototype.daysInMonth),En("Temporal.Calendar.prototype.daysInWeek",pn.prototype.daysInWeek),En("Temporal.Calendar.prototype.daysInYear",pn.prototype.daysInYear),En("Temporal.Calendar.prototype.era",pn.prototype.era),En("Temporal.Calendar.prototype.eraYear",pn.prototype.eraYear),En("Temporal.Calendar.prototype.fields",pn.prototype.fields),En("Temporal.Calendar.prototype.inLeapYear",pn.prototype.inLeapYear),En("Temporal.Calendar.prototype.mergeFields",pn.prototype.mergeFields),En("Temporal.Calendar.prototype.month",pn.prototype.month),En("Temporal.Calendar.prototype.monthCode",pn.prototype.monthCode),En("Temporal.Calendar.prototype.monthDayFromFields",pn.prototype.monthDayFromFields),En("Temporal.Calendar.prototype.monthsInYear",pn.prototype.monthsInYear),En("Temporal.Calendar.prototype.weekOfYear",pn.prototype.weekOfYear),En("Temporal.Calendar.prototype.year",pn.prototype.year),En("Temporal.Calendar.prototype.yearMonthFromFields",pn.prototype.yearMonthFromFields),En("Temporal.Calendar.prototype.yearOfWeek",pn.prototype.yearOfWeek),mn.iso8601={dateFromFields(t,e,r){let n=Dt(t,["day","month","monthCode","year"],["year","day"]),i=zn(e);n=CT(n);let{year:o,month:s,day:a}=n;return{year:o,month:s,day:a}=LT(o,s,a,i),Ac(o,s,a,r)},yearMonthFromFields(t,e,r){let n=Dt(t,["month","monthCode","year"],["year"]),i=zn(e);n=CT(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":Gl(l,m,1);break;case"constrain":({year:l,month:m}=kle(l,m))}return{year:l,month:m}}(o,s,i),qE(o,s,r,1)},monthDayFromFields(t,e,r){let n=Dt(t,["day","month","monthCode","year"],["day"]),i=zn(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=CT(n);let{month:s,day:a,year:d}=n;return{month:s,day:a}=LT(o?d:1972,s,a,i),UE(s,a,r,1972)},fields:t=>t,fieldKeysToIgnore(t){let e=new Yle;for(let r=0;r<t.length;r++){let n=t[r];Ge(So,e,[n]),n==="month"?Ge(So,e,["monthCode"]):n==="monthCode"&&Ge(So,e,["month"])}return[...Ge(Zle,e,[])]},dateAdd(t,e,r,n,i,o,s){let a=R(t,Te),d=R(t,ke),u=R(t,Ce);return{year:a,month:d,day:u}=Pg(a,d,u,e,r,n,i,o),Ac(a,d,u,s)},dateUntil:(t,e,r)=>Tj(R(t,Te),R(t,ke),R(t,Ce),R(e,Te),R(e,ke),R(e,Ce),r),year:t=>R(t,Te),era(){},eraYear(){},month:t=>R(t,ke),monthCode:t=>Ah(R(t,ke)),day:t=>R(t,Ce),dayOfWeek:t=>KN(R(t,Te),R(t,ke),R(t,Ce)),dayOfYear:t=>HT(R(t,Te),R(t,ke),R(t,Ce)),weekOfYear:t=>Due(R(t,Te),R(t,ke),R(t,Ce)).week,yearOfWeek:t=>Due(R(t,Te),R(t,ke),R(t,Ce)).year,daysInWeek:()=>7,daysInMonth:t=>Sh(R(t,Te),R(t,ke)),daysInYear(t){let e=t;return Pi(e,Te)||(e=Ur(e)),Dm(R(e,Te))?366:365},monthsInYear:()=>12,inLeapYear(t){let e=t;return Pi(e,Te)||(e=Ur(e)),Dm(R(e,Te))}};var fi=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 Xle({isoYear:t,isoMonth:e,isoDay:r}){return`${jg(t)}-${yn(e)}-${yn(r)}T00:00Z`}function DN(t,e){return{years:t.year-e.year,months:t.month-e.month,days:t.day-e.day}}fi.objectMap=new WeakMap,fi.MAX_CACHE_ENTRIES=1e3;var Cm=class{constructor(){this.eraLength="short",this.hasEra=!0,this.erasBeginMidYear=!1}getFormatter(){return this.formatter===void 0&&(this.formatter=new oKe(`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=Xle({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 v=/^([0-9]*)(.*?)$/.exec(g);if(!v||v.length!=3||!v[1]&&!v[2])throw new RangeError(`Unexpected month: ${g}`);if(l.month=v[1]?+v[1]:1,l.month<1)throw new RangeError(`Invalid month ${g} from ${c}[u-ca-${this.id}] (probably due to https://bugs.chromium.org/p/v8/issues/detail?id=10527)`);if(l.month>13)throw new RangeError(`Invalid month ${g} from ${c}[u-ca-${this.id}] (probably due to https://bugs.chromium.org/p/v8/issues/detail?id=10529)`);v[2]&&(l.monthExtra=v[2])}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}=CT(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"?(ro(o,1,i),ro(s,1,this.maximumMonthLength(e))):(o=ca(o,1,i),s=ca(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=P=>{let I=this.addDaysIso(m,P);if(o.day>this.minimumMonthLength(o)){let $=this.isoToCalendarDate(I,n);for(;$.month!==a||$.year!==s;){if(r==="reject")throw new RangeError(`day ${d} does not exist in month ${a} of year ${s}`);I=this.addDaysIso(I,-1),$=this.isoToCalendarDate(I,n)}}return I},g=0,v=this.isoToCalendarDate(m,n),E=DN(o,v);if(E.years!==0||E.months!==0||E.days!==0){let P=365*E.years+30*E.months+E.days;m=this.addDaysIso(m,P),v=this.isoToCalendarDate(m,n),E=DN(o,v),E.years===0&&E.months===0?m=p(E.days):g=this.compareCalendarDates(o,v)}let A=8;for(;g;){m=this.addDaysIso(m,g*A);let P=v;v=this.isoToCalendarDate(m,n);let I=g;if(g=this.compareCalendarDates(o,v),g){if(E=DN(o,v),E.years===0&&E.months===0)m=p(E.days),g=0;else if(I&&g!==I)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(v,P)>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,ke),day:R(e,Ce)};return this.isoToCalendarDate(n,r)}compareCalendarDates(e,r){let n=Dt(e,["day","month","year"],["day","month","year"]),i=Dt(r,["day","month","year"],["day","month","year"]);return n.year!==i.year?kg(n.year-i.year):n.month!==i.month?kg(n.month-i.month):n.day!==i.day?kg(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 Pg(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=aKe(r);a<d;a++){let{month:u}=o,c=o,l=r<0?-Math.max(s,this.daysInPreviousMonth(o,i)):this.daysInMonth(o,i),m=this.calendarToIsoDate(o,"constrain",i),p=this.addDaysIso(m,l);if(o=this.isoToCalendarDate(p,i),r>0){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<e.monthCode&&(g=-1),g||(g=Math.sign(l)),d=g*u<0?c-u:c}let m,p=d?this.addCalendar(e,{years:d},"constrain",i):e;do a+=u,m=p,p=this.addMonthsCalendar(m,u,"constrain",i),p.day!==e.day&&(p=this.regulateDate({...p,day:e.day},"constrain",i));while(this.compareCalendarDates(r,p)*u>=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 Tj(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:v}=e;if(p===void 0&&(g===void 0||v===void 0))throw new TypeError("when `monthCode` is omitted, `year` (or `era` and `eraYear`) and `month` are required");({monthCode:u,day:c}=this.isoToCalendarDate(this.calendarToIsoDate(e,r,n),n))}let l=this.isoToCalendarDate({year:1972,month:12,day:31},n),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),v=this.calendarToIsoDate(g,"constrain",n),E=this.isoToCalendarDate(v,n);if({year:i,month:o,day:s}=v,E.monthCode===u&&E.day===c)return{month:o,day:s,year:i};r==="constrain"&&(a===void 0||E.monthCode===a.monthCode&&E.day>a.day)&&(a=E,d=v)}if(r==="constrain"&&d!==void 0)return d;throw new RangeError(`No recent ${this.id} year with monthCode ${u} and day ${c}`)}},WN=class extends Cm{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=HN(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?Ah(5,!0):Ah(r<6?r:r-1):Ah(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=Oj(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"?(ro(a,1,this.monthsInYear({year:o})),ro(u,1,this.maximumMonthLength({year:o,month:a}))):(a=ca(a,1,this.monthsInYear({year:o})),u=ca(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}}},$m=class extends Cm{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:cKe(r*this.DAYS_PER_ISLAMIC_YEAR/this.DAYS_PER_ISO_YEAR)+622,month:1,day:1}}},YT=class extends $m{constructor(){super(...arguments),this.id="islamic"}},GN=class extends $m{constructor(){super(...arguments),this.id="islamic-umalqura"}},JN=class extends $m{constructor(){super(...arguments),this.id="islamic-tbla"}},YN=class extends $m{constructor(){super(...arguments),this.id="islamic-civil"}},ZN=class extends $m{constructor(){super(...arguments),this.id="islamic-rgsa"}},XN=class extends $m{constructor(){super(...arguments),this.id="islamicc"}},QN=class extends Cm{constructor(){super(...arguments),this.id="persian",this.calendarType="solar",this.constantEra="ap"}inLeapYear(e,r){return YT.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}}},ej=class extends Cm{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 Qle(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 Pg(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 Qle(t){return t%4==0&&(t%100!=0||t%400==0)}var $g=class extends Cm{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)}),sKe.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 Qle(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:Oj(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 LT(n+s.isoEpoch.year-(s.hasYearZero?0:1),i,o,"constrain")}checkIcuBugs(e){if(this.calendarIsVulnerableToJulianBug&&this.v8IsVulnerableToJulianBug&&km(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)`)}},FE=class extends $g{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)}},tj=class extends FE{constructor(){super("ethioaa",[{name:"era0",isoEpoch:{year:-5492,month:7,day:17}}])}},rj=class extends FE{constructor(){super("coptic",[{name:"era1",isoEpoch:{year:284,month:8,day:29}},{name:"era0",reverseOf:"era1"}])}},nj=class extends FE{constructor(){super("ethiopic",[{name:"era0",isoEpoch:{year:-5492,month:7,day:17}},{name:"era1",isoEpoch:{year:8,month:8,day:27},anchorEpoch:{year:5501}}])}},ij=class extends $g{constructor(){super("roc",[{name:"minguo",isoEpoch:{year:1912,month:1,day:1}},{name:"before-roc",reverseOf:"minguo"}]),this.calendarIsVulnerableToJulianBug=!0}},oj=class extends $g{constructor(){super("buddhist",[{name:"be",hasYearZero:!0,isoEpoch:{year:-543,month:1,day:1}}]),this.calendarIsVulnerableToJulianBug=!0}},sj=class extends $g{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}}},aj=class extends $g{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}}},ZT=class extends Cm{constructor(){super(...arguments),this.calendarType="lunisolar",this.hasEra=!1}inLeapYear(e,r){let n=this.getMonthList(e.year,r);return HN(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=(E,A)=>{let P=Xle({isoYear:E,isoMonth:2,isoDay:1}),I=new Date(P);I.setUTCDate(A+1);let $=o.formatToParts(I),N=$.find(U=>U.type==="month").value,K=+$.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:K,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,v=!1;do({calendarMonthString:d,calendarDay:u,calendarYearToVerify:c}=s(e,a)),m&&(l[p].daysInMonth=m+30-u),c!==e?v=!0:(l[d]={monthIndex:g++},a+=30),m=u,p=d;while(!v);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=Ah(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=Ah(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=HN(l),p=m.length;n==="reject"?(ro(s,1,p),ro(d,1,this.maximumMonthLength())):(s=ca(s,1,p),d=ca(d,1,this.maximumMonthLength()));let g=m.find(([,v])=>v.monthIndex===s);if(g===void 0)throw new RangeError(`Invalid month ${s} in Chinese year ${o}`);u=Ah(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}}},cj=class extends ZT{constructor(){super(...arguments),this.id="chinese"}},dj=class extends ZT{constructor(){super(...arguments),this.id="dangi"}},uj=class{constructor(e){this.helper=e}dateFromFields(e,r,n){let i=new fi,o=Dt(e,this.fields(["day","month","monthCode","year"]),[]),s=zn(r),{year:a,month:d,day:u}=this.helper.calendarToIsoDate(o,s,i),c=Ac(a,d,u,n);return i.setObject(c),c}yearMonthFromFields(e,r,n){let i=new fi,o=Dt(e,this.fields(["month","monthCode","year"]),[]),s=zn(r),{year:a,month:d,day:u}=this.helper.calendarToIsoDate({...o,day:1},s,i),c=qE(a,d,n,u);return i.setObject(c),c}monthDayFromFields(e,r,n){let i=new fi,o=Dt(e,this.fields(["day","month","monthCode","year"]),[]),s=zn(r),{year:a,month:d,day:u}=this.helper.monthDayFromFields(o,s,i),c=UE(d,u,n,a);return i.setObject(c),c}fields(e){let r=e;return Jle.call(r,"year")&&(r=[...r,"era","eraYear"]),r}fieldKeysToIgnore(e){let r=new Yle;for(let n=0;n<e.length;n++){let i=e[n];switch(Ge(So,r,[i]),i){case"era":Ge(So,r,["eraYear"]),Ge(So,r,["year"]);break;case"eraYear":Ge(So,r,["era"]),Ge(So,r,["year"]);break;case"year":Ge(So,r,["era"]),Ge(So,r,["eraYear"]);break;case"month":Ge(So,r,["monthCode"]),this.helper.erasBeginMidYear&&(Ge(So,r,["era"]),Ge(So,r,["eraYear"]));break;case"monthCode":Ge(So,r,["month"]),this.helper.erasBeginMidYear&&(Ge(So,r,["era"]),Ge(So,r,["eraYear"]));break;case"day":this.helper.erasBeginMidYear&&(Ge(So,r,["era"]),Ge(So,r,["eraYear"]))}}return[...Ge(Zle,r,[])]}dateAdd(e,r,n,i,o,s,a){let d=fi.getCacheForObject(e),u=this.helper.temporalToCalendarDate(e,d),c=this.helper.addCalendar(u,{years:r,months:n,weeks:i,days:o},s,d),l=this.helper.calendarToIsoDate(c,"constrain",d),{year:m,month:p,day:g}=l,v=Ac(m,p,g,a);return new fi(d).setObject(v),v}dateUntil(e,r,n){let i=fi.getCacheForObject(e),o=fi.getCacheForObject(r),s=this.helper.temporalToCalendarDate(e,i),a=this.helper.temporalToCalendarDate(r,o);return this.helper.untilCalendar(s,a,n,i)}year(e){let r=fi.getCacheForObject(e);return this.helper.temporalToCalendarDate(e,r).year}month(e){let r=fi.getCacheForObject(e);return this.helper.temporalToCalendarDate(e,r).month}day(e){let r=fi.getCacheForObject(e);return this.helper.temporalToCalendarDate(e,r).day}era(e){if(!this.helper.hasEra)return;let r=fi.getCacheForObject(e);return this.helper.temporalToCalendarDate(e,r).era}eraYear(e){if(!this.helper.hasEra)return;let r=fi.getCacheForObject(e);return this.helper.temporalToCalendarDate(e,r).eraYear}monthCode(e){let r=fi.getCacheForObject(e);return this.helper.temporalToCalendarDate(e,r).monthCode}dayOfWeek(e){return mn.iso8601.dayOfWeek(e)}dayOfYear(e){let r=fi.getCacheForObject(e),n=this.helper.isoToCalendarDate(e,r),i=this.helper.startOfCalendarYear(n);return this.helper.calendarDaysUntil(i,n,r)+1}weekOfYear(e){return mn.iso8601.weekOfYear(e)}yearOfWeek(e){return mn.iso8601.yearOfWeek(e)}daysInWeek(e){return mn.iso8601.daysInWeek(e)}daysInMonth(e){let r=fi.getCacheForObject(e),n=this.helper.temporalToCalendarDate(e,r),i=this.helper.maximumMonthLength(n);if(i===this.helper.minimumMonthLength(n))return i;let o=this.helper.startOfCalendarMonth(n),s=this.helper.addMonthsCalendar(o,1,"constrain",r);return this.helper.calendarDaysUntil(o,s,r)}daysInYear(e){let r=e;Pi(r,Te)||(r=Ur(r));let n=fi.getCacheForObject(r),i=this.helper.temporalToCalendarDate(r,n),o=this.helper.startOfCalendarYear(i),s=this.helper.addCalendar(o,{years:1},"constrain",n);return this.helper.calendarDaysUntil(o,s,n)}monthsInYear(e){let r=fi.getCacheForObject(e),n=this.helper.temporalToCalendarDate(e,r);return this.helper.monthsInYear(n,r)}inLeapYear(e){let r=e;Pi(r,Te)||(r=Ur(r));let n=fi.getCacheForObject(r),i=this.helper.temporalToCalendarDate(r,n);return this.helper.inLeapYear(i,n)}};for(let t of[WN,QN,nj,tj,rj,cj,dj,ij,ej,oj,sj,aj,YT,GN,JN,YN,ZN,XN]){let e=new t;mn[e.id]=new uj(e)}var zE=class t{constructor(e,r,n,i="iso8601"){hle(this,gr(e),gr(r),gr(n),la(i))}get calendarId(){if(!Ht(this))throw new TypeError("invalid receiver");return no(R(this,oe))}get era(){if(!Ht(this))throw new TypeError("invalid receiver");return nI(R(this,oe),this)}get eraYear(){if(!Ht(this))throw new TypeError("invalid receiver");return iI(R(this,oe),this)}get year(){if(!Ht(this))throw new TypeError("invalid receiver");return tI(R(this,oe),this)}get month(){if(!Ht(this))throw new TypeError("invalid receiver");return rI(R(this,oe),this)}get monthCode(){if(!Ht(this))throw new TypeError("invalid receiver");return i6(R(this,oe),this)}get day(){if(!Ht(this))throw new TypeError("invalid receiver");return o6(R(this,oe),this)}get dayOfWeek(){if(!Ht(this))throw new TypeError("invalid receiver");return yj(R(this,oe),this)}get dayOfYear(){if(!Ht(this))throw new TypeError("invalid receiver");return gj(R(this,oe),this)}get weekOfYear(){if(!Ht(this))throw new TypeError("invalid receiver");return vj(R(this,oe),this)}get yearOfWeek(){if(!Ht(this))throw new TypeError("invalid receiver");return bj(R(this,oe),this)}get daysInWeek(){if(!Ht(this))throw new TypeError("invalid receiver");return wj(R(this,oe),this)}get daysInMonth(){if(!Ht(this))throw new TypeError("invalid receiver");return oI(R(this,oe),this)}get daysInYear(){if(!Ht(this))throw new TypeError("invalid receiver");return sI(R(this,oe),this)}get monthsInYear(){if(!Ht(this))throw new TypeError("invalid receiver");return aI(R(this,oe),this)}get inLeapYear(){if(!Ht(this))throw new TypeError("invalid receiver");return cI(R(this,oe),this)}with(e,r){if(!Ht(this))throw new TypeError("invalid receiver");if(!an(e))throw new TypeError("invalid argument");m1(e);let n=Qt(r),i=R(this,oe),o=Qn(i,["day","month","monthCode","year"]),s=Dt(this,o,[]);return s=Dg(i,s,Dt(e,o,"partial")),s=Dt(s,o,[]),Th(i,s,n)}withCalendar(e){if(!Ht(this))throw new TypeError("invalid receiver");let r=la(e);return new t(R(this,Te),R(this,ke),R(this,Ce),r)}add(e,r){if(!Ht(this))throw new TypeError("invalid receiver");let n=e1(e),i=Qt(r);return to(R(this,oe),this,n,i)}subtract(e,r){if(!Ht(this))throw new TypeError("invalid receiver");let n=Ple(e1(e)),i=Qt(r);return to(R(this,oe),this,n,i)}until(e,r){if(!Ht(this))throw new TypeError("invalid receiver");return $ue("until",this,e,r)}since(e,r){if(!Ht(this))throw new TypeError("invalid receiver");return $ue("since",this,e,r)}equals(e){if(!Ht(this))throw new TypeError("invalid receiver");let r=Ur(e);for(let n of[Te,ke,Ce])if(R(this,n)!==R(r,n))return!1;return a6(R(this,oe),R(r,oe))}toString(e){if(!Ht(this))throw new TypeError("invalid receiver");return Iue(this,e6(Qt(e)))}toJSON(){if(!Ht(this))throw new TypeError("invalid receiver");return Iue(this)}toLocaleString(e,r){if(!Ht(this))throw new TypeError("invalid receiver");return new Rh(e,r).format(this)}valueOf(){throw new TypeError("use compare() or equals() to compare Temporal.PlainDate")}toPlainDateTime(e){if(!Ht(this))throw new TypeError("invalid receiver");let r=R(this,Te),n=R(this,ke),i=R(this,Ce),o=R(this,oe);if(e===void 0)return aa(r,n,i,0,0,0,0,0,0,o);let s=xh(e);return aa(r,n,i,R(s,wt),R(s,_t),R(s,xt),R(s,Et),R(s,St),R(s,At),o)}toZonedDateTime(e){if(!Ht(this))throw new TypeError("invalid receiver");let r,n;if(an(e))if(_c(e))r=e;else{let g=e.timeZone;g===void 0?r=Io(e):(r=Io(g),n=e.plainTime)}else r=Io(e);let i=R(this,Te),o=R(this,ke),s=R(this,Ce),a=R(this,oe),d=0,u=0,c=0,l=0,m=0,p=0;return n!==void 0&&(n=xh(n),d=R(n,wt),u=R(n,_t),c=R(n,xt),l=R(n,Et),m=R(n,St),p=R(n,At)),eo(R(is(r,aa(i,o,s,d,u,c,l,m,p,a),"compatible"),dt),r,a)}toPlainYearMonth(){if(!Ht(this))throw new TypeError("invalid receiver");let e=R(this,oe);return Og(e,Dt(this,Qn(e,["monthCode","year"]),[]))}toPlainMonthDay(){if(!Ht(this))throw new TypeError("invalid receiver");let e=R(this,oe);return d1(e,Dt(this,Qn(e,["day","monthCode"]),[]))}getISOFields(){if(!Ht(this))throw new TypeError("invalid receiver");return{calendar:R(this,oe),isoDay:R(this,Ce),isoMonth:R(this,ke),isoYear:R(this,Te)}}getCalendar(){if(!Ht(this))throw new TypeError("invalid receiver");return v1(R(this,oe))}static from(e,r){let n=Qt(r);return Ht(e)?(zn(n),Ac(R(e,Te),R(e,ke),R(e,Ce),R(e,oe))):Ur(e,n)}static compare(e,r){let n=Ur(e),i=Ur(r);return km(R(n,Te),R(n,ke),R(n,Ce),R(i,Te),R(i,ke),R(i,Ce))}};Yl(zE,"Temporal.PlainDate");var VE=class t{constructor(e,r,n,i=0,o=0,s=0,a=0,d=0,u=0,c="iso8601"){ple(this,gr(e),gr(r),gr(n),i===void 0?0:gr(i),o===void 0?0:gr(o),s===void 0?0:gr(s),a===void 0?0:gr(a),d===void 0?0:gr(d),u===void 0?0:gr(u),la(c))}get calendarId(){if(!bt(this))throw new TypeError("invalid receiver");return no(R(this,oe))}get year(){if(!bt(this))throw new TypeError("invalid receiver");return tI(R(this,oe),this)}get month(){if(!bt(this))throw new TypeError("invalid receiver");return rI(R(this,oe),this)}get monthCode(){if(!bt(this))throw new TypeError("invalid receiver");return i6(R(this,oe),this)}get day(){if(!bt(this))throw new TypeError("invalid receiver");return o6(R(this,oe),this)}get hour(){if(!bt(this))throw new TypeError("invalid receiver");return R(this,wt)}get minute(){if(!bt(this))throw new TypeError("invalid receiver");return R(this,_t)}get second(){if(!bt(this))throw new TypeError("invalid receiver");return R(this,xt)}get millisecond(){if(!bt(this))throw new TypeError("invalid receiver");return R(this,Et)}get microsecond(){if(!bt(this))throw new TypeError("invalid receiver");return R(this,St)}get nanosecond(){if(!bt(this))throw new TypeError("invalid receiver");return R(this,At)}get era(){if(!bt(this))throw new TypeError("invalid receiver");return nI(R(this,oe),this)}get eraYear(){if(!bt(this))throw new TypeError("invalid receiver");return iI(R(this,oe),this)}get dayOfWeek(){if(!bt(this))throw new TypeError("invalid receiver");return yj(R(this,oe),this)}get dayOfYear(){if(!bt(this))throw new TypeError("invalid receiver");return gj(R(this,oe),this)}get weekOfYear(){if(!bt(this))throw new TypeError("invalid receiver");return vj(R(this,oe),this)}get yearOfWeek(){if(!bt(this))throw new TypeError("invalid receiver");return bj(R(this,oe),this)}get daysInWeek(){if(!bt(this))throw new TypeError("invalid receiver");return wj(R(this,oe),this)}get daysInYear(){if(!bt(this))throw new TypeError("invalid receiver");return sI(R(this,oe),this)}get daysInMonth(){if(!bt(this))throw new TypeError("invalid receiver");return oI(R(this,oe),this)}get monthsInYear(){if(!bt(this))throw new TypeError("invalid receiver");return aI(R(this,oe),this)}get inLeapYear(){if(!bt(this))throw new TypeError("invalid receiver");return cI(R(this,oe),this)}with(e,r){if(!bt(this))throw new TypeError("invalid receiver");if(!an(e))throw new TypeError("invalid argument");m1(e);let n=Qt(r),i=R(this,oe),o=Qn(i,["day","hour","microsecond","millisecond","minute","month","monthCode","nanosecond","second","year"]),s=Dt(this,o,[]);s=Dg(i,s,Dt(e,o,"partial")),s=Dt(s,o,[]);let{year:a,month:d,day:u,hour:c,minute:l,second:m,millisecond:p,microsecond:g,nanosecond:v}=n6(i,s,n);return aa(a,d,u,c,l,m,p,g,v,i)}withPlainTime(e){if(!bt(this))throw new TypeError("invalid receiver");let r=R(this,Te),n=R(this,ke),i=R(this,Ce),o=R(this,oe);if(e===void 0)return aa(r,n,i,0,0,0,0,0,0,o);let s=xh(e);return aa(r,n,i,R(s,wt),R(s,_t),R(s,xt),R(s,Et),R(s,St),R(s,At),o)}withPlainDate(e){if(!bt(this))throw new TypeError("invalid receiver");let r=Ur(e),n=R(r,Te),i=R(r,ke),o=R(r,Ce),s=R(r,oe),a=R(this,wt),d=R(this,_t),u=R(this,xt),c=R(this,Et),l=R(this,St),m=R(this,At);return s=vle(R(this,oe),s),aa(n,i,o,a,d,u,c,l,m,s)}withCalendar(e){if(!bt(this))throw new TypeError("invalid receiver");let r=la(e);return new t(R(this,Te),R(this,ke),R(this,Ce),R(this,wt),R(this,_t),R(this,xt),R(this,Et),R(this,St),R(this,At),r)}add(e,r){if(!bt(this))throw new TypeError("invalid receiver");return Fue("add",this,e,r)}subtract(e,r){if(!bt(this))throw new TypeError("invalid receiver");return Fue("subtract",this,e,r)}until(e,r){if(!bt(this))throw new TypeError("invalid receiver");return Nue("until",this,e,r)}since(e,r){if(!bt(this))throw new TypeError("invalid receiver");return Nue("since",this,e,r)}round(e){if(!bt(this))throw new TypeError("invalid receiver");if(e===void 0)throw new TypeError("options parameter is required");let r=typeof e=="string"?f1("smallestUnit",e):Qt(e),n=y1(r),i=Iu(r,"halfExpand"),o=ua(r,"smallestUnit","time",Bg,["day"]),s={day:1,hour:24,minute:60,second:60,millisecond:1e3,microsecond:1e3,nanosecond:1e3}[o];g1(n,s,s===1);let a=R(this,Te),d=R(this,ke),u=R(this,Ce),c=R(this,wt),l=R(this,_t),m=R(this,xt),p=R(this,Et),g=R(this,St),v=R(this,At);return{year:a,month:d,day:u,hour:c,minute:l,second:m,millisecond:p,microsecond:g,nanosecond:v}=kj(a,d,u,c,l,m,p,g,v,n,o,i),aa(a,d,u,c,l,m,p,g,v,R(this,oe))}equals(e){if(!bt(this))throw new TypeError("invalid receiver");let r=Ig(e);for(let n of[Te,ke,Ce,wt,_t,xt,Et,St,At])if(R(this,n)!==R(r,n))return!1;return a6(R(this,oe),R(r,oe))}toString(e){if(!bt(this))throw new TypeError("invalid receiver");let r=Qt(e),n=e6(r),i=t6(r),o=Iu(r,"trunc"),s=ua(r,"smallestUnit","time",void 0);if(s==="hour")throw new RangeError('smallestUnit must be a time unit other than "hour"');let{precision:a,unit:d,increment:u}=r6(s,i);return Pue(this,a,n,{unit:d,increment:u,roundingMode:o})}toJSON(){if(!bt(this))throw new TypeError("invalid receiver");return Pue(this,"auto")}toLocaleString(e,r){if(!bt(this))throw new TypeError("invalid receiver");return new Rh(e,r).format(this)}valueOf(){throw new TypeError("use compare() or equals() to compare Temporal.PlainDateTime")}toZonedDateTime(e,r){if(!bt(this))throw new TypeError("invalid receiver");let n=Io(e);return eo(R(is(n,this,c1(Qt(r))),dt),n,R(this,oe))}toPlainDate(){if(!bt(this))throw new TypeError("invalid receiver");return u1(this)}toPlainYearMonth(){if(!bt(this))throw new TypeError("invalid receiver");let e=R(this,oe);return Og(e,Dt(this,Qn(e,["monthCode","year"]),[]))}toPlainMonthDay(){if(!bt(this))throw new TypeError("invalid receiver");let e=R(this,oe);return d1(e,Dt(this,Qn(e,["day","monthCode"]),[]))}toPlainTime(){if(!bt(this))throw new TypeError("invalid receiver");return _j(this)}getISOFields(){if(!bt(this))throw new TypeError("invalid receiver");return{calendar:R(this,oe),isoDay:R(this,Ce),isoHour:R(this,wt),isoMicrosecond:R(this,St),isoMillisecond:R(this,Et),isoMinute:R(this,_t),isoMonth:R(this,ke),isoNanosecond:R(this,At),isoSecond:R(this,xt),isoYear:R(this,Te)}}getCalendar(){if(!bt(this))throw new TypeError("invalid receiver");return v1(R(this,oe))}static from(e,r){let n=Qt(r);return bt(e)?(zn(n),aa(R(e,Te),R(e,ke),R(e,Ce),R(e,wt),R(e,_t),R(e,xt),R(e,Et),R(e,St),R(e,At),R(e,oe))):Ig(e,n)}static compare(e,r){let n=Ig(e),i=Ig(r);for(let o of[Te,ke,Ce,wt,_t,xt,Et,St,At]){let s=R(n,o),a=R(i,o);if(s!==a)return kg(s-a)}return 0}};Yl(VE,"Temporal.PlainDateTime");var HE=class t{constructor(e=0,r=0,n=0,i=0,o=0,s=0,a=0,d=0,u=0,c=0){let l=e===void 0?0:Ii(e),m=r===void 0?0:Ii(r),p=n===void 0?0:Ii(n),g=i===void 0?0:Ii(i),v=o===void 0?0:Ii(o),E=s===void 0?0:Ii(s),A=a===void 0?0:Ii(a),P=d===void 0?0:Ii(d),I=u===void 0?0:Ii(u),$=c===void 0?0:Ii(c);WT(l,m,p,g,v,E,A,P,I,$),Zl(this),Rt(this,Jo,l),Rt(this,ji,m),Rt(this,Cs,p),Rt(this,Yo,g),Rt(this,Zo,v),Rt(this,Xo,E),Rt(this,Qo,A),Rt(this,es,P),Rt(this,ts,I),Rt(this,rs,$)}get years(){if(!Pn(this))throw new TypeError("invalid receiver");return R(this,Jo)}get months(){if(!Pn(this))throw new TypeError("invalid receiver");return R(this,ji)}get weeks(){if(!Pn(this))throw new TypeError("invalid receiver");return R(this,Cs)}get days(){if(!Pn(this))throw new TypeError("invalid receiver");return R(this,Yo)}get hours(){if(!Pn(this))throw new TypeError("invalid receiver");return R(this,Zo)}get minutes(){if(!Pn(this))throw new TypeError("invalid receiver");return R(this,Xo)}get seconds(){if(!Pn(this))throw new TypeError("invalid receiver");return R(this,Qo)}get milliseconds(){if(!Pn(this))throw new TypeError("invalid receiver");return R(this,es)}get microseconds(){if(!Pn(this))throw new TypeError("invalid receiver");return R(this,ts)}get nanoseconds(){if(!Pn(this))throw new TypeError("invalid receiver");return R(this,rs)}get sign(){if(!Pn(this))throw new TypeError("invalid receiver");return Hl(R(this,Jo),R(this,ji),R(this,Cs),R(this,Yo),R(this,Zo),R(this,Xo),R(this,Qo),R(this,es),R(this,ts),R(this,rs))}get blank(){if(!Pn(this))throw new TypeError("invalid receiver");return Hl(R(this,Jo),R(this,ji),R(this,Cs),R(this,Yo),R(this,Zo),R(this,Xo),R(this,Qo),R(this,es),R(this,ts),R(this,rs))===0}with(e){if(!Pn(this))throw new TypeError("invalid receiver");let r=Dt(e,["days","hours","microseconds","milliseconds","minutes","months","nanoseconds","seconds","weeks","years"],"partial"),{years:n=R(this,Jo),months:i=R(this,ji),weeks:o=R(this,Cs),days:s=R(this,Yo),hours:a=R(this,Zo),minutes:d=R(this,Xo),seconds:u=R(this,Qo),milliseconds:c=R(this,es),microseconds:l=R(this,ts),nanoseconds:m=R(this,rs)}=r;return new t(n,i,o,s,a,d,u,c,l,m)}negated(){if(!Pn(this))throw new TypeError("invalid receiver");return Ple(this)}abs(){if(!Pn(this))throw new TypeError("invalid receiver");return new t(Math.abs(R(this,Jo)),Math.abs(R(this,ji)),Math.abs(R(this,Cs)),Math.abs(R(this,Yo)),Math.abs(R(this,Zo)),Math.abs(R(this,Xo)),Math.abs(R(this,Qo)),Math.abs(R(this,es)),Math.abs(R(this,ts)),Math.abs(R(this,rs)))}add(e,r){if(!Pn(this))throw new TypeError("invalid receiver");return Lue("add",this,e,r)}subtract(e,r){if(!Pn(this))throw new TypeError("invalid receiver");return Lue("subtract",this,e,r)}round(e){if(!Pn(this))throw new TypeError("invalid receiver");if(e===void 0)throw new TypeError("options parameter is required");let r=R(this,Jo),n=R(this,ji),i=R(this,Cs),o=R(this,Yo),s=R(this,Zo),a=R(this,Xo),d=R(this,Qo),u=R(this,es),c=R(this,ts),l=R(this,rs),m=UN(r,n,i,o,s,a,d,u,c,l),p=typeof e=="string"?f1("smallestUnit",e):Qt(e),g=ua(p,"largestUnit","datetime",void 0,["auto"]),v=MT(p),E=y1(p),A=Iu(p,"halfExpand"),P=ua(p,"smallestUnit","datetime",void 0),I=!0;P||(I=!1,P="nanosecond"),m=Mg(m,P);let $=!0;if(g||($=!1,g=m),g==="auto"&&(g=m),!I&&!$)throw new RangeError("at least one of smallestUnit or largestUnit is required");if(Mg(g,P)!==g)throw new RangeError(`largestUnit ${g} cannot be smaller than smallestUnit ${P}`);let N={hour:24,minute:60,second:60,millisecond:1e3,microsecond:1e3,nanosecond:1e3}[P];return N!==void 0&&g1(E,N,!1),{years:r,months:n,weeks:i,days:o}=BT(r,n,i,o,g,v),{years:r,months:n,weeks:i,days:o,hours:s,minutes:a,seconds:d,milliseconds:u,microseconds:c,nanoseconds:l}=Ih(r,n,i,o,s,a,d,u,c,l,E,P,A,v),{years:r,months:n,weeks:i,days:o,hours:s,minutes:a,seconds:d,milliseconds:u,microseconds:c,nanoseconds:l}=Nle(r,n,i,o,s,a,d,u,c,l,E,P,A,v),{days:o,hours:s,minutes:a,seconds:d,milliseconds:u,microseconds:c,nanoseconds:l}=Td(o,s,a,d,u,c,l,g,v),{years:r,months:n,weeks:i,days:o}=function(F,U,V,L,T,S){let k=_e("%Temporal.Duration%"),f=Hl(F,U,V,L,0,0,0,0,0,0);if(f===0)return{years:F,months:U,weeks:V,days:L};let y=z.default.BigInt(f),w,_,x=z.default.BigInt(F),b=z.default.BigInt(U),B=z.default.BigInt(V),q=z.default.BigInt(L);S&&(_=Ur(S),w=R(_,oe));let M=new k(f),j=new k(0,f),J=new k(0,0,f);switch(T){case"year":{if(!w)throw new RangeError("a starting point is required for years balancing");let Z=typeof w!="string"?kr(w,"dateAdd"):void 0,G,W,X;for({relativeTo:G,days:W}=Ao(w,_,M,Z);z.default.greaterThanOrEqual(Au(q),z.default.BigInt(sn(W)));)q=z.default.subtract(q,z.default.BigInt(W)),x=z.default.add(x,y),_=G,{relativeTo:G,days:W}=Ao(w,_,M,Z);for({relativeTo:G,days:X}=Ao(w,_,j,Z);z.default.greaterThanOrEqual(Au(q),z.default.BigInt(sn(X)));)q=z.default.subtract(q,z.default.BigInt(X)),b=z.default.add(b,y),_=G,{relativeTo:G,days:X}=Ao(w,_,j,Z);G=to(w,_,M,void 0,Z);let ee=typeof w!="string"?kr(w,"dateUntil"):void 0,ue=Po(null);ue.largestUnit="month";let ae=Rm(w,_,G,ue,ee),ce=R(ae,ji);for(;z.default.greaterThanOrEqual(Au(b),z.default.BigInt(sn(ce)));){b=z.default.subtract(b,z.default.BigInt(ce)),x=z.default.add(x,y),_=G,G=to(w,_,M,void 0,Z);let pe=Po(null);pe.largestUnit="month",ae=Rm(w,_,G,pe,ee),ce=R(ae,ji)}break}case"month":{if(!w)throw new RangeError("a starting point is required for months balancing");let Z=typeof w!="string"?kr(w,"dateAdd"):void 0,G,W;for({relativeTo:G,days:W}=Ao(w,_,j,Z);z.default.greaterThanOrEqual(Au(q),z.default.BigInt(sn(W)));)q=z.default.subtract(q,z.default.BigInt(W)),b=z.default.add(b,y),_=G,{relativeTo:G,days:W}=Ao(w,_,j,Z);break}case"week":{if(!w)throw new RangeError("a starting point is required for weeks balancing");let Z=typeof w!="string"?kr(w,"dateAdd"):void 0,G,W;for({relativeTo:G,days:W}=Ao(w,_,J,Z);z.default.greaterThanOrEqual(Au(q),z.default.BigInt(sn(W)));)q=z.default.subtract(q,z.default.BigInt(W)),B=z.default.add(B,y),_=G,{relativeTo:G,days:W}=Ao(w,_,J,Z);break}}return{years:z.default.toNumber(x),months:z.default.toNumber(b),weeks:z.default.toNumber(B),days:z.default.toNumber(q)}}(r,n,i,o,g,v),new t(r,n,i,o,s,a,d,u,c,l)}total(e){if(!Pn(this))throw new TypeError("invalid receiver");let r=R(this,Jo),n=R(this,ji),i=R(this,Cs),o=R(this,Yo),s=R(this,Zo),a=R(this,Xo),d=R(this,Qo),u=R(this,es),c=R(this,ts),l=R(this,rs);if(e===void 0)throw new TypeError("options argument is required");let m=typeof e=="string"?f1("unit",e):Qt(e),p=MT(m),g=ua(m,"unit","datetime",Bg),v;({years:r,months:n,weeks:i,days:o}=BT(r,n,i,o,g,p)),Le(p)&&(v=$le(p,r,n,i,0));let E=Ile(o,s,a,d,u,c,l,g,v);if(E==="positive overflow")return 1/0;if(E==="negative overflow")return-1/0;({days:o,hours:s,minutes:a,seconds:d,milliseconds:u,microseconds:c,nanoseconds:l}=E);let{total:A}=Ih(r,n,i,o,s,a,d,u,c,l,1,g,"trunc",p);return A}toString(e){if(!Pn(this))throw new TypeError("invalid receiver");let r=Qt(e),n=t6(r),i=Iu(r,"trunc"),o=ua(r,"smallestUnit","time",void 0);if(o==="hour"||o==="minute")throw new RangeError('smallestUnit must be a time unit other than "hours" or "minutes"');let{precision:s,unit:a,increment:d}=r6(o,n);return RN(this,s,{unit:a,increment:d,roundingMode:i})}toJSON(){if(!Pn(this))throw new TypeError("invalid receiver");return RN(this)}toLocaleString(e,r){if(!Pn(this))throw new TypeError("invalid receiver");return typeof Intl<"u"&&Intl.DurationFormat!==void 0?new Intl.DurationFormat(e,r).format(this):(console.warn("Temporal.Duration.prototype.toLocaleString() requires Intl.DurationFormat."),RN(this))}valueOf(){throw new TypeError("use compare() to compare Temporal.Duration")}static from(e){return Pn(e)?new t(R(e,Jo),R(e,ji),R(e,Cs),R(e,Yo),R(e,Zo),R(e,Xo),R(e,Qo),R(e,es),R(e,ts),R(e,rs)):e1(e)}static compare(e,r,n){let i=e1(e),o=e1(r),s=MT(Qt(n)),a=R(i,Jo),d=R(i,ji),u=R(i,Cs),c=R(i,Yo),l=R(i,Zo),m=R(i,Xo),p=R(i,Qo),g=R(i,es),v=R(i,ts),E=R(i,rs),A=R(o,Jo),P=R(o,ji),I=R(o,Cs),$=R(o,Yo),N=R(o,Zo),K=R(o,Xo),F=R(o,Qo),U=R(o,es),V=R(o,ts),L=R(o,rs),T=Oue(s,a,d,u,c),S=Oue(s,A,P,I,$);a===0&&A===0&&d===0&&P===0&&u===0&&I===0||({days:c}=BT(a,d,u,c,"day",s),{days:$}=BT(A,P,I,$,"day",s));let k=l1(c,l,m,p,g,v,E,T),f=l1($,N,K,F,U,V,L,S);return kg(z.default.toNumber(z.default.subtract(k,f)))}};Yl(HE,"Temporal.Duration");var dKe=Object.create,WE=class{constructor(e,r,n="iso8601",i=1972){mle(this,gr(e),gr(r),la(n),gr(i))}get monthCode(){if(!Ti(this))throw new TypeError("invalid receiver");return i6(R(this,oe),this)}get day(){if(!Ti(this))throw new TypeError("invalid receiver");return o6(R(this,oe),this)}get calendarId(){if(!Ti(this))throw new TypeError("invalid receiver");return no(R(this,oe))}with(e,r){if(!Ti(this))throw new TypeError("invalid receiver");if(!an(e))throw new TypeError("invalid argument");m1(e);let n=Qt(r),i=R(this,oe),o=Qn(i,["day","month","monthCode","year"]),s=Dt(this,o,[]);return s=Dg(i,s,Dt(e,o,"partial")),s=Dt(s,o,[]),d1(i,s,n)}equals(e){if(!Ti(this))throw new TypeError("invalid receiver");let r=Aue(e);for(let n of[ke,Ce,Te])if(R(this,n)!==R(r,n))return!1;return a6(R(this,oe),R(r,oe))}toString(e){if(!Ti(this))throw new TypeError("invalid receiver");return kue(this,e6(Qt(e)))}toJSON(){if(!Ti(this))throw new TypeError("invalid receiver");return kue(this)}toLocaleString(e,r){if(!Ti(this))throw new TypeError("invalid receiver");return new Rh(e,r).format(this)}valueOf(){throw new TypeError("use equals() to compare Temporal.PlainMonthDay")}toPlainDate(e){if(!Ti(this))throw new TypeError("invalid receiver");if(!an(e))throw new TypeError("argument should be an object");let r=R(this,oe),n=Qn(r,["day","monthCode"]),i=Dt(this,n,[]),o=Qn(r,["year"]),s=Dg(r,i,Dt(e,o,[]));s=Dt(s,[...new Set([...n,...o])],[]);let a=dKe(null);return a.overflow="reject",Th(r,s,a)}getISOFields(){if(!Ti(this))throw new TypeError("invalid receiver");return{calendar:R(this,oe),isoDay:R(this,Ce),isoMonth:R(this,ke),isoYear:R(this,Te)}}getCalendar(){if(!Ti(this))throw new TypeError("invalid receiver");return v1(R(this,oe))}static from(e,r){let n=Qt(r);return Ti(e)?(zn(n),UE(R(e,ke),R(e,Ce),R(e,oe),R(e,Te))):Aue(e,n)}};Yl(WE,"Temporal.PlainMonthDay");var Cj=()=>new(_e("%Temporal.Instant%"))(Bj()),Gue=(t,e=Pm())=>{let r=Io(e),n=la(t);return Ua(r,Cj(),n)},ON=(t=Pm())=>Ua(Io(t),Cj(),"iso8601"),Jue=(t,e=Pm())=>{let r=Io(e),n=la(t);return eo(Bj(),r,n)},efe={instant:Cj,plainDateTime:Gue,plainDateTimeISO:ON,plainDate:(t,e=Pm())=>u1(Gue(t,e)),plainDateISO:(t=Pm())=>u1(ON(t)),plainTimeISO:(t=Pm())=>_j(ON(t)),timeZoneId:()=>Pm(),zonedDateTime:Jue,zonedDateTimeISO:(t=Pm())=>Jue("iso8601",t),[Symbol.toStringTag]:"Temporal.Now"};Object.defineProperty(efe,Symbol.toStringTag,{value:"Temporal.Now",writable:!1,enumerable:!1,configurable:!0});var uKe=Object.assign;function Yue(t,e,r){let n=R(t,wt),i=R(t,_t),o=R(t,xt),s=R(t,Et),a=R(t,St),d=R(t,At);if(r){let{unit:u,increment:c,roundingMode:l}=r;({hour:n,minute:i,second:o,millisecond:s,microsecond:a,nanosecond:d}=Rj(n,i,o,s,a,d,c,u,l))}return`${yn(n)}:${yn(i)}${uI(o,s,a,d,e)}`}var GE=class t{constructor(e=0,r=0,n=0,i=0,o=0,s=0){let a=e===void 0?0:gr(e),d=r===void 0?0:gr(r),u=n===void 0?0:gr(n),c=i===void 0?0:gr(i),l=o===void 0?0:gr(o),m=s===void 0?0:gr(s);hI(a,d,u,c,l,m),Zl(this),Rt(this,wt,a),Rt(this,_t,d),Rt(this,xt,u),Rt(this,Et,c),Rt(this,St,l),Rt(this,At,m)}get hour(){if(!kn(this))throw new TypeError("invalid receiver");return R(this,wt)}get minute(){if(!kn(this))throw new TypeError("invalid receiver");return R(this,_t)}get second(){if(!kn(this))throw new TypeError("invalid receiver");return R(this,xt)}get millisecond(){if(!kn(this))throw new TypeError("invalid receiver");return R(this,Et)}get microsecond(){if(!kn(this))throw new TypeError("invalid receiver");return R(this,St)}get nanosecond(){if(!kn(this))throw new TypeError("invalid receiver");return R(this,At)}with(e,r){if(!kn(this))throw new TypeError("invalid receiver");if(!an(e))throw new TypeError("invalid argument");m1(e);let n=zn(Qt(r)),i=FT(e,"partial"),o=FT(this),{hour:s,minute:a,second:d,millisecond:u,microsecond:c,nanosecond:l}=uKe(o,i);return{hour:s,minute:a,second:d,millisecond:u,microsecond:c,nanosecond:l}=eI(s,a,d,u,c,l,n),new t(s,a,d,u,c,l)}add(e){if(!kn(this))throw new TypeError("invalid receiver");return zue("add",this,e)}subtract(e){if(!kn(this))throw new TypeError("invalid receiver");return zue("subtract",this,e)}until(e,r){if(!kn(this))throw new TypeError("invalid receiver");return jue("until",this,e,r)}since(e,r){if(!kn(this))throw new TypeError("invalid receiver");return jue("since",this,e,r)}round(e){if(!kn(this))throw new TypeError("invalid receiver");if(e===void 0)throw new TypeError("options parameter is required");let r=typeof e=="string"?f1("smallestUnit",e):Qt(e),n=y1(r),i=Iu(r,"halfExpand"),o=ua(r,"smallestUnit","time",Bg);g1(n,{hour:24,minute:60,second:60,millisecond:1e3,microsecond:1e3,nanosecond:1e3}[o],!1);let s=R(this,wt),a=R(this,_t),d=R(this,xt),u=R(this,Et),c=R(this,St),l=R(this,At);return{hour:s,minute:a,second:d,millisecond:u,microsecond:c,nanosecond:l}=Rj(s,a,d,u,c,l,n,o,i),new t(s,a,d,u,c,l)}equals(e){if(!kn(this))throw new TypeError("invalid receiver");let r=xh(e);for(let n of[wt,_t,xt,Et,St,At])if(R(this,n)!==R(r,n))return!1;return!0}toString(e){if(!kn(this))throw new TypeError("invalid receiver");let r=Qt(e),n=t6(r),i=Iu(r,"trunc"),o=ua(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}=r6(o,n);return Yue(this,s,{unit:a,increment:d,roundingMode:i})}toJSON(){if(!kn(this))throw new TypeError("invalid receiver");return Yue(this,"auto")}toLocaleString(e,r){if(!kn(this))throw new TypeError("invalid receiver");return new Rh(e,r).format(this)}valueOf(){throw new TypeError("use compare() or equals() to compare Temporal.PlainTime")}toPlainDateTime(e){if(!kn(this))throw new TypeError("invalid receiver");let r=Ur(e),n=R(r,Te),i=R(r,ke),o=R(r,Ce),s=R(r,oe);return aa(n,i,o,R(this,wt),R(this,_t),R(this,xt),R(this,Et),R(this,St),R(this,At),s)}toZonedDateTime(e){if(!kn(this))throw new TypeError("invalid receiver");if(!an(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=Io(i),s=R(n,Te),a=R(n,ke),d=R(n,Ce),u=R(n,oe),c=R(this,wt),l=R(this,_t),m=R(this,xt),p=R(this,Et),g=R(this,St),v=R(this,At);return eo(R(is(o,new(_e("%Temporal.PlainDateTime%"))(s,a,d,c,l,m,p,g,v,u),"compatible"),dt),o,u)}getISOFields(){if(!kn(this))throw new TypeError("invalid receiver");return{isoHour:R(this,wt),isoMicrosecond:R(this,St),isoMillisecond:R(this,Et),isoMinute:R(this,_t),isoNanosecond:R(this,At),isoSecond:R(this,xt)}}static from(e,r){let n=zn(Qt(r));return kn(e)?new t(R(e,wt),R(e,_t),R(e,xt),R(e,Et),R(e,St),R(e,At)):xh(e,n)}static compare(e,r){let n=xh(e),i=xh(r);for(let o of[wt,_t,xt,Et,St,At]){let s=R(n,o),a=R(i,o);if(s!==a)return kg(s-a)}return 0}};Yl(GE,"Temporal.PlainTime");var Rg=class{constructor(e){if(arguments.length<1)throw new RangeError("missing argument: identifier is required");let r=xj(e);Zl(this),Rt(this,Fl,r)}get id(){if(!_c(this))throw new TypeError("invalid receiver");return R(this,Fl)}getOffsetNanosecondsFor(e){if(!_c(this))throw new TypeError("invalid receiver");let r=Tu(e),n=R(this,Fl);return Zw(n)?Bm(n):Eh(n,R(r,dt))}getOffsetStringFor(e){if(!_c(this))throw new TypeError("invalid receiver");return qN(this,Tu(e))}getPlainDateTimeFor(e,r="iso8601"){if(!_c(this))throw new TypeError("invalid receiver");return Ua(this,Tu(e),la(r))}getInstantFor(e,r){if(!_c(this))throw new TypeError("invalid receiver");return is(this,Ig(e),c1(Qt(r)))}getPossibleInstantsFor(e){if(!_c(this))throw new TypeError("invalid receiver");let r=Ig(e),n=_e("%Temporal.Instant%"),i=R(this,Fl);if(Zw(i)){let s=Mm(R(r,Te),R(r,ke),R(r,Ce),R(r,wt),R(r,_t),R(r,xt),R(r,Et),R(r,St),R(r,At));if(s===null)throw new RangeError("DateTime outside of supported range");let a=Bm(i);return[new n(z.default.subtract(s,z.default.BigInt(a)))]}return function(a,d,u,c,l,m,p,g,v,E){let A=Mm(d,u,c,l,m,p,g,v,E);if(A===null)throw new RangeError("DateTime outside of supported range");let P=z.default.subtract(A,Wl);z.default.lessThan(P,jE)&&(P=A);let I=z.default.add(A,Wl);z.default.greaterThan(I,s1)&&(I=A);let $=Eh(a,P),N=Eh(a,I);return($===N?[$]:[$,N]).map(K=>{let F=z.default.subtract(A,z.default.BigInt(K)),U=Sle(a,F);if(d===U.year&&u===U.month&&c===U.day&&l===U.hour&&m===U.minute&&p===U.second&&g===U.millisecond&&v===U.microsecond&&E===U.nanosecond)return F}).filter(K=>K!==void 0)}(i,R(r,Te),R(r,ke),R(r,Ce),R(r,wt),R(r,_t),R(r,xt),R(r,Et),R(r,St),R(r,At)).map(s=>new n(s))}getNextTransition(e){if(!_c(this))throw new TypeError("invalid receiver");let r=Tu(e),n=R(this,Fl);if(Zw(n)||n==="UTC")return null;let i=R(r,dt),o=_e("%Temporal.Instant%");return i=Tle(n,i),i===null?null:new o(i)}getPreviousTransition(e){if(!_c(this))throw new TypeError("invalid receiver");let r=Tu(e),n=R(this,Fl);if(Zw(n)||n==="UTC")return null;let i=R(r,dt),o=_e("%Temporal.Instant%");return i=LN(n,i),i===null?null:new o(i)}toString(){if(!_c(this))throw new TypeError("invalid receiver");return R(this,Fl)}toJSON(){if(!_c(this))throw new TypeError("invalid receiver");return R(this,Fl)}static from(e){return ble(Io(e))}};Yl(Rg,"Temporal.TimeZone"),En("Temporal.TimeZone.prototype.getOffsetNanosecondsFor",Rg.prototype.getOffsetNanosecondsFor),En("Temporal.TimeZone.prototype.getPossibleInstantsFor",Rg.prototype.getPossibleInstantsFor);var lKe=Object.create,JE=class{constructor(e,r,n="iso8601",i=1){yle(this,gr(e),gr(r),la(n),gr(i))}get year(){if(!Sr(this))throw new TypeError("invalid receiver");return tI(R(this,oe),this)}get month(){if(!Sr(this))throw new TypeError("invalid receiver");return rI(R(this,oe),this)}get monthCode(){if(!Sr(this))throw new TypeError("invalid receiver");return i6(R(this,oe),this)}get calendarId(){if(!Sr(this))throw new TypeError("invalid receiver");return no(R(this,oe))}get era(){if(!Sr(this))throw new TypeError("invalid receiver");return nI(R(this,oe),this)}get eraYear(){if(!Sr(this))throw new TypeError("invalid receiver");return iI(R(this,oe),this)}get daysInMonth(){if(!Sr(this))throw new TypeError("invalid receiver");return oI(R(this,oe),this)}get daysInYear(){if(!Sr(this))throw new TypeError("invalid receiver");return sI(R(this,oe),this)}get monthsInYear(){if(!Sr(this))throw new TypeError("invalid receiver");return aI(R(this,oe),this)}get inLeapYear(){if(!Sr(this))throw new TypeError("invalid receiver");return cI(R(this,oe),this)}with(e,r){if(!Sr(this))throw new TypeError("invalid receiver");if(!an(e))throw new TypeError("invalid argument");m1(e);let n=Qt(r),i=R(this,oe),o=Qn(i,["month","monthCode","year"]),s=Dt(this,o,[]);return s=Dg(i,s,Dt(e,o,"partial")),s=Dt(s,o,[]),Og(i,s,n)}add(e,r){if(!Sr(this))throw new TypeError("invalid receiver");return Vue("add",this,e,r)}subtract(e,r){if(!Sr(this))throw new TypeError("invalid receiver");return Vue("subtract",this,e,r)}until(e,r){if(!Sr(this))throw new TypeError("invalid receiver");return Uue("until",this,e,r)}since(e,r){if(!Sr(this))throw new TypeError("invalid receiver");return Uue("since",this,e,r)}equals(e){if(!Sr(this))throw new TypeError("invalid receiver");let r=OE(e);for(let n of[Te,ke,Ce])if(R(this,n)!==R(r,n))return!1;return a6(R(this,oe),R(r,oe))}toString(e){if(!Sr(this))throw new TypeError("invalid receiver");return Rue(this,e6(Qt(e)))}toJSON(){if(!Sr(this))throw new TypeError("invalid receiver");return Rue(this)}toLocaleString(e,r){if(!Sr(this))throw new TypeError("invalid receiver");return new Rh(e,r).format(this)}valueOf(){throw new TypeError("use compare() or equals() to compare Temporal.PlainYearMonth")}toPlainDate(e){if(!Sr(this))throw new TypeError("invalid receiver");if(!an(e))throw new TypeError("argument should be an object");let r=R(this,oe),n=Qn(r,["monthCode","year"]),i=Dt(this,n,[]),o=Qn(r,["day"]),s=Dg(r,i,Dt(e,o,[]));s=Dt(s,[...new Set([...n,...o])],[]);let a=lKe(null);return a.overflow="reject",Th(r,s,a)}getISOFields(){if(!Sr(this))throw new TypeError("invalid receiver");return{calendar:R(this,oe),isoDay:R(this,Ce),isoMonth:R(this,ke),isoYear:R(this,Te)}}getCalendar(){if(!Sr(this))throw new TypeError("invalid receiver");return v1(R(this,oe))}static from(e,r){let n=Qt(r);return Sr(e)?(zn(n),qE(R(e,Te),R(e,ke),R(e,oe),R(e,Ce))):OE(e,n)}static compare(e,r){let n=OE(e),i=OE(r);return km(R(n,Te),R(n,ke),R(n,Ce),R(i,Te),R(i,ke),R(i,Ce))}};Yl(JE,"Temporal.PlainYearMonth");var fKe=Rh.prototype.resolvedOptions,hKe=Object.create,YE=class{constructor(e,r,n="iso8601"){if(arguments.length<1)throw new TypeError("missing argument: epochNanoseconds is required");gle(this,$E(e),Io(r),la(n))}get calendarId(){if(!Le(this))throw new TypeError("invalid receiver");return no(R(this,oe))}get timeZoneId(){if(!Le(this))throw new TypeError("invalid receiver");return LE(R(this,Nr))}get year(){if(!Le(this))throw new TypeError("invalid receiver");return tI(R(this,oe),on(this))}get month(){if(!Le(this))throw new TypeError("invalid receiver");return rI(R(this,oe),on(this))}get monthCode(){if(!Le(this))throw new TypeError("invalid receiver");return i6(R(this,oe),on(this))}get day(){if(!Le(this))throw new TypeError("invalid receiver");return o6(R(this,oe),on(this))}get hour(){if(!Le(this))throw new TypeError("invalid receiver");return R(on(this),wt)}get minute(){if(!Le(this))throw new TypeError("invalid receiver");return R(on(this),_t)}get second(){if(!Le(this))throw new TypeError("invalid receiver");return R(on(this),xt)}get millisecond(){if(!Le(this))throw new TypeError("invalid receiver");return R(on(this),Et)}get microsecond(){if(!Le(this))throw new TypeError("invalid receiver");return R(on(this),St)}get nanosecond(){if(!Le(this))throw new TypeError("invalid receiver");return R(on(this),At)}get era(){if(!Le(this))throw new TypeError("invalid receiver");return nI(R(this,oe),on(this))}get eraYear(){if(!Le(this))throw new TypeError("invalid receiver");return iI(R(this,oe),on(this))}get epochSeconds(){if(!Le(this))throw new TypeError("invalid receiver");let e=R(this,dt);return z.default.toNumber(t1(e,Vl))}get epochMilliseconds(){if(!Le(this))throw new TypeError("invalid receiver");let e=R(this,dt);return z.default.toNumber(t1(e,Ec))}get epochMicroseconds(){if(!Le(this))throw new TypeError("invalid receiver");return JT(t1(R(this,dt),Ar))}get epochNanoseconds(){if(!Le(this))throw new TypeError("invalid receiver");return JT(R(this,dt))}get dayOfWeek(){if(!Le(this))throw new TypeError("invalid receiver");return yj(R(this,oe),on(this))}get dayOfYear(){if(!Le(this))throw new TypeError("invalid receiver");return gj(R(this,oe),on(this))}get weekOfYear(){if(!Le(this))throw new TypeError("invalid receiver");return vj(R(this,oe),on(this))}get yearOfWeek(){if(!Le(this))throw new TypeError("invalid receiver");return bj(R(this,oe),on(this))}get hoursInDay(){if(!Le(this))throw new TypeError("invalid receiver");let e=on(this),r=_e("%Temporal.PlainDateTime%"),n=R(e,Te),i=R(e,ke),o=R(e,Ce),s=new r(n,i,o,0,0,0,0,0,0),a=Pg(n,i,o,0,0,0,1,"reject"),d=new r(a.year,a.month,a.day,0,0,0,0,0,0),u=R(this,Nr),c=R(is(u,s,"compatible"),dt),l=R(is(u,d,"compatible"),dt);return Kl(z.default.subtract(l,c),cle)}get daysInWeek(){if(!Le(this))throw new TypeError("invalid receiver");return wj(R(this,oe),on(this))}get daysInMonth(){if(!Le(this))throw new TypeError("invalid receiver");return oI(R(this,oe),on(this))}get daysInYear(){if(!Le(this))throw new TypeError("invalid receiver");return sI(R(this,oe),on(this))}get monthsInYear(){if(!Le(this))throw new TypeError("invalid receiver");return aI(R(this,oe),on(this))}get inLeapYear(){if(!Le(this))throw new TypeError("invalid receiver");return cI(R(this,oe),on(this))}get offset(){if(!Le(this))throw new TypeError("invalid receiver");return qN(R(this,Nr),R(this,To))}get offsetNanoseconds(){if(!Le(this))throw new TypeError("invalid receiver");return Pu(R(this,Nr),R(this,To))}with(e,r){if(!Le(this))throw new TypeError("invalid receiver");if(!an(e))throw new TypeError("invalid zoned-date-time-like");m1(e);let n=Qt(r),i=R(this,oe),o=Qn(i,["day","hour","microsecond","millisecond","minute","month","monthCode","nanosecond","second","year"]);o.push("offset");let s=Dt(this,o,["offset"]);s=Dg(i,s,Dt(e,o,"partial")),s=Dt(s,o,["offset"]);let a=c1(n),d=KT(n,"prefer"),{year:u,month:c,day:l,hour:m,minute:p,second:g,millisecond:v,microsecond:E,nanosecond:A}=n6(i,s,n),P=Bm(s.offset),I=R(this,Nr);return eo(zT(u,c,l,m,p,g,v,E,A,"option",P,I,a,d,!1),I,i)}withPlainDate(e){if(!Le(this))throw new TypeError("invalid receiver");let r=Ur(e),n=R(r,Te),i=R(r,ke),o=R(r,Ce),s=R(r,oe),a=on(this),d=R(a,wt),u=R(a,_t),c=R(a,xt),l=R(a,Et),m=R(a,St),p=R(a,At);s=vle(R(this,oe),s);let g=R(this,Nr);return eo(R(is(g,new(_e("%Temporal.PlainDateTime%"))(n,i,o,d,u,c,l,m,p,s),"compatible"),dt),g,s)}withPlainTime(e){if(!Le(this))throw new TypeError("invalid receiver");let r=_e("%Temporal.PlainTime%"),n=e===void 0?new r:xh(e),i=on(this),o=R(i,Te),s=R(i,ke),a=R(i,Ce),d=R(this,oe),u=R(n,wt),c=R(n,_t),l=R(n,xt),m=R(n,Et),p=R(n,St),g=R(n,At),v=R(this,Nr);return eo(R(is(v,new(_e("%Temporal.PlainDateTime%"))(o,s,a,u,c,l,m,p,g,d),"compatible"),dt),v,d)}withTimeZone(e){if(!Le(this))throw new TypeError("invalid receiver");let r=Io(e);return eo(R(this,dt),r,R(this,oe))}withCalendar(e){if(!Le(this))throw new TypeError("invalid receiver");let r=la(e);return eo(R(this,dt),R(this,Nr),r)}add(e,r){if(!Le(this))throw new TypeError("invalid receiver");return Hue("add",this,e,r)}subtract(e,r){if(!Le(this))throw new TypeError("invalid receiver");return Hue("subtract",this,e,r)}until(e,r){if(!Le(this))throw new TypeError("invalid receiver");return que("until",this,e,r)}since(e,r){if(!Le(this))throw new TypeError("invalid receiver");return que("since",this,e,r)}round(e){if(!Le(this))throw new TypeError("invalid receiver");if(e===void 0)throw new TypeError("options parameter is required");let r=typeof e=="string"?f1("smallestUnit",e):Qt(e),n=y1(r),i=Iu(r,"halfExpand"),o=ua(r,"smallestUnit","time",Bg,["day"]),s={day:1,hour:24,minute:60,second:60,millisecond:1e3,microsecond:1e3,nanosecond:1e3}[o];g1(n,s,s===1);let a=on(this),d=R(a,Te),u=R(a,ke),c=R(a,Ce),l=R(a,wt),m=R(a,_t),p=R(a,xt),g=R(a,Et),v=R(a,St),E=R(a,At),A=_e("%Temporal.PlainDateTime%"),P=R(this,Nr),I=R(this,oe),$=is(P,new A(R(a,Te),R(a,ke),R(a,Ce),0,0,0,0,0,0),"compatible"),N=Sc($,P,I,0,0,0,1,0,0,0,0,0,0),K=z.default.subtract(N,z.default.BigInt(R($,dt)));if(z.default.lessThanOrEqual(K,Rn))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:v,nanosecond:E}=kj(d,u,c,l,m,p,g,v,E,n,o,i,z.default.toNumber(K)),eo(zT(d,u,c,l,m,p,g,v,E,"option",Pu(P,R(this,To)),P,"compatible","prefer",!1),P,R(this,oe))}equals(e){if(!Le(this))throw new TypeError("invalid receiver");let r=CE(e),n=R(this,dt),i=R(r,dt);return!!z.default.equal(z.default.BigInt(n),z.default.BigInt(i))&&!!wle(R(this,Nr),R(r,Nr))&&a6(R(this,oe),R(r,oe))}toString(e){if(!Le(this))throw new TypeError("invalid receiver");let r=Qt(e),n=e6(r),i=t6(r),o=function(p){return Om(p,"offset",["auto","never"],"auto")}(r),s=Iu(r,"trunc"),a=ua(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 Om(p,"timeZoneName",["auto","never","critical"],"auto")}(r),{precision:u,unit:c,increment:l}=r6(a,i);return Bue(this,u,n,d,o,{unit:c,increment:l,roundingMode:s})}toLocaleString(e,r){if(!Le(this))throw new TypeError("invalid receiver");let n=Qt(r),i=hKe(null);if(Qw(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=LE(R(this,Nr));if(Zw(o))throw new RangeError("toLocaleString does not support offset string time zones");o=xj(o),i.timeZone=o;let s=new Rh(e,i),a=Ge(fKe,s,[]).calendar,d=no(R(this,oe));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,To))}toJSON(){if(!Le(this))throw new TypeError("invalid receiver");return Bue(this,"auto")}valueOf(){throw new TypeError("use compare() or equals() to compare Temporal.ZonedDateTime")}startOfDay(){if(!Le(this))throw new TypeError("invalid receiver");let e=on(this),r=_e("%Temporal.PlainDateTime%"),n=R(this,oe),i=new r(R(e,Te),R(e,ke),R(e,Ce),0,0,0,0,0,0,n),o=R(this,Nr);return eo(R(is(o,i,"compatible"),dt),o,n)}toInstant(){if(!Le(this))throw new TypeError("invalid receiver");return new(_e("%Temporal.Instant%"))(R(this,dt))}toPlainDate(){if(!Le(this))throw new TypeError("invalid receiver");return u1(on(this))}toPlainTime(){if(!Le(this))throw new TypeError("invalid receiver");return _j(on(this))}toPlainDateTime(){if(!Le(this))throw new TypeError("invalid receiver");return on(this)}toPlainYearMonth(){if(!Le(this))throw new TypeError("invalid receiver");let e=R(this,oe);return Og(e,Dt(this,Qn(e,["monthCode","year"]),[]))}toPlainMonthDay(){if(!Le(this))throw new TypeError("invalid receiver");let e=R(this,oe);return d1(e,Dt(this,Qn(e,["day","monthCode"]),[]))}getISOFields(){if(!Le(this))throw new TypeError("invalid receiver");let e=on(this),r=R(this,Nr);return{calendar:R(this,oe),isoDay:R(e,Ce),isoHour:R(e,wt),isoMicrosecond:R(e,St),isoMillisecond:R(e,Et),isoMinute:R(e,_t),isoMonth:R(e,ke),isoNanosecond:R(e,At),isoSecond:R(e,xt),isoYear:R(e,Te),offset:qN(r,R(this,To)),timeZone:r}}getCalendar(){if(!Le(this))throw new TypeError("invalid receiver");return v1(R(this,oe))}getTimeZone(){if(!Le(this))throw new TypeError("invalid receiver");return ble(R(this,Nr))}static from(e,r){let n=Qt(r);return Le(e)?(c1(n),KT(n,"reject"),zn(n),eo(R(e,dt),R(e,Nr),R(e,oe))):CE(e,n)}static compare(e,r){let n=CE(e),i=CE(r),o=R(n,dt),s=R(i,dt);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 on(t){return Ua(R(t,Nr),R(t,To),R(t,oe))}Yl(YE,"Temporal.ZonedDateTime");var Ug=Object.freeze({__proto__:null,Calendar:pn,Duration:HE,Instant:KE,Now:efe,PlainDate:zE,PlainDateTime:VE,PlainMonthDay:WE,PlainTime:GE,PlainYearMonth:JE,TimeZone:Rg,ZonedDateTime:YE});var pKe=[KE,pn,zE,VE,HE,WE,GE,Rg,JE,YE];for(let t of pKe){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 tfe=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},or=class t{static sleep(e){return tfe(this,void 0,void 0,function*(){return new Promise(r=>setTimeout(r,e))})}static minimalSleep(){return tfe(this,void 0,void 0,function*(){yield t.sleep(2)})}static getCurrentTimestamp(){return Ug.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 Ug.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?Ug.Instant.from(r):Ug.Now.instant(),i=Ug.Duration.from(e);return n.add(i).toString({smallestUnit:"microseconds"})}static validateTimestamp(e){try{Ug.Instant.from(e)}catch{throw new se(ne.TimestampInvalid,`Invalid timestamp: ${e}`)}}};var ki=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},mKe=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.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]]);return r},Vr=class t{get message(){if(this._message.authorization===void 0)throw new se(ne.RecordsWriteMissingSigner,"This RecordsWrite is not yet signed, JSON message cannot be generated from an incomplete state.");return this._message}get author(){return this._author}get signaturePayload(){return this._signaturePayload}get owner(){return this._owner}get ownerSignaturePayload(){return this._ownerSignaturePayload}get isSignedByAuthorDelegate(){return ve.isSignedByAuthorDelegate(this._message)}get isSignedByOwnerDelegate(){return ve.isSignedByOwnerDelegate(this._message)}get signer(){return ve.getSigner(this._message)}get ownerSignatureSigner(){var e;return((e=this._message.authorization)===null||e===void 0?void 0:e.ownerSignature)===void 0?void 0:en.getSignerDid(this._message.authorization.ownerSignature.signatures[0])}constructor(e,r){this.parentContextId=r,this._message=e,e.authorization!==void 0&&(this._author=yt.getAuthor(e),this._signaturePayload=en.decodePlainObjectPayload(e.authorization.signature),e.authorization.ownerSignature!==void 0&&(e.authorization.ownerDelegatedGrant!==void 0?this._owner=ve.getSigner(e.authorization.ownerDelegatedGrant):this._owner=en.getSignerDid(e.authorization.ownerSignature.signatures[0]),this._ownerSignaturePayload=en.decodePlainObjectPayload(e.authorization.ownerSignature))),this.attesters=t.getAttesters(e)}static parse(e){return ki(this,void 0,void 0,function*(){let r=JSON.parse(JSON.stringify(e));yield ve.validateSignatureStructure(r.authorization.signature,r.descriptor,"RecordsWriteSignaturePayload"),r.authorization.ownerSignature!==void 0&&(yield ve.validateSignatureStructure(r.authorization.ownerSignature,r.descriptor)),yield t.validateAttestationIntegrity(r);let n=new t(r);return yield n.validateIntegrity(),n})}static create(e){var r,n,i,o;return ki(this,void 0,void 0,function*(){if(e.protocol===void 0&&e.protocolPath!==void 0||e.protocol!==void 0&&e.protocolPath===void 0)throw new se(ne.RecordsWriteCreateProtocolAndProtocolPathMutuallyInclusive,"`protocol` and `protocolPath` must both be defined or undefined at the same time");if(e.data===void 0&&e.dataCid===void 0||e.data!==void 0&&e.dataCid!==void 0)throw new se(ne.RecordsWriteCreateDataAndDataCidMutuallyExclusive,"one and only one parameter between `data` and `dataCid` is required");if(e.dataCid===void 0&&e.dataSize!==void 0||e.dataCid!==void 0&&e.dataSize===void 0)throw new se(ne.RecordsWriteCreateDataCidAndDataSizeMutuallyInclusive,"`dataCid` and `dataSize` must both be defined or undefined at the same time");if(e.signer===void 0&&e.delegatedGrant!==void 0)throw new se(ne.RecordsWriteCreateMissingSigner,"`signer` must be given when `delegatedGrant` is given");let s=(r=e.dataCid)!==null&&r!==void 0?r:yield An.computeDagPbCidFromBytes(e.data),a=(n=e.dataSize)!==null&&n!==void 0?n:e.data.length,d=or.getCurrentTimestamp(),u={interface:Oe.Records,method:Se.Write,protocol:e.protocol!==void 0?Su(e.protocol):void 0,protocolPath:e.protocolPath,recipient:e.recipient,schema:e.schema!==void 0?bh(e.schema):void 0,tags:e.tags,parentId:t.getRecordIdFromContextId(e.parentContextId),dataCid:s,dataSize:a,dateCreated:(i=e.dateCreated)!==null&&i!==void 0?i:d,messageTimestamp:(o=e.messageTimestamp)!==null&&o!==void 0?o:d,published:e.published,datePublished:e.datePublished,dataFormat:e.dataFormat};e.published===!0&&e.datePublished===void 0&&(u.datePublished=d),_n(u);let c=e.recordId,l=yield An.computeCid(u),m=yield t.createAttestation(l,e.attestationSigners),p=yield t.createEncryptionProperty(u,e.encryptionInput),g={recordId:c,descriptor:u};m!==void 0&&(g.attestation=m),p!==void 0&&(g.encryption=p);let v=new t(g,e.parentContextId);return e.signer!==void 0&&(yield v.sign({signer:e.signer,delegatedGrant:e.delegatedGrant,permissionGrantId:e.permissionGrantId,protocolRole:e.protocolRole})),v})}static getRecordIdFromContextId(e){return e?.split("/").filter(r=>r!=="").pop()}static createFrom(e){var r,n,i,o;return ki(this,void 0,void 0,function*(){let s=e.recordsWriteMessage,a=yield t.parse(s),d=or.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:yt.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 ki(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 ki(this,void 0,void 0,function*(){let{signer:n,delegatedGrant:i,permissionGrantId:o,protocolRole:s}=e,a,d;i!==void 0?(a=yield ve.getCid(i),d=en.getSignerDid(i.authorization.signature.signatures[0])):d=en.extractDid(n.keyId);let u=this._message.descriptor,c=yield An.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=en.decodePlainObjectPayload(l),this._author=d})}signAsOwner(e){return ki(this,void 0,void 0,function*(){if(this._author===void 0)throw new se(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 ve.createSignature(r,e);this._message.authorization.ownerSignature=n,this._ownerSignaturePayload=en.decodePlainObjectPayload(n),this._owner=en.extractDid(e.keyId)})}signAsOwnerDelegate(e,r){return ki(this,void 0,void 0,function*(){if(this._author===void 0)throw new se(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 ve.getCid(r),i=this._message.descriptor,o=yield ve.createSignature(i,e,{delegatedGrantId:n});this._message.authorization.ownerSignature=o,this._message.authorization.ownerDelegatedGrant=r,this._ownerSignaturePayload=en.decodePlainObjectPayload(o),this._owner=en.getSignerDid(r.authorization.signature.signatures[0])})}validateIntegrity(){return ki(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 se(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 se(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 se(ne.RecordsWriteValidateIntegrityRecordIdUnauthorized,`recordId in message ${this.message.recordId} does not match recordId in authorization: ${r.recordId}`);if(this.message.contextId!==r.contextId)throw new se(ne.RecordsWriteValidateIntegrityContextIdNotInSignerSignaturePayload,`contextId in message ${this.message.contextId} does not match contextId in authorization: ${r.contextId}`);if(yield yt.validateDelegatedGrantReferentialIntegrity(this.message,r,this.ownerSignaturePayload),r.attestationCid!==void 0){let n=yield An.computeCid(this.message.attestation),i=r.attestationCid;if(i!==n)throw new se(ne.RecordsWriteValidateIntegrityAttestationMismatch,`CID ${n} of attestation property in message does not match attestationCid in authorization: ${i}`)}if(r.encryptionCid!==void 0){let n=yield An.computeCid(this.message.encryption),i=r.encryptionCid;if(i!==n)throw new se(ne.RecordsWriteValidateIntegrityEncryptionCidMismatch,`CID ${n} of encryption property in message does not match encryptionCid in authorization: ${i}`)}this.message.descriptor.protocol!==void 0&&Na(this.message.descriptor.protocol),this.message.descriptor.schema!==void 0&&Sd(this.message.descriptor.schema),or.validateTimestamp(this.message.descriptor.messageTimestamp),or.validateTimestamp(this.message.descriptor.dateCreated),this.message.descriptor.datePublished&&or.validateTimestamp(this.message.descriptor.datePublished)})}static validateAttestationIntegrity(e){return ki(this,void 0,void 0,function*(){if(e.attestation===void 0)return;if(e.attestation.signatures.length!==1)throw new se(ne.RecordsWriteAttestationIntegrityMoreThanOneSignature,`Currently implementation only supports 1 attester, but got ${e.attestation.signatures.length}`);let r=en.decodePlainObjectPayload(e.attestation),{descriptorCid:n}=r,i=yield An.computeCid(e.descriptor);if(n!==i)throw new se(ne.RecordsWriteAttestationIntegrityDescriptorCidMismatch,`descriptorCid ${n} does not match expected descriptorCid ${i}`);let o=Object.keys(r).length;if(o>1)throw new se(ne.RecordsWriteAttestationIntegrityInvalidPayloadProperty,`Only 'descriptorCid' is allowed in attestation payload, but got ${o} properties.`)})}getEntryId(){return ki(this,void 0,void 0,function*(){return yield t.getEntryId(this.author,this.message.descriptor)})}static getEntryId(e,r){return ki(this,void 0,void 0,function*(){if(e===void 0)throw new se(ne.RecordsWriteGetEntryIdUndefinedAuthor,"Property `author` is needed to compute entry ID.");let n=Object.assign({},r);return n.author=e,yield An.computeCid(n)})}isInitialWrite(){return ki(this,void 0,void 0,function*(){return(yield this.getEntryId())===this.message.recordId})}constructIndexes(e){return ki(this,void 0,void 0,function*(){let r=this.message,n=r.descriptor,{tags:i}=n,o=mKe(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=yt.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 ki(this,void 0,void 0,function*(){let r=yield xo.parse(this.message.authorization.authorDelegatedGrant);yield Go.authorizeWrite({recordsWriteMessage:this.message,expectedGrantor:this.author,expectedGrantee:this.signer,permissionGrant:r,messageStore:e})})}authorizeOwnerDelegate(e){return ki(this,void 0,void 0,function*(){let r=yield xo.parse(this.message.authorization.ownerDelegatedGrant);yield Go.authorizeWrite({recordsWriteMessage:this.message,expectedGrantor:this.owner,expectedGrantee:this.ownerSignatureSigner,permissionGrant:r,messageStore:e})})}static isInitialWrite(e){return ki(this,void 0,void 0,function*(){if(e.descriptor.interface!==Oe.Records||e.descriptor.method!==Se.Write)return!1;let r=e,n=yt.getAuthor(r);return(yield t.getEntryId(n,r.descriptor))===r.recordId})}static createEncryptionProperty(e,r){var n,i;return ki(this,void 0,void 0,function*(){if(r===void 0)return;let o=[];for(let a of r.keyEncryptionInputs){if(a.derivationScheme===Qi.ProtocolPath&&e.protocol===void 0)throw new se(ne.RecordsWriteMissingProtocol,"`protocols` encryption scheme cannot be applied to record without the `protocol` property.");if(a.derivationScheme===Qi.Schemas&&e.schema===void 0)throw new se(ne.RecordsWriteMissingSchema,"`schemas` encryption scheme cannot be applied to record without the `schema` property.");let d=Ci.publicJwkToBytes(a.publicKey),u=yield vh.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:_g.EciesSecp256k1,derivationScheme:a.derivationScheme,ephemeralPublicKey:l,initializationVector:m,messageAuthenticationCode:p,encryptedKey:c};a.derivationScheme===Qi.ProtocolContext&&(g.derivedPublicKey=a.publicKey),o.push(g)}return{algorithm:(i=r.algorithm)!==null&&i!==void 0?i:_g.Aes256Ctr,initializationVector:Ye.bytesToBase64Url(r.initializationVector),keyEncryption:o}})}static createAttestation(e,r){return ki(this,void 0,void 0,function*(){if(r===void 0||r.length===0)return;let n={descriptorCid:e},i=Ye.objectToBytes(n);return(yield xg.create(i,r)).getJws()})}static createSignerSignature(e){return ki(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 An.computeCid(o):void 0,m=s?yield An.computeCid(s):void 0,p={recordId:r,descriptorCid:i,contextId:n,attestationCid:l,encryptionCid:m,delegatedGrantId:d,permissionGrantId:u,protocolRole:c};_n(p);let g=Ye.objectToBytes(p);return(yield xg.create(g,[a])).getJws()})}static getInitialWrite(e){return ki(this,void 0,void 0,function*(){for(let r of e)if(yield t.isInitialWrite(r))return r;throw new se(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 se(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=>en.getSignerDid(s))}static fetchInitialRecordsWrite(e,r,n){return ki(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 rfe=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(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 ei(t,e){return rfe(this,void 0,void 0,function*(){if(t===void 0)throw new se(ne.AuthenticateJwsMissing,"Missing JWS.");if(yield x0.verifySignatures(t.signature,e),t.ownerSignature!==void 0&&(yield x0.verifySignatures(t.ownerSignature,e)),t.authorDelegatedGrant!==void 0){let r=yield Vr.parse(t.authorDelegatedGrant);yield x0.verifySignatures(r.message.authorization.signature,e)}if(t.ownerDelegatedGrant!==void 0){let r=yield Vr.parse(t.ownerDelegatedGrant);yield x0.verifySignatures(r.message.authorization.signature,e)}})}function Ql(t,e){return rfe(this,void 0,void 0,function*(){if(e.author!==t)throw new se(ne.AuthorizationAuthorNotOwner,`Message authored by ${e.author}, not authored by expected owner ${t}.`)})}h();var yKe=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},d6=class{isActiveTenant(e){return yKe(this,void 0,void 0,function*(){return{isActiveTenant:!0}})}};h();h();var pi=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=ve.getSigner(e),e.authorization.authorDelegatedGrant!==void 0?this._author=ve.getSigner(e.authorization.authorDelegatedGrant):this._author=this._signer,this._signaturePayload=en.decodePlainObjectPayload(e.authorization.signature))}toJSON(){return this.message}};var $j=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},Um=class t extends pi{static parse(e){return $j(this,void 0,void 0,function*(){if(e.descriptor.filter.published===!1&&(e.descriptor.dateSort===Eo.PublishedAscending||e.descriptor.dateSort===Eo.PublishedDescending))throw new se(ne.RecordsQueryParseFilterPublishedSortInvalid,`queries must not filter for \`published:false\` and sort by ${e.descriptor.dateSort}`);let r;if(e.authorization!==void 0&&(r=yield ve.validateSignatureStructure(e.authorization.signature,e.descriptor)),yield yt.validateDelegatedGrantReferentialIntegrity(e,r),r?.protocolRole!==void 0&&e.descriptor.filter.protocolPath===void 0)throw new se(ne.RecordsQueryFilterMissingRequiredProperties,"Role-authorized queries must include `protocolPath` in the filter");return e.descriptor.filter.protocol!==void 0&&Na(e.descriptor.filter.protocol),e.descriptor.filter.schema!==void 0&&Sd(e.descriptor.filter.schema),or.validateTimestamp(e.descriptor.messageTimestamp),new t(e)})}static create(e){var r;return $j(this,void 0,void 0,function*(){let n={interface:Oe.Records,method:Se.Query,messageTimestamp:(r=e.messageTimestamp)!==null&&r!==void 0?r:or.getCurrentTimestamp(),filter:yt.normalizeFilter(e.filter),dateSort:e.dateSort,pagination:e.pagination};if(e.filter.published===!1&&(e.dateSort===Eo.PublishedAscending||e.dateSort===Eo.PublishedDescending))throw new se(ne.RecordsQueryCreateFilterPublishedSortInvalid,`queries must not filter for \`published:false\` and sort by ${e.dateSort}`);_n(n);let i=e.signer,o;i&&(o=yield ve.createAuthorization({descriptor:n,signer:i,protocolRole:e.protocolRole,delegatedGrant:e.delegatedGrant}));let s={descriptor:n,authorization:o};return ve.validateJsonSchema(s),new t(s)})}authorizeDelegate(e){return $j(this,void 0,void 0,function*(){let r=yield xo.parse(this.message.authorization.authorDelegatedGrant);yield Go.authorizeQueryOrSubscribe({incomingMessage:this.message,expectedGrantee:this.signer,expectedGrantor:this.author,permissionGrant:r,messageStore:e})})}};h();var pI=qt(ST(),1),nfe=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},ku=class t{static toBytes(e){return nfe(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 nfe(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 pI.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<r;i++){let o=new pI.PassThrough;e.pipe(o),n.push(o)}return n}};h();h();h();var ife=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},qm=class t extends pi{static parse(e){return ife(this,void 0,void 0,function*(){return ve.validateJsonSchema(e),yield ve.validateSignatureStructure(e.authorization.signature,e.descriptor),or.validateTimestamp(e.descriptor.messageTimestamp),new t(e)})}static create(e){var r;return ife(this,void 0,void 0,function*(){let n={interface:Oe.Events,method:Se.Get,messageTimestamp:(r=e.messageTimestamp)!==null&&r!==void 0?r:or.getCurrentTimestamp()};e.cursor&&(n.cursor=e.cursor);let i=yield ve.createAuthorization({descriptor:n,signer:e.signer}),o={descriptor:n,authorization:i};return ve.validateJsonSchema(o),new t(o)})}};h();function er(t,e){let r=t instanceof Error?t.message:"Error";return{status:{code:e,detail:r}}}var gKe=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},mI=class{constructor(e,r){this.didResolver=e,this.eventLog=r}handle({tenant:e,message:r}){return gKe(this,void 0,void 0,function*(){let n;try{n=yield qm.parse(r)}catch(a){return er(a,400)}try{yield ei(r.authorization,this.didResolver),yield Ql(e,n)}catch(a){return er(a,401)}let{cursor:i}=r.descriptor,{events:o,cursor:s}=yield this.eventLog.getEvents(e,i);return{status:{code:200,detail:"OK"},entries:o,cursor:s}})}};h();h();var Lm=class{static normalizeFilters(e){let r=[];for(let n of e){let i;this.isRecordsFilter(n)?i=yt.normalizeFilter(n):i=n,_n(i),ME(i)||r.push(i)}return r}static convertFilters(e){let r=[];for(let n of e)this.isRecordsFilter(n)?r.push(yt.convertFilter(n)):r.push(this.convertFilter(n));return r}static convertFilter(e){let r=Object.assign({},e),{dateUpdated:n}=e,i=n?Zn.convertRangeCriterion(n):void 0;return i&&(r.messageTimestamp=i,delete r.dateUpdated),r}static isRecordsFilter(e){return"author"in e||"dateCreated"in e||"dataFormat"in e||"dataSize"in e||"parentId"in e||"recordId"in e||"schema"in e||"protocol"in e||"protocolPath"in e||"recipient"in e}};h();var ofe=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},Km=class t extends pi{static parse(e){return ofe(this,void 0,void 0,function*(){ve.validateJsonSchema(e),yield ve.validateSignatureStructure(e.authorization.signature,e.descriptor);for(let r of e.descriptor.filters)"protocol"in r&&r.protocol!==void 0&&Na(r.protocol),"schema"in r&&r.schema!==void 0&&Sd(r.schema);return new t(e)})}static create(e){var r;return ofe(this,void 0,void 0,function*(){let n={interface:Oe.Events,method:Se.Query,filters:Lm.normalizeFilters(e.filters),messageTimestamp:(r=e.messageTimestamp)!==null&&r!==void 0?r:or.getCurrentTimestamp(),cursor:e.cursor};_n(n);let i=yield ve.createAuthorization({descriptor:n,signer:e.signer}),o={descriptor:n,authorization:i};return ve.validateJsonSchema(o),new t(o)})}};var vKe=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},yI=class{constructor(e,r){this.didResolver=e,this.eventLog=r}handle({tenant:e,message:r}){return vKe(this,void 0,void 0,function*(){let n;try{n=yield Km.parse(r)}catch(a){return er(a,400)}try{yield ei(r.authorization,this.didResolver),yield Ql(e,n)}catch(a){return er(a,401)}let i=Lm.convertFilters(r.descriptor.filters),{events:o,cursor:s}=yield this.eventLog.queryEvents(e,i,r.descriptor.cursor);return{status:{code:200,detail:"OK"},entries:o,cursor:s}})}};h();h();var sfe=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},Fm=class t extends pi{static parse(e){return sfe(this,void 0,void 0,function*(){ve.validateJsonSchema(e),yield ve.validateSignatureStructure(e.authorization.signature,e.descriptor);for(let r of e.descriptor.filters)"protocol"in r&&r.protocol!==void 0&&Na(r.protocol),"schema"in r&&r.schema!==void 0&&Sd(r.schema);return or.validateTimestamp(e.descriptor.messageTimestamp),new t(e)})}static create(e){var r,n;return sfe(this,void 0,void 0,function*(){let i=or.getCurrentTimestamp(),o={interface:Oe.Events,method:Se.Subscribe,filters:(r=e.filters)!==null&&r!==void 0?r:[],messageTimestamp:(n=e.messageTimestamp)!==null&&n!==void 0?n:i};_n(o);let s=yield ve.createAuthorization({descriptor:o,signer:e.signer}),a={descriptor:o,authorization:s};return ve.validateJsonSchema(a),new t(a)})}};var bKe=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},gI=class{constructor(e,r){this.didResolver=e,this.eventStream=r}handle({tenant:e,message:r,subscriptionHandler:n}){return bKe(this,void 0,void 0,function*(){if(this.eventStream===void 0)return er(new se(ne.EventsSubscribeEventStreamUnimplemented,"Subscriptions are not supported"),501);let i;try{i=yield Fm.parse(r)}catch(c){return er(c,400)}try{yield ei(r.authorization,this.didResolver),yield Ql(e,i)}catch(c){return er(c,401)}let{filters:o}=r.descriptor,s=Lm.convertFilters(o),a=yield ve.getCid(r),d=(c,l,m)=>{e===c&&Zn.matchAnyFilter(m,s)&&n(l)},u=yield this.eventStream.subscribe(e,a,d);return{status:{code:200,detail:"OK"},subscription:u}})}};h();h();var afe=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},zm=class t extends pi{static parse(e){return afe(this,void 0,void 0,function*(){return ve.validateJsonSchema(e),this.validateMessageCids(e.descriptor.messageCids),yield ve.validateSignatureStructure(e.authorization.signature,e.descriptor),or.validateTimestamp(e.descriptor.messageTimestamp),new t(e)})}static create(e){var r;return afe(this,void 0,void 0,function*(){let n={interface:Oe.Messages,method:Se.Get,messageCids:e.messageCids,messageTimestamp:(r=e?.messageTimestamp)!==null&&r!==void 0?r:or.getCurrentTimestamp()},i=yield ve.createAuthorization({descriptor:n,signer:e.signer}),o={descriptor:n,authorization:i};return ve.validateJsonSchema(o),t.validateMessageCids(e.messageCids),new t(o)})}static validateMessageCids(e){for(let r of e)try{An.parseCid(r)}catch{throw new se(ne.MessageGetInvalidCid,`${r} is not a valid CID`)}}};var wKe=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},vI=class{constructor(e,r,n){this.didResolver=e,this.messageStore=r,this.dataStore=n}handle({tenant:e,message:r}){return wKe(this,void 0,void 0,function*(){let n;try{n=yield zm.parse(r)}catch(a){return er(a,400)}try{yield ei(r.authorization,this.didResolver),yield Ql(e,n)}catch(a){return er(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!==Oe.Records||c!==Se.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 Wpe=qt(Rq(),1);h();var Oh;(function(t){t.Anyone="anyone",t.Author="author",t.Recipient="recipient"})(Oh||(Oh={}));var mi;(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"})(mi||(mi={}));var Hpe=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},pGe=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.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]]);return r},Qm=class t extends pi{static parse(e){return Hpe(this,void 0,void 0,function*(){return ve.validateJsonSchema(e),t.validateProtocolDefinition(e.descriptor.definition),yield ve.validateSignatureStructure(e.authorization.signature,e.descriptor),or.validateTimestamp(e.descriptor.messageTimestamp),new t(e)})}static create(e){var r;return Hpe(this,void 0,void 0,function*(){let n={interface:Oe.Protocols,method:Se.Configure,messageTimestamp:(r=e.messageTimestamp)!==null&&r!==void 0?r:or.getCurrentTimestamp(),definition:t.normalizeDefinition(e.definition)},i=yield ve.createAuthorization({descriptor:n,signer:e.signer,permissionGrantId:e.permissionGrantId}),o={descriptor:n,authorization:i};return ve.validateJsonSchema(o),t.validateProtocolDefinition(o.descriptor.definition),new t(o)})}static validateProtocolDefinition(e){let{protocol:r,types:n}=e;Na(r);for(let i in n){let o=n[i].schema;o!==void 0&&Sd(o)}t.validateStructure(e)}static validateStructure(e){let r=Object.keys(e.types),n=t.fetchAllRolePathsRecursively("",e.structure,[]);t.validateRuleSetRecursively({ruleSet:e.structure,ruleSetProtocolPath:"",recordTypes:r,roles:n})}static fetchAllRolePathsRecursively(e,r,n){if(e.split("/").length>10)throw new se(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<d)throw new se(ne.ProtocolsConfigureInvalidSize,`Invalid size range found: max limit ${u} less than min limit ${d} at protocol path '${i}'`)}if(n.$tags){let d=new Wpe.default.default,u=n.$tags,{$allowUndefinedTags:c,$requiredTags:l}=u,m=pGe(u,["$allowUndefinedTags","$requiredTags"]);for(let p in m){let g=m[p];if(!d.validateSchema(g)){let v=d.errorsText(d.errors,{dataVar:`${i}/$tags/${p}`});throw new se(ne.ProtocolsConfigureInvalidTagSchema,`tags schema validation error: ${v}`)}}}let a=(r=n.$actions)!==null&&r!==void 0?r:[];for(let d=0;d<a.length;d++){let u=a[d];if(u.role!==void 0&&!s.includes(u.role))throw new se(ne.ProtocolsConfigureRoleDoesNotExistAtGivenPath,`Role in action ${JSON.stringify(u)} for rule set ${i} does not exist.`);if(u.who==="anyone"&&u.of)throw new se(ne.ProtocolsConfigureInvalidActionOfNotAllowed,`'of' is not allowed at rule set protocol path (${i})`);if(u.who===Oh.Recipient&&u.of===void 0&&u.can.some(l=>![mi.CoUpdate,mi.CoDelete,mi.CoPrune].includes(l)))throw new se(ne.ProtocolsConfigureInvalidRecipientOfAction,"Rules for `recipient` without `of` property must have `can` containing only `co-update`, `co-delete`, and `co-prune`.");if(u.who===Oh.Author&&!u.of)throw new se(ne.ProtocolsConfigureInvalidActionMissingOf,"'of' is required when 'author' is specified as 'who'");if(u.can!==void 0){if(u.can.includes(mi.Update)&&!u.can.includes(mi.Create))throw new se(ne.ProtocolsConfigureInvalidActionUpdateWithoutCreate,`Action rule ${JSON.stringify(u)} contains 'update' action but missing the required 'create' action.`);if(u.can.includes(mi.Delete)&&!u.can.includes(mi.Create))throw new se(ne.ProtocolsConfigureInvalidActionDeleteWithoutCreate,`Action rule ${JSON.stringify(u)} contains 'delete' action but missing the required 'create' action.`)}for(let c=d+1;c<a.length;c++){let l=a[c];if(u.who!==void 0){if(u.who===l.who&&u.of===l.of)throw new se(ne.ProtocolsConfigureDuplicateActorInRuleSet,`More than one action rule per actor ${u.who} of ${u.of} not allowed within a rule set: ${JSON.stringify(u)}`)}else if(u.role===l.role)throw new se(ne.ProtocolsConfigureDuplicateRoleInRuleSet,`More than one action rule per role ${u.role} not allowed within a rule set: ${JSON.stringify(u)}`)}}for(let d in n){if(d.startsWith("$"))continue;if(!o.includes(d))throw new se(ne.ProtocolsConfigureInvalidRuleSetRecordType,`Rule set ${d} is not declared as an allowed type in the protocol definition.`);let u=n[d],c;i===""?c=d:c=`${i}/${d}`,t.validateRuleSetRecursively({ruleSet:u,ruleSetProtocolPath:c,recordTypes:o,roles:s})}}static normalizeDefinition(e){let r=Object.assign({},e.types);for(let n in r){let i=r[n].schema;i!==void 0&&(r[n].schema=bh(i))}return Object.assign(Object.assign({},e),{protocol:Su(e.protocol),types:r})}};var mGe=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},yGe=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.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]]);return r},YI=class t{constructor(e,r,n,i){this.didResolver=e,this.messageStore=r,this.eventLog=n,this.eventStream=i}handle({tenant:e,message:r}){return mGe(this,void 0,void 0,function*(){let n;try{n=yield Qm.parse(r)}catch(c){return er(c,400)}try{yield ei(r.authorization,this.didResolver),yield Ql(e,n)}catch(c){return er(c,401)}let i={interface:Oe.Protocols,method:Se.Configure,protocol:r.descriptor.definition.protocol},{messages:o}=yield this.messageStore.query(e,[i]),s=yield ve.getNewestMessage(o),a=!1;(s===void 0||(yield ve.isNewer(r,s)))&&(a=!0,s=r);let d;if(a){let c=t.constructIndexes(n);yield this.messageStore.put(e,r,c);let l=yield ve.getCid(r);yield this.eventLog.append(e,l,c),this.eventStream!==void 0&&this.eventStream.emit(e,{message:r},c),d={status:{code:202,detail:"Accepted"}}}else d={status:{code:409,detail:"Conflict"}};let u=[];for(let c of o)if(yield ve.isNewer(s,c)){let l=yield ve.getCid(c);u.push(l),yield this.messageStore.delete(e,l)}return yield this.eventLog.deleteEventsByCid(e,u),d})}static constructIndexes(e){let r=e.message.descriptor,{definition:n}=r,i=yGe(r,["definition"]),{author:o}=e;return Object.assign(Object.assign({},i),{author:o,protocol:n.protocol,published:n.published})}};h();h();h();var ZI=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},yi=class t{static parseRequest(e){return Ye.base64UrlToObject(e)}static createRequest(e){return ZI(this,void 0,void 0,function*(){let r=t.normalizePermissionScope(e.scope),n={description:e.description,delegated:e.delegated,scope:r,conditions:e.conditions},i=Ye.objectToBytes(n);return{recordsWrite:yield Vr.create({signer:e.signer,messageTimestamp:e.dateRequested,protocol:t.uri,protocolPath:t.requestPath,dataFormat:"application/json",data:i}),permissionRequestData:n,permissionRequestBytes:i}})}static createGrant(e){return ZI(this,void 0,void 0,function*(){let r=t.normalizePermissionScope(e.scope),n={dateExpires:e.dateExpires,requestId:e.requestId,description:e.description,delegated:e.delegated,scope:r,conditions:e.conditions},i=Ye.objectToBytes(n),o=yield Vr.create({signer:e.signer,messageTimestamp:e.dateGranted,dateCreated:e.dateGranted,recipient:e.grantedTo,protocol:t.uri,protocolPath:t.grantPath,dataFormat:"application/json",data:i}),s=Object.assign(Object.assign({},o.message),{encodedData:Ye.bytesToBase64Url(i)});return{recordsWrite:o,permissionGrantData:n,permissionGrantBytes:i,dataEncodedMessage:s}})}static createRevocation(e){return ZI(this,void 0,void 0,function*(){let r={description:e.description},n=Ye.objectToBytes(r);return{recordsWrite:yield Vr.create({signer:e.signer,parentContextId:e.grantId,protocol:t.uri,protocolPath:t.revocationPath,dataFormat:"application/json",data:n}),permissionRevocationData:r,permissionRevocationBytes:n}})}static validateSchema(e,r){let n=Ye.bytesToString(r),i=JSON.parse(n);if(e.descriptor.protocolPath===t.requestPath)Hf("PermissionRequestData",i);else if(e.descriptor.protocolPath===t.grantPath){Hf("PermissionGrantData",i);let o=i;t.validateScope(o.scope),or.validateTimestamp(o.dateExpires)}else if(e.descriptor.protocolPath===t.revocationPath)Hf("PermissionRevocationData",i);else throw new se(ne.PermissionsProtocolValidateSchemaUnexpectedRecord,`Unexpected permission record: ${e.descriptor.protocolPath}`)}static fetchGrant(e,r,n){return ZI(this,void 0,void 0,function*(){let i={recordId:n,isLatestBaseState:!0},{messages:o}=yield r.query(e,[i]),s=o[0],a=s?.descriptor.interface,d=s?.descriptor.method;if(a!==Oe.Records||d!==Se.Write||s.descriptor.protocolPath!==t.grantPath)throw new se(ne.GrantAuthorizationGrantMissing,`Could not find permission grant with record ID ${n}.`);let u=s;return yield xo.parse(u)})}static normalizePermissionScope(e){let r=Object.assign({},e);return t.isRecordPermissionScope(r)&&(r.protocol!==void 0&&(r.protocol=Su(r.protocol)),r.schema!==void 0&&(r.schema=bh(r.schema))),r}static isRecordPermissionScope(e){return e.interface==="Records"}static validateScope(e){if(this.isRecordPermissionScope(e)){if(e.schema!==void 0&&(e.protocol!==void 0||e.contextId!==void 0||e.protocolPath))throw new se(ne.PermissionsProtocolValidateScopeSchemaProhibitedProperties,"Permission grants that have `schema` present cannot also have protocol-related properties present");if(e.protocol!==void 0&&e.contextId!==void 0&&e.protocolPath!==void 0)throw new se(ne.PermissionsProtocolValidateScopeContextIdProhibitedProperties,"Permission grants cannot have both `contextId` and `protocolPath` present")}}};yi.uri="https://tbd.website/dwn/permissions";yi.requestPath="request";yi.grantPath="grant";yi.revocationPath="grant/revocation";yi.definition={published:!0,protocol:yi.uri,types:{request:{dataFormats:["application/json"]},grant:{dataFormats:["application/json"]},revocation:{dataFormats:["application/json"]}},structure:{request:{$size:{max:1e4},$actions:[{who:"anyone",can:["create"]}]},grant:{$size:{max:1e4},$actions:[{who:"recipient",of:"grant",can:["read","query"]}],revocation:{$size:{max:1e4},$actions:[{who:"anyone",can:["read"]}]}}}};var Bq=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},ey=class t extends pi{static parse(e){return Bq(this,void 0,void 0,function*(){return e.authorization!==void 0&&(yield ve.validateSignatureStructure(e.authorization.signature,e.descriptor)),e.descriptor.filter!==void 0&&Na(e.descriptor.filter.protocol),or.validateTimestamp(e.descriptor.messageTimestamp),new t(e)})}static create(e){var r;return Bq(this,void 0,void 0,function*(){let n={interface:Oe.Protocols,method:Se.Query,messageTimestamp:(r=e.messageTimestamp)!==null&&r!==void 0?r:or.getCurrentTimestamp(),filter:e.filter?t.normalizeFilter(e.filter):void 0};_n(n);let i;e.signer!==void 0&&(i=yield ve.createAuthorization({descriptor:n,signer:e.signer,permissionGrantId:e.permissionGrantId}));let o={descriptor:n,authorization:i};return ve.validateJsonSchema(o),new t(o)})}static normalizeFilter(e){return Object.assign(Object.assign({},e),{protocol:Su(e.protocol)})}authorize(e,r){return Bq(this,void 0,void 0,function*(){if(this.author!==e)if(this.author!==void 0&&this.signaturePayload.permissionGrantId){let n=yield yi.fetchGrant(e,r,this.signaturePayload.permissionGrantId);yield wh.performBaseValidation({incomingMessage:this.message,expectedGrantor:e,expectedGrantee:this.author,permissionGrant:n,messageStore:r})}else throw new se(ne.ProtocolsQueryUnauthorized,"The ProtocolsQuery failed authorization")})}};var Gpe=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},XI=class{constructor(e,r,n){this.didResolver=e,this.messageStore=r,this.dataStore=n}handle({tenant:e,message:r}){return Gpe(this,void 0,void 0,function*(){let n;try{n=yield ey.parse(r)}catch(s){return er(s,400)}try{yield ei(r.authorization,this.didResolver),yield n.authorize(e,this.messageStore)}catch(s){if(s.code===ne.AuthenticateJwsMissing||s.code===ne.ProtocolsQueryUnauthorized){let a=yield this.fetchPublishedProtocolsConfigure(e,n);return{status:{code:200,detail:"OK"},entries:a}}else return er(s,401)}let i=Object.assign(Object.assign({},r.descriptor.filter),{interface:Oe.Protocols,method:Se.Configure});_n(i);let{messages:o}=yield this.messageStore.query(e,[i]);return{status:{code:200,detail:"OK"},entries:o}})}fetchPublishedProtocolsConfigure(e,r){return Gpe(this,void 0,void 0,function*(){let n=Object.assign(Object.assign({},r.message.descriptor.filter),{interface:Oe.Protocols,method:Se.Configure,published:!0}),{messages:i}=yield this.messageStore.query(e,[n]);return i})}};h();h();var Jpe=qt(Rq(),1);var za=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},gGe=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.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]]);return r},Tc=class t{static validateReferentialIntegrity(e,r,n){return za(this,void 0,void 0,function*(){let i=yield t.fetchProtocolDefinition(e,r.message.descriptor.protocol,n);t.verifyType(r.message,i.types),yield t.verifyProtocolPathAndContextId(e,r,n);let o=t.getRuleSet(r.message.descriptor.protocolPath,i);yield t.verifyAsRoleRecordIfNeeded(e,r,o,n),t.verifySizeLimit(r,o),t.verifyTagsIfNeeded(r,o)})}static authorizeWrite(e,r,n){return za(this,void 0,void 0,function*(){let i=yield t.fetchInitialWrite(e,r.message.recordId,n),o;i===void 0?o=yield t.constructRecordChain(e,r.message.descriptor.parentId,n):o=yield t.constructRecordChain(e,r.message.recordId,n);let s=yield t.fetchProtocolDefinition(e,r.message.descriptor.protocol,n),a=t.getRuleSet(r.message.descriptor.protocolPath,s);yield t.verifyInvokedRole(e,r,r.message.descriptor.protocol,r.message.contextId,s,n),yield t.authorizeAgainstAllowedActions(e,r,a,o,n)})}static authorizeRead(e,r,n,i){return za(this,void 0,void 0,function*(){let o=yield t.constructRecordChain(e,n.message.recordId,i),s=yield t.fetchProtocolDefinition(e,n.message.descriptor.protocol,i),a=t.getRuleSet(n.message.descriptor.protocolPath,s);yield t.verifyInvokedRole(e,r,n.message.descriptor.protocol,n.message.contextId,s,i),yield t.authorizeAgainstAllowedActions(e,r,a,o,i)})}static authorizeQueryOrSubscribe(e,r,n){return za(this,void 0,void 0,function*(){let{protocol:i,protocolPath:o,contextId:s}=r.message.descriptor.filter,a=yield t.fetchProtocolDefinition(e,i,n),d=t.getRuleSet(o,a);yield t.verifyInvokedRole(e,r,i,s,a,n),yield t.authorizeAgainstAllowedActions(e,r,d,[],n)})}static authorizeDelete(e,r,n,i){return za(this,void 0,void 0,function*(){let o=yield t.constructRecordChain(e,r.message.descriptor.recordId,i),s=yield t.fetchProtocolDefinition(e,n.message.descriptor.protocol,i),a=t.getRuleSet(n.message.descriptor.protocolPath,s);yield t.verifyInvokedRole(e,r,n.message.descriptor.protocol,n.message.contextId,s,i),yield t.authorizeAgainstAllowedActions(e,r,a,o,i)})}static fetchProtocolDefinition(e,r,n){return za(this,void 0,void 0,function*(){if(r===yi.uri)return yi.definition;let i={interface:Oe.Protocols,method:Se.Configure,protocol:r},{messages:o}=yield n.query(e,[i]);if(o.length===0)throw new se(ne.ProtocolAuthorizationProtocolNotFound,`unable to find protocol definition for ${r}`);return o[0].descriptor.definition})}static constructRecordChain(e,r,n){return za(this,void 0,void 0,function*(){if(r===void 0)return[];let i=[],o=r;for(;o!==void 0;){let s=yield t.fetchInitialWrite(e,o,n);if(s===void 0)throw new se(ne.ProtocolAuthorizationParentNotFoundConstructingRecordChain,`Unexpected error that should never trigger: no parent found with ID ${o} when constructing record chain.`);i.push(s),o=s.descriptor.parentId}return i.reverse()})}static fetchInitialWrite(e,r,n){return za(this,void 0,void 0,function*(){let i={interface:Oe.Records,method:Se.Write,recordId:r},{messages:o}=yield n.query(e,[i]);return o.length===0?void 0:yield Vr.getInitialWrite(o)})}static getRuleSet(e,r){let n=t.getRuleSetAtProtocolPath(e,r);if(n===void 0)throw new se(ne.ProtocolAuthorizationMissingRuleSet,`No rule set defined for protocolPath ${e}`);return n}static verifyProtocolPathAndContextId(e,r,n){var i;return za(this,void 0,void 0,function*(){let o=r.message.descriptor.protocolPath,s=t.getTypeName(o),a=r.message.descriptor.parentId;if(a===void 0){if(o!==s)throw new se(ne.ProtocolAuthorizationParentlessIncorrectProtocolPath,`Declared protocol path '${o}' is not valid for records with no parent'.`);return}let d=r.message.descriptor.protocol,u={isLatestBaseState:!0,interface:Oe.Records,method:Se.Write,protocol:d,recordId:a},{messages:c}=yield n.query(e,[u]),l=c[0];if(`${(i=l?.descriptor)===null||i===void 0?void 0:i.protocolPath}/${s}`!==o)throw new se(ne.ProtocolAuthorizationIncorrectProtocolPath,`Could not find matching parent record to verify declared protocol path '${o}'.`);let g=`${l.contextId}/${r.message.recordId}`,v=r.message.contextId;if(v!==g)throw new se(ne.ProtocolAuthorizationIncorrectContextId,`Declared contextId '${v}' is not the same as expected: '${g}'.`)})}static verifyType(e,r){let n=Object.keys(r),i=e.descriptor.protocolPath,o=t.getTypeName(i);if(!n.includes(o))throw new se(ne.ProtocolAuthorizationInvalidType,`record with type ${o} not allowed in protocol`);let s=e.descriptor.protocolPath,a=t.getTypeName(s),d=r[a],{schema:u}=e.descriptor;if(d.schema!==void 0&&d.schema!==u)throw new se(ne.ProtocolAuthorizationInvalidSchema,`type '${a}' must have schema '${d.schema}', instead has '${u}'`);let{dataFormat:c}=e.descriptor;if(d.dataFormats!==void 0&&!d.dataFormats.includes(c))throw new se(ne.ProtocolAuthorizationIncorrectDataFormat,`type '${a}' must have data format in (${d.dataFormats}), instead has '${c}'`)}static verifyInvokedRole(e,r,n,i,o,s){var a;return za(this,void 0,void 0,function*(){let d=(a=r.signaturePayload)===null||a===void 0?void 0:a.protocolRole;if(d===void 0)return;let u=t.getRuleSetAtProtocolPath(d,o);if(u===void 0||!u.$role)throw new se(ne.ProtocolAuthorizationNotARole,`Protocol path ${d} does not match role record type.`);let c={interface:Oe.Records,method:Se.Write,protocol:n,protocolPath:d,recipient:r.author,isLatestBaseState:!0},l=d.split("/").length-1;if(i===void 0&&l>0)throw new se(ne.ProtocolAuthorizationMissingContextId,"Could not verify role because contextId is missing.");if(l>0){let g=i.split("/").slice(0,l).join("/"),v=Zn.constructPrefixFilterAsRangeFilter(g);c.contextId=v}let{messages:m}=yield s.query(e,[c]);if(m.length===0)throw new se(ne.ProtocolAuthorizationMatchingRoleRecordNotFound,`No matching role record found for protocol path ${d}`)})}static getActionsSeekingARuleMatch(e,r,n){return za(this,void 0,void 0,function*(){switch(r.message.descriptor.method){case Se.Delete:let i=r,o=i.message.descriptor.recordId,s=yield Vr.fetchInitialRecordsWrite(n,e,o);if(s===void 0)return[];let a=[];return i.message.descriptor.prune?(a.push(mi.CoPrune),r.author===s.author&&a.push(mi.Prune)):(a.push(mi.CoDelete),r.author===s.author&&a.push(mi.Delete)),a;case Se.Query:return[mi.Query];case Se.Read:return[mi.Read];case Se.Subscribe:return[mi.Subscribe];case Se.Write:if(yield r.isInitialWrite())return[mi.Create];{let c=r.message.recordId,l=yield Vr.fetchInitialRecordsWrite(n,e,c);return l===void 0?[]:r.author===l.author?[mi.CoUpdate,mi.Update]:[mi.CoUpdate]}}return[]})}static authorizeAgainstAllowedActions(e,r,n,i,o){var s;return za(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 se(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(v=>d.includes(v)))continue;if(m.who===Oh.Anyone)return;if(u===void 0)continue;if(l!==void 0){if(m.role===l)return;continue}if(m.who===Oh.Recipient&&m.of===void 0){let v;if(r.message.descriptor.method===Se.Write?v=r.message:v=i[i.length-1],v.descriptor.recipient===u)return;continue}if(yield t.checkActor(u,m,i))return}throw new se(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(o<n)throw new se(ne.ProtocolAuthorizationMinSizeInvalid,`data size ${o} is less than allowed ${n}`);if(i!==void 0&&o>i)throw new se(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=gGe(s,["$allowUndefinedTags","$requiredTags"]),c=a||!1,l=d||[],m=new Jpe.default.default,p=m.compile({type:"object",properties:u,required:l,additionalProperties:c});if(!p(n)){let v=m.errorsText(p.errors,{dataVar:`${i}/${o}/$tags`});throw new se(ne.ProtocolAuthorizationTagsInvalidSchema,`tags schema validation error: ${v}`)}}}static verifyAsRoleRecordIfNeeded(e,r,n,i){return za(this,void 0,void 0,function*(){if(!n.$role)return;let o=r,s=o.message.descriptor.recipient;if(s===void 0)throw new se(ne.ProtocolAuthorizationRoleMissingRecipient,"Role records must have a recipient");let a=o.message.descriptor.protocolPath,d={interface:Oe.Records,method:Se.Write,isLatestBaseState:!0,protocol:o.message.descriptor.protocol,protocolPath:a,recipient:s},u=yt.getParentContextFromOfContextId(o.message.contextId);if(u!==""){let p=Zn.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 se(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(;o<n.length;){let s=n[o],a=i[s];if(a===void 0)return;i=a,o++}return i}static checkActor(e,r,n){return za(this,void 0,void 0,function*(){let i=n.find(o=>o.descriptor.protocolPath===r.of);if(i===void 0)return!1;if(r.who===Oh.Recipient)return e===i.descriptor.recipient;{let o=(yield Vr.parse(i)).author;return e===o}})}static getTypeName(e){return e.split("/").slice(-1)[0]}};h();var Mq=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},ty=class t extends pi{static parse(e){return Mq(this,void 0,void 0,function*(){let r;return e.authorization!==void 0&&(r=yield ve.validateSignatureStructure(e.authorization.signature,e.descriptor)),yield yt.validateDelegatedGrantReferentialIntegrity(e,r),or.validateTimestamp(e.descriptor.messageTimestamp),new t(e)})}static create(e){var r,n;return Mq(this,void 0,void 0,function*(){let i=e.recordId,o=or.getCurrentTimestamp(),s={interface:Oe.Records,method:Se.Delete,messageTimestamp:(r=e.messageTimestamp)!==null&&r!==void 0?r:o,recordId:i,prune:(n=e.prune)!==null&&n!==void 0?n:!1},a=yield ve.createAuthorization({descriptor:s,signer:e.signer,protocolRole:e.protocolRole,delegatedGrant:e.delegatedGrant}),d={descriptor:s,authorization:a};return ve.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 _n(c),c}authorizeDelegate(e,r){return Mq(this,void 0,void 0,function*(){let n=yield xo.parse(this.message.authorization.authorDelegatedGrant);yield Go.authorizeDelete({recordsDeleteMessage:this.message,recordsWriteToDelete:e,expectedGrantor:this.author,expectedGrantee:this.signer,permissionGrant:n,messageStore:r})})}};h();h();var nf=class{};nf.maxDataSizeAllowedToBeEncoded=3e4;var QI=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},Zg=class t{static deleteFromDataStoreIfNeeded(e,r,n,i){return QI(this,void 0,void 0,function*(){if(n.descriptor.method!==Se.Write)return;let o=n;o.descriptor.dataSize<=nf.maxDataSizeAllowedToBeEncoded||o.descriptor.dataCid!==i.descriptor.dataCid&&(yield e.delete(r,o.recordId,o.descriptor.dataCid))})}static purgeRecordDescendants(e,r,n,i,o){return QI(this,void 0,void 0,function*(){let s={interface:Oe.Records,parentId:r},{messages:a}=yield n.query(e,[s]),d=new Map;for(let u of a){let c;yt.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 QI(this,void 0,void 0,function*(){let s=r.filter(u=>u.descriptor.method===Se.Write),a=yield ve.getNewestMessage(s);yield i.delete(e,a.recordId,a.descriptor.dataCid);let d=yield Promise.all(r.map(u=>ve.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 QI(this,void 0,void 0,function*(){let a=[];for(let d of r){if(yield ve.isOlder(d,n)){yield t.deleteFromDataStoreIfNeeded(o,e,d,n);let c=yield ve.getCid(d);if(yield i.delete(e,c),yield Vr.isInitialWrite(d)){let m=yield Vr.parse(d),p=!1,g=yield m.constructIndexes(p),v=d;delete v.encodedData,yield i.put(e,v,g)}else{let m=yield ve.getCid(d);a.push(m)}}yield s.deleteEventsByCid(e,a)}})}};var Ype=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(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,i,o){this.didResolver=e,this.messageStore=r,this.dataStore=n,this.eventLog=i,this.eventStream=o}handle({tenant:e,message:r}){return Ype(this,void 0,void 0,function*(){let n;try{n=yield ty.parse(r)}catch(p){return er(p,400)}try{yield ei(r.authorization,this.didResolver)}catch(p){return er(p,401)}let i={interface:Oe.Records,recordId:r.descriptor.recordId},{messages:o}=yield this.messageStore.query(e,[i]),s=yield ve.getNewestMessage(o),a=!1,d;if(s===void 0||(yield ve.isNewer(r,s))?(a=!0,d=r):d=s,!a)return{status:{code:409,detail:"Conflict"}};if(s===void 0||s.descriptor.method===Se.Delete)return{status:{code:404,detail:"Not Found"}};try{yield t.authorizeRecordsDelete(e,n,yield Vr.parse(s),this.messageStore)}catch(p){return er(p,401)}let u=yield Vr.getInitialWrite(o),c=n.constructIndexes(u),l=yield ve.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 Zg.purgeRecordDescendants(e,r.descriptor.recordId,this.messageStore,this.dataStore,this.eventLog)),yield Zg.deleteAllOlderMessagesButKeepInitialWrite(e,o,d,this.messageStore,this.dataStore,this.eventLog),{status:{code:202,detail:"Accepted"}}})}static authorizeRecordsDelete(e,r,n,i){return Ype(this,void 0,void 0,function*(){if(ve.isSignedByAuthorDelegate(r.message)&&(yield r.authorizeDelegate(n.message,i)),r.author!==e)if(n.message.descriptor.protocol!==void 0)yield Tc.authorizeDelete(e,r,n,i);else throw new se(ne.RecordsDeleteAuthorizationFailed,"RecordsDelete message failed authorization")})}};h();h();var ds;(function(t){t[t.Descending=-1]="Descending",t[t.Ascending=1]="Ascending"})(ds||(ds={}));var L6=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(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 L6(this,void 0,void 0,function*(){let n;try{n=yield Um.parse(r)}catch(s){return er(s,400)}let i,o;if(yt.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 ei(r.authorization,this.didResolver),yield t.authorizeRecordsQuery(e,n,this.messageStore)}catch(s){return er(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 Vr.isInitialWrite(s))){let d=(yield this.messageStore.query(e,[{recordId:s.recordId,isLatestBaseState:!1,method:Se.Write}])).messages[0];delete d.encodedData,s.initialWrite=d}return{status:{code:200,detail:"OK"},entries:i,cursor:o}})}convertDateSort(e){switch(e){case Eo.CreatedAscending:return{dateCreated:ds.Ascending};case Eo.CreatedDescending:return{dateCreated:ds.Descending};case Eo.PublishedAscending:return{datePublished:ds.Ascending};case Eo.PublishedDescending:return{datePublished:ds.Descending};default:return{dateCreated:ds.Ascending}}}fetchRecordsAsOwner(e,r){return L6(this,void 0,void 0,function*(){let{dateSort:n,filter:i,pagination:o}=r.message.descriptor,s=Object.assign(Object.assign({},yt.convertFilter(i,n)),{interface:Oe.Records,method:Se.Write,isLatestBaseState:!0}),a=this.convertDateSort(n);return this.messageStore.query(e,[s],a,o)})}fetchRecordsAsNonOwner(e,r){return L6(this,void 0,void 0,function*(){let{dateSort:n,pagination:i,filter:o}=r.message.descriptor,s=[];if(yt.filterIncludesPublishedRecords(o)&&s.push(t.buildPublishedRecordsFilter(r)),yt.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)),yt.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 L6(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({},yt.convertFilter(n,r)),{interface:Oe.Records,method:Se.Write,published:!0,isLatestBaseState:!0})}static buildUnpublishedRecordsForQueryAuthorFilter(e){let{dateSort:r,filter:n}=e.message.descriptor;return Object.assign(Object.assign({},yt.convertFilter(n,r)),{interface:Oe.Records,method:Se.Write,recipient:e.author,isLatestBaseState:!0,published:!1})}static buildUnpublishedProtocolAuthorizedRecordsFilter(e){let{dateSort:r,filter:n}=e.message.descriptor;return Object.assign(Object.assign({},yt.convertFilter(n,r)),{interface:Oe.Records,method:Se.Write,isLatestBaseState:!0,published:!1})}static buildUnpublishedRecordsByQueryAuthorFilter(e){let{dateSort:r,filter:n}=e.message.descriptor;return Object.assign(Object.assign({},yt.convertFilter(n,r)),{author:e.author,interface:Oe.Records,method:Se.Write,isLatestBaseState:!0,published:!1})}static authorizeRecordsQuery(e,r,n){return L6(this,void 0,void 0,function*(){ve.isSignedByAuthorDelegate(r.message)&&(yield r.authorizeDelegate(n)),yt.shouldProtocolAuthorize(r.signaturePayload)&&(yield Tc.authorizeQueryOrSubscribe(e,r,n))})}};h();h();var Dq=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(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 t extends pi{static parse(e){return Dq(this,void 0,void 0,function*(){let r;return e.authorization!==void 0&&(r=yield ve.validateSignatureStructure(e.authorization.signature,e.descriptor)),yield yt.validateDelegatedGrantReferentialIntegrity(e,r),or.validateTimestamp(e.descriptor.messageTimestamp),new t(e)})}static create(e){var r;return Dq(this,void 0,void 0,function*(){let{filter:n,signer:i,permissionGrantId:o,protocolRole:s}=e,a=or.getCurrentTimestamp(),d={interface:Oe.Records,method:Se.Read,filter:yt.normalizeFilter(n),messageTimestamp:(r=e.messageTimestamp)!==null&&r!==void 0?r:a};_n(d);let u;i!==void 0&&(u=yield ve.createAuthorization({descriptor:d,signer:i,permissionGrantId:o,protocolRole:s,delegatedGrant:e.delegatedGrant}));let c={descriptor:d,authorization:u};return ve.validateJsonSchema(c),new t(c)})}authorizeDelegate(e,r){return Dq(this,void 0,void 0,function*(){let n=yield xo.parse(this.message.authorization.authorDelegatedGrant);yield Go.authorizeRead({recordsReadMessage:this.message,recordsWriteMessageToBeRead:e,expectedGrantor:this.author,expectedGrantee:this.signer,permissionGrant:n,messageStore:r})})}};var Zpe=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},rP=class t{constructor(e,r,n){this.didResolver=e,this.messageStore=r,this.dataStore=n}handle({tenant:e,message:r}){return Zpe(this,void 0,void 0,function*(){let n;try{n=yield Xg.parse(r)}catch(c){return er(c,400)}try{n.author!==void 0&&(yield ei(r.authorization,this.didResolver))}catch(c){return er(c,401)}let i=Object.assign({interface:Oe.Records,isLatestBaseState:!0},yt.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 er(new se(ne.RecordsReadReturnedMultiple,"Multiple records exist for the RecordsRead filter"),400);let s=o[0];try{yield t.authorizeRecordsRead(e,n,yield Vr.parse(s),this.messageStore)}catch(c){return er(c,401)}let a;if(s.encodedData!==void 0){let c=Ye.base64UrlToBytes(s.encodedData);a=ku.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 Vr.isInitialWrite(d))){let l=(yield this.messageStore.query(e,[{recordId:d.recordId,isLatestBaseState:!1,method:Se.Write}])).messages[0];delete l.encodedData,d.initialWrite=l}return{status:{code:200,detail:"OK"},record:d}})}static authorizeRecordsRead(e,r,n,i){return Zpe(this,void 0,void 0,function*(){ve.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 yi.fetchGrant(e,i,r.signaturePayload.permissionGrantId);yield Go.authorizeRead({recordsReadMessage:r.message,recordsWriteMessageToBeRead:n.message,expectedGrantor:e,expectedGrantee:r.author,permissionGrant:s,messageStore:i})}else if(o.protocol!==void 0)yield Tc.authorizeRead(e,r,n,i);else throw new se(ne.RecordsReadAuthorizationFailed,"message failed authorization")}})}};h();h();var Oq=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},ry=class t extends pi{static parse(e){return Oq(this,void 0,void 0,function*(){let r;if(e.authorization!==void 0&&(r=yield ve.validateSignatureStructure(e.authorization.signature,e.descriptor)),yield yt.validateDelegatedGrantReferentialIntegrity(e,r),r?.protocolRole!==void 0&&e.descriptor.filter.protocolPath===void 0)throw new se(ne.RecordsSubscribeFilterMissingRequiredProperties,"Role-authorized subscriptions must include `protocolPath` in the filter");return e.descriptor.filter.protocol!==void 0&&Na(e.descriptor.filter.protocol),e.descriptor.filter.schema!==void 0&&Sd(e.descriptor.filter.schema),or.validateTimestamp(e.descriptor.messageTimestamp),new t(e)})}static create(e){var r;return Oq(this,void 0,void 0,function*(){let n={interface:Oe.Records,method:Se.Subscribe,messageTimestamp:(r=e.messageTimestamp)!==null&&r!==void 0?r:or.getCurrentTimestamp(),filter:yt.normalizeFilter(e.filter)};_n(n);let i=e.signer,o;i&&(o=yield ve.createAuthorization({descriptor:n,signer:i,protocolRole:e.protocolRole,delegatedGrant:e.delegatedGrant}));let s={descriptor:n,authorization:o};return ve.validateJsonSchema(s),new t(s)})}authorizeDelegate(e){return Oq(this,void 0,void 0,function*(){let r=yield xo.parse(this.message.authorization.authorDelegatedGrant);yield Go.authorizeQueryOrSubscribe({incomingMessage:this.message,expectedGrantor:this.author,expectedGrantee:this.signer,permissionGrant:r,messageStore:e})})}};var nP=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},iP=class t{constructor(e,r,n){this.didResolver=e,this.messageStore=r,this.eventStream=n}handle({tenant:e,message:r,subscriptionHandler:n}){return nP(this,void 0,void 0,function*(){if(this.eventStream===void 0)return er(new se(ne.RecordsSubscribeEventStreamUnimplemented,"Subscriptions are not supported"),501);let i;try{i=yield ry.parse(r)}catch(u){return er(u,400)}let o=[];if(yt.filterIncludesPublishedRecords(i.message.descriptor.filter)&&i.author===void 0)o=[t.buildPublishedRecordsFilter(i)],delete r.authorization;else{try{yield ei(r.authorization,this.didResolver),yield t.authorizeRecordsSubscribe(e,i,this.messageStore)}catch(u){return er(u,401)}i.author===e?o=yield t.filterAsOwner(i):o=yield t.filterAsNonOwner(i)}let s=(u,c,l)=>{e===u&&Zn.matchAnyFilter(l,o)&&n(c)},a=yield ve.getCid(r),d=yield this.eventStream.subscribe(e,a,s);return{status:{code:200,detail:"OK"},subscription:d}})}static filterAsOwner(e){return nP(this,void 0,void 0,function*(){let{filter:r}=e.message.descriptor;return[Object.assign(Object.assign({},yt.convertFilter(r)),{interface:Oe.Records,method:[Se.Write,Se.Delete]})]})}static filterAsNonOwner(e){return nP(this,void 0,void 0,function*(){let r=[],{filter:n}=e.message.descriptor;if(yt.filterIncludesPublishedRecords(n)&&r.push(t.buildPublishedRecordsFilter(e)),yt.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)),yt.shouldProtocolAuthorize(e.signaturePayload)&&r.push(t.buildUnpublishedProtocolAuthorizedRecordsFilter(e))}return r})}static buildPublishedRecordsFilter(e){return Object.assign(Object.assign({},yt.convertFilter(e.message.descriptor.filter)),{interface:Oe.Records,method:[Se.Write,Se.Delete],published:!0})}static buildUnpublishedRecordsForSubscribeAuthorFilter(e){return Object.assign(Object.assign({},yt.convertFilter(e.message.descriptor.filter)),{interface:Oe.Records,method:[Se.Write,Se.Delete],recipient:e.author,published:!1})}static buildUnpublishedProtocolAuthorizedRecordsFilter(e){return Object.assign(Object.assign({},yt.convertFilter(e.message.descriptor.filter)),{interface:Oe.Records,method:[Se.Write,Se.Delete],published:!1})}static buildUnpublishedRecordsBySubscribeAuthorFilter(e){return Object.assign(Object.assign({},yt.convertFilter(e.message.descriptor.filter)),{author:e.author,interface:Oe.Records,method:[Se.Write,Se.Delete],published:!1})}static authorizeRecordsSubscribe(e,r,n){return nP(this,void 0,void 0,function*(){ve.isSignedByAuthorDelegate(r.message)&&(yield r.authorizeDelegate(n)),yt.shouldProtocolAuthorize(r.signaturePayload)&&(yield Tc.authorizeQueryOrSubscribe(e,r,n))})}};h();var M1=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},oP=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 M1(this,void 0,void 0,function*(){let i;try{i=yield Vr.parse(r),r.descriptor.protocol!==void 0&&(yield Tc.validateReferentialIntegrity(e,i,this.messageStore))}catch(p){return er(p,400)}try{yield ei(r.authorization,this.didResolver),yield t.authorizeRecordsWrite(e,i,this.messageStore)}catch(p){return er(p,401)}let o={interface:Oe.Records,recordId:r.recordId},{messages:s}=yield this.messageStore.query(e,[o]),a=yield i.isInitialWrite(),d;if(!a)try{d=yield Vr.getInitialWrite(s),Vr.verifyEqualityOfImmutableProperties(d,r)}catch(p){return er(p,400)}let u=yield ve.getNewestMessage(s),c=!1,l;if(u===void 0||(yield ve.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===Se.Delete)throw new se(ne.RecordsWriteMissingDataStream,"No data stream was provided with the previous message being a delete");if(!a){let E=u;g=yield this.processMessageWithoutDataStream(e,r,E),p=!0}}let v=yield i.constructIndexes(p);yield this.messageStore.put(e,g,v),yield this.eventLog.append(e,yield ve.getCid(r),v),this.eventStream!==void 0&&p&&this.eventStream.emit(e,{message:r,initialWrite:d},v)}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 er(p,400);throw p}let m={status:{code:202,detail:"Accepted"}};return yield Zg.deleteAllOlderMessagesButKeepInitialWrite(e,s,l,this.messageStore,this.dataStore,this.eventLog),yield this.postProcessingForCoreRecordsWrite(e,i),m})}static validateSchemaForCoreRecordsWrite(e,r){e.descriptor.protocol===yi.uri&&yi.validateSchema(e,r)}postProcessingForCoreRecordsWrite(e,r){return M1(this,void 0,void 0,function*(){if(r.message.descriptor.protocol===yi.uri&&r.message.descriptor.protocolPath===yi.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 ve.getCid(a);yield this.messageStore.delete(e,d)}this.eventLog.deleteEventsByCid(e,s)}})}cloneAndAddEncodedData(e,r){return M1(this,void 0,void 0,function*(){let n=Object.assign({},e);return n.encodedData=Ye.bytesToBase64Url(r),n})}processMessageWithDataStream(e,r,n){return M1(this,void 0,void 0,function*(){let i=r;if(r.descriptor.dataSize<=nf.maxDataSizeAllowedToBeEncoded){let o=yield ku.toBytes(n),s=yield An.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]=ku.duplicateDataStream(n,2);try{let[a,d]=yield Promise.all([An.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 M1(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<=nf.maxDataSizeAllowedToBeEncoded)if(n.encodedData!==void 0)i.encodedData=n.encodedData;else throw new se(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 se(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 se(ne.RecordsWriteDataCidMismatch,`actual data CID ${n} does not match dataCid in descriptor: ${e}`);if(r!==i)throw new se(ne.RecordsWriteDataSizeMismatch,`actual data size ${i} bytes does not match dataSize in descriptor: ${r}`)}static authorizeRecordsWrite(e,r,n){return M1(this,void 0,void 0,function*(){if(r.owner!==void 0&&r.owner!==e)throw new se(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 yi.fetchGrant(e,n,r.signaturePayload.permissionGrantId);yield Go.authorizeWrite({recordsWriteMessage:r.message,expectedGrantor:e,expectedGrantee:r.author,permissionGrant:i,messageStore:n})}else if(r.message.descriptor.protocol!==void 0)yield Tc.authorizeWrite(e,r,n);else throw new se(ne.RecordsWriteAuthorizationFailed,"message failed authorization")}})}};h();h();var Qg;(function(t){t.authentication="authentication",t.assertionMethod="assertionMethod",t.keyAgreement="keyAgreement",t.capabilityInvocation="capabilityInvocation",t.capabilityDelegation="capabilityDelegation"})(Qg||(Qg={}));h();var ri={"@context":"https://w3id.org/did-resolution/v1",didResolutionMetadata:{},didDocument:null,didDocumentMetadata:{}};h();var wr=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}};wr.METHOD_PATTERN="([a-z0-9]+)";wr.PCT_ENCODED_PATTERN="(?:%[0-9a-fA-F]{2})";wr.ID_CHAR_PATTERN=`(?:[a-zA-Z0-9._-]|${wr.PCT_ENCODED_PATTERN})`;wr.METHOD_ID_PATTERN=`((?:${wr.ID_CHAR_PATTERN}*:)*(${wr.ID_CHAR_PATTERN}+))`;wr.PATH_PATTERN="(/[^#?]*)?";wr.QUERY_PATTERN="([?][^#]*)?";wr.FRAGMENT_PATTERN="(#.*)?";wr.DID_URI_PATTERN=new RegExp(`^did:(?<method>${wr.METHOD_PATTERN}):(?<id>${wr.METHOD_ID_PATTERN})(?<path>${wr.PATH_PATTERN})(?<query>${wr.QUERY_PATTERN})(?<fragment>${wr.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();h();function Ic(t){if(typeof t=="string"&&t.length!==0)return t.split("#").pop()}function $q({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(Cq))!==null&&r!==void 0?r:[]),Object.keys(Qg).forEach(i=>{var o,s;n.push(...(s=(o=t[i])===null||o===void 0?void 0:o.filter(Cq))!==null&&s!==void 0?s:[])}),n}function Xpe({didDocument:t}){let r=$q({didDocument:t}).map(n=>n.type);return[...new Set(r)]}function Qpe({didDocument:t,methodId:e}){let r=[];return Object.keys(Qg).forEach(n=>{if(Array.isArray(t[n])){let i=t[n],o=Ic(e);i.some(a=>{let d=Ic(a)===o,u=Cq(a)&&Ic(a.id)===o;return d||u})&&r.push(n)}}),r}function Cq(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 Nq({keyBytes:t,multicodecCode:e,multicodecName:r}){let n=ii.addPrefix({code:e,data:t,name:r}),i=de.uint8Array(n).toBase58Btc();return de.base58Btc(i).toMultibase()}function jq({multibaseKeyId:t}){try{let e=de.multibase(t).toBase58Btc(),r=de.base58Btc(e).toUint8Array(),{code:n,data:i,name:o}=ii.removePrefix({prefixedData:r});return{keyBytes:i,multicodecCode:n,multicodecName:o}}catch{throw new at(tt.InvalidDid,`Invalid multibase identifier: ${t}`)}}var K6=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},Va=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 K6(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 K6(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 Ic(d.id)===((u=Ic(e?.methodId))!==null&&u!==void 0?u:Ic((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:Ei.getJoseSignatureAlgorithmFromPublicKey(o),keyId:n.id,sign(d){return K6(this,arguments,void 0,function*({data:u}){return yield s.sign({data:u,keyUri:i})})},verify(d){return K6(this,arguments,void 0,function*({data:u,signature:c}){return yield s.verify({data:u,key:o,signature:c})})}}})}static import(e){return K6(this,arguments,void 0,function*({portableDid:r,keyManager:n=new xr}){var i;let o=$q({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 eme=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},Md=class{static getSigningMethod(e){return eme(this,void 0,void 0,function*(){throw new Error("Not implemented: Classes extending DidMethod must implement getSigningMethod()")})}static resolve(e,r){return eme(this,void 0,void 0,function*(){throw new Error("Not implemented: Classes extending DidMethod must implement resolve()")})}};var Ro=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},tme=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.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]]);return r},rme="https://diddht.tbddev.org",bGe=0,ny=7200,sP=";",ma=",",Uq;(function(t){t[t.Discoverable=0]="Discoverable",t[t.Organization=1]="Organization",t[t.Government=2]="Government",t[t.Corporation=3]="Corporation",t[t.LocalBusiness=4]="LocalBusiness",t[t.SoftwarePackage=5]="SoftwarePackage",t[t.WebApp=6]="WebApp",t[t.FinancialInstitution=7]="FinancialInstitution"})(Uq||(Uq={}));var ya;(function(t){t[t.Ed25519=0]="Ed25519",t[t.secp256k1=1]="secp256k1",t[t.secp256r1=2]="secp256r1",t[t.X25519=3]="X25519"})(ya||(ya={}));var qq;(function(t){t.authentication="auth",t.assertionMethod="asm",t.capabilityDelegation="del",t.capabilityInvocation="inv",t.keyAgreement="agm"})(qq||(qq={}));var ime={Ed25519:ya.Ed25519,ES256K:ya.secp256k1,ES256:ya.secp256r1,"P-256":ya.secp256r1,secp256k1:ya.secp256k1,secp256r1:ya.secp256r1,X25519:ya.X25519},nme={[ya.Ed25519]:"Ed25519",[ya.secp256k1]:"ES256K",[ya.secp256r1]:"ES256",[ya.X25519]:"ECDH-ES+A256KW"},ev=class t extends Md{static create(){return Ro(this,arguments,void 0,function*({keyManager:e=new xr,options:r={}}={}){var n,i,o,s,a,d,u,c,l,m,p;if(!((n=r.verificationMethods)===null||n===void 0)&&n.some(N=>!(N.algorithm in ime)))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 v=yield e.generateKey({algorithm:"Ed25519"}),E=yield e.getPublicKey({keyUri:v}),A=yield ko.identityKeyToIdentifier({identityKey:E}),P=Object.assign(Object.assign({id:A},r.alsoKnownAs&&{alsoKnownAs:r.alsoKnownAs}),r.controllers&&{controller:r.controllers}),I=[...(s=r.verificationMethods)!==null&&s!==void 0?s:[]];I?.some(N=>{var K;return((K=N.id)===null||K===void 0?void 0:K.split("#").pop())==="0"})||I.unshift({algorithm:"Ed25519",id:"0",purposes:["authentication","assertionMethod","capabilityDelegation","capabilityInvocation"]});for(let N of I){let K=N.id&&N.id.split("#").pop()==="0"?v:yield e.generateKey({algorithm:N.algorithm}),F=yield e.getPublicKey({keyUri:K}),U=(d=(a=N.id)!==null&&a!==void 0?a:F.kid)!==null&&d!==void 0?d:yield nt({jwk:F});U=`${A}#${Ic(U)}`,(u=P.verificationMethod)!==null&&u!==void 0||(P.verificationMethod=[]),P.verificationMethod.push({id:U,type:"JsonWebKey",controller:(c=N.controller)!==null&&c!==void 0?c:A,publicKeyJwk:F});for(let V of(l=N.purposes)!==null&&l!==void 0?l:[])P[V]||(P[V]=[]),P[V].push(U)}(m=r.services)===null||m===void 0||m.forEach(N=>{var K;(K=P.service)!==null&&K!==void 0||(P.service=[]),N.id=`${A}#${N.id.split("#").pop()}`,P.service.push(N)});let $=new Va({uri:A,document:P,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 Ro(this,arguments,void 0,function*({portableDid:r,keyManager:n=new xr}){var i;let o=wr.parse(r.uri);if(o?.method!==t.methodName)throw new at(tt.MethodNotSupported,"Method not supported");let s=yield Va.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 Ro(this,arguments,void 0,function*({didDocument:r,methodId:n="#0"}){var i;let o=wr.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 Ic(a.id)===((d=Ic(n))!==null&&d!==void 0?d:Ic((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 Ro(this,arguments,void 0,function*({did:r,gatewayUri:n=rme}){return yield aP.put({did:r,gatewayUri:n})})}static resolve(e){return Ro(this,arguments,void 0,function*(r,n={}){var i;let o=(i=n?.gatewayUri)!==null&&i!==void 0?i:rme;try{yield ko.identifierToIdentityKey({didUri:r});let{didDocument:s,didDocumentMetadata:a}=yield aP.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})})}})}};ev.methodName="dht";var aP=class t{static get(e){return Ro(this,arguments,void 0,function*({didUri:r,gatewayUri:n}){let i=ko.identifierToIdentityKeyBytes({didUri:r}),o=yield t.pkarrGet({gatewayUri:n,publicKeyBytes:i}),s=yield ko.parseBep44GetMessage({bep44Message:o}),a=yield t.fromDnsPacket({didUri:r,dnsPacket:s});return a.didDocumentMetadata.versionId=o.seq.toString(),a})}static put(e){return Ro(this,arguments,void 0,function*({did:r,gatewayUri:n}){let i=yield t.toDnsPacket({didDocument:r.document,didMetadata:r.metadata,authoritativeGatewayUris:[n]}),o=yield ko.createBep44PutMessage({dnsPacket:i,publicKeyBytes:ko.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 Ro(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 Ro(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 Ro(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=ko.parseTxtDataToString(c.data);a.alsoKnownAs=m.split(ma);break}case l.startsWith("cnt"):{let m=ko.parseTxtDataToString(c.data);a.controller=m.includes(ma)?m.split(ma):m;break}case l.startsWith("k"):{let{id:m,t:p,k:g,c:v,a:E}=ko.parseTxtDataToObject(c.data),A=de.base64Url(g).toUint8Array(),P=ya[Number(p)],I=yield ko.keyConverter(P).bytesToPublicKey({publicKeyBytes:A});I.alg=E||nme[Number(p)];let $=l==="k0"?"0":m!==void 0?m:yield nt({jwk:I});(o=a.verificationMethod)!==null&&o!==void 0||(a.verificationMethod=[]);let N=`${r}#${$}`;a.verificationMethod.push({id:N,type:"JsonWebKey",controller:v??r,publicKeyJwk:I}),u.set(l,N);break}case l.startsWith("s"):{let m=ko.parseTxtDataToObject(c.data),{id:p,t:g,se:v}=m,E=tme(m,["id","t","se"]),A=v.includes(ma)?v.split(ma):[v],P=Object.fromEntries(Object.entries(E).map(([I,$])=>[I,$.includes(ma)?$.split(ma):$]));(s=a.service)!==null&&s!==void 0||(a.service=[]),a.service.push(Object.assign(Object.assign({},P),{id:`${r}#${p}`,type:g,serviceEndpoint:A}));break}case l.startsWith("typ"):{let{id:m}=ko.parseTxtDataToObject(c.data);d.types=m.split(ma).map(p=>Number(p));break}case l.startsWith("did"):{let m=P=>P.split(ma).map(I=>u.get(I)).filter(I=>typeof I=="string"),{auth:p,asm:g,del:v,inv:E,agm:A}=ko.parseTxtDataToObject(c.data);p&&(a.authentication=m(p)),g&&(a.assertionMethod=m(g)),v&&(a.capabilityDelegation=m(v)),E&&(a.capabilityInvocation=m(E)),A&&(a.keyAgreement=m(A));break}}}return{didDocument:a,didDocumentMetadata:d,didResolutionMetadata:{}}})}static toDnsPacket(e){return Ro(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=[],v=[];if(o!==void 0){let{signature:P,previousDid:I}=o;yield ko.validatePreviousDidProof({newDid:r.id,previousDidProof:o}),l.push({type:"TXT",name:"_prv._did.",ttl:ny,data:`id=${I};s=${P}`})}if(r.alsoKnownAs&&l.push({type:"TXT",name:"_aka._did.",ttl:ny,data:r.alsoKnownAs.join(ma)}),r.controller){let P=Array.isArray(r.controller)?r.controller.join(ma):r.controller;l.push({type:"TXT",name:"_cnt._did.",ttl:ny,data:P})}for(let[P,I]of(a=(s=r.verificationMethod)===null||s===void 0?void 0:s.entries())!==null&&a!==void 0?a:[]){let $=`k${P}`;v.push($);let N=I.id.split("#").pop();p.set(N,$);let K=I.publicKeyJwk;if(!(K?.crv&&K.crv in ime))throw new at(tt.InvalidPublicKeyType,`Verification method '${I.id}' contains an unsupported key type: ${(d=K?.crv)!==null&&d!==void 0?d:"undefined"}`);let F=ya[K.crv],U=yield ko.keyConverter(K.crv).publicKeyToBytes({publicKey:K}),V=de.uint8Array(U).toBase64Url(),L=[`t=${F}`,`k=${V}`];N!=="0"&&(yield nt({jwk:K}))!==N&&L.unshift(`id=${N}`),K.alg!==nme[F]&&L.push(`a=${K.alg}`),I.controller!==r.id&&L.push(`c=${I.controller}`),l.push({type:"TXT",name:`_${$}._did.`,ttl:ny,data:L.join(sP)})}(u=r.service)===null||u===void 0||u.forEach((P,I)=>{let $=`s${I}`;g.push($);let{id:N,type:K,serviceEndpoint:F}=P,U=tme(P,["id","type","serviceEndpoint"]);N=Ic(N),F=Array.isArray(F)?F.join(","):F;let L=Object.entries(Object.assign({id:N,t:K,se:F},U)).map(([S,k])=>`${S}=${k}`).join(sP),T=ko.chunkDataIfNeeded(L);l.push({type:"TXT",name:`_${$}._did.`,ttl:ny,data:T})});let E=[`v=${bGe}`];if(v.length&&E.push(`vm=${v.join(ma)}`),Object.keys(Qg).forEach(P=>{var I;let $=(I=r[P])===null||I===void 0?void 0:I.map(N=>p.get(N.split("#").pop()));if($){let N=qq[P];E.push(`${N}=${$.join(ma)}`)}}),g.length&&E.push(`svc=${g.join(ma)}`),!((c=n.types)===null||c===void 0)&&c.length){let I=n.types.map($=>typeof $=="string"?Uq[$]:$);l.push({type:"TXT",name:"_typ._did.",ttl:ny,data:`id=${I.join(ma)}`})}l.push({type:"TXT",name:"_did."+t.getUniqueDidSuffix(r.id)+".",ttl:ny,data:E.join(sP)});for(let P of i||[])m.push({type:"NS",name:"_did."+t.getUniqueDidSuffix(r.id)+".",ttl:ny,data:P+"."});return{id:0,type:"response",flags:D5,answers:[...l,...m]}})}static getUniqueDidSuffix(e){return e.split(":")[2]}},ko=class t{static createBep44PutMessage(e){return Ro(this,arguments,void 0,function*({dnsPacket:r,publicKeyBytes:n,signer:i}){let o=Math.ceil(Date.now()/1e3),s=s0(r),a=nb.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 Ro(this,arguments,void 0,function*({didUri:r}){let n=t.identifierToIdentityKeyBytes({didUri:r});return yield Yt.bytesToPublicKey({publicKeyBytes:n})})}static identifierToIdentityKeyBytes({didUri:e}){let r=wr.parse(e);if(!r)throw new at(tt.InvalidDid,`Invalid DID URI: ${e}`);if(r.method!==ev.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 Ro(this,arguments,void 0,function*({identityKey:r}){let n=yield Yt.publicKeyToBytes({publicKey:r}),i=de.uint8Array(n).toBase32Z();return`did:${ev.methodName}:${i}`})}static keyConverter(e){let n={Ed25519:Yt,"P-256":{publicKeyToBytes:i=>Ro(this,[i],void 0,function*({publicKey:o}){let s=yield Dr.publicKeyToBytes({publicKey:o});return yield Dr.compressPublicKey({publicKeyBytes:s})}),bytesToPublicKey:Dr.bytesToPublicKey,privateKeyToBytes:Dr.privateKeyToBytes,bytesToPrivateKey:Dr.bytesToPrivateKey},secp256k1:{publicKeyToBytes:i=>Ro(this,[i],void 0,function*({publicKey:o}){let s=yield _r.publicKeyToBytes({publicKey:o});return yield _r.compressPublicKey({publicKeyBytes:s})}),bytesToPublicKey:_r.bytesToPublicKey,privateKeyToBytes:_r.privateKeyToBytes,bytesToPrivateKey:_r.bytesToPrivateKey},X25519:ol}[e];if(!n)throw new at(tt.InvalidPublicKeyType,`Unsupported curve: ${e}`);return n}static parseBep44GetMessage(e){return Ro(this,arguments,void 0,function*({bep44Message:r}){let n=yield Yt.bytesToPublicKey({publicKeyBytes:r.k}),i=nb.encode({seq:r.seq,v:r.v}).subarray(1,-1);if(!(yield Yt.verify({key:n,signature:r.sig,data:i})))throw new at(tt.InvalidSignature,"Invalid signature for DHT BEP44 message");return fb(r.v)})}static parseTxtDataToObject(e){return this.parseTxtDataToString(e).split(sP).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 Ro(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 Yt.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<e.length;n+=255)r.push(e.slice(n,n+255));return r}};h();var iy=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},of;(function(t){t.Ed25519="Ed25519",t.secp256k1="secp256k1",t.secp256r1="secp256r1",t.X25519="X25519"})(of||(of={}));var wGe={Ed25519:of.Ed25519,ES256K:of.secp256k1,ES256:of.secp256r1,"P-256":of.secp256r1,secp256k1:of.secp256k1,secp256r1:of.secp256r1},ome="https://ion.tbd.engineering",F6=class t extends Md{static create(){return iy(this,arguments,void 0,function*({keyManager:e=new xr,options:r={}}={}){var n,i,o,s,a,d,u;if(!((n=r.verificationMethods)===null||n===void 0)&&n.some(N=>!(N.algorithm in wGe)))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 K=yield e.generateKey({algorithm:N.algorithm}),F=yield e.getPublicKey({keyUri:K});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:of.secp256k1}),g=yield e.getPublicKey({keyUri:p}),v=yield e.generateKey({algorithm:of.secp256k1}),E=yield e.getPublicKey({keyUri:v}),A=yield tv.computeLongFormDidUri({recoveryKey:g,updateKey:E,services:(d=r.services)!==null&&d!==void 0?d:[],verificationMethods:m}),{didDocument:P,didResolutionMetadata:I}=yield t.resolve(A,{gatewayUri:r.gatewayUri});if(P===null)throw new Error(`Unable to resolve DID during creation: ${I?.error}`);let $=new Va({uri:A,document:P,metadata:{published:!1,canonicalId:A.split(":",3).join(":"),recoveryKey:g,updateKey:E},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 iy(this,arguments,void 0,function*({didDocument:r,methodId:n}){var i;let o=wr.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 iy(this,arguments,void 0,function*({portableDid:r,keyManager:n=new xr}){let i=wr.parse(r.uri);if(i?.method!==t.methodName)throw new at(tt.MethodNotSupported,"Method not supported");return yield Va.import({portableDid:r,keyManager:n})})}static publish(e){return iy(this,arguments,void 0,function*({did:r,gatewayUri:n=ome}){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:Qpe({didDocument:r.document,methodId:c.id})})))!==null&&o!==void 0?o:[],d=yield tv.createIonDocument({services:(s=r.document.service)!==null&&s!==void 0?s:[],verificationMethods:a}),u=yield tv.constructCreateRequest({ionDocument:d,recoveryKey:r.metadata.recoveryKey,updateKey:r.metadata.updateKey});try{let c=tv.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 iy(this,arguments,void 0,function*(r,n={}){var i,o;let s=wr.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:ome;try{let d=tv.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})})}})}};F6.methodName="ion";var tv=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 iy(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 Rp.createLongFormDid({document:s,recoveryKey:a,updateKey:d})})}static constructCreateRequest(e){return iy(this,arguments,void 0,function*({ionDocument:r,recoveryKey:n,updateKey:i}){return yield dl.createCreateRequest({document:r,recoveryKey:t.normalizeJwk(n),updateKey:t.normalizeJwk(i)})})}static createIonDocument(e){return iy(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 nt({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 cP=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},Lq=class t extends Md{static create(){return cP(this,arguments,void 0,function*({keyManager:e=new xr,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 Va({uri:l,document:p,metadata:{},keyManager:e})})}static getSigningMethod(e){return cP(this,arguments,void 0,function*({didDocument:r}){var n;let i=wr.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 cP(this,arguments,void 0,function*({portableDid:r,keyManager:n=new xr}){let i=wr.parse(r.uri);if(i?.method!==t.methodName)throw new at(tt.MethodNotSupported,"Method not supported");let o=yield Va.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 cP(this,void 0,void 0,function*(){let n=wr.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})})}};Lq.methodName="jwk";h();var Ou=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},Ch;(function(t){t.Ed25519="Ed25519",t.secp256k1="secp256k1",t.secp256r1="secp256r1",t.X25519="X25519"})(Ch||(Ch={}));var Kq={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"},_Ge={Ed25519:Ch.Ed25519,ES256K:Ch.secp256k1,ES256:Ch.secp256r1,"P-256":Ch.secp256r1,secp256k1:Ch.secp256k1,secp256r1:Ch.secp256r1,X25519:Ch.X25519},D1=class t extends Md{static create(){return Ou(this,arguments,void 0,function*({keyManager:e=new xr,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 Ha.publicKeyToMultibaseId({publicKey:u}),l=`did:${t.methodName}:${c}`,p=(yield t.resolve(l,r)).didDocument;return new Va({uri:l,document:p,metadata:{},keyManager:e})})}static getSigningMethod(e){return Ou(this,arguments,void 0,function*({didDocument:r}){var n;let i=wr.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 Ou(this,arguments,void 0,function*({portableDid:r,keyManager:n=new xr}){let i=wr.parse(r.uri);if(i?.method!==t.methodName)throw new at(tt.MethodNotSupported,"Method not supported");let o=yield Va.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 Ou(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 Ou(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=wr.parse(r);if(!u)throw new at(tt.InvalidDid,`Invalid DID URI: ${r}`);let c=u.id;if(u.method!==t.methodName)throw new at(tt.MethodNotSupported,`Method not supported: ${u.method}`);if(!t.validateIdentifier(u))throw new at(tt.InvalidDid,`Invalid DID URI: ${r}`);let l=yield t.createSignatureMethod({didUri:r,multibaseValue:c,options:{enableExperimentalPublicKeyTypes:s,publicKeyFormat:a}});if(d.id=u.uri,d.verificationMethod=[l],d.authentication=[l.id],d.assertionMethod=[l.id],d.capabilityInvocation=[l.id],d.capabilityDelegation=[l.id],o===!0){let g=a==="Ed25519VerificationKey2020"?"X25519KeyAgreementKey2020":"JsonWebKey2020",v=yield this.createEncryptionMethod({didUri:r,multibaseValue:c,options:{enableExperimentalPublicKeyTypes:s,publicKeyFormat:g}});d.verificationMethod.push(v),d.keyAgreement=[v.id]}let m=[i];return Xpe({didDocument:d}).forEach(g=>{let v=Kq[g];m.push(v)}),d["@context"]=m,d})}static createEncryptionMethod(e){return Ou(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=Ha.MULTICODEC_PUBLIC_KEY_LENGTH[u];if(c!==l)throw new at(tt.InvalidPublicKeyLength,`Expected ${c} bytes. Actual: ${l}`);let m=Nq({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 Kq))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 Ha.multicodecToJwk({code:u});a.publicKeyJwk=yield Ha.keyConverter(g).bytesToPublicKey({publicKeyBytes:d})}return a})}static createSignatureMethod(e){return Ou(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}=jq({multibaseKeyId:n}),l=d.byteLength,m=Ha.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 _r.validatePublicKey({publicKeyBytes:d});break;case"ed25519-pub":p=yield Yt.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 Kq))throw new at(tt.UnsupportedPublicKeyType,`Unsupported format: ${s}`);if(o===!1&&!["Multikey","JsonWebKey2020","Ed25519VerificationKey2020"].includes(s))throw new at(tt.InvalidPublicKeyType,`Specified '${s}' without setting enableExperimentalPublicKeyTypes to true.`);if(a.type=s,a.controller=r,s==="Ed25519VerificationKey2020"&&(a.publicKeyMultibase=n),s==="JsonWebKey2020"){let{crv:v}=yield Ha.multicodecToJwk({code:u});a.publicKeyJwk=yield Ha.keyConverter(v).bytesToPublicKey({publicKeyBytes:d})}return a})}static deriveEncryptionKey(e){return Ou(this,arguments,void 0,function*({multibaseValue:r}){let n={keyBytes:new Uint8Array,multicodecCode:0},{keyBytes:i,multicodecCode:o}=jq({multibaseKeyId:r});if(o===237){let s=yield Ha.keyConverter("Ed25519").bytesToPublicKey({publicKeyBytes:i}),a=yield Yt.convertPublicKeyToX25519({publicKey:s});n={keyBytes:yield Ha.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&&Xh(n)==="String"&&n.startsWith("z")}};D1.methodName="key";var Ha=class t{static jwkToMulticodec(e){return Ou(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:ii.getCodeFromName({name:o}),name:o}})}static keyCompressor(e){let n={"P-256":Dr.compressPublicKey,secp256k1:_r.compressPublicKey}[e];if(!n)throw new at(tt.InvalidPublicKeyType,`Unsupported curve: ${e}`);return n}static keyConverter(e){let n={Ed25519:Yt,"P-256":Dr,secp256k1:_r,X25519:ol}[e];if(!n)throw new at(tt.InvalidPublicKeyType,`Unsupported curve: ${e}`);return n}static multicodecToJwk(e){return Ou(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?ii.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 Ou(this,arguments,void 0,function*({publicKey:r}){var n;if(!(r?.crv&&r.crv in _Ge))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 Nq({keyBytes:i,multicodecName:o})})}};Ha.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"};Ha.MULTICODEC_PUBLIC_KEY_LENGTH={231:33,236:32,237:32};Ha.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 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())})},Fq=class t extends Md{static resolve(e,r){return xGe(this,void 0,void 0,function*(){let n=wr.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"}})}})}};Fq.methodName="web";h();var sme=qt(h0(),1),ame=qt(gB(),1),EGe=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},dP=class{constructor({db:e,location:r="DATA/DID_RESOLVERCACHE",ttl:n="15m"}={}){this.cache=e??new ame.Level(r),this.ttl=(0,sme.default)(n)}get(e){return EGe(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 cme={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 dme=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},uP=class{constructor({cache:e,didResolvers:r}){this.didResolvers=new Map,this.cache=e||cme;for(let n of r)this.didResolvers.set(n.methodName,n)}resolve(e,r){return dme(this,void 0,void 0,function*(){let n=wr.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 dme(this,void 0,void 0,function*(){let n=wr.parse(e);if(!n)return{dereferencingMetadata:{error:tt.InvalidDidUrl},contentStream:null,contentMetadata:{}};let{didDocument:i,didResolutionMetadata:o,didDocumentMetadata:s}=yield this.resolve(n.uri);if(!i)return{dereferencingMetadata:{error:o.error},contentStream:null,contentMetadata:{}};if(!n.fragment||n.query)return{dereferencingMetadata:{contentType:"application/did+json"},contentStream:i,contentMetadata:s};let{service:a=[],verificationMethod:d=[]}=i,u=new Set([e,n.fragment,`#${n.fragment}`]),c;for(let l of d)if(u.has(l.id)){c=l;break}for(let l of a)if(u.has(l.id)){c=l;break}return c?{dereferencingMetadata:{contentType:"application/did+json"},contentStream:c,contentMetadata:o}:{dereferencingMetadata:{error:tt.NotFound},contentStream:null,contentMetadata:{}}})}};var O1=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},z6=class 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={[Oe.Events+Se.Get]:new mI(this.didResolver,this.eventLog),[Oe.Events+Se.Query]:new yI(this.didResolver,this.eventLog),[Oe.Events+Se.Subscribe]:new gI(this.didResolver,this.eventStream),[Oe.Messages+Se.Get]:new vI(this.didResolver,this.messageStore,this.dataStore),[Oe.Protocols+Se.Configure]:new YI(this.didResolver,this.messageStore,this.eventLog,this.eventStream),[Oe.Protocols+Se.Query]:new XI(this.didResolver,this.messageStore,this.dataStore),[Oe.Records+Se.Delete]:new eP(this.didResolver,this.messageStore,this.dataStore,this.eventLog,this.eventStream),[Oe.Records+Se.Query]:new tP(this.didResolver,this.messageStore,this.dataStore),[Oe.Records+Se.Read]:new rP(this.didResolver,this.messageStore,this.dataStore),[Oe.Records+Se.Subscribe]:new iP(this.didResolver,this.messageStore,this.eventStream),[Oe.Records+Se.Write]:new oP(this.didResolver,this.messageStore,this.dataStore,this.eventLog,this.eventStream)}}static create(e){var r,n;return O1(this,void 0,void 0,function*(){(r=e.didResolver)!==null&&r!==void 0||(e.didResolver=new uP({didResolvers:[ev,F6,D1],cache:new dP({location:"RESOLVERCACHE"})})),(n=e.tenantGate)!==null&&n!==void 0||(e.tenantGate=new d6);let i=new t(e);return yield i.open(),i})}open(){var e;return O1(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 O1(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 O1(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 O1(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 O1(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{ve.validateJsonSchema(e)}catch(s){return er(s,400)}})}};h();var SGe=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(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 AGe(t){return new Promise((e,r)=>{if(t.aborted){r(t.reason);return}t.addEventListener("abort",()=>{r(t.reason)})})}function Ui(t,e){return SGe(this,void 0,void 0,function*(){return e?Promise.race([t,AGe(e)]):t})}h();h();h();h();var lme=qt(N2(),1),Pc=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},Cu=function(t){return this instanceof Cu?(this.v=t,this):new Cu(t)},zq=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)}},ume=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,v){o.push([m,p,g,v])>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 Cu?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 $u(t,e){return Pc(this,void 0,void 0,function*(){return new lme.Level(t,Object.assign(Object.assign({},e),{keyEncoding:"utf8"}))})}var C1=class t{constructor(e,r){this.config=Object.assign({createLevelDatabase:$u},e),this.db=r}open(){return Pc(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 Pc(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 Pc(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 Pc(this,void 0,void 0,function*(){(n=r?.signal)===null||n===void 0||n.throwIfAborted(),yield Ui(this.createLevelDatabase(),r?.signal);try{return yield Ui(this.db.get(String(e)),r?.signal)}catch(i){if(i.code==="LEVEL_NOT_FOUND")return;throw i}})}has(e,r){return Pc(this,void 0,void 0,function*(){return!!(yield this.get(e,r))})}keys(e){var r,n;return ume(this,arguments,function*(){var o,s,a,d;(r=e?.signal)===null||r===void 0||r.throwIfAborted(),yield Cu(Ui(this.createLevelDatabase(),e?.signal));try{for(var u=!0,c=zq(this.db.keys()),l;l=yield Cu(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 Cu(m)}}catch(m){s={error:m}}finally{try{!u&&!o&&(a=c.return)&&(yield Cu(a.call(c)))}finally{if(s)throw s.error}}})}iterator(e,r){var n,i;return ume(this,arguments,function*(){var s,a,d,u;(n=r?.signal)===null||n===void 0||n.throwIfAborted(),yield Cu(Ui(this.createLevelDatabase(),r?.signal));try{for(var c=!0,l=zq(this.db.iterator(e)),m;m=yield Cu(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 Cu(p)}}catch(p){a={error:p}}finally{try{!c&&!s&&(d=l.return)&&(yield Cu(d.call(l)))}finally{if(a)throw a.error}}})}put(e,r,n){var i;return Pc(this,void 0,void 0,function*(){return(i=n?.signal)===null||i===void 0||i.throwIfAborted(),yield Ui(this.createLevelDatabase(),n?.signal),Ui(this.db.put(String(e),r),n?.signal)})}delete(e,r){var n;return Pc(this,void 0,void 0,function*(){return(n=r?.signal)===null||n===void 0||n.throwIfAborted(),yield Ui(this.createLevelDatabase(),r?.signal),Ui(this.db.del(String(e)),r?.signal)})}isEmpty(e){var r,n,i,o;return Pc(this,void 0,void 0,function*(){try{for(var s=!0,a=zq(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 Pc(this,void 0,void 0,function*(){yield this.createLevelDatabase(),yield this.db.clear(),yield this.compactUnderlyingStorage()})}batch(e,r){var n;return Pc(this,void 0,void 0,function*(){return(n=r?.signal)===null||n===void 0||n.throwIfAborted(),yield Ui(this.createLevelDatabase(),r?.signal),Ui(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 Pc(this,void 0,void 0,function*(){(r=e?.signal)===null||r===void 0||r.throwIfAborted(),yield Ui(this.createLevelDatabase(),e?.signal);let o=this.sublevelRange;if(!o)return;let s=this.root;if(s.db.supports.additionalMethods.compactRange)return Ui((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 Pc(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 $h=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},lP=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)}},Bo=function(t){return this instanceof Bo?(this.v=t,this):new Bo(t)},fP=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,v){o.push([m,p,g,v])>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 Bo?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])}},$1=class t{constructor(e,r){this.config=Object.assign({createLevelDatabase:$u},e),this.db=r??new C1(Object.assign(Object.assign({},this.config),{valueEncoding:"binary"}))}open(){return $h(this,void 0,void 0,function*(){return this.db.open()})}close(){return $h(this,void 0,void 0,function*(){return this.db.close()})}partition(e){return $h(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 $h(this,void 0,void 0,function*(){return yield this.db.put(String(e),r,n),$r.parse(e.toString())})}get(e,r){return $h(this,void 0,void 0,function*(){return yield this.db.get(String(e),r)})}has(e,r){return $h(this,void 0,void 0,function*(){return this.db.has(String(e),r)})}delete(e,r){return $h(this,void 0,void 0,function*(){return this.db.delete(String(e),r)})}isEmpty(e){return $h(this,void 0,void 0,function*(){return this.db.isEmpty(e)})}putMany(e,r){return fP(this,arguments,function*(){var i,o,s,a;try{for(var d=!0,u=lP(e),c;c=yield Bo(u.next()),i=c.done,!i;d=!0){a=c.value,d=!1;let l=a;yield Bo(this.put(l.cid,l.block,r)),yield yield Bo(l.cid)}}catch(l){o={error:l}}finally{try{!d&&!i&&(s=u.return)&&(yield Bo(s.call(u)))}finally{if(o)throw o.error}}})}getMany(e,r){return fP(this,arguments,function*(){var i,o,s,a;try{for(var d=!0,u=lP(e),c;c=yield Bo(u.next()),i=c.done,!i;d=!0){a=c.value,d=!1;let l=a;yield yield Bo({cid:l,block:yield Bo(this.get(l,r))})}}catch(l){o={error:l}}finally{try{!d&&!i&&(s=u.return)&&(yield Bo(s.call(u)))}finally{if(o)throw o.error}}})}getAll(e){return fP(this,arguments,function*(){var n,i,o,s;let a=this.db.iterator({keys:!0,keyEncoding:"buffer"},e);try{for(var d=!0,u=lP(a),c;c=yield Bo(u.next()),n=c.done,!n;d=!0){s=c.value,d=!1;let[l,m]=s;yield yield Bo({cid:$r.decode(l),block:m})}}catch(l){i={error:l}}finally{try{!d&&!n&&(o=u.return)&&(yield Bo(o.call(u)))}finally{if(i)throw i.error}}})}deleteMany(e,r){return fP(this,arguments,function*(){var i,o,s,a;try{for(var d=!0,u=lP(e),c;c=yield Bo(u.next()),i=c.done,!i;d=!0){a=c.value,d=!1;let l=a;yield Bo(this.delete(l,r)),yield yield Bo(l)}}catch(l){o={error:l}}finally{try{!d&&!i&&(s=u.return)&&(yield Bo(s.call(u)))}finally{if(o)throw o.error}}})}clear(){return $h(this,void 0,void 0,function*(){return this.db.clear()})}};h();var NP=qt(cc(),1);h();function TGe(t){return t[Symbol.asyncIterator]!=null}function IGe(t){if(TGe(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 fme=IGe;h();h();h();h();h();var PGe=["string","number","bigint","symbol"],kGe=["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 hme(t){if(t===null)return"null";if(t===void 0)return"undefined";if(t===!0||t===!1)return"boolean";let e=typeof t;if(PGe.includes(e))return e;if(e==="function")return"Function";if(Array.isArray(t))return"Array";if(RGe(t))return"Buffer";let r=BGe(t);return r||"Object"}function RGe(t){return t&&t.constructor&&t.constructor.isBuffer&&t.constructor.isBuffer.call(null,t)}function BGe(t){let e=Object.prototype.toString.call(t).slice(8,-1);if(kGe.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.major<e.major?-1:this.major>e.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 Ve=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 N1=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",MGe=new TextDecoder,DGe=new TextEncoder;function hP(t){return N1&&globalThis.Buffer.isBuffer(t)}function gme(t){return t instanceof Uint8Array?hP(t)?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):t:Uint8Array.from(t)}var vme=N1?(t,e,r)=>r-e>64?globalThis.Buffer.from(t.subarray(e,r)).toString("utf8"):mme(t,e,r):(t,e,r)=>r-e>64?MGe.decode(t.subarray(e,r)):mme(t,e,r),bme=N1?t=>t.length>64?globalThis.Buffer.from(t):pme(t):t=>t.length>64?DGe.encode(t):pme(t);var j1=N1?(t,e,r)=>hP(t)?new Uint8Array(t.subarray(e,r)):t.slice(e,r):(t,e,r)=>t.slice(e,r),wme=N1?(t,e)=>(t=t.map(r=>r instanceof Uint8Array?r:globalThis.Buffer.from(r)),gme(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},_me=N1?t=>globalThis.Buffer.allocUnsafe(t):t=>new Uint8Array(t);function xme(t,e){if(hP(t)&&hP(e))return t.compare(e);for(let r=0;r<t.length;r++)if(t[r]!==e[r])return t[r]<e[r]?-1:1;return 0}function pme(t){let e=[],r=0;for(let n=0;n<t.length;n++){let i=t.charCodeAt(n);i<128?e[r++]=i:i<2048?(e[r++]=i>>6|192,e[r++]=i&63|128):(i&64512)===55296&&n+1<t.length&&(t.charCodeAt(n+1)&64512)===56320?(i=65536+((i&1023)<<10)+(t.charCodeAt(++n)&1023),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 e}function mme(t,e,r){let n=[];for(;e<r;){let i=t[e],o=null,s=i>239?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 OGe(n)}var yme=4096;function OGe(t){let e=t.length;if(e<=yme)return String.fromCharCode.apply(String,t);let r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=yme));return r}var CGe=256,pP=class{constructor(e=CGe){this.chunkSize=e,this.cursor=0,this.maxCursor=-1,this.chunks=[],this._initReuseChunk=null}reset(){this.cursor=0,this.maxCursor=-1,this.chunks.length&&(this.chunks=[]),this._initReuseChunk!==null&&(this.chunks.push(this._initReuseChunk),this.maxCursor=this._initReuseChunk.length-1)}push(e){let r=this.chunks[this.chunks.length-1];if(this.cursor+e.length<=this.maxCursor+1){let i=r.length-(this.maxCursor-this.cursor)-1;r.set(e,i)}else{if(r){let i=r.length-(this.maxCursor-this.cursor)-1;i<r.length&&(this.chunks[this.chunks.length-1]=r.subarray(0,i),this.maxCursor=this.cursor-1)}e.length<64&&e.length<this.chunkSize?(r=_me(this.chunkSize),this.chunks.push(r),this.maxCursor+=r.length,this._initReuseChunk===null&&(this._initReuseChunk=r),r.set(e,0)):(this.chunks.push(e),this.maxCursor+=e.length)}this.cursor+=e.length}toBytes(e=!1){let r;if(this.chunks.length===1){let n=this.chunks[0];e&&this.cursor>n.length/2?(r=this.cursor===n.length?n:n.subarray(0,this.cursor),this._initReuseChunk=null,this.chunks=[]):r=j1(n,0,this.cursor)}else r=wme(this.chunks,this.cursor);return e&&this.reset(),r}};h();var Kt="CBOR decode error:",Vq="CBOR encode error:",V6=[];V6[23]=1;V6[24]=2;V6[25]=3;V6[26]=5;V6[27]=9;function Nh(t,e,r){if(t.length-e<r)throw new Error(`${Kt} not enough data for type`)}h();h();var Mo=[24,256,65536,4294967296,BigInt("18446744073709551616")];function kc(t,e,r){Nh(t,e,1);let n=t[e];if(r.strict===!0&&n<Mo[0])throw new Error(`${Kt} integer encoded in more bytes than necessary (strict decode)`);return n}function Rc(t,e,r){Nh(t,e,2);let n=t[e]<<8|t[e+1];if(r.strict===!0&&n<Mo[1])throw new Error(`${Kt} integer encoded in more bytes than necessary (strict decode)`);return n}function Bc(t,e,r){Nh(t,e,4);let n=t[e]*16777216+(t[e+1]<<16)+(t[e+2]<<8)+t[e+3];if(r.strict===!0&&n<Mo[2])throw new Error(`${Kt} integer encoded in more bytes than necessary (strict decode)`);return n}function Mc(t,e,r){Nh(t,e,8);let n=t[e]*16777216+(t[e+1]<<16)+(t[e+2]<<8)+t[e+3],i=t[e+4]*16777216+(t[e+5]<<16)+(t[e+6]<<8)+t[e+7],o=(BigInt(n)<<BigInt(32))+BigInt(i);if(r.strict===!0&&o<Mo[3])throw new Error(`${Kt} integer encoded in more bytes than necessary (strict decode)`);if(o<=Number.MAX_SAFE_INTEGER)return Number(o);if(r.allowBigInt===!0)return o;throw new Error(`${Kt} integers outside of the safe integer range are not supported`)}function Eme(t,e,r,n){return new Ve(ye.uint,kc(t,e+1,n),2)}function Sme(t,e,r,n){return new Ve(ye.uint,Rc(t,e+1,n),3)}function Ame(t,e,r,n){return new Ve(ye.uint,Bc(t,e+1,n),5)}function Tme(t,e,r,n){return new Ve(ye.uint,Mc(t,e+1,n),9)}function Dd(t,e){return us(t,0,e.value)}function us(t,e,r){if(r<Mo[0]){let n=Number(r);t.push([e|n])}else if(r<Mo[1]){let n=Number(r);t.push([e|24,n])}else if(r<Mo[2]){let n=Number(r);t.push([e|25,n>>>8,n&255])}else if(r<Mo[3]){let n=Number(r);t.push([e|26,n>>>24&255,n>>>16&255,n>>>8&255,n&255])}else{let n=BigInt(r);if(n<Mo[4]){let i=[e|27,0,0,0,0,0,0,0],o=Number(n&BigInt(4294967295)),s=Number(n>>BigInt(32)&BigInt(4294967295));i[8]=o&255,o=o>>8,i[7]=o&255,o=o>>8,i[6]=o&255,o=o>>8,i[5]=o&255,i[4]=s&255,s=s>>8,i[3]=s&255,s=s>>8,i[2]=s&255,s=s>>8,i[1]=s&255,t.push(i)}else throw new Error(`${Kt} encountered BigInt larger than allowable range`)}}Dd.encodedSize=function(e){return us.encodedSize(e.value)};us.encodedSize=function(e){return e<Mo[0]?1:e<Mo[1]?2:e<Mo[2]?3:e<Mo[3]?5:9};Dd.compareTokens=function(e,r){return e.value<r.value?-1:e.value>r.value?1:0};h();function Ime(t,e,r,n){return new Ve(ye.negint,-1-kc(t,e+1,n),2)}function Pme(t,e,r,n){return new Ve(ye.negint,-1-Rc(t,e+1,n),3)}function kme(t,e,r,n){return new Ve(ye.negint,-1-Bc(t,e+1,n),5)}var Hq=BigInt(-1),Rme=BigInt(1);function Bme(t,e,r,n){let i=Mc(t,e+1,n);if(typeof i!="bigint"){let o=-1-i;if(o>=Number.MIN_SAFE_INTEGER)return new Ve(ye.negint,o,9)}if(n.allowBigInt!==!0)throw new Error(`${Kt} integers outside of the safe integer range are not supported`);return new Ve(ye.negint,Hq-BigInt(i),9)}function mP(t,e){let r=e.value,n=typeof r=="bigint"?r*Hq-Rme:r*-1-1;us(t,e.type.majorEncoded,n)}mP.encodedSize=function(e){let r=e.value,n=typeof r=="bigint"?r*Hq-Rme:r*-1-1;return n<Mo[0]?1:n<Mo[1]?2:n<Mo[2]?3:n<Mo[3]?5:9};mP.compareTokens=function(e,r){return e.value<r.value?1:e.value>r.value?-1:0};h();function H6(t,e,r,n){Nh(t,e,r+n);let i=j1(t,e+r,e+r+n);return new Ve(ye.bytes,i,r+n)}function Mme(t,e,r,n){return H6(t,e,1,r)}function Dme(t,e,r,n){return H6(t,e,2,kc(t,e+1,n))}function Ome(t,e,r,n){return H6(t,e,3,Rc(t,e+1,n))}function Cme(t,e,r,n){return H6(t,e,5,Bc(t,e+1,n))}function $me(t,e,r,n){let i=Mc(t,e+1,n);if(typeof i=="bigint")throw new Error(`${Kt} 64-bit integer bytes lengths not supported`);return H6(t,e,9,i)}function yP(t){return t.encodedBytes===void 0&&(t.encodedBytes=t.type===ye.string?bme(t.value):t.value),t.encodedBytes}function U1(t,e){let r=yP(e);us(t,e.type.majorEncoded,r.length),t.push(r)}U1.encodedSize=function(e){let r=yP(e);return us.encodedSize(r.length)+r.length};U1.compareTokens=function(e,r){return NGe(yP(e),yP(r))};function NGe(t,e){return t.length<e.length?-1:t.length>e.length?1:xme(t,e)}h();function W6(t,e,r,n,i){let o=r+n;Nh(t,e,o);let s=new Ve(ye.string,vme(t,e+r,e+o),o);return i.retainStringBytes===!0&&(s.byteValue=j1(t,e+r,e+o)),s}function Nme(t,e,r,n){return W6(t,e,1,r,n)}function jme(t,e,r,n){return W6(t,e,2,kc(t,e+1,n),n)}function Ume(t,e,r,n){return W6(t,e,3,Rc(t,e+1,n),n)}function qme(t,e,r,n){return W6(t,e,5,Bc(t,e+1,n),n)}function Lme(t,e,r,n){let i=Mc(t,e+1,n);if(typeof i=="bigint")throw new Error(`${Kt} 64-bit integer string lengths not supported`);return W6(t,e,9,i,n)}var Kme=U1;h();function q1(t,e,r,n){return new Ve(ye.array,n,r)}function Fme(t,e,r,n){return q1(t,e,1,r)}function zme(t,e,r,n){return q1(t,e,2,kc(t,e+1,n))}function Vme(t,e,r,n){return q1(t,e,3,Rc(t,e+1,n))}function Hme(t,e,r,n){return q1(t,e,5,Bc(t,e+1,n))}function Wme(t,e,r,n){let i=Mc(t,e+1,n);if(typeof i=="bigint")throw new Error(`${Kt} 64-bit integer array lengths not supported`);return q1(t,e,9,i)}function Gme(t,e,r,n){if(n.allowIndefinite===!1)throw new Error(`${Kt} indefinite length items not allowed`);return q1(t,e,1,1/0)}function gP(t,e){us(t,ye.array.majorEncoded,e.value)}gP.compareTokens=Dd.compareTokens;gP.encodedSize=function(e){return us.encodedSize(e.value)};h();function L1(t,e,r,n){return new Ve(ye.map,n,r)}function Jme(t,e,r,n){return L1(t,e,1,r)}function Yme(t,e,r,n){return L1(t,e,2,kc(t,e+1,n))}function Zme(t,e,r,n){return L1(t,e,3,Rc(t,e+1,n))}function Xme(t,e,r,n){return L1(t,e,5,Bc(t,e+1,n))}function Qme(t,e,r,n){let i=Mc(t,e+1,n);if(typeof i=="bigint")throw new Error(`${Kt} 64-bit integer map lengths not supported`);return L1(t,e,9,i)}function eye(t,e,r,n){if(n.allowIndefinite===!1)throw new Error(`${Kt} indefinite length items not allowed`);return L1(t,e,1,1/0)}function vP(t,e){us(t,ye.map.majorEncoded,e.value)}vP.compareTokens=Dd.compareTokens;vP.encodedSize=function(e){return us.encodedSize(e.value)};h();function tye(t,e,r,n){return new Ve(ye.tag,r,1)}function rye(t,e,r,n){return new Ve(ye.tag,kc(t,e+1,n),2)}function nye(t,e,r,n){return new Ve(ye.tag,Rc(t,e+1,n),3)}function iye(t,e,r,n){return new Ve(ye.tag,Bc(t,e+1,n),5)}function oye(t,e,r,n){return new Ve(ye.tag,Mc(t,e+1,n),9)}function bP(t,e){us(t,ye.tag.majorEncoded,e.value)}bP.compareTokens=Dd.compareTokens;bP.encodedSize=function(e){return us.encodedSize(e.value)};h();var FGe=20,zGe=21,VGe=22,HGe=23;function sye(t,e,r,n){if(n.allowUndefined===!1)throw new Error(`${Kt} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new Ve(ye.null,null,1):new Ve(ye.undefined,void 0,1)}function aye(t,e,r,n){if(n.allowIndefinite===!1)throw new Error(`${Kt} indefinite length items not allowed`);return new Ve(ye.break,void 0,1)}function Wq(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 Ve(ye.float,t,e)}function cye(t,e,r,n){return Wq(Gq(t,e+1),3,n)}function dye(t,e,r,n){return Wq(Jq(t,e+1),5,n)}function uye(t,e,r,n){return Wq(pye(t,e+1),9,n)}function wP(t,e,r){let n=e.value;if(n===!1)t.push([ye.float.majorEncoded|FGe]);else if(n===!0)t.push([ye.float.majorEncoded|zGe]);else if(n===null)t.push([ye.float.majorEncoded|VGe]);else if(n===void 0)t.push([ye.float.majorEncoded|HGe]);else{let i,o=!1;(!r||r.float64!==!0)&&(fye(n),i=Gq(Nu,1),n===i||Number.isNaN(n)?(Nu[0]=249,t.push(Nu.slice(0,3)),o=!0):(hye(n),i=Jq(Nu,1),n===i&&(Nu[0]=250,t.push(Nu.slice(0,5)),o=!0))),o||(WGe(n),i=pye(Nu,1),Nu[0]=251,t.push(Nu.slice(0,9)))}}wP.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){fye(n);let i=Gq(Nu,1);if(n===i||Number.isNaN(n))return 3;if(hye(n),i=Jq(Nu,1),n===i)return 5}return 9};var lye=new ArrayBuffer(9),Od=new DataView(lye,1),Nu=new Uint8Array(lye,0);function fye(t){if(t===1/0)Od.setUint16(0,31744,!1);else if(t===-1/0)Od.setUint16(0,64512,!1);else if(Number.isNaN(t))Od.setUint16(0,32256,!1);else{Od.setFloat32(0,t);let e=Od.getUint32(0),r=(e&2139095040)>>23,n=e&8388607;if(r===255)Od.setUint16(0,31744,!1);else if(r===0)Od.setUint16(0,(t&2147483648)>>16|n>>13,!1);else{let i=r-127;i<-24?Od.setUint16(0,0):i<-14?Od.setUint16(0,(e&2147483648)>>16|1<<24+i,!1):Od.setUint16(0,(e&2147483648)>>16|i+15<<10|n>>13,!1)}}}function Gq(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 hye(t){Od.setFloat32(0,t,!1)}function Jq(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 WGe(t){Od.setFloat64(0,t,!1)}function pye(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)}wP.compareTokens=Dd.compareTokens;function Jr(t,e,r){throw new Error(`${Kt} encountered invalid minor (${r}) for major ${t[e]>>>5}`)}function _P(t){return()=>{throw new Error(`${Kt} ${t}`)}}var Me=[];for(let t=0;t<=23;t++)Me[t]=Jr;Me[24]=Eme;Me[25]=Sme;Me[26]=Ame;Me[27]=Tme;Me[28]=Jr;Me[29]=Jr;Me[30]=Jr;Me[31]=Jr;for(let t=32;t<=55;t++)Me[t]=Jr;Me[56]=Ime;Me[57]=Pme;Me[58]=kme;Me[59]=Bme;Me[60]=Jr;Me[61]=Jr;Me[62]=Jr;Me[63]=Jr;for(let t=64;t<=87;t++)Me[t]=Mme;Me[88]=Dme;Me[89]=Ome;Me[90]=Cme;Me[91]=$me;Me[92]=Jr;Me[93]=Jr;Me[94]=Jr;Me[95]=_P("indefinite length bytes/strings are not supported");for(let t=96;t<=119;t++)Me[t]=Nme;Me[120]=jme;Me[121]=Ume;Me[122]=qme;Me[123]=Lme;Me[124]=Jr;Me[125]=Jr;Me[126]=Jr;Me[127]=_P("indefinite length bytes/strings are not supported");for(let t=128;t<=151;t++)Me[t]=Fme;Me[152]=zme;Me[153]=Vme;Me[154]=Hme;Me[155]=Wme;Me[156]=Jr;Me[157]=Jr;Me[158]=Jr;Me[159]=Gme;for(let t=160;t<=183;t++)Me[t]=Jme;Me[184]=Yme;Me[185]=Zme;Me[186]=Xme;Me[187]=Qme;Me[188]=Jr;Me[189]=Jr;Me[190]=Jr;Me[191]=eye;for(let t=192;t<=215;t++)Me[t]=tye;Me[216]=rye;Me[217]=nye;Me[218]=iye;Me[219]=oye;Me[220]=Jr;Me[221]=Jr;Me[222]=Jr;Me[223]=Jr;for(let t=224;t<=243;t++)Me[t]=_P("simple values are not supported");Me[244]=Jr;Me[245]=Jr;Me[246]=Jr;Me[247]=sye;Me[248]=_P("simple values are not supported");Me[249]=cye;Me[250]=dye;Me[251]=uye;Me[252]=Jr;Me[253]=Jr;Me[254]=Jr;Me[255]=aye;var ju=[];for(let t=0;t<24;t++)ju[t]=new Ve(ye.uint,t,1);for(let t=-1;t>=-24;t--)ju[31-t]=new Ve(ye.negint,t,1);ju[64]=new Ve(ye.bytes,new Uint8Array(0),1);ju[96]=new Ve(ye.string,"",1);ju[128]=new Ve(ye.array,0,1);ju[160]=new Ve(ye.map,0,1);ju[244]=new Ve(ye.false,!1,1);ju[245]=new Ve(ye.true,!0,1);ju[246]=new Ve(ye.null,null,1);function JGe(){let t=[];return t[ye.uint.major]=Dd,t[ye.negint.major]=mP,t[ye.bytes.major]=U1,t[ye.string.major]=Kme,t[ye.array.major]=gP,t[ye.map.major]=vP,t[ye.tag.major]=bP,t[ye.float.major]=wP,t}var DRt=JGe(),ORt=new pP,xP=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(`${Vq} object contains circular references`);return new t(r,e)}},oy={null:new Ve(ye.null,null),undefined:new Ve(ye.undefined,void 0),true:new Ve(ye.true,!0),false:new Ve(ye.false,!1),emptyArray:new Ve(ye.array,0),emptyMap:new Ve(ye.map,0)},sy={number(t,e,r,n){return!Number.isInteger(t)||!Number.isSafeInteger(t)?new Ve(ye.float,t):t>=0?new Ve(ye.uint,t):new Ve(ye.negint,t)},bigint(t,e,r,n){return t>=BigInt(0)?new Ve(ye.uint,t):new Ve(ye.negint,t)},Uint8Array(t,e,r,n){return new Ve(ye.bytes,t)},string(t,e,r,n){return new Ve(ye.string,t)},boolean(t,e,r,n){return t?oy.true:oy.false},null(t,e,r,n){return oy.null},undefined(t,e,r,n){return oy.undefined},ArrayBuffer(t,e,r,n){return new Ve(ye.bytes,new Uint8Array(t))},DataView(t,e,r,n){return new Ve(ye.bytes,new Uint8Array(t.buffer,t.byteOffset,t.byteLength))},Array(t,e,r,n){if(!t.length)return r.addBreakTokens===!0?[oy.emptyArray,new Ve(ye.break)]:oy.emptyArray;n=xP.createCheck(n,t);let i=[],o=0;for(let s of t)i[o++]=Yq(s,r,n);return r.addBreakTokens?[new Ve(ye.array,t.length),i,new Ve(ye.break)]:[new Ve(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?[oy.emptyMap,new Ve(ye.break)]:oy.emptyMap;n=xP.createCheck(n,t);let a=[],d=0;for(let u of o)a[d++]=[Yq(u,r,n),Yq(i?t.get(u):t[u],r,n)];return YGe(a,r),r.addBreakTokens?[new Ve(ye.map,s),a,new Ve(ye.break)]:[new Ve(ye.map,s),a]}};sy.Map=sy.Object;sy.Buffer=sy.Uint8Array;for(let t of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))sy[`${t}Array`]=sy.DataView;function Yq(t,e={},r){let n=hme(t),i=e&&e.typeEncoders&&e.typeEncoders[n]||sy[n];if(typeof i=="function"){let s=i(t,n,e,r);if(s!=null)return s}let o=sy[n];if(!o)throw new Error(`${Vq} unsupported type: ${n}`);return o(t,n,e,r)}function YGe(t,e){e.mapSorter&&t.sort(e.mapSorter)}h();var ZGe={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},Zq=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=ju[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}},G6=Symbol.for("DONE"),EP=Symbol.for("BREAK");function XGe(t,e,r){let n=[];for(let i=0;i<t.value;i++){let o=J6(e,r);if(o===EP){if(t.value===1/0)break;throw new Error(`${Kt} got unexpected break to lengthed array`)}if(o===G6)throw new Error(`${Kt} found array but not enough entries (got ${i}, expected ${t.value})`);n[i]=o}return n}function QGe(t,e,r){let n=r.useMaps===!0,i=n?void 0:{},o=n?new Map:void 0;for(let s=0;s<t.value;s++){let a=J6(e,r);if(a===EP){if(t.value===1/0)break;throw new Error(`${Kt} got unexpected break to lengthed map`)}if(a===G6)throw new Error(`${Kt} found map but not enough entries (got ${s} [no key], expected ${t.value})`);if(n!==!0&&typeof a!="string")throw new Error(`${Kt} non-string keys not supported (got ${typeof a})`);if(r.rejectDuplicateMapKeys===!0&&(n&&o.has(a)||!n&&a in i))throw new Error(`${Kt} found repeat map key "${a}"`);let d=J6(e,r);if(d===G6)throw new Error(`${Kt} found map but not enough entries (got ${s} [no value], expected ${t.value})`);n?o.set(a,d):i[a]=d}return n?o:i}function J6(t,e){if(t.done())return G6;let r=t.next();if(r.type===ye.break)return EP;if(r.type.terminal)return r.value;if(r.type===ye.array)return XGe(r,t,e);if(r.type===ye.map)return QGe(r,t,e);if(r.type===ye.tag){if(e.tags&&typeof e.tags[r.value]=="function"){let n=J6(t,e);return e.tags[r.value](n)}throw new Error(`${Kt} tag not supported (${r.value})`)}throw new Error("unsupported")}function mye(t,e){if(!(t instanceof Uint8Array))throw new Error(`${Kt} data to decode must be a Uint8Array`);e=Object.assign({},ZGe,e);let r=e.tokenizer||new Zq(t,e),n=J6(r,e);if(n===G6)throw new Error(`${Kt} did not find any content to decode`);if(n===EP)throw new Error(`${Kt} got unexpected break`);return[n,t.subarray(r.pos())]}function Xq(t,e){let[r,n]=mye(t,e);if(n.length>0)throw new Error(`${Kt} too many terminals, data makes no sense`);return r}var gye=42;function rJe(t){return t instanceof ArrayBuffer?new Uint8Array(t,0,t.byteLength):t}function nJe(t){if(t.asCID!==t&&t["/"]!==t.bytes)return null;let e=Ra.asCID(t);if(!e)return null;let r=new Uint8Array(e.bytes.byteLength+1);return r.set(e.bytes,1),[new Ve(ye.tag,gye),new Ve(ye.bytes,r)]}function iJe(){throw new Error("`undefined` is not supported by the IPLD Data Model and cannot be encoded")}function oJe(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 yye={float64:!0,typeEncoders:{Object:nJe,undefined:iJe,number:oJe}},WRt={...yye,typeEncoders:{...yye.typeEncoders}};function sJe(t){if(t[0]!==0)throw new Error("Invalid CID for CBOR tag 42; expected leading 0x00");return Ra.decode(t.subarray(1))}var SP={allowIndefinite:!1,coerceUndefinedToNull:!0,allowNaN:!1,allowInfinity:!1,allowBigInt:!0,strict:!0,useMaps:!1,rejectDuplicateMapKeys:!0,tags:[]};SP.tags[gye]=sJe;var GRt={...SP,tags:SP.tags.slice()};var vye=113;var bye=t=>Xq(rJe(t),SP);var e0e=qt(cc(),1);h();var _ye=0,aJe="identity",xye=jd,cJe=t=>Ey(_ye,xye(t)),Eye={code:_ye,name:aJe,encode:xye,digest:cJe};h();var Sye=qt(cc(),1);var dJe=async(t,e,r,n,i,o,s,a)=>{let d=await s.get(t,a),u=bye(d),c=u,l=r;for(;n.length>0;){let m=n[0];if(m in c){n.shift(),l=`${l}/${m}`;let p=$r.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,Sye.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}}}},Aye=dJe;h();var Tye=qt(cc(),1);h();function uJe(t,e,r,n){let i=BigInt(t.length),o=BigInt(e+i);return r>=o||n<e?new Uint8Array(0):(n>=e&&n<o&&(t=t.subarray(0,Number(n-e))),r>=e&&r<o&&(t=t.subarray(Number(r-e))),t)}var nv=uJe;h();var Y6=qt(cc(),1),lJe=(t,e=0,r=t)=>{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,Y6.default)(new Error("Offset must be greater than or equal to 0"),"ERR_INVALID_PARAMS");if(i>n)throw(0,Y6.default)(new Error("Offset must be less than the file size"),"ERR_INVALID_PARAMS");if(o<0n)throw(0,Y6.default)(new Error("Length must be greater than or equal to 0"),"ERR_INVALID_PARAMS");if(o>n)throw(0,Y6.default)(new Error("Length must be less than the file size"),"ERR_INVALID_PARAMS");return{start:i,end:o}},K1=lJe;var fJe=t=>{async function*e(r={}){let{start:n,end:i}=K1(t.length,r.offset,r.length),o=nv(t,0n,n,i);r.onProgress?.(new ci("unixfs:exporter:progress:identity",{bytesRead:BigInt(o.byteLength),totalBytes:i-n,fileSize:BigInt(t.byteLength)})),yield o}return e},hJe=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=F3(t.multihash.bytes);return{entry:{type:"identity",name:e,path:r,cid:t,content:fJe(d.digest),depth:o,size:BigInt(d.digest.length),node:d.digest}}},Iye=hJe;h();var Pye=qt(cc(),1);var pJe=t=>{async function*e(r={}){let{start:n,end:i}=K1(t.length,r.offset,r.length),o=nv(t,0n,n,i);r.onProgress?.(new ci("unixfs:exporter:progress:raw",{bytesRead:BigInt(o.byteLength),totalBytes:i-n,fileSize:BigInt(t.byteLength)})),yield o}return e},mJe=async(t,e,r,n,i,o,s,a)=>{if(n.length>0)throw(0,Pye.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:pJe(d),depth:o,size:BigInt(d.length),node:d}}},kye=mJe;h();var i3=qt(cc(),1);h();var yJe=async function(t){return(await B8.encode(t)).slice(0,8).reverse()},gJe=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 wl({hash:r._options.hash,bits:r._options.bits},e,i));return}await r.put(n.Name.substring(2),!0)}))},Rye=t=>t.toString(16).toUpperCase().padStart(2,"0").substring(0,2),vJe=t=>{let e=t.bucket,r=[];for(;e._parent!=null;)r.push(e),e=e._parent;return r.push(e),r.reverse()},Bye=async(t,e,r,n,i)=>{if(n==null){let c=O8({hashFn:yJe});n={rootBucket:c,hamtDepth:1,lastBucket:c}}await gJe(t.Links,n.lastBucket,n.rootBucket);let o=await n.rootBucket._findNewBucketAndPos(e),s=Rye(o.pos),a=vJe(o);a.length>n.hamtDepth&&(n.lastBucket=a[n.hamtDepth],s=Rye(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=Jf(u),Bye(t,e,r,n,i)},Mye=Bye;h();h();h();function bJe(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 AP=bJe;function wJe(t){return t[Symbol.asyncIterator]!=null}function _Je(t,e){if(wJe(t))return async function*(){for await(let a of t)await e(a)&&(yield a)}();let r=AP(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 Dye=_Je;h();function xJe(t){return t[Symbol.asyncIterator]!=null}function EJe(t,e){if(xJe(t))return async function*(){for await(let a of t)yield e(a)}();let r=AP(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 F1=EJe;h();h();function jh(){let t={};return t.promise=new Promise((e,r)=>{t.resolve=e,t.reject=r}),t}var TP=globalThis.CustomEvent??Event;async function*iv(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=jh(),a=jh(),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=jh(),await s.promise),c)break;let v={done:!1};o.push(v),g().then(E=>{v.done=!0,v.ok=!0,v.value=E,i.dispatchEvent(new TP("task-complete"))},E=>{v.done=!0,v.err=E,i.dispatchEvent(new TP("task-complete"))})}d=!0,i.dispatchEvent(new TP("task-complete"))}catch(g){u=g,i.dispatchEvent(new TP("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;g<o.length;g++)if(o[g].done){let v=o[g];if(o.splice(g,1),g--,v.ok)yield v.value;else throw c=!0,s.resolve(),v.err;s.resolve()}}for(;;){if(l()||(a=jh(),await a.promise),u!=null)throw u;if(n?yield*m():yield*p(),d&&o.length===0)break}}h();h();h();var IP=class{buffer;mask;top;btm;next;constructor(e){if(!(e>0)||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}},z1=class{size;hwm;head;tail;constructor(e={}){this.hwm=e.splitLimit??16,this.head=new IP(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 IP(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 Qq=class extends Error{type;code;constructor(e,r){super(e??"The operation was aborted"),this.type="aborted",this.code=r??"ABORT_ERR"}};function V1(t={}){return SJe(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 SJe(t,e){e=e??{};let r=e.onEnd,n=new z1,i,o,s,a=jh(),d=async()=>{try{return n.isEmpty()?s?{done:!0}:await new Promise((E,A)=>{o=P=>{o=null,n.push(P);try{E(t(n))}catch(I){A(I)}return i}}):t(n)}finally{n.isEmpty()&&queueMicrotask(()=>{a.resolve(),a=jh()})}},u=E=>o!=null?o(E):(n.push(E),i),c=E=>(n=new z1,o!=null?o({error:E}):(n.push({error:E}),i)),l=E=>{if(s)return i;if(e?.objectMode!==!0&&E?.byteLength==null)throw new Error("objectMode was not true but tried to push non-Uint8Array value");return u({done:!1,value:E})},m=E=>s?i:(s=!0,E!=null?c(E):u({done:!0})),p=()=>(n=new z1,m(),{done:!0}),g=E=>(m(E),{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 E=>{let A=E?.signal;if(A?.throwIfAborted(),n.isEmpty())return;let P,I;A!=null&&(P=new Promise(($,N)=>{I=()=>{N(new Qq)},A.addEventListener("abort",I)}));try{await Promise.race([a.promise,P])}finally{I!=null&&A!=null&&A?.removeEventListener("abort",I)}}},r==null)return i;let v=i;return i={[Symbol.asyncIterator](){return this},next(){return v.next()},throw(E){return v.throw(E),r!=null&&(r(E),r=void 0),{done:!0}},return(){return v.return(),r!=null&&(r(),r=void 0),{done:!0}},push:l,end(E){return v.end(E),r!=null&&(r(E),r=void 0),i},get readableLength(){return v.readableLength},onEmpty:E=>v.onEmpty(E)},i}h();function AJe(t){return t[Symbol.asyncIterator]!=null}function TJe(...t){let e=[];for(let r of t)AJe(r)||e.push(r);return e.length===t.length?function*(){for(let r of e)yield*r}():async function*(){let r=V1({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 Oye=TJe;function H1(t,...e){if(t==null)throw new Error("Empty pipeline");if(eL(t)){let n=t;t=()=>n.source}else if($ye(t)||Cye(t)){let n=t;t=()=>n}let r=[t,...e];if(r.length>1&&eL(r[r.length-1])&&(r[r.length-1]=r[r.length-1].sink),r.length>2)for(let n=1;n<r.length-1;n++)eL(r[n])&&(r[n]=PJe(r[n]));return IJe(...r)}var IJe=(...t)=>{let e;for(;t.length>0;)e=t.shift()(e);return e},Cye=t=>t?.[Symbol.asyncIterator]!=null,$ye=t=>t?.[Symbol.iterator]!=null,eL=t=>t==null?!1:t.sink!=null&&t.source!=null,PJe=t=>e=>{let r=t.sink(e);if(r?.then!=null){let n=V1({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($ye(o))i=function*(){yield*o,n.end()};else throw new Error("Unknown duplex source type - must be Iterable or AsyncIterable");return Oye(n,i())}return t.source};var kJe=(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 ci("unixfs:exporter:walk:directory",{cid:t})),yield*H1(l,m=>F1(m,p=>async()=>{let g=p.Name??"",v=`${n}/${g}`;return(await i(p.Hash,g,v,[],o+1,s,d)).entry}),m=>iv(m,{ordered:!0}),m=>Dye(m,p=>p!=null))}return a},Nye=kJe;h();var sv=qt(cc(),1);h();h();var rL=qt(Uye(),1);h();var X6=class extends Error{constructor(e){super(e),this.name="TimeoutError"}},nL=class extends Error{constructor(e){super(),this.name="AbortError",this.message=e}},qye=t=>globalThis.DOMException===void 0?new nL(t):new DOMException(t),Lye=t=>{let e=t.reason===void 0?qye("This operation was aborted."):t.reason;return e instanceof Error?e:qye(e)};function iL(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(Lye(d)),d.addEventListener("abort",()=>{a(Lye(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 X6(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 oL(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 ov=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)},Uh,sL=class{constructor(){Uh.set(this,[])}enqueue(e,r){r={priority:0,...r};let n={priority:r.priority,run:e};if(this.size&&ov(this,Uh,"f")[this.size-1].priority>=r.priority){ov(this,Uh,"f").push(n);return}let i=oL(ov(this,Uh,"f"),n,(o,s)=>s.priority-o.priority);ov(this,Uh,"f").splice(i,0,n)}dequeue(){let e=ov(this,Uh,"f").shift();return e?.run}filter(e){return ov(this,Uh,"f").filter(r=>r.priority===e.priority).map(r=>r.run)}get size(){return ov(this,Uh,"f").length}};Uh=new WeakMap;var Kye=sL;var ni=function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},ct=function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},Bi,e3,t3,cy,OP,r3,kP,Uu,Q6,Dc,RP,Oc,n3,ay,BP,Fye,zye,Wye,Vye,Hye,MP,aL,cL,CP,Gye,DP,$P=class extends Error{},dL=class extends rL.default{constructor(e){var r,n,i,o;if(super(),Bi.add(this),e3.set(this,void 0),t3.set(this,void 0),cy.set(this,0),OP.set(this,void 0),r3.set(this,void 0),kP.set(this,0),Uu.set(this,void 0),Q6.set(this,void 0),Dc.set(this,void 0),RP.set(this,void 0),Oc.set(this,0),n3.set(this,void 0),ay.set(this,void 0),BP.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:Kye,...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})`);ni(this,e3,e.carryoverConcurrencyCount,"f"),ni(this,t3,e.intervalCap===Number.POSITIVE_INFINITY||e.interval===0,"f"),ni(this,OP,e.intervalCap,"f"),ni(this,r3,e.interval,"f"),ni(this,Dc,new e.queueClass,"f"),ni(this,RP,e.queueClass,"f"),this.concurrency=e.concurrency,this.timeout=e.timeout,ni(this,BP,e.throwOnTimeout===!0,"f"),ni(this,ay,e.autoStart===!1,"f")}get concurrency(){return ct(this,n3,"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})`);ni(this,n3,e,"f"),ct(this,Bi,"m",CP).call(this)}async add(e,r={}){return r={timeout:this.timeout,throwOnTimeout:ct(this,BP,"f"),...r},new Promise((n,i)=>{ct(this,Dc,"f").enqueue(async()=>{var o,s,a;ni(this,Oc,(s=ct(this,Oc,"f"),s++,s),"f"),ni(this,cy,(a=ct(this,cy,"f"),a++,a),"f");try{if(!((o=r.signal)===null||o===void 0)&&o.aborted)throw new $P("The task was aborted.");let d=e({signal:r.signal});r.timeout&&(d=iL(Promise.resolve(d),r.timeout)),r.signal&&(d=Promise.race([d,ct(this,Bi,"m",Gye).call(this,r.signal)]));let u=await d;n(u),this.emit("completed",u)}catch(d){if(d instanceof X6&&!r.throwOnTimeout){n();return}i(d),this.emit("error",d)}finally{ct(this,Bi,"m",Wye).call(this)}},r),this.emit("add"),ct(this,Bi,"m",MP).call(this)})}async addAll(e,r){return Promise.all(e.map(async n=>this.add(n,r)))}start(){return ct(this,ay,"f")?(ni(this,ay,!1,"f"),ct(this,Bi,"m",CP).call(this),this):this}pause(){ni(this,ay,!0,"f")}clear(){ni(this,Dc,new(ct(this,RP,"f")),"f")}async onEmpty(){ct(this,Dc,"f").size!==0&&await ct(this,Bi,"m",DP).call(this,"empty")}async onSizeLessThan(e){ct(this,Dc,"f").size<e||await ct(this,Bi,"m",DP).call(this,"next",()=>ct(this,Dc,"f").size<e)}async onIdle(){ct(this,Oc,"f")===0&&ct(this,Dc,"f").size===0||await ct(this,Bi,"m",DP).call(this,"idle")}get size(){return ct(this,Dc,"f").size}sizeBy(e){return ct(this,Dc,"f").filter(e).length}get pending(){return ct(this,Oc,"f")}get isPaused(){return ct(this,ay,"f")}};e3=new WeakMap,t3=new WeakMap,cy=new WeakMap,OP=new WeakMap,r3=new WeakMap,kP=new WeakMap,Uu=new WeakMap,Q6=new WeakMap,Dc=new WeakMap,RP=new WeakMap,Oc=new WeakMap,n3=new WeakMap,ay=new WeakMap,BP=new WeakMap,Bi=new WeakSet,Fye=function(){return ct(this,t3,"f")||ct(this,cy,"f")<ct(this,OP,"f")},zye=function(){return ct(this,Oc,"f")<ct(this,n3,"f")},Wye=function(){var e;ni(this,Oc,(e=ct(this,Oc,"f"),e--,e),"f"),ct(this,Bi,"m",MP).call(this),this.emit("next")},Vye=function(){ct(this,Bi,"m",cL).call(this),ct(this,Bi,"m",aL).call(this),ni(this,Q6,void 0,"f")},Hye=function(){let e=Date.now();if(ct(this,Uu,"f")===void 0){let r=ct(this,kP,"f")-e;if(r<0)ni(this,cy,ct(this,e3,"f")?ct(this,Oc,"f"):0,"f");else return ct(this,Q6,"f")===void 0&&ni(this,Q6,setTimeout(()=>{ct(this,Bi,"m",Vye).call(this)},r),"f"),!0}return!1},MP=function(){if(ct(this,Dc,"f").size===0)return ct(this,Uu,"f")&&clearInterval(ct(this,Uu,"f")),ni(this,Uu,void 0,"f"),this.emit("empty"),ct(this,Oc,"f")===0&&this.emit("idle"),!1;if(!ct(this,ay,"f")){let e=!ct(this,Bi,"a",Hye);if(ct(this,Bi,"a",Fye)&&ct(this,Bi,"a",zye)){let r=ct(this,Dc,"f").dequeue();return r?(this.emit("active"),r(),e&&ct(this,Bi,"m",aL).call(this),!0):!1}}return!1},aL=function(){ct(this,t3,"f")||ct(this,Uu,"f")!==void 0||(ni(this,Uu,setInterval(()=>{ct(this,Bi,"m",cL).call(this)},ct(this,r3,"f")),"f"),ni(this,kP,Date.now()+ct(this,r3,"f"),"f"))},cL=function(){ct(this,cy,"f")===0&&ct(this,Oc,"f")===0&&ct(this,Uu,"f")&&(clearInterval(ct(this,Uu,"f")),ni(this,Uu,void 0,"f")),ni(this,cy,ct(this,e3,"f")?ct(this,Oc,"f"):0,"f"),ct(this,Bi,"m",CP).call(this)},CP=function(){for(;ct(this,Bi,"m",MP).call(this););},Gye=async function(e){return new Promise((r,n)=>{e.addEventListener("abort",()=>{n(new $P("The task was aborted."))},{once:!0})})},DP=async function(e,r){return new Promise(n=>{let i=()=>{r&&!r()||(this.off(e,i),n())};this.on(e,i)})};var Jye=dL;async function Yye(t,e,r,n,i,o,s){if(e instanceof Uint8Array){let u=nv(e,n,i,o);r.push(u);return}if(e.Data==null)throw(0,sv.default)(new Error("no data in PBNode"),"ERR_NOT_UNIXFS");let a;try{a=yo.unmarshal(e.Data)}catch(u){throw(0,sv.default)(u,"ERR_NOT_UNIXFS")}if(a.data!=null){let u=a.data,c=nv(u,n,i,o);r.push(c),n+=BigInt(c.byteLength)}let d=[];if(e.Links.length!==a.blockSizes.length)throw(0,sv.default)(new Error("Inconsistent block sizes and dag links"),"ERR_NOT_UNIXFS");for(let u=0;u<e.Links.length;u++){let c=e.Links[u],l=n,m=l+a.blockSizes[u];if((i>=l&&i<m||o>=l&&o<=m||i<l&&o>m)&&d.push({link:c,blockStart:n}),n=m,n>o)break}await H1(d,u=>F1(u,c=>async()=>{let l=await t.get(c.link.Hash,s);return{...c,block:l}}),u=>iv(u,{ordered:!0}),async u=>{for await(let{link:c,block:l,blockStart:m}of u){let p;switch(c.Hash.code){case sx:p=Jf(l);break;case Wp:p=l;break;default:r.end((0,sv.default)(new Error(`Unsupported codec: ${c.Hash.code}`),"ERR_NOT_UNIXFS"));return}let g=new Jye({concurrency:1});g.on("error",v=>{r.end(v)}),g.add(async()=>{s.onProgress?.(new ci("unixfs:exporter:walk:file",{cid:c.Hash})),await Yye(t,p,r,m,i,o,s)}),await g.onIdle()}}),n>=o&&r.end()}var MJe=(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}=K1(u,d.offset,d.length);if(l===0n)return;let m=0n,p=l-c,g=V1();d.onProgress?.(new ci("unixfs:exporter:walk:file",{cid:t})),Yye(s,e,g,0n,c,l,d).catch(v=>{g.end(v)});for await(let v of g)if(v!=null){if(m+=BigInt(v.byteLength),m>p)throw g.end(),(0,sv.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 ci("unixfs:exporter:progress:unixfs:file",{bytesRead:m,totalBytes:p,fileSize:u})),yield v}if(m<p)throw(0,sv.default)(new Error("Traversed entire DAG but did not read enough bytes"),"ERR_UNDER_READ")}return a},uL=MJe;h();var DJe=(t,e,r,n,i,o,s)=>{function a(d={}){return d.onProgress?.(new ci("unixfs:exporter:walk:hamt-sharded-directory",{cid:t})),Zye(e,n,i,o,s,d)}return a};async function*Zye(t,e,r,n,i,o){let s=t.Links,a=H1(s,d=>F1(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=Jf(l),o.onProgress?.(new ci("unixfs:exporter:walk:hamt-sharded-directory",{cid:u.Hash})),{entries:Zye(t,e,r,n,i,o)}}}),d=>iv(d,{ordered:!0}));for await(let{entries:d}of a)yield*d}var Xye=DJe;var OJe=(t,e)=>t.Links.find(n=>n.Name===e)?.Hash,CJe={raw:uL,file:uL,directory:Nye,"hamt-sharded-directory":Xye,metadata:(t,e,r,n,i,o,s)=>()=>[],symlink:(t,e,r,n,i,o,s)=>()=>[]},$Je=async(t,e,r,n,i,o,s,a)=>{let d=await s.get(t,a),u=Jf(d),c,l;if(e==null&&(e=t.toString()),u.Data==null)throw(0,i3.default)(new Error("no data in PBNode"),"ERR_NOT_UNIXFS");try{c=yo.unmarshal(u.Data)}catch(p){throw(0,i3.default)(p,"ERR_NOT_UNIXFS")}if(r==null&&(r=e),n.length>0){let p;if(c?.type==="hamt-sharded-directory"?p=await Mye(u,n[0],s):p=OJe(u,n[0]),p==null)throw(0,i3.default)(new Error("file does not exist"),"ERR_NOT_FOUND");let g=n.shift(),v=`${r}/${g}`;l={cid:p,toResolve:n,name:g??"",path:v}}let m=CJe[c.type](t,u,c,r,i,o,s);if(m==null)throw(0,i3.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}},Qye=$Je;var NJe={[sx]:Qye,[Wp]:kye,[vye]:Aye,[Eye.code]:Iye},t0e=async(t,e,r,n,i,o,s)=>{let a=NJe[t.code];if(a==null)throw(0,e0e.default)(new Error(`No resolver for code ${t.code}`),"ERR_NO_RESOLVER");return a(t,e,r,n,t0e,i,o,s)},r0e=t0e;var jJe=(t="")=>(t.trim().match(/([^\\^/]|\\\/)+/g)??[]).filter(Boolean),UJe=t=>{if(t instanceof Uint8Array)return{cid:$r.decode(t),toResolve:[]};let e=$r.asCID(t);if(e!=null)return{cid:e,toResolve:[]};if(typeof t=="string"){t.indexOf("/ipfs/")===0&&(t=t.substring(6));let r=jJe(t);return{cid:$r.parse(r[0]),toResolve:r.slice(1)}}throw(0,NP.default)(new Error(`Unknown path type ${t}`),"ERR_BAD_PATH")};async function*qJe(t,e,r={}){let{cid:n,toResolve:i}=UJe(t),o=n.toString(),s=o,a=i.length;for(;;){let d=await r0e(n,o,s,i,a,e,r);if(d.entry==null&&d.next==null)throw(0,NP.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 n0e(t,e,r={}){let n=await fme(qJe(t,e,r));if(n==null)throw(0,NP.default)(new Error(`Could not resolve ${t}`),"ERR_NOT_FOUND");return n}var i0e=qt(ST(),1),dy=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},LJe=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)}},W1=class{constructor(e={}){this.config=Object.assign({blockstoreLocation:"DATASTORE",createLevelDatabase:$u},e),this.blockstore=new $1({location:this.config.blockstoreLocation,createLevelDatabase:this.config.createLevelDatabase})}open(){return dy(this,void 0,void 0,function*(){yield this.blockstore.open()})}close(){return dy(this,void 0,void 0,function*(){yield this.blockstore.close()})}put(e,r,n,i){var o,s,a,d,u,c;return dy(this,void 0,void 0,function*(){let l=yield this.getBlockstoreForStoringData(e,r,n),m=yx([{content:i}],l,{cidVersion:1}),p;try{for(var g=!0,v=LJe(m),E;E=yield v.next(),o=E.done,!o;g=!0)d=E.value,g=!1,p=d}catch(A){s={error:A}}finally{try{!g&&!o&&(a=v.return)&&(yield a.call(v))}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 dy(this,void 0,void 0,function*(){let i=yield this.getBlockstoreForStoringData(e,r,n);if(!(yield i.has(n)))return;let s=yield n0e(n,i),a=s.content(),d=new i0e.Readable({read(){return dy(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 dy(this,void 0,void 0,function*(){yield(yield this.getBlockstoreForStoringData(e,r,n)).clear()})}clear(){return dy(this,void 0,void 0,function*(){yield this.blockstore.clear()})}getBlockstoreForStoringData(e,r,n){return dy(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 io=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},o3=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)}},av=function(t){return this instanceof av?(this.v=t,this):new av(t)},KJe=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,v){o.push([m,p,g,v])>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 av?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])}},o0e="index",qh=class t{constructor(e){this.config=Object.assign({createLevelDatabase:$u},e),this.db=new C1({location:this.config.location,createLevelDatabase:this.config.createLevelDatabase,keyEncoding:"utf8"})}open(){return io(this,void 0,void 0,function*(){yield this.db.open()})}close(){return io(this,void 0,void 0,function*(){yield this.db.close()})}clear(){return io(this,void 0,void 0,function*(){yield this.db.clear()})}put(e,r,n,i){return io(this,void 0,void 0,function*(){if(ME(n))throw new se(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 io(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 io(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 io(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 io(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 io(this,void 0,void 0,function*(){return(yield this.db.partition(e)).createPartitionOperation(o0e,r)})}static getIndexPartitionName(e){return`__${e}__`}getIndexPartition(e,r){return io(this,void 0,void 0,function*(){let n=t.getIndexPartitionName(r);return(yield this.db.partition(e)).partition(n)})}getIndexesLookupPartition(e){return io(this,void 0,void 0,function*(){return(yield this.db.partition(e)).partition(o0e)})}query(e,r,n,i){return io(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 io(this,void 0,void 0,function*(){let{cursor:u,limit:c}=n,l=u?this.createStartingKeyFromCursor(u):"",m=[];try{for(var p=!0,g=o3(this.getIndexIterator(e,l,n,i)),v;v=yield g.next(),o=v.done,!o;p=!0){d=v.value,p=!1;let E=d;if(c!==void 0&&c===m.length)break;let{indexes:A}=E;Zn.matchAnyFilter(A,r)&&m.push(E)}}catch(E){s={error:E}}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 KJe(this,arguments,function*(){var s,a,d,u;let{sortProperty:c,sortDirection:l=ds.Ascending,cursor:m}=n,p={gt:r};l===ds.Descending&&(p.reverse=!0,m!==void 0&&(p.lt=r,delete p.gt));let g=yield av(this.getIndexPartition(e,c));try{for(var v=!0,E=o3(g.iterator(p,i)),A;A=yield av(E.next()),s=A.done,!s;v=!0){u=A.value,v=!1;let[P,I]=u,{indexes:$,messageCid:N}=JSON.parse(I);yield yield av({indexes:$,messageCid:N})}}catch(P){a={error:P}}finally{try{!v&&!s&&(d=E.return)&&(yield av(d.call(E)))}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 se(ne.IndexInvalidCursorSortProperty,`the sort property '${r}' is not defined within the given item.`);if(typeof o=="boolean"||Array.isArray(o))throw new se(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 io(this,void 0,void 0,function*(){let{sortProperty:o,sortDirection:s=ds.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,v)=>this.sortItems(g,v,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 io(this,void 0,void 0,function*(){let s=[];if(ME(r)){let d=this.getAllItems(e,n);s.push(d)}let a=kT.reduceFilter(r);for(let d in a){let u=a[d];if(Zn.isEqualFilter(u)){let c=this.filterExactMatches(e,d,u,o);s.push(c)}else if(Zn.isOneOfFilter(u))for(let c of new Set(u)){let l=this.filterExactMatches(e,d,c,o);s.push(l)}else if(Zn.isRangeFilter(u)){let c=this.filterRangeMatches(e,d,u,o);s.push(c)}}for(let d of s){let u=yield d;for(let c of u)if(!(i.has(c.messageCid)||!Zn.matchFilter(c.indexes,r))){if(c.indexes[n]===void 0)throw new se(ne.IndexInvalidSortPropertyInMemory,`invalid sort property ${n}`);i.set(c.messageCid,c)}}})}getAllItems(e,r){var n,i,o,s;return io(this,void 0,void 0,function*(){let a=yield this.getIndexPartition(e,r),d=[];try{for(var u=!0,c=o3(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 io(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=o3(l.iterator(c,i)),v;v=yield g.next(),o=v.done,!o;p=!0){d=v.value,p=!1;let[E,A]=d;if(!E.startsWith(u))break;m.push(JSON.parse(A))}}catch(E){s={error:E}}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 io(this,void 0,void 0,function*(){let u={};for(let v in n){let E=v;u[E]=t.encodeValue(n[E])}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=o3(l.iterator(u,i)),g;g=yield p.next(),o=g.done,!o;m=!0){d=g.value,m=!1;let[v,E]=d;"gt"in n&&this.extractIndexValueFromKey(v)===t.encodeValue(n.gt)||c.push(JSON.parse(E))}}catch(v){s={error:v}}finally{try{!m&&!o&&(a=p.return)&&(yield a.call(p))}finally{if(s)throw s.error}}if("lte"in n)for(let v of yield this.filterExactMatches(e,r,n.lte,i))c.push(v);return c})}sortItems(e,r,n,i){let o=e.indexes[n],s=r.indexes[n],a=t.encodeValue(o)+e.messageCid,d=t.encodeValue(s)+r.messageCid;return i===ds.Ascending?BE(a,d):BE(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===ds.Ascending?c>i:c<i};return e.findIndex(o)}getIndexes(e,r){return io(this,void 0,void 0,function*(){let i=yield(yield this.getIndexesLookupPartition(e)).get(r);if(i!==void 0)return JSON.parse(i)})}extractIndexValueFromKey(e){let[r]=e.split(t.delimiter);return r}static keySegmentJoin(...e){return e.join(t.delimiter)}static encodeNumberValue(e){let r=Number.MAX_SAFE_INTEGER,n="!",i=String(Number.MAX_SAFE_INTEGER).length,o=e<0?n:"",s=e<0?r:0;return o+String(e+s).padStart(i,"0")}static encodeValue(e){switch(typeof e){case"number":return this.encodeNumberValue(e);default:return JSON.stringify(e)}}static shouldQueryWithInMemoryPaging(e,r){for(let n of e)if(!t.isFilterConcise(n,r))return!1;return!0}static isFilterConcise(e,r){return e.recordId!==void 0?!0:r.cursor!==void 0?!1:e.protocolPath!==void 0||e.contextId!==void 0||e.parentId!==void 0||e.schema!==void 0}};qh.delimiter="\0";h();h();h();h();function s3(t){if(!G1(t))throw new Error("Parameter was not an error")}function G1(t){return FJe(t)==="[object Error]"||t instanceof Error}function FJe(t){return Object.prototype.toString.call(t)}h();function s0e(t){let e,r="";if(t.length===0)e={};else if(G1(t[0]))e={cause:t[0]},r=t.slice(1).join(" ")||"";else if(t[0]&&typeof t[0]=="object")e=Object.assign({},t[0]),r=t.slice(1).join(" ")||"";else if(typeof t[0]=="string")e={},r=r=t.join(" ")||"";else throw new Error("Invalid arguments passed to Layerr");return{options:e,shortMessage:r}}var qu=class t extends Error{constructor(e,r){let n=[...arguments],{options:i,shortMessage:o}=s0e(n),s=o;if(i.cause&&(s=`${s}: ${i.cause.message}`),super(s),this.message=s,i.name&&typeof i.name=="string"?this.name=i.name:this.name="Layerr",i.cause&&Object.defineProperty(this,"_cause",{value:i.cause}),Object.defineProperty(this,"_info",{value:{}}),i.info&&typeof i.info=="object"&&Object.assign(this._info,i.info),Error.captureStackTrace){let a=i.constructorOpt||this.constructor;Error.captureStackTrace(this,a)}}static cause(e){return s3(e),e._cause&&G1(e._cause)?e._cause:null}static fullStack(e){s3(e);let r=t.cause(e);return r?`${e.stack}
caused by: ${t.fullStack(r)}`:e.stack}static info(e){s3(e);let r={},n=t.cause(e);return n&&Object.assign(r,t.info(n)),e._info&&Object.assign(r,e._info),r}cause(){return t.cause(this)}toString(){let e=this.name||this.constructor.name||this.constructor.prototype.name;return this.message&&(e=`${e}: ${this.message}`),e}};h();var a3="0123456789ABCDEFGHJKMNPQRSTVWXYZ",J1=32,a0e=0xffffffffffff,c0e=10,zJe=16,cv=Object.freeze({source:"ulid"});function VJe(t){let e=t||HJe(),r=e&&(e.crypto||e.msCrypto)||null;if(typeof r?.getRandomValues=="function")return()=>{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 qu({info:{code:"PRNG_DETECT",...cv}},"Failed to find a reliable PRNG")}function HJe(){return JJe()?self:typeof window<"u"?window:typeof globalThis<"u"||typeof globalThis<"u"?globalThis:null}function WJe(t,e){let r="";for(;t>0;t--)r=YJe(e)+r;return r}function d0e(t,e){if(isNaN(t))throw new qu({info:{code:"ENC_TIME_NAN",...cv}},`Time must be a number: ${t}`);if(t>a0e)throw new qu({info:{code:"ENC_TIME_SIZE_EXCEED",...cv}},`Cannot encode a time larger than ${a0e}: ${t}`);if(t<0)throw new qu({info:{code:"ENC_TIME_NEG",...cv}},`Time must be positive: ${t}`);if(Number.isInteger(t)===!1)throw new qu({info:{code:"ENC_TIME_TYPE",...cv}},`Time must be an integer: ${t}`);let r,n="";for(let i=e;i>0;i--)r=t%J1,n=a3.charAt(r)+n,t=(t-r)/J1;return n}function GJe(t){let e,r=t.length,n,i,o=t,s=J1-1;for(;!e&&r-->=0;){if(n=o[r],i=a3.indexOf(n),i===-1)throw new qu({info:{code:"B32_INC_ENC",...cv}},"Incorrectly encoded string");if(i===s){o=u0e(o,r,a3[0]);continue}e=u0e(o,r,a3[i+1])}if(typeof e=="string")return e;throw new qu({info:{code:"B32_INC_INVALID",...cv}},"Failed incrementing string")}function JJe(){return typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope}function jP(t){let e=t||VJe(),r=0,n;return function(o){let s=isNaN(o)?Date.now():o;if(s<=r){let d=n=GJe(n);return d0e(r,c0e)+d}r=s;let a=n=WJe(zJe,e);return d0e(s,c0e)+a}}function YJe(t){let e=Math.floor(t()*J1);return e===J1&&(e=J1-1),a3.charAt(e)}function u0e(t,e,r){return e>t.length-1?t:t.substr(0,e)+r+t.substr(e+1)}var dv=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},Y1=class{constructor(e){this.index=new qh(Object.assign({location:"EVENTLOG",createLevelDatabase:$u},e)),this.ulidFactory=jP()}open(){return dv(this,void 0,void 0,function*(){return this.index.open()})}close(){return dv(this,void 0,void 0,function*(){return this.index.close()})}clear(){return dv(this,void 0,void 0,function*(){return this.index.clear()})}append(e,r,n){return dv(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 dv(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:qh.createCursorFromLastArrayItem(i,"watermark")}})}getEvents(e,r){return dv(this,void 0,void 0,function*(){return this.queryEvents(e,[],r)})}deleteEventsByCid(e,r){return dv(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 UP({enumerable:t=!0,configurable:e=!1}={}){return{enumerable:t,configurable:e,writable:!1}}function*ZJe(t,e){if(e!=null&&typeof e=="object")if(Array.isArray(e))for(let[r,n]of e.entries()){let i=[...t,r],o=$r.asCID(n);o?yield[i.join("/"),o]:typeof n=="object"&&(yield*lL(n,i))}else{let r=$r.asCID(e);r?yield[t.join("/"),r]:yield*lL(e,t)}}function*lL(t,e){if(t==null||t instanceof Uint8Array)return;let r=$r.asCID(t);r&&(yield[e.join("/"),r]);for(let[n,i]of Object.entries(t)){let o=[...e,n];yield*ZJe(o,i)}}function*XJe(t,e){if(Array.isArray(e))for(let[r,n]of e.entries()){let i=[...t,r];yield i.join("/"),typeof n=="object"&&!$r.asCID(n)&&(yield*fL(n,i))}else yield*fL(e,t)}function*fL(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"&&!$r.asCID(n)&&(yield*XJe(i,n))}}function QJe(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=$r.asCID(r);if(o)return{value:o,remaining:e.slice(n+1).join("/")}}return{value:r}}var qP=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:UP(),bytes:UP(),value:UP(),asBlock:UP()})}links(){return lL(this.value,[])}tree(){return fL(this.value,[])}get(e="/"){return QJe(this.value,e.split("/").filter(Boolean))}};async function l0e({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=$r.create(1,e.code,i);return new qP({value:t,bytes:n,cid:o})}async function f0e({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=$r.create(1,e.code,i);return new qP({value:n,bytes:t,cid:o})}var uv=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},Z1=class t{constructor(e={}){this.config=Object.assign({blockstoreLocation:"MESSAGESTORE",indexLocation:"INDEX",createLevelDatabase:$u},e),this.blockstore=new $1({location:this.config.blockstoreLocation,createLevelDatabase:this.config.createLevelDatabase}),this.index=new qh({location:this.config.indexLocation,createLevelDatabase:this.config.createLevelDatabase})}open(){return uv(this,void 0,void 0,function*(){yield this.blockstore.open(),yield this.index.open()})}close(){return uv(this,void 0,void 0,function*(){yield this.blockstore.close(),yield this.index.close()})}get(e,r,n){var i;return uv(this,void 0,void 0,function*(){(i=n?.signal)===null||i===void 0||i.throwIfAborted();let o=yield Ui(this.blockstore.partition(e),n?.signal),s=$r.parse(r),a=yield o.get(s,n);return a?(yield Ui(f0e({bytes:a,codec:S0,hasher:gs}),n?.signal)).value:void 0})}query(e,r,n,i,o){var s;return uv(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.limit<d.length&&(d.splice(-1),u=qh.createCursorFromLastArrayItem(d,a.sortProperty));let c=[];for(let l=0;l<d.length;l++){let{messageCid:m}=d[l],p=yield this.get(e,m,o);p&&c.push(p)}return{messages:c,cursor:u}})}static buildQueryOptions(e={},r={}){let{limit:n,cursor:i}=r,{dateCreated:o,datePublished:s,messageTimestamp:a}=e,d=ds.Ascending,u="messageTimestamp";return o!==void 0?u="dateCreated":s!==void 0?u="datePublished":a!==void 0&&(u="messageTimestamp"),e[u]!==void 0&&(d=e[u]),n!==void 0&&n>0&&(n=n+1),{sortDirection:d,sortProperty:u,limit:n,cursor:i}}delete(e,r,n){var i;return uv(this,void 0,void 0,function*(){(i=n?.signal)===null||i===void 0||i.throwIfAborted();let o=yield Ui(this.blockstore.partition(e),n?.signal),s=$r.parse(r);yield o.delete(s,n),yield this.index.delete(e,r,n)})}put(e,r,n,i){var o;return uv(this,void 0,void 0,function*(){(o=i?.signal)===null||o===void 0||o.throwIfAborted();let s=yield Ui(this.blockstore.partition(e),i?.signal),a=yield Ui(l0e({value:r,codec:S0,hasher:gs}),i?.signal),d=An.parseCid(yield ve.getCid(r));yield s.put(d,a.bytes,i);let u=d.toString();yield this.index.put(e,u,n,i)})}clear(){return uv(this,void 0,void 0,function*(){yield this.blockstore.clear(),yield this.index.clear()})}};h();var tYe=qt(Ja(),1);h();var Lr;(function(t){t.EventsGet="EventsGet",t.EventsQuery="EventsQuery",t.EventsSubscribe="EventsSubscribe",t.MessagesGet="MessagesGet",t.ProtocolsConfigure="ProtocolsConfigure",t.ProtocolsQuery="ProtocolsQuery",t.RecordsDelete="RecordsDelete",t.RecordsQuery="RecordsQuery",t.RecordsRead="RecordsRead",t.RecordsSubscribe="RecordsSubscribe",t.RecordsWrite="RecordsWrite"})(Lr||(Lr={}));var c3={[Lr.EventsGet]:qm,[Lr.EventsQuery]:Km,[Lr.EventsSubscribe]:Fm,[Lr.MessagesGet]:zm,[Lr.ProtocolsConfigure]:Qm,[Lr.ProtocolsQuery]:ey,[Lr.RecordsDelete]:ty,[Lr.RecordsQuery]:Um,[Lr.RecordsRead]:Xg,[Lr.RecordsSubscribe]:ry,[Lr.RecordsWrite]:Vr};h();var nYe=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},lv=class{constructor({did:e,metadata:r}){this.did=e,this.metadata=r}export(){return nYe(this,void 0,void 0,function*(){return{portableDid:yield this.did.export(),metadata:this.metadata}})}};h();h();h();var iYe=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},LP=class{static deriveKeyBytes({baseKeyBytes:e,length:r,hash:n,salt:i,info:o=new Uint8Array}){return iYe(this,void 0,void 0,function*(){let a=yield Gs().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=yield crypto.subtle.deriveBits({name:"HKDF",hash:n,salt:i,info:o},a,r);return new Uint8Array(d)})}};var oYe=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},sYe=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.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]]);return r},KP=class extends Wn{deriveKeyBytes(e){var{algorithm:r}=e,n=sYe(e,["algorithm"]);return oYe(this,void 0,void 0,function*(){let i={"HKDF-256":"SHA-256","HKDF-384":"SHA-384","HKDF-512":"SHA-512"}[r];return yield LP.deriveKeyBytes(Object.assign(Object.assign({},n),{hash:i}))})}};h();h();var ot=class t extends Error{constructor(e,r){super(r),this.code=e,this.name="CryptoError",Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,t)}},rt;(function(t){t.AlgorithmNotSupported="algorithmNotSupported",t.EncodingError="encodingError",t.InvalidJwe="invalidJwe",t.InvalidJwk="invalidJwk",t.OperationNotSupported="operationNotSupported"})(rt||(rt={}));var Lh=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},d3=class extends Wn{bytesToPrivateKey({algorithm:e,privateKeyBytes:r}){return Lh(this,void 0,void 0,function*(){switch(e){case"ES256K":case"secp256k1":{let n=yield _r.bytesToPrivateKey({privateKeyBytes:r});return n.alg="EdDSA",n}case"ES256":case"secp256r1":{let n=yield Dr.bytesToPrivateKey({privateKeyBytes:r});return n.alg="EdDSA",n}default:throw new ot(rt.AlgorithmNotSupported,`Algorithm not supported: ${e}`)}})}bytesToPublicKey({algorithm:e,publicKeyBytes:r}){return Lh(this,void 0,void 0,function*(){switch(e){case"ES256K":case"secp256k1":{let n=yield _r.bytesToPublicKey({publicKeyBytes:r});return n.alg="EdDSA",n}case"ES256":case"secp256r1":{let n=yield Dr.bytesToPublicKey({publicKeyBytes:r});return n.alg="EdDSA",n}default:throw new ot(rt.AlgorithmNotSupported,`Algorithm not supported: ${e}`)}})}computePublicKey({key:e}){return Lh(this,void 0,void 0,function*(){if(!Sa(e))throw new TypeError("Invalid key provided. Must be an elliptic curve (EC) private key.");switch(e.crv){case"secp256k1":{let r=yield _r.computePublicKey({key:e});return r.alg="ES256K",r}case"P-256":{let r=yield Dr.computePublicKey({key:e});return r.alg="ES256",r}default:throw new Error(`Unsupported curve: ${e.crv}`)}})}generateKey({algorithm:e}){return Lh(this,void 0,void 0,function*(){switch(e){case"ES256K":case"secp256k1":{let r=yield _r.generateKey();return r.alg="ES256K",r}case"ES256":case"secp256r1":{let r=yield Dr.generateKey();return r.alg="ES256",r}}})}getPublicKey({key:e}){return Lh(this,void 0,void 0,function*(){if(!Sa(e))throw new TypeError("Invalid key provided. Must be an elliptic curve (EC) private key.");switch(e.crv){case"secp256k1":{let r=yield _r.getPublicKey({key:e});return r.alg="ES256K",r}case"P-256":{let r=yield Dr.getPublicKey({key:e});return r.alg="ES256",r}default:throw new Error(`Unsupported curve: ${e.crv}`)}})}privateKeyToBytes({privateKey:e}){return Lh(this,void 0,void 0,function*(){switch(e.crv){case"secp256k1":return yield _r.privateKeyToBytes({privateKey:e});case"P-256":return yield Dr.privateKeyToBytes({privateKey:e});default:throw new ot(rt.AlgorithmNotSupported,`Curve not supported: ${e.crv}`)}})}publicKeyToBytes({publicKey:e}){return Lh(this,void 0,void 0,function*(){switch(e.crv){case"secp256k1":return yield _r.publicKeyToBytes({publicKey:e});case"P-256":return yield Dr.publicKeyToBytes({publicKey:e});default:throw new ot(rt.AlgorithmNotSupported,`Curve not supported: ${e.crv}`)}})}sign({key:e,data:r}){return Lh(this,void 0,void 0,function*(){if(!Sa(e))throw new TypeError("Invalid key provided. Must be an elliptic curve (EC) private key.");switch(e.crv){case"secp256k1":return yield _r.sign({key:e,data:r});case"P-256":return yield Dr.sign({key:e,data:r});default:throw new Error(`Unsupported curve: ${e.crv}`)}})}verify({key:e,signature:r,data:n}){return Lh(this,void 0,void 0,function*(){if(!vp(e))throw new TypeError("Invalid key provided. Must be an elliptic curve (EC) public key.");switch(e.crv){case"secp256k1":return yield _r.verify({key:e,signature:r,data:n});case"P-256":return yield Dr.verify({key:e,signature:r,data:n});default:throw new Error(`Unsupported curve: ${e.crv}`)}})}};h();var Kh=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},FP=class extends Wn{bytesToPrivateKey({algorithm:e,privateKeyBytes:r}){return Kh(this,void 0,void 0,function*(){switch(e){case"Ed25519":{let n=yield Yt.bytesToPrivateKey({privateKeyBytes:r});return n.alg="EdDSA",n}default:throw new ot(rt.AlgorithmNotSupported,`Algorithm not supported: ${e}`)}})}bytesToPublicKey({algorithm:e,publicKeyBytes:r}){return Kh(this,void 0,void 0,function*(){switch(e){case"Ed25519":{let n=yield Yt.bytesToPublicKey({publicKeyBytes:r});return n.alg="EdDSA",n}default:throw new ot(rt.AlgorithmNotSupported,`Algorithm not supported: ${e}`)}})}computePublicKey({key:e}){return Kh(this,void 0,void 0,function*(){if(!Aa(e))throw new TypeError("Invalid key provided. Must be an octet key pair (OKP) private key.");switch(e.crv){case"Ed25519":{let r=yield Yt.computePublicKey({key:e});return r.alg="EdDSA",r}default:throw new ot(rt.AlgorithmNotSupported,`Curve not supported: ${e.crv}`)}})}generateKey({algorithm:e}){return Kh(this,void 0,void 0,function*(){switch(e){case"Ed25519":{let r=yield Yt.generateKey();return r.alg="EdDSA",r}}})}getPublicKey({key:e}){return Kh(this,void 0,void 0,function*(){if(!Aa(e))throw new TypeError("Invalid key provided. Must be an octet key pair (OKP) private key.");switch(e.crv){case"Ed25519":{let r=yield Yt.getPublicKey({key:e});return r.alg="EdDSA",r}default:throw new Error(`Unsupported curve: ${e.crv}`)}})}privateKeyToBytes({privateKey:e}){return Kh(this,void 0,void 0,function*(){switch(e.crv){case"Ed25519":return yield Yt.privateKeyToBytes({privateKey:e});default:throw new ot(rt.AlgorithmNotSupported,`Curve not supported: ${e.crv}`)}})}publicKeyToBytes({publicKey:e}){return Kh(this,void 0,void 0,function*(){switch(e.crv){case"Ed25519":return yield Yt.publicKeyToBytes({publicKey:e});default:throw new ot(rt.AlgorithmNotSupported,`Curve not supported: ${e.crv}`)}})}sign({key:e,data:r}){return Kh(this,void 0,void 0,function*(){if(!Aa(e))throw new TypeError("Invalid key provided. Must be an octet key pair (OKP) private key.");switch(e.crv){case"Ed25519":return yield Yt.sign({key:e,data:r});default:throw new ot(rt.AlgorithmNotSupported,`Curve not supported: ${e.crv}`)}})}verify({key:e,signature:r,data:n}){return Kh(this,void 0,void 0,function*(){if(!bp(e))throw new TypeError("Invalid key provided. Must be an octet key pair (OKP) public key.");switch(e.crv){case"Ed25519":return yield Yt.verify({key:e,signature:r,data:n});default:throw new ot(rt.AlgorithmNotSupported,`Curve not supported: ${e.crv}`)}})}};h();h();var u3=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},h0e=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.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]]);return r},p0e=[128,192,256],uy=class{static bytesToPrivateKey({privateKeyBytes:e}){return u3(this,void 0,void 0,function*(){let r={k:de.uint8Array(e).toBase64Url(),kty:"oct"};r.kid=yield nt({jwk:r});let n=e.length*8;return r.alg={128:"A128KW",192:"A192KW",256:"A256KW"}[n],r})}static generateKey({length:e}){return u3(this,void 0,void 0,function*(){if(!p0e.includes(e))throw new RangeError(`The key length is invalid: Must be ${p0e.join(", ")} bits`);let r=Gs(),n=yield r.generateKey({name:"AES-KW",length:e},!0,["wrapKey","unwrapKey"]),i=yield r.exportKey("jwk",n),{ext:o,key_ops:s}=i,a=h0e(i,["ext","key_ops"]);return a.kid=yield nt({jwk:a}),a})}static privateKeyToBytes({privateKey:e}){return u3(this,void 0,void 0,function*(){if(!n0(e))throw new Error("AesKw: The provided key is not a valid oct private key.");return de.base64Url(e.k).toUint8Array()})}static unwrapKey({wrappedKeyBytes:e,wrappedKeyAlgorithm:r,decryptionKey:n}){return u3(this,void 0,void 0,function*(){if(!("alg"in n&&n.alg))throw new ot(rt.InvalidJwk,"The decryption key is missing the 'alg' property.");if(!["A128KW","A192KW","A256KW"].includes(n.alg))throw new ot(rt.AlgorithmNotSupported,`The 'decryptionKey' algorithm is not supported: ${n.alg}`);let i=Gs(),o=yield 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 ot(rt.AlgorithmNotSupported,`The 'wrappedKeyAlgorithm' is not supported: ${r}`);let a=yield i.unwrapKey("raw",e.buffer,o,"AES-KW",{name:s},!0,["unwrapKey"]),d=yield i.exportKey("jwk",a),{ext:u,key_ops:c}=d,m=h0e(d,["ext","key_ops"]);return m.kid=yield nt({jwk:m}),m})}static wrapKey({unwrappedKey:e,encryptionKey:r}){return u3(this,void 0,void 0,function*(){if(!("alg"in r&&r.alg))throw new ot(rt.InvalidJwk,"The encryption key is missing the 'alg' property.");if(!["A128KW","A192KW","A256KW"].includes(r.alg))throw new ot(rt.AlgorithmNotSupported,`The 'encryptionKey' algorithm is not supported: ${r.alg}`);if(!("alg"in e&&e.alg))throw new ot(rt.InvalidJwk,"The private key to wrap is missing the 'alg' property.");let n=Gs(),i=yield 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 ot(rt.AlgorithmNotSupported,`The 'unwrappedKey' algorithm is not supported: ${e.alg}`);let s=yield n.importKey("jwk",e,{name:o},!0,["unwrapKey"]),a=yield n.wrapKey("raw",s,i,"AES-KW");return new Uint8Array(a)})}};var l3=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},X1=class extends Wn{bytesToPrivateKey({privateKeyBytes:e}){return l3(this,void 0,void 0,function*(){let r=yield uy.bytesToPrivateKey({privateKeyBytes:e});return r.alg={16:"A128KW",24:"A192KW",32:"A256KW"}[e.length],r})}generateKey({algorithm:e}){return l3(this,void 0,void 0,function*(){let r={A128KW:128,A192KW:192,A256KW:256}[e],n=yield uy.generateKey({length:r});return n.alg=e,n})}privateKeyToBytes({privateKey:e}){return l3(this,void 0,void 0,function*(){return yield uy.privateKeyToBytes({privateKey:e})})}unwrapKey(e){return l3(this,void 0,void 0,function*(){return yield uy.unwrapKey(e)})}wrapKey(e){return l3(this,void 0,void 0,function*(){return uy.wrapKey(e)})}};h();h();var aYe=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(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=class{static deriveKeyBytes({baseKeyBytes:e,hash:r,salt:n,iterations:i,length:o}){return aYe(this,void 0,void 0,function*(){let s=Gs(),a=yield s.importKey("raw",e,{name:"PBKDF2"},!1,["deriveBits"]),d=yield s.deriveBits({name:"PBKDF2",hash:r,salt:n,iterations:i},a,o);return new Uint8Array(d)})}};var cYe=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},dYe=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.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]]);return r},VP=class extends Wn{deriveKeyBytes(e){var{algorithm:r}=e,n=dYe(e,["algorithm"]);return cYe(this,void 0,void 0,function*(){let[,i]=r.split(/[-+]/),o={HS256:"SHA-256",HS384:"SHA-384",HS512:"SHA-512"}[i];return yield zP.deriveKeyBytes(Object.assign(Object.assign({},n),{hash:o}))})}};h();var f3=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},HP=class extends Wn{bytesToPrivateKey({privateKeyBytes:e}){return f3(this,void 0,void 0,function*(){let r=yield Jc.bytesToPrivateKey({privateKeyBytes:e});return r.alg={16:"A128GCM",24:"A192GCM",32:"A256GCM"}[e.length],r})}decrypt(e){return f3(this,void 0,void 0,function*(){return Jc.decrypt(e)})}encrypt(e){return f3(this,void 0,void 0,function*(){return Jc.encrypt(e)})}generateKey({algorithm:e}){return f3(this,void 0,void 0,function*(){let r={A128GCM:128,A192GCM:192,A256GCM:256}[e],n=yield Jc.generateKey({length:r});return n.alg=e,n})}privateKeyToBytes({privateKey:e}){return f3(this,void 0,void 0,function*(){return yield Jc.privateKeyToBytes({privateKey:e})})}};var Us=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},hL={"AES-GCM":{implementation:HP,names:["A128GCM","A192GCM","A256GCM"],operations:["bytesToPrivateKey","decrypt","encrypt","generateKey"]},"AES-KW":{implementation:X1,names:["A128KW","A192KW","A256KW"],operations:["bytesToPrivateKey","generateKey","privateKeyToBytes","wrapKey","unwrapKey"]},Ed25519:{implementation:FP,names:["Ed25519"],operations:["bytesToPrivateKey","bytesToPublicKey","generateKey","sign","verify"]},HKDF:{implementation:KP,names:["HKDF-256","HKDF-384","HKDF-512"],operations:["deriveKey","deriveKeyBytes"]},PBKDF2:{implementation:VP,names:["PBES2-HS256+A128KW","PBES2-HS384+A192KW","PBES2-HS512+A256KW"],operations:["deriveKey","deriveKeyBytes"]},secp256k1:{implementation:d3,names:["ES256K","secp256k1"],operations:["bytesToPrivateKey","bytesToPublicKey","generateKey","sign","verify"]},secp256r1:{implementation:d3,names:["ES256","secp256r1"],operations:["bytesToPrivateKey","bytesToPublicKey","generateKey","sign","verify"]},"SHA-256":{implementation:yp,names:["SHA-256"],operations:["digest"]}},Cc=class{constructor(){this._algorithmInstances=new Map}bytesToPrivateKey({algorithm:e,privateKeyBytes:r}){return Us(this,void 0,void 0,function*(){let n=this.getAlgorithmName({algorithm:e});return yield this.getAlgorithm({algorithm:n}).bytesToPrivateKey({algorithm:e,privateKeyBytes:r})})}bytesToPublicKey({algorithm:e,publicKeyBytes:r}){return Us(this,void 0,void 0,function*(){let n=this.getAlgorithmName({algorithm:e});return yield this.getAlgorithm({algorithm:n}).bytesToPublicKey({algorithm:e,publicKeyBytes:r})})}decrypt(e){return Us(this,void 0,void 0,function*(){let r=this.getAlgorithmName({key:e.key});return yield this.getAlgorithm({algorithm:r}).decrypt(e)})}deriveKey(e){var r,n;return Us(this,void 0,void 0,function*(){let i=this.getAlgorithmName({algorithm:e.algorithm}),o=this.getAlgorithm({algorithm:i}),s;switch(e.algorithm){case"HKDF-256":case"HKDF-384":case"HKDF-512":{s=e.derivedKeyAlgorithm;break}case"PBES2-HS256+A128KW":case"PBES2-HS384+A192KW":case"PBES2-HS512+A256KW":{s=e.algorithm.split(/[-+]/)[2];break}default:throw new ot(rt.AlgorithmNotSupported,`The specified "algorithm" is not supported: ${e.algorithm}`)}let a=+((n=(r=s.match(/\d+/))===null||r===void 0?void 0:r[0])!==null&&n!==void 0?n:-1);if(a===-1)throw new ot(rt.AlgorithmNotSupported,`The derived key algorithm" is not supported: ${s}`);let d=yield o.deriveKeyBytes(Object.assign(Object.assign({},e),{length:a}));return yield this.bytesToPrivateKey({algorithm:s,privateKeyBytes:d})})}deriveKeyBytes(e){return Us(this,void 0,void 0,function*(){let r=this.getAlgorithmName({algorithm:e.algorithm});return yield this.getAlgorithm({algorithm:r}).deriveKeyBytes(e)})}digest({algorithm:e,data:r}){return Us(this,void 0,void 0,function*(){return yield this.getAlgorithm({algorithm:e}).digest({algorithm:e,data:r})})}encrypt(e){return Us(this,void 0,void 0,function*(){let r=this.getAlgorithmName({key:e.key});return yield this.getAlgorithm({algorithm:r}).encrypt(e)})}generateKey(e){var r;return Us(this,void 0,void 0,function*(){let n=this.getAlgorithmName({algorithm:e.algorithm}),o=yield this.getAlgorithm({algorithm:n}).generateKey({algorithm:e.algorithm});return(r=o.kid)!==null&&r!==void 0||(o.kid=yield nt({jwk:o})),o})}getKeyUri(e){return Us(this,void 0,void 0,function*(){throw new Error("Method not implemented.")})}getPublicKey({key:e}){return Us(this,void 0,void 0,function*(){let r=this.getAlgorithmName({key:e});return yield this.getAlgorithm({algorithm:r}).getPublicKey({key:e})})}privateKeyToBytes({privateKey:e}){return Us(this,void 0,void 0,function*(){let r=this.getAlgorithmName({key:e});return yield this.getAlgorithm({algorithm:r}).privateKeyToBytes({privateKey:e})})}publicKeyToBytes({publicKey:e}){return Us(this,void 0,void 0,function*(){let r=this.getAlgorithmName({key:e});return yield this.getAlgorithm({algorithm:r}).publicKeyToBytes({publicKey:e})})}sign({key:e,data:r}){return Us(this,void 0,void 0,function*(){let n=this.getAlgorithmName({key:e});return this.getAlgorithm({algorithm:n}).sign({data:r,key:e})})}unwrapKey(e){return Us(this,void 0,void 0,function*(){let r=this.getAlgorithmName({key:e.decryptionKey});return yield this.getAlgorithm({algorithm:r}).unwrapKey(e)})}verify({key:e,signature:r,data:n}){return Us(this,void 0,void 0,function*(){let i=this.getAlgorithmName({key:e});return this.getAlgorithm({algorithm:i}).verify({key:e,signature:r,data:n})})}wrapKey(e){return Us(this,void 0,void 0,function*(){let r=this.getAlgorithmName({key:e.encryptionKey});return yield this.getAlgorithm({algorithm:r}).wrapKey(e)})}getAlgorithm({algorithm:e}){var r;let n=(r=hL[e])===null||r===void 0?void 0:r.implementation;if(!n)throw new ot(rt.AlgorithmNotSupported,`Algorithm not supported: ${e}`);return this._algorithmInstances.has(n)||this._algorithmInstances.set(n,new n),this._algorithmInstances.get(n)}getAlgorithmName({algorithm:e,key:r}){var n;let i=(n=r?.alg)!==null&&n!==void 0?n:e,o=r?.crv;for(let s of Object.keys(hL)){let a=hL[s].names;if(i&&a.includes(i))return s;if(o&&a.includes(o))return s}throw new ot(rt.AlgorithmNotSupported,`Algorithm not supported based on provided input: alg=${i}, crv=${o}. Please check the documentation for the list of supported algorithms.`)}};h();h();h();var Q1=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},uYe=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.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]]);return r},ls="^",WP=class extends xr{constructor(){super(),this._predefinedKeys=new Map,this._keyGenerator=this._predefinedKeys.keys()}addPredefinedKeys({privateKeys:e}){var r;return Q1(this,void 0,void 0,function*(){let n={};for(let i of e){(r=i.kid)!==null&&r!==void 0||(i.kid=yield nt({jwk:i}));let o=yield this.getKeyUri({key:i});n[o]=i}this._predefinedKeys=new Map(Object.entries(n)),this._keyGenerator=this._predefinedKeys.keys()})}exportKey({keyUri:e}){return Q1(this,void 0,void 0,function*(){let r=this._predefinedKeys.get(e);if(!r)throw new Error(`DeterministicKeyGenerator.exportKey: Key not found: ${e}`);return r})}generateKey(e){return Q1(this,void 0,void 0,function*(){let{value:r,done:n}=this._keyGenerator.next();if(n)throw new Error("Ran out of predefined keys");return r})}getPublicKey({keyUri:e}){return Q1(this,void 0,void 0,function*(){let r=this._predefinedKeys.get(e);if(!r)throw new Error(`DeterministicKeyGenerator.getPublicKey: Key not found: ${e}`);let{d:n}=r;return uYe(r,["d"])})}sign({keyUri:e,data:r}){return Q1(this,void 0,void 0,function*(){let n=this._predefinedKeys.get(e);if(!n)throw new Error(`DeterministicKeyGenerator.sign: Key not found: ${e}`);return yield Yt.sign({data:r,key:n})})}};function Fh({agent:t,tenant:e,didUri:r}){return Q1(this,void 0,void 0,function*(){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 h3(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 pL=qt(h0(),1);var Lu=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},ly=class{constructor(){this.name="DwnDataStore",this._cache=new Zh.default({ttl:(0,pL.default)("15 minutes"),max:100}),this._index=new Zh.default({ttl:(0,pL.default)("2 hours"),max:1e3}),this._recordProperties={dataFormat:"application/json",schema:"https://identity.foundation/schemas/web5/private-jwk"}}delete({id:e,agent:r,tenant:n}){return Lu(this,void 0,void 0,function*(){let i=yield Fh({agent:r,tenant:n,didUri:e}),o=yield this.lookupRecordId({id:e,tenantDid:i,agent:r});if(!o)return!1;let{reply:{status:s}}=yield r.dwn.processRequest({author:i,target:i,messageType:Lr.RecordsDelete,messageParams:{recordId:o}});if(s.code===202)return this._index.delete(`${i}${ls}${e}`),this._cache.delete(o),!0;throw new Error(`${this.name}: Failed to delete '${e}' from store: (${s.code}) ${s.detail}`)})}get({id:e,agent:r,tenant:n,useCache:i=!1}){return Lu(this,void 0,void 0,function*(){let o=yield Fh({agent:r,tenant:n,didUri:e}),s=yield this.lookupRecordId({id:e,tenantDid:o,agent:r});if(s)return yield this.getRecord({recordId:s,tenantDid:o,agent:r,useCache:i})})}list({agent:e,tenant:r}){return Lu(this,void 0,void 0,function*(){let n=yield Fh({tenant:r,agent:e});return yield this.getAllRecords({agent:e,tenantDid:n})})}set({id:e,data:r,tenant:n,agent:i,preventDuplicates:o=!0,useCache:s=!1}){return Lu(this,void 0,void 0,function*(){let a=yield Fh({agent:i,tenant:n,didUri:e});if(o&&(yield 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}}=yield i.dwn.processRequest({author:a,target:a,messageType:Lr.RecordsWrite,messageParams:Object.assign({},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}${ls}${e}`,u.recordId),s&&this._cache.set(u.recordId,r)})}getAllRecords(e){return Lu(this,void 0,void 0,function*(){throw new Error("Not implemented: Classes extending DwnDataStore must implement getAllRecords()")})}getRecord({recordId:e,tenantDid:r,agent:n,useCache:i}){var o;return Lu(this,void 0,void 0,function*(){if(i){let d=this._cache.get(e);if(d)return d}let{reply:s}=yield n.dwn.processRequest({author:r,target:r,messageType:Lr.RecordsRead,messageParams:{filter:{recordId:e}}});if(!(!((o=s.record)===null||o===void 0)&&o.data))throw new Error(`${this.name}: Failed to read data from DWN for: ${e}`);let a=yield Af.consumeToJson({readable:s.record.data});return i&&this._cache.set(e,a),a})}lookupRecordId({id:e,tenantDid:r,agent:n}){return Lu(this,void 0,void 0,function*(){let i=this._index.get(`${r}${ls}${e}`,{updateAgeOnGet:!0});return i||(yield this.getAllRecords({agent:n,tenantDid:r}),i=this._index.get(`${r}${ls}${e}`)),i})}},fy=class{constructor(){this.name="InMemoryDataStore",this.store=new Map}delete({id:e,agent:r,tenant:n}){return Lu(this,void 0,void 0,function*(){let i=yield Fh({agent:r,tenant:n,didUri:e});return this.store.has(`${i}${ls}${e}`)?(this.store.delete(`${i}${ls}${e}`),!0):!1})}get({id:e,agent:r,tenant:n}){return Lu(this,void 0,void 0,function*(){let i=yield Fh({agent:r,tenant:n,didUri:e});return this.store.get(`${i}${ls}${e}`)})}list({agent:e,tenant:r}){return Lu(this,void 0,void 0,function*(){let n=yield Fh({tenant:r,agent:e}),i=[];for(let[o,s]of this.store.entries())o.startsWith(`${n}${ls}`)&&i.push(s);return i})}set({id:e,data:r,tenant:n,agent:i,preventDuplicates:o}){return Lu(this,void 0,void 0,function*(){let s=yield Fh({agent:i,tenant:n,didUri:e});if(o&&this.store.has(`${s}${ls}${e}`))throw new Error(`${this.name}: Import failed due to duplicate entry for: ${e}`);let a=structuredClone(r);this.store.set(`${s}${ls}${e}`,a)})}};var zh=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},p3=class extends ly{constructor(){super(...arguments),this.name="DwnDidStore",this._recordProperties={dataFormat:"application/json",schema:"https://identity.foundation/schemas/web5/portable-did"}}delete(e){let r=Object.create(null,{delete:{get:()=>super.delete}});return zh(this,void 0,void 0,function*(){return yield r.delete.call(this,e)})}get(e){let r=Object.create(null,{get:{get:()=>super.get}});return zh(this,void 0,void 0,function*(){return yield r.get.call(this,e)})}list(e){let r=Object.create(null,{list:{get:()=>super.list}});return zh(this,void 0,void 0,function*(){return yield r.list.call(this,e)})}set(e){let r=Object.create(null,{set:{get:()=>super.set}});return zh(this,void 0,void 0,function*(){return yield r.set.call(this,e)})}getAllRecords({agent:e,tenantDid:r}){var n;return zh(this,void 0,void 0,function*(){this._index.clear();let{reply:i}=yield e.dwn.processRequest({author:r,target:r,messageType:Lr.RecordsQuery,messageParams:{filter:Object.assign({},this._recordProperties)}}),o=[];for(let s of(n=i.entries)!==null&&n!==void 0?n:[]){if(!s.encodedData)throw new Error(`${this.name}: Expected 'encodedData' to be present in the DWN query result entry`);let a=de.base64Url(s.encodedData).toObject();if(h3(a)){let d=`${r}${ls}${a.uri}`;this._index.set(d,s.recordId),this._cache.set(s.recordId,a),o.push(a)}}return o})}},m3=class extends fy{constructor(){super(...arguments),this.name="InMemoryDidStore"}delete(e){let r=Object.create(null,{delete:{get:()=>super.delete}});return zh(this,void 0,void 0,function*(){return yield r.delete.call(this,e)})}get(e){let r=Object.create(null,{get:{get:()=>super.get}});return zh(this,void 0,void 0,function*(){return yield r.get.call(this,e)})}list(e){let r=Object.create(null,{list:{get:()=>super.list}});return zh(this,void 0,void 0,function*(){return yield r.list.call(this,e)})}set(e){let r=Object.create(null,{set:{get:()=>super.set}});return zh(this,void 0,void 0,function*(){return yield r.set.call(this,e)})}};h();var m0e=qt(h0(),1);var y3=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},g3=class{constructor({ttl:e="15m"}={}){this.cache=new Zh.default({ttl:(0,m0e.default)(e)})}get(e){return y3(this,void 0,void 0,function*(){if(!e)throw new Error("Key cannot be null or undefined");return this.cache.get(e)})}set(e,r){return y3(this,void 0,void 0,function*(){this.cache.set(e,r)})}delete(e){return y3(this,void 0,void 0,function*(){this.cache.delete(e)})}clear(){return y3(this,void 0,void 0,function*(){this.cache.clear()})}close(){return y3(this,void 0,void 0,function*(){})}};var e2=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},GP;(function(t){t.Create="Create",t.Resolve="Resolve"})(GP||(GP={}));function y0e(t,e){return t.messageType===e}var v3=class extends Sb{constructor({agent:e,didMethods:r,resolverCache:n,store:i}){if(!r)throw new TypeError("AgentDidApi: Required parameter missing: 'didMethods'");super({didResolvers:r,cache:n??new g3}),this._didMethods=new Map,this._agent=e,this._store=i??new m3;for(let o of r)this._didMethods.set(o.methodName,o)}get agent(){if(this._agent===void 0)throw new Error("AgentDidApi: Unable to determine agent execution context.");return this._agent}set agent(e){this._agent=e}create({method:e,tenant:r,options:n,store:i}){return e2(this,void 0,void 0,function*(){let s=yield this.getMethod(e).create({keyManager:this.agent.keyManager,options:n});if(i??!0){let{uri:a,document:d,metadata:u}=s,c={uri:a,document:d,metadata:u};yield this._store.set({id:c.uri,data:c,agent:this.agent,tenant:r??c.uri,preventDuplicates:!1,useCache:!0})}return s})}export({didUri:e,tenant:r}){return e2(this,void 0,void 0,function*(){let n=yield this.get({didUri:e,tenant:r});if(!n)throw new Error(`AgentDidApi: Failed to export due to DID not found: ${e}`);return yield n.export()})}get({didUri:e,tenant:r}){return e2(this,void 0,void 0,function*(){let n=yield this._store.get({id:e,agent:this.agent,tenant:r,useCache:!0});return n?yield Ki.import({portableDid:n,keyManager:this.agent.keyManager}):void 0})}getSigningMethod({didUri:e,methodId:r}){return e2(this,void 0,void 0,function*(){let n=rr.parse(e);if(!n)throw new Error(`Invalid DID URI: ${e}`);let i=this.getMethod(n.method),{didDocument:o,didResolutionMetadata:s}=yield this.resolve(e);if(!o)throw new Error(`DID resolution failed for '${e}': ${JSON.stringify(s)}`);return yield i.getSigningMethod({didDocument:o,methodId:r})})}import({portableDid:e,tenant:r}){return e2(this,void 0,void 0,function*(){let n=yield Ki.import({keyManager:this.agent.keyManager,portableDid:e}),{uri:i,document:o,metadata:s}=n,a={uri:i,document:o,metadata:s};return yield this._store.set({id:a.uri,data:a,agent:this.agent,tenant:r??a.uri,preventDuplicates:!0,useCache:!0}),n})}processRequest(e){var r;return e2(this,void 0,void 0,function*(){if(y0e(e,GP.Create))try{let n=yield this.create(Object.assign({},e.messageParams));return{result:{uri:n.uri,document:n.document,metadata:n.metadata},ok:!0,status:{code:201,message:"Created"}}}catch(n){return{ok:!1,status:{code:500,message:(r=n.message)!==null&&r!==void 0?r:"Unknown error occurred"}}}if(y0e(e,GP.Resolve)){let{didUri:n,options:i}=e.messageParams;return{result:yield this.resolve(n,i),ok:!0,status:{code:200,message:"OK"}}}throw new Error(`AgentDidApi: Unsupported request type: ${e.messageType}`)})}getMethod(e){let r=this._didMethods.get(e);if(r===void 0)throw new Error(`DID Method not supported: ${e}`);return r}};h();h();var v0e=qt(g0e(),1);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())})};function yL(t){return ZP(t.stream())}function YP(t,e){return fYe(this,void 0,void 0,function*(){let r=yield e.dereference(`${t}#dwn`);if(r.dereferencingMetadata.error)throw new Error(`Failed to dereference '${t}#dwn': ${r.dereferencingMetadata.error}`);if(p5.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 t2(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===Oe.Records&&"method"in t.message.descriptor&&t.message.descriptor.method===Se.Write}function ZP(t){return new v0e.ReadableWebToNodeStream(t)}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())})};function hYe(t,e){return t.messageType===e}var r2=class{constructor({agent:e,dwn:r}){this._agent=e,this._dwn=r}get agent(){if(this._agent===void 0)throw new Error("AgentDwnApi: Unable to determine agent execution context.");return this._agent}set agent(e){this._agent=e}get node(){return this._dwn}static createDwn({dataPath:e,dataStore:r,didResolver:n,eventLog:i,eventStream:o,messageStore:s,tenantGate:a}){return Ku(this,void 0,void 0,function*(){return r??(r=new W1({blockstoreLocation:`${e}/DWN_DATASTORE`})),n??(n=new Sb({didResolvers:[Qc,Cp],cache:new p0({location:`${e}/DID_RESOLVERCACHE`})})),i??(i=new Y1({location:`${e}/DWN_EVENTLOG`})),s??(s=new Z1({blockstoreLocation:`${e}/DWN_MESSAGESTORE`,indexLocation:`${e}/DWN_MESSAGEINDEX`})),yield z6.create({dataStore:r,didResolver:n,eventLog:i,eventStream:o,messageStore:s,tenantGate:a})})}processRequest(e){return Ku(this,void 0,void 0,function*(){let{message:r,dataStream:n}=yield this.constructDwnMessage({request:e}),{subscriptionHandler:i}=e;return{reply:e.store!==!1?yield this._dwn.processMessage(e.target,r,{dataStream:n,subscriptionHandler:i}):{status:{code:202,detail:"Accepted"}},message:r,messageCid:yield ve.getCid(r)}})}sendRequest(e){return Ku(this,void 0,void 0,function*(){let r=yield YP(e.target,this.agent.did);if(r.length===0)throw new Error(`AgentDwnApi: DID Service is missing or malformed: ${e.target}#dwn`);let n,i,o,s;if("messageCid"in e)({message:i,data:o}=yield this.getDwnMessage({author:e.author,messageCid:e.messageCid,messageType:e.messageType})),n=e.messageCid;else{if({message:i}=yield this.constructDwnMessage({request:e}),e.dataStream&&!(e.dataStream instanceof Blob))throw new Error("AgentDwnApi: DataStream must be provided as a Blob");o=e.dataStream,s=e.subscriptionHandler}let a=yield this.sendDwnRpcRequest({targetDid:e.target,dwnEndpointUrls:r,message:i,data:o,subscriptionHandler:s});return n??(n=yield ve.getCid(i)),{reply:a,message:i,messageCid:n}})}sendDwnRpcRequest({targetDid:e,dwnEndpointUrls:r,message:n,data:i,subscriptionHandler:o}){return Ku(this,void 0,void 0,function*(){let s=[];if(n.descriptor.method===Se.Subscribe&&o===void 0)throw new Error("AgentDwnApi: Subscription handler is required for subscription requests.");for(let a of r)try{if(o!==void 0){if(!(yield this.agent.rpc.getServerInfo(a)).webSocketSupport){s.push({url:a,message:"WebSocket support is not enabled on the server."});continue}let c=new URL(a);c.protocol=c.protocol==="http:"?"ws:":"wss:",a=c.toString()}return yield this.agent.rpc.sendDwnRequest({dwnUrl:a,targetDid:e,message:n,data:i,subscriptionHandler:o})}catch(d){s.push({url:a,message:d instanceof Error?d.message:"Unknown error"})}throw new Error(`Failed to send DWN RPC request: ${JSON.stringify(s)}`)})}constructDwnMessage({request:e}){var r;return Ku(this,void 0,void 0,function*(){let n=e.rawMessage,i;if(hYe(e,Lr.RecordsWrite)){let d=e.messageParams;if(e.dataStream&&!d?.data){let{dataStream:u}=e,c;if(u instanceof Blob)c=yL(u),i=yL(u);else if(u instanceof ReadableStream){let[l,m]=u.tee();c=ZP(l),i=ZP(m)}n||(d.dataCid=yield An.computeDagPbCidFromStream(c),(r=d.dataSize)!==null&&r!==void 0||(d.dataSize=c.bytesRead))}}let o=yield this.getSigner(e.author),s=c3[e.messageType],a=n?yield s.parse(n):yield s.create(Object.assign(Object.assign({},e.messageParams),{signer:o}));return t2(a)&&e.signAsOwner&&(yield a.signAsOwner(o)),{message:a.message,dataStream:i}})}getSigner(e){return Ku(this,void 0,void 0,function*(){if(e===this.agent.agentDid.uri){let r=yield this.agent.agentDid.getSigner();return{algorithm:r.algorithm,keyId:r.keyId,sign:n=>Ku(this,void 0,void 0,function*(){return yield r.sign({data:n})})}}else try{let r=yield this.agent.did.getSigningMethod({didUri:e});if(!r.publicKeyJwk)throw new Error(`Verification method '${r.id}' does not contain a public key in JWK format`);let n=yield this.agent.keyManager.getKeyUri({key:r.publicKeyJwk}),i=yield this.agent.keyManager.getPublicKey({keyUri:n}),o=this.agent.keyManager;return{algorithm:Ei.getJoseSignatureAlgorithmFromPublicKey(i),keyId:r.id,sign:s=>Ku(this,void 0,void 0,function*(){return yield o.sign({data:s,keyUri:n})})}}catch(r){throw new Error(`AgentDwnApi: Unable to get signer for author '${e}': ${r.message}`)}})}getDwnMessage({author:e,messageCid:r}){return Ku(this,void 0,void 0,function*(){let n=yield this.getSigner(e),i=yield c3[Lr.MessagesGet].create({messageCids:[r],signer:n}),o=yield 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(t2(s))if(s.encodedData){let u=de.base64Url(s.encodedData).toUint8Array();d.data=new Blob([u])}else{let u=yield c3[Lr.RecordsRead].create({filter:{recordId:s.message.recordId},signer:n}),c=yield 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=yield Af.consumeToBytes({readable:c.record.data});d.data=new Blob([l])}}return d})}createMessage({author:e,messageParams:r,messageType:n}){return Ku(this,void 0,void 0,function*(){let i=yield this.getSigner(e);return yield c3[n].create(Object.assign(Object.assign({},r),{signer:i}))})}processMessage({dataStream:e,message:r,targetDid:n}){return Ku(this,void 0,void 0,function*(){return yield this._dwn.processMessage(n,r,{dataStream:e})})}};h();h();h();var pYe=new Uint8Array([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),w0e=Uint8Array.from({length:16},(t,e)=>e),mYe=w0e.map(t=>(9*t+5)%16),vL=[w0e],bL=[mYe];for(let t=0;t<4;t++)for(let e of[vL,bL])e.push(e[t].map(r=>pYe[r]));var _0e=[[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)),yYe=vL.map((t,e)=>t.map(r=>_0e[e][r])),gYe=bL.map((t,e)=>t.map(r=>_0e[e][r])),vYe=new Uint32Array([0,1518500249,1859775393,2400959708,2840853838]),bYe=new Uint32Array([1352829926,1548603684,1836072691,2053994217,0]),XP=(t,e)=>t<<e|t>>>32-e;function b0e(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 QP=new Uint32Array(16),gL=class extends hp{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)QP[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,v=vYe[p],E=bYe[p],A=vL[p],P=bL[p],I=yYe[p],$=gYe[p];for(let N=0;N<16;N++){let K=XP(n+b0e(p,o,a,u)+QP[A[N]]+v,I[N])+l|0;n=l,l=u,u=XP(a,10)|0,a=o,o=K}for(let N=0;N<16;N++){let K=XP(i+b0e(g,s,d,c)+QP[P[N]]+E,$[N])+m|0;i=m,m=c,c=XP(d,10)|0,d=s,s=K}}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(){QP.fill(0)}destroy(){this.destroyed=!0,this.buffer.fill(0),this.set(0,0,0,0,0)}},x0e=Yv(()=>new gL);var wYe=X2("ed25519 seed"),wL=2147483648,E0e=new Uint8Array([0]);function S0e(t,...e){return typeof t=="string"&&(t=TH(t)),Tf(t,...e),t}var _Ye=t=>x0e(ps(t)),xYe=t=>Pf(t).getUint32(0,!1),_L=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 Pf(e).setUint32(0,t,!1),e},ek=class t{get publicKeyRaw(){return Wc.getPublicKey(this.privateKey)}get publicKey(){return Xy(E0e,this.publicKeyRaw)}get pubHash(){return _Ye(this.publicKey)}get fingerprint(){return xYe(this.pubHash)}get fingerprintHex(){return G7(_L(this.fingerprint))}get parentFingerprintHex(){return G7(_L(this.parentFingerprint))}static fromMasterSeed(e){if(e=S0e(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=gp(Ep,wYe,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(Tf(e.privateKey,32),Tf(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>=wL)throw new Error("Invalid index");(r||s[2]==="'")&&(a+=wL),i=i.deriveChild(a)}return i}deriveChild(e){if(e<wL)throw new Error(`Non-hardened child derivation not possible for Ed25519 (index=${e})`);let r=Xy(E0e,this.privateKey,_L(e)),n=gp(Ep,this.chainCode,r);return new t({chainCode:n.slice(32),depth:this.depth+1,parentFingerprint:this.fingerprint,index:e,privateKey:n.slice(0,32)})}sign(e){return Wc.sign(e,this.privateKey)}verify(e,r){return r=S0e(r,64),Wc.verify(r,e,this.publicKeyRaw)}};h();var xL=`abandon
ability
able
about
above
absent
absorb
abstract
absurd
abuse
access
accident
account
accuse
achieve
acid
acoustic
acquire
across
act
action
actor
actress
actual
adapt
add
addict
address
adjust
admit
adult
advance
advice
aerobic
affair
afford
afraid
again
age
agent
agree
ahead
aim
air
airport
aisle
alarm
album
alcohol
alert
alien
all
alley
allow
almost
alone
alpha
already
also
alter
always
amateur
amazing
among
amount
amused
analyst
anchor
ancient
anger
angle
angry
animal
ankle
announce
annual
another
answer
antenna
antique
anxiety
any
apart
apology
appear
apple
approve
april
arch
arctic
area
arena
argue
arm
armed
armor
army
around
arrange
arrest
arrive
arrow
art
artefact
artist
artwork
ask
aspect
assault
asset
assist
assume
asthma
athlete
atom
attack
attend
attitude
attract
auction
audit
august
aunt
author
auto
autumn
average
avocado
avoid
awake
aware
away
awesome
awful
awkward
axis
baby
bachelor
bacon
badge
bag
balance
balcony
ball
bamboo
banana
banner
bar
barely
bargain
barrel
base
basic
basket
battle
beach
bean
beauty
because
become
beef
before
begin
behave
behind
believe
below
belt
bench
benefit
best
betray
better
between
beyond
bicycle
bid
bike
bind
biology
bird
birth
bitter
black
blade
blame
blanket
blast
bleak
bless
blind
blood
blossom
blouse
blue
blur
blush
board
boat
body
boil
bomb
bone
bonus
book
boost
border
boring
borrow
boss
bottom
bounce
box
boy
bracket
brain
brand
brass
brave
bread
breeze
brick
bridge
brief
bright
bring
brisk
broccoli
broken
bronze
broom
brother
brown
brush
bubble
buddy
budget
buffalo
build
bulb
bulk
bullet
bundle
bunker
burden
burger
burst
bus
business
busy
butter
buyer
buzz
cabbage
cabin
cable
cactus
cage
cake
call
calm
camera
camp
can
canal
cancel
candy
cannon
canoe
canvas
canyon
capable
capital
captain
car
carbon
card
cargo
carpet
carry
cart
case
cash
casino
castle
casual
cat
catalog
catch
category
cattle
caught
cause
caution
cave
ceiling
celery
cement
census
century
cereal
certain
chair
chalk
champion
change
chaos
chapter
charge
chase
chat
cheap
check
cheese
chef
cherry
chest
chicken
chief
child
chimney
choice
choose
chronic
chuckle
chunk
churn
cigar
cinnamon
circle
citizen
city
civil
claim
clap
clarify
claw
clay
clean
clerk
clever
click
client
cliff
climb
clinic
clip
clock
clog
close
cloth
cloud
clown
club
clump
cluster
clutch
coach
coast
coconut
code
coffee
coil
coin
collect
color
column
combine
come
comfort
comic
common
company
concert
conduct
confirm
congress
connect
consider
control
convince
cook
cool
copper
copy
coral
core
corn
correct
cost
cotton
couch
country
couple
course
cousin
cover
coyote
crack
cradle
craft
cram
crane
crash
crater
crawl
crazy
cream
credit
creek
crew
cricket
crime
crisp
critic
crop
cross
crouch
crowd
crucial
cruel
cruise
crumble
crunch
crush
cry
crystal
cube
culture
cup
cupboard
curious
current
curtain
curve
cushion
custom
cute
cycle
dad
damage
damp
dance
danger
daring
dash
daughter
dawn
day
deal
debate
debris
decade
december
decide
decline
decorate
decrease
deer
defense
define
defy
degree
delay
deliver
demand
demise
denial
dentist
deny
depart
depend
deposit
depth
deputy
derive
describe
desert
design
desk
despair
destroy
detail
detect
develop
device
devote
diagram
dial
diamond
diary
dice
diesel
diet
differ
digital
dignity
dilemma
dinner
dinosaur
direct
dirt
disagree
discover
disease
dish
dismiss
disorder
display
distance
divert
divide
divorce
dizzy
doctor
document
dog
doll
dolphin
domain
donate
donkey
donor
door
dose
double
dove
draft
dragon
drama
drastic
draw
dream
dress
drift
drill
drink
drip
drive
drop
drum
dry
duck
dumb
dune
during
dust
dutch
duty
dwarf
dynamic
eager
eagle
early
earn
earth
easily
east
easy
echo
ecology
economy
edge
edit
educate
effort
egg
eight
either
elbow
elder
electric
elegant
element
elephant
elevator
elite
else
embark
embody
embrace
emerge
emotion
employ
empower
empty
enable
enact
end
endless
endorse
enemy
energy
enforce
engage
engine
enhance
enjoy
enlist
enough
enrich
enroll
ensure
enter
entire
entry
envelope
episode
equal
equip
era
erase
erode
erosion
error
erupt
escape
essay
essence
estate
eternal
ethics
evidence
evil
evoke
evolve
exact
example
excess
exchange
excite
exclude
excuse
execute
exercise
exhaust
exhibit
exile
exist
exit
exotic
expand
expect
expire
explain
expose
express
extend
extra
eye
eyebrow
fabric
face
faculty
fade
faint
faith
fall
false
fame
family
famous
fan
fancy
fantasy
farm
fashion
fat
fatal
father
fatigue
fault
favorite
feature
february
federal
fee
feed
feel
female
fence
festival
fetch
fever
few
fiber
fiction
field
figure
file
film
filter
final
find
fine
finger
finish
fire
firm
first
fiscal
fish
fit
fitness
fix
flag
flame
flash
flat
flavor
flee
flight
flip
float
flock
floor
flower
fluid
flush
fly
foam
focus
fog
foil
fold
follow
food
foot
force
forest
forget
fork
fortune
forum
forward
fossil
foster
found
fox
fragile
frame
frequent
fresh
friend
fringe
frog
front
frost
frown
frozen
fruit
fuel
fun
funny
furnace
fury
future
gadget
gain
galaxy
gallery
game
gap
garage
garbage
garden
garlic
garment
gas
gasp
gate
gather
gauge
gaze
general
genius
genre
gentle
genuine
gesture
ghost
giant
gift
giggle
ginger
giraffe
girl
give
glad
glance
glare
glass
glide
glimpse
globe
gloom
glory
glove
glow
glue
goat
goddess
gold
good
goose
gorilla
gospel
gossip
govern
gown
grab
grace
grain
grant
grape
grass
gravity
great
green
grid
grief
grit
grocery
group
grow
grunt
guard
guess
guide
guilt
guitar
gun
gym
habit
hair
half
hammer
hamster
hand
happy
harbor
hard
harsh
harvest
hat
have
hawk
hazard
head
health
heart
heavy
hedgehog
height
hello
helmet
help
hen
hero
hidden
high
hill
hint
hip
hire
history
hobby
hockey
hold
hole
holiday
hollow
home
honey
hood
hope
horn
horror
horse
hospital
host
hotel
hour
hover
hub
huge
human
humble
humor
hundred
hungry
hunt
hurdle
hurry
hurt
husband
hybrid
ice
icon
idea
identify
idle
ignore
ill
illegal
illness
image
imitate
immense
immune
impact
impose
improve
impulse
inch
include
income
increase
index
indicate
indoor
industry
infant
inflict
inform
inhale
inherit
initial
inject
injury
inmate
inner
innocent
input
inquiry
insane
insect
inside
inspire
install
intact
interest
into
invest
invite
involve
iron
island
isolate
issue
item
ivory
jacket
jaguar
jar
jazz
jealous
jeans
jelly
jewel
job
join
joke
journey
joy
judge
juice
jump
jungle
junior
junk
just
kangaroo
keen
keep
ketchup
key
kick
kid
kidney
kind
kingdom
kiss
kit
kitchen
kite
kitten
kiwi
knee
knife
knock
know
lab
label
labor
ladder
lady
lake
lamp
language
laptop
large
later
latin
laugh
laundry
lava
law
lawn
lawsuit
layer
lazy
leader
leaf
learn
leave
lecture
left
leg
legal
legend
leisure
lemon
lend
length
lens
leopard
lesson
letter
level
liar
liberty
library
license
life
lift
light
like
limb
limit
link
lion
liquid
list
little
live
lizard
load
loan
lobster
local
lock
logic
lonely
long
loop
lottery
loud
lounge
love
loyal
lucky
luggage
lumber
lunar
lunch
luxury
lyrics
machine
mad
magic
magnet
maid
mail
main
major
make
mammal
man
manage
mandate
mango
mansion
manual
maple
marble
march
margin
marine
market
marriage
mask
mass
master
match
material
math
matrix
matter
maximum
maze
meadow
mean
measure
meat
mechanic
medal
media
melody
melt
member
memory
mention
menu
mercy
merge
merit
merry
mesh
message
metal
method
middle
midnight
milk
million
mimic
mind
minimum
minor
minute
miracle
mirror
misery
miss
mistake
mix
mixed
mixture
mobile
model
modify
mom
moment
monitor
monkey
monster
month
moon
moral
more
morning
mosquito
mother
motion
motor
mountain
mouse
move
movie
much
muffin
mule
multiply
muscle
museum
mushroom
music
must
mutual
myself
mystery
myth
naive
name
napkin
narrow
nasty
nation
nature
near
neck
need
negative
neglect
neither
nephew
nerve
nest
net
network
neutral
never
news
next
nice
night
noble
noise
nominee
noodle
normal
north
nose
notable
note
nothing
notice
novel
now
nuclear
number
nurse
nut
oak
obey
object
oblige
obscure
observe
obtain
obvious
occur
ocean
october
odor
off
offer
office
often
oil
okay
old
olive
olympic
omit
once
one
onion
online
only
open
opera
opinion
oppose
option
orange
orbit
orchard
order
ordinary
organ
orient
original
orphan
ostrich
other
outdoor
outer
output
outside
oval
oven
over
own
owner
oxygen
oyster
ozone
pact
paddle
page
pair
palace
palm
panda
panel
panic
panther
paper
parade
parent
park
parrot
party
pass
patch
path
patient
patrol
pattern
pause
pave
payment
peace
peanut
pear
peasant
pelican
pen
penalty
pencil
people
pepper
perfect
permit
person
pet
phone
photo
phrase
physical
piano
picnic
picture
piece
pig
pigeon
pill
pilot
pink
pioneer
pipe
pistol
pitch
pizza
place
planet
plastic
plate
play
please
pledge
pluck
plug
plunge
poem
poet
point
polar
pole
police
pond
pony
pool
popular
portion
position
possible
post
potato
pottery
poverty
powder
power
practice
praise
predict
prefer
prepare
present
pretty
prevent
price
pride
primary
print
priority
prison
private
prize
problem
process
produce
profit
program
project
promote
proof
property
prosper
protect
proud
provide
public
pudding
pull
pulp
pulse
pumpkin
punch
pupil
puppy
purchase
purity
purpose
purse
push
put
puzzle
pyramid
quality
quantum
quarter
question
quick
quit
quiz
quote
rabbit
raccoon
race
rack
radar
radio
rail
rain
raise
rally
ramp
ranch
random
range
rapid
rare
rate
rather
raven
raw
razor
ready
real
reason
rebel
rebuild
recall
receive
recipe
record
recycle
reduce
reflect
reform
refuse
region
regret
regular
reject
relax
release
relief
rely
remain
remember
remind
remove
render
renew
rent
reopen
repair
repeat
replace
report
require
rescue
resemble
resist
resource
response
result
retire
retreat
return
reunion
reveal
review
reward
rhythm
rib
ribbon
rice
rich
ride
ridge
rifle
right
rigid
ring
riot
ripple
risk
ritual
rival
river
road
roast
robot
robust
rocket
romance
roof
rookie
room
rose
rotate
rough
round
route
royal
rubber
rude
rug
rule
run
runway
rural
sad
saddle
sadness
safe
sail
salad
salmon
salon
salt
salute
same
sample
sand
satisfy
satoshi
sauce
sausage
save
say
scale
scan
scare
scatter
scene
scheme
school
science
scissors
scorpion
scout
scrap
screen
script
scrub
sea
search
season
seat
second
secret
section
security
seed
seek
segment
select
sell
seminar
senior
sense
sentence
series
service
session
settle
setup
seven
shadow
shaft
shallow
share
shed
shell
sheriff
shield
shift
shine
ship
shiver
shock
shoe
shoot
shop
short
shoulder
shove
shrimp
shrug
shuffle
shy
sibling
sick
side
siege
sight
sign
silent
silk
silly
silver
similar
simple
since
sing
siren
sister
situate
six
size
skate
sketch
ski
skill
skin
skirt
skull
slab
slam
sleep
slender
slice
slide
slight
slim
slogan
slot
slow
slush
small
smart
smile
smoke
smooth
snack
snake
snap
sniff
snow
soap
soccer
social
sock
soda
soft
solar
soldier
solid
solution
solve
someone
song
soon
sorry
sort
soul
sound
soup
source
south
space
spare
spatial
spawn
speak
special
speed
spell
spend
sphere
spice
spider
spike
spin
spirit
split
spoil
sponsor
spoon
sport
spot
spray
spread
spring
spy
square
squeeze
squirrel
stable
stadium
staff
stage
stairs
stamp
stand
start
state
stay
steak
steel
stem
step
stereo
stick
still
sting
stock
stomach
stone
stool
story
stove
strategy
street
strike
strong
struggle
student
stuff
stumble
style
subject
submit
subway
success
such
sudden
suffer
sugar
suggest
suit
summer
sun
sunny
sunset
super
supply
supreme
sure
surface
surge
surprise
surround
survey
suspect
sustain
swallow
swamp
swap
swarm
swear
sweet
swift
swim
swing
switch
sword
symbol
symptom
syrup
system
table
tackle
tag
tail
talent
talk
tank
tape
target
task
taste
tattoo
taxi
teach
team
tell
ten
tenant
tennis
tent
term
test
text
thank
that
theme
then
theory
there
they
thing
this
thought
three
thrive
throw
thumb
thunder
ticket
tide
tiger
tilt
timber
time
tiny
tip
tired
tissue
title
toast
tobacco
today
toddler
toe
together
toilet
token
tomato
tomorrow
tone
tongue
tonight
tool
tooth
top
topic
topple
torch
tornado
tortoise
toss
total
tourist
toward
tower
town
toy
track
trade
traffic
tragic
train
transfer
trap
trash
travel
tray
treat
tree
trend
trial
tribe
trick
trigger
trim
trip
trophy
trouble
truck
true
truly
trumpet
trust
truth
try
tube
tuition
tumble
tuna
tunnel
turkey
turn
turtle
twelve
twenty
twice
twin
twist
two
type
typical
ugly
umbrella
unable
unaware
uncle
uncover
under
undo
unfair
unfold
unhappy
uniform
unique
unit
universe
unknown
unlock
until
unusual
unveil
update
upgrade
uphold
upon
upper
upset
urban
urge
usage
use
used
useful
useless
usual
utility
vacant
vacuum
vague
valid
valley
valve
van
vanish
vapor
various
vast
vault
vehicle
velvet
vendor
venture
venue
verb
verify
version
very
vessel
veteran
viable
vibrant
vicious
victory
video
view
village
vintage
violin
virtual
virus
visa
visit
visual
vital
vivid
vocal
voice
void
volcano
volume
vote
voyage
wage
wagon
wait
walk
wall
walnut
want
warfare
warm
warrior
wash
wasp
waste
water
wave
way
wealth
weapon
wear
weasel
weather
web
wedding
weekend
weird
welcome
west
wet
whale
what
wheat
wheel
when
where
whip
whisper
wide
width
wife
wild
will
win
window
wine
wing
wink
winner
winter
wire
wisdom
wise
wish
witness
wolf
woman
wonder
wood
wool
word
work
world
worry
worth
wrap
wreck
wrestle
wrist
write
wrong
yard
year
yellow
you
young
youth
zebra
zero
zone
zoo`.split(`
`);h();h();function EYe(t,e,r,n){JS(t);let i=PH({dkLen:32,asyncTick:10},n),{c:o,dkLen:s,asyncTick:a}=i;if(lp(o),lp(s),lp(a),o<1)throw new Error("PBKDF2: iterations (c) should be >= 1");let d=fp(e),u=fp(r),c=new Uint8Array(s),l=gp.create(t,d),m=l._cloneInto().update(u);return{c:o,dkLen:s,asyncTick:a,DK:c,PRF:l,PRFSalt:m}}function SYe(t,e,r,n,i){return t.destroy(),e.destroy(),n&&n.destroy(),i.fill(0),r}async function A0e(t,e,r,n){let{c:i,dkLen:o,asyncTick:s,DK:a,PRF:d,PRFSalt:u}=EYe(t,e,r,n),c,l=new Uint8Array(4),m=Pf(l),p=new Uint8Array(d.outputLen);for(let g=1,v=0;v<o;g++,v+=d.outputLen){let E=a.subarray(v,v+d.outputLen);m.setInt32(0,g,!1),(c=u._cloneInto(c)).update(l).digestInto(p),E.set(p.subarray(0,E.length)),await IH(i-1,s,()=>{d._cloneInto(c).update(p).digestInto(p);for(let A=0;A<E.length;A++)E[A]^=p[A]})}return SYe(d,u,a,c,p)}h();function fv(t){if(!Number.isSafeInteger(t))throw new Error(`Wrong integer: ${t}`)}function tk(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}function AYe(...t){let e=o=>o,r=(o,s)=>a=>o(s(a)),n=t.map(o=>o.encode).reduceRight(r,e),i=t.map(o=>o.decode).reduce(r,e);return{encode:n,decode:i}}function TYe(t){return{encode:e=>{if(!Array.isArray(e)||e.length&&typeof e[0]!="number")throw new Error("alphabet.encode input should be an array of numbers");return e.map(r=>{if(r<0||r>=t.length)throw new Error(`Digit index outside alphabet: ${r} (alphabet: ${t.length})`);return t[r]})},decode:e=>{if(!Array.isArray(e)||e.length&&typeof e[0]!="string")throw new Error("alphabet.decode input should be array of strings");return e.map(r=>{if(typeof r!="string")throw new Error(`alphabet.decode: not string element=${r}`);let n=t.indexOf(r);if(n===-1)throw new Error(`Unknown letter: "${r}". Allowed: ${t}`);return n})}}}function IYe(t=""){if(typeof t!="string")throw new Error("join separator should be string");return{encode:e=>{if(!Array.isArray(e)||e.length&&typeof e[0]!="string")throw new Error("join.encode input should be array of strings");for(let r of e)if(typeof r!="string")throw new Error(`join.encode: non-string input=${r}`);return e.join(t)},decode:e=>{if(typeof e!="string")throw new Error("join.decode input should be string");return e.split(t)}}}function PYe(t,e="="){if(typeof e!="string")throw new Error("padding chr should be string");return{encode(r){if(!Array.isArray(r)||r.length&&typeof r[0]!="string")throw new Error("padding.encode input should be array of strings");for(let n of r)if(typeof n!="string")throw new Error(`padding.encode: non-string input=${n}`);for(;r.length*t%8;)r.push(e);return r},decode(r){if(!Array.isArray(r)||r.length&&typeof r[0]!="string")throw new Error("padding.encode input should be array of strings");for(let i of r)if(typeof i!="string")throw new Error(`padding.decode: non-string input=${i}`);let n=r.length;if(n*t%8)throw new Error("Invalid padding: string should have whole number of bytes");for(;n>0&&r[n-1]===e;n--)if(!((n-1)*t%8))throw new Error("Invalid padding: string has too much padding");return r.slice(0,n)}}}function EL(t,e,r){if(e<2)throw new Error(`convertRadix: wrong from=${e}, base cannot be less than 2`);if(r<2)throw new Error(`convertRadix: wrong to=${r}, base cannot be less than 2`);if(!Array.isArray(t))throw new Error("convertRadix: data should be array");if(!t.length)return[];let n=0,i=[],o=Array.from(t);for(o.forEach(s=>{if(s<0||s>=e)throw new Error(`Wrong integer: ${s}`)});;){let s=0,a=!0;for(let d=n;d<o.length;d++){let u=o[d],c=e*s+u;if(!Number.isSafeInteger(c)||e*s/e!==s||c-u!==e*s)throw new Error("convertRadix: carry overflow");s=c%r;let l=Math.floor(c/r);if(o[d]=l,!Number.isSafeInteger(l)||l*r+s!==c)throw new Error("convertRadix: carry overflow");if(a)l?a=!1:n=d;else continue}if(i.push(s),a)break}for(let s=0;s<t.length-1&&t[s]===0;s++)i.push(0);return i.reverse()}var T0e=(t,e)=>e?T0e(e,t%e):t,rk=(t,e)=>t+(e-T0e(t,e));function SL(t,e,r,n){if(!Array.isArray(t))throw new Error("convertRadix2: data should be array");if(e<=0||e>32)throw new Error(`convertRadix2: wrong from=${e}`);if(r<=0||r>32)throw new Error(`convertRadix2: wrong to=${r}`);if(rk(e,r)>32)throw new Error(`convertRadix2: carry overflow from=${e} to=${r} carryBits=${rk(e,r)}`);let i=0,o=0,s=2**r-1,a=[];for(let d of t){if(d>=2**e)throw new Error(`convertRadix2: invalid data word=${d} from=${e}`);if(i=i<<e|d,o+e>32)throw new Error(`convertRadix2: carry overflow pos=${o} from=${e}`);for(o+=e;o>=r;o-=r)a.push((i>>o-r&s)>>>0);i&=2**o-1}if(i=i<<r-o&s,!n&&o>=e)throw new Error("Excess padding");if(!n&&i)throw new Error(`Non-zero padding: ${i}`);return n&&o>0&&a.push(i>>>0),a}function kYe(t){return{encode:e=>{if(!tk(e))throw new Error("radix.encode input should be Uint8Array");return EL(Array.from(e),2**8,t)},decode:e=>{if(!Array.isArray(e)||e.length&&typeof e[0]!="number")throw new Error("radix.decode input should be array of numbers");return Uint8Array.from(EL(e,t,2**8))}}}function RYe(t,e=!1){if(t<=0||t>32)throw new Error("radix2: bits should be in (0..32]");if(rk(8,t)>32||rk(t,8)>32)throw new Error("radix2: carry overflow");return{encode:r=>{if(!tk(r))throw new Error("radix2.encode input should be Uint8Array");return SL(Array.from(r),8,t,!e)},decode:r=>{if(!Array.isArray(r)||r.length&&typeof r[0]!="number")throw new Error("radix2.decode input should be array of numbers");return Uint8Array.from(SL(r,t,8,e))}}}function BYe(t,e){if(typeof e!="function")throw new Error("checksum fn should be function");return{encode(r){if(!tk(r))throw new Error("checksum.encode: input should be Uint8Array");let n=e(r).slice(0,t),i=new Uint8Array(r.length+t);return i.set(r),i.set(n,r.length),i},decode(r){if(!tk(r))throw new Error("checksum.decode: input should be Uint8Array");let n=r.slice(0,-t),i=e(n).slice(0,t),o=r.slice(-t);for(let s=0;s<t;s++)if(i[s]!==o[s])throw new Error("Invalid checksum");return n}}}var b3={alphabet:TYe,chain:AYe,checksum:BYe,convertRadix:EL,convertRadix2:SL,radix:kYe,radix2:RYe,join:IYe,padding:PYe};var MYe=t=>t[0]==="\u3042\u3044\u3053\u304F\u3057\u3093";function I0e(t){if(typeof t!="string")throw new TypeError(`Invalid mnemonic type: ${typeof t}`);return t.normalize("NFKD")}function P0e(t){let e=I0e(t),r=e.split(" ");if(![12,15,18,21,24].includes(r.length))throw new Error("Invalid mnemonic");return{nfkd:e,words:r}}function k0e(t){Tf(t,16,20,24,28,32)}function R0e(t,e=128){if(lp(e),e%32!==0||e>256)throw new TypeError("Invalid entropy");return CYe(kf(e/8),t)}var DYe=t=>{let e=8-t.length/4;return new Uint8Array([ps(t)[0]>>e<<e])};function B0e(t){if(!Array.isArray(t)||t.length!==2048||typeof t[0]!="string")throw new Error("Wordlist: expected array of 2048 strings");return t.forEach(e=>{if(typeof e!="string")throw new Error(`Wordlist: non-string element: ${e}`)}),b3.chain(b3.checksum(1,DYe),b3.radix2(11,!0),b3.alphabet(t))}function OYe(t,e){let{words:r}=P0e(t),n=B0e(e).decode(r);return k0e(n),n}function CYe(t,e){return k0e(t),B0e(e).encode(t).join(MYe(e)?"\u3000":" ")}function M0e(t,e){try{OYe(t,e)}catch{return!1}return!0}var $Ye=t=>I0e(`mnemonic${t}`);function D0e(t,e=""){return A0e(Ep,P0e(t).nfkd,$Ye(e),{c:2048,dkLen:64})}h();h();var Vh=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},w3=class extends ly{constructor(){super(...arguments),this.name="DwnKeyStore",this._recordProperties={dataFormat:"application/json",schema:"https://identity.foundation/schemas/web5/private-jwk"}}delete(e){let r=Object.create(null,{delete:{get:()=>super.delete}});return Vh(this,void 0,void 0,function*(){return yield r.delete.call(this,e)})}get(e){let r=Object.create(null,{get:{get:()=>super.get}});return Vh(this,void 0,void 0,function*(){return yield r.get.call(this,e)})}set(e){let r=Object.create(null,{set:{get:()=>super.set}});return Vh(this,void 0,void 0,function*(){yield r.set.call(this,e)})}list(e){let r=Object.create(null,{list:{get:()=>super.list}});return Vh(this,void 0,void 0,function*(){return yield r.list.call(this,e)})}getAllRecords({agent:e,tenantDid:r}){var n;return Vh(this,void 0,void 0,function*(){this._index.clear();let{reply:i}=yield e.dwn.processRequest({author:r,target:r,messageType:Lr.RecordsQuery,messageParams:{filter:Object.assign({},this._recordProperties)}}),o=[];for(let s of(n=i.entries)!==null&&n!==void 0?n:[]){if(!s.encodedData)throw new Error(`${this.name}: Expected 'encodedData' to be present in the DWN query result entry`);let a=de.base64Url(s.encodedData).toObject();if(Qv(a)){let d=`${r}${ls}${r0}${a.kid}`;this._index.set(d,s.recordId),this._cache.set(s.recordId,a),o.push(a)}}return o})}},_3=class extends fy{constructor(){super(...arguments),this.name="InMemoryKeyStore"}delete(e){let r=Object.create(null,{delete:{get:()=>super.delete}});return Vh(this,void 0,void 0,function*(){return yield r.delete.call(this,e)})}get(e){let r=Object.create(null,{get:{get:()=>super.get}});return Vh(this,void 0,void 0,function*(){return yield r.get.call(this,e)})}list(e){let r=Object.create(null,{list:{get:()=>super.list}});return Vh(this,void 0,void 0,function*(){return yield r.list.call(this,e)})}set(e){let r=Object.create(null,{set:{get:()=>super.set}});return Vh(this,void 0,void 0,function*(){return yield r.set.call(this,e)})}};var Cd=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},O0e=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.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]]);return r},AL={"AES-GCM":{implementation:d5,names:["A128GCM","A192GCM","A256GCM"]},"AES-KW":{implementation:X1,names:["A128KW","A192KW","A256KW"]},Ed25519:{implementation:eb,names:["Ed25519"]},secp256k1:{implementation:wp,names:["ES256K","secp256k1"]},secp256r1:{implementation:wp,names:["ES256","secp256r1"]},"SHA-256":{implementation:yp,names:["SHA-256"]}},$d=class{constructor({agent:e,keyStore:r}={}){this._algorithmInstances=new Map,this._agent=e,this._keyStore=r??new _3}get agent(){if(this._agent===void 0)throw new Error("LocalKeyManager: Unable to determine agent execution context.");return this._agent}set agent(e){this._agent=e}decrypt(e){var{keyUri:r}=e,n=O0e(e,["keyUri"]);return Cd(this,void 0,void 0,function*(){let i=yield this.getPrivateKey({keyUri:r}),o=this.getAlgorithmName({key:i});return yield this.getAlgorithm({algorithm:o}).decrypt(Object.assign({key:i},n))})}digest(e){throw new Error("Method not implemented.")}encrypt(e){var{keyUri:r}=e,n=O0e(e,["keyUri"]);return Cd(this,void 0,void 0,function*(){let i=yield this.getPrivateKey({keyUri:r}),o=this.getAlgorithmName({key:i});return yield this.getAlgorithm({algorithm:o}).encrypt(Object.assign({key:i},n))})}exportKey({keyUri:e}){return Cd(this,void 0,void 0,function*(){return yield this.getPrivateKey({keyUri:e})})}generateKey({algorithm:e}){var r;return Cd(this,void 0,void 0,function*(){let n=this.getAlgorithmName({key:{alg:e}}),o=yield this.getAlgorithm({algorithm:n}).generateKey({algorithm:e});(r=o.kid)!==null&&r!==void 0||(o.kid=yield nt({jwk:o}));let s=yield this.getKeyUri({key:o});return yield this._keyStore.set({id:s,data:o,agent:this.agent,preventDuplicates:!1,useCache:!0}),s})}getKeyUri({key:e}){return Cd(this,void 0,void 0,function*(){let r=yield nt({jwk:e});return`${r0}${r}`})}getPublicKey({keyUri:e}){return Cd(this,void 0,void 0,function*(){let r=yield this.getPrivateKey({keyUri:e}),n=this.getAlgorithmName({key:r});return yield this.getAlgorithm({algorithm:n}).getPublicKey({key:r})})}importKey({key:e}){var r;return Cd(this,void 0,void 0,function*(){if(!Qv(e))throw new TypeError("Invalid key provided. Must be a private key in JWK format.");let n=structuredClone(e);(r=n.kid)!==null&&r!==void 0||(n.kid=yield nt({jwk:n}));let i=yield this.getKeyUri({key:n});return yield this._keyStore.set({id:i,data:n,agent:this.agent,preventDuplicates:!0,useCache:!0}),i})}sign({keyUri:e,data:r}){return Cd(this,void 0,void 0,function*(){let n=yield this.getPrivateKey({keyUri:e}),i=this.getAlgorithmName({key:n});return this.getAlgorithm({algorithm:i}).sign({data:r,key:n})})}unwrapKey({wrappedKeyBytes:e,wrappedKeyAlgorithm:r,decryptionKeyUri:n}){return Cd(this,void 0,void 0,function*(){let i=yield this.getPrivateKey({keyUri:n}),o=this.getAlgorithmName({key:i});return yield this.getAlgorithm({algorithm:o}).unwrapKey({wrappedKeyBytes:e,wrappedKeyAlgorithm:r,decryptionKey:i})})}verify({key:e,signature:r,data:n}){return Cd(this,void 0,void 0,function*(){let i=this.getAlgorithmName({key:e});return this.getAlgorithm({algorithm:i}).verify({key:e,signature:r,data:n})})}wrapKey({unwrappedKey:e,encryptionKeyUri:r}){return Cd(this,void 0,void 0,function*(){let n=yield this.getPrivateKey({keyUri:r}),i=this.getAlgorithmName({key:n});return yield this.getAlgorithm({algorithm:i}).wrapKey({unwrappedKey:e,encryptionKey:n})})}getAlgorithm({algorithm:e}){var r;let n=(r=AL[e])===null||r===void 0?void 0:r.implementation;if(!n)throw new ot(rt.AlgorithmNotSupported,`Algorithm not supported: ${e}`);return this._algorithmInstances.has(n)||this._algorithmInstances.set(n,new n),this._algorithmInstances.get(n)}getAlgorithmName({key:e}){let r=e.alg,n=e.crv;for(let i of Object.keys(AL)){let o=AL[i].names;if(r&&o.includes(r))return i;if(n&&o.includes(n))return i}throw new ot(rt.AlgorithmNotSupported,`Algorithm not supported based on provided input: alg=${r}, crv=${n}. Please check the documentation for the list of supported algorithms.`)}getPrivateKey({keyUri:e}){return Cd(this,void 0,void 0,function*(){let r=yield this._keyStore.get({id:e,agent:this.agent,useCache:!0});if(!r)throw new Error(`Key not found: ${e}`);return r})}};h();h();var C0e=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(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 E3(t){return typeof t=="object"&&t!==null&&"alg"in t&&t.alg!==void 0&&"enc"in t&&t.enc!==void 0}var x3=class{static decrypt({key:e,encryptedKey:r,joseHeader:n,crypto:i}){return C0e(this,void 0,void 0,function*(){switch(n.alg){case"dir":{if(r!==void 0)throw new ot(rt.InvalidJwe,'JWE "encrypted_key" is not allowed when using "dir" (Direct Encryption Mode).');if(e instanceof Uint8Array)throw new ot(rt.InvalidJwe,'Key management "key" must be a Key URI or JWK when using "dir" (Direct Encryption Mode).');return e}case"PBES2-HS256+A128KW":case"PBES2-HS384+A192KW":case"PBES2-HS512+A256KW":{if(typeof n.p2c!="number")throw new ot(rt.InvalidJwe,'JOSE Header "p2c" (PBES2 Count) is missing or not a number.');if(typeof n.p2s!="string")throw new ot(rt.InvalidJwe,'JOSE Header "p2s" (PBES2 salt) is missing or not a string.');if(!(e instanceof Uint8Array))throw new ot(rt.InvalidJwe,'Key management "key" must be a Uint8Array when using "PBES2" (Key Encryption Mode).');if(r===void 0)throw new ot(rt.InvalidJwe,'JWE "encrypted_key" is required when using "PBES2" (Key Encryption Mode).');let o;try{o=new Uint8Array([...de.string(n.alg).toUint8Array(),0,...de.base64Url(n.p2s).toUint8Array()])}catch{throw new ot(rt.EncodingError,'Failed to decode the JOSE Header "p2s" (PBES2 salt) value.')}let s=yield i.deriveKey({algorithm:n.alg,baseKeyBytes:e,iterations:n.p2c,salt:o});if(!(s.alg&&["A128KW","A192KW","A256KW"].includes(s.alg)))throw new ot(rt.AlgorithmNotSupported,`Unsupported Key Encryption Algorithm (alg) value: ${s.alg}`);return yield i.unwrapKey({decryptionKey:s,wrappedKeyBytes:r,wrappedKeyAlgorithm:n.enc})}default:throw new ot(rt.AlgorithmNotSupported,`Unsupported "alg" (Algorithm) Header Parameter value: ${n.alg}`)}})}static encrypt({key:e,joseHeader:r,crypto:n}){return C0e(this,void 0,void 0,function*(){let i,o;switch(r.alg){case"dir":{if(o!==void 0)throw new ot(rt.InvalidJwe,'JWE "encrypted_key" is not allowed when using "dir" (Direct Encryption Mode).');if(e instanceof Uint8Array)throw new ot(rt.InvalidJwe,'Key management "key" must be a Key URI or JWK when using "dir" (Direct Encryption Mode).');i=e;break}case"PBES2-HS256+A128KW":case"PBES2-HS384+A192KW":case"PBES2-HS512+A256KW":{if(typeof r.p2c!="number")throw new ot(rt.InvalidJwe,'JOSE Header "p2c" (PBES2 Count) is missing or not a number.');if(typeof r.p2s!="string")throw new ot(rt.InvalidJwe,'JOSE Header "p2s" (PBES2 salt) is missing or not a string.');if(!(e instanceof Uint8Array))throw new ot(rt.InvalidJwe,'Key management "key" must be a Uint8Array when using "PBES2" (Key Encryption Mode).');i=yield n.generateKey({algorithm:r.enc});let s;try{s=new Uint8Array([...de.string(r.alg).toUint8Array(),0,...de.base64Url(r.p2s).toUint8Array()])}catch{throw new ot(rt.EncodingError,'Failed to decode the JOSE Header "p2s" (PBES2 salt) value.')}let a=yield n.deriveKey({algorithm:r.alg,baseKeyBytes:e,iterations:r.p2c,salt:s});o=yield n.wrapKey({encryptionKey:a,unwrappedKey:i});break}default:throw new ot(rt.AlgorithmNotSupported,`Unsupported "alg" (Algorithm) Header Parameter value: ${r.alg}`)}return{cek:i,encryptedKey:o}})}};h();h();function S3(t){return t!==null&&typeof t=="object"&&"encrypt"in t&&typeof t.encrypt=="function"&&"decrypt"in t&&typeof t.decrypt=="function"}h();function TL(...t){let e=new Set,r=t.filter(Boolean);for(let n of r)for(let i in n){if(e.has(i))return!0;e.add(i)}return!1}var $0e=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(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 IL(t,e){if(e!==void 0)try{if(typeof e!="string")throw new Error;return de.base64Url(e).toUint8Array()}catch{throw new ot(rt.InvalidJwe,`Failed to decode the JWE Header parameter '${t}' from Base64 URL format to Uint8Array. Ensure the value is properly encoded in Base64 URL format without padding.`)}}var A3=class t{constructor(e){this.ciphertext="",Object.assign(this,e)}static decrypt({jwe:e,key:r,keyManager:n=new xr,crypto:i=new Cc,options:o={}}){var s,a;return $0e(this,void 0,void 0,function*(){if(!S3(i))throw new ot(rt.OperationNotSupported,'Crypto API does not support the "encrypt" operation.');if(!S3(n))throw new ot(rt.OperationNotSupported,'Key Manager does not support the "decrypt" operation.');if(!e.protected&&!e.header&&!e.unprotected)throw new ot(rt.InvalidJwe,'JWE is missing the required JOSE header parameters. Please provide at least one of the following: "protected", "header", or "unprotected"');if(typeof e.ciphertext!="string")throw new ot(rt.InvalidJwe,"JWE Ciphertext is missing or not a string.");let d;if(e.protected)try{d=de.base64Url(e.protected).toObject()}catch{throw new Error("JWE Protected Header is invalid")}if(TL(d,e.header,e.unprotected))throw new Error('Duplicate properties detected. Please ensure that each parameter is defined only once across the JWE "header", "protected", and "unprotected" objects.');let u=Object.assign(Object.assign(Object.assign({},d),e.header),e.unprotected);if(!E3(u))throw new Error('JWE Header is missing required "alg" (Algorithm) and/or "enc" (Encryption) Header Parameters');if(Array.isArray(o.allowedAlgValues)&&!o.allowedAlgValues.includes(u.alg))throw new Error(`"alg" (Algorithm) Header Parameter value not allowed: ${u.alg}`);if(Array.isArray(o.allowedEncValues)&&!o.allowedEncValues.includes(u.enc))throw new Error(`"enc" (Encryption Algorithm) Header Parameter value not allowed: ${u.enc}`);let c;try{let E=e.encrypted_key?de.base64Url(e.encrypted_key).toUint8Array():void 0;c=yield x3.decrypt({key:r,encryptedKey:E,joseHeader:u,keyManager:n,crypto:i})}catch(E){if(E instanceof ot&&(E.code===rt.InvalidJwe||E.code===rt.AlgorithmNotSupported))throw E;c=typeof r=="string"?yield n.generateKey({algorithm:u.enc}):yield i.generateKey({algorithm:u.enc})}let l=IL("iv",e.iv),m=IL("tag",e.tag),p=m!==void 0?new Uint8Array([...de.base64Url(e.ciphertext).toUint8Array(),...m??[]]):de.base64Url(e.ciphertext).toUint8Array(),g=e.aad!==void 0?new Uint8Array([...de.string((s=e.protected)!==null&&s!==void 0?s:"").toUint8Array(),...de.string(".").toUint8Array(),...de.string(e.aad).toUint8Array()]):de.string((a=e.protected)!==null&&a!==void 0?a:"").toUint8Array();return{plaintext:typeof c=="string"?yield n.decrypt({keyUri:c,data:p,iv:l,additionalData:g}):yield i.decrypt({key:c,data:p,iv:l,additionalData:g}),protectedHeader:d,additionalAuthenticatedData:IL("aad",e.aad),sharedUnprotectedHeader:e.unprotected,unprotectedHeader:e.header}})}static encrypt({key:e,plaintext:r,additionalAuthenticatedData:n,protectedHeader:i,sharedUnprotectedHeader:o,unprotectedHeader:s,keyManager:a=new xr,crypto:d=new Cc}){return $0e(this,void 0,void 0,function*(){if(!S3(d))throw new ot(rt.OperationNotSupported,'Crypto API does not support the "encrypt" operation.');if(!S3(a))throw new ot(rt.OperationNotSupported,'Key Manager does not support the "decrypt" operation.');if(!i&&!o&&!s)throw new ot(rt.InvalidJwe,'JWE is missing the required JOSE header parameters. Please provide at least one of the following: "protectedHeader", "sharedUnprotectedHeader", or "unprotectedHeader"');if(!(r instanceof Uint8Array))throw new ot(rt.InvalidJwe,"Plaintext is missing or not a byte array.");if(TL(i,o,s))throw new Error('Duplicate properties detected. Please ensure that each parameter is defined only once across the JWE "protectedHeader", "sharedUnprotectedHeader", and "unprotectedHeader" objects.');let u=Object.assign(Object.assign(Object.assign({},i),o),s);if(!E3(u))throw new Error('JWE Header is missing required "alg" (Algorithm) and/or "enc" (Encryption) Header Parameters');let{cek:c,encryptedKey:l}=yield x3.encrypt({key:e,joseHeader:u,keyManager:a,crypto:d}),m;switch(u.enc){case"A128GCM":case"A192GCM":case"A256GCM":m=Ei.randomBytes(12);break;default:m=new Uint8Array(0)}let p=i?de.object(i).toBase64Url():"",g,v;n?(v=de.uint8Array(n).toBase64Url(),g=de.string(p+"."+v).toUint8Array()):g=de.string(p).toUint8Array();let E=typeof c=="string"?yield a.encrypt({keyUri:c,data:r,iv:m,additionalData:g}):yield d.encrypt({key:c,data:r,iv:m,additionalData:g}),A=E.slice(0,-16),P=E.slice(-16),I=new t({ciphertext:de.uint8Array(A).toBase64Url()});return l&&(I.encrypted_key=de.uint8Array(l).toBase64Url()),i&&(I.protected=p),o&&(I.unprotected=o),s&&(I.header=s),m&&(I.iv=de.uint8Array(m).toBase64Url()),v&&(I.aad=v),P&&(I.tag=de.uint8Array(P).toBase64Url()),I})}};var N0e=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},Hh=class{static decrypt({jwe:e,key:r,keyManager:n=new xr,crypto:i=new Cc,options:o={}}){return N0e(this,void 0,void 0,function*(){if(typeof e!="string")throw new ot(rt.InvalidJwe,"Invalid JWE format. JWE must be a string.");let{0:s,1:a,2:d,3:u,4:c,length:l}=e.split(".");if(l!==5)throw new ot(rt.InvalidJwe,"Invalid JWE format. JWE must have 5 parts.");let m=yield A3.decrypt({jwe:{ciphertext:u,encrypted_key:a||void 0,iv:d||void 0,protected:s,tag:c||void 0},key:r,keyManager:n,crypto:i,options:o});if(!E3(m.protectedHeader))throw new ot(rt.InvalidJwe,"Decrypt operation failed due to missing or malformed JWE Protected Header");return{plaintext:m.plaintext,protectedHeader:m.protectedHeader}})}static encrypt({plaintext:e,protectedHeader:r,key:n,keyManager:i=new xr,crypto:o=new Cc,options:s={}}){return N0e(this,void 0,void 0,function*(){let a=yield A3.encrypt({plaintext:e,protectedHeader:r,key:n,keyManager:i,crypto:o,options:s});return[a.protected,a.encrypted_key,a.iv,a.ciphertext,a.tag].join(".")})}};var Nd=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})};function j0e(t){return typeof t!="string"||t.trim().length===0}function NYe(t){return typeof t=="object"&&t!==null&&"dateCreated"in t&&typeof t.dateCreated=="string"&&"size"in t&&typeof t.size=="number"&&"data"in t&&typeof t.data=="string"}function jYe(t){return typeof t=="object"&&t!==null&&"initialized"in t&&typeof t.initialized=="boolean"&&"lastBackup"in t&&"lastRestore"in t}var T3=class{constructor({keyDerivationWorkFactor:e,store:r}={}){this.crypto=new Cc,this._keyDerivationWorkFactor=e??21e4,this._store=r??new Uy}backup(){return Nd(this,void 0,void 0,function*(){if(this.isLocked()||(yield this.isInitialized())===!1)throw new Error("HdIdentityVault: Unable to proceed with the backup operation because the identity vault has not been initialized and unlocked. Please ensure the vault is properly initialized with a secure password before attempting to backup its contents.");let e={did:yield this.getStoredDid(),contentEncryptionKey:yield this.getStoredContentEncryptionKey(),status:yield this.getStatus()},r=de.object(e).toBase64Url(),n={data:r,dateCreated:new Date().toISOString(),size:r.length};return yield this.setStatus({lastBackup:n.dateCreated}),n})}changePassword({oldPassword:e,newPassword:r}){return Nd(this,void 0,void 0,function*(){if((yield this.isInitialized())===!1)throw new Error("HdIdentityVault: Unable to proceed with the change password operation because the identity vault has not been initialized. Please ensure the vault is properly initialized with a secure password before trying again.");yield this.lock();let n=yield this.getStoredContentEncryptionKey(),i,o;try{let a;({plaintext:a,protectedHeader:i}=yield Hh.decrypt({jwe:n,key:de.string(e).toUint8Array(),crypto:this.crypto,keyManager:new $d})),o=de.uint8Array(a).toObject()}catch{throw new Error("HdIdentityVault: Unable to change the vault password due to an incorrectly entered old password.")}let s=yield Hh.encrypt({key:de.string(r).toUint8Array(),protectedHeader:i,plaintext:de.object(o).toUint8Array(),crypto:this.crypto,keyManager:new $d});yield this._store.set("contentEncryptionKey",s),this._contentEncryptionKey=o})}getDid(){return Nd(this,void 0,void 0,function*(){if(this.isLocked())throw new Error("HdIdentityVault: Vault has not been initialized and unlocked.");let e=yield this.getStoredDid(),{plaintext:r}=yield Hh.decrypt({jwe:e,key:this._contentEncryptionKey,crypto:this.crypto,keyManager:new $d}),n=de.uint8Array(r).toObject();if(!h3(n))throw new Error("HdIdentityVault: Unable to decode malformed DID in identity vault");return yield Ki.import({portableDid:n})})}getStatus(){return Nd(this,void 0,void 0,function*(){let e=yield this._store.get("vaultStatus");if(!e)return{initialized:!1,lastBackup:null,lastRestore:null};let r=de.string(e).toObject();if(!jYe(r))throw new Error("HdIdentityVault: Invalid IdentityVaultStatus object in store");return r})}initialize({password:e,recoveryPhrase:r}){return Nd(this,void 0,void 0,function*(){if(yield this.isInitialized())throw new Error("HdIdentityVault: Vault has already been initialized.");if(j0e(e))throw new Error(`HdIdentityVault: The password is required and cannot be blank. Please provide a ' +
'valid, non-empty password.`);if(r&&j0e(r))throw new Error(`HdIdentityVault: The password is required and cannot be blank. Please provide a ' +
'valid, non-empty password.`);if(r??(r=R0e(xL,128)),!M0e(r,xL))throw new Error("HdIdentityVault: The provided recovery phrase is invalid. Please ensure that the recovery phrase is a correctly formatted series of 12 words.");let n=yield D0e(r),i=ek.fromMasterSeed(n),o=i.derive("m/44'/0'/0'/0'/0'"),s=yield this.crypto.deriveKey({algorithm:"HKDF-512",baseKeyBytes:o.privateKey,salt:"",info:"vault_cek",derivedKeyAlgorithm:"A256GCM"}),a=yield this.crypto.deriveKeyBytes({algorithm:"HKDF-512",baseKeyBytes:o.publicKey,salt:"",info:"vault_unlock_salt",length:256}),d={alg:"PBES2-HS512+A256KW",enc:"A256GCM",cty:"text/plain",p2c:this._keyDerivationWorkFactor,p2s:de.uint8Array(a).toBase64Url()},u=yield Hh.encrypt({key:de.string(e).toUint8Array(),protectedHeader:d,plaintext:de.object(s).toUint8Array(),crypto:this.crypto,keyManager:new $d});yield this._store.set("contentEncryptionKey",u);let c=i.derive("m/44'/0'/1708523827'/0'/0'"),l=yield this.crypto.bytesToPrivateKey({algorithm:"Ed25519",privateKeyBytes:c.privateKey}),m=i.derive("m/44'/0'/1708523827'/0'/1'"),p=yield this.crypto.bytesToPrivateKey({algorithm:"Ed25519",privateKeyBytes:m.privateKey}),g=new WP;yield g.addPredefinedKeys({privateKeys:[l,p]});let E=yield(yield Qc.create({keyManager:g,options:{verificationMethods:[{algorithm:"Ed25519",id:"sig",purposes:["assertionMethod","authentication"]}]}})).export(),A={alg:"dir",enc:"A256GCM",cty:"json"},P=yield Hh.encrypt({key:s,plaintext:de.object(E).toUint8Array(),protectedHeader:A,crypto:this.crypto,keyManager:new $d});return yield this._store.set("did",P),this._contentEncryptionKey=s,yield this.setStatus({initialized:!0}),r})}isInitialized(){return Nd(this,void 0,void 0,function*(){return this.getStatus().then(({initialized:e})=>e)})}isLocked(){return!this._contentEncryptionKey}lock(){return Nd(this,void 0,void 0,function*(){if((yield this.isInitialized())===!1)throw new Error("HdIdentityVault: Lock operation failed. Vault has not been initialized.");this._contentEncryptionKey&&(this._contentEncryptionKey.k=""),this._contentEncryptionKey=void 0})}restore({backup:e,password:r}){return Nd(this,void 0,void 0,function*(){if(!NYe(e))throw new Error("HdIdentityVault: Restore operation failed due to invalid backup object.");let n,i,o;try{o=yield this.getStoredDid(),i=yield this.getStoredContentEncryptionKey(),n=yield this.getStatus()}catch{throw new Error("HdIdentityVault: The restore operation cannot proceed because the existing vault contents are missing or inaccessible. If the problem persists consider re-initializing the vault and retrying the restore.")}try{let s=de.base64Url(e.data).toObject();yield this._store.set("did",s.did),yield this._store.set("contentEncryptionKey",s.contentEncryptionKey),yield this.setStatus(s.status),yield this.unlock({password:r})}catch{throw yield this.setStatus(n),yield this._store.set("contentEncryptionKey",i),yield this._store.set("did",o),new Error("HdIdentityVault: Restore operation failed due to invalid backup data or an incorrect password. Please verify the password is correct for the provided backup and try again.")}yield this.setStatus({lastRestore:new Date().toISOString()})})}unlock({password:e}){return Nd(this,void 0,void 0,function*(){yield this.lock();let r=yield this.getStoredContentEncryptionKey();try{let{plaintext:n}=yield Hh.decrypt({jwe:r,key:de.string(e).toUint8Array(),crypto:this.crypto,keyManager:new $d}),i=de.uint8Array(n).toObject();this._contentEncryptionKey=i}catch{throw new Error("HdIdentityVault: Unable to unlock the vault due to an incorrect password.")}})}getStoredDid(){return Nd(this,void 0,void 0,function*(){let e=yield this._store.get("did");if(!e)throw new Error("HdIdentityVault: Unable to retrieve the DID record from the vault. Please check the vault status and if the problem persists consider re-initializing the vault and restoring the contents from a previous backup.");return e})}getStoredContentEncryptionKey(){return Nd(this,void 0,void 0,function*(){let e=yield this._store.get("contentEncryptionKey");if(!e)throw new Error("HdIdentityVault: Unable to retrieve the Content Encryption Key record from the vault. Please check the vault status and if the problem persists consider re-initializing the vault and restoring the contents from a previous backup.");return e})}setStatus({initialized:e,lastBackup:r,lastRestore:n}){return Nd(this,void 0,void 0,function*(){let i=yield this.getStatus();return i.initialized=e??i.initialized,i.lastBackup=r??i.lastBackup,i.lastRestore=n??i.lastRestore,yield this._store.set("vaultStatus",JSON.stringify(i)),!0})}};h();h();var Wh=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(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 UYe(t){return!(!t||typeof t!="object"||t===null)&&"name"in t}var I3=class extends ly{constructor(){super(...arguments),this.name="DwnIdentityStore",this._recordProperties={dataFormat:"application/json",schema:"https://identity.foundation/schemas/web5/identity-metadata"}}delete(e){let r=Object.create(null,{delete:{get:()=>super.delete}});return Wh(this,void 0,void 0,function*(){return yield r.delete.call(this,e)})}get(e){let r=Object.create(null,{get:{get:()=>super.get}});return Wh(this,void 0,void 0,function*(){return yield r.get.call(this,e)})}set(e){let r=Object.create(null,{set:{get:()=>super.set}});return Wh(this,void 0,void 0,function*(){return yield r.set.call(this,e)})}list(e){let r=Object.create(null,{list:{get:()=>super.list}});return Wh(this,void 0,void 0,function*(){return yield r.list.call(this,e)})}getAllRecords({agent:e,tenantDid:r}){var n;return Wh(this,void 0,void 0,function*(){this._index.clear();let{reply:i}=yield e.dwn.processRequest({author:r,target:r,messageType:Lr.RecordsQuery,messageParams:{filter:Object.assign({},this._recordProperties)}}),o=[];for(let s of(n=i.entries)!==null&&n!==void 0?n:[]){if(!s.encodedData)throw new Error(`${this.name}: Expected 'encodedData' to be present in the DWN query result entry`);let a=de.base64Url(s.encodedData).toObject();if(UYe(a)){let d=`${r}${ls}${a.uri}`;this._index.set(d,s.recordId),this._cache.set(s.recordId,a),o.push(a)}}return o})}},P3=class extends fy{constructor(){super(...arguments),this.name="InMemoryIdentityStore"}delete(e){let r=Object.create(null,{delete:{get:()=>super.delete}});return Wh(this,void 0,void 0,function*(){return yield r.delete.call(this,e)})}get(e){let r=Object.create(null,{get:{get:()=>super.get}});return Wh(this,void 0,void 0,function*(){return yield r.get.call(this,e)})}list(e){let r=Object.create(null,{list:{get:()=>super.list}});return Wh(this,void 0,void 0,function*(){return yield r.list.call(this,e)})}set(e){let r=Object.create(null,{set:{get:()=>super.set}});return Wh(this,void 0,void 0,function*(){return yield r.set.call(this,e)})}};var n2=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})};var k3=class{constructor({agent:e,store:r}={}){this._agent=e,this._store=r??new P3}get agent(){if(this._agent===void 0)throw new Error("AgentIdentityApi: Unable to determine agent execution context.");return this._agent}set agent(e){this._agent=e}create({metadata:e,didMethod:r="dht",didOptions:n,store:i,tenant:o}){return n2(this,void 0,void 0,function*(){let s=yield this.agent.did.create({method:r,options:n,store:i,tenant:o}),a=new lv({did:s,metadata:Object.assign(Object.assign({},e),{uri:s.uri,tenant:o??s.uri})});return(i??!0)&&(yield this._store.set({id:a.did.uri,data:a.metadata,agent:this.agent,tenant:a.metadata.tenant,preventDuplicates:!1,useCache:!0})),a})}export({didUri:e,tenant:r}){return n2(this,void 0,void 0,function*(){let n=yield this.get({didUri:e,tenant:r});if(!n)throw new Error(`AgentIdentityApi: Failed to export due to Identity not found: ${e}`);return yield n.export()})}get({didUri:e,tenant:r}){return n2(this,void 0,void 0,function*(){let n=yield this._store.get({id:e,agent:this.agent,tenant:r,useCache:!0});if(!n)return;let i=yield this.agent.did.get({didUri:e,tenant:n.tenant});if(!i)throw new Error(`AgentIdentityApi: Identity is present in the store but DID is missing: ${e}`);return new lv({did:i,metadata:n})})}import({portableIdentity:e}){return n2(this,void 0,void 0,function*(){let r=yield this.agent.did.import({portableDid:e.portableDid,tenant:e.metadata.tenant});if(!r)throw new Error(`AgentIdentityApi: Failed to import Identity: ${e.metadata.uri}`);let n=new lv({did:r,metadata:e.metadata});return yield this._store.set({id:n.did.uri,data:n.metadata,agent:this.agent,tenant:n.metadata.tenant,preventDuplicates:!0,useCache:!0}),n})}list({tenant:e}={}){return n2(this,void 0,void 0,function*(){let r=yield this._store.list({agent:this.agent,tenant:e}),n=[];for(let i of r){let o=yield this.get({didUri:i.uri,tenant:i.tenant});n.push(o)}return n})}manage({portableIdentity:e}){return n2(this,void 0,void 0,function*(){let r=yield this.agent.did.get({didUri:e.metadata.uri,tenant:e.metadata.tenant});if(!r)throw new Error(`AgentIdentityApi: Failed to manage Identity: ${e.metadata.uri}`);let n=new lv({did:r,metadata:e.metadata});return yield this._store.set({id:n.did.uri,data:n.metadata,agent:this.agent,preventDuplicates:!0,useCache:!0}),n})}};h();h();var U0e;(function(t){t[t.InvalidRequest=-32600]="InvalidRequest",t[t.MethodNotFound=-32601]="MethodNotFound",t[t.InvalidParams=-32602]="InvalidParams",t[t.InternalError=-32603]="InternalError",t[t.ParseError=-32700]="ParseError",t[t.TransportError=-32300]="TransportError",t[t.BadRequest=-50400]="BadRequest",t[t.Unauthorized=-50401]="Unauthorized",t[t.Forbidden=-50403]="Forbidden"})(U0e||(U0e={}));var i2=(t,e,r)=>({jsonrpc:"2.0",id:t,method:e,params:r}),nk=(t,e,r,n)=>({jsonrpc:"2.0",id:t,method:`rpc.subscribe.${e}`,params:n,subscription:{id:r}});function o2(t){try{return JSON.parse(t)}catch{return null}}h();h();var q0e=qt(h0(),1);var R3=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},ik=class{constructor({ttl:e="15m"}={}){this.cache=new Zh.default({ttl:(0,q0e.default)(e)})}get(e){return R3(this,void 0,void 0,function*(){return this.cache.get(e)})}set(e,r){return R3(this,void 0,void 0,function*(){this.cache.set(e,r)})}delete(e){return R3(this,void 0,void 0,function*(){this.cache.delete(e)})}clear(){return R3(this,void 0,void 0,function*(){this.cache.clear()})}close(){return R3(this,void 0,void 0,function*(){})}};var L0e=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},ok=class{constructor(e){this.serverInfoCache=e??new ik}get transportProtocols(){return["http:","https:"]}sendDwnRequest(e){return L0e(this,void 0,void 0,function*(){let r=Ei.randomUuid(),n=i2(r,"dwn.processMessage",{target:e.targetDid,message:e.message}),i={method:"POST",headers:{"dwn-request":JSON.stringify(n)}};e.data&&(i.headers["content-type"]="application/octet-stream",i.body=e.data);let o=yield fetch(e.dwnUrl,i),s,a,{headers:d}=o;if(d.has("dwn-response")){let c=o2(d.get("dwn-response"));if(c==null)throw new Error(`failed to parse json rpc response. dwn url: ${e.dwnUrl}`);a=o.body,s=c}else{let c=yield o.text();s=JSON.parse(c)}if(s.error){let{code:c,message:l}=s.error;throw new Error(`(${c}) - ${l}`)}let{reply:u}=s.result;return a&&(u.record.data=a),u})}getServerInfo(e){return L0e(this,void 0,void 0,function*(){let r=yield this.serverInfoCache.get(e);if(r)return r;let n=new URL(e);n.pathname.endsWith("/")?n.pathname+="info":n.pathname+="/info";try{let i=yield fetch(n.toString());if(i.ok){let o=yield i.json(),s={registrationRequirements:o.registrationRequirements,maxFileSize:o.maxFileSize,webSocketSupport:o.webSocketSupport};return this.serverInfoCache.set(e,s),s}else throw new Error(`HTTP (${i.status}) - ${i.statusText}`)}catch(i){throw new Error(`Error encountered while processing response from ${n.toString()}: ${i.message}`)}})}};h();h();h();var s2=null;typeof WebSocket<"u"?s2=WebSocket:typeof MozWebSocket<"u"?s2=MozWebSocket:typeof globalThis<"u"?s2=globalThis.WebSocket||globalThis.MozWebSocket:typeof window<"u"?s2=window.WebSocket||window.MozWebSocket:typeof self<"u"&&(s2=self.WebSocket||self.MozWebSocket);var K0e=s2;var sk=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},qYe=3e3,LYe=3e4,ak=class t{constructor(e,r){this.socket=e,this.responseTimeout=r,this.messageHandlers=new Map}static connect(e,r={}){return sk(this,void 0,void 0,function*(){let{connectTimeout:n=qYe,responseTimeout:i=LYe,onclose:o,onerror:s}=r,a=new K0e(e);return o?a.onclose=o:a.onclose=()=>{console.info(`JSON RPC Socket close ${e}`)},s?a.onerror=s:a.onerror=d=>{console.error(`JSON RPC Socket error ${e}`,d)},new Promise((d,u)=>{a.addEventListener("open",()=>{let c=new t(a,i);a.addEventListener("message",l=>{let m=o2(l.data),p=c.messageHandlers.get(m.id);p&&p(l)}),d(c)}),a.addEventListener("error",c=>{u(c)}),setTimeout(()=>u,n)})})}close(){this.socket.close()}request(e){return sk(this,void 0,void 0,function*(){return new Promise((r,n)=>{var i;(i=e.id)!==null&&i!==void 0||(e.id=Ei.randomUuid());let o=s=>{let a=o2(s.data);if(a.id===e.id)return this.messageHandlers.delete(e.id),r(a)};this.messageHandlers.set(e.id,o),this.send(e),setTimeout(()=>{this.messageHandlers.delete(e.id),n(new Error("request timed out"))},this.responseTimeout)})})}subscribe(e,r){return sk(this,void 0,void 0,function*(){if(!e.method.startsWith("rpc.subscribe."))throw new Error("subscribe rpc requests must include the `rpc.subscribe` prefix");if(!e.subscription)throw new Error("subscribe rpc requests must include subscribe options");let n=e.subscription.id,i=a=>{let d=o2(a.data.toString());d.id===n&&(d.error!==void 0&&(this.messageHandlers.delete(n),this.closeSubscription(n)),r(d))};this.messageHandlers.set(n,i);let o=yield this.request(e);return o.error?(this.messageHandlers.delete(n),{response:o}):{response:o,close:()=>sk(this,void 0,void 0,function*(){this.messageHandlers.delete(n),yield this.closeSubscription(n)})}})}closeSubscription(e){let r=Ei.randomUuid(),n=nk(r,"close",e,{});return this.request(n)}send(e){this.socket.send(JSON.stringify(e))}};var PL=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},B3=class t{get transportProtocols(){return["ws:","wss:"]}sendDwnRequest(e,r){return PL(this,void 0,void 0,function*(){let n=new URL(e.dwnUrl);if(n.protocol!=="ws:"&&n.protocol!=="wss:")throw new Error(`Invalid websocket protocol ${n.protocol}`);if(!t.connections.has(n.host))try{let u=yield ak.connect(n.toString(),r),c=new Map;t.connections.set(n.host,{socket:u,subscriptions:c})}catch(u){throw new Error(`Error connecting to ${n.host}: ${u.message}`)}let o=t.connections.get(n.host),{targetDid:s,message:a,subscriptionHandler:d}=e;return d?t.subscriptionRequest(o,s,a,d):t.processMessage(o,s,a)})}static processMessage(e,r,n){return PL(this,void 0,void 0,function*(){let i=Ei.randomUuid(),o=i2(i,"dwn.processMessage",{target:r,message:n}),{socket:s}=e,a=yield s.request(o),{error:d,result:u}=a;if(d!==void 0)throw new Error(`error sending DWN request: ${d.message}`);return u.reply})}static subscriptionRequest(e,r,n,i){return PL(this,void 0,void 0,function*(){let o=Ei.randomUuid(),s=Ei.randomUuid(),a=nk(o,"dwn.processMessage",s,{target:r,message:n}),{socket:d,subscriptions:u}=e,{response:c,close:l}=yield d.subscribe(a,v=>{let{result:E,error:A}=v;if(A){let I=u.get(s);I&&I.close(),u.delete(s);return}let{event:P}=E;i(P)}),{error:m,result:p}=c;if(m)throw new Error(`could not subscribe via jsonrpc socket: ${m.message}`);let{reply:g}=p;return g.subscription&&l&&(u.set(s,Object.assign(Object.assign({},g.subscription),{close:l})),g.subscription.close=l),g})}};B3.connections=new Map;var M3=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},F0e;(function(t){t.Create="did.create",t.Resolve="did.resolve"})(F0e||(F0e={}));var D3=class{constructor(e=[]){this.transportClients=new Map,e=[new kL,new RL,...e];for(let r of e)for(let n of r.transportProtocols)this.transportClients.set(n,r)}get transportProtocols(){return Array.from(this.transportClients.keys())}sendDidRequest(e){return M3(this,void 0,void 0,function*(){let r=new URL(e.url),n=this.transportClients.get(r.protocol);if(!n){let i=new Error(`no ${r.protocol} transport client available`);throw i.name="NO_TRANSPORT_CLIENT",i}return n.sendDidRequest(e)})}sendDwnRequest(e){let r=new URL(e.dwnUrl),n=this.transportClients.get(r.protocol);if(!n){let i=new Error(`no ${r.protocol} transport client available`);throw i.name="NO_TRANSPORT_CLIENT",i}return n.sendDwnRequest(e)}getServerInfo(e){return M3(this,void 0,void 0,function*(){let r=new URL(e),n=this.transportClients.get(r.protocol);if(!n){let i=new Error(`no ${r.protocol} transport client available`);throw i.name="NO_TRANSPORT_CLIENT",i}return n.getServerInfo(e)})}},kL=class extends ok{sendDidRequest(e){return M3(this,void 0,void 0,function*(){let r=Ei.randomUuid(),n=i2(r,e.method,{data:e.data}),i=new Request(e.url,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)}),o;try{let s=yield fetch(i);if(s.ok){if(o=yield s.json(),o.error){let{code:a,message:d}=o.error;throw new Error(`JSON RPC (${a}) - ${d}`)}}else throw new Error(`HTTP (${s.status}) - ${s.statusText}`)}catch(s){throw new Error(`Error encountered while processing response from ${e.url}: ${s.message}`)}return o.result})}},RL=class extends B3{sendDidRequest(e){return M3(this,void 0,void 0,function*(){throw new Error(`not implemented for transports [${this.transportProtocols.join(", ")}]`)})}getServerInfo(e){return M3(this,void 0,void 0,function*(){throw new Error(`not implemented for transports [${this.transportProtocols.join(", ")}]`)})}};h();var KYe=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},O3=class{constructor({agent:e,syncEngine:r}){this._syncEngine=r,this._agent=e}get agent(){if(this._agent===void 0)throw new Error("AgentSyncApi: Unable to determine agent execution context.");return this._agent}set agent(e){this._agent=e,this._syncEngine.agent=e}registerIdentity(e){return KYe(this,void 0,void 0,function*(){yield this._syncEngine.registerIdentity(e)})}startSync(e){return this._syncEngine.startSync(e)}stopSync(){this._syncEngine.stopSync()}};h();var V0e=qt(h0(),1),H0e=qt(N2(),1);var Wa=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},z0e=t=>t>=200&&t<=299,FYe=t=>t>=400&&t<=499,C3=class{constructor({agent:e,dataPath:r,db:n}){this._agent=e,this._db=n||new H0e.Level(r??"DATA/AGENT/SYNC_STORE"),this._ulidFactory=jP()}get agent(){if(this._agent===void 0)throw new Error("SyncEngineLevel: Unable to determine agent execution context.");return this._agent}set agent(e){this._agent=e}clear(){return Wa(this,void 0,void 0,function*(){yield this._db.clear()})}close(){return Wa(this,void 0,void 0,function*(){yield this._db.close()})}pull(){var e;return Wa(this,void 0,void 0,function*(){let r=yield this.getSyncPeerState({syncDirection:"pull"});yield this.enqueueOperations({syncDirection:"pull",syncPeerState:r});let n=this.getPullQueue(),i=yield n.iterator().all(),o=[],s=new Set;for(let a of i){let[d]=a,[u,c,l,m]=d.split("~");if(s.has(c))continue;if(yield this.messageExists(u,m)){o.push({type:"del",key:d});continue}let g=yield this.agent.dwn.createMessage({author:u,messageType:Lr.MessagesGet,messageParams:{messageCids:[m]}}),v;try{v=yield this.agent.rpc.sendDwnRequest({dwnUrl:c,targetDid:u,message:g})}catch{s.add(c);continue}for(let E of(e=v.entries)!==null&&e!==void 0?e:[]){if(E.error||!E.message){yield this.addMessage(u,m),o.push({type:"del",key:d});continue}let A;if(t2(E)){let{encodedData:I}=E,$=E.message;if(I){let N=de.base64Url(I).toUint8Array();A=ku.fromBytes(N)}else{let N=yield this.agent.dwn.createMessage({author:u,messageType:Lr.RecordsRead,messageParams:{filter:{recordId:$.recordId}}}),K=yield this.agent.rpc.sendDwnRequest({dwnUrl:c,targetDid:u,message:N.message}),{record:F,status:U}=K;if(z0e(U.code)&&F)A=Af.fromWebReadable({readableStream:F.data});else if(U.code>=400){let V=yield this.agent.dwn.processMessage({targetDid:u,message:$});if(V.status.code===202||V.status.code===409){yield this.addMessage(u,m),o.push({type:"del",key:d});continue}else throw new Error(`SyncManager: Failed to sync tombstone for message '${m}'`)}}}let P=yield this.agent.dwn.processMessage({targetDid:u,message:E.message,dataStream:A});(P.status.code===202||P.status.code===409)&&(yield this.addMessage(u,m),o.push({type:"del",key:d}))}}yield n.batch(o)})}push(){return Wa(this,void 0,void 0,function*(){let e=yield this.getSyncPeerState({syncDirection:"push"});yield this.enqueueOperations({syncDirection:"push",syncPeerState:e});let r=this.getPushQueue(),n=yield r.iterator().all(),i=[],o=new Set;for(let s of n){let[a]=s,[d,u,c,l]=a.split("~");if(o.has(u))continue;let m=yield this.getDwnMessage({author:d,messageCid:l});if(!m){i.push({type:"del",key:a}),yield this.addMessage(d,l);continue}try{let p=yield this.agent.rpc.sendDwnRequest({dwnUrl:u,targetDid:d,data:m.data,message:m.message});(p.status.code===202||p.status.code===409)&&(yield this.addMessage(d,l),i.push({type:"del",key:a}))}catch{o.add(u)}}yield r.batch(i)})}registerIdentity({did:e}){return Wa(this,void 0,void 0,function*(){yield this._db.sublevel("registeredIdentities").put(e,"")})}startSync({interval:e}){let r=(0,V0e.default)(e);return new Promise((n,i)=>{let o=()=>Wa(this,void 0,void 0,function*(){this._syncIntervalId&&clearInterval(this._syncIntervalId);try{yield this.push(),yield this.pull()}catch(s){this.stopSync(),i(s)}this._syncIntervalId=setInterval(o,r)});this._syncIntervalId=setInterval(o,r)})}stopSync(){this._syncIntervalId&&(clearInterval(this._syncIntervalId),this._syncIntervalId=void 0)}enqueueOperations({syncDirection:e,syncPeerState:r}){return Wa(this,void 0,void 0,function*(){for(let n of r){let i=yield this.getDwnEventLog({did:n.did,dwnUrl:n.dwnUrl,cursor:n.cursor,syncDirection:e}),o=[];for(let s of i){let a=this._ulidFactory(),d=[n.did,n.dwnUrl,a,s].join("~");o.push({type:"put",key:d,value:""})}o.length>0&&(yield(e==="pull"?this.getPullQueue():this.getPushQueue()).batch(o))}})}getDwnEventLog({did:e,dwnUrl:r,syncDirection:n,cursor:i}){var o;return Wa(this,void 0,void 0,function*(){let s={};if(n==="pull"){let d=yield this.agent.dwn.createMessage({author:e,messageType:Lr.EventsGet,messageParams:{cursor:i}});try{s=yield this.agent.rpc.sendDwnRequest({dwnUrl:r,targetDid:e,message:d})}catch{}}else n==="push"&&(s=(yield this.agent.dwn.processRequest({author:e,target:e,messageType:Lr.EventsGet,messageParams:{cursor:i}})).reply);let a=(o=s.entries)!==null&&o!==void 0?o:[];return s.cursor&&this.setCursor(e,r,n,s.cursor),a})}getDwnMessage({author:e,messageCid:r}){return Wa(this,void 0,void 0,function*(){let{reply:n}=yield this.agent.dwn.processRequest({author:e,target:e,messageType:Lr.MessagesGet,messageParams:{messageCids:[r]}});if(!(n.entries&&n.entries.length===1))return;let[i]=n.entries,o=i.message;if(!o)return;let s={message:o};if(t2(i))if(i.encodedData){let a=de.base64Url(i.encodedData).toUint8Array();s.data=new Blob([a])}else{let d=(yield this.agent.dwn.processRequest({author:e,target:e,messageType:Lr.RecordsRead,messageParams:{filter:{recordId:i.message.recordId}}})).reply;if(z0e(d.status.code)&&d.record)s.data=yield Af.consumeToBlob({readable:d.record.data});else if(!FYe(d.status.code)){let{status:{code:u,detail:c}}=d;throw new Error(`SyncEngineLevel: (${u}) Failed to read data associated with record ${i.message.recordId}. ${c}}`)}}return s})}getSyncPeerState({syncDirection:e}){return Wa(this,void 0,void 0,function*(){let r=yield this._db.sublevel("registeredIdentities").keys().all(),n=[];for(let i of r){let o=yield YP(i,this.agent.did);if(o.length!==0)for(let s of o){let a=yield this.getCursor(i,s,e);n.push({did:i,dwnUrl:s,cursor:a})}}return n})}getCursor(e,r,n){return Wa(this,void 0,void 0,function*(){let i=`${e}~${r}~${n}`,o=this.getCursorStore();try{let s=yield o.get(i);if(s)return JSON.parse(s)}catch(s){if(s.notFound)return}})}setCursor(e,r,n,i){return Wa(this,void 0,void 0,function*(){let o=`${e}~${r}~${n}`;yield this.getCursorStore().put(o,JSON.stringify(i))})}messageExists(e,r){return Wa(this,void 0,void 0,function*(){let n=this.getMessageStore(e);try{return yield n.get(r),!0}catch(i){if(i.notFound)return!1;throw i}})}addMessage(e,r){return Wa(this,void 0,void 0,function*(){return yield this.getMessageStore(e).put(r,"")})}getMessageStore(e){return this._db.sublevel("history").sublevel(e).sublevel("messages")}getCursorStore(){return this._db.sublevel("cursors")}getPushQueue(){return this._db.sublevel("pushQueue")}getPullQueue(){return this._db.sublevel("pullQueue")}};h();var zYe=qt(N2(),1);var W0e=class t{constructor(e){this._agentDid=e.agentDid,this.crypto=e.cryptoApi,this.did=e.didApi,this.dwn=e.dwnApi,this.identity=e.identityApi,this.keyManager=e.keyManager,this.rpc=e.rpcClient,this.sync=e.syncApi,this.vault=e.agentVault,this.did.agent=this,this.dwn.agent=this,this.identity.agent=this,this.keyManager.agent=this,this.sync.agent=this}get agentDid(){if(this._agentDid===void 0)throw new Error('Web5UserAgent: The "agentDid" property is not set. Ensure the agent is properly initialized and a DID is assigned.');return this._agentDid}set agentDid(e){this._agentDid=e}static async create({dataPath:e="DATA/AGENT",agentDid:r,agentVault:n,cryptoApi:i,didApi:o,dwnApi:s,identityApi:a,keyManager:d,rpcClient:u,syncApi:c}={}){return n??=new T3({keyDerivationWorkFactor:21e4,store:new j2({location:`${e}/VAULT_STORE`})}),i??=new Cc,o??=new v3({didMethods:[Qc,Cp],resolverCache:new p0({location:`${e}/DID_RESOLVERCACHE`}),store:new p3}),s??=new r2({dwn:await r2.createDwn({dataPath:e,didResolver:o})}),a??=new k3({store:new I3}),d??=new $d({keyStore:new w3}),u??=new D3,c??=new O3({syncEngine:new C3({dataPath:e})}),new t({agentDid:r,agentVault:n,cryptoApi:i,didApi:o,dwnApi:s,keyManager:d,identityApi:a,rpcClient:u,syncApi:c})}async firstLaunch(){return await this.vault.isInitialized()===!1}async initialize({password:e,recoveryPhrase:r}){return r=await this.vault.initialize({password:e,recoveryPhrase:r}),r}async processDidRequest(e){return this.did.processRequest(e)}async processDwnRequest(e){return this.dwn.processRequest(e)}async processVcRequest(e){throw new Error("Not implemented")}async sendDidRequest(e){throw new Error("Not implemented")}async sendDwnRequest(e){return this.dwn.sendRequest(e)}async sendVcRequest(e){throw new Error("Not implemented")}async start({password:e}){this.vault.isLocked()&&await this.vault.unlock({password:e}),this.agentDid=await this.vault.getDid()}};export{W0e as Web5UserAgent};
/*! Bundled license information:
ieee754/index.js:
(*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> *)
buffer/index.js:
(*!
* The buffer module from node.js, for the browser.
*
* @author Feross Aboukhadijeh <https://feross.org>
* @license MIT
*)
buffer/index.js:
(*!
* The buffer module from node.js, for the browser.
*
* @author Feross Aboukhadijeh <https://feross.org>
* @license MIT
*)
queue-microtask/index.js:
(*! queue-microtask. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> *)
run-parallel-limit/index.js:
(*! run-parallel-limit. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> *)
safe-buffer/index.js:
(*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> *)
uri-js/dist/es5/uri.all.js:
(** @license URI.js v4.4.1 (c) 2011 Gary Court. License: http://github.com/garycourt/uri-js *)
@noble/ciphers/utils.js:
(*! noble-ciphers - MIT License (c) 2023 Paul Miller (paulmillr.com) *)
@noble/hashes/utils.js:
(*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
@noble/curves/abstract/utils.js:
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
@noble/curves/abstract/modular.js:
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
@noble/curves/abstract/curve.js:
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
@noble/curves/abstract/edwards.js:
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
@noble/curves/abstract/montgomery.js:
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
@noble/curves/ed25519.js:
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
@noble/curves/abstract/weierstrass.js:
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
@noble/curves/_shortw_utils.js:
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
@noble/curves/secp256k1.js:
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
@noble/hashes/utils.js:
(*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
@noble/hashes/esm/utils.js:
(*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
@noble/curves/esm/abstract/utils.js:
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
@noble/curves/esm/abstract/modular.js:
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
@noble/curves/esm/abstract/curve.js:
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
@noble/curves/esm/abstract/weierstrass.js:
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
@noble/curves/esm/_shortw_utils.js:
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
@noble/curves/esm/secp256k1.js:
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
@noble/curves/esm/p256.js:
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
@noble/curves/esm/abstract/edwards.js:
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
@noble/curves/esm/abstract/montgomery.js:
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
@noble/curves/esm/ed25519.js:
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
@noble/ciphers/esm/utils.js:
(*! noble-ciphers - MIT License (c) 2023 Paul Miller (paulmillr.com) *)
uint8-util/util.js:
(* Common package for dealing with hex/string/uint8 conversions (and sha1 hashing)
*
* @author Jimmy Wärting <jimmy@warting.se> (https://jimmy.warting.se/opensource)
* @license MIT
*)
@noble/ed25519/index.js:
(*! noble-ed25519 - MIT License (c) 2019 Paul Miller (paulmillr.com) *)
@noble/secp256k1/index.js:
(*! noble-secp256k1 - MIT License (c) 2019 Paul Miller (paulmillr.com) *)
ed25519-keygen/hdkey.js:
(*! micro-ed25519-hdkey - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
@scure/base/lib/esm/index.js:
(*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
@scure/bip39/esm/index.js:
(*! scure-bip39 - MIT License (c) 2022 Patricio Palladino, Paul Miller (paulmillr.com) *)
*/
//# sourceMappingURL=browser.mjs.map