@smartledger/bsv 9.16.1 → 9.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bsv-ltp.min.js CHANGED
@@ -1,75 +1,75 @@
1
- var bsvLTP=(()=>{var gI=Object.create;var ys=Object.defineProperty;var yI=Object.getOwnPropertyDescriptor;var mI=Object.getOwnPropertyNames;var vI=Object.getPrototypeOf,bI=Object.prototype.hasOwnProperty;var _I=(e,t,r)=>t in e?ys(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var Yt=(e,t,r)=>()=>{if(r)throw r[0];try{return e&&(t=e(e=0)),t}catch(n){throw r=[n],n}};var B=(e,t)=>()=>{try{return t||e((t={exports:{}}).exports,t),t.exports}catch(r){throw t=0,r}},fl=(e,t)=>{for(var r in t)ys(e,r,{get:t[r],enumerable:!0})},u0=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of mI(t))!bI.call(e,i)&&i!==r&&ys(e,i,{get:()=>t[i],enumerable:!(n=yI(t,i))||n.enumerable});return e};var f0=(e,t,r)=>(r=e!=null?gI(vI(e)):{},u0(t||!e||!e.__esModule?ys(r,"default",{value:e,enumerable:!0}):r,e)),cl=e=>u0(ys({},"__esModule",{value:!0}),e);var Z=(e,t,r)=>_I(e,typeof t!="symbol"?t+"":t,r);var p0=B((UC,d0)=>{p();var nt=d0.exports={},zr,Yr;function ll(){throw new Error("setTimeout has not been defined")}function hl(){throw new Error("clearTimeout has not been defined")}(function(){try{typeof setTimeout=="function"?zr=setTimeout:zr=ll}catch{zr=ll}try{typeof clearTimeout=="function"?Yr=clearTimeout:Yr=hl}catch{Yr=hl}})();function c0(e){if(zr===setTimeout)return setTimeout(e,0);if((zr===ll||!zr)&&setTimeout)return zr=setTimeout,setTimeout(e,0);try{return zr(e,0)}catch{try{return zr.call(null,e,0)}catch{return zr.call(this,e,0)}}}function SI(e){if(Yr===clearTimeout)return clearTimeout(e);if((Yr===hl||!Yr)&&clearTimeout)return Yr=clearTimeout,clearTimeout(e);try{return Yr(e)}catch{try{return Yr.call(null,e)}catch{return Yr.call(this,e)}}}var gn=[],co=!1,xi,Ja=-1;function wI(){!co||!xi||(co=!1,xi.length?gn=xi.concat(gn):Ja=-1,gn.length&&l0())}function l0(){if(!co){var e=c0(wI);co=!0;for(var t=gn.length;t;){for(xi=gn,gn=[];++Ja<t;)xi&&xi[Ja].run();Ja=-1,t=gn.length}xi=null,co=!1,SI(e)}}nt.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];gn.push(new h0(e,t)),gn.length===1&&!co&&c0(l0)};function h0(e,t){this.fun=e,this.array=t}h0.prototype.run=function(){this.fun.apply(null,this.array)};nt.title="browser";nt.browser=!0;nt.env={};nt.argv=[];nt.version="";nt.versions={};function yn(){}nt.on=yn;nt.addListener=yn;nt.once=yn;nt.off=yn;nt.removeListener=yn;nt.removeAllListeners=yn;nt.emit=yn;nt.prependListener=yn;nt.prependOnceListener=yn;nt.listeners=function(e){return[]};nt.binding=function(e){throw new Error("process.binding is not supported")};nt.cwd=function(){return"/"};nt.chdir=function(e){throw new Error("process.chdir is not supported")};nt.umask=function(){return 0}});var m0=B(Qa=>{"use strict";p();Qa.byteLength=xI;Qa.toByteArray=AI;Qa.fromByteArray=TI;var $r=[],br=[],EI=typeof Uint8Array<"u"?Uint8Array:Array,dl="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(Ii=0,g0=dl.length;Ii<g0;++Ii)$r[Ii]=dl[Ii],br[dl.charCodeAt(Ii)]=Ii;var Ii,g0;br[45]=62;br[95]=63;function y0(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");r===-1&&(r=t);var n=r===t?0:4-r%4;return[r,n]}function xI(e){var t=y0(e),r=t[0],n=t[1];return(r+n)*3/4-n}function II(e,t,r){return(t+r)*3/4-r}function AI(e){var t,r=y0(e),n=r[0],i=r[1],o=new EI(II(e,n,i)),s=0,a=i>0?n-4:n,f;for(f=0;f<a;f+=4)t=br[e.charCodeAt(f)]<<18|br[e.charCodeAt(f+1)]<<12|br[e.charCodeAt(f+2)]<<6|br[e.charCodeAt(f+3)],o[s++]=t>>16&255,o[s++]=t>>8&255,o[s++]=t&255;return i===2&&(t=br[e.charCodeAt(f)]<<2|br[e.charCodeAt(f+1)]>>4,o[s++]=t&255),i===1&&(t=br[e.charCodeAt(f)]<<10|br[e.charCodeAt(f+1)]<<4|br[e.charCodeAt(f+2)]>>2,o[s++]=t>>8&255,o[s++]=t&255),o}function OI(e){return $r[e>>18&63]+$r[e>>12&63]+$r[e>>6&63]+$r[e&63]}function RI(e,t,r){for(var n,i=[],o=t;o<r;o+=3)n=(e[o]<<16&16711680)+(e[o+1]<<8&65280)+(e[o+2]&255),i.push(OI(n));return i.join("")}function TI(e){for(var t,r=e.length,n=r%3,i=[],o=16383,s=0,a=r-n;s<a;s+=o)i.push(RI(e,s,s+o>a?a:s+o));return n===1?(t=e[r-1],i.push($r[t>>2]+$r[t<<4&63]+"==")):n===2&&(t=(e[r-2]<<8)+e[r-1],i.push($r[t>>10]+$r[t>>4&63]+$r[t<<2&63]+"=")),i.join("")}});var v0=B(pl=>{p();pl.read=function(e,t,r,n,i){var o,s,a=i*8-n-1,f=(1<<a)-1,l=f>>1,y=-7,g=r?i-1:0,v=r?-1:1,E=e[t+g];for(g+=v,o=E&(1<<-y)-1,E>>=-y,y+=a;y>0;o=o*256+e[t+g],g+=v,y-=8);for(s=o&(1<<-y)-1,o>>=-y,y+=n;y>0;s=s*256+e[t+g],g+=v,y-=8);if(o===0)o=1-l;else{if(o===f)return s?NaN:(E?-1:1)*(1/0);s=s+Math.pow(2,n),o=o-l}return(E?-1:1)*s*Math.pow(2,o-n)};pl.write=function(e,t,r,n,i,o){var s,a,f,l=o*8-i-1,y=(1<<l)-1,g=y>>1,v=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,E=n?0:o-1,T=n?1:-1,M=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=y):(s=Math.floor(Math.log(t)/Math.LN2),t*(f=Math.pow(2,-s))<1&&(s--,f*=2),s+g>=1?t+=v/f:t+=v*Math.pow(2,1-g),t*f>=2&&(s++,f/=2),s+g>=y?(a=0,s=y):s+g>=1?(a=(t*f-1)*Math.pow(2,i),s=s+g):(a=t*Math.pow(2,g-1)*Math.pow(2,i),s=0));i>=8;e[r+E]=a&255,E+=T,a/=256,i-=8);for(s=s<<i|a,l+=i;l>0;e[r+E]=s&255,E+=T,s/=256,l-=8);e[r+E-T]|=M*128}});var Mt=B(go=>{"use strict";p();var gl=m0(),ho=v0(),b0=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;go.Buffer=j;go.SlowBuffer=CI;go.INSPECT_MAX_BYTES=50;var eu=2147483647;go.kMaxLength=eu;j.TYPED_ARRAY_SUPPORT=PI();!j.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 PI(){try{let e=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(e,t),e.foo()===42}catch{return!1}}Object.defineProperty(j.prototype,"parent",{enumerable:!0,get:function(){if(j.isBuffer(this))return this.buffer}});Object.defineProperty(j.prototype,"offset",{enumerable:!0,get:function(){if(j.isBuffer(this))return this.byteOffset}});function mn(e){if(e>eu)throw new RangeError('The value "'+e+'" is invalid for option "size"');let t=new Uint8Array(e);return Object.setPrototypeOf(t,j.prototype),t}function j(e,t,r){if(typeof e=="number"){if(typeof t=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return bl(e)}return E0(e,t,r)}j.poolSize=8192;function E0(e,t,r){if(typeof e=="string")return NI(e,t);if(ArrayBuffer.isView(e))return MI(e);if(e==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(Zr(e,ArrayBuffer)||e&&Zr(e.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(Zr(e,SharedArrayBuffer)||e&&Zr(e.buffer,SharedArrayBuffer)))return ml(e,t,r);if(typeof e=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let n=e.valueOf&&e.valueOf();if(n!=null&&n!==e)return j.from(n,t,r);let i=kI(e);if(i)return i;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof e[Symbol.toPrimitive]=="function")return j.from(e[Symbol.toPrimitive]("string"),t,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}j.from=function(e,t,r){return E0(e,t,r)};Object.setPrototypeOf(j.prototype,Uint8Array.prototype);Object.setPrototypeOf(j,Uint8Array);function x0(e){if(typeof e!="number")throw new TypeError('"size" argument must be of type number');if(e<0)throw new RangeError('The value "'+e+'" is invalid for option "size"')}function BI(e,t,r){return x0(e),e<=0?mn(e):t!==void 0?typeof r=="string"?mn(e).fill(t,r):mn(e).fill(t):mn(e)}j.alloc=function(e,t,r){return BI(e,t,r)};function bl(e){return x0(e),mn(e<0?0:_l(e)|0)}j.allocUnsafe=function(e){return bl(e)};j.allocUnsafeSlow=function(e){return bl(e)};function NI(e,t){if((typeof t!="string"||t==="")&&(t="utf8"),!j.isEncoding(t))throw new TypeError("Unknown encoding: "+t);let r=I0(e,t)|0,n=mn(r),i=n.write(e,t);return i!==r&&(n=n.slice(0,i)),n}function yl(e){let t=e.length<0?0:_l(e.length)|0,r=mn(t);for(let n=0;n<t;n+=1)r[n]=e[n]&255;return r}function MI(e){if(Zr(e,Uint8Array)){let t=new Uint8Array(e);return ml(t.buffer,t.byteOffset,t.byteLength)}return yl(e)}function ml(e,t,r){if(t<0||e.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(e.byteLength<t+(r||0))throw new RangeError('"length" is outside of buffer bounds');let n;return t===void 0&&r===void 0?n=new Uint8Array(e):r===void 0?n=new Uint8Array(e,t):n=new Uint8Array(e,t,r),Object.setPrototypeOf(n,j.prototype),n}function kI(e){if(j.isBuffer(e)){let t=_l(e.length)|0,r=mn(t);return r.length===0||e.copy(r,0,0,t),r}if(e.length!==void 0)return typeof e.length!="number"||wl(e.length)?mn(0):yl(e);if(e.type==="Buffer"&&Array.isArray(e.data))return yl(e.data)}function _l(e){if(e>=eu)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+eu.toString(16)+" bytes");return e|0}function CI(e){return+e!=e&&(e=0),j.alloc(+e)}j.isBuffer=function(t){return t!=null&&t._isBuffer===!0&&t!==j.prototype};j.compare=function(t,r){if(Zr(t,Uint8Array)&&(t=j.from(t,t.offset,t.byteLength)),Zr(r,Uint8Array)&&(r=j.from(r,r.offset,r.byteLength)),!j.isBuffer(t)||!j.isBuffer(r))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===r)return 0;let n=t.length,i=r.length;for(let o=0,s=Math.min(n,i);o<s;++o)if(t[o]!==r[o]){n=t[o],i=r[o];break}return n<i?-1:i<n?1:0};j.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}};j.concat=function(t,r){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(t.length===0)return j.alloc(0);let n;if(r===void 0)for(r=0,n=0;n<t.length;++n)r+=t[n].length;let i=j.allocUnsafe(r),o=0;for(n=0;n<t.length;++n){let s=t[n];if(Zr(s,Uint8Array))o+s.length>i.length?(j.isBuffer(s)||(s=j.from(s)),s.copy(i,o)):Uint8Array.prototype.set.call(i,s,o);else if(j.isBuffer(s))s.copy(i,o);else throw new TypeError('"list" argument must be an Array of Buffers');o+=s.length}return i};function I0(e,t){if(j.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||Zr(e,ArrayBuffer))return e.byteLength;if(typeof e!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);let r=e.length,n=arguments.length>2&&arguments[2]===!0;if(!n&&r===0)return 0;let i=!1;for(;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return vl(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return k0(e).length;default:if(i)return n?-1:vl(e).length;t=(""+t).toLowerCase(),i=!0}}j.byteLength=I0;function LI(e,t,r){let n=!1;if((t===void 0||t<0)&&(t=0),t>this.length||((r===void 0||r>this.length)&&(r=this.length),r<=0)||(r>>>=0,t>>>=0,r<=t))return"";for(e||(e="utf8");;)switch(e){case"hex":return WI(this,t,r);case"utf8":case"utf-8":return O0(this,t,r);case"ascii":return GI(this,t,r);case"latin1":case"binary":return VI(this,t,r);case"base64":return jI(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return zI(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}j.prototype._isBuffer=!0;function Ai(e,t,r){let n=e[t];e[t]=e[r],e[r]=n}j.prototype.swap16=function(){let t=this.length;if(t%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let r=0;r<t;r+=2)Ai(this,r,r+1);return this};j.prototype.swap32=function(){let t=this.length;if(t%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let r=0;r<t;r+=4)Ai(this,r,r+3),Ai(this,r+1,r+2);return this};j.prototype.swap64=function(){let t=this.length;if(t%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let r=0;r<t;r+=8)Ai(this,r,r+7),Ai(this,r+1,r+6),Ai(this,r+2,r+5),Ai(this,r+3,r+4);return this};j.prototype.toString=function(){let t=this.length;return t===0?"":arguments.length===0?O0(this,0,t):LI.apply(this,arguments)};j.prototype.toLocaleString=j.prototype.toString;j.prototype.equals=function(t){if(!j.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t?!0:j.compare(this,t)===0};j.prototype.inspect=function(){let t="",r=go.INSPECT_MAX_BYTES;return t=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(t+=" ... "),"<Buffer "+t+">"};b0&&(j.prototype[b0]=j.prototype.inspect);j.prototype.compare=function(t,r,n,i,o){if(Zr(t,Uint8Array)&&(t=j.from(t,t.offset,t.byteLength)),!j.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(r===void 0&&(r=0),n===void 0&&(n=t?t.length:0),i===void 0&&(i=0),o===void 0&&(o=this.length),r<0||n>t.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===t)return 0;let s=o-i,a=n-r,f=Math.min(s,a),l=this.slice(i,o),y=t.slice(r,n);for(let g=0;g<f;++g)if(l[g]!==y[g]){s=l[g],a=y[g];break}return s<a?-1:a<s?1:0};function A0(e,t,r,n,i){if(e.length===0)return-1;if(typeof r=="string"?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,wl(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0)if(i)r=0;else return-1;if(typeof t=="string"&&(t=j.from(t,n)),j.isBuffer(t))return t.length===0?-1:_0(e,t,r,n,i);if(typeof t=="number")return t=t&255,typeof Uint8Array.prototype.indexOf=="function"?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):_0(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function _0(e,t,r,n,i){let o=1,s=e.length,a=t.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(e.length<2||t.length<2)return-1;o=2,s/=2,a/=2,r/=2}function f(y,g){return o===1?y[g]:y.readUInt16BE(g*o)}let l;if(i){let y=-1;for(l=r;l<s;l++)if(f(e,l)===f(t,y===-1?0:l-y)){if(y===-1&&(y=l),l-y+1===a)return y*o}else y!==-1&&(l-=l-y),y=-1}else for(r+a>s&&(r=s-a),l=r;l>=0;l--){let y=!0;for(let g=0;g<a;g++)if(f(e,l+g)!==f(t,g)){y=!1;break}if(y)return l}return-1}j.prototype.includes=function(t,r,n){return this.indexOf(t,r,n)!==-1};j.prototype.indexOf=function(t,r,n){return A0(this,t,r,n,!0)};j.prototype.lastIndexOf=function(t,r,n){return A0(this,t,r,n,!1)};function DI(e,t,r,n){r=Number(r)||0;let i=e.length-r;n?(n=Number(n),n>i&&(n=i)):n=i;let o=t.length;n>o/2&&(n=o/2);let s;for(s=0;s<n;++s){let a=parseInt(t.substr(s*2,2),16);if(wl(a))return s;e[r+s]=a}return s}function UI(e,t,r,n){return tu(vl(t,e.length-r),e,r,n)}function FI(e,t,r,n){return tu(XI(t),e,r,n)}function qI(e,t,r,n){return tu(k0(t),e,r,n)}function HI(e,t,r,n){return tu(JI(t,e.length-r),e,r,n)}j.prototype.write=function(t,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),t.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 DI(this,t,r,n);case"utf8":case"utf-8":return UI(this,t,r,n);case"ascii":case"latin1":case"binary":return FI(this,t,r,n);case"base64":return qI(this,t,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return HI(this,t,r,n);default:if(s)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),s=!0}};j.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function jI(e,t,r){return t===0&&r===e.length?gl.fromByteArray(e):gl.fromByteArray(e.slice(t,r))}function O0(e,t,r){r=Math.min(e.length,r);let n=[],i=t;for(;i<r;){let o=e[i],s=null,a=o>239?4:o>223?3:o>191?2:1;if(i+a<=r){let f,l,y,g;switch(a){case 1:o<128&&(s=o);break;case 2:f=e[i+1],(f&192)===128&&(g=(o&31)<<6|f&63,g>127&&(s=g));break;case 3:f=e[i+1],l=e[i+2],(f&192)===128&&(l&192)===128&&(g=(o&15)<<12|(f&63)<<6|l&63,g>2047&&(g<55296||g>57343)&&(s=g));break;case 4:f=e[i+1],l=e[i+2],y=e[i+3],(f&192)===128&&(l&192)===128&&(y&192)===128&&(g=(o&15)<<18|(f&63)<<12|(l&63)<<6|y&63,g>65535&&g<1114112&&(s=g))}}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 KI(n)}var S0=4096;function KI(e){let t=e.length;if(t<=S0)return String.fromCharCode.apply(String,e);let r="",n=0;for(;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=S0));return r}function GI(e,t,r){let n="";r=Math.min(e.length,r);for(let i=t;i<r;++i)n+=String.fromCharCode(e[i]&127);return n}function VI(e,t,r){let n="";r=Math.min(e.length,r);for(let i=t;i<r;++i)n+=String.fromCharCode(e[i]);return n}function WI(e,t,r){let n=e.length;(!t||t<0)&&(t=0),(!r||r<0||r>n)&&(r=n);let i="";for(let o=t;o<r;++o)i+=QI[e[o]];return i}function zI(e,t,r){let n=e.slice(t,r),i="";for(let o=0;o<n.length-1;o+=2)i+=String.fromCharCode(n[o]+n[o+1]*256);return i}j.prototype.slice=function(t,r){let n=this.length;t=~~t,r=r===void 0?n:~~r,t<0?(t+=n,t<0&&(t=0)):t>n&&(t=n),r<0?(r+=n,r<0&&(r=0)):r>n&&(r=n),r<t&&(r=t);let i=this.subarray(t,r);return Object.setPrototypeOf(i,j.prototype),i};function qt(e,t,r){if(e%1!==0||e<0)throw new RangeError("offset is not uint");if(e+t>r)throw new RangeError("Trying to access beyond buffer length")}j.prototype.readUintLE=j.prototype.readUIntLE=function(t,r,n){t=t>>>0,r=r>>>0,n||qt(t,r,this.length);let i=this[t],o=1,s=0;for(;++s<r&&(o*=256);)i+=this[t+s]*o;return i};j.prototype.readUintBE=j.prototype.readUIntBE=function(t,r,n){t=t>>>0,r=r>>>0,n||qt(t,r,this.length);let i=this[t+--r],o=1;for(;r>0&&(o*=256);)i+=this[t+--r]*o;return i};j.prototype.readUint8=j.prototype.readUInt8=function(t,r){return t=t>>>0,r||qt(t,1,this.length),this[t]};j.prototype.readUint16LE=j.prototype.readUInt16LE=function(t,r){return t=t>>>0,r||qt(t,2,this.length),this[t]|this[t+1]<<8};j.prototype.readUint16BE=j.prototype.readUInt16BE=function(t,r){return t=t>>>0,r||qt(t,2,this.length),this[t]<<8|this[t+1]};j.prototype.readUint32LE=j.prototype.readUInt32LE=function(t,r){return t=t>>>0,r||qt(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+this[t+3]*16777216};j.prototype.readUint32BE=j.prototype.readUInt32BE=function(t,r){return t=t>>>0,r||qt(t,4,this.length),this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])};j.prototype.readBigUInt64LE=Gn(function(t){t=t>>>0,po(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&ms(t,this.length-8);let i=r+this[++t]*2**8+this[++t]*2**16+this[++t]*2**24,o=this[++t]+this[++t]*2**8+this[++t]*2**16+n*2**24;return BigInt(i)+(BigInt(o)<<BigInt(32))});j.prototype.readBigUInt64BE=Gn(function(t){t=t>>>0,po(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&ms(t,this.length-8);let i=r*2**24+this[++t]*2**16+this[++t]*2**8+this[++t],o=this[++t]*2**24+this[++t]*2**16+this[++t]*2**8+n;return(BigInt(i)<<BigInt(32))+BigInt(o)});j.prototype.readIntLE=function(t,r,n){t=t>>>0,r=r>>>0,n||qt(t,r,this.length);let i=this[t],o=1,s=0;for(;++s<r&&(o*=256);)i+=this[t+s]*o;return o*=128,i>=o&&(i-=Math.pow(2,8*r)),i};j.prototype.readIntBE=function(t,r,n){t=t>>>0,r=r>>>0,n||qt(t,r,this.length);let i=r,o=1,s=this[t+--i];for(;i>0&&(o*=256);)s+=this[t+--i]*o;return o*=128,s>=o&&(s-=Math.pow(2,8*r)),s};j.prototype.readInt8=function(t,r){return t=t>>>0,r||qt(t,1,this.length),this[t]&128?(255-this[t]+1)*-1:this[t]};j.prototype.readInt16LE=function(t,r){t=t>>>0,r||qt(t,2,this.length);let n=this[t]|this[t+1]<<8;return n&32768?n|4294901760:n};j.prototype.readInt16BE=function(t,r){t=t>>>0,r||qt(t,2,this.length);let n=this[t+1]|this[t]<<8;return n&32768?n|4294901760:n};j.prototype.readInt32LE=function(t,r){return t=t>>>0,r||qt(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24};j.prototype.readInt32BE=function(t,r){return t=t>>>0,r||qt(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]};j.prototype.readBigInt64LE=Gn(function(t){t=t>>>0,po(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&ms(t,this.length-8);let i=this[t+4]+this[t+5]*2**8+this[t+6]*2**16+(n<<24);return(BigInt(i)<<BigInt(32))+BigInt(r+this[++t]*2**8+this[++t]*2**16+this[++t]*2**24)});j.prototype.readBigInt64BE=Gn(function(t){t=t>>>0,po(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&ms(t,this.length-8);let i=(r<<24)+this[++t]*2**16+this[++t]*2**8+this[++t];return(BigInt(i)<<BigInt(32))+BigInt(this[++t]*2**24+this[++t]*2**16+this[++t]*2**8+n)});j.prototype.readFloatLE=function(t,r){return t=t>>>0,r||qt(t,4,this.length),ho.read(this,t,!0,23,4)};j.prototype.readFloatBE=function(t,r){return t=t>>>0,r||qt(t,4,this.length),ho.read(this,t,!1,23,4)};j.prototype.readDoubleLE=function(t,r){return t=t>>>0,r||qt(t,8,this.length),ho.read(this,t,!0,52,8)};j.prototype.readDoubleBE=function(t,r){return t=t>>>0,r||qt(t,8,this.length),ho.read(this,t,!1,52,8)};function ar(e,t,r,n,i,o){if(!j.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<o)throw new RangeError('"value" argument is out of bounds');if(r+n>e.length)throw new RangeError("Index out of range")}j.prototype.writeUintLE=j.prototype.writeUIntLE=function(t,r,n,i){if(t=+t,r=r>>>0,n=n>>>0,!i){let a=Math.pow(2,8*n)-1;ar(this,t,r,n,a,0)}let o=1,s=0;for(this[r]=t&255;++s<n&&(o*=256);)this[r+s]=t/o&255;return r+n};j.prototype.writeUintBE=j.prototype.writeUIntBE=function(t,r,n,i){if(t=+t,r=r>>>0,n=n>>>0,!i){let a=Math.pow(2,8*n)-1;ar(this,t,r,n,a,0)}let o=n-1,s=1;for(this[r+o]=t&255;--o>=0&&(s*=256);)this[r+o]=t/s&255;return r+n};j.prototype.writeUint8=j.prototype.writeUInt8=function(t,r,n){return t=+t,r=r>>>0,n||ar(this,t,r,1,255,0),this[r]=t&255,r+1};j.prototype.writeUint16LE=j.prototype.writeUInt16LE=function(t,r,n){return t=+t,r=r>>>0,n||ar(this,t,r,2,65535,0),this[r]=t&255,this[r+1]=t>>>8,r+2};j.prototype.writeUint16BE=j.prototype.writeUInt16BE=function(t,r,n){return t=+t,r=r>>>0,n||ar(this,t,r,2,65535,0),this[r]=t>>>8,this[r+1]=t&255,r+2};j.prototype.writeUint32LE=j.prototype.writeUInt32LE=function(t,r,n){return t=+t,r=r>>>0,n||ar(this,t,r,4,4294967295,0),this[r+3]=t>>>24,this[r+2]=t>>>16,this[r+1]=t>>>8,this[r]=t&255,r+4};j.prototype.writeUint32BE=j.prototype.writeUInt32BE=function(t,r,n){return t=+t,r=r>>>0,n||ar(this,t,r,4,4294967295,0),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=t&255,r+4};function R0(e,t,r,n,i){M0(t,n,i,e,r,7);let o=Number(t&BigInt(4294967295));e[r++]=o,o=o>>8,e[r++]=o,o=o>>8,e[r++]=o,o=o>>8,e[r++]=o;let s=Number(t>>BigInt(32)&BigInt(4294967295));return e[r++]=s,s=s>>8,e[r++]=s,s=s>>8,e[r++]=s,s=s>>8,e[r++]=s,r}function T0(e,t,r,n,i){M0(t,n,i,e,r,7);let o=Number(t&BigInt(4294967295));e[r+7]=o,o=o>>8,e[r+6]=o,o=o>>8,e[r+5]=o,o=o>>8,e[r+4]=o;let s=Number(t>>BigInt(32)&BigInt(4294967295));return e[r+3]=s,s=s>>8,e[r+2]=s,s=s>>8,e[r+1]=s,s=s>>8,e[r]=s,r+8}j.prototype.writeBigUInt64LE=Gn(function(t,r=0){return R0(this,t,r,BigInt(0),BigInt("0xffffffffffffffff"))});j.prototype.writeBigUInt64BE=Gn(function(t,r=0){return T0(this,t,r,BigInt(0),BigInt("0xffffffffffffffff"))});j.prototype.writeIntLE=function(t,r,n,i){if(t=+t,r=r>>>0,!i){let f=Math.pow(2,8*n-1);ar(this,t,r,n,f-1,-f)}let o=0,s=1,a=0;for(this[r]=t&255;++o<n&&(s*=256);)t<0&&a===0&&this[r+o-1]!==0&&(a=1),this[r+o]=(t/s>>0)-a&255;return r+n};j.prototype.writeIntBE=function(t,r,n,i){if(t=+t,r=r>>>0,!i){let f=Math.pow(2,8*n-1);ar(this,t,r,n,f-1,-f)}let o=n-1,s=1,a=0;for(this[r+o]=t&255;--o>=0&&(s*=256);)t<0&&a===0&&this[r+o+1]!==0&&(a=1),this[r+o]=(t/s>>0)-a&255;return r+n};j.prototype.writeInt8=function(t,r,n){return t=+t,r=r>>>0,n||ar(this,t,r,1,127,-128),t<0&&(t=255+t+1),this[r]=t&255,r+1};j.prototype.writeInt16LE=function(t,r,n){return t=+t,r=r>>>0,n||ar(this,t,r,2,32767,-32768),this[r]=t&255,this[r+1]=t>>>8,r+2};j.prototype.writeInt16BE=function(t,r,n){return t=+t,r=r>>>0,n||ar(this,t,r,2,32767,-32768),this[r]=t>>>8,this[r+1]=t&255,r+2};j.prototype.writeInt32LE=function(t,r,n){return t=+t,r=r>>>0,n||ar(this,t,r,4,2147483647,-2147483648),this[r]=t&255,this[r+1]=t>>>8,this[r+2]=t>>>16,this[r+3]=t>>>24,r+4};j.prototype.writeInt32BE=function(t,r,n){return t=+t,r=r>>>0,n||ar(this,t,r,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=t&255,r+4};j.prototype.writeBigInt64LE=Gn(function(t,r=0){return R0(this,t,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});j.prototype.writeBigInt64BE=Gn(function(t,r=0){return T0(this,t,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function P0(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function B0(e,t,r,n,i){return t=+t,r=r>>>0,i||P0(e,t,r,4,34028234663852886e22,-34028234663852886e22),ho.write(e,t,r,n,23,4),r+4}j.prototype.writeFloatLE=function(t,r,n){return B0(this,t,r,!0,n)};j.prototype.writeFloatBE=function(t,r,n){return B0(this,t,r,!1,n)};function N0(e,t,r,n,i){return t=+t,r=r>>>0,i||P0(e,t,r,8,17976931348623157e292,-17976931348623157e292),ho.write(e,t,r,n,52,8),r+8}j.prototype.writeDoubleLE=function(t,r,n){return N0(this,t,r,!0,n)};j.prototype.writeDoubleBE=function(t,r,n){return N0(this,t,r,!1,n)};j.prototype.copy=function(t,r,n,i){if(!j.isBuffer(t))throw new TypeError("argument should be a Buffer");if(n||(n=0),!i&&i!==0&&(i=this.length),r>=t.length&&(r=t.length),r||(r=0),i>0&&i<n&&(i=n),i===n||t.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),t.length-r<i-n&&(i=t.length-r+n);let o=i-n;return this===t&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(r,n,i):Uint8Array.prototype.set.call(t,this.subarray(n,i),r),o};j.prototype.fill=function(t,r,n,i){if(typeof t=="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"&&!j.isEncoding(i))throw new TypeError("Unknown encoding: "+i);if(t.length===1){let s=t.charCodeAt(0);(i==="utf8"&&s<128||i==="latin1")&&(t=s)}}else typeof t=="number"?t=t&255:typeof t=="boolean"&&(t=Number(t));if(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,t||(t=0);let o;if(typeof t=="number")for(o=r;o<n;++o)this[o]=t;else{let s=j.isBuffer(t)?t:j.from(t,i),a=s.length;if(a===0)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(o=0;o<n-r;++o)this[o+r]=s[o%a]}return this};var lo={};function Sl(e,t,r){lo[e]=class extends r{constructor(){super(),Object.defineProperty(this,"message",{value:t.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${e}]`,this.stack,delete this.name}get code(){return e}set code(i){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:i,writable:!0})}toString(){return`${this.name} [${e}]: ${this.message}`}}}Sl("ERR_BUFFER_OUT_OF_BOUNDS",function(e){return e?`${e} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);Sl("ERR_INVALID_ARG_TYPE",function(e,t){return`The "${e}" argument must be of type number. Received type ${typeof t}`},TypeError);Sl("ERR_OUT_OF_RANGE",function(e,t,r){let n=`The value of "${e}" is out of range.`,i=r;return Number.isInteger(r)&&Math.abs(r)>2**32?i=w0(String(r)):typeof r=="bigint"&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=w0(i)),i+="n"),n+=` It must be ${t}. Received ${i}`,n},RangeError);function w0(e){let t="",r=e.length,n=e[0]==="-"?1:0;for(;r>=n+4;r-=3)t=`_${e.slice(r-3,r)}${t}`;return`${e.slice(0,r)}${t}`}function YI(e,t,r){po(t,"offset"),(e[t]===void 0||e[t+r]===void 0)&&ms(t,e.length-(r+1))}function M0(e,t,r,n,i,o){if(e>r||e<t){let s=typeof t=="bigint"?"n":"",a;throw o>3?t===0||t===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=`>= ${t}${s} and <= ${r}${s}`,new lo.ERR_OUT_OF_RANGE("value",a,e)}YI(n,i,o)}function po(e,t){if(typeof e!="number")throw new lo.ERR_INVALID_ARG_TYPE(t,"number",e)}function ms(e,t,r){throw Math.floor(e)!==e?(po(e,r),new lo.ERR_OUT_OF_RANGE(r||"offset","an integer",e)):t<0?new lo.ERR_BUFFER_OUT_OF_BOUNDS:new lo.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${t}`,e)}var $I=/[^+/0-9A-Za-z-_]/g;function ZI(e){if(e=e.split("=")[0],e=e.trim().replace($I,""),e.length<2)return"";for(;e.length%4!==0;)e=e+"=";return e}function vl(e,t){t=t||1/0;let r,n=e.length,i=null,o=[];for(let s=0;s<n;++s){if(r=e.charCodeAt(s),r>55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}else if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=(i-55296<<10|r-56320)+65536}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,r&63|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<1114112){if((t-=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 XI(e){let t=[];for(let r=0;r<e.length;++r)t.push(e.charCodeAt(r)&255);return t}function JI(e,t){let r,n,i,o=[];for(let s=0;s<e.length&&!((t-=2)<0);++s)r=e.charCodeAt(s),n=r>>8,i=r%256,o.push(i),o.push(n);return o}function k0(e){return gl.toByteArray(ZI(e))}function tu(e,t,r,n){let i;for(i=0;i<n&&!(i+r>=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function Zr(e,t){return e instanceof t||e!=null&&e.constructor!=null&&e.constructor.name!=null&&e.constructor.name===t.name}function wl(e){return e!==e}var QI=(function(){let e="0123456789abcdef",t=new Array(256);for(let r=0;r<16;++r){let n=r*16;for(let i=0;i<16;++i)t[n+i]=e[r]+e[i]}return t})();function Gn(e){return typeof BigInt>"u"?eA:e}function eA(){throw new Error("BigInt not supported")}});var x,d,p=Yt(()=>{x=f0(p0()),d=f0(Mt())});var L0=B((C0,El)=>{p();(function(e,t){"use strict";function r(I,u){if(!I)throw new Error(u||"Assertion failed")}function n(I,u){I.super_=u;var h=function(){};h.prototype=u.prototype,I.prototype=new h,I.prototype.constructor=I}function i(I,u,h){if(i.isBN(I))return I;this.negative=0,this.words=null,this.length=0,this.red=null,I!==null&&((u==="le"||u==="be")&&(h=u,u=10),this._init(I||0,u||10,h||"be"))}typeof e=="object"?e.exports=i:t.BN=i,i.BN=i,i.wordSize=26;var o;try{typeof window<"u"&&typeof window.Buffer<"u"?o=window.Buffer:o=Mt().Buffer}catch{}i.isBN=function(u){return u instanceof i?!0:u!==null&&typeof u=="object"&&u.constructor.wordSize===i.wordSize&&Array.isArray(u.words)},i.max=function(u,h){return u.cmp(h)>0?u:h},i.min=function(u,h){return u.cmp(h)<0?u:h},i.prototype._init=function(u,h,m){if(typeof u=="number")return this._initNumber(u,h,m);if(typeof u=="object")return this._initArray(u,h,m);h==="hex"&&(h=16),r(h===(h|0)&&h>=2&&h<=36),u=u.toString().replace(/\s+/g,"");var S=0;u[0]==="-"&&(S++,this.negative=1),S<u.length&&(h===16?this._parseHex(u,S,m):(this._parseBase(u,h,S),m==="le"&&this._initArray(this.toArray(),h,m)))},i.prototype._initNumber=function(u,h,m){u<0&&(this.negative=1,u=-u),u<67108864?(this.words=[u&67108863],this.length=1):u<4503599627370496?(this.words=[u&67108863,u/67108864&67108863],this.length=2):(r(u<9007199254740992),this.words=[u&67108863,u/67108864&67108863,1],this.length=3),m==="le"&&this._initArray(this.toArray(),h,m)},i.prototype._initArray=function(u,h,m){if(r(typeof u.length=="number"),u.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(u.length/3),this.words=new Array(this.length);for(var S=0;S<this.length;S++)this.words[S]=0;var w,R,A=0;if(m==="be")for(S=u.length-1,w=0;S>=0;S-=3)R=u[S]|u[S-1]<<8|u[S-2]<<16,this.words[w]|=R<<A&67108863,this.words[w+1]=R>>>26-A&67108863,A+=24,A>=26&&(A-=26,w++);else if(m==="le")for(S=0,w=0;S<u.length;S+=3)R=u[S]|u[S+1]<<8|u[S+2]<<16,this.words[w]|=R<<A&67108863,this.words[w+1]=R>>>26-A&67108863,A+=24,A>=26&&(A-=26,w++);return this.strip()};function s(I,u){var h=I.charCodeAt(u);return h>=65&&h<=70?h-55:h>=97&&h<=102?h-87:h-48&15}function a(I,u,h){var m=s(I,h);return h-1>=u&&(m|=s(I,h-1)<<4),m}i.prototype._parseHex=function(u,h,m){this.length=Math.ceil((u.length-h)/6),this.words=new Array(this.length);for(var S=0;S<this.length;S++)this.words[S]=0;var w=0,R=0,A;if(m==="be")for(S=u.length-1;S>=h;S-=2)A=a(u,h,S)<<w,this.words[R]|=A&67108863,w>=18?(w-=18,R+=1,this.words[R]|=A>>>26):w+=8;else{var _=u.length-h;for(S=_%2===0?h+1:h;S<u.length;S+=2)A=a(u,h,S)<<w,this.words[R]|=A&67108863,w>=18?(w-=18,R+=1,this.words[R]|=A>>>26):w+=8}this.strip()};function f(I,u,h,m){for(var S=0,w=Math.min(I.length,h),R=u;R<w;R++){var A=I.charCodeAt(R)-48;S*=m,A>=49?S+=A-49+10:A>=17?S+=A-17+10:S+=A}return S}i.prototype._parseBase=function(u,h,m){this.words=[0],this.length=1;for(var S=0,w=1;w<=67108863;w*=h)S++;S--,w=w/h|0;for(var R=u.length-m,A=R%S,_=Math.min(R,R-A)+m,c=0,b=m;b<_;b+=S)c=f(u,b,b+S,h),this.imuln(w),this.words[0]+c<67108864?this.words[0]+=c:this._iaddn(c);if(A!==0){var k=1;for(c=f(u,b,u.length,h),b=0;b<A;b++)k*=h;this.imuln(k),this.words[0]+c<67108864?this.words[0]+=c:this._iaddn(c)}this.strip()},i.prototype.copy=function(u){u.words=new Array(this.length);for(var h=0;h<this.length;h++)u.words[h]=this.words[h];u.length=this.length,u.negative=this.negative,u.red=this.red},i.prototype.clone=function(){var u=new i(null);return this.copy(u),u},i.prototype._expand=function(u){for(;this.length<u;)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 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"],y=[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],g=[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(u,h){u=u||10,h=h|0||1;var m;if(u===16||u==="hex"){m="";for(var S=0,w=0,R=0;R<this.length;R++){var A=this.words[R],_=((A<<S|w)&16777215).toString(16);w=A>>>24-S&16777215,S+=2,S>=26&&(S-=26,R--),w!==0||R!==this.length-1?m=l[6-_.length]+_+m:m=_+m}for(w!==0&&(m=w.toString(16)+m);m.length%h!==0;)m="0"+m;return this.negative!==0&&(m="-"+m),m}if(u===(u|0)&&u>=2&&u<=36){var c=y[u],b=g[u];m="";var k=this.clone();for(k.negative=0;!k.isZero();){var U=k.modn(b).toString(u);k=k.idivn(b),k.isZero()?m=U+m:m=l[c-U.length]+U+m}for(this.isZero()&&(m="0"+m);m.length%h!==0;)m="0"+m;return this.negative!==0&&(m="-"+m),m}r(!1,"Base should be between 2 and 36")},i.prototype.toNumber=function(){var u=this.words[0];return this.length===2?u+=this.words[1]*67108864:this.length===3&&this.words[2]===1?u+=4503599627370496+this.words[1]*67108864:this.length>2&&r(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-u:u},i.prototype.toJSON=function(){return this.toString(16)},i.prototype.toBuffer=function(u,h){return r(typeof o<"u"),this.toArrayLike(o,u,h)},i.prototype.toArray=function(u,h){return this.toArrayLike(Array,u,h)},i.prototype.toArrayLike=function(u,h,m){var S=this.byteLength(),w=m||Math.max(1,S);r(S<=w,"byte array longer than desired length"),r(w>0,"Requested array length <= 0"),this.strip();var R=h==="le",A=new u(w),_,c,b=this.clone();if(R){for(c=0;!b.isZero();c++)_=b.andln(255),b.iushrn(8),A[c]=_;for(;c<w;c++)A[c]=0}else{for(c=0;c<w-S;c++)A[c]=0;for(c=0;!b.isZero();c++)_=b.andln(255),b.iushrn(8),A[w-c-1]=_}return A},Math.clz32?i.prototype._countBits=function(u){return 32-Math.clz32(u)}:i.prototype._countBits=function(u){var h=u,m=0;return h>=4096&&(m+=13,h>>>=13),h>=64&&(m+=7,h>>>=7),h>=8&&(m+=4,h>>>=4),h>=2&&(m+=2,h>>>=2),m+h},i.prototype._zeroBits=function(u){if(u===0)return 26;var h=u,m=0;return(h&8191)===0&&(m+=13,h>>>=13),(h&127)===0&&(m+=7,h>>>=7),(h&15)===0&&(m+=4,h>>>=4),(h&3)===0&&(m+=2,h>>>=2),(h&1)===0&&m++,m},i.prototype.bitLength=function(){var u=this.words[this.length-1],h=this._countBits(u);return(this.length-1)*26+h};function v(I){for(var u=new Array(I.bitLength()),h=0;h<u.length;h++){var m=h/26|0,S=h%26;u[h]=(I.words[m]&1<<S)>>>S}return u}i.prototype.zeroBits=function(){if(this.isZero())return 0;for(var u=0,h=0;h<this.length;h++){var m=this._zeroBits(this.words[h]);if(u+=m,m!==26)break}return u},i.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},i.prototype.toTwos=function(u){return this.negative!==0?this.abs().inotn(u).iaddn(1):this.clone()},i.prototype.fromTwos=function(u){return this.testn(u-1)?this.notn(u).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(u){for(;this.length<u.length;)this.words[this.length++]=0;for(var h=0;h<u.length;h++)this.words[h]=this.words[h]|u.words[h];return this.strip()},i.prototype.ior=function(u){return r((this.negative|u.negative)===0),this.iuor(u)},i.prototype.or=function(u){return this.length>u.length?this.clone().ior(u):u.clone().ior(this)},i.prototype.uor=function(u){return this.length>u.length?this.clone().iuor(u):u.clone().iuor(this)},i.prototype.iuand=function(u){var h;this.length>u.length?h=u:h=this;for(var m=0;m<h.length;m++)this.words[m]=this.words[m]&u.words[m];return this.length=h.length,this.strip()},i.prototype.iand=function(u){return r((this.negative|u.negative)===0),this.iuand(u)},i.prototype.and=function(u){return this.length>u.length?this.clone().iand(u):u.clone().iand(this)},i.prototype.uand=function(u){return this.length>u.length?this.clone().iuand(u):u.clone().iuand(this)},i.prototype.iuxor=function(u){var h,m;this.length>u.length?(h=this,m=u):(h=u,m=this);for(var S=0;S<m.length;S++)this.words[S]=h.words[S]^m.words[S];if(this!==h)for(;S<h.length;S++)this.words[S]=h.words[S];return this.length=h.length,this.strip()},i.prototype.ixor=function(u){return r((this.negative|u.negative)===0),this.iuxor(u)},i.prototype.xor=function(u){return this.length>u.length?this.clone().ixor(u):u.clone().ixor(this)},i.prototype.uxor=function(u){return this.length>u.length?this.clone().iuxor(u):u.clone().iuxor(this)},i.prototype.inotn=function(u){r(typeof u=="number"&&u>=0);var h=Math.ceil(u/26)|0,m=u%26;this._expand(h),m>0&&h--;for(var S=0;S<h;S++)this.words[S]=~this.words[S]&67108863;for(m>0&&(this.words[S]=~this.words[S]&67108863>>26-m,S++);S<this.length;S++)this.words[S]=0;return this.strip()},i.prototype.notn=function(u){return this.clone().inotn(u)},i.prototype.setn=function(u,h){r(typeof u=="number"&&u>=0);var m=u/26|0,S=u%26;return this._expand(m+1),h?this.words[m]=this.words[m]|1<<S:this.words[m]=this.words[m]&~(1<<S),this.strip()},i.prototype.iadd=function(u){var h;if(this.negative!==0&&u.negative===0)return this.negative=0,h=this.isub(u),this.negative^=1,this._normSign();if(this.negative===0&&u.negative!==0)return u.negative=0,h=this.isub(u),u.negative=1,h._normSign();var m,S;this.length>u.length?(m=this,S=u):(m=u,S=this);for(var w=0,R=0;R<S.length;R++)h=(m.words[R]|0)+(S.words[R]|0)+w,this.words[R]=h&67108863,w=h>>>26;for(;w!==0&&R<m.length;R++)h=(m.words[R]|0)+w,this.words[R]=h&67108863,w=h>>>26;if(this.length=m.length,w!==0)this.words[this.length]=w,this.length++;else if(m!==this)for(;R<m.length;R++)this.words[R]=m.words[R];return this},i.prototype.add=function(u){var h;return u.negative!==0&&this.negative===0?(u.negative=0,h=this.sub(u),u.negative^=1,h):u.negative===0&&this.negative!==0?(this.negative=0,h=u.sub(this),this.negative=1,h):this.length>u.length?this.clone().iadd(u):u.clone().iadd(this)},i.prototype.isub=function(u){if(u.negative!==0){u.negative=0;var h=this.iadd(u);return u.negative=1,h._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(u),this.negative=1,this._normSign();var m=this.cmp(u);if(m===0)return this.negative=0,this.length=1,this.words[0]=0,this;var S,w;m>0?(S=this,w=u):(S=u,w=this);for(var R=0,A=0;A<w.length;A++)h=(S.words[A]|0)-(w.words[A]|0)+R,R=h>>26,this.words[A]=h&67108863;for(;R!==0&&A<S.length;A++)h=(S.words[A]|0)+R,R=h>>26,this.words[A]=h&67108863;if(R===0&&A<S.length&&S!==this)for(;A<S.length;A++)this.words[A]=S.words[A];return this.length=Math.max(this.length,A),S!==this&&(this.negative=1),this.strip()},i.prototype.sub=function(u){return this.clone().isub(u)};function E(I,u,h){h.negative=u.negative^I.negative;var m=I.length+u.length|0;h.length=m,m=m-1|0;var S=I.words[0]|0,w=u.words[0]|0,R=S*w,A=R&67108863,_=R/67108864|0;h.words[0]=A;for(var c=1;c<m;c++){for(var b=_>>>26,k=_&67108863,U=Math.min(c,u.length-1),K=Math.max(0,c-I.length+1);K<=U;K++){var W=c-K|0;S=I.words[W]|0,w=u.words[K]|0,R=S*w+k,b+=R/67108864|0,k=R&67108863}h.words[c]=k|0,_=b|0}return _!==0?h.words[c]=_|0:h.length--,h.strip()}var T=function(u,h,m){var S=u.words,w=h.words,R=m.words,A=0,_,c,b,k=S[0]|0,U=k&8191,K=k>>>13,W=S[1]|0,ee=W&8191,X=W>>>13,le=S[2]|0,ae=le&8191,O=le>>>13,C=S[3]|0,D=C&8191,H=C>>>13,Q=S[4]|0,J=Q&8191,re=Q>>>13,ue=S[5]|0,oe=ue&8191,se=ue>>>13,be=S[6]|0,we=be&8191,Re=be>>>13,he=S[7]|0,me=he&8191,_e=he>>>13,Ft=S[8]|0,Ue=Ft&8191,Ee=Ft>>>13,Ei=S[9]|0,je=Ei&8191,Qe=Ei>>>13,Ce=w[0]|0,ut=Ce&8191,ft=Ce>>>13,Qp=w[1]|0,ct=Qp&8191,lt=Qp>>>13,e0=w[2]|0,ht=e0&8191,dt=e0>>>13,t0=w[3]|0,pt=t0&8191,gt=t0>>>13,r0=w[4]|0,yt=r0&8191,mt=r0>>>13,n0=w[5]|0,vt=n0&8191,bt=n0>>>13,i0=w[6]|0,_t=i0&8191,St=i0>>>13,o0=w[7]|0,wt=o0&8191,Et=o0>>>13,s0=w[8]|0,xt=s0&8191,It=s0>>>13,a0=w[9]|0,At=a0&8191,Ot=a0>>>13;m.negative=u.negative^h.negative,m.length=19,_=Math.imul(U,ut),c=Math.imul(U,ft),c=c+Math.imul(K,ut)|0,b=Math.imul(K,ft);var Gc=(A+_|0)+((c&8191)<<13)|0;A=(b+(c>>>13)|0)+(Gc>>>26)|0,Gc&=67108863,_=Math.imul(ee,ut),c=Math.imul(ee,ft),c=c+Math.imul(X,ut)|0,b=Math.imul(X,ft),_=_+Math.imul(U,ct)|0,c=c+Math.imul(U,lt)|0,c=c+Math.imul(K,ct)|0,b=b+Math.imul(K,lt)|0;var Vc=(A+_|0)+((c&8191)<<13)|0;A=(b+(c>>>13)|0)+(Vc>>>26)|0,Vc&=67108863,_=Math.imul(ae,ut),c=Math.imul(ae,ft),c=c+Math.imul(O,ut)|0,b=Math.imul(O,ft),_=_+Math.imul(ee,ct)|0,c=c+Math.imul(ee,lt)|0,c=c+Math.imul(X,ct)|0,b=b+Math.imul(X,lt)|0,_=_+Math.imul(U,ht)|0,c=c+Math.imul(U,dt)|0,c=c+Math.imul(K,ht)|0,b=b+Math.imul(K,dt)|0;var Wc=(A+_|0)+((c&8191)<<13)|0;A=(b+(c>>>13)|0)+(Wc>>>26)|0,Wc&=67108863,_=Math.imul(D,ut),c=Math.imul(D,ft),c=c+Math.imul(H,ut)|0,b=Math.imul(H,ft),_=_+Math.imul(ae,ct)|0,c=c+Math.imul(ae,lt)|0,c=c+Math.imul(O,ct)|0,b=b+Math.imul(O,lt)|0,_=_+Math.imul(ee,ht)|0,c=c+Math.imul(ee,dt)|0,c=c+Math.imul(X,ht)|0,b=b+Math.imul(X,dt)|0,_=_+Math.imul(U,pt)|0,c=c+Math.imul(U,gt)|0,c=c+Math.imul(K,pt)|0,b=b+Math.imul(K,gt)|0;var zc=(A+_|0)+((c&8191)<<13)|0;A=(b+(c>>>13)|0)+(zc>>>26)|0,zc&=67108863,_=Math.imul(J,ut),c=Math.imul(J,ft),c=c+Math.imul(re,ut)|0,b=Math.imul(re,ft),_=_+Math.imul(D,ct)|0,c=c+Math.imul(D,lt)|0,c=c+Math.imul(H,ct)|0,b=b+Math.imul(H,lt)|0,_=_+Math.imul(ae,ht)|0,c=c+Math.imul(ae,dt)|0,c=c+Math.imul(O,ht)|0,b=b+Math.imul(O,dt)|0,_=_+Math.imul(ee,pt)|0,c=c+Math.imul(ee,gt)|0,c=c+Math.imul(X,pt)|0,b=b+Math.imul(X,gt)|0,_=_+Math.imul(U,yt)|0,c=c+Math.imul(U,mt)|0,c=c+Math.imul(K,yt)|0,b=b+Math.imul(K,mt)|0;var Yc=(A+_|0)+((c&8191)<<13)|0;A=(b+(c>>>13)|0)+(Yc>>>26)|0,Yc&=67108863,_=Math.imul(oe,ut),c=Math.imul(oe,ft),c=c+Math.imul(se,ut)|0,b=Math.imul(se,ft),_=_+Math.imul(J,ct)|0,c=c+Math.imul(J,lt)|0,c=c+Math.imul(re,ct)|0,b=b+Math.imul(re,lt)|0,_=_+Math.imul(D,ht)|0,c=c+Math.imul(D,dt)|0,c=c+Math.imul(H,ht)|0,b=b+Math.imul(H,dt)|0,_=_+Math.imul(ae,pt)|0,c=c+Math.imul(ae,gt)|0,c=c+Math.imul(O,pt)|0,b=b+Math.imul(O,gt)|0,_=_+Math.imul(ee,yt)|0,c=c+Math.imul(ee,mt)|0,c=c+Math.imul(X,yt)|0,b=b+Math.imul(X,mt)|0,_=_+Math.imul(U,vt)|0,c=c+Math.imul(U,bt)|0,c=c+Math.imul(K,vt)|0,b=b+Math.imul(K,bt)|0;var $c=(A+_|0)+((c&8191)<<13)|0;A=(b+(c>>>13)|0)+($c>>>26)|0,$c&=67108863,_=Math.imul(we,ut),c=Math.imul(we,ft),c=c+Math.imul(Re,ut)|0,b=Math.imul(Re,ft),_=_+Math.imul(oe,ct)|0,c=c+Math.imul(oe,lt)|0,c=c+Math.imul(se,ct)|0,b=b+Math.imul(se,lt)|0,_=_+Math.imul(J,ht)|0,c=c+Math.imul(J,dt)|0,c=c+Math.imul(re,ht)|0,b=b+Math.imul(re,dt)|0,_=_+Math.imul(D,pt)|0,c=c+Math.imul(D,gt)|0,c=c+Math.imul(H,pt)|0,b=b+Math.imul(H,gt)|0,_=_+Math.imul(ae,yt)|0,c=c+Math.imul(ae,mt)|0,c=c+Math.imul(O,yt)|0,b=b+Math.imul(O,mt)|0,_=_+Math.imul(ee,vt)|0,c=c+Math.imul(ee,bt)|0,c=c+Math.imul(X,vt)|0,b=b+Math.imul(X,bt)|0,_=_+Math.imul(U,_t)|0,c=c+Math.imul(U,St)|0,c=c+Math.imul(K,_t)|0,b=b+Math.imul(K,St)|0;var Zc=(A+_|0)+((c&8191)<<13)|0;A=(b+(c>>>13)|0)+(Zc>>>26)|0,Zc&=67108863,_=Math.imul(me,ut),c=Math.imul(me,ft),c=c+Math.imul(_e,ut)|0,b=Math.imul(_e,ft),_=_+Math.imul(we,ct)|0,c=c+Math.imul(we,lt)|0,c=c+Math.imul(Re,ct)|0,b=b+Math.imul(Re,lt)|0,_=_+Math.imul(oe,ht)|0,c=c+Math.imul(oe,dt)|0,c=c+Math.imul(se,ht)|0,b=b+Math.imul(se,dt)|0,_=_+Math.imul(J,pt)|0,c=c+Math.imul(J,gt)|0,c=c+Math.imul(re,pt)|0,b=b+Math.imul(re,gt)|0,_=_+Math.imul(D,yt)|0,c=c+Math.imul(D,mt)|0,c=c+Math.imul(H,yt)|0,b=b+Math.imul(H,mt)|0,_=_+Math.imul(ae,vt)|0,c=c+Math.imul(ae,bt)|0,c=c+Math.imul(O,vt)|0,b=b+Math.imul(O,bt)|0,_=_+Math.imul(ee,_t)|0,c=c+Math.imul(ee,St)|0,c=c+Math.imul(X,_t)|0,b=b+Math.imul(X,St)|0,_=_+Math.imul(U,wt)|0,c=c+Math.imul(U,Et)|0,c=c+Math.imul(K,wt)|0,b=b+Math.imul(K,Et)|0;var Xc=(A+_|0)+((c&8191)<<13)|0;A=(b+(c>>>13)|0)+(Xc>>>26)|0,Xc&=67108863,_=Math.imul(Ue,ut),c=Math.imul(Ue,ft),c=c+Math.imul(Ee,ut)|0,b=Math.imul(Ee,ft),_=_+Math.imul(me,ct)|0,c=c+Math.imul(me,lt)|0,c=c+Math.imul(_e,ct)|0,b=b+Math.imul(_e,lt)|0,_=_+Math.imul(we,ht)|0,c=c+Math.imul(we,dt)|0,c=c+Math.imul(Re,ht)|0,b=b+Math.imul(Re,dt)|0,_=_+Math.imul(oe,pt)|0,c=c+Math.imul(oe,gt)|0,c=c+Math.imul(se,pt)|0,b=b+Math.imul(se,gt)|0,_=_+Math.imul(J,yt)|0,c=c+Math.imul(J,mt)|0,c=c+Math.imul(re,yt)|0,b=b+Math.imul(re,mt)|0,_=_+Math.imul(D,vt)|0,c=c+Math.imul(D,bt)|0,c=c+Math.imul(H,vt)|0,b=b+Math.imul(H,bt)|0,_=_+Math.imul(ae,_t)|0,c=c+Math.imul(ae,St)|0,c=c+Math.imul(O,_t)|0,b=b+Math.imul(O,St)|0,_=_+Math.imul(ee,wt)|0,c=c+Math.imul(ee,Et)|0,c=c+Math.imul(X,wt)|0,b=b+Math.imul(X,Et)|0,_=_+Math.imul(U,xt)|0,c=c+Math.imul(U,It)|0,c=c+Math.imul(K,xt)|0,b=b+Math.imul(K,It)|0;var Jc=(A+_|0)+((c&8191)<<13)|0;A=(b+(c>>>13)|0)+(Jc>>>26)|0,Jc&=67108863,_=Math.imul(je,ut),c=Math.imul(je,ft),c=c+Math.imul(Qe,ut)|0,b=Math.imul(Qe,ft),_=_+Math.imul(Ue,ct)|0,c=c+Math.imul(Ue,lt)|0,c=c+Math.imul(Ee,ct)|0,b=b+Math.imul(Ee,lt)|0,_=_+Math.imul(me,ht)|0,c=c+Math.imul(me,dt)|0,c=c+Math.imul(_e,ht)|0,b=b+Math.imul(_e,dt)|0,_=_+Math.imul(we,pt)|0,c=c+Math.imul(we,gt)|0,c=c+Math.imul(Re,pt)|0,b=b+Math.imul(Re,gt)|0,_=_+Math.imul(oe,yt)|0,c=c+Math.imul(oe,mt)|0,c=c+Math.imul(se,yt)|0,b=b+Math.imul(se,mt)|0,_=_+Math.imul(J,vt)|0,c=c+Math.imul(J,bt)|0,c=c+Math.imul(re,vt)|0,b=b+Math.imul(re,bt)|0,_=_+Math.imul(D,_t)|0,c=c+Math.imul(D,St)|0,c=c+Math.imul(H,_t)|0,b=b+Math.imul(H,St)|0,_=_+Math.imul(ae,wt)|0,c=c+Math.imul(ae,Et)|0,c=c+Math.imul(O,wt)|0,b=b+Math.imul(O,Et)|0,_=_+Math.imul(ee,xt)|0,c=c+Math.imul(ee,It)|0,c=c+Math.imul(X,xt)|0,b=b+Math.imul(X,It)|0,_=_+Math.imul(U,At)|0,c=c+Math.imul(U,Ot)|0,c=c+Math.imul(K,At)|0,b=b+Math.imul(K,Ot)|0;var Qc=(A+_|0)+((c&8191)<<13)|0;A=(b+(c>>>13)|0)+(Qc>>>26)|0,Qc&=67108863,_=Math.imul(je,ct),c=Math.imul(je,lt),c=c+Math.imul(Qe,ct)|0,b=Math.imul(Qe,lt),_=_+Math.imul(Ue,ht)|0,c=c+Math.imul(Ue,dt)|0,c=c+Math.imul(Ee,ht)|0,b=b+Math.imul(Ee,dt)|0,_=_+Math.imul(me,pt)|0,c=c+Math.imul(me,gt)|0,c=c+Math.imul(_e,pt)|0,b=b+Math.imul(_e,gt)|0,_=_+Math.imul(we,yt)|0,c=c+Math.imul(we,mt)|0,c=c+Math.imul(Re,yt)|0,b=b+Math.imul(Re,mt)|0,_=_+Math.imul(oe,vt)|0,c=c+Math.imul(oe,bt)|0,c=c+Math.imul(se,vt)|0,b=b+Math.imul(se,bt)|0,_=_+Math.imul(J,_t)|0,c=c+Math.imul(J,St)|0,c=c+Math.imul(re,_t)|0,b=b+Math.imul(re,St)|0,_=_+Math.imul(D,wt)|0,c=c+Math.imul(D,Et)|0,c=c+Math.imul(H,wt)|0,b=b+Math.imul(H,Et)|0,_=_+Math.imul(ae,xt)|0,c=c+Math.imul(ae,It)|0,c=c+Math.imul(O,xt)|0,b=b+Math.imul(O,It)|0,_=_+Math.imul(ee,At)|0,c=c+Math.imul(ee,Ot)|0,c=c+Math.imul(X,At)|0,b=b+Math.imul(X,Ot)|0;var el=(A+_|0)+((c&8191)<<13)|0;A=(b+(c>>>13)|0)+(el>>>26)|0,el&=67108863,_=Math.imul(je,ht),c=Math.imul(je,dt),c=c+Math.imul(Qe,ht)|0,b=Math.imul(Qe,dt),_=_+Math.imul(Ue,pt)|0,c=c+Math.imul(Ue,gt)|0,c=c+Math.imul(Ee,pt)|0,b=b+Math.imul(Ee,gt)|0,_=_+Math.imul(me,yt)|0,c=c+Math.imul(me,mt)|0,c=c+Math.imul(_e,yt)|0,b=b+Math.imul(_e,mt)|0,_=_+Math.imul(we,vt)|0,c=c+Math.imul(we,bt)|0,c=c+Math.imul(Re,vt)|0,b=b+Math.imul(Re,bt)|0,_=_+Math.imul(oe,_t)|0,c=c+Math.imul(oe,St)|0,c=c+Math.imul(se,_t)|0,b=b+Math.imul(se,St)|0,_=_+Math.imul(J,wt)|0,c=c+Math.imul(J,Et)|0,c=c+Math.imul(re,wt)|0,b=b+Math.imul(re,Et)|0,_=_+Math.imul(D,xt)|0,c=c+Math.imul(D,It)|0,c=c+Math.imul(H,xt)|0,b=b+Math.imul(H,It)|0,_=_+Math.imul(ae,At)|0,c=c+Math.imul(ae,Ot)|0,c=c+Math.imul(O,At)|0,b=b+Math.imul(O,Ot)|0;var tl=(A+_|0)+((c&8191)<<13)|0;A=(b+(c>>>13)|0)+(tl>>>26)|0,tl&=67108863,_=Math.imul(je,pt),c=Math.imul(je,gt),c=c+Math.imul(Qe,pt)|0,b=Math.imul(Qe,gt),_=_+Math.imul(Ue,yt)|0,c=c+Math.imul(Ue,mt)|0,c=c+Math.imul(Ee,yt)|0,b=b+Math.imul(Ee,mt)|0,_=_+Math.imul(me,vt)|0,c=c+Math.imul(me,bt)|0,c=c+Math.imul(_e,vt)|0,b=b+Math.imul(_e,bt)|0,_=_+Math.imul(we,_t)|0,c=c+Math.imul(we,St)|0,c=c+Math.imul(Re,_t)|0,b=b+Math.imul(Re,St)|0,_=_+Math.imul(oe,wt)|0,c=c+Math.imul(oe,Et)|0,c=c+Math.imul(se,wt)|0,b=b+Math.imul(se,Et)|0,_=_+Math.imul(J,xt)|0,c=c+Math.imul(J,It)|0,c=c+Math.imul(re,xt)|0,b=b+Math.imul(re,It)|0,_=_+Math.imul(D,At)|0,c=c+Math.imul(D,Ot)|0,c=c+Math.imul(H,At)|0,b=b+Math.imul(H,Ot)|0;var rl=(A+_|0)+((c&8191)<<13)|0;A=(b+(c>>>13)|0)+(rl>>>26)|0,rl&=67108863,_=Math.imul(je,yt),c=Math.imul(je,mt),c=c+Math.imul(Qe,yt)|0,b=Math.imul(Qe,mt),_=_+Math.imul(Ue,vt)|0,c=c+Math.imul(Ue,bt)|0,c=c+Math.imul(Ee,vt)|0,b=b+Math.imul(Ee,bt)|0,_=_+Math.imul(me,_t)|0,c=c+Math.imul(me,St)|0,c=c+Math.imul(_e,_t)|0,b=b+Math.imul(_e,St)|0,_=_+Math.imul(we,wt)|0,c=c+Math.imul(we,Et)|0,c=c+Math.imul(Re,wt)|0,b=b+Math.imul(Re,Et)|0,_=_+Math.imul(oe,xt)|0,c=c+Math.imul(oe,It)|0,c=c+Math.imul(se,xt)|0,b=b+Math.imul(se,It)|0,_=_+Math.imul(J,At)|0,c=c+Math.imul(J,Ot)|0,c=c+Math.imul(re,At)|0,b=b+Math.imul(re,Ot)|0;var nl=(A+_|0)+((c&8191)<<13)|0;A=(b+(c>>>13)|0)+(nl>>>26)|0,nl&=67108863,_=Math.imul(je,vt),c=Math.imul(je,bt),c=c+Math.imul(Qe,vt)|0,b=Math.imul(Qe,bt),_=_+Math.imul(Ue,_t)|0,c=c+Math.imul(Ue,St)|0,c=c+Math.imul(Ee,_t)|0,b=b+Math.imul(Ee,St)|0,_=_+Math.imul(me,wt)|0,c=c+Math.imul(me,Et)|0,c=c+Math.imul(_e,wt)|0,b=b+Math.imul(_e,Et)|0,_=_+Math.imul(we,xt)|0,c=c+Math.imul(we,It)|0,c=c+Math.imul(Re,xt)|0,b=b+Math.imul(Re,It)|0,_=_+Math.imul(oe,At)|0,c=c+Math.imul(oe,Ot)|0,c=c+Math.imul(se,At)|0,b=b+Math.imul(se,Ot)|0;var il=(A+_|0)+((c&8191)<<13)|0;A=(b+(c>>>13)|0)+(il>>>26)|0,il&=67108863,_=Math.imul(je,_t),c=Math.imul(je,St),c=c+Math.imul(Qe,_t)|0,b=Math.imul(Qe,St),_=_+Math.imul(Ue,wt)|0,c=c+Math.imul(Ue,Et)|0,c=c+Math.imul(Ee,wt)|0,b=b+Math.imul(Ee,Et)|0,_=_+Math.imul(me,xt)|0,c=c+Math.imul(me,It)|0,c=c+Math.imul(_e,xt)|0,b=b+Math.imul(_e,It)|0,_=_+Math.imul(we,At)|0,c=c+Math.imul(we,Ot)|0,c=c+Math.imul(Re,At)|0,b=b+Math.imul(Re,Ot)|0;var ol=(A+_|0)+((c&8191)<<13)|0;A=(b+(c>>>13)|0)+(ol>>>26)|0,ol&=67108863,_=Math.imul(je,wt),c=Math.imul(je,Et),c=c+Math.imul(Qe,wt)|0,b=Math.imul(Qe,Et),_=_+Math.imul(Ue,xt)|0,c=c+Math.imul(Ue,It)|0,c=c+Math.imul(Ee,xt)|0,b=b+Math.imul(Ee,It)|0,_=_+Math.imul(me,At)|0,c=c+Math.imul(me,Ot)|0,c=c+Math.imul(_e,At)|0,b=b+Math.imul(_e,Ot)|0;var sl=(A+_|0)+((c&8191)<<13)|0;A=(b+(c>>>13)|0)+(sl>>>26)|0,sl&=67108863,_=Math.imul(je,xt),c=Math.imul(je,It),c=c+Math.imul(Qe,xt)|0,b=Math.imul(Qe,It),_=_+Math.imul(Ue,At)|0,c=c+Math.imul(Ue,Ot)|0,c=c+Math.imul(Ee,At)|0,b=b+Math.imul(Ee,Ot)|0;var al=(A+_|0)+((c&8191)<<13)|0;A=(b+(c>>>13)|0)+(al>>>26)|0,al&=67108863,_=Math.imul(je,At),c=Math.imul(je,Ot),c=c+Math.imul(Qe,At)|0,b=Math.imul(Qe,Ot);var ul=(A+_|0)+((c&8191)<<13)|0;return A=(b+(c>>>13)|0)+(ul>>>26)|0,ul&=67108863,R[0]=Gc,R[1]=Vc,R[2]=Wc,R[3]=zc,R[4]=Yc,R[5]=$c,R[6]=Zc,R[7]=Xc,R[8]=Jc,R[9]=Qc,R[10]=el,R[11]=tl,R[12]=rl,R[13]=nl,R[14]=il,R[15]=ol,R[16]=sl,R[17]=al,R[18]=ul,A!==0&&(R[19]=A,m.length++),m};Math.imul||(T=E);function M(I,u,h){h.negative=u.negative^I.negative,h.length=I.length+u.length;for(var m=0,S=0,w=0;w<h.length-1;w++){var R=S;S=0;for(var A=m&67108863,_=Math.min(w,u.length-1),c=Math.max(0,w-I.length+1);c<=_;c++){var b=w-c,k=I.words[b]|0,U=u.words[c]|0,K=k*U,W=K&67108863;R=R+(K/67108864|0)|0,W=W+A|0,A=W&67108863,R=R+(W>>>26)|0,S+=R>>>26,R&=67108863}h.words[w]=A,m=R,R=S}return m!==0?h.words[w]=m:h.length--,h.strip()}function L(I,u,h){var m=new F;return m.mulp(I,u,h)}i.prototype.mulTo=function(u,h){var m,S=this.length+u.length;return this.length===10&&u.length===10?m=T(this,u,h):S<63?m=E(this,u,h):S<1024?m=M(this,u,h):m=L(this,u,h),m};function F(I,u){this.x=I,this.y=u}F.prototype.makeRBT=function(u){for(var h=new Array(u),m=i.prototype._countBits(u)-1,S=0;S<u;S++)h[S]=this.revBin(S,m,u);return h},F.prototype.revBin=function(u,h,m){if(u===0||u===m-1)return u;for(var S=0,w=0;w<h;w++)S|=(u&1)<<h-w-1,u>>=1;return S},F.prototype.permute=function(u,h,m,S,w,R){for(var A=0;A<R;A++)S[A]=h[u[A]],w[A]=m[u[A]]},F.prototype.transform=function(u,h,m,S,w,R){this.permute(R,u,h,m,S,w);for(var A=1;A<w;A<<=1)for(var _=A<<1,c=Math.cos(2*Math.PI/_),b=Math.sin(2*Math.PI/_),k=0;k<w;k+=_)for(var U=c,K=b,W=0;W<A;W++){var ee=m[k+W],X=S[k+W],le=m[k+W+A],ae=S[k+W+A],O=U*le-K*ae;ae=U*ae+K*le,le=O,m[k+W]=ee+le,S[k+W]=X+ae,m[k+W+A]=ee-le,S[k+W+A]=X-ae,W!==_&&(O=c*U-b*K,K=c*K+b*U,U=O)}},F.prototype.guessLen13b=function(u,h){var m=Math.max(h,u)|1,S=m&1,w=0;for(m=m/2|0;m;m=m>>>1)w++;return 1<<w+1+S},F.prototype.conjugate=function(u,h,m){if(!(m<=1))for(var S=0;S<m/2;S++){var w=u[S];u[S]=u[m-S-1],u[m-S-1]=w,w=h[S],h[S]=-h[m-S-1],h[m-S-1]=-w}},F.prototype.normalize13b=function(u,h){for(var m=0,S=0;S<h/2;S++){var w=Math.round(u[2*S+1]/h)*8192+Math.round(u[2*S]/h)+m;u[S]=w&67108863,w<67108864?m=0:m=w/67108864|0}return u},F.prototype.convert13b=function(u,h,m,S){for(var w=0,R=0;R<h;R++)w=w+(u[R]|0),m[2*R]=w&8191,w=w>>>13,m[2*R+1]=w&8191,w=w>>>13;for(R=2*h;R<S;++R)m[R]=0;r(w===0),r((w&-8192)===0)},F.prototype.stub=function(u){for(var h=new Array(u),m=0;m<u;m++)h[m]=0;return h},F.prototype.mulp=function(u,h,m){var S=2*this.guessLen13b(u.length,h.length),w=this.makeRBT(S),R=this.stub(S),A=new Array(S),_=new Array(S),c=new Array(S),b=new Array(S),k=new Array(S),U=new Array(S),K=m.words;K.length=S,this.convert13b(u.words,u.length,A,S),this.convert13b(h.words,h.length,b,S),this.transform(A,R,_,c,S,w),this.transform(b,R,k,U,S,w);for(var W=0;W<S;W++){var ee=_[W]*k[W]-c[W]*U[W];c[W]=_[W]*U[W]+c[W]*k[W],_[W]=ee}return this.conjugate(_,c,S),this.transform(_,c,K,R,S,w),this.conjugate(K,R,S),this.normalize13b(K,S),m.negative=u.negative^h.negative,m.length=u.length+h.length,m.strip()},i.prototype.mul=function(u){var h=new i(null);return h.words=new Array(this.length+u.length),this.mulTo(u,h)},i.prototype.mulf=function(u){var h=new i(null);return h.words=new Array(this.length+u.length),L(this,u,h)},i.prototype.imul=function(u){return this.clone().mulTo(u,this)},i.prototype.imuln=function(u){r(typeof u=="number"),r(u<67108864);for(var h=0,m=0;m<this.length;m++){var S=(this.words[m]|0)*u,w=(S&67108863)+(h&67108863);h>>=26,h+=S/67108864|0,h+=w>>>26,this.words[m]=w&67108863}return h!==0&&(this.words[m]=h,this.length++),u===0&&(this.length=1,this._normSign()),this},i.prototype.muln=function(u){return this.clone().imuln(u)},i.prototype.sqr=function(){return this.mul(this)},i.prototype.isqr=function(){return this.imul(this.clone())},i.prototype.pow=function(u){var h=v(u);if(h.length===0)return new i(1);for(var m=this,S=0;S<h.length&&h[S]===0;S++,m=m.sqr());if(++S<h.length)for(var w=m.sqr();S<h.length;S++,w=w.sqr())h[S]!==0&&(m=m.mul(w));return m},i.prototype.iushln=function(u){r(typeof u=="number"&&u>=0);var h=u%26,m=(u-h)/26,S=67108863>>>26-h<<26-h,w;if(h!==0){var R=0;for(w=0;w<this.length;w++){var A=this.words[w]&S,_=(this.words[w]|0)-A<<h;this.words[w]=_|R,R=A>>>26-h}R&&(this.words[w]=R,this.length++)}if(m!==0){for(w=this.length-1;w>=0;w--)this.words[w+m]=this.words[w];for(w=0;w<m;w++)this.words[w]=0;this.length+=m}return this.strip()},i.prototype.ishln=function(u){return r(this.negative===0),this.iushln(u)},i.prototype.iushrn=function(u,h,m){r(typeof u=="number"&&u>=0);var S;h?S=(h-h%26)/26:S=0;var w=u%26,R=Math.min((u-w)/26,this.length),A=67108863^67108863>>>w<<w,_=m;if(S-=R,S=Math.max(0,S),_){for(var c=0;c<R;c++)_.words[c]=this.words[c];_.length=R}if(R!==0)if(this.length>R)for(this.length-=R,c=0;c<this.length;c++)this.words[c]=this.words[c+R];else this.words[0]=0,this.length=1;var b=0;for(c=this.length-1;c>=0&&(b!==0||c>=S);c--){var k=this.words[c]|0;this.words[c]=b<<26-w|k>>>w,b=k&A}return _&&b!==0&&(_.words[_.length++]=b),this.length===0&&(this.words[0]=0,this.length=1),this.strip()},i.prototype.ishrn=function(u,h,m){return r(this.negative===0),this.iushrn(u,h,m)},i.prototype.shln=function(u){return this.clone().ishln(u)},i.prototype.ushln=function(u){return this.clone().iushln(u)},i.prototype.shrn=function(u){return this.clone().ishrn(u)},i.prototype.ushrn=function(u){return this.clone().iushrn(u)},i.prototype.testn=function(u){r(typeof u=="number"&&u>=0);var h=u%26,m=(u-h)/26,S=1<<h;if(this.length<=m)return!1;var w=this.words[m];return!!(w&S)},i.prototype.imaskn=function(u){r(typeof u=="number"&&u>=0);var h=u%26,m=(u-h)/26;if(r(this.negative===0,"imaskn works only with positive numbers"),this.length<=m)return this;if(h!==0&&m++,this.length=Math.min(m,this.length),h!==0){var S=67108863^67108863>>>h<<h;this.words[this.length-1]&=S}return this.length===0&&(this.words[0]=0,this.length=1),this.strip()},i.prototype.maskn=function(u){return this.clone().imaskn(u)},i.prototype.iaddn=function(u){return r(typeof u=="number"),r(u<67108864),u<0?this.isubn(-u):this.negative!==0?this.length===1&&(this.words[0]|0)<u?(this.words[0]=u-(this.words[0]|0),this.negative=0,this):(this.negative=0,this.isubn(u),this.negative=1,this):this._iaddn(u)},i.prototype._iaddn=function(u){this.words[0]+=u;for(var h=0;h<this.length&&this.words[h]>=67108864;h++)this.words[h]-=67108864,h===this.length-1?this.words[h+1]=1:this.words[h+1]++;return this.length=Math.max(this.length,h+1),this},i.prototype.isubn=function(u){if(r(typeof u=="number"),r(u<67108864),u<0)return this.iaddn(-u);if(this.negative!==0)return this.negative=0,this.iaddn(u),this.negative=1,this;if(this.words[0]-=u,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var h=0;h<this.length&&this.words[h]<0;h++)this.words[h]+=67108864,this.words[h+1]-=1;return this.strip()},i.prototype.addn=function(u){return this.clone().iaddn(u)},i.prototype.subn=function(u){return this.clone().isubn(u)},i.prototype.iabs=function(){return this.negative=0,this},i.prototype.abs=function(){return this.clone().iabs()},i.prototype._ishlnsubmul=function(u,h,m){var S=u.length+m,w;this._expand(S);var R,A=0;for(w=0;w<u.length;w++){R=(this.words[w+m]|0)+A;var _=(u.words[w]|0)*h;R-=_&67108863,A=(R>>26)-(_/67108864|0),this.words[w+m]=R&67108863}for(;w<this.length-m;w++)R=(this.words[w+m]|0)+A,A=R>>26,this.words[w+m]=R&67108863;if(A===0)return this.strip();for(r(A===-1),A=0,w=0;w<this.length;w++)R=-(this.words[w]|0)+A,A=R>>26,this.words[w]=R&67108863;return this.negative=1,this.strip()},i.prototype._wordDiv=function(u,h){var m=this.length-u.length,S=this.clone(),w=u,R=w.words[w.length-1]|0,A=this._countBits(R);m=26-A,m!==0&&(w=w.ushln(m),S.iushln(m),R=w.words[w.length-1]|0);var _=S.length-w.length,c;if(h!=="mod"){c=new i(null),c.length=_+1,c.words=new Array(c.length);for(var b=0;b<c.length;b++)c.words[b]=0}var k=S.clone()._ishlnsubmul(w,1,_);k.negative===0&&(S=k,c&&(c.words[_]=1));for(var U=_-1;U>=0;U--){var K=(S.words[w.length+U]|0)*67108864+(S.words[w.length+U-1]|0);for(K=Math.min(K/R|0,67108863),S._ishlnsubmul(w,K,U);S.negative!==0;)K--,S.negative=0,S._ishlnsubmul(w,1,U),S.isZero()||(S.negative^=1);c&&(c.words[U]=K)}return c&&c.strip(),S.strip(),h!=="div"&&m!==0&&S.iushrn(m),{div:c||null,mod:S}},i.prototype.divmod=function(u,h,m){if(r(!u.isZero()),this.isZero())return{div:new i(0),mod:new i(0)};var S,w,R;return this.negative!==0&&u.negative===0?(R=this.neg().divmod(u,h),h!=="mod"&&(S=R.div.neg()),h!=="div"&&(w=R.mod.neg(),m&&w.negative!==0&&w.iadd(u)),{div:S,mod:w}):this.negative===0&&u.negative!==0?(R=this.divmod(u.neg(),h),h!=="mod"&&(S=R.div.neg()),{div:S,mod:R.mod}):(this.negative&u.negative)!==0?(R=this.neg().divmod(u.neg(),h),h!=="div"&&(w=R.mod.neg(),m&&w.negative!==0&&w.isub(u)),{div:R.div,mod:w}):u.length>this.length||this.cmp(u)<0?{div:new i(0),mod:this}:u.length===1?h==="div"?{div:this.divn(u.words[0]),mod:null}:h==="mod"?{div:null,mod:new i(this.modn(u.words[0]))}:{div:this.divn(u.words[0]),mod:new i(this.modn(u.words[0]))}:this._wordDiv(u,h)},i.prototype.div=function(u){return this.divmod(u,"div",!1).div},i.prototype.mod=function(u){return this.divmod(u,"mod",!1).mod},i.prototype.umod=function(u){return this.divmod(u,"mod",!0).mod},i.prototype.divRound=function(u){var h=this.divmod(u);if(h.mod.isZero())return h.div;var m=h.mod.abs(),S=u.abs().iushrn(1),w=u.words[0]&1,R=m.cmp(S);if(R<0||w===1&&R===0)return h.div;var A=new i(1);return A.negative=this.negative^u.negative,h.div.iadd(A)},i.prototype.modn=function(u){r(u<=67108863);for(var h=(1<<26)%u,m=0,S=this.length-1;S>=0;S--)m=(h*m+(this.words[S]|0))%u;return m},i.prototype.idivn=function(u){r(u<=67108863);for(var h=0,m=this.length-1;m>=0;m--){var S=(this.words[m]|0)+h*67108864;this.words[m]=S/u|0,h=S%u}return this.strip()},i.prototype.divn=function(u){return this.clone().idivn(u)},i.prototype.egcd=function(u){r(u.negative===0),r(!u.isZero());var h=this,m=u.clone();h.negative!==0?h=h.umod(u):h=h.clone();for(var S=new i(1),w=new i(0),R=new i(0),A=new i(1),_=0;h.isEven()&&m.isEven();)h.iushrn(1),m.iushrn(1),++_;for(var c=m.clone(),b=h.clone();!h.isZero();){for(var k=0,U=1;(h.words[0]&U)===0&&k<26;++k,U<<=1);if(k>0)for(h.iushrn(k);k-- >0;)(S.isOdd()||w.isOdd())&&(S.iadd(c),w.isub(b)),S.iushrn(1),w.iushrn(1);for(var K=0,W=1;(m.words[0]&W)===0&&K<26;++K,W<<=1);if(K>0)for(m.iushrn(K);K-- >0;)(R.isOdd()||A.isOdd())&&(R.iadd(c),A.isub(b)),R.iushrn(1),A.iushrn(1);h.cmp(m)>=0?(h.isub(m),S.isub(R),w.isub(A)):(m.isub(h),R.isub(S),A.isub(w))}return{a:R,b:A,gcd:m.iushln(_)}},i.prototype._invmp=function(u){r(u.negative===0),r(!u.isZero());var h=this,m=u.clone();h.negative!==0?h=h.umod(u):h=h.clone();for(var S=new i(1),w=new i(0),R=m.clone();h.cmpn(1)>0&&m.cmpn(1)>0;){for(var A=0,_=1;(h.words[0]&_)===0&&A<26;++A,_<<=1);if(A>0)for(h.iushrn(A);A-- >0;)S.isOdd()&&S.iadd(R),S.iushrn(1);for(var c=0,b=1;(m.words[0]&b)===0&&c<26;++c,b<<=1);if(c>0)for(m.iushrn(c);c-- >0;)w.isOdd()&&w.iadd(R),w.iushrn(1);h.cmp(m)>=0?(h.isub(m),S.isub(w)):(m.isub(h),w.isub(S))}var k;return h.cmpn(1)===0?k=S:k=w,k.cmpn(0)<0&&k.iadd(u),k},i.prototype.gcd=function(u){if(this.isZero())return u.abs();if(u.isZero())return this.abs();var h=this.clone(),m=u.clone();h.negative=0,m.negative=0;for(var S=0;h.isEven()&&m.isEven();S++)h.iushrn(1),m.iushrn(1);do{for(;h.isEven();)h.iushrn(1);for(;m.isEven();)m.iushrn(1);var w=h.cmp(m);if(w<0){var R=h;h=m,m=R}else if(w===0||m.cmpn(1)===0)break;h.isub(m)}while(!0);return m.iushln(S)},i.prototype.invm=function(u){return this.egcd(u).a.umod(u)},i.prototype.isEven=function(){return(this.words[0]&1)===0},i.prototype.isOdd=function(){return(this.words[0]&1)===1},i.prototype.andln=function(u){return this.words[0]&u},i.prototype.bincn=function(u){r(typeof u=="number");var h=u%26,m=(u-h)/26,S=1<<h;if(this.length<=m)return this._expand(m+1),this.words[m]|=S,this;for(var w=S,R=m;w!==0&&R<this.length;R++){var A=this.words[R]|0;A+=w,w=A>>>26,A&=67108863,this.words[R]=A}return w!==0&&(this.words[R]=w,this.length++),this},i.prototype.isZero=function(){return this.length===1&&this.words[0]===0},i.prototype.cmpn=function(u){var h=u<0;if(this.negative!==0&&!h)return-1;if(this.negative===0&&h)return 1;this.strip();var m;if(this.length>1)m=1;else{h&&(u=-u),r(u<=67108863,"Number is too big");var S=this.words[0]|0;m=S===u?0:S<u?-1:1}return this.negative!==0?-m|0:m},i.prototype.cmp=function(u){if(this.negative!==0&&u.negative===0)return-1;if(this.negative===0&&u.negative!==0)return 1;var h=this.ucmp(u);return this.negative!==0?-h|0:h},i.prototype.ucmp=function(u){if(this.length>u.length)return 1;if(this.length<u.length)return-1;for(var h=0,m=this.length-1;m>=0;m--){var S=this.words[m]|0,w=u.words[m]|0;if(S!==w){S<w?h=-1:S>w&&(h=1);break}}return h},i.prototype.gtn=function(u){return this.cmpn(u)===1},i.prototype.gt=function(u){return this.cmp(u)===1},i.prototype.gten=function(u){return this.cmpn(u)>=0},i.prototype.gte=function(u){return this.cmp(u)>=0},i.prototype.ltn=function(u){return this.cmpn(u)===-1},i.prototype.lt=function(u){return this.cmp(u)===-1},i.prototype.lten=function(u){return this.cmpn(u)<=0},i.prototype.lte=function(u){return this.cmp(u)<=0},i.prototype.eqn=function(u){return this.cmpn(u)===0},i.prototype.eq=function(u){return this.cmp(u)===0},i.red=function(u){return new fe(u)},i.prototype.toRed=function(u){return r(!this.red,"Already a number in reduction context"),r(this.negative===0,"red works only with positives"),u.convertTo(this)._forceRed(u)},i.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},i.prototype._forceRed=function(u){return this.red=u,this},i.prototype.forceRed=function(u){return r(!this.red,"Already a number in reduction context"),this._forceRed(u)},i.prototype.redAdd=function(u){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,u)},i.prototype.redIAdd=function(u){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,u)},i.prototype.redSub=function(u){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,u)},i.prototype.redISub=function(u){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,u)},i.prototype.redShl=function(u){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,u)},i.prototype.redMul=function(u){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,u),this.red.mul(this,u)},i.prototype.redIMul=function(u){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,u),this.red.imul(this,u)},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(u){return r(this.red&&!u.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,u)};var V={k256:null,p224:null,p192:null,p25519:null};function z(I,u){this.name=I,this.p=new i(u,16),this.n=this.p.bitLength(),this.k=new i(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}z.prototype._tmp=function(){var u=new i(null);return u.words=new Array(Math.ceil(this.n/13)),u},z.prototype.ireduce=function(u){var h=u,m;do this.split(h,this.tmp),h=this.imulK(h),h=h.iadd(this.tmp),m=h.bitLength();while(m>this.n);var S=m<this.n?-1:h.ucmp(this.p);return S===0?(h.words[0]=0,h.length=1):S>0?h.isub(this.p):h.strip!==void 0?h.strip():h._strip(),h},z.prototype.split=function(u,h){u.iushrn(this.n,0,h)},z.prototype.imulK=function(u){return u.imul(this.k)};function G(){z.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}n(G,z),G.prototype.split=function(u,h){for(var m=4194303,S=Math.min(u.length,9),w=0;w<S;w++)h.words[w]=u.words[w];if(h.length=S,u.length<=9){u.words[0]=0,u.length=1;return}var R=u.words[9];for(h.words[h.length++]=R&m,w=10;w<u.length;w++){var A=u.words[w]|0;u.words[w-10]=(A&m)<<4|R>>>22,R=A}R>>>=22,u.words[w-10]=R,R===0&&u.length>10?u.length-=10:u.length-=9},G.prototype.imulK=function(u){u.words[u.length]=0,u.words[u.length+1]=0,u.length+=2;for(var h=0,m=0;m<u.length;m++){var S=u.words[m]|0;h+=S*977,u.words[m]=h&67108863,h=S*64+(h/67108864|0)}return u.words[u.length-1]===0&&(u.length--,u.words[u.length-1]===0&&u.length--),u};function ie(){z.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}n(ie,z);function te(){z.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}n(te,z);function pe(){z.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}n(pe,z),pe.prototype.imulK=function(u){for(var h=0,m=0;m<u.length;m++){var S=(u.words[m]|0)*19+h,w=S&67108863;S>>>=26,u.words[m]=w,h=S}return h!==0&&(u.words[u.length++]=h),u},i._prime=function(u){if(V[u])return V[u];var h;if(u==="k256")h=new G;else if(u==="p224")h=new ie;else if(u==="p192")h=new te;else if(u==="p25519")h=new pe;else throw new Error("Unknown prime "+u);return V[u]=h,h};function fe(I){if(typeof I=="string"){var u=i._prime(I);this.m=u.p,this.prime=u}else r(I.gtn(1),"modulus must be greater than 1"),this.m=I,this.prime=null}fe.prototype._verify1=function(u){r(u.negative===0,"red works only with positives"),r(u.red,"red works only with red numbers")},fe.prototype._verify2=function(u,h){r((u.negative|h.negative)===0,"red works only with positives"),r(u.red&&u.red===h.red,"red works only with red numbers")},fe.prototype.imod=function(u){return this.prime?this.prime.ireduce(u)._forceRed(this):u.umod(this.m)._forceRed(this)},fe.prototype.neg=function(u){return u.isZero()?u.clone():this.m.sub(u)._forceRed(this)},fe.prototype.add=function(u,h){this._verify2(u,h);var m=u.add(h);return m.cmp(this.m)>=0&&m.isub(this.m),m._forceRed(this)},fe.prototype.iadd=function(u,h){this._verify2(u,h);var m=u.iadd(h);return m.cmp(this.m)>=0&&m.isub(this.m),m},fe.prototype.sub=function(u,h){this._verify2(u,h);var m=u.sub(h);return m.cmpn(0)<0&&m.iadd(this.m),m._forceRed(this)},fe.prototype.isub=function(u,h){this._verify2(u,h);var m=u.isub(h);return m.cmpn(0)<0&&m.iadd(this.m),m},fe.prototype.shl=function(u,h){return this._verify1(u),this.imod(u.ushln(h))},fe.prototype.imul=function(u,h){return this._verify2(u,h),this.imod(u.imul(h))},fe.prototype.mul=function(u,h){return this._verify2(u,h),this.imod(u.mul(h))},fe.prototype.isqr=function(u){return this.imul(u,u.clone())},fe.prototype.sqr=function(u){return this.mul(u,u)},fe.prototype.sqrt=function(u){if(u.isZero())return u.clone();var h=this.m.andln(3);if(r(h%2===1),h===3){var m=this.m.add(new i(1)).iushrn(2);return this.pow(u,m)}for(var S=this.m.subn(1),w=0;!S.isZero()&&S.andln(1)===0;)w++,S.iushrn(1);r(!S.isZero());var R=new i(1).toRed(this),A=R.redNeg(),_=this.m.subn(1).iushrn(1),c=this.m.bitLength();for(c=new i(2*c*c).toRed(this);this.pow(c,_).cmp(A)!==0;)c.redIAdd(A);for(var b=this.pow(c,S),k=this.pow(u,S.addn(1).iushrn(1)),U=this.pow(u,S),K=w;U.cmp(R)!==0;){for(var W=U,ee=0;W.cmp(R)!==0;ee++)W=W.redSqr();r(ee<K);var X=this.pow(b,new i(1).iushln(K-ee-1));k=k.redMul(X),b=X.redSqr(),U=U.redMul(b),K=ee}return k},fe.prototype.invm=function(u){var h=u._invmp(this.m);return h.negative!==0?(h.negative=0,this.imod(h).redNeg()):this.imod(h)},fe.prototype.pow=function(u,h){if(h.isZero())return new i(1).toRed(this);if(h.cmpn(1)===0)return u.clone();var m=4,S=new Array(1<<m);S[0]=new i(1).toRed(this),S[1]=u;for(var w=2;w<S.length;w++)S[w]=this.mul(S[w-1],u);var R=S[0],A=0,_=0,c=h.bitLength()%26;for(c===0&&(c=26),w=h.length-1;w>=0;w--){for(var b=h.words[w],k=c-1;k>=0;k--){var U=b>>k&1;if(R!==S[0]&&(R=this.sqr(R)),U===0&&A===0){_=0;continue}A<<=1,A|=U,_++,!(_!==m&&(w!==0||k!==0))&&(R=this.mul(R,S[A]),_=0,A=0)}c=26}return R},fe.prototype.convertTo=function(u){var h=u.umod(this.m);return h===u?h.clone():h},fe.prototype.convertFrom=function(u){var h=u.clone();return h.red=null,h},i.mont=function(u){return new ye(u)};function ye(I){fe.call(this,I),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(ye,fe),ye.prototype.convertTo=function(u){return this.imod(u.ushln(this.shift))},ye.prototype.convertFrom=function(u){var h=this.imod(u.mul(this.rinv));return h.red=null,h},ye.prototype.imul=function(u,h){if(u.isZero()||h.isZero())return u.words[0]=0,u.length=1,u;var m=u.imul(h),S=m.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),w=m.isub(S).iushrn(this.shift),R=w;return w.cmp(this.m)>=0?R=w.isub(this.m):w.cmpn(0)<0&&(R=w.iadd(this.m)),R._forceRed(this)},ye.prototype.mul=function(u,h){if(u.isZero()||h.isZero())return new i(0)._forceRed(this);var m=u.mul(h),S=m.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),w=m.isub(S).iushrn(this.shift),R=w;return w.cmp(this.m)>=0?R=w.isub(this.m):w.cmpn(0)<0&&(R=w.iadd(this.m)),R._forceRed(this)},ye.prototype.invm=function(u){var h=this.imod(u._invmp(this.m).mul(this.r2));return h._forceRed(this)}})(typeof El>"u"||El,C0)});var Ke=B(($C,xl)=>{p();typeof Object.create=="function"?xl.exports=function(t,r){r&&(t.super_=r,t.prototype=Object.create(r.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:xl.exports=function(t,r){if(r){t.super_=r;var n=function(){};n.prototype=r.prototype,t.prototype=new n,t.prototype.constructor=t}}});var Wt=B((Il,U0)=>{p();var ru=Mt(),Xr=ru.Buffer;function D0(e,t){for(var r in e)t[r]=e[r]}Xr.from&&Xr.alloc&&Xr.allocUnsafe&&Xr.allocUnsafeSlow?U0.exports=ru:(D0(ru,Il),Il.Buffer=Oi);function Oi(e,t,r){return Xr(e,t,r)}Oi.prototype=Object.create(Xr.prototype);D0(Xr,Oi);Oi.from=function(e,t,r){if(typeof e=="number")throw new TypeError("Argument must not be a number");return Xr(e,t,r)};Oi.alloc=function(e,t,r){if(typeof e!="number")throw new TypeError("Argument must be a number");var n=Xr(e);return t!==void 0?typeof r=="string"?n.fill(t,r):n.fill(t):n.fill(0),n};Oi.allocUnsafe=function(e){if(typeof e!="number")throw new TypeError("Argument must be a number");return Xr(e)};Oi.allocUnsafeSlow=function(e){if(typeof e!="number")throw new TypeError("Argument must be a number");return ru.SlowBuffer(e)}});var mo=B((JC,Al)=>{"use strict";p();var yo=typeof Reflect=="object"?Reflect:null,F0=yo&&typeof yo.apply=="function"?yo.apply:function(t,r,n){return Function.prototype.apply.call(t,r,n)},nu;yo&&typeof yo.ownKeys=="function"?nu=yo.ownKeys:Object.getOwnPropertySymbols?nu=function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:nu=function(t){return Object.getOwnPropertyNames(t)};function tA(e){console&&console.warn&&console.warn(e)}var H0=Number.isNaN||function(t){return t!==t};function qe(){qe.init.call(this)}Al.exports=qe;Al.exports.once=oA;qe.EventEmitter=qe;qe.prototype._events=void 0;qe.prototype._eventsCount=0;qe.prototype._maxListeners=void 0;var q0=10;function iu(e){if(typeof e!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}Object.defineProperty(qe,"defaultMaxListeners",{enumerable:!0,get:function(){return q0},set:function(e){if(typeof e!="number"||e<0||H0(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");q0=e}});qe.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};qe.prototype.setMaxListeners=function(t){if(typeof t!="number"||t<0||H0(t))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+t+".");return this._maxListeners=t,this};function j0(e){return e._maxListeners===void 0?qe.defaultMaxListeners:e._maxListeners}qe.prototype.getMaxListeners=function(){return j0(this)};qe.prototype.emit=function(t){for(var r=[],n=1;n<arguments.length;n++)r.push(arguments[n]);var i=t==="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 f=o[t];if(f===void 0)return!1;if(typeof f=="function")F0(f,this,r);else for(var l=f.length,y=z0(f,l),n=0;n<l;++n)F0(y[n],this,r);return!0};function K0(e,t,r,n){var i,o,s;if(iu(r),o=e._events,o===void 0?(o=e._events=Object.create(null),e._eventsCount=0):(o.newListener!==void 0&&(e.emit("newListener",t,r.listener?r.listener:r),o=e._events),s=o[t]),s===void 0)s=o[t]=r,++e._eventsCount;else if(typeof s=="function"?s=o[t]=n?[r,s]:[s,r]:n?s.unshift(r):s.push(r),i=j0(e),i>0&&s.length>i&&!s.warned){s.warned=!0;var a=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");a.name="MaxListenersExceededWarning",a.emitter=e,a.type=t,a.count=s.length,tA(a)}return e}qe.prototype.addListener=function(t,r){return K0(this,t,r,!1)};qe.prototype.on=qe.prototype.addListener;qe.prototype.prependListener=function(t,r){return K0(this,t,r,!0)};function rA(){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 G0(e,t,r){var n={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},i=rA.bind(n);return i.listener=r,n.wrapFn=i,i}qe.prototype.once=function(t,r){return iu(r),this.on(t,G0(this,t,r)),this};qe.prototype.prependOnceListener=function(t,r){return iu(r),this.prependListener(t,G0(this,t,r)),this};qe.prototype.removeListener=function(t,r){var n,i,o,s,a;if(iu(r),i=this._events,i===void 0)return this;if(n=i[t],n===void 0)return this;if(n===r||n.listener===r)--this._eventsCount===0?this._events=Object.create(null):(delete i[t],i.removeListener&&this.emit("removeListener",t,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():nA(n,o),n.length===1&&(i[t]=n[0]),i.removeListener!==void 0&&this.emit("removeListener",t,a||r)}return this};qe.prototype.off=qe.prototype.removeListener;qe.prototype.removeAllListeners=function(t){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[t]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete n[t]),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[t],typeof r=="function")this.removeListener(t,r);else if(r!==void 0)for(i=r.length-1;i>=0;i--)this.removeListener(t,r[i]);return this};function V0(e,t,r){var n=e._events;if(n===void 0)return[];var i=n[t];return i===void 0?[]:typeof i=="function"?r?[i.listener||i]:[i]:r?iA(i):z0(i,i.length)}qe.prototype.listeners=function(t){return V0(this,t,!0)};qe.prototype.rawListeners=function(t){return V0(this,t,!1)};qe.listenerCount=function(e,t){return typeof e.listenerCount=="function"?e.listenerCount(t):W0.call(e,t)};qe.prototype.listenerCount=W0;function W0(e){var t=this._events;if(t!==void 0){var r=t[e];if(typeof r=="function")return 1;if(r!==void 0)return r.length}return 0}qe.prototype.eventNames=function(){return this._eventsCount>0?nu(this._events):[]};function z0(e,t){for(var r=new Array(t),n=0;n<t;++n)r[n]=e[n];return r}function nA(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}function iA(e){for(var t=new Array(e.length),r=0;r<t.length;++r)t[r]=e[r].listener||e[r];return t}function oA(e,t){return new Promise(function(r,n){function i(s){e.removeListener(t,o),n(s)}function o(){typeof e.removeListener=="function"&&e.removeListener("error",i),r([].slice.call(arguments))}Y0(e,t,o,{once:!0}),t!=="error"&&sA(e,i,{once:!0})})}function sA(e,t,r){typeof e.on=="function"&&Y0(e,"error",t,r)}function Y0(e,t,r,n){if(typeof e.on=="function")n.once?e.once(t,r):e.on(t,r);else if(typeof e.addEventListener=="function")e.addEventListener(t,function i(o){n.once&&e.removeEventListener(t,i),r(o)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e)}});var Ol=B((eL,$0)=>{p();$0.exports=mo().EventEmitter});var ou=B((rL,Z0)=>{"use strict";p();Z0.exports=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var t={},r=Symbol("test"),n=Object(r);if(typeof r=="string"||Object.prototype.toString.call(r)!=="[object Symbol]"||Object.prototype.toString.call(n)!=="[object Symbol]")return!1;var i=42;t[r]=i;for(var o in t)return!1;if(typeof Object.keys=="function"&&Object.keys(t).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(t).length!==0)return!1;var s=Object.getOwnPropertySymbols(t);if(s.length!==1||s[0]!==r||!Object.prototype.propertyIsEnumerable.call(t,r))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var a=Object.getOwnPropertyDescriptor(t,r);if(a.value!==i||a.enumerable!==!0)return!1}return!0}});var vs=B((iL,X0)=>{"use strict";p();var aA=ou();X0.exports=function(){return aA()&&!!Symbol.toStringTag}});var su=B((sL,J0)=>{"use strict";p();J0.exports=Object});var eg=B((uL,Q0)=>{"use strict";p();Q0.exports=Error});var rg=B((cL,tg)=>{"use strict";p();tg.exports=EvalError});var ig=B((hL,ng)=>{"use strict";p();ng.exports=RangeError});var sg=B((pL,og)=>{"use strict";p();og.exports=ReferenceError});var Rl=B((yL,ag)=>{"use strict";p();ag.exports=SyntaxError});var Ri=B((vL,ug)=>{"use strict";p();ug.exports=TypeError});var cg=B((_L,fg)=>{"use strict";p();fg.exports=URIError});var hg=B((wL,lg)=>{"use strict";p();lg.exports=Math.abs});var pg=B((xL,dg)=>{"use strict";p();dg.exports=Math.floor});var yg=B((AL,gg)=>{"use strict";p();gg.exports=Math.max});var vg=B((RL,mg)=>{"use strict";p();mg.exports=Math.min});var _g=B((PL,bg)=>{"use strict";p();bg.exports=Math.pow});var wg=B((NL,Sg)=>{"use strict";p();Sg.exports=Math.round});var xg=B((kL,Eg)=>{"use strict";p();Eg.exports=Number.isNaN||function(t){return t!==t}});var Ag=B((LL,Ig)=>{"use strict";p();var uA=xg();Ig.exports=function(t){return uA(t)||t===0?t:t<0?-1:1}});var Rg=B((UL,Og)=>{"use strict";p();Og.exports=Object.getOwnPropertyDescriptor});var Ti=B((qL,Tg)=>{"use strict";p();var au=Rg();if(au)try{au([],"length")}catch{au=null}Tg.exports=au});var bs=B((jL,Pg)=>{"use strict";p();var uu=Object.defineProperty||!1;if(uu)try{uu({},"a",{value:1})}catch{uu=!1}Pg.exports=uu});var Mg=B((GL,Ng)=>{"use strict";p();var Bg=typeof Symbol<"u"&&Symbol,fA=ou();Ng.exports=function(){return typeof Bg!="function"||typeof Symbol!="function"||typeof Bg("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:fA()}});var Tl=B((WL,kg)=>{"use strict";p();kg.exports=typeof Reflect<"u"&&Reflect.getPrototypeOf||null});var Pl=B((YL,Cg)=>{"use strict";p();var cA=su();Cg.exports=cA.getPrototypeOf||null});var Ug=B((ZL,Dg)=>{"use strict";p();var lA="Function.prototype.bind called on incompatible ",hA=Object.prototype.toString,dA=Math.max,pA="[object Function]",Lg=function(t,r){for(var n=[],i=0;i<t.length;i+=1)n[i]=t[i];for(var o=0;o<r.length;o+=1)n[o+t.length]=r[o];return n},gA=function(t,r){for(var n=[],i=r||0,o=0;i<t.length;i+=1,o+=1)n[o]=t[i];return n},yA=function(e,t){for(var r="",n=0;n<e.length;n+=1)r+=e[n],n+1<e.length&&(r+=t);return r};Dg.exports=function(t){var r=this;if(typeof r!="function"||hA.apply(r)!==pA)throw new TypeError(lA+r);for(var n=gA(arguments,1),i,o=function(){if(this instanceof i){var y=r.apply(this,Lg(n,arguments));return Object(y)===y?y:this}return r.apply(t,Lg(n,arguments))},s=dA(0,r.length-n.length),a=[],f=0;f<s;f++)a[f]="$"+f;if(i=Function("binder","return function ("+yA(a,",")+"){ return binder.apply(this,arguments); }")(o),r.prototype){var l=function(){};l.prototype=r.prototype,i.prototype=new l,l.prototype=null}return i}});var vo=B((JL,Fg)=>{"use strict";p();var mA=Ug();Fg.exports=Function.prototype.bind||mA});var fu=B((e8,qg)=>{"use strict";p();qg.exports=Function.prototype.call});var cu=B((r8,Hg)=>{"use strict";p();Hg.exports=Function.prototype.apply});var Kg=B((i8,jg)=>{"use strict";p();jg.exports=typeof Reflect<"u"&&Reflect&&Reflect.apply});var Bl=B((s8,Gg)=>{"use strict";p();var vA=vo(),bA=cu(),_A=fu(),SA=Kg();Gg.exports=SA||vA.call(_A,bA)});var lu=B((u8,Vg)=>{"use strict";p();var wA=vo(),EA=Ri(),xA=fu(),IA=Bl();Vg.exports=function(t){if(t.length<1||typeof t[0]!="function")throw new EA("a function is required");return IA(wA,xA,t)}});var Xg=B((c8,Zg)=>{"use strict";p();var AA=lu(),Wg=Ti(),Yg;try{Yg=[].__proto__===Array.prototype}catch(e){if(!e||typeof e!="object"||!("code"in e)||e.code!=="ERR_PROTO_ACCESS")throw e}var Nl=!!Yg&&Wg&&Wg(Object.prototype,"__proto__"),$g=Object,zg=$g.getPrototypeOf;Zg.exports=Nl&&typeof Nl.get=="function"?AA([Nl.get]):typeof zg=="function"?function(t){return zg(t==null?t:$g(t))}:!1});var hu=B((h8,ty)=>{"use strict";p();var Jg=Tl(),Qg=Pl(),ey=Xg();ty.exports=Jg?function(t){return Jg(t)}:Qg?function(t){if(!t||typeof t!="object"&&typeof t!="function")throw new TypeError("getProto: not an object");return Qg(t)}:ey?function(t){return ey(t)}:null});var Ml=B((p8,ry)=>{"use strict";p();var OA=Function.prototype.call,RA=Object.prototype.hasOwnProperty,TA=vo();ry.exports=TA.call(OA,RA)});var gu=B((y8,uy)=>{"use strict";p();var Ie,PA=su(),BA=eg(),NA=rg(),MA=ig(),kA=sg(),wo=Rl(),So=Ri(),CA=cg(),LA=hg(),DA=pg(),UA=yg(),FA=vg(),qA=_g(),HA=wg(),jA=Ag(),sy=Function,kl=function(e){try{return sy('"use strict"; return ('+e+").constructor;")()}catch{}},_s=Ti(),KA=bs(),Cl=function(){throw new So},GA=_s?(function(){try{return arguments.callee,Cl}catch{try{return _s(arguments,"callee").get}catch{return Cl}}})():Cl,bo=Mg()(),Ht=hu(),VA=Pl(),WA=Tl(),ay=cu(),Ss=fu(),_o={},zA=typeof Uint8Array>"u"||!Ht?Ie:Ht(Uint8Array),Pi={__proto__:null,"%AggregateError%":typeof AggregateError>"u"?Ie:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?Ie:ArrayBuffer,"%ArrayIteratorPrototype%":bo&&Ht?Ht([][Symbol.iterator]()):Ie,"%AsyncFromSyncIteratorPrototype%":Ie,"%AsyncFunction%":_o,"%AsyncGenerator%":_o,"%AsyncGeneratorFunction%":_o,"%AsyncIteratorPrototype%":_o,"%Atomics%":typeof Atomics>"u"?Ie:Atomics,"%BigInt%":typeof BigInt>"u"?Ie:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?Ie:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?Ie:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?Ie:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":BA,"%eval%":eval,"%EvalError%":NA,"%Float16Array%":typeof Float16Array>"u"?Ie:Float16Array,"%Float32Array%":typeof Float32Array>"u"?Ie:Float32Array,"%Float64Array%":typeof Float64Array>"u"?Ie:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?Ie:FinalizationRegistry,"%Function%":sy,"%GeneratorFunction%":_o,"%Int8Array%":typeof Int8Array>"u"?Ie:Int8Array,"%Int16Array%":typeof Int16Array>"u"?Ie:Int16Array,"%Int32Array%":typeof Int32Array>"u"?Ie:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":bo&&Ht?Ht(Ht([][Symbol.iterator]())):Ie,"%JSON%":typeof JSON=="object"?JSON:Ie,"%Map%":typeof Map>"u"?Ie:Map,"%MapIteratorPrototype%":typeof Map>"u"||!bo||!Ht?Ie:Ht(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":PA,"%Object.getOwnPropertyDescriptor%":_s,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?Ie:Promise,"%Proxy%":typeof Proxy>"u"?Ie:Proxy,"%RangeError%":MA,"%ReferenceError%":kA,"%Reflect%":typeof Reflect>"u"?Ie:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?Ie:Set,"%SetIteratorPrototype%":typeof Set>"u"||!bo||!Ht?Ie:Ht(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?Ie:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":bo&&Ht?Ht(""[Symbol.iterator]()):Ie,"%Symbol%":bo?Symbol:Ie,"%SyntaxError%":wo,"%ThrowTypeError%":GA,"%TypedArray%":zA,"%TypeError%":So,"%Uint8Array%":typeof Uint8Array>"u"?Ie:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?Ie:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?Ie:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?Ie:Uint32Array,"%URIError%":CA,"%WeakMap%":typeof WeakMap>"u"?Ie:WeakMap,"%WeakRef%":typeof WeakRef>"u"?Ie:WeakRef,"%WeakSet%":typeof WeakSet>"u"?Ie:WeakSet,"%Function.prototype.call%":Ss,"%Function.prototype.apply%":ay,"%Object.defineProperty%":KA,"%Object.getPrototypeOf%":VA,"%Math.abs%":LA,"%Math.floor%":DA,"%Math.max%":UA,"%Math.min%":FA,"%Math.pow%":qA,"%Math.round%":HA,"%Math.sign%":jA,"%Reflect.getPrototypeOf%":WA};if(Ht)try{null.error}catch(e){ny=Ht(Ht(e)),Pi["%Error.prototype%"]=ny}var ny,YA=function e(t){var r;if(t==="%AsyncFunction%")r=kl("async function () {}");else if(t==="%GeneratorFunction%")r=kl("function* () {}");else if(t==="%AsyncGeneratorFunction%")r=kl("async function* () {}");else if(t==="%AsyncGenerator%"){var n=e("%AsyncGeneratorFunction%");n&&(r=n.prototype)}else if(t==="%AsyncIteratorPrototype%"){var i=e("%AsyncGenerator%");i&&Ht&&(r=Ht(i.prototype))}return Pi[t]=r,r},iy={__proto__:null,"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},ws=vo(),du=Ml(),$A=ws.call(Ss,Array.prototype.concat),ZA=ws.call(ay,Array.prototype.splice),oy=ws.call(Ss,String.prototype.replace),pu=ws.call(Ss,String.prototype.slice),XA=ws.call(Ss,RegExp.prototype.exec),JA=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,QA=/\\(\\)?/g,eO=function(t){var r=pu(t,0,1),n=pu(t,-1);if(r==="%"&&n!=="%")throw new wo("invalid intrinsic syntax, expected closing `%`");if(n==="%"&&r!=="%")throw new wo("invalid intrinsic syntax, expected opening `%`");var i=[];return oy(t,JA,function(o,s,a,f){i[i.length]=a?oy(f,QA,"$1"):s||o}),i},tO=function(t,r){var n=t,i;if(du(iy,n)&&(i=iy[n],n="%"+i[0]+"%"),du(Pi,n)){var o=Pi[n];if(o===_o&&(o=YA(n)),typeof o>"u"&&!r)throw new So("intrinsic "+t+" exists, but is not available. Please file an issue!");return{alias:i,name:n,value:o}}throw new wo("intrinsic "+t+" does not exist!")};uy.exports=function(t,r){if(typeof t!="string"||t.length===0)throw new So("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof r!="boolean")throw new So('"allowMissing" argument must be a boolean');if(XA(/^%?[^%]*%?$/,t)===null)throw new wo("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var n=eO(t),i=n.length>0?n[0]:"",o=tO("%"+i+"%",r),s=o.name,a=o.value,f=!1,l=o.alias;l&&(i=l[0],ZA(n,$A([0,1],l)));for(var y=1,g=!0;y<n.length;y+=1){var v=n[y],E=pu(v,0,1),T=pu(v,-1);if((E==='"'||E==="'"||E==="`"||T==='"'||T==="'"||T==="`")&&E!==T)throw new wo("property names with quotes must have matching quotes");if((v==="constructor"||!g)&&(f=!0),i+="."+v,s="%"+i+"%",du(Pi,s))a=Pi[s];else if(a!=null){if(!(v in a)){if(!r)throw new So("base intrinsic for "+t+" exists, but the property is not available.");return}if(_s&&y+1>=n.length){var M=_s(a,v);g=!!M,g&&"get"in M&&!("originalValue"in M.get)?a=M.get:a=a[v]}else g=du(a,v),a=a[v];g&&!f&&(Pi[s]=a)}}return a}});var Vn=B((v8,ly)=>{"use strict";p();var fy=gu(),cy=lu(),rO=cy([fy("%String.prototype.indexOf%")]);ly.exports=function(t,r){var n=fy(t,!!r);return typeof n=="function"&&rO(t,".prototype.")>-1?cy([n]):n}});var py=B((_8,dy)=>{"use strict";p();var nO=vs()(),iO=Vn(),Ll=iO("Object.prototype.toString"),yu=function(t){return nO&&t&&typeof t=="object"&&Symbol.toStringTag in t?!1:Ll(t)==="[object Arguments]"},hy=function(t){return yu(t)?!0:t!==null&&typeof t=="object"&&"length"in t&&typeof t.length=="number"&&t.length>=0&&Ll(t)!=="[object Array]"&&"callee"in t&&Ll(t.callee)==="[object Function]"},oO=(function(){return yu(arguments)})();yu.isLegacyArguments=hy;dy.exports=oO?yu:hy});var _y=B((w8,by)=>{"use strict";p();var gy=Vn(),sO=vs()(),aO=Ml(),uO=Ti(),Fl;sO?(yy=gy("RegExp.prototype.exec"),Dl={},mu=function(){throw Dl},Ul={toString:mu,valueOf:mu},typeof Symbol.toPrimitive=="symbol"&&(Ul[Symbol.toPrimitive]=mu),Fl=function(t){if(!t||typeof t!="object")return!1;var r=uO(t,"lastIndex"),n=r&&aO(r,"value");if(!n)return!1;try{yy(t,Ul)}catch(i){return i===Dl}}):(my=gy("Object.prototype.toString"),vy="[object RegExp]",Fl=function(t){return!t||typeof t!="object"&&typeof t!="function"?!1:my(t)===vy});var yy,Dl,mu,Ul,my,vy;by.exports=Fl});var wy=B((x8,Sy)=>{"use strict";p();var fO=Vn(),cO=_y(),lO=fO("RegExp.prototype.exec"),hO=Ri();Sy.exports=function(t){if(!cO(t))throw new hO("`regex` must be a RegExp");return function(n){return lO(t,n)!==null}}});var xy=B((A8,Ey)=>{"use strict";p();var dO=function*(){}.constructor;Ey.exports=()=>dO});var Ry=B((R8,Oy)=>{"use strict";p();var Ay=Vn(),pO=wy(),gO=pO(/^\s*(?:function)?\*/),yO=vs()(),Iy=hu(),mO=Ay("Object.prototype.toString"),vO=Ay("Function.prototype.toString"),bO=xy();Oy.exports=function(t){if(typeof t!="function")return!1;if(gO(vO(t)))return!0;if(!yO){var r=mO(t);return r==="[object GeneratorFunction]"}if(!Iy)return!1;var n=bO();return n&&Iy(t)===n.prototype}});var Ny=B((P8,By)=>{"use strict";p();var Py=Function.prototype.toString,Eo=typeof Reflect=="object"&&Reflect!==null&&Reflect.apply,Hl,vu;if(typeof Eo=="function"&&typeof Object.defineProperty=="function")try{Hl=Object.defineProperty({},"length",{get:function(){throw vu}}),vu={},Eo(function(){throw 42},null,Hl)}catch(e){e!==vu&&(Eo=null)}else Eo=null;var _O=/^\s*class\b/,jl=function(t){try{var r=Py.call(t);return _O.test(r)}catch{return!1}},ql=function(t){try{return jl(t)?!1:(Py.call(t),!0)}catch{return!1}},bu=Object.prototype.toString,SO="[object Object]",wO="[object Function]",EO="[object GeneratorFunction]",xO="[object HTMLAllCollection]",IO="[object HTML document.all class]",AO="[object HTMLCollection]",OO=typeof Symbol=="function"&&!!Symbol.toStringTag,RO=!(0 in[,]),Kl=function(){return!1};typeof document=="object"&&(Ty=document.all,bu.call(Ty)===bu.call(document.all)&&(Kl=function(t){if((RO||!t)&&(typeof t>"u"||typeof t=="object"))try{var r=bu.call(t);return(r===xO||r===IO||r===AO||r===SO)&&t("")==null}catch{}return!1}));var Ty;By.exports=Eo?function(t){if(Kl(t))return!0;if(!t||typeof t!="function"&&typeof t!="object")return!1;try{Eo(t,null,Hl)}catch(r){if(r!==vu)return!1}return!jl(t)&&ql(t)}:function(t){if(Kl(t))return!0;if(!t||typeof t!="function"&&typeof t!="object")return!1;if(OO)return ql(t);if(jl(t))return!1;var r=bu.call(t);return r!==wO&&r!==EO&&!/^\[object HTML/.test(r)?!1:ql(t)}});var Cy=B((N8,ky)=>{"use strict";p();var TO=Ny(),PO=Object.prototype.toString,My=Object.prototype.hasOwnProperty,BO=function(t,r,n){for(var i=0,o=t.length;i<o;i++)My.call(t,i)&&(n==null?r(t[i],i,t):r.call(n,t[i],i,t))},NO=function(t,r,n){for(var i=0,o=t.length;i<o;i++)n==null?r(t.charAt(i),i,t):r.call(n,t.charAt(i),i,t)},MO=function(t,r,n){for(var i in t)My.call(t,i)&&(n==null?r(t[i],i,t):r.call(n,t[i],i,t))};function kO(e){return PO.call(e)==="[object Array]"}ky.exports=function(t,r,n){if(!TO(r))throw new TypeError("iterator must be a function");var i;arguments.length>=3&&(i=n),kO(t)?BO(t,r,i):typeof t=="string"?NO(t,r,i):MO(t,r,i)}});var Dy=B((k8,Ly)=>{"use strict";p();Ly.exports=["Float16Array","Float32Array","Float64Array","Int8Array","Int16Array","Int32Array","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array"]});var Fy=B((L8,Uy)=>{"use strict";p();var Gl=Dy(),CO=globalThis;Uy.exports=function(){for(var t=[],r=0;r<Gl.length;r++)typeof CO[Gl[r]]=="function"&&(t[t.length]=Gl[r]);return t}});var Vl=B((U8,jy)=>{"use strict";p();var qy=bs(),LO=Rl(),xo=Ri(),Hy=Ti();jy.exports=function(t,r,n){if(!t||typeof t!="object"&&typeof t!="function")throw new xo("`obj` must be an object or a function`");if(typeof r!="string"&&typeof r!="symbol")throw new xo("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!="boolean"&&arguments[3]!==null)throw new xo("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!="boolean"&&arguments[4]!==null)throw new xo("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!="boolean"&&arguments[5]!==null)throw new xo("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!="boolean")throw new xo("`loose`, if provided, must be a boolean");var i=arguments.length>3?arguments[3]:null,o=arguments.length>4?arguments[4]:null,s=arguments.length>5?arguments[5]:null,a=arguments.length>6?arguments[6]:!1,f=!!Hy&&Hy(t,r);if(qy)qy(t,r,{configurable:s===null&&f?f.configurable:!s,enumerable:i===null&&f?f.enumerable:!i,value:n,writable:o===null&&f?f.writable:!o});else if(a||!i&&!o&&!s)t[r]=n;else throw new LO("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")}});var zl=B((q8,Gy)=>{"use strict";p();var Wl=bs(),Ky=function(){return!!Wl};Ky.hasArrayLengthDefineBug=function(){if(!Wl)return null;try{return Wl([],"length",{value:1}).length!==1}catch{return!0}};Gy.exports=Ky});var $y=B((j8,Yy)=>{"use strict";p();var DO=gu(),Vy=Vl(),UO=zl()(),Wy=Ti(),zy=Ri(),FO=DO("%Math.floor%");Yy.exports=function(t,r){if(typeof t!="function")throw new zy("`fn` is not a function");if(typeof r!="number"||r<0||r>4294967295||FO(r)!==r)throw new zy("`length` must be a positive 32-bit integer");var n=arguments.length>2&&!!arguments[2],i=!0,o=!0;if("length"in t&&Wy){var s=Wy(t,"length");s&&!s.configurable&&(i=!1),s&&!s.writable&&(o=!1)}return(i||o||!n)&&(UO?Vy(t,"length",r,!0,!0):Vy(t,"length",r)),t}});var Xy=B((G8,Zy)=>{"use strict";p();var qO=vo(),HO=cu(),jO=Bl();Zy.exports=function(){return jO(qO,HO,arguments)}});var Es=B((W8,_u)=>{"use strict";p();var KO=$y(),Jy=bs(),GO=lu(),Qy=Xy();_u.exports=function(t){var r=GO(arguments),n=1+t.length-(arguments.length-1);return KO(r,n>0?n:0,!0)};Jy?Jy(_u.exports,"apply",{value:Qy}):_u.exports.apply=Qy});var Xl=B((Y8,nm)=>{"use strict";p();var Eu=Cy(),VO=Fy(),em=Es(),$l=Vn(),wu=Ti(),Su=hu(),WO=$l("Object.prototype.toString"),rm=vs()(),tm=globalThis,Yl=VO(),Zl=$l("String.prototype.slice"),zO=$l("Array.prototype.indexOf",!0)||function(t,r){for(var n=0;n<t.length;n+=1)if(t[n]===r)return n;return-1},xu={__proto__:null};rm&&wu&&Su?Eu(Yl,function(e){var t=new tm[e];if(Symbol.toStringTag in t&&Su){var r=Su(t),n=wu(r,Symbol.toStringTag);if(!n&&r){var i=Su(r);n=wu(i,Symbol.toStringTag)}if(n&&n.get){var o=em(n.get);xu["$"+e]=o}}}):Eu(Yl,function(e){var t=new tm[e],r=t.slice||t.set;if(r){var n=em(r);xu["$"+e]=n}});var YO=function(t){var r=!1;return Eu(xu,function(n,i){if(!r)try{"$"+n(t)===i&&(r=Zl(i,1))}catch{}}),r},$O=function(t){var r=!1;return Eu(xu,function(n,i){if(!r)try{n(t),r=Zl(i,1)}catch{}}),r};nm.exports=function(t){if(!t||typeof t!="object")return!1;if(!rm){var r=Zl(WO(t),8,-1);return zO(Yl,r)>-1?r:r!=="Object"?!1:$O(t)}return wu?YO(t):null}});var Jl=B((Z8,im)=>{"use strict";p();var ZO=Xl();im.exports=function(t){return!!ZO(t)}});var vm=B(Ae=>{"use strict";p();var XO=py(),JO=Ry(),Pr=Xl(),om=Jl();function Io(e){return e.call.bind(e)}var sm=typeof BigInt<"u",am=typeof Symbol<"u",_r=Io(Object.prototype.toString),QO=Io(Number.prototype.valueOf),eR=Io(String.prototype.valueOf),tR=Io(Boolean.prototype.valueOf);sm&&(um=Io(BigInt.prototype.valueOf));var um;am&&(fm=Io(Symbol.prototype.valueOf));var fm;function Is(e,t){if(typeof e!="object")return!1;try{return t(e),!0}catch{return!1}}Ae.isArgumentsObject=XO;Ae.isGeneratorFunction=JO;Ae.isTypedArray=om;function rR(e){return typeof Promise<"u"&&e instanceof Promise||e!==null&&typeof e=="object"&&typeof e.then=="function"&&typeof e.catch=="function"}Ae.isPromise=rR;function nR(e){return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?ArrayBuffer.isView(e):om(e)||lm(e)}Ae.isArrayBufferView=nR;function iR(e){return Pr(e)==="Uint8Array"}Ae.isUint8Array=iR;function oR(e){return Pr(e)==="Uint8ClampedArray"}Ae.isUint8ClampedArray=oR;function sR(e){return Pr(e)==="Uint16Array"}Ae.isUint16Array=sR;function aR(e){return Pr(e)==="Uint32Array"}Ae.isUint32Array=aR;function uR(e){return Pr(e)==="Int8Array"}Ae.isInt8Array=uR;function fR(e){return Pr(e)==="Int16Array"}Ae.isInt16Array=fR;function cR(e){return Pr(e)==="Int32Array"}Ae.isInt32Array=cR;function lR(e){return Pr(e)==="Float32Array"}Ae.isFloat32Array=lR;function hR(e){return Pr(e)==="Float64Array"}Ae.isFloat64Array=hR;function dR(e){return Pr(e)==="BigInt64Array"}Ae.isBigInt64Array=dR;function pR(e){return Pr(e)==="BigUint64Array"}Ae.isBigUint64Array=pR;function Iu(e){return _r(e)==="[object Map]"}Iu.working=typeof Map<"u"&&Iu(new Map);function gR(e){return typeof Map>"u"?!1:Iu.working?Iu(e):e instanceof Map}Ae.isMap=gR;function Au(e){return _r(e)==="[object Set]"}Au.working=typeof Set<"u"&&Au(new Set);function yR(e){return typeof Set>"u"?!1:Au.working?Au(e):e instanceof Set}Ae.isSet=yR;function Ou(e){return _r(e)==="[object WeakMap]"}Ou.working=typeof WeakMap<"u"&&Ou(new WeakMap);function mR(e){return typeof WeakMap>"u"?!1:Ou.working?Ou(e):e instanceof WeakMap}Ae.isWeakMap=mR;function eh(e){return _r(e)==="[object WeakSet]"}eh.working=typeof WeakSet<"u"&&eh(new WeakSet);function vR(e){return eh(e)}Ae.isWeakSet=vR;function Ru(e){return _r(e)==="[object ArrayBuffer]"}Ru.working=typeof ArrayBuffer<"u"&&Ru(new ArrayBuffer);function cm(e){return typeof ArrayBuffer>"u"?!1:Ru.working?Ru(e):e instanceof ArrayBuffer}Ae.isArrayBuffer=cm;function Tu(e){return _r(e)==="[object DataView]"}Tu.working=typeof ArrayBuffer<"u"&&typeof DataView<"u"&&Tu(new DataView(new ArrayBuffer(1),0,1));function lm(e){return typeof DataView>"u"?!1:Tu.working?Tu(e):e instanceof DataView}Ae.isDataView=lm;var Ql=typeof SharedArrayBuffer<"u"?SharedArrayBuffer:void 0;function xs(e){return _r(e)==="[object SharedArrayBuffer]"}function hm(e){return typeof Ql>"u"?!1:(typeof xs.working>"u"&&(xs.working=xs(new Ql)),xs.working?xs(e):e instanceof Ql)}Ae.isSharedArrayBuffer=hm;function bR(e){return _r(e)==="[object AsyncFunction]"}Ae.isAsyncFunction=bR;function _R(e){return _r(e)==="[object Map Iterator]"}Ae.isMapIterator=_R;function SR(e){return _r(e)==="[object Set Iterator]"}Ae.isSetIterator=SR;function wR(e){return _r(e)==="[object Generator]"}Ae.isGeneratorObject=wR;function ER(e){return _r(e)==="[object WebAssembly.Module]"}Ae.isWebAssemblyCompiledModule=ER;function dm(e){return Is(e,QO)}Ae.isNumberObject=dm;function pm(e){return Is(e,eR)}Ae.isStringObject=pm;function gm(e){return Is(e,tR)}Ae.isBooleanObject=gm;function ym(e){return sm&&Is(e,um)}Ae.isBigIntObject=ym;function mm(e){return am&&Is(e,fm)}Ae.isSymbolObject=mm;function xR(e){return dm(e)||pm(e)||gm(e)||ym(e)||mm(e)}Ae.isBoxedPrimitive=xR;function IR(e){return typeof Uint8Array<"u"&&(cm(e)||hm(e))}Ae.isAnyArrayBuffer=IR;["isProxy","isExternal","isModuleNamespaceObject"].forEach(function(e){Object.defineProperty(Ae,e,{enumerable:!1,value:function(){throw new Error(e+" is not supported in userland")}})})});var _m=B((e4,bm)=>{p();bm.exports=function(t){return t&&typeof t=="object"&&typeof t.copy=="function"&&typeof t.fill=="function"&&typeof t.readUInt8=="function"}});var Jr=B(Oe=>{p();var Sm=Object.getOwnPropertyDescriptors||function(t){for(var r=Object.keys(t),n={},i=0;i<r.length;i++)n[r[i]]=Object.getOwnPropertyDescriptor(t,r[i]);return n},AR=/%[sdj%]/g;Oe.format=function(e){if(!Lu(e)){for(var t=[],r=0;r<arguments.length;r++)t.push(Wn(arguments[r]));return t.join(" ")}for(var r=1,n=arguments,i=n.length,o=String(e).replace(AR,function(a){if(a==="%%")return"%";if(r>=i)return a;switch(a){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch{return"[Circular]"}default:return a}}),s=n[r];r<i;s=n[++r])Cu(s)||!Ao(s)?o+=" "+s:o+=" "+Wn(s);return o};Oe.deprecate=function(e,t){if(typeof x.default<"u"&&x.default.noDeprecation===!0)return e;if(typeof x.default>"u")return function(){return Oe.deprecate(e,t).apply(this,arguments)};var r=!1;function n(){if(!r){if(x.default.throwDeprecation)throw new Error(t);x.default.traceDeprecation?console.trace(t):console.error(t),r=!0}return e.apply(this,arguments)}return n};var Pu={},wm=/^$/;x.default.env.NODE_DEBUG&&(Bu=x.default.env.NODE_DEBUG,Bu=Bu.replace(/[|\\{}()[\]^$+?.]/g,"\\$&").replace(/\*/g,".*").replace(/,/g,"$|^").toUpperCase(),wm=new RegExp("^"+Bu+"$","i"));var Bu;Oe.debuglog=function(e){if(e=e.toUpperCase(),!Pu[e])if(wm.test(e)){var t=x.default.pid;Pu[e]=function(){var r=Oe.format.apply(Oe,arguments);console.error("%s %d: %s",e,t,r)}}else Pu[e]=function(){};return Pu[e]};function Wn(e,t){var r={seen:[],stylize:RR};return arguments.length>=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),ih(t)?r.showHidden=t:t&&Oe._extend(r,t),Ni(r.showHidden)&&(r.showHidden=!1),Ni(r.depth)&&(r.depth=2),Ni(r.colors)&&(r.colors=!1),Ni(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=OR),Mu(r,e,r.depth)}Oe.inspect=Wn;Wn.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]};Wn.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"};function OR(e,t){var r=Wn.styles[t];return r?"\x1B["+Wn.colors[r][0]+"m"+e+"\x1B["+Wn.colors[r][1]+"m":e}function RR(e,t){return e}function TR(e){var t={};return e.forEach(function(r,n){t[r]=!0}),t}function Mu(e,t,r){if(e.customInspect&&t&&Nu(t.inspect)&&t.inspect!==Oe.inspect&&!(t.constructor&&t.constructor.prototype===t)){var n=t.inspect(r,e);return Lu(n)||(n=Mu(e,n,r)),n}var i=PR(e,t);if(i)return i;var o=Object.keys(t),s=TR(o);if(e.showHidden&&(o=Object.getOwnPropertyNames(t)),Os(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return th(t);if(o.length===0){if(Nu(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(As(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(ku(t))return e.stylize(Date.prototype.toString.call(t),"date");if(Os(t))return th(t)}var f="",l=!1,y=["{","}"];if(Em(t)&&(l=!0,y=["[","]"]),Nu(t)){var g=t.name?": "+t.name:"";f=" [Function"+g+"]"}if(As(t)&&(f=" "+RegExp.prototype.toString.call(t)),ku(t)&&(f=" "+Date.prototype.toUTCString.call(t)),Os(t)&&(f=" "+th(t)),o.length===0&&(!l||t.length==0))return y[0]+f+y[1];if(r<0)return As(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special");e.seen.push(t);var v;return l?v=BR(e,t,r,s,o):v=o.map(function(E){return nh(e,t,r,s,E,l)}),e.seen.pop(),NR(v,f,y)}function PR(e,t){if(Ni(t))return e.stylize("undefined","undefined");if(Lu(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}if(xm(t))return e.stylize(""+t,"number");if(ih(t))return e.stylize(""+t,"boolean");if(Cu(t))return e.stylize("null","null")}function th(e){return"["+Error.prototype.toString.call(e)+"]"}function BR(e,t,r,n,i){for(var o=[],s=0,a=t.length;s<a;++s)Im(t,String(s))?o.push(nh(e,t,r,n,String(s),!0)):o.push("");return i.forEach(function(f){f.match(/^\d+$/)||o.push(nh(e,t,r,n,f,!0))}),o}function nh(e,t,r,n,i,o){var s,a,f;if(f=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]},f.get?f.set?a=e.stylize("[Getter/Setter]","special"):a=e.stylize("[Getter]","special"):f.set&&(a=e.stylize("[Setter]","special")),Im(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(f.value)<0?(Cu(r)?a=Mu(e,f.value,null):a=Mu(e,f.value,r-1),a.indexOf(`
1
+ var bsvLTP=(()=>{var yI=Object.create;var Ss=Object.defineProperty;var mI=Object.getOwnPropertyDescriptor;var vI=Object.getOwnPropertyNames;var bI=Object.getPrototypeOf,_I=Object.prototype.hasOwnProperty;var SI=(e,t,r)=>t in e?Ss(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var Xt=(e,t,r)=>()=>{if(r)throw r[0];try{return e&&(t=e(e=0)),t}catch(n){throw r=[n],n}};var B=(e,t)=>()=>{try{return t||e((t={exports:{}}).exports,t),t.exports}catch(r){throw t=0,r}},pl=(e,t)=>{for(var r in t)Ss(e,r,{get:t[r],enumerable:!0})},c0=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of vI(t))!_I.call(e,i)&&i!==r&&Ss(e,i,{get:()=>t[i],enumerable:!(n=mI(t,i))||n.enumerable});return e};var l0=(e,t,r)=>(r=e!=null?yI(bI(e)):{},c0(t||!e||!e.__esModule?Ss(r,"default",{value:e,enumerable:!0}):r,e)),gl=e=>c0(Ss({},"__esModule",{value:!0}),e);var J=(e,t,r)=>SI(e,typeof t!="symbol"?t+"":t,r);var y0=B((jC,g0)=>{g();var yt=g0.exports={},Xr,Jr;function yl(){throw new Error("setTimeout has not been defined")}function ml(){throw new Error("clearTimeout has not been defined")}(function(){try{typeof setTimeout=="function"?Xr=setTimeout:Xr=yl}catch{Xr=yl}try{typeof clearTimeout=="function"?Jr=clearTimeout:Jr=ml}catch{Jr=ml}})();function h0(e){if(Xr===setTimeout)return setTimeout(e,0);if((Xr===yl||!Xr)&&setTimeout)return Xr=setTimeout,setTimeout(e,0);try{return Xr(e,0)}catch{try{return Xr.call(null,e,0)}catch{return Xr.call(this,e,0)}}}function wI(e){if(Jr===clearTimeout)return clearTimeout(e);if((Jr===ml||!Jr)&&clearTimeout)return Jr=clearTimeout,clearTimeout(e);try{return Jr(e)}catch{try{return Jr.call(null,e)}catch{return Jr.call(this,e)}}}var bn=[],yo=!1,Ri,nu=-1;function EI(){!yo||!Ri||(yo=!1,Ri.length?bn=Ri.concat(bn):nu=-1,bn.length&&d0())}function d0(){if(!yo){var e=h0(EI);yo=!0;for(var t=bn.length;t;){for(Ri=bn,bn=[];++nu<t;)Ri&&Ri[nu].run();nu=-1,t=bn.length}Ri=null,yo=!1,wI(e)}}yt.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];bn.push(new p0(e,t)),bn.length===1&&!yo&&h0(d0)};function p0(e,t){this.fun=e,this.array=t}p0.prototype.run=function(){this.fun.apply(null,this.array)};yt.title="browser";yt.browser=!0;yt.env={};yt.argv=[];yt.version="";yt.versions={};function _n(){}yt.on=_n;yt.addListener=_n;yt.once=_n;yt.off=_n;yt.removeListener=_n;yt.removeAllListeners=_n;yt.emit=_n;yt.prependListener=_n;yt.prependOnceListener=_n;yt.listeners=function(e){return[]};yt.binding=function(e){throw new Error("process.binding is not supported")};yt.cwd=function(){return"/"};yt.chdir=function(e){throw new Error("process.chdir is not supported")};yt.umask=function(){return 0}});var b0=B(iu=>{"use strict";g();iu.byteLength=II;iu.toByteArray=OI;iu.fromByteArray=PI;var Qr=[],wr=[],xI=typeof Uint8Array<"u"?Uint8Array:Array,vl="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(Ti=0,m0=vl.length;Ti<m0;++Ti)Qr[Ti]=vl[Ti],wr[vl.charCodeAt(Ti)]=Ti;var Ti,m0;wr[45]=62;wr[95]=63;function v0(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");r===-1&&(r=t);var n=r===t?0:4-r%4;return[r,n]}function II(e){var t=v0(e),r=t[0],n=t[1];return(r+n)*3/4-n}function AI(e,t,r){return(t+r)*3/4-r}function OI(e){var t,r=v0(e),n=r[0],i=r[1],o=new xI(AI(e,n,i)),s=0,a=i>0?n-4:n,f;for(f=0;f<a;f+=4)t=wr[e.charCodeAt(f)]<<18|wr[e.charCodeAt(f+1)]<<12|wr[e.charCodeAt(f+2)]<<6|wr[e.charCodeAt(f+3)],o[s++]=t>>16&255,o[s++]=t>>8&255,o[s++]=t&255;return i===2&&(t=wr[e.charCodeAt(f)]<<2|wr[e.charCodeAt(f+1)]>>4,o[s++]=t&255),i===1&&(t=wr[e.charCodeAt(f)]<<10|wr[e.charCodeAt(f+1)]<<4|wr[e.charCodeAt(f+2)]>>2,o[s++]=t>>8&255,o[s++]=t&255),o}function RI(e){return Qr[e>>18&63]+Qr[e>>12&63]+Qr[e>>6&63]+Qr[e&63]}function TI(e,t,r){for(var n,i=[],o=t;o<r;o+=3)n=(e[o]<<16&16711680)+(e[o+1]<<8&65280)+(e[o+2]&255),i.push(RI(n));return i.join("")}function PI(e){for(var t,r=e.length,n=r%3,i=[],o=16383,s=0,a=r-n;s<a;s+=o)i.push(TI(e,s,s+o>a?a:s+o));return n===1?(t=e[r-1],i.push(Qr[t>>2]+Qr[t<<4&63]+"==")):n===2&&(t=(e[r-2]<<8)+e[r-1],i.push(Qr[t>>10]+Qr[t>>4&63]+Qr[t<<2&63]+"=")),i.join("")}});var _0=B(bl=>{g();bl.read=function(e,t,r,n,i){var o,s,a=i*8-n-1,f=(1<<a)-1,l=f>>1,m=-7,y=r?i-1:0,p=r?-1:1,w=e[t+y];for(y+=p,o=w&(1<<-m)-1,w>>=-m,m+=a;m>0;o=o*256+e[t+y],y+=p,m-=8);for(s=o&(1<<-m)-1,o>>=-m,m+=n;m>0;s=s*256+e[t+y],y+=p,m-=8);if(o===0)o=1-l;else{if(o===f)return s?NaN:(w?-1:1)*(1/0);s=s+Math.pow(2,n),o=o-l}return(w?-1:1)*s*Math.pow(2,o-n)};bl.write=function(e,t,r,n,i,o){var s,a,f,l=o*8-i-1,m=(1<<l)-1,y=m>>1,p=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,w=n?0:o-1,O=n?1:-1,M=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=m):(s=Math.floor(Math.log(t)/Math.LN2),t*(f=Math.pow(2,-s))<1&&(s--,f*=2),s+y>=1?t+=p/f:t+=p*Math.pow(2,1-y),t*f>=2&&(s++,f/=2),s+y>=m?(a=0,s=m):s+y>=1?(a=(t*f-1)*Math.pow(2,i),s=s+y):(a=t*Math.pow(2,y-1)*Math.pow(2,i),s=0));i>=8;e[r+w]=a&255,w+=O,a/=256,i-=8);for(s=s<<i|a,l+=i;l>0;e[r+w]=s&255,w+=O,s/=256,l-=8);e[r+w-O]|=M*128}});var Lt=B(_o=>{"use strict";g();var _l=b0(),vo=_0(),S0=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;_o.Buffer=j;_o.SlowBuffer=LI;_o.INSPECT_MAX_BYTES=50;var ou=2147483647;_o.kMaxLength=ou;j.TYPED_ARRAY_SUPPORT=BI();!j.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 BI(){try{let e=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(e,t),e.foo()===42}catch{return!1}}Object.defineProperty(j.prototype,"parent",{enumerable:!0,get:function(){if(j.isBuffer(this))return this.buffer}});Object.defineProperty(j.prototype,"offset",{enumerable:!0,get:function(){if(j.isBuffer(this))return this.byteOffset}});function Sn(e){if(e>ou)throw new RangeError('The value "'+e+'" is invalid for option "size"');let t=new Uint8Array(e);return Object.setPrototypeOf(t,j.prototype),t}function j(e,t,r){if(typeof e=="number"){if(typeof t=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return xl(e)}return I0(e,t,r)}j.poolSize=8192;function I0(e,t,r){if(typeof e=="string")return MI(e,t);if(ArrayBuffer.isView(e))return kI(e);if(e==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(en(e,ArrayBuffer)||e&&en(e.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(en(e,SharedArrayBuffer)||e&&en(e.buffer,SharedArrayBuffer)))return wl(e,t,r);if(typeof e=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let n=e.valueOf&&e.valueOf();if(n!=null&&n!==e)return j.from(n,t,r);let i=CI(e);if(i)return i;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof e[Symbol.toPrimitive]=="function")return j.from(e[Symbol.toPrimitive]("string"),t,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}j.from=function(e,t,r){return I0(e,t,r)};Object.setPrototypeOf(j.prototype,Uint8Array.prototype);Object.setPrototypeOf(j,Uint8Array);function A0(e){if(typeof e!="number")throw new TypeError('"size" argument must be of type number');if(e<0)throw new RangeError('The value "'+e+'" is invalid for option "size"')}function NI(e,t,r){return A0(e),e<=0?Sn(e):t!==void 0?typeof r=="string"?Sn(e).fill(t,r):Sn(e).fill(t):Sn(e)}j.alloc=function(e,t,r){return NI(e,t,r)};function xl(e){return A0(e),Sn(e<0?0:Il(e)|0)}j.allocUnsafe=function(e){return xl(e)};j.allocUnsafeSlow=function(e){return xl(e)};function MI(e,t){if((typeof t!="string"||t==="")&&(t="utf8"),!j.isEncoding(t))throw new TypeError("Unknown encoding: "+t);let r=O0(e,t)|0,n=Sn(r),i=n.write(e,t);return i!==r&&(n=n.slice(0,i)),n}function Sl(e){let t=e.length<0?0:Il(e.length)|0,r=Sn(t);for(let n=0;n<t;n+=1)r[n]=e[n]&255;return r}function kI(e){if(en(e,Uint8Array)){let t=new Uint8Array(e);return wl(t.buffer,t.byteOffset,t.byteLength)}return Sl(e)}function wl(e,t,r){if(t<0||e.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(e.byteLength<t+(r||0))throw new RangeError('"length" is outside of buffer bounds');let n;return t===void 0&&r===void 0?n=new Uint8Array(e):r===void 0?n=new Uint8Array(e,t):n=new Uint8Array(e,t,r),Object.setPrototypeOf(n,j.prototype),n}function CI(e){if(j.isBuffer(e)){let t=Il(e.length)|0,r=Sn(t);return r.length===0||e.copy(r,0,0,t),r}if(e.length!==void 0)return typeof e.length!="number"||Ol(e.length)?Sn(0):Sl(e);if(e.type==="Buffer"&&Array.isArray(e.data))return Sl(e.data)}function Il(e){if(e>=ou)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+ou.toString(16)+" bytes");return e|0}function LI(e){return+e!=e&&(e=0),j.alloc(+e)}j.isBuffer=function(t){return t!=null&&t._isBuffer===!0&&t!==j.prototype};j.compare=function(t,r){if(en(t,Uint8Array)&&(t=j.from(t,t.offset,t.byteLength)),en(r,Uint8Array)&&(r=j.from(r,r.offset,r.byteLength)),!j.isBuffer(t)||!j.isBuffer(r))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===r)return 0;let n=t.length,i=r.length;for(let o=0,s=Math.min(n,i);o<s;++o)if(t[o]!==r[o]){n=t[o],i=r[o];break}return n<i?-1:i<n?1:0};j.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}};j.concat=function(t,r){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(t.length===0)return j.alloc(0);let n;if(r===void 0)for(r=0,n=0;n<t.length;++n)r+=t[n].length;let i=j.allocUnsafe(r),o=0;for(n=0;n<t.length;++n){let s=t[n];if(en(s,Uint8Array))o+s.length>i.length?(j.isBuffer(s)||(s=j.from(s)),s.copy(i,o)):Uint8Array.prototype.set.call(i,s,o);else if(j.isBuffer(s))s.copy(i,o);else throw new TypeError('"list" argument must be an Array of Buffers');o+=s.length}return i};function O0(e,t){if(j.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||en(e,ArrayBuffer))return e.byteLength;if(typeof e!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);let r=e.length,n=arguments.length>2&&arguments[2]===!0;if(!n&&r===0)return 0;let i=!1;for(;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return El(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return L0(e).length;default:if(i)return n?-1:El(e).length;t=(""+t).toLowerCase(),i=!0}}j.byteLength=O0;function DI(e,t,r){let n=!1;if((t===void 0||t<0)&&(t=0),t>this.length||((r===void 0||r>this.length)&&(r=this.length),r<=0)||(r>>>=0,t>>>=0,r<=t))return"";for(e||(e="utf8");;)switch(e){case"hex":return zI(this,t,r);case"utf8":case"utf-8":return T0(this,t,r);case"ascii":return VI(this,t,r);case"latin1":case"binary":return WI(this,t,r);case"base64":return KI(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return YI(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}j.prototype._isBuffer=!0;function Pi(e,t,r){let n=e[t];e[t]=e[r],e[r]=n}j.prototype.swap16=function(){let t=this.length;if(t%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let r=0;r<t;r+=2)Pi(this,r,r+1);return this};j.prototype.swap32=function(){let t=this.length;if(t%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let r=0;r<t;r+=4)Pi(this,r,r+3),Pi(this,r+1,r+2);return this};j.prototype.swap64=function(){let t=this.length;if(t%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let r=0;r<t;r+=8)Pi(this,r,r+7),Pi(this,r+1,r+6),Pi(this,r+2,r+5),Pi(this,r+3,r+4);return this};j.prototype.toString=function(){let t=this.length;return t===0?"":arguments.length===0?T0(this,0,t):DI.apply(this,arguments)};j.prototype.toLocaleString=j.prototype.toString;j.prototype.equals=function(t){if(!j.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t?!0:j.compare(this,t)===0};j.prototype.inspect=function(){let t="",r=_o.INSPECT_MAX_BYTES;return t=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(t+=" ... "),"<Buffer "+t+">"};S0&&(j.prototype[S0]=j.prototype.inspect);j.prototype.compare=function(t,r,n,i,o){if(en(t,Uint8Array)&&(t=j.from(t,t.offset,t.byteLength)),!j.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(r===void 0&&(r=0),n===void 0&&(n=t?t.length:0),i===void 0&&(i=0),o===void 0&&(o=this.length),r<0||n>t.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===t)return 0;let s=o-i,a=n-r,f=Math.min(s,a),l=this.slice(i,o),m=t.slice(r,n);for(let y=0;y<f;++y)if(l[y]!==m[y]){s=l[y],a=m[y];break}return s<a?-1:a<s?1:0};function R0(e,t,r,n,i){if(e.length===0)return-1;if(typeof r=="string"?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,Ol(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0)if(i)r=0;else return-1;if(typeof t=="string"&&(t=j.from(t,n)),j.isBuffer(t))return t.length===0?-1:w0(e,t,r,n,i);if(typeof t=="number")return t=t&255,typeof Uint8Array.prototype.indexOf=="function"?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):w0(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function w0(e,t,r,n,i){let o=1,s=e.length,a=t.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(e.length<2||t.length<2)return-1;o=2,s/=2,a/=2,r/=2}function f(m,y){return o===1?m[y]:m.readUInt16BE(y*o)}let l;if(i){let m=-1;for(l=r;l<s;l++)if(f(e,l)===f(t,m===-1?0:l-m)){if(m===-1&&(m=l),l-m+1===a)return m*o}else m!==-1&&(l-=l-m),m=-1}else for(r+a>s&&(r=s-a),l=r;l>=0;l--){let m=!0;for(let y=0;y<a;y++)if(f(e,l+y)!==f(t,y)){m=!1;break}if(m)return l}return-1}j.prototype.includes=function(t,r,n){return this.indexOf(t,r,n)!==-1};j.prototype.indexOf=function(t,r,n){return R0(this,t,r,n,!0)};j.prototype.lastIndexOf=function(t,r,n){return R0(this,t,r,n,!1)};function UI(e,t,r,n){r=Number(r)||0;let i=e.length-r;n?(n=Number(n),n>i&&(n=i)):n=i;let o=t.length;n>o/2&&(n=o/2);let s;for(s=0;s<n;++s){let a=parseInt(t.substr(s*2,2),16);if(Ol(a))return s;e[r+s]=a}return s}function FI(e,t,r,n){return su(El(t,e.length-r),e,r,n)}function qI(e,t,r,n){return su(JI(t),e,r,n)}function HI(e,t,r,n){return su(L0(t),e,r,n)}function jI(e,t,r,n){return su(QI(t,e.length-r),e,r,n)}j.prototype.write=function(t,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),t.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 UI(this,t,r,n);case"utf8":case"utf-8":return FI(this,t,r,n);case"ascii":case"latin1":case"binary":return qI(this,t,r,n);case"base64":return HI(this,t,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return jI(this,t,r,n);default:if(s)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),s=!0}};j.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function KI(e,t,r){return t===0&&r===e.length?_l.fromByteArray(e):_l.fromByteArray(e.slice(t,r))}function T0(e,t,r){r=Math.min(e.length,r);let n=[],i=t;for(;i<r;){let o=e[i],s=null,a=o>239?4:o>223?3:o>191?2:1;if(i+a<=r){let f,l,m,y;switch(a){case 1:o<128&&(s=o);break;case 2:f=e[i+1],(f&192)===128&&(y=(o&31)<<6|f&63,y>127&&(s=y));break;case 3:f=e[i+1],l=e[i+2],(f&192)===128&&(l&192)===128&&(y=(o&15)<<12|(f&63)<<6|l&63,y>2047&&(y<55296||y>57343)&&(s=y));break;case 4:f=e[i+1],l=e[i+2],m=e[i+3],(f&192)===128&&(l&192)===128&&(m&192)===128&&(y=(o&15)<<18|(f&63)<<12|(l&63)<<6|m&63,y>65535&&y<1114112&&(s=y))}}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 GI(n)}var E0=4096;function GI(e){let t=e.length;if(t<=E0)return String.fromCharCode.apply(String,e);let r="",n=0;for(;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=E0));return r}function VI(e,t,r){let n="";r=Math.min(e.length,r);for(let i=t;i<r;++i)n+=String.fromCharCode(e[i]&127);return n}function WI(e,t,r){let n="";r=Math.min(e.length,r);for(let i=t;i<r;++i)n+=String.fromCharCode(e[i]);return n}function zI(e,t,r){let n=e.length;(!t||t<0)&&(t=0),(!r||r<0||r>n)&&(r=n);let i="";for(let o=t;o<r;++o)i+=eA[e[o]];return i}function YI(e,t,r){let n=e.slice(t,r),i="";for(let o=0;o<n.length-1;o+=2)i+=String.fromCharCode(n[o]+n[o+1]*256);return i}j.prototype.slice=function(t,r){let n=this.length;t=~~t,r=r===void 0?n:~~r,t<0?(t+=n,t<0&&(t=0)):t>n&&(t=n),r<0?(r+=n,r<0&&(r=0)):r>n&&(r=n),r<t&&(r=t);let i=this.subarray(t,r);return Object.setPrototypeOf(i,j.prototype),i};function jt(e,t,r){if(e%1!==0||e<0)throw new RangeError("offset is not uint");if(e+t>r)throw new RangeError("Trying to access beyond buffer length")}j.prototype.readUintLE=j.prototype.readUIntLE=function(t,r,n){t=t>>>0,r=r>>>0,n||jt(t,r,this.length);let i=this[t],o=1,s=0;for(;++s<r&&(o*=256);)i+=this[t+s]*o;return i};j.prototype.readUintBE=j.prototype.readUIntBE=function(t,r,n){t=t>>>0,r=r>>>0,n||jt(t,r,this.length);let i=this[t+--r],o=1;for(;r>0&&(o*=256);)i+=this[t+--r]*o;return i};j.prototype.readUint8=j.prototype.readUInt8=function(t,r){return t=t>>>0,r||jt(t,1,this.length),this[t]};j.prototype.readUint16LE=j.prototype.readUInt16LE=function(t,r){return t=t>>>0,r||jt(t,2,this.length),this[t]|this[t+1]<<8};j.prototype.readUint16BE=j.prototype.readUInt16BE=function(t,r){return t=t>>>0,r||jt(t,2,this.length),this[t]<<8|this[t+1]};j.prototype.readUint32LE=j.prototype.readUInt32LE=function(t,r){return t=t>>>0,r||jt(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+this[t+3]*16777216};j.prototype.readUint32BE=j.prototype.readUInt32BE=function(t,r){return t=t>>>0,r||jt(t,4,this.length),this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])};j.prototype.readBigUInt64LE=$n(function(t){t=t>>>0,bo(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&ws(t,this.length-8);let i=r+this[++t]*2**8+this[++t]*2**16+this[++t]*2**24,o=this[++t]+this[++t]*2**8+this[++t]*2**16+n*2**24;return BigInt(i)+(BigInt(o)<<BigInt(32))});j.prototype.readBigUInt64BE=$n(function(t){t=t>>>0,bo(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&ws(t,this.length-8);let i=r*2**24+this[++t]*2**16+this[++t]*2**8+this[++t],o=this[++t]*2**24+this[++t]*2**16+this[++t]*2**8+n;return(BigInt(i)<<BigInt(32))+BigInt(o)});j.prototype.readIntLE=function(t,r,n){t=t>>>0,r=r>>>0,n||jt(t,r,this.length);let i=this[t],o=1,s=0;for(;++s<r&&(o*=256);)i+=this[t+s]*o;return o*=128,i>=o&&(i-=Math.pow(2,8*r)),i};j.prototype.readIntBE=function(t,r,n){t=t>>>0,r=r>>>0,n||jt(t,r,this.length);let i=r,o=1,s=this[t+--i];for(;i>0&&(o*=256);)s+=this[t+--i]*o;return o*=128,s>=o&&(s-=Math.pow(2,8*r)),s};j.prototype.readInt8=function(t,r){return t=t>>>0,r||jt(t,1,this.length),this[t]&128?(255-this[t]+1)*-1:this[t]};j.prototype.readInt16LE=function(t,r){t=t>>>0,r||jt(t,2,this.length);let n=this[t]|this[t+1]<<8;return n&32768?n|4294901760:n};j.prototype.readInt16BE=function(t,r){t=t>>>0,r||jt(t,2,this.length);let n=this[t+1]|this[t]<<8;return n&32768?n|4294901760:n};j.prototype.readInt32LE=function(t,r){return t=t>>>0,r||jt(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24};j.prototype.readInt32BE=function(t,r){return t=t>>>0,r||jt(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]};j.prototype.readBigInt64LE=$n(function(t){t=t>>>0,bo(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&ws(t,this.length-8);let i=this[t+4]+this[t+5]*2**8+this[t+6]*2**16+(n<<24);return(BigInt(i)<<BigInt(32))+BigInt(r+this[++t]*2**8+this[++t]*2**16+this[++t]*2**24)});j.prototype.readBigInt64BE=$n(function(t){t=t>>>0,bo(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&ws(t,this.length-8);let i=(r<<24)+this[++t]*2**16+this[++t]*2**8+this[++t];return(BigInt(i)<<BigInt(32))+BigInt(this[++t]*2**24+this[++t]*2**16+this[++t]*2**8+n)});j.prototype.readFloatLE=function(t,r){return t=t>>>0,r||jt(t,4,this.length),vo.read(this,t,!0,23,4)};j.prototype.readFloatBE=function(t,r){return t=t>>>0,r||jt(t,4,this.length),vo.read(this,t,!1,23,4)};j.prototype.readDoubleLE=function(t,r){return t=t>>>0,r||jt(t,8,this.length),vo.read(this,t,!0,52,8)};j.prototype.readDoubleBE=function(t,r){return t=t>>>0,r||jt(t,8,this.length),vo.read(this,t,!1,52,8)};function lr(e,t,r,n,i,o){if(!j.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<o)throw new RangeError('"value" argument is out of bounds');if(r+n>e.length)throw new RangeError("Index out of range")}j.prototype.writeUintLE=j.prototype.writeUIntLE=function(t,r,n,i){if(t=+t,r=r>>>0,n=n>>>0,!i){let a=Math.pow(2,8*n)-1;lr(this,t,r,n,a,0)}let o=1,s=0;for(this[r]=t&255;++s<n&&(o*=256);)this[r+s]=t/o&255;return r+n};j.prototype.writeUintBE=j.prototype.writeUIntBE=function(t,r,n,i){if(t=+t,r=r>>>0,n=n>>>0,!i){let a=Math.pow(2,8*n)-1;lr(this,t,r,n,a,0)}let o=n-1,s=1;for(this[r+o]=t&255;--o>=0&&(s*=256);)this[r+o]=t/s&255;return r+n};j.prototype.writeUint8=j.prototype.writeUInt8=function(t,r,n){return t=+t,r=r>>>0,n||lr(this,t,r,1,255,0),this[r]=t&255,r+1};j.prototype.writeUint16LE=j.prototype.writeUInt16LE=function(t,r,n){return t=+t,r=r>>>0,n||lr(this,t,r,2,65535,0),this[r]=t&255,this[r+1]=t>>>8,r+2};j.prototype.writeUint16BE=j.prototype.writeUInt16BE=function(t,r,n){return t=+t,r=r>>>0,n||lr(this,t,r,2,65535,0),this[r]=t>>>8,this[r+1]=t&255,r+2};j.prototype.writeUint32LE=j.prototype.writeUInt32LE=function(t,r,n){return t=+t,r=r>>>0,n||lr(this,t,r,4,4294967295,0),this[r+3]=t>>>24,this[r+2]=t>>>16,this[r+1]=t>>>8,this[r]=t&255,r+4};j.prototype.writeUint32BE=j.prototype.writeUInt32BE=function(t,r,n){return t=+t,r=r>>>0,n||lr(this,t,r,4,4294967295,0),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=t&255,r+4};function P0(e,t,r,n,i){C0(t,n,i,e,r,7);let o=Number(t&BigInt(4294967295));e[r++]=o,o=o>>8,e[r++]=o,o=o>>8,e[r++]=o,o=o>>8,e[r++]=o;let s=Number(t>>BigInt(32)&BigInt(4294967295));return e[r++]=s,s=s>>8,e[r++]=s,s=s>>8,e[r++]=s,s=s>>8,e[r++]=s,r}function B0(e,t,r,n,i){C0(t,n,i,e,r,7);let o=Number(t&BigInt(4294967295));e[r+7]=o,o=o>>8,e[r+6]=o,o=o>>8,e[r+5]=o,o=o>>8,e[r+4]=o;let s=Number(t>>BigInt(32)&BigInt(4294967295));return e[r+3]=s,s=s>>8,e[r+2]=s,s=s>>8,e[r+1]=s,s=s>>8,e[r]=s,r+8}j.prototype.writeBigUInt64LE=$n(function(t,r=0){return P0(this,t,r,BigInt(0),BigInt("0xffffffffffffffff"))});j.prototype.writeBigUInt64BE=$n(function(t,r=0){return B0(this,t,r,BigInt(0),BigInt("0xffffffffffffffff"))});j.prototype.writeIntLE=function(t,r,n,i){if(t=+t,r=r>>>0,!i){let f=Math.pow(2,8*n-1);lr(this,t,r,n,f-1,-f)}let o=0,s=1,a=0;for(this[r]=t&255;++o<n&&(s*=256);)t<0&&a===0&&this[r+o-1]!==0&&(a=1),this[r+o]=(t/s>>0)-a&255;return r+n};j.prototype.writeIntBE=function(t,r,n,i){if(t=+t,r=r>>>0,!i){let f=Math.pow(2,8*n-1);lr(this,t,r,n,f-1,-f)}let o=n-1,s=1,a=0;for(this[r+o]=t&255;--o>=0&&(s*=256);)t<0&&a===0&&this[r+o+1]!==0&&(a=1),this[r+o]=(t/s>>0)-a&255;return r+n};j.prototype.writeInt8=function(t,r,n){return t=+t,r=r>>>0,n||lr(this,t,r,1,127,-128),t<0&&(t=255+t+1),this[r]=t&255,r+1};j.prototype.writeInt16LE=function(t,r,n){return t=+t,r=r>>>0,n||lr(this,t,r,2,32767,-32768),this[r]=t&255,this[r+1]=t>>>8,r+2};j.prototype.writeInt16BE=function(t,r,n){return t=+t,r=r>>>0,n||lr(this,t,r,2,32767,-32768),this[r]=t>>>8,this[r+1]=t&255,r+2};j.prototype.writeInt32LE=function(t,r,n){return t=+t,r=r>>>0,n||lr(this,t,r,4,2147483647,-2147483648),this[r]=t&255,this[r+1]=t>>>8,this[r+2]=t>>>16,this[r+3]=t>>>24,r+4};j.prototype.writeInt32BE=function(t,r,n){return t=+t,r=r>>>0,n||lr(this,t,r,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=t&255,r+4};j.prototype.writeBigInt64LE=$n(function(t,r=0){return P0(this,t,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});j.prototype.writeBigInt64BE=$n(function(t,r=0){return B0(this,t,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function N0(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function M0(e,t,r,n,i){return t=+t,r=r>>>0,i||N0(e,t,r,4,34028234663852886e22,-34028234663852886e22),vo.write(e,t,r,n,23,4),r+4}j.prototype.writeFloatLE=function(t,r,n){return M0(this,t,r,!0,n)};j.prototype.writeFloatBE=function(t,r,n){return M0(this,t,r,!1,n)};function k0(e,t,r,n,i){return t=+t,r=r>>>0,i||N0(e,t,r,8,17976931348623157e292,-17976931348623157e292),vo.write(e,t,r,n,52,8),r+8}j.prototype.writeDoubleLE=function(t,r,n){return k0(this,t,r,!0,n)};j.prototype.writeDoubleBE=function(t,r,n){return k0(this,t,r,!1,n)};j.prototype.copy=function(t,r,n,i){if(!j.isBuffer(t))throw new TypeError("argument should be a Buffer");if(n||(n=0),!i&&i!==0&&(i=this.length),r>=t.length&&(r=t.length),r||(r=0),i>0&&i<n&&(i=n),i===n||t.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),t.length-r<i-n&&(i=t.length-r+n);let o=i-n;return this===t&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(r,n,i):Uint8Array.prototype.set.call(t,this.subarray(n,i),r),o};j.prototype.fill=function(t,r,n,i){if(typeof t=="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"&&!j.isEncoding(i))throw new TypeError("Unknown encoding: "+i);if(t.length===1){let s=t.charCodeAt(0);(i==="utf8"&&s<128||i==="latin1")&&(t=s)}}else typeof t=="number"?t=t&255:typeof t=="boolean"&&(t=Number(t));if(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,t||(t=0);let o;if(typeof t=="number")for(o=r;o<n;++o)this[o]=t;else{let s=j.isBuffer(t)?t:j.from(t,i),a=s.length;if(a===0)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(o=0;o<n-r;++o)this[o+r]=s[o%a]}return this};var mo={};function Al(e,t,r){mo[e]=class extends r{constructor(){super(),Object.defineProperty(this,"message",{value:t.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${e}]`,this.stack,delete this.name}get code(){return e}set code(i){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:i,writable:!0})}toString(){return`${this.name} [${e}]: ${this.message}`}}}Al("ERR_BUFFER_OUT_OF_BOUNDS",function(e){return e?`${e} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);Al("ERR_INVALID_ARG_TYPE",function(e,t){return`The "${e}" argument must be of type number. Received type ${typeof t}`},TypeError);Al("ERR_OUT_OF_RANGE",function(e,t,r){let n=`The value of "${e}" is out of range.`,i=r;return Number.isInteger(r)&&Math.abs(r)>2**32?i=x0(String(r)):typeof r=="bigint"&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=x0(i)),i+="n"),n+=` It must be ${t}. Received ${i}`,n},RangeError);function x0(e){let t="",r=e.length,n=e[0]==="-"?1:0;for(;r>=n+4;r-=3)t=`_${e.slice(r-3,r)}${t}`;return`${e.slice(0,r)}${t}`}function $I(e,t,r){bo(t,"offset"),(e[t]===void 0||e[t+r]===void 0)&&ws(t,e.length-(r+1))}function C0(e,t,r,n,i,o){if(e>r||e<t){let s=typeof t=="bigint"?"n":"",a;throw o>3?t===0||t===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=`>= ${t}${s} and <= ${r}${s}`,new mo.ERR_OUT_OF_RANGE("value",a,e)}$I(n,i,o)}function bo(e,t){if(typeof e!="number")throw new mo.ERR_INVALID_ARG_TYPE(t,"number",e)}function ws(e,t,r){throw Math.floor(e)!==e?(bo(e,r),new mo.ERR_OUT_OF_RANGE(r||"offset","an integer",e)):t<0?new mo.ERR_BUFFER_OUT_OF_BOUNDS:new mo.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${t}`,e)}var ZI=/[^+/0-9A-Za-z-_]/g;function XI(e){if(e=e.split("=")[0],e=e.trim().replace(ZI,""),e.length<2)return"";for(;e.length%4!==0;)e=e+"=";return e}function El(e,t){t=t||1/0;let r,n=e.length,i=null,o=[];for(let s=0;s<n;++s){if(r=e.charCodeAt(s),r>55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}else if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=(i-55296<<10|r-56320)+65536}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,r&63|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<1114112){if((t-=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 JI(e){let t=[];for(let r=0;r<e.length;++r)t.push(e.charCodeAt(r)&255);return t}function QI(e,t){let r,n,i,o=[];for(let s=0;s<e.length&&!((t-=2)<0);++s)r=e.charCodeAt(s),n=r>>8,i=r%256,o.push(i),o.push(n);return o}function L0(e){return _l.toByteArray(XI(e))}function su(e,t,r,n){let i;for(i=0;i<n&&!(i+r>=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function en(e,t){return e instanceof t||e!=null&&e.constructor!=null&&e.constructor.name!=null&&e.constructor.name===t.name}function Ol(e){return e!==e}var eA=(function(){let e="0123456789abcdef",t=new Array(256);for(let r=0;r<16;++r){let n=r*16;for(let i=0;i<16;++i)t[n+i]=e[r]+e[i]}return t})();function $n(e){return typeof BigInt>"u"?tA:e}function tA(){throw new Error("BigInt not supported")}});var x,d,g=Xt(()=>{x=l0(y0()),d=l0(Lt())});var U0=B((D0,Rl)=>{g();(function(e,t){"use strict";function r(I,u){if(!I)throw new Error(u||"Assertion failed")}function n(I,u){I.super_=u;var h=function(){};h.prototype=u.prototype,I.prototype=new h,I.prototype.constructor=I}function i(I,u,h){if(i.isBN(I))return I;this.negative=0,this.words=null,this.length=0,this.red=null,I!==null&&((u==="le"||u==="be")&&(h=u,u=10),this._init(I||0,u||10,h||"be"))}typeof e=="object"?e.exports=i:t.BN=i,i.BN=i,i.wordSize=26;var o;try{typeof window<"u"&&typeof window.Buffer<"u"?o=window.Buffer:o=Lt().Buffer}catch{}i.isBN=function(u){return u instanceof i?!0:u!==null&&typeof u=="object"&&u.constructor.wordSize===i.wordSize&&Array.isArray(u.words)},i.max=function(u,h){return u.cmp(h)>0?u:h},i.min=function(u,h){return u.cmp(h)<0?u:h},i.prototype._init=function(u,h,v){if(typeof u=="number")return this._initNumber(u,h,v);if(typeof u=="object")return this._initArray(u,h,v);h==="hex"&&(h=16),r(h===(h|0)&&h>=2&&h<=36),u=u.toString().replace(/\s+/g,"");var _=0;u[0]==="-"&&(_++,this.negative=1),_<u.length&&(h===16?this._parseHex(u,_,v):(this._parseBase(u,h,_),v==="le"&&this._initArray(this.toArray(),h,v)))},i.prototype._initNumber=function(u,h,v){u<0&&(this.negative=1,u=-u),u<67108864?(this.words=[u&67108863],this.length=1):u<4503599627370496?(this.words=[u&67108863,u/67108864&67108863],this.length=2):(r(u<9007199254740992),this.words=[u&67108863,u/67108864&67108863,1],this.length=3),v==="le"&&this._initArray(this.toArray(),h,v)},i.prototype._initArray=function(u,h,v){if(r(typeof u.length=="number"),u.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(u.length/3),this.words=new Array(this.length);for(var _=0;_<this.length;_++)this.words[_]=0;var S,T,P=0;if(v==="be")for(_=u.length-1,S=0;_>=0;_-=3)T=u[_]|u[_-1]<<8|u[_-2]<<16,this.words[S]|=T<<P&67108863,this.words[S+1]=T>>>26-P&67108863,P+=24,P>=26&&(P-=26,S++);else if(v==="le")for(_=0,S=0;_<u.length;_+=3)T=u[_]|u[_+1]<<8|u[_+2]<<16,this.words[S]|=T<<P&67108863,this.words[S+1]=T>>>26-P&67108863,P+=24,P>=26&&(P-=26,S++);return this.strip()};function s(I,u){var h=I.charCodeAt(u);return h>=65&&h<=70?h-55:h>=97&&h<=102?h-87:h-48&15}function a(I,u,h){var v=s(I,h);return h-1>=u&&(v|=s(I,h-1)<<4),v}i.prototype._parseHex=function(u,h,v){this.length=Math.ceil((u.length-h)/6),this.words=new Array(this.length);for(var _=0;_<this.length;_++)this.words[_]=0;var S=0,T=0,P;if(v==="be")for(_=u.length-1;_>=h;_-=2)P=a(u,h,_)<<S,this.words[T]|=P&67108863,S>=18?(S-=18,T+=1,this.words[T]|=P>>>26):S+=8;else{var E=u.length-h;for(_=E%2===0?h+1:h;_<u.length;_+=2)P=a(u,h,_)<<S,this.words[T]|=P&67108863,S>=18?(S-=18,T+=1,this.words[T]|=P>>>26):S+=8}this.strip()};function f(I,u,h,v){for(var _=0,S=Math.min(I.length,h),T=u;T<S;T++){var P=I.charCodeAt(T)-48;_*=v,P>=49?_+=P-49+10:P>=17?_+=P-17+10:_+=P}return _}i.prototype._parseBase=function(u,h,v){this.words=[0],this.length=1;for(var _=0,S=1;S<=67108863;S*=h)_++;_--,S=S/h|0;for(var T=u.length-v,P=T%_,E=Math.min(T,T-P)+v,c=0,b=v;b<E;b+=_)c=f(u,b,b+_,h),this.imuln(S),this.words[0]+c<67108864?this.words[0]+=c:this._iaddn(c);if(P!==0){var C=1;for(c=f(u,b,u.length,h),b=0;b<P;b++)C*=h;this.imuln(C),this.words[0]+c<67108864?this.words[0]+=c:this._iaddn(c)}this.strip()},i.prototype.copy=function(u){u.words=new Array(this.length);for(var h=0;h<this.length;h++)u.words[h]=this.words[h];u.length=this.length,u.negative=this.negative,u.red=this.red},i.prototype.clone=function(){var u=new i(null);return this.copy(u),u},i.prototype._expand=function(u){for(;this.length<u;)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 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],y=[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(u,h){u=u||10,h=h|0||1;var v;if(u===16||u==="hex"){v="";for(var _=0,S=0,T=0;T<this.length;T++){var P=this.words[T],E=((P<<_|S)&16777215).toString(16);S=P>>>24-_&16777215,_+=2,_>=26&&(_-=26,T--),S!==0||T!==this.length-1?v=l[6-E.length]+E+v:v=E+v}for(S!==0&&(v=S.toString(16)+v);v.length%h!==0;)v="0"+v;return this.negative!==0&&(v="-"+v),v}if(u===(u|0)&&u>=2&&u<=36){var c=m[u],b=y[u];v="";var C=this.clone();for(C.negative=0;!C.isZero();){var N=C.modn(b).toString(u);C=C.idivn(b),C.isZero()?v=N+v:v=l[c-N.length]+N+v}for(this.isZero()&&(v="0"+v);v.length%h!==0;)v="0"+v;return this.negative!==0&&(v="-"+v),v}r(!1,"Base should be between 2 and 36")},i.prototype.toNumber=function(){var u=this.words[0];return this.length===2?u+=this.words[1]*67108864:this.length===3&&this.words[2]===1?u+=4503599627370496+this.words[1]*67108864:this.length>2&&r(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-u:u},i.prototype.toJSON=function(){return this.toString(16)},i.prototype.toBuffer=function(u,h){return r(typeof o<"u"),this.toArrayLike(o,u,h)},i.prototype.toArray=function(u,h){return this.toArrayLike(Array,u,h)},i.prototype.toArrayLike=function(u,h,v){var _=this.byteLength(),S=v||Math.max(1,_);r(_<=S,"byte array longer than desired length"),r(S>0,"Requested array length <= 0"),this.strip();var T=h==="le",P=new u(S),E,c,b=this.clone();if(T){for(c=0;!b.isZero();c++)E=b.andln(255),b.iushrn(8),P[c]=E;for(;c<S;c++)P[c]=0}else{for(c=0;c<S-_;c++)P[c]=0;for(c=0;!b.isZero();c++)E=b.andln(255),b.iushrn(8),P[S-c-1]=E}return P},Math.clz32?i.prototype._countBits=function(u){return 32-Math.clz32(u)}:i.prototype._countBits=function(u){var h=u,v=0;return h>=4096&&(v+=13,h>>>=13),h>=64&&(v+=7,h>>>=7),h>=8&&(v+=4,h>>>=4),h>=2&&(v+=2,h>>>=2),v+h},i.prototype._zeroBits=function(u){if(u===0)return 26;var h=u,v=0;return(h&8191)===0&&(v+=13,h>>>=13),(h&127)===0&&(v+=7,h>>>=7),(h&15)===0&&(v+=4,h>>>=4),(h&3)===0&&(v+=2,h>>>=2),(h&1)===0&&v++,v},i.prototype.bitLength=function(){var u=this.words[this.length-1],h=this._countBits(u);return(this.length-1)*26+h};function p(I){for(var u=new Array(I.bitLength()),h=0;h<u.length;h++){var v=h/26|0,_=h%26;u[h]=(I.words[v]&1<<_)>>>_}return u}i.prototype.zeroBits=function(){if(this.isZero())return 0;for(var u=0,h=0;h<this.length;h++){var v=this._zeroBits(this.words[h]);if(u+=v,v!==26)break}return u},i.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},i.prototype.toTwos=function(u){return this.negative!==0?this.abs().inotn(u).iaddn(1):this.clone()},i.prototype.fromTwos=function(u){return this.testn(u-1)?this.notn(u).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(u){for(;this.length<u.length;)this.words[this.length++]=0;for(var h=0;h<u.length;h++)this.words[h]=this.words[h]|u.words[h];return this.strip()},i.prototype.ior=function(u){return r((this.negative|u.negative)===0),this.iuor(u)},i.prototype.or=function(u){return this.length>u.length?this.clone().ior(u):u.clone().ior(this)},i.prototype.uor=function(u){return this.length>u.length?this.clone().iuor(u):u.clone().iuor(this)},i.prototype.iuand=function(u){var h;this.length>u.length?h=u:h=this;for(var v=0;v<h.length;v++)this.words[v]=this.words[v]&u.words[v];return this.length=h.length,this.strip()},i.prototype.iand=function(u){return r((this.negative|u.negative)===0),this.iuand(u)},i.prototype.and=function(u){return this.length>u.length?this.clone().iand(u):u.clone().iand(this)},i.prototype.uand=function(u){return this.length>u.length?this.clone().iuand(u):u.clone().iuand(this)},i.prototype.iuxor=function(u){var h,v;this.length>u.length?(h=this,v=u):(h=u,v=this);for(var _=0;_<v.length;_++)this.words[_]=h.words[_]^v.words[_];if(this!==h)for(;_<h.length;_++)this.words[_]=h.words[_];return this.length=h.length,this.strip()},i.prototype.ixor=function(u){return r((this.negative|u.negative)===0),this.iuxor(u)},i.prototype.xor=function(u){return this.length>u.length?this.clone().ixor(u):u.clone().ixor(this)},i.prototype.uxor=function(u){return this.length>u.length?this.clone().iuxor(u):u.clone().iuxor(this)},i.prototype.inotn=function(u){r(typeof u=="number"&&u>=0);var h=Math.ceil(u/26)|0,v=u%26;this._expand(h),v>0&&h--;for(var _=0;_<h;_++)this.words[_]=~this.words[_]&67108863;for(v>0&&(this.words[_]=~this.words[_]&67108863>>26-v,_++);_<this.length;_++)this.words[_]=0;return this.strip()},i.prototype.notn=function(u){return this.clone().inotn(u)},i.prototype.setn=function(u,h){r(typeof u=="number"&&u>=0);var v=u/26|0,_=u%26;return this._expand(v+1),h?this.words[v]=this.words[v]|1<<_:this.words[v]=this.words[v]&~(1<<_),this.strip()},i.prototype.iadd=function(u){var h;if(this.negative!==0&&u.negative===0)return this.negative=0,h=this.isub(u),this.negative^=1,this._normSign();if(this.negative===0&&u.negative!==0)return u.negative=0,h=this.isub(u),u.negative=1,h._normSign();var v,_;this.length>u.length?(v=this,_=u):(v=u,_=this);for(var S=0,T=0;T<_.length;T++)h=(v.words[T]|0)+(_.words[T]|0)+S,this.words[T]=h&67108863,S=h>>>26;for(;S!==0&&T<v.length;T++)h=(v.words[T]|0)+S,this.words[T]=h&67108863,S=h>>>26;if(this.length=v.length,S!==0)this.words[this.length]=S,this.length++;else if(v!==this)for(;T<v.length;T++)this.words[T]=v.words[T];return this},i.prototype.add=function(u){var h;return u.negative!==0&&this.negative===0?(u.negative=0,h=this.sub(u),u.negative^=1,h):u.negative===0&&this.negative!==0?(this.negative=0,h=u.sub(this),this.negative=1,h):this.length>u.length?this.clone().iadd(u):u.clone().iadd(this)},i.prototype.isub=function(u){if(u.negative!==0){u.negative=0;var h=this.iadd(u);return u.negative=1,h._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(u),this.negative=1,this._normSign();var v=this.cmp(u);if(v===0)return this.negative=0,this.length=1,this.words[0]=0,this;var _,S;v>0?(_=this,S=u):(_=u,S=this);for(var T=0,P=0;P<S.length;P++)h=(_.words[P]|0)-(S.words[P]|0)+T,T=h>>26,this.words[P]=h&67108863;for(;T!==0&&P<_.length;P++)h=(_.words[P]|0)+T,T=h>>26,this.words[P]=h&67108863;if(T===0&&P<_.length&&_!==this)for(;P<_.length;P++)this.words[P]=_.words[P];return this.length=Math.max(this.length,P),_!==this&&(this.negative=1),this.strip()},i.prototype.sub=function(u){return this.clone().isub(u)};function w(I,u,h){h.negative=u.negative^I.negative;var v=I.length+u.length|0;h.length=v,v=v-1|0;var _=I.words[0]|0,S=u.words[0]|0,T=_*S,P=T&67108863,E=T/67108864|0;h.words[0]=P;for(var c=1;c<v;c++){for(var b=E>>>26,C=E&67108863,N=Math.min(c,u.length-1),L=Math.max(0,c-I.length+1);L<=N;L++){var K=c-L|0;_=I.words[K]|0,S=u.words[L]|0,T=_*S+C,b+=T/67108864|0,C=T&67108863}h.words[c]=C|0,E=b|0}return E!==0?h.words[c]=E|0:h.length--,h.strip()}var O=function(u,h,v){var _=u.words,S=h.words,T=v.words,P=0,E,c,b,C=_[0]|0,N=C&8191,L=C>>>13,K=_[1]|0,z=K&8191,W=K>>>13,te=_[2]|0,re=te&8191,se=te>>>13,Ie=_[3]|0,ue=Ie&8191,fe=Ie>>>13,Oe=_[4]|0,ve=Oe&8191,Ee=Oe>>>13,ke=_[5]|0,_e=ke&8191,He=ke>>>13,Zt=_[6]|0,ze=Zt&8191,Ge=Zt>>>13,Zr=_[7]|0,nt=Zr&8191,A=Zr>>>13,U=_[8]|0,H=U&8191,G=U>>>13,ne=_[9]|0,$=ne&8191,oe=ne>>>13,ie=S[0]|0,be=ie&8191,ye=ie>>>13,Re=S[1]|0,Te=Re&8191,Xe=Re>>>13,it=S[2]|0,Pe=it&8191,he=it>>>13,ht=S[3]|0,Ve=ht&8191,ft=ht>>>13,go=S[4]|0,ot=go&8191,_t=go>>>13,o0=S[5]|0,St=o0&8191,wt=o0>>>13,s0=S[6]|0,Et=s0&8191,xt=s0>>>13,a0=S[7]|0,It=a0&8191,At=a0>>>13,u0=S[8]|0,Ot=u0&8191,Rt=u0>>>13,f0=S[9]|0,Tt=f0&8191,Pt=f0>>>13;v.negative=u.negative^h.negative,v.length=19,E=Math.imul(N,be),c=Math.imul(N,ye),c=c+Math.imul(L,be)|0,b=Math.imul(L,ye);var $c=(P+E|0)+((c&8191)<<13)|0;P=(b+(c>>>13)|0)+($c>>>26)|0,$c&=67108863,E=Math.imul(z,be),c=Math.imul(z,ye),c=c+Math.imul(W,be)|0,b=Math.imul(W,ye),E=E+Math.imul(N,Te)|0,c=c+Math.imul(N,Xe)|0,c=c+Math.imul(L,Te)|0,b=b+Math.imul(L,Xe)|0;var Zc=(P+E|0)+((c&8191)<<13)|0;P=(b+(c>>>13)|0)+(Zc>>>26)|0,Zc&=67108863,E=Math.imul(re,be),c=Math.imul(re,ye),c=c+Math.imul(se,be)|0,b=Math.imul(se,ye),E=E+Math.imul(z,Te)|0,c=c+Math.imul(z,Xe)|0,c=c+Math.imul(W,Te)|0,b=b+Math.imul(W,Xe)|0,E=E+Math.imul(N,Pe)|0,c=c+Math.imul(N,he)|0,c=c+Math.imul(L,Pe)|0,b=b+Math.imul(L,he)|0;var Xc=(P+E|0)+((c&8191)<<13)|0;P=(b+(c>>>13)|0)+(Xc>>>26)|0,Xc&=67108863,E=Math.imul(ue,be),c=Math.imul(ue,ye),c=c+Math.imul(fe,be)|0,b=Math.imul(fe,ye),E=E+Math.imul(re,Te)|0,c=c+Math.imul(re,Xe)|0,c=c+Math.imul(se,Te)|0,b=b+Math.imul(se,Xe)|0,E=E+Math.imul(z,Pe)|0,c=c+Math.imul(z,he)|0,c=c+Math.imul(W,Pe)|0,b=b+Math.imul(W,he)|0,E=E+Math.imul(N,Ve)|0,c=c+Math.imul(N,ft)|0,c=c+Math.imul(L,Ve)|0,b=b+Math.imul(L,ft)|0;var Jc=(P+E|0)+((c&8191)<<13)|0;P=(b+(c>>>13)|0)+(Jc>>>26)|0,Jc&=67108863,E=Math.imul(ve,be),c=Math.imul(ve,ye),c=c+Math.imul(Ee,be)|0,b=Math.imul(Ee,ye),E=E+Math.imul(ue,Te)|0,c=c+Math.imul(ue,Xe)|0,c=c+Math.imul(fe,Te)|0,b=b+Math.imul(fe,Xe)|0,E=E+Math.imul(re,Pe)|0,c=c+Math.imul(re,he)|0,c=c+Math.imul(se,Pe)|0,b=b+Math.imul(se,he)|0,E=E+Math.imul(z,Ve)|0,c=c+Math.imul(z,ft)|0,c=c+Math.imul(W,Ve)|0,b=b+Math.imul(W,ft)|0,E=E+Math.imul(N,ot)|0,c=c+Math.imul(N,_t)|0,c=c+Math.imul(L,ot)|0,b=b+Math.imul(L,_t)|0;var Qc=(P+E|0)+((c&8191)<<13)|0;P=(b+(c>>>13)|0)+(Qc>>>26)|0,Qc&=67108863,E=Math.imul(_e,be),c=Math.imul(_e,ye),c=c+Math.imul(He,be)|0,b=Math.imul(He,ye),E=E+Math.imul(ve,Te)|0,c=c+Math.imul(ve,Xe)|0,c=c+Math.imul(Ee,Te)|0,b=b+Math.imul(Ee,Xe)|0,E=E+Math.imul(ue,Pe)|0,c=c+Math.imul(ue,he)|0,c=c+Math.imul(fe,Pe)|0,b=b+Math.imul(fe,he)|0,E=E+Math.imul(re,Ve)|0,c=c+Math.imul(re,ft)|0,c=c+Math.imul(se,Ve)|0,b=b+Math.imul(se,ft)|0,E=E+Math.imul(z,ot)|0,c=c+Math.imul(z,_t)|0,c=c+Math.imul(W,ot)|0,b=b+Math.imul(W,_t)|0,E=E+Math.imul(N,St)|0,c=c+Math.imul(N,wt)|0,c=c+Math.imul(L,St)|0,b=b+Math.imul(L,wt)|0;var el=(P+E|0)+((c&8191)<<13)|0;P=(b+(c>>>13)|0)+(el>>>26)|0,el&=67108863,E=Math.imul(ze,be),c=Math.imul(ze,ye),c=c+Math.imul(Ge,be)|0,b=Math.imul(Ge,ye),E=E+Math.imul(_e,Te)|0,c=c+Math.imul(_e,Xe)|0,c=c+Math.imul(He,Te)|0,b=b+Math.imul(He,Xe)|0,E=E+Math.imul(ve,Pe)|0,c=c+Math.imul(ve,he)|0,c=c+Math.imul(Ee,Pe)|0,b=b+Math.imul(Ee,he)|0,E=E+Math.imul(ue,Ve)|0,c=c+Math.imul(ue,ft)|0,c=c+Math.imul(fe,Ve)|0,b=b+Math.imul(fe,ft)|0,E=E+Math.imul(re,ot)|0,c=c+Math.imul(re,_t)|0,c=c+Math.imul(se,ot)|0,b=b+Math.imul(se,_t)|0,E=E+Math.imul(z,St)|0,c=c+Math.imul(z,wt)|0,c=c+Math.imul(W,St)|0,b=b+Math.imul(W,wt)|0,E=E+Math.imul(N,Et)|0,c=c+Math.imul(N,xt)|0,c=c+Math.imul(L,Et)|0,b=b+Math.imul(L,xt)|0;var tl=(P+E|0)+((c&8191)<<13)|0;P=(b+(c>>>13)|0)+(tl>>>26)|0,tl&=67108863,E=Math.imul(nt,be),c=Math.imul(nt,ye),c=c+Math.imul(A,be)|0,b=Math.imul(A,ye),E=E+Math.imul(ze,Te)|0,c=c+Math.imul(ze,Xe)|0,c=c+Math.imul(Ge,Te)|0,b=b+Math.imul(Ge,Xe)|0,E=E+Math.imul(_e,Pe)|0,c=c+Math.imul(_e,he)|0,c=c+Math.imul(He,Pe)|0,b=b+Math.imul(He,he)|0,E=E+Math.imul(ve,Ve)|0,c=c+Math.imul(ve,ft)|0,c=c+Math.imul(Ee,Ve)|0,b=b+Math.imul(Ee,ft)|0,E=E+Math.imul(ue,ot)|0,c=c+Math.imul(ue,_t)|0,c=c+Math.imul(fe,ot)|0,b=b+Math.imul(fe,_t)|0,E=E+Math.imul(re,St)|0,c=c+Math.imul(re,wt)|0,c=c+Math.imul(se,St)|0,b=b+Math.imul(se,wt)|0,E=E+Math.imul(z,Et)|0,c=c+Math.imul(z,xt)|0,c=c+Math.imul(W,Et)|0,b=b+Math.imul(W,xt)|0,E=E+Math.imul(N,It)|0,c=c+Math.imul(N,At)|0,c=c+Math.imul(L,It)|0,b=b+Math.imul(L,At)|0;var rl=(P+E|0)+((c&8191)<<13)|0;P=(b+(c>>>13)|0)+(rl>>>26)|0,rl&=67108863,E=Math.imul(H,be),c=Math.imul(H,ye),c=c+Math.imul(G,be)|0,b=Math.imul(G,ye),E=E+Math.imul(nt,Te)|0,c=c+Math.imul(nt,Xe)|0,c=c+Math.imul(A,Te)|0,b=b+Math.imul(A,Xe)|0,E=E+Math.imul(ze,Pe)|0,c=c+Math.imul(ze,he)|0,c=c+Math.imul(Ge,Pe)|0,b=b+Math.imul(Ge,he)|0,E=E+Math.imul(_e,Ve)|0,c=c+Math.imul(_e,ft)|0,c=c+Math.imul(He,Ve)|0,b=b+Math.imul(He,ft)|0,E=E+Math.imul(ve,ot)|0,c=c+Math.imul(ve,_t)|0,c=c+Math.imul(Ee,ot)|0,b=b+Math.imul(Ee,_t)|0,E=E+Math.imul(ue,St)|0,c=c+Math.imul(ue,wt)|0,c=c+Math.imul(fe,St)|0,b=b+Math.imul(fe,wt)|0,E=E+Math.imul(re,Et)|0,c=c+Math.imul(re,xt)|0,c=c+Math.imul(se,Et)|0,b=b+Math.imul(se,xt)|0,E=E+Math.imul(z,It)|0,c=c+Math.imul(z,At)|0,c=c+Math.imul(W,It)|0,b=b+Math.imul(W,At)|0,E=E+Math.imul(N,Ot)|0,c=c+Math.imul(N,Rt)|0,c=c+Math.imul(L,Ot)|0,b=b+Math.imul(L,Rt)|0;var nl=(P+E|0)+((c&8191)<<13)|0;P=(b+(c>>>13)|0)+(nl>>>26)|0,nl&=67108863,E=Math.imul($,be),c=Math.imul($,ye),c=c+Math.imul(oe,be)|0,b=Math.imul(oe,ye),E=E+Math.imul(H,Te)|0,c=c+Math.imul(H,Xe)|0,c=c+Math.imul(G,Te)|0,b=b+Math.imul(G,Xe)|0,E=E+Math.imul(nt,Pe)|0,c=c+Math.imul(nt,he)|0,c=c+Math.imul(A,Pe)|0,b=b+Math.imul(A,he)|0,E=E+Math.imul(ze,Ve)|0,c=c+Math.imul(ze,ft)|0,c=c+Math.imul(Ge,Ve)|0,b=b+Math.imul(Ge,ft)|0,E=E+Math.imul(_e,ot)|0,c=c+Math.imul(_e,_t)|0,c=c+Math.imul(He,ot)|0,b=b+Math.imul(He,_t)|0,E=E+Math.imul(ve,St)|0,c=c+Math.imul(ve,wt)|0,c=c+Math.imul(Ee,St)|0,b=b+Math.imul(Ee,wt)|0,E=E+Math.imul(ue,Et)|0,c=c+Math.imul(ue,xt)|0,c=c+Math.imul(fe,Et)|0,b=b+Math.imul(fe,xt)|0,E=E+Math.imul(re,It)|0,c=c+Math.imul(re,At)|0,c=c+Math.imul(se,It)|0,b=b+Math.imul(se,At)|0,E=E+Math.imul(z,Ot)|0,c=c+Math.imul(z,Rt)|0,c=c+Math.imul(W,Ot)|0,b=b+Math.imul(W,Rt)|0,E=E+Math.imul(N,Tt)|0,c=c+Math.imul(N,Pt)|0,c=c+Math.imul(L,Tt)|0,b=b+Math.imul(L,Pt)|0;var il=(P+E|0)+((c&8191)<<13)|0;P=(b+(c>>>13)|0)+(il>>>26)|0,il&=67108863,E=Math.imul($,Te),c=Math.imul($,Xe),c=c+Math.imul(oe,Te)|0,b=Math.imul(oe,Xe),E=E+Math.imul(H,Pe)|0,c=c+Math.imul(H,he)|0,c=c+Math.imul(G,Pe)|0,b=b+Math.imul(G,he)|0,E=E+Math.imul(nt,Ve)|0,c=c+Math.imul(nt,ft)|0,c=c+Math.imul(A,Ve)|0,b=b+Math.imul(A,ft)|0,E=E+Math.imul(ze,ot)|0,c=c+Math.imul(ze,_t)|0,c=c+Math.imul(Ge,ot)|0,b=b+Math.imul(Ge,_t)|0,E=E+Math.imul(_e,St)|0,c=c+Math.imul(_e,wt)|0,c=c+Math.imul(He,St)|0,b=b+Math.imul(He,wt)|0,E=E+Math.imul(ve,Et)|0,c=c+Math.imul(ve,xt)|0,c=c+Math.imul(Ee,Et)|0,b=b+Math.imul(Ee,xt)|0,E=E+Math.imul(ue,It)|0,c=c+Math.imul(ue,At)|0,c=c+Math.imul(fe,It)|0,b=b+Math.imul(fe,At)|0,E=E+Math.imul(re,Ot)|0,c=c+Math.imul(re,Rt)|0,c=c+Math.imul(se,Ot)|0,b=b+Math.imul(se,Rt)|0,E=E+Math.imul(z,Tt)|0,c=c+Math.imul(z,Pt)|0,c=c+Math.imul(W,Tt)|0,b=b+Math.imul(W,Pt)|0;var ol=(P+E|0)+((c&8191)<<13)|0;P=(b+(c>>>13)|0)+(ol>>>26)|0,ol&=67108863,E=Math.imul($,Pe),c=Math.imul($,he),c=c+Math.imul(oe,Pe)|0,b=Math.imul(oe,he),E=E+Math.imul(H,Ve)|0,c=c+Math.imul(H,ft)|0,c=c+Math.imul(G,Ve)|0,b=b+Math.imul(G,ft)|0,E=E+Math.imul(nt,ot)|0,c=c+Math.imul(nt,_t)|0,c=c+Math.imul(A,ot)|0,b=b+Math.imul(A,_t)|0,E=E+Math.imul(ze,St)|0,c=c+Math.imul(ze,wt)|0,c=c+Math.imul(Ge,St)|0,b=b+Math.imul(Ge,wt)|0,E=E+Math.imul(_e,Et)|0,c=c+Math.imul(_e,xt)|0,c=c+Math.imul(He,Et)|0,b=b+Math.imul(He,xt)|0,E=E+Math.imul(ve,It)|0,c=c+Math.imul(ve,At)|0,c=c+Math.imul(Ee,It)|0,b=b+Math.imul(Ee,At)|0,E=E+Math.imul(ue,Ot)|0,c=c+Math.imul(ue,Rt)|0,c=c+Math.imul(fe,Ot)|0,b=b+Math.imul(fe,Rt)|0,E=E+Math.imul(re,Tt)|0,c=c+Math.imul(re,Pt)|0,c=c+Math.imul(se,Tt)|0,b=b+Math.imul(se,Pt)|0;var sl=(P+E|0)+((c&8191)<<13)|0;P=(b+(c>>>13)|0)+(sl>>>26)|0,sl&=67108863,E=Math.imul($,Ve),c=Math.imul($,ft),c=c+Math.imul(oe,Ve)|0,b=Math.imul(oe,ft),E=E+Math.imul(H,ot)|0,c=c+Math.imul(H,_t)|0,c=c+Math.imul(G,ot)|0,b=b+Math.imul(G,_t)|0,E=E+Math.imul(nt,St)|0,c=c+Math.imul(nt,wt)|0,c=c+Math.imul(A,St)|0,b=b+Math.imul(A,wt)|0,E=E+Math.imul(ze,Et)|0,c=c+Math.imul(ze,xt)|0,c=c+Math.imul(Ge,Et)|0,b=b+Math.imul(Ge,xt)|0,E=E+Math.imul(_e,It)|0,c=c+Math.imul(_e,At)|0,c=c+Math.imul(He,It)|0,b=b+Math.imul(He,At)|0,E=E+Math.imul(ve,Ot)|0,c=c+Math.imul(ve,Rt)|0,c=c+Math.imul(Ee,Ot)|0,b=b+Math.imul(Ee,Rt)|0,E=E+Math.imul(ue,Tt)|0,c=c+Math.imul(ue,Pt)|0,c=c+Math.imul(fe,Tt)|0,b=b+Math.imul(fe,Pt)|0;var al=(P+E|0)+((c&8191)<<13)|0;P=(b+(c>>>13)|0)+(al>>>26)|0,al&=67108863,E=Math.imul($,ot),c=Math.imul($,_t),c=c+Math.imul(oe,ot)|0,b=Math.imul(oe,_t),E=E+Math.imul(H,St)|0,c=c+Math.imul(H,wt)|0,c=c+Math.imul(G,St)|0,b=b+Math.imul(G,wt)|0,E=E+Math.imul(nt,Et)|0,c=c+Math.imul(nt,xt)|0,c=c+Math.imul(A,Et)|0,b=b+Math.imul(A,xt)|0,E=E+Math.imul(ze,It)|0,c=c+Math.imul(ze,At)|0,c=c+Math.imul(Ge,It)|0,b=b+Math.imul(Ge,At)|0,E=E+Math.imul(_e,Ot)|0,c=c+Math.imul(_e,Rt)|0,c=c+Math.imul(He,Ot)|0,b=b+Math.imul(He,Rt)|0,E=E+Math.imul(ve,Tt)|0,c=c+Math.imul(ve,Pt)|0,c=c+Math.imul(Ee,Tt)|0,b=b+Math.imul(Ee,Pt)|0;var ul=(P+E|0)+((c&8191)<<13)|0;P=(b+(c>>>13)|0)+(ul>>>26)|0,ul&=67108863,E=Math.imul($,St),c=Math.imul($,wt),c=c+Math.imul(oe,St)|0,b=Math.imul(oe,wt),E=E+Math.imul(H,Et)|0,c=c+Math.imul(H,xt)|0,c=c+Math.imul(G,Et)|0,b=b+Math.imul(G,xt)|0,E=E+Math.imul(nt,It)|0,c=c+Math.imul(nt,At)|0,c=c+Math.imul(A,It)|0,b=b+Math.imul(A,At)|0,E=E+Math.imul(ze,Ot)|0,c=c+Math.imul(ze,Rt)|0,c=c+Math.imul(Ge,Ot)|0,b=b+Math.imul(Ge,Rt)|0,E=E+Math.imul(_e,Tt)|0,c=c+Math.imul(_e,Pt)|0,c=c+Math.imul(He,Tt)|0,b=b+Math.imul(He,Pt)|0;var fl=(P+E|0)+((c&8191)<<13)|0;P=(b+(c>>>13)|0)+(fl>>>26)|0,fl&=67108863,E=Math.imul($,Et),c=Math.imul($,xt),c=c+Math.imul(oe,Et)|0,b=Math.imul(oe,xt),E=E+Math.imul(H,It)|0,c=c+Math.imul(H,At)|0,c=c+Math.imul(G,It)|0,b=b+Math.imul(G,At)|0,E=E+Math.imul(nt,Ot)|0,c=c+Math.imul(nt,Rt)|0,c=c+Math.imul(A,Ot)|0,b=b+Math.imul(A,Rt)|0,E=E+Math.imul(ze,Tt)|0,c=c+Math.imul(ze,Pt)|0,c=c+Math.imul(Ge,Tt)|0,b=b+Math.imul(Ge,Pt)|0;var cl=(P+E|0)+((c&8191)<<13)|0;P=(b+(c>>>13)|0)+(cl>>>26)|0,cl&=67108863,E=Math.imul($,It),c=Math.imul($,At),c=c+Math.imul(oe,It)|0,b=Math.imul(oe,At),E=E+Math.imul(H,Ot)|0,c=c+Math.imul(H,Rt)|0,c=c+Math.imul(G,Ot)|0,b=b+Math.imul(G,Rt)|0,E=E+Math.imul(nt,Tt)|0,c=c+Math.imul(nt,Pt)|0,c=c+Math.imul(A,Tt)|0,b=b+Math.imul(A,Pt)|0;var ll=(P+E|0)+((c&8191)<<13)|0;P=(b+(c>>>13)|0)+(ll>>>26)|0,ll&=67108863,E=Math.imul($,Ot),c=Math.imul($,Rt),c=c+Math.imul(oe,Ot)|0,b=Math.imul(oe,Rt),E=E+Math.imul(H,Tt)|0,c=c+Math.imul(H,Pt)|0,c=c+Math.imul(G,Tt)|0,b=b+Math.imul(G,Pt)|0;var hl=(P+E|0)+((c&8191)<<13)|0;P=(b+(c>>>13)|0)+(hl>>>26)|0,hl&=67108863,E=Math.imul($,Tt),c=Math.imul($,Pt),c=c+Math.imul(oe,Tt)|0,b=Math.imul(oe,Pt);var dl=(P+E|0)+((c&8191)<<13)|0;return P=(b+(c>>>13)|0)+(dl>>>26)|0,dl&=67108863,T[0]=$c,T[1]=Zc,T[2]=Xc,T[3]=Jc,T[4]=Qc,T[5]=el,T[6]=tl,T[7]=rl,T[8]=nl,T[9]=il,T[10]=ol,T[11]=sl,T[12]=al,T[13]=ul,T[14]=fl,T[15]=cl,T[16]=ll,T[17]=hl,T[18]=dl,P!==0&&(T[19]=P,v.length++),v};Math.imul||(O=w);function M(I,u,h){h.negative=u.negative^I.negative,h.length=I.length+u.length;for(var v=0,_=0,S=0;S<h.length-1;S++){var T=_;_=0;for(var P=v&67108863,E=Math.min(S,u.length-1),c=Math.max(0,S-I.length+1);c<=E;c++){var b=S-c,C=I.words[b]|0,N=u.words[c]|0,L=C*N,K=L&67108863;T=T+(L/67108864|0)|0,K=K+P|0,P=K&67108863,T=T+(K>>>26)|0,_+=T>>>26,T&=67108863}h.words[S]=P,v=T,T=_}return v!==0?h.words[S]=v:h.length--,h.strip()}function D(I,u,h){var v=new F;return v.mulp(I,u,h)}i.prototype.mulTo=function(u,h){var v,_=this.length+u.length;return this.length===10&&u.length===10?v=O(this,u,h):_<63?v=w(this,u,h):_<1024?v=M(this,u,h):v=D(this,u,h),v};function F(I,u){this.x=I,this.y=u}F.prototype.makeRBT=function(u){for(var h=new Array(u),v=i.prototype._countBits(u)-1,_=0;_<u;_++)h[_]=this.revBin(_,v,u);return h},F.prototype.revBin=function(u,h,v){if(u===0||u===v-1)return u;for(var _=0,S=0;S<h;S++)_|=(u&1)<<h-S-1,u>>=1;return _},F.prototype.permute=function(u,h,v,_,S,T){for(var P=0;P<T;P++)_[P]=h[u[P]],S[P]=v[u[P]]},F.prototype.transform=function(u,h,v,_,S,T){this.permute(T,u,h,v,_,S);for(var P=1;P<S;P<<=1)for(var E=P<<1,c=Math.cos(2*Math.PI/E),b=Math.sin(2*Math.PI/E),C=0;C<S;C+=E)for(var N=c,L=b,K=0;K<P;K++){var z=v[C+K],W=_[C+K],te=v[C+K+P],re=_[C+K+P],se=N*te-L*re;re=N*re+L*te,te=se,v[C+K]=z+te,_[C+K]=W+re,v[C+K+P]=z-te,_[C+K+P]=W-re,K!==E&&(se=c*N-b*L,L=c*L+b*N,N=se)}},F.prototype.guessLen13b=function(u,h){var v=Math.max(h,u)|1,_=v&1,S=0;for(v=v/2|0;v;v=v>>>1)S++;return 1<<S+1+_},F.prototype.conjugate=function(u,h,v){if(!(v<=1))for(var _=0;_<v/2;_++){var S=u[_];u[_]=u[v-_-1],u[v-_-1]=S,S=h[_],h[_]=-h[v-_-1],h[v-_-1]=-S}},F.prototype.normalize13b=function(u,h){for(var v=0,_=0;_<h/2;_++){var S=Math.round(u[2*_+1]/h)*8192+Math.round(u[2*_]/h)+v;u[_]=S&67108863,S<67108864?v=0:v=S/67108864|0}return u},F.prototype.convert13b=function(u,h,v,_){for(var S=0,T=0;T<h;T++)S=S+(u[T]|0),v[2*T]=S&8191,S=S>>>13,v[2*T+1]=S&8191,S=S>>>13;for(T=2*h;T<_;++T)v[T]=0;r(S===0),r((S&-8192)===0)},F.prototype.stub=function(u){for(var h=new Array(u),v=0;v<u;v++)h[v]=0;return h},F.prototype.mulp=function(u,h,v){var _=2*this.guessLen13b(u.length,h.length),S=this.makeRBT(_),T=this.stub(_),P=new Array(_),E=new Array(_),c=new Array(_),b=new Array(_),C=new Array(_),N=new Array(_),L=v.words;L.length=_,this.convert13b(u.words,u.length,P,_),this.convert13b(h.words,h.length,b,_),this.transform(P,T,E,c,_,S),this.transform(b,T,C,N,_,S);for(var K=0;K<_;K++){var z=E[K]*C[K]-c[K]*N[K];c[K]=E[K]*N[K]+c[K]*C[K],E[K]=z}return this.conjugate(E,c,_),this.transform(E,c,L,T,_,S),this.conjugate(L,T,_),this.normalize13b(L,_),v.negative=u.negative^h.negative,v.length=u.length+h.length,v.strip()},i.prototype.mul=function(u){var h=new i(null);return h.words=new Array(this.length+u.length),this.mulTo(u,h)},i.prototype.mulf=function(u){var h=new i(null);return h.words=new Array(this.length+u.length),D(this,u,h)},i.prototype.imul=function(u){return this.clone().mulTo(u,this)},i.prototype.imuln=function(u){r(typeof u=="number"),r(u<67108864);for(var h=0,v=0;v<this.length;v++){var _=(this.words[v]|0)*u,S=(_&67108863)+(h&67108863);h>>=26,h+=_/67108864|0,h+=S>>>26,this.words[v]=S&67108863}return h!==0&&(this.words[v]=h,this.length++),u===0&&(this.length=1,this._normSign()),this},i.prototype.muln=function(u){return this.clone().imuln(u)},i.prototype.sqr=function(){return this.mul(this)},i.prototype.isqr=function(){return this.imul(this.clone())},i.prototype.pow=function(u){var h=p(u);if(h.length===0)return new i(1);for(var v=this,_=0;_<h.length&&h[_]===0;_++,v=v.sqr());if(++_<h.length)for(var S=v.sqr();_<h.length;_++,S=S.sqr())h[_]!==0&&(v=v.mul(S));return v},i.prototype.iushln=function(u){r(typeof u=="number"&&u>=0);var h=u%26,v=(u-h)/26,_=67108863>>>26-h<<26-h,S;if(h!==0){var T=0;for(S=0;S<this.length;S++){var P=this.words[S]&_,E=(this.words[S]|0)-P<<h;this.words[S]=E|T,T=P>>>26-h}T&&(this.words[S]=T,this.length++)}if(v!==0){for(S=this.length-1;S>=0;S--)this.words[S+v]=this.words[S];for(S=0;S<v;S++)this.words[S]=0;this.length+=v}return this.strip()},i.prototype.ishln=function(u){return r(this.negative===0),this.iushln(u)},i.prototype.iushrn=function(u,h,v){r(typeof u=="number"&&u>=0);var _;h?_=(h-h%26)/26:_=0;var S=u%26,T=Math.min((u-S)/26,this.length),P=67108863^67108863>>>S<<S,E=v;if(_-=T,_=Math.max(0,_),E){for(var c=0;c<T;c++)E.words[c]=this.words[c];E.length=T}if(T!==0)if(this.length>T)for(this.length-=T,c=0;c<this.length;c++)this.words[c]=this.words[c+T];else this.words[0]=0,this.length=1;var b=0;for(c=this.length-1;c>=0&&(b!==0||c>=_);c--){var C=this.words[c]|0;this.words[c]=b<<26-S|C>>>S,b=C&P}return E&&b!==0&&(E.words[E.length++]=b),this.length===0&&(this.words[0]=0,this.length=1),this.strip()},i.prototype.ishrn=function(u,h,v){return r(this.negative===0),this.iushrn(u,h,v)},i.prototype.shln=function(u){return this.clone().ishln(u)},i.prototype.ushln=function(u){return this.clone().iushln(u)},i.prototype.shrn=function(u){return this.clone().ishrn(u)},i.prototype.ushrn=function(u){return this.clone().iushrn(u)},i.prototype.testn=function(u){r(typeof u=="number"&&u>=0);var h=u%26,v=(u-h)/26,_=1<<h;if(this.length<=v)return!1;var S=this.words[v];return!!(S&_)},i.prototype.imaskn=function(u){r(typeof u=="number"&&u>=0);var h=u%26,v=(u-h)/26;if(r(this.negative===0,"imaskn works only with positive numbers"),this.length<=v)return this;if(h!==0&&v++,this.length=Math.min(v,this.length),h!==0){var _=67108863^67108863>>>h<<h;this.words[this.length-1]&=_}return this.length===0&&(this.words[0]=0,this.length=1),this.strip()},i.prototype.maskn=function(u){return this.clone().imaskn(u)},i.prototype.iaddn=function(u){return r(typeof u=="number"),r(u<67108864),u<0?this.isubn(-u):this.negative!==0?this.length===1&&(this.words[0]|0)<u?(this.words[0]=u-(this.words[0]|0),this.negative=0,this):(this.negative=0,this.isubn(u),this.negative=1,this):this._iaddn(u)},i.prototype._iaddn=function(u){this.words[0]+=u;for(var h=0;h<this.length&&this.words[h]>=67108864;h++)this.words[h]-=67108864,h===this.length-1?this.words[h+1]=1:this.words[h+1]++;return this.length=Math.max(this.length,h+1),this},i.prototype.isubn=function(u){if(r(typeof u=="number"),r(u<67108864),u<0)return this.iaddn(-u);if(this.negative!==0)return this.negative=0,this.iaddn(u),this.negative=1,this;if(this.words[0]-=u,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var h=0;h<this.length&&this.words[h]<0;h++)this.words[h]+=67108864,this.words[h+1]-=1;return this.strip()},i.prototype.addn=function(u){return this.clone().iaddn(u)},i.prototype.subn=function(u){return this.clone().isubn(u)},i.prototype.iabs=function(){return this.negative=0,this},i.prototype.abs=function(){return this.clone().iabs()},i.prototype._ishlnsubmul=function(u,h,v){var _=u.length+v,S;this._expand(_);var T,P=0;for(S=0;S<u.length;S++){T=(this.words[S+v]|0)+P;var E=(u.words[S]|0)*h;T-=E&67108863,P=(T>>26)-(E/67108864|0),this.words[S+v]=T&67108863}for(;S<this.length-v;S++)T=(this.words[S+v]|0)+P,P=T>>26,this.words[S+v]=T&67108863;if(P===0)return this.strip();for(r(P===-1),P=0,S=0;S<this.length;S++)T=-(this.words[S]|0)+P,P=T>>26,this.words[S]=T&67108863;return this.negative=1,this.strip()},i.prototype._wordDiv=function(u,h){var v=this.length-u.length,_=this.clone(),S=u,T=S.words[S.length-1]|0,P=this._countBits(T);v=26-P,v!==0&&(S=S.ushln(v),_.iushln(v),T=S.words[S.length-1]|0);var E=_.length-S.length,c;if(h!=="mod"){c=new i(null),c.length=E+1,c.words=new Array(c.length);for(var b=0;b<c.length;b++)c.words[b]=0}var C=_.clone()._ishlnsubmul(S,1,E);C.negative===0&&(_=C,c&&(c.words[E]=1));for(var N=E-1;N>=0;N--){var L=(_.words[S.length+N]|0)*67108864+(_.words[S.length+N-1]|0);for(L=Math.min(L/T|0,67108863),_._ishlnsubmul(S,L,N);_.negative!==0;)L--,_.negative=0,_._ishlnsubmul(S,1,N),_.isZero()||(_.negative^=1);c&&(c.words[N]=L)}return c&&c.strip(),_.strip(),h!=="div"&&v!==0&&_.iushrn(v),{div:c||null,mod:_}},i.prototype.divmod=function(u,h,v){if(r(!u.isZero()),this.isZero())return{div:new i(0),mod:new i(0)};var _,S,T;return this.negative!==0&&u.negative===0?(T=this.neg().divmod(u,h),h!=="mod"&&(_=T.div.neg()),h!=="div"&&(S=T.mod.neg(),v&&S.negative!==0&&S.iadd(u)),{div:_,mod:S}):this.negative===0&&u.negative!==0?(T=this.divmod(u.neg(),h),h!=="mod"&&(_=T.div.neg()),{div:_,mod:T.mod}):(this.negative&u.negative)!==0?(T=this.neg().divmod(u.neg(),h),h!=="div"&&(S=T.mod.neg(),v&&S.negative!==0&&S.isub(u)),{div:T.div,mod:S}):u.length>this.length||this.cmp(u)<0?{div:new i(0),mod:this}:u.length===1?h==="div"?{div:this.divn(u.words[0]),mod:null}:h==="mod"?{div:null,mod:new i(this.modn(u.words[0]))}:{div:this.divn(u.words[0]),mod:new i(this.modn(u.words[0]))}:this._wordDiv(u,h)},i.prototype.div=function(u){return this.divmod(u,"div",!1).div},i.prototype.mod=function(u){return this.divmod(u,"mod",!1).mod},i.prototype.umod=function(u){return this.divmod(u,"mod",!0).mod},i.prototype.divRound=function(u){var h=this.divmod(u);if(h.mod.isZero())return h.div;var v=h.mod.abs(),_=u.abs().iushrn(1),S=u.words[0]&1,T=v.cmp(_);if(T<0||S===1&&T===0)return h.div;var P=new i(1);return P.negative=this.negative^u.negative,h.div.iadd(P)},i.prototype.modn=function(u){r(u<=67108863);for(var h=(1<<26)%u,v=0,_=this.length-1;_>=0;_--)v=(h*v+(this.words[_]|0))%u;return v},i.prototype.idivn=function(u){r(u<=67108863);for(var h=0,v=this.length-1;v>=0;v--){var _=(this.words[v]|0)+h*67108864;this.words[v]=_/u|0,h=_%u}return this.strip()},i.prototype.divn=function(u){return this.clone().idivn(u)},i.prototype.egcd=function(u){r(u.negative===0),r(!u.isZero());var h=this,v=u.clone();h.negative!==0?h=h.umod(u):h=h.clone();for(var _=new i(1),S=new i(0),T=new i(0),P=new i(1),E=0;h.isEven()&&v.isEven();)h.iushrn(1),v.iushrn(1),++E;for(var c=v.clone(),b=h.clone();!h.isZero();){for(var C=0,N=1;(h.words[0]&N)===0&&C<26;++C,N<<=1);if(C>0)for(h.iushrn(C);C-- >0;)(_.isOdd()||S.isOdd())&&(_.iadd(c),S.isub(b)),_.iushrn(1),S.iushrn(1);for(var L=0,K=1;(v.words[0]&K)===0&&L<26;++L,K<<=1);if(L>0)for(v.iushrn(L);L-- >0;)(T.isOdd()||P.isOdd())&&(T.iadd(c),P.isub(b)),T.iushrn(1),P.iushrn(1);h.cmp(v)>=0?(h.isub(v),_.isub(T),S.isub(P)):(v.isub(h),T.isub(_),P.isub(S))}return{a:T,b:P,gcd:v.iushln(E)}},i.prototype._invmp=function(u){r(u.negative===0),r(!u.isZero());var h=this,v=u.clone();h.negative!==0?h=h.umod(u):h=h.clone();for(var _=new i(1),S=new i(0),T=v.clone();h.cmpn(1)>0&&v.cmpn(1)>0;){for(var P=0,E=1;(h.words[0]&E)===0&&P<26;++P,E<<=1);if(P>0)for(h.iushrn(P);P-- >0;)_.isOdd()&&_.iadd(T),_.iushrn(1);for(var c=0,b=1;(v.words[0]&b)===0&&c<26;++c,b<<=1);if(c>0)for(v.iushrn(c);c-- >0;)S.isOdd()&&S.iadd(T),S.iushrn(1);h.cmp(v)>=0?(h.isub(v),_.isub(S)):(v.isub(h),S.isub(_))}var C;return h.cmpn(1)===0?C=_:C=S,C.cmpn(0)<0&&C.iadd(u),C},i.prototype.gcd=function(u){if(this.isZero())return u.abs();if(u.isZero())return this.abs();var h=this.clone(),v=u.clone();h.negative=0,v.negative=0;for(var _=0;h.isEven()&&v.isEven();_++)h.iushrn(1),v.iushrn(1);do{for(;h.isEven();)h.iushrn(1);for(;v.isEven();)v.iushrn(1);var S=h.cmp(v);if(S<0){var T=h;h=v,v=T}else if(S===0||v.cmpn(1)===0)break;h.isub(v)}while(!0);return v.iushln(_)},i.prototype.invm=function(u){return this.egcd(u).a.umod(u)},i.prototype.isEven=function(){return(this.words[0]&1)===0},i.prototype.isOdd=function(){return(this.words[0]&1)===1},i.prototype.andln=function(u){return this.words[0]&u},i.prototype.bincn=function(u){r(typeof u=="number");var h=u%26,v=(u-h)/26,_=1<<h;if(this.length<=v)return this._expand(v+1),this.words[v]|=_,this;for(var S=_,T=v;S!==0&&T<this.length;T++){var P=this.words[T]|0;P+=S,S=P>>>26,P&=67108863,this.words[T]=P}return S!==0&&(this.words[T]=S,this.length++),this},i.prototype.isZero=function(){return this.length===1&&this.words[0]===0},i.prototype.cmpn=function(u){var h=u<0;if(this.negative!==0&&!h)return-1;if(this.negative===0&&h)return 1;this.strip();var v;if(this.length>1)v=1;else{h&&(u=-u),r(u<=67108863,"Number is too big");var _=this.words[0]|0;v=_===u?0:_<u?-1:1}return this.negative!==0?-v|0:v},i.prototype.cmp=function(u){if(this.negative!==0&&u.negative===0)return-1;if(this.negative===0&&u.negative!==0)return 1;var h=this.ucmp(u);return this.negative!==0?-h|0:h},i.prototype.ucmp=function(u){if(this.length>u.length)return 1;if(this.length<u.length)return-1;for(var h=0,v=this.length-1;v>=0;v--){var _=this.words[v]|0,S=u.words[v]|0;if(_!==S){_<S?h=-1:_>S&&(h=1);break}}return h},i.prototype.gtn=function(u){return this.cmpn(u)===1},i.prototype.gt=function(u){return this.cmp(u)===1},i.prototype.gten=function(u){return this.cmpn(u)>=0},i.prototype.gte=function(u){return this.cmp(u)>=0},i.prototype.ltn=function(u){return this.cmpn(u)===-1},i.prototype.lt=function(u){return this.cmp(u)===-1},i.prototype.lten=function(u){return this.cmpn(u)<=0},i.prototype.lte=function(u){return this.cmp(u)<=0},i.prototype.eqn=function(u){return this.cmpn(u)===0},i.prototype.eq=function(u){return this.cmp(u)===0},i.red=function(u){return new pe(u)},i.prototype.toRed=function(u){return r(!this.red,"Already a number in reduction context"),r(this.negative===0,"red works only with positives"),u.convertTo(this)._forceRed(u)},i.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},i.prototype._forceRed=function(u){return this.red=u,this},i.prototype.forceRed=function(u){return r(!this.red,"Already a number in reduction context"),this._forceRed(u)},i.prototype.redAdd=function(u){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,u)},i.prototype.redIAdd=function(u){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,u)},i.prototype.redSub=function(u){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,u)},i.prototype.redISub=function(u){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,u)},i.prototype.redShl=function(u){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,u)},i.prototype.redMul=function(u){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,u),this.red.mul(this,u)},i.prototype.redIMul=function(u){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,u),this.red.imul(this,u)},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(u){return r(this.red&&!u.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,u)};var V={k256:null,p224:null,p192:null,p25519:null};function Y(I,u){this.name=I,this.p=new i(u,16),this.n=this.p.bitLength(),this.k=new i(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}Y.prototype._tmp=function(){var u=new i(null);return u.words=new Array(Math.ceil(this.n/13)),u},Y.prototype.ireduce=function(u){var h=u,v;do this.split(h,this.tmp),h=this.imulK(h),h=h.iadd(this.tmp),v=h.bitLength();while(v>this.n);var _=v<this.n?-1:h.ucmp(this.p);return _===0?(h.words[0]=0,h.length=1):_>0?h.isub(this.p):h.strip!==void 0?h.strip():h._strip(),h},Y.prototype.split=function(u,h){u.iushrn(this.n,0,h)},Y.prototype.imulK=function(u){return u.imul(this.k)};function Q(){Y.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}n(Q,Y),Q.prototype.split=function(u,h){for(var v=4194303,_=Math.min(u.length,9),S=0;S<_;S++)h.words[S]=u.words[S];if(h.length=_,u.length<=9){u.words[0]=0,u.length=1;return}var T=u.words[9];for(h.words[h.length++]=T&v,S=10;S<u.length;S++){var P=u.words[S]|0;u.words[S-10]=(P&v)<<4|T>>>22,T=P}T>>>=22,u.words[S-10]=T,T===0&&u.length>10?u.length-=10:u.length-=9},Q.prototype.imulK=function(u){u.words[u.length]=0,u.words[u.length+1]=0,u.length+=2;for(var h=0,v=0;v<u.length;v++){var _=u.words[v]|0;h+=_*977,u.words[v]=h&67108863,h=_*64+(h/67108864|0)}return u.words[u.length-1]===0&&(u.length--,u.words[u.length-1]===0&&u.length--),u};function ce(){Y.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}n(ce,Y);function ee(){Y.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}n(ee,Y);function de(){Y.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}n(de,Y),de.prototype.imulK=function(u){for(var h=0,v=0;v<u.length;v++){var _=(u.words[v]|0)*19+h,S=_&67108863;_>>>=26,u.words[v]=S,h=_}return h!==0&&(u.words[u.length++]=h),u},i._prime=function(u){if(V[u])return V[u];var h;if(u==="k256")h=new Q;else if(u==="p224")h=new ce;else if(u==="p192")h=new ee;else if(u==="p25519")h=new de;else throw new Error("Unknown prime "+u);return V[u]=h,h};function pe(I){if(typeof I=="string"){var u=i._prime(I);this.m=u.p,this.prime=u}else r(I.gtn(1),"modulus must be greater than 1"),this.m=I,this.prime=null}pe.prototype._verify1=function(u){r(u.negative===0,"red works only with positives"),r(u.red,"red works only with red numbers")},pe.prototype._verify2=function(u,h){r((u.negative|h.negative)===0,"red works only with positives"),r(u.red&&u.red===h.red,"red works only with red numbers")},pe.prototype.imod=function(u){return this.prime?this.prime.ireduce(u)._forceRed(this):u.umod(this.m)._forceRed(this)},pe.prototype.neg=function(u){return u.isZero()?u.clone():this.m.sub(u)._forceRed(this)},pe.prototype.add=function(u,h){this._verify2(u,h);var v=u.add(h);return v.cmp(this.m)>=0&&v.isub(this.m),v._forceRed(this)},pe.prototype.iadd=function(u,h){this._verify2(u,h);var v=u.iadd(h);return v.cmp(this.m)>=0&&v.isub(this.m),v},pe.prototype.sub=function(u,h){this._verify2(u,h);var v=u.sub(h);return v.cmpn(0)<0&&v.iadd(this.m),v._forceRed(this)},pe.prototype.isub=function(u,h){this._verify2(u,h);var v=u.isub(h);return v.cmpn(0)<0&&v.iadd(this.m),v},pe.prototype.shl=function(u,h){return this._verify1(u),this.imod(u.ushln(h))},pe.prototype.imul=function(u,h){return this._verify2(u,h),this.imod(u.imul(h))},pe.prototype.mul=function(u,h){return this._verify2(u,h),this.imod(u.mul(h))},pe.prototype.isqr=function(u){return this.imul(u,u.clone())},pe.prototype.sqr=function(u){return this.mul(u,u)},pe.prototype.sqrt=function(u){if(u.isZero())return u.clone();var h=this.m.andln(3);if(r(h%2===1),h===3){var v=this.m.add(new i(1)).iushrn(2);return this.pow(u,v)}for(var _=this.m.subn(1),S=0;!_.isZero()&&_.andln(1)===0;)S++,_.iushrn(1);r(!_.isZero());var T=new i(1).toRed(this),P=T.redNeg(),E=this.m.subn(1).iushrn(1),c=this.m.bitLength();for(c=new i(2*c*c).toRed(this);this.pow(c,E).cmp(P)!==0;)c.redIAdd(P);for(var b=this.pow(c,_),C=this.pow(u,_.addn(1).iushrn(1)),N=this.pow(u,_),L=S;N.cmp(T)!==0;){for(var K=N,z=0;K.cmp(T)!==0;z++)K=K.redSqr();r(z<L);var W=this.pow(b,new i(1).iushln(L-z-1));C=C.redMul(W),b=W.redSqr(),N=N.redMul(b),L=z}return C},pe.prototype.invm=function(u){var h=u._invmp(this.m);return h.negative!==0?(h.negative=0,this.imod(h).redNeg()):this.imod(h)},pe.prototype.pow=function(u,h){if(h.isZero())return new i(1).toRed(this);if(h.cmpn(1)===0)return u.clone();var v=4,_=new Array(1<<v);_[0]=new i(1).toRed(this),_[1]=u;for(var S=2;S<_.length;S++)_[S]=this.mul(_[S-1],u);var T=_[0],P=0,E=0,c=h.bitLength()%26;for(c===0&&(c=26),S=h.length-1;S>=0;S--){for(var b=h.words[S],C=c-1;C>=0;C--){var N=b>>C&1;if(T!==_[0]&&(T=this.sqr(T)),N===0&&P===0){E=0;continue}P<<=1,P|=N,E++,!(E!==v&&(S!==0||C!==0))&&(T=this.mul(T,_[P]),E=0,P=0)}c=26}return T},pe.prototype.convertTo=function(u){var h=u.umod(this.m);return h===u?h.clone():h},pe.prototype.convertFrom=function(u){var h=u.clone();return h.red=null,h},i.mont=function(u){return new xe(u)};function xe(I){pe.call(this,I),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(xe,pe),xe.prototype.convertTo=function(u){return this.imod(u.ushln(this.shift))},xe.prototype.convertFrom=function(u){var h=this.imod(u.mul(this.rinv));return h.red=null,h},xe.prototype.imul=function(u,h){if(u.isZero()||h.isZero())return u.words[0]=0,u.length=1,u;var v=u.imul(h),_=v.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),S=v.isub(_).iushrn(this.shift),T=S;return S.cmp(this.m)>=0?T=S.isub(this.m):S.cmpn(0)<0&&(T=S.iadd(this.m)),T._forceRed(this)},xe.prototype.mul=function(u,h){if(u.isZero()||h.isZero())return new i(0)._forceRed(this);var v=u.mul(h),_=v.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),S=v.isub(_).iushrn(this.shift),T=S;return S.cmp(this.m)>=0?T=S.isub(this.m):S.cmpn(0)<0&&(T=S.iadd(this.m)),T._forceRed(this)},xe.prototype.invm=function(u){var h=this.imod(u._invmp(this.m).mul(this.r2));return h._forceRed(this)}})(typeof Rl>"u"||Rl,D0)});var Je=B((QC,Tl)=>{g();typeof Object.create=="function"?Tl.exports=function(t,r){r&&(t.super_=r,t.prototype=Object.create(r.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:Tl.exports=function(t,r){if(r){t.super_=r;var n=function(){};n.prototype=r.prototype,t.prototype=new n,t.prototype.constructor=t}}});var Yt=B((Pl,q0)=>{g();var au=Lt(),tn=au.Buffer;function F0(e,t){for(var r in e)t[r]=e[r]}tn.from&&tn.alloc&&tn.allocUnsafe&&tn.allocUnsafeSlow?q0.exports=au:(F0(au,Pl),Pl.Buffer=Bi);function Bi(e,t,r){return tn(e,t,r)}Bi.prototype=Object.create(tn.prototype);F0(tn,Bi);Bi.from=function(e,t,r){if(typeof e=="number")throw new TypeError("Argument must not be a number");return tn(e,t,r)};Bi.alloc=function(e,t,r){if(typeof e!="number")throw new TypeError("Argument must be a number");var n=tn(e);return t!==void 0?typeof r=="string"?n.fill(t,r):n.fill(t):n.fill(0),n};Bi.allocUnsafe=function(e){if(typeof e!="number")throw new TypeError("Argument must be a number");return tn(e)};Bi.allocUnsafeSlow=function(e){if(typeof e!="number")throw new TypeError("Argument must be a number");return au.SlowBuffer(e)}});var wo=B((rL,Bl)=>{"use strict";g();var So=typeof Reflect=="object"?Reflect:null,H0=So&&typeof So.apply=="function"?So.apply:function(t,r,n){return Function.prototype.apply.call(t,r,n)},uu;So&&typeof So.ownKeys=="function"?uu=So.ownKeys:Object.getOwnPropertySymbols?uu=function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:uu=function(t){return Object.getOwnPropertyNames(t)};function rA(e){console&&console.warn&&console.warn(e)}var K0=Number.isNaN||function(t){return t!==t};function Ye(){Ye.init.call(this)}Bl.exports=Ye;Bl.exports.once=sA;Ye.EventEmitter=Ye;Ye.prototype._events=void 0;Ye.prototype._eventsCount=0;Ye.prototype._maxListeners=void 0;var j0=10;function fu(e){if(typeof e!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}Object.defineProperty(Ye,"defaultMaxListeners",{enumerable:!0,get:function(){return j0},set:function(e){if(typeof e!="number"||e<0||K0(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");j0=e}});Ye.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};Ye.prototype.setMaxListeners=function(t){if(typeof t!="number"||t<0||K0(t))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+t+".");return this._maxListeners=t,this};function G0(e){return e._maxListeners===void 0?Ye.defaultMaxListeners:e._maxListeners}Ye.prototype.getMaxListeners=function(){return G0(this)};Ye.prototype.emit=function(t){for(var r=[],n=1;n<arguments.length;n++)r.push(arguments[n]);var i=t==="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 f=o[t];if(f===void 0)return!1;if(typeof f=="function")H0(f,this,r);else for(var l=f.length,m=$0(f,l),n=0;n<l;++n)H0(m[n],this,r);return!0};function V0(e,t,r,n){var i,o,s;if(fu(r),o=e._events,o===void 0?(o=e._events=Object.create(null),e._eventsCount=0):(o.newListener!==void 0&&(e.emit("newListener",t,r.listener?r.listener:r),o=e._events),s=o[t]),s===void 0)s=o[t]=r,++e._eventsCount;else if(typeof s=="function"?s=o[t]=n?[r,s]:[s,r]:n?s.unshift(r):s.push(r),i=G0(e),i>0&&s.length>i&&!s.warned){s.warned=!0;var a=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");a.name="MaxListenersExceededWarning",a.emitter=e,a.type=t,a.count=s.length,rA(a)}return e}Ye.prototype.addListener=function(t,r){return V0(this,t,r,!1)};Ye.prototype.on=Ye.prototype.addListener;Ye.prototype.prependListener=function(t,r){return V0(this,t,r,!0)};function nA(){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 W0(e,t,r){var n={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},i=nA.bind(n);return i.listener=r,n.wrapFn=i,i}Ye.prototype.once=function(t,r){return fu(r),this.on(t,W0(this,t,r)),this};Ye.prototype.prependOnceListener=function(t,r){return fu(r),this.prependListener(t,W0(this,t,r)),this};Ye.prototype.removeListener=function(t,r){var n,i,o,s,a;if(fu(r),i=this._events,i===void 0)return this;if(n=i[t],n===void 0)return this;if(n===r||n.listener===r)--this._eventsCount===0?this._events=Object.create(null):(delete i[t],i.removeListener&&this.emit("removeListener",t,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():iA(n,o),n.length===1&&(i[t]=n[0]),i.removeListener!==void 0&&this.emit("removeListener",t,a||r)}return this};Ye.prototype.off=Ye.prototype.removeListener;Ye.prototype.removeAllListeners=function(t){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[t]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete n[t]),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[t],typeof r=="function")this.removeListener(t,r);else if(r!==void 0)for(i=r.length-1;i>=0;i--)this.removeListener(t,r[i]);return this};function z0(e,t,r){var n=e._events;if(n===void 0)return[];var i=n[t];return i===void 0?[]:typeof i=="function"?r?[i.listener||i]:[i]:r?oA(i):$0(i,i.length)}Ye.prototype.listeners=function(t){return z0(this,t,!0)};Ye.prototype.rawListeners=function(t){return z0(this,t,!1)};Ye.listenerCount=function(e,t){return typeof e.listenerCount=="function"?e.listenerCount(t):Y0.call(e,t)};Ye.prototype.listenerCount=Y0;function Y0(e){var t=this._events;if(t!==void 0){var r=t[e];if(typeof r=="function")return 1;if(r!==void 0)return r.length}return 0}Ye.prototype.eventNames=function(){return this._eventsCount>0?uu(this._events):[]};function $0(e,t){for(var r=new Array(t),n=0;n<t;++n)r[n]=e[n];return r}function iA(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}function oA(e){for(var t=new Array(e.length),r=0;r<t.length;++r)t[r]=e[r].listener||e[r];return t}function sA(e,t){return new Promise(function(r,n){function i(s){e.removeListener(t,o),n(s)}function o(){typeof e.removeListener=="function"&&e.removeListener("error",i),r([].slice.call(arguments))}Z0(e,t,o,{once:!0}),t!=="error"&&aA(e,i,{once:!0})})}function aA(e,t,r){typeof e.on=="function"&&Z0(e,"error",t,r)}function Z0(e,t,r,n){if(typeof e.on=="function")n.once?e.once(t,r):e.on(t,r);else if(typeof e.addEventListener=="function")e.addEventListener(t,function i(o){n.once&&e.removeEventListener(t,i),r(o)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e)}});var Nl=B((iL,X0)=>{g();X0.exports=wo().EventEmitter});var cu=B((sL,J0)=>{"use strict";g();J0.exports=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var t={},r=Symbol("test"),n=Object(r);if(typeof r=="string"||Object.prototype.toString.call(r)!=="[object Symbol]"||Object.prototype.toString.call(n)!=="[object Symbol]")return!1;var i=42;t[r]=i;for(var o in t)return!1;if(typeof Object.keys=="function"&&Object.keys(t).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(t).length!==0)return!1;var s=Object.getOwnPropertySymbols(t);if(s.length!==1||s[0]!==r||!Object.prototype.propertyIsEnumerable.call(t,r))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var a=Object.getOwnPropertyDescriptor(t,r);if(a.value!==i||a.enumerable!==!0)return!1}return!0}});var Es=B((uL,Q0)=>{"use strict";g();var uA=cu();Q0.exports=function(){return uA()&&!!Symbol.toStringTag}});var lu=B((cL,eg)=>{"use strict";g();eg.exports=Object});var rg=B((hL,tg)=>{"use strict";g();tg.exports=Error});var ig=B((pL,ng)=>{"use strict";g();ng.exports=EvalError});var sg=B((yL,og)=>{"use strict";g();og.exports=RangeError});var ug=B((vL,ag)=>{"use strict";g();ag.exports=ReferenceError});var Ml=B((_L,fg)=>{"use strict";g();fg.exports=SyntaxError});var Ni=B((wL,cg)=>{"use strict";g();cg.exports=TypeError});var hg=B((xL,lg)=>{"use strict";g();lg.exports=URIError});var pg=B((AL,dg)=>{"use strict";g();dg.exports=Math.abs});var yg=B((RL,gg)=>{"use strict";g();gg.exports=Math.floor});var vg=B((PL,mg)=>{"use strict";g();mg.exports=Math.max});var _g=B((NL,bg)=>{"use strict";g();bg.exports=Math.min});var wg=B((kL,Sg)=>{"use strict";g();Sg.exports=Math.pow});var xg=B((LL,Eg)=>{"use strict";g();Eg.exports=Math.round});var Ag=B((UL,Ig)=>{"use strict";g();Ig.exports=Number.isNaN||function(t){return t!==t}});var Rg=B((qL,Og)=>{"use strict";g();var fA=Ag();Og.exports=function(t){return fA(t)||t===0?t:t<0?-1:1}});var Pg=B((jL,Tg)=>{"use strict";g();Tg.exports=Object.getOwnPropertyDescriptor});var Mi=B((GL,Bg)=>{"use strict";g();var hu=Pg();if(hu)try{hu([],"length")}catch{hu=null}Bg.exports=hu});var xs=B((WL,Ng)=>{"use strict";g();var du=Object.defineProperty||!1;if(du)try{du({},"a",{value:1})}catch{du=!1}Ng.exports=du});var Cg=B((YL,kg)=>{"use strict";g();var Mg=typeof Symbol<"u"&&Symbol,cA=cu();kg.exports=function(){return typeof Mg!="function"||typeof Symbol!="function"||typeof Mg("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:cA()}});var kl=B((ZL,Lg)=>{"use strict";g();Lg.exports=typeof Reflect<"u"&&Reflect.getPrototypeOf||null});var Cl=B((JL,Dg)=>{"use strict";g();var lA=lu();Dg.exports=lA.getPrototypeOf||null});var qg=B((e8,Fg)=>{"use strict";g();var hA="Function.prototype.bind called on incompatible ",dA=Object.prototype.toString,pA=Math.max,gA="[object Function]",Ug=function(t,r){for(var n=[],i=0;i<t.length;i+=1)n[i]=t[i];for(var o=0;o<r.length;o+=1)n[o+t.length]=r[o];return n},yA=function(t,r){for(var n=[],i=r||0,o=0;i<t.length;i+=1,o+=1)n[o]=t[i];return n},mA=function(e,t){for(var r="",n=0;n<e.length;n+=1)r+=e[n],n+1<e.length&&(r+=t);return r};Fg.exports=function(t){var r=this;if(typeof r!="function"||dA.apply(r)!==gA)throw new TypeError(hA+r);for(var n=yA(arguments,1),i,o=function(){if(this instanceof i){var m=r.apply(this,Ug(n,arguments));return Object(m)===m?m:this}return r.apply(t,Ug(n,arguments))},s=pA(0,r.length-n.length),a=[],f=0;f<s;f++)a[f]="$"+f;if(i=Function("binder","return function ("+mA(a,",")+"){ return binder.apply(this,arguments); }")(o),r.prototype){var l=function(){};l.prototype=r.prototype,i.prototype=new l,l.prototype=null}return i}});var Eo=B((r8,Hg)=>{"use strict";g();var vA=qg();Hg.exports=Function.prototype.bind||vA});var pu=B((i8,jg)=>{"use strict";g();jg.exports=Function.prototype.call});var gu=B((s8,Kg)=>{"use strict";g();Kg.exports=Function.prototype.apply});var Vg=B((u8,Gg)=>{"use strict";g();Gg.exports=typeof Reflect<"u"&&Reflect&&Reflect.apply});var Ll=B((c8,Wg)=>{"use strict";g();var bA=Eo(),_A=gu(),SA=pu(),wA=Vg();Wg.exports=wA||bA.call(SA,_A)});var yu=B((h8,zg)=>{"use strict";g();var EA=Eo(),xA=Ni(),IA=pu(),AA=Ll();zg.exports=function(t){if(t.length<1||typeof t[0]!="function")throw new xA("a function is required");return AA(EA,IA,t)}});var Qg=B((p8,Jg)=>{"use strict";g();var OA=yu(),Yg=Mi(),Zg;try{Zg=[].__proto__===Array.prototype}catch(e){if(!e||typeof e!="object"||!("code"in e)||e.code!=="ERR_PROTO_ACCESS")throw e}var Dl=!!Zg&&Yg&&Yg(Object.prototype,"__proto__"),Xg=Object,$g=Xg.getPrototypeOf;Jg.exports=Dl&&typeof Dl.get=="function"?OA([Dl.get]):typeof $g=="function"?function(t){return $g(t==null?t:Xg(t))}:!1});var mu=B((y8,ny)=>{"use strict";g();var ey=kl(),ty=Cl(),ry=Qg();ny.exports=ey?function(t){return ey(t)}:ty?function(t){if(!t||typeof t!="object"&&typeof t!="function")throw new TypeError("getProto: not an object");return ty(t)}:ry?function(t){return ry(t)}:null});var Ul=B((v8,iy)=>{"use strict";g();var RA=Function.prototype.call,TA=Object.prototype.hasOwnProperty,PA=Eo();iy.exports=PA.call(RA,TA)});var _u=B((_8,cy)=>{"use strict";g();var Be,BA=lu(),NA=rg(),MA=ig(),kA=sg(),CA=ug(),Oo=Ml(),Ao=Ni(),LA=hg(),DA=pg(),UA=yg(),FA=vg(),qA=_g(),HA=wg(),jA=xg(),KA=Rg(),uy=Function,Fl=function(e){try{return uy('"use strict"; return ('+e+").constructor;")()}catch{}},Is=Mi(),GA=xs(),ql=function(){throw new Ao},VA=Is?(function(){try{return arguments.callee,ql}catch{try{return Is(arguments,"callee").get}catch{return ql}}})():ql,xo=Cg()(),Kt=mu(),WA=Cl(),zA=kl(),fy=gu(),As=pu(),Io={},YA=typeof Uint8Array>"u"||!Kt?Be:Kt(Uint8Array),ki={__proto__:null,"%AggregateError%":typeof AggregateError>"u"?Be:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?Be:ArrayBuffer,"%ArrayIteratorPrototype%":xo&&Kt?Kt([][Symbol.iterator]()):Be,"%AsyncFromSyncIteratorPrototype%":Be,"%AsyncFunction%":Io,"%AsyncGenerator%":Io,"%AsyncGeneratorFunction%":Io,"%AsyncIteratorPrototype%":Io,"%Atomics%":typeof Atomics>"u"?Be:Atomics,"%BigInt%":typeof BigInt>"u"?Be:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?Be:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?Be:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?Be:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":NA,"%eval%":eval,"%EvalError%":MA,"%Float16Array%":typeof Float16Array>"u"?Be:Float16Array,"%Float32Array%":typeof Float32Array>"u"?Be:Float32Array,"%Float64Array%":typeof Float64Array>"u"?Be:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?Be:FinalizationRegistry,"%Function%":uy,"%GeneratorFunction%":Io,"%Int8Array%":typeof Int8Array>"u"?Be:Int8Array,"%Int16Array%":typeof Int16Array>"u"?Be:Int16Array,"%Int32Array%":typeof Int32Array>"u"?Be:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":xo&&Kt?Kt(Kt([][Symbol.iterator]())):Be,"%JSON%":typeof JSON=="object"?JSON:Be,"%Map%":typeof Map>"u"?Be:Map,"%MapIteratorPrototype%":typeof Map>"u"||!xo||!Kt?Be:Kt(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":BA,"%Object.getOwnPropertyDescriptor%":Is,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?Be:Promise,"%Proxy%":typeof Proxy>"u"?Be:Proxy,"%RangeError%":kA,"%ReferenceError%":CA,"%Reflect%":typeof Reflect>"u"?Be:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?Be:Set,"%SetIteratorPrototype%":typeof Set>"u"||!xo||!Kt?Be:Kt(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?Be:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":xo&&Kt?Kt(""[Symbol.iterator]()):Be,"%Symbol%":xo?Symbol:Be,"%SyntaxError%":Oo,"%ThrowTypeError%":VA,"%TypedArray%":YA,"%TypeError%":Ao,"%Uint8Array%":typeof Uint8Array>"u"?Be:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?Be:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?Be:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?Be:Uint32Array,"%URIError%":LA,"%WeakMap%":typeof WeakMap>"u"?Be:WeakMap,"%WeakRef%":typeof WeakRef>"u"?Be:WeakRef,"%WeakSet%":typeof WeakSet>"u"?Be:WeakSet,"%Function.prototype.call%":As,"%Function.prototype.apply%":fy,"%Object.defineProperty%":GA,"%Object.getPrototypeOf%":WA,"%Math.abs%":DA,"%Math.floor%":UA,"%Math.max%":FA,"%Math.min%":qA,"%Math.pow%":HA,"%Math.round%":jA,"%Math.sign%":KA,"%Reflect.getPrototypeOf%":zA};if(Kt)try{null.error}catch(e){oy=Kt(Kt(e)),ki["%Error.prototype%"]=oy}var oy,$A=function e(t){var r;if(t==="%AsyncFunction%")r=Fl("async function () {}");else if(t==="%GeneratorFunction%")r=Fl("function* () {}");else if(t==="%AsyncGeneratorFunction%")r=Fl("async function* () {}");else if(t==="%AsyncGenerator%"){var n=e("%AsyncGeneratorFunction%");n&&(r=n.prototype)}else if(t==="%AsyncIteratorPrototype%"){var i=e("%AsyncGenerator%");i&&Kt&&(r=Kt(i.prototype))}return ki[t]=r,r},sy={__proto__:null,"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},Os=Eo(),vu=Ul(),ZA=Os.call(As,Array.prototype.concat),XA=Os.call(fy,Array.prototype.splice),ay=Os.call(As,String.prototype.replace),bu=Os.call(As,String.prototype.slice),JA=Os.call(As,RegExp.prototype.exec),QA=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,eO=/\\(\\)?/g,tO=function(t){var r=bu(t,0,1),n=bu(t,-1);if(r==="%"&&n!=="%")throw new Oo("invalid intrinsic syntax, expected closing `%`");if(n==="%"&&r!=="%")throw new Oo("invalid intrinsic syntax, expected opening `%`");var i=[];return ay(t,QA,function(o,s,a,f){i[i.length]=a?ay(f,eO,"$1"):s||o}),i},rO=function(t,r){var n=t,i;if(vu(sy,n)&&(i=sy[n],n="%"+i[0]+"%"),vu(ki,n)){var o=ki[n];if(o===Io&&(o=$A(n)),typeof o>"u"&&!r)throw new Ao("intrinsic "+t+" exists, but is not available. Please file an issue!");return{alias:i,name:n,value:o}}throw new Oo("intrinsic "+t+" does not exist!")};cy.exports=function(t,r){if(typeof t!="string"||t.length===0)throw new Ao("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof r!="boolean")throw new Ao('"allowMissing" argument must be a boolean');if(JA(/^%?[^%]*%?$/,t)===null)throw new Oo("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var n=tO(t),i=n.length>0?n[0]:"",o=rO("%"+i+"%",r),s=o.name,a=o.value,f=!1,l=o.alias;l&&(i=l[0],XA(n,ZA([0,1],l)));for(var m=1,y=!0;m<n.length;m+=1){var p=n[m],w=bu(p,0,1),O=bu(p,-1);if((w==='"'||w==="'"||w==="`"||O==='"'||O==="'"||O==="`")&&w!==O)throw new Oo("property names with quotes must have matching quotes");if((p==="constructor"||!y)&&(f=!0),i+="."+p,s="%"+i+"%",vu(ki,s))a=ki[s];else if(a!=null){if(!(p in a)){if(!r)throw new Ao("base intrinsic for "+t+" exists, but the property is not available.");return}if(Is&&m+1>=n.length){var M=Is(a,p);y=!!M,y&&"get"in M&&!("originalValue"in M.get)?a=M.get:a=a[p]}else y=vu(a,p),a=a[p];y&&!f&&(ki[s]=a)}}return a}});var Zn=B((w8,dy)=>{"use strict";g();var ly=_u(),hy=yu(),nO=hy([ly("%String.prototype.indexOf%")]);dy.exports=function(t,r){var n=ly(t,!!r);return typeof n=="function"&&nO(t,".prototype.")>-1?hy([n]):n}});var yy=B((x8,gy)=>{"use strict";g();var iO=Es()(),oO=Zn(),Hl=oO("Object.prototype.toString"),Su=function(t){return iO&&t&&typeof t=="object"&&Symbol.toStringTag in t?!1:Hl(t)==="[object Arguments]"},py=function(t){return Su(t)?!0:t!==null&&typeof t=="object"&&"length"in t&&typeof t.length=="number"&&t.length>=0&&Hl(t)!=="[object Array]"&&"callee"in t&&Hl(t.callee)==="[object Function]"},sO=(function(){return Su(arguments)})();Su.isLegacyArguments=py;gy.exports=sO?Su:py});var wy=B((A8,Sy)=>{"use strict";g();var my=Zn(),aO=Es()(),uO=Ul(),fO=Mi(),Gl;aO?(vy=my("RegExp.prototype.exec"),jl={},wu=function(){throw jl},Kl={toString:wu,valueOf:wu},typeof Symbol.toPrimitive=="symbol"&&(Kl[Symbol.toPrimitive]=wu),Gl=function(t){if(!t||typeof t!="object")return!1;var r=fO(t,"lastIndex"),n=r&&uO(r,"value");if(!n)return!1;try{vy(t,Kl)}catch(i){return i===jl}}):(by=my("Object.prototype.toString"),_y="[object RegExp]",Gl=function(t){return!t||typeof t!="object"&&typeof t!="function"?!1:by(t)===_y});var vy,jl,wu,Kl,by,_y;Sy.exports=Gl});var xy=B((R8,Ey)=>{"use strict";g();var cO=Zn(),lO=wy(),hO=cO("RegExp.prototype.exec"),dO=Ni();Ey.exports=function(t){if(!lO(t))throw new dO("`regex` must be a RegExp");return function(n){return hO(t,n)!==null}}});var Ay=B((P8,Iy)=>{"use strict";g();var pO=function*(){}.constructor;Iy.exports=()=>pO});var Py=B((N8,Ty)=>{"use strict";g();var Ry=Zn(),gO=xy(),yO=gO(/^\s*(?:function)?\*/),mO=Es()(),Oy=mu(),vO=Ry("Object.prototype.toString"),bO=Ry("Function.prototype.toString"),_O=Ay();Ty.exports=function(t){if(typeof t!="function")return!1;if(yO(bO(t)))return!0;if(!mO){var r=vO(t);return r==="[object GeneratorFunction]"}if(!Oy)return!1;var n=_O();return n&&Oy(t)===n.prototype}});var ky=B((k8,My)=>{"use strict";g();var Ny=Function.prototype.toString,Ro=typeof Reflect=="object"&&Reflect!==null&&Reflect.apply,Wl,Eu;if(typeof Ro=="function"&&typeof Object.defineProperty=="function")try{Wl=Object.defineProperty({},"length",{get:function(){throw Eu}}),Eu={},Ro(function(){throw 42},null,Wl)}catch(e){e!==Eu&&(Ro=null)}else Ro=null;var SO=/^\s*class\b/,zl=function(t){try{var r=Ny.call(t);return SO.test(r)}catch{return!1}},Vl=function(t){try{return zl(t)?!1:(Ny.call(t),!0)}catch{return!1}},xu=Object.prototype.toString,wO="[object Object]",EO="[object Function]",xO="[object GeneratorFunction]",IO="[object HTMLAllCollection]",AO="[object HTML document.all class]",OO="[object HTMLCollection]",RO=typeof Symbol=="function"&&!!Symbol.toStringTag,TO=!(0 in[,]),Yl=function(){return!1};typeof document=="object"&&(By=document.all,xu.call(By)===xu.call(document.all)&&(Yl=function(t){if((TO||!t)&&(typeof t>"u"||typeof t=="object"))try{var r=xu.call(t);return(r===IO||r===AO||r===OO||r===wO)&&t("")==null}catch{}return!1}));var By;My.exports=Ro?function(t){if(Yl(t))return!0;if(!t||typeof t!="function"&&typeof t!="object")return!1;try{Ro(t,null,Wl)}catch(r){if(r!==Eu)return!1}return!zl(t)&&Vl(t)}:function(t){if(Yl(t))return!0;if(!t||typeof t!="function"&&typeof t!="object")return!1;if(RO)return Vl(t);if(zl(t))return!1;var r=xu.call(t);return r!==EO&&r!==xO&&!/^\[object HTML/.test(r)?!1:Vl(t)}});var Dy=B((L8,Ly)=>{"use strict";g();var PO=ky(),BO=Object.prototype.toString,Cy=Object.prototype.hasOwnProperty,NO=function(t,r,n){for(var i=0,o=t.length;i<o;i++)Cy.call(t,i)&&(n==null?r(t[i],i,t):r.call(n,t[i],i,t))},MO=function(t,r,n){for(var i=0,o=t.length;i<o;i++)n==null?r(t.charAt(i),i,t):r.call(n,t.charAt(i),i,t)},kO=function(t,r,n){for(var i in t)Cy.call(t,i)&&(n==null?r(t[i],i,t):r.call(n,t[i],i,t))};function CO(e){return BO.call(e)==="[object Array]"}Ly.exports=function(t,r,n){if(!PO(r))throw new TypeError("iterator must be a function");var i;arguments.length>=3&&(i=n),CO(t)?NO(t,r,i):typeof t=="string"?MO(t,r,i):kO(t,r,i)}});var Fy=B((U8,Uy)=>{"use strict";g();Uy.exports=["Float16Array","Float32Array","Float64Array","Int8Array","Int16Array","Int32Array","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array"]});var Hy=B((q8,qy)=>{"use strict";g();var $l=Fy(),LO=globalThis;qy.exports=function(){for(var t=[],r=0;r<$l.length;r++)typeof LO[$l[r]]=="function"&&(t[t.length]=$l[r]);return t}});var Zl=B((j8,Gy)=>{"use strict";g();var jy=xs(),DO=Ml(),To=Ni(),Ky=Mi();Gy.exports=function(t,r,n){if(!t||typeof t!="object"&&typeof t!="function")throw new To("`obj` must be an object or a function`");if(typeof r!="string"&&typeof r!="symbol")throw new To("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!="boolean"&&arguments[3]!==null)throw new To("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!="boolean"&&arguments[4]!==null)throw new To("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!="boolean"&&arguments[5]!==null)throw new To("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!="boolean")throw new To("`loose`, if provided, must be a boolean");var i=arguments.length>3?arguments[3]:null,o=arguments.length>4?arguments[4]:null,s=arguments.length>5?arguments[5]:null,a=arguments.length>6?arguments[6]:!1,f=!!Ky&&Ky(t,r);if(jy)jy(t,r,{configurable:s===null&&f?f.configurable:!s,enumerable:i===null&&f?f.enumerable:!i,value:n,writable:o===null&&f?f.writable:!o});else if(a||!i&&!o&&!s)t[r]=n;else throw new DO("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")}});var Jl=B((G8,Wy)=>{"use strict";g();var Xl=xs(),Vy=function(){return!!Xl};Vy.hasArrayLengthDefineBug=function(){if(!Xl)return null;try{return Xl([],"length",{value:1}).length!==1}catch{return!0}};Wy.exports=Vy});var Xy=B((W8,Zy)=>{"use strict";g();var UO=_u(),zy=Zl(),FO=Jl()(),Yy=Mi(),$y=Ni(),qO=UO("%Math.floor%");Zy.exports=function(t,r){if(typeof t!="function")throw new $y("`fn` is not a function");if(typeof r!="number"||r<0||r>4294967295||qO(r)!==r)throw new $y("`length` must be a positive 32-bit integer");var n=arguments.length>2&&!!arguments[2],i=!0,o=!0;if("length"in t&&Yy){var s=Yy(t,"length");s&&!s.configurable&&(i=!1),s&&!s.writable&&(o=!1)}return(i||o||!n)&&(FO?zy(t,"length",r,!0,!0):zy(t,"length",r)),t}});var Qy=B((Y8,Jy)=>{"use strict";g();var HO=Eo(),jO=gu(),KO=Ll();Jy.exports=function(){return KO(HO,jO,arguments)}});var Rs=B((Z8,Iu)=>{"use strict";g();var GO=Xy(),em=xs(),VO=yu(),tm=Qy();Iu.exports=function(t){var r=VO(arguments),n=1+t.length-(arguments.length-1);return GO(r,n>0?n:0,!0)};em?em(Iu.exports,"apply",{value:tm}):Iu.exports.apply=tm});var rh=B((J8,om)=>{"use strict";g();var Ru=Dy(),WO=Hy(),rm=Rs(),eh=Zn(),Ou=Mi(),Au=mu(),zO=eh("Object.prototype.toString"),im=Es()(),nm=globalThis,Ql=WO(),th=eh("String.prototype.slice"),YO=eh("Array.prototype.indexOf",!0)||function(t,r){for(var n=0;n<t.length;n+=1)if(t[n]===r)return n;return-1},Tu={__proto__:null};im&&Ou&&Au?Ru(Ql,function(e){var t=new nm[e];if(Symbol.toStringTag in t&&Au){var r=Au(t),n=Ou(r,Symbol.toStringTag);if(!n&&r){var i=Au(r);n=Ou(i,Symbol.toStringTag)}if(n&&n.get){var o=rm(n.get);Tu["$"+e]=o}}}):Ru(Ql,function(e){var t=new nm[e],r=t.slice||t.set;if(r){var n=rm(r);Tu["$"+e]=n}});var $O=function(t){var r=!1;return Ru(Tu,function(n,i){if(!r)try{"$"+n(t)===i&&(r=th(i,1))}catch{}}),r},ZO=function(t){var r=!1;return Ru(Tu,function(n,i){if(!r)try{n(t),r=th(i,1)}catch{}}),r};om.exports=function(t){if(!t||typeof t!="object")return!1;if(!im){var r=th(zO(t),8,-1);return YO(Ql,r)>-1?r:r!=="Object"?!1:ZO(t)}return Ou?$O(t):null}});var nh=B((e4,sm)=>{"use strict";g();var XO=rh();sm.exports=function(t){return!!XO(t)}});var _m=B(Ne=>{"use strict";g();var JO=yy(),QO=Py(),Mr=rh(),am=nh();function Po(e){return e.call.bind(e)}var um=typeof BigInt<"u",fm=typeof Symbol<"u",Er=Po(Object.prototype.toString),eR=Po(Number.prototype.valueOf),tR=Po(String.prototype.valueOf),rR=Po(Boolean.prototype.valueOf);um&&(cm=Po(BigInt.prototype.valueOf));var cm;fm&&(lm=Po(Symbol.prototype.valueOf));var lm;function Ps(e,t){if(typeof e!="object")return!1;try{return t(e),!0}catch{return!1}}Ne.isArgumentsObject=JO;Ne.isGeneratorFunction=QO;Ne.isTypedArray=am;function nR(e){return typeof Promise<"u"&&e instanceof Promise||e!==null&&typeof e=="object"&&typeof e.then=="function"&&typeof e.catch=="function"}Ne.isPromise=nR;function iR(e){return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?ArrayBuffer.isView(e):am(e)||dm(e)}Ne.isArrayBufferView=iR;function oR(e){return Mr(e)==="Uint8Array"}Ne.isUint8Array=oR;function sR(e){return Mr(e)==="Uint8ClampedArray"}Ne.isUint8ClampedArray=sR;function aR(e){return Mr(e)==="Uint16Array"}Ne.isUint16Array=aR;function uR(e){return Mr(e)==="Uint32Array"}Ne.isUint32Array=uR;function fR(e){return Mr(e)==="Int8Array"}Ne.isInt8Array=fR;function cR(e){return Mr(e)==="Int16Array"}Ne.isInt16Array=cR;function lR(e){return Mr(e)==="Int32Array"}Ne.isInt32Array=lR;function hR(e){return Mr(e)==="Float32Array"}Ne.isFloat32Array=hR;function dR(e){return Mr(e)==="Float64Array"}Ne.isFloat64Array=dR;function pR(e){return Mr(e)==="BigInt64Array"}Ne.isBigInt64Array=pR;function gR(e){return Mr(e)==="BigUint64Array"}Ne.isBigUint64Array=gR;function Pu(e){return Er(e)==="[object Map]"}Pu.working=typeof Map<"u"&&Pu(new Map);function yR(e){return typeof Map>"u"?!1:Pu.working?Pu(e):e instanceof Map}Ne.isMap=yR;function Bu(e){return Er(e)==="[object Set]"}Bu.working=typeof Set<"u"&&Bu(new Set);function mR(e){return typeof Set>"u"?!1:Bu.working?Bu(e):e instanceof Set}Ne.isSet=mR;function Nu(e){return Er(e)==="[object WeakMap]"}Nu.working=typeof WeakMap<"u"&&Nu(new WeakMap);function vR(e){return typeof WeakMap>"u"?!1:Nu.working?Nu(e):e instanceof WeakMap}Ne.isWeakMap=vR;function oh(e){return Er(e)==="[object WeakSet]"}oh.working=typeof WeakSet<"u"&&oh(new WeakSet);function bR(e){return oh(e)}Ne.isWeakSet=bR;function Mu(e){return Er(e)==="[object ArrayBuffer]"}Mu.working=typeof ArrayBuffer<"u"&&Mu(new ArrayBuffer);function hm(e){return typeof ArrayBuffer>"u"?!1:Mu.working?Mu(e):e instanceof ArrayBuffer}Ne.isArrayBuffer=hm;function ku(e){return Er(e)==="[object DataView]"}ku.working=typeof ArrayBuffer<"u"&&typeof DataView<"u"&&ku(new DataView(new ArrayBuffer(1),0,1));function dm(e){return typeof DataView>"u"?!1:ku.working?ku(e):e instanceof DataView}Ne.isDataView=dm;var ih=typeof SharedArrayBuffer<"u"?SharedArrayBuffer:void 0;function Ts(e){return Er(e)==="[object SharedArrayBuffer]"}function pm(e){return typeof ih>"u"?!1:(typeof Ts.working>"u"&&(Ts.working=Ts(new ih)),Ts.working?Ts(e):e instanceof ih)}Ne.isSharedArrayBuffer=pm;function _R(e){return Er(e)==="[object AsyncFunction]"}Ne.isAsyncFunction=_R;function SR(e){return Er(e)==="[object Map Iterator]"}Ne.isMapIterator=SR;function wR(e){return Er(e)==="[object Set Iterator]"}Ne.isSetIterator=wR;function ER(e){return Er(e)==="[object Generator]"}Ne.isGeneratorObject=ER;function xR(e){return Er(e)==="[object WebAssembly.Module]"}Ne.isWebAssemblyCompiledModule=xR;function gm(e){return Ps(e,eR)}Ne.isNumberObject=gm;function ym(e){return Ps(e,tR)}Ne.isStringObject=ym;function mm(e){return Ps(e,rR)}Ne.isBooleanObject=mm;function vm(e){return um&&Ps(e,cm)}Ne.isBigIntObject=vm;function bm(e){return fm&&Ps(e,lm)}Ne.isSymbolObject=bm;function IR(e){return gm(e)||ym(e)||mm(e)||vm(e)||bm(e)}Ne.isBoxedPrimitive=IR;function AR(e){return typeof Uint8Array<"u"&&(hm(e)||pm(e))}Ne.isAnyArrayBuffer=AR;["isProxy","isExternal","isModuleNamespaceObject"].forEach(function(e){Object.defineProperty(Ne,e,{enumerable:!1,value:function(){throw new Error(e+" is not supported in userland")}})})});var wm=B((i4,Sm)=>{g();Sm.exports=function(t){return t&&typeof t=="object"&&typeof t.copy=="function"&&typeof t.fill=="function"&&typeof t.readUInt8=="function"}});var rn=B(Me=>{g();var Em=Object.getOwnPropertyDescriptors||function(t){for(var r=Object.keys(t),n={},i=0;i<r.length;i++)n[r[i]]=Object.getOwnPropertyDescriptor(t,r[i]);return n},OR=/%[sdj%]/g;Me.format=function(e){if(!Hu(e)){for(var t=[],r=0;r<arguments.length;r++)t.push(Xn(arguments[r]));return t.join(" ")}for(var r=1,n=arguments,i=n.length,o=String(e).replace(OR,function(a){if(a==="%%")return"%";if(r>=i)return a;switch(a){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch{return"[Circular]"}default:return a}}),s=n[r];r<i;s=n[++r])qu(s)||!Bo(s)?o+=" "+s:o+=" "+Xn(s);return o};Me.deprecate=function(e,t){if(typeof x.default<"u"&&x.default.noDeprecation===!0)return e;if(typeof x.default>"u")return function(){return Me.deprecate(e,t).apply(this,arguments)};var r=!1;function n(){if(!r){if(x.default.throwDeprecation)throw new Error(t);x.default.traceDeprecation?console.trace(t):console.error(t),r=!0}return e.apply(this,arguments)}return n};var Cu={},xm=/^$/;x.default.env.NODE_DEBUG&&(Lu=x.default.env.NODE_DEBUG,Lu=Lu.replace(/[|\\{}()[\]^$+?.]/g,"\\$&").replace(/\*/g,".*").replace(/,/g,"$|^").toUpperCase(),xm=new RegExp("^"+Lu+"$","i"));var Lu;Me.debuglog=function(e){if(e=e.toUpperCase(),!Cu[e])if(xm.test(e)){var t=x.default.pid;Cu[e]=function(){var r=Me.format.apply(Me,arguments);console.error("%s %d: %s",e,t,r)}}else Cu[e]=function(){};return Cu[e]};function Xn(e,t){var r={seen:[],stylize:TR};return arguments.length>=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),fh(t)?r.showHidden=t:t&&Me._extend(r,t),Li(r.showHidden)&&(r.showHidden=!1),Li(r.depth)&&(r.depth=2),Li(r.colors)&&(r.colors=!1),Li(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=RR),Uu(r,e,r.depth)}Me.inspect=Xn;Xn.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]};Xn.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"};function RR(e,t){var r=Xn.styles[t];return r?"\x1B["+Xn.colors[r][0]+"m"+e+"\x1B["+Xn.colors[r][1]+"m":e}function TR(e,t){return e}function PR(e){var t={};return e.forEach(function(r,n){t[r]=!0}),t}function Uu(e,t,r){if(e.customInspect&&t&&Du(t.inspect)&&t.inspect!==Me.inspect&&!(t.constructor&&t.constructor.prototype===t)){var n=t.inspect(r,e);return Hu(n)||(n=Uu(e,n,r)),n}var i=BR(e,t);if(i)return i;var o=Object.keys(t),s=PR(o);if(e.showHidden&&(o=Object.getOwnPropertyNames(t)),Ns(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return sh(t);if(o.length===0){if(Du(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(Bs(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(Fu(t))return e.stylize(Date.prototype.toString.call(t),"date");if(Ns(t))return sh(t)}var f="",l=!1,m=["{","}"];if(Im(t)&&(l=!0,m=["[","]"]),Du(t)){var y=t.name?": "+t.name:"";f=" [Function"+y+"]"}if(Bs(t)&&(f=" "+RegExp.prototype.toString.call(t)),Fu(t)&&(f=" "+Date.prototype.toUTCString.call(t)),Ns(t)&&(f=" "+sh(t)),o.length===0&&(!l||t.length==0))return m[0]+f+m[1];if(r<0)return Bs(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special");e.seen.push(t);var p;return l?p=NR(e,t,r,s,o):p=o.map(function(w){return uh(e,t,r,s,w,l)}),e.seen.pop(),MR(p,f,m)}function BR(e,t){if(Li(t))return e.stylize("undefined","undefined");if(Hu(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}if(Am(t))return e.stylize(""+t,"number");if(fh(t))return e.stylize(""+t,"boolean");if(qu(t))return e.stylize("null","null")}function sh(e){return"["+Error.prototype.toString.call(e)+"]"}function NR(e,t,r,n,i){for(var o=[],s=0,a=t.length;s<a;++s)Om(t,String(s))?o.push(uh(e,t,r,n,String(s),!0)):o.push("");return i.forEach(function(f){f.match(/^\d+$/)||o.push(uh(e,t,r,n,f,!0))}),o}function uh(e,t,r,n,i,o){var s,a,f;if(f=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]},f.get?f.set?a=e.stylize("[Getter/Setter]","special"):a=e.stylize("[Getter]","special"):f.set&&(a=e.stylize("[Setter]","special")),Om(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(f.value)<0?(qu(r)?a=Uu(e,f.value,null):a=Uu(e,f.value,r-1),a.indexOf(`
2
2
  `)>-1&&(o?a=a.split(`
3
3
  `).map(function(l){return" "+l}).join(`
4
4
  `).slice(2):a=`
5
5
  `+a.split(`
6
6
  `).map(function(l){return" "+l}).join(`
7
- `))):a=e.stylize("[Circular]","special")),Ni(s)){if(o&&i.match(/^\d+$/))return a;s=JSON.stringify(""+i),s.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.slice(1,-1),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+a}function NR(e,t,r){var n=0,i=e.reduce(function(o,s){return n++,s.indexOf(`
7
+ `))):a=e.stylize("[Circular]","special")),Li(s)){if(o&&i.match(/^\d+$/))return a;s=JSON.stringify(""+i),s.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.slice(1,-1),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+a}function MR(e,t,r){var n=0,i=e.reduce(function(o,s){return n++,s.indexOf(`
8
8
  `)>=0&&n++,o+s.replace(/\u001b\[\d\d?m/g,"").length+1},0);return i>60?r[0]+(t===""?"":t+`
9
9
  `)+" "+e.join(`,
10
- `)+" "+r[1]:r[0]+t+" "+e.join(", ")+" "+r[1]}Oe.types=vm();function Em(e){return Array.isArray(e)}Oe.isArray=Em;function ih(e){return typeof e=="boolean"}Oe.isBoolean=ih;function Cu(e){return e===null}Oe.isNull=Cu;function MR(e){return e==null}Oe.isNullOrUndefined=MR;function xm(e){return typeof e=="number"}Oe.isNumber=xm;function Lu(e){return typeof e=="string"}Oe.isString=Lu;function kR(e){return typeof e=="symbol"}Oe.isSymbol=kR;function Ni(e){return e===void 0}Oe.isUndefined=Ni;function As(e){return Ao(e)&&oh(e)==="[object RegExp]"}Oe.isRegExp=As;Oe.types.isRegExp=As;function Ao(e){return typeof e=="object"&&e!==null}Oe.isObject=Ao;function ku(e){return Ao(e)&&oh(e)==="[object Date]"}Oe.isDate=ku;Oe.types.isDate=ku;function Os(e){return Ao(e)&&(oh(e)==="[object Error]"||e instanceof Error)}Oe.isError=Os;Oe.types.isNativeError=Os;function Nu(e){return typeof e=="function"}Oe.isFunction=Nu;function CR(e){return e===null||typeof e=="boolean"||typeof e=="number"||typeof e=="string"||typeof e=="symbol"||typeof e>"u"}Oe.isPrimitive=CR;Oe.isBuffer=_m();function oh(e){return Object.prototype.toString.call(e)}function rh(e){return e<10?"0"+e.toString(10):e.toString(10)}var LR=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function DR(){var e=new Date,t=[rh(e.getHours()),rh(e.getMinutes()),rh(e.getSeconds())].join(":");return[e.getDate(),LR[e.getMonth()],t].join(" ")}Oe.log=function(){console.log("%s - %s",DR(),Oe.format.apply(Oe,arguments))};Oe.inherits=Ke();Oe._extend=function(e,t){if(!t||!Ao(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e};function Im(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var Bi=typeof Symbol<"u"?Symbol("util.promisify.custom"):void 0;Oe.promisify=function(t){if(typeof t!="function")throw new TypeError('The "original" argument must be of type Function');if(Bi&&t[Bi]){var r=t[Bi];if(typeof r!="function")throw new TypeError('The "util.promisify.custom" argument must be of type Function');return Object.defineProperty(r,Bi,{value:r,enumerable:!1,writable:!1,configurable:!0}),r}function r(){for(var n,i,o=new Promise(function(f,l){n=f,i=l}),s=[],a=0;a<arguments.length;a++)s.push(arguments[a]);s.push(function(f,l){f?i(f):n(l)});try{t.apply(this,s)}catch(f){i(f)}return o}return Object.setPrototypeOf(r,Object.getPrototypeOf(t)),Bi&&Object.defineProperty(r,Bi,{value:r,enumerable:!1,writable:!1,configurable:!0}),Object.defineProperties(r,Sm(t))};Oe.promisify.custom=Bi;function UR(e,t){if(!e){var r=new Error("Promise was rejected with a falsy value");r.reason=e,e=r}return t(e)}function FR(e){if(typeof e!="function")throw new TypeError('The "original" argument must be of type Function');function t(){for(var r=[],n=0;n<arguments.length;n++)r.push(arguments[n]);var i=r.pop();if(typeof i!="function")throw new TypeError("The last argument must be of type Function");var o=this,s=function(){return i.apply(o,arguments)};e.apply(this,r).then(function(a){x.default.nextTick(s.bind(null,null,a))},function(a){x.default.nextTick(UR.bind(null,a,s))})}return Object.setPrototypeOf(t,Object.getPrototypeOf(e)),Object.defineProperties(t,Sm(e)),t}Oe.callbackify=FR});var Bm=B((i4,Pm)=>{"use strict";p();function Am(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function Om(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?Am(Object(r),!0).forEach(function(n){qR(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Am(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function qR(e,t,r){return t=Tm(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function HR(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Rm(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,Tm(n.key),n)}}function jR(e,t,r){return t&&Rm(e.prototype,t),r&&Rm(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function Tm(e){var t=KR(e,"string");return typeof t=="symbol"?t:String(t)}function KR(e,t){if(typeof e!="object"||e===null)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var GR=Mt(),Du=GR.Buffer,VR=Jr(),sh=VR.inspect,WR=sh&&sh.custom||"inspect";function zR(e,t,r){Du.prototype.copy.call(e,t,r)}Pm.exports=(function(){function e(){HR(this,e),this.head=null,this.tail=null,this.length=0}return jR(e,[{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 Du.alloc(0);for(var n=Du.allocUnsafe(r>>>0),i=this.head,o=0;i;)zR(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=Du.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:WR,value:function(r,n){return sh(this,Om(Om({},n),{},{depth:0,customInspect:!1}))}}]),e})()});var uh=B((s4,Mm)=>{"use strict";p();function YR(e,t){var r=this,n=this._readableState&&this._readableState.destroyed,i=this._writableState&&this._writableState.destroyed;return n||i?(t?t(e):e&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,x.default.nextTick(ah,this,e)):x.default.nextTick(ah,this,e)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(e||null,function(o){!t&&o?r._writableState?r._writableState.errorEmitted?x.default.nextTick(Uu,r):(r._writableState.errorEmitted=!0,x.default.nextTick(Nm,r,o)):x.default.nextTick(Nm,r,o):t?(x.default.nextTick(Uu,r),t(o)):x.default.nextTick(Uu,r)}),this)}function Nm(e,t){ah(e,t),Uu(e)}function Uu(e){e._writableState&&!e._writableState.emitClose||e._readableState&&!e._readableState.emitClose||e.emit("close")}function $R(){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 ah(e,t){e.emit("error",t)}function ZR(e,t){var r=e._readableState,n=e._writableState;r&&r.autoDestroy||n&&n.autoDestroy?e.destroy(t):e.emit("error",t)}Mm.exports={destroy:YR,undestroy:$R,errorOrDestroy:ZR}});var Mi=B((u4,Lm)=>{"use strict";p();function XR(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}var Cm={};function Sr(e,t,r){r||(r=Error);function n(o,s,a){return typeof t=="string"?t:t(o,s,a)}var i=(function(o){XR(s,o);function s(a,f,l){return o.call(this,n(a,f,l))||this}return s})(r);i.prototype.name=r.name,i.prototype.code=e,Cm[e]=i}function km(e,t){if(Array.isArray(e)){var r=e.length;return e=e.map(function(n){return String(n)}),r>2?"one of ".concat(t," ").concat(e.slice(0,r-1).join(", "),", or ")+e[r-1]:r===2?"one of ".concat(t," ").concat(e[0]," or ").concat(e[1]):"of ".concat(t," ").concat(e[0])}else return"of ".concat(t," ").concat(String(e))}function JR(e,t,r){return e.substr(!r||r<0?0:+r,t.length)===t}function QR(e,t,r){return(r===void 0||r>e.length)&&(r=e.length),e.substring(r-t.length,r)===t}function eT(e,t,r){return typeof r!="number"&&(r=0),r+t.length>e.length?!1:e.indexOf(t,r)!==-1}Sr("ERR_INVALID_OPT_VALUE",function(e,t){return'The value "'+t+'" is invalid for option "'+e+'"'},TypeError);Sr("ERR_INVALID_ARG_TYPE",function(e,t,r){var n;typeof t=="string"&&JR(t,"not ")?(n="must not be",t=t.replace(/^not /,"")):n="must be";var i;if(QR(e," argument"))i="The ".concat(e," ").concat(n," ").concat(km(t,"type"));else{var o=eT(e,".")?"property":"argument";i='The "'.concat(e,'" ').concat(o," ").concat(n," ").concat(km(t,"type"))}return i+=". Received type ".concat(typeof r),i},TypeError);Sr("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF");Sr("ERR_METHOD_NOT_IMPLEMENTED",function(e){return"The "+e+" method is not implemented"});Sr("ERR_STREAM_PREMATURE_CLOSE","Premature close");Sr("ERR_STREAM_DESTROYED",function(e){return"Cannot call "+e+" after a stream was destroyed"});Sr("ERR_MULTIPLE_CALLBACK","Callback called multiple times");Sr("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable");Sr("ERR_STREAM_WRITE_AFTER_END","write after end");Sr("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError);Sr("ERR_UNKNOWN_ENCODING",function(e){return"Unknown encoding: "+e},TypeError);Sr("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event");Lm.exports.codes=Cm});var fh=B((c4,Dm)=>{"use strict";p();var tT=Mi().codes.ERR_INVALID_OPT_VALUE;function rT(e,t,r){return e.highWaterMark!=null?e.highWaterMark:t?e[r]:null}function nT(e,t,r,n){var i=rT(t,n,r);if(i!=null){if(!(isFinite(i)&&Math.floor(i)===i)||i<0){var o=n?r:"highWaterMark";throw new tT(o,i)}return Math.floor(i)}return e.objectMode?16:16*1024}Dm.exports={getHighWaterMark:nT}});var lh=B((h4,Um)=>{p();Um.exports=iT;function iT(e,t){if(ch("noDeprecation"))return e;var r=!1;function n(){if(!r){if(ch("throwDeprecation"))throw new Error(t);ch("traceDeprecation")?console.trace(t):console.warn(t),r=!0}return e.apply(this,arguments)}return n}function ch(e){try{if(!globalThis.localStorage)return!1}catch{return!1}var t=globalThis.localStorage[e];return t==null?!1:String(t).toLowerCase()==="true"}});var ph=B((p4,Gm)=>{"use strict";p();Gm.exports=tt;function qm(e){var t=this;this.next=null,this.entry=null,this.finish=function(){BT(t,e)}}var Oo;tt.WritableState=Ts;var oT={deprecate:lh()},Hm=Ol(),qu=Mt().Buffer,sT=(typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function aT(e){return qu.from(e)}function uT(e){return qu.isBuffer(e)||e instanceof sT}var dh=uh(),fT=fh(),cT=fT.getHighWaterMark,zn=Mi().codes,lT=zn.ERR_INVALID_ARG_TYPE,hT=zn.ERR_METHOD_NOT_IMPLEMENTED,dT=zn.ERR_MULTIPLE_CALLBACK,pT=zn.ERR_STREAM_CANNOT_PIPE,gT=zn.ERR_STREAM_DESTROYED,yT=zn.ERR_STREAM_NULL_VALUES,mT=zn.ERR_STREAM_WRITE_AFTER_END,vT=zn.ERR_UNKNOWN_ENCODING,Ro=dh.errorOrDestroy;Ke()(tt,Hm);function bT(){}function Ts(e,t,r){Oo=Oo||ki(),e=e||{},typeof r!="boolean"&&(r=t instanceof Oo),this.objectMode=!!e.objectMode,r&&(this.objectMode=this.objectMode||!!e.writableObjectMode),this.highWaterMark=cT(this,e,"writableHighWaterMark",r),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var n=e.decodeStrings===!1;this.decodeStrings=!n,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(i){AT(t,i)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=e.emitClose!==!1,this.autoDestroy=!!e.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new qm(this)}Ts.prototype.getBuffer=function(){for(var t=this.bufferedRequest,r=[];t;)r.push(t),t=t.next;return r};(function(){try{Object.defineProperty(Ts.prototype,"buffer",{get:oT.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch{}})();var Fu;typeof Symbol=="function"&&Symbol.hasInstance&&typeof Function.prototype[Symbol.hasInstance]=="function"?(Fu=Function.prototype[Symbol.hasInstance],Object.defineProperty(tt,Symbol.hasInstance,{value:function(t){return Fu.call(this,t)?!0:this!==tt?!1:t&&t._writableState instanceof Ts}})):Fu=function(t){return t instanceof this};function tt(e){Oo=Oo||ki();var t=this instanceof Oo;if(!t&&!Fu.call(tt,this))return new tt(e);this._writableState=new Ts(e,this,t),this.writable=!0,e&&(typeof e.write=="function"&&(this._write=e.write),typeof e.writev=="function"&&(this._writev=e.writev),typeof e.destroy=="function"&&(this._destroy=e.destroy),typeof e.final=="function"&&(this._final=e.final)),Hm.call(this)}tt.prototype.pipe=function(){Ro(this,new pT)};function _T(e,t){var r=new mT;Ro(e,r),x.default.nextTick(t,r)}function ST(e,t,r,n){var i;return r===null?i=new yT:typeof r!="string"&&!t.objectMode&&(i=new lT("chunk",["string","Buffer"],r)),i?(Ro(e,i),x.default.nextTick(n,i),!1):!0}tt.prototype.write=function(e,t,r){var n=this._writableState,i=!1,o=!n.objectMode&&uT(e);return o&&!qu.isBuffer(e)&&(e=aT(e)),typeof t=="function"&&(r=t,t=null),o?t="buffer":t||(t=n.defaultEncoding),typeof r!="function"&&(r=bT),n.ending?_T(this,r):(o||ST(this,n,e,r))&&(n.pendingcb++,i=ET(this,n,o,e,t,r)),i};tt.prototype.cork=function(){this._writableState.corked++};tt.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,!e.writing&&!e.corked&&!e.bufferProcessing&&e.bufferedRequest&&jm(this,e))};tt.prototype.setDefaultEncoding=function(t){if(typeof t=="string"&&(t=t.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((t+"").toLowerCase())>-1))throw new vT(t);return this._writableState.defaultEncoding=t,this};Object.defineProperty(tt.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}});function wT(e,t,r){return!e.objectMode&&e.decodeStrings!==!1&&typeof t=="string"&&(t=qu.from(t,r)),t}Object.defineProperty(tt.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function ET(e,t,r,n,i,o){if(!r){var s=wT(t,n,i);n!==s&&(r=!0,i="buffer",n=s)}var a=t.objectMode?1:n.length;t.length+=a;var f=t.length<t.highWaterMark;if(f||(t.needDrain=!0),t.writing||t.corked){var l=t.lastBufferedRequest;t.lastBufferedRequest={chunk:n,encoding:i,isBuf:r,callback:o,next:null},l?l.next=t.lastBufferedRequest:t.bufferedRequest=t.lastBufferedRequest,t.bufferedRequestCount+=1}else hh(e,t,!1,a,n,i,o);return f}function hh(e,t,r,n,i,o,s){t.writelen=n,t.writecb=s,t.writing=!0,t.sync=!0,t.destroyed?t.onwrite(new gT("write")):r?e._writev(i,t.onwrite):e._write(i,o,t.onwrite),t.sync=!1}function xT(e,t,r,n,i){--t.pendingcb,r?(x.default.nextTick(i,n),x.default.nextTick(Rs,e,t),e._writableState.errorEmitted=!0,Ro(e,n)):(i(n),e._writableState.errorEmitted=!0,Ro(e,n),Rs(e,t))}function IT(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}function AT(e,t){var r=e._writableState,n=r.sync,i=r.writecb;if(typeof i!="function")throw new dT;if(IT(r),t)xT(e,r,n,t,i);else{var o=Km(r)||e.destroyed;!o&&!r.corked&&!r.bufferProcessing&&r.bufferedRequest&&jm(e,r),n?x.default.nextTick(Fm,e,r,o,i):Fm(e,r,o,i)}}function Fm(e,t,r,n){r||OT(e,t),t.pendingcb--,n(),Rs(e,t)}function OT(e,t){t.length===0&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}function jm(e,t){t.bufferProcessing=!0;var r=t.bufferedRequest;if(e._writev&&r&&r.next){var n=t.bufferedRequestCount,i=new Array(n),o=t.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,hh(e,t,!0,t.length,i,"",o.finish),t.pendingcb++,t.lastBufferedRequest=null,o.next?(t.corkedRequestsFree=o.next,o.next=null):t.corkedRequestsFree=new qm(t),t.bufferedRequestCount=0}else{for(;r;){var f=r.chunk,l=r.encoding,y=r.callback,g=t.objectMode?1:f.length;if(hh(e,t,!1,g,f,l,y),r=r.next,t.bufferedRequestCount--,t.writing)break}r===null&&(t.lastBufferedRequest=null)}t.bufferedRequest=r,t.bufferProcessing=!1}tt.prototype._write=function(e,t,r){r(new hT("_write()"))};tt.prototype._writev=null;tt.prototype.end=function(e,t,r){var n=this._writableState;return typeof e=="function"?(r=e,e=null,t=null):typeof t=="function"&&(r=t,t=null),e!=null&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||PT(this,n,r),this};Object.defineProperty(tt.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}});function Km(e){return e.ending&&e.length===0&&e.bufferedRequest===null&&!e.finished&&!e.writing}function RT(e,t){e._final(function(r){t.pendingcb--,r&&Ro(e,r),t.prefinished=!0,e.emit("prefinish"),Rs(e,t)})}function TT(e,t){!t.prefinished&&!t.finalCalled&&(typeof e._final=="function"&&!t.destroyed?(t.pendingcb++,t.finalCalled=!0,x.default.nextTick(RT,e,t)):(t.prefinished=!0,e.emit("prefinish")))}function Rs(e,t){var r=Km(t);if(r&&(TT(e,t),t.pendingcb===0&&(t.finished=!0,e.emit("finish"),t.autoDestroy))){var n=e._readableState;(!n||n.autoDestroy&&n.endEmitted)&&e.destroy()}return r}function PT(e,t,r){t.ending=!0,Rs(e,t),r&&(t.finished?x.default.nextTick(r):e.once("finish",r)),t.ended=!0,e.writable=!1}function BT(e,t,r){var n=e.entry;for(e.entry=null;n;){var i=n.callback;t.pendingcb--,i(r),n=n.next}t.corkedRequestsFree.next=e}Object.defineProperty(tt.prototype,"destroyed",{enumerable:!1,get:function(){return this._writableState===void 0?!1:this._writableState.destroyed},set:function(t){this._writableState&&(this._writableState.destroyed=t)}});tt.prototype.destroy=dh.destroy;tt.prototype._undestroy=dh.undestroy;tt.prototype._destroy=function(e,t){t(e)}});var ki=B((y4,Wm)=>{"use strict";p();var NT=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t};Wm.exports=Qr;var Vm=mh(),yh=ph();Ke()(Qr,Vm);for(gh=NT(yh.prototype),Hu=0;Hu<gh.length;Hu++)ju=gh[Hu],Qr.prototype[ju]||(Qr.prototype[ju]=yh.prototype[ju]);var gh,ju,Hu;function Qr(e){if(!(this instanceof Qr))return new Qr(e);Vm.call(this,e),yh.call(this,e),this.allowHalfOpen=!0,e&&(e.readable===!1&&(this.readable=!1),e.writable===!1&&(this.writable=!1),e.allowHalfOpen===!1&&(this.allowHalfOpen=!1,this.once("end",MT)))}Object.defineProperty(Qr.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});Object.defineProperty(Qr.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}});Object.defineProperty(Qr.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}});function MT(){this._writableState.ended||x.default.nextTick(kT,this)}function kT(e){e.end()}Object.defineProperty(Qr.prototype,"destroyed",{enumerable:!1,get:function(){return this._readableState===void 0||this._writableState===void 0?!1:this._readableState.destroyed&&this._writableState.destroyed},set:function(t){this._readableState===void 0||this._writableState===void 0||(this._readableState.destroyed=t,this._writableState.destroyed=t)}})});var $m=B((vh,Ym)=>{p();var Ku=Mt(),vn=Ku.Buffer;function zm(e,t){for(var r in e)t[r]=e[r]}vn.from&&vn.alloc&&vn.allocUnsafe&&vn.allocUnsafeSlow?Ym.exports=Ku:(zm(Ku,vh),vh.Buffer=To);function To(e,t,r){return vn(e,t,r)}zm(vn,To);To.from=function(e,t,r){if(typeof e=="number")throw new TypeError("Argument must not be a number");return vn(e,t,r)};To.alloc=function(e,t,r){if(typeof e!="number")throw new TypeError("Argument must be a number");var n=vn(e);return t!==void 0?typeof r=="string"?n.fill(t,r):n.fill(t):n.fill(0),n};To.allocUnsafe=function(e){if(typeof e!="number")throw new TypeError("Argument must be a number");return vn(e)};To.allocUnsafeSlow=function(e){if(typeof e!="number")throw new TypeError("Argument must be a number");return Ku.SlowBuffer(e)}});var Po=B(Xm=>{"use strict";p();var _h=$m().Buffer,Zm=_h.isEncoding||function(e){switch(e=""+e,e&&e.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 CT(e){if(!e)return"utf8";for(var t;;)switch(e){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 e;default:if(t)return;e=(""+e).toLowerCase(),t=!0}}function LT(e){var t=CT(e);if(typeof t!="string"&&(_h.isEncoding===Zm||!Zm(e)))throw new Error("Unknown encoding: "+e);return t||e}Xm.StringDecoder=Ps;function Ps(e){this.encoding=LT(e);var t;switch(this.encoding){case"utf16le":this.text=jT,this.end=KT,t=4;break;case"utf8":this.fillLast=FT,t=4;break;case"base64":this.text=GT,this.end=VT,t=3;break;default:this.write=WT,this.end=zT;return}this.lastNeed=0,this.lastTotal=0,this.lastChar=_h.allocUnsafe(t)}Ps.prototype.write=function(e){if(e.length===0)return"";var t,r;if(this.lastNeed){if(t=this.fillLast(e),t===void 0)return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r<e.length?t?t+this.text(e,r):this.text(e,r):t||""};Ps.prototype.end=HT;Ps.prototype.text=qT;Ps.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length};function bh(e){return e<=127?0:e>>5===6?2:e>>4===14?3:e>>3===30?4:e>>6===2?-1:-2}function DT(e,t,r){var n=t.length-1;if(n<r)return 0;var i=bh(t[n]);return i>=0?(i>0&&(e.lastNeed=i-1),i):--n<r||i===-2?0:(i=bh(t[n]),i>=0?(i>0&&(e.lastNeed=i-2),i):--n<r||i===-2?0:(i=bh(t[n]),i>=0?(i>0&&(i===2?i=0:e.lastNeed=i-3),i):0))}function UT(e,t,r){if((t[0]&192)!==128)return e.lastNeed=0,"\uFFFD";if(e.lastNeed>1&&t.length>1){if((t[1]&192)!==128)return e.lastNeed=1,"\uFFFD";if(e.lastNeed>2&&t.length>2&&(t[2]&192)!==128)return e.lastNeed=2,"\uFFFD"}}function FT(e){var t=this.lastTotal-this.lastNeed,r=UT(this,e,t);if(r!==void 0)return r;if(this.lastNeed<=e.length)return e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,t,0,e.length),this.lastNeed-=e.length}function qT(e,t){var r=DT(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=r;var n=e.length-(r-this.lastNeed);return e.copy(this.lastChar,0,n),e.toString("utf8",t,n)}function HT(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+"\uFFFD":t}function jT(e,t){if((e.length-t)%2===0){var r=e.toString("utf16le",t);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function KT(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,r)}return t}function GT(e,t){var r=(e.length-t)%3;return r===0?e.toString("base64",t):(this.lastNeed=3-r,this.lastTotal=3,r===1?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-r))}function VT(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function WT(e){return e.toString(this.encoding)}function zT(e){return e&&e.length?this.write(e):""}});var Gu=B((S4,ev)=>{"use strict";p();var Jm=Mi().codes.ERR_STREAM_PREMATURE_CLOSE;function YT(e){var t=!1;return function(){if(!t){t=!0;for(var r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];e.apply(this,n)}}}function $T(){}function ZT(e){return e.setHeader&&typeof e.abort=="function"}function Qm(e,t,r){if(typeof t=="function")return Qm(e,null,t);t||(t={}),r=YT(r||$T);var n=t.readable||t.readable!==!1&&e.readable,i=t.writable||t.writable!==!1&&e.writable,o=function(){e.writable||a()},s=e._writableState&&e._writableState.finished,a=function(){i=!1,s=!0,n||r.call(e)},f=e._readableState&&e._readableState.endEmitted,l=function(){n=!1,f=!0,i||r.call(e)},y=function(T){r.call(e,T)},g=function(){var T;if(n&&!f)return(!e._readableState||!e._readableState.ended)&&(T=new Jm),r.call(e,T);if(i&&!s)return(!e._writableState||!e._writableState.ended)&&(T=new Jm),r.call(e,T)},v=function(){e.req.on("finish",a)};return ZT(e)?(e.on("complete",a),e.on("abort",g),e.req?v():e.on("request",v)):i&&!e._writableState&&(e.on("end",o),e.on("close",o)),e.on("end",l),e.on("finish",a),t.error!==!1&&e.on("error",y),e.on("close",g),function(){e.removeListener("complete",a),e.removeListener("abort",g),e.removeListener("request",v),e.req&&e.req.removeListener("finish",a),e.removeListener("end",o),e.removeListener("close",o),e.removeListener("finish",a),e.removeListener("end",l),e.removeListener("error",y),e.removeListener("close",g)}}ev.exports=Qm});var rv=B((E4,tv)=>{"use strict";p();var Vu;function Yn(e,t,r){return t=XT(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function XT(e){var t=JT(e,"string");return typeof t=="symbol"?t:String(t)}function JT(e,t){if(typeof e!="object"||e===null)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var QT=Gu(),$n=Symbol("lastResolve"),Ci=Symbol("lastReject"),Bs=Symbol("error"),Wu=Symbol("ended"),Li=Symbol("lastPromise"),Sh=Symbol("handlePromise"),Di=Symbol("stream");function Zn(e,t){return{value:e,done:t}}function e2(e){var t=e[$n];if(t!==null){var r=e[Di].read();r!==null&&(e[Li]=null,e[$n]=null,e[Ci]=null,t(Zn(r,!1)))}}function t2(e){x.default.nextTick(e2,e)}function r2(e,t){return function(r,n){e.then(function(){if(t[Wu]){r(Zn(void 0,!0));return}t[Sh](r,n)},n)}}var n2=Object.getPrototypeOf(function(){}),i2=Object.setPrototypeOf((Vu={get stream(){return this[Di]},next:function(){var t=this,r=this[Bs];if(r!==null)return Promise.reject(r);if(this[Wu])return Promise.resolve(Zn(void 0,!0));if(this[Di].destroyed)return new Promise(function(s,a){x.default.nextTick(function(){t[Bs]?a(t[Bs]):s(Zn(void 0,!0))})});var n=this[Li],i;if(n)i=new Promise(r2(n,this));else{var o=this[Di].read();if(o!==null)return Promise.resolve(Zn(o,!1));i=new Promise(this[Sh])}return this[Li]=i,i}},Yn(Vu,Symbol.asyncIterator,function(){return this}),Yn(Vu,"return",function(){var t=this;return new Promise(function(r,n){t[Di].destroy(null,function(i){if(i){n(i);return}r(Zn(void 0,!0))})})}),Vu),n2),o2=function(t){var r,n=Object.create(i2,(r={},Yn(r,Di,{value:t,writable:!0}),Yn(r,$n,{value:null,writable:!0}),Yn(r,Ci,{value:null,writable:!0}),Yn(r,Bs,{value:null,writable:!0}),Yn(r,Wu,{value:t._readableState.endEmitted,writable:!0}),Yn(r,Sh,{value:function(o,s){var a=n[Di].read();a?(n[Li]=null,n[$n]=null,n[Ci]=null,o(Zn(a,!1))):(n[$n]=o,n[Ci]=s)},writable:!0}),r));return n[Li]=null,QT(t,function(i){if(i&&i.code!=="ERR_STREAM_PREMATURE_CLOSE"){var o=n[Ci];o!==null&&(n[Li]=null,n[$n]=null,n[Ci]=null,o(i)),n[Bs]=i;return}var s=n[$n];s!==null&&(n[Li]=null,n[$n]=null,n[Ci]=null,s(Zn(void 0,!0))),n[Wu]=!0}),t.on("readable",t2.bind(null,n)),n};tv.exports=o2});var iv=B((I4,nv)=>{p();nv.exports=function(){throw new Error("Readable.from is not available in the browser")}});var mh=B((R4,pv)=>{"use strict";p();pv.exports=Ne;var Bo;Ne.ReadableState=uv;var O4=mo().EventEmitter,av=function(t,r){return t.listeners(r).length},Ms=Ol(),zu=Mt().Buffer,s2=(typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function a2(e){return zu.from(e)}function u2(e){return zu.isBuffer(e)||e instanceof s2}var wh=Jr(),xe;wh&&wh.debuglog?xe=wh.debuglog("stream"):xe=function(){};var f2=Bm(),Th=uh(),c2=fh(),l2=c2.getHighWaterMark,Yu=Mi().codes,h2=Yu.ERR_INVALID_ARG_TYPE,d2=Yu.ERR_STREAM_PUSH_AFTER_EOF,p2=Yu.ERR_METHOD_NOT_IMPLEMENTED,g2=Yu.ERR_STREAM_UNSHIFT_AFTER_END_EVENT,No,Eh,xh;Ke()(Ne,Ms);var Ns=Th.errorOrDestroy,Ih=["error","close","destroy","pause","resume"];function y2(e,t,r){if(typeof e.prependListener=="function")return e.prependListener(t,r);!e._events||!e._events[t]?e.on(t,r):Array.isArray(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]}function uv(e,t,r){Bo=Bo||ki(),e=e||{},typeof r!="boolean"&&(r=t instanceof Bo),this.objectMode=!!e.objectMode,r&&(this.objectMode=this.objectMode||!!e.readableObjectMode),this.highWaterMark=l2(this,e,"readableHighWaterMark",r),this.buffer=new f2,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=e.emitClose!==!1,this.autoDestroy=!!e.autoDestroy,this.destroyed=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(No||(No=Po().StringDecoder),this.decoder=new No(e.encoding),this.encoding=e.encoding)}function Ne(e){if(Bo=Bo||ki(),!(this instanceof Ne))return new Ne(e);var t=this instanceof Bo;this._readableState=new uv(e,this,t),this.readable=!0,e&&(typeof e.read=="function"&&(this._read=e.read),typeof e.destroy=="function"&&(this._destroy=e.destroy)),Ms.call(this)}Object.defineProperty(Ne.prototype,"destroyed",{enumerable:!1,get:function(){return this._readableState===void 0?!1:this._readableState.destroyed},set:function(t){this._readableState&&(this._readableState.destroyed=t)}});Ne.prototype.destroy=Th.destroy;Ne.prototype._undestroy=Th.undestroy;Ne.prototype._destroy=function(e,t){t(e)};Ne.prototype.push=function(e,t){var r=this._readableState,n;return r.objectMode?n=!0:typeof e=="string"&&(t=t||r.defaultEncoding,t!==r.encoding&&(e=zu.from(e,t),t=""),n=!0),fv(this,e,t,!1,n)};Ne.prototype.unshift=function(e){return fv(this,e,null,!0,!1)};function fv(e,t,r,n,i){xe("readableAddChunk",t);var o=e._readableState;if(t===null)o.reading=!1,b2(e,o);else{var s;if(i||(s=m2(o,t)),s)Ns(e,s);else if(o.objectMode||t&&t.length>0)if(typeof t!="string"&&!o.objectMode&&Object.getPrototypeOf(t)!==zu.prototype&&(t=a2(t)),n)o.endEmitted?Ns(e,new g2):Ah(e,o,t,!0);else if(o.ended)Ns(e,new d2);else{if(o.destroyed)return!1;o.reading=!1,o.decoder&&!r?(t=o.decoder.write(t),o.objectMode||t.length!==0?Ah(e,o,t,!1):Rh(e,o)):Ah(e,o,t,!1)}else n||(o.reading=!1,Rh(e,o))}return!o.ended&&(o.length<o.highWaterMark||o.length===0)}function Ah(e,t,r,n){t.flowing&&t.length===0&&!t.sync?(t.awaitDrain=0,e.emit("data",r)):(t.length+=t.objectMode?1:r.length,n?t.buffer.unshift(r):t.buffer.push(r),t.needReadable&&$u(e)),Rh(e,t)}function m2(e,t){var r;return!u2(t)&&typeof t!="string"&&t!==void 0&&!e.objectMode&&(r=new h2("chunk",["string","Buffer","Uint8Array"],t)),r}Ne.prototype.isPaused=function(){return this._readableState.flowing===!1};Ne.prototype.setEncoding=function(e){No||(No=Po().StringDecoder);var t=new No(e);this._readableState.decoder=t,this._readableState.encoding=this._readableState.decoder.encoding;for(var r=this._readableState.buffer.head,n="";r!==null;)n+=t.write(r.data),r=r.next;return this._readableState.buffer.clear(),n!==""&&this._readableState.buffer.push(n),this._readableState.length=n.length,this};var ov=1073741824;function v2(e){return e>=ov?e=ov:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}function sv(e,t){return e<=0||t.length===0&&t.ended?0:t.objectMode?1:e!==e?t.flowing&&t.length?t.buffer.head.data.length:t.length:(e>t.highWaterMark&&(t.highWaterMark=v2(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}Ne.prototype.read=function(e){xe("read",e),e=parseInt(e,10);var t=this._readableState,r=e;if(e!==0&&(t.emittedReadable=!1),e===0&&t.needReadable&&((t.highWaterMark!==0?t.length>=t.highWaterMark:t.length>0)||t.ended))return xe("read: emitReadable",t.length,t.ended),t.length===0&&t.ended?Oh(this):$u(this),null;if(e=sv(e,t),e===0&&t.ended)return t.length===0&&Oh(this),null;var n=t.needReadable;xe("need readable",n),(t.length===0||t.length-e<t.highWaterMark)&&(n=!0,xe("length less than watermark",n)),t.ended||t.reading?(n=!1,xe("reading or ended",n)):n&&(xe("do read"),t.reading=!0,t.sync=!0,t.length===0&&(t.needReadable=!0),this._read(t.highWaterMark),t.sync=!1,t.reading||(e=sv(r,t)));var i;return e>0?i=hv(e,t):i=null,i===null?(t.needReadable=t.length<=t.highWaterMark,e=0):(t.length-=e,t.awaitDrain=0),t.length===0&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Oh(this)),i!==null&&this.emit("data",i),i};function b2(e,t){if(xe("onEofChunk"),!t.ended){if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,t.sync?$u(e):(t.needReadable=!1,t.emittedReadable||(t.emittedReadable=!0,cv(e)))}}function $u(e){var t=e._readableState;xe("emitReadable",t.needReadable,t.emittedReadable),t.needReadable=!1,t.emittedReadable||(xe("emitReadable",t.flowing),t.emittedReadable=!0,x.default.nextTick(cv,e))}function cv(e){var t=e._readableState;xe("emitReadable_",t.destroyed,t.length,t.ended),!t.destroyed&&(t.length||t.ended)&&(e.emit("readable"),t.emittedReadable=!1),t.needReadable=!t.flowing&&!t.ended&&t.length<=t.highWaterMark,Ph(e)}function Rh(e,t){t.readingMore||(t.readingMore=!0,x.default.nextTick(_2,e,t))}function _2(e,t){for(;!t.reading&&!t.ended&&(t.length<t.highWaterMark||t.flowing&&t.length===0);){var r=t.length;if(xe("maybeReadMore read 0"),e.read(0),r===t.length)break}t.readingMore=!1}Ne.prototype._read=function(e){Ns(this,new p2("_read()"))};Ne.prototype.pipe=function(e,t){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=e;break;case 1:n.pipes=[n.pipes,e];break;default:n.pipes.push(e);break}n.pipesCount+=1,xe("pipe count=%d opts=%j",n.pipesCount,t);var i=(!t||t.end!==!1)&&e!==x.default.stdout&&e!==x.default.stderr,o=i?a:M;n.endEmitted?x.default.nextTick(o):r.once("end",o),e.on("unpipe",s);function s(L,F){xe("onunpipe"),L===r&&F&&F.hasUnpiped===!1&&(F.hasUnpiped=!0,y())}function a(){xe("onend"),e.end()}var f=S2(r);e.on("drain",f);var l=!1;function y(){xe("cleanup"),e.removeListener("close",E),e.removeListener("finish",T),e.removeListener("drain",f),e.removeListener("error",v),e.removeListener("unpipe",s),r.removeListener("end",a),r.removeListener("end",M),r.removeListener("data",g),l=!0,n.awaitDrain&&(!e._writableState||e._writableState.needDrain)&&f()}r.on("data",g);function g(L){xe("ondata");var F=e.write(L);xe("dest.write",F),F===!1&&((n.pipesCount===1&&n.pipes===e||n.pipesCount>1&&dv(n.pipes,e)!==-1)&&!l&&(xe("false write response, pause",n.awaitDrain),n.awaitDrain++),r.pause())}function v(L){xe("onerror",L),M(),e.removeListener("error",v),av(e,"error")===0&&Ns(e,L)}y2(e,"error",v);function E(){e.removeListener("finish",T),M()}e.once("close",E);function T(){xe("onfinish"),e.removeListener("close",E),M()}e.once("finish",T);function M(){xe("unpipe"),r.unpipe(e)}return e.emit("pipe",r),n.flowing||(xe("pipe resume"),r.resume()),e};function S2(e){return function(){var r=e._readableState;xe("pipeOnDrain",r.awaitDrain),r.awaitDrain&&r.awaitDrain--,r.awaitDrain===0&&av(e,"data")&&(r.flowing=!0,Ph(e))}}Ne.prototype.unpipe=function(e){var t=this._readableState,r={hasUnpiped:!1};if(t.pipesCount===0)return this;if(t.pipesCount===1)return e&&e!==t.pipes?this:(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,r),this);if(!e){var n=t.pipes,i=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var o=0;o<i;o++)n[o].emit("unpipe",this,{hasUnpiped:!1});return this}var s=dv(t.pipes,e);return s===-1?this:(t.pipes.splice(s,1),t.pipesCount-=1,t.pipesCount===1&&(t.pipes=t.pipes[0]),e.emit("unpipe",this,r),this)};Ne.prototype.on=function(e,t){var r=Ms.prototype.on.call(this,e,t),n=this._readableState;return e==="data"?(n.readableListening=this.listenerCount("readable")>0,n.flowing!==!1&&this.resume()):e==="readable"&&!n.endEmitted&&!n.readableListening&&(n.readableListening=n.needReadable=!0,n.flowing=!1,n.emittedReadable=!1,xe("on readable",n.length,n.reading),n.length?$u(this):n.reading||x.default.nextTick(w2,this)),r};Ne.prototype.addListener=Ne.prototype.on;Ne.prototype.removeListener=function(e,t){var r=Ms.prototype.removeListener.call(this,e,t);return e==="readable"&&x.default.nextTick(lv,this),r};Ne.prototype.removeAllListeners=function(e){var t=Ms.prototype.removeAllListeners.apply(this,arguments);return(e==="readable"||e===void 0)&&x.default.nextTick(lv,this),t};function lv(e){var t=e._readableState;t.readableListening=e.listenerCount("readable")>0,t.resumeScheduled&&!t.paused?t.flowing=!0:e.listenerCount("data")>0&&e.resume()}function w2(e){xe("readable nexttick read 0"),e.read(0)}Ne.prototype.resume=function(){var e=this._readableState;return e.flowing||(xe("resume"),e.flowing=!e.readableListening,E2(this,e)),e.paused=!1,this};function E2(e,t){t.resumeScheduled||(t.resumeScheduled=!0,x.default.nextTick(x2,e,t))}function x2(e,t){xe("resume",t.reading),t.reading||e.read(0),t.resumeScheduled=!1,e.emit("resume"),Ph(e),t.flowing&&!t.reading&&e.read(0)}Ne.prototype.pause=function(){return xe("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(xe("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this};function Ph(e){var t=e._readableState;for(xe("flow",t.flowing);t.flowing&&e.read()!==null;);}Ne.prototype.wrap=function(e){var t=this,r=this._readableState,n=!1;e.on("end",function(){if(xe("wrapped end"),r.decoder&&!r.ended){var s=r.decoder.end();s&&s.length&&t.push(s)}t.push(null)}),e.on("data",function(s){if(xe("wrapped data"),r.decoder&&(s=r.decoder.write(s)),!(r.objectMode&&s==null)&&!(!r.objectMode&&(!s||!s.length))){var a=t.push(s);a||(n=!0,e.pause())}});for(var i in e)this[i]===void 0&&typeof e[i]=="function"&&(this[i]=(function(a){return function(){return e[a].apply(e,arguments)}})(i));for(var o=0;o<Ih.length;o++)e.on(Ih[o],this.emit.bind(this,Ih[o]));return this._read=function(s){xe("wrapped _read",s),n&&(n=!1,e.resume())},this};typeof Symbol=="function"&&(Ne.prototype[Symbol.asyncIterator]=function(){return Eh===void 0&&(Eh=rv()),Eh(this)});Object.defineProperty(Ne.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}});Object.defineProperty(Ne.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}});Object.defineProperty(Ne.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(t){this._readableState&&(this._readableState.flowing=t)}});Ne._fromList=hv;Object.defineProperty(Ne.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}});function hv(e,t){if(t.length===0)return null;var r;return t.objectMode?r=t.buffer.shift():!e||e>=t.length?(t.decoder?r=t.buffer.join(""):t.buffer.length===1?r=t.buffer.first():r=t.buffer.concat(t.length),t.buffer.clear()):r=t.buffer.consume(e,t.decoder),r}function Oh(e){var t=e._readableState;xe("endReadable",t.endEmitted),t.endEmitted||(t.ended=!0,x.default.nextTick(I2,t,e))}function I2(e,t){if(xe("endReadableNT",e.endEmitted,e.length),!e.endEmitted&&e.length===0&&(e.endEmitted=!0,t.readable=!1,t.emit("end"),e.autoDestroy)){var r=t._writableState;(!r||r.autoDestroy&&r.finished)&&t.destroy()}}typeof Symbol=="function"&&(Ne.from=function(e,t){return xh===void 0&&(xh=iv()),xh(Ne,e,t)});function dv(e,t){for(var r=0,n=e.length;r<n;r++)if(e[r]===t)return r;return-1}});var Bh=B((P4,yv)=>{"use strict";p();yv.exports=bn;var Zu=Mi().codes,A2=Zu.ERR_METHOD_NOT_IMPLEMENTED,O2=Zu.ERR_MULTIPLE_CALLBACK,R2=Zu.ERR_TRANSFORM_ALREADY_TRANSFORMING,T2=Zu.ERR_TRANSFORM_WITH_LENGTH_0,Xu=ki();Ke()(bn,Xu);function P2(e,t){var r=this._transformState;r.transforming=!1;var n=r.writecb;if(n===null)return this.emit("error",new O2);r.writechunk=null,r.writecb=null,t!=null&&this.push(t),n(e);var i=this._readableState;i.reading=!1,(i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}function bn(e){if(!(this instanceof bn))return new bn(e);Xu.call(this,e),this._transformState={afterTransform:P2.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,e&&(typeof e.transform=="function"&&(this._transform=e.transform),typeof e.flush=="function"&&(this._flush=e.flush)),this.on("prefinish",B2)}function B2(){var e=this;typeof this._flush=="function"&&!this._readableState.destroyed?this._flush(function(t,r){gv(e,t,r)}):gv(this,null,null)}bn.prototype.push=function(e,t){return this._transformState.needTransform=!1,Xu.prototype.push.call(this,e,t)};bn.prototype._transform=function(e,t,r){r(new A2("_transform()"))};bn.prototype._write=function(e,t,r){var n=this._transformState;if(n.writecb=r,n.writechunk=e,n.writeencoding=t,!n.transforming){var i=this._readableState;(n.needTransform||i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}};bn.prototype._read=function(e){var t=this._transformState;t.writechunk!==null&&!t.transforming?(t.transforming=!0,this._transform(t.writechunk,t.writeencoding,t.afterTransform)):t.needTransform=!0};bn.prototype._destroy=function(e,t){Xu.prototype._destroy.call(this,e,function(r){t(r)})};function gv(e,t,r){if(t)return e.emit("error",t);if(r!=null&&e.push(r),e._writableState.length)throw new T2;if(e._transformState.transforming)throw new R2;return e.push(null)}});var bv=B((N4,vv)=>{"use strict";p();vv.exports=ks;var mv=Bh();Ke()(ks,mv);function ks(e){if(!(this instanceof ks))return new ks(e);mv.call(this,e)}ks.prototype._transform=function(e,t,r){r(null,e)}});var xv=B((k4,Ev)=>{"use strict";p();var Nh;function N2(e){var t=!1;return function(){t||(t=!0,e.apply(void 0,arguments))}}var wv=Mi().codes,M2=wv.ERR_MISSING_ARGS,k2=wv.ERR_STREAM_DESTROYED;function _v(e){if(e)throw e}function C2(e){return e.setHeader&&typeof e.abort=="function"}function L2(e,t,r,n){n=N2(n);var i=!1;e.on("close",function(){i=!0}),Nh===void 0&&(Nh=Gu()),Nh(e,{readable:t,writable:r},function(s){if(s)return n(s);i=!0,n()});var o=!1;return function(s){if(!i&&!o){if(o=!0,C2(e))return e.abort();if(typeof e.destroy=="function")return e.destroy();n(s||new k2("pipe"))}}}function Sv(e){e()}function D2(e,t){return e.pipe(t)}function U2(e){return!e.length||typeof e[e.length-1]!="function"?_v:e.pop()}function F2(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];var n=U2(t);if(Array.isArray(t[0])&&(t=t[0]),t.length<2)throw new M2("streams");var i,o=t.map(function(s,a){var f=a<t.length-1,l=a>0;return L2(s,f,l,function(y){i||(i=y),y&&o.forEach(Sv),!f&&(o.forEach(Sv),n(i))})});return t.reduce(D2)}Ev.exports=F2});var kh=B((L4,Iv)=>{p();Iv.exports=wr;var Mh=mo().EventEmitter,q2=Ke();q2(wr,Mh);wr.Readable=mh();wr.Writable=ph();wr.Duplex=ki();wr.Transform=Bh();wr.PassThrough=bv();wr.finished=Gu();wr.pipeline=xv();wr.Stream=wr;function wr(){Mh.call(this)}wr.prototype.pipe=function(e,t){var r=this;function n(y){e.writable&&e.write(y)===!1&&r.pause&&r.pause()}r.on("data",n);function i(){r.readable&&r.resume&&r.resume()}e.on("drain",i),!e._isStdio&&(!t||t.end!==!1)&&(r.on("end",s),r.on("close",a));var o=!1;function s(){o||(o=!0,e.end())}function a(){o||(o=!0,typeof e.destroy=="function"&&e.destroy())}function f(y){if(l(),Mh.listenerCount(this,"error")===0)throw y}r.on("error",f),e.on("error",f);function l(){r.removeListener("data",n),e.removeListener("drain",i),r.removeListener("end",s),r.removeListener("close",a),r.removeListener("error",f),e.removeListener("error",f),r.removeListener("end",l),r.removeListener("close",l),e.removeListener("close",l)}return r.on("end",l),r.on("close",l),e.on("close",l),e.emit("pipe",r),e}});var Rv=B((U4,Ov)=>{"use strict";p();var en=Wt().Buffer,Av=kh().Transform,H2=Ke();function Xn(e){Av.call(this),this._block=en.allocUnsafe(e),this._blockSize=e,this._blockOffset=0,this._length=[0,0,0,0],this._finalized=!1}H2(Xn,Av);Xn.prototype._transform=function(e,t,r){var n=null;try{this.update(e,t)}catch(i){n=i}r(n)};Xn.prototype._flush=function(e){var t=null;try{this.push(this.digest())}catch(r){t=r}e(t)};var j2=typeof Uint8Array<"u",K2=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u"&&ArrayBuffer.isView&&(en.prototype instanceof Uint8Array||en.TYPED_ARRAY_SUPPORT);function G2(e,t){if(e instanceof en)return e;if(typeof e=="string")return en.from(e,t);if(K2&&ArrayBuffer.isView(e)){if(e.byteLength===0)return en.alloc(0);var r=en.from(e.buffer,e.byteOffset,e.byteLength);if(r.byteLength===e.byteLength)return r}if(j2&&e instanceof Uint8Array||en.isBuffer(e)&&e.constructor&&typeof e.constructor.isBuffer=="function"&&e.constructor.isBuffer(e))return en.from(e);throw new TypeError('The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView.')}Xn.prototype.update=function(e,t){if(this._finalized)throw new Error("Digest already called");e=G2(e,t);for(var r=this._block,n=0;this._blockOffset+e.length-n>=this._blockSize;){for(var i=this._blockOffset;i<this._blockSize;)r[i++]=e[n++];this._update(),this._blockOffset=0}for(;n<e.length;)r[this._blockOffset++]=e[n++];for(var o=0,s=e.length*8;s>0;++o)this._length[o]+=s,s=this._length[o]/4294967296|0,s>0&&(this._length[o]-=4294967296*s);return this};Xn.prototype._update=function(){throw new Error("_update is not implemented")};Xn.prototype.digest=function(e){if(this._finalized)throw new Error("Digest already called");this._finalized=!0;var t=this._digest();e!==void 0&&(t=t.toString(e)),this._block.fill(0),this._blockOffset=0;for(var r=0;r<4;++r)this._length[r]=0;return t};Xn.prototype._digest=function(){throw new Error("_digest is not implemented")};Ov.exports=Xn});var Ch=B((q4,Pv)=>{"use strict";p();var V2=Ke(),Tv=Rv(),W2=Wt().Buffer,z2=new Array(16);function Ju(){Tv.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878}V2(Ju,Tv);Ju.prototype._update=function(){for(var e=z2,t=0;t<16;++t)e[t]=this._block.readInt32LE(t*4);var r=this._a,n=this._b,i=this._c,o=this._d;r=$t(r,n,i,o,e[0],3614090360,7),o=$t(o,r,n,i,e[1],3905402710,12),i=$t(i,o,r,n,e[2],606105819,17),n=$t(n,i,o,r,e[3],3250441966,22),r=$t(r,n,i,o,e[4],4118548399,7),o=$t(o,r,n,i,e[5],1200080426,12),i=$t(i,o,r,n,e[6],2821735955,17),n=$t(n,i,o,r,e[7],4249261313,22),r=$t(r,n,i,o,e[8],1770035416,7),o=$t(o,r,n,i,e[9],2336552879,12),i=$t(i,o,r,n,e[10],4294925233,17),n=$t(n,i,o,r,e[11],2304563134,22),r=$t(r,n,i,o,e[12],1804603682,7),o=$t(o,r,n,i,e[13],4254626195,12),i=$t(i,o,r,n,e[14],2792965006,17),n=$t(n,i,o,r,e[15],1236535329,22),r=Zt(r,n,i,o,e[1],4129170786,5),o=Zt(o,r,n,i,e[6],3225465664,9),i=Zt(i,o,r,n,e[11],643717713,14),n=Zt(n,i,o,r,e[0],3921069994,20),r=Zt(r,n,i,o,e[5],3593408605,5),o=Zt(o,r,n,i,e[10],38016083,9),i=Zt(i,o,r,n,e[15],3634488961,14),n=Zt(n,i,o,r,e[4],3889429448,20),r=Zt(r,n,i,o,e[9],568446438,5),o=Zt(o,r,n,i,e[14],3275163606,9),i=Zt(i,o,r,n,e[3],4107603335,14),n=Zt(n,i,o,r,e[8],1163531501,20),r=Zt(r,n,i,o,e[13],2850285829,5),o=Zt(o,r,n,i,e[2],4243563512,9),i=Zt(i,o,r,n,e[7],1735328473,14),n=Zt(n,i,o,r,e[12],2368359562,20),r=Xt(r,n,i,o,e[5],4294588738,4),o=Xt(o,r,n,i,e[8],2272392833,11),i=Xt(i,o,r,n,e[11],1839030562,16),n=Xt(n,i,o,r,e[14],4259657740,23),r=Xt(r,n,i,o,e[1],2763975236,4),o=Xt(o,r,n,i,e[4],1272893353,11),i=Xt(i,o,r,n,e[7],4139469664,16),n=Xt(n,i,o,r,e[10],3200236656,23),r=Xt(r,n,i,o,e[13],681279174,4),o=Xt(o,r,n,i,e[0],3936430074,11),i=Xt(i,o,r,n,e[3],3572445317,16),n=Xt(n,i,o,r,e[6],76029189,23),r=Xt(r,n,i,o,e[9],3654602809,4),o=Xt(o,r,n,i,e[12],3873151461,11),i=Xt(i,o,r,n,e[15],530742520,16),n=Xt(n,i,o,r,e[2],3299628645,23),r=Jt(r,n,i,o,e[0],4096336452,6),o=Jt(o,r,n,i,e[7],1126891415,10),i=Jt(i,o,r,n,e[14],2878612391,15),n=Jt(n,i,o,r,e[5],4237533241,21),r=Jt(r,n,i,o,e[12],1700485571,6),o=Jt(o,r,n,i,e[3],2399980690,10),i=Jt(i,o,r,n,e[10],4293915773,15),n=Jt(n,i,o,r,e[1],2240044497,21),r=Jt(r,n,i,o,e[8],1873313359,6),o=Jt(o,r,n,i,e[15],4264355552,10),i=Jt(i,o,r,n,e[6],2734768916,15),n=Jt(n,i,o,r,e[13],1309151649,21),r=Jt(r,n,i,o,e[4],4149444226,6),o=Jt(o,r,n,i,e[11],3174756917,10),i=Jt(i,o,r,n,e[2],718787259,15),n=Jt(n,i,o,r,e[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};Ju.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 e=W2.allocUnsafe(16);return e.writeInt32LE(this._a,0),e.writeInt32LE(this._b,4),e.writeInt32LE(this._c,8),e.writeInt32LE(this._d,12),e};function Qu(e,t){return e<<t|e>>>32-t}function $t(e,t,r,n,i,o,s){return Qu(e+(t&r|~t&n)+i+o|0,s)+t|0}function Zt(e,t,r,n,i,o,s){return Qu(e+(t&n|r&~n)+i+o|0,s)+t|0}function Xt(e,t,r,n,i,o,s){return Qu(e+(t^r^n)+i+o|0,s)+t|0}function Jt(e,t,r,n,i,o,s){return Qu(e+(r^(t|~n))+i+o|0,s)+t|0}Pv.exports=Ju});var Nv=B((j4,Bv)=>{p();var Y2={}.toString;Bv.exports=Array.isArray||function(e){return Y2.call(e)=="[object Array]"}});var kv=B((G4,Mv)=>{"use strict";p();var $2=Ri(),Z2=Vn(),X2=Z2("TypedArray.prototype.buffer",!0),J2=Jl();Mv.exports=X2||function(t){if(!J2(t))throw new $2("Not a Typed Array");return t.buffer}});var ef=B((W4,Lv)=>{"use strict";p();var Br=Wt().Buffer,Q2=Nv(),eP=kv(),tP=ArrayBuffer.isView||function(t){try{return eP(t),!0}catch{return!1}},rP=typeof Uint8Array<"u",Cv=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u",nP=Cv&&(Br.prototype instanceof Uint8Array||Br.TYPED_ARRAY_SUPPORT);Lv.exports=function(t,r){if(Br.isBuffer(t))return t.constructor&&!("isBuffer"in t)?Br.from(t):t;if(typeof t=="string")return Br.from(t,r);if(Cv&&tP(t)){if(t.byteLength===0)return Br.alloc(0);if(nP){var n=Br.from(t.buffer,t.byteOffset,t.byteLength);if(n.byteLength===t.byteLength)return n}var i=t instanceof Uint8Array?t:new Uint8Array(t.buffer,t.byteOffset,t.byteLength),o=Br.from(i);if(o.length===t.byteLength)return o}if(rP&&t instanceof Uint8Array)return Br.from(t);var s=Q2(t);if(s)for(var a=0;a<t.length;a+=1){var f=t[a];if(typeof f!="number"||f<0||f>255||~~f!==f)throw new RangeError("Array items must be numbers in the range 0-255.")}if(s||Br.isBuffer(t)&&t.constructor&&typeof t.constructor.isBuffer=="function"&&t.constructor.isBuffer(t))return Br.from(t);throw new TypeError('The "data" argument must be a string, an Array, a Buffer, a Uint8Array, or a DataView.')}});var qv=B((Y4,Fv)=>{"use strict";p();var iP=Wt().Buffer,oP=ef(),Uv=typeof Uint8Array<"u",sP=Uv&&typeof ArrayBuffer<"u",Dv=sP&&ArrayBuffer.isView;Fv.exports=function(e,t){if(typeof e=="string"||iP.isBuffer(e)||Uv&&e instanceof Uint8Array||Dv&&Dv(e))return oP(e,t);throw new TypeError('The "data" argument must be a string, a Buffer, a Uint8Array, or a DataView')}});var Cs=B((Z4,Lh)=>{"use strict";p();typeof x.default>"u"||!x.default.version||x.default.version.indexOf("v0.")===0||x.default.version.indexOf("v1.")===0&&x.default.version.indexOf("v1.8.")!==0?Lh.exports={nextTick:aP}:Lh.exports=x.default;function aP(e,t,r,n){if(typeof e!="function")throw new TypeError('"callback" argument must be a function');var i=arguments.length,o,s;switch(i){case 0:case 1:return x.default.nextTick(e);case 2:return x.default.nextTick(function(){e.call(null,t)});case 3:return x.default.nextTick(function(){e.call(null,t,r)});case 4:return x.default.nextTick(function(){e.call(null,t,r,n)});default:for(o=new Array(i-1),s=0;s<o.length;)o[s++]=arguments[s];return x.default.nextTick(function(){e.apply(null,o)})}}});var jv=B((J4,Hv)=>{p();var uP={}.toString;Hv.exports=Array.isArray||function(e){return uP.call(e)=="[object Array]"}});var Dh=B((eD,Kv)=>{p();Kv.exports=mo().EventEmitter});var rf=B((Uh,Vv)=>{p();var tf=Mt(),_n=tf.Buffer;function Gv(e,t){for(var r in e)t[r]=e[r]}_n.from&&_n.alloc&&_n.allocUnsafe&&_n.allocUnsafeSlow?Vv.exports=tf:(Gv(tf,Uh),Uh.Buffer=Mo);function Mo(e,t,r){return _n(e,t,r)}Gv(_n,Mo);Mo.from=function(e,t,r){if(typeof e=="number")throw new TypeError("Argument must not be a number");return _n(e,t,r)};Mo.alloc=function(e,t,r){if(typeof e!="number")throw new TypeError("Argument must be a number");var n=_n(e);return t!==void 0?typeof r=="string"?n.fill(t,r):n.fill(t):n.fill(0),n};Mo.allocUnsafe=function(e){if(typeof e!="number")throw new TypeError("Argument must be a number");return _n(e)};Mo.allocUnsafeSlow=function(e){if(typeof e!="number")throw new TypeError("Argument must be a number");return tf.SlowBuffer(e)}});var ko=B(Qt=>{p();function fP(e){return Array.isArray?Array.isArray(e):nf(e)==="[object Array]"}Qt.isArray=fP;function cP(e){return typeof e=="boolean"}Qt.isBoolean=cP;function lP(e){return e===null}Qt.isNull=lP;function hP(e){return e==null}Qt.isNullOrUndefined=hP;function dP(e){return typeof e=="number"}Qt.isNumber=dP;function pP(e){return typeof e=="string"}Qt.isString=pP;function gP(e){return typeof e=="symbol"}Qt.isSymbol=gP;function yP(e){return e===void 0}Qt.isUndefined=yP;function mP(e){return nf(e)==="[object RegExp]"}Qt.isRegExp=mP;function vP(e){return typeof e=="object"&&e!==null}Qt.isObject=vP;function bP(e){return nf(e)==="[object Date]"}Qt.isDate=bP;function _P(e){return nf(e)==="[object Error]"||e instanceof Error}Qt.isError=_P;function SP(e){return typeof e=="function"}Qt.isFunction=SP;function wP(e){return e===null||typeof e=="boolean"||typeof e=="number"||typeof e=="string"||typeof e=="symbol"||typeof e>"u"}Qt.isPrimitive=wP;Qt.isBuffer=Mt().Buffer.isBuffer;function nf(e){return Object.prototype.toString.call(e)}});var zv=B((oD,Fh)=>{"use strict";p();function EP(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var Wv=rf().Buffer,Ls=Jr();function xP(e,t,r){e.copy(t,r)}Fh.exports=(function(){function e(){EP(this,e),this.head=null,this.tail=null,this.length=0}return e.prototype.push=function(r){var n={data:r,next:null};this.length>0?this.tail.next=n:this.head=n,this.tail=n,++this.length},e.prototype.unshift=function(r){var n={data:r,next:this.head};this.length===0&&(this.tail=n),this.head=n,++this.length},e.prototype.shift=function(){if(this.length!==0){var r=this.head.data;return this.length===1?this.head=this.tail=null:this.head=this.head.next,--this.length,r}},e.prototype.clear=function(){this.head=this.tail=null,this.length=0},e.prototype.join=function(r){if(this.length===0)return"";for(var n=this.head,i=""+n.data;n=n.next;)i+=r+n.data;return i},e.prototype.concat=function(r){if(this.length===0)return Wv.alloc(0);for(var n=Wv.allocUnsafe(r>>>0),i=this.head,o=0;i;)xP(i.data,n,o),o+=i.data.length,i=i.next;return n},e})();Ls&&Ls.inspect&&Ls.inspect.custom&&(Fh.exports.prototype[Ls.inspect.custom]=function(){var e=Ls.inspect({length:this.length});return this.constructor.name+" "+e})});var qh=B((aD,Yv)=>{"use strict";p();var of=Cs();function IP(e,t){var r=this,n=this._readableState&&this._readableState.destroyed,i=this._writableState&&this._writableState.destroyed;return n||i?(t?t(e):e&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,of.nextTick(sf,this,e)):of.nextTick(sf,this,e)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(e||null,function(o){!t&&o?r._writableState?r._writableState.errorEmitted||(r._writableState.errorEmitted=!0,of.nextTick(sf,r,o)):of.nextTick(sf,r,o):t&&t(o)}),this)}function AP(){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 sf(e,t){e.emit("error",t)}Yv.exports={destroy:IP,undestroy:AP}});var jh=B((fD,rb)=>{"use strict";p();var Ui=Cs();rb.exports=Rt;function Zv(e){var t=this;this.next=null,this.entry=null,this.finish=function(){GP(t,e)}}var OP=!x.default.browser&&["v0.10","v0.9."].indexOf(x.default.version.slice(0,5))>-1?setImmediate:Ui.nextTick,Co;Rt.WritableState=Us;var Xv=Object.create(ko());Xv.inherits=Ke();var RP={deprecate:lh()},Jv=Dh(),uf=rf().Buffer,TP=(typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function PP(e){return uf.from(e)}function BP(e){return uf.isBuffer(e)||e instanceof TP}var Qv=qh();Xv.inherits(Rt,Jv);function NP(){}function Us(e,t){Co=Co||Fi(),e=e||{};var r=t instanceof Co;this.objectMode=!!e.objectMode,r&&(this.objectMode=this.objectMode||!!e.writableObjectMode);var n=e.highWaterMark,i=e.writableHighWaterMark,o=this.objectMode?16:16*1024;n||n===0?this.highWaterMark=n:r&&(i||i===0)?this.highWaterMark=i:this.highWaterMark=o,this.highWaterMark=Math.floor(this.highWaterMark),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var s=e.decodeStrings===!1;this.decodeStrings=!s,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(a){FP(t,a)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new Zv(this)}Us.prototype.getBuffer=function(){for(var t=this.bufferedRequest,r=[];t;)r.push(t),t=t.next;return r};(function(){try{Object.defineProperty(Us.prototype,"buffer",{get:RP.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch{}})();var af;typeof Symbol=="function"&&Symbol.hasInstance&&typeof Function.prototype[Symbol.hasInstance]=="function"?(af=Function.prototype[Symbol.hasInstance],Object.defineProperty(Rt,Symbol.hasInstance,{value:function(e){return af.call(this,e)?!0:this!==Rt?!1:e&&e._writableState instanceof Us}})):af=function(e){return e instanceof this};function Rt(e){if(Co=Co||Fi(),!af.call(Rt,this)&&!(this instanceof Co))return new Rt(e);this._writableState=new Us(e,this),this.writable=!0,e&&(typeof e.write=="function"&&(this._write=e.write),typeof e.writev=="function"&&(this._writev=e.writev),typeof e.destroy=="function"&&(this._destroy=e.destroy),typeof e.final=="function"&&(this._final=e.final)),Jv.call(this)}Rt.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))};function MP(e,t){var r=new Error("write after end");e.emit("error",r),Ui.nextTick(t,r)}function kP(e,t,r,n){var i=!0,o=!1;return r===null?o=new TypeError("May not write null values to stream"):typeof r!="string"&&r!==void 0&&!t.objectMode&&(o=new TypeError("Invalid non-string/buffer chunk")),o&&(e.emit("error",o),Ui.nextTick(n,o),i=!1),i}Rt.prototype.write=function(e,t,r){var n=this._writableState,i=!1,o=!n.objectMode&&BP(e);return o&&!uf.isBuffer(e)&&(e=PP(e)),typeof t=="function"&&(r=t,t=null),o?t="buffer":t||(t=n.defaultEncoding),typeof r!="function"&&(r=NP),n.ended?MP(this,r):(o||kP(this,n,e,r))&&(n.pendingcb++,i=LP(this,n,o,e,t,r)),i};Rt.prototype.cork=function(){var e=this._writableState;e.corked++};Rt.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,!e.writing&&!e.corked&&!e.bufferProcessing&&e.bufferedRequest&&eb(this,e))};Rt.prototype.setDefaultEncoding=function(t){if(typeof t=="string"&&(t=t.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((t+"").toLowerCase())>-1))throw new TypeError("Unknown encoding: "+t);return this._writableState.defaultEncoding=t,this};function CP(e,t,r){return!e.objectMode&&e.decodeStrings!==!1&&typeof t=="string"&&(t=uf.from(t,r)),t}Object.defineProperty(Rt.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function LP(e,t,r,n,i,o){if(!r){var s=CP(t,n,i);n!==s&&(r=!0,i="buffer",n=s)}var a=t.objectMode?1:n.length;t.length+=a;var f=t.length<t.highWaterMark;if(f||(t.needDrain=!0),t.writing||t.corked){var l=t.lastBufferedRequest;t.lastBufferedRequest={chunk:n,encoding:i,isBuf:r,callback:o,next:null},l?l.next=t.lastBufferedRequest:t.bufferedRequest=t.lastBufferedRequest,t.bufferedRequestCount+=1}else Hh(e,t,!1,a,n,i,o);return f}function Hh(e,t,r,n,i,o,s){t.writelen=n,t.writecb=s,t.writing=!0,t.sync=!0,r?e._writev(i,t.onwrite):e._write(i,o,t.onwrite),t.sync=!1}function DP(e,t,r,n,i){--t.pendingcb,r?(Ui.nextTick(i,n),Ui.nextTick(Ds,e,t),e._writableState.errorEmitted=!0,e.emit("error",n)):(i(n),e._writableState.errorEmitted=!0,e.emit("error",n),Ds(e,t))}function UP(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}function FP(e,t){var r=e._writableState,n=r.sync,i=r.writecb;if(UP(r),t)DP(e,r,n,t,i);else{var o=tb(r);!o&&!r.corked&&!r.bufferProcessing&&r.bufferedRequest&&eb(e,r),n?OP($v,e,r,o,i):$v(e,r,o,i)}}function $v(e,t,r,n){r||qP(e,t),t.pendingcb--,n(),Ds(e,t)}function qP(e,t){t.length===0&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}function eb(e,t){t.bufferProcessing=!0;var r=t.bufferedRequest;if(e._writev&&r&&r.next){var n=t.bufferedRequestCount,i=new Array(n),o=t.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,Hh(e,t,!0,t.length,i,"",o.finish),t.pendingcb++,t.lastBufferedRequest=null,o.next?(t.corkedRequestsFree=o.next,o.next=null):t.corkedRequestsFree=new Zv(t),t.bufferedRequestCount=0}else{for(;r;){var f=r.chunk,l=r.encoding,y=r.callback,g=t.objectMode?1:f.length;if(Hh(e,t,!1,g,f,l,y),r=r.next,t.bufferedRequestCount--,t.writing)break}r===null&&(t.lastBufferedRequest=null)}t.bufferedRequest=r,t.bufferProcessing=!1}Rt.prototype._write=function(e,t,r){r(new Error("_write() is not implemented"))};Rt.prototype._writev=null;Rt.prototype.end=function(e,t,r){var n=this._writableState;typeof e=="function"?(r=e,e=null,t=null):typeof t=="function"&&(r=t,t=null),e!=null&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||KP(this,n,r)};function tb(e){return e.ending&&e.length===0&&e.bufferedRequest===null&&!e.finished&&!e.writing}function HP(e,t){e._final(function(r){t.pendingcb--,r&&e.emit("error",r),t.prefinished=!0,e.emit("prefinish"),Ds(e,t)})}function jP(e,t){!t.prefinished&&!t.finalCalled&&(typeof e._final=="function"?(t.pendingcb++,t.finalCalled=!0,Ui.nextTick(HP,e,t)):(t.prefinished=!0,e.emit("prefinish")))}function Ds(e,t){var r=tb(t);return r&&(jP(e,t),t.pendingcb===0&&(t.finished=!0,e.emit("finish"))),r}function KP(e,t,r){t.ending=!0,Ds(e,t),r&&(t.finished?Ui.nextTick(r):e.once("finish",r)),t.ended=!0,e.writable=!1}function GP(e,t,r){var n=e.entry;for(e.entry=null;n;){var i=n.callback;t.pendingcb--,i(r),n=n.next}t.corkedRequestsFree.next=e}Object.defineProperty(Rt.prototype,"destroyed",{get:function(){return this._writableState===void 0?!1:this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}});Rt.prototype.destroy=Qv.destroy;Rt.prototype._undestroy=Qv.undestroy;Rt.prototype._destroy=function(e,t){this.end(),t(e)}});var Fi=B((lD,sb)=>{"use strict";p();var nb=Cs(),VP=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t};sb.exports=Sn;var ib=Object.create(ko());ib.inherits=Ke();var ob=Vh(),Gh=jh();ib.inherits(Sn,ob);for(Kh=VP(Gh.prototype),ff=0;ff<Kh.length;ff++)cf=Kh[ff],Sn.prototype[cf]||(Sn.prototype[cf]=Gh.prototype[cf]);var Kh,cf,ff;function Sn(e){if(!(this instanceof Sn))return new Sn(e);ob.call(this,e),Gh.call(this,e),e&&e.readable===!1&&(this.readable=!1),e&&e.writable===!1&&(this.writable=!1),this.allowHalfOpen=!0,e&&e.allowHalfOpen===!1&&(this.allowHalfOpen=!1),this.once("end",WP)}Object.defineProperty(Sn.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function WP(){this.allowHalfOpen||this._writableState.ended||nb.nextTick(zP,this)}function zP(e){e.end()}Object.defineProperty(Sn.prototype,"destroyed",{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)}});Sn.prototype._destroy=function(e,t){this.push(null),this.end(),nb.nextTick(t,e)}});var Vh=B((pD,vb)=>{"use strict";p();var Do=Cs();vb.exports=Je;var YP=jv(),Fs;Je.ReadableState=db;var dD=mo().EventEmitter,cb=function(e,t){return e.listeners(t).length},Zh=Dh(),qs=rf().Buffer,$P=(typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function ZP(e){return qs.from(e)}function XP(e){return qs.isBuffer(e)||e instanceof $P}var lb=Object.create(ko());lb.inherits=Ke();var Wh=Jr(),Le=void 0;Wh&&Wh.debuglog?Le=Wh.debuglog("stream"):Le=function(){};var JP=zv(),hb=qh(),Lo;lb.inherits(Je,Zh);var zh=["error","close","destroy","pause","resume"];function QP(e,t,r){if(typeof e.prependListener=="function")return e.prependListener(t,r);!e._events||!e._events[t]?e.on(t,r):YP(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]}function db(e,t){Fs=Fs||Fi(),e=e||{};var r=t instanceof Fs;this.objectMode=!!e.objectMode,r&&(this.objectMode=this.objectMode||!!e.readableObjectMode);var n=e.highWaterMark,i=e.readableHighWaterMark,o=this.objectMode?16:16*1024;n||n===0?this.highWaterMark=n:r&&(i||i===0)?this.highWaterMark=i:this.highWaterMark=o,this.highWaterMark=Math.floor(this.highWaterMark),this.buffer=new JP,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.destroyed=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(Lo||(Lo=Po().StringDecoder),this.decoder=new Lo(e.encoding),this.encoding=e.encoding)}function Je(e){if(Fs=Fs||Fi(),!(this instanceof Je))return new Je(e);this._readableState=new db(e,this),this.readable=!0,e&&(typeof e.read=="function"&&(this._read=e.read),typeof e.destroy=="function"&&(this._destroy=e.destroy)),Zh.call(this)}Object.defineProperty(Je.prototype,"destroyed",{get:function(){return this._readableState===void 0?!1:this._readableState.destroyed},set:function(e){this._readableState&&(this._readableState.destroyed=e)}});Je.prototype.destroy=hb.destroy;Je.prototype._undestroy=hb.undestroy;Je.prototype._destroy=function(e,t){this.push(null),t(e)};Je.prototype.push=function(e,t){var r=this._readableState,n;return r.objectMode?n=!0:typeof e=="string"&&(t=t||r.defaultEncoding,t!==r.encoding&&(e=qs.from(e,t),t=""),n=!0),pb(this,e,t,!1,n)};Je.prototype.unshift=function(e){return pb(this,e,null,!0,!1)};function pb(e,t,r,n,i){var o=e._readableState;if(t===null)o.reading=!1,nB(e,o);else{var s;i||(s=eB(o,t)),s?e.emit("error",s):o.objectMode||t&&t.length>0?(typeof t!="string"&&!o.objectMode&&Object.getPrototypeOf(t)!==qs.prototype&&(t=ZP(t)),n?o.endEmitted?e.emit("error",new Error("stream.unshift() after end event")):Yh(e,o,t,!0):o.ended?e.emit("error",new Error("stream.push() after EOF")):(o.reading=!1,o.decoder&&!r?(t=o.decoder.write(t),o.objectMode||t.length!==0?Yh(e,o,t,!1):gb(e,o)):Yh(e,o,t,!1))):n||(o.reading=!1)}return tB(o)}function Yh(e,t,r,n){t.flowing&&t.length===0&&!t.sync?(e.emit("data",r),e.read(0)):(t.length+=t.objectMode?1:r.length,n?t.buffer.unshift(r):t.buffer.push(r),t.needReadable&&lf(e)),gb(e,t)}function eB(e,t){var r;return!XP(t)&&typeof t!="string"&&t!==void 0&&!e.objectMode&&(r=new TypeError("Invalid non-string/buffer chunk")),r}function tB(e){return!e.ended&&(e.needReadable||e.length<e.highWaterMark||e.length===0)}Je.prototype.isPaused=function(){return this._readableState.flowing===!1};Je.prototype.setEncoding=function(e){return Lo||(Lo=Po().StringDecoder),this._readableState.decoder=new Lo(e),this._readableState.encoding=e,this};var ab=8388608;function rB(e){return e>=ab?e=ab:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}function ub(e,t){return e<=0||t.length===0&&t.ended?0:t.objectMode?1:e!==e?t.flowing&&t.length?t.buffer.head.data.length:t.length:(e>t.highWaterMark&&(t.highWaterMark=rB(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}Je.prototype.read=function(e){Le("read",e),e=parseInt(e,10);var t=this._readableState,r=e;if(e!==0&&(t.emittedReadable=!1),e===0&&t.needReadable&&(t.length>=t.highWaterMark||t.ended))return Le("read: emitReadable",t.length,t.ended),t.length===0&&t.ended?$h(this):lf(this),null;if(e=ub(e,t),e===0&&t.ended)return t.length===0&&$h(this),null;var n=t.needReadable;Le("need readable",n),(t.length===0||t.length-e<t.highWaterMark)&&(n=!0,Le("length less than watermark",n)),t.ended||t.reading?(n=!1,Le("reading or ended",n)):n&&(Le("do read"),t.reading=!0,t.sync=!0,t.length===0&&(t.needReadable=!0),this._read(t.highWaterMark),t.sync=!1,t.reading||(e=ub(r,t)));var i;return e>0?i=yb(e,t):i=null,i===null?(t.needReadable=!0,e=0):t.length-=e,t.length===0&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&$h(this)),i!==null&&this.emit("data",i),i};function nB(e,t){if(!t.ended){if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,lf(e)}}function lf(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(Le("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Do.nextTick(fb,e):fb(e))}function fb(e){Le("emit readable"),e.emit("readable"),Xh(e)}function gb(e,t){t.readingMore||(t.readingMore=!0,Do.nextTick(iB,e,t))}function iB(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length<t.highWaterMark&&(Le("maybeReadMore read 0"),e.read(0),r!==t.length);)r=t.length;t.readingMore=!1}Je.prototype._read=function(e){this.emit("error",new Error("_read() is not implemented"))};Je.prototype.pipe=function(e,t){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=e;break;case 1:n.pipes=[n.pipes,e];break;default:n.pipes.push(e);break}n.pipesCount+=1,Le("pipe count=%d opts=%j",n.pipesCount,t);var i=(!t||t.end!==!1)&&e!==x.default.stdout&&e!==x.default.stderr,o=i?a:L;n.endEmitted?Do.nextTick(o):r.once("end",o),e.on("unpipe",s);function s(F,V){Le("onunpipe"),F===r&&V&&V.hasUnpiped===!1&&(V.hasUnpiped=!0,y())}function a(){Le("onend"),e.end()}var f=oB(r);e.on("drain",f);var l=!1;function y(){Le("cleanup"),e.removeListener("close",T),e.removeListener("finish",M),e.removeListener("drain",f),e.removeListener("error",E),e.removeListener("unpipe",s),r.removeListener("end",a),r.removeListener("end",L),r.removeListener("data",v),l=!0,n.awaitDrain&&(!e._writableState||e._writableState.needDrain)&&f()}var g=!1;r.on("data",v);function v(F){Le("ondata"),g=!1;var V=e.write(F);V===!1&&!g&&((n.pipesCount===1&&n.pipes===e||n.pipesCount>1&&mb(n.pipes,e)!==-1)&&!l&&(Le("false write response, pause",n.awaitDrain),n.awaitDrain++,g=!0),r.pause())}function E(F){Le("onerror",F),L(),e.removeListener("error",E),cb(e,"error")===0&&e.emit("error",F)}QP(e,"error",E);function T(){e.removeListener("finish",M),L()}e.once("close",T);function M(){Le("onfinish"),e.removeListener("close",T),L()}e.once("finish",M);function L(){Le("unpipe"),r.unpipe(e)}return e.emit("pipe",r),n.flowing||(Le("pipe resume"),r.resume()),e};function oB(e){return function(){var t=e._readableState;Le("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,t.awaitDrain===0&&cb(e,"data")&&(t.flowing=!0,Xh(e))}}Je.prototype.unpipe=function(e){var t=this._readableState,r={hasUnpiped:!1};if(t.pipesCount===0)return this;if(t.pipesCount===1)return e&&e!==t.pipes?this:(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,r),this);if(!e){var n=t.pipes,i=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var o=0;o<i;o++)n[o].emit("unpipe",this,{hasUnpiped:!1});return this}var s=mb(t.pipes,e);return s===-1?this:(t.pipes.splice(s,1),t.pipesCount-=1,t.pipesCount===1&&(t.pipes=t.pipes[0]),e.emit("unpipe",this,r),this)};Je.prototype.on=function(e,t){var r=Zh.prototype.on.call(this,e,t);if(e==="data")this._readableState.flowing!==!1&&this.resume();else if(e==="readable"){var n=this._readableState;!n.endEmitted&&!n.readableListening&&(n.readableListening=n.needReadable=!0,n.emittedReadable=!1,n.reading?n.length&&lf(this):Do.nextTick(sB,this))}return r};Je.prototype.addListener=Je.prototype.on;function sB(e){Le("readable nexttick read 0"),e.read(0)}Je.prototype.resume=function(){var e=this._readableState;return e.flowing||(Le("resume"),e.flowing=!0,aB(this,e)),this};function aB(e,t){t.resumeScheduled||(t.resumeScheduled=!0,Do.nextTick(uB,e,t))}function uB(e,t){t.reading||(Le("resume read 0"),e.read(0)),t.resumeScheduled=!1,t.awaitDrain=0,e.emit("resume"),Xh(e),t.flowing&&!t.reading&&e.read(0)}Je.prototype.pause=function(){return Le("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(Le("pause"),this._readableState.flowing=!1,this.emit("pause")),this};function Xh(e){var t=e._readableState;for(Le("flow",t.flowing);t.flowing&&e.read()!==null;);}Je.prototype.wrap=function(e){var t=this,r=this._readableState,n=!1;e.on("end",function(){if(Le("wrapped end"),r.decoder&&!r.ended){var s=r.decoder.end();s&&s.length&&t.push(s)}t.push(null)}),e.on("data",function(s){if(Le("wrapped data"),r.decoder&&(s=r.decoder.write(s)),!(r.objectMode&&s==null)&&!(!r.objectMode&&(!s||!s.length))){var a=t.push(s);a||(n=!0,e.pause())}});for(var i in e)this[i]===void 0&&typeof e[i]=="function"&&(this[i]=(function(s){return function(){return e[s].apply(e,arguments)}})(i));for(var o=0;o<zh.length;o++)e.on(zh[o],this.emit.bind(this,zh[o]));return this._read=function(s){Le("wrapped _read",s),n&&(n=!1,e.resume())},this};Object.defineProperty(Je.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}});Je._fromList=yb;function yb(e,t){if(t.length===0)return null;var r;return t.objectMode?r=t.buffer.shift():!e||e>=t.length?(t.decoder?r=t.buffer.join(""):t.buffer.length===1?r=t.buffer.head.data:r=t.buffer.concat(t.length),t.buffer.clear()):r=fB(e,t.buffer,t.decoder),r}function fB(e,t,r){var n;return e<t.head.data.length?(n=t.head.data.slice(0,e),t.head.data=t.head.data.slice(e)):e===t.head.data.length?n=t.shift():n=r?cB(e,t):lB(e,t),n}function cB(e,t){var r=t.head,n=1,i=r.data;for(e-=i.length;r=r.next;){var o=r.data,s=e>o.length?o.length:e;if(s===o.length?i+=o:i+=o.slice(0,e),e-=s,e===0){s===o.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=o.slice(s));break}++n}return t.length-=n,i}function lB(e,t){var r=qs.allocUnsafe(e),n=t.head,i=1;for(n.data.copy(r),e-=n.data.length;n=n.next;){var o=n.data,s=e>o.length?o.length:e;if(o.copy(r,r.length-e,0,s),e-=s,e===0){s===o.length?(++i,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=o.slice(s));break}++i}return t.length-=i,r}function $h(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Do.nextTick(hB,t,e))}function hB(e,t){!e.endEmitted&&e.length===0&&(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function mb(e,t){for(var r=0,n=e.length;r<n;r++)if(e[r]===t)return r;return-1}});var Jh=B((yD,Sb)=>{"use strict";p();Sb.exports=wn;var hf=Fi(),_b=Object.create(ko());_b.inherits=Ke();_b.inherits(wn,hf);function dB(e,t){var r=this._transformState;r.transforming=!1;var n=r.writecb;if(!n)return this.emit("error",new Error("write callback called multiple times"));r.writechunk=null,r.writecb=null,t!=null&&this.push(t),n(e);var i=this._readableState;i.reading=!1,(i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}function wn(e){if(!(this instanceof wn))return new wn(e);hf.call(this,e),this._transformState={afterTransform:dB.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,e&&(typeof e.transform=="function"&&(this._transform=e.transform),typeof e.flush=="function"&&(this._flush=e.flush)),this.on("prefinish",pB)}function pB(){var e=this;typeof this._flush=="function"?this._flush(function(t,r){bb(e,t,r)}):bb(this,null,null)}wn.prototype.push=function(e,t){return this._transformState.needTransform=!1,hf.prototype.push.call(this,e,t)};wn.prototype._transform=function(e,t,r){throw new Error("_transform() is not implemented")};wn.prototype._write=function(e,t,r){var n=this._transformState;if(n.writecb=r,n.writechunk=e,n.writeencoding=t,!n.transforming){var i=this._readableState;(n.needTransform||i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}};wn.prototype._read=function(e){var t=this._transformState;t.writechunk!==null&&t.writecb&&!t.transforming?(t.transforming=!0,this._transform(t.writechunk,t.writeencoding,t.afterTransform)):t.needTransform=!0};wn.prototype._destroy=function(e,t){var r=this;hf.prototype._destroy.call(this,e,function(n){t(n),r.emit("close")})};function bb(e,t,r){if(t)return e.emit("error",t);if(r!=null&&e.push(r),e._writableState.length)throw new Error("Calling transform done when ws.length != 0");if(e._transformState.transforming)throw new Error("Calling transform done when still transforming");return e.push(null)}});var Ib=B((vD,xb)=>{"use strict";p();xb.exports=Hs;var wb=Jh(),Eb=Object.create(ko());Eb.inherits=Ke();Eb.inherits(Hs,wb);function Hs(e){if(!(this instanceof Hs))return new Hs(e);wb.call(this,e)}Hs.prototype._transform=function(e,t,r){r(null,e)}});var Ob=B((tn,Ab)=>{p();tn=Ab.exports=Vh();tn.Stream=tn;tn.Readable=tn;tn.Writable=jh();tn.Duplex=Fi();tn.Transform=Jh();tn.PassThrough=Ib()});var Pb=B((SD,Tb)=>{"use strict";p();var gB=Wt().Buffer,yB=qv(),Rb=Ob().Transform,mB=Ke();function Jn(e){Rb.call(this),this._block=gB.allocUnsafe(e),this._blockSize=e,this._blockOffset=0,this._length=[0,0,0,0],this._finalized=!1}mB(Jn,Rb);Jn.prototype._transform=function(e,t,r){var n=null;try{this.update(e,t)}catch(i){n=i}r(n)};Jn.prototype._flush=function(e){var t=null;try{this.push(this.digest())}catch(r){t=r}e(t)};Jn.prototype.update=function(e,t){if(this._finalized)throw new Error("Digest already called");for(var r=yB(e,t),n=this._block,i=0;this._blockOffset+r.length-i>=this._blockSize;){for(var o=this._blockOffset;o<this._blockSize;)n[o]=r[i],o+=1,i+=1;this._update(),this._blockOffset=0}for(;i<r.length;)n[this._blockOffset]=r[i],this._blockOffset+=1,i+=1;for(var s=0,a=r.length*8;a>0;++s)this._length[s]+=a,a=this._length[s]/4294967296|0,a>0&&(this._length[s]-=4294967296*a);return this};Jn.prototype._update=function(){throw new Error("_update is not implemented")};Jn.prototype.digest=function(e){if(this._finalized)throw new Error("Digest already called");this._finalized=!0;var t=this._digest();e!==void 0&&(t=t.toString(e)),this._block.fill(0),this._blockOffset=0;for(var r=0;r<4;++r)this._length[r]=0;return t};Jn.prototype._digest=function(){throw new Error("_digest is not implemented")};Tb.exports=Jn});var ed=B((ED,Db)=>{"use strict";p();var Qh=Mt().Buffer,vB=Ke(),Lb=Pb(),bB=new Array(16),js=[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],Ks=[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],Gs=[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],Vs=[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],Ws=[0,1518500249,1859775393,2400959708,2840853838],zs=[1352829926,1548603684,1836072691,2053994217,0];function qi(e,t){return e<<t|e>>>32-t}function Bb(e,t,r,n,i,o,s,a){return qi(e+(t^r^n)+o+s|0,a)+i|0}function Nb(e,t,r,n,i,o,s,a){return qi(e+(t&r|~t&n)+o+s|0,a)+i|0}function Mb(e,t,r,n,i,o,s,a){return qi(e+((t|~r)^n)+o+s|0,a)+i|0}function kb(e,t,r,n,i,o,s,a){return qi(e+(t&n|r&~n)+o+s|0,a)+i|0}function Cb(e,t,r,n,i,o,s,a){return qi(e+(t^(r|~n))+o+s|0,a)+i|0}function df(){Lb.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520}vB(df,Lb);df.prototype._update=function(){for(var e=bB,t=0;t<16;++t)e[t]=this._block.readInt32LE(t*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,f=this._b|0,l=this._c|0,y=this._d|0,g=this._e|0,v=0;v<80;v+=1){var E,T;v<16?(E=Bb(r,n,i,o,s,e[js[v]],Ws[0],Gs[v]),T=Cb(a,f,l,y,g,e[Ks[v]],zs[0],Vs[v])):v<32?(E=Nb(r,n,i,o,s,e[js[v]],Ws[1],Gs[v]),T=kb(a,f,l,y,g,e[Ks[v]],zs[1],Vs[v])):v<48?(E=Mb(r,n,i,o,s,e[js[v]],Ws[2],Gs[v]),T=Mb(a,f,l,y,g,e[Ks[v]],zs[2],Vs[v])):v<64?(E=kb(r,n,i,o,s,e[js[v]],Ws[3],Gs[v]),T=Nb(a,f,l,y,g,e[Ks[v]],zs[3],Vs[v])):(E=Cb(r,n,i,o,s,e[js[v]],Ws[4],Gs[v]),T=Bb(a,f,l,y,g,e[Ks[v]],zs[4],Vs[v])),r=s,s=o,o=qi(i,10),i=n,n=E,a=g,g=y,y=qi(l,10),l=f,f=T}var M=this._b+i+y|0;this._b=this._c+o+g|0,this._c=this._d+s+a|0,this._d=this._e+r+f|0,this._e=this._a+n+l|0,this._a=M};df.prototype._digest=function(){this._block[this._blockOffset]=128,this._blockOffset+=1,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 e=Qh.alloc?Qh.alloc(20):new Qh(20);return e.writeInt32LE(this._a,0),e.writeInt32LE(this._b,4),e.writeInt32LE(this._c,8),e.writeInt32LE(this._d,12),e.writeInt32LE(this._e,16),e};Db.exports=df});var Hi=B((ID,Ub)=>{"use strict";p();var _B=Wt().Buffer,SB=ef();function pf(e,t){this._block=_B.alloc(e),this._finalSize=t,this._blockSize=e,this._len=0}pf.prototype.update=function(e,t){e=SB(e,t||"utf8");for(var r=this._block,n=this._blockSize,i=e.length,o=this._len,s=0;s<i;){for(var a=o%n,f=Math.min(i-s,n-a),l=0;l<f;l++)r[a+l]=e[s+l];o+=f,s+=f,o%n===0&&this._update(r)}return this._len+=i,this};pf.prototype.digest=function(e){var t=this._len%this._blockSize;this._block[t]=128,this._block.fill(0,t+1),t>=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 e?o.toString(e):o};pf.prototype._update=function(){throw new Error("_update must be implemented by subclass")};Ub.exports=pf});var Hb=B((OD,qb)=>{"use strict";p();var wB=Ke(),Fb=Hi(),EB=Wt().Buffer,xB=[1518500249,1859775393,-1894007588,-899497514],IB=new Array(80);function Ys(){this.init(),this._w=IB,Fb.call(this,64,56)}wB(Ys,Fb);Ys.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function AB(e){return e<<5|e>>>27}function OB(e){return e<<30|e>>>2}function RB(e,t,r,n){return e===0?t&r|~t&n:e===2?t&r|t&n|r&n:t^r^n}Ys.prototype._update=function(e){for(var t=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)t[a]=e.readInt32BE(a*4);for(;a<80;++a)t[a]=t[a-3]^t[a-8]^t[a-14]^t[a-16];for(var f=0;f<80;++f){var l=~~(f/20),y=AB(r)+RB(l,n,i,o)+s+t[f]+xB[l]|0;s=o,o=i,i=OB(n),n=r,r=y}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};Ys.prototype._hash=function(){var e=EB.allocUnsafe(20);return e.writeInt32BE(this._a|0,0),e.writeInt32BE(this._b|0,4),e.writeInt32BE(this._c|0,8),e.writeInt32BE(this._d|0,12),e.writeInt32BE(this._e|0,16),e};qb.exports=Ys});var Gb=B((TD,Kb)=>{"use strict";p();var TB=Ke(),jb=Hi(),PB=Wt().Buffer,BB=[1518500249,1859775393,-1894007588,-899497514],NB=new Array(80);function $s(){this.init(),this._w=NB,jb.call(this,64,56)}TB($s,jb);$s.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function MB(e){return e<<1|e>>>31}function kB(e){return e<<5|e>>>27}function CB(e){return e<<30|e>>>2}function LB(e,t,r,n){return e===0?t&r|~t&n:e===2?t&r|t&n|r&n:t^r^n}$s.prototype._update=function(e){for(var t=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)t[a]=e.readInt32BE(a*4);for(;a<80;++a)t[a]=MB(t[a-3]^t[a-8]^t[a-14]^t[a-16]);for(var f=0;f<80;++f){var l=~~(f/20),y=kB(r)+LB(l,n,i,o)+s+t[f]+BB[l]|0;s=o,o=i,i=CB(n),n=r,r=y}this._a=r+this._a|0,this._b=n+this._b|0,this._c=i+this._c|0,this._d=o+this._d|0,this._e=s+this._e|0};$s.prototype._hash=function(){var e=PB.allocUnsafe(20);return e.writeInt32BE(this._a|0,0),e.writeInt32BE(this._b|0,4),e.writeInt32BE(this._c|0,8),e.writeInt32BE(this._d|0,12),e.writeInt32BE(this._e|0,16),e};Kb.exports=$s});var td=B((BD,Wb)=>{"use strict";p();var DB=Ke(),Vb=Hi(),UB=Wt().Buffer,FB=[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],qB=new Array(64);function Zs(){this.init(),this._w=qB,Vb.call(this,64,56)}DB(Zs,Vb);Zs.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 HB(e,t,r){return r^e&(t^r)}function jB(e,t,r){return e&t|r&(e|t)}function KB(e){return(e>>>2|e<<30)^(e>>>13|e<<19)^(e>>>22|e<<10)}function GB(e){return(e>>>6|e<<26)^(e>>>11|e<<21)^(e>>>25|e<<7)}function VB(e){return(e>>>7|e<<25)^(e>>>18|e<<14)^e>>>3}function WB(e){return(e>>>17|e<<15)^(e>>>19|e<<13)^e>>>10}Zs.prototype._update=function(e){for(var t=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,f=this._g|0,l=this._h|0,y=0;y<16;++y)t[y]=e.readInt32BE(y*4);for(;y<64;++y)t[y]=WB(t[y-2])+t[y-7]+VB(t[y-15])+t[y-16]|0;for(var g=0;g<64;++g){var v=l+GB(s)+HB(s,a,f)+FB[g]+t[g]|0,E=KB(r)+jB(r,n,i)|0;l=f,f=a,a=s,s=o+v|0,o=i,i=n,n=r,r=v+E|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=f+this._g|0,this._h=l+this._h|0};Zs.prototype._hash=function(){var e=UB.allocUnsafe(32);return e.writeInt32BE(this._a,0),e.writeInt32BE(this._b,4),e.writeInt32BE(this._c,8),e.writeInt32BE(this._d,12),e.writeInt32BE(this._e,16),e.writeInt32BE(this._f,20),e.writeInt32BE(this._g,24),e.writeInt32BE(this._h,28),e};Wb.exports=Zs});var Yb=B((MD,zb)=>{"use strict";p();var zB=Ke(),YB=td(),$B=Hi(),ZB=Wt().Buffer,XB=new Array(64);function gf(){this.init(),this._w=XB,$B.call(this,64,56)}zB(gf,YB);gf.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};gf.prototype._hash=function(){var e=ZB.allocUnsafe(28);return e.writeInt32BE(this._a,0),e.writeInt32BE(this._b,4),e.writeInt32BE(this._c,8),e.writeInt32BE(this._d,12),e.writeInt32BE(this._e,16),e.writeInt32BE(this._f,20),e.writeInt32BE(this._g,24),e};zb.exports=gf});var rd=B((CD,t_)=>{"use strict";p();var JB=Ke(),e_=Hi(),QB=Wt().Buffer,$b=[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],eN=new Array(160);function Xs(){this.init(),this._w=eN,e_.call(this,128,112)}JB(Xs,e_);Xs.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 Zb(e,t,r){return r^e&(t^r)}function Xb(e,t,r){return e&t|r&(e|t)}function Jb(e,t){return(e>>>28|t<<4)^(t>>>2|e<<30)^(t>>>7|e<<25)}function Qb(e,t){return(e>>>14|t<<18)^(e>>>18|t<<14)^(t>>>9|e<<23)}function tN(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^e>>>7}function rN(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^(e>>>7|t<<25)}function nN(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^e>>>6}function iN(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^(e>>>6|t<<26)}function jt(e,t){return e>>>0<t>>>0?1:0}Xs.prototype._update=function(e){for(var t=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,f=this._gh|0,l=this._hh|0,y=this._al|0,g=this._bl|0,v=this._cl|0,E=this._dl|0,T=this._el|0,M=this._fl|0,L=this._gl|0,F=this._hl|0,V=0;V<32;V+=2)t[V]=e.readInt32BE(V*4),t[V+1]=e.readInt32BE(V*4+4);for(;V<160;V+=2){var z=t[V-30],G=t[V-30+1],ie=tN(z,G),te=rN(G,z);z=t[V-4],G=t[V-4+1];var pe=nN(z,G),fe=iN(G,z),ye=t[V-14],I=t[V-14+1],u=t[V-32],h=t[V-32+1],m=te+I|0,S=ie+ye+jt(m,te)|0;m=m+fe|0,S=S+pe+jt(m,fe)|0,m=m+h|0,S=S+u+jt(m,h)|0,t[V]=S,t[V+1]=m}for(var w=0;w<160;w+=2){S=t[w],m=t[w+1];var R=Xb(r,n,i),A=Xb(y,g,v),_=Jb(r,y),c=Jb(y,r),b=Qb(s,T),k=Qb(T,s),U=$b[w],K=$b[w+1],W=Zb(s,a,f),ee=Zb(T,M,L),X=F+k|0,le=l+b+jt(X,F)|0;X=X+ee|0,le=le+W+jt(X,ee)|0,X=X+K|0,le=le+U+jt(X,K)|0,X=X+m|0,le=le+S+jt(X,m)|0;var ae=c+A|0,O=_+R+jt(ae,c)|0;l=f,F=L,f=a,L=M,a=s,M=T,T=E+X|0,s=o+le+jt(T,E)|0,o=i,E=v,i=n,v=g,n=r,g=y,y=X+ae|0,r=le+O+jt(y,X)|0}this._al=this._al+y|0,this._bl=this._bl+g|0,this._cl=this._cl+v|0,this._dl=this._dl+E|0,this._el=this._el+T|0,this._fl=this._fl+M|0,this._gl=this._gl+L|0,this._hl=this._hl+F|0,this._ah=this._ah+r+jt(this._al,y)|0,this._bh=this._bh+n+jt(this._bl,g)|0,this._ch=this._ch+i+jt(this._cl,v)|0,this._dh=this._dh+o+jt(this._dl,E)|0,this._eh=this._eh+s+jt(this._el,T)|0,this._fh=this._fh+a+jt(this._fl,M)|0,this._gh=this._gh+f+jt(this._gl,L)|0,this._hh=this._hh+l+jt(this._hl,F)|0};Xs.prototype._hash=function(){var e=QB.allocUnsafe(64);function t(r,n,i){e.writeInt32BE(r,i),e.writeInt32BE(n,i+4)}return t(this._ah,this._al,0),t(this._bh,this._bl,8),t(this._ch,this._cl,16),t(this._dh,this._dl,24),t(this._eh,this._el,32),t(this._fh,this._fl,40),t(this._gh,this._gl,48),t(this._hh,this._hl,56),e};t_.exports=Xs});var n_=B((DD,r_)=>{"use strict";p();var oN=Ke(),sN=rd(),aN=Hi(),uN=Wt().Buffer,fN=new Array(160);function yf(){this.init(),this._w=fN,aN.call(this,128,112)}oN(yf,sN);yf.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};yf.prototype._hash=function(){var e=uN.allocUnsafe(48);function t(r,n,i){e.writeInt32BE(r,i),e.writeInt32BE(n,i+4)}return t(this._ah,this._al,0),t(this._bh,this._bl,8),t(this._ch,this._cl,16),t(this._dh,this._dl,24),t(this._eh,this._el,32),t(this._fh,this._fl,40),e};r_.exports=yf});var nd=B((FD,En)=>{"use strict";p();En.exports=function(t){var r=t.toLowerCase(),n=En.exports[r];if(!n)throw new Error(r+" is not supported (we accept pull requests)");return new n};En.exports.sha=Hb();En.exports.sha1=Gb();En.exports.sha224=Yb();En.exports.sha256=td();En.exports.sha384=n_();En.exports.sha512=rd()});var mf=B((HD,o_)=>{"use strict";p();var cN=Wt().Buffer,i_=kh().Transform,lN=Po().StringDecoder,hN=Ke(),dN=ef();function Nr(e){i_.call(this),this.hashMode=typeof e=="string",this.hashMode?this[e]=this._finalOrDigest:this.final=this._finalOrDigest,this._final&&(this.__final=this._final,this._final=null),this._decoder=null,this._encoding=null}hN(Nr,i_);Nr.prototype.update=function(e,t,r){var n=dN(e,t),i=this._update(n);return this.hashMode?this:(r&&(i=this._toString(i,r)),i)};Nr.prototype.setAutoPadding=function(){};Nr.prototype.getAuthTag=function(){throw new Error("trying to get auth tag in unsupported state")};Nr.prototype.setAuthTag=function(){throw new Error("trying to set auth tag in unsupported state")};Nr.prototype.setAAD=function(){throw new Error("trying to set aad in unsupported state")};Nr.prototype._transform=function(e,t,r){var n;try{this.hashMode?this._update(e):this.push(this._update(e))}catch(i){n=i}finally{r(n)}};Nr.prototype._flush=function(e){var t;try{this.push(this.__final())}catch(r){t=r}e(t)};Nr.prototype._finalOrDigest=function(e){var t=this.__final()||cN.alloc(0);return e&&(t=this._toString(t,e,!0)),t};Nr.prototype._toString=function(e,t,r){if(this._decoder||(this._decoder=new lN(t),this._encoding=t),this._encoding!==t)throw new Error("can\u2019t switch encodings");var n=this._decoder.write(e);return r&&(n+=this._decoder.end()),n};o_.exports=Nr});var u_=B((KD,a_)=>{"use strict";p();var pN=Ke(),gN=Ch(),yN=ed(),mN=nd(),s_=mf();function vf(e){s_.call(this,"digest"),this._hash=e}pN(vf,s_);vf.prototype._update=function(e){this._hash.update(e)};vf.prototype._final=function(){return this._hash.digest()};a_.exports=function(t){return t=t.toLowerCase(),t==="md5"?new gN:t==="rmd160"||t==="ripemd160"?new yN:new vf(mN(t))}});var l_=B((VD,c_)=>{"use strict";p();var vN=Ke(),ji=Wt().Buffer,f_=mf(),bN=ji.alloc(128),Uo=64;function bf(e,t){f_.call(this,"digest"),typeof t=="string"&&(t=ji.from(t)),this._alg=e,this._key=t,t.length>Uo?t=e(t):t.length<Uo&&(t=ji.concat([t,bN],Uo));for(var r=this._ipad=ji.allocUnsafe(Uo),n=this._opad=ji.allocUnsafe(Uo),i=0;i<Uo;i++)r[i]=t[i]^54,n[i]=t[i]^92;this._hash=[r]}vN(bf,f_);bf.prototype._update=function(e){this._hash.push(e)};bf.prototype._final=function(){var e=this._alg(ji.concat(this._hash));return this._alg(ji.concat([this._opad,e]))};c_.exports=bf});var d_=B((zD,h_)=>{p();var _N=Ch();h_.exports=function(e){return new _N().update(e).digest()}});var y_=B(($D,g_)=>{"use strict";p();var SN=Ke(),wN=l_(),p_=mf(),Js=Wt().Buffer,EN=d_(),id=ed(),od=nd(),xN=Js.alloc(128);function Qs(e,t){p_.call(this,"digest"),typeof t=="string"&&(t=Js.from(t));var r=e==="sha512"||e==="sha384"?128:64;if(this._alg=e,this._key=t,t.length>r){var n=e==="rmd160"?new id:od(e);t=n.update(t).digest()}else t.length<r&&(t=Js.concat([t,xN],r));for(var i=this._ipad=Js.allocUnsafe(r),o=this._opad=Js.allocUnsafe(r),s=0;s<r;s++)i[s]=t[s]^54,o[s]=t[s]^92;this._hash=e==="rmd160"?new id:od(e),this._hash.update(i)}SN(Qs,p_);Qs.prototype._update=function(e){this._hash.update(e)};Qs.prototype._final=function(){var e=this._hash.digest(),t=this._alg==="rmd160"?new id:od(this._alg);return t.update(this._opad).update(e).digest()};g_.exports=function(t,r){return t=t.toLowerCase(),t==="rmd160"||t==="ripemd160"?new Qs("rmd160",r):t==="md5"?new wN(EN,r):new Qs(t,r)}});var m_=B((XD,ad)=>{"use strict";p();var sd=65536,IN=4294967295;function AN(){throw new Error(`Secure random number generation is not supported by this browser.
11
- Use Chrome, Firefox or Internet Explorer 11`)}var ON=Wt().Buffer,_f=globalThis.crypto||globalThis.msCrypto;_f&&_f.getRandomValues?ad.exports=RN:ad.exports=AN;function RN(e,t){if(e>IN)throw new RangeError("requested too many random bytes");var r=ON.allocUnsafe(e);if(e>0)if(e>sd)for(var n=0;n<e;n+=sd)_f.getRandomValues(r.slice(n,n+sd));else _f.getRandomValues(r);return typeof t=="function"?x.default.nextTick(function(){t(null,r)}):r}});var ea=B(Sf=>{"use strict";p();Sf.createHash=u_();Sf.createHmac=y_();Sf.randomBytes=m_()});var ta=B((tU,b_)=>{"use strict";p();var v_=65536;function Ki(){}Ki.getRandomBuffer=function(e){var t=typeof globalThis<"u"?globalThis.crypto:void 0;if(t&&typeof t.getRandomValues=="function")return Ki._fromGetRandomValues(t,e);try{var r=ea();if(r&&typeof r.randomBytes=="function")return r.randomBytes(e)}catch{}throw new Error("bsv: no CSPRNG available in this environment (needs globalThis.crypto.getRandomValues or node crypto)")};Ki._fromGetRandomValues=function(e,t){for(var r=d.Buffer.alloc(t),n=0;n<t;n+=v_){var i=new Uint8Array(Math.min(v_,t-n));e.getRandomValues(i),d.Buffer.from(i).copy(r,n)}return r};Ki.getRandomBufferNode=function(e){var t=ea();return t.randomBytes(e)};Ki.getRandomBufferBrowser=function(e){var t=typeof globalThis<"u"?globalThis:{},r=null;if(t.crypto&&typeof t.crypto.getRandomValues=="function"?r=t.crypto:t.msCrypto&&typeof t.msCrypto.getRandomValues=="function"&&(r=t.msCrypto),!r)throw new Error("window.crypto.getRandomValues not available");return Ki._fromGetRandomValues(r,e)};b_.exports=Ki});var Ze=B((nU,__)=>{"use strict";p();var TN=ta(),$e={};$e.isArray=e=>Array.isArray(e);$e.isNumber=e=>typeof e=="number";$e.isObject=e=>e&&typeof e=="object";$e.isString=e=>typeof e=="string";$e.isUndefined=e=>typeof e>"u";$e.isFunction=e=>typeof e=="function";$e.isNull=e=>e===null;$e.isDate=e=>e instanceof Date;$e.extend=(e,t)=>Object.assign(e,t);$e.noop=()=>{};$e.every=(e,t)=>e.every(t||(r=>r));$e.map=(e,t)=>Array.from(e).map(t||(r=>r));$e.includes=(e,t)=>e.includes(t);$e.each=(e,t)=>e.forEach(t);$e.clone=e=>Object.assign({},e);$e.pick=(e,t)=>{let r={};return t.forEach(n=>{typeof e[n]<"u"&&(r[n]=e[n])}),r};$e.values=e=>Object.values(e);$e.filter=(e,t)=>e.filter(t);$e.reduce=(e,t,r)=>e.reduce(t,r);$e.without=(e,t)=>e.filter(r=>r!==t);$e.shuffle=e=>{let t=e.slice(0);for(let r=t.length-1;r>0;r--){let i=TN.getRandomBuffer(4).readUInt32BE(0)/4294967296,o=Math.floor(i*(r+1));[t[r],t[o]]=[t[o],t[r]]}return t};$e.difference=(e,t)=>e.filter(r=>!t.includes(r));$e.findIndex=(e,t)=>e.findIndex(t);$e.some=(e,t)=>e.some(t);$e.range=e=>[...Array(e).keys()];__.exports=$e});var w_=B((oU,S_)=>{"use strict";p();var PN="https://docs.moneybutton.com/";S_.exports=[{name:"InvalidB58Char",message:"Invalid Base58 character: {0} in {1}"},{name:"InvalidB58Checksum",message:"Invalid Base58 checksum for {0}"},{name:"InvalidNetwork",message:"Invalid version for network: got {0}"},{name:"InvalidState",message:"Invalid state: {0}"},{name:"NotImplemented",message:"Function {0} was not implemented yet"},{name:"InvalidNetworkArgument",message:'Invalid network: must be "livenet" or "testnet", got {0}'},{name:"InvalidArgument",message:function(){return"Invalid Argument"+(arguments[0]?": "+arguments[0]:"")+(arguments[1]?" Documentation: "+PN+arguments[1]:"")}},{name:"AbstractMethodInvoked",message:"Abstract Method Invocation: {0}"},{name:"InvalidArgumentType",message:function(){return"Invalid Argument for "+arguments[2]+", expected "+arguments[1]+" but got "+typeof arguments[0]}},{name:"Unit",message:"Internal Error on Unit {0}",errors:[{name:"UnknownCode",message:"Unrecognized unit code: {0}"},{name:"InvalidRate",message:"Invalid exchange rate: {0}"}]},{name:"MerkleBlock",message:"Internal Error on MerkleBlock {0}",errors:[{name:"InvalidMerkleTree",message:"This MerkleBlock contain an invalid Merkle Tree"}]},{name:"Transaction",message:"Internal Error on Transaction {0}",errors:[{name:"Input",message:"Internal Error on Input {0}",errors:[{name:"MissingScript",message:"Need a script to create an input"},{name:"UnsupportedScript",message:"Unsupported input script type: {0}"},{name:"MissingPreviousOutput",message:"No previous output information."}]},{name:"NeedMoreInfo",message:"{0}"},{name:"InvalidSorting",message:"The sorting function provided did not return the change output as one of the array elements"},{name:"InvalidOutputAmountSum",message:"{0}"},{name:"MissingSignatures",message:"Some inputs have not been fully signed"},{name:"InvalidIndex",message:"Invalid index: {0} is not between 0, {1}"},{name:"UnableToVerifySignature",message:"Unable to verify signature: {0}"},{name:"DustOutputs",message:"Dust amount detected in one output"},{name:"InvalidSatoshis",message:"Output satoshis are invalid"},{name:"FeeError",message:"Internal Error on Fee {0}",errors:[{name:"TooSmall",message:"Fee is too small: {0}"},{name:"TooLarge",message:"Fee is too large: {0}"},{name:"Different",message:"Unspent value is different from specified fee: {0}"}]},{name:"ChangeAddressMissing",message:"Change address is missing"},{name:"BlockHeightTooHigh",message:"Block Height can be at most 2^32 -1"},{name:"NLockTimeOutOfRange",message:"Block Height can only be between 0 and 499 999 999"},{name:"LockTimeTooEarly",message:"Lock Time can't be earlier than UNIX date 500 000 000"}]},{name:"Script",message:"Internal Error on Script {0}",errors:[{name:"UnrecognizedAddress",message:"Expected argument {0} to be an address"},{name:"CantDeriveAddress",message:"Can't derive address associated with script {0}, needs to be p2pkh in, p2pkh out, p2sh in, or p2sh out."},{name:"InvalidBuffer",message:"Invalid script buffer: can't parse valid script from given buffer {0}"}]},{name:"HDPrivateKey",message:"Internal Error on HDPrivateKey {0}",errors:[{name:"InvalidDerivationArgument",message:"Invalid derivation argument {0}, expected string, or number and boolean"},{name:"InvalidEntropyArgument",message:"Invalid entropy: must be an hexa string or binary buffer, got {0}",errors:[{name:"TooMuchEntropy",message:'Invalid entropy: more than 512 bits is non standard, got "{0}"'},{name:"NotEnoughEntropy",message:'Invalid entropy: at least 128 bits needed, got "{0}"'}]},{name:"InvalidLength",message:"Invalid length for xprivkey string in {0}"},{name:"InvalidPath",message:"Invalid derivation path: {0}"},{name:"UnrecognizedArgument",message:'Invalid argument: creating a HDPrivateKey requires a string, buffer, json or object, got "{0}"'}]},{name:"HDPublicKey",message:"Internal Error on HDPublicKey {0}",errors:[{name:"ArgumentIsPrivateExtended",message:"Argument is an extended private key: {0}"},{name:"InvalidDerivationArgument",message:"Invalid derivation argument: got {0}"},{name:"InvalidLength",message:'Invalid length for xpubkey: got "{0}"'},{name:"InvalidPath",message:'Invalid derivation path, it should look like: "m/1/100", got "{0}"'},{name:"InvalidIndexCantDeriveHardened",message:"Invalid argument: creating a hardened path requires an HDPrivateKey"},{name:"MustSupplyArgument",message:"Must supply an argument to create a HDPublicKey"},{name:"UnrecognizedArgument",message:"Invalid argument for creation, must be string, json, buffer, or object"}]}]});var Qn=B((aU,fd)=>{"use strict";p();var ud=Ze();function BN(e,t){return e.replace("{0}",t[0]).replace("{1}",t[1]).replace("{2}",t[2])}var E_=function(e,t){var r=function(){if(ud.isString(t.message))this.message=BN(t.message,arguments);else if(ud.isFunction(t.message))this.message=t.message.apply(null,arguments);else throw new Error("Invalid error definition for "+t.name);this.stack=this.message+`
12
- `+new Error().stack};return r.prototype=Object.create(e.prototype),r.prototype.name=e.prototype.name+t.name,e[t.name]=r,t.errors&&x_(r,t.errors),r},x_=function(e,t){ud.each(t,function(r){E_(e,r)})},NN=function(e,t){return x_(e,t),e},Fo={};Fo.Error=function(){this.message="Internal error",this.stack=this.message+`
13
- `+new Error().stack};Fo.Error.prototype=Object.create(Error.prototype);Fo.Error.prototype.name="bsv.Error";var MN=w_();NN(Fo.Error,MN);fd.exports=Fo.Error;fd.exports.extend=function(e){return E_(Fo.Error,e)}});var Fe=B((fU,I_)=>{"use strict";p();var ra=Qn(),kN=Ze();I_.exports={checkState:function(e,t){if(!e)throw new ra.InvalidState(t)},checkArgument:function(e,t,r,n){if(!e)throw new ra.InvalidArgument(t,r,n)},checkArgumentType:function(e,t,r){if(r=r||"(unknown name)",kN.isString(t)){if(t==="Buffer"){var n=Mt();if(!n.Buffer.isBuffer(e))throw new ra.InvalidArgumentType(e,t,r)}else if(typeof e!==t)throw new ra.InvalidArgumentType(e,t,r)}else if(!(e instanceof t))throw new ra.InvalidArgumentType(e,t.name,r)}}});var Er=B((lU,T_)=>{"use strict";p();var ke=L0(),O_=Fe(),R_=Ze(),wf=function(e){for(var t=d.Buffer.alloc(e.length),r=0;r<e.length;r++)t[r]=e[e.length-1-r];return t};ke.Zero=new ke(0);ke.One=new ke(1);ke.Minus1=new ke(-1);ke.fromNumber=function(e){return O_.checkArgument(R_.isNumber(e)),new ke(e)};ke.fromString=function(e,t){return O_.checkArgument(R_.isString(e)),new ke(e,t)};ke.fromBuffer=function(e,t){typeof t<"u"&&t.endian==="little"&&(e=wf(e));var r=e.toString("hex"),n=new ke(r,16);return n};ke.fromSM=function(e,t){var r;if(e.length===0)return ke.fromBuffer(d.Buffer.from([0]));var n="big";return t&&(n=t.endian),n==="little"&&(e=wf(e)),e[0]&128?(e[0]=e[0]&127,r=ke.fromBuffer(e),r.neg().copy(r)):r=ke.fromBuffer(e),r};ke.prototype.toNumber=function(){return parseInt(this.toString(10),10)};ke.prototype.toBuffer=function(e){var t,r;if(e&&e.size){r=this.toString(16,2);var n=r.length/2;t=d.Buffer.from(r,"hex"),n===e.size||(n>e.size?t=ke.trim(t,n):n<e.size&&(t=ke.pad(t,n,e.size)))}else r=this.toString(16,2),t=d.Buffer.from(r,"hex");return typeof e<"u"&&e.endian==="little"&&(t=wf(t)),t};ke.prototype.toSMBigEndian=function(){var e;return this.cmp(ke.Zero)===-1?(e=this.neg().toBuffer(),e[0]&128?e=d.Buffer.concat([d.Buffer.from([128]),e]):e[0]=e[0]|128):(e=this.toBuffer(),e[0]&128&&(e=d.Buffer.concat([d.Buffer.from([0]),e]))),e.length===1&&e[0]===0&&(e=d.Buffer.from([])),e};ke.prototype.toSM=function(e){var t=e?e.endian:"big",r=this.toSMBigEndian();return t==="little"&&(r=wf(r)),r};function A_(e,t){var r=new Error(e);return r.scriptErr=t,r}ke.fromScriptNumBuffer=function(e,t,r){var n=r||4;if(e.length>n)throw A_("script number overflow","SCRIPT_ERR_SCRIPTNUM_OVERFLOW");if(t&&e.length>0&&(e[e.length-1]&127)===0&&(e.length<=1||(e[e.length-2]&128)===0))throw A_("non-minimally encoded script number","SCRIPT_ERR_SCRIPTNUM_MINENCODE");return ke.fromSM(e,{endian:"little"})};ke.prototype.toScriptNumBuffer=function(){return this.toSM({endian:"little"})};ke.trim=function(e,t){return e.slice(t-e.length,e.length)};ke.pad=function(e,t,r){for(var n=d.Buffer.alloc(r),i=0;i<e.length;i++)n[n.length-1-i]=e[e.length-1-i];for(i=0;i<r-t;i++)n[i]=0;return n};ke.prototype.toHex=function(...e){return this.toBuffer(...e).toString("hex")};ke.fromHex=function(e,...t){return ke.fromBuffer(d.Buffer.from(e,"hex"),...t)};T_.exports=ke});function CN(e,t=!1){return t?{h:Number(e&Ef),l:Number(e>>P_&Ef)}:{h:Number(e>>P_&Ef)|0,l:Number(e&Ef)|0}}function B_(e,t=!1){let r=e.length,n=new Uint32Array(r),i=new Uint32Array(r);for(let o=0;o<r;o++){let{h:s,l:a}=CN(e[o],t);[n[o],i[o]]=[s,a]}return[n,i]}function N_(e,t,r,n){let i=LN(r),o=DN(r);e.setUint32(t,n?o:i,n),e.setUint32(t+4,n?i:o,n)}function rn(e,t,r,n){let i=(t>>>0)+(n>>>0);return{h:e+r+(i/2**32|0)|0,l:i|0}}var Ef,P_,LN,DN,cd,ld,Gi,Vi,na,ia,M_,k_,C_,L_,D_,U_,hd=Yt(()=>{p();Ef=BigInt(4294967295),P_=BigInt(32);LN=e=>e/2**32|0,DN=e=>e>>>0;cd=(e,t,r)=>e>>>r,ld=(e,t,r)=>e<<32-r|t>>>r,Gi=(e,t,r)=>e>>>r|t<<32-r,Vi=(e,t,r)=>e<<32-r|t>>>r,na=(e,t,r)=>e<<64-r|t>>>r-32,ia=(e,t,r)=>e>>>r-32|t<<64-r;M_=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0),k_=(e,t,r,n)=>t+r+n+(e/2**32|0)|0,C_=(e,t,r,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0),L_=(e,t,r,n,i)=>t+r+n+i+(e/2**32|0)|0,D_=(e,t,r,n,i)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0)+(i>>>0),U_=(e,t,r,n,i,o)=>t+r+n+i+o+(e/2**32|0)|0});function xf(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in e&&e.BYTES_PER_ELEMENT===1}function xn(e,t=""){if(typeof e!="number")throw new TypeError(dd(t)+"expected number, got "+typeof e);if(!Number.isSafeInteger(e)||e<0)throw new RangeError(dd(t)+"expected integer >= 0, got "+e);return e}function nn(e,t,r=""){if(xf(e)&&(t===void 0||e.length===t))return e;t!==void 0&&xn(t,"length");let n=xf(e),i=t!==void 0?` of length ${t}`:"",o=n?`length=${e.length}`:`type=${typeof e}`,s=dd(r)+"expected Uint8Array"+i+", got "+o;throw n?new RangeError(s):new TypeError(s)}function If(e){if(typeof e!="function"||typeof e.create!="function")throw new TypeError("expected hash wrapped by utils.createHasher");if(xn(e.outputLen),xn(e.blockLen),e.outputLen<1||e.blockLen<1)throw new Error("hash blockLen / outputLen must be >= 1")}function qo(e,t=!0){if(e.destroyed)throw new Error("hash was destroyed");if(t&&e.finished)throw new Error("digest() was already called")}function Af(e,t){nn(e,void 0,"output");let r=t.outputLen;if(!(e.length>=r))throw new RangeError('"output" expected length >= '+r)}function ur(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function Of(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function Mr(e,t){return e<<32-t|e>>>t}function In(e,t){return e<<t|e>>>32-t>>>0}function Rf(e){if(nn(e),H_)return e.toHex();let t="";for(let r=0;r<e.length;r++)t+=FN[e[r]];return t}function q_(e){return e>=48&&e<=57?e-48:e>=65&&e<=70?e-55:e>=97&&e<=102?e-87:void 0}function pd(e){if(typeof e!="string")throw new TypeError("hex string expected, got "+typeof e);if(H_)try{return Uint8Array.fromHex(e)}catch(i){throw i instanceof SyntaxError?new RangeError(i.message):i}let t=e.length,r=t/2;if(t%2)throw new RangeError("hex string expected, got unpadded hex of length "+t);let n=new Uint8Array(r);for(let i=0,o=0;i<r;i++,o+=2){let s=q_(e.charCodeAt(o)),a=q_(e.charCodeAt(o+1));if(s===void 0||a===void 0){let f=e[o]+e[o+1];throw new RangeError('hex string expected, got non-hex character "'+f+'" at index '+o)}n[i]=s*16+a}return n}function An(e){if(typeof e!="string")throw new TypeError("string expected");return new Uint8Array(new TextEncoder().encode(e))}function j_(...e){let t=0;for(let n=0;n<e.length;n++){let i=e[n];nn(i),t+=i.length}let r=new Uint8Array(t);for(let n=0,i=0;n<e.length;n++){let o=e[n];r.set(o,i),i+=o.length}return r}function qN(e,t,r="opts"){return F_(e,"defaults"),t!==void 0&&F_(t,r),Object.assign(e,t)}function kr(e,t={}){if(typeof e!="function")throw new TypeError('"hashCons" expected function, got type='+typeof e);t=qN({},t,"info");let r=(i,o)=>e(o).update(i).digest(),n=e(void 0);return r.outputLen=n.outputLen,r.blockLen=n.blockLen,r.canXOF=n.canXOF,r.create=i=>e(i),Object.assign(r,t),Object.freeze(r)}function oa(e=32){xn(e,"bytesLength");let t=typeof globalThis=="object"?globalThis.crypto:null;if(typeof t?.getRandomValues!="function")throw new Error("crypto.getRandomValues must be defined");if(e>65536)throw new RangeError(`"bytesLength" expected <= 65536, got ${e}`);return t.getRandomValues(new Uint8Array(e))}var dd,F_,H_,FN,Wi,On=Yt(()=>{p();dd=e=>e?`"${e}" `:"";F_=(e,t)=>{if(e===null||typeof e!="object"||Array.isArray(e))throw new TypeError((t==="object"?"":`"${t}" `)+"expected object, got type="+typeof e)};H_=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",FN=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));Wi=e=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])})});function Ho(e,t,r){return e&t^~e&r}function Tf(e,t,r){return e&t^e&r^t&r}var Rn,K_,G_,V_,W_,gd=Yt(()=>{p();hd();On();Rn=class{constructor(t,r,n,i){Z(this,"blockLen");Z(this,"outputLen");Z(this,"canXOF",!1);Z(this,"padOffset");Z(this,"isLE");Z(this,"buffer");Z(this,"view");Z(this,"finished",!1);Z(this,"length",0);Z(this,"pos",0);Z(this,"destroyed",!1);this.blockLen=t,this.outputLen=r,this.padOffset=n,this.isLE=i,this.buffer=new Uint8Array(t),this.view=Of(this.buffer)}update(t){qo(this),nn(t);let{view:r,buffer:n,blockLen:i}=this,o=t.length,s=!1;for(let a=0;a<o;){let f=Math.min(i-this.pos,o-a);if(f===i){let l=Of(t);for(;i<=o-a;a+=i)this.process(l,a);s=!0;continue}n.set(a===0&&f===o?t:t.subarray(a,a+f),this.pos),this.pos+=f,a+=f,this.pos===i&&(this.process(r,0),this.pos=0,s=!0)}return this.length+=t.length,s&&this.roundClean(),this}digestInto(t){qo(this),Af(t,this),this.finished=!0;let{buffer:r,view:n,blockLen:i,isLE:o}=this,{pos:s}=this;r[s++]=128,r.fill(0,s),this.padOffset>i-s&&(this.process(n,0),r.fill(0)),N_(n,i-8,this.length*8,o),this.process(n,0),this.roundClean();let a=t===r?n:Of(t),f=this.outputLen,l=f/4,y=this.get();if(f%4||l>y.length)throw new Error("invalid outputLen");for(let g=0;g<l;g++)a.setUint32(4*g,y[g],o)}digest(){let{buffer:t,outputLen:r}=this;this.digestInto(t);let n=t.slice(0,r);return this.destroy(),n}_cloneIntoMeta(t){let{buffer:r,length:n,finished:i,destroyed:o,pos:s}=this;return t.destroyed=o,t.finished=i,t.length=n,t.pos=s,s&&t.buffer.set(r),t}clone(){return this._cloneInto()}},K_=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),G_=Uint32Array.from([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]),V_=Uint32Array.from([3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]),W_=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209])});var Y_={};fl(Y_,{_SHA224:()=>Nf,_SHA256:()=>Bf,_SHA384:()=>kf,_SHA512:()=>Mf,_SHA512_224:()=>Cf,_SHA512_256:()=>Lf,sha224:()=>WN,sha256:()=>ni,sha384:()=>YN,sha512:()=>zN,sha512_224:()=>ZN,sha512_256:()=>$N});var HN,ei,Pf,Bf,Nf,z_,jN,KN,ti,ri,jo,Mf,kf,GN,VN,Cf,Lf,ni,WN,zN,YN,$N,ZN,yd=Yt(()=>{p();gd();hd();On();HN=Uint32Array.from([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]),ei=new Uint32Array(64),Pf=class extends Rn{constructor(r,n){super(64,r,8,!1);Z(this,"A",0);Z(this,"B",0);Z(this,"C",0);Z(this,"D",0);Z(this,"E",0);Z(this,"F",0);Z(this,"G",0);Z(this,"H",0);this.A=n[0]|0,this.B=n[1]|0,this.C=n[2]|0,this.D=n[3]|0,this.E=n[4]|0,this.F=n[5]|0,this.G=n[6]|0,this.H=n[7]|0}get(){let{A:r,B:n,C:i,D:o,E:s,F:a,G:f,H:l}=this;return[r,n,i,o,s,a,f,l]}set(r,n,i,o,s,a,f,l){this.A=r|0,this.B=n|0,this.C=i|0,this.D=o|0,this.E=s|0,this.F=a|0,this.G=f|0,this.H=l|0}_cloneInto(r){return(r||(r=new this.constructor)).set(...this.get()),this._cloneIntoMeta(r)}process(r,n){for(let v=0;v<16;v++,n+=4)ei[v]=r.getUint32(n,!1);for(let v=16;v<64;v++){let E=ei[v-15],T=ei[v-2],M=Mr(E,7)^Mr(E,18)^E>>>3,L=Mr(T,17)^Mr(T,19)^T>>>10;ei[v]=L+ei[v-7]+M+ei[v-16]|0}let{A:i,B:o,C:s,D:a,E:f,F:l,G:y,H:g}=this;for(let v=0;v<64;v++){let E=Mr(f,6)^Mr(f,11)^Mr(f,25),T=g+E+Ho(f,l,y)+HN[v]+ei[v]|0,L=(Mr(i,2)^Mr(i,13)^Mr(i,22))+Tf(i,o,s)|0;g=y,y=l,l=f,f=a+T|0,a=s,s=o,o=i,i=T+L|0}i=i+this.A|0,o=o+this.B|0,s=s+this.C|0,a=a+this.D|0,f=f+this.E|0,l=l+this.F|0,y=y+this.G|0,g=g+this.H|0,this.set(i,o,s,a,f,l,y,g)}roundClean(){ur(ei)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0,0,0,0),ur(this.buffer)}},Bf=class extends Pf{constructor(){super(32,K_)}},Nf=class extends Pf{constructor(){super(28,G_)}},z_=B_(["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(e=>BigInt(e))),jN=z_[0],KN=z_[1],ti=new Uint32Array(80),ri=new Uint32Array(80),jo=class extends Rn{constructor(r,n){super(128,r,16,!1);Z(this,"Ah",0);Z(this,"Al",0);Z(this,"Bh",0);Z(this,"Bl",0);Z(this,"Ch",0);Z(this,"Cl",0);Z(this,"Dh",0);Z(this,"Dl",0);Z(this,"Eh",0);Z(this,"El",0);Z(this,"Fh",0);Z(this,"Fl",0);Z(this,"Gh",0);Z(this,"Gl",0);Z(this,"Hh",0);Z(this,"Hl",0);this.Ah=n[0]|0,this.Al=n[1]|0,this.Bh=n[2]|0,this.Bl=n[3]|0,this.Ch=n[4]|0,this.Cl=n[5]|0,this.Dh=n[6]|0,this.Dl=n[7]|0,this.Eh=n[8]|0,this.El=n[9]|0,this.Fh=n[10]|0,this.Fl=n[11]|0,this.Gh=n[12]|0,this.Gl=n[13]|0,this.Hh=n[14]|0,this.Hl=n[15]|0}get(){let{Ah:r,Al:n,Bh:i,Bl:o,Ch:s,Cl:a,Dh:f,Dl:l,Eh:y,El:g,Fh:v,Fl:E,Gh:T,Gl:M,Hh:L,Hl:F}=this;return[r,n,i,o,s,a,f,l,y,g,v,E,T,M,L,F]}set(r,n,i,o,s,a,f,l,y,g,v,E,T,M,L,F){this.Ah=r|0,this.Al=n|0,this.Bh=i|0,this.Bl=o|0,this.Ch=s|0,this.Cl=a|0,this.Dh=f|0,this.Dl=l|0,this.Eh=y|0,this.El=g|0,this.Fh=v|0,this.Fl=E|0,this.Gh=T|0,this.Gl=M|0,this.Hh=L|0,this.Hl=F|0}_cloneInto(r){return(r||(r=new this.constructor)).set(...this.get()),this._cloneIntoMeta(r)}process(r,n){for(let G=0;G<16;G++,n+=4)ti[G]=r.getUint32(n),ri[G]=r.getUint32(n+=4);for(let G=16;G<80;G++){let ie=ti[G-15]|0,te=ri[G-15]|0,pe=Gi(ie,te,1)^Gi(ie,te,8)^cd(ie,te,7),fe=Vi(ie,te,1)^Vi(ie,te,8)^ld(ie,te,7),ye=ti[G-2]|0,I=ri[G-2]|0,u=Gi(ye,I,19)^na(ye,I,61)^cd(ye,I,6),h=Vi(ye,I,19)^ia(ye,I,61)^ld(ye,I,6),m=C_(fe,h,ri[G-7],ri[G-16]),S=L_(m,pe,u,ti[G-7],ti[G-16]);ti[G]=S|0,ri[G]=m|0}let{Ah:i,Al:o,Bh:s,Bl:a,Ch:f,Cl:l,Dh:y,Dl:g,Eh:v,El:E,Fh:T,Fl:M,Gh:L,Gl:F,Hh:V,Hl:z}=this;for(let G=0;G<80;G++){let ie=Gi(v,E,14)^Gi(v,E,18)^na(v,E,41),te=Vi(v,E,14)^Vi(v,E,18)^ia(v,E,41),pe=v&T^~v&L,fe=E&M^~E&F,ye=D_(z,te,fe,KN[G],ri[G]),I=U_(ye,V,ie,pe,jN[G],ti[G]),u=ye|0,h=Gi(i,o,28)^na(i,o,34)^na(i,o,39),m=Vi(i,o,28)^ia(i,o,34)^ia(i,o,39),S=i&s^i&f^s&f,w=o&a^o&l^a&l;V=L|0,z=F|0,L=T|0,F=M|0,T=v|0,M=E|0,{h:v,l:E}=rn(y|0,g|0,I|0,u|0),y=f|0,g=l|0,f=s|0,l=a|0,s=i|0,a=o|0;let R=M_(u,m,w);i=k_(R,I,h,S),o=R|0}({h:i,l:o}=rn(this.Ah|0,this.Al|0,i|0,o|0)),{h:s,l:a}=rn(this.Bh|0,this.Bl|0,s|0,a|0),{h:f,l}=rn(this.Ch|0,this.Cl|0,f|0,l|0),{h:y,l:g}=rn(this.Dh|0,this.Dl|0,y|0,g|0),{h:v,l:E}=rn(this.Eh|0,this.El|0,v|0,E|0),{h:T,l:M}=rn(this.Fh|0,this.Fl|0,T|0,M|0),{h:L,l:F}=rn(this.Gh|0,this.Gl|0,L|0,F|0),{h:V,l:z}=rn(this.Hh|0,this.Hl|0,V|0,z|0),this.set(i,o,s,a,f,l,y,g,v,E,T,M,L,F,V,z)}roundClean(){ur(ti,ri)}destroy(){this.destroyed=!0,ur(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}},Mf=class extends jo{constructor(){super(64,W_)}},kf=class extends jo{constructor(){super(48,V_)}},GN=Uint32Array.from([2352822216,424955298,1944164710,2312950998,502970286,855612546,1738396948,1479516111,258812777,2077511080,2011393907,79989058,1067287976,1780299464,286451373,2446758561]),VN=Uint32Array.from([573645204,4230739756,2673172387,3360449730,596883563,1867755857,2520282905,1497426621,2519219938,2827943907,3193839141,1401305490,721525244,746961066,246885852,2177182882]),Cf=class extends jo{constructor(){super(28,GN)}},Lf=class extends jo{constructor(){super(32,VN)}},ni=kr(()=>new Bf,Wi(1)),WN=kr(()=>new Nf,Wi(4)),zN=kr(()=>new Mf,Wi(3)),YN=kr(()=>new kf,Wi(2)),$N=kr(()=>new Lf,Wi(6)),ZN=kr(()=>new Cf,Wi(5))});function it(e,t,r=()=>{}){if(!Array.isArray(e))throw new TypeError(`"${t}" expected array, got type=${typeof e}`);for(let n=0;n<e.length;n++)r(e[n],`${t}[${n}]`);return e}function sa(e,t=""){if(typeof e!="string"){let r=t&&`"${t}" `;throw new TypeError(r+"expected string, got type="+typeof e)}return e}function ii(e,t="object"){if(e===null||typeof e!="object"||Array.isArray(e))throw new TypeError(t==="object"?"expected valid options object":`"${t}" expected object, got type=${typeof e}`);return e}function zi(e,t){if(typeof e!="function")throw new TypeError(`"${t}" is invalid: expected function, got ${typeof e}`);return e}function sn(e,t=""){if(typeof e!="boolean")throw new TypeError(XN(t)+"expected boolean, got type="+typeof e);return e}function Uf(e){if(typeof e=="bigint"){if(!oi(e))throw new RangeError("positive bigint expected, got "+e)}else md(e);return e}function ot(e,t=""){if(typeof e!="number"){let r=t&&`"${t}" `;throw new TypeError(r+"expected number, got type="+typeof e)}if(!Number.isSafeInteger(e)){let r=t&&`"${t}" `;throw new RangeError(r+"expected safe integer, got "+e)}}function aa(e){let t=Uf(e).toString(16);return t.length&1?"0"+t:t}function Z_(e){if(typeof e!="string")throw new TypeError("hex string expected, got "+typeof e);return e===""?Df:BigInt("0x"+e)}function kt(e){return Z_(Rf(e))}function Go(e){return Z_(Rf(qf(nn(e)).reverse()))}function Ff(e,t){if(xn(t),t===0)throw new Error("zero output length is invalid");e=Uf(e);let r=t*2,n=e.toString(16);if(n.length>r)throw new RangeError("number is too large");return pd(n.padStart(r,"0"))}function vd(e,t){return Ff(e,t).reverse()}function qf(e){return Uint8Array.from(Se(e))}function Vo(e){if(typeof e!="string")throw new TypeError("ascii string expected, got "+typeof e);return Uint8Array.from(e,(t,r)=>{let n=t.charCodeAt(0);if(t.length!==1||n>127)throw new RangeError(`string contains non-ASCII character "${e[r]}" with code ${n} at position ${r}`);return n})}function oi(e){return typeof e=="bigint"&&Df<=e}function bd(e,t,r){return oi(e)&&oi(t)&&oi(r)&&t<=e&&e<r}function _d(e,t,r,n){if(!bd(t,r,n))throw new RangeError("expected valid "+e+": "+r+" <= n < "+n+", got "+t)}function Wo(e){if(e<Df)throw new Error("expected non-negative bigint, got "+e);return e===Df?0:e.toString(2).length}function X_(e,t,r){if(xn(e,"hashLen"),xn(t,"qByteLen"),typeof r!="function")throw new TypeError("hmacFn must be a function");let n=L=>new Uint8Array(L),i=Uint8Array.of(),o=Uint8Array.of(0),s=Uint8Array.of(1),a=1e3,f=n(e),l=n(e),y=0,g=()=>{f.fill(1),l.fill(0),y=0},v=(...L)=>r(l,De(f,...L)),E=(L=i)=>{l=v(o,L),f=v(),L.length!==0&&(l=v(s,L),f=v())},T=()=>{if(y++>=a)throw new Error("drbg: tried max amount of iterations");let L=0,F=[];for(;L<t;){f=v();let V=f.slice();F.push(V),L+=f.length}return De(...F)};return(L,F)=>{g(),E(L);let V;for(;(V=F(T()))===void 0;)E();return g(),V}}function Ge(e,t={},r={},n="object"){ii(e,n),ii(t,"fields"),ii(r,"optFields");function i(s,a,f){let l=n==="object"?`param "${String(s)}"`:`"${n}.${String(s)}"`,y=e[s];if(!Object.hasOwn(e,s)&&(f?y!==void 0:a!=="function"))throw new TypeError(`${l} is invalid: expected own property`);if(f&&y===void 0)return;let g=typeof y;if(g!==a||y===null)throw new TypeError(`${l} is invalid: expected ${a}, got ${g}`)}let o=(s,a)=>Object.entries(s).forEach(([f,l])=>i(f,l,a));o(t,!1),o(r,!0)}var Se,md,Tn,De,Ko,on,tr,Df,$_,XN,ua,si=Yt(()=>{p();On();Se=(e,t,r)=>nn(e,t,r),md=xn;Tn=Rf,De=(...e)=>j_(...e),Ko=e=>pd(e),on=xf,tr=e=>oa(e),Df=BigInt(0),$_=BigInt(1),XN=e=>e?`"${e}" `:"";ua=e=>(ot(e,"n"),($_<<BigInt(e))-$_)});function rr(e,t){if(t<=Ct)throw new Error("mod: expected positive modulus, got "+t);let r=e%t;return r>=Ct?r:t+r}function iS(e,t,r){if(r<=He)throw new Error("pow: expected modulus > 1, got "+r);if(typeof t!="bigint")throw new TypeError("invalid exponent: expected bigint, got "+typeof t);if(t<Ct)throw new Error("invalid exponent, negatives unsupported");if(t===Ct)return He;if(t===He)return e;let n=e%r;if(n<Ct&&(n+=r),t<tM){let a=He;for(;t>Ct;)t&He&&(a=a*n%r),n=n*n%r,t>>=He;return a}let i=[];for(;t>Ct;)i.push(Number(t&eM)),t>>=wd;let o=new Array(16);o[0]=He,o[1]=n;for(let a=2;a<16;a++)o[a]=o[a-1]*n%r;let s=o[i[i.length-1]];for(let a=i.length-2;a>=0;a--){s=s*s%r,s=s*s%r,s=s*s%r,s=s*s%r;let f=i[a];f!==0&&(s=s*o[f]%r)}return s}function pr(e,t,r){if(r<=He)throw new Error("pow2: expected modulus > 1, got "+r);if(t<Ct)throw new Error("pow2: expected non-negative exponent, got "+t);let n=e;for(;t-- >Ct;)n*=n,n%=r;return n}function J_(e,t){if(e===Ct)throw new Error("invert: expected non-zero number");if(t<=He)throw new Error("invert: expected modulus > 1, got "+t);let r=rr(e,t),n=t,i=Ct,o=He;for(;r!==Ct;){let a=n/r,f=n-r*a,l=i-o*a;n=r,r=f,i=o,o=l}if(n!==He)throw new Error("invert: does not exist");return rr(i,t)}function oS(e,t){if(t<=He)throw new Error("invertCt: expected prime modulus > 1, got "+t);let r=rr(e,t);if(r===Ct)throw new Error("invertCt: expected non-zero number");let n=iS(r,t-ai,t);if(rr(r*n,t)!==He)throw new Error("invertCt: does not exist");return n}function Ed(e,t,r){let n=e;if(!n.eql(n.sqr(t),r))throw new Error("Cannot find square root")}function xd(e,t){if((e&He)===Ct)throw new Error(t+": expected odd modulus, got "+e)}function sS(e,t){let r=e,n=(r.ORDER+He)/wd,i=r.pow(t,n);return Ed(r,i,t),i}function rM(e,t){let r=e,n=(r.ORDER-tS)/rS,i=r.mul(t,ai),o=r.pow(i,n),s=r.mul(t,o),a=r.mul(r.mul(s,ai),o),f=r.mul(s,r.sub(a,r.ONE));return Ed(r,f,t),f}function nM(e){let t=Yo(e),r=aS(e),n=r(t,t.neg(t.ONE)),i=r(t,n),o=r(t,t.neg(n)),s=(e+JN)/nS;return((a,f)=>{let l=a,y=l.pow(f,s),g=l.mul(y,n),v=l.mul(y,i),E=l.mul(y,o),T=l.eql(l.sqr(g),f),M=l.eql(l.sqr(v),f);y=l.cmov(y,g,T),g=l.cmov(E,v,M);let L=l.eql(l.sqr(g),f),F=l.cmov(y,g,L);return Ed(l,F,f),F})}function aS(e){if(e<eS)throw new Error("sqrt is not defined for small field");xd(e,"tonelliShanks");let t=e-He,r=0;for(;t%ai===Ct;)t/=ai,r++;let n=ai,i=Yo(e);for(;Sd(i,n)===1;)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(r===1)return sS;let o=i.pow(n,t),s=(t+He)/ai;return function(f,l){let y=f;if(y.is0(l))return l;if(Sd(y,l)!==1)throw new Error("Cannot find square root");let g=r,v=y.mul(y.ONE,o),E=y.pow(l,t),T=y.pow(l,s);for(;!y.eql(E,y.ONE);){if(y.is0(E))throw new Error("Cannot find square root: probably non-prime P");let M=1,L=y.sqr(E);for(;!y.eql(L,y.ONE);)if(M++,L=y.sqr(L),M===g)throw new Error("Cannot find square root");let F=He<<BigInt(g-M-1),V=y.pow(v,F);g=M,v=y.sqr(V),E=y.mul(E,v),T=y.mul(T,V)}return T}}function iM(e){return xd(e,"Fp.sqrt"),e%wd===eS?sS:e%rS===tS?rM:e%nS===QN?nM(e):aS(e)}function xr(e){if(ii(e,"field"),typeof e.ORDER!="bigint")throw new TypeError('param "ORDER" is invalid: expected bigint, got '+typeof e.ORDER);ot(e.BYTES,"BYTES"),ot(e.BITS,"BITS");for(let t of oM)zi(e[t],"field."+t);if(e.BYTES<1||e.BITS<1)throw new Error("invalid field: expected BYTES/BITS > 0");if(e.ORDER<=He)throw new Error("invalid field: expected ORDER > 1, got "+e.ORDER);return e}function zo(e,t,r=!1){xr(e),it(t,"nums"),sn(r,"passZero");let n=e,i=new Array(t.length).fill(r?n.ZERO:void 0),o=t.reduce((a,f,l)=>n.is0(f)?a:(i[l]=a,n.mul(a,f)),n.ONE),s=n.inv(o);return t.reduceRight((a,f,l)=>n.is0(f)?a:(i[l]=n.mul(a,i[l]),n.mul(a,f)),s),i}function Sd(e,t){xr(e);let r=e;xd(r.ORDER,"FpLegendre");let n=(r.ORDER-He)/ai,i=r.pow(t,n),o=r.eql(i,r.ONE),s=r.eql(i,r.ZERO),a=r.eql(i,r.neg(r.ONE));if(!o&&!s&&!a)throw new Error("invalid Legendre symbol result");return o?1:s?0:-1}function Id(e,t){return Sd(e,t)!==-1}function sM(e,t){if(t!==void 0&&md(t),e<=Ct)throw new Error("invalid n length: expected positive n, got "+e);if(t!==void 0&&t<1)throw new Error("invalid n length: expected positive bit length, got "+t);let r=Wo(e);if(t!==void 0&&t<r)throw new Error(`invalid n length: expected nBitLength (${t}) >= bitLen(n) (${r})`);let n=t!==void 0?t:r,i=Math.ceil(n/8);return{nBitLength:n,nByteLength:i}}function Yo(e,t={}){return Object.freeze(Hf.prototype),new Hf(e,t)}function uS(e){if(typeof e!="bigint")throw new Error("field order must be bigint");if(e<=He)throw new Error("field order must be greater than 1");let t=Wo(e-He);return Math.ceil(t/8)}function $o(e){let t=uS(e);return t+Math.ceil(t/2)}function Yi(e,t,r=!1){Se(e);let n=e.length,i=uS(t),o=Math.max($o(t),16);if(n<o||n>1024)throw new Error("expected "+o+"-1024 bytes of input, got "+n);let s=r?Go(e):kt(e),a=rr(s,t-He)+He;return r?vd(a,i):Ff(a,i)}var Ct,He,ai,eS,wd,tS,JN,rS,QN,eM,nS,tM,oM,Q_,Hf,$i=Yt(()=>{p();si();Ct=BigInt(0),He=BigInt(1),ai=BigInt(2),eS=BigInt(3),wd=BigInt(4),tS=BigInt(5),JN=BigInt(7),rS=BigInt(8),QN=BigInt(9),eM=BigInt(15),nS=BigInt(16),tM=BigInt("0x10000000000000000");oM=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];Q_=new WeakMap,Hf=class{constructor(t,r={}){Z(this,"ORDER");Z(this,"BITS");Z(this,"BYTES");Z(this,"isLE");Z(this,"ZERO",Ct);Z(this,"ONE",He);Z(this,"_lengths");Z(this,"_mod");if(t<=He)throw new Error("invalid field: expected ORDER > 1, got "+t);let n;this.isLE=!1,r!=null&&typeof r=="object"&&(typeof r.BITS=="number"&&(n=r.BITS),typeof r.sqrt=="function"&&Object.defineProperty(this,"sqrt",{value:r.sqrt,enumerable:!0}),typeof r.isLE=="boolean"&&(this.isLE=r.isLE),r.allowedLengths&&(this._lengths=Object.freeze(r.allowedLengths.slice())),typeof r.modFromBytes=="boolean"&&(this._mod=r.modFromBytes));let{nBitLength:i,nByteLength:o}=sM(t,n);if(o>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");this.ORDER=t,this.BITS=i,this.BYTES=o,Object.freeze(this)}create(t){return rr(t,this.ORDER)}isValid(t){if(typeof t!="bigint")throw new TypeError("invalid field element: expected bigint, got "+typeof t);return Ct<=t&&t<this.ORDER}is0(t){return t===Ct}isValidNot0(t){return!this.is0(t)&&this.isValid(t)}isOdd(t){return(t&He)===He}neg(t){return rr(-t,this.ORDER)}eql(t,r){return t===r}sqr(t){return rr(t*t,this.ORDER)}add(t,r){return rr(t+r,this.ORDER)}sub(t,r){return rr(t-r,this.ORDER)}mul(t,r){return rr(t*r,this.ORDER)}pow(t,r){return iS(t,r,this.ORDER)}div(t,r){return rr(t*J_(r,this.ORDER),this.ORDER)}sqrN(t){return t*t}addN(t,r){return t+r}subN(t,r){return t-r}mulN(t,r){return t*r}inv(t){return J_(t,this.ORDER)}sqrt(t){let r=Q_.get(this);return r||Q_.set(this,r=iM(this.ORDER)),r(this,t)}toBytes(t){return this.isLE?vd(t,this.BYTES):Ff(t,this.BYTES)}fromBytes(t,r=!1){Se(t);let{_lengths:n,BYTES:i,isLE:o,ORDER:s,_mod:a}=this;if(n){if(t.length<1||!n.includes(t.length)||t.length>i)throw new Error("Field.fromBytes: expected "+n+" bytes, got "+t.length);let l=new Uint8Array(i);l.set(t,o?0:l.length-t.length),t=l}if(t.length!==i)throw new Error("Field.fromBytes: expected "+i+" bytes, got "+t.length);let f=o?Go(t):kt(t);if(a&&(f=rr(f,s)),!r&&!this.isValid(f))throw new Error("invalid field element: outside of range 0..ORDER");return f}invertBatch(t){return zo(this,t,!0)}cmov(t,r,n){return sn(n,"condition"),n?r:t}}});function ui(e){let t=e;if(typeof t!="function")throw new TypeError('"Point" expected constructor, got type='+typeof e);zi(t.fromAffine,"Point.fromAffine"),zi(t.fromBytes,"Point.fromBytes"),zi(t.fromHex,"Point.fromHex"),ii(t.BASE,"Point.BASE"),ii(t.ZERO,"Point.ZERO"),xr(t.Fp),xr(t.Fn)}function hS(e,t){ui(e),dS(t,e);let r=zo(e.Fp,t.map(n=>n.Z));return t.map((n,i)=>e.fromAffine(n.toAffine(r[i])))}function fM(e,t,r=1){if(!Number.isSafeInteger(e)||e<r||e>t)throw new Error("invalid window size, expected ["+r+".."+t+"], got W="+e)}function cM(e,t){let r=e*(4*t+128);if(r>cS)throw new Error("invalid window size: table would need ~"+Math.ceil(r/2**20)+" MiB, max "+cS/2**20+" MiB")}function Td(e,t){if(e!==void 0){zi(e,"randomBytes");try{let r=e(t);if(!on(r)||r.length!==t)return}catch{return}return e}}function dS(e,t){it(e,"points"),e.forEach((r,n)=>{if(!(r instanceof t))throw new Error("invalid point at index "+n)})}function lM(e,t,r){if(!Array.isArray(e))throw new Error("array of scalars expected");e.forEach((n,i)=>{if(!(r===void 0?t.isValid(n):oi(n)&&n<r))throw new Error("invalid scalar at index "+i)})}function Od(e){return pS.get(e)||1}function hM(e,t){let r=e.double(),n=[e];for(let i=1;i<t;i++)n.push(n[i-1].add(r));return n}function dM(e,t){let r=2**t,n=r/2,i=BigInt(r-1),o=[];for(;e>Rd;){let s=0;e&fa&&(s=Number(e&i),s>=n&&(s-=r),e-=BigInt(s)),o.push(s),e>>=fa}return o}function pM(e,t,r){let n=2**t,i=n/2,o=BigInt(n-1),s=BigInt(t),a=[];for(let f=0;f<r;f++){let l=Number(e&o);e>>=s,l>i&&(l-=n,e+=fa),a.push(l)}if(e!==Rd)throw new Error("invalid wnaf");return a}function gM(e,t,r){let n=0;for(let o of r)n=Math.max(n,o.length);let i=e;for(let o=n-1;o>=0;o--){o!==n-1&&(i=i.double());for(let s=0;s<r.length;s++){let a=r[s][o];if(a){let f=t[s][Math.abs(a)-1>>1];i=i.add(a<0?f.negate():f)}}}return i}function Zo(e,t,r,n=!1){if(ui(e),dS(t,e),sn(n,"allowOversized"),lM(r,e.Fn,n?e.Fn.ORDER**aM:void 0),t.length!==r.length)throw new Error("arrays of points and scalars must have equal length");let i=t.map(s=>hM(s,4)),o=r.map(s=>dM(s,4));return gM(e.ZERO,i,o)}function lS(e,t,r){if(t){if(t.ORDER!==e)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return xr(t),t}else return Yo(e,{isLE:r})}function gS(e,t,r={},n){if(e!=="weierstrass"&&e!=="edwards")throw new Error('expected curve type "weierstrass" or "edwards"');if(n===void 0&&(n=e==="edwards"),!t||typeof t!="object")throw new Error(`expected valid ${e} CURVE object`);Ge(r);for(let f of["p","n","h"]){let l=t[f];if(!(oi(l)&&l!==Rd))throw new Error(`CURVE.${f} must be positive bigint`)}let i=lS(t.p,r.Fp,n),o=lS(t.n,r.Fn,n),a=["Gx","Gy","a",e==="weierstrass"?"b":"d"];for(let f of a)if(!i.isValid(t[f]))throw new Error(`CURVE.${f} must be valid field element of CURVE.Fp`);return t=Object.freeze(Object.assign({},t)),{CURVE:t,Fp:i,Fn:o}}function Kf(e,t){return function(n){let i=e(n);return{secretKey:i,publicKey:t(i)}}}var Rd,fa,aM,Ad,fS,uM,cS,pS,jf,Gf=Yt(()=>{p();si();$i();Rd=BigInt(0),fa=BigInt(1),aM=BigInt(4),Ad=16,fS=128,uM=5,cS=2**31;pS=new WeakMap;jf=class{constructor(t,r){Z(this,"Point");Z(this,"BASE");Z(this,"ZERO");Z(this,"randomBytes");Z(this,"wnafPrecomputes",new WeakMap);Z(this,"baseCanBeBlinded");Z(this,"bits");ui(t),this.randomBytes=Td(r,Ad),this.Point=t,this.BASE=t.BASE,this.ZERO=t.ZERO,this.bits=t.Fn.BITS}buildWnafTable(t,r,n){let i=Math.ceil(n/r)+1,o=2**(r-1),s=[],a=t;for(let f=0;f<i;f++){let l=a;for(let y=0;y<o;y++)s.push(l),l=l.add(a);a=s[s.length-1].double()}return{W:r,bits:n,windows:i,comp:s}}wnafCachedCT(t,r){let{W:n,windows:i,comp:o}=t,s=2**(n-1),a=pM(r,n,i),f=this.ZERO,l=this.BASE;for(let y=0;y<i;y++){let g=a[y],v=y*s,E=Math.abs(g)-1,T=o[v];for(let L=1;L<s;L++)T=L===E?o[v+L]:T;let M=T.negate();g===0?l=l.add(o[v]):f=f.add(g<0?M:T)}return{p:f,f:l}}getWnafPrecomputes(t,r,n,i){let o=this.wnafPrecomputes.get(r),s=o?.find(a=>a.W===t&&a.bits===n);return s||(s=this.buildWnafTable(r,t,n),typeof i=="function"&&(s={...s,comp:i(s.comp)}),o||(o=[],this.wnafPrecomputes.set(r,o)),o.push(s)),s}assertPoint(t){if(!(t instanceof this.Point))throw new TypeError('"point" expected Point instance, got type='+typeof t)}validateMulInput(t,r){if(this.assertPoint(t),!bd(r,fa,this.Point.Fn.ORDER))throw new Error("invalid scalar")}runCT(t,r,n,i){let o=Od(t);return o===1?this.fixedWindowCT(t,r,n):this.wnafCachedCT(this.getWnafPrecomputes(o,t,n,i),r)}mulCT(t,r,n){return this.validateMulInput(t,r),this.runCT(t,r,this.bits,n)}mulCTBlinded(t,r,n){if(this.validateMulInput(t,r),this.randomBytes===void 0)throw new Error("randomBytes is required for scalar blinding");let i=this.Point.Fn.BITS+fS,o=this.randomBytes(Ad);if(!on(o)||o.length!==Ad)throw new Error("randomBytes returned invalid byte array");o[0]=o[0]&63|128;let s=r+kt(o)*this.Point.Fn.ORDER;return this.runCT(t,s,i,n)}fixedWindowCT(t,r,n){let i=uM,o=1<<i,s=ua(i),a=new Array(o);a[0]=this.ZERO;for(let y=1;y<o;y++)a[y]=a[y-1].add(t);let f=Math.ceil(n/i),l=this.ZERO;for(let y=f-1;y>=0;y--){if(y!==f-1)for(let E=0;E<i;E++)l=l.double();let g=Number(r>>BigInt(y*i)&s),v=a[0];for(let E=1;E<o;E++)v=E===g?a[E]:v;l=l.add(v)}return{p:l,f:l}}shouldBlind(t,r){return this.randomBytes===void 0?!1:r===fa?!0:t!==this.BASE?!1:(this.baseCanBeBlinded===void 0&&(this.baseCanBeBlinded=this.mulUnsafe(this.BASE,this.Point.Fn.ORDER).is0()),this.baseCanBeBlinded)}mulSecret(t,r,n,i){return this.shouldBlind(t,n)?this.mulCTBlinded(t,r,i):this.mulCT(t,r,i)}mulUnsafe(t,r,n){if(this.assertPoint(t),!oi(r))throw new Error("invalid scalar");let i=Od(t);if(i===1||r>=this.Point.Fn.ORDER)return Zo(this.Point,[t],[r],!0);let o=this.getWnafPrecomputes(i,t,this.bits,n);return this.wnafCachedCT(o,r).p}setWindowSize(t,r){this.assertPoint(t),fM(r,this.bits);let n=Math.ceil((this.bits+fS)/r)+1;cM(n*2**(r-1),this.Point.Fp.BYTES),pS.set(t,r),this.wnafPrecomputes.delete(t)}hasWindowSize(t){return Od(t)!==1}}});function Pd(e,t="n"){if(typeof e!="number")throw new TypeError(`wrong u32 integer "${t}": expected number, got type=${typeof e}`);if(!Number.isSafeInteger(e)||e<0||e>4294967295)throw new RangeError(`wrong u32 integer "${t}": expected 0..4294967295, got ${e}`);return e}function yS(e){return Pd(e,"x"),(e&e-1)===0&&e!==0}function yM(e){if(Pd(e),e<=1)return 1;if(e>2147483648)throw new Error("nextPowerOfTwo overflow: result does not fit u32");return 1<<Vf(e-1)+1>>>0}function Vf(e){return Pd(e),31-Math.clz32(e)}function mS(e,t,r,n,i){xr(e);let o=e,s=r||((g,v)=>new Array(g).fill(v??o.ZERO)),a=g=>{if(Array.isArray(g))return!0;if(!ArrayBuffer.isView(g))return!1;let v=g;return typeof v.length=="number"&&typeof v.slice=="function"&&typeof v[Symbol.iterator]=="function"},f=(g,v)=>{if(!a(v))throw new TypeError(`"${g}" expected polynomial, got type=${typeof v}`)},l=(g,v)=>{f("a",g);let E=g.length;if(v!==void 0&&(f("b",v),v.length!==E))throw new Error(`poly: mismatched lengths ${E} vs ${v.length}`);if(i!==void 0&&E!==i)throw new Error(`poly: expected fixed length ${i}, got ${E}`);return E};function y(g,v,E=!1,T){if(!yS(v))throw new Error("poly.lagrange: expected power of two length, got "+v);let M=T||(E?t.brp(Vf(v)):t.roots(Vf(v)));for(let L=0;L<v;L++)if(o.eql(g,M[L]))return L;return-1}return{roots:t,create:s,length:i,extend:(g,v)=>{l(g);let E=s(v,o.ZERO);for(let T=0;T<Math.min(g.length,v);T++)E[T]=g[T];return E},degree:g=>{l(g);for(let v=g.length-1;v>=0;v--)if(!o.is0(g[v]))return v;return-1},add:(g,v)=>{let E=l(g,v),T=s(E);for(let M=0;M<E;M++)T[M]=o.add(g[M],v[M]);return T},sub:(g,v)=>{let E=l(g,v),T=s(E);for(let M=0;M<E;M++)T[M]=o.sub(g[M],v[M]);return T},dot:(g,v)=>{let E=l(g,v),T=s(E);for(let M=0;M<E;M++)T[M]=o.mul(g[M],v[M]);return T},mul:(g,v)=>{if(a(v)){let E=l(g,v);if(n){let T=n.direct(g,!1,!0),M=n.direct(v,!1,!0);for(let L=0;L<T.length;L++)T[L]=o.mul(T[L],M[L]);return n.inverse(T,!0,!1)}else{let T=s(E);for(let M=0;M<E;M++)for(let L=0;L<E;L++){let F=(M+L)%E;T[F]=o.add(T[F],o.mul(g[M],v[L]))}return T}}else{let E=s(l(g));for(let T=0;T<E.length;T++)E[T]=o.mul(g[T],v);return E}},convolve(g,v){f("a",g),f("b",v);let E=yM(g.length+v.length-1);return this.mul(this.extend(g,E),this.extend(v,E))},shift(g,v){f("p",g);let E=s(g.length);if(i!==void 0&&g.length!==i)throw new Error(`poly: expected fixed length ${i}, got ${g.length}`);if(!g.length)return E;E[0]=g[0];for(let T=1,M=o.ONE;T<g.length;T++)M=o.mul(M,v),E[T]=o.mul(g[T],M);return E},clone:g=>{l(g);let v=s(g.length);for(let E=0;E<g.length;E++)v[E]=g[E];return v},eval:(g,v)=>{l(g,v);let E=o.ZERO;for(let T=0;T<g.length;T++)E=o.add(E,o.mul(g[T],v[T]));return E},monomial:{basis:(g,v)=>{let E=s(v),T=o.ONE;for(let M=0;M<v;M++)E[M]=T,T=o.mul(T,g);return E},eval:(g,v)=>{l(g);let E=o.ZERO;for(let T=g.length-1;T>=0;T--)E=o.add(o.mul(E,v),g[T]);return E}},lagrange:{basis:(g,v,E=!1,T)=>{if(!yS(v))throw new Error("poly.lagrange: expected power of two length, got "+v);let M=Vf(v),L=T||(E?t.brp(M):t.roots(M)),F=s(v),V=y(g,v,E,T);if(V!==-1)return F[V]=o.ONE,F;let z=o.pow(g,BigInt(v)),G=o.mul(o.sub(z,o.ONE),o.inv(BigInt(v))),ie=s(v);for(let pe=0;pe<v;pe++)ie[pe]=o.sub(g,L[pe]);let te=o.invertBatch(ie);for(let pe=0;pe<v;pe++)F[pe]=o.mul(G,o.mul(L[pe],te[pe]));return F},eval(g,v,E=!1){l(g);let T=y(v,g.length,E);if(T!==-1)return g[T];let M=this.basis(v,g.length,E),L=o.ZERO;for(let F=0;F<g.length;F++)o.is0(g[F])||(L=o.add(L,o.mul(g[F],M[F])));return L}},vanishing(g){if(f("roots",g),i!==void 0&&g.length!==i)throw new Error(`poly: expected fixed length ${i}, got ${g.length}`);let v=s(g.length+1,o.ZERO);v[0]=o.ONE;for(let E of g){let T=o.neg(E);for(let M=v.length-1;M>0;M--)v[M]=o.add(o.mul(v[M],T),v[M-1]);v[0]=o.mul(v[0],T)}return v}}}var vS=Yt(()=>{p();$i()});function Zi(e,t){if(ot(e),ot(t),t<0||t>4)throw new Error("invalid I2OSP length: "+t);if(e<0||e>2**(8*t)-1)throw new Error("invalid I2OSP input: "+e);let r=Array.from({length:t}).fill(0);for(let n=t-1;n>=0;n--)r[n]=e&255,e>>>=8;return new Uint8Array(r)}function vM(e,t){let r=new Uint8Array(e.length);for(let n=0;n<e.length;n++)r[n]=e[n]^t[n];return r}function wS(e){if(!on(e)&&typeof e!="string")throw new Error("DST must be Uint8Array or ascii string");let t=typeof e=="string"?Vo(e):e;if(t.length===0)throw new Error("DST must be non-empty");return t}function bM(e,t,r,n){if(Se(e),ot(r),typeof n!="function")throw new Error("expand_message_xmd: expected hash function");ot(n.outputLen,"hash.outputLen"),ot(n.blockLen,"hash.blockLen"),t=wS(t),t.length>255&&(t=n(De(Vo("H2C-OVERSIZE-DST-"),t)));let{outputLen:i,blockLen:o}=n,s=Math.ceil(r/i);if(r>65535||s>255)throw new Error("expand_message_xmd: invalid lenInBytes");let a=De(t,Zi(t.length,1)),f=new Uint8Array(o),l=Zi(r,2),y=new Array(s),g=n(De(f,e,l,Zi(0,1),a));y[0]=n(De(g,Zi(1,1),a));for(let E=1;E<s;E++){let T=[vM(g,y[E-1]),Zi(E+1,1),a];y[E]=n(De(...T))}return De(...y).slice(0,r)}function _M(e,t,r,n,i){if(Se(e),ot(r),ot(n,"k"),n<0)throw new Error("expand_message_xof: invalid k");if(typeof i!="function")throw new Error("expand_message_xof: expected XOF function");if(typeof i.create!="function")throw new Error("expand_message_xof: expected XOF create");if(t=wS(t),r<0||r>65535)throw new Error("expand_message_xof: invalid lenInBytes");if(t.length>255){let o=Math.ceil(2*n/8);t=i.create({dkLen:o}).update(Vo("H2C-OVERSIZE-DST-")).update(t).digest()}if(t.length>255)throw new Error("expand_message_xof: invalid DST");return i.create({dkLen:r}).update(e).update(Zi(r,2)).update(t).update(Zi(t.length,1)).digest()}function Bd(e,t,r){Ge(r,{p:"bigint",m:"number",k:"number",hash:"function"});let{p:n,k:i,m:o,hash:s,expand:a,DST:f}=r;if(ot(s.outputLen,"valid hash"),Se(e),ot(t),ot(o,"m"),ot(i,"k"),n<=BigInt(1))throw new Error("hash_to_field: expected valid field characteristic");if(t<1)throw new Error("hash_to_field: expected count >= 1");if(o<1)throw new Error("hash_to_field: expected m >= 1");if(i<0)throw new Error("hash_to_field: invalid k");let l=n.toString(2).length,y=Math.ceil((l+i)/8),g=t*o*y,v;if(a==="xmd")v=bM(e,f,g,s);else if(a==="xof")v=_M(e,f,g,i,s);else if(a==="_internal_pass")v=e;else throw new Error('expand must be "xmd" or "xof"');let E=new Array(t);for(let T=0;T<t;T++){let M=new Array(o);for(let L=0;L<o;L++){let F=y*(L+T*o),V=v.subarray(F,F+y);M[L]=rr(mM(V),n)}E[T]=M}return E}function ES(e,t){xr(e),it(t,"map");let r=t.map((n,i)=>{if(it(n,"map["+i+"]"),n.length<1)throw new Error("isogenyMap: expected non-empty coefficients");return Array.from(n).reverse()});return(n,i)=>{let[o,s,a,f]=r.map(v=>v.reduce((E,T)=>e.add(e.mul(E,n),T))),l=e.is0(s)||e.is0(f),[y,g]=zo(e,[s,f],!0);return n=e.mul(o,y),i=e.mul(i,e.mul(a,g)),l?{x:e.ZERO,y:e.ZERO}:{x:n,y:i}}}function xS(e,t,r){if(typeof t!="function")throw new Error("mapToCurve() must be defined");Ge(r);let n=f=>Object.freeze({...f,DST:on(f.DST)?qf(f.DST):f.DST,...f.encodeDST===void 0?{}:{encodeDST:on(f.encodeDST)?qf(f.encodeDST):f.encodeDST}}),i=n(r),o=f=>f&&f.DST!==void 0?{DST:f.DST}:void 0;function s(f){return e.fromAffine(t(f))}function a(f){let l=f.clearCofactor();return l.equals(e.ZERO)?e.ZERO:(l.assertValidity(),l)}return Object.freeze({get defaults(){return n(i)},Point:e,hashToCurve(f,l){let y=Object.assign({},i,o(l)),g=Bd(f,2,y),v=s(g[0]),E=s(g[1]);return a(v.add(E))},encodeToCurve(f,l){let y=i.encodeDST===void 0?{}:{DST:i.encodeDST},g=Object.assign({},i,y,o(l)),v=Bd(f,1,g),E=s(v[0]);return a(E)},mapToCurve(f){if(i.m===1){if(typeof f!="bigint")throw new Error("expected bigint (m=1)");return a(s([f]))}if(!Array.isArray(f))throw new Error("expected array of bigints");if(f.length!==i.m)throw new Error(`expected array of ${i.m} bigints`);for(let l of f)if(typeof l!="bigint")throw new Error("expected array of bigints");return a(s(f))},hashToScalar(f,l){let y=e.Fn.ORDER,g=Object.assign({},i,{DST:SM},o(l),{p:y,m:1});return Bd(f,1,g)[0][0]}})}function wM(e,t){let r=xr(e),n=r.ORDER,i=bS;for(let M=n-an;M%fi===bS;M/=fi)i+=an;let o=i,s=fi<<o-an-an,a=s*fi,f=(n-an)/a,l=(f-an)/fi,y=a-an,g=s,v=r.pow(t,f),E=r.pow(t,(f+an)/fi),T=(M,L)=>{let F=v,V=r.pow(L,y),z=r.sqr(V);z=r.mul(z,L);let G=r.mul(M,z);G=r.pow(G,l),G=r.mul(G,V),V=r.mul(G,L),z=r.mul(G,M);let ie=r.mul(z,V);G=r.pow(ie,g);let te=r.eql(G,r.ONE);V=r.mul(z,E),G=r.mul(ie,F),z=r.cmov(V,z,te),ie=r.cmov(G,ie,te);for(let pe=o;pe>an;pe--){let fe=pe-fi;fe=fi<<fe-an;let ye=r.pow(ie,fe),I=r.eql(ye,r.ONE);V=r.mul(z,F),F=r.mul(F,F),ye=r.mul(ie,F),z=r.cmov(V,z,I),ie=r.cmov(ye,ie,I)}return{isValid:!r.is0(L)&&(te||r.is0(M)),value:z}};if(r.ORDER%SS===_S){let M=(r.ORDER-_S)/SS,L=r.sqrt(r.neg(t));T=(F,V)=>{let z=r.sqr(V),G=r.mul(F,V);z=r.mul(z,G);let ie=r.pow(z,M);ie=r.mul(ie,G);let te=r.mul(ie,L),pe=r.mul(r.sqr(ie),V),fe=r.eql(pe,F),ye=r.cmov(te,ie,fe);return{isValid:!r.is0(V)&&fe,value:ye}}}return T}function IS(e,t){let r=xr(e);Ge(t,{},{},"opts");let{A:n,B:i,Z:o}=t;if(!r.isValidNot0(n)||!r.isValidNot0(i)||!r.isValid(o))throw new Error("mapToCurveSimpleSWU: invalid opts");if(r.eql(o,r.neg(r.ONE))||Id(r,o))throw new Error("mapToCurveSimpleSWU: invalid opts");let s=r.mul(i,r.inv(r.mul(o,n))),a=r.add(r.add(r.mul(r.sqr(s),s),r.mul(n,s)),i);if(!Id(r,a))throw new Error("mapToCurveSimpleSWU: invalid opts");let f=wM(r,o);if(!r.isOdd)throw new Error("Field does not have .isOdd()");return l=>{let y,g,v,E,T,M,L,F;y=r.sqr(l),y=r.mul(y,o),g=r.sqr(y),g=r.add(g,y),v=r.add(g,r.ONE),v=r.mul(v,i),E=r.cmov(o,r.neg(g),!r.eql(g,r.ZERO)),E=r.mul(E,n),g=r.sqr(v),M=r.sqr(E),T=r.mul(M,n),g=r.add(g,T),g=r.mul(g,v),M=r.mul(M,E),T=r.mul(M,i),g=r.add(g,T),L=r.mul(y,v);let{isValid:V,value:z}=f(g,M);F=r.mul(y,l),F=r.mul(F,z),L=r.cmov(L,v,V),F=r.cmov(F,z,V);let G=r.isOdd(l)===r.isOdd(F);F=r.cmov(r.neg(F),F,G);let ie=zo(r,[E],!0)[0];return L=r.mul(L,ie),{x:L,y:F}}}var bS,an,fi,_S,SS,mM,SM,AS=Yt(()=>{p();si();$i();bS=BigInt(0),an=BigInt(1),fi=BigInt(2),_S=BigInt(3),SS=BigInt(4),mM=kt;SM="HashToScalar-"});function Nd(e){Ge(e,{name:"string",hash:"function"},{hashToScalar:"function",validatePoint:"function",parsePublicKey:"function",adjustScalar:"function",adjustPoint:"function",challenge:"function",adjustNonces:"function",adjustSecret:"function",adjustPublic:"function",adjustGroupCommitmentShare:"function",adjustDKG:"function"}),ui(e.Point);let{Point:t}=e,r=e.Fn===void 0?t.Fn:e.Fn,n=e.hash,i=e.hashToScalar===void 0?(O,C={DST:new Uint8Array})=>{let D=n(De(C.DST,O));return r.create(r.isLE?Go(D):kt(D))}:e.hashToScalar,o=An(e.H1!==void 0?e.H1:e.name+"rho"),s=An(e.H2!==void 0?e.H2:e.name+"chal"),a=An(e.H3!==void 0?e.H3:e.name+"nonce"),f=An(e.H4!==void 0?e.H4:e.name+"msg"),l=An(e.H5!==void 0?e.H5:e.name+"com"),y=An(e.HDKG!==void 0?e.HDKG:e.name+"dkg"),g=An(e.HID!==void 0?e.HID:e.name+"id"),v=O=>i(O,{DST:o}),E=O=>i(O,{DST:s}),T=O=>i(O,{DST:a}),M=O=>n(De(f,O)),L=O=>n(De(l,O)),F=O=>i(O,{DST:y}),V=O=>i(O,{DST:g}),z=(O=tr)=>{if(typeof O!="function")throw new TypeError('"rng" expected function, got type='+typeof O);let C=Yi(O($o(r.ORDER)),r.ORDER,r.isLE);return r.isLE?Go(C):kt(C)},G=O=>O.toBytes(),ie=O=>{let C=t.fromBytes(O);return e.validatePoint&&e.validatePoint(C),C},te=(O,C)=>({identifier:O,hiding:G(t.BASE.multiply(r.fromBytes(C.hiding))),binding:G(t.BASE.multiply(r.fromBytes(C.binding)))}),pe=e.adjustPoint===void 0?O=>O:e.adjustPoint,fe=O=>{if(!r.isValid(O)||r.is0(O))throw new Error("Invalid identifier "+O);return O},ye=O=>Tn(r.toBytes(fe(O))),I=(O,C="identifier")=>{sa(O,C);let D=fe(r.fromBytes(Ko(O)));if(ye(D)!==O)throw new Error("expected canonical identifier hex");return D},u={encode:(O,C)=>{let D=De(G(O),r.toBytes(C));return e.adjustTx&&(D=e.adjustTx.encode(D)),D},decode:O=>{e.adjustTx&&(O=e.adjustTx.decode(O));let C=O.subarray(0,-r.BYTES),D=ie(C);if(G(D).length!==C.length)throw new Error("invalid signature encoding");let H=r.fromBytes(O.subarray(-r.BYTES));return{R:D,z:H}}},h=(O=tr)=>{let C=z(O);e.adjustScalar&&(C=e.adjustScalar(C));let D=t.BASE.multiply(C);return{scalar:C,point:D}},m="roots are unavailable in FROST polynomial mode",S={info:{G:r.ZERO,oddFactor:r.ZERO,powerOfTwo:0},roots(){throw new Error(m)},brp(){throw new Error(m)},inverse(){throw new Error(m)},omega(){throw new Error(m)},clear(){}},w=mS(r,S),R=(O,C)=>Zo(t,O,C),A=(O,C)=>{if(!C.length)throw new Error("empty coefficients");return w.monomial.eval(C,O)},_=(O,C)=>{let D="invalid parameters";if(!O.some(re=>r.eql(re,C)))throw new Error(D);let H=new Set(O);if(H.size!==O.length)throw new Error(D);if(!H.has(C))throw new Error(D);let Q=r.ONE,J=r.ONE;for(let re of O)r.eql(re,C)||(Q=r.mul(Q,re),J=r.mul(J,r.sub(re,C)));return r.div(Q,J)},c=(O,C)=>{let D=w.monomial.basis(O,C.length);return R(C,D)},b=(O,C,D,H=tr)=>{if(un(O),C!==void 0&&Se(C,r.BYTES,"secret"),D!==void 0&&it(D,"coeffs"),typeof H!="function")throw new TypeError('"rng" expected function, got type='+typeof H);let Q=C===void 0?z(H):r.fromBytes(C);if(!D){D=[];for(let ue=0;ue<O.min-1;ue++)D.push(z(H))}if(D.length!==O.min-1)throw new Error("wrong coefficients length");let J=[Q,...D],re=J.map(ue=>t.BASE.multiply(ue));return{coefficients:J,commitment:re,secret:Q}},k={challenge:(O,C,D)=>F(De(r.toBytes(O),G(C),G(D))),compute(O,C,D,H=tr){if(C.length<1)throw new Error("coefficients should have at least one element");let{point:Q,scalar:J}=h(H),re=D[0],ue=this.challenge(O,re,Q),oe=r.add(J,r.mul(C[0],ue));return u.encode(Q,oe)},validate(O,C,D){if(C.length<1)throw new Error("commitment should have at least one element");let{R:H,z:Q}=u.decode(D),J=ie(C[0]),re=this.challenge(O,J,H);if(!H.equals(t.BASE.multiplyUnsafe(Q).subtract(J.multiplyUnsafe(re))))throw new Error("invalid proof of knowledge")}},U={challenge:(O,C,D)=>e.challenge?e.challenge(O,C,D):E(De(G(O),G(C),D)),sign(O,C,D=tr){let{point:H,scalar:Q}=h(D),J=t.BASE.multiply(C),re=this.challenge(H,J,O),ue=r.add(Q,r.mul(re,C));return[H,ue]},verify(O,C,D,H){e.adjustPoint&&(H=e.adjustPoint(H)),e.adjustPoint&&(C=e.adjustPoint(C));let Q=this.challenge(C,H,O),J=t.BASE.multiplyUnsafe(D),re=H.multiplyUnsafe(Q),ue=J.subtract(re).subtract(C);return ue.clearCofactor&&(ue=ue.clearCofactor()),t.ZERO.equals(ue)}},K=(O,C,D)=>{if(!t.BASE.multiply(D).equals(c(O,C)))throw new Error("invalid secret share")},W={fromNumber(O){if(!Number.isSafeInteger(O))throw new Error("expected safe interger");return ye(BigInt(O))},derive(O){return sa(O,"s"),ye(V(An(O)))}},ee=(O,C=tr)=>T(De(C(32),r.toBytes(O))),X=(O,C,D)=>{let H=C.map(he=>[he.identifier,I(he.identifier),ie(he.hiding),ie(he.binding)]);H.sort((he,me)=>he[1]<me[1]?-1:he[1]>me[1]?1:0);let Q=[];for(let[he,me,_e,Ft]of H)Q.push(r.toBytes(me),G(_e),G(Ft));let J=L(De(...Q)),re=De(G(O),M(D),J),ue={};for(let[he,me]of H)ue[he]=v(De(re,r.toBytes(me)));let oe=t.ZERO,se=[],be=[];for(let[he,me,_e,Ft]of H){if(t.ZERO.equals(_e)||t.ZERO.equals(Ft))throw new Error("infinity commitment");oe=oe.add(_e),se.push(Ft),be.push(ue[he])}let we=oe.add(R(se,be));return{identifiers:H.map(he=>he[1]),groupCommitment:we,bindingFactors:ue}},le=(O,C,D,H)=>{let Q=pe(ie(O)),J=I(H),{identifiers:re,groupCommitment:ue,bindingFactors:oe}=X(Q,C,D),se=oe[H],be=_(re,J),we=U.challenge(ue,Q,D);return{lambda:be,challenge:we,bindingFactor:se,groupCommitment:ue}};Object.freeze(W);let ae={Identifier:W,DKG:Object.freeze({round1:(O,C,D,H=tr)=>{let Q=I(O,"id");un(C);let{coefficients:J,commitment:re}=b(C,D,void 0,H),ue=k.compute(Q,J,re,H),oe=re.map(G),se={identifier:ye(Q),commitment:oe,proofOfKnowledge:ue},be={identifier:Q,coefficients:J,commitment:re.map(G),signers:{min:C.min,max:C.max},step:1};return{public:se,secret:be}},round2:(O,C)=>{if(Ge(O,{identifier:"bigint",commitment:"object",signers:"object"},{coefficients:"object",round2Cache:"object",step:"number"},"secret"),un(O.signers,"secret.signers"),it(C,"others"),C.length!==O.signers.max-1)throw new Error("wrong number of round1 packages");if(!O.coefficients||O.step===3)throw new Error("round3 package used in round2");if(O.round2Cache!==void 0)return O.round2Cache;let D={};for(let H of C){if(H.commitment.length!==O.signers.min)throw new Error("wrong number of commitments");let Q=I(H.identifier);if(Q===O.identifier)throw new Error("duplicate id="+ye(Q));k.validate(Q,H.commitment,H.proofOfKnowledge);for(let re of H.commitment)ie(re);if(D[H.identifier])throw new Error("Duplicate id="+Q);let J=r.toBytes(A(Q,O.coefficients));D[H.identifier]={identifier:ye(O.identifier),signingShare:J}}return O.round2Cache=D,O.step=2,D},round3:(O,C,D)=>{if(Ge(O,{identifier:"bigint",commitment:"object",signers:"object"},{coefficients:"object",round2Cache:"object",step:"number"},"secret"),un(O.signers,"secret.signers"),it(C,"round1"),it(D,"round2"),C.length!==O.signers.max-1)throw new Error("wrong length of round1 packages");if(!O.coefficients||O.step!==2)throw new Error("round2 package used in round3");if(D.length!==C.length)throw new Error("wrong length of round2 packages");let H={};for(let he of C){if(!he.identifier||!he.commitment)throw new Error("wrong round1 share");H[he.identifier]={...he}}for(let he of D){if(!he.identifier||!he.signingShare)throw new Error("wrong round2 share");if(!H[he.identifier])throw new Error("round1 share for "+he.identifier+" is missing");H[he.identifier].signingShare=he.signingShare}if(Object.keys(H).length!==C.length)throw new Error("mismatch identifiers between rounds");let Q=r.ZERO;if(O.commitment.length!==O.signers.min)throw new Error("wrong commitments length");let J=O.commitment.map(ie),re=A(O.identifier,O.coefficients);K(O.identifier,J,re);let ue=J.map(G),oe={[ye(O.identifier)]:ue};for(let he in H){let me=H[he];if(!me.signingShare||!me.commitment)throw new Error("mismatch identifiers");let _e=I(he),Ft=r.fromBytes(me.signingShare),Ue=me.commitment.map(ie);K(O.identifier,Ue,Ft),Q=r.add(Q,Ft);let Ee=ye(_e);if(oe[Ee])throw new Error("duplicated id="+Ee);oe[Ee]=me.commitment}Q=r.add(Q,re);let se=new Array(O.signers.min).fill(t.ZERO);for(let he in oe){let me=oe[he];if(me.length!==O.signers.min)throw new Error("wrong commitments length");for(let _e=0;_e<me.length;_e++)se[_e]=se[_e].add(ie(me[_e]))}let be=se.map(G),we={};for(let he in oe)we[he]=G(c(I(he),se));let Re={public:{signers:{min:O.signers.min,max:O.signers.max},commitments:be,verifyingShares:Object.fromEntries(Object.entries(we).map(([he,me])=>[he,me.slice()]))},secret:{identifier:ye(O.identifier),signingShare:r.toBytes(Q)}};e.adjustDKG&&(Re=e.adjustDKG(Re));for(let he=0;he<O.coefficients.length;he++)O.coefficients[he]-=O.coefficients[he];return delete O.coefficients,delete O.round2Cache,O.step=3,Re},clean(O){if(Ge(O,{identifier:"bigint",commitment:"object",signers:"object"},{coefficients:"object",round2Cache:"object",step:"number"},"secret"),O.identifier-=O.identifier,O.coefficients)for(let C=0;C<O.coefficients.length;C++)O.coefficients[C]-=O.coefficients[C];delete O.round2Cache,O.step=3}}),trustedDealer(O,C,D,H=tr){if(un(O),C===void 0){C=[];for(let se=1;se<=O.max;se++)C.push(W.fromNumber(se))}else if(it(C,"identifiers"),C.length!==O.max)throw new Error("identifiers should be array of "+O.max);let Q={};for(let se of C){let be=I(se);if(se in Q)throw new Error("duplicated id="+se);Q[se]=be}let J=b(O,D,void 0,H),re=J.commitment.map(G),ue={},oe={};for(let se of C){let be=A(Q[se],J.coefficients);oe[se]=G(t.BASE.multiply(be)),ue[se]={identifier:se,signingShare:r.toBytes(be)}}return{public:{signers:{min:O.min,max:O.max},commitments:re,verifyingShares:oe},secretShares:ue}},validateSecret(O,C){Ge(O,{identifier:"string",signingShare:"object"},{},"secret"),Se(O.signingShare,r.BYTES,"secret.signingShare"),Ge(C,{signers:"object",commitments:"object",verifyingShares:"object"},{},"pub"),un(C.signers,"pub.signers"),it(C.commitments,"pub.commitments");let D=I(O.identifier),H=C.commitments.map(ie),Q=r.fromBytes(O.signingShare);K(D,H,Q)},commit(O,C=tr){if(Ge(O,{identifier:"string",signingShare:"object"},{},"secret"),Se(O.signingShare,r.BYTES,"secret.signingShare"),typeof C!="function")throw new TypeError('"rng" expected function, got type='+typeof C);let D=r.fromBytes(O.signingShare),H=ee(D,C),Q=ee(D,C),J={hiding:r.toBytes(H),binding:r.toBytes(Q)};return{nonces:J,commitments:te(O.identifier,J)}},signShare(O,C,D,H,Q){Ge(O,{identifier:"string",signingShare:"object"},{},"secret"),Se(O.signingShare,r.BYTES,"secret.signingShare"),Ge(C,{signers:"object",commitments:"object",verifyingShares:"object"},{},"pub"),un(C.signers,"pub.signers"),it(C.commitments,"pub.commitments"),Ge(D,{hiding:"object",binding:"object"},{},"nonces"),Se(D.hiding,r.BYTES,"nonces.hiding"),Se(D.binding,r.BYTES,"nonces.binding"),it(H,"commitmentList"),Se(Q,void 0,"msg"),OS(C.signers,H.length);let J=r.fromBytes(D.hiding),re=r.fromBytes(D.binding);if(r.is0(J)||r.is0(re))throw new Error("signing nonces already used");let ue={identifier:O.identifier,hiding:G(t.BASE.multiply(J)),binding:G(t.BASE.multiply(re))},oe=H.find(je=>je.identifier===O.identifier);if(!oe)throw new Error("missing signer commitment");if(Tn(oe.hiding)!==Tn(ue.hiding)||Tn(oe.binding)!==Tn(ue.binding))throw new Error("incorrect signer commitment");e.adjustSecret&&(O=e.adjustSecret(O,C)),e.adjustPublic&&(C=e.adjustPublic(C));let se=r.fromBytes(O.signingShare),{lambda:be,challenge:we,bindingFactor:Re,groupCommitment:he}=le(C.commitments[0],H,Q,O.identifier),me=e.adjustNonces?e.adjustNonces(he,D):D,_e=e.adjustNonces?r.fromBytes(me.hiding):J,Ft=e.adjustNonces?r.fromBytes(me.binding):re,Ue=r.mul(r.mul(be,se),we),Ee=r.mul(Ft,Re),Ei=r.toBytes(r.add(r.add(_e,Ee),Ue));return D.hiding.fill(0),D.binding.fill(0),Ei},verifyShare(O,C,D,H,Q){Ge(O,{signers:"object",commitments:"object",verifyingShares:"object"},{},"pub"),un(O.signers,"pub.signers"),it(O.commitments,"pub.commitments"),it(C,"commitmentList"),Se(D,void 0,"msg"),I(H),Se(Q,r.BYTES,"sigShare"),e.adjustPublic&&(O=e.adjustPublic(O));let J=C.find(Ft=>Ft.identifier===H);if(!J)throw new Error("cannot find identifier commitment");let re=ie(O.verifyingShares[H]),ue=ie(J.hiding),oe=ie(J.binding),{lambda:se,challenge:be,bindingFactor:we,groupCommitment:Re}=le(O.commitments[0],C,D,H),he=ue.add(oe.multiplyUnsafe(we));e.adjustGroupCommitmentShare&&(he=e.adjustGroupCommitmentShare(Re,he));let me=t.BASE.multiplyUnsafe(r.fromBytes(Q)),_e=he.add(re.multiplyUnsafe(r.mul(be,se)));return me.equals(_e)},aggregate(O,C,D,H){Ge(O,{signers:"object",commitments:"object",verifyingShares:"object"},{},"pub"),un(O.signers,"pub.signers"),it(O.commitments,"pub.commitments"),it(C,"commitmentList"),Se(D,void 0,"msg"),Ge(H,{},{},"sigShares");let Q=O;e.adjustPublic&&(O=e.adjustPublic(O));try{OS(O.signers,C.length)}catch{throw new Xi("aggregation failed",[])}let J=C.map(be=>be.identifier),re=new Set;for(let be of J){if(re.has(be))throw new Xi("aggregation failed",[]);re.add(be)}if(J.length!==Object.keys(H).length)throw new Xi("aggregation failed",[]);for(let be of J)if(!(be in H)||!(be in O.verifyingShares))throw new Xi("aggregation failed",[]);let ue=ie(O.commitments[0]),{groupCommitment:oe}=X(ue,C,D),se=r.ZERO;for(let be of J)se=r.add(se,r.fromBytes(H[be]));if(!U.verify(D,oe,se,ue)){let be=[];for(let we of J)this.verifyShare(Q,C,D,we,H[we])||be.push(we);throw new Xi("aggregation failed",be)}return u.encode(oe,se)},sign(O,C){let D=r.fromBytes(C);e.adjustScalar&&(D=e.adjustScalar(D));let[H,Q]=U.sign(O,D);return u.encode(H,Q)},verify(O,C,D){let H=e.parsePublicKey?e.parsePublicKey(D):ie(D),{R:Q,z:J}=u.decode(O);return U.verify(C,Q,J,H)},combineSecret(O,C){if(it(O,"shares"),un(C),O.length<C.min||O.length>C.max)throw new Error("wrong secret shares array");let D=[],H={};for(let re of O){let ue=I(re.identifier),oe=ye(ue);if(H[oe])throw new Error("duplicated id="+oe);H[oe]=!0,D.push([ue,r.fromBytes(re.signingShare)])}let Q=D.map(([re])=>re),J=r.ZERO;for(let[re,ue]of D)J=r.add(J,r.mul(ue,_(Q,re)));return r.toBytes(J)},utils:Object.freeze({Fn:r,randomScalar:(O=tr)=>r.toBytes(h(O).scalar),generateSecretPolynomial:(O,C,D,H)=>{let Q=b(O,C,D,H);return{...Q,commitment:Q.commitment.map(G)}}})};return Object.freeze(ae)}var un,OS,Xi,RS=Yt(()=>{p();On();si();Gf();vS();$i();un=(e,t="signers")=>{if(Ge(e,{min:"number",max:"number"},{},t),ot(e.min,t+".min"),ot(e.max,t+".max"),e.min<2||e.max<2||e.min>e.max)throw new Error("Wrong signers info: min="+e.min+" max="+e.max)},OS=(e,t)=>{if(t<e.min||t>e.max)throw new Error("Wrong number of commitments="+t)},Xi=class extends Error{constructor(r,n){super(r);Z(this,"cheaters");this.cheaters=n}}});var Wf,TS,PS=Yt(()=>{p();On();Wf=class{constructor(t,r){Z(this,"oHash");Z(this,"iHash");Z(this,"blockLen");Z(this,"outputLen");Z(this,"canXOF",!1);Z(this,"finished",!1);Z(this,"destroyed",!1);if(If(t),nn(r,void 0,"key"),this.iHash=t.create(),typeof this.iHash.update!="function")throw new Error("expected Hash instance");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let n=this.blockLen,i=new Uint8Array(n);i.set(r.length>n?t.create().update(r).digest():r);for(let o=0;o<i.length;o++)i[o]^=54;this.iHash.update(i),this.oHash=t.create();for(let o=0;o<i.length;o++)i[o]^=106;this.oHash.update(i),ur(i)}update(t){return qo(this),this.iHash.update(t),this}digestInto(t){qo(this),Af(t,this),this.finished=!0;let r=t.subarray(0,this.outputLen);this.iHash.digestInto(r),this.oHash.update(r),this.oHash.digestInto(r),this.destroy()}digest(){let t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));let{oHash:r,iHash:n,finished:i,destroyed:o,blockLen:s,outputLen:a,canXOF:f}=this;return t=t,t.finished=i,t.destroyed=o,t.blockLen=s,t.outputLen=a,t.canXOF=f,t.oHash=r._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},TS=(()=>{let e=((t,r,n)=>new Wf(t,r).update(n).digest());return e.create=(t,r)=>new Wf(t,r),e})()});var EM,Md,Pn,kd,BS=Yt(()=>{p();si();EM=BigInt(0),Md=class extends Error{constructor(t=""){super(t)}},Pn={Err:Md,_tlv:{encode:(e,t)=>{let{Err:r}=Pn;if(ot(e,"tag"),e<0||e>255)throw new r("tlv.encode: wrong tag");if(sa(t,"data"),t.length&1)throw new r("tlv.encode: unpadded data");let n=t.length/2,i=aa(n);if(i.length/2&128)throw new r("tlv.encode: long form length too big");let o=n>127?aa(i.length/2|128):"";return aa(e)+o+i+t},decode(e,t){let{Err:r}=Pn;t=Se(t,void 0,"DER data");let n=0;if(e<0||e>255)throw new r("tlv.decode: wrong tag");if(t.length<2||t[n++]!==e)throw new r("tlv.decode: wrong tlv");let i=t[n++],o=!!(i&128),s=0;if(!o)s=i;else{let f=i&127;if(!f)throw new r("tlv.decode(long): indefinite length not supported");if(f>4)throw new r("tlv.decode(long): byte length is too big");let l=t.subarray(n,n+f);if(l.length!==f)throw new r("tlv.decode: length bytes not complete");if(l[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(let y of l)s=s<<8|y;if(n+=f,s<128)throw new r("tlv.decode(long): not minimal encoding")}let a=t.subarray(n,n+s);if(a.length!==s)throw new r("tlv.decode: wrong value length");return{v:a,l:t.subarray(n+s)}}},_int:{encode(e){let{Err:t}=Pn;if(Uf(e),e<EM)throw new t("integer: negative integers are not allowed");let r=aa(e);if(Number.parseInt(r[0],16)&8&&(r="00"+r),r.length&1)throw new t("unexpected DER parsing assertion: unpadded hex");return r},decode(e){let{Err:t}=Pn;if(e.length<1)throw new t("invalid signature integer: empty");if(e[0]&128)throw new t("invalid signature integer: negative");if(e.length>1&&e[0]===0&&!(e[1]&128))throw new t("invalid signature integer: unnecessary leading zero");return kt(e)}},toSig(e){let{Err:t,_int:r,_tlv:n}=Pn,i=Se(e,void 0,"signature"),{v:o,l:s}=n.decode(48,i);if(s.length)throw new t("invalid signature: left bytes after parsing");let{v:a,l:f}=n.decode(2,o),{v:l,l:y}=n.decode(2,f);if(y.length)throw new t("invalid signature: left bytes after parsing");return{r:r.decode(a),s:r.decode(l)}},hexFromSig(e){let{_tlv:t,_int:r}=Pn;Ge(e,{r:"bigint",s:"bigint"},{},"sig");let n=t.encode(2,r.encode(e.r)),i=t.encode(2,r.encode(e.s)),o=n+i;return t.encode(48,o)}},kd=(Object.freeze(Pn._tlv),Object.freeze(Pn._int),Object.freeze(Pn))});function xM(e,t,r){_d("scalar",e,Bn,r);let[[n,i],[o,s]]=t,a=NS(s*e,r),f=NS(-i*e,r),l=e-a*n-f*o,y=-a*i-f*s,g=l<Bn,v=y<Bn;g&&(l=-l),v&&(y=-y);let E=ua(Math.ceil(Wo(r)/2))+Ji;if(l<Bn||l>=E||y<Bn||y>=E)throw new Error("splitScalar (endomorphism): failed for k");return{k1neg:g,k1:l,k2neg:v,k2:y}}function Dd(e){if(!["compact","recovered","der"].includes(e))throw new Error('Signature format must be "compact", "recovered", or "der"');return e}function Cd(e,t){Ge(e);let r={};for(let n of Object.keys(t))r[n]=e[n]===void 0?t[n]:e[n];return sn(r.lowS,"lowS"),sn(r.prehash,"prehash"),r.format!==void 0&&Dd(r.format),r}function kS(e,t={}){let r=gS("weierstrass",e,t),n=r.Fp,i=r.Fn,o=r.CURVE,{h:s,n:a}=o;Ge(t,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object",randomBytes:"function"});let{endo:f,allowInfinityPoint:l}=t,y=t.randomBytes===void 0?tr:t.randomBytes;if(f&&(!n.is0(o.a)||typeof f.beta!="bigint"||!Array.isArray(f.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');let g=LS(n,i);function v(){if(!n.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function E(R,A,_){if(l&&A.is0())return Uint8Array.of(0);let{x:c,y:b}=A.toAffine(),k=n.toBytes(c);if(sn(_,"isCompressed"),_){v();let U=!n.isOdd(b);return De(CS(U),k)}else return De(Uint8Array.of(4),k,n.toBytes(b))}function T(R){Se(R,void 0,"Point");let{publicKey:A,publicKeyUncompressed:_}=g,c=R.length,b=R[0],k=R.subarray(1);if(l&&c===1&&b===0)return{x:n.ZERO,y:n.ZERO};if(c===A&&(b===2||b===3)){let U=n.fromBytes(k);if(!n.isValid(U))throw new Error("bad point: is not on curve, wrong x");let K=z(U),W;try{W=n.sqrt(K)}catch(le){let ae=le instanceof Error?": "+le.message:"";throw new Error("bad point: is not on curve, sqrt error"+ae)}v();let ee=n.isOdd(W);return(b&1)===1!==ee&&(W=n.neg(W)),{x:U,y:W}}else if(c===_&&b===4){let U=n.BYTES,K=n.fromBytes(k.subarray(0,U)),W=n.fromBytes(k.subarray(U,U*2));if(!G(K,W))throw new Error("bad point: is not on curve");return{x:K,y:W}}else throw new Error(`bad point: got length ${c}, expected compressed=${A} or uncompressed=${_}`)}let M=t.toBytes===void 0?E:t.toBytes,L=t.fromBytes===void 0?T:t.fromBytes,F=n.mul(o.b,Ld),V=n.is0(o.a)?R=>n.ZERO:R=>n.mul(o.a,R);function z(R){let A=n.sqr(R),_=n.mul(A,R);return n.add(n.add(_,n.mul(R,o.a)),o.b)}function G(R,A){let _=n.sqr(A),c=z(R);return n.eql(_,c)}if(!G(o.Gx,o.Gy))throw new Error("bad curve params: generator point");let ie=n.mul(n.pow(o.a,Ld),IM),te=n.mul(n.sqr(o.b),BigInt(27));if(n.is0(n.add(ie,te)))throw new Error("bad curve params: a or b");function pe(R,A,_=!1){if(!n.isValid(A)||_&&n.is0(A))throw new Error(`bad point coordinate ${R}`);return A}function fe(R){if(!(R instanceof h))throw new Error("Weierstrass Point expected")}function ye(R){if(!f||!f.basises)throw new Error("no endo");return xM(R,f.basises,i.ORDER)}function I(R,A,_,c){if(!i.isValid(c))throw new RangeError("invalid scalar: out of range");if(f){let{k1neg:b,k1:k,k2neg:U,k2:K}=ye(c),W=new h(n.mul(_.X,f.beta),_.Y,_.Z);R.push(b?_.negate():_,U?W.negate():W),A.push(k,K)}else R.push(_),A.push(c)}let u=new WeakSet,w=class w{constructor(A,_,c){Z(this,"X");Z(this,"Y");Z(this,"Z");this.X=pe("x",A),this.Y=pe("y",_,!0),this.Z=pe("z",c),Object.freeze(this)}static CURVE(){return o}static fromAffine(A){let{x:_,y:c}=A||{};if(!A||!n.isValid(_)||!n.isValid(c))throw new Error("invalid affine point");if(A instanceof w)throw new Error("projective point not allowed");return n.is0(_)&&n.is0(c)?w.ZERO:new w(_,c,n.ONE)}static fromBytes(A){let _=w.fromAffine(L(Se(A,void 0,"point")));return _.assertValidity(),_}static fromHex(A){return w.fromBytes(Ko(A))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(A=6,_=!0){return S.setWindowSize(this,A),_||this.multiply(Ld),this}assertValidity(){let A=this;if(A.is0()){if(t.allowInfinityPoint&&n.is0(A.X)&&n.eql(A.Y,n.ONE)&&n.is0(A.Z))return;throw new Error("bad point: ZERO")}if(u.has(A))return;let{x:_,y:c}=A.toAffine();if(!n.isValid(_)||!n.isValid(c))throw new Error("bad point: x or y not field elements");if(!G(_,c))throw new Error("bad point: equation left != right");if(!A.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");u.add(A)}hasEvenY(){let{y:A}=this.toAffine();if(!n.isOdd)throw new Error("Field doesn't support isOdd");return!n.isOdd(A)}equals(A){fe(A);let{X:_,Y:c,Z:b}=this,{X:k,Y:U,Z:K}=A,W=n.eql(n.mul(_,K),n.mul(k,b)),ee=n.eql(n.mul(c,K),n.mul(U,b));return W&&ee}negate(){return new w(this.X,n.neg(this.Y),this.Z)}double(){let{X:A,Y:_,Z:c}=this,b=n.ZERO,k=n.ZERO,U=n.ZERO,K=n.mul(A,A),W=n.mul(_,_),ee=n.mul(c,c),X=n.mul(A,_);return X=n.add(X,X),U=n.mul(A,c),U=n.add(U,U),b=V(U),k=n.mul(F,ee),k=n.add(b,k),b=n.sub(W,k),k=n.add(W,k),k=n.mul(b,k),b=n.mul(X,b),U=n.mul(F,U),ee=V(ee),X=n.sub(K,ee),X=V(X),X=n.add(X,U),U=n.add(K,K),K=n.add(U,K),K=n.add(K,ee),K=n.mul(K,X),k=n.add(k,K),ee=n.mul(_,c),ee=n.add(ee,ee),K=n.mul(ee,X),b=n.sub(b,K),U=n.mul(ee,W),U=n.add(U,U),U=n.add(U,U),new w(b,k,U)}add(A){fe(A);let{X:_,Y:c,Z:b}=this,{X:k,Y:U,Z:K}=A,W=n.ZERO,ee=n.ZERO,X=n.ZERO,le=n.mul(_,k),ae=n.mul(c,U),O=n.mul(b,K),C=n.add(_,c),D=n.add(k,U);C=n.mul(C,D),D=n.add(le,ae),C=n.sub(C,D),D=n.add(_,b);let H=n.add(k,K);return D=n.mul(D,H),H=n.add(le,O),D=n.sub(D,H),H=n.add(c,b),W=n.add(U,K),H=n.mul(H,W),W=n.add(ae,O),H=n.sub(H,W),X=V(D),W=n.mul(F,O),X=n.add(W,X),W=n.sub(ae,X),X=n.add(ae,X),ee=n.mul(W,X),ae=n.add(le,le),ae=n.add(ae,le),O=V(O),D=n.mul(F,D),ae=n.add(ae,O),O=n.sub(le,O),O=V(O),D=n.add(D,O),le=n.mul(ae,D),ee=n.add(ee,le),le=n.mul(H,D),W=n.mul(C,W),W=n.sub(W,le),le=n.mul(C,ae),X=n.mul(H,X),X=n.add(X,le),new w(W,ee,X)}subtract(A){return fe(A),this.add(A.negate())}is0(){return this.equals(w.ZERO)}multiply(A){if(!i.isValidNot0(A))throw new RangeError("invalid scalar: out of range");let{p:_,f:c}=S.mulSecret(this,A,s,m);return m([_,c])[0]}multiplyUnsafe(A){let _=this,c=A;if(!i.isValid(c))throw new RangeError("invalid scalar: out of range");if(c===Bn||_.is0())return w.ZERO;if(c===Ji)return _;if(S.hasWindowSize(this))return S.mulUnsafe(_,c,m);let b=[],k=[];return I(b,k,_,c),Zo(w,b,k)}mulAddUnsafe(A,_,c){fe(_);let b=[],k=[];return I(b,k,this,A),I(b,k,_,c),Zo(w,b,k)}toAffine(A){let _=this,c=A;if(c!=null&&!n.isValid(c))throw new RangeError('"invertedZ" expected valid field element');let{X:b,Y:k,Z:U}=_;if(n.eql(U,n.ONE))return{x:b,y:k};let K=_.is0();c==null&&(c=K?n.ONE:n.inv(U));let W=n.mul(b,c),ee=n.mul(k,c),X=n.mul(U,c);if(K)return{x:n.ZERO,y:n.ZERO};if(!n.eql(X,n.ONE))throw new Error("invZ was invalid");return{x:W,y:ee}}isTorsionFree(){let{isTorsionFree:A}=t;return s===Ji?!0:A?A(w,this):S.mulUnsafe(this,a).is0()}clearCofactor(){let{clearCofactor:A}=t;return s===Ji?this:A?A(w,this):this.multiplyUnsafe(s)}isSmallOrder(){return s===Ji?this.is0():this.clearCofactor().is0()}toBytes(A=!0){return sn(A,"isCompressed"),this.assertValidity(),M(w,this,A)}toHex(A=!0){return Tn(this.toBytes(A))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}};Z(w,"BASE",new w(o.Gx,o.Gy,n.ONE)),Z(w,"ZERO",new w(n.ZERO,n.ONE,n.ZERO)),Z(w,"Fp",n),Z(w,"Fn",i);let h=w,m=R=>hS(h,R),S=new jf(h,y);return S.bits>=6&&h.BASE.precompute(6),Object.freeze(h.prototype),Object.freeze(h),h}function CS(e){return Uint8Array.of(e?2:3)}function LS(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function AM(e,t={}){ui(e);let{Fn:r}=e,n=t.randomBytes===void 0?tr:t.randomBytes,i=Object.assign(LS(e.Fp,r),{seed:Math.max($o(r.ORDER),16)});function o(E){try{let T=r.fromBytes(E);return r.isValidNot0(T)}catch{return!1}}function s(E,T){let{publicKey:M,publicKeyUncompressed:L}=i;try{let F=E.length;return T===!0&&F!==M||T===!1&&F!==L?!1:!!e.fromBytes(E)}catch{return!1}}function a(E){return E=E===void 0?n(i.seed):E,Yi(Se(E,i.seed,"seed"),r.ORDER)}function f(E,T=!0){return e.BASE.multiply(r.fromBytes(E)).toBytes(T)}function l(E){let{secretKey:T,publicKey:M,publicKeyUncompressed:L}=i,F=r._lengths;if(!on(E))return;let V=Se(E,void 0,"key").length,z=V===M||V===L,G=V===T||!!F?.includes(V);if(!(z&&G))return z}function y(E,T,M=!0){if(l(E)===!0)throw new Error("first arg must be private key");if(l(T)===!1)throw new Error("second arg must be public key");let L=r.fromBytes(E);return e.fromBytes(T).multiply(L).toBytes(M)}let g={isValidSecretKey:o,isValidPublicKey:s,randomSecretKey:a},v=Kf(a,f);return Object.freeze(g),Object.freeze(i),Object.freeze({getPublicKey:f,getSharedSecret:y,keygen:v,Point:e,utils:g,lengths:i})}function DS(e,t,r={}){ui(e);let n=t;If(n),Ge(r,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});let i=Object.assign({},r),o=i.randomBytes===void 0?tr:i.randomBytes,s=i.hmac===void 0?(b,k)=>TS(n,b,k):i.hmac,{Fp:a,Fn:f}=e,{ORDER:l,BITS:y}=f,g=$o(l),v=Td(o,g),{keygen:E,getPublicKey:T,getSharedSecret:M,utils:L,lengths:F}=AM(e,i),V={prehash:!0,lowS:typeof i.lowS=="boolean"?i.lowS:!0,format:"compact",extraEntropy:!1},z=l*MS+Ji<a.ORDER;function G(b){let k=l>>Ji;return b>k}function ie(b,k){if(!f.isValidNot0(k))throw new Error(`invalid signature ${b}: out of range 1..Point.Fn.ORDER`);return k}function te(){if(!a.isOdd)throw new Error("Field doesn't support isOdd")}function pe(b,k,U){return te(),(b===U?0:2)|Number(a.isOdd(k))}function fe(){if(z)throw new Error('"recovered" sig type is not supported for cofactor >2 curves')}function ye(b,k){Dd(k);let U=F.signature,K=k==="compact"?U:k==="recovered"?U+1:void 0;return Se(b,K)}class I{constructor(k,U,K){Z(this,"r");Z(this,"s");Z(this,"recovery");if(this.r=ie("r",k),this.s=ie("s",U),K!=null){if(fe(),![0,1,2,3].includes(K))throw new Error("invalid recovery id");this.recovery=K}Object.freeze(this)}static fromBytes(k,U=V.format){ye(k,U);let K;if(U==="der"){let{r:le,s:ae}=kd.toSig(Se(k));return new I(le,ae)}U==="recovered"&&(K=k[0],U="compact",k=k.subarray(1));let W=F.signature/2,ee=k.subarray(0,W),X=k.subarray(W,W*2);return new I(f.fromBytes(ee),f.fromBytes(X),K)}static fromHex(k,U){return this.fromBytes(Ko(k),U)}assertRecovery(){let{recovery:k}=this;if(k==null)throw new Error("invalid recovery id: must be present");return k}addRecoveryBit(k){return new I(this.r,this.s,k)}recoverPublicKey(k){let{r:U,s:K}=this,W=this.assertRecovery(),ee=W===2||W===3?U+l:U;if(!a.isValid(ee))throw new Error("invalid recovery id: sig.r+curve.n != R.x");let X=a.toBytes(ee),le=e.fromBytes(De(CS((W&1)===0),X)),ae=f.inv(ee),O=h(Se(k,void 0,"msgHash")),C=f.create(-O*ae),D=f.create(K*ae),H=e.BASE.mulAddUnsafe(C,le,D);if(H.is0())throw new Error("invalid recovery: point at infinify");return H.assertValidity(),H}hasHighS(){return G(this.s)}toBytes(k=V.format){if(Dd(k),k==="der")return Ko(kd.hexFromSig(this));let{r:U,s:K}=this,W=f.toBytes(U),ee=f.toBytes(K);return k==="recovered"?(fe(),De(Uint8Array.of(this.assertRecovery()),W,ee)):De(W,ee)}toHex(k){return Tn(this.toBytes(k))}}Object.freeze(I.prototype),Object.freeze(I);let u=i.bits2int===void 0?function(k){if(k.length>8192)throw new Error("input is too large");let U=kt(k),K=k.length*8-y;return K>0?U>>BigInt(K):U}:i.bits2int,h=i.bits2int_modN===void 0?function(k){return f.create(u(k))}:i.bits2int_modN,m=ua(y);function S(b){return _d("num < 2^"+y,b,Bn,m),f.toBytes(b)}function w(b,k){return Se(b,void 0,"message"),k?Se(n(b),void 0,"prehashed message"):b}function R(b,k,U){let{lowS:K,prehash:W,extraEntropy:ee}=Cd(U,V);b=w(b,W);let X=h(b),le=f.fromBytes(k);if(!f.isValidNot0(le))throw new Error("invalid private key");let ae=[S(le),S(X)];if(ee!=null&&ee!==!1){let H=ee===!0?o(F.secretKey):ee;ae.push(Se(H,void 0,"extraEntropy"))}let O=De(...ae),C=X;function D(H){let Q=u(H);if(!f.isValidNot0(Q))return;let J=e.BASE.multiply(Q).toAffine(),re=f.create(J.x);if(re===Bn)return;let ue;if(v!==void 0){let be=kt(Yi(v(g),l)),we=f.inv(f.mul(be,Q)),Re=f.mul(be,C),he=f.mul(be,le);ue=f.create(we*f.create(Re+he*re))}else{let be=oS(Q,l);ue=f.create(be*f.create(C+re*le))}if(ue===Bn)return;let oe=pe(J.x,J.y,re),se=ue;return K&&G(ue)&&(se=f.neg(ue),oe^=1),new I(re,se,z?void 0:oe)}return{seed:O,k2sig:D}}function A(b,k,U={}){let{seed:K,k2sig:W}=R(b,k,U);return X_(n.outputLen,f.BYTES,s)(K,W).toBytes(U.format)}function _(b,k,U,K={}){let{lowS:W,prehash:ee,format:X}=Cd(K,V);if(U=Se(U,void 0,"publicKey"),k=w(k,ee),!on(b)){let le=b instanceof I?", use sig.toBytes()":"";throw new Error("verify expects Uint8Array signature"+le)}ye(b,X);try{let le=I.fromBytes(b,X),ae=e.fromBytes(U);if(W&&le.hasHighS())return!1;let{r:O,s:C}=le,D=h(k),H=f.inv(C),Q=f.create(D*H),J=f.create(O*H),re=e.BASE.mulAddUnsafe(Q,ae,J);if(re.is0())return!1;let ue=re.toAffine();return!(f.create(ue.x)!==O||X==="recovered"&&le.recovery!==pe(ue.x,ue.y,O))}catch{return!1}}function c(b,k,U={}){let{prehash:K}=Cd(U,V);return k=w(k,K),I.fromBytes(b,"recovered").recoverPublicKey(k).toBytes()}return Object.freeze({keygen:E,getPublicKey:T,getSharedSecret:M,utils:L,lengths:F,Point:e,sign:A,verify:_,recoverPublicKey:c,Signature:I,hash:n})}var NS,Bn,Ji,MS,Ld,IM,US=Yt(()=>{p();PS();On();si();Gf();BS();$i();NS=(e,t)=>(e+(e>=0?t:-t)/MS)/t;Bn=BigInt(0),Ji=BigInt(1),MS=BigInt(2),Ld=BigInt(3),IM=BigInt(4)});var ZS={};fl(ZS,{__TEST:()=>BM,schnorr:()=>NM,schnorr_FROST:()=>DM,secp256k1:()=>TM,secp256k1_FROST:()=>CM,secp256k1_hasher:()=>qd});function RM(e){let t=zf.p,r=BigInt(3),n=BigInt(6),i=BigInt(11),o=BigInt(22),s=BigInt(23),a=BigInt(44),f=BigInt(88),l=e*e*e%t,y=l*l*e%t,g=pr(y,r,t)*y%t,v=pr(g,r,t)*y%t,E=pr(v,FS,t)*l%t,T=pr(E,i,t)*E%t,M=pr(T,o,t)*T%t,L=pr(M,a,t)*M%t,F=pr(L,f,t)*L%t,V=pr(F,a,t)*M%t,z=pr(V,r,t)*y%t,G=pr(z,s,t)*T%t,ie=pr(G,n,t)*l%t,te=pr(ie,FS,t);if(!Cr.eql(Cr.sqr(te),e))throw new Error("Cannot find square root");return te}function ca(e,...t){let r=qS[e];if(r===void 0){let n=ni(Vo(e));r=De(n,n),qS[e]=r}return ni(De(r,...t))}function GS(e){let{Fn:t,BASE:r}=Ve,n=t.fromBytes(Se(e,32,"secretKey")),o=r.multiply(n).toAffine();return{scalar:fn(o.y)?n:t.neg(n),bytes:KS(o)}}function Yf(e){let t=Cr;if(!t.isValidNot0(e))throw new Error("invalid x: Fail if x \u2265 p");let r=t.sqr(e),n=t.add(t.mulN(r,e),BigInt(7)),i=t.sqrt(n);fn(i)||(i=t.neg(i));let o=Ve.fromAffine({x:e,y:i});return o.assertValidity(),o}function Fd(...e){return Ve.Fn.create(Xo(ca("BIP0340/challenge",...e)))}function HS(e){return GS(e).bytes}function PM(e,t,r=oa(32)){let{Fn:n,BASE:i}=Ve,o=Se(e,void 0,"message"),{bytes:s,scalar:a}=GS(t),f=Se(r,32,"auxRand"),l=n.toBytes(a^Xo(ca("BIP0340/aux",f))),y=ca("BIP0340/nonce",l,s,o),g=n.create(Xo(y));if(g===Ud)throw new Error("sign failed: k is zero");let E=i.multiply(g).toAffine(),T=fn(E.y)?g:n.neg(g),M=KS(E),L=Fd(M,s,o),F=new Uint8Array(64);if(F.set(M,0),F.set(n.toBytes(n.create(T+L*a)),32),!VS(F,o,s))throw new Error("sign: Invalid signature produced");return F}function VS(e,t,r){let{Fp:n,Fn:i,BASE:o}=Ve,s=Se(e,64,"signature"),a=Se(t,void 0,"message"),f=Se(r,32,"publicKey");try{let l=Yf(Xo(f)),y=s.subarray(0,32),g=Xo(y);if(!n.isValidNot0(g))return!1;let v=Xo(s.subarray(32,64));if(!i.isValidNot0(v))return!1;let E=Fd(y,la(l),a),T=o.mulAddUnsafe(v,l,i.neg(E)),{x:M,y:L}=T.toAffine();return!(T.is0()||!fn(L)||!n.eql(M,g))}catch{return!1}}function WS(e,t){if(t===void 0)return Ud;let r=la(e),n=kt(ca("TapTweak",r,t));if(!Ve.Fn.isValid(n))throw new Error("invalid TapTweak hash");return n}function Hd(e){let t=Ve.fromBytes(e.commitments[0]);return fn(t.y)?e:{signers:{min:e.signers.min,max:e.signers.max},commitments:e.commitments.map(r=>Ve.fromBytes(r).negate().toBytes()),verifyingShares:Object.fromEntries(Object.entries(e.verifyingShares).map(([r,n])=>[r,Ve.fromBytes(n).negate().toBytes()]))}}function zS(e,t){let r=Ve.fromBytes(t.commitments[0]);if(fn(r.y))return e;let n=Ve.Fn;return{...e,signingShare:n.toBytes(n.neg(n.fromBytes(e.signingShare)))}}function LM(e,t){if(fn(e.y))return t;let r=Ve.Fn;return{binding:r.toBytes(r.neg(r.fromBytes(t.binding))),hiding:r.toBytes(r.neg(r.fromBytes(t.hiding)))}}function YS(e,t,r){let n=Ve.Fn,i=zS(e,t),o=Hd(t),s=WS(Ve.fromBytes(o.commitments[0]),r),a=n.toBytes(n.add(n.fromBytes(i.signingShare),s));return{identifier:i.identifier,signingShare:a}}function $S(e,t){let r=Hd(e),n=WS(Ve.fromBytes(r.commitments[0]),t);if(n===Ud)return r;let i=Ve.BASE.multiply(n),o=r.commitments.map((a,f)=>(f===0?Ve.fromBytes(a).add(i):Ve.fromBytes(a)).toBytes()),s={};for(let a in r.verifyingShares)s[a]=Ve.fromBytes(r.verifyingShares[a]).add(i).toBytes();return{signers:{min:r.signers.min,max:r.signers.max},commitments:o,verifyingShares:s}}var zf,OM,Ud,FS,Cr,Ve,TM,qS,la,KS,fn,Xo,BM,NM,MM,jS,kM,qd,CM,DM,XS=Yt(()=>{p();yd();On();Gf();RS();AS();$i();US();si();zf={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},OM={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]},Ud=BigInt(0),FS=BigInt(2);Cr=Yo(zf.p,{sqrt:RM}),Ve=kS(zf,{Fp:Cr,endo:OM}),TM=DS(Ve,ni),qS=Object.create(null);la=e=>e.toBytes(!0).slice(1),KS=({x:e})=>Cr.toBytes(e),fn=e=>!Cr.isOdd(e);Xo=kt;BM=Object.freeze({lift_x:Yf,frostTweakPublic:$S,frostTweakSecret:YS}),NM=(()=>{let r=n=>(n=n===void 0?oa(48):n,Yi(Se(n,48,"seed"),zf.n));return Object.freeze({keygen:Kf(r,HS),getPublicKey:HS,sign:PM,verify:VS,Point:Ve,utils:Object.freeze({randomSecretKey:r,taggedHash:ca,lift_x:Yf,pointToBytes:la}),lengths:Object.freeze({secretKey:32,publicKey:32,publicKeyHasPrefix:!1,signature:64,seed:48})})})(),MM=ES(Cr,[["0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa8c7","0x7d3d4c80bc321d5b9f315cea7fd44c5d595d2fc0bf63b92dfff1044f17c6581","0x534c328d23f234e6e2a413deca25caece4506144037c40314ecbd0b53d9dd262","0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa88c"],["0xd35771193d94918a9ca34ccbb7b640dd86cd409542f8487d9fe6b745781eb49b","0xedadc6f64383dc1df7c4b2d51b54225406d36b641f5e41bbc52a56612a8c6d14","0x0000000000000000000000000000000000000000000000000000000000000001"],["0x4bda12f684bda12f684bda12f684bda12f684bda12f684bda12f684b8e38e23c","0xc75e0c32d5cb7c0fa9d0a54b12a0a6d5647ab046d686da6fdffc90fc201d71a3","0x29a6194691f91a73715209ef6512e576722830a201be2018a765e85a9ecee931","0x2f684bda12f684bda12f684bda12f684bda12f684bda12f684bda12f38e38d84"],["0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffff93b","0x7a06534bb8bdb49fd5e9e6632722c2989467c1bfc8e8d978dfb425d2685c2573","0x6484aa716545ca2cf3a70c3fa8fe337e0a3d21162f0d6299a7bf8192bfd2a76f","0x0000000000000000000000000000000000000000000000000000000000000001"]].map(e=>e.map(t=>BigInt(t)))),kM=()=>jS||(jS=IS(Cr,{A:BigInt("0x3f8731abdd661adca08a5558f0f5d272e953d363cb6f0e5d405447c01a444533"),B:BigInt("1771"),Z:Cr.create(BigInt("-11"))})),qd=xS(Ve,e=>{let{x:t,y:r}=kM()(Cr.create(e[0]));return MM(t,r)},{DST:"secp256k1_XMD:SHA-256_SSWU_RO_",encodeDST:"secp256k1_XMD:SHA-256_SSWU_NU_",p:Cr.ORDER,m:1,k:128,expand:"xmd",hash:ni}),CM=Nd({name:"FROST-secp256k1-SHA256-v1",Point:Ve,hashToScalar:qd.hashToScalar,hash:ni});DM=Nd({name:"FROST-secp256k1-SHA256-TR-v1",Point:Ve,hashToScalar:qd.hashToScalar,hash:ni,parsePublicKey(e){if(e.length===32)return Yf(kt(e));if(e.length===33)return Ve.fromBytes(e);throw new Error(`expected x-only or compressed public key, got length=${e.length}`)},adjustScalar(e){let t=Ve.BASE.multiply(e);return fn(t.y)?e:Ve.Fn.neg(e)},adjustPoint:e=>fn(e.y)?e:e.negate(),challenge(e,t,r){return Fd(la(e),la(t),r)},adjustNonces:LM,adjustGroupCommitmentShare:(e,t)=>fn(e.y)?t:t.negate(),adjustPublic:Hd,adjustSecret:zS,adjustTx:{encode:e=>e.subarray(1),decode:e=>De(Uint8Array.of(2),e)},adjustDKG:e=>{let t=new Uint8Array(0);return{public:$S(e.public,t),secret:YS(e.secret,e.public,t)}}})});var ci=B((EF,tw)=>{"use strict";p();var JS=Er(),{secp256k1:UM}=(XS(),cl(ZS)),da=UM.Point,$f=da.Fn.ORDER;function FM(e){return BigInt("0x"+(e.toString(16)||"0"))}function jd(e){var t=e.toString(16);return t.length%2&&(t="0"+t),new JS(t,16)}function Zf(e){if(e==null)throw new Error("Invalid Point");if(typeof e=="bigint")return e;if(typeof e=="number")return BigInt(e);if(typeof e=="string")return BigInt(e.indexOf("0x")===0?e:"0x"+e);if(typeof e.toString=="function")return FM(e);throw new Error("Invalid Point")}function ha(e){var t=Object.create(We.prototype);return t._p=e,t}function QS(e,t){var r=Zf(t).toString(16).padStart(64,"0");return da.fromHex((e?"03":"02")+r)}function ew(e,t){var r;try{r=QS((t&1n)===1n,e)}catch{throw new Error("Point does not lie on the curve")}if(r.toAffine().y!==t)throw new Error("Invalid y value for curve.")}function We(e,t,r){if(!(this instanceof We))return new We(e,t,r);var n,i;try{n=Zf(e),i=Zf(t)}catch{throw new Error("Invalid Point")}ew(n,i);try{this._p=da.fromAffine({x:n,y:i})}catch{throw new Error("Invalid Point")}return this}We.fromX=function(t,r){try{var n=ha(QS(t,r))}catch{throw new Error("Invalid X")}return n.validate(),n};We.getG=function(){return ha(da.BASE)};We.getN=function(){return jd($f)};We.prototype.getX=function(){return jd(this._p.toAffine().x)};We.prototype.getY=function(){return jd(this._p.toAffine().y)};Object.defineProperty(We.prototype,"x",{configurable:!0,enumerable:!0,get:function(){return this.getX()}});Object.defineProperty(We.prototype,"y",{configurable:!0,enumerable:!0,get:function(){return this.getY()}});We.prototype.mul=function(t){var r=(Zf(t)%$f+$f)%$f;return r===0n||this._p.is0()?ha(da.ZERO):ha(this._p.multiply(r))};We.prototype.add=function(t){return ha(this._p.add(t._p))};We.prototype.mulAdd=function(t,r,n){return this.mul(t).add(r.mul(n))};We.prototype.eq=function(t){return this._p.equals(t._p)};We.prototype.isInfinity=function(){return this._p.is0()};We.prototype.validate=function(){if(this.isInfinity())throw new Error("Point cannot be equal to Infinity");var t=this._p.toAffine();return ew(t.x,t.y),this};We.pointToCompressed=function(t){var r=t.getX().toBuffer({size:32}),n=t.getY().toBuffer({size:32}),i,o=n[n.length-1]%2;return o?i=d.Buffer.from([3]):i=d.Buffer.from([2]),d.Buffer.concat([i,r])};We.pointFromCompressed=function(e){if(e.length!==33)throw new Error("invalid buffer length");var t=e[0],r;if(t===3)r=!0;else if(t===2)r=!1;else throw new Error("invalid value of compressed prefix");var n=JS.fromBuffer(e.slice(1,33));return We.fromX(r,n)};We.prototype.toBuffer=function(){return We.pointToCompressed(this)};We.prototype.toHex=function(){return this.toBuffer().toString("hex")};We.fromBuffer=function(e){return We.pointFromCompressed(e)};We.fromHex=function(e){return We.fromBuffer(d.Buffer.from(e,"hex"))};tw.exports=We});var nw=B((IF,rw)=>{"use strict";p();var Xf=ea(),Nn=Fe(),Tt=rw.exports;Tt.sha1=function(e){return Nn.checkArgument(d.Buffer.isBuffer(e)),Xf.createHash("sha1").update(e).digest()};Tt.sha1.blocksize=512;Tt.sha256=function(e){return Nn.checkArgument(d.Buffer.isBuffer(e)),Xf.createHash("sha256").update(e).digest()};Tt.sha256.blocksize=512;Tt.sha256sha256=function(e){return Nn.checkArgument(d.Buffer.isBuffer(e)),Tt.sha256(Tt.sha256(e))};Tt.ripemd160=function(e){return Nn.checkArgument(d.Buffer.isBuffer(e)),Xf.createHash("ripemd160").update(e).digest()};Tt.sha256ripemd160=function(e){return Nn.checkArgument(d.Buffer.isBuffer(e)),Tt.ripemd160(Tt.sha256(e))};Tt.sha512=function(e){return Nn.checkArgument(d.Buffer.isBuffer(e)),Xf.createHash("sha512").update(e).digest()};Tt.sha512.blocksize=1024;Tt.hmac=function(e,t,r){Nn.checkArgument(d.Buffer.isBuffer(t)),Nn.checkArgument(d.Buffer.isBuffer(r)),Nn.checkArgument(e.blocksize);var n=e.blocksize/8;if(r.length>n)r=e(r);else if(r.length<n){var i=d.Buffer.alloc(n);i.fill(0),r.copy(i),r=i}var o=d.Buffer.alloc(n);o.fill(92);var s=d.Buffer.alloc(n);s.fill(54);for(var a=d.Buffer.alloc(n),f=d.Buffer.alloc(n),l=0;l<n;l++)a[l]=o[l]^r[l],f[l]=s[l]^r[l];return e(d.Buffer.concat([a,e(d.Buffer.concat([f,t]))]))};Tt.sha256hmac=function(e,t){return Tt.hmac(Tt.sha256,e,t)};Tt.sha512hmac=function(e,t){return Tt.hmac(Tt.sha512,e,t)}});var cw={};fl(cw,{_MD5:()=>tc,_RIPEMD160:()=>rc,_SHA1:()=>ec,md5:()=>GM,ripemd160:()=>XM,sha1:()=>qM});function iw(e,t,r,n){return e===0?t^r^n:e===1?t&r|~t&n:e===2?(t|~r)^n:e===3?t&n|r&~n:t^(r|~n)}var Jo,li,ec,qM,HM,jM,Jf,Kd,KM,tc,GM,VM,ow,WM,sw,aw,uw,fw,zM,YM,$M,ZM,Qf,rc,XM,lw=Yt(()=>{p();gd();On();Jo=Uint32Array.from([1732584193,4023233417,2562383102,271733878,3285377520]),li=new Uint32Array(80),ec=class extends Rn{constructor(){super(64,20,8,!1);Z(this,"A",Jo[0]|0);Z(this,"B",Jo[1]|0);Z(this,"C",Jo[2]|0);Z(this,"D",Jo[3]|0);Z(this,"E",Jo[4]|0)}get(){let{A:r,B:n,C:i,D:o,E:s}=this;return[r,n,i,o,s]}set(r,n,i,o,s){this.A=r|0,this.B=n|0,this.C=i|0,this.D=o|0,this.E=s|0}_cloneInto(r){return(r||(r=new this.constructor)).set(...this.get()),this._cloneIntoMeta(r)}process(r,n){for(let l=0;l<16;l++,n+=4)li[l]=r.getUint32(n,!1);for(let l=16;l<80;l++)li[l]=In(li[l-3]^li[l-8]^li[l-14]^li[l-16],1);let{A:i,B:o,C:s,D:a,E:f}=this;for(let l=0;l<80;l++){let y,g;l<20?(y=Ho(o,s,a),g=1518500249):l<40?(y=o^s^a,g=1859775393):l<60?(y=Tf(o,s,a),g=2400959708):(y=o^s^a,g=3395469782);let v=In(i,5)+y+f+g+li[l]|0;f=a,a=s,s=In(o,30),o=i,i=v}i=i+this.A|0,o=o+this.B|0,s=s+this.C|0,a=a+this.D|0,f=f+this.E|0,this.set(i,o,s,a,f)}roundClean(){ur(li)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0),ur(this.buffer)}},qM=kr(()=>new ec),HM=Math.pow(2,32),jM=Array.from({length:64},(e,t)=>Math.floor(HM*Math.abs(Math.sin(t+1)))),Jf=Jo.slice(0,4),Kd=new Uint32Array(16),KM=(()=>{let e=[[7,12,17,22],[5,9,14,20],[4,11,16,23],[6,10,15,21]];return Uint8Array.from({length:64},(t,r)=>e[Math.floor(r/16)][r%4])})(),tc=class extends Rn{constructor(){super(64,16,8,!0);Z(this,"A",Jf[0]|0);Z(this,"B",Jf[1]|0);Z(this,"C",Jf[2]|0);Z(this,"D",Jf[3]|0)}get(){let{A:r,B:n,C:i,D:o}=this;return[r,n,i,o]}set(r,n,i,o){this.A=r|0,this.B=n|0,this.C=i|0,this.D=o|0}_cloneInto(r){return(r||(r=new this.constructor)).set(...this.get()),this._cloneIntoMeta(r)}process(r,n){for(let f=0;f<16;f++,n+=4)Kd[f]=r.getUint32(n,!0);let{A:i,B:o,C:s,D:a}=this;for(let f=0;f<64;f++){let l,y;f<16?(l=Ho(o,s,a),y=f):f<32?(l=Ho(a,o,s),y=(5*f+1)%16):f<48?(l=o^s^a,y=(3*f+5)%16):(l=s^(o|~a),y=7*f%16),l=l+i+jM[f]+Kd[y],i=a,a=s,s=o,o=o+In(l,KM[f])}i=i+this.A|0,o=o+this.B|0,s=s+this.C|0,a=a+this.D|0,this.set(i,o,s,a)}roundClean(){ur(Kd)}destroy(){this.destroyed=!0,this.set(0,0,0,0),ur(this.buffer)}},GM=kr(()=>new tc),VM=Uint8Array.from([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),ow=Uint8Array.from(new Array(16).fill(0).map((e,t)=>t)),WM=ow.map(e=>(9*e+5)%16),sw=(()=>{let r=[[ow],[WM]];for(let n=0;n<4;n++)for(let i of r)i.push(i[n].map(o=>VM[o]));return r})(),aw=sw[0],uw=sw[1],fw=[[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(e=>Uint8Array.from(e)),zM=aw.map((e,t)=>e.map(r=>fw[t][r])),YM=uw.map((e,t)=>e.map(r=>fw[t][r])),$M=Uint32Array.from([0,1518500249,1859775393,2400959708,2840853838]),ZM=Uint32Array.from([1352829926,1548603684,1836072691,2053994217,0]);Qf=new Uint32Array(16),rc=class extends Rn{constructor(){super(64,20,8,!0);Z(this,"h0",1732584193);Z(this,"h1",-271733879);Z(this,"h2",-1732584194);Z(this,"h3",271733878);Z(this,"h4",-1009589776)}get(){let{h0:r,h1:n,h2:i,h3:o,h4:s}=this;return[r,n,i,o,s]}set(r,n,i,o,s){this.h0=r|0,this.h1=n|0,this.h2=i|0,this.h3=o|0,this.h4=s|0}_cloneInto(r){return(r||(r=new this.constructor)).set(...this.get()),this._cloneIntoMeta(r)}process(r,n){for(let T=0;T<16;T++,n+=4)Qf[T]=r.getUint32(n,!0);let i=this.h0|0,o=i,s=this.h1|0,a=s,f=this.h2|0,l=f,y=this.h3|0,g=y,v=this.h4|0,E=v;for(let T=0;T<5;T++){let M=4-T,L=$M[T],F=ZM[T],V=aw[T],z=uw[T],G=zM[T],ie=YM[T];for(let te=0;te<16;te++){let pe=In(i+iw(T,s,f,y)+Qf[V[te]]+L,G[te])+v|0;i=v,v=y,y=In(f,10)|0,f=s,s=pe}for(let te=0;te<16;te++){let pe=In(o+iw(M,a,l,g)+Qf[z[te]]+F,ie[te])+E|0;o=E,E=g,g=In(l,10)|0,l=a,a=pe}}this.set(this.h1+f+g|0,this.h2+y+E|0,this.h3+v+o|0,this.h4+i+a|0,this.h0+s+l|0)}roundClean(){ur(Qf)}destroy(){this.destroyed=!0,ur(this.buffer),this.set(0,0,0,0,0)}},XM=kr(()=>new rc)});var dw=B((BF,hw)=>{"use strict";p();var{sha256:JM,sha512:QM}=(yd(),cl(Y_)),{sha1:ek,ripemd160:tk}=(lw(),cl(cw)),Mn=Fe(),Pt=hw.exports;Pt.sha1=function(e){return Mn.checkArgument(d.Buffer.isBuffer(e)),d.Buffer.from(ek(e))};Pt.sha1.blocksize=512;Pt.sha256=function(e){return Mn.checkArgument(d.Buffer.isBuffer(e)),d.Buffer.from(JM(e))};Pt.sha256.blocksize=512;Pt.sha256sha256=function(e){return Mn.checkArgument(d.Buffer.isBuffer(e)),Pt.sha256(Pt.sha256(e))};Pt.ripemd160=function(e){return Mn.checkArgument(d.Buffer.isBuffer(e)),d.Buffer.from(tk(e))};Pt.sha256ripemd160=function(e){return Mn.checkArgument(d.Buffer.isBuffer(e)),Pt.ripemd160(Pt.sha256(e))};Pt.sha512=function(e){return Mn.checkArgument(d.Buffer.isBuffer(e)),d.Buffer.from(QM(e))};Pt.sha512.blocksize=1024;Pt.hmac=function(e,t,r){Mn.checkArgument(d.Buffer.isBuffer(t)),Mn.checkArgument(d.Buffer.isBuffer(r)),Mn.checkArgument(e.blocksize);var n=e.blocksize/8;if(r.length>n)r=e(r);else if(r.length<n){var i=d.Buffer.alloc(n);i.fill(0),r.copy(i),r=i}var o=d.Buffer.alloc(n);o.fill(92);var s=d.Buffer.alloc(n);s.fill(54);for(var a=d.Buffer.alloc(n),f=d.Buffer.alloc(n),l=0;l<n;l++)a[l]=o[l]^r[l],f[l]=s[l]^r[l];return e(d.Buffer.concat([a,e(d.Buffer.concat([f,t]))]))};Pt.sha256hmac=function(e,t){return Pt.hmac(Pt.sha256,e,t)};Pt.sha512hmac=function(e,t){return Pt.hmac(Pt.sha512,e,t)}});var er=B((MF,gw)=>{"use strict";p();var pw={sha1:"a9993e364706816aba3e25717850c26c9cd0d89d",sha256:"ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad",sha512:"ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f",ripemd160:"8eb208f7e05d987a9b044a8e98c6b087f15a0bfc"};function rk(){var e;try{e=ea()}catch{return!1}if(!e||typeof e.createHash!="function")return!1;for(var t=Object.keys(pw),r=0;r<t.length;r++){var n=t[r];try{if(e.createHash(n).update("abc").digest("hex")!==pw[n])return!1}catch{return!1}}return!0}gw.exports=rk()?nw():dw()});var gr=B((CF,vw)=>{"use strict";p();var mw=Ze(),nk=Fe(),yw=function(t){return mw.isString(t)?/^[0-9a-fA-F]+$/.test(t):!1};vw.exports={isValidJSON:function(t){var r;if(!mw.isString(t))return!1;try{r=JSON.parse(t)}catch{return!1}return typeof r=="object"},isHexa:yw,isHexaString:yw,defineImmutable:function(t,r){return Object.keys(r).forEach(function(n){Object.defineProperty(t,n,{configurable:!1,enumerable:!0,value:r[n]})}),t},isNaturalNumber:function(t){return typeof t=="number"&&isFinite(t)&&Math.floor(t)===t&&t>=0},integerAsBuffer:function(t){nk.checkArgumentType(t,"number","integer");let r=d.Buffer.allocUnsafe(4);return r.writeUInt32BE(t,0),r}}});var va=B((DF,Sw)=>{"use strict";p();var kn=Ze(),pa=gr(),Qi=[],ga={};function bw(){}bw.prototype.toString=function(){return this.name};function ya(e,t){if(~Qi.indexOf(e))return e;if(t){kn.isArray(t)||(t=[t]);for(var r=0;r<Qi.length;r++){var n=Qi[r],i=kn.pick(n,t),o=kn.values(i);if(~o.indexOf(e))return n}return}return ga[e]}function nc(e){for(var t=[],r=0;r<e.length;r++)t.push(e.charCodeAt(r)&31);return t}function ma(e){var t=new bw;pa.defineImmutable(t,{name:e.name,alias:e.alias,pubkeyhash:e.pubkeyhash,privatekey:e.privatekey,scripthash:e.scripthash,xpubkey:e.xpubkey,xprivkey:e.xprivkey});var r=e.indexBy||Object.keys(e);return e.cashAddrPrefix&&kn.extend(t,{cashAddrPrefix:e.cashAddrPrefix,cashAddrPrefixArray:nc(e.cashAddrPrefix)}),e.networkMagic&&kn.extend(t,{networkMagic:pa.integerAsBuffer(e.networkMagic)}),e.port&&kn.extend(t,{port:e.port}),e.dnsSeeds&&kn.extend(t,{dnsSeeds:e.dnsSeeds}),Qi.push(t),ik(t,r),t}function ik(e,t){for(var r=0;r<t.length;r++){var n=t[r],i=e[n];!kn.isUndefined(i)&&!kn.isObject(i)&&(ga[i]=e)}}function ok(e,t){for(var r=0;r<t.length;r++){var n=t[r];ga[n]===e&&delete ga[n]}}function sk(e){for(var t=0;t<Qi.length;t++)Qi[t]===e&&Qi.splice(t,1);ok(e,Object.keys(ga))}var ic={livenet:3823236072,testnet:4108710900,regtest:3669344250,stn:4224632057},_w=["seed.bitcoinsv.org","seed.bitcoinunlimited.info"],hi={PORT:18333,NETWORK_MAGIC:ic.testnet,DNS_SEEDS:_w,PREFIX:"testnet",CASHADDRPREFIX:"bchtest"},Cn={PORT:18444,NETWORK_MAGIC:ic.regtest,DNS_SEEDS:[],PREFIX:"regtest",CASHADDRPREFIX:"bchreg"},di={PORT:9333,NETWORK_MAGIC:ic.stn,DNS_SEEDS:["stn-seed.bitcoinsv.io"],PREFIX:"stn",CASHADDRPREFIX:"bsvstn"},ak={name:"livenet",alias:"mainnet",prefix:"bitcoin",cashAddrPrefix:"bitcoincash",pubkeyhash:0,privatekey:128,scripthash:5,xpubkey:76067358,xprivkey:76066276,networkMagic:ic.livenet,port:8333,dnsSeeds:_w},uk={name:"testnet",prefix:hi.PREFIX,cashAddrPrefix:hi.CASHADDRPREFIX,pubkeyhash:111,privatekey:239,scripthash:196,xpubkey:70617039,xprivkey:70615956,networkMagic:hi.NETWORK_MAGIC},fk={name:"regtest",prefix:Cn.PREFIX,cashAddrPrefix:Cn.CASHADDRPREFIX,pubkeyhash:111,privatekey:239,scripthash:196,xpubkey:70617039,xprivkey:70615956,networkMagic:Cn.NETWORK_MAGIC,port:Cn.PORT,dnsSeeds:[],indexBy:["port","name","cashAddrPrefix","networkMagic"]},ck={name:"stn",prefix:di.PREFIX,cashAddrPrefix:di.CASHADDRPREFIX,pubkeyhash:111,privatekey:239,scripthash:196,xpubkey:70617039,xprivkey:70615956,networkMagic:di.NETWORK_MAGIC,indexBy:["port","name","cashAddrPrefix","networkMagic"]};ma(uk);ma(ck);ma(fk);ma(ak);var Gd=ya("livenet"),lk=ya("regtest"),cn=ya("testnet"),hk=ya("stn");Object.defineProperty(cn,"port",{enumerable:!0,configurable:!1,get:function(){return this.regtestEnabled?Cn.PORT:this.stnEnabled?di.PORT:hi.PORT}});Object.defineProperty(cn,"networkMagic",{enumerable:!0,configurable:!1,get:function(){return this.regtestEnabled?pa.integerAsBuffer(Cn.NETWORK_MAGIC):this.stnEnabled?pa.integerAsBuffer(di.NETWORK_MAGIC):pa.integerAsBuffer(hi.NETWORK_MAGIC)}});Object.defineProperty(cn,"dnsSeeds",{enumerable:!0,configurable:!1,get:function(){return this.regtestEnabled?Cn.DNS_SEEDS:this.stnEnabled?di.DNS_SEEDS:hi.DNS_SEEDS}});Object.defineProperty(cn,"cashAddrPrefix",{enumerable:!0,configurable:!1,get:function(){return this.regtestEnabled?Cn.CASHADDRPREFIX:this.stnEnabled?di.CASHADDRPREFIX:hi.CASHADDRPREFIX}});Object.defineProperty(cn,"cashAddrPrefixArray",{enumerable:!0,configurable:!1,get:function(){return this.regtestEnabled?nc(Cn.CASHADDRPREFIX):this.stnEnabled?nc(di.CASHADDRPREFIX):nc(hi.CASHADDRPREFIX)}});function dk(){cn.regtestEnabled=!0}function pk(){cn.regtestEnabled=!1}function gk(){cn.stnEnabled=!0}function yk(){cn.stnEnabled=!1}Sw.exports={add:ma,remove:sk,defaultNetwork:Gd,livenet:Gd,mainnet:Gd,testnet:cn,regtest:lk,stn:hk,get:ya,enableRegtest:dk,disableRegtest:pk,enableStn:gk,disableStn:yk}});var Iw=B((FF,xw)=>{"use strict";p();var Vd=Ze(),ww=Mt(),Qo="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz".split(""),Ew={};for(ba=0;ba<Qo.length;ba++)Ew[Qo[ba]]=ba;var ba;function mk(e){if(e.length===0)return"";var t=[0],r,n,i;for(r=0;r<e.length;r++){for(n=0,i=e[r];n<t.length;n++)i+=t[n]<<8,t[n]=i%58,i=i/58|0;for(;i>0;)t.push(i%58),i=i/58|0}var o="";for(r=0;e[r]===0&&r<e.length-1;r++)o+=Qo[0];for(r=t.length-1;r>=0;r--)o+=Qo[t[r]];return o}function vk(e){if(e.length===0)return d.Buffer.alloc(0);var t=[0],r,n,i;for(r=0;r<e.length;r++){var o=Ew[e[r]];if(o===void 0)throw new Error("Non-base58 character");for(n=0,i=o;n<t.length;n++)i+=t[n]*58,t[n]=i&255,i>>=8;for(;i>0;)t.push(i&255),i>>=8}for(r=0;e[r]===Qo[0]&&r<e.length-1;r++)t.push(0);return d.Buffer.from(t.reverse())}var Kt=function e(t){if(!(this instanceof e))return new e(t);if(d.Buffer.isBuffer(t)){var r=t;this.fromBuffer(r)}else if(typeof t=="string"){var n=t;this.fromString(n)}};Kt.validCharacters=function(t){return ww.Buffer.isBuffer(t)&&(t=t.toString()),Vd.every(Vd.map(t,function(r){return Vd.includes(Qo,r)}))};Kt.prototype.set=function(e){return this.buf=e.buf||this.buf||void 0,this};Kt.encode=function(e){if(!ww.Buffer.isBuffer(e))throw new Error("Input should be a buffer");return mk(e)};Kt.decode=function(e){if(typeof e!="string")throw new Error("Input should be a string");return vk(e)};Kt.prototype.fromBuffer=function(e){return this.buf=e,this};Kt.fromBuffer=function(e){return new Kt().fromBuffer(e)};Kt.fromHex=function(e){return Kt.fromBuffer(d.Buffer.from(e,"hex"))};Kt.prototype.fromString=function(e){var t=Kt.decode(e);return this.buf=t,this};Kt.fromString=function(e){return new Kt().fromString(e)};Kt.prototype.toBuffer=function(){return this.buf};Kt.prototype.toHex=function(){return this.toBuffer().toString("hex")};Kt.prototype.toString=function(){return Kt.encode(this.buf)};xw.exports=Kt});var Wd=B((HF,Tw)=>{"use strict";p();var Aw=Ze(),oc=Iw(),Ow=Mt(),Rw=er().sha256sha256,rt=function e(t){if(!(this instanceof e))return new e(t);if(d.Buffer.isBuffer(t)){var r=t;this.fromBuffer(r)}else if(typeof t=="string"){var n=t;this.fromString(n)}};rt.prototype.set=function(e){return this.buf=e.buf||this.buf||void 0,this};rt.validChecksum=function(t,r){return Aw.isString(t)&&(t=Ow.Buffer.from(oc.decode(t))),Aw.isString(r)&&(r=Ow.Buffer.from(oc.decode(r))),r||(r=t.slice(-4),t=t.slice(0,-4)),rt.checksum(t).toString("hex")===r.toString("hex")};rt.decode=function(e){if(typeof e!="string")throw new Error("Input must be a string");var t=d.Buffer.from(oc.decode(e));if(t.length<4)throw new Error("Input string too short");var r=t.slice(0,-4),n=t.slice(-4),i=Rw(r),o=i.slice(0,4);if(n.toString("hex")!==o.toString("hex"))throw new Error("Checksum mismatch");return r};rt.checksum=function(e){return Rw(e).slice(0,4)};rt.encode=function(e){if(!d.Buffer.isBuffer(e))throw new Error("Input must be a buffer");var t=d.Buffer.alloc(e.length+4),r=rt.checksum(e);return e.copy(t),r.copy(t,e.length),oc.encode(t)};rt.prototype.fromBuffer=function(e){return this.buf=e,this};rt.fromBuffer=function(e){return new rt().fromBuffer(e)};rt.fromHex=function(e){return rt.fromBuffer(d.Buffer.from(e,"hex"))};rt.prototype.fromString=function(e){var t=rt.decode(e);return this.buf=t,this};rt.fromString=function(e){var t=rt.decode(e);return new rt(t)};rt.prototype.toBuffer=function(){return this.buf};rt.prototype.toHex=function(){return this.toBuffer().toString("hex")};rt.prototype.toString=function(){return rt.encode(this.buf)};Tw.exports=rt});var $d=B((KF,Mw)=>{"use strict";p();function pi(e){"@babel/helpers - typeof";return pi=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},pi(e)}function Pw(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,_k(n.key),n)}}function bk(e,t,r){return t&&Pw(e.prototype,t),r&&Pw(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function _k(e){var t=Sk(e,"string");return pi(t)==="symbol"?t:String(t)}function Sk(e,t){if(pi(e)!=="object"||e===null)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t||"default");if(pi(n)!=="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function wk(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Ek(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&Yd(e,t)}function Yd(e,t){return Yd=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,i){return n.__proto__=i,n},Yd(e,t)}function xk(e){var t=Ok();return function(){var n=sc(e),i;if(t){var o=sc(this).constructor;i=Reflect.construct(n,arguments,o)}else i=n.apply(this,arguments);return Ik(this,i)}}function Ik(e,t){if(t&&(pi(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Ak(e)}function Ak(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Ok(){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 sc(e){return sc=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},sc(e)}var Nw={},es,zd;function _a(e,t,r){r||(r=Error);function n(o,s,a){return typeof t=="string"?t:t(o,s,a)}var i=(function(o){Ek(a,o);var s=xk(a);function a(f,l,y){var g;return wk(this,a),g=s.call(this,n(f,l,y)),g.code=e,g}return bk(a)})(r);Nw[e]=i}function Bw(e,t){if(Array.isArray(e)){var r=e.length;return e=e.map(function(n){return String(n)}),r>2?"one of ".concat(t," ").concat(e.slice(0,r-1).join(", "),", or ")+e[r-1]:r===2?"one of ".concat(t," ").concat(e[0]," or ").concat(e[1]):"of ".concat(t," ").concat(e[0])}else return"of ".concat(t," ").concat(String(e))}function Rk(e,t,r){return e.substr(!r||r<0?0:+r,t.length)===t}function Tk(e,t,r){return(r===void 0||r>e.length)&&(r=e.length),e.substring(r-t.length,r)===t}function Pk(e,t,r){return typeof r!="number"&&(r=0),r+t.length>e.length?!1:e.indexOf(t,r)!==-1}_a("ERR_AMBIGUOUS_ARGUMENT",'The "%s" argument is ambiguous. %s',TypeError);_a("ERR_INVALID_ARG_TYPE",function(e,t,r){es===void 0&&(es=Sa()),es(typeof e=="string","'name' must be a string");var n;typeof t=="string"&&Rk(t,"not ")?(n="must not be",t=t.replace(/^not /,"")):n="must be";var i;if(Tk(e," argument"))i="The ".concat(e," ").concat(n," ").concat(Bw(t,"type"));else{var o=Pk(e,".")?"property":"argument";i='The "'.concat(e,'" ').concat(o," ").concat(n," ").concat(Bw(t,"type"))}return i+=". Received type ".concat(pi(r)),i},TypeError);_a("ERR_INVALID_ARG_VALUE",function(e,t){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"is invalid";zd===void 0&&(zd=Jr());var n=zd.inspect(t);return n.length>128&&(n="".concat(n.slice(0,128),"...")),"The argument '".concat(e,"' ").concat(r,". Received ").concat(n)},TypeError,RangeError);_a("ERR_INVALID_RETURN_VALUE",function(e,t,r){var n;return r&&r.constructor&&r.constructor.name?n="instance of ".concat(r.constructor.name):n="type ".concat(pi(r)),"Expected ".concat(e,' to be returned from the "').concat(t,'"')+" function but got ".concat(n,".")},TypeError);_a("ERR_MISSING_ARGS",function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];es===void 0&&(es=Sa()),es(t.length>0,"At least one arg needs to be specified");var n="The ",i=t.length;switch(t=t.map(function(o){return'"'.concat(o,'"')}),i){case 1:n+="".concat(t[0]," argument");break;case 2:n+="".concat(t[0]," and ").concat(t[1]," arguments");break;default:n+=t.slice(0,i-1).join(", "),n+=", and ".concat(t[i-1]," arguments");break}return"".concat(n," must be specified")},TypeError);Mw.exports.codes=Nw});var Kw=B((VF,jw)=>{"use strict";p();function kw(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function Cw(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?kw(Object(r),!0).forEach(function(n){Bk(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):kw(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function Bk(e,t,r){return t=Fw(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Nk(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Lw(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,Fw(n.key),n)}}function Mk(e,t,r){return t&&Lw(e.prototype,t),r&&Lw(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function Fw(e){var t=kk(e,"string");return fr(t)==="symbol"?t:String(t)}function kk(e,t){if(fr(e)!=="object"||e===null)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t||"default");if(fr(n)!=="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function Ck(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&Ia(e,t)}function Lk(e){var t=Hw();return function(){var n=Aa(e),i;if(t){var o=Aa(this).constructor;i=Reflect.construct(n,arguments,o)}else i=n.apply(this,arguments);return qw(this,i)}}function qw(e,t){if(t&&(fr(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Zd(e)}function Zd(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Xd(e){var t=typeof Map=="function"?new Map:void 0;return Xd=function(n){if(n===null||!Dk(n))return n;if(typeof n!="function")throw new TypeError("Super expression must either be null or a function");if(typeof t<"u"){if(t.has(n))return t.get(n);t.set(n,i)}function i(){return ac(n,arguments,Aa(this).constructor)}return i.prototype=Object.create(n.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),Ia(i,n)},Xd(e)}function ac(e,t,r){return Hw()?ac=Reflect.construct.bind():ac=function(i,o,s){var a=[null];a.push.apply(a,o);var f=Function.bind.apply(i,a),l=new f;return s&&Ia(l,s.prototype),l},ac.apply(null,arguments)}function Hw(){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 Dk(e){return Function.toString.call(e).indexOf("[native code]")!==-1}function Ia(e,t){return Ia=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,i){return n.__proto__=i,n},Ia(e,t)}function Aa(e){return Aa=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},Aa(e)}function fr(e){"@babel/helpers - typeof";return fr=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},fr(e)}var Uk=Jr(),Jd=Uk.inspect,Fk=$d(),qk=Fk.codes.ERR_INVALID_ARG_TYPE;function Dw(e,t,r){return(r===void 0||r>e.length)&&(r=e.length),e.substring(r-t.length,r)===t}function Hk(e,t){if(t=Math.floor(t),e.length==0||t==0)return"";var r=e.length*t;for(t=Math.floor(Math.log(t)/Math.log(2));t;)e+=e,t--;return e+=e.substring(0,r-e.length),e}var Lr="",wa="",Ea="",zt="",eo={deepStrictEqual:"Expected values to be strictly deep-equal:",strictEqual:"Expected values to be strictly equal:",strictEqualObject:'Expected "actual" to be reference-equal to "expected":',deepEqual:"Expected values to be loosely deep-equal:",equal:"Expected values to be loosely equal:",notDeepStrictEqual:'Expected "actual" not to be strictly deep-equal to:',notStrictEqual:'Expected "actual" to be strictly unequal to:',notStrictEqualObject:'Expected "actual" not to be reference-equal to "expected":',notDeepEqual:'Expected "actual" not to be loosely deep-equal to:',notEqual:'Expected "actual" to be loosely unequal to:',notIdentical:"Values identical but not reference-equal:"},jk=10;function Uw(e){var t=Object.keys(e),r=Object.create(Object.getPrototypeOf(e));return t.forEach(function(n){r[n]=e[n]}),Object.defineProperty(r,"message",{value:e.message}),r}function xa(e){return Jd(e,{compact:!1,customInspect:!1,depth:1e3,maxArrayLength:1/0,showHidden:!1,breakLength:1/0,showProxy:!1,sorted:!0,getters:!0})}function Kk(e,t,r){var n="",i="",o=0,s="",a=!1,f=xa(e),l=f.split(`
14
- `),y=xa(t).split(`
15
- `),g=0,v="";if(r==="strictEqual"&&fr(e)==="object"&&fr(t)==="object"&&e!==null&&t!==null&&(r="strictEqualObject"),l.length===1&&y.length===1&&l[0]!==y[0]){var E=l[0].length+y[0].length;if(E<=jk){if((fr(e)!=="object"||e===null)&&(fr(t)!=="object"||t===null)&&(e!==0||t!==0))return"".concat(eo[r],`
10
+ `)+" "+r[1]:r[0]+t+" "+e.join(", ")+" "+r[1]}Me.types=_m();function Im(e){return Array.isArray(e)}Me.isArray=Im;function fh(e){return typeof e=="boolean"}Me.isBoolean=fh;function qu(e){return e===null}Me.isNull=qu;function kR(e){return e==null}Me.isNullOrUndefined=kR;function Am(e){return typeof e=="number"}Me.isNumber=Am;function Hu(e){return typeof e=="string"}Me.isString=Hu;function CR(e){return typeof e=="symbol"}Me.isSymbol=CR;function Li(e){return e===void 0}Me.isUndefined=Li;function Bs(e){return Bo(e)&&ch(e)==="[object RegExp]"}Me.isRegExp=Bs;Me.types.isRegExp=Bs;function Bo(e){return typeof e=="object"&&e!==null}Me.isObject=Bo;function Fu(e){return Bo(e)&&ch(e)==="[object Date]"}Me.isDate=Fu;Me.types.isDate=Fu;function Ns(e){return Bo(e)&&(ch(e)==="[object Error]"||e instanceof Error)}Me.isError=Ns;Me.types.isNativeError=Ns;function Du(e){return typeof e=="function"}Me.isFunction=Du;function LR(e){return e===null||typeof e=="boolean"||typeof e=="number"||typeof e=="string"||typeof e=="symbol"||typeof e>"u"}Me.isPrimitive=LR;Me.isBuffer=wm();function ch(e){return Object.prototype.toString.call(e)}function ah(e){return e<10?"0"+e.toString(10):e.toString(10)}var DR=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function UR(){var e=new Date,t=[ah(e.getHours()),ah(e.getMinutes()),ah(e.getSeconds())].join(":");return[e.getDate(),DR[e.getMonth()],t].join(" ")}Me.log=function(){console.log("%s - %s",UR(),Me.format.apply(Me,arguments))};Me.inherits=Je();Me._extend=function(e,t){if(!t||!Bo(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e};function Om(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var Ci=typeof Symbol<"u"?Symbol("util.promisify.custom"):void 0;Me.promisify=function(t){if(typeof t!="function")throw new TypeError('The "original" argument must be of type Function');if(Ci&&t[Ci]){var r=t[Ci];if(typeof r!="function")throw new TypeError('The "util.promisify.custom" argument must be of type Function');return Object.defineProperty(r,Ci,{value:r,enumerable:!1,writable:!1,configurable:!0}),r}function r(){for(var n,i,o=new Promise(function(f,l){n=f,i=l}),s=[],a=0;a<arguments.length;a++)s.push(arguments[a]);s.push(function(f,l){f?i(f):n(l)});try{t.apply(this,s)}catch(f){i(f)}return o}return Object.setPrototypeOf(r,Object.getPrototypeOf(t)),Ci&&Object.defineProperty(r,Ci,{value:r,enumerable:!1,writable:!1,configurable:!0}),Object.defineProperties(r,Em(t))};Me.promisify.custom=Ci;function FR(e,t){if(!e){var r=new Error("Promise was rejected with a falsy value");r.reason=e,e=r}return t(e)}function qR(e){if(typeof e!="function")throw new TypeError('The "original" argument must be of type Function');function t(){for(var r=[],n=0;n<arguments.length;n++)r.push(arguments[n]);var i=r.pop();if(typeof i!="function")throw new TypeError("The last argument must be of type Function");var o=this,s=function(){return i.apply(o,arguments)};e.apply(this,r).then(function(a){x.default.nextTick(s.bind(null,null,a))},function(a){x.default.nextTick(FR.bind(null,a,s))})}return Object.setPrototypeOf(t,Object.getPrototypeOf(e)),Object.defineProperties(t,Em(e)),t}Me.callbackify=qR});var Mm=B((u4,Nm)=>{"use strict";g();function Rm(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function Tm(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?Rm(Object(r),!0).forEach(function(n){HR(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Rm(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function HR(e,t,r){return t=Bm(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function jR(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Pm(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,Bm(n.key),n)}}function KR(e,t,r){return t&&Pm(e.prototype,t),r&&Pm(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function Bm(e){var t=GR(e,"string");return typeof t=="symbol"?t:String(t)}function GR(e,t){if(typeof e!="object"||e===null)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var VR=Lt(),ju=VR.Buffer,WR=rn(),lh=WR.inspect,zR=lh&&lh.custom||"inspect";function YR(e,t,r){ju.prototype.copy.call(e,t,r)}Nm.exports=(function(){function e(){jR(this,e),this.head=null,this.tail=null,this.length=0}return KR(e,[{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 ju.alloc(0);for(var n=ju.allocUnsafe(r>>>0),i=this.head,o=0;i;)YR(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=ju.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:zR,value:function(r,n){return lh(this,Tm(Tm({},n),{},{depth:0,customInspect:!1}))}}]),e})()});var dh=B((c4,Cm)=>{"use strict";g();function $R(e,t){var r=this,n=this._readableState&&this._readableState.destroyed,i=this._writableState&&this._writableState.destroyed;return n||i?(t?t(e):e&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,x.default.nextTick(hh,this,e)):x.default.nextTick(hh,this,e)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(e||null,function(o){!t&&o?r._writableState?r._writableState.errorEmitted?x.default.nextTick(Ku,r):(r._writableState.errorEmitted=!0,x.default.nextTick(km,r,o)):x.default.nextTick(km,r,o):t?(x.default.nextTick(Ku,r),t(o)):x.default.nextTick(Ku,r)}),this)}function km(e,t){hh(e,t),Ku(e)}function Ku(e){e._writableState&&!e._writableState.emitClose||e._readableState&&!e._readableState.emitClose||e.emit("close")}function ZR(){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 hh(e,t){e.emit("error",t)}function XR(e,t){var r=e._readableState,n=e._writableState;r&&r.autoDestroy||n&&n.autoDestroy?e.destroy(t):e.emit("error",t)}Cm.exports={destroy:$R,undestroy:ZR,errorOrDestroy:XR}});var Di=B((h4,Um)=>{"use strict";g();function JR(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}var Dm={};function xr(e,t,r){r||(r=Error);function n(o,s,a){return typeof t=="string"?t:t(o,s,a)}var i=(function(o){JR(s,o);function s(a,f,l){return o.call(this,n(a,f,l))||this}return s})(r);i.prototype.name=r.name,i.prototype.code=e,Dm[e]=i}function Lm(e,t){if(Array.isArray(e)){var r=e.length;return e=e.map(function(n){return String(n)}),r>2?"one of ".concat(t," ").concat(e.slice(0,r-1).join(", "),", or ")+e[r-1]:r===2?"one of ".concat(t," ").concat(e[0]," or ").concat(e[1]):"of ".concat(t," ").concat(e[0])}else return"of ".concat(t," ").concat(String(e))}function QR(e,t,r){return e.substr(!r||r<0?0:+r,t.length)===t}function eT(e,t,r){return(r===void 0||r>e.length)&&(r=e.length),e.substring(r-t.length,r)===t}function tT(e,t,r){return typeof r!="number"&&(r=0),r+t.length>e.length?!1:e.indexOf(t,r)!==-1}xr("ERR_INVALID_OPT_VALUE",function(e,t){return'The value "'+t+'" is invalid for option "'+e+'"'},TypeError);xr("ERR_INVALID_ARG_TYPE",function(e,t,r){var n;typeof t=="string"&&QR(t,"not ")?(n="must not be",t=t.replace(/^not /,"")):n="must be";var i;if(eT(e," argument"))i="The ".concat(e," ").concat(n," ").concat(Lm(t,"type"));else{var o=tT(e,".")?"property":"argument";i='The "'.concat(e,'" ').concat(o," ").concat(n," ").concat(Lm(t,"type"))}return i+=". Received type ".concat(typeof r),i},TypeError);xr("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF");xr("ERR_METHOD_NOT_IMPLEMENTED",function(e){return"The "+e+" method is not implemented"});xr("ERR_STREAM_PREMATURE_CLOSE","Premature close");xr("ERR_STREAM_DESTROYED",function(e){return"Cannot call "+e+" after a stream was destroyed"});xr("ERR_MULTIPLE_CALLBACK","Callback called multiple times");xr("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable");xr("ERR_STREAM_WRITE_AFTER_END","write after end");xr("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError);xr("ERR_UNKNOWN_ENCODING",function(e){return"Unknown encoding: "+e},TypeError);xr("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event");Um.exports.codes=Dm});var ph=B((p4,Fm)=>{"use strict";g();var rT=Di().codes.ERR_INVALID_OPT_VALUE;function nT(e,t,r){return e.highWaterMark!=null?e.highWaterMark:t?e[r]:null}function iT(e,t,r,n){var i=nT(t,n,r);if(i!=null){if(!(isFinite(i)&&Math.floor(i)===i)||i<0){var o=n?r:"highWaterMark";throw new rT(o,i)}return Math.floor(i)}return e.objectMode?16:16*1024}Fm.exports={getHighWaterMark:iT}});var yh=B((y4,qm)=>{g();qm.exports=oT;function oT(e,t){if(gh("noDeprecation"))return e;var r=!1;function n(){if(!r){if(gh("throwDeprecation"))throw new Error(t);gh("traceDeprecation")?console.trace(t):console.warn(t),r=!0}return e.apply(this,arguments)}return n}function gh(e){try{if(!globalThis.localStorage)return!1}catch{return!1}var t=globalThis.localStorage[e];return t==null?!1:String(t).toLowerCase()==="true"}});var bh=B((v4,Wm)=>{"use strict";g();Wm.exports=dt;function jm(e){var t=this;this.next=null,this.entry=null,this.finish=function(){NT(t,e)}}var No;dt.WritableState=ks;var sT={deprecate:yh()},Km=Nl(),Vu=Lt().Buffer,aT=(typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function uT(e){return Vu.from(e)}function fT(e){return Vu.isBuffer(e)||e instanceof aT}var vh=dh(),cT=ph(),lT=cT.getHighWaterMark,Jn=Di().codes,hT=Jn.ERR_INVALID_ARG_TYPE,dT=Jn.ERR_METHOD_NOT_IMPLEMENTED,pT=Jn.ERR_MULTIPLE_CALLBACK,gT=Jn.ERR_STREAM_CANNOT_PIPE,yT=Jn.ERR_STREAM_DESTROYED,mT=Jn.ERR_STREAM_NULL_VALUES,vT=Jn.ERR_STREAM_WRITE_AFTER_END,bT=Jn.ERR_UNKNOWN_ENCODING,Mo=vh.errorOrDestroy;Je()(dt,Km);function _T(){}function ks(e,t,r){No=No||Ui(),e=e||{},typeof r!="boolean"&&(r=t instanceof No),this.objectMode=!!e.objectMode,r&&(this.objectMode=this.objectMode||!!e.writableObjectMode),this.highWaterMark=lT(this,e,"writableHighWaterMark",r),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var n=e.decodeStrings===!1;this.decodeStrings=!n,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(i){OT(t,i)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=e.emitClose!==!1,this.autoDestroy=!!e.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new jm(this)}ks.prototype.getBuffer=function(){for(var t=this.bufferedRequest,r=[];t;)r.push(t),t=t.next;return r};(function(){try{Object.defineProperty(ks.prototype,"buffer",{get:sT.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch{}})();var Gu;typeof Symbol=="function"&&Symbol.hasInstance&&typeof Function.prototype[Symbol.hasInstance]=="function"?(Gu=Function.prototype[Symbol.hasInstance],Object.defineProperty(dt,Symbol.hasInstance,{value:function(t){return Gu.call(this,t)?!0:this!==dt?!1:t&&t._writableState instanceof ks}})):Gu=function(t){return t instanceof this};function dt(e){No=No||Ui();var t=this instanceof No;if(!t&&!Gu.call(dt,this))return new dt(e);this._writableState=new ks(e,this,t),this.writable=!0,e&&(typeof e.write=="function"&&(this._write=e.write),typeof e.writev=="function"&&(this._writev=e.writev),typeof e.destroy=="function"&&(this._destroy=e.destroy),typeof e.final=="function"&&(this._final=e.final)),Km.call(this)}dt.prototype.pipe=function(){Mo(this,new gT)};function ST(e,t){var r=new vT;Mo(e,r),x.default.nextTick(t,r)}function wT(e,t,r,n){var i;return r===null?i=new mT:typeof r!="string"&&!t.objectMode&&(i=new hT("chunk",["string","Buffer"],r)),i?(Mo(e,i),x.default.nextTick(n,i),!1):!0}dt.prototype.write=function(e,t,r){var n=this._writableState,i=!1,o=!n.objectMode&&fT(e);return o&&!Vu.isBuffer(e)&&(e=uT(e)),typeof t=="function"&&(r=t,t=null),o?t="buffer":t||(t=n.defaultEncoding),typeof r!="function"&&(r=_T),n.ending?ST(this,r):(o||wT(this,n,e,r))&&(n.pendingcb++,i=xT(this,n,o,e,t,r)),i};dt.prototype.cork=function(){this._writableState.corked++};dt.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,!e.writing&&!e.corked&&!e.bufferProcessing&&e.bufferedRequest&&Gm(this,e))};dt.prototype.setDefaultEncoding=function(t){if(typeof t=="string"&&(t=t.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((t+"").toLowerCase())>-1))throw new bT(t);return this._writableState.defaultEncoding=t,this};Object.defineProperty(dt.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}});function ET(e,t,r){return!e.objectMode&&e.decodeStrings!==!1&&typeof t=="string"&&(t=Vu.from(t,r)),t}Object.defineProperty(dt.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function xT(e,t,r,n,i,o){if(!r){var s=ET(t,n,i);n!==s&&(r=!0,i="buffer",n=s)}var a=t.objectMode?1:n.length;t.length+=a;var f=t.length<t.highWaterMark;if(f||(t.needDrain=!0),t.writing||t.corked){var l=t.lastBufferedRequest;t.lastBufferedRequest={chunk:n,encoding:i,isBuf:r,callback:o,next:null},l?l.next=t.lastBufferedRequest:t.bufferedRequest=t.lastBufferedRequest,t.bufferedRequestCount+=1}else mh(e,t,!1,a,n,i,o);return f}function mh(e,t,r,n,i,o,s){t.writelen=n,t.writecb=s,t.writing=!0,t.sync=!0,t.destroyed?t.onwrite(new yT("write")):r?e._writev(i,t.onwrite):e._write(i,o,t.onwrite),t.sync=!1}function IT(e,t,r,n,i){--t.pendingcb,r?(x.default.nextTick(i,n),x.default.nextTick(Ms,e,t),e._writableState.errorEmitted=!0,Mo(e,n)):(i(n),e._writableState.errorEmitted=!0,Mo(e,n),Ms(e,t))}function AT(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}function OT(e,t){var r=e._writableState,n=r.sync,i=r.writecb;if(typeof i!="function")throw new pT;if(AT(r),t)IT(e,r,n,t,i);else{var o=Vm(r)||e.destroyed;!o&&!r.corked&&!r.bufferProcessing&&r.bufferedRequest&&Gm(e,r),n?x.default.nextTick(Hm,e,r,o,i):Hm(e,r,o,i)}}function Hm(e,t,r,n){r||RT(e,t),t.pendingcb--,n(),Ms(e,t)}function RT(e,t){t.length===0&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}function Gm(e,t){t.bufferProcessing=!0;var r=t.bufferedRequest;if(e._writev&&r&&r.next){var n=t.bufferedRequestCount,i=new Array(n),o=t.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,mh(e,t,!0,t.length,i,"",o.finish),t.pendingcb++,t.lastBufferedRequest=null,o.next?(t.corkedRequestsFree=o.next,o.next=null):t.corkedRequestsFree=new jm(t),t.bufferedRequestCount=0}else{for(;r;){var f=r.chunk,l=r.encoding,m=r.callback,y=t.objectMode?1:f.length;if(mh(e,t,!1,y,f,l,m),r=r.next,t.bufferedRequestCount--,t.writing)break}r===null&&(t.lastBufferedRequest=null)}t.bufferedRequest=r,t.bufferProcessing=!1}dt.prototype._write=function(e,t,r){r(new dT("_write()"))};dt.prototype._writev=null;dt.prototype.end=function(e,t,r){var n=this._writableState;return typeof e=="function"?(r=e,e=null,t=null):typeof t=="function"&&(r=t,t=null),e!=null&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||BT(this,n,r),this};Object.defineProperty(dt.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}});function Vm(e){return e.ending&&e.length===0&&e.bufferedRequest===null&&!e.finished&&!e.writing}function TT(e,t){e._final(function(r){t.pendingcb--,r&&Mo(e,r),t.prefinished=!0,e.emit("prefinish"),Ms(e,t)})}function PT(e,t){!t.prefinished&&!t.finalCalled&&(typeof e._final=="function"&&!t.destroyed?(t.pendingcb++,t.finalCalled=!0,x.default.nextTick(TT,e,t)):(t.prefinished=!0,e.emit("prefinish")))}function Ms(e,t){var r=Vm(t);if(r&&(PT(e,t),t.pendingcb===0&&(t.finished=!0,e.emit("finish"),t.autoDestroy))){var n=e._readableState;(!n||n.autoDestroy&&n.endEmitted)&&e.destroy()}return r}function BT(e,t,r){t.ending=!0,Ms(e,t),r&&(t.finished?x.default.nextTick(r):e.once("finish",r)),t.ended=!0,e.writable=!1}function NT(e,t,r){var n=e.entry;for(e.entry=null;n;){var i=n.callback;t.pendingcb--,i(r),n=n.next}t.corkedRequestsFree.next=e}Object.defineProperty(dt.prototype,"destroyed",{enumerable:!1,get:function(){return this._writableState===void 0?!1:this._writableState.destroyed},set:function(t){this._writableState&&(this._writableState.destroyed=t)}});dt.prototype.destroy=vh.destroy;dt.prototype._undestroy=vh.undestroy;dt.prototype._destroy=function(e,t){t(e)}});var Ui=B((_4,Ym)=>{"use strict";g();var MT=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t};Ym.exports=nn;var zm=wh(),Sh=bh();Je()(nn,zm);for(_h=MT(Sh.prototype),Wu=0;Wu<_h.length;Wu++)zu=_h[Wu],nn.prototype[zu]||(nn.prototype[zu]=Sh.prototype[zu]);var _h,zu,Wu;function nn(e){if(!(this instanceof nn))return new nn(e);zm.call(this,e),Sh.call(this,e),this.allowHalfOpen=!0,e&&(e.readable===!1&&(this.readable=!1),e.writable===!1&&(this.writable=!1),e.allowHalfOpen===!1&&(this.allowHalfOpen=!1,this.once("end",kT)))}Object.defineProperty(nn.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});Object.defineProperty(nn.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}});Object.defineProperty(nn.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}});function kT(){this._writableState.ended||x.default.nextTick(CT,this)}function CT(e){e.end()}Object.defineProperty(nn.prototype,"destroyed",{enumerable:!1,get:function(){return this._readableState===void 0||this._writableState===void 0?!1:this._readableState.destroyed&&this._writableState.destroyed},set:function(t){this._readableState===void 0||this._writableState===void 0||(this._readableState.destroyed=t,this._writableState.destroyed=t)}})});var Xm=B((Eh,Zm)=>{g();var Yu=Lt(),wn=Yu.Buffer;function $m(e,t){for(var r in e)t[r]=e[r]}wn.from&&wn.alloc&&wn.allocUnsafe&&wn.allocUnsafeSlow?Zm.exports=Yu:($m(Yu,Eh),Eh.Buffer=ko);function ko(e,t,r){return wn(e,t,r)}$m(wn,ko);ko.from=function(e,t,r){if(typeof e=="number")throw new TypeError("Argument must not be a number");return wn(e,t,r)};ko.alloc=function(e,t,r){if(typeof e!="number")throw new TypeError("Argument must be a number");var n=wn(e);return t!==void 0?typeof r=="string"?n.fill(t,r):n.fill(t):n.fill(0),n};ko.allocUnsafe=function(e){if(typeof e!="number")throw new TypeError("Argument must be a number");return wn(e)};ko.allocUnsafeSlow=function(e){if(typeof e!="number")throw new TypeError("Argument must be a number");return Yu.SlowBuffer(e)}});var Co=B(Qm=>{"use strict";g();var Ih=Xm().Buffer,Jm=Ih.isEncoding||function(e){switch(e=""+e,e&&e.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 LT(e){if(!e)return"utf8";for(var t;;)switch(e){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 e;default:if(t)return;e=(""+e).toLowerCase(),t=!0}}function DT(e){var t=LT(e);if(typeof t!="string"&&(Ih.isEncoding===Jm||!Jm(e)))throw new Error("Unknown encoding: "+e);return t||e}Qm.StringDecoder=Cs;function Cs(e){this.encoding=DT(e);var t;switch(this.encoding){case"utf16le":this.text=KT,this.end=GT,t=4;break;case"utf8":this.fillLast=qT,t=4;break;case"base64":this.text=VT,this.end=WT,t=3;break;default:this.write=zT,this.end=YT;return}this.lastNeed=0,this.lastTotal=0,this.lastChar=Ih.allocUnsafe(t)}Cs.prototype.write=function(e){if(e.length===0)return"";var t,r;if(this.lastNeed){if(t=this.fillLast(e),t===void 0)return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r<e.length?t?t+this.text(e,r):this.text(e,r):t||""};Cs.prototype.end=jT;Cs.prototype.text=HT;Cs.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length};function xh(e){return e<=127?0:e>>5===6?2:e>>4===14?3:e>>3===30?4:e>>6===2?-1:-2}function UT(e,t,r){var n=t.length-1;if(n<r)return 0;var i=xh(t[n]);return i>=0?(i>0&&(e.lastNeed=i-1),i):--n<r||i===-2?0:(i=xh(t[n]),i>=0?(i>0&&(e.lastNeed=i-2),i):--n<r||i===-2?0:(i=xh(t[n]),i>=0?(i>0&&(i===2?i=0:e.lastNeed=i-3),i):0))}function FT(e,t,r){if((t[0]&192)!==128)return e.lastNeed=0,"\uFFFD";if(e.lastNeed>1&&t.length>1){if((t[1]&192)!==128)return e.lastNeed=1,"\uFFFD";if(e.lastNeed>2&&t.length>2&&(t[2]&192)!==128)return e.lastNeed=2,"\uFFFD"}}function qT(e){var t=this.lastTotal-this.lastNeed,r=FT(this,e,t);if(r!==void 0)return r;if(this.lastNeed<=e.length)return e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,t,0,e.length),this.lastNeed-=e.length}function HT(e,t){var r=UT(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=r;var n=e.length-(r-this.lastNeed);return e.copy(this.lastChar,0,n),e.toString("utf8",t,n)}function jT(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+"\uFFFD":t}function KT(e,t){if((e.length-t)%2===0){var r=e.toString("utf16le",t);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function GT(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,r)}return t}function VT(e,t){var r=(e.length-t)%3;return r===0?e.toString("base64",t):(this.lastNeed=3-r,this.lastTotal=3,r===1?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-r))}function WT(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function zT(e){return e.toString(this.encoding)}function YT(e){return e&&e.length?this.write(e):""}});var $u=B((I4,rv)=>{"use strict";g();var ev=Di().codes.ERR_STREAM_PREMATURE_CLOSE;function $T(e){var t=!1;return function(){if(!t){t=!0;for(var r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];e.apply(this,n)}}}function ZT(){}function XT(e){return e.setHeader&&typeof e.abort=="function"}function tv(e,t,r){if(typeof t=="function")return tv(e,null,t);t||(t={}),r=$T(r||ZT);var n=t.readable||t.readable!==!1&&e.readable,i=t.writable||t.writable!==!1&&e.writable,o=function(){e.writable||a()},s=e._writableState&&e._writableState.finished,a=function(){i=!1,s=!0,n||r.call(e)},f=e._readableState&&e._readableState.endEmitted,l=function(){n=!1,f=!0,i||r.call(e)},m=function(O){r.call(e,O)},y=function(){var O;if(n&&!f)return(!e._readableState||!e._readableState.ended)&&(O=new ev),r.call(e,O);if(i&&!s)return(!e._writableState||!e._writableState.ended)&&(O=new ev),r.call(e,O)},p=function(){e.req.on("finish",a)};return XT(e)?(e.on("complete",a),e.on("abort",y),e.req?p():e.on("request",p)):i&&!e._writableState&&(e.on("end",o),e.on("close",o)),e.on("end",l),e.on("finish",a),t.error!==!1&&e.on("error",m),e.on("close",y),function(){e.removeListener("complete",a),e.removeListener("abort",y),e.removeListener("request",p),e.req&&e.req.removeListener("finish",a),e.removeListener("end",o),e.removeListener("close",o),e.removeListener("finish",a),e.removeListener("end",l),e.removeListener("error",m),e.removeListener("close",y)}}rv.exports=tv});var iv=B((O4,nv)=>{"use strict";g();var Zu;function Qn(e,t,r){return t=JT(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function JT(e){var t=QT(e,"string");return typeof t=="symbol"?t:String(t)}function QT(e,t){if(typeof e!="object"||e===null)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var e2=$u(),ei=Symbol("lastResolve"),Fi=Symbol("lastReject"),Ls=Symbol("error"),Xu=Symbol("ended"),qi=Symbol("lastPromise"),Ah=Symbol("handlePromise"),Hi=Symbol("stream");function ti(e,t){return{value:e,done:t}}function t2(e){var t=e[ei];if(t!==null){var r=e[Hi].read();r!==null&&(e[qi]=null,e[ei]=null,e[Fi]=null,t(ti(r,!1)))}}function r2(e){x.default.nextTick(t2,e)}function n2(e,t){return function(r,n){e.then(function(){if(t[Xu]){r(ti(void 0,!0));return}t[Ah](r,n)},n)}}var i2=Object.getPrototypeOf(function(){}),o2=Object.setPrototypeOf((Zu={get stream(){return this[Hi]},next:function(){var t=this,r=this[Ls];if(r!==null)return Promise.reject(r);if(this[Xu])return Promise.resolve(ti(void 0,!0));if(this[Hi].destroyed)return new Promise(function(s,a){x.default.nextTick(function(){t[Ls]?a(t[Ls]):s(ti(void 0,!0))})});var n=this[qi],i;if(n)i=new Promise(n2(n,this));else{var o=this[Hi].read();if(o!==null)return Promise.resolve(ti(o,!1));i=new Promise(this[Ah])}return this[qi]=i,i}},Qn(Zu,Symbol.asyncIterator,function(){return this}),Qn(Zu,"return",function(){var t=this;return new Promise(function(r,n){t[Hi].destroy(null,function(i){if(i){n(i);return}r(ti(void 0,!0))})})}),Zu),i2),s2=function(t){var r,n=Object.create(o2,(r={},Qn(r,Hi,{value:t,writable:!0}),Qn(r,ei,{value:null,writable:!0}),Qn(r,Fi,{value:null,writable:!0}),Qn(r,Ls,{value:null,writable:!0}),Qn(r,Xu,{value:t._readableState.endEmitted,writable:!0}),Qn(r,Ah,{value:function(o,s){var a=n[Hi].read();a?(n[qi]=null,n[ei]=null,n[Fi]=null,o(ti(a,!1))):(n[ei]=o,n[Fi]=s)},writable:!0}),r));return n[qi]=null,e2(t,function(i){if(i&&i.code!=="ERR_STREAM_PREMATURE_CLOSE"){var o=n[Fi];o!==null&&(n[qi]=null,n[ei]=null,n[Fi]=null,o(i)),n[Ls]=i;return}var s=n[ei];s!==null&&(n[qi]=null,n[ei]=null,n[Fi]=null,s(ti(void 0,!0))),n[Xu]=!0}),t.on("readable",r2.bind(null,n)),n};nv.exports=s2});var sv=B((T4,ov)=>{g();ov.exports=function(){throw new Error("Readable.from is not available in the browser")}});var wh=B((N4,yv)=>{"use strict";g();yv.exports=Ue;var Lo;Ue.ReadableState=cv;var B4=wo().EventEmitter,fv=function(t,r){return t.listeners(r).length},Us=Nl(),Ju=Lt().Buffer,a2=(typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function u2(e){return Ju.from(e)}function f2(e){return Ju.isBuffer(e)||e instanceof a2}var Oh=rn(),Ae;Oh&&Oh.debuglog?Ae=Oh.debuglog("stream"):Ae=function(){};var c2=Mm(),kh=dh(),l2=ph(),h2=l2.getHighWaterMark,Qu=Di().codes,d2=Qu.ERR_INVALID_ARG_TYPE,p2=Qu.ERR_STREAM_PUSH_AFTER_EOF,g2=Qu.ERR_METHOD_NOT_IMPLEMENTED,y2=Qu.ERR_STREAM_UNSHIFT_AFTER_END_EVENT,Do,Rh,Th;Je()(Ue,Us);var Ds=kh.errorOrDestroy,Ph=["error","close","destroy","pause","resume"];function m2(e,t,r){if(typeof e.prependListener=="function")return e.prependListener(t,r);!e._events||!e._events[t]?e.on(t,r):Array.isArray(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]}function cv(e,t,r){Lo=Lo||Ui(),e=e||{},typeof r!="boolean"&&(r=t instanceof Lo),this.objectMode=!!e.objectMode,r&&(this.objectMode=this.objectMode||!!e.readableObjectMode),this.highWaterMark=h2(this,e,"readableHighWaterMark",r),this.buffer=new c2,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=e.emitClose!==!1,this.autoDestroy=!!e.autoDestroy,this.destroyed=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(Do||(Do=Co().StringDecoder),this.decoder=new Do(e.encoding),this.encoding=e.encoding)}function Ue(e){if(Lo=Lo||Ui(),!(this instanceof Ue))return new Ue(e);var t=this instanceof Lo;this._readableState=new cv(e,this,t),this.readable=!0,e&&(typeof e.read=="function"&&(this._read=e.read),typeof e.destroy=="function"&&(this._destroy=e.destroy)),Us.call(this)}Object.defineProperty(Ue.prototype,"destroyed",{enumerable:!1,get:function(){return this._readableState===void 0?!1:this._readableState.destroyed},set:function(t){this._readableState&&(this._readableState.destroyed=t)}});Ue.prototype.destroy=kh.destroy;Ue.prototype._undestroy=kh.undestroy;Ue.prototype._destroy=function(e,t){t(e)};Ue.prototype.push=function(e,t){var r=this._readableState,n;return r.objectMode?n=!0:typeof e=="string"&&(t=t||r.defaultEncoding,t!==r.encoding&&(e=Ju.from(e,t),t=""),n=!0),lv(this,e,t,!1,n)};Ue.prototype.unshift=function(e){return lv(this,e,null,!0,!1)};function lv(e,t,r,n,i){Ae("readableAddChunk",t);var o=e._readableState;if(t===null)o.reading=!1,_2(e,o);else{var s;if(i||(s=v2(o,t)),s)Ds(e,s);else if(o.objectMode||t&&t.length>0)if(typeof t!="string"&&!o.objectMode&&Object.getPrototypeOf(t)!==Ju.prototype&&(t=u2(t)),n)o.endEmitted?Ds(e,new y2):Bh(e,o,t,!0);else if(o.ended)Ds(e,new p2);else{if(o.destroyed)return!1;o.reading=!1,o.decoder&&!r?(t=o.decoder.write(t),o.objectMode||t.length!==0?Bh(e,o,t,!1):Mh(e,o)):Bh(e,o,t,!1)}else n||(o.reading=!1,Mh(e,o))}return!o.ended&&(o.length<o.highWaterMark||o.length===0)}function Bh(e,t,r,n){t.flowing&&t.length===0&&!t.sync?(t.awaitDrain=0,e.emit("data",r)):(t.length+=t.objectMode?1:r.length,n?t.buffer.unshift(r):t.buffer.push(r),t.needReadable&&ef(e)),Mh(e,t)}function v2(e,t){var r;return!f2(t)&&typeof t!="string"&&t!==void 0&&!e.objectMode&&(r=new d2("chunk",["string","Buffer","Uint8Array"],t)),r}Ue.prototype.isPaused=function(){return this._readableState.flowing===!1};Ue.prototype.setEncoding=function(e){Do||(Do=Co().StringDecoder);var t=new Do(e);this._readableState.decoder=t,this._readableState.encoding=this._readableState.decoder.encoding;for(var r=this._readableState.buffer.head,n="";r!==null;)n+=t.write(r.data),r=r.next;return this._readableState.buffer.clear(),n!==""&&this._readableState.buffer.push(n),this._readableState.length=n.length,this};var av=1073741824;function b2(e){return e>=av?e=av:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}function uv(e,t){return e<=0||t.length===0&&t.ended?0:t.objectMode?1:e!==e?t.flowing&&t.length?t.buffer.head.data.length:t.length:(e>t.highWaterMark&&(t.highWaterMark=b2(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}Ue.prototype.read=function(e){Ae("read",e),e=parseInt(e,10);var t=this._readableState,r=e;if(e!==0&&(t.emittedReadable=!1),e===0&&t.needReadable&&((t.highWaterMark!==0?t.length>=t.highWaterMark:t.length>0)||t.ended))return Ae("read: emitReadable",t.length,t.ended),t.length===0&&t.ended?Nh(this):ef(this),null;if(e=uv(e,t),e===0&&t.ended)return t.length===0&&Nh(this),null;var n=t.needReadable;Ae("need readable",n),(t.length===0||t.length-e<t.highWaterMark)&&(n=!0,Ae("length less than watermark",n)),t.ended||t.reading?(n=!1,Ae("reading or ended",n)):n&&(Ae("do read"),t.reading=!0,t.sync=!0,t.length===0&&(t.needReadable=!0),this._read(t.highWaterMark),t.sync=!1,t.reading||(e=uv(r,t)));var i;return e>0?i=pv(e,t):i=null,i===null?(t.needReadable=t.length<=t.highWaterMark,e=0):(t.length-=e,t.awaitDrain=0),t.length===0&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Nh(this)),i!==null&&this.emit("data",i),i};function _2(e,t){if(Ae("onEofChunk"),!t.ended){if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,t.sync?ef(e):(t.needReadable=!1,t.emittedReadable||(t.emittedReadable=!0,hv(e)))}}function ef(e){var t=e._readableState;Ae("emitReadable",t.needReadable,t.emittedReadable),t.needReadable=!1,t.emittedReadable||(Ae("emitReadable",t.flowing),t.emittedReadable=!0,x.default.nextTick(hv,e))}function hv(e){var t=e._readableState;Ae("emitReadable_",t.destroyed,t.length,t.ended),!t.destroyed&&(t.length||t.ended)&&(e.emit("readable"),t.emittedReadable=!1),t.needReadable=!t.flowing&&!t.ended&&t.length<=t.highWaterMark,Ch(e)}function Mh(e,t){t.readingMore||(t.readingMore=!0,x.default.nextTick(S2,e,t))}function S2(e,t){for(;!t.reading&&!t.ended&&(t.length<t.highWaterMark||t.flowing&&t.length===0);){var r=t.length;if(Ae("maybeReadMore read 0"),e.read(0),r===t.length)break}t.readingMore=!1}Ue.prototype._read=function(e){Ds(this,new g2("_read()"))};Ue.prototype.pipe=function(e,t){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=e;break;case 1:n.pipes=[n.pipes,e];break;default:n.pipes.push(e);break}n.pipesCount+=1,Ae("pipe count=%d opts=%j",n.pipesCount,t);var i=(!t||t.end!==!1)&&e!==x.default.stdout&&e!==x.default.stderr,o=i?a:M;n.endEmitted?x.default.nextTick(o):r.once("end",o),e.on("unpipe",s);function s(D,F){Ae("onunpipe"),D===r&&F&&F.hasUnpiped===!1&&(F.hasUnpiped=!0,m())}function a(){Ae("onend"),e.end()}var f=w2(r);e.on("drain",f);var l=!1;function m(){Ae("cleanup"),e.removeListener("close",w),e.removeListener("finish",O),e.removeListener("drain",f),e.removeListener("error",p),e.removeListener("unpipe",s),r.removeListener("end",a),r.removeListener("end",M),r.removeListener("data",y),l=!0,n.awaitDrain&&(!e._writableState||e._writableState.needDrain)&&f()}r.on("data",y);function y(D){Ae("ondata");var F=e.write(D);Ae("dest.write",F),F===!1&&((n.pipesCount===1&&n.pipes===e||n.pipesCount>1&&gv(n.pipes,e)!==-1)&&!l&&(Ae("false write response, pause",n.awaitDrain),n.awaitDrain++),r.pause())}function p(D){Ae("onerror",D),M(),e.removeListener("error",p),fv(e,"error")===0&&Ds(e,D)}m2(e,"error",p);function w(){e.removeListener("finish",O),M()}e.once("close",w);function O(){Ae("onfinish"),e.removeListener("close",w),M()}e.once("finish",O);function M(){Ae("unpipe"),r.unpipe(e)}return e.emit("pipe",r),n.flowing||(Ae("pipe resume"),r.resume()),e};function w2(e){return function(){var r=e._readableState;Ae("pipeOnDrain",r.awaitDrain),r.awaitDrain&&r.awaitDrain--,r.awaitDrain===0&&fv(e,"data")&&(r.flowing=!0,Ch(e))}}Ue.prototype.unpipe=function(e){var t=this._readableState,r={hasUnpiped:!1};if(t.pipesCount===0)return this;if(t.pipesCount===1)return e&&e!==t.pipes?this:(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,r),this);if(!e){var n=t.pipes,i=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var o=0;o<i;o++)n[o].emit("unpipe",this,{hasUnpiped:!1});return this}var s=gv(t.pipes,e);return s===-1?this:(t.pipes.splice(s,1),t.pipesCount-=1,t.pipesCount===1&&(t.pipes=t.pipes[0]),e.emit("unpipe",this,r),this)};Ue.prototype.on=function(e,t){var r=Us.prototype.on.call(this,e,t),n=this._readableState;return e==="data"?(n.readableListening=this.listenerCount("readable")>0,n.flowing!==!1&&this.resume()):e==="readable"&&!n.endEmitted&&!n.readableListening&&(n.readableListening=n.needReadable=!0,n.flowing=!1,n.emittedReadable=!1,Ae("on readable",n.length,n.reading),n.length?ef(this):n.reading||x.default.nextTick(E2,this)),r};Ue.prototype.addListener=Ue.prototype.on;Ue.prototype.removeListener=function(e,t){var r=Us.prototype.removeListener.call(this,e,t);return e==="readable"&&x.default.nextTick(dv,this),r};Ue.prototype.removeAllListeners=function(e){var t=Us.prototype.removeAllListeners.apply(this,arguments);return(e==="readable"||e===void 0)&&x.default.nextTick(dv,this),t};function dv(e){var t=e._readableState;t.readableListening=e.listenerCount("readable")>0,t.resumeScheduled&&!t.paused?t.flowing=!0:e.listenerCount("data")>0&&e.resume()}function E2(e){Ae("readable nexttick read 0"),e.read(0)}Ue.prototype.resume=function(){var e=this._readableState;return e.flowing||(Ae("resume"),e.flowing=!e.readableListening,x2(this,e)),e.paused=!1,this};function x2(e,t){t.resumeScheduled||(t.resumeScheduled=!0,x.default.nextTick(I2,e,t))}function I2(e,t){Ae("resume",t.reading),t.reading||e.read(0),t.resumeScheduled=!1,e.emit("resume"),Ch(e),t.flowing&&!t.reading&&e.read(0)}Ue.prototype.pause=function(){return Ae("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(Ae("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this};function Ch(e){var t=e._readableState;for(Ae("flow",t.flowing);t.flowing&&e.read()!==null;);}Ue.prototype.wrap=function(e){var t=this,r=this._readableState,n=!1;e.on("end",function(){if(Ae("wrapped end"),r.decoder&&!r.ended){var s=r.decoder.end();s&&s.length&&t.push(s)}t.push(null)}),e.on("data",function(s){if(Ae("wrapped data"),r.decoder&&(s=r.decoder.write(s)),!(r.objectMode&&s==null)&&!(!r.objectMode&&(!s||!s.length))){var a=t.push(s);a||(n=!0,e.pause())}});for(var i in e)this[i]===void 0&&typeof e[i]=="function"&&(this[i]=(function(a){return function(){return e[a].apply(e,arguments)}})(i));for(var o=0;o<Ph.length;o++)e.on(Ph[o],this.emit.bind(this,Ph[o]));return this._read=function(s){Ae("wrapped _read",s),n&&(n=!1,e.resume())},this};typeof Symbol=="function"&&(Ue.prototype[Symbol.asyncIterator]=function(){return Rh===void 0&&(Rh=iv()),Rh(this)});Object.defineProperty(Ue.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}});Object.defineProperty(Ue.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}});Object.defineProperty(Ue.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(t){this._readableState&&(this._readableState.flowing=t)}});Ue._fromList=pv;Object.defineProperty(Ue.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}});function pv(e,t){if(t.length===0)return null;var r;return t.objectMode?r=t.buffer.shift():!e||e>=t.length?(t.decoder?r=t.buffer.join(""):t.buffer.length===1?r=t.buffer.first():r=t.buffer.concat(t.length),t.buffer.clear()):r=t.buffer.consume(e,t.decoder),r}function Nh(e){var t=e._readableState;Ae("endReadable",t.endEmitted),t.endEmitted||(t.ended=!0,x.default.nextTick(A2,t,e))}function A2(e,t){if(Ae("endReadableNT",e.endEmitted,e.length),!e.endEmitted&&e.length===0&&(e.endEmitted=!0,t.readable=!1,t.emit("end"),e.autoDestroy)){var r=t._writableState;(!r||r.autoDestroy&&r.finished)&&t.destroy()}}typeof Symbol=="function"&&(Ue.from=function(e,t){return Th===void 0&&(Th=sv()),Th(Ue,e,t)});function gv(e,t){for(var r=0,n=e.length;r<n;r++)if(e[r]===t)return r;return-1}});var Lh=B((k4,vv)=>{"use strict";g();vv.exports=En;var tf=Di().codes,O2=tf.ERR_METHOD_NOT_IMPLEMENTED,R2=tf.ERR_MULTIPLE_CALLBACK,T2=tf.ERR_TRANSFORM_ALREADY_TRANSFORMING,P2=tf.ERR_TRANSFORM_WITH_LENGTH_0,rf=Ui();Je()(En,rf);function B2(e,t){var r=this._transformState;r.transforming=!1;var n=r.writecb;if(n===null)return this.emit("error",new R2);r.writechunk=null,r.writecb=null,t!=null&&this.push(t),n(e);var i=this._readableState;i.reading=!1,(i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}function En(e){if(!(this instanceof En))return new En(e);rf.call(this,e),this._transformState={afterTransform:B2.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,e&&(typeof e.transform=="function"&&(this._transform=e.transform),typeof e.flush=="function"&&(this._flush=e.flush)),this.on("prefinish",N2)}function N2(){var e=this;typeof this._flush=="function"&&!this._readableState.destroyed?this._flush(function(t,r){mv(e,t,r)}):mv(this,null,null)}En.prototype.push=function(e,t){return this._transformState.needTransform=!1,rf.prototype.push.call(this,e,t)};En.prototype._transform=function(e,t,r){r(new O2("_transform()"))};En.prototype._write=function(e,t,r){var n=this._transformState;if(n.writecb=r,n.writechunk=e,n.writeencoding=t,!n.transforming){var i=this._readableState;(n.needTransform||i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}};En.prototype._read=function(e){var t=this._transformState;t.writechunk!==null&&!t.transforming?(t.transforming=!0,this._transform(t.writechunk,t.writeencoding,t.afterTransform)):t.needTransform=!0};En.prototype._destroy=function(e,t){rf.prototype._destroy.call(this,e,function(r){t(r)})};function mv(e,t,r){if(t)return e.emit("error",t);if(r!=null&&e.push(r),e._writableState.length)throw new P2;if(e._transformState.transforming)throw new T2;return e.push(null)}});var Sv=B((L4,_v)=>{"use strict";g();_v.exports=Fs;var bv=Lh();Je()(Fs,bv);function Fs(e){if(!(this instanceof Fs))return new Fs(e);bv.call(this,e)}Fs.prototype._transform=function(e,t,r){r(null,e)}});var Av=B((U4,Iv)=>{"use strict";g();var Dh;function M2(e){var t=!1;return function(){t||(t=!0,e.apply(void 0,arguments))}}var xv=Di().codes,k2=xv.ERR_MISSING_ARGS,C2=xv.ERR_STREAM_DESTROYED;function wv(e){if(e)throw e}function L2(e){return e.setHeader&&typeof e.abort=="function"}function D2(e,t,r,n){n=M2(n);var i=!1;e.on("close",function(){i=!0}),Dh===void 0&&(Dh=$u()),Dh(e,{readable:t,writable:r},function(s){if(s)return n(s);i=!0,n()});var o=!1;return function(s){if(!i&&!o){if(o=!0,L2(e))return e.abort();if(typeof e.destroy=="function")return e.destroy();n(s||new C2("pipe"))}}}function Ev(e){e()}function U2(e,t){return e.pipe(t)}function F2(e){return!e.length||typeof e[e.length-1]!="function"?wv:e.pop()}function q2(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];var n=F2(t);if(Array.isArray(t[0])&&(t=t[0]),t.length<2)throw new k2("streams");var i,o=t.map(function(s,a){var f=a<t.length-1,l=a>0;return D2(s,f,l,function(m){i||(i=m),m&&o.forEach(Ev),!f&&(o.forEach(Ev),n(i))})});return t.reduce(U2)}Iv.exports=q2});var Fh=B((q4,Ov)=>{g();Ov.exports=Ir;var Uh=wo().EventEmitter,H2=Je();H2(Ir,Uh);Ir.Readable=wh();Ir.Writable=bh();Ir.Duplex=Ui();Ir.Transform=Lh();Ir.PassThrough=Sv();Ir.finished=$u();Ir.pipeline=Av();Ir.Stream=Ir;function Ir(){Uh.call(this)}Ir.prototype.pipe=function(e,t){var r=this;function n(m){e.writable&&e.write(m)===!1&&r.pause&&r.pause()}r.on("data",n);function i(){r.readable&&r.resume&&r.resume()}e.on("drain",i),!e._isStdio&&(!t||t.end!==!1)&&(r.on("end",s),r.on("close",a));var o=!1;function s(){o||(o=!0,e.end())}function a(){o||(o=!0,typeof e.destroy=="function"&&e.destroy())}function f(m){if(l(),Uh.listenerCount(this,"error")===0)throw m}r.on("error",f),e.on("error",f);function l(){r.removeListener("data",n),e.removeListener("drain",i),r.removeListener("end",s),r.removeListener("close",a),r.removeListener("error",f),e.removeListener("error",f),r.removeListener("end",l),r.removeListener("close",l),e.removeListener("close",l)}return r.on("end",l),r.on("close",l),e.on("close",l),e.emit("pipe",r),e}});var Pv=B((j4,Tv)=>{"use strict";g();var on=Yt().Buffer,Rv=Fh().Transform,j2=Je();function ri(e){Rv.call(this),this._block=on.allocUnsafe(e),this._blockSize=e,this._blockOffset=0,this._length=[0,0,0,0],this._finalized=!1}j2(ri,Rv);ri.prototype._transform=function(e,t,r){var n=null;try{this.update(e,t)}catch(i){n=i}r(n)};ri.prototype._flush=function(e){var t=null;try{this.push(this.digest())}catch(r){t=r}e(t)};var K2=typeof Uint8Array<"u",G2=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u"&&ArrayBuffer.isView&&(on.prototype instanceof Uint8Array||on.TYPED_ARRAY_SUPPORT);function V2(e,t){if(e instanceof on)return e;if(typeof e=="string")return on.from(e,t);if(G2&&ArrayBuffer.isView(e)){if(e.byteLength===0)return on.alloc(0);var r=on.from(e.buffer,e.byteOffset,e.byteLength);if(r.byteLength===e.byteLength)return r}if(K2&&e instanceof Uint8Array||on.isBuffer(e)&&e.constructor&&typeof e.constructor.isBuffer=="function"&&e.constructor.isBuffer(e))return on.from(e);throw new TypeError('The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView.')}ri.prototype.update=function(e,t){if(this._finalized)throw new Error("Digest already called");e=V2(e,t);for(var r=this._block,n=0;this._blockOffset+e.length-n>=this._blockSize;){for(var i=this._blockOffset;i<this._blockSize;)r[i++]=e[n++];this._update(),this._blockOffset=0}for(;n<e.length;)r[this._blockOffset++]=e[n++];for(var o=0,s=e.length*8;s>0;++o)this._length[o]+=s,s=this._length[o]/4294967296|0,s>0&&(this._length[o]-=4294967296*s);return this};ri.prototype._update=function(){throw new Error("_update is not implemented")};ri.prototype.digest=function(e){if(this._finalized)throw new Error("Digest already called");this._finalized=!0;var t=this._digest();e!==void 0&&(t=t.toString(e)),this._block.fill(0),this._blockOffset=0;for(var r=0;r<4;++r)this._length[r]=0;return t};ri.prototype._digest=function(){throw new Error("_digest is not implemented")};Tv.exports=ri});var qh=B((G4,Nv)=>{"use strict";g();var W2=Je(),Bv=Pv(),z2=Yt().Buffer,Y2=new Array(16);function nf(){Bv.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878}W2(nf,Bv);nf.prototype._update=function(){for(var e=Y2,t=0;t<16;++t)e[t]=this._block.readInt32LE(t*4);var r=this._a,n=this._b,i=this._c,o=this._d;r=Jt(r,n,i,o,e[0],3614090360,7),o=Jt(o,r,n,i,e[1],3905402710,12),i=Jt(i,o,r,n,e[2],606105819,17),n=Jt(n,i,o,r,e[3],3250441966,22),r=Jt(r,n,i,o,e[4],4118548399,7),o=Jt(o,r,n,i,e[5],1200080426,12),i=Jt(i,o,r,n,e[6],2821735955,17),n=Jt(n,i,o,r,e[7],4249261313,22),r=Jt(r,n,i,o,e[8],1770035416,7),o=Jt(o,r,n,i,e[9],2336552879,12),i=Jt(i,o,r,n,e[10],4294925233,17),n=Jt(n,i,o,r,e[11],2304563134,22),r=Jt(r,n,i,o,e[12],1804603682,7),o=Jt(o,r,n,i,e[13],4254626195,12),i=Jt(i,o,r,n,e[14],2792965006,17),n=Jt(n,i,o,r,e[15],1236535329,22),r=Qt(r,n,i,o,e[1],4129170786,5),o=Qt(o,r,n,i,e[6],3225465664,9),i=Qt(i,o,r,n,e[11],643717713,14),n=Qt(n,i,o,r,e[0],3921069994,20),r=Qt(r,n,i,o,e[5],3593408605,5),o=Qt(o,r,n,i,e[10],38016083,9),i=Qt(i,o,r,n,e[15],3634488961,14),n=Qt(n,i,o,r,e[4],3889429448,20),r=Qt(r,n,i,o,e[9],568446438,5),o=Qt(o,r,n,i,e[14],3275163606,9),i=Qt(i,o,r,n,e[3],4107603335,14),n=Qt(n,i,o,r,e[8],1163531501,20),r=Qt(r,n,i,o,e[13],2850285829,5),o=Qt(o,r,n,i,e[2],4243563512,9),i=Qt(i,o,r,n,e[7],1735328473,14),n=Qt(n,i,o,r,e[12],2368359562,20),r=er(r,n,i,o,e[5],4294588738,4),o=er(o,r,n,i,e[8],2272392833,11),i=er(i,o,r,n,e[11],1839030562,16),n=er(n,i,o,r,e[14],4259657740,23),r=er(r,n,i,o,e[1],2763975236,4),o=er(o,r,n,i,e[4],1272893353,11),i=er(i,o,r,n,e[7],4139469664,16),n=er(n,i,o,r,e[10],3200236656,23),r=er(r,n,i,o,e[13],681279174,4),o=er(o,r,n,i,e[0],3936430074,11),i=er(i,o,r,n,e[3],3572445317,16),n=er(n,i,o,r,e[6],76029189,23),r=er(r,n,i,o,e[9],3654602809,4),o=er(o,r,n,i,e[12],3873151461,11),i=er(i,o,r,n,e[15],530742520,16),n=er(n,i,o,r,e[2],3299628645,23),r=tr(r,n,i,o,e[0],4096336452,6),o=tr(o,r,n,i,e[7],1126891415,10),i=tr(i,o,r,n,e[14],2878612391,15),n=tr(n,i,o,r,e[5],4237533241,21),r=tr(r,n,i,o,e[12],1700485571,6),o=tr(o,r,n,i,e[3],2399980690,10),i=tr(i,o,r,n,e[10],4293915773,15),n=tr(n,i,o,r,e[1],2240044497,21),r=tr(r,n,i,o,e[8],1873313359,6),o=tr(o,r,n,i,e[15],4264355552,10),i=tr(i,o,r,n,e[6],2734768916,15),n=tr(n,i,o,r,e[13],1309151649,21),r=tr(r,n,i,o,e[4],4149444226,6),o=tr(o,r,n,i,e[11],3174756917,10),i=tr(i,o,r,n,e[2],718787259,15),n=tr(n,i,o,r,e[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};nf.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 e=z2.allocUnsafe(16);return e.writeInt32LE(this._a,0),e.writeInt32LE(this._b,4),e.writeInt32LE(this._c,8),e.writeInt32LE(this._d,12),e};function of(e,t){return e<<t|e>>>32-t}function Jt(e,t,r,n,i,o,s){return of(e+(t&r|~t&n)+i+o|0,s)+t|0}function Qt(e,t,r,n,i,o,s){return of(e+(t&n|r&~n)+i+o|0,s)+t|0}function er(e,t,r,n,i,o,s){return of(e+(t^r^n)+i+o|0,s)+t|0}function tr(e,t,r,n,i,o,s){return of(e+(r^(t|~n))+i+o|0,s)+t|0}Nv.exports=nf});var kv=B((W4,Mv)=>{g();var $2={}.toString;Mv.exports=Array.isArray||function(e){return $2.call(e)=="[object Array]"}});var Lv=B((Y4,Cv)=>{"use strict";g();var Z2=Ni(),X2=Zn(),J2=X2("TypedArray.prototype.buffer",!0),Q2=nh();Cv.exports=J2||function(t){if(!Q2(t))throw new Z2("Not a Typed Array");return t.buffer}});var sf=B((Z4,Uv)=>{"use strict";g();var kr=Yt().Buffer,eP=kv(),tP=Lv(),rP=ArrayBuffer.isView||function(t){try{return tP(t),!0}catch{return!1}},nP=typeof Uint8Array<"u",Dv=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u",iP=Dv&&(kr.prototype instanceof Uint8Array||kr.TYPED_ARRAY_SUPPORT);Uv.exports=function(t,r){if(kr.isBuffer(t))return t.constructor&&!("isBuffer"in t)?kr.from(t):t;if(typeof t=="string")return kr.from(t,r);if(Dv&&rP(t)){if(t.byteLength===0)return kr.alloc(0);if(iP){var n=kr.from(t.buffer,t.byteOffset,t.byteLength);if(n.byteLength===t.byteLength)return n}var i=t instanceof Uint8Array?t:new Uint8Array(t.buffer,t.byteOffset,t.byteLength),o=kr.from(i);if(o.length===t.byteLength)return o}if(nP&&t instanceof Uint8Array)return kr.from(t);var s=eP(t);if(s)for(var a=0;a<t.length;a+=1){var f=t[a];if(typeof f!="number"||f<0||f>255||~~f!==f)throw new RangeError("Array items must be numbers in the range 0-255.")}if(s||kr.isBuffer(t)&&t.constructor&&typeof t.constructor.isBuffer=="function"&&t.constructor.isBuffer(t))return kr.from(t);throw new TypeError('The "data" argument must be a string, an Array, a Buffer, a Uint8Array, or a DataView.')}});var jv=B((J4,Hv)=>{"use strict";g();var oP=Yt().Buffer,sP=sf(),qv=typeof Uint8Array<"u",aP=qv&&typeof ArrayBuffer<"u",Fv=aP&&ArrayBuffer.isView;Hv.exports=function(e,t){if(typeof e=="string"||oP.isBuffer(e)||qv&&e instanceof Uint8Array||Fv&&Fv(e))return sP(e,t);throw new TypeError('The "data" argument must be a string, a Buffer, a Uint8Array, or a DataView')}});var qs=B((eD,Hh)=>{"use strict";g();typeof x.default>"u"||!x.default.version||x.default.version.indexOf("v0.")===0||x.default.version.indexOf("v1.")===0&&x.default.version.indexOf("v1.8.")!==0?Hh.exports={nextTick:uP}:Hh.exports=x.default;function uP(e,t,r,n){if(typeof e!="function")throw new TypeError('"callback" argument must be a function');var i=arguments.length,o,s;switch(i){case 0:case 1:return x.default.nextTick(e);case 2:return x.default.nextTick(function(){e.call(null,t)});case 3:return x.default.nextTick(function(){e.call(null,t,r)});case 4:return x.default.nextTick(function(){e.call(null,t,r,n)});default:for(o=new Array(i-1),s=0;s<o.length;)o[s++]=arguments[s];return x.default.nextTick(function(){e.apply(null,o)})}}});var Gv=B((rD,Kv)=>{g();var fP={}.toString;Kv.exports=Array.isArray||function(e){return fP.call(e)=="[object Array]"}});var jh=B((iD,Vv)=>{g();Vv.exports=wo().EventEmitter});var uf=B((Kh,zv)=>{g();var af=Lt(),xn=af.Buffer;function Wv(e,t){for(var r in e)t[r]=e[r]}xn.from&&xn.alloc&&xn.allocUnsafe&&xn.allocUnsafeSlow?zv.exports=af:(Wv(af,Kh),Kh.Buffer=Uo);function Uo(e,t,r){return xn(e,t,r)}Wv(xn,Uo);Uo.from=function(e,t,r){if(typeof e=="number")throw new TypeError("Argument must not be a number");return xn(e,t,r)};Uo.alloc=function(e,t,r){if(typeof e!="number")throw new TypeError("Argument must be a number");var n=xn(e);return t!==void 0?typeof r=="string"?n.fill(t,r):n.fill(t):n.fill(0),n};Uo.allocUnsafe=function(e){if(typeof e!="number")throw new TypeError("Argument must be a number");return xn(e)};Uo.allocUnsafeSlow=function(e){if(typeof e!="number")throw new TypeError("Argument must be a number");return af.SlowBuffer(e)}});var Fo=B(rr=>{g();function cP(e){return Array.isArray?Array.isArray(e):ff(e)==="[object Array]"}rr.isArray=cP;function lP(e){return typeof e=="boolean"}rr.isBoolean=lP;function hP(e){return e===null}rr.isNull=hP;function dP(e){return e==null}rr.isNullOrUndefined=dP;function pP(e){return typeof e=="number"}rr.isNumber=pP;function gP(e){return typeof e=="string"}rr.isString=gP;function yP(e){return typeof e=="symbol"}rr.isSymbol=yP;function mP(e){return e===void 0}rr.isUndefined=mP;function vP(e){return ff(e)==="[object RegExp]"}rr.isRegExp=vP;function bP(e){return typeof e=="object"&&e!==null}rr.isObject=bP;function _P(e){return ff(e)==="[object Date]"}rr.isDate=_P;function SP(e){return ff(e)==="[object Error]"||e instanceof Error}rr.isError=SP;function wP(e){return typeof e=="function"}rr.isFunction=wP;function EP(e){return e===null||typeof e=="boolean"||typeof e=="number"||typeof e=="string"||typeof e=="symbol"||typeof e>"u"}rr.isPrimitive=EP;rr.isBuffer=Lt().Buffer.isBuffer;function ff(e){return Object.prototype.toString.call(e)}});var $v=B((fD,Gh)=>{"use strict";g();function xP(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var Yv=uf().Buffer,Hs=rn();function IP(e,t,r){e.copy(t,r)}Gh.exports=(function(){function e(){xP(this,e),this.head=null,this.tail=null,this.length=0}return e.prototype.push=function(r){var n={data:r,next:null};this.length>0?this.tail.next=n:this.head=n,this.tail=n,++this.length},e.prototype.unshift=function(r){var n={data:r,next:this.head};this.length===0&&(this.tail=n),this.head=n,++this.length},e.prototype.shift=function(){if(this.length!==0){var r=this.head.data;return this.length===1?this.head=this.tail=null:this.head=this.head.next,--this.length,r}},e.prototype.clear=function(){this.head=this.tail=null,this.length=0},e.prototype.join=function(r){if(this.length===0)return"";for(var n=this.head,i=""+n.data;n=n.next;)i+=r+n.data;return i},e.prototype.concat=function(r){if(this.length===0)return Yv.alloc(0);for(var n=Yv.allocUnsafe(r>>>0),i=this.head,o=0;i;)IP(i.data,n,o),o+=i.data.length,i=i.next;return n},e})();Hs&&Hs.inspect&&Hs.inspect.custom&&(Gh.exports.prototype[Hs.inspect.custom]=function(){var e=Hs.inspect({length:this.length});return this.constructor.name+" "+e})});var Vh=B((lD,Zv)=>{"use strict";g();var cf=qs();function AP(e,t){var r=this,n=this._readableState&&this._readableState.destroyed,i=this._writableState&&this._writableState.destroyed;return n||i?(t?t(e):e&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,cf.nextTick(lf,this,e)):cf.nextTick(lf,this,e)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(e||null,function(o){!t&&o?r._writableState?r._writableState.errorEmitted||(r._writableState.errorEmitted=!0,cf.nextTick(lf,r,o)):cf.nextTick(lf,r,o):t&&t(o)}),this)}function OP(){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 lf(e,t){e.emit("error",t)}Zv.exports={destroy:AP,undestroy:OP}});var zh=B((dD,ib)=>{"use strict";g();var ji=qs();ib.exports=Bt;function Jv(e){var t=this;this.next=null,this.entry=null,this.finish=function(){VP(t,e)}}var RP=!x.default.browser&&["v0.10","v0.9."].indexOf(x.default.version.slice(0,5))>-1?setImmediate:ji.nextTick,qo;Bt.WritableState=Ks;var Qv=Object.create(Fo());Qv.inherits=Je();var TP={deprecate:yh()},eb=jh(),df=uf().Buffer,PP=(typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function BP(e){return df.from(e)}function NP(e){return df.isBuffer(e)||e instanceof PP}var tb=Vh();Qv.inherits(Bt,eb);function MP(){}function Ks(e,t){qo=qo||Ki(),e=e||{};var r=t instanceof qo;this.objectMode=!!e.objectMode,r&&(this.objectMode=this.objectMode||!!e.writableObjectMode);var n=e.highWaterMark,i=e.writableHighWaterMark,o=this.objectMode?16:16*1024;n||n===0?this.highWaterMark=n:r&&(i||i===0)?this.highWaterMark=i:this.highWaterMark=o,this.highWaterMark=Math.floor(this.highWaterMark),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var s=e.decodeStrings===!1;this.decodeStrings=!s,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(a){qP(t,a)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new Jv(this)}Ks.prototype.getBuffer=function(){for(var t=this.bufferedRequest,r=[];t;)r.push(t),t=t.next;return r};(function(){try{Object.defineProperty(Ks.prototype,"buffer",{get:TP.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch{}})();var hf;typeof Symbol=="function"&&Symbol.hasInstance&&typeof Function.prototype[Symbol.hasInstance]=="function"?(hf=Function.prototype[Symbol.hasInstance],Object.defineProperty(Bt,Symbol.hasInstance,{value:function(e){return hf.call(this,e)?!0:this!==Bt?!1:e&&e._writableState instanceof Ks}})):hf=function(e){return e instanceof this};function Bt(e){if(qo=qo||Ki(),!hf.call(Bt,this)&&!(this instanceof qo))return new Bt(e);this._writableState=new Ks(e,this),this.writable=!0,e&&(typeof e.write=="function"&&(this._write=e.write),typeof e.writev=="function"&&(this._writev=e.writev),typeof e.destroy=="function"&&(this._destroy=e.destroy),typeof e.final=="function"&&(this._final=e.final)),eb.call(this)}Bt.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))};function kP(e,t){var r=new Error("write after end");e.emit("error",r),ji.nextTick(t,r)}function CP(e,t,r,n){var i=!0,o=!1;return r===null?o=new TypeError("May not write null values to stream"):typeof r!="string"&&r!==void 0&&!t.objectMode&&(o=new TypeError("Invalid non-string/buffer chunk")),o&&(e.emit("error",o),ji.nextTick(n,o),i=!1),i}Bt.prototype.write=function(e,t,r){var n=this._writableState,i=!1,o=!n.objectMode&&NP(e);return o&&!df.isBuffer(e)&&(e=BP(e)),typeof t=="function"&&(r=t,t=null),o?t="buffer":t||(t=n.defaultEncoding),typeof r!="function"&&(r=MP),n.ended?kP(this,r):(o||CP(this,n,e,r))&&(n.pendingcb++,i=DP(this,n,o,e,t,r)),i};Bt.prototype.cork=function(){var e=this._writableState;e.corked++};Bt.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,!e.writing&&!e.corked&&!e.bufferProcessing&&e.bufferedRequest&&rb(this,e))};Bt.prototype.setDefaultEncoding=function(t){if(typeof t=="string"&&(t=t.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((t+"").toLowerCase())>-1))throw new TypeError("Unknown encoding: "+t);return this._writableState.defaultEncoding=t,this};function LP(e,t,r){return!e.objectMode&&e.decodeStrings!==!1&&typeof t=="string"&&(t=df.from(t,r)),t}Object.defineProperty(Bt.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function DP(e,t,r,n,i,o){if(!r){var s=LP(t,n,i);n!==s&&(r=!0,i="buffer",n=s)}var a=t.objectMode?1:n.length;t.length+=a;var f=t.length<t.highWaterMark;if(f||(t.needDrain=!0),t.writing||t.corked){var l=t.lastBufferedRequest;t.lastBufferedRequest={chunk:n,encoding:i,isBuf:r,callback:o,next:null},l?l.next=t.lastBufferedRequest:t.bufferedRequest=t.lastBufferedRequest,t.bufferedRequestCount+=1}else Wh(e,t,!1,a,n,i,o);return f}function Wh(e,t,r,n,i,o,s){t.writelen=n,t.writecb=s,t.writing=!0,t.sync=!0,r?e._writev(i,t.onwrite):e._write(i,o,t.onwrite),t.sync=!1}function UP(e,t,r,n,i){--t.pendingcb,r?(ji.nextTick(i,n),ji.nextTick(js,e,t),e._writableState.errorEmitted=!0,e.emit("error",n)):(i(n),e._writableState.errorEmitted=!0,e.emit("error",n),js(e,t))}function FP(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}function qP(e,t){var r=e._writableState,n=r.sync,i=r.writecb;if(FP(r),t)UP(e,r,n,t,i);else{var o=nb(r);!o&&!r.corked&&!r.bufferProcessing&&r.bufferedRequest&&rb(e,r),n?RP(Xv,e,r,o,i):Xv(e,r,o,i)}}function Xv(e,t,r,n){r||HP(e,t),t.pendingcb--,n(),js(e,t)}function HP(e,t){t.length===0&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}function rb(e,t){t.bufferProcessing=!0;var r=t.bufferedRequest;if(e._writev&&r&&r.next){var n=t.bufferedRequestCount,i=new Array(n),o=t.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,Wh(e,t,!0,t.length,i,"",o.finish),t.pendingcb++,t.lastBufferedRequest=null,o.next?(t.corkedRequestsFree=o.next,o.next=null):t.corkedRequestsFree=new Jv(t),t.bufferedRequestCount=0}else{for(;r;){var f=r.chunk,l=r.encoding,m=r.callback,y=t.objectMode?1:f.length;if(Wh(e,t,!1,y,f,l,m),r=r.next,t.bufferedRequestCount--,t.writing)break}r===null&&(t.lastBufferedRequest=null)}t.bufferedRequest=r,t.bufferProcessing=!1}Bt.prototype._write=function(e,t,r){r(new Error("_write() is not implemented"))};Bt.prototype._writev=null;Bt.prototype.end=function(e,t,r){var n=this._writableState;typeof e=="function"?(r=e,e=null,t=null):typeof t=="function"&&(r=t,t=null),e!=null&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||GP(this,n,r)};function nb(e){return e.ending&&e.length===0&&e.bufferedRequest===null&&!e.finished&&!e.writing}function jP(e,t){e._final(function(r){t.pendingcb--,r&&e.emit("error",r),t.prefinished=!0,e.emit("prefinish"),js(e,t)})}function KP(e,t){!t.prefinished&&!t.finalCalled&&(typeof e._final=="function"?(t.pendingcb++,t.finalCalled=!0,ji.nextTick(jP,e,t)):(t.prefinished=!0,e.emit("prefinish")))}function js(e,t){var r=nb(t);return r&&(KP(e,t),t.pendingcb===0&&(t.finished=!0,e.emit("finish"))),r}function GP(e,t,r){t.ending=!0,js(e,t),r&&(t.finished?ji.nextTick(r):e.once("finish",r)),t.ended=!0,e.writable=!1}function VP(e,t,r){var n=e.entry;for(e.entry=null;n;){var i=n.callback;t.pendingcb--,i(r),n=n.next}t.corkedRequestsFree.next=e}Object.defineProperty(Bt.prototype,"destroyed",{get:function(){return this._writableState===void 0?!1:this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}});Bt.prototype.destroy=tb.destroy;Bt.prototype._undestroy=tb.undestroy;Bt.prototype._destroy=function(e,t){this.end(),t(e)}});var Ki=B((gD,ub)=>{"use strict";g();var ob=qs(),WP=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t};ub.exports=In;var sb=Object.create(Fo());sb.inherits=Je();var ab=Zh(),$h=zh();sb.inherits(In,ab);for(Yh=WP($h.prototype),pf=0;pf<Yh.length;pf++)gf=Yh[pf],In.prototype[gf]||(In.prototype[gf]=$h.prototype[gf]);var Yh,gf,pf;function In(e){if(!(this instanceof In))return new In(e);ab.call(this,e),$h.call(this,e),e&&e.readable===!1&&(this.readable=!1),e&&e.writable===!1&&(this.writable=!1),this.allowHalfOpen=!0,e&&e.allowHalfOpen===!1&&(this.allowHalfOpen=!1),this.once("end",zP)}Object.defineProperty(In.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function zP(){this.allowHalfOpen||this._writableState.ended||ob.nextTick(YP,this)}function YP(e){e.end()}Object.defineProperty(In.prototype,"destroyed",{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)}});In.prototype._destroy=function(e,t){this.push(null),this.end(),ob.nextTick(t,e)}});var Zh=B((vD,_b)=>{"use strict";g();var jo=qs();_b.exports=ct;var $P=Gv(),Gs;ct.ReadableState=gb;var mD=wo().EventEmitter,hb=function(e,t){return e.listeners(t).length},td=jh(),Vs=uf().Buffer,ZP=(typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function XP(e){return Vs.from(e)}function JP(e){return Vs.isBuffer(e)||e instanceof ZP}var db=Object.create(Fo());db.inherits=Je();var Xh=rn(),je=void 0;Xh&&Xh.debuglog?je=Xh.debuglog("stream"):je=function(){};var QP=$v(),pb=Vh(),Ho;db.inherits(ct,td);var Jh=["error","close","destroy","pause","resume"];function eB(e,t,r){if(typeof e.prependListener=="function")return e.prependListener(t,r);!e._events||!e._events[t]?e.on(t,r):$P(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]}function gb(e,t){Gs=Gs||Ki(),e=e||{};var r=t instanceof Gs;this.objectMode=!!e.objectMode,r&&(this.objectMode=this.objectMode||!!e.readableObjectMode);var n=e.highWaterMark,i=e.readableHighWaterMark,o=this.objectMode?16:16*1024;n||n===0?this.highWaterMark=n:r&&(i||i===0)?this.highWaterMark=i:this.highWaterMark=o,this.highWaterMark=Math.floor(this.highWaterMark),this.buffer=new QP,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.destroyed=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(Ho||(Ho=Co().StringDecoder),this.decoder=new Ho(e.encoding),this.encoding=e.encoding)}function ct(e){if(Gs=Gs||Ki(),!(this instanceof ct))return new ct(e);this._readableState=new gb(e,this),this.readable=!0,e&&(typeof e.read=="function"&&(this._read=e.read),typeof e.destroy=="function"&&(this._destroy=e.destroy)),td.call(this)}Object.defineProperty(ct.prototype,"destroyed",{get:function(){return this._readableState===void 0?!1:this._readableState.destroyed},set:function(e){this._readableState&&(this._readableState.destroyed=e)}});ct.prototype.destroy=pb.destroy;ct.prototype._undestroy=pb.undestroy;ct.prototype._destroy=function(e,t){this.push(null),t(e)};ct.prototype.push=function(e,t){var r=this._readableState,n;return r.objectMode?n=!0:typeof e=="string"&&(t=t||r.defaultEncoding,t!==r.encoding&&(e=Vs.from(e,t),t=""),n=!0),yb(this,e,t,!1,n)};ct.prototype.unshift=function(e){return yb(this,e,null,!0,!1)};function yb(e,t,r,n,i){var o=e._readableState;if(t===null)o.reading=!1,iB(e,o);else{var s;i||(s=tB(o,t)),s?e.emit("error",s):o.objectMode||t&&t.length>0?(typeof t!="string"&&!o.objectMode&&Object.getPrototypeOf(t)!==Vs.prototype&&(t=XP(t)),n?o.endEmitted?e.emit("error",new Error("stream.unshift() after end event")):Qh(e,o,t,!0):o.ended?e.emit("error",new Error("stream.push() after EOF")):(o.reading=!1,o.decoder&&!r?(t=o.decoder.write(t),o.objectMode||t.length!==0?Qh(e,o,t,!1):mb(e,o)):Qh(e,o,t,!1))):n||(o.reading=!1)}return rB(o)}function Qh(e,t,r,n){t.flowing&&t.length===0&&!t.sync?(e.emit("data",r),e.read(0)):(t.length+=t.objectMode?1:r.length,n?t.buffer.unshift(r):t.buffer.push(r),t.needReadable&&yf(e)),mb(e,t)}function tB(e,t){var r;return!JP(t)&&typeof t!="string"&&t!==void 0&&!e.objectMode&&(r=new TypeError("Invalid non-string/buffer chunk")),r}function rB(e){return!e.ended&&(e.needReadable||e.length<e.highWaterMark||e.length===0)}ct.prototype.isPaused=function(){return this._readableState.flowing===!1};ct.prototype.setEncoding=function(e){return Ho||(Ho=Co().StringDecoder),this._readableState.decoder=new Ho(e),this._readableState.encoding=e,this};var fb=8388608;function nB(e){return e>=fb?e=fb:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}function cb(e,t){return e<=0||t.length===0&&t.ended?0:t.objectMode?1:e!==e?t.flowing&&t.length?t.buffer.head.data.length:t.length:(e>t.highWaterMark&&(t.highWaterMark=nB(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}ct.prototype.read=function(e){je("read",e),e=parseInt(e,10);var t=this._readableState,r=e;if(e!==0&&(t.emittedReadable=!1),e===0&&t.needReadable&&(t.length>=t.highWaterMark||t.ended))return je("read: emitReadable",t.length,t.ended),t.length===0&&t.ended?ed(this):yf(this),null;if(e=cb(e,t),e===0&&t.ended)return t.length===0&&ed(this),null;var n=t.needReadable;je("need readable",n),(t.length===0||t.length-e<t.highWaterMark)&&(n=!0,je("length less than watermark",n)),t.ended||t.reading?(n=!1,je("reading or ended",n)):n&&(je("do read"),t.reading=!0,t.sync=!0,t.length===0&&(t.needReadable=!0),this._read(t.highWaterMark),t.sync=!1,t.reading||(e=cb(r,t)));var i;return e>0?i=vb(e,t):i=null,i===null?(t.needReadable=!0,e=0):t.length-=e,t.length===0&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&ed(this)),i!==null&&this.emit("data",i),i};function iB(e,t){if(!t.ended){if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,yf(e)}}function yf(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(je("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?jo.nextTick(lb,e):lb(e))}function lb(e){je("emit readable"),e.emit("readable"),rd(e)}function mb(e,t){t.readingMore||(t.readingMore=!0,jo.nextTick(oB,e,t))}function oB(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length<t.highWaterMark&&(je("maybeReadMore read 0"),e.read(0),r!==t.length);)r=t.length;t.readingMore=!1}ct.prototype._read=function(e){this.emit("error",new Error("_read() is not implemented"))};ct.prototype.pipe=function(e,t){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=e;break;case 1:n.pipes=[n.pipes,e];break;default:n.pipes.push(e);break}n.pipesCount+=1,je("pipe count=%d opts=%j",n.pipesCount,t);var i=(!t||t.end!==!1)&&e!==x.default.stdout&&e!==x.default.stderr,o=i?a:D;n.endEmitted?jo.nextTick(o):r.once("end",o),e.on("unpipe",s);function s(F,V){je("onunpipe"),F===r&&V&&V.hasUnpiped===!1&&(V.hasUnpiped=!0,m())}function a(){je("onend"),e.end()}var f=sB(r);e.on("drain",f);var l=!1;function m(){je("cleanup"),e.removeListener("close",O),e.removeListener("finish",M),e.removeListener("drain",f),e.removeListener("error",w),e.removeListener("unpipe",s),r.removeListener("end",a),r.removeListener("end",D),r.removeListener("data",p),l=!0,n.awaitDrain&&(!e._writableState||e._writableState.needDrain)&&f()}var y=!1;r.on("data",p);function p(F){je("ondata"),y=!1;var V=e.write(F);V===!1&&!y&&((n.pipesCount===1&&n.pipes===e||n.pipesCount>1&&bb(n.pipes,e)!==-1)&&!l&&(je("false write response, pause",n.awaitDrain),n.awaitDrain++,y=!0),r.pause())}function w(F){je("onerror",F),D(),e.removeListener("error",w),hb(e,"error")===0&&e.emit("error",F)}eB(e,"error",w);function O(){e.removeListener("finish",M),D()}e.once("close",O);function M(){je("onfinish"),e.removeListener("close",O),D()}e.once("finish",M);function D(){je("unpipe"),r.unpipe(e)}return e.emit("pipe",r),n.flowing||(je("pipe resume"),r.resume()),e};function sB(e){return function(){var t=e._readableState;je("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,t.awaitDrain===0&&hb(e,"data")&&(t.flowing=!0,rd(e))}}ct.prototype.unpipe=function(e){var t=this._readableState,r={hasUnpiped:!1};if(t.pipesCount===0)return this;if(t.pipesCount===1)return e&&e!==t.pipes?this:(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,r),this);if(!e){var n=t.pipes,i=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var o=0;o<i;o++)n[o].emit("unpipe",this,{hasUnpiped:!1});return this}var s=bb(t.pipes,e);return s===-1?this:(t.pipes.splice(s,1),t.pipesCount-=1,t.pipesCount===1&&(t.pipes=t.pipes[0]),e.emit("unpipe",this,r),this)};ct.prototype.on=function(e,t){var r=td.prototype.on.call(this,e,t);if(e==="data")this._readableState.flowing!==!1&&this.resume();else if(e==="readable"){var n=this._readableState;!n.endEmitted&&!n.readableListening&&(n.readableListening=n.needReadable=!0,n.emittedReadable=!1,n.reading?n.length&&yf(this):jo.nextTick(aB,this))}return r};ct.prototype.addListener=ct.prototype.on;function aB(e){je("readable nexttick read 0"),e.read(0)}ct.prototype.resume=function(){var e=this._readableState;return e.flowing||(je("resume"),e.flowing=!0,uB(this,e)),this};function uB(e,t){t.resumeScheduled||(t.resumeScheduled=!0,jo.nextTick(fB,e,t))}function fB(e,t){t.reading||(je("resume read 0"),e.read(0)),t.resumeScheduled=!1,t.awaitDrain=0,e.emit("resume"),rd(e),t.flowing&&!t.reading&&e.read(0)}ct.prototype.pause=function(){return je("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(je("pause"),this._readableState.flowing=!1,this.emit("pause")),this};function rd(e){var t=e._readableState;for(je("flow",t.flowing);t.flowing&&e.read()!==null;);}ct.prototype.wrap=function(e){var t=this,r=this._readableState,n=!1;e.on("end",function(){if(je("wrapped end"),r.decoder&&!r.ended){var s=r.decoder.end();s&&s.length&&t.push(s)}t.push(null)}),e.on("data",function(s){if(je("wrapped data"),r.decoder&&(s=r.decoder.write(s)),!(r.objectMode&&s==null)&&!(!r.objectMode&&(!s||!s.length))){var a=t.push(s);a||(n=!0,e.pause())}});for(var i in e)this[i]===void 0&&typeof e[i]=="function"&&(this[i]=(function(s){return function(){return e[s].apply(e,arguments)}})(i));for(var o=0;o<Jh.length;o++)e.on(Jh[o],this.emit.bind(this,Jh[o]));return this._read=function(s){je("wrapped _read",s),n&&(n=!1,e.resume())},this};Object.defineProperty(ct.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}});ct._fromList=vb;function vb(e,t){if(t.length===0)return null;var r;return t.objectMode?r=t.buffer.shift():!e||e>=t.length?(t.decoder?r=t.buffer.join(""):t.buffer.length===1?r=t.buffer.head.data:r=t.buffer.concat(t.length),t.buffer.clear()):r=cB(e,t.buffer,t.decoder),r}function cB(e,t,r){var n;return e<t.head.data.length?(n=t.head.data.slice(0,e),t.head.data=t.head.data.slice(e)):e===t.head.data.length?n=t.shift():n=r?lB(e,t):hB(e,t),n}function lB(e,t){var r=t.head,n=1,i=r.data;for(e-=i.length;r=r.next;){var o=r.data,s=e>o.length?o.length:e;if(s===o.length?i+=o:i+=o.slice(0,e),e-=s,e===0){s===o.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=o.slice(s));break}++n}return t.length-=n,i}function hB(e,t){var r=Vs.allocUnsafe(e),n=t.head,i=1;for(n.data.copy(r),e-=n.data.length;n=n.next;){var o=n.data,s=e>o.length?o.length:e;if(o.copy(r,r.length-e,0,s),e-=s,e===0){s===o.length?(++i,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=o.slice(s));break}++i}return t.length-=i,r}function ed(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,jo.nextTick(dB,t,e))}function dB(e,t){!e.endEmitted&&e.length===0&&(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function bb(e,t){for(var r=0,n=e.length;r<n;r++)if(e[r]===t)return r;return-1}});var nd=B((_D,Eb)=>{"use strict";g();Eb.exports=An;var mf=Ki(),wb=Object.create(Fo());wb.inherits=Je();wb.inherits(An,mf);function pB(e,t){var r=this._transformState;r.transforming=!1;var n=r.writecb;if(!n)return this.emit("error",new Error("write callback called multiple times"));r.writechunk=null,r.writecb=null,t!=null&&this.push(t),n(e);var i=this._readableState;i.reading=!1,(i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}function An(e){if(!(this instanceof An))return new An(e);mf.call(this,e),this._transformState={afterTransform:pB.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,e&&(typeof e.transform=="function"&&(this._transform=e.transform),typeof e.flush=="function"&&(this._flush=e.flush)),this.on("prefinish",gB)}function gB(){var e=this;typeof this._flush=="function"?this._flush(function(t,r){Sb(e,t,r)}):Sb(this,null,null)}An.prototype.push=function(e,t){return this._transformState.needTransform=!1,mf.prototype.push.call(this,e,t)};An.prototype._transform=function(e,t,r){throw new Error("_transform() is not implemented")};An.prototype._write=function(e,t,r){var n=this._transformState;if(n.writecb=r,n.writechunk=e,n.writeencoding=t,!n.transforming){var i=this._readableState;(n.needTransform||i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}};An.prototype._read=function(e){var t=this._transformState;t.writechunk!==null&&t.writecb&&!t.transforming?(t.transforming=!0,this._transform(t.writechunk,t.writeencoding,t.afterTransform)):t.needTransform=!0};An.prototype._destroy=function(e,t){var r=this;mf.prototype._destroy.call(this,e,function(n){t(n),r.emit("close")})};function Sb(e,t,r){if(t)return e.emit("error",t);if(r!=null&&e.push(r),e._writableState.length)throw new Error("Calling transform done when ws.length != 0");if(e._transformState.transforming)throw new Error("Calling transform done when still transforming");return e.push(null)}});var Ob=B((wD,Ab)=>{"use strict";g();Ab.exports=Ws;var xb=nd(),Ib=Object.create(Fo());Ib.inherits=Je();Ib.inherits(Ws,xb);function Ws(e){if(!(this instanceof Ws))return new Ws(e);xb.call(this,e)}Ws.prototype._transform=function(e,t,r){r(null,e)}});var Tb=B((sn,Rb)=>{g();sn=Rb.exports=Zh();sn.Stream=sn;sn.Readable=sn;sn.Writable=zh();sn.Duplex=Ki();sn.Transform=nd();sn.PassThrough=Ob()});var Nb=B((ID,Bb)=>{"use strict";g();var yB=Yt().Buffer,mB=jv(),Pb=Tb().Transform,vB=Je();function ni(e){Pb.call(this),this._block=yB.allocUnsafe(e),this._blockSize=e,this._blockOffset=0,this._length=[0,0,0,0],this._finalized=!1}vB(ni,Pb);ni.prototype._transform=function(e,t,r){var n=null;try{this.update(e,t)}catch(i){n=i}r(n)};ni.prototype._flush=function(e){var t=null;try{this.push(this.digest())}catch(r){t=r}e(t)};ni.prototype.update=function(e,t){if(this._finalized)throw new Error("Digest already called");for(var r=mB(e,t),n=this._block,i=0;this._blockOffset+r.length-i>=this._blockSize;){for(var o=this._blockOffset;o<this._blockSize;)n[o]=r[i],o+=1,i+=1;this._update(),this._blockOffset=0}for(;i<r.length;)n[this._blockOffset]=r[i],this._blockOffset+=1,i+=1;for(var s=0,a=r.length*8;a>0;++s)this._length[s]+=a,a=this._length[s]/4294967296|0,a>0&&(this._length[s]-=4294967296*a);return this};ni.prototype._update=function(){throw new Error("_update is not implemented")};ni.prototype.digest=function(e){if(this._finalized)throw new Error("Digest already called");this._finalized=!0;var t=this._digest();e!==void 0&&(t=t.toString(e)),this._block.fill(0),this._blockOffset=0;for(var r=0;r<4;++r)this._length[r]=0;return t};ni.prototype._digest=function(){throw new Error("_digest is not implemented")};Bb.exports=ni});var od=B((OD,Fb)=>{"use strict";g();var id=Lt().Buffer,bB=Je(),Ub=Nb(),_B=new Array(16),zs=[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],Ys=[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],$s=[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],Zs=[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],Xs=[0,1518500249,1859775393,2400959708,2840853838],Js=[1352829926,1548603684,1836072691,2053994217,0];function Gi(e,t){return e<<t|e>>>32-t}function Mb(e,t,r,n,i,o,s,a){return Gi(e+(t^r^n)+o+s|0,a)+i|0}function kb(e,t,r,n,i,o,s,a){return Gi(e+(t&r|~t&n)+o+s|0,a)+i|0}function Cb(e,t,r,n,i,o,s,a){return Gi(e+((t|~r)^n)+o+s|0,a)+i|0}function Lb(e,t,r,n,i,o,s,a){return Gi(e+(t&n|r&~n)+o+s|0,a)+i|0}function Db(e,t,r,n,i,o,s,a){return Gi(e+(t^(r|~n))+o+s|0,a)+i|0}function vf(){Ub.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520}bB(vf,Ub);vf.prototype._update=function(){for(var e=_B,t=0;t<16;++t)e[t]=this._block.readInt32LE(t*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,f=this._b|0,l=this._c|0,m=this._d|0,y=this._e|0,p=0;p<80;p+=1){var w,O;p<16?(w=Mb(r,n,i,o,s,e[zs[p]],Xs[0],$s[p]),O=Db(a,f,l,m,y,e[Ys[p]],Js[0],Zs[p])):p<32?(w=kb(r,n,i,o,s,e[zs[p]],Xs[1],$s[p]),O=Lb(a,f,l,m,y,e[Ys[p]],Js[1],Zs[p])):p<48?(w=Cb(r,n,i,o,s,e[zs[p]],Xs[2],$s[p]),O=Cb(a,f,l,m,y,e[Ys[p]],Js[2],Zs[p])):p<64?(w=Lb(r,n,i,o,s,e[zs[p]],Xs[3],$s[p]),O=kb(a,f,l,m,y,e[Ys[p]],Js[3],Zs[p])):(w=Db(r,n,i,o,s,e[zs[p]],Xs[4],$s[p]),O=Mb(a,f,l,m,y,e[Ys[p]],Js[4],Zs[p])),r=s,s=o,o=Gi(i,10),i=n,n=w,a=y,y=m,m=Gi(l,10),l=f,f=O}var M=this._b+i+m|0;this._b=this._c+o+y|0,this._c=this._d+s+a|0,this._d=this._e+r+f|0,this._e=this._a+n+l|0,this._a=M};vf.prototype._digest=function(){this._block[this._blockOffset]=128,this._blockOffset+=1,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 e=id.alloc?id.alloc(20):new id(20);return e.writeInt32LE(this._a,0),e.writeInt32LE(this._b,4),e.writeInt32LE(this._c,8),e.writeInt32LE(this._d,12),e.writeInt32LE(this._e,16),e};Fb.exports=vf});var Vi=B((TD,qb)=>{"use strict";g();var SB=Yt().Buffer,wB=sf();function bf(e,t){this._block=SB.alloc(e),this._finalSize=t,this._blockSize=e,this._len=0}bf.prototype.update=function(e,t){e=wB(e,t||"utf8");for(var r=this._block,n=this._blockSize,i=e.length,o=this._len,s=0;s<i;){for(var a=o%n,f=Math.min(i-s,n-a),l=0;l<f;l++)r[a+l]=e[s+l];o+=f,s+=f,o%n===0&&this._update(r)}return this._len+=i,this};bf.prototype.digest=function(e){var t=this._len%this._blockSize;this._block[t]=128,this._block.fill(0,t+1),t>=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 e?o.toString(e):o};bf.prototype._update=function(){throw new Error("_update must be implemented by subclass")};qb.exports=bf});var Kb=B((BD,jb)=>{"use strict";g();var EB=Je(),Hb=Vi(),xB=Yt().Buffer,IB=[1518500249,1859775393,-1894007588,-899497514],AB=new Array(80);function Qs(){this.init(),this._w=AB,Hb.call(this,64,56)}EB(Qs,Hb);Qs.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function OB(e){return e<<5|e>>>27}function RB(e){return e<<30|e>>>2}function TB(e,t,r,n){return e===0?t&r|~t&n:e===2?t&r|t&n|r&n:t^r^n}Qs.prototype._update=function(e){for(var t=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)t[a]=e.readInt32BE(a*4);for(;a<80;++a)t[a]=t[a-3]^t[a-8]^t[a-14]^t[a-16];for(var f=0;f<80;++f){var l=~~(f/20),m=OB(r)+TB(l,n,i,o)+s+t[f]+IB[l]|0;s=o,o=i,i=RB(n),n=r,r=m}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};Qs.prototype._hash=function(){var e=xB.allocUnsafe(20);return e.writeInt32BE(this._a|0,0),e.writeInt32BE(this._b|0,4),e.writeInt32BE(this._c|0,8),e.writeInt32BE(this._d|0,12),e.writeInt32BE(this._e|0,16),e};jb.exports=Qs});var Wb=B((MD,Vb)=>{"use strict";g();var PB=Je(),Gb=Vi(),BB=Yt().Buffer,NB=[1518500249,1859775393,-1894007588,-899497514],MB=new Array(80);function ea(){this.init(),this._w=MB,Gb.call(this,64,56)}PB(ea,Gb);ea.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function kB(e){return e<<1|e>>>31}function CB(e){return e<<5|e>>>27}function LB(e){return e<<30|e>>>2}function DB(e,t,r,n){return e===0?t&r|~t&n:e===2?t&r|t&n|r&n:t^r^n}ea.prototype._update=function(e){for(var t=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)t[a]=e.readInt32BE(a*4);for(;a<80;++a)t[a]=kB(t[a-3]^t[a-8]^t[a-14]^t[a-16]);for(var f=0;f<80;++f){var l=~~(f/20),m=CB(r)+DB(l,n,i,o)+s+t[f]+NB[l]|0;s=o,o=i,i=LB(n),n=r,r=m}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};ea.prototype._hash=function(){var e=BB.allocUnsafe(20);return e.writeInt32BE(this._a|0,0),e.writeInt32BE(this._b|0,4),e.writeInt32BE(this._c|0,8),e.writeInt32BE(this._d|0,12),e.writeInt32BE(this._e|0,16),e};Vb.exports=ea});var sd=B((CD,Yb)=>{"use strict";g();var UB=Je(),zb=Vi(),FB=Yt().Buffer,qB=[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],HB=new Array(64);function ta(){this.init(),this._w=HB,zb.call(this,64,56)}UB(ta,zb);ta.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 jB(e,t,r){return r^e&(t^r)}function KB(e,t,r){return e&t|r&(e|t)}function GB(e){return(e>>>2|e<<30)^(e>>>13|e<<19)^(e>>>22|e<<10)}function VB(e){return(e>>>6|e<<26)^(e>>>11|e<<21)^(e>>>25|e<<7)}function WB(e){return(e>>>7|e<<25)^(e>>>18|e<<14)^e>>>3}function zB(e){return(e>>>17|e<<15)^(e>>>19|e<<13)^e>>>10}ta.prototype._update=function(e){for(var t=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,f=this._g|0,l=this._h|0,m=0;m<16;++m)t[m]=e.readInt32BE(m*4);for(;m<64;++m)t[m]=zB(t[m-2])+t[m-7]+WB(t[m-15])+t[m-16]|0;for(var y=0;y<64;++y){var p=l+VB(s)+jB(s,a,f)+qB[y]+t[y]|0,w=GB(r)+KB(r,n,i)|0;l=f,f=a,a=s,s=o+p|0,o=i,i=n,n=r,r=p+w|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=f+this._g|0,this._h=l+this._h|0};ta.prototype._hash=function(){var e=FB.allocUnsafe(32);return e.writeInt32BE(this._a,0),e.writeInt32BE(this._b,4),e.writeInt32BE(this._c,8),e.writeInt32BE(this._d,12),e.writeInt32BE(this._e,16),e.writeInt32BE(this._f,20),e.writeInt32BE(this._g,24),e.writeInt32BE(this._h,28),e};Yb.exports=ta});var Zb=B((DD,$b)=>{"use strict";g();var YB=Je(),$B=sd(),ZB=Vi(),XB=Yt().Buffer,JB=new Array(64);function _f(){this.init(),this._w=JB,ZB.call(this,64,56)}YB(_f,$B);_f.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};_f.prototype._hash=function(){var e=XB.allocUnsafe(28);return e.writeInt32BE(this._a,0),e.writeInt32BE(this._b,4),e.writeInt32BE(this._c,8),e.writeInt32BE(this._d,12),e.writeInt32BE(this._e,16),e.writeInt32BE(this._f,20),e.writeInt32BE(this._g,24),e};$b.exports=_f});var ad=B((FD,n_)=>{"use strict";g();var QB=Je(),r_=Vi(),eN=Yt().Buffer,Xb=[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],tN=new Array(160);function ra(){this.init(),this._w=tN,r_.call(this,128,112)}QB(ra,r_);ra.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 Jb(e,t,r){return r^e&(t^r)}function Qb(e,t,r){return e&t|r&(e|t)}function e_(e,t){return(e>>>28|t<<4)^(t>>>2|e<<30)^(t>>>7|e<<25)}function t_(e,t){return(e>>>14|t<<18)^(e>>>18|t<<14)^(t>>>9|e<<23)}function rN(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^e>>>7}function nN(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^(e>>>7|t<<25)}function iN(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^e>>>6}function oN(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^(e>>>6|t<<26)}function Gt(e,t){return e>>>0<t>>>0?1:0}ra.prototype._update=function(e){for(var t=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,f=this._gh|0,l=this._hh|0,m=this._al|0,y=this._bl|0,p=this._cl|0,w=this._dl|0,O=this._el|0,M=this._fl|0,D=this._gl|0,F=this._hl|0,V=0;V<32;V+=2)t[V]=e.readInt32BE(V*4),t[V+1]=e.readInt32BE(V*4+4);for(;V<160;V+=2){var Y=t[V-30],Q=t[V-30+1],ce=rN(Y,Q),ee=nN(Q,Y);Y=t[V-4],Q=t[V-4+1];var de=iN(Y,Q),pe=oN(Q,Y),xe=t[V-14],I=t[V-14+1],u=t[V-32],h=t[V-32+1],v=ee+I|0,_=ce+xe+Gt(v,ee)|0;v=v+pe|0,_=_+de+Gt(v,pe)|0,v=v+h|0,_=_+u+Gt(v,h)|0,t[V]=_,t[V+1]=v}for(var S=0;S<160;S+=2){_=t[S],v=t[S+1];var T=Qb(r,n,i),P=Qb(m,y,p),E=e_(r,m),c=e_(m,r),b=t_(s,O),C=t_(O,s),N=Xb[S],L=Xb[S+1],K=Jb(s,a,f),z=Jb(O,M,D),W=F+C|0,te=l+b+Gt(W,F)|0;W=W+z|0,te=te+K+Gt(W,z)|0,W=W+L|0,te=te+N+Gt(W,L)|0,W=W+v|0,te=te+_+Gt(W,v)|0;var re=c+P|0,se=E+T+Gt(re,c)|0;l=f,F=D,f=a,D=M,a=s,M=O,O=w+W|0,s=o+te+Gt(O,w)|0,o=i,w=p,i=n,p=y,n=r,y=m,m=W+re|0,r=te+se+Gt(m,W)|0}this._al=this._al+m|0,this._bl=this._bl+y|0,this._cl=this._cl+p|0,this._dl=this._dl+w|0,this._el=this._el+O|0,this._fl=this._fl+M|0,this._gl=this._gl+D|0,this._hl=this._hl+F|0,this._ah=this._ah+r+Gt(this._al,m)|0,this._bh=this._bh+n+Gt(this._bl,y)|0,this._ch=this._ch+i+Gt(this._cl,p)|0,this._dh=this._dh+o+Gt(this._dl,w)|0,this._eh=this._eh+s+Gt(this._el,O)|0,this._fh=this._fh+a+Gt(this._fl,M)|0,this._gh=this._gh+f+Gt(this._gl,D)|0,this._hh=this._hh+l+Gt(this._hl,F)|0};ra.prototype._hash=function(){var e=eN.allocUnsafe(64);function t(r,n,i){e.writeInt32BE(r,i),e.writeInt32BE(n,i+4)}return t(this._ah,this._al,0),t(this._bh,this._bl,8),t(this._ch,this._cl,16),t(this._dh,this._dl,24),t(this._eh,this._el,32),t(this._fh,this._fl,40),t(this._gh,this._gl,48),t(this._hh,this._hl,56),e};n_.exports=ra});var o_=B((HD,i_)=>{"use strict";g();var sN=Je(),aN=ad(),uN=Vi(),fN=Yt().Buffer,cN=new Array(160);function Sf(){this.init(),this._w=cN,uN.call(this,128,112)}sN(Sf,aN);Sf.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};Sf.prototype._hash=function(){var e=fN.allocUnsafe(48);function t(r,n,i){e.writeInt32BE(r,i),e.writeInt32BE(n,i+4)}return t(this._ah,this._al,0),t(this._bh,this._bl,8),t(this._ch,this._cl,16),t(this._dh,this._dl,24),t(this._eh,this._el,32),t(this._fh,this._fl,40),e};i_.exports=Sf});var ud=B((KD,On)=>{"use strict";g();On.exports=function(t){var r=t.toLowerCase(),n=On.exports[r];if(!n)throw new Error(r+" is not supported (we accept pull requests)");return new n};On.exports.sha=Kb();On.exports.sha1=Wb();On.exports.sha224=Zb();On.exports.sha256=sd();On.exports.sha384=o_();On.exports.sha512=ad()});var wf=B((VD,a_)=>{"use strict";g();var lN=Yt().Buffer,s_=Fh().Transform,hN=Co().StringDecoder,dN=Je(),pN=sf();function Cr(e){s_.call(this),this.hashMode=typeof e=="string",this.hashMode?this[e]=this._finalOrDigest:this.final=this._finalOrDigest,this._final&&(this.__final=this._final,this._final=null),this._decoder=null,this._encoding=null}dN(Cr,s_);Cr.prototype.update=function(e,t,r){var n=pN(e,t),i=this._update(n);return this.hashMode?this:(r&&(i=this._toString(i,r)),i)};Cr.prototype.setAutoPadding=function(){};Cr.prototype.getAuthTag=function(){throw new Error("trying to get auth tag in unsupported state")};Cr.prototype.setAuthTag=function(){throw new Error("trying to set auth tag in unsupported state")};Cr.prototype.setAAD=function(){throw new Error("trying to set aad in unsupported state")};Cr.prototype._transform=function(e,t,r){var n;try{this.hashMode?this._update(e):this.push(this._update(e))}catch(i){n=i}finally{r(n)}};Cr.prototype._flush=function(e){var t;try{this.push(this.__final())}catch(r){t=r}e(t)};Cr.prototype._finalOrDigest=function(e){var t=this.__final()||lN.alloc(0);return e&&(t=this._toString(t,e,!0)),t};Cr.prototype._toString=function(e,t,r){if(this._decoder||(this._decoder=new hN(t),this._encoding=t),this._encoding!==t)throw new Error("can\u2019t switch encodings");var n=this._decoder.write(e);return r&&(n+=this._decoder.end()),n};a_.exports=Cr});var c_=B((zD,f_)=>{"use strict";g();var gN=Je(),yN=qh(),mN=od(),vN=ud(),u_=wf();function Ef(e){u_.call(this,"digest"),this._hash=e}gN(Ef,u_);Ef.prototype._update=function(e){this._hash.update(e)};Ef.prototype._final=function(){return this._hash.digest()};f_.exports=function(t){return t=t.toLowerCase(),t==="md5"?new yN:t==="rmd160"||t==="ripemd160"?new mN:new Ef(vN(t))}});var d_=B(($D,h_)=>{"use strict";g();var bN=Je(),Wi=Yt().Buffer,l_=wf(),_N=Wi.alloc(128),Ko=64;function xf(e,t){l_.call(this,"digest"),typeof t=="string"&&(t=Wi.from(t)),this._alg=e,this._key=t,t.length>Ko?t=e(t):t.length<Ko&&(t=Wi.concat([t,_N],Ko));for(var r=this._ipad=Wi.allocUnsafe(Ko),n=this._opad=Wi.allocUnsafe(Ko),i=0;i<Ko;i++)r[i]=t[i]^54,n[i]=t[i]^92;this._hash=[r]}bN(xf,l_);xf.prototype._update=function(e){this._hash.push(e)};xf.prototype._final=function(){var e=this._alg(Wi.concat(this._hash));return this._alg(Wi.concat([this._opad,e]))};h_.exports=xf});var g_=B((XD,p_)=>{g();var SN=qh();p_.exports=function(e){return new SN().update(e).digest()}});var v_=B((QD,m_)=>{"use strict";g();var wN=Je(),EN=d_(),y_=wf(),na=Yt().Buffer,xN=g_(),fd=od(),cd=ud(),IN=na.alloc(128);function ia(e,t){y_.call(this,"digest"),typeof t=="string"&&(t=na.from(t));var r=e==="sha512"||e==="sha384"?128:64;if(this._alg=e,this._key=t,t.length>r){var n=e==="rmd160"?new fd:cd(e);t=n.update(t).digest()}else t.length<r&&(t=na.concat([t,IN],r));for(var i=this._ipad=na.allocUnsafe(r),o=this._opad=na.allocUnsafe(r),s=0;s<r;s++)i[s]=t[s]^54,o[s]=t[s]^92;this._hash=e==="rmd160"?new fd:cd(e),this._hash.update(i)}wN(ia,y_);ia.prototype._update=function(e){this._hash.update(e)};ia.prototype._final=function(){var e=this._hash.digest(),t=this._alg==="rmd160"?new fd:cd(this._alg);return t.update(this._opad).update(e).digest()};m_.exports=function(t,r){return t=t.toLowerCase(),t==="rmd160"||t==="ripemd160"?new ia("rmd160",r):t==="md5"?new EN(xN,r):new ia(t,r)}});var b_=B((tU,hd)=>{"use strict";g();var ld=65536,AN=4294967295;function ON(){throw new Error(`Secure random number generation is not supported by this browser.
11
+ Use Chrome, Firefox or Internet Explorer 11`)}var RN=Yt().Buffer,If=globalThis.crypto||globalThis.msCrypto;If&&If.getRandomValues?hd.exports=TN:hd.exports=ON;function TN(e,t){if(e>AN)throw new RangeError("requested too many random bytes");var r=RN.allocUnsafe(e);if(e>0)if(e>ld)for(var n=0;n<e;n+=ld)If.getRandomValues(r.slice(n,n+ld));else If.getRandomValues(r);return typeof t=="function"?x.default.nextTick(function(){t(null,r)}):r}});var oa=B(Af=>{"use strict";g();Af.createHash=c_();Af.createHmac=v_();Af.randomBytes=b_()});var sa=B((oU,S_)=>{"use strict";g();var __=65536;function zi(){}zi.getRandomBuffer=function(e){var t=typeof globalThis<"u"?globalThis.crypto:void 0;if(t&&typeof t.getRandomValues=="function")return zi._fromGetRandomValues(t,e);try{var r=oa();if(r&&typeof r.randomBytes=="function")return r.randomBytes(e)}catch{}throw new Error("bsv: no CSPRNG available in this environment (needs globalThis.crypto.getRandomValues or node crypto)")};zi._fromGetRandomValues=function(e,t){for(var r=d.Buffer.alloc(t),n=0;n<t;n+=__){var i=new Uint8Array(Math.min(__,t-n));e.getRandomValues(i),d.Buffer.from(i).copy(r,n)}return r};zi.getRandomBufferNode=function(e){var t=oa();return t.randomBytes(e)};zi.getRandomBufferBrowser=function(e){var t=typeof globalThis<"u"?globalThis:{},r=null;if(t.crypto&&typeof t.crypto.getRandomValues=="function"?r=t.crypto:t.msCrypto&&typeof t.msCrypto.getRandomValues=="function"&&(r=t.msCrypto),!r)throw new Error("window.crypto.getRandomValues not available");return zi._fromGetRandomValues(r,e)};S_.exports=zi});var at=B((aU,w_)=>{"use strict";g();var PN=sa(),st={};st.isArray=e=>Array.isArray(e);st.isNumber=e=>typeof e=="number";st.isObject=e=>e&&typeof e=="object";st.isString=e=>typeof e=="string";st.isUndefined=e=>typeof e>"u";st.isFunction=e=>typeof e=="function";st.isNull=e=>e===null;st.isDate=e=>e instanceof Date;st.extend=(e,t)=>Object.assign(e,t);st.noop=()=>{};st.every=(e,t)=>e.every(t||(r=>r));st.map=(e,t)=>Array.from(e).map(t||(r=>r));st.includes=(e,t)=>e.includes(t);st.each=(e,t)=>e.forEach(t);st.clone=e=>Object.assign({},e);st.pick=(e,t)=>{let r={};return t.forEach(n=>{typeof e[n]<"u"&&(r[n]=e[n])}),r};st.values=e=>Object.values(e);st.filter=(e,t)=>e.filter(t);st.reduce=(e,t,r)=>e.reduce(t,r);st.without=(e,t)=>e.filter(r=>r!==t);st.shuffle=e=>{let t=e.slice(0);for(let r=t.length-1;r>0;r--){let i=PN.getRandomBuffer(4).readUInt32BE(0)/4294967296,o=Math.floor(i*(r+1));[t[r],t[o]]=[t[o],t[r]]}return t};st.difference=(e,t)=>e.filter(r=>!t.includes(r));st.findIndex=(e,t)=>e.findIndex(t);st.some=(e,t)=>e.some(t);st.range=e=>[...Array(e).keys()];w_.exports=st});var x_=B((fU,E_)=>{"use strict";g();var BN="https://docs.moneybutton.com/";E_.exports=[{name:"InvalidB58Char",message:"Invalid Base58 character: {0} in {1}"},{name:"InvalidB58Checksum",message:"Invalid Base58 checksum for {0}"},{name:"InvalidNetwork",message:"Invalid version for network: got {0}"},{name:"InvalidState",message:"Invalid state: {0}"},{name:"NotImplemented",message:"Function {0} was not implemented yet"},{name:"InvalidNetworkArgument",message:'Invalid network: must be "livenet" or "testnet", got {0}'},{name:"InvalidArgument",message:function(){return"Invalid Argument"+(arguments[0]?": "+arguments[0]:"")+(arguments[1]?" Documentation: "+BN+arguments[1]:"")}},{name:"AbstractMethodInvoked",message:"Abstract Method Invocation: {0}"},{name:"InvalidArgumentType",message:function(){return"Invalid Argument for "+arguments[2]+", expected "+arguments[1]+" but got "+typeof arguments[0]}},{name:"Unit",message:"Internal Error on Unit {0}",errors:[{name:"UnknownCode",message:"Unrecognized unit code: {0}"},{name:"InvalidRate",message:"Invalid exchange rate: {0}"}]},{name:"MerkleBlock",message:"Internal Error on MerkleBlock {0}",errors:[{name:"InvalidMerkleTree",message:"This MerkleBlock contain an invalid Merkle Tree"}]},{name:"Transaction",message:"Internal Error on Transaction {0}",errors:[{name:"Input",message:"Internal Error on Input {0}",errors:[{name:"MissingScript",message:"Need a script to create an input"},{name:"UnsupportedScript",message:"Unsupported input script type: {0}"},{name:"MissingPreviousOutput",message:"No previous output information."}]},{name:"NeedMoreInfo",message:"{0}"},{name:"InvalidSorting",message:"The sorting function provided did not return the change output as one of the array elements"},{name:"InvalidOutputAmountSum",message:"{0}"},{name:"MissingSignatures",message:"Some inputs have not been fully signed"},{name:"InvalidIndex",message:"Invalid index: {0} is not between 0, {1}"},{name:"UnableToVerifySignature",message:"Unable to verify signature: {0}"},{name:"DustOutputs",message:"Dust amount detected in one output"},{name:"InvalidSatoshis",message:"Output satoshis are invalid"},{name:"FeeError",message:"Internal Error on Fee {0}",errors:[{name:"TooSmall",message:"Fee is too small: {0}"},{name:"TooLarge",message:"Fee is too large: {0}"},{name:"Different",message:"Unspent value is different from specified fee: {0}"}]},{name:"ChangeAddressMissing",message:"Change address is missing"},{name:"BlockHeightTooHigh",message:"Block Height can be at most 2^32 -1"},{name:"NLockTimeOutOfRange",message:"Block Height can only be between 0 and 499 999 999"},{name:"LockTimeTooEarly",message:"Lock Time can't be earlier than UNIX date 500 000 000"}]},{name:"Script",message:"Internal Error on Script {0}",errors:[{name:"UnrecognizedAddress",message:"Expected argument {0} to be an address"},{name:"CantDeriveAddress",message:"Can't derive address associated with script {0}, needs to be p2pkh in, p2pkh out, p2sh in, or p2sh out."},{name:"InvalidBuffer",message:"Invalid script buffer: can't parse valid script from given buffer {0}"}]},{name:"HDPrivateKey",message:"Internal Error on HDPrivateKey {0}",errors:[{name:"InvalidDerivationArgument",message:"Invalid derivation argument {0}, expected string, or number and boolean"},{name:"InvalidEntropyArgument",message:"Invalid entropy: must be an hexa string or binary buffer, got {0}",errors:[{name:"TooMuchEntropy",message:'Invalid entropy: more than 512 bits is non standard, got "{0}"'},{name:"NotEnoughEntropy",message:'Invalid entropy: at least 128 bits needed, got "{0}"'}]},{name:"InvalidLength",message:"Invalid length for xprivkey string in {0}"},{name:"InvalidPath",message:"Invalid derivation path: {0}"},{name:"UnrecognizedArgument",message:'Invalid argument: creating a HDPrivateKey requires a string, buffer, json or object, got "{0}"'}]},{name:"HDPublicKey",message:"Internal Error on HDPublicKey {0}",errors:[{name:"ArgumentIsPrivateExtended",message:"Argument is an extended private key: {0}"},{name:"InvalidDerivationArgument",message:"Invalid derivation argument: got {0}"},{name:"InvalidLength",message:'Invalid length for xpubkey: got "{0}"'},{name:"InvalidPath",message:'Invalid derivation path, it should look like: "m/1/100", got "{0}"'},{name:"InvalidIndexCantDeriveHardened",message:"Invalid argument: creating a hardened path requires an HDPrivateKey"},{name:"MustSupplyArgument",message:"Must supply an argument to create a HDPublicKey"},{name:"UnrecognizedArgument",message:"Invalid argument for creation, must be string, json, buffer, or object"}]}]});var ii=B((lU,pd)=>{"use strict";g();var dd=at();function NN(e,t){return e.replace("{0}",t[0]).replace("{1}",t[1]).replace("{2}",t[2])}var I_=function(e,t){var r=function(){if(dd.isString(t.message))this.message=NN(t.message,arguments);else if(dd.isFunction(t.message))this.message=t.message.apply(null,arguments);else throw new Error("Invalid error definition for "+t.name);this.stack=this.message+`
12
+ `+new Error().stack};return r.prototype=Object.create(e.prototype),r.prototype.name=e.prototype.name+t.name,e[t.name]=r,t.errors&&A_(r,t.errors),r},A_=function(e,t){dd.each(t,function(r){I_(e,r)})},MN=function(e,t){return A_(e,t),e},Go={};Go.Error=function(){this.message="Internal error",this.stack=this.message+`
13
+ `+new Error().stack};Go.Error.prototype=Object.create(Error.prototype);Go.Error.prototype.name="bsv.Error";var kN=x_();MN(Go.Error,kN);pd.exports=Go.Error;pd.exports.extend=function(e){return I_(Go.Error,e)}});var We=B((dU,O_)=>{"use strict";g();var aa=ii(),CN=at();O_.exports={checkState:function(e,t){if(!e)throw new aa.InvalidState(t)},checkArgument:function(e,t,r,n){if(!e)throw new aa.InvalidArgument(t,r,n)},checkArgumentType:function(e,t,r){if(r=r||"(unknown name)",CN.isString(t)){if(t==="Buffer"){var n=Lt();if(!n.Buffer.isBuffer(e))throw new aa.InvalidArgumentType(e,t,r)}else if(typeof e!==t)throw new aa.InvalidArgumentType(e,t,r)}else if(!(e instanceof t))throw new aa.InvalidArgumentType(e,t.name,r)}}});var Ar=B((gU,B_)=>{"use strict";g();var qe=U0(),T_=We(),P_=at(),Of=function(e){for(var t=d.Buffer.alloc(e.length),r=0;r<e.length;r++)t[r]=e[e.length-1-r];return t};qe.Zero=new qe(0);qe.One=new qe(1);qe.Minus1=new qe(-1);qe.fromNumber=function(e){return T_.checkArgument(P_.isNumber(e)),new qe(e)};qe.fromString=function(e,t){return T_.checkArgument(P_.isString(e)),new qe(e,t)};qe.fromBuffer=function(e,t){typeof t<"u"&&t.endian==="little"&&(e=Of(e));var r=e.toString("hex"),n=new qe(r,16);return n};qe.fromSM=function(e,t){var r;if(e.length===0)return qe.fromBuffer(d.Buffer.from([0]));var n="big";return t&&(n=t.endian),n==="little"&&(e=Of(e)),e[0]&128?(e[0]=e[0]&127,r=qe.fromBuffer(e),r.neg().copy(r)):r=qe.fromBuffer(e),r};qe.prototype.toNumber=function(){return parseInt(this.toString(10),10)};qe.prototype.toBuffer=function(e){var t,r;if(e&&e.size){r=this.toString(16,2);var n=r.length/2;t=d.Buffer.from(r,"hex"),n===e.size||(n>e.size?t=qe.trim(t,n):n<e.size&&(t=qe.pad(t,n,e.size)))}else r=this.toString(16,2),t=d.Buffer.from(r,"hex");return typeof e<"u"&&e.endian==="little"&&(t=Of(t)),t};qe.prototype.toSMBigEndian=function(){var e;return this.cmp(qe.Zero)===-1?(e=this.neg().toBuffer(),e[0]&128?e=d.Buffer.concat([d.Buffer.from([128]),e]):e[0]=e[0]|128):(e=this.toBuffer(),e[0]&128&&(e=d.Buffer.concat([d.Buffer.from([0]),e]))),e.length===1&&e[0]===0&&(e=d.Buffer.from([])),e};qe.prototype.toSM=function(e){var t=e?e.endian:"big",r=this.toSMBigEndian();return t==="little"&&(r=Of(r)),r};function R_(e,t){var r=new Error(e);return r.scriptErr=t,r}qe.fromScriptNumBuffer=function(e,t,r){var n=r||4;if(e.length>n)throw R_("script number overflow","SCRIPT_ERR_SCRIPTNUM_OVERFLOW");if(t&&e.length>0&&(e[e.length-1]&127)===0&&(e.length<=1||(e[e.length-2]&128)===0))throw R_("non-minimally encoded script number","SCRIPT_ERR_SCRIPTNUM_MINENCODE");return qe.fromSM(e,{endian:"little"})};qe.prototype.toScriptNumBuffer=function(){return this.toSM({endian:"little"})};qe.trim=function(e,t){return e.slice(t-e.length,e.length)};qe.pad=function(e,t,r){for(var n=d.Buffer.alloc(r),i=0;i<e.length;i++)n[n.length-1-i]=e[e.length-1-i];for(i=0;i<r-t;i++)n[i]=0;return n};qe.prototype.toHex=function(...e){return this.toBuffer(...e).toString("hex")};qe.fromHex=function(e,...t){return qe.fromBuffer(d.Buffer.from(e,"hex"),...t)};B_.exports=qe});function LN(e,t=!1){return t?{h:Number(e&Rf),l:Number(e>>N_&Rf)}:{h:Number(e>>N_&Rf)|0,l:Number(e&Rf)|0}}function M_(e,t=!1){let r=e.length,n=new Uint32Array(r),i=new Uint32Array(r);for(let o=0;o<r;o++){let{h:s,l:a}=LN(e[o],t);[n[o],i[o]]=[s,a]}return[n,i]}function k_(e,t,r,n){let i=DN(r),o=UN(r);e.setUint32(t,n?o:i,n),e.setUint32(t+4,n?i:o,n)}function an(e,t,r,n){let i=(t>>>0)+(n>>>0);return{h:e+r+(i/2**32|0)|0,l:i|0}}var Rf,N_,DN,UN,gd,yd,Yi,$i,ua,fa,C_,L_,D_,U_,F_,q_,md=Xt(()=>{g();Rf=BigInt(4294967295),N_=BigInt(32);DN=e=>e/2**32|0,UN=e=>e>>>0;gd=(e,t,r)=>e>>>r,yd=(e,t,r)=>e<<32-r|t>>>r,Yi=(e,t,r)=>e>>>r|t<<32-r,$i=(e,t,r)=>e<<32-r|t>>>r,ua=(e,t,r)=>e<<64-r|t>>>r-32,fa=(e,t,r)=>e>>>r-32|t<<64-r;C_=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0),L_=(e,t,r,n)=>t+r+n+(e/2**32|0)|0,D_=(e,t,r,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0),U_=(e,t,r,n,i)=>t+r+n+i+(e/2**32|0)|0,F_=(e,t,r,n,i)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0)+(i>>>0),q_=(e,t,r,n,i,o)=>t+r+n+i+o+(e/2**32|0)|0});function Tf(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in e&&e.BYTES_PER_ELEMENT===1}function Rn(e,t=""){if(typeof e!="number")throw new TypeError(vd(t)+"expected number, got "+typeof e);if(!Number.isSafeInteger(e)||e<0)throw new RangeError(vd(t)+"expected integer >= 0, got "+e);return e}function un(e,t,r=""){if(Tf(e)&&(t===void 0||e.length===t))return e;t!==void 0&&Rn(t,"length");let n=Tf(e),i=t!==void 0?` of length ${t}`:"",o=n?`length=${e.length}`:`type=${typeof e}`,s=vd(r)+"expected Uint8Array"+i+", got "+o;throw n?new RangeError(s):new TypeError(s)}function Pf(e){if(typeof e!="function"||typeof e.create!="function")throw new TypeError("expected hash wrapped by utils.createHasher");if(Rn(e.outputLen),Rn(e.blockLen),e.outputLen<1||e.blockLen<1)throw new Error("hash blockLen / outputLen must be >= 1")}function Vo(e,t=!0){if(e.destroyed)throw new Error("hash was destroyed");if(t&&e.finished)throw new Error("digest() was already called")}function Bf(e,t){un(e,void 0,"output");let r=t.outputLen;if(!(e.length>=r))throw new RangeError('"output" expected length >= '+r)}function ir(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function Nf(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function Lr(e,t){return e<<32-t|e>>>t}function Tn(e,t){return e<<t|e>>>32-t>>>0}function Mf(e){if(un(e),K_)return e.toHex();let t="";for(let r=0;r<e.length;r++)t+=HN[e[r]];return t}function j_(e){return e>=48&&e<=57?e-48:e>=65&&e<=70?e-55:e>=97&&e<=102?e-87:void 0}function bd(e){if(typeof e!="string")throw new TypeError("hex string expected, got "+typeof e);if(K_)try{return Uint8Array.fromHex(e)}catch(i){throw i instanceof SyntaxError?new RangeError(i.message):i}let t=e.length,r=t/2;if(t%2)throw new RangeError("hex string expected, got unpadded hex of length "+t);let n=new Uint8Array(r);for(let i=0,o=0;i<r;i++,o+=2){let s=j_(e.charCodeAt(o)),a=j_(e.charCodeAt(o+1));if(s===void 0||a===void 0){let f=e[o]+e[o+1];throw new RangeError('hex string expected, got non-hex character "'+f+'" at index '+o)}n[i]=s*16+a}return n}function Pn(e){if(typeof e!="string")throw new TypeError("string expected");let t=new TextEncoder().encode(e);try{return new Uint8Array(t)}finally{ir(t)}}function G_(...e){let t=0;for(let n=0;n<e.length;n++){let i=e[n];un(i),t+=i.length}let r=new Uint8Array(t);for(let n=0,i=0;n<e.length;n++){let o=e[n];r.set(o,i),i+=o.length}return r}function jN(e,t,r="opts"){return H_(e,"defaults"),t!==void 0&&H_(t,r),Object.assign(Object.create(null),e,t)}function Dr(e,t={}){if(typeof e!="function")throw new TypeError('"hashCons" expected function, got type='+typeof e);t=jN({},t,"info");let r=(i,o)=>e(o).update(i).digest(),n=e(void 0);return r.outputLen=n.outputLen,r.blockLen=n.blockLen,r.canXOF=n.canXOF,r.create=i=>e(i),Object.assign(r,t),Object.freeze(r)}function ca(e=32){Rn(e,"bytesLength");let t=typeof globalThis=="object"?globalThis.crypto:null;if(typeof t?.getRandomValues!="function")throw new Error("crypto.getRandomValues must be defined");if(e>65536)throw new RangeError(`"bytesLength" expected <= 65536, got ${e}`);return t.getRandomValues(new Uint8Array(e))}var vd,qN,H_,K_,HN,Zi,Bn=Xt(()=>{g();vd=e=>e?`"${e}" `:"";qN=(e,t)=>{if(e===null||typeof e!="object"||Array.isArray(e))throw new TypeError((t==="object"?"":`"${t}" `)+"expected object, got type="+typeof e)},H_=(e,t)=>{qN(e,t);let r=Object.getPrototypeOf(e);if(r!==Object.prototype&&r!==null)throw new TypeError(`"${t}" expected plain object`);if(Object.hasOwn(e,"__proto__"))throw new TypeError(`"${t}.__proto__" is not allowed`)};K_=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",HN=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));Zi=e=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])})});function Wo(e,t,r){return e&t^~e&r}function kf(e,t,r){return e&t^e&r^t&r}var Nn,V_,W_,z_,Y_,_d=Xt(()=>{g();md();Bn();Nn=class{constructor(t,r,n,i){J(this,"blockLen");J(this,"outputLen");J(this,"canXOF",!1);J(this,"padOffset");J(this,"isLE");J(this,"buffer");J(this,"view");J(this,"finished",!1);J(this,"length",0);J(this,"pos",0);J(this,"destroyed",!1);this.blockLen=t,this.outputLen=r,this.padOffset=n,this.isLE=i,this.buffer=new Uint8Array(t),this.view=Nf(this.buffer)}update(t){Vo(this),un(t);let{view:r,buffer:n,blockLen:i}=this,o=t.length,s=!1;for(let a=0;a<o;){let f=Math.min(i-this.pos,o-a);if(f===i){let l=Nf(t);for(;i<=o-a;a+=i)this.process(l,a);s=!0;continue}n.set(a===0&&f===o?t:t.subarray(a,a+f),this.pos),this.pos+=f,a+=f,this.pos===i&&(this.process(r,0),this.pos=0,s=!0)}return this.length+=t.length,s&&this.roundClean(),this}digestInto(t){Vo(this),Bf(t,this),this.finished=!0;let{buffer:r,view:n,blockLen:i,isLE:o}=this,{pos:s}=this;r[s++]=128,r.fill(0,s),this.padOffset>i-s&&(this.process(n,0),r.fill(0)),k_(n,i-8,this.length*8,o),this.process(n,0),this.roundClean();let a=t===r?n:Nf(t),f=this.outputLen,l=f/4,m=this.get();if(f%4||l>m.length)throw new Error("invalid outputLen");for(let y=0;y<l;y++)a.setUint32(4*y,m[y],o)}digest(){let{buffer:t,outputLen:r}=this;this.digestInto(t);let n=t.slice(0,r);return this.destroy(),n}_cloneIntoMeta(t){let{buffer:r,length:n,finished:i,destroyed:o,pos:s}=this;return t.destroyed=o,t.finished=i,t.length=n,t.pos=s,s&&t.buffer.set(r),t}clone(){return this._cloneInto()}},V_=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),W_=Uint32Array.from([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]),z_=Uint32Array.from([3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]),Y_=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209])});var Z_={};pl(Z_,{_SHA224:()=>Df,_SHA256:()=>Lf,_SHA384:()=>Ff,_SHA512:()=>Uf,_SHA512_224:()=>qf,_SHA512_256:()=>Hf,sha224:()=>YN,sha256:()=>ui,sha384:()=>ZN,sha512:()=>$N,sha512_224:()=>JN,sha512_256:()=>XN});var KN,oi,Cf,Lf,Df,$_,GN,VN,si,ai,zo,Uf,Ff,WN,zN,qf,Hf,ui,YN,$N,ZN,XN,JN,Sd=Xt(()=>{g();_d();md();Bn();KN=Uint32Array.from([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]),oi=new Uint32Array(64),Cf=class extends Nn{constructor(r,n){super(64,r,8,!1);J(this,"A",0);J(this,"B",0);J(this,"C",0);J(this,"D",0);J(this,"E",0);J(this,"F",0);J(this,"G",0);J(this,"H",0);this.A=n[0]|0,this.B=n[1]|0,this.C=n[2]|0,this.D=n[3]|0,this.E=n[4]|0,this.F=n[5]|0,this.G=n[6]|0,this.H=n[7]|0}get(){let{A:r,B:n,C:i,D:o,E:s,F:a,G:f,H:l}=this;return[r,n,i,o,s,a,f,l]}set(r,n,i,o,s,a,f,l){this.A=r|0,this.B=n|0,this.C=i|0,this.D=o|0,this.E=s|0,this.F=a|0,this.G=f|0,this.H=l|0}_cloneInto(r){return(r||(r=new this.constructor)).set(...this.get()),this._cloneIntoMeta(r)}process(r,n){for(let p=0;p<16;p++,n+=4)oi[p]=r.getUint32(n,!1);for(let p=16;p<64;p++){let w=oi[p-15],O=oi[p-2],M=Lr(w,7)^Lr(w,18)^w>>>3,D=Lr(O,17)^Lr(O,19)^O>>>10;oi[p]=D+oi[p-7]+M+oi[p-16]|0}let{A:i,B:o,C:s,D:a,E:f,F:l,G:m,H:y}=this;for(let p=0;p<64;p++){let w=Lr(f,6)^Lr(f,11)^Lr(f,25),O=y+w+Wo(f,l,m)+KN[p]+oi[p]|0,D=(Lr(i,2)^Lr(i,13)^Lr(i,22))+kf(i,o,s)|0;y=m,m=l,l=f,f=a+O|0,a=s,s=o,o=i,i=O+D|0}i=i+this.A|0,o=o+this.B|0,s=s+this.C|0,a=a+this.D|0,f=f+this.E|0,l=l+this.F|0,m=m+this.G|0,y=y+this.H|0,this.set(i,o,s,a,f,l,m,y)}roundClean(){ir(oi)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0,0,0,0),ir(this.buffer)}},Lf=class extends Cf{constructor(){super(32,V_)}},Df=class extends Cf{constructor(){super(28,W_)}},$_=M_(["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(e=>BigInt(e))),GN=$_[0],VN=$_[1],si=new Uint32Array(80),ai=new Uint32Array(80),zo=class extends Nn{constructor(r,n){super(128,r,16,!1);J(this,"Ah",0);J(this,"Al",0);J(this,"Bh",0);J(this,"Bl",0);J(this,"Ch",0);J(this,"Cl",0);J(this,"Dh",0);J(this,"Dl",0);J(this,"Eh",0);J(this,"El",0);J(this,"Fh",0);J(this,"Fl",0);J(this,"Gh",0);J(this,"Gl",0);J(this,"Hh",0);J(this,"Hl",0);this.Ah=n[0]|0,this.Al=n[1]|0,this.Bh=n[2]|0,this.Bl=n[3]|0,this.Ch=n[4]|0,this.Cl=n[5]|0,this.Dh=n[6]|0,this.Dl=n[7]|0,this.Eh=n[8]|0,this.El=n[9]|0,this.Fh=n[10]|0,this.Fl=n[11]|0,this.Gh=n[12]|0,this.Gl=n[13]|0,this.Hh=n[14]|0,this.Hl=n[15]|0}get(){let{Ah:r,Al:n,Bh:i,Bl:o,Ch:s,Cl:a,Dh:f,Dl:l,Eh:m,El:y,Fh:p,Fl:w,Gh:O,Gl:M,Hh:D,Hl:F}=this;return[r,n,i,o,s,a,f,l,m,y,p,w,O,M,D,F]}set(r,n,i,o,s,a,f,l,m,y,p,w,O,M,D,F){this.Ah=r|0,this.Al=n|0,this.Bh=i|0,this.Bl=o|0,this.Ch=s|0,this.Cl=a|0,this.Dh=f|0,this.Dl=l|0,this.Eh=m|0,this.El=y|0,this.Fh=p|0,this.Fl=w|0,this.Gh=O|0,this.Gl=M|0,this.Hh=D|0,this.Hl=F|0}_cloneInto(r){return(r||(r=new this.constructor)).set(...this.get()),this._cloneIntoMeta(r)}process(r,n){for(let Q=0;Q<16;Q++,n+=4)si[Q]=r.getUint32(n),ai[Q]=r.getUint32(n+=4);for(let Q=16;Q<80;Q++){let ce=si[Q-15]|0,ee=ai[Q-15]|0,de=Yi(ce,ee,1)^Yi(ce,ee,8)^gd(ce,ee,7),pe=$i(ce,ee,1)^$i(ce,ee,8)^yd(ce,ee,7),xe=si[Q-2]|0,I=ai[Q-2]|0,u=Yi(xe,I,19)^ua(xe,I,61)^gd(xe,I,6),h=$i(xe,I,19)^fa(xe,I,61)^yd(xe,I,6),v=D_(pe,h,ai[Q-7],ai[Q-16]),_=U_(v,de,u,si[Q-7],si[Q-16]);si[Q]=_|0,ai[Q]=v|0}let{Ah:i,Al:o,Bh:s,Bl:a,Ch:f,Cl:l,Dh:m,Dl:y,Eh:p,El:w,Fh:O,Fl:M,Gh:D,Gl:F,Hh:V,Hl:Y}=this;for(let Q=0;Q<80;Q++){let ce=Yi(p,w,14)^Yi(p,w,18)^ua(p,w,41),ee=$i(p,w,14)^$i(p,w,18)^fa(p,w,41),de=p&O^~p&D,pe=w&M^~w&F,xe=F_(Y,ee,pe,VN[Q],ai[Q]),I=q_(xe,V,ce,de,GN[Q],si[Q]),u=xe|0,h=Yi(i,o,28)^ua(i,o,34)^ua(i,o,39),v=$i(i,o,28)^fa(i,o,34)^fa(i,o,39),_=i&s^i&f^s&f,S=o&a^o&l^a&l;V=D|0,Y=F|0,D=O|0,F=M|0,O=p|0,M=w|0,{h:p,l:w}=an(m|0,y|0,I|0,u|0),m=f|0,y=l|0,f=s|0,l=a|0,s=i|0,a=o|0;let T=C_(u,v,S);i=L_(T,I,h,_),o=T|0}({h:i,l:o}=an(this.Ah|0,this.Al|0,i|0,o|0)),{h:s,l:a}=an(this.Bh|0,this.Bl|0,s|0,a|0),{h:f,l}=an(this.Ch|0,this.Cl|0,f|0,l|0),{h:m,l:y}=an(this.Dh|0,this.Dl|0,m|0,y|0),{h:p,l:w}=an(this.Eh|0,this.El|0,p|0,w|0),{h:O,l:M}=an(this.Fh|0,this.Fl|0,O|0,M|0),{h:D,l:F}=an(this.Gh|0,this.Gl|0,D|0,F|0),{h:V,l:Y}=an(this.Hh|0,this.Hl|0,V|0,Y|0),this.set(i,o,s,a,f,l,m,y,p,w,O,M,D,F,V,Y)}roundClean(){ir(si,ai)}destroy(){this.destroyed=!0,ir(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}},Uf=class extends zo{constructor(){super(64,Y_)}},Ff=class extends zo{constructor(){super(48,z_)}},WN=Uint32Array.from([2352822216,424955298,1944164710,2312950998,502970286,855612546,1738396948,1479516111,258812777,2077511080,2011393907,79989058,1067287976,1780299464,286451373,2446758561]),zN=Uint32Array.from([573645204,4230739756,2673172387,3360449730,596883563,1867755857,2520282905,1497426621,2519219938,2827943907,3193839141,1401305490,721525244,746961066,246885852,2177182882]),qf=class extends zo{constructor(){super(28,WN)}},Hf=class extends zo{constructor(){super(32,zN)}},ui=Dr(()=>new Lf,Zi(1)),YN=Dr(()=>new Df,Zi(4)),$N=Dr(()=>new Uf,Zi(3)),ZN=Dr(()=>new Ff,Zi(2)),XN=Dr(()=>new Hf,Zi(6)),JN=Dr(()=>new qf,Zi(5))});function mt(e,t,r=()=>{}){if(!Array.isArray(e))throw new TypeError(`"${t}" expected array, got type=${typeof e}`);for(let n=0;n<e.length;n++)r(e[n],`${t}[${n}]`);return e}function la(e,t=""){if(typeof e!="string"){let r=t&&`"${t}" `;throw new TypeError(r+"expected string, got type="+typeof e)}return e}function fi(e,t="object"){if(e===null||typeof e!="object"||Array.isArray(e))throw new TypeError(t==="object"?"expected valid options object":`"${t}" expected object, got type=${typeof e}`);return e}function Xi(e,t){if(typeof e!="function")throw new TypeError(`"${t}" is invalid: expected function, got ${typeof e}`);return e}function cn(e,t=""){if(typeof e!="boolean")throw new TypeError(QN(t)+"expected boolean, got type="+typeof e);return e}function Kf(e){if(typeof e=="bigint"){if(!ci(e))throw new RangeError("positive bigint expected, got "+e)}else wd(e);return e}function pt(e,t=""){if(typeof e!="number"){let r=t&&`"${t}" `;throw new TypeError(r+"expected number, got type="+typeof e)}if(!Number.isSafeInteger(e)){let r=t&&`"${t}" `;throw new RangeError(r+"expected safe integer, got "+e)}}function ha(e){let t=Kf(e).toString(16);return t.length&1?"0"+t:t}function J_(e){if(typeof e!="string")throw new TypeError("hex string expected, got "+typeof e);return e===""?jf:BigInt("0x"+e)}function Dt(e){return J_(Mf(e))}function $o(e){return J_(Mf(kn(un(e)).reverse()))}function Gf(e,t){if(Rn(t),t===0)throw new Error("zero output length is invalid");e=Kf(e);let r=t*2,n=e.toString(16);if(n.length>r)throw new RangeError("number is too large");return bd(n.padStart(r,"0"))}function Ed(e,t){return Gf(e,t).reverse()}function xd(e,t){if(e=we(e),t=we(t),e.length!==t.length)return!1;let r=0;for(let n=0;n<e.length;n++)r|=e[n]^t[n];return r===0}function kn(e){return Uint8Array.from(we(e))}function Zo(e){if(typeof e!="string")throw new TypeError("ascii string expected, got "+typeof e);return Uint8Array.from(e,(t,r)=>{let n=t.charCodeAt(0);if(t.length!==1||n>127)throw new RangeError(`string contains non-ASCII character "${e[r]}" with code ${n} at position ${r}`);return n})}function ci(e){return typeof e=="bigint"&&jf<=e}function Id(e,t,r){return ci(e)&&ci(t)&&ci(r)&&t<=e&&e<r}function Ad(e,t,r,n){if(!Id(t,r,n))throw new RangeError("expected valid "+e+": "+r+" <= n < "+n+", got "+t)}function Xo(e){if(e<jf)throw new Error("expected non-negative bigint, got "+e);return e===jf?0:e.toString(2).length}function Q_(e,t,r){if(Rn(e,"hashLen"),Rn(t,"qByteLen"),typeof r!="function")throw new TypeError("hmacFn must be a function");let n=D=>new Uint8Array(D),i=Uint8Array.of(),o=Uint8Array.of(0),s=Uint8Array.of(1),a=1e3,f=n(e),l=n(e),m=0,y=()=>{f.fill(1),l.fill(0),m=0},p=(...D)=>r(l,Ke(f,...D)),w=(D=i)=>{l=p(o,D),f=p(),D.length!==0&&(l=p(s,D),f=p())},O=()=>{if(m++>=a)throw new Error("drbg: tried max amount of iterations");let D=0,F=[];for(;D<t;){f=p();let V=f.slice();F.push(V),D+=f.length}return Ke(...F)};return(D,F)=>{y(),w(D);let V;for(;(V=F(O()))===void 0;)w();return y(),V}}function $e(e,t={},r={},n="object"){fi(e,n),fi(t,"fields"),fi(r,"optFields");function i(s,a,f){let l=n==="object"?`param "${String(s)}"`:`"${n}.${String(s)}"`,m=e[s];if(!Object.hasOwn(e,s)&&(f?m!==void 0:a!=="function"))throw new TypeError(`${l} is invalid: expected own property`);if(f&&m===void 0)return;let y=typeof m;if(y!==a||m===null)throw new TypeError(`${l} is invalid: expected ${a}, got ${y}`)}let o=(s,a)=>Object.entries(s).forEach(([f,l])=>i(f,l,a));o(t,!1),o(r,!0)}var we,wd,Mn,Ke,Yo,fn,or,jf,X_,QN,da,li=Xt(()=>{g();Bn();we=(e,t,r)=>un(e,t,r),wd=Rn;Mn=Mf,Ke=(...e)=>G_(...e),Yo=e=>bd(e),fn=Tf,or=e=>ca(e),jf=BigInt(0),X_=BigInt(1),QN=e=>e?`"${e}" `:"";da=e=>(pt(e,"n"),(X_<<BigInt(e))-X_)});function sr(e,t){if(t<=Ut)throw new Error("mod: expected positive modulus, got "+t);let r=e%t;return r>=Ut?r:t+r}function sS(e,t,r){if(r<=Ze)throw new Error("pow: expected modulus > 1, got "+r);if(typeof t!="bigint")throw new TypeError("invalid exponent: expected bigint, got "+typeof t);if(t<Ut)throw new Error("invalid exponent, negatives unsupported");if(t===Ut)return Ze;if(t===Ze)return e;let n=e%r;if(n<Ut&&(n+=r),t<nM){let a=Ze;for(;t>Ut;)t&Ze&&(a=a*n%r),n=n*n%r,t>>=Ze;return a}let i=[];for(;t>Ut;)i.push(Number(t&rM)),t>>=Rd;let o=new Array(16);o[0]=Ze,o[1]=n;for(let a=2;a<16;a++)o[a]=o[a-1]*n%r;let s=o[i[i.length-1]];for(let a=i.length-2;a>=0;a--){s=s*s%r,s=s*s%r,s=s*s%r,s=s*s%r;let f=i[a];f!==0&&(s=s*o[f]%r)}return s}function mr(e,t,r){if(r<=Ze)throw new Error("pow2: expected modulus > 1, got "+r);if(t<Ut)throw new Error("pow2: expected non-negative exponent, got "+t);let n=e;for(;t-- >Ut;)n*=n,n%=r;return n}function eS(e,t){if(e===Ut)throw new Error("invert: expected non-zero number");if(t<=Ze)throw new Error("invert: expected modulus > 1, got "+t);let r=sr(e,t),n=t,i=Ut,o=Ze;for(;r!==Ut;){let a=n/r,f=n-r*a,l=i-o*a;n=r,r=f,i=o,o=l}if(n!==Ze)throw new Error("invert: does not exist");return sr(i,t)}function aS(e,t){if(t<=Ze)throw new Error("invertCt: expected prime modulus > 1, got "+t);let r=sr(e,t);if(r===Ut)throw new Error("invertCt: expected non-zero number");let n=sS(r,t-hi,t);if(sr(r*n,t)!==Ze)throw new Error("invertCt: does not exist");return n}function Td(e,t,r){let n=e;if(!n.eql(n.sqr(t),r))throw new Error("Cannot find square root")}function Pd(e,t){if((e&Ze)===Ut)throw new Error(t+": expected odd modulus, got "+e)}function uS(e,t){let r=e,n=(r.ORDER+Ze)/Rd,i=r.pow(t,n);return Td(r,i,t),i}function iM(e,t){let r=e,n=(r.ORDER-nS)/iS,i=r.mul(t,hi),o=r.pow(i,n),s=r.mul(t,o),a=r.mul(r.mul(s,hi),o),f=r.mul(s,r.sub(a,r.ONE));return Td(r,f,t),f}function oM(e){let t=Qo(e),r=fS(e),n=r(t,t.neg(t.ONE)),i=r(t,n),o=r(t,t.neg(n)),s=(e+eM)/oS;return((a,f)=>{let l=a,m=l.pow(f,s),y=l.mul(m,n),p=l.mul(m,i),w=l.mul(m,o),O=l.eql(l.sqr(y),f),M=l.eql(l.sqr(p),f);m=l.cmov(m,y,O),y=l.cmov(w,p,M);let D=l.eql(l.sqr(y),f),F=l.cmov(m,y,D);return Td(l,F,f),F})}function fS(e){if(e<rS)throw new Error("sqrt is not defined for small field");Pd(e,"tonelliShanks");let t=e-Ze,r=0;for(;t%hi===Ut;)t/=hi,r++;let n=hi,i=Qo(e);for(;Od(i,n)===1;)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(r===1)return uS;let o=i.pow(n,t),s=(t+Ze)/hi;return function(f,l){let m=f;if(m.is0(l))return l;if(Od(m,l)!==1)throw new Error("Cannot find square root");let y=r,p=m.mul(m.ONE,o),w=m.pow(l,t),O=m.pow(l,s);for(;!m.eql(w,m.ONE);){if(m.is0(w))throw new Error("Cannot find square root: probably non-prime P");let M=1,D=m.sqr(w);for(;!m.eql(D,m.ONE);)if(M++,D=m.sqr(D),M===y)throw new Error("Cannot find square root");let F=Ze<<BigInt(y-M-1),V=m.pow(p,F);y=M,p=m.sqr(V),w=m.mul(w,p),O=m.mul(O,V)}return O}}function sM(e){return Pd(e,"Fp.sqrt"),e%Rd===rS?uS:e%iS===nS?iM:e%oS===tM?oM(e):fS(e)}function Or(e){if(fi(e,"field"),typeof e.ORDER!="bigint")throw new TypeError('param "ORDER" is invalid: expected bigint, got '+typeof e.ORDER);pt(e.BYTES,"BYTES"),pt(e.BITS,"BITS");for(let t of aM)Xi(e[t],"field."+t);if(e.BYTES<1||e.BITS<1)throw new Error("invalid field: expected BYTES/BITS > 0");if(e.ORDER<=Ze)throw new Error("invalid field: expected ORDER > 1, got "+e.ORDER);return e}function Jo(e,t,r=!1){Or(e),mt(t,"nums"),cn(r,"passZero");let n=e,i=new Array(t.length).fill(r?n.ZERO:void 0),o=t.reduce((a,f,l)=>n.is0(f)?a:(i[l]=a,n.mul(a,f)),n.ONE),s=n.inv(o);return t.reduceRight((a,f,l)=>n.is0(f)?a:(i[l]=n.mul(a,i[l]),n.mul(a,f)),s),i}function Od(e,t){Or(e);let r=e;Pd(r.ORDER,"FpLegendre");let n=(r.ORDER-Ze)/hi,i=r.pow(t,n),o=r.eql(i,r.ONE),s=r.eql(i,r.ZERO),a=r.eql(i,r.neg(r.ONE));if(!o&&!s&&!a)throw new Error("invalid Legendre symbol result");return o?1:s?0:-1}function Bd(e,t){return Od(e,t)!==-1}function uM(e,t){if(t!==void 0&&wd(t),e<=Ut)throw new Error("invalid n length: expected positive n, got "+e);if(t!==void 0&&t<1)throw new Error("invalid n length: expected positive bit length, got "+t);let r=Xo(e);if(t!==void 0&&t<r)throw new Error(`invalid n length: expected nBitLength (${t}) >= bitLen(n) (${r})`);let n=t!==void 0?t:r,i=Math.ceil(n/8);return{nBitLength:n,nByteLength:i}}function Qo(e,t={}){return Object.freeze(Vf.prototype),new Vf(e,t)}function cS(e){if(typeof e!="bigint")throw new Error("field order must be bigint");if(e<=Ze)throw new Error("field order must be greater than 1");let t=Xo(e-Ze);return Math.ceil(t/8)}function es(e){let t=cS(e);return t+Math.ceil(t/2)}function Ji(e,t,r=!1){we(e);let n=e.length,i=cS(t),o=Math.max(es(t),16);if(n<o||n>1024)throw new Error("expected "+o+"-1024 bytes of input, got "+n);let s=r?$o(e):Dt(e),a=sr(s,t-Ze)+Ze;return r?Ed(a,i):Gf(a,i)}var Ut,Ze,hi,rS,Rd,nS,eM,iS,tM,rM,oS,nM,aM,tS,Vf,Qi=Xt(()=>{g();li();Ut=BigInt(0),Ze=BigInt(1),hi=BigInt(2),rS=BigInt(3),Rd=BigInt(4),nS=BigInt(5),eM=BigInt(7),iS=BigInt(8),tM=BigInt(9),rM=BigInt(15),oS=BigInt(16),nM=BigInt("0x10000000000000000");aM=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];tS=new WeakMap,Vf=class{constructor(t,r={}){J(this,"ORDER");J(this,"BITS");J(this,"BYTES");J(this,"isLE");J(this,"ZERO",Ut);J(this,"ONE",Ze);J(this,"_lengths");J(this,"_mod");if(t<=Ze)throw new Error("invalid field: expected ORDER > 1, got "+t);let n;this.isLE=!1,r!=null&&typeof r=="object"&&(typeof r.BITS=="number"&&(n=r.BITS),typeof r.sqrt=="function"&&Object.defineProperty(this,"sqrt",{value:r.sqrt,enumerable:!0}),typeof r.isLE=="boolean"&&(this.isLE=r.isLE),r.allowedLengths&&(this._lengths=Object.freeze(r.allowedLengths.slice())),typeof r.modFromBytes=="boolean"&&(this._mod=r.modFromBytes));let{nBitLength:i,nByteLength:o}=uM(t,n);if(o>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");this.ORDER=t,this.BITS=i,this.BYTES=o,Object.freeze(this)}create(t){return sr(t,this.ORDER)}isValid(t){if(typeof t!="bigint")throw new TypeError("invalid field element: expected bigint, got "+typeof t);return Ut<=t&&t<this.ORDER}is0(t){return t===Ut}isValidNot0(t){return!this.is0(t)&&this.isValid(t)}isOdd(t){return(t&Ze)===Ze}neg(t){return sr(-t,this.ORDER)}eql(t,r){return t===r}sqr(t){return sr(t*t,this.ORDER)}add(t,r){return sr(t+r,this.ORDER)}sub(t,r){return sr(t-r,this.ORDER)}mul(t,r){return sr(t*r,this.ORDER)}pow(t,r){return sS(t,r,this.ORDER)}div(t,r){return sr(t*eS(r,this.ORDER),this.ORDER)}sqrN(t){return t*t}addN(t,r){return t+r}subN(t,r){return t-r}mulN(t,r){return t*r}inv(t){return eS(t,this.ORDER)}sqrt(t){let r=tS.get(this);return r||tS.set(this,r=sM(this.ORDER)),r(this,t)}toBytes(t){return this.isLE?Ed(t,this.BYTES):Gf(t,this.BYTES)}fromBytes(t,r=!1){we(t);let{_lengths:n,BYTES:i,isLE:o,ORDER:s,_mod:a}=this;if(n){if(t.length<1||!n.includes(t.length)||t.length>i)throw new Error("Field.fromBytes: expected "+n+" bytes, got "+t.length);let l=new Uint8Array(i);l.set(t,o?0:l.length-t.length),t=l}if(t.length!==i)throw new Error("Field.fromBytes: expected "+i+" bytes, got "+t.length);let f=o?$o(t):Dt(t);if(a&&(f=sr(f,s)),!r&&!this.isValid(f))throw new Error("invalid field element: outside of range 0..ORDER");return f}invertBatch(t){return Jo(this,t,!0)}cmov(t,r,n){return cn(n,"condition"),n?r:t}}});function di(e){let t=e;if(typeof t!="function")throw new TypeError('"Point" expected constructor, got type='+typeof e);Xi(t.fromAffine,"Point.fromAffine"),Xi(t.fromBytes,"Point.fromBytes"),Xi(t.fromHex,"Point.fromHex"),fi(t.BASE,"Point.BASE"),fi(t.ZERO,"Point.ZERO"),Or(t.Fp),Or(t.Fn)}function pS(e,t){di(e),gS(t,e);let r=Jo(e.Fp,t.map(n=>n.Z));return t.map((n,i)=>e.fromAffine(n.toAffine(r[i])))}function lM(e,t,r=1){if(!Number.isSafeInteger(e)||e<r||e>t)throw new Error("invalid window size, expected ["+r+".."+t+"], got W="+e)}function hM(e,t){let r=e*(4*t+128);if(r>hS)throw new Error("invalid window size: table would need ~"+Math.ceil(r/2**20)+" MiB, max "+hS/2**20+" MiB")}function Cd(e,t){if(e!==void 0){Xi(e,"randomBytes");try{let r=e(t);if(!fn(r)||r.length!==t)return}catch{return}return e}}function gS(e,t){mt(e,"points"),e.forEach((r,n)=>{if(!(r instanceof t))throw new Error("invalid point at index "+n)})}function dM(e,t,r){if(!Array.isArray(e))throw new Error("array of scalars expected");e.forEach((n,i)=>{if(!(r===void 0?t.isValid(n):ci(n)&&n<r))throw new Error("invalid scalar at index "+i)})}function Md(e){return yS.get(e)||1}function pM(e,t){let r=e.double(),n=[e];for(let i=1;i<t;i++)n.push(n[i-1].add(r));return n}function gM(e,t){let r=2**t,n=r/2,i=BigInt(r-1),o=[];for(;e>kd;){let s=0;e&pa&&(s=Number(e&i),s>=n&&(s-=r),e-=BigInt(s)),o.push(s),e>>=pa}return o}function yM(e,t,r){let n=2**t,i=n/2,o=BigInt(n-1),s=BigInt(t),a=[];for(let f=0;f<r;f++){let l=Number(e&o);e>>=s,l>i&&(l-=n,e+=pa),a.push(l)}if(e!==kd)throw new Error("invalid wnaf");return a}function mM(e,t,r){let n=0;for(let o of r)n=Math.max(n,o.length);let i=e;for(let o=n-1;o>=0;o--){o!==n-1&&(i=i.double());for(let s=0;s<r.length;s++){let a=r[s][o];if(a){let f=t[s][Math.abs(a)-1>>1];i=i.add(a<0?f.negate():f)}}}return i}function ts(e,t,r,n=!1){if(di(e),gS(t,e),cn(n,"allowOversized"),dM(r,e.Fn,n?e.Fn.ORDER**fM:void 0),t.length!==r.length)throw new Error("arrays of points and scalars must have equal length");let i=t.map(s=>pM(s,4)),o=r.map(s=>gM(s,4));return mM(e.ZERO,i,o)}function dS(e,t,r){if(t){if(t.ORDER!==e)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return Or(t),t}else return Qo(e,{isLE:r})}function mS(e,t,r={},n){if(e!=="weierstrass"&&e!=="edwards")throw new Error('expected curve type "weierstrass" or "edwards"');if(n===void 0&&(n=e==="edwards"),!t||typeof t!="object")throw new Error(`expected valid ${e} CURVE object`);$e(r);for(let f of["p","n","h"]){let l=t[f];if(!(ci(l)&&l!==kd))throw new Error(`CURVE.${f} must be positive bigint`)}let i=dS(t.p,r.Fp,n),o=dS(t.n,r.Fn,n),a=["Gx","Gy","a",e==="weierstrass"?"b":"d"];for(let f of a)if(!i.isValid(t[f]))throw new Error(`CURVE.${f} must be valid field element of CURVE.Fp`);return t=Object.freeze(Object.assign({},t)),{CURVE:t,Fp:i,Fn:o}}function zf(e,t){return function(n){let i=e(n);return{secretKey:i,publicKey:t(i)}}}var kd,pa,fM,Nd,lS,cM,hS,yS,Wf,Yf=Xt(()=>{g();li();Qi();kd=BigInt(0),pa=BigInt(1),fM=BigInt(4),Nd=16,lS=128,cM=5,hS=2**31;yS=new WeakMap;Wf=class{constructor(t,r){J(this,"Point");J(this,"BASE");J(this,"ZERO");J(this,"randomBytes");J(this,"wnafPrecomputes",new WeakMap);J(this,"baseCanBeBlinded");J(this,"bits");di(t),this.randomBytes=Cd(r,Nd),this.Point=t,this.BASE=t.BASE,this.ZERO=t.ZERO,this.bits=t.Fn.BITS}buildWnafTable(t,r,n){let i=Math.ceil(n/r)+1,o=2**(r-1),s=[],a=t;for(let f=0;f<i;f++){let l=a;for(let m=0;m<o;m++)s.push(l),l=l.add(a);a=s[s.length-1].double()}return{W:r,bits:n,windows:i,comp:s}}wnafCachedCT(t,r){let{W:n,windows:i,comp:o}=t,s=2**(n-1),a=yM(r,n,i),f=this.ZERO,l=this.BASE;for(let m=0;m<i;m++){let y=a[m],p=m*s,w=Math.abs(y)-1,O=o[p];for(let D=1;D<s;D++)O=D===w?o[p+D]:O;let M=O.negate();y===0?l=l.add(o[p]):f=f.add(y<0?M:O)}return{p:f,f:l}}getWnafPrecomputes(t,r,n,i){let o=this.wnafPrecomputes.get(r),s=o?.find(a=>a.W===t&&a.bits===n);return s||(s=this.buildWnafTable(r,t,n),typeof i=="function"&&(s={...s,comp:i(s.comp)}),o||(o=[],this.wnafPrecomputes.set(r,o)),o.push(s)),s}assertPoint(t){if(!(t instanceof this.Point))throw new TypeError('"point" expected Point instance, got type='+typeof t)}validateMulInput(t,r){if(this.assertPoint(t),!Id(r,pa,this.Point.Fn.ORDER))throw new Error("invalid scalar")}runCT(t,r,n,i){let o=Md(t);return o===1?this.fixedWindowCT(t,r,n):this.wnafCachedCT(this.getWnafPrecomputes(o,t,n,i),r)}mulCT(t,r,n){return this.validateMulInput(t,r),this.runCT(t,r,this.bits,n)}mulCTBlinded(t,r,n){if(this.validateMulInput(t,r),this.randomBytes===void 0)throw new Error("randomBytes is required for scalar blinding");let i=this.Point.Fn.BITS+lS,o=this.randomBytes(Nd);if(!fn(o)||o.length!==Nd)throw new Error("randomBytes returned invalid byte array");o[0]=o[0]&63|128;let s=r+Dt(o)*this.Point.Fn.ORDER;return this.runCT(t,s,i,n)}fixedWindowCT(t,r,n){let i=cM,o=1<<i,s=da(i),a=new Array(o);a[0]=this.ZERO;for(let m=1;m<o;m++)a[m]=a[m-1].add(t);let f=Math.ceil(n/i),l=this.ZERO;for(let m=f-1;m>=0;m--){if(m!==f-1)for(let w=0;w<i;w++)l=l.double();let y=Number(r>>BigInt(m*i)&s),p=a[0];for(let w=1;w<o;w++)p=w===y?a[w]:p;l=l.add(p)}return{p:l,f:l}}shouldBlind(t,r){return this.randomBytes===void 0?!1:r===pa?!0:t!==this.BASE?!1:(this.baseCanBeBlinded===void 0&&(this.baseCanBeBlinded=this.mulUnsafe(this.BASE,this.Point.Fn.ORDER).is0()),this.baseCanBeBlinded)}mulSecret(t,r,n,i){return this.shouldBlind(t,n)?this.mulCTBlinded(t,r,i):this.mulCT(t,r,i)}mulUnsafe(t,r,n){if(this.assertPoint(t),!ci(r))throw new Error("invalid scalar");let i=Md(t);if(i===1||r>=this.Point.Fn.ORDER)return ts(this.Point,[t],[r],!0);let o=this.getWnafPrecomputes(i,t,this.bits,n);return this.wnafCachedCT(o,r).p}setWindowSize(t,r){this.assertPoint(t),lM(r,this.bits);let n=Math.ceil((this.bits+lS)/r)+1;hM(n*2**(r-1),this.Point.Fp.BYTES),yS.set(t,r),this.wnafPrecomputes.delete(t)}hasWindowSize(t){return Md(t)!==1}}});function Ld(e,t="n"){if(typeof e!="number")throw new TypeError(`wrong u32 integer "${t}": expected number, got type=${typeof e}`);if(!Number.isSafeInteger(e)||e<0||e>4294967295)throw new RangeError(`wrong u32 integer "${t}": expected 0..4294967295, got ${e}`);return e}function vS(e){return Ld(e,"x"),(e&e-1)===0&&e!==0}function vM(e){if(Ld(e),e<=1)return 1;if(e>2147483648)throw new Error("nextPowerOfTwo overflow: result does not fit u32");return 1<<$f(e-1)+1>>>0}function $f(e){return Ld(e),31-Math.clz32(e)}function bS(e,t,r,n,i){Or(e);let o=e,s=r||((y,p)=>new Array(y).fill(p??o.ZERO)),a=y=>{if(Array.isArray(y))return!0;if(!ArrayBuffer.isView(y))return!1;let p=y;return typeof p.length=="number"&&typeof p.slice=="function"&&typeof p[Symbol.iterator]=="function"},f=(y,p)=>{if(!a(p))throw new TypeError(`"${y}" expected polynomial, got type=${typeof p}`)},l=(y,p)=>{f("a",y);let w=y.length;if(p!==void 0&&(f("b",p),p.length!==w))throw new Error(`poly: mismatched lengths ${w} vs ${p.length}`);if(i!==void 0&&w!==i)throw new Error(`poly: expected fixed length ${i}, got ${w}`);return w};function m(y,p,w=!1,O){if(!vS(p))throw new Error("poly.lagrange: expected power of two length, got "+p);let M=O||(w?t.brp($f(p)):t.roots($f(p)));for(let D=0;D<p;D++)if(o.eql(y,M[D]))return D;return-1}return{roots:t,create:s,length:i,extend:(y,p)=>{l(y);let w=s(p,o.ZERO);for(let O=0;O<Math.min(y.length,p);O++)w[O]=y[O];return w},degree:y=>{l(y);for(let p=y.length-1;p>=0;p--)if(!o.is0(y[p]))return p;return-1},add:(y,p)=>{let w=l(y,p),O=s(w);for(let M=0;M<w;M++)O[M]=o.add(y[M],p[M]);return O},sub:(y,p)=>{let w=l(y,p),O=s(w);for(let M=0;M<w;M++)O[M]=o.sub(y[M],p[M]);return O},dot:(y,p)=>{let w=l(y,p),O=s(w);for(let M=0;M<w;M++)O[M]=o.mul(y[M],p[M]);return O},mul:(y,p)=>{if(a(p)){let w=l(y,p);if(n){let O=n.direct(y,!1,!0),M=n.direct(p,!1,!0);for(let D=0;D<O.length;D++)O[D]=o.mul(O[D],M[D]);return n.inverse(O,!0,!1)}else{let O=s(w);for(let M=0;M<w;M++)for(let D=0;D<w;D++){let F=(M+D)%w;O[F]=o.add(O[F],o.mul(y[M],p[D]))}return O}}else{let w=s(l(y));for(let O=0;O<w.length;O++)w[O]=o.mul(y[O],p);return w}},convolve(y,p){f("a",y),f("b",p);let w=vM(y.length+p.length-1);return this.mul(this.extend(y,w),this.extend(p,w))},shift(y,p){f("p",y);let w=s(y.length);if(i!==void 0&&y.length!==i)throw new Error(`poly: expected fixed length ${i}, got ${y.length}`);if(!y.length)return w;w[0]=y[0];for(let O=1,M=o.ONE;O<y.length;O++)M=o.mul(M,p),w[O]=o.mul(y[O],M);return w},clone:y=>{l(y);let p=s(y.length);for(let w=0;w<y.length;w++)p[w]=y[w];return p},eval:(y,p)=>{l(y,p);let w=o.ZERO;for(let O=0;O<y.length;O++)w=o.add(w,o.mul(y[O],p[O]));return w},monomial:{basis:(y,p)=>{let w=s(p),O=o.ONE;for(let M=0;M<p;M++)w[M]=O,O=o.mul(O,y);return w},eval:(y,p)=>{l(y);let w=o.ZERO;for(let O=y.length-1;O>=0;O--)w=o.add(o.mul(w,p),y[O]);return w}},lagrange:{basis:(y,p,w=!1,O)=>{if(!vS(p))throw new Error("poly.lagrange: expected power of two length, got "+p);let M=$f(p),D=O||(w?t.brp(M):t.roots(M)),F=s(p),V=m(y,p,w,O);if(V!==-1)return F[V]=o.ONE,F;let Y=o.pow(y,BigInt(p)),Q=o.mul(o.sub(Y,o.ONE),o.inv(BigInt(p))),ce=s(p);for(let de=0;de<p;de++)ce[de]=o.sub(y,D[de]);let ee=o.invertBatch(ce);for(let de=0;de<p;de++)F[de]=o.mul(Q,o.mul(D[de],ee[de]));return F},eval(y,p,w=!1){l(y);let O=m(p,y.length,w);if(O!==-1)return y[O];let M=this.basis(p,y.length,w),D=o.ZERO;for(let F=0;F<y.length;F++)o.is0(y[F])||(D=o.add(D,o.mul(y[F],M[F])));return D}},vanishing(y){if(f("roots",y),i!==void 0&&y.length!==i)throw new Error(`poly: expected fixed length ${i}, got ${y.length}`);let p=s(y.length+1,o.ZERO);p[0]=o.ONE;for(let w of y){let O=o.neg(w);for(let M=p.length-1;M>0;M--)p[M]=o.add(o.mul(p[M],O),p[M-1]);p[0]=o.mul(p[0],O)}return p}}}var _S=Xt(()=>{g();Qi()});function eo(e,t){if(pt(e),pt(t),t<0||t>4)throw new Error("invalid I2OSP length: "+t);if(e<0||e>2**(8*t)-1)throw new Error("invalid I2OSP input: "+e);let r=Array.from({length:t}).fill(0);for(let n=t-1;n>=0;n--)r[n]=e&255,e>>>=8;return new Uint8Array(r)}function _M(e,t){let r=new Uint8Array(e.length);for(let n=0;n<e.length;n++)r[n]=e[n]^t[n];return r}function xS(e){if(!fn(e)&&typeof e!="string")throw new Error("DST must be Uint8Array or ascii string");let t=typeof e=="string"?Zo(e):e;if(t.length===0)throw new Error("DST must be non-empty");return t}function SM(e,t,r,n){if(we(e),pt(r),typeof n!="function")throw new Error("expand_message_xmd: expected hash function");pt(n.outputLen,"hash.outputLen"),pt(n.blockLen,"hash.blockLen"),t=xS(t),t.length>255&&(t=n(Ke(Zo("H2C-OVERSIZE-DST-"),t)));let{outputLen:i,blockLen:o}=n,s=Math.ceil(r/i);if(r>65535||s>255)throw new Error("expand_message_xmd: invalid lenInBytes");let a=Ke(t,eo(t.length,1)),f=new Uint8Array(o),l=eo(r,2),m=new Array(s),y=n(Ke(f,e,l,eo(0,1),a));m[0]=n(Ke(y,eo(1,1),a));for(let w=1;w<s;w++){let O=[_M(y,m[w-1]),eo(w+1,1),a];m[w]=n(Ke(...O))}return Ke(...m).slice(0,r)}function wM(e,t,r,n,i){if(we(e),pt(r),pt(n,"k"),n<0)throw new Error("expand_message_xof: invalid k");if(typeof i!="function")throw new Error("expand_message_xof: expected XOF function");if(typeof i.create!="function")throw new Error("expand_message_xof: expected XOF create");if(t=xS(t),r<0||r>65535)throw new Error("expand_message_xof: invalid lenInBytes");if(t.length>255){let o=Math.ceil(2*n/8);t=i.create({dkLen:o}).update(Zo("H2C-OVERSIZE-DST-")).update(t).digest()}if(t.length>255)throw new Error("expand_message_xof: invalid DST");return i.create({dkLen:r}).update(e).update(eo(r,2)).update(t).update(eo(t.length,1)).digest()}function Dd(e,t,r){$e(r,{p:"bigint",m:"number",k:"number",hash:"function"});let{p:n,k:i,m:o,hash:s,expand:a,DST:f}=r;if(pt(s.outputLen,"valid hash"),we(e),pt(t),pt(o,"m"),pt(i,"k"),n<=BigInt(1))throw new Error("hash_to_field: expected valid field characteristic");if(t<1)throw new Error("hash_to_field: expected count >= 1");if(o<1)throw new Error("hash_to_field: expected m >= 1");if(i<0)throw new Error("hash_to_field: invalid k");let l=n.toString(2).length,m=Math.ceil((l+i)/8),y=t*o*m,p;if(a==="xmd")p=SM(e,f,y,s);else if(a==="xof")p=wM(e,f,y,i,s);else if(a==="_internal_pass")p=e;else throw new Error('expand must be "xmd" or "xof"');let w=new Array(t);for(let O=0;O<t;O++){let M=new Array(o);for(let D=0;D<o;D++){let F=m*(D+O*o),V=p.subarray(F,F+m);M[D]=sr(bM(V),n)}w[O]=M}return w}function IS(e,t){Or(e),mt(t,"map");let r=t.map((n,i)=>{if(mt(n,"map["+i+"]"),n.length<1)throw new Error("isogenyMap: expected non-empty coefficients");return Array.from(n).reverse()});return(n,i)=>{let[o,s,a,f]=r.map(p=>p.reduce((w,O)=>e.add(e.mul(w,n),O))),l=e.is0(s)||e.is0(f),[m,y]=Jo(e,[s,f],!0);return n=e.mul(o,m),i=e.mul(i,e.mul(a,y)),l?{x:e.ZERO,y:e.ZERO}:{x:n,y:i}}}function AS(e,t,r){if(typeof t!="function")throw new Error("mapToCurve() must be defined");$e(r);let n=f=>Object.freeze({...f,DST:fn(f.DST)?kn(f.DST):f.DST,...f.encodeDST===void 0?{}:{encodeDST:fn(f.encodeDST)?kn(f.encodeDST):f.encodeDST}}),i=n(r),o=f=>f&&f.DST!==void 0?{DST:f.DST}:void 0;function s(f){return e.fromAffine(t(f))}function a(f){let l=f.clearCofactor();return l.equals(e.ZERO)?e.ZERO:(l.assertValidity(),l)}return Object.freeze({get defaults(){return n(i)},Point:e,hashToCurve(f,l){let m=Object.assign({},i,o(l)),y=Dd(f,2,m),p=s(y[0]),w=s(y[1]);return a(p.add(w))},encodeToCurve(f,l){let m=i.encodeDST===void 0?{}:{DST:i.encodeDST},y=Object.assign({},i,m,o(l)),p=Dd(f,1,y),w=s(p[0]);return a(w)},mapToCurve(f){if(i.m===1){if(typeof f!="bigint")throw new Error("expected bigint (m=1)");return a(s([f]))}if(!Array.isArray(f))throw new Error("expected array of bigints");if(f.length!==i.m)throw new Error(`expected array of ${i.m} bigints`);for(let l of f)if(typeof l!="bigint")throw new Error("expected array of bigints");return a(s(f))},hashToScalar(f,l){let m=e.Fn.ORDER,y=Object.assign({},i,{DST:EM},o(l),{p:m,m:1});return Dd(f,1,y)[0][0]}})}function xM(e,t){let r=Or(e),n=r.ORDER,i=SS;for(let M=n-ln;M%pi===SS;M/=pi)i+=ln;let o=i,s=pi<<o-ln-ln,a=s*pi,f=(n-ln)/a,l=(f-ln)/pi,m=a-ln,y=s,p=r.pow(t,f),w=r.pow(t,(f+ln)/pi),O=(M,D)=>{let F=p,V=r.pow(D,m),Y=r.sqr(V);Y=r.mul(Y,D);let Q=r.mul(M,Y);Q=r.pow(Q,l),Q=r.mul(Q,V),V=r.mul(Q,D),Y=r.mul(Q,M);let ce=r.mul(Y,V);Q=r.pow(ce,y);let ee=r.eql(Q,r.ONE);V=r.mul(Y,w),Q=r.mul(ce,F),Y=r.cmov(V,Y,ee),ce=r.cmov(Q,ce,ee);for(let de=o;de>ln;de--){let pe=de-pi;pe=pi<<pe-ln;let xe=r.pow(ce,pe),I=r.eql(xe,r.ONE);V=r.mul(Y,F),F=r.mul(F,F),xe=r.mul(ce,F),Y=r.cmov(V,Y,I),ce=r.cmov(xe,ce,I)}return{isValid:!r.is0(D)&&(ee||r.is0(M)),value:Y}};if(r.ORDER%ES===wS){let M=(r.ORDER-wS)/ES,D=r.sqrt(r.neg(t));O=(F,V)=>{let Y=r.sqr(V),Q=r.mul(F,V);Y=r.mul(Y,Q);let ce=r.pow(Y,M);ce=r.mul(ce,Q);let ee=r.mul(ce,D),de=r.mul(r.sqr(ce),V),pe=r.eql(de,F),xe=r.cmov(ee,ce,pe);return{isValid:!r.is0(V)&&pe,value:xe}}}return O}function OS(e,t){let r=Or(e);$e(t,{},{},"opts");let{A:n,B:i,Z:o}=t;if(!r.isValidNot0(n)||!r.isValidNot0(i)||!r.isValid(o))throw new Error("mapToCurveSimpleSWU: invalid opts");if(r.eql(o,r.neg(r.ONE))||Bd(r,o))throw new Error("mapToCurveSimpleSWU: invalid opts");let s=r.mul(i,r.inv(r.mul(o,n))),a=r.add(r.add(r.mul(r.sqr(s),s),r.mul(n,s)),i);if(!Bd(r,a))throw new Error("mapToCurveSimpleSWU: invalid opts");let f=xM(r,o);if(!r.isOdd)throw new Error("Field does not have .isOdd()");return l=>{let m,y,p,w,O,M,D,F;m=r.sqr(l),m=r.mul(m,o),y=r.sqr(m),y=r.add(y,m),p=r.add(y,r.ONE),p=r.mul(p,i),w=r.cmov(o,r.neg(y),!r.eql(y,r.ZERO)),w=r.mul(w,n),y=r.sqr(p),M=r.sqr(w),O=r.mul(M,n),y=r.add(y,O),y=r.mul(y,p),M=r.mul(M,w),O=r.mul(M,i),y=r.add(y,O),D=r.mul(m,p);let{isValid:V,value:Y}=f(y,M);F=r.mul(m,l),F=r.mul(F,Y),D=r.cmov(D,p,V),F=r.cmov(F,Y,V);let Q=r.isOdd(l)===r.isOdd(F);F=r.cmov(r.neg(F),F,Q);let ce=Jo(r,[w],!0)[0];return D=r.mul(D,ce),{x:D,y:F}}}var SS,ln,pi,wS,ES,bM,EM,RS=Xt(()=>{g();li();Qi();SS=BigInt(0),ln=BigInt(1),pi=BigInt(2),wS=BigInt(3),ES=BigInt(4),bM=Dt;EM="HashToScalar-"});function Ud(e){$e(e,{name:"string",hash:"function"},{hashToScalar:"function",validatePoint:"function",parsePublicKey:"function",adjustScalar:"function",adjustPoint:"function",challenge:"function",adjustNonces:"function",adjustSecret:"function",adjustPublic:"function",adjustGroupCommitmentShare:"function",adjustTx:"object",adjustDKG:"function"}),di(e.Point);let{Point:t,validatePoint:r,parsePublicKey:n,adjustScalar:i,adjustPoint:o,challenge:s,adjustNonces:a,adjustSecret:f,adjustPublic:l,adjustGroupCommitmentShare:m,adjustDKG:y}=e,p=e.Fn===void 0?t.Fn:e.Fn,w=e.adjustTx===void 0?void 0:{encode:e.adjustTx.encode,decode:e.adjustTx.decode};w&&$e(w,{encode:"function",decode:"function"});let O=e.hash,M=e.hashToScalar===void 0?(A,U={DST:new Uint8Array})=>{let H=O(Ke(U.DST,A));return p.create(p.isLE?$o(H):Dt(H))}:e.hashToScalar,D=Pn(e.H1!==void 0?e.H1:e.name+"rho"),F=Pn(e.H2!==void 0?e.H2:e.name+"chal"),V=Pn(e.H3!==void 0?e.H3:e.name+"nonce"),Y=Pn(e.H4!==void 0?e.H4:e.name+"msg"),Q=Pn(e.H5!==void 0?e.H5:e.name+"com"),ce=Pn(e.HDKG!==void 0?e.HDKG:e.name+"dkg"),ee=Pn(e.HID!==void 0?e.HID:e.name+"id"),de=A=>M(A,{DST:D}),pe=A=>M(A,{DST:F}),xe=A=>M(A,{DST:V}),I=A=>O(Ke(Y,A)),u=A=>O(Ke(Q,A)),h=A=>M(A,{DST:ce}),v=A=>M(A,{DST:ee}),_=(A=or)=>{if(typeof A!="function")throw new TypeError('"rng" expected function, got type='+typeof A);let U=Ji(A(es(p.ORDER)),p.ORDER,p.isLE);return p.isLE?$o(U):Dt(U)},S=A=>A.toBytes(),T=A=>{if(A.assertValidity(),A.is0())throw new Error("invalid point: identity");if(!A.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return r&&r(A),A},P=A=>T(t.fromBytes(A)),E=(A,U)=>({identifier:A,hiding:S(t.BASE.multiply(p.fromBytes(U.hiding))),binding:S(t.BASE.multiply(p.fromBytes(U.binding)))}),c=o===void 0?A=>A:o,b=A=>{if(!p.isValid(A)||p.is0(A))throw new Error("Invalid identifier "+A);return A},C=A=>Mn(p.toBytes(b(A))),N=(A,U="identifier")=>{la(A,U);let H=b(p.fromBytes(Yo(A)));if(C(H)!==A)throw new Error("expected canonical identifier hex");return H},L=A=>({identifier:C(N(A.identifier)),commitment:A.commitment.map(U=>kn(U)),proofOfKnowledge:kn(A.proofOfKnowledge)}),K=A=>{let U=A.map(L);return U.sort((H,G)=>{let ne=N(H.identifier),$=N(G.identifier);return ne<$?-1:ne>$?1:0}),U},z=(A,U)=>{if(A.length!==U.length)return!1;for(let H=0;H<A.length;H++){let G=A[H],ne=U[H];if(G.identifier!==ne.identifier||G.commitment.length!==ne.commitment.length)return!1;for(let $=0;$<G.commitment.length;$++)if(!xd(G.commitment[$],ne.commitment[$]))return!1;if(!xd(G.proofOfKnowledge,ne.proofOfKnowledge))return!1}return!0},W={encode:(A,U)=>{let H=Ke(S(A),p.toBytes(U));return w&&(H=w.encode(H)),H},decode:A=>{w&&(A=w.decode(A));let U=A.subarray(0,-p.BYTES),H=P(U);if(S(H).length!==U.length)throw new Error("invalid signature encoding");let G=p.fromBytes(A.subarray(-p.BYTES));return{R:H,z:G}}},te=(A=or)=>{let U=_(A);i&&(U=i(U));let H=t.BASE.multiply(U);return{scalar:U,point:H}},re="roots are unavailable in FROST polynomial mode",se={info:{G:p.ZERO,oddFactor:p.ZERO,powerOfTwo:0},roots(){throw new Error(re)},brp(){throw new Error(re)},inverse(){throw new Error(re)},omega(){throw new Error(re)},clear(){}},Ie=bS(p,se),ue=(A,U)=>ts(t,A,U),fe=(A,U)=>{if(!U.length)throw new Error("empty coefficients");return Ie.monomial.eval(U,A)},Oe=(A,U)=>{let H="invalid parameters";if(!A.some(oe=>p.eql(oe,U)))throw new Error(H);let G=new Set(A);if(G.size!==A.length)throw new Error(H);if(!G.has(U))throw new Error(H);let ne=p.ONE,$=p.ONE;for(let oe of A)p.eql(oe,U)||(ne=p.mul(ne,oe),$=p.mul($,p.sub(oe,U)));return p.div(ne,$)},ve=(A,U)=>{let H=Ie.monomial.basis(A,U.length);return ue(U,H)},Ee=(A,U,H,G=or)=>{if(hn(A),U!==void 0&&we(U,p.BYTES,"secret"),H!==void 0&&mt(H,"coeffs"),typeof G!="function")throw new TypeError('"rng" expected function, got type='+typeof G);let ne=U===void 0?_(G):p.fromBytes(U);if(!H){H=[];for(let ie=0;ie<A.min-1;ie++)H.push(_(G))}if(H.length!==A.min-1)throw new Error("wrong coefficients length");let $=[ne,...H],oe=$.map(ie=>t.BASE.multiply(ie));return{coefficients:$,commitment:oe,secret:ne}},ke={challenge:(A,U,H)=>h(Ke(p.toBytes(A),S(U),S(H))),compute(A,U,H,G=or){if(U.length<1)throw new Error("coefficients should have at least one element");let{point:ne,scalar:$}=te(G),oe=H[0],ie=this.challenge(A,oe,ne),be=p.add($,p.mul(U[0],ie));return W.encode(ne,be)},validate(A,U,H){if(U.length<1)throw new Error("commitment should have at least one element");let{R:G,z:ne}=W.decode(H),$=P(U[0]),oe=this.challenge(A,$,G);if(!G.equals(t.BASE.multiplyUnsafe(ne).subtract($.multiplyUnsafe(oe))))throw new Error("invalid proof of knowledge")}},_e={challenge:(A,U,H)=>s?s(A,U,H):pe(Ke(S(A),S(U),H)),sign(A,U,H=or){let{point:G,scalar:ne}=te(H),$=t.BASE.multiply(U),oe=this.challenge(G,$,A),ie=p.add(ne,p.mul(oe,U));return[G,ie]},verify(A,U,H,G){o&&(G=o(G)),o&&(U=o(U));let ne=this.challenge(U,G,A),$=t.BASE.multiplyUnsafe(H),oe=G.multiplyUnsafe(ne),ie=$.subtract(oe).subtract(U);return ie.clearCofactor&&(ie=ie.clearCofactor()),t.ZERO.equals(ie)}},He=(A,U,H)=>{if(!t.BASE.multiply(H).equals(ve(A,U)))throw new Error("invalid secret share")},Zt={fromNumber(A){if(!Number.isSafeInteger(A))throw new Error("expected safe interger");return C(BigInt(A))},derive(A){return la(A,"s"),C(v(Pn(A)))}},ze=(A,U=or)=>xe(Ke(U(32),p.toBytes(A))),Ge=(A,U,H)=>{let G=U.map(it=>[it.identifier,N(it.identifier),P(it.hiding),P(it.binding)]);G.sort((it,Pe)=>it[1]<Pe[1]?-1:it[1]>Pe[1]?1:0);let ne=[];for(let[it,Pe,he,ht]of G)ne.push(p.toBytes(Pe),S(he),S(ht));let $=u(Ke(...ne)),oe=Ke(S(A),I(H),$),ie={};for(let[it,Pe]of G)ie[it]=de(Ke(oe,p.toBytes(Pe)));let be=t.ZERO,ye=[],Re=[];for(let[it,Pe,he,ht]of G){if(t.ZERO.equals(he)||t.ZERO.equals(ht))throw new Error("infinity commitment");be=be.add(he),ye.push(ht),Re.push(ie[it])}let Te=be.add(ue(ye,Re));return{identifiers:G.map(it=>it[1]),groupCommitment:Te,bindingFactors:ie}},Zr=(A,U,H,G)=>{let ne=c(P(A)),$=N(G),{identifiers:oe,groupCommitment:ie,bindingFactors:be}=Ge(ne,U,H),ye=be[G],Re=Oe(oe,$),Te=_e.challenge(ie,ne,H);return{lambda:Re,challenge:Te,bindingFactor:ye,groupCommitment:ie}};Object.freeze(Zt);let nt={Identifier:Zt,DKG:Object.freeze({round1:(A,U,H,G=or)=>{let ne=N(A,"id");hn(U);let{coefficients:$,commitment:oe}=Ee(U,H,void 0,G),ie=ke.compute(ne,$,oe,G),be=oe.map(S),ye={identifier:C(ne),commitment:be,proofOfKnowledge:ie},Re={identifier:ne,coefficients:$,commitment:oe.map(S),signers:{min:U.min,max:U.max},step:1};return{public:ye,secret:Re}},round2:(A,U)=>{if($e(A,{identifier:"bigint",commitment:"object",signers:"object"},{coefficients:"object",round1Cache:"object",round2Cache:"object",step:"number"},"secret"),hn(A.signers,"secret.signers"),mt(U,"others"),U.length!==A.signers.max-1)throw new Error("wrong number of round1 packages");if(!A.coefficients||A.step===3)throw new Error("round3 package used in round2");let H=K(U);if(A.round2Cache!==void 0){if(A.round1Cache===void 0||!z(A.round1Cache,H))throw new Error("round1 packages do not match authenticated transcript");return A.round2Cache}let G={};for(let ne of H){if(ne.commitment.length!==A.signers.min)throw new Error("wrong number of commitments");let $=N(ne.identifier);if($===A.identifier)throw new Error("duplicate id="+C($));ke.validate($,ne.commitment,ne.proofOfKnowledge);for(let ie of ne.commitment)P(ie);if(G[ne.identifier])throw new Error("Duplicate id="+$);let oe=p.toBytes(fe($,A.coefficients));G[ne.identifier]={identifier:C(A.identifier),signingShare:oe}}return A.round1Cache=H,A.round2Cache=G,A.step=2,G},round3:(A,U,H)=>{if($e(A,{identifier:"bigint",commitment:"object",signers:"object"},{coefficients:"object",round1Cache:"object",round2Cache:"object",step:"number"},"secret"),hn(A.signers,"secret.signers"),mt(U,"round1"),mt(H,"round2"),U.length!==A.signers.max-1)throw new Error("wrong length of round1 packages");if(!A.coefficients||A.step!==2||!A.round1Cache)throw new Error("round2 package used in round3");let G=K(U),ne=A.round1Cache;if(!z(ne,G))throw new Error("round1 packages do not match authenticated transcript");if(H.length!==ne.length)throw new Error("wrong length of round2 packages");let $={};for(let he of ne){if(!he.identifier||!he.commitment)throw new Error("wrong round1 share");$[he.identifier]={...he}}for(let he of H){if(!he.identifier||!he.signingShare)throw new Error("wrong round2 share");if(!$[he.identifier])throw new Error("round1 share for "+he.identifier+" is missing");$[he.identifier].signingShare=he.signingShare}if(Object.keys($).length!==ne.length)throw new Error("mismatch identifiers between rounds");let oe=p.ZERO;if(A.commitment.length!==A.signers.min)throw new Error("wrong commitments length");let ie=A.commitment.map(P),be=fe(A.identifier,A.coefficients);He(A.identifier,ie,be);let ye=ie.map(S),Re={[C(A.identifier)]:ye};for(let he in $){let ht=$[he];if(!ht.signingShare||!ht.commitment)throw new Error("mismatch identifiers");let Ve=N(he),ft=p.fromBytes(ht.signingShare),go=ht.commitment.map(P);He(A.identifier,go,ft),oe=p.add(oe,ft);let ot=C(Ve);if(Re[ot])throw new Error("duplicated id="+ot);Re[ot]=ht.commitment}oe=p.add(oe,be);let Te=new Array(A.signers.min).fill(t.ZERO);for(let he in Re){let ht=Re[he];if(ht.length!==A.signers.min)throw new Error("wrong commitments length");for(let Ve=0;Ve<ht.length;Ve++)Te[Ve]=Te[Ve].add(P(ht[Ve]))}let Xe=Te.map(S),it={};for(let he in Re)it[he]=S(ve(N(he),Te));let Pe={public:{signers:{min:A.signers.min,max:A.signers.max},commitments:Xe,verifyingShares:Object.fromEntries(Object.entries(it).map(([he,ht])=>[he,ht.slice()]))},secret:{identifier:C(A.identifier),signingShare:p.toBytes(oe)}};y&&(Pe=y(Pe));for(let he=0;he<A.coefficients.length;he++)A.coefficients[he]-=A.coefficients[he];return delete A.coefficients,delete A.round1Cache,delete A.round2Cache,A.step=3,Pe},clean(A){if($e(A,{identifier:"bigint",commitment:"object",signers:"object"},{coefficients:"object",round1Cache:"object",round2Cache:"object",step:"number"},"secret"),A.identifier-=A.identifier,A.coefficients)for(let U=0;U<A.coefficients.length;U++)A.coefficients[U]-=A.coefficients[U];delete A.round1Cache,delete A.round2Cache,A.step=3}}),trustedDealer(A,U,H,G=or){if(hn(A),U===void 0){U=[];for(let ye=1;ye<=A.max;ye++)U.push(Zt.fromNumber(ye))}else if(mt(U,"identifiers"),U.length!==A.max)throw new Error("identifiers should be array of "+A.max);let ne={};for(let ye of U){let Re=N(ye);if(ye in ne)throw new Error("duplicated id="+ye);ne[ye]=Re}let $=Ee(A,H,void 0,G),oe=$.commitment.map(S),ie={},be={};for(let ye of U){let Re=fe(ne[ye],$.coefficients);be[ye]=S(t.BASE.multiply(Re)),ie[ye]={identifier:ye,signingShare:p.toBytes(Re)}}return{public:{signers:{min:A.min,max:A.max},commitments:oe,verifyingShares:be},secretShares:ie}},validateSecret(A,U){$e(A,{identifier:"string",signingShare:"object"},{},"secret"),we(A.signingShare,p.BYTES,"secret.signingShare"),$e(U,{signers:"object",commitments:"object",verifyingShares:"object"},{},"pub"),hn(U.signers,"pub.signers"),mt(U.commitments,"pub.commitments");let H=N(A.identifier),G=U.commitments.map(P),ne=p.fromBytes(A.signingShare);He(H,G,ne)},commit(A,U=or){if($e(A,{identifier:"string",signingShare:"object"},{},"secret"),we(A.signingShare,p.BYTES,"secret.signingShare"),typeof U!="function")throw new TypeError('"rng" expected function, got type='+typeof U);let H=p.fromBytes(A.signingShare),G=ze(H,U),ne=ze(H,U),$={hiding:p.toBytes(G),binding:p.toBytes(ne)};return{nonces:$,commitments:E(A.identifier,$)}},signShare(A,U,H,G,ne){$e(A,{identifier:"string",signingShare:"object"},{},"secret"),we(A.signingShare,p.BYTES,"secret.signingShare"),$e(U,{signers:"object",commitments:"object",verifyingShares:"object"},{},"pub"),hn(U.signers,"pub.signers"),mt(U.commitments,"pub.commitments"),$e(H,{hiding:"object",binding:"object"},{},"nonces"),we(H.hiding,p.BYTES,"nonces.hiding"),we(H.binding,p.BYTES,"nonces.binding"),mt(G,"commitmentList"),we(ne,void 0,"msg"),TS(U.signers,G.length);let $=p.fromBytes(H.hiding),oe=p.fromBytes(H.binding);if(p.is0($)||p.is0(oe))throw new Error("signing nonces already used");let ie={identifier:A.identifier,hiding:S(t.BASE.multiply($)),binding:S(t.BASE.multiply(oe))},be=G.find(ot=>ot.identifier===A.identifier);if(!be)throw new Error("missing signer commitment");if(Mn(be.hiding)!==Mn(ie.hiding)||Mn(be.binding)!==Mn(ie.binding))throw new Error("incorrect signer commitment");f&&(A=f(A,U)),l&&(U=l(U));let ye=p.fromBytes(A.signingShare),{lambda:Re,challenge:Te,bindingFactor:Xe,groupCommitment:it}=Zr(U.commitments[0],G,ne,A.identifier),Pe=a?a(it,H):H,he=a?p.fromBytes(Pe.hiding):$,ht=a?p.fromBytes(Pe.binding):oe,Ve=p.mul(p.mul(Re,ye),Te),ft=p.mul(ht,Xe),go=p.toBytes(p.add(p.add(he,ft),Ve));return H.hiding.fill(0),H.binding.fill(0),go},verifyShare(A,U,H,G,ne){$e(A,{signers:"object",commitments:"object",verifyingShares:"object"},{},"pub"),hn(A.signers,"pub.signers"),mt(A.commitments,"pub.commitments"),mt(U,"commitmentList"),we(H,void 0,"msg"),N(G),we(ne,p.BYTES,"sigShare"),l&&(A=l(A));let $=U.find(ht=>ht.identifier===G);if(!$)throw new Error("cannot find identifier commitment");let oe=P(A.verifyingShares[G]),ie=P($.hiding),be=P($.binding),{lambda:ye,challenge:Re,bindingFactor:Te,groupCommitment:Xe}=Zr(A.commitments[0],U,H,G),it=ie.add(be.multiplyUnsafe(Te));m&&(it=m(Xe,it));let Pe=t.BASE.multiplyUnsafe(p.fromBytes(ne)),he=it.add(oe.multiplyUnsafe(p.mul(Re,ye)));return Pe.equals(he)},aggregate(A,U,H,G){$e(A,{signers:"object",commitments:"object",verifyingShares:"object"},{},"pub"),hn(A.signers,"pub.signers"),mt(A.commitments,"pub.commitments"),mt(U,"commitmentList"),we(H,void 0,"msg"),$e(G,{},{},"sigShares");let ne=A;l&&(A=l(A));try{TS(A.signers,U.length)}catch{throw new to("aggregation failed",[])}let $=U.map(Re=>Re.identifier),oe=new Set;for(let Re of $){if(oe.has(Re))throw new to("aggregation failed",[]);oe.add(Re)}if($.length!==Object.keys(G).length)throw new to("aggregation failed",[]);for(let Re of $)if(!(Re in G)||!(Re in A.verifyingShares))throw new to("aggregation failed",[]);let ie=P(A.commitments[0]),{groupCommitment:be}=Ge(ie,U,H),ye=p.ZERO;for(let Re of $)ye=p.add(ye,p.fromBytes(G[Re]));if(!_e.verify(H,be,ye,ie)){let Re=[];for(let Te of $)this.verifyShare(ne,U,H,Te,G[Te])||Re.push(Te);throw new to("aggregation failed",Re)}return W.encode(be,ye)},sign(A,U){let H=p.fromBytes(U);i&&(H=i(H));let[G,ne]=_e.sign(A,H);return W.encode(G,ne)},verify(A,U,H){let G=n?T(n(H)):P(H),{R:ne,z:$}=W.decode(A);return _e.verify(U,ne,$,G)},combineSecret(A,U){if(mt(A,"shares"),hn(U),A.length<U.min||A.length>U.max)throw new Error("wrong secret shares array");let H=[],G={};for(let oe of A){let ie=N(oe.identifier),be=C(ie);if(G[be])throw new Error("duplicated id="+be);G[be]=!0,H.push([ie,p.fromBytes(oe.signingShare)])}let ne=H.map(([oe])=>oe),$=p.ZERO;for(let[oe,ie]of H)$=p.add($,p.mul(ie,Oe(ne,oe)));return p.toBytes($)},utils:Object.freeze({Fn:p,randomScalar:(A=or)=>p.toBytes(te(A).scalar),generateSecretPolynomial:(A,U,H,G)=>{let ne=Ee(A,U,H,G);return{...ne,commitment:ne.commitment.map(S)}}})};return Object.freeze(nt)}var hn,TS,to,PS=Xt(()=>{g();Bn();li();Yf();_S();Qi();hn=(e,t="signers")=>{if($e(e,{min:"number",max:"number"},{},t),pt(e.min,t+".min"),pt(e.max,t+".max"),e.min<2||e.max<2||e.min>e.max)throw new Error("Wrong signers info: min="+e.min+" max="+e.max)},TS=(e,t)=>{if(t<e.min||t>e.max)throw new Error("Wrong number of commitments="+t)},to=class extends Error{constructor(r,n){super(r);J(this,"cheaters");this.cheaters=n}}});var Zf,BS,NS=Xt(()=>{g();Bn();Zf=class{constructor(t,r){J(this,"oHash");J(this,"iHash");J(this,"blockLen");J(this,"outputLen");J(this,"canXOF",!1);J(this,"finished",!1);J(this,"destroyed",!1);if(Pf(t),un(r,void 0,"key"),this.iHash=t.create(),typeof this.iHash.update!="function")throw new Error("expected Hash instance");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let n=this.blockLen,i=new Uint8Array(n);i.set(r.length>n?t.create().update(r).digest():r);for(let o=0;o<i.length;o++)i[o]^=54;this.iHash.update(i),this.oHash=t.create();for(let o=0;o<i.length;o++)i[o]^=106;this.oHash.update(i),ir(i)}update(t){return Vo(this),this.iHash.update(t),this}digestInto(t){Vo(this),Bf(t,this),this.finished=!0;let r=t.subarray(0,this.outputLen);this.iHash.digestInto(r),this.oHash.update(r),this.oHash.digestInto(r),this.destroy()}digest(){let t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));let{oHash:r,iHash:n,finished:i,destroyed:o,blockLen:s,outputLen:a,canXOF:f}=this;return t=t,t.finished=i,t.destroyed=o,t.blockLen=s,t.outputLen=a,t.canXOF=f,t.oHash=r._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},BS=(()=>{let e=((t,r,n)=>new Zf(t,r).update(n).digest());return e.create=(t,r)=>new Zf(t,r),e})()});var IM,Fd,Cn,Xf,MS=Xt(()=>{g();li();IM=BigInt(0),Fd=class extends Error{constructor(t=""){super(t)}},Cn={Err:Fd,_tlv:{encode:(e,t)=>{let{Err:r}=Cn;if(pt(e,"tag"),e<0||e>255)throw new r("tlv.encode: wrong tag");if(la(t,"data"),t.length&1)throw new r("tlv.encode: unpadded data");let n=t.length/2,i=ha(n);if(i.length/2&128)throw new r("tlv.encode: long form length too big");let o=n>127?ha(i.length/2|128):"";return ha(e)+o+i+t},decode(e,t){let{Err:r}=Cn;t=we(t,void 0,"DER data");let n=0;if(e<0||e>255)throw new r("tlv.decode: wrong tag");if(t.length<2||t[n++]!==e)throw new r("tlv.decode: wrong tlv");let i=t[n++],o=!!(i&128),s=0;if(!o)s=i;else{let f=i&127;if(!f)throw new r("tlv.decode(long): indefinite length not supported");if(f>4)throw new r("tlv.decode(long): byte length is too big");let l=t.subarray(n,n+f);if(l.length!==f)throw new r("tlv.decode: length bytes not complete");if(l[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(let m of l)s=s<<8|m;if(n+=f,s<128)throw new r("tlv.decode(long): not minimal encoding")}let a=t.subarray(n,n+s);if(a.length!==s)throw new r("tlv.decode: wrong value length");return{v:a,l:t.subarray(n+s)}}},_int:{encode(e){let{Err:t}=Cn;if(Kf(e),e<IM)throw new t("integer: negative integers are not allowed");let r=ha(e);if(Number.parseInt(r[0],16)&8&&(r="00"+r),r.length&1)throw new t("unexpected DER parsing assertion: unpadded hex");return r},decode(e){let{Err:t}=Cn;if(e.length<1)throw new t("invalid signature integer: empty");if(e[0]&128)throw new t("invalid signature integer: negative");if(e.length>1&&e[0]===0&&!(e[1]&128))throw new t("invalid signature integer: unnecessary leading zero");return Dt(e)}},toSig(e,t){let{Err:r,_int:n,_tlv:i}=Cn;if(t!==void 0&&(pt(t,"maxScalarBytes"),t<1))throw new r("invalid signature: maxScalarBytes must be positive");let o=we(e,void 0,"signature"),{v:s,l:a}=i.decode(48,o);if(a.length)throw new r("invalid signature: left bytes after parsing");let{v:f,l}=i.decode(2,s),{v:m,l:y}=i.decode(2,l);if(y.length)throw new r("invalid signature: left bytes after parsing");if(t!==void 0&&(f.length>t||m.length>t))throw new r("invalid signature: integer too large");return{r:n.decode(f),s:n.decode(m)}},hexFromSig(e){let{_tlv:t,_int:r}=Cn;$e(e,{r:"bigint",s:"bigint"},{},"sig");let n=t.encode(2,r.encode(e.r)),i=t.encode(2,r.encode(e.s)),o=n+i;return t.encode(48,o)}},Xf=(Object.freeze(Cn._tlv),Object.freeze(Cn._int),Object.freeze(Cn))});function AM(e,t,r){Ad("scalar",e,Ln,r);let[[n,i],[o,s]]=t,a=kS(s*e,r),f=kS(-i*e,r),l=e-a*n-f*o,m=-a*i-f*s,y=l<Ln,p=m<Ln;y&&(l=-l),p&&(m=-m);let w=da(Math.ceil(Xo(r)/2))+ro;if(l<Ln||l>=w||m<Ln||m>=w)throw new Error("splitScalar (endomorphism): failed for k");return{k1neg:y,k1:l,k2neg:p,k2:m}}function jd(e){if(!["compact","recovered","der"].includes(e))throw new Error('Signature format must be "compact", "recovered", or "der"');return e}function qd(e,t){$e(e);let r={};for(let n of Object.keys(t))r[n]=e[n]===void 0?t[n]:e[n];return cn(r.lowS,"lowS"),cn(r.prehash,"prehash"),r.format!==void 0&&jd(r.format),r}function LS(e,t={}){let r=mS("weierstrass",e,t),n=r.Fp,i=r.Fn,o=r.CURVE,{h:s,n:a}=o;$e(t,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object",randomBytes:"function"});let{endo:f,allowInfinityPoint:l,clearCofactor:m,isTorsionFree:y,fromBytes:p,toBytes:w}=t,O=t.randomBytes===void 0?or:t.randomBytes;if(f&&(!n.is0(o.a)||typeof f.beta!="bigint"||!Array.isArray(f.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');let M=f?{beta:f.beta,basises:f.basises.map(C=>[...C])}:void 0,D=US(n,i);function F(){if(!n.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function V(C,N,L){if(N.is0()){if(!l)throw new Error("bad point: ZERO");return Uint8Array.of(0)}let{x:K,y:z}=N.toAffine(),W=n.toBytes(K);if(cn(L,"isCompressed"),L){F();let te=!n.isOdd(z);return Ke(DS(te),W)}else return Ke(Uint8Array.of(4),W,n.toBytes(z))}function Y(C){we(C,void 0,"Point");let{publicKey:N,publicKeyUncompressed:L}=D,K=C.length,z=C[0],W=C.subarray(1);if(l&&K===1&&z===0)return{x:n.ZERO,y:n.ZERO};if(K===N&&(z===2||z===3)){let te=n.fromBytes(W);if(!n.isValid(te))throw new Error("bad point: is not on curve, wrong x");let re=pe(te),se;try{se=n.sqrt(re)}catch(fe){let Oe=fe instanceof Error?": "+fe.message:"";throw new Error("bad point: is not on curve, sqrt error"+Oe)}F();let Ie=n.isOdd(se);return(z&1)===1!==Ie&&(se=n.neg(se)),{x:te,y:se}}else if(K===L&&z===4){let te=n.BYTES,re=n.fromBytes(W.subarray(0,te)),se=n.fromBytes(W.subarray(te,te*2));if(!xe(re,se))throw new Error("bad point: is not on curve");return{x:re,y:se}}else throw new Error(`bad point: got length ${K}, expected compressed=${N} or uncompressed=${L}`)}let Q=w===void 0?V:w,ce=p===void 0?Y:p,ee=n.mul(o.b,Hd),de=n.is0(o.a)?C=>n.ZERO:C=>n.mul(o.a,C);function pe(C){let N=n.sqr(C),L=n.mul(N,C);return n.add(n.add(L,n.mul(C,o.a)),o.b)}function xe(C,N){let L=n.sqr(N),K=pe(C);return n.eql(L,K)}if(!xe(o.Gx,o.Gy))throw new Error("bad curve params: generator point");let I=n.mul(n.pow(o.a,Hd),OM),u=n.mul(n.sqr(o.b),BigInt(27));if(n.is0(n.add(I,u)))throw new Error("bad curve params: a or b");function h(C,N,L=!1){if(!n.isValid(N)||L&&n.is0(N))throw new Error(`bad point coordinate ${C}`);return typeof N=="object"&&N!==null?n.create(N):N}function v(C){if(!(C instanceof P))throw new Error("Weierstrass Point expected")}function _(C){if(!M||!M.basises)throw new Error("no endo");return AM(C,M.basises,i.ORDER)}function S(C,N,L,K){if(!i.isValid(K))throw new RangeError("invalid scalar: out of range");if(M){let{k1neg:z,k1:W,k2neg:te,k2:re}=_(K),se=new P(n.mul(L.X,M.beta),L.Y,L.Z);C.push(z?L.negate():L,te?se.negate():se),N.push(W,re)}else C.push(L),N.push(K)}let T=new WeakSet,b=class b{constructor(N,L,K){J(this,"X");J(this,"Y");J(this,"Z");this.X=h("x",N),this.Y=h("y",L,!0),this.Z=h("z",K),Object.freeze(this)}static CURVE(){return o}static fromAffine(N){let{x:L,y:K}=N||{};if(!N||!n.isValid(L)||!n.isValid(K))throw new Error("invalid affine point");if(N instanceof b)throw new Error("projective point not allowed");return n.is0(L)&&n.is0(K)?b.ZERO:new b(L,K,n.ONE)}static fromBytes(N){let L=b.fromAffine(ce(we(N,void 0,"point")));return L.assertValidity(),L}static fromHex(N){return b.fromBytes(Yo(N))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(N=6,L=!0){return c.setWindowSize(this,N),L||this.multiply(Hd),this}assertValidity(){let N=this;if(N.is0()){if(l&&n.is0(N.X)&&n.eql(N.Y,n.ONE)&&n.is0(N.Z))return;throw new Error("bad point: ZERO")}if(T.has(N))return;let{x:L,y:K}=N.toAffine();if(!n.isValid(L)||!n.isValid(K))throw new Error("bad point: x or y not field elements");if(!xe(L,K))throw new Error("bad point: equation left != right");if(!N.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");T.add(N)}hasEvenY(){let{y:N}=this.toAffine();if(!n.isOdd)throw new Error("Field doesn't support isOdd");return!n.isOdd(N)}equals(N){v(N);let{X:L,Y:K,Z:z}=this,{X:W,Y:te,Z:re}=N,se=n.eql(n.mul(L,re),n.mul(W,z)),Ie=n.eql(n.mul(K,re),n.mul(te,z));return se&&Ie}negate(){return new b(this.X,n.neg(this.Y),this.Z)}double(){let{X:N,Y:L,Z:K}=this,z=n.ZERO,W=n.ZERO,te=n.ZERO,re=n.mul(N,N),se=n.mul(L,L),Ie=n.mul(K,K),ue=n.mul(N,L);return ue=n.add(ue,ue),te=n.mul(N,K),te=n.add(te,te),z=de(te),W=n.mul(ee,Ie),W=n.add(z,W),z=n.sub(se,W),W=n.add(se,W),W=n.mul(z,W),z=n.mul(ue,z),te=n.mul(ee,te),Ie=de(Ie),ue=n.sub(re,Ie),ue=de(ue),ue=n.add(ue,te),te=n.add(re,re),re=n.add(te,re),re=n.add(re,Ie),re=n.mul(re,ue),W=n.add(W,re),Ie=n.mul(L,K),Ie=n.add(Ie,Ie),re=n.mul(Ie,ue),z=n.sub(z,re),te=n.mul(Ie,se),te=n.add(te,te),te=n.add(te,te),new b(z,W,te)}add(N){v(N);let{X:L,Y:K,Z:z}=this,{X:W,Y:te,Z:re}=N,se=n.ZERO,Ie=n.ZERO,ue=n.ZERO,fe=n.mul(L,W),Oe=n.mul(K,te),ve=n.mul(z,re),Ee=n.add(L,K),ke=n.add(W,te);Ee=n.mul(Ee,ke),ke=n.add(fe,Oe),Ee=n.sub(Ee,ke),ke=n.add(L,z);let _e=n.add(W,re);return ke=n.mul(ke,_e),_e=n.add(fe,ve),ke=n.sub(ke,_e),_e=n.add(K,z),se=n.add(te,re),_e=n.mul(_e,se),se=n.add(Oe,ve),_e=n.sub(_e,se),ue=de(ke),se=n.mul(ee,ve),ue=n.add(se,ue),se=n.sub(Oe,ue),ue=n.add(Oe,ue),Ie=n.mul(se,ue),Oe=n.add(fe,fe),Oe=n.add(Oe,fe),ve=de(ve),ke=n.mul(ee,ke),Oe=n.add(Oe,ve),ve=n.sub(fe,ve),ve=de(ve),ke=n.add(ke,ve),fe=n.mul(Oe,ke),Ie=n.add(Ie,fe),fe=n.mul(_e,ke),se=n.mul(Ee,se),se=n.sub(se,fe),fe=n.mul(Ee,Oe),ue=n.mul(_e,ue),ue=n.add(ue,fe),new b(se,Ie,ue)}subtract(N){return v(N),this.add(N.negate())}is0(){return this.equals(b.ZERO)}multiply(N){if(!i.isValidNot0(N))throw new RangeError("invalid scalar: out of range");let{p:L,f:K}=c.mulSecret(this,N,s,E);return E([L,K])[0]}multiplyUnsafe(N){let L=this,K=N;if(!i.isValid(K))throw new RangeError("invalid scalar: out of range");if(K===Ln||L.is0())return b.ZERO;if(K===ro)return L;if(c.hasWindowSize(this))return c.mulUnsafe(L,K,E);let z=[],W=[];return S(z,W,L,K),ts(b,z,W)}mulAddUnsafe(N,L,K){v(L);let z=[],W=[];return S(z,W,this,N),S(z,W,L,K),ts(b,z,W)}toAffine(N){let L=this,K=N;if(K!=null&&!n.isValid(K))throw new RangeError('"invertedZ" expected valid field element');let{X:z,Y:W,Z:te}=L;if(n.eql(te,n.ONE))return{x:z,y:W};let re=L.is0();K==null&&(K=re?n.ONE:n.inv(te));let se=n.mul(z,K),Ie=n.mul(W,K),ue=n.mul(te,K);if(re)return{x:n.ZERO,y:n.ZERO};if(!n.eql(ue,n.ONE))throw new Error("invZ was invalid");return{x:se,y:Ie}}isTorsionFree(){return s===ro?!0:y?y(b,this):c.mulUnsafe(this,a).is0()}clearCofactor(){return s===ro?this:m?m(b,this):this.multiplyUnsafe(s)}isSmallOrder(){return s===ro?this.is0():this.clearCofactor().is0()}toBytes(N=!0){return cn(N,"isCompressed"),this.assertValidity(),Q(b,this,N)}toHex(N=!0){return Mn(this.toBytes(N))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}};J(b,"BASE",new b(o.Gx,o.Gy,n.ONE)),J(b,"ZERO",new b(n.ZERO,n.ONE,n.ZERO)),J(b,"Fp",n),J(b,"Fn",i);let P=b,E=C=>pS(P,C),c=new Wf(P,O);return c.bits>=6&&P.BASE.precompute(6),Object.freeze(P.prototype),Object.freeze(P),P}function DS(e){return Uint8Array.of(e?2:3)}function US(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function RM(e,t={}){di(e);let{Fn:r}=e,n=t.randomBytes===void 0?or:t.randomBytes,i=Object.assign(US(e.Fp,r),{seed:Math.max(es(r.ORDER),16)});function o(w){try{let O=r.fromBytes(w);return r.isValidNot0(O)}catch{return!1}}function s(w,O){let{publicKey:M,publicKeyUncompressed:D}=i;try{let F=w.length;return O===!0&&F!==M||O===!1&&F!==D?!1:!e.fromBytes(w).is0()}catch{return!1}}function a(w){return w=w===void 0?n(i.seed):w,Ji(we(w,i.seed,"seed"),r.ORDER)}function f(w,O=!0){return e.BASE.multiply(r.fromBytes(w)).toBytes(O)}function l(w){let{secretKey:O,publicKey:M,publicKeyUncompressed:D}=i,F=r._lengths;if(!fn(w))return;let V=we(w,void 0,"key").length,Y=V===M||V===D,Q=V===O||!!F?.includes(V);if(!(Y&&Q))return Y}function m(w,O,M=!0){if(l(w)===!0)throw new Error("first arg must be private key");if(l(O)===!1)throw new Error("second arg must be public key");let D=r.fromBytes(w),F=e.fromBytes(O);if(F.is0())throw new Error("invalid public key: point at infinity");return F.multiply(D).toBytes(M)}let y={isValidSecretKey:o,isValidPublicKey:s,randomSecretKey:a},p=zf(a,f);return Object.freeze(y),Object.freeze(i),Object.freeze({getPublicKey:f,getSharedSecret:m,keygen:p,Point:e,utils:y,lengths:i})}function FS(e,t,r={}){di(e);let n=t;Pf(n),$e(r,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});let i=Object.assign({},r),o=i.randomBytes===void 0?or:i.randomBytes,s=i.hmac===void 0?(b,C)=>BS(n,b,C):i.hmac,{Fp:a,Fn:f}=e,{ORDER:l,BITS:m}=f,y=es(l),p=Cd(o,y),{keygen:w,getPublicKey:O,getSharedSecret:M,utils:D,lengths:F}=RM(e,i),V={prehash:!0,lowS:typeof i.lowS=="boolean"?i.lowS:!0,format:"compact",extraEntropy:!1},Y=l*CS+ro<a.ORDER;function Q(b){let C=l>>ro;return b>C}function ce(b,C){if(!f.isValidNot0(C))throw new Error(`invalid signature ${b}: out of range 1..Point.Fn.ORDER`);return C}function ee(){if(!a.isOdd)throw new Error("Field doesn't support isOdd")}function de(b,C,N){return ee(),(b===N?0:2)|Number(a.isOdd(C))}function pe(){if(Y)throw new Error('"recovered" sig type is not supported for cofactor >2 curves')}function xe(b,C){jd(C);let N=F.signature,L=C==="compact"?N:C==="recovered"?N+1:void 0;return we(b,L)}class I{constructor(C,N,L){J(this,"r");J(this,"s");J(this,"recovery");if(this.r=ce("r",C),this.s=ce("s",N),L!=null){if(pe(),![0,1,2,3].includes(L))throw new Error("invalid recovery id");this.recovery=L}Object.freeze(this)}static fromBytes(C,N=V.format){xe(C,N);let L;if(N==="der"){if(C.length>2*f.BYTES+16)throw new Xf.Err("invalid signature: DER signature too long");let{r:te,s:re}=Xf.toSig(we(C),f.BYTES+1);return new I(te,re)}N==="recovered"&&(L=C[0],N="compact",C=C.subarray(1));let K=F.signature/2,z=C.subarray(0,K),W=C.subarray(K,K*2);return new I(f.fromBytes(z),f.fromBytes(W),L)}static fromHex(C,N){return this.fromBytes(Yo(C),N)}assertRecovery(){let{recovery:C}=this;if(C==null)throw new Error("invalid recovery id: must be present");return C}addRecoveryBit(C){return new I(this.r,this.s,C)}recoverPublicKey(C){let{r:N,s:L}=this,K=this.assertRecovery(),z=K===2||K===3?N+l:N;if(!a.isValid(z))throw new Error("invalid recovery id: sig.r+curve.n != R.x");let W=a.toBytes(z),te=e.fromBytes(Ke(DS((K&1)===0),W)),re=f.inv(z),se=h(we(C,void 0,"msgHash")),Ie=f.create(-se*re),ue=f.create(L*re),fe=e.BASE.mulAddUnsafe(Ie,te,ue);if(fe.is0())throw new Error("invalid recovery: point at infinify");return fe.assertValidity(),fe}hasHighS(){return Q(this.s)}toBytes(C=V.format){if(jd(C),C==="der")return Yo(Xf.hexFromSig(this));let{r:N,s:L}=this,K=f.toBytes(N),z=f.toBytes(L);return C==="recovered"?(pe(),Ke(Uint8Array.of(this.assertRecovery()),K,z)):Ke(K,z)}toHex(C){return Mn(this.toBytes(C))}}Object.freeze(I.prototype),Object.freeze(I);let u=i.bits2int===void 0?function(C){if(C.length>8192)throw new Error("input is too large");let N=Dt(C),L=C.length*8-m;return L>0?N>>BigInt(L):N}:i.bits2int,h=i.bits2int_modN===void 0?function(C){return f.create(u(C))}:i.bits2int_modN,v=da(m);function _(b){return Ad("num < 2^"+m,b,Ln,v),f.toBytes(b)}function S(b,C){return we(b,void 0,"message"),C?we(n(b),void 0,"prehashed message"):b}function T(b,C,N){let{lowS:L,prehash:K,extraEntropy:z}=qd(N,V);b=S(b,K);let W=h(b),te=f.fromBytes(C);if(!f.isValidNot0(te))throw new Error("invalid private key");let re=[_(te),_(W)];if(z!=null&&z!==!1){let fe=z===!0?o(F.secretKey):z;re.push(we(fe,void 0,"extraEntropy"))}let se=Ke(...re),Ie=W;function ue(fe){let Oe=u(fe);if(!f.isValidNot0(Oe))return;let ve=e.BASE.multiply(Oe).toAffine(),Ee=f.create(ve.x);if(Ee===Ln)return;let ke;if(p!==void 0){let Zt=Dt(Ji(p(y),l)),ze=f.inv(f.mul(Zt,Oe)),Ge=f.mul(Zt,Ie),Zr=f.mul(Zt,te);ke=f.create(ze*f.create(Ge+Zr*Ee))}else{let Zt=aS(Oe,l);ke=f.create(Zt*f.create(Ie+Ee*te))}if(ke===Ln)return;let _e=de(ve.x,ve.y,Ee),He=ke;return L&&Q(ke)&&(He=f.neg(ke),_e^=1),new I(Ee,He,Y?void 0:_e)}return{seed:se,k2sig:ue}}function P(b,C,N={}){let{seed:L,k2sig:K}=T(b,C,N);return Q_(n.outputLen,f.BYTES,s)(L,K).toBytes(N.format)}function E(b,C,N,L={}){let{lowS:K,prehash:z,format:W}=qd(L,V);if(N=we(N,void 0,"publicKey"),C=S(C,z),!fn(b)){let te=b instanceof I?", use sig.toBytes()":"";throw new Error("verify expects Uint8Array signature"+te)}xe(b,W);try{let te=I.fromBytes(b,W),re=e.fromBytes(N);if(re.is0()||K&&te.hasHighS())return!1;let{r:se,s:Ie}=te,ue=h(C),fe=f.inv(Ie),Oe=f.create(ue*fe),ve=f.create(se*fe),Ee=e.BASE.mulAddUnsafe(Oe,re,ve);if(Ee.is0())return!1;let ke=Ee.toAffine();return!(f.create(ke.x)!==se||W==="recovered"&&te.recovery!==de(ke.x,ke.y,se))}catch{return!1}}function c(b,C,N={}){let{prehash:L}=qd(N,V);return C=S(C,L),I.fromBytes(b,"recovered").recoverPublicKey(C).toBytes()}return Object.freeze({keygen:w,getPublicKey:O,getSharedSecret:M,utils:D,lengths:F,Point:e,sign:P,verify:E,recoverPublicKey:c,Signature:I,hash:n})}var kS,Ln,ro,CS,Hd,OM,qS=Xt(()=>{g();NS();Bn();li();Yf();MS();Qi();kS=(e,t)=>(e+(e>=0?t:-t)/CS)/t;Ln=BigInt(0),ro=BigInt(1),CS=BigInt(2),Hd=BigInt(3),OM=BigInt(4)});var JS={};pl(JS,{__TEST:()=>MM,schnorr:()=>kM,schnorr_FROST:()=>FM,secp256k1:()=>BM,secp256k1_FROST:()=>DM,secp256k1_hasher:()=>Vd});function PM(e){let t=Jf.p,r=BigInt(3),n=BigInt(6),i=BigInt(11),o=BigInt(22),s=BigInt(23),a=BigInt(44),f=BigInt(88),l=e*e*e%t,m=l*l*e%t,y=mr(m,r,t)*m%t,p=mr(y,r,t)*m%t,w=mr(p,HS,t)*l%t,O=mr(w,i,t)*w%t,M=mr(O,o,t)*O%t,D=mr(M,a,t)*M%t,F=mr(D,f,t)*D%t,V=mr(F,a,t)*M%t,Y=mr(V,r,t)*m%t,Q=mr(Y,s,t)*O%t,ce=mr(Q,n,t)*l%t,ee=mr(ce,HS,t);if(!Ur.eql(Ur.sqr(ee),e))throw new Error("Cannot find square root");return ee}function ga(e,...t){let r=jS[e];if(r===void 0){let n=ui(Zo(e));r=Ke(n,n),jS[e]=r}return ui(Ke(r,...t))}function WS(e){let{Fn:t,BASE:r}=Qe,n=t.fromBytes(we(e,32,"secretKey")),o=r.multiply(n).toAffine();return{scalar:dn(o.y)?n:t.neg(n),bytes:VS(o)}}function Qf(e){let t=Ur;if(!t.isValidNot0(e))throw new Error("invalid x: Fail if x \u2265 p");let r=t.sqr(e),n=t.add(t.mulN(r,e),BigInt(7)),i=t.sqrt(n);dn(i)||(i=t.neg(i));let o=Qe.fromAffine({x:e,y:i});return o.assertValidity(),o}function Gd(...e){return Qe.Fn.create(rs(ga("BIP0340/challenge",...e)))}function KS(e){return WS(e).bytes}function NM(e,t,r=ca(32)){let{Fn:n,BASE:i}=Qe,o=kn(we(e,void 0,"message")),{bytes:s,scalar:a}=WS(t),f=we(r,32,"auxRand"),l=n.toBytes(a^rs(ga("BIP0340/aux",f))),m=ga("BIP0340/nonce",l,s,o),y=n.create(rs(m));if(y===Kd)throw new Error("sign failed: k is zero");let w=i.multiply(y).toAffine(),O=dn(w.y)?y:n.neg(y),M=VS(w),D=Gd(M,s,o),F=new Uint8Array(64);if(F.set(M,0),F.set(n.toBytes(n.create(O+D*a)),32),!zS(F,o,s))throw new Error("sign: Invalid signature produced");return F}function zS(e,t,r){let{Fp:n,Fn:i,BASE:o}=Qe,s=we(e,64,"signature"),a=we(t,void 0,"message"),f=we(r,32,"publicKey");try{let l=Qf(rs(f)),m=s.subarray(0,32),y=rs(m);if(!n.isValidNot0(y))return!1;let p=rs(s.subarray(32,64));if(!i.isValidNot0(p))return!1;let w=Gd(m,ya(l),a),O=o.mulAddUnsafe(p,l,i.neg(w)),{x:M,y:D}=O.toAffine();return!(O.is0()||!dn(D)||!n.eql(M,y))}catch{return!1}}function YS(e,t){if(t===void 0)return Kd;let r=ya(e),n=Dt(ga("TapTweak",r,t));if(!Qe.Fn.isValid(n))throw new Error("invalid TapTweak hash");return n}function Wd(e){let t=Qe.fromBytes(e.commitments[0]);return dn(t.y)?e:{signers:{min:e.signers.min,max:e.signers.max},commitments:e.commitments.map(r=>Qe.fromBytes(r).negate().toBytes()),verifyingShares:Object.fromEntries(Object.entries(e.verifyingShares).map(([r,n])=>[r,Qe.fromBytes(n).negate().toBytes()]))}}function $S(e,t){let r=Qe.fromBytes(t.commitments[0]);if(dn(r.y))return e;let n=Qe.Fn;return{...e,signingShare:n.toBytes(n.neg(n.fromBytes(e.signingShare)))}}function UM(e,t){if(dn(e.y))return t;let r=Qe.Fn;return{binding:r.toBytes(r.neg(r.fromBytes(t.binding))),hiding:r.toBytes(r.neg(r.fromBytes(t.hiding)))}}function ZS(e,t,r){let n=Qe.Fn,i=$S(e,t),o=Wd(t),s=YS(Qe.fromBytes(o.commitments[0]),r),a=n.toBytes(n.add(n.fromBytes(i.signingShare),s));return{identifier:i.identifier,signingShare:a}}function XS(e,t){let r=Wd(e),n=YS(Qe.fromBytes(r.commitments[0]),t);if(n===Kd)return r;let i=Qe.BASE.multiply(n),o=r.commitments.map((a,f)=>(f===0?Qe.fromBytes(a).add(i):Qe.fromBytes(a)).toBytes()),s={};for(let a in r.verifyingShares)s[a]=Qe.fromBytes(r.verifyingShares[a]).add(i).toBytes();return{signers:{min:r.signers.min,max:r.signers.max},commitments:o,verifyingShares:s}}var Jf,TM,Kd,HS,Ur,Qe,BM,jS,ya,VS,dn,rs,MM,kM,CM,GS,LM,Vd,DM,FM,QS=Xt(()=>{g();Sd();Bn();Yf();PS();RS();Qi();qS();li();Jf={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},TM={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]},Kd=BigInt(0),HS=BigInt(2);Ur=Qo(Jf.p,{sqrt:PM}),Qe=LS(Jf,{Fp:Ur,endo:TM}),BM=FS(Qe,ui),jS=Object.create(null);ya=e=>e.toBytes(!0).slice(1),VS=({x:e})=>Ur.toBytes(e),dn=e=>!Ur.isOdd(e);rs=Dt;MM=Object.freeze({lift_x:Qf,frostTweakPublic:XS,frostTweakSecret:ZS}),kM=(()=>{let r=n=>(n=n===void 0?ca(48):n,Ji(we(n,48,"seed"),Jf.n));return Object.freeze({keygen:zf(r,KS),getPublicKey:KS,sign:NM,verify:zS,Point:Qe,utils:Object.freeze({randomSecretKey:r,taggedHash:ga,lift_x:Qf,pointToBytes:ya}),lengths:Object.freeze({secretKey:32,publicKey:32,publicKeyHasPrefix:!1,signature:64,seed:48})})})(),CM=IS(Ur,[["0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa8c7","0x7d3d4c80bc321d5b9f315cea7fd44c5d595d2fc0bf63b92dfff1044f17c6581","0x534c328d23f234e6e2a413deca25caece4506144037c40314ecbd0b53d9dd262","0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa88c"],["0xd35771193d94918a9ca34ccbb7b640dd86cd409542f8487d9fe6b745781eb49b","0xedadc6f64383dc1df7c4b2d51b54225406d36b641f5e41bbc52a56612a8c6d14","0x0000000000000000000000000000000000000000000000000000000000000001"],["0x4bda12f684bda12f684bda12f684bda12f684bda12f684bda12f684b8e38e23c","0xc75e0c32d5cb7c0fa9d0a54b12a0a6d5647ab046d686da6fdffc90fc201d71a3","0x29a6194691f91a73715209ef6512e576722830a201be2018a765e85a9ecee931","0x2f684bda12f684bda12f684bda12f684bda12f684bda12f684bda12f38e38d84"],["0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffff93b","0x7a06534bb8bdb49fd5e9e6632722c2989467c1bfc8e8d978dfb425d2685c2573","0x6484aa716545ca2cf3a70c3fa8fe337e0a3d21162f0d6299a7bf8192bfd2a76f","0x0000000000000000000000000000000000000000000000000000000000000001"]].map(e=>e.map(t=>BigInt(t)))),LM=()=>GS||(GS=OS(Ur,{A:BigInt("0x3f8731abdd661adca08a5558f0f5d272e953d363cb6f0e5d405447c01a444533"),B:BigInt("1771"),Z:Ur.create(BigInt("-11"))})),Vd=AS(Qe,e=>{let{x:t,y:r}=LM()(Ur.create(e[0]));return CM(t,r)},{DST:"secp256k1_XMD:SHA-256_SSWU_RO_",encodeDST:"secp256k1_XMD:SHA-256_SSWU_NU_",p:Ur.ORDER,m:1,k:128,expand:"xmd",hash:ui}),DM=Ud({name:"FROST-secp256k1-SHA256-v1",Point:Qe,hashToScalar:Vd.hashToScalar,hash:ui});FM=Ud({name:"FROST-secp256k1-SHA256-TR-v1",Point:Qe,hashToScalar:Vd.hashToScalar,hash:ui,parsePublicKey(e){if(e.length===32)return Qf(Dt(e));if(e.length===33)return Qe.fromBytes(e);throw new Error(`expected x-only or compressed public key, got length=${e.length}`)},adjustScalar(e){let t=Qe.BASE.multiply(e);return dn(t.y)?e:Qe.Fn.neg(e)},adjustPoint:e=>dn(e.y)?e:e.negate(),challenge(e,t,r){return Gd(ya(e),ya(t),r)},adjustNonces:UM,adjustGroupCommitmentShare:(e,t)=>dn(e.y)?t:t.negate(),adjustPublic:Wd,adjustSecret:$S,adjustTx:{encode:e=>e.subarray(1),decode:e=>Ke(Uint8Array.of(2),e)},adjustDKG:e=>{let t=new Uint8Array(0);return{public:XS(e.public,t),secret:ZS(e.secret,e.public,t)}}})});var gi=B((OF,nw)=>{"use strict";g();var ew=Ar(),{secp256k1:qM}=(QS(),gl(JS)),va=qM.Point,ec=va.Fn.ORDER;function HM(e){return BigInt("0x"+(e.toString(16)||"0"))}function zd(e){var t=e.toString(16);return t.length%2&&(t="0"+t),new ew(t,16)}function tc(e){if(e==null)throw new Error("Invalid Point");if(typeof e=="bigint")return e;if(typeof e=="number")return BigInt(e);if(typeof e=="string")return BigInt(e.indexOf("0x")===0?e:"0x"+e);if(typeof e.toString=="function")return HM(e);throw new Error("Invalid Point")}function ma(e){var t=Object.create(et.prototype);return t._p=e,t}function tw(e,t){var r=tc(t).toString(16).padStart(64,"0");return va.fromHex((e?"03":"02")+r)}function rw(e,t){var r;try{r=tw((t&1n)===1n,e)}catch{throw new Error("Point does not lie on the curve")}if(r.toAffine().y!==t)throw new Error("Invalid y value for curve.")}function et(e,t,r){if(!(this instanceof et))return new et(e,t,r);var n,i;try{n=tc(e),i=tc(t)}catch{throw new Error("Invalid Point")}rw(n,i);try{this._p=va.fromAffine({x:n,y:i})}catch{throw new Error("Invalid Point")}return this}et.fromX=function(t,r){try{var n=ma(tw(t,r))}catch{throw new Error("Invalid X")}return n.validate(),n};et.getG=function(){return ma(va.BASE)};et.getN=function(){return zd(ec)};et.prototype.getX=function(){return zd(this._p.toAffine().x)};et.prototype.getY=function(){return zd(this._p.toAffine().y)};Object.defineProperty(et.prototype,"x",{configurable:!0,enumerable:!0,get:function(){return this.getX()}});Object.defineProperty(et.prototype,"y",{configurable:!0,enumerable:!0,get:function(){return this.getY()}});et.prototype.mul=function(t){var r=(tc(t)%ec+ec)%ec;return r===0n||this._p.is0()?ma(va.ZERO):ma(this._p.multiply(r))};et.prototype.add=function(t){return ma(this._p.add(t._p))};et.prototype.mulAdd=function(t,r,n){return this.mul(t).add(r.mul(n))};et.prototype.eq=function(t){return this._p.equals(t._p)};et.prototype.isInfinity=function(){return this._p.is0()};et.prototype.validate=function(){if(this.isInfinity())throw new Error("Point cannot be equal to Infinity");var t=this._p.toAffine();return rw(t.x,t.y),this};et.pointToCompressed=function(t){var r=t.getX().toBuffer({size:32}),n=t.getY().toBuffer({size:32}),i,o=n[n.length-1]%2;return o?i=d.Buffer.from([3]):i=d.Buffer.from([2]),d.Buffer.concat([i,r])};et.pointFromCompressed=function(e){if(e.length!==33)throw new Error("invalid buffer length");var t=e[0],r;if(t===3)r=!0;else if(t===2)r=!1;else throw new Error("invalid value of compressed prefix");var n=ew.fromBuffer(e.slice(1,33));return et.fromX(r,n)};et.prototype.toBuffer=function(){return et.pointToCompressed(this)};et.prototype.toHex=function(){return this.toBuffer().toString("hex")};et.fromBuffer=function(e){return et.pointFromCompressed(e)};et.fromHex=function(e){return et.fromBuffer(d.Buffer.from(e,"hex"))};nw.exports=et});var ow=B((TF,iw)=>{"use strict";g();var rc=oa(),Dn=We(),Nt=iw.exports;Nt.sha1=function(e){return Dn.checkArgument(d.Buffer.isBuffer(e)),rc.createHash("sha1").update(e).digest()};Nt.sha1.blocksize=512;Nt.sha256=function(e){return Dn.checkArgument(d.Buffer.isBuffer(e)),rc.createHash("sha256").update(e).digest()};Nt.sha256.blocksize=512;Nt.sha256sha256=function(e){return Dn.checkArgument(d.Buffer.isBuffer(e)),Nt.sha256(Nt.sha256(e))};Nt.ripemd160=function(e){return Dn.checkArgument(d.Buffer.isBuffer(e)),rc.createHash("ripemd160").update(e).digest()};Nt.sha256ripemd160=function(e){return Dn.checkArgument(d.Buffer.isBuffer(e)),Nt.ripemd160(Nt.sha256(e))};Nt.sha512=function(e){return Dn.checkArgument(d.Buffer.isBuffer(e)),rc.createHash("sha512").update(e).digest()};Nt.sha512.blocksize=1024;Nt.hmac=function(e,t,r){Dn.checkArgument(d.Buffer.isBuffer(t)),Dn.checkArgument(d.Buffer.isBuffer(r)),Dn.checkArgument(e.blocksize);var n=e.blocksize/8;if(r.length>n)r=e(r);else if(r.length<n){var i=d.Buffer.alloc(n);i.fill(0),r.copy(i),r=i}var o=d.Buffer.alloc(n);o.fill(92);var s=d.Buffer.alloc(n);s.fill(54);for(var a=d.Buffer.alloc(n),f=d.Buffer.alloc(n),l=0;l<n;l++)a[l]=o[l]^r[l],f[l]=s[l]^r[l];return e(d.Buffer.concat([a,e(d.Buffer.concat([f,t]))]))};Nt.sha256hmac=function(e,t){return Nt.hmac(Nt.sha256,e,t)};Nt.sha512hmac=function(e,t){return Nt.hmac(Nt.sha512,e,t)}});var hw={};pl(hw,{_MD5:()=>sc,_RIPEMD160:()=>ac,_SHA1:()=>oc,md5:()=>WM,ripemd160:()=>QM,sha1:()=>jM});function sw(e,t,r,n){return e===0?t^r^n:e===1?t&r|~t&n:e===2?(t|~r)^n:e===3?t&n|r&~n:t^(r|~n)}var ns,yi,oc,jM,KM,GM,nc,Yd,VM,sc,WM,zM,aw,YM,uw,fw,cw,lw,$M,ZM,XM,JM,ic,ac,QM,dw=Xt(()=>{g();_d();Bn();ns=Uint32Array.from([1732584193,4023233417,2562383102,271733878,3285377520]),yi=new Uint32Array(80),oc=class extends Nn{constructor(){super(64,20,8,!1);J(this,"A",ns[0]|0);J(this,"B",ns[1]|0);J(this,"C",ns[2]|0);J(this,"D",ns[3]|0);J(this,"E",ns[4]|0)}get(){let{A:r,B:n,C:i,D:o,E:s}=this;return[r,n,i,o,s]}set(r,n,i,o,s){this.A=r|0,this.B=n|0,this.C=i|0,this.D=o|0,this.E=s|0}_cloneInto(r){return(r||(r=new this.constructor)).set(...this.get()),this._cloneIntoMeta(r)}process(r,n){for(let l=0;l<16;l++,n+=4)yi[l]=r.getUint32(n,!1);for(let l=16;l<80;l++)yi[l]=Tn(yi[l-3]^yi[l-8]^yi[l-14]^yi[l-16],1);let{A:i,B:o,C:s,D:a,E:f}=this;for(let l=0;l<80;l++){let m,y;l<20?(m=Wo(o,s,a),y=1518500249):l<40?(m=o^s^a,y=1859775393):l<60?(m=kf(o,s,a),y=2400959708):(m=o^s^a,y=3395469782);let p=Tn(i,5)+m+f+y+yi[l]|0;f=a,a=s,s=Tn(o,30),o=i,i=p}i=i+this.A|0,o=o+this.B|0,s=s+this.C|0,a=a+this.D|0,f=f+this.E|0,this.set(i,o,s,a,f)}roundClean(){ir(yi)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0),ir(this.buffer)}},jM=Dr(()=>new oc),KM=Math.pow(2,32),GM=Array.from({length:64},(e,t)=>Math.floor(KM*Math.abs(Math.sin(t+1)))),nc=ns.slice(0,4),Yd=new Uint32Array(16),VM=(()=>{let e=[[7,12,17,22],[5,9,14,20],[4,11,16,23],[6,10,15,21]];return Uint8Array.from({length:64},(t,r)=>e[Math.floor(r/16)][r%4])})(),sc=class extends Nn{constructor(){super(64,16,8,!0);J(this,"A",nc[0]|0);J(this,"B",nc[1]|0);J(this,"C",nc[2]|0);J(this,"D",nc[3]|0)}get(){let{A:r,B:n,C:i,D:o}=this;return[r,n,i,o]}set(r,n,i,o){this.A=r|0,this.B=n|0,this.C=i|0,this.D=o|0}_cloneInto(r){return(r||(r=new this.constructor)).set(...this.get()),this._cloneIntoMeta(r)}process(r,n){for(let f=0;f<16;f++,n+=4)Yd[f]=r.getUint32(n,!0);let{A:i,B:o,C:s,D:a}=this;for(let f=0;f<64;f++){let l,m;f<16?(l=Wo(o,s,a),m=f):f<32?(l=Wo(a,o,s),m=(5*f+1)%16):f<48?(l=o^s^a,m=(3*f+5)%16):(l=s^(o|~a),m=7*f%16),l=l+i+GM[f]+Yd[m],i=a,a=s,s=o,o=o+Tn(l,VM[f])}i=i+this.A|0,o=o+this.B|0,s=s+this.C|0,a=a+this.D|0,this.set(i,o,s,a)}roundClean(){ir(Yd)}destroy(){this.destroyed=!0,this.set(0,0,0,0),ir(this.buffer)}},WM=Dr(()=>new sc),zM=Uint8Array.from([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),aw=Uint8Array.from(new Array(16).fill(0).map((e,t)=>t)),YM=aw.map(e=>(9*e+5)%16),uw=(()=>{let r=[[aw],[YM]];for(let n=0;n<4;n++)for(let i of r)i.push(i[n].map(o=>zM[o]));return r})(),fw=uw[0],cw=uw[1],lw=[[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(e=>Uint8Array.from(e)),$M=fw.map((e,t)=>e.map(r=>lw[t][r])),ZM=cw.map((e,t)=>e.map(r=>lw[t][r])),XM=Uint32Array.from([0,1518500249,1859775393,2400959708,2840853838]),JM=Uint32Array.from([1352829926,1548603684,1836072691,2053994217,0]);ic=new Uint32Array(16),ac=class extends Nn{constructor(){super(64,20,8,!0);J(this,"h0",1732584193);J(this,"h1",-271733879);J(this,"h2",-1732584194);J(this,"h3",271733878);J(this,"h4",-1009589776)}get(){let{h0:r,h1:n,h2:i,h3:o,h4:s}=this;return[r,n,i,o,s]}set(r,n,i,o,s){this.h0=r|0,this.h1=n|0,this.h2=i|0,this.h3=o|0,this.h4=s|0}_cloneInto(r){return(r||(r=new this.constructor)).set(...this.get()),this._cloneIntoMeta(r)}process(r,n){for(let O=0;O<16;O++,n+=4)ic[O]=r.getUint32(n,!0);let i=this.h0|0,o=i,s=this.h1|0,a=s,f=this.h2|0,l=f,m=this.h3|0,y=m,p=this.h4|0,w=p;for(let O=0;O<5;O++){let M=4-O,D=XM[O],F=JM[O],V=fw[O],Y=cw[O],Q=$M[O],ce=ZM[O];for(let ee=0;ee<16;ee++){let de=Tn(i+sw(O,s,f,m)+ic[V[ee]]+D,Q[ee])+p|0;i=p,p=m,m=Tn(f,10)|0,f=s,s=de}for(let ee=0;ee<16;ee++){let de=Tn(o+sw(M,a,l,y)+ic[Y[ee]]+F,ce[ee])+w|0;o=w,w=y,y=Tn(l,10)|0,l=a,a=de}}this.set(this.h1+f+y|0,this.h2+m+w|0,this.h3+p+o|0,this.h4+i+a|0,this.h0+s+l|0)}roundClean(){ir(ic)}destroy(){this.destroyed=!0,ir(this.buffer),this.set(0,0,0,0,0)}},QM=Dr(()=>new ac)});var gw=B((CF,pw)=>{"use strict";g();var{sha256:ek,sha512:tk}=(Sd(),gl(Z_)),{sha1:rk,ripemd160:nk}=(dw(),gl(hw)),Un=We(),Mt=pw.exports;Mt.sha1=function(e){return Un.checkArgument(d.Buffer.isBuffer(e)),d.Buffer.from(rk(e))};Mt.sha1.blocksize=512;Mt.sha256=function(e){return Un.checkArgument(d.Buffer.isBuffer(e)),d.Buffer.from(ek(e))};Mt.sha256.blocksize=512;Mt.sha256sha256=function(e){return Un.checkArgument(d.Buffer.isBuffer(e)),Mt.sha256(Mt.sha256(e))};Mt.ripemd160=function(e){return Un.checkArgument(d.Buffer.isBuffer(e)),d.Buffer.from(nk(e))};Mt.sha256ripemd160=function(e){return Un.checkArgument(d.Buffer.isBuffer(e)),Mt.ripemd160(Mt.sha256(e))};Mt.sha512=function(e){return Un.checkArgument(d.Buffer.isBuffer(e)),d.Buffer.from(tk(e))};Mt.sha512.blocksize=1024;Mt.hmac=function(e,t,r){Un.checkArgument(d.Buffer.isBuffer(t)),Un.checkArgument(d.Buffer.isBuffer(r)),Un.checkArgument(e.blocksize);var n=e.blocksize/8;if(r.length>n)r=e(r);else if(r.length<n){var i=d.Buffer.alloc(n);i.fill(0),r.copy(i),r=i}var o=d.Buffer.alloc(n);o.fill(92);var s=d.Buffer.alloc(n);s.fill(54);for(var a=d.Buffer.alloc(n),f=d.Buffer.alloc(n),l=0;l<n;l++)a[l]=o[l]^r[l],f[l]=s[l]^r[l];return e(d.Buffer.concat([a,e(d.Buffer.concat([f,t]))]))};Mt.sha256hmac=function(e,t){return Mt.hmac(Mt.sha256,e,t)};Mt.sha512hmac=function(e,t){return Mt.hmac(Mt.sha512,e,t)}});var nr=B((DF,mw)=>{"use strict";g();var yw={sha1:"a9993e364706816aba3e25717850c26c9cd0d89d",sha256:"ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad",sha512:"ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f",ripemd160:"8eb208f7e05d987a9b044a8e98c6b087f15a0bfc"};function ik(){var e;try{e=oa()}catch{return!1}if(!e||typeof e.createHash!="function")return!1;for(var t=Object.keys(yw),r=0;r<t.length;r++){var n=t[r];try{if(e.createHash(n).update("abc").digest("hex")!==yw[n])return!1}catch{return!1}}return!0}mw.exports=ik()?ow():gw()});var vr=B((FF,_w)=>{"use strict";g();var bw=at(),ok=We(),vw=function(t){return bw.isString(t)?/^[0-9a-fA-F]+$/.test(t):!1};_w.exports={isValidJSON:function(t){var r;if(!bw.isString(t))return!1;try{r=JSON.parse(t)}catch{return!1}return typeof r=="object"},isHexa:vw,isHexaString:vw,defineImmutable:function(t,r){return Object.keys(r).forEach(function(n){Object.defineProperty(t,n,{configurable:!1,enumerable:!0,value:r[n]})}),t},isNaturalNumber:function(t){return typeof t=="number"&&isFinite(t)&&Math.floor(t)===t&&t>=0},integerAsBuffer:function(t){ok.checkArgumentType(t,"number","integer");let r=d.Buffer.allocUnsafe(4);return r.writeUInt32BE(t,0),r}}});var Ea=B((HF,Ew)=>{"use strict";g();var Fn=at(),ba=vr(),no=[],_a={};function Sw(){}Sw.prototype.toString=function(){return this.name};function Sa(e,t){if(~no.indexOf(e))return e;if(t){Fn.isArray(t)||(t=[t]);for(var r=0;r<no.length;r++){var n=no[r],i=Fn.pick(n,t),o=Fn.values(i);if(~o.indexOf(e))return n}return}return _a[e]}function uc(e){for(var t=[],r=0;r<e.length;r++)t.push(e.charCodeAt(r)&31);return t}function wa(e){var t=new Sw;ba.defineImmutable(t,{name:e.name,alias:e.alias,pubkeyhash:e.pubkeyhash,privatekey:e.privatekey,scripthash:e.scripthash,xpubkey:e.xpubkey,xprivkey:e.xprivkey});var r=e.indexBy||Object.keys(e);return e.cashAddrPrefix&&Fn.extend(t,{cashAddrPrefix:e.cashAddrPrefix,cashAddrPrefixArray:uc(e.cashAddrPrefix)}),e.networkMagic&&Fn.extend(t,{networkMagic:ba.integerAsBuffer(e.networkMagic)}),e.port&&Fn.extend(t,{port:e.port}),e.dnsSeeds&&Fn.extend(t,{dnsSeeds:e.dnsSeeds}),no.push(t),sk(t,r),t}function sk(e,t){for(var r=0;r<t.length;r++){var n=t[r],i=e[n];!Fn.isUndefined(i)&&!Fn.isObject(i)&&(_a[i]=e)}}function ak(e,t){for(var r=0;r<t.length;r++){var n=t[r];_a[n]===e&&delete _a[n]}}function uk(e){for(var t=0;t<no.length;t++)no[t]===e&&no.splice(t,1);ak(e,Object.keys(_a))}var fc={livenet:3823236072,testnet:4108710900,regtest:3669344250,stn:4224632057},ww=["seed.bitcoinsv.org","seed.bitcoinunlimited.info"],mi={PORT:18333,NETWORK_MAGIC:fc.testnet,DNS_SEEDS:ww,PREFIX:"testnet",CASHADDRPREFIX:"bchtest"},qn={PORT:18444,NETWORK_MAGIC:fc.regtest,DNS_SEEDS:[],PREFIX:"regtest",CASHADDRPREFIX:"bchreg"},vi={PORT:9333,NETWORK_MAGIC:fc.stn,DNS_SEEDS:["stn-seed.bitcoinsv.io"],PREFIX:"stn",CASHADDRPREFIX:"bsvstn"},fk={name:"livenet",alias:"mainnet",prefix:"bitcoin",cashAddrPrefix:"bitcoincash",pubkeyhash:0,privatekey:128,scripthash:5,xpubkey:76067358,xprivkey:76066276,networkMagic:fc.livenet,port:8333,dnsSeeds:ww},ck={name:"testnet",prefix:mi.PREFIX,cashAddrPrefix:mi.CASHADDRPREFIX,pubkeyhash:111,privatekey:239,scripthash:196,xpubkey:70617039,xprivkey:70615956,networkMagic:mi.NETWORK_MAGIC},lk={name:"regtest",prefix:qn.PREFIX,cashAddrPrefix:qn.CASHADDRPREFIX,pubkeyhash:111,privatekey:239,scripthash:196,xpubkey:70617039,xprivkey:70615956,networkMagic:qn.NETWORK_MAGIC,port:qn.PORT,dnsSeeds:[],indexBy:["port","name","cashAddrPrefix","networkMagic"]},hk={name:"stn",prefix:vi.PREFIX,cashAddrPrefix:vi.CASHADDRPREFIX,pubkeyhash:111,privatekey:239,scripthash:196,xpubkey:70617039,xprivkey:70615956,networkMagic:vi.NETWORK_MAGIC,indexBy:["port","name","cashAddrPrefix","networkMagic"]};wa(ck);wa(hk);wa(lk);wa(fk);var $d=Sa("livenet"),dk=Sa("regtest"),pn=Sa("testnet"),pk=Sa("stn");Object.defineProperty(pn,"port",{enumerable:!0,configurable:!1,get:function(){return this.regtestEnabled?qn.PORT:this.stnEnabled?vi.PORT:mi.PORT}});Object.defineProperty(pn,"networkMagic",{enumerable:!0,configurable:!1,get:function(){return this.regtestEnabled?ba.integerAsBuffer(qn.NETWORK_MAGIC):this.stnEnabled?ba.integerAsBuffer(vi.NETWORK_MAGIC):ba.integerAsBuffer(mi.NETWORK_MAGIC)}});Object.defineProperty(pn,"dnsSeeds",{enumerable:!0,configurable:!1,get:function(){return this.regtestEnabled?qn.DNS_SEEDS:this.stnEnabled?vi.DNS_SEEDS:mi.DNS_SEEDS}});Object.defineProperty(pn,"cashAddrPrefix",{enumerable:!0,configurable:!1,get:function(){return this.regtestEnabled?qn.CASHADDRPREFIX:this.stnEnabled?vi.CASHADDRPREFIX:mi.CASHADDRPREFIX}});Object.defineProperty(pn,"cashAddrPrefixArray",{enumerable:!0,configurable:!1,get:function(){return this.regtestEnabled?uc(qn.CASHADDRPREFIX):this.stnEnabled?uc(vi.CASHADDRPREFIX):uc(mi.CASHADDRPREFIX)}});function gk(){pn.regtestEnabled=!0}function yk(){pn.regtestEnabled=!1}function mk(){pn.stnEnabled=!0}function vk(){pn.stnEnabled=!1}Ew.exports={add:wa,remove:uk,defaultNetwork:$d,livenet:$d,mainnet:$d,testnet:pn,regtest:dk,stn:pk,get:Sa,enableRegtest:gk,disableRegtest:yk,enableStn:mk,disableStn:vk}});var Ow=B((KF,Aw)=>{"use strict";g();var Zd=at(),xw=Lt(),is="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz".split(""),Iw={};for(xa=0;xa<is.length;xa++)Iw[is[xa]]=xa;var xa;function bk(e){if(e.length===0)return"";var t=[0],r,n,i;for(r=0;r<e.length;r++){for(n=0,i=e[r];n<t.length;n++)i+=t[n]<<8,t[n]=i%58,i=i/58|0;for(;i>0;)t.push(i%58),i=i/58|0}var o="";for(r=0;e[r]===0&&r<e.length-1;r++)o+=is[0];for(r=t.length-1;r>=0;r--)o+=is[t[r]];return o}function _k(e){if(e.length===0)return d.Buffer.alloc(0);var t=[0],r,n,i;for(r=0;r<e.length;r++){var o=Iw[e[r]];if(o===void 0)throw new Error("Non-base58 character");for(n=0,i=o;n<t.length;n++)i+=t[n]*58,t[n]=i&255,i>>=8;for(;i>0;)t.push(i&255),i>>=8}for(r=0;e[r]===is[0]&&r<e.length-1;r++)t.push(0);return d.Buffer.from(t.reverse())}var Vt=function e(t){if(!(this instanceof e))return new e(t);if(d.Buffer.isBuffer(t)){var r=t;this.fromBuffer(r)}else if(typeof t=="string"){var n=t;this.fromString(n)}};Vt.validCharacters=function(t){return xw.Buffer.isBuffer(t)&&(t=t.toString()),Zd.every(Zd.map(t,function(r){return Zd.includes(is,r)}))};Vt.prototype.set=function(e){return this.buf=e.buf||this.buf||void 0,this};Vt.encode=function(e){if(!xw.Buffer.isBuffer(e))throw new Error("Input should be a buffer");return bk(e)};Vt.decode=function(e){if(typeof e!="string")throw new Error("Input should be a string");return _k(e)};Vt.prototype.fromBuffer=function(e){return this.buf=e,this};Vt.fromBuffer=function(e){return new Vt().fromBuffer(e)};Vt.fromHex=function(e){return Vt.fromBuffer(d.Buffer.from(e,"hex"))};Vt.prototype.fromString=function(e){var t=Vt.decode(e);return this.buf=t,this};Vt.fromString=function(e){return new Vt().fromString(e)};Vt.prototype.toBuffer=function(){return this.buf};Vt.prototype.toHex=function(){return this.toBuffer().toString("hex")};Vt.prototype.toString=function(){return Vt.encode(this.buf)};Aw.exports=Vt});var Xd=B((VF,Bw)=>{"use strict";g();var Rw=at(),cc=Ow(),Tw=Lt(),Pw=nr().sha256sha256,gt=function e(t){if(!(this instanceof e))return new e(t);if(d.Buffer.isBuffer(t)){var r=t;this.fromBuffer(r)}else if(typeof t=="string"){var n=t;this.fromString(n)}};gt.prototype.set=function(e){return this.buf=e.buf||this.buf||void 0,this};gt.validChecksum=function(t,r){return Rw.isString(t)&&(t=Tw.Buffer.from(cc.decode(t))),Rw.isString(r)&&(r=Tw.Buffer.from(cc.decode(r))),r||(r=t.slice(-4),t=t.slice(0,-4)),gt.checksum(t).toString("hex")===r.toString("hex")};gt.decode=function(e){if(typeof e!="string")throw new Error("Input must be a string");var t=d.Buffer.from(cc.decode(e));if(t.length<4)throw new Error("Input string too short");var r=t.slice(0,-4),n=t.slice(-4),i=Pw(r),o=i.slice(0,4);if(n.toString("hex")!==o.toString("hex"))throw new Error("Checksum mismatch");return r};gt.checksum=function(e){return Pw(e).slice(0,4)};gt.encode=function(e){if(!d.Buffer.isBuffer(e))throw new Error("Input must be a buffer");var t=d.Buffer.alloc(e.length+4),r=gt.checksum(e);return e.copy(t),r.copy(t,e.length),cc.encode(t)};gt.prototype.fromBuffer=function(e){return this.buf=e,this};gt.fromBuffer=function(e){return new gt().fromBuffer(e)};gt.fromHex=function(e){return gt.fromBuffer(d.Buffer.from(e,"hex"))};gt.prototype.fromString=function(e){var t=gt.decode(e);return this.buf=t,this};gt.fromString=function(e){var t=gt.decode(e);return new gt(t)};gt.prototype.toBuffer=function(){return this.buf};gt.prototype.toHex=function(){return this.toBuffer().toString("hex")};gt.prototype.toString=function(){return gt.encode(this.buf)};Bw.exports=gt});var ep=B((zF,Cw)=>{"use strict";g();function bi(e){"@babel/helpers - typeof";return bi=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},bi(e)}function Nw(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,wk(n.key),n)}}function Sk(e,t,r){return t&&Nw(e.prototype,t),r&&Nw(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function wk(e){var t=Ek(e,"string");return bi(t)==="symbol"?t:String(t)}function Ek(e,t){if(bi(e)!=="object"||e===null)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t||"default");if(bi(n)!=="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function xk(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Ik(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&Qd(e,t)}function Qd(e,t){return Qd=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,i){return n.__proto__=i,n},Qd(e,t)}function Ak(e){var t=Tk();return function(){var n=lc(e),i;if(t){var o=lc(this).constructor;i=Reflect.construct(n,arguments,o)}else i=n.apply(this,arguments);return Ok(this,i)}}function Ok(e,t){if(t&&(bi(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Rk(e)}function Rk(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Tk(){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 lc(e){return lc=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},lc(e)}var kw={},os,Jd;function Ia(e,t,r){r||(r=Error);function n(o,s,a){return typeof t=="string"?t:t(o,s,a)}var i=(function(o){Ik(a,o);var s=Ak(a);function a(f,l,m){var y;return xk(this,a),y=s.call(this,n(f,l,m)),y.code=e,y}return Sk(a)})(r);kw[e]=i}function Mw(e,t){if(Array.isArray(e)){var r=e.length;return e=e.map(function(n){return String(n)}),r>2?"one of ".concat(t," ").concat(e.slice(0,r-1).join(", "),", or ")+e[r-1]:r===2?"one of ".concat(t," ").concat(e[0]," or ").concat(e[1]):"of ".concat(t," ").concat(e[0])}else return"of ".concat(t," ").concat(String(e))}function Pk(e,t,r){return e.substr(!r||r<0?0:+r,t.length)===t}function Bk(e,t,r){return(r===void 0||r>e.length)&&(r=e.length),e.substring(r-t.length,r)===t}function Nk(e,t,r){return typeof r!="number"&&(r=0),r+t.length>e.length?!1:e.indexOf(t,r)!==-1}Ia("ERR_AMBIGUOUS_ARGUMENT",'The "%s" argument is ambiguous. %s',TypeError);Ia("ERR_INVALID_ARG_TYPE",function(e,t,r){os===void 0&&(os=Aa()),os(typeof e=="string","'name' must be a string");var n;typeof t=="string"&&Pk(t,"not ")?(n="must not be",t=t.replace(/^not /,"")):n="must be";var i;if(Bk(e," argument"))i="The ".concat(e," ").concat(n," ").concat(Mw(t,"type"));else{var o=Nk(e,".")?"property":"argument";i='The "'.concat(e,'" ').concat(o," ").concat(n," ").concat(Mw(t,"type"))}return i+=". Received type ".concat(bi(r)),i},TypeError);Ia("ERR_INVALID_ARG_VALUE",function(e,t){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"is invalid";Jd===void 0&&(Jd=rn());var n=Jd.inspect(t);return n.length>128&&(n="".concat(n.slice(0,128),"...")),"The argument '".concat(e,"' ").concat(r,". Received ").concat(n)},TypeError,RangeError);Ia("ERR_INVALID_RETURN_VALUE",function(e,t,r){var n;return r&&r.constructor&&r.constructor.name?n="instance of ".concat(r.constructor.name):n="type ".concat(bi(r)),"Expected ".concat(e,' to be returned from the "').concat(t,'"')+" function but got ".concat(n,".")},TypeError);Ia("ERR_MISSING_ARGS",function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];os===void 0&&(os=Aa()),os(t.length>0,"At least one arg needs to be specified");var n="The ",i=t.length;switch(t=t.map(function(o){return'"'.concat(o,'"')}),i){case 1:n+="".concat(t[0]," argument");break;case 2:n+="".concat(t[0]," and ").concat(t[1]," arguments");break;default:n+=t.slice(0,i-1).join(", "),n+=", and ".concat(t[i-1]," arguments");break}return"".concat(n," must be specified")},TypeError);Cw.exports.codes=kw});var Vw=B(($F,Gw)=>{"use strict";g();function Lw(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function Dw(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?Lw(Object(r),!0).forEach(function(n){Mk(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Lw(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function Mk(e,t,r){return t=Hw(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function kk(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Uw(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,Hw(n.key),n)}}function Ck(e,t,r){return t&&Uw(e.prototype,t),r&&Uw(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function Hw(e){var t=Lk(e,"string");return hr(t)==="symbol"?t:String(t)}function Lk(e,t){if(hr(e)!=="object"||e===null)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t||"default");if(hr(n)!=="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function Dk(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&Pa(e,t)}function Uk(e){var t=Kw();return function(){var n=Ba(e),i;if(t){var o=Ba(this).constructor;i=Reflect.construct(n,arguments,o)}else i=n.apply(this,arguments);return jw(this,i)}}function jw(e,t){if(t&&(hr(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return tp(e)}function tp(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function rp(e){var t=typeof Map=="function"?new Map:void 0;return rp=function(n){if(n===null||!Fk(n))return n;if(typeof n!="function")throw new TypeError("Super expression must either be null or a function");if(typeof t<"u"){if(t.has(n))return t.get(n);t.set(n,i)}function i(){return hc(n,arguments,Ba(this).constructor)}return i.prototype=Object.create(n.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),Pa(i,n)},rp(e)}function hc(e,t,r){return Kw()?hc=Reflect.construct.bind():hc=function(i,o,s){var a=[null];a.push.apply(a,o);var f=Function.bind.apply(i,a),l=new f;return s&&Pa(l,s.prototype),l},hc.apply(null,arguments)}function Kw(){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 Fk(e){return Function.toString.call(e).indexOf("[native code]")!==-1}function Pa(e,t){return Pa=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,i){return n.__proto__=i,n},Pa(e,t)}function Ba(e){return Ba=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},Ba(e)}function hr(e){"@babel/helpers - typeof";return hr=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},hr(e)}var qk=rn(),np=qk.inspect,Hk=ep(),jk=Hk.codes.ERR_INVALID_ARG_TYPE;function Fw(e,t,r){return(r===void 0||r>e.length)&&(r=e.length),e.substring(r-t.length,r)===t}function Kk(e,t){if(t=Math.floor(t),e.length==0||t==0)return"";var r=e.length*t;for(t=Math.floor(Math.log(t)/Math.log(2));t;)e+=e,t--;return e+=e.substring(0,r-e.length),e}var Fr="",Oa="",Ra="",$t="",io={deepStrictEqual:"Expected values to be strictly deep-equal:",strictEqual:"Expected values to be strictly equal:",strictEqualObject:'Expected "actual" to be reference-equal to "expected":',deepEqual:"Expected values to be loosely deep-equal:",equal:"Expected values to be loosely equal:",notDeepStrictEqual:'Expected "actual" not to be strictly deep-equal to:',notStrictEqual:'Expected "actual" to be strictly unequal to:',notStrictEqualObject:'Expected "actual" not to be reference-equal to "expected":',notDeepEqual:'Expected "actual" not to be loosely deep-equal to:',notEqual:'Expected "actual" to be loosely unequal to:',notIdentical:"Values identical but not reference-equal:"},Gk=10;function qw(e){var t=Object.keys(e),r=Object.create(Object.getPrototypeOf(e));return t.forEach(function(n){r[n]=e[n]}),Object.defineProperty(r,"message",{value:e.message}),r}function Ta(e){return np(e,{compact:!1,customInspect:!1,depth:1e3,maxArrayLength:1/0,showHidden:!1,breakLength:1/0,showProxy:!1,sorted:!0,getters:!0})}function Vk(e,t,r){var n="",i="",o=0,s="",a=!1,f=Ta(e),l=f.split(`
14
+ `),m=Ta(t).split(`
15
+ `),y=0,p="";if(r==="strictEqual"&&hr(e)==="object"&&hr(t)==="object"&&e!==null&&t!==null&&(r="strictEqualObject"),l.length===1&&m.length===1&&l[0]!==m[0]){var w=l[0].length+m[0].length;if(w<=Gk){if((hr(e)!=="object"||e===null)&&(hr(t)!=="object"||t===null)&&(e!==0||t!==0))return"".concat(io[r],`
16
16
 
17
- `)+"".concat(l[0]," !== ").concat(y[0],`
18
- `)}else if(r!=="strictEqualObject"){var T=x.default.stderr&&x.default.stderr.isTTY?x.default.stderr.columns:80;if(E<T){for(;l[0][g]===y[0][g];)g++;g>2&&(v=`
19
- `.concat(Hk(" ",g),"^"),g=0)}}}for(var M=l[l.length-1],L=y[y.length-1];M===L&&(g++<2?s=`
20
- `.concat(M).concat(s):n=M,l.pop(),y.pop(),!(l.length===0||y.length===0));)M=l[l.length-1],L=y[y.length-1];var F=Math.max(l.length,y.length);if(F===0){var V=f.split(`
21
- `);if(V.length>30)for(V[26]="".concat(Lr,"...").concat(zt);V.length>27;)V.pop();return"".concat(eo.notIdentical,`
17
+ `)+"".concat(l[0]," !== ").concat(m[0],`
18
+ `)}else if(r!=="strictEqualObject"){var O=x.default.stderr&&x.default.stderr.isTTY?x.default.stderr.columns:80;if(w<O){for(;l[0][y]===m[0][y];)y++;y>2&&(p=`
19
+ `.concat(Kk(" ",y),"^"),y=0)}}}for(var M=l[l.length-1],D=m[m.length-1];M===D&&(y++<2?s=`
20
+ `.concat(M).concat(s):n=M,l.pop(),m.pop(),!(l.length===0||m.length===0));)M=l[l.length-1],D=m[m.length-1];var F=Math.max(l.length,m.length);if(F===0){var V=f.split(`
21
+ `);if(V.length>30)for(V[26]="".concat(Fr,"...").concat($t);V.length>27;)V.pop();return"".concat(io.notIdentical,`
22
22
 
23
23
  `).concat(V.join(`
24
24
  `),`
25
- `)}g>3&&(s=`
26
- `.concat(Lr,"...").concat(zt).concat(s),a=!0),n!==""&&(s=`
27
- `.concat(n).concat(s),n="");var z=0,G=eo[r]+`
28
- `.concat(wa,"+ actual").concat(zt," ").concat(Ea,"- expected").concat(zt),ie=" ".concat(Lr,"...").concat(zt," Lines skipped");for(g=0;g<F;g++){var te=g-o;if(l.length<g+1)te>1&&g>2&&(te>4?(i+=`
29
- `.concat(Lr,"...").concat(zt),a=!0):te>3&&(i+=`
30
- `.concat(y[g-2]),z++),i+=`
31
- `.concat(y[g-1]),z++),o=g,n+=`
32
- `.concat(Ea,"-").concat(zt," ").concat(y[g]),z++;else if(y.length<g+1)te>1&&g>2&&(te>4?(i+=`
33
- `.concat(Lr,"...").concat(zt),a=!0):te>3&&(i+=`
34
- `.concat(l[g-2]),z++),i+=`
35
- `.concat(l[g-1]),z++),o=g,i+=`
36
- `.concat(wa,"+").concat(zt," ").concat(l[g]),z++;else{var pe=y[g],fe=l[g],ye=fe!==pe&&(!Dw(fe,",")||fe.slice(0,-1)!==pe);ye&&Dw(pe,",")&&pe.slice(0,-1)===fe&&(ye=!1,fe+=","),ye?(te>1&&g>2&&(te>4?(i+=`
37
- `.concat(Lr,"...").concat(zt),a=!0):te>3&&(i+=`
38
- `.concat(l[g-2]),z++),i+=`
39
- `.concat(l[g-1]),z++),o=g,i+=`
40
- `.concat(wa,"+").concat(zt," ").concat(fe),n+=`
41
- `.concat(Ea,"-").concat(zt," ").concat(pe),z+=2):(i+=n,n="",(te===1||g===0)&&(i+=`
42
- `.concat(fe),z++))}if(z>20&&g<F-2)return"".concat(G).concat(ie,`
25
+ `)}y>3&&(s=`
26
+ `.concat(Fr,"...").concat($t).concat(s),a=!0),n!==""&&(s=`
27
+ `.concat(n).concat(s),n="");var Y=0,Q=io[r]+`
28
+ `.concat(Oa,"+ actual").concat($t," ").concat(Ra,"- expected").concat($t),ce=" ".concat(Fr,"...").concat($t," Lines skipped");for(y=0;y<F;y++){var ee=y-o;if(l.length<y+1)ee>1&&y>2&&(ee>4?(i+=`
29
+ `.concat(Fr,"...").concat($t),a=!0):ee>3&&(i+=`
30
+ `.concat(m[y-2]),Y++),i+=`
31
+ `.concat(m[y-1]),Y++),o=y,n+=`
32
+ `.concat(Ra,"-").concat($t," ").concat(m[y]),Y++;else if(m.length<y+1)ee>1&&y>2&&(ee>4?(i+=`
33
+ `.concat(Fr,"...").concat($t),a=!0):ee>3&&(i+=`
34
+ `.concat(l[y-2]),Y++),i+=`
35
+ `.concat(l[y-1]),Y++),o=y,i+=`
36
+ `.concat(Oa,"+").concat($t," ").concat(l[y]),Y++;else{var de=m[y],pe=l[y],xe=pe!==de&&(!Fw(pe,",")||pe.slice(0,-1)!==de);xe&&Fw(de,",")&&de.slice(0,-1)===pe&&(xe=!1,pe+=","),xe?(ee>1&&y>2&&(ee>4?(i+=`
37
+ `.concat(Fr,"...").concat($t),a=!0):ee>3&&(i+=`
38
+ `.concat(l[y-2]),Y++),i+=`
39
+ `.concat(l[y-1]),Y++),o=y,i+=`
40
+ `.concat(Oa,"+").concat($t," ").concat(pe),n+=`
41
+ `.concat(Ra,"-").concat($t," ").concat(de),Y+=2):(i+=n,n="",(ee===1||y===0)&&(i+=`
42
+ `.concat(pe),Y++))}if(Y>20&&y<F-2)return"".concat(Q).concat(ce,`
43
43
  `).concat(i,`
44
- `).concat(Lr,"...").concat(zt).concat(n,`
45
- `)+"".concat(Lr,"...").concat(zt)}return"".concat(G).concat(a?ie:"",`
46
- `).concat(i).concat(n).concat(s).concat(v)}var Gk=(function(e,t){Ck(n,e);var r=Lk(n);function n(i){var o;if(Nk(this,n),fr(i)!=="object"||i===null)throw new qk("options","Object",i);var s=i.message,a=i.operator,f=i.stackStartFn,l=i.actual,y=i.expected,g=Error.stackTraceLimit;if(Error.stackTraceLimit=0,s!=null)o=r.call(this,String(s));else if(x.default.stderr&&x.default.stderr.isTTY&&(x.default.stderr&&x.default.stderr.getColorDepth&&x.default.stderr.getColorDepth()!==1?(Lr="\x1B[34m",wa="\x1B[32m",zt="\x1B[39m",Ea="\x1B[31m"):(Lr="",wa="",zt="",Ea="")),fr(l)==="object"&&l!==null&&fr(y)==="object"&&y!==null&&"stack"in l&&l instanceof Error&&"stack"in y&&y instanceof Error&&(l=Uw(l),y=Uw(y)),a==="deepStrictEqual"||a==="strictEqual")o=r.call(this,Kk(l,y,a));else if(a==="notDeepStrictEqual"||a==="notStrictEqual"){var v=eo[a],E=xa(l).split(`
47
- `);if(a==="notStrictEqual"&&fr(l)==="object"&&l!==null&&(v=eo.notStrictEqualObject),E.length>30)for(E[26]="".concat(Lr,"...").concat(zt);E.length>27;)E.pop();E.length===1?o=r.call(this,"".concat(v," ").concat(E[0])):o=r.call(this,"".concat(v,`
44
+ `).concat(Fr,"...").concat($t).concat(n,`
45
+ `)+"".concat(Fr,"...").concat($t)}return"".concat(Q).concat(a?ce:"",`
46
+ `).concat(i).concat(n).concat(s).concat(p)}var Wk=(function(e,t){Dk(n,e);var r=Uk(n);function n(i){var o;if(kk(this,n),hr(i)!=="object"||i===null)throw new jk("options","Object",i);var s=i.message,a=i.operator,f=i.stackStartFn,l=i.actual,m=i.expected,y=Error.stackTraceLimit;if(Error.stackTraceLimit=0,s!=null)o=r.call(this,String(s));else if(x.default.stderr&&x.default.stderr.isTTY&&(x.default.stderr&&x.default.stderr.getColorDepth&&x.default.stderr.getColorDepth()!==1?(Fr="\x1B[34m",Oa="\x1B[32m",$t="\x1B[39m",Ra="\x1B[31m"):(Fr="",Oa="",$t="",Ra="")),hr(l)==="object"&&l!==null&&hr(m)==="object"&&m!==null&&"stack"in l&&l instanceof Error&&"stack"in m&&m instanceof Error&&(l=qw(l),m=qw(m)),a==="deepStrictEqual"||a==="strictEqual")o=r.call(this,Vk(l,m,a));else if(a==="notDeepStrictEqual"||a==="notStrictEqual"){var p=io[a],w=Ta(l).split(`
47
+ `);if(a==="notStrictEqual"&&hr(l)==="object"&&l!==null&&(p=io.notStrictEqualObject),w.length>30)for(w[26]="".concat(Fr,"...").concat($t);w.length>27;)w.pop();w.length===1?o=r.call(this,"".concat(p," ").concat(w[0])):o=r.call(this,"".concat(p,`
48
48
 
49
- `).concat(E.join(`
49
+ `).concat(w.join(`
50
50
  `),`
51
- `))}else{var T=xa(l),M="",L=eo[a];a==="notDeepEqual"||a==="notEqual"?(T="".concat(eo[a],`
51
+ `))}else{var O=Ta(l),M="",D=io[a];a==="notDeepEqual"||a==="notEqual"?(O="".concat(io[a],`
52
52
 
53
- `).concat(T),T.length>1024&&(T="".concat(T.slice(0,1021),"..."))):(M="".concat(xa(y)),T.length>512&&(T="".concat(T.slice(0,509),"...")),M.length>512&&(M="".concat(M.slice(0,509),"...")),a==="deepEqual"||a==="equal"?T="".concat(L,`
53
+ `).concat(O),O.length>1024&&(O="".concat(O.slice(0,1021),"..."))):(M="".concat(Ta(m)),O.length>512&&(O="".concat(O.slice(0,509),"...")),M.length>512&&(M="".concat(M.slice(0,509),"...")),a==="deepEqual"||a==="equal"?O="".concat(D,`
54
54
 
55
- `).concat(T,`
55
+ `).concat(O,`
56
56
 
57
57
  should equal
58
58
 
59
- `):M=" ".concat(a," ").concat(M)),o=r.call(this,"".concat(T).concat(M))}return Error.stackTraceLimit=g,o.generatedMessage=!s,Object.defineProperty(Zd(o),"name",{value:"AssertionError [ERR_ASSERTION]",enumerable:!1,writable:!0,configurable:!0}),o.code="ERR_ASSERTION",o.actual=l,o.expected=y,o.operator=a,Error.captureStackTrace&&Error.captureStackTrace(Zd(o),f),o.stack,o.name="AssertionError",qw(o)}return Mk(n,[{key:"toString",value:function(){return"".concat(this.name," [").concat(this.code,"]: ").concat(this.message)}},{key:t,value:function(o,s){return Jd(this,Cw(Cw({},s),{},{customInspect:!1,depth:0}))}}]),n})(Xd(Error),Jd.custom);jw.exports=Gk});var Qd=B((zF,Vw)=>{"use strict";p();var Gw=Object.prototype.toString;Vw.exports=function(t){var r=Gw.call(t),n=r==="[object Arguments]";return n||(n=r!=="[object Array]"&&t!==null&&typeof t=="object"&&typeof t.length=="number"&&t.length>=0&&Gw.call(t.callee)==="[object Function]"),n}});var eE=B(($F,Qw)=>{"use strict";p();var Jw;Object.keys||(Oa=Object.prototype.hasOwnProperty,ep=Object.prototype.toString,Ww=Qd(),tp=Object.prototype.propertyIsEnumerable,zw=!tp.call({toString:null},"toString"),Yw=tp.call(function(){},"prototype"),Ra=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],uc=function(e){var t=e.constructor;return t&&t.prototype===e},$w={$applicationCache:!0,$console:!0,$external:!0,$frame:!0,$frameElement:!0,$frames:!0,$innerHeight:!0,$innerWidth:!0,$onmozfullscreenchange:!0,$onmozfullscreenerror:!0,$outerHeight:!0,$outerWidth:!0,$pageXOffset:!0,$pageYOffset:!0,$parent:!0,$scrollLeft:!0,$scrollTop:!0,$scrollX:!0,$scrollY:!0,$self:!0,$webkitIndexedDB:!0,$webkitStorageInfo:!0,$window:!0},Zw=(function(){if(typeof window>"u")return!1;for(var e in window)try{if(!$w["$"+e]&&Oa.call(window,e)&&window[e]!==null&&typeof window[e]=="object")try{uc(window[e])}catch{return!0}}catch{return!0}return!1})(),Xw=function(e){if(typeof window>"u"||!Zw)return uc(e);try{return uc(e)}catch{return!1}},Jw=function(t){var r=t!==null&&typeof t=="object",n=ep.call(t)==="[object Function]",i=Ww(t),o=r&&ep.call(t)==="[object String]",s=[];if(!r&&!n&&!i)throw new TypeError("Object.keys called on a non-object");var a=Yw&&n;if(o&&t.length>0&&!Oa.call(t,0))for(var f=0;f<t.length;++f)s.push(String(f));if(i&&t.length>0)for(var l=0;l<t.length;++l)s.push(String(l));else for(var y in t)!(a&&y==="prototype")&&Oa.call(t,y)&&s.push(String(y));if(zw)for(var g=Xw(t),v=0;v<Ra.length;++v)!(g&&Ra[v]==="constructor")&&Oa.call(t,Ra[v])&&s.push(Ra[v]);return s});var Oa,ep,Ww,tp,zw,Yw,Ra,uc,$w,Zw,Xw;Qw.exports=Jw});var rp=B((XF,nE)=>{"use strict";p();var Vk=Array.prototype.slice,Wk=Qd(),tE=Object.keys,fc=tE?function(t){return tE(t)}:eE(),rE=Object.keys;fc.shim=function(){if(Object.keys){var t=(function(){var r=Object.keys(arguments);return r&&r.length===arguments.length})(1,2);t||(Object.keys=function(n){return Wk(n)?rE(Vk.call(n)):rE(n)})}else Object.keys=fc;return Object.keys||fc};nE.exports=fc});var uE=B((QF,aE)=>{"use strict";p();var zk=rp(),oE=ou()(),sE=Vn(),cc=su(),Yk=sE("Array.prototype.push"),iE=sE("Object.prototype.propertyIsEnumerable"),$k=oE?cc.getOwnPropertySymbols:null;aE.exports=function(t,r){if(t==null)throw new TypeError("target must be an object");var n=cc(t);if(arguments.length===1)return n;for(var i=1;i<arguments.length;++i){var o=cc(arguments[i]),s=zk(o),a=oE&&(cc.getOwnPropertySymbols||$k);if(a)for(var f=a(o),l=0;l<f.length;++l){var y=f[l];iE(o,y)&&Yk(s,y)}for(var g=0;g<s.length;++g){var v=s[g];if(iE(o,v)){var E=o[v];n[v]=E}}}return n}});var cE=B((t5,fE)=>{"use strict";p();var np=uE(),Zk=function(){if(!Object.assign)return!1;for(var e="abcdefghijklmnopqrst",t=e.split(""),r={},n=0;n<t.length;++n)r[t[n]]=t[n];var i=Object.assign({},r),o="";for(var s in i)o+=s;return e!==o},Xk=function(){if(!Object.assign||!Object.preventExtensions)return!1;var e=Object.preventExtensions({1:2});try{Object.assign(e,"xy")}catch{return e[1]==="y"}return!1};fE.exports=function(){return!Object.assign||Zk()||Xk()?np:Object.assign}});var ip=B((n5,hE)=>{"use strict";p();var lE=function(e){return e!==e};hE.exports=function(t,r){return t===0&&r===0?1/t===1/r:!!(t===r||lE(t)&&lE(r))}});var lc=B((o5,dE)=>{"use strict";p();var Jk=ip();dE.exports=function(){return typeof Object.is=="function"?Object.is:Jk}});var mE=B((a5,yE)=>{"use strict";p();var pE=gu(),gE=Es(),Qk=gE(pE("String.prototype.indexOf"));yE.exports=function(t,r){var n=pE(t,!!r);return typeof n=="function"&&Qk(t,".prototype.")>-1?gE(n):n}});var Ta=B((f5,SE)=>{"use strict";p();var e3=rp(),t3=typeof Symbol=="function"&&typeof Symbol("foo")=="symbol",r3=Object.prototype.toString,n3=Array.prototype.concat,vE=Vl(),i3=function(e){return typeof e=="function"&&r3.call(e)==="[object Function]"},bE=zl()(),o3=function(e,t,r,n){if(t in e){if(n===!0){if(e[t]===r)return}else if(!i3(n)||!n())return}bE?vE(e,t,r,!0):vE(e,t,r)},_E=function(e,t){var r=arguments.length>2?arguments[2]:{},n=e3(t);t3&&(n=n3.call(n,Object.getOwnPropertySymbols(t)));for(var i=0;i<n.length;i+=1)o3(e,n[i],t[n[i]],r[n[i]])};_E.supportsDescriptors=!!bE;SE.exports=_E});var EE=B((l5,wE)=>{"use strict";p();var s3=lc(),a3=Ta();wE.exports=function(){var t=s3();return a3(Object,{is:t},{is:function(){return Object.is!==t}}),t}});var OE=B((d5,AE)=>{"use strict";p();var u3=Ta(),f3=Es(),c3=ip(),xE=lc(),l3=EE(),IE=f3(xE(),Object);u3(IE,{getPolyfill:xE,implementation:c3,shim:l3});AE.exports=IE});var op=B((g5,RE)=>{"use strict";p();RE.exports=function(t){return t!==t}});var sp=B((m5,TE)=>{"use strict";p();var h3=op();TE.exports=function(){return Number.isNaN&&Number.isNaN(NaN)&&!Number.isNaN("a")?Number.isNaN:h3}});var BE=B((b5,PE)=>{"use strict";p();var d3=Ta(),p3=sp();PE.exports=function(){var t=p3();return d3(Number,{isNaN:t},{isNaN:function(){return Number.isNaN!==t}}),t}});var CE=B((S5,kE)=>{"use strict";p();var g3=Es(),y3=Ta(),m3=op(),NE=sp(),v3=BE(),ME=g3(NE(),Number);y3(ME,{getPolyfill:NE,implementation:m3,shim:v3});kE.exports=ME});var t1=B((E5,e1)=>{"use strict";p();function LE(e,t){return w3(e)||S3(e,t)||_3(e,t)||b3()}function b3(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
60
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function _3(e,t){if(e){if(typeof e=="string")return DE(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return DE(e,t)}}function DE(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function S3(e,t){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var n,i,o,s,a=[],f=!0,l=!1;try{if(o=(r=r.call(e)).next,t===0){if(Object(r)!==r)return;f=!1}else for(;!(f=(n=o.call(r)).done)&&(a.push(n.value),a.length!==t);f=!0);}catch(y){l=!0,i=y}finally{try{if(!f&&r.return!=null&&(s=r.return(),Object(s)!==s))return}finally{if(l)throw i}}return a}}function w3(e){if(Array.isArray(e))return e}function Ir(e){"@babel/helpers - typeof";return Ir=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Ir(e)}var E3=/a/g.flags!==void 0,vc=function(t){var r=[];return t.forEach(function(n){return r.push(n)}),r},UE=function(t){var r=[];return t.forEach(function(n,i){return r.push([i,n])}),r},$E=Object.is?Object.is:OE(),yc=Object.getOwnPropertySymbols?Object.getOwnPropertySymbols:function(){return[]},ap=Number.isNaN?Number.isNaN:CE();function fp(e){return e.call.bind(e)}var Ba=fp(Object.prototype.hasOwnProperty),mc=fp(Object.prototype.propertyIsEnumerable),FE=fp(Object.prototype.toString),nr=Jr().types,x3=nr.isAnyArrayBuffer,I3=nr.isArrayBufferView,qE=nr.isDate,hc=nr.isMap,HE=nr.isRegExp,dc=nr.isSet,A3=nr.isNativeError,O3=nr.isBoxedPrimitive,jE=nr.isNumberObject,KE=nr.isStringObject,GE=nr.isBooleanObject,VE=nr.isBigIntObject,R3=nr.isSymbolObject,T3=nr.isFloat32Array,P3=nr.isFloat64Array;function B3(e){if(e.length===0||e.length>10)return!0;for(var t=0;t<e.length;t++){var r=e.charCodeAt(t);if(r<48||r>57)return!0}return e.length===10&&e>=Math.pow(2,32)}function pc(e){return Object.keys(e).filter(B3).concat(yc(e).filter(Object.prototype.propertyIsEnumerable.bind(e)))}function ZE(e,t){if(e===t)return 0;for(var r=e.length,n=t.length,i=0,o=Math.min(r,n);i<o;++i)if(e[i]!==t[i]){r=e[i],n=t[i];break}return r<n?-1:n<r?1:0}var gc=void 0,N3=!0,M3=!1,up=0,cp=1,XE=2,JE=3;function k3(e,t){return E3?e.source===t.source&&e.flags===t.flags:RegExp.prototype.toString.call(e)===RegExp.prototype.toString.call(t)}function C3(e,t){if(e.byteLength!==t.byteLength)return!1;for(var r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}function L3(e,t){return e.byteLength!==t.byteLength?!1:ZE(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),new Uint8Array(t.buffer,t.byteOffset,t.byteLength))===0}function D3(e,t){return e.byteLength===t.byteLength&&ZE(new Uint8Array(e),new Uint8Array(t))===0}function U3(e,t){return jE(e)?jE(t)&&$E(Number.prototype.valueOf.call(e),Number.prototype.valueOf.call(t)):KE(e)?KE(t)&&String.prototype.valueOf.call(e)===String.prototype.valueOf.call(t):GE(e)?GE(t)&&Boolean.prototype.valueOf.call(e)===Boolean.prototype.valueOf.call(t):VE(e)?VE(t)&&BigInt.prototype.valueOf.call(e)===BigInt.prototype.valueOf.call(t):R3(t)&&Symbol.prototype.valueOf.call(e)===Symbol.prototype.valueOf.call(t)}function Ar(e,t,r,n){if(e===t)return e!==0?!0:r?$E(e,t):!0;if(r){if(Ir(e)!=="object")return typeof e=="number"&&ap(e)&&ap(t);if(Ir(t)!=="object"||e===null||t===null||Object.getPrototypeOf(e)!==Object.getPrototypeOf(t))return!1}else{if(e===null||Ir(e)!=="object")return t===null||Ir(t)!=="object"?e==t:!1;if(t===null||Ir(t)!=="object")return!1}var i=FE(e),o=FE(t);if(i!==o)return!1;if(Array.isArray(e)){if(e.length!==t.length)return!1;var s=pc(e,gc),a=pc(t,gc);return s.length!==a.length?!1:Pa(e,t,r,n,cp,s)}if(i==="[object Object]"&&(!hc(e)&&hc(t)||!dc(e)&&dc(t)))return!1;if(qE(e)){if(!qE(t)||Date.prototype.getTime.call(e)!==Date.prototype.getTime.call(t))return!1}else if(HE(e)){if(!HE(t)||!k3(e,t))return!1}else if(A3(e)||e instanceof Error){if(e.message!==t.message||e.name!==t.name)return!1}else if(I3(e)){if(!r&&(T3(e)||P3(e))){if(!C3(e,t))return!1}else if(!L3(e,t))return!1;var f=pc(e,gc),l=pc(t,gc);return f.length!==l.length?!1:Pa(e,t,r,n,up,f)}else{if(dc(e))return!dc(t)||e.size!==t.size?!1:Pa(e,t,r,n,XE);if(hc(e))return!hc(t)||e.size!==t.size?!1:Pa(e,t,r,n,JE);if(x3(e)){if(!D3(e,t))return!1}else if(O3(e)&&!U3(e,t))return!1}return Pa(e,t,r,n,up)}function WE(e,t){return t.filter(function(r){return mc(e,r)})}function Pa(e,t,r,n,i,o){if(arguments.length===5){o=Object.keys(e);var s=Object.keys(t);if(o.length!==s.length)return!1}for(var a=0;a<o.length;a++)if(!Ba(t,o[a]))return!1;if(r&&arguments.length===5){var f=yc(e);if(f.length!==0){var l=0;for(a=0;a<f.length;a++){var y=f[a];if(mc(e,y)){if(!mc(t,y))return!1;o.push(y),l++}else if(mc(t,y))return!1}var g=yc(t);if(f.length!==g.length&&WE(t,g).length!==l)return!1}else{var v=yc(t);if(v.length!==0&&WE(t,v).length!==0)return!1}}if(o.length===0&&(i===up||i===cp&&e.length===0||e.size===0))return!0;if(n===void 0)n={val1:new Map,val2:new Map,position:0};else{var E=n.val1.get(e);if(E!==void 0){var T=n.val2.get(t);if(T!==void 0)return E===T}n.position++}n.val1.set(e,n.position),n.val2.set(t,n.position);var M=K3(e,t,r,o,n,i);return n.val1.delete(e),n.val2.delete(t),M}function zE(e,t,r,n){for(var i=vc(e),o=0;o<i.length;o++){var s=i[o];if(Ar(t,s,r,n))return e.delete(s),!0}return!1}function QE(e){switch(Ir(e)){case"undefined":return null;case"object":return;case"symbol":return!1;case"string":e=+e;case"number":if(ap(e))return!1}return!0}function F3(e,t,r){var n=QE(r);return n??(t.has(n)&&!e.has(n))}function q3(e,t,r,n,i){var o=QE(r);if(o!=null)return o;var s=t.get(o);return s===void 0&&!t.has(o)||!Ar(n,s,!1,i)?!1:!e.has(o)&&Ar(n,s,!1,i)}function H3(e,t,r,n){for(var i=null,o=vc(e),s=0;s<o.length;s++){var a=o[s];if(Ir(a)==="object"&&a!==null)i===null&&(i=new Set),i.add(a);else if(!t.has(a)){if(r||!F3(e,t,a))return!1;i===null&&(i=new Set),i.add(a)}}if(i!==null){for(var f=vc(t),l=0;l<f.length;l++){var y=f[l];if(Ir(y)==="object"&&y!==null){if(!zE(i,y,r,n))return!1}else if(!r&&!e.has(y)&&!zE(i,y,r,n))return!1}return i.size===0}return!0}function YE(e,t,r,n,i,o){for(var s=vc(e),a=0;a<s.length;a++){var f=s[a];if(Ar(r,f,i,o)&&Ar(n,t.get(f),i,o))return e.delete(f),!0}return!1}function j3(e,t,r,n){for(var i=null,o=UE(e),s=0;s<o.length;s++){var a=LE(o[s],2),f=a[0],l=a[1];if(Ir(f)==="object"&&f!==null)i===null&&(i=new Set),i.add(f);else{var y=t.get(f);if(y===void 0&&!t.has(f)||!Ar(l,y,r,n)){if(r||!q3(e,t,f,l,n))return!1;i===null&&(i=new Set),i.add(f)}}}if(i!==null){for(var g=UE(t),v=0;v<g.length;v++){var E=LE(g[v],2),T=E[0],M=E[1];if(Ir(T)==="object"&&T!==null){if(!YE(i,e,T,M,r,n))return!1}else if(!r&&(!e.has(T)||!Ar(e.get(T),M,!1,n))&&!YE(i,e,T,M,!1,n))return!1}return i.size===0}return!0}function K3(e,t,r,n,i,o){var s=0;if(o===XE){if(!H3(e,t,r,i))return!1}else if(o===JE){if(!j3(e,t,r,i))return!1}else if(o===cp)for(;s<e.length;s++)if(Ba(e,s)){if(!Ba(t,s)||!Ar(e[s],t[s],r,i))return!1}else{if(Ba(t,s))return!1;for(var a=Object.keys(e);s<a.length;s++){var f=a[s];if(!Ba(t,f)||!Ar(e[f],t[f],r,i))return!1}return a.length===Object.keys(t).length}for(s=0;s<n.length;s++){var l=n[s];if(!Ar(e[l],t[l],r,i))return!1}return!0}function G3(e,t){return Ar(e,t,M3)}function V3(e,t){return Ar(e,t,N3)}e1.exports={isDeepEqual:G3,isDeepStrictEqual:V3}});var Sa=B((I5,b1)=>{"use strict";p();function Dr(e){"@babel/helpers - typeof";return Dr=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Dr(e)}function r1(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,z3(n.key),n)}}function W3(e,t,r){return t&&r1(e.prototype,t),r&&r1(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function z3(e){var t=Y3(e,"string");return Dr(t)==="symbol"?t:String(t)}function Y3(e,t){if(Dr(e)!=="object"||e===null)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t||"default");if(Dr(n)!=="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function $3(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var Z3=$d(),Na=Z3.codes,n1=Na.ERR_AMBIGUOUS_ARGUMENT,ts=Na.ERR_INVALID_ARG_TYPE,X3=Na.ERR_INVALID_ARG_VALUE,J3=Na.ERR_INVALID_RETURN_VALUE,yi=Na.ERR_MISSING_ARGS,mi=Kw(),Q3=Jr(),bc=Q3.inspect,a1=Jr().types,e6=a1.isPromise,_c=a1.isRegExp,t6=cE()(),u1=lc()(),Sc=mE()("RegExp.prototype.test"),gi,wc;function Ma(){var e=t1();gi=e.isDeepEqual,wc=e.isDeepStrictEqual}var i1=!1,Xe=b1.exports=lp,Ec={};function Ur(e){throw e.message instanceof Error?e.message:new mi(e)}function f1(e,t,r,n,i){var o=arguments.length,s;if(o===0)s="Failed";else if(o===1)r=e,e=void 0;else{if(i1===!1){i1=!0;var a=x.default.emitWarning?x.default.emitWarning:console.warn.bind(console);a("assert.fail() with more than one argument is deprecated. Please use assert.strictEqual() instead or only pass a message.","DeprecationWarning","DEP0094")}o===2&&(n="!=")}if(r instanceof Error)throw r;var f={actual:e,expected:t,operator:n===void 0?"fail":n,stackStartFn:i||f1};r!==void 0&&(f.message=r);var l=new mi(f);throw s&&(l.message=s,l.generatedMessage=!0),l}Xe.fail=f1;Xe.AssertionError=mi;function c1(e,t,r,n){if(!r){var i=!1;if(t===0)i=!0,n="No value argument passed to `assert.ok()`";else if(n instanceof Error)throw n;var o=new mi({actual:r,expected:!0,message:n,operator:"==",stackStartFn:e});throw o.generatedMessage=i,o}}function lp(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];c1.apply(void 0,[lp,t.length].concat(t))}Xe.ok=lp;Xe.equal=function e(t,r,n){if(arguments.length<2)throw new yi("actual","expected");t!=r&&Ur({actual:t,expected:r,message:n,operator:"==",stackStartFn:e})};Xe.notEqual=function e(t,r,n){if(arguments.length<2)throw new yi("actual","expected");t==r&&Ur({actual:t,expected:r,message:n,operator:"!=",stackStartFn:e})};Xe.deepEqual=function e(t,r,n){if(arguments.length<2)throw new yi("actual","expected");gi===void 0&&Ma(),gi(t,r)||Ur({actual:t,expected:r,message:n,operator:"deepEqual",stackStartFn:e})};Xe.notDeepEqual=function e(t,r,n){if(arguments.length<2)throw new yi("actual","expected");gi===void 0&&Ma(),gi(t,r)&&Ur({actual:t,expected:r,message:n,operator:"notDeepEqual",stackStartFn:e})};Xe.deepStrictEqual=function e(t,r,n){if(arguments.length<2)throw new yi("actual","expected");gi===void 0&&Ma(),wc(t,r)||Ur({actual:t,expected:r,message:n,operator:"deepStrictEqual",stackStartFn:e})};Xe.notDeepStrictEqual=l1;function l1(e,t,r){if(arguments.length<2)throw new yi("actual","expected");gi===void 0&&Ma(),wc(e,t)&&Ur({actual:e,expected:t,message:r,operator:"notDeepStrictEqual",stackStartFn:l1})}Xe.strictEqual=function e(t,r,n){if(arguments.length<2)throw new yi("actual","expected");u1(t,r)||Ur({actual:t,expected:r,message:n,operator:"strictEqual",stackStartFn:e})};Xe.notStrictEqual=function e(t,r,n){if(arguments.length<2)throw new yi("actual","expected");u1(t,r)&&Ur({actual:t,expected:r,message:n,operator:"notStrictEqual",stackStartFn:e})};var o1=W3(function e(t,r,n){var i=this;$3(this,e),r.forEach(function(o){o in t&&(n!==void 0&&typeof n[o]=="string"&&_c(t[o])&&Sc(t[o],n[o])?i[o]=n[o]:i[o]=t[o])})});function r6(e,t,r,n,i,o){if(!(r in e)||!wc(e[r],t[r])){if(!n){var s=new o1(e,i),a=new o1(t,i,e),f=new mi({actual:s,expected:a,operator:"deepStrictEqual",stackStartFn:o});throw f.actual=e,f.expected=t,f.operator=o.name,f}Ur({actual:e,expected:t,message:n,operator:o.name,stackStartFn:o})}}function h1(e,t,r,n){if(typeof t!="function"){if(_c(t))return Sc(t,e);if(arguments.length===2)throw new ts("expected",["Function","RegExp"],t);if(Dr(e)!=="object"||e===null){var i=new mi({actual:e,expected:t,message:r,operator:"deepStrictEqual",stackStartFn:n});throw i.operator=n.name,i}var o=Object.keys(t);if(t instanceof Error)o.push("name","message");else if(o.length===0)throw new X3("error",t,"may not be an empty object");return gi===void 0&&Ma(),o.forEach(function(s){typeof e[s]=="string"&&_c(t[s])&&Sc(t[s],e[s])||r6(e,t,s,r,o,n)}),!0}return t.prototype!==void 0&&e instanceof t?!0:Error.isPrototypeOf(t)?!1:t.call({},e)===!0}function d1(e){if(typeof e!="function")throw new ts("fn","Function",e);try{e()}catch(t){return t}return Ec}function s1(e){return e6(e)||e!==null&&Dr(e)==="object"&&typeof e.then=="function"&&typeof e.catch=="function"}function p1(e){return Promise.resolve().then(function(){var t;if(typeof e=="function"){if(t=e(),!s1(t))throw new J3("instance of Promise","promiseFn",t)}else if(s1(e))t=e;else throw new ts("promiseFn",["Function","Promise"],e);return Promise.resolve().then(function(){return t}).then(function(){return Ec}).catch(function(r){return r})})}function g1(e,t,r,n){if(typeof r=="string"){if(arguments.length===4)throw new ts("error",["Object","Error","Function","RegExp"],r);if(Dr(t)==="object"&&t!==null){if(t.message===r)throw new n1("error/message",'The error message "'.concat(t.message,'" is identical to the message.'))}else if(t===r)throw new n1("error/message",'The error "'.concat(t,'" is identical to the message.'));n=r,r=void 0}else if(r!=null&&Dr(r)!=="object"&&typeof r!="function")throw new ts("error",["Object","Error","Function","RegExp"],r);if(t===Ec){var i="";r&&r.name&&(i+=" (".concat(r.name,")")),i+=n?": ".concat(n):".";var o=e.name==="rejects"?"rejection":"exception";Ur({actual:void 0,expected:r,operator:e.name,message:"Missing expected ".concat(o).concat(i),stackStartFn:e})}if(r&&!h1(t,r,n,e))throw t}function y1(e,t,r,n){if(t!==Ec){if(typeof r=="string"&&(n=r,r=void 0),!r||h1(t,r)){var i=n?": ".concat(n):".",o=e.name==="doesNotReject"?"rejection":"exception";Ur({actual:t,expected:r,operator:e.name,message:"Got unwanted ".concat(o).concat(i,`
61
- `)+'Actual message: "'.concat(t&&t.message,'"'),stackStartFn:e})}throw t}}Xe.throws=function e(t){for(var r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];g1.apply(void 0,[e,d1(t)].concat(n))};Xe.rejects=function e(t){for(var r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];return p1(t).then(function(o){return g1.apply(void 0,[e,o].concat(n))})};Xe.doesNotThrow=function e(t){for(var r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];y1.apply(void 0,[e,d1(t)].concat(n))};Xe.doesNotReject=function e(t){for(var r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];return p1(t).then(function(o){return y1.apply(void 0,[e,o].concat(n))})};Xe.ifError=function e(t){if(t!=null){var r="ifError got unwanted exception: ";Dr(t)==="object"&&typeof t.message=="string"?t.message.length===0&&t.constructor?r+=t.constructor.name:r+=t.message:r+=bc(t);var n=new mi({actual:t,expected:null,operator:"ifError",message:r,stackStartFn:e}),i=t.stack;if(typeof i=="string"){var o=i.split(`
59
+ `):M=" ".concat(a," ").concat(M)),o=r.call(this,"".concat(O).concat(M))}return Error.stackTraceLimit=y,o.generatedMessage=!s,Object.defineProperty(tp(o),"name",{value:"AssertionError [ERR_ASSERTION]",enumerable:!1,writable:!0,configurable:!0}),o.code="ERR_ASSERTION",o.actual=l,o.expected=m,o.operator=a,Error.captureStackTrace&&Error.captureStackTrace(tp(o),f),o.stack,o.name="AssertionError",jw(o)}return Ck(n,[{key:"toString",value:function(){return"".concat(this.name," [").concat(this.code,"]: ").concat(this.message)}},{key:t,value:function(o,s){return np(this,Dw(Dw({},s),{},{customInspect:!1,depth:0}))}}]),n})(rp(Error),np.custom);Gw.exports=Wk});var ip=B((XF,zw)=>{"use strict";g();var Ww=Object.prototype.toString;zw.exports=function(t){var r=Ww.call(t),n=r==="[object Arguments]";return n||(n=r!=="[object Array]"&&t!==null&&typeof t=="object"&&typeof t.length=="number"&&t.length>=0&&Ww.call(t.callee)==="[object Function]"),n}});var rE=B((QF,tE)=>{"use strict";g();var eE;Object.keys||(Na=Object.prototype.hasOwnProperty,op=Object.prototype.toString,Yw=ip(),sp=Object.prototype.propertyIsEnumerable,$w=!sp.call({toString:null},"toString"),Zw=sp.call(function(){},"prototype"),Ma=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],dc=function(e){var t=e.constructor;return t&&t.prototype===e},Xw={$applicationCache:!0,$console:!0,$external:!0,$frame:!0,$frameElement:!0,$frames:!0,$innerHeight:!0,$innerWidth:!0,$onmozfullscreenchange:!0,$onmozfullscreenerror:!0,$outerHeight:!0,$outerWidth:!0,$pageXOffset:!0,$pageYOffset:!0,$parent:!0,$scrollLeft:!0,$scrollTop:!0,$scrollX:!0,$scrollY:!0,$self:!0,$webkitIndexedDB:!0,$webkitStorageInfo:!0,$window:!0},Jw=(function(){if(typeof window>"u")return!1;for(var e in window)try{if(!Xw["$"+e]&&Na.call(window,e)&&window[e]!==null&&typeof window[e]=="object")try{dc(window[e])}catch{return!0}}catch{return!0}return!1})(),Qw=function(e){if(typeof window>"u"||!Jw)return dc(e);try{return dc(e)}catch{return!1}},eE=function(t){var r=t!==null&&typeof t=="object",n=op.call(t)==="[object Function]",i=Yw(t),o=r&&op.call(t)==="[object String]",s=[];if(!r&&!n&&!i)throw new TypeError("Object.keys called on a non-object");var a=Zw&&n;if(o&&t.length>0&&!Na.call(t,0))for(var f=0;f<t.length;++f)s.push(String(f));if(i&&t.length>0)for(var l=0;l<t.length;++l)s.push(String(l));else for(var m in t)!(a&&m==="prototype")&&Na.call(t,m)&&s.push(String(m));if($w)for(var y=Qw(t),p=0;p<Ma.length;++p)!(y&&Ma[p]==="constructor")&&Na.call(t,Ma[p])&&s.push(Ma[p]);return s});var Na,op,Yw,sp,$w,Zw,Ma,dc,Xw,Jw,Qw;tE.exports=eE});var ap=B((t5,oE)=>{"use strict";g();var zk=Array.prototype.slice,Yk=ip(),nE=Object.keys,pc=nE?function(t){return nE(t)}:rE(),iE=Object.keys;pc.shim=function(){if(Object.keys){var t=(function(){var r=Object.keys(arguments);return r&&r.length===arguments.length})(1,2);t||(Object.keys=function(n){return Yk(n)?iE(zk.call(n)):iE(n)})}else Object.keys=pc;return Object.keys||pc};oE.exports=pc});var cE=B((n5,fE)=>{"use strict";g();var $k=ap(),aE=cu()(),uE=Zn(),gc=lu(),Zk=uE("Array.prototype.push"),sE=uE("Object.prototype.propertyIsEnumerable"),Xk=aE?gc.getOwnPropertySymbols:null;fE.exports=function(t,r){if(t==null)throw new TypeError("target must be an object");var n=gc(t);if(arguments.length===1)return n;for(var i=1;i<arguments.length;++i){var o=gc(arguments[i]),s=$k(o),a=aE&&(gc.getOwnPropertySymbols||Xk);if(a)for(var f=a(o),l=0;l<f.length;++l){var m=f[l];sE(o,m)&&Zk(s,m)}for(var y=0;y<s.length;++y){var p=s[y];if(sE(o,p)){var w=o[p];n[p]=w}}}return n}});var hE=B((o5,lE)=>{"use strict";g();var up=cE(),Jk=function(){if(!Object.assign)return!1;for(var e="abcdefghijklmnopqrst",t=e.split(""),r={},n=0;n<t.length;++n)r[t[n]]=t[n];var i=Object.assign({},r),o="";for(var s in i)o+=s;return e!==o},Qk=function(){if(!Object.assign||!Object.preventExtensions)return!1;var e=Object.preventExtensions({1:2});try{Object.assign(e,"xy")}catch{return e[1]==="y"}return!1};lE.exports=function(){return!Object.assign||Jk()||Qk()?up:Object.assign}});var fp=B((a5,pE)=>{"use strict";g();var dE=function(e){return e!==e};pE.exports=function(t,r){return t===0&&r===0?1/t===1/r:!!(t===r||dE(t)&&dE(r))}});var yc=B((f5,gE)=>{"use strict";g();var e3=fp();gE.exports=function(){return typeof Object.is=="function"?Object.is:e3}});var bE=B((l5,vE)=>{"use strict";g();var yE=_u(),mE=Rs(),t3=mE(yE("String.prototype.indexOf"));vE.exports=function(t,r){var n=yE(t,!!r);return typeof n=="function"&&t3(t,".prototype.")>-1?mE(n):n}});var ka=B((d5,EE)=>{"use strict";g();var r3=ap(),n3=typeof Symbol=="function"&&typeof Symbol("foo")=="symbol",i3=Object.prototype.toString,o3=Array.prototype.concat,_E=Zl(),s3=function(e){return typeof e=="function"&&i3.call(e)==="[object Function]"},SE=Jl()(),a3=function(e,t,r,n){if(t in e){if(n===!0){if(e[t]===r)return}else if(!s3(n)||!n())return}SE?_E(e,t,r,!0):_E(e,t,r)},wE=function(e,t){var r=arguments.length>2?arguments[2]:{},n=r3(t);n3&&(n=o3.call(n,Object.getOwnPropertySymbols(t)));for(var i=0;i<n.length;i+=1)a3(e,n[i],t[n[i]],r[n[i]])};wE.supportsDescriptors=!!SE;EE.exports=wE});var IE=B((g5,xE)=>{"use strict";g();var u3=yc(),f3=ka();xE.exports=function(){var t=u3();return f3(Object,{is:t},{is:function(){return Object.is!==t}}),t}});var TE=B((m5,RE)=>{"use strict";g();var c3=ka(),l3=Rs(),h3=fp(),AE=yc(),d3=IE(),OE=l3(AE(),Object);c3(OE,{getPolyfill:AE,implementation:h3,shim:d3});RE.exports=OE});var cp=B((b5,PE)=>{"use strict";g();PE.exports=function(t){return t!==t}});var lp=B((S5,BE)=>{"use strict";g();var p3=cp();BE.exports=function(){return Number.isNaN&&Number.isNaN(NaN)&&!Number.isNaN("a")?Number.isNaN:p3}});var ME=B((E5,NE)=>{"use strict";g();var g3=ka(),y3=lp();NE.exports=function(){var t=y3();return g3(Number,{isNaN:t},{isNaN:function(){return Number.isNaN!==t}}),t}});var DE=B((I5,LE)=>{"use strict";g();var m3=Rs(),v3=ka(),b3=cp(),kE=lp(),_3=ME(),CE=m3(kE(),Number);v3(CE,{getPolyfill:kE,implementation:b3,shim:_3});LE.exports=CE});var n1=B((O5,r1)=>{"use strict";g();function UE(e,t){return x3(e)||E3(e,t)||w3(e,t)||S3()}function S3(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
60
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function w3(e,t){if(e){if(typeof e=="string")return FE(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return FE(e,t)}}function FE(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function E3(e,t){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var n,i,o,s,a=[],f=!0,l=!1;try{if(o=(r=r.call(e)).next,t===0){if(Object(r)!==r)return;f=!1}else for(;!(f=(n=o.call(r)).done)&&(a.push(n.value),a.length!==t);f=!0);}catch(m){l=!0,i=m}finally{try{if(!f&&r.return!=null&&(s=r.return(),Object(s)!==s))return}finally{if(l)throw i}}return a}}function x3(e){if(Array.isArray(e))return e}function Rr(e){"@babel/helpers - typeof";return Rr=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Rr(e)}var I3=/a/g.flags!==void 0,Ec=function(t){var r=[];return t.forEach(function(n){return r.push(n)}),r},qE=function(t){var r=[];return t.forEach(function(n,i){return r.push([i,n])}),r},XE=Object.is?Object.is:TE(),Sc=Object.getOwnPropertySymbols?Object.getOwnPropertySymbols:function(){return[]},hp=Number.isNaN?Number.isNaN:DE();function pp(e){return e.call.bind(e)}var La=pp(Object.prototype.hasOwnProperty),wc=pp(Object.prototype.propertyIsEnumerable),HE=pp(Object.prototype.toString),ar=rn().types,A3=ar.isAnyArrayBuffer,O3=ar.isArrayBufferView,jE=ar.isDate,mc=ar.isMap,KE=ar.isRegExp,vc=ar.isSet,R3=ar.isNativeError,T3=ar.isBoxedPrimitive,GE=ar.isNumberObject,VE=ar.isStringObject,WE=ar.isBooleanObject,zE=ar.isBigIntObject,P3=ar.isSymbolObject,B3=ar.isFloat32Array,N3=ar.isFloat64Array;function M3(e){if(e.length===0||e.length>10)return!0;for(var t=0;t<e.length;t++){var r=e.charCodeAt(t);if(r<48||r>57)return!0}return e.length===10&&e>=Math.pow(2,32)}function bc(e){return Object.keys(e).filter(M3).concat(Sc(e).filter(Object.prototype.propertyIsEnumerable.bind(e)))}function JE(e,t){if(e===t)return 0;for(var r=e.length,n=t.length,i=0,o=Math.min(r,n);i<o;++i)if(e[i]!==t[i]){r=e[i],n=t[i];break}return r<n?-1:n<r?1:0}var _c=void 0,k3=!0,C3=!1,dp=0,gp=1,QE=2,e1=3;function L3(e,t){return I3?e.source===t.source&&e.flags===t.flags:RegExp.prototype.toString.call(e)===RegExp.prototype.toString.call(t)}function D3(e,t){if(e.byteLength!==t.byteLength)return!1;for(var r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}function U3(e,t){return e.byteLength!==t.byteLength?!1:JE(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),new Uint8Array(t.buffer,t.byteOffset,t.byteLength))===0}function F3(e,t){return e.byteLength===t.byteLength&&JE(new Uint8Array(e),new Uint8Array(t))===0}function q3(e,t){return GE(e)?GE(t)&&XE(Number.prototype.valueOf.call(e),Number.prototype.valueOf.call(t)):VE(e)?VE(t)&&String.prototype.valueOf.call(e)===String.prototype.valueOf.call(t):WE(e)?WE(t)&&Boolean.prototype.valueOf.call(e)===Boolean.prototype.valueOf.call(t):zE(e)?zE(t)&&BigInt.prototype.valueOf.call(e)===BigInt.prototype.valueOf.call(t):P3(t)&&Symbol.prototype.valueOf.call(e)===Symbol.prototype.valueOf.call(t)}function Tr(e,t,r,n){if(e===t)return e!==0?!0:r?XE(e,t):!0;if(r){if(Rr(e)!=="object")return typeof e=="number"&&hp(e)&&hp(t);if(Rr(t)!=="object"||e===null||t===null||Object.getPrototypeOf(e)!==Object.getPrototypeOf(t))return!1}else{if(e===null||Rr(e)!=="object")return t===null||Rr(t)!=="object"?e==t:!1;if(t===null||Rr(t)!=="object")return!1}var i=HE(e),o=HE(t);if(i!==o)return!1;if(Array.isArray(e)){if(e.length!==t.length)return!1;var s=bc(e,_c),a=bc(t,_c);return s.length!==a.length?!1:Ca(e,t,r,n,gp,s)}if(i==="[object Object]"&&(!mc(e)&&mc(t)||!vc(e)&&vc(t)))return!1;if(jE(e)){if(!jE(t)||Date.prototype.getTime.call(e)!==Date.prototype.getTime.call(t))return!1}else if(KE(e)){if(!KE(t)||!L3(e,t))return!1}else if(R3(e)||e instanceof Error){if(e.message!==t.message||e.name!==t.name)return!1}else if(O3(e)){if(!r&&(B3(e)||N3(e))){if(!D3(e,t))return!1}else if(!U3(e,t))return!1;var f=bc(e,_c),l=bc(t,_c);return f.length!==l.length?!1:Ca(e,t,r,n,dp,f)}else{if(vc(e))return!vc(t)||e.size!==t.size?!1:Ca(e,t,r,n,QE);if(mc(e))return!mc(t)||e.size!==t.size?!1:Ca(e,t,r,n,e1);if(A3(e)){if(!F3(e,t))return!1}else if(T3(e)&&!q3(e,t))return!1}return Ca(e,t,r,n,dp)}function YE(e,t){return t.filter(function(r){return wc(e,r)})}function Ca(e,t,r,n,i,o){if(arguments.length===5){o=Object.keys(e);var s=Object.keys(t);if(o.length!==s.length)return!1}for(var a=0;a<o.length;a++)if(!La(t,o[a]))return!1;if(r&&arguments.length===5){var f=Sc(e);if(f.length!==0){var l=0;for(a=0;a<f.length;a++){var m=f[a];if(wc(e,m)){if(!wc(t,m))return!1;o.push(m),l++}else if(wc(t,m))return!1}var y=Sc(t);if(f.length!==y.length&&YE(t,y).length!==l)return!1}else{var p=Sc(t);if(p.length!==0&&YE(t,p).length!==0)return!1}}if(o.length===0&&(i===dp||i===gp&&e.length===0||e.size===0))return!0;if(n===void 0)n={val1:new Map,val2:new Map,position:0};else{var w=n.val1.get(e);if(w!==void 0){var O=n.val2.get(t);if(O!==void 0)return w===O}n.position++}n.val1.set(e,n.position),n.val2.set(t,n.position);var M=V3(e,t,r,o,n,i);return n.val1.delete(e),n.val2.delete(t),M}function $E(e,t,r,n){for(var i=Ec(e),o=0;o<i.length;o++){var s=i[o];if(Tr(t,s,r,n))return e.delete(s),!0}return!1}function t1(e){switch(Rr(e)){case"undefined":return null;case"object":return;case"symbol":return!1;case"string":e=+e;case"number":if(hp(e))return!1}return!0}function H3(e,t,r){var n=t1(r);return n??(t.has(n)&&!e.has(n))}function j3(e,t,r,n,i){var o=t1(r);if(o!=null)return o;var s=t.get(o);return s===void 0&&!t.has(o)||!Tr(n,s,!1,i)?!1:!e.has(o)&&Tr(n,s,!1,i)}function K3(e,t,r,n){for(var i=null,o=Ec(e),s=0;s<o.length;s++){var a=o[s];if(Rr(a)==="object"&&a!==null)i===null&&(i=new Set),i.add(a);else if(!t.has(a)){if(r||!H3(e,t,a))return!1;i===null&&(i=new Set),i.add(a)}}if(i!==null){for(var f=Ec(t),l=0;l<f.length;l++){var m=f[l];if(Rr(m)==="object"&&m!==null){if(!$E(i,m,r,n))return!1}else if(!r&&!e.has(m)&&!$E(i,m,r,n))return!1}return i.size===0}return!0}function ZE(e,t,r,n,i,o){for(var s=Ec(e),a=0;a<s.length;a++){var f=s[a];if(Tr(r,f,i,o)&&Tr(n,t.get(f),i,o))return e.delete(f),!0}return!1}function G3(e,t,r,n){for(var i=null,o=qE(e),s=0;s<o.length;s++){var a=UE(o[s],2),f=a[0],l=a[1];if(Rr(f)==="object"&&f!==null)i===null&&(i=new Set),i.add(f);else{var m=t.get(f);if(m===void 0&&!t.has(f)||!Tr(l,m,r,n)){if(r||!j3(e,t,f,l,n))return!1;i===null&&(i=new Set),i.add(f)}}}if(i!==null){for(var y=qE(t),p=0;p<y.length;p++){var w=UE(y[p],2),O=w[0],M=w[1];if(Rr(O)==="object"&&O!==null){if(!ZE(i,e,O,M,r,n))return!1}else if(!r&&(!e.has(O)||!Tr(e.get(O),M,!1,n))&&!ZE(i,e,O,M,!1,n))return!1}return i.size===0}return!0}function V3(e,t,r,n,i,o){var s=0;if(o===QE){if(!K3(e,t,r,i))return!1}else if(o===e1){if(!G3(e,t,r,i))return!1}else if(o===gp)for(;s<e.length;s++)if(La(e,s)){if(!La(t,s)||!Tr(e[s],t[s],r,i))return!1}else{if(La(t,s))return!1;for(var a=Object.keys(e);s<a.length;s++){var f=a[s];if(!La(t,f)||!Tr(e[f],t[f],r,i))return!1}return a.length===Object.keys(t).length}for(s=0;s<n.length;s++){var l=n[s];if(!Tr(e[l],t[l],r,i))return!1}return!0}function W3(e,t){return Tr(e,t,C3)}function z3(e,t){return Tr(e,t,k3)}r1.exports={isDeepEqual:W3,isDeepStrictEqual:z3}});var Aa=B((T5,S1)=>{"use strict";g();function qr(e){"@babel/helpers - typeof";return qr=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},qr(e)}function i1(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,$3(n.key),n)}}function Y3(e,t,r){return t&&i1(e.prototype,t),r&&i1(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function $3(e){var t=Z3(e,"string");return qr(t)==="symbol"?t:String(t)}function Z3(e,t){if(qr(e)!=="object"||e===null)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t||"default");if(qr(n)!=="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function X3(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var J3=ep(),Da=J3.codes,o1=Da.ERR_AMBIGUOUS_ARGUMENT,ss=Da.ERR_INVALID_ARG_TYPE,Q3=Da.ERR_INVALID_ARG_VALUE,e6=Da.ERR_INVALID_RETURN_VALUE,Si=Da.ERR_MISSING_ARGS,wi=Vw(),t6=rn(),xc=t6.inspect,f1=rn().types,r6=f1.isPromise,Ic=f1.isRegExp,n6=hE()(),c1=yc()(),Ac=bE()("RegExp.prototype.test"),_i,Oc;function Ua(){var e=n1();_i=e.isDeepEqual,Oc=e.isDeepStrictEqual}var s1=!1,ut=S1.exports=yp,Rc={};function Hr(e){throw e.message instanceof Error?e.message:new wi(e)}function l1(e,t,r,n,i){var o=arguments.length,s;if(o===0)s="Failed";else if(o===1)r=e,e=void 0;else{if(s1===!1){s1=!0;var a=x.default.emitWarning?x.default.emitWarning:console.warn.bind(console);a("assert.fail() with more than one argument is deprecated. Please use assert.strictEqual() instead or only pass a message.","DeprecationWarning","DEP0094")}o===2&&(n="!=")}if(r instanceof Error)throw r;var f={actual:e,expected:t,operator:n===void 0?"fail":n,stackStartFn:i||l1};r!==void 0&&(f.message=r);var l=new wi(f);throw s&&(l.message=s,l.generatedMessage=!0),l}ut.fail=l1;ut.AssertionError=wi;function h1(e,t,r,n){if(!r){var i=!1;if(t===0)i=!0,n="No value argument passed to `assert.ok()`";else if(n instanceof Error)throw n;var o=new wi({actual:r,expected:!0,message:n,operator:"==",stackStartFn:e});throw o.generatedMessage=i,o}}function yp(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];h1.apply(void 0,[yp,t.length].concat(t))}ut.ok=yp;ut.equal=function e(t,r,n){if(arguments.length<2)throw new Si("actual","expected");t!=r&&Hr({actual:t,expected:r,message:n,operator:"==",stackStartFn:e})};ut.notEqual=function e(t,r,n){if(arguments.length<2)throw new Si("actual","expected");t==r&&Hr({actual:t,expected:r,message:n,operator:"!=",stackStartFn:e})};ut.deepEqual=function e(t,r,n){if(arguments.length<2)throw new Si("actual","expected");_i===void 0&&Ua(),_i(t,r)||Hr({actual:t,expected:r,message:n,operator:"deepEqual",stackStartFn:e})};ut.notDeepEqual=function e(t,r,n){if(arguments.length<2)throw new Si("actual","expected");_i===void 0&&Ua(),_i(t,r)&&Hr({actual:t,expected:r,message:n,operator:"notDeepEqual",stackStartFn:e})};ut.deepStrictEqual=function e(t,r,n){if(arguments.length<2)throw new Si("actual","expected");_i===void 0&&Ua(),Oc(t,r)||Hr({actual:t,expected:r,message:n,operator:"deepStrictEqual",stackStartFn:e})};ut.notDeepStrictEqual=d1;function d1(e,t,r){if(arguments.length<2)throw new Si("actual","expected");_i===void 0&&Ua(),Oc(e,t)&&Hr({actual:e,expected:t,message:r,operator:"notDeepStrictEqual",stackStartFn:d1})}ut.strictEqual=function e(t,r,n){if(arguments.length<2)throw new Si("actual","expected");c1(t,r)||Hr({actual:t,expected:r,message:n,operator:"strictEqual",stackStartFn:e})};ut.notStrictEqual=function e(t,r,n){if(arguments.length<2)throw new Si("actual","expected");c1(t,r)&&Hr({actual:t,expected:r,message:n,operator:"notStrictEqual",stackStartFn:e})};var a1=Y3(function e(t,r,n){var i=this;X3(this,e),r.forEach(function(o){o in t&&(n!==void 0&&typeof n[o]=="string"&&Ic(t[o])&&Ac(t[o],n[o])?i[o]=n[o]:i[o]=t[o])})});function i6(e,t,r,n,i,o){if(!(r in e)||!Oc(e[r],t[r])){if(!n){var s=new a1(e,i),a=new a1(t,i,e),f=new wi({actual:s,expected:a,operator:"deepStrictEqual",stackStartFn:o});throw f.actual=e,f.expected=t,f.operator=o.name,f}Hr({actual:e,expected:t,message:n,operator:o.name,stackStartFn:o})}}function p1(e,t,r,n){if(typeof t!="function"){if(Ic(t))return Ac(t,e);if(arguments.length===2)throw new ss("expected",["Function","RegExp"],t);if(qr(e)!=="object"||e===null){var i=new wi({actual:e,expected:t,message:r,operator:"deepStrictEqual",stackStartFn:n});throw i.operator=n.name,i}var o=Object.keys(t);if(t instanceof Error)o.push("name","message");else if(o.length===0)throw new Q3("error",t,"may not be an empty object");return _i===void 0&&Ua(),o.forEach(function(s){typeof e[s]=="string"&&Ic(t[s])&&Ac(t[s],e[s])||i6(e,t,s,r,o,n)}),!0}return t.prototype!==void 0&&e instanceof t?!0:Error.isPrototypeOf(t)?!1:t.call({},e)===!0}function g1(e){if(typeof e!="function")throw new ss("fn","Function",e);try{e()}catch(t){return t}return Rc}function u1(e){return r6(e)||e!==null&&qr(e)==="object"&&typeof e.then=="function"&&typeof e.catch=="function"}function y1(e){return Promise.resolve().then(function(){var t;if(typeof e=="function"){if(t=e(),!u1(t))throw new e6("instance of Promise","promiseFn",t)}else if(u1(e))t=e;else throw new ss("promiseFn",["Function","Promise"],e);return Promise.resolve().then(function(){return t}).then(function(){return Rc}).catch(function(r){return r})})}function m1(e,t,r,n){if(typeof r=="string"){if(arguments.length===4)throw new ss("error",["Object","Error","Function","RegExp"],r);if(qr(t)==="object"&&t!==null){if(t.message===r)throw new o1("error/message",'The error message "'.concat(t.message,'" is identical to the message.'))}else if(t===r)throw new o1("error/message",'The error "'.concat(t,'" is identical to the message.'));n=r,r=void 0}else if(r!=null&&qr(r)!=="object"&&typeof r!="function")throw new ss("error",["Object","Error","Function","RegExp"],r);if(t===Rc){var i="";r&&r.name&&(i+=" (".concat(r.name,")")),i+=n?": ".concat(n):".";var o=e.name==="rejects"?"rejection":"exception";Hr({actual:void 0,expected:r,operator:e.name,message:"Missing expected ".concat(o).concat(i),stackStartFn:e})}if(r&&!p1(t,r,n,e))throw t}function v1(e,t,r,n){if(t!==Rc){if(typeof r=="string"&&(n=r,r=void 0),!r||p1(t,r)){var i=n?": ".concat(n):".",o=e.name==="doesNotReject"?"rejection":"exception";Hr({actual:t,expected:r,operator:e.name,message:"Got unwanted ".concat(o).concat(i,`
61
+ `)+'Actual message: "'.concat(t&&t.message,'"'),stackStartFn:e})}throw t}}ut.throws=function e(t){for(var r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];m1.apply(void 0,[e,g1(t)].concat(n))};ut.rejects=function e(t){for(var r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];return y1(t).then(function(o){return m1.apply(void 0,[e,o].concat(n))})};ut.doesNotThrow=function e(t){for(var r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];v1.apply(void 0,[e,g1(t)].concat(n))};ut.doesNotReject=function e(t){for(var r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];return y1(t).then(function(o){return v1.apply(void 0,[e,o].concat(n))})};ut.ifError=function e(t){if(t!=null){var r="ifError got unwanted exception: ";qr(t)==="object"&&typeof t.message=="string"?t.message.length===0&&t.constructor?r+=t.constructor.name:r+=t.message:r+=xc(t);var n=new wi({actual:t,expected:null,operator:"ifError",message:r,stackStartFn:e}),i=t.stack;if(typeof i=="string"){var o=i.split(`
62
62
  `);o.shift();for(var s=n.stack.split(`
63
63
  `),a=0;a<o.length;a++){var f=s.indexOf(o[a]);if(f!==-1){s=s.slice(0,f);break}}n.stack="".concat(s.join(`
64
64
  `),`
65
65
  `).concat(o.join(`
66
- `))}throw n}};function m1(e,t,r,n,i){if(!_c(t))throw new ts("regexp","RegExp",t);var o=i==="match";if(typeof e!="string"||Sc(t,e)!==o){if(r instanceof Error)throw r;var s=!r;r=r||(typeof e!="string"?'The "string" argument must be of type string. Received type '+"".concat(Dr(e)," (").concat(bc(e),")"):(o?"The input did not match the regular expression ":"The input was expected to not match the regular expression ")+"".concat(bc(t),`. Input:
66
+ `))}throw n}};function b1(e,t,r,n,i){if(!Ic(t))throw new ss("regexp","RegExp",t);var o=i==="match";if(typeof e!="string"||Ac(t,e)!==o){if(r instanceof Error)throw r;var s=!r;r=r||(typeof e!="string"?'The "string" argument must be of type string. Received type '+"".concat(qr(e)," (").concat(xc(e),")"):(o?"The input did not match the regular expression ":"The input was expected to not match the regular expression ")+"".concat(xc(t),`. Input:
67
67
 
68
- `).concat(bc(e),`
69
- `));var a=new mi({actual:e,expected:t,message:r,operator:i,stackStartFn:n});throw a.generatedMessage=s,a}}Xe.match=function e(t,r,n){m1(t,r,n,e,"match")};Xe.doesNotMatch=function e(t,r,n){m1(t,r,n,e,"doesNotMatch")};function v1(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];c1.apply(void 0,[v1,t.length].concat(t))}Xe.strict=t6(v1,Xe,{equal:Xe.strictEqual,deepEqual:Xe.deepStrictEqual,notEqual:Xe.notStrictEqual,notDeepEqual:Xe.notDeepStrictEqual});Xe.strict.strict=Xe.strict});var Ca=B((O5,S1)=>{"use strict";p();var ka=Ze(),_1=Fe(),rs=Er(),st=function e(t){if(!(this instanceof e))return new e(t);if(!ka.isUndefined(t))if(d.Buffer.isBuffer(t))this.set({buf:t});else if(ka.isString(t)){var r=d.Buffer.from(t,"hex");if(r.length*2!==t.length)throw new TypeError("Invalid hex string");this.set({buf:r})}else if(ka.isObject(t)){var n=t;this.set(n)}else throw new TypeError("Unrecognized argument for BufferReader")};st.prototype.set=function(e){return this.buf=e.buf||this.buf||void 0,this.pos=e.pos||this.pos||0,this};st.prototype.eof=function(){return this.pos>=this.buf.length};st.prototype.finished=st.prototype.eof;st.prototype.read=function(e){_1.checkArgument(!ka.isUndefined(e),"Must specify a length");var t=this.buf.slice(this.pos,this.pos+e);return this.pos=this.pos+e,t};st.prototype.readAll=function(){var e=this.buf.slice(this.pos,this.buf.length);return this.pos=this.buf.length,e};st.prototype.readUInt8=function(){var e=this.buf.readUInt8(this.pos);return this.pos=this.pos+1,e};st.prototype.readUInt16BE=function(){var e=this.buf.readUInt16BE(this.pos);return this.pos=this.pos+2,e};st.prototype.readUInt16LE=function(){var e=this.buf.readUInt16LE(this.pos);return this.pos=this.pos+2,e};st.prototype.readUInt32BE=function(){var e=this.buf.readUInt32BE(this.pos);return this.pos=this.pos+4,e};st.prototype.readUInt32LE=function(){var e=this.buf.readUInt32LE(this.pos);return this.pos=this.pos+4,e};st.prototype.readInt32LE=function(){var e=this.buf.readInt32LE(this.pos);return this.pos=this.pos+4,e};st.prototype.readUInt64BEBN=function(){var e=this.buf.slice(this.pos,this.pos+8),t=rs.fromBuffer(e);return this.pos=this.pos+8,t};st.prototype.readUInt64LEBN=function(){var e=this.buf.readUInt32LE(this.pos),t=this.buf.readUInt32LE(this.pos+4),r=t*4294967296+e,n;if(r<=9007199254740991)n=new rs(r);else{var i=Array.prototype.slice.call(this.buf,this.pos,this.pos+8);n=new rs(i,10,"le")}return this.pos=this.pos+8,n};st.prototype.readVarintNum=function(){var e=this.readUInt8();switch(e){case 253:return this.readUInt16LE();case 254:return this.readUInt32LE();case 255:var t=this.readUInt64LEBN(),r=t.toNumber();if(r<=Math.pow(2,53))return r;throw new Error("number too large to retain precision - use readVarintBN");default:return e}};st.prototype.readVarLengthBuffer=function(){var e=this.readVarintNum(),t=this.read(e);return _1.checkState(t.length===e,"Invalid length while reading varlength buffer. Expected to read: "+e+" and read "+t.length),t};st.prototype.readVarintBuf=function(){var e=this.buf.readUInt8(this.pos);switch(e){case 253:return this.read(3);case 254:return this.read(5);case 255:return this.read(9);default:return this.read(1)}};st.prototype.readVarintBN=function(){var e=this.readUInt8();switch(e){case 253:return new rs(this.readUInt16LE());case 254:return new rs(this.readUInt32LE());case 255:return this.readUInt64LEBN();default:return new rs(e)}};st.prototype.reverse=function(){for(var e=d.Buffer.alloc(this.buf.length),t=0;t<e.length;t++)e[t]=this.buf[this.buf.length-1-t];return this.buf=e,this};st.prototype.readReverse=function(e){ka.isUndefined(e)&&(e=this.buf.length);var t=this.buf.slice(this.pos,this.pos+e);return this.pos=this.pos+e,d.Buffer.from(t).reverse()};S1.exports=st});var dp=B((T5,w1)=>{"use strict";p();var ns=Ze(),La=Fe(),n6=gr();function Me(e){if(!(this instanceof Me))return new Me(e);var t;if(ns.isNumber(e))t=e;else if(ns.isString(e))t=Me.map[e];else throw new TypeError('Unrecognized num type: "'+typeof e+'" for Opcode');return n6.defineImmutable(this,{num:t}),this}Me.fromBuffer=function(e){return La.checkArgument(d.Buffer.isBuffer(e)),new Me(+("0x"+e.toString("hex")))};Me.fromNumber=function(e){return La.checkArgument(ns.isNumber(e)),new Me(e)};Me.fromString=function(e){La.checkArgument(ns.isString(e));var t=Me.map[e];if(typeof t>"u")throw new TypeError("Invalid opcodestr");return new Me(t)};Me.prototype.toHex=function(){return this.num.toString(16)};Me.prototype.toBuffer=function(){return d.Buffer.from(this.toHex(),"hex")};Me.prototype.toNumber=function(){return this.num};Me.prototype.toString=function(){var e=Me.reverseMap[this.num];if(typeof e>"u")throw new Error("Opcode does not have a string representation");return e};Me.smallInt=function(e){return La.checkArgument(ns.isNumber(e),"Invalid Argument: n should be number"),La.checkArgument(e>=0&&e<=16,"Invalid Argument: n must be between 0 and 16"),e===0?Me("OP_0"):new Me(Me.map.OP_1+e-1)};Me.map={OP_FALSE:0,OP_0:0,OP_PUSHDATA1:76,OP_PUSHDATA2:77,OP_PUSHDATA4:78,OP_1NEGATE:79,OP_RESERVED:80,OP_TRUE:81,OP_1:81,OP_2:82,OP_3:83,OP_4:84,OP_5:85,OP_6:86,OP_7:87,OP_8:88,OP_9:89,OP_10:90,OP_11:91,OP_12:92,OP_13:93,OP_14:94,OP_15:95,OP_16:96,OP_NOP:97,OP_VER:98,OP_IF:99,OP_NOTIF:100,OP_VERIF:101,OP_VERNOTIF:102,OP_ELSE:103,OP_ENDIF:104,OP_VERIFY:105,OP_RETURN:106,OP_TOALTSTACK:107,OP_FROMALTSTACK:108,OP_2DROP:109,OP_2DUP:110,OP_3DUP:111,OP_2OVER:112,OP_2ROT:113,OP_2SWAP:114,OP_IFDUP:115,OP_DEPTH:116,OP_DROP:117,OP_DUP:118,OP_NIP:119,OP_OVER:120,OP_PICK:121,OP_ROLL:122,OP_ROT:123,OP_SWAP:124,OP_TUCK:125,OP_CAT:126,OP_SPLIT:127,OP_NUM2BIN:128,OP_BIN2NUM:129,OP_SIZE:130,OP_INVERT:131,OP_AND:132,OP_OR:133,OP_XOR:134,OP_EQUAL:135,OP_EQUALVERIFY:136,OP_RESERVED1:137,OP_RESERVED2:138,OP_1ADD:139,OP_1SUB:140,OP_2MUL:141,OP_2DIV:142,OP_NEGATE:143,OP_ABS:144,OP_NOT:145,OP_0NOTEQUAL:146,OP_ADD:147,OP_SUB:148,OP_MUL:149,OP_DIV:150,OP_MOD:151,OP_LSHIFT:152,OP_RSHIFT:153,OP_BOOLAND:154,OP_BOOLOR:155,OP_NUMEQUAL:156,OP_NUMEQUALVERIFY:157,OP_NUMNOTEQUAL:158,OP_LESSTHAN:159,OP_GREATERTHAN:160,OP_LESSTHANOREQUAL:161,OP_GREATERTHANOREQUAL:162,OP_MIN:163,OP_MAX:164,OP_WITHIN:165,OP_RIPEMD160:166,OP_SHA1:167,OP_SHA256:168,OP_HASH160:169,OP_HASH256:170,OP_CODESEPARATOR:171,OP_CHECKSIG:172,OP_CHECKSIGVERIFY:173,OP_CHECKMULTISIG:174,OP_CHECKMULTISIGVERIFY:175,OP_CHECKLOCKTIMEVERIFY:177,OP_CHECKSEQUENCEVERIFY:178,OP_NOP1:176,OP_NOP2:177,OP_NOP3:178,OP_SUBSTR:179,OP_LEFT:180,OP_RIGHT:181,OP_LSHIFTNUM:182,OP_RSHIFTNUM:183,OP_NOP9:184,OP_NOP10:185,OP_PUBKEYHASH:253,OP_PUBKEY:254,OP_INVALIDOPCODE:255};Me.reverseMap=[];for(hp in Me.map)Me.reverseMap[Me.map[hp]]=hp;var hp;ns.extend(Me,Me.map);Me.isSmallIntOp=function(e){return e instanceof Me&&(e=e.toNumber()),e===Me.map.OP_0||e>=Me.map.OP_1&&e<=Me.map.OP_16};Me.prototype.inspect=function(){return"<Opcode: "+this.toString()+", hex: "+this.toHex()+", decimal: "+this.num+">"};w1.exports=Me});var or=B((B5,x1)=>{"use strict";p();var to=Er(),i6=Ze(),ir=Fe(),o6=gr(),Te=function e(t,r){if(!(this instanceof e))return new e(t,r);if(t instanceof to)this.set({r:t,s:r});else if(t){var n=t;this.set(n)}};Te.prototype.set=function(e){return this.r=e.r||this.r||void 0,this.s=e.s||this.s||void 0,this.i=typeof e.i<"u"?e.i:this.i,this.compressed=typeof e.compressed<"u"?e.compressed:this.compressed,this.nhashtype=e.nhashtype||this.nhashtype||void 0,this};Te.fromCompact=function(e){ir.checkArgument(d.Buffer.isBuffer(e),"Argument is expected to be a Buffer");var t=new Te,r=!0,n=e.slice(0,1)[0]-27-4;n<0&&(r=!1,n=n+4);var i=e.slice(1,33),o=e.slice(33,65);return ir.checkArgument(n===0||n===1||n===2||n===3,new Error("i must be 0, 1, 2, or 3")),ir.checkArgument(i.length===32,new Error("r must be 32 bytes")),ir.checkArgument(o.length===32,new Error("s must be 32 bytes")),t.compressed=r,t.i=n,t.r=to.fromBuffer(i),t.s=to.fromBuffer(o),t};Te.fromDER=Te.fromBuffer=function(e,t){var r=Te.parseDER(e,t),n=new Te;return n.r=r.r,n.s=r.s,n};Te.fromTxFormat=function(e){var t=e.readUInt8(e.length-1),r=e.slice(0,e.length-1),n=Te.fromDER(r,!1);return n.nhashtype=t,n};Te.fromString=function(e){var t=d.Buffer.from(e,"hex");return Te.fromDER(t)};function E1(e,t){ir.checkArgument(t.length>0,new Error("Length of "+e+" is zero")),ir.checkArgument(!(t[0]&128),new Error("Value of "+e+" is negative")),ir.checkArgument(!(t.length>1&&t[0]===0&&!(t[1]&128)),new Error("Value of "+e+" is excessively padded"))}Te.parseDER=function(e,t){ir.checkArgument(d.Buffer.isBuffer(e),new Error("DER formatted signature should be a buffer")),i6.isUndefined(t)&&(t=!0);var r=e[0];ir.checkArgument(r===48,new Error("Header byte should be 0x30"));var n=e[1],i=e.slice(2).length;ir.checkArgument(!t||n===i,new Error("Length byte should length of what follows")),n=n<i?n:i;var o=e[2];ir.checkArgument(o===2,new Error("Integer byte for r should be 0x02"));var s=e[3],a=e.slice(4,4+s),f=to.fromBuffer(a),l=e[4]===0;ir.checkArgument(s===a.length,new Error("Length of r incorrect"));var y=e[4+s+0];ir.checkArgument(y===2,new Error("Integer byte for s should be 0x02"));var g=e[4+s+1],v=e.slice(4+s+2,4+s+2+g),E=to.fromBuffer(v),T=e[4+s+2]===0;ir.checkArgument(g===v.length,new Error("Length of s incorrect"));var M=4+s+2+g;ir.checkArgument(n===M-2,new Error("Length of signature incorrect")),t&&(E1("r",a),E1("s",v));var L={header:r,length:n,rheader:o,rlength:s,rneg:l,rbuf:a,r:f,sheader:y,slength:g,sneg:T,sbuf:v,s:E};return L};Te.prototype.toCompact=function(e,t){if(e=typeof e=="number"?e:this.i,t=typeof t=="boolean"?t:this.compressed,!(e===0||e===1||e===2||e===3))throw new Error("i must be equal to 0, 1, 2, or 3");var r=e+27+4;t===!1&&(r=r-4);var n=d.Buffer.from([r]),i=this.r.toBuffer({size:32}),o=this.s.toBuffer({size:32});return d.Buffer.concat([n,i,o])};Te.prototype.toBuffer=Te.prototype.toDER=function(){var e=this.r.toBuffer(),t=this.s.toBuffer(),r=!!(e[0]&128),n=!!(t[0]&128),i=r?d.Buffer.concat([d.Buffer.from([0]),e]):e,o=n?d.Buffer.concat([d.Buffer.from([0]),t]):t,s=i.length,a=o.length,f=2+s+2+a,l=2,y=2,g=48,v=d.Buffer.concat([d.Buffer.from([g,f,l,s]),i,d.Buffer.from([y,a]),o]);return v};Te.prototype.toString=function(){var e=this.toDER();return e.toString("hex")};Te.isTxDER=function(e){if(e.length<9||e.length>73||e[0]!==48||e[1]!==e.length-3)return!1;var t=e[3];if(5+t>=e.length)return!1;var r=e[5+t];if(t+r+7!==e.length)return!1;var n=e.slice(4);if(e[2]!==2||t===0||n[0]&128||t>1&&n[0]===0&&!(n[1]&128))return!1;var i=e.slice(6+t);return!(e[6+t-2]!==2||r===0||i[0]&128||r>1&&i[0]===0&&!(i[1]&128))};Te.prototype.hasLowS=function(){return!(this.s.lt(new to(1))||this.s.gt(new to("7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0","hex")))};Te.prototype.hasDefinedHashtype=function(){if(!o6.isNaturalNumber(this.nhashtype))return!1;var e=this.nhashtype&31;return!(e<Te.SIGHASH_ALL||e>Te.SIGHASH_SINGLE)};Te.prototype.toTxFormat=function(){var e=this.toDER(),t=d.Buffer.alloc(1);return t.writeUInt8(this.nhashtype,0),d.Buffer.concat([e,t])};Te.SIGHASH_ALL=1;Te.SIGHASH_NONE=2;Te.SIGHASH_SINGLE=3;Te.SIGHASH_CHRONICLE=32;Te.SIGHASH_FORKID=64;Te.SIGHASH_ANYONECANPAY=128;Te.prototype.isCanonical=function(){var e=ci(),t=e.getN().shrn(1);return this.s.lte(t)};Te.prototype.toCanonical=function(){if(this.isCanonical())return new Te({r:this.r,s:this.s,i:this.i,compressed:this.compressed,nhashtype:this.nhashtype});var e=ci(),t=e.getN(),r=t.sub(this.s);return new Te({r:this.r,s:r,i:this.i,compressed:this.compressed,nhashtype:this.nhashtype})};Te.prototype.validate=function(){if(!this.r||!this.s)throw new Error("Signature missing r or s component");if(this.r.isZero())throw new Error("Signature r component is zero");if(this.s.isZero())throw new Error("Signature s component is zero");var e=ci(),t=e.getN();if(this.r.gte(t))throw new Error("Signature r component >= curve order");if(this.s.gte(t))throw new Error("Signature s component >= curve order");if(this.r.isNeg())throw new Error("Signature r component is negative");if(this.s.isNeg())throw new Error("Signature s component is negative");return!0};Te.prototype.isValid=function(){try{return this.validate(),!0}catch{return!1}};Te.prototype.applySecurityPatches=function(){var e=ci(),t=e.getN(),r=t.shrn(1);if(this.r.isZero()||this.s.isZero())throw new Error("Invalid signature: zero r or s");if(this.r.gte(t)||this.s.gte(t))throw new Error("Invalid signature: out of range");if(this.s.gt(r))throw new Error("Invalid signature: non-canonical (high) s");return this};x1.exports=Te});var yp=B((M5,R1)=>{"use strict";p();var s6=Sa(),Fr=io(),a6=Ca(),pp=er(),$=dp(),no=Or(),ro=or(),I1=va(),et=Fe(),Pe=Ze(),gp=Qn(),A1=Mt(),u6=gr(),q=function e(t){if(!(this instanceof e))return new e(t);if(this.chunks=[],d.Buffer.isBuffer(t))return e.fromBuffer(t);if(t instanceof Fr)return e.fromAddress(t);if(t instanceof e)return e.fromBuffer(t.toBuffer());if(Pe.isString(t))return e.fromString(t);Pe.isObject(t)&&Pe.isArray(t.chunks)&&this.set(t)};q.prototype.set=function(e){return et.checkArgument(Pe.isObject(e)),et.checkArgument(Pe.isArray(e.chunks)),this.chunks=e.chunks,this};q.fromBuffer=function(e){var t=new q;t.chunks=[];for(var r=new a6(e);!r.finished();)try{var n=r.readUInt8(),i,o;n>0&&n<$.OP_PUSHDATA1?(i=n,t.chunks.push({buf:r.read(i),len:i,opcodenum:n})):n===$.OP_PUSHDATA1?(i=r.readUInt8(),o=r.read(i),t.chunks.push({buf:o,len:i,opcodenum:n})):n===$.OP_PUSHDATA2?(i=r.readUInt16LE(),o=r.read(i),t.chunks.push({buf:o,len:i,opcodenum:n})):n===$.OP_PUSHDATA4?(i=r.readUInt32LE(),o=r.read(i),t.chunks.push({buf:o,len:i,opcodenum:n})):t.chunks.push({opcodenum:n})}catch(s){throw s instanceof RangeError?new gp.Script.InvalidBuffer(e.toString("hex")):s}return t};q.prototype.toBuffer=function(){var e=this.chunks,t=0,r,n,i;for(r=0;r<e.length;r++)n=e[r],i=n.opcodenum,t+=1,n.buf&&(i<$.OP_PUSHDATA1?t+=xc(n.buf):i===$.OP_PUSHDATA1?t+=1+xc(n.buf):i===$.OP_PUSHDATA2?t+=2+xc(n.buf):i===$.OP_PUSHDATA4&&(t+=4+xc(n.buf)));var o=d.Buffer.alloc(t),s=0;for(r=0;r<e.length;r++)n=e[r],i=n.opcodenum,s=o.writeUInt8(n.opcodenum,s),n.buf&&(i<$.OP_PUSHDATA1?s+=n.buf.copy(o,s):i===$.OP_PUSHDATA1?(s=o.writeUInt8(n.len,s),s+=n.buf.copy(o,s)):i===$.OP_PUSHDATA2?(s=o.writeUInt16LE(n.len,s),s+=n.buf.copy(o,s)):i===$.OP_PUSHDATA4&&(s=o.writeUInt32LE(n.len,s),s+=n.buf.copy(o,s)));return o};function xc(e){if(!d.Buffer.isBuffer(e))throw new s6.AssertionError({message:"chunk data must be a Buffer",actual:e,expected:"Buffer",operator:"isBuffer"});return e.length}function O1(e){if(/^0x[0-9a-fA-F]{2}$/.test(e)){var t=parseInt(e.slice(2),16);return t>$.OP_PUSHDATA4?t:void 0}}q.fromASM=function(e){var t=new q;if(t.chunks=[],e==="")return t;for(var r=e.split(" "),n=0;n<r.length;){var i=r[n],o=$(i),s=o.toNumber(),a=O1(i);if(a!==void 0)t.chunks.push({opcodenum:a}),n=n+1;else if(i==="0")s=0,t.chunks.push({opcodenum:s}),n=n+1;else if(i==="-1")s=$.OP_1NEGATE,t.chunks.push({opcodenum:s}),n=n+1;else if(Pe.isUndefined(s)){var f=d.Buffer.from(r[n],"hex");if(f.toString("hex")!==r[n])throw new Error("invalid hex string in script");var l=f.length;l>=0&&l<$.OP_PUSHDATA1?s=l:l<Math.pow(2,8)?s=$.OP_PUSHDATA1:l<Math.pow(2,16)?s=$.OP_PUSHDATA2:l<Math.pow(2,32)&&(s=$.OP_PUSHDATA4),t.chunks.push({buf:f,len:f.length,opcodenum:s}),n=n+1}else t.chunks.push({opcodenum:s}),n=n+1}return t};q.fromHex=function(e){return new q(A1.Buffer.from(e,"hex"))};q.fromString=function(e){if(u6.isHexa(e)||e.length===0)return new q(A1.Buffer.from(e,"hex"));var t=new q;t.chunks=[];for(var r=e.split(" "),n=0;n<r.length;){var i=r[n],o=$(i),s=o.toNumber(),a=O1(i);if(a!==void 0)t.chunks.push({opcodenum:a}),n=n+1;else if(Pe.isUndefined(s))if(s=parseInt(i),s>0&&s<$.OP_PUSHDATA1)t.chunks.push({buf:d.Buffer.from(r[n+1].slice(2),"hex"),len:s,opcodenum:s}),n=n+2;else throw new Error("Invalid script: "+JSON.stringify(e));else if(s===$.OP_PUSHDATA1||s===$.OP_PUSHDATA2||s===$.OP_PUSHDATA4){if(r[n+2].slice(0,2)!=="0x")throw new Error("Pushdata data must start with 0x");t.chunks.push({buf:d.Buffer.from(r[n+2].slice(2),"hex"),len:parseInt(r[n+1]),opcodenum:s}),n=n+3}else t.chunks.push({opcodenum:s}),n=n+1}return t};q.prototype._chunkToString=function(e,t){var r=e.opcodenum,n=t==="asm",i="";if(e.buf){var s=r===$.OP_PUSHDATA1||r===$.OP_PUSHDATA2||r===$.OP_PUSHDATA4;!n&&s&&(i=i+" "+$(r).toString()),e.len>0?n?i=i+" "+e.buf.toString("hex"):i=i+" "+e.len+" 0x"+e.buf.toString("hex"):n?i=i+" 0":s?i=i+" 0 0x":i=i+" OP_0"}else if(typeof $.reverseMap[r]<"u")n?r===0?i=i+" 0":r===79?i=i+" -1":i=i+" "+$(r).toString():i=i+" "+$(r).toString();else{var o=r.toString(16);o.length%2!==0&&(o="0"+o),i=i+" 0x"+o}return i};q.prototype.toASM=function(){for(var e="",t=0;t<this.chunks.length;t++){var r=this.chunks[t];e+=this._chunkToString(r,"asm")}return e.substr(1)};q.prototype.toString=function(){for(var e="",t=0;t<this.chunks.length;t++){var r=this.chunks[t];e+=this._chunkToString(r)}return e.substr(1)};q.prototype.toHex=function(){return this.toBuffer().toString("hex")};q.prototype.inspect=function(){return"<Script: "+this.toString()+">"};q.prototype.isPublicKeyHashOut=function(){return!!(this.chunks.length===5&&this.chunks[0].opcodenum===$.OP_DUP&&this.chunks[1].opcodenum===$.OP_HASH160&&this.chunks[2].buf&&this.chunks[2].buf.length===20&&this.chunks[3].opcodenum===$.OP_EQUALVERIFY&&this.chunks[4].opcodenum===$.OP_CHECKSIG)};q.prototype.isPublicKeyHashOutPrefix=function(){return!!(this.chunks.length>=5&&this.chunks[0].opcodenum===$.OP_DUP&&this.chunks[1].opcodenum===$.OP_HASH160&&this.chunks[2].buf&&this.chunks[2].buf.length===20&&this.chunks[3].opcodenum===$.OP_EQUALVERIFY&&this.chunks[4].opcodenum===$.OP_CHECKSIG)};q.prototype.isPublicKeyHashIn=function(){if(this.chunks.length===2){var e=this.chunks[0].buf,t=this.chunks[1].buf;if(e&&e.length&&e[0]===48&&t&&t.length){var r=t[0];if((r===4||r===6||r===7)&&t.length===65)return!0;if((r===3||r===2)&&t.length===33)return!0}}return!1};q.prototype.getPublicKey=function(){return et.checkState(this.isPublicKeyOut(),"Can't retrieve PublicKey from a non-PK output"),this.chunks[0].buf};q.prototype.getPublicKeyHash=function(){return et.checkState(this.isPublicKeyHashOut(),"Can't retrieve PublicKeyHash from a non-PKH output"),this.chunks[2].buf};q.prototype.isPublicKeyOut=function(){if(this.chunks.length===2&&this.chunks[0].buf&&this.chunks[0].buf.length&&this.chunks[1].opcodenum===$.OP_CHECKSIG){var e=this.chunks[0].buf,t=e[0],r=!1;if(((t===4||t===6||t===7)&&e.length===65||(t===3||t===2)&&e.length===33)&&(r=!0),r)return no.isValid(e)}return!1};q.prototype.isPublicKeyIn=function(){if(this.chunks.length===1){var e=this.chunks[0].buf;if(e&&e.length&&e[0]===48)return!0}return!1};q.prototype.isScriptHashOut=function(){var e=this.toBuffer();return e.length===23&&e[0]===$.OP_HASH160&&e[1]===20&&e[e.length-1]===$.OP_EQUAL};q.prototype.isScriptHashIn=function(){if(this.chunks.length<=1)return!1;var e=this.chunks[this.chunks.length-1],t=e.buf;if(!t)return!1;var r;try{r=q.fromBuffer(t)}catch(i){if(i instanceof gp.Script.InvalidBuffer)return!1;throw i}var n=r.classify();return n!==q.types.UNKNOWN};q.prototype.isMultisigOut=function(){return this.chunks.length>3&&$.isSmallIntOp(this.chunks[0].opcodenum)&&this.chunks.slice(1,this.chunks.length-2).every(function(e){return e.buf&&d.Buffer.isBuffer(e.buf)})&&$.isSmallIntOp(this.chunks[this.chunks.length-2].opcodenum)&&this.chunks[this.chunks.length-1].opcodenum===$.OP_CHECKMULTISIG};q.prototype.isMultisigIn=function(){return this.chunks.length>=2&&this.chunks[0].opcodenum===0&&this.chunks.slice(1,this.chunks.length).every(function(e){return e.buf&&d.Buffer.isBuffer(e.buf)&&ro.isTxDER(e.buf)})};q.prototype.isDataOut=function(){var e=this.chunks.length>=1&&this.chunks[0].opcodenum===$.OP_RETURN;if(!e)return!1;var t=this.chunks.slice(1),r=new q({chunks:t});return r.isPushOnly()};q.prototype.isSafeDataOut=function(){if(this.chunks.length<2||this.chunks[0].opcodenum!==$.OP_FALSE)return!1;var e=this.chunks.slice(1),t=new q({chunks:e});return t.isDataOut()};q.prototype.getData=function(){if(this.isSafeDataOut()){var e=this.chunks.slice(2),t=e.map(r=>r.buf);return t}if(this.isDataOut()||this.isScriptHashOut())return Pe.isUndefined(this.chunks[1])?d.Buffer.alloc(0):d.Buffer.from(this.chunks[1].buf);if(this.isPublicKeyHashOut())return d.Buffer.from(this.chunks[2].buf);throw new Error("Unrecognized script type to get data from")};q.prototype.isPushOnly=function(){return Pe.every(this.chunks,function(e){return e.opcodenum<=$.OP_16||e.opcodenum===$.OP_PUSHDATA1||e.opcodenum===$.OP_PUSHDATA2||e.opcodenum===$.OP_PUSHDATA4})};q.types={};q.types.UNKNOWN="Unknown";q.types.PUBKEY_OUT="Pay to public key";q.types.PUBKEY_IN="Spend from public key";q.types.PUBKEYHASH_OUT="Pay to public key hash";q.types.PUBKEYHASH_IN="Spend from public key hash";q.types.SCRIPTHASH_OUT="Pay to script hash";q.types.SCRIPTHASH_IN="Spend from script hash";q.types.MULTISIG_OUT="Pay to multisig";q.types.MULTISIG_IN="Spend from multisig";q.types.DATA_OUT="Data push";q.types.SAFE_DATA_OUT="Safe data push";q.OP_RETURN_STANDARD_SIZE=220;q.prototype.classify=function(){if(this._isInput)return this.classifyInput();if(this._isOutput)return this.classifyOutput();var e=this.classifyOutput();return e!==q.types.UNKNOWN?e:this.classifyInput()};q.outputIdentifiers={};q.outputIdentifiers.PUBKEY_OUT=q.prototype.isPublicKeyOut;q.outputIdentifiers.PUBKEYHASH_OUT=q.prototype.isPublicKeyHashOut;q.outputIdentifiers.MULTISIG_OUT=q.prototype.isMultisigOut;q.outputIdentifiers.SCRIPTHASH_OUT=q.prototype.isScriptHashOut;q.outputIdentifiers.DATA_OUT=q.prototype.isDataOut;q.outputIdentifiers.SAFE_DATA_OUT=q.prototype.isSafeDataOut;q.prototype.classifyOutput=function(){for(var e in q.outputIdentifiers)if(q.outputIdentifiers[e].bind(this)())return q.types[e];return q.types.UNKNOWN};q.inputIdentifiers={};q.inputIdentifiers.PUBKEY_IN=q.prototype.isPublicKeyIn;q.inputIdentifiers.PUBKEYHASH_IN=q.prototype.isPublicKeyHashIn;q.inputIdentifiers.MULTISIG_IN=q.prototype.isMultisigIn;q.inputIdentifiers.SCRIPTHASH_IN=q.prototype.isScriptHashIn;q.prototype.classifyInput=function(){for(var e in q.inputIdentifiers)if(q.inputIdentifiers[e].bind(this)())return q.types[e];return q.types.UNKNOWN};q.prototype.isStandard=function(){return this.classify()!==q.types.UNKNOWN};q.prototype.prepend=function(e){return this._addByType(e,!0),this};q.prototype.equals=function(e){if(et.checkState(e instanceof q,"Must provide another script"),this.chunks.length!==e.chunks.length)return!1;var t;for(t=0;t<this.chunks.length;t++){if(d.Buffer.isBuffer(this.chunks[t].buf)&&!d.Buffer.isBuffer(e.chunks[t].buf)||d.Buffer.isBuffer(this.chunks[t].buf)&&!this.chunks[t].buf.equals(e.chunks[t].buf))return!1;if(this.chunks[t].opcodenum!==e.chunks[t].opcodenum)return!1}return!0};q.prototype.add=function(e){return this._addByType(e,!1),this};q.prototype._addByType=function(e,t){if(typeof e=="string")this._addOpcode(e,t);else if(typeof e=="number")this._addOpcode(e,t);else if(e instanceof $)this._addOpcode(e,t);else if(d.Buffer.isBuffer(e))this._addBuffer(e,t);else if(e instanceof q)this.chunks=this.chunks.concat(e.chunks);else if(typeof e=="object")this._insertAtPosition(e,t);else throw new Error("Invalid script chunk")};q.prototype._insertAtPosition=function(e,t){t?this.chunks.unshift(e):this.chunks.push(e)};q.prototype._addOpcode=function(e,t){var r;return typeof e=="number"?r=e:e instanceof $?r=e.toNumber():r=$(e).toNumber(),this._insertAtPosition({opcodenum:r},t),this};q.prototype._addBuffer=function(e,t){var r,n=e.length;if(n>=0&&n<$.OP_PUSHDATA1)r=n;else if(n<Math.pow(2,8))r=$.OP_PUSHDATA1;else if(n<Math.pow(2,16))r=$.OP_PUSHDATA2;else if(n<Math.pow(2,32))r=$.OP_PUSHDATA4;else throw new Error("You can't push that much data");return this._insertAtPosition({buf:e,len:n,opcodenum:r},t),this};q.prototype.removeCodeseparators=function(){for(var e=[],t=0;t<this.chunks.length;t++)this.chunks[t].opcodenum!==$.OP_CODESEPARATOR&&e.push(this.chunks[t]);return this.chunks=e,this};q.buildMultisigOut=function(e,t,r){et.checkArgument(t<=e.length,"Number of required signatures must be less than or equal to the number of public keys"),r=r||{};var n=new q;n.add($.smallInt(t)),e=Pe.map(e,no);var i=e;r.noSorting||(i=e.map(a=>a.toString("hex")).sort().map(a=>new no(a)));for(var o=0;o<i.length;o++){var s=i[o];n.add(s.toBuffer())}return n.add($.smallInt(e.length)),n.add($.OP_CHECKMULTISIG),n};q.buildMultisigIn=function(e,t,r,n){et.checkArgument(Pe.isArray(e)),et.checkArgument(Pe.isNumber(t)),et.checkArgument(Pe.isArray(r)),n=n||{};var i=new q;return i.add($.OP_0),Pe.each(r,function(o){et.checkArgument(d.Buffer.isBuffer(o),"Signatures must be an array of Buffers"),i.add(o)}),i};q.buildP2SHMultisigIn=function(e,t,r,n){et.checkArgument(Pe.isArray(e)),et.checkArgument(Pe.isNumber(t)),et.checkArgument(Pe.isArray(r)),n=n||{};var i=new q;return i.add($.OP_0),Pe.each(r,function(o){et.checkArgument(d.Buffer.isBuffer(o),"Signatures must be an array of Buffers"),i.add(o)}),i.add((n.cachedMultisig||q.buildMultisigOut(e,t,n)).toBuffer()),i};q.buildPublicKeyHashOut=function(e){et.checkArgument(!Pe.isUndefined(e)),et.checkArgument(e instanceof no||e instanceof Fr||Pe.isString(e)),e instanceof no?e=e.toAddress():Pe.isString(e)&&(e=new Fr(e));var t=new q;return t.add($.OP_DUP).add($.OP_HASH160).add(e.hashBuffer).add($.OP_EQUALVERIFY).add($.OP_CHECKSIG),t._network=e.network,t};q.buildPublicKeyOut=function(e){et.checkArgument(e instanceof no);var t=new q;return t.add(e.toBuffer()).add($.OP_CHECKSIG),t};q.buildDataOut=function(e,t){et.checkArgument(Pe.isUndefined(e)||Pe.isString(e)||Pe.isArray(e)||d.Buffer.isBuffer(e));var r=e;Pe.isArray(r)||(r=[e]);var n=new q;n.add($.OP_RETURN);for(let i of r)et.checkArgument(Pe.isUndefined(i)||Pe.isString(i)||d.Buffer.isBuffer(i)),Pe.isString(i)&&(i=d.Buffer.from(i,t)),Pe.isUndefined(i)||n.add(i);return n};q.buildSafeDataOut=function(e,t){var r=q.buildDataOut(e,t),n=new q;return n.add($.OP_FALSE),n.add(r),n};q.buildScriptHashOut=function(e){et.checkArgument(e instanceof q||e instanceof Fr&&e.isPayToScriptHash());var t=new q;return t.add($.OP_HASH160).add(e instanceof Fr?e.hashBuffer:pp.sha256ripemd160(e.toBuffer())).add($.OP_EQUAL),t._network=e._network||e.network,t};q.buildPublicKeyIn=function(e,t){et.checkArgument(e instanceof ro||d.Buffer.isBuffer(e)),et.checkArgument(Pe.isUndefined(t)||Pe.isNumber(t)),e instanceof ro&&(e=e.toBuffer());var r=new q;return r.add(d.Buffer.concat([e,d.Buffer.from([(t||ro.SIGHASH_ALL)&255])])),r};q.buildPublicKeyHashIn=function(e,t,r){et.checkArgument(t instanceof ro||d.Buffer.isBuffer(t)),et.checkArgument(Pe.isUndefined(r)||Pe.isNumber(r)),t instanceof ro&&(t=t.toBuffer());var n=new q().add(d.Buffer.concat([t,d.Buffer.from([(r||ro.SIGHASH_ALL)&255])])).add(new no(e).toBuffer());return n};q.empty=function(){return new q};q.prototype.toScriptHashOut=function(){return q.buildScriptHashOut(this)};q.fromAddress=function(e){if(e=Fr(e),e.isPayToScriptHash())return q.buildScriptHashOut(e);if(e.isPayToPublicKeyHash())return q.buildPublicKeyHashOut(e);throw new gp.Script.UnrecognizedAddress(e)};q.prototype.getAddressInfo=function(e){if(this._isInput)return this._getInputAddressInfo();if(this._isOutput)return this._getOutputAddressInfo();var t=this._getOutputAddressInfo();return t||this._getInputAddressInfo()};q.prototype._getOutputAddressInfo=function(){var e={};if(this.isScriptHashOut())e.hashBuffer=this.getData(),e.type=Fr.PayToScriptHash;else if(this.isPublicKeyHashOut())e.hashBuffer=this.getData(),e.type=Fr.PayToPublicKeyHash;else return!1;return e};q.prototype._getInputAddressInfo=function(){var e={};if(this.isPublicKeyHashIn())e.hashBuffer=pp.sha256ripemd160(this.chunks[1].buf),e.type=Fr.PayToPublicKeyHash;else if(this.isScriptHashIn())e.hashBuffer=pp.sha256ripemd160(this.chunks[this.chunks.length-1].buf),e.type=Fr.PayToScriptHash;else return!1;return e};q.prototype.toAddress=function(e){var t=this.getAddressInfo();return t?(t.network=I1.get(e)||this._network||I1.defaultNetwork,new Fr(t)):!1};q.prototype.findAndDelete=function(e){for(var t=e.toBuffer(),r=t.length?t[0]:-1,n=0;n<this.chunks.length;n++){var i=this.chunks[n];if(!(i.opcodenum!==r&&f6(i))){var o=q({chunks:[i]}).toBuffer();t.equals(o)&&(this.chunks.splice(n,1),n--)}}return this};function f6(e){var t=e.opcodenum;if(typeof t!="number"||!Number.isInteger(t)||t<0||t>255)return!1;if(!e.buf||t>$.OP_PUSHDATA4)return!0;if(!d.Buffer.isBuffer(e.buf))return!1;var r=e.len;return t===$.OP_PUSHDATA1?Number.isInteger(r)&&r>=0&&r<=255:t===$.OP_PUSHDATA2?Number.isInteger(r)&&r>=0&&r<=65535:t===$.OP_PUSHDATA4?Number.isInteger(r)&&r>=0&&r<=4294967295:!0}q.prototype.checkMinimalPush=function(e){var t=this.chunks[e],r=t.buf,n=t.opcodenum;return r?r.length===0?n===$.OP_0:r.length===1&&r[0]>=1&&r[0]<=16?n===$.OP_1+(r[0]-1):r.length===1&&r[0]===129?n===$.OP_1NEGATE:r.length<=75?n===r.length:r.length<=255?n===$.OP_PUSHDATA1:r.length<=65535?n===$.OP_PUSHDATA2:!0:!0};q.prototype._decodeOP_N=function(e){if(e===$.OP_0)return 0;if(e>=$.OP_1&&e<=$.OP_16)return e-($.OP_1-1);throw new Error("Invalid opcode: "+JSON.stringify(e))};q.prototype.getSignatureOperationsCount=function(e){e=Pe.isUndefined(e)?!0:e;var t=this,r=0,n=$.OP_INVALIDOPCODE;return Pe.each(t.chunks,function(o){var s=o.opcodenum;s===$.OP_CHECKSIG||s===$.OP_CHECKSIGVERIFY?r++:(s===$.OP_CHECKMULTISIG||s===$.OP_CHECKMULTISIGVERIFY)&&(e&&n>=$.OP_1&&n<=$.OP_16?r+=t._decodeOP_N(n):r+=20),n=s}),r};R1.exports=q});var is=B((C5,P1)=>{"use strict";p();var T1=Sa(),at=function e(t){if(!(this instanceof e))return new e(t);this.bufLen=0,t?this.set(t):this.bufs=[]};at.prototype.set=function(e){return this.bufs=e.bufs||this.bufs||[],this.bufLen=this.bufs.reduce(function(t,r){return t+r.length},0),this};at.prototype.toBuffer=function(){return this.concat()};at.prototype.concat=function(){return d.Buffer.concat(this.bufs,this.bufLen)};at.prototype.write=function(e){return T1(d.Buffer.isBuffer(e)),this.bufs.push(e),this.bufLen+=e.length,this};at.prototype.writeReverse=function(e){return T1(d.Buffer.isBuffer(e)),this.bufs.push(d.Buffer.from(e).reverse()),this.bufLen+=e.length,this};at.prototype.writeUInt8=function(e){var t=d.Buffer.alloc(1);return t.writeUInt8(e,0),this.write(t),this};at.prototype.writeUInt16BE=function(e){var t=d.Buffer.alloc(2);return t.writeUInt16BE(e,0),this.write(t),this};at.prototype.writeUInt16LE=function(e){var t=d.Buffer.alloc(2);return t.writeUInt16LE(e,0),this.write(t),this};at.prototype.writeUInt32BE=function(e){var t=d.Buffer.alloc(4);return t.writeUInt32BE(e,0),this.write(t),this};at.prototype.writeInt32LE=function(e){var t=d.Buffer.alloc(4);return t.writeInt32LE(e,0),this.write(t),this};at.prototype.writeUInt32LE=function(e){var t=d.Buffer.alloc(4);return t.writeUInt32LE(e,0),this.write(t),this};at.prototype.writeUInt64BEBN=function(e){var t=e.toBuffer({size:8});return this.write(t),this};at.prototype.writeUInt64LEBN=function(e){var t=e.toBuffer({size:8});return this.writeReverse(t),this};at.prototype.writeVarintNum=function(e){var t=at.varintBufNum(e);return this.write(t),this};at.prototype.writeVarintBN=function(e){var t=at.varintBufBN(e);return this.write(t),this};at.varintBufNum=function(e){var t;return e<253?(t=d.Buffer.alloc(1),t.writeUInt8(e,0)):e<65536?(t=d.Buffer.alloc(3),t.writeUInt8(253,0),t.writeUInt16LE(e,1)):e<4294967296?(t=d.Buffer.alloc(5),t.writeUInt8(254,0),t.writeUInt32LE(e,1)):(t=d.Buffer.alloc(9),t.writeUInt8(255,0),t.writeInt32LE(e&-1,1),t.writeUInt32LE(Math.floor(e/4294967296),5)),t};at.varintBufBN=function(e){var t,r=e.toNumber();if(r<253)t=d.Buffer.alloc(1),t.writeUInt8(r,0);else if(r<65536)t=d.Buffer.alloc(3),t.writeUInt8(253,0),t.writeUInt16LE(r,1);else if(r<4294967296)t=d.Buffer.alloc(5),t.writeUInt8(254,0),t.writeUInt32LE(r,1);else{var n=new at;n.writeUInt8(255),n.writeUInt64LEBN(e),t=n.concat()}return t};P1.exports=at});var Da=B((D5,M1)=>{"use strict";p();var B1=is(),N1=Ca(),c6=Er(),qr=function e(t){if(!(this instanceof e))return new e(t);if(d.Buffer.isBuffer(t))this.buf=t;else if(typeof t=="number"){var r=t;this.fromNumber(r)}else if(t instanceof c6){var n=t;this.fromBN(n)}else if(t){var i=t;this.set(i)}};qr.prototype.set=function(e){return this.buf=e.buf||this.buf,this};qr.prototype.fromString=function(e){return this.set({buf:d.Buffer.from(e,"hex")}),this};qr.prototype.toString=function(){return this.buf.toString("hex")};qr.prototype.fromBuffer=function(e){return this.buf=e,this};qr.prototype.fromBufferReader=function(e){return this.buf=e.readVarintBuf(),this};qr.prototype.fromBN=function(e){return this.buf=B1().writeVarintBN(e).concat(),this};qr.prototype.fromNumber=function(e){return this.buf=B1().writeVarintNum(e).concat(),this};qr.prototype.toBuffer=function(){return this.buf};qr.prototype.toBN=function(){return N1(this.buf).readVarintBN()};qr.prototype.toNumber=function(){return N1(this.buf).readVarintNum()};M1.exports=qr});var Ln=B((F5,C1)=>{"use strict";p();var Ic=Ze(),mp=Er(),k1=Mt(),Ac=gr(),l6=is(),h6=Da(),vp=Hr(),bp=Fe(),d6=Qn(),p6=9007199254740991;function Gt(e){if(!(this instanceof Gt))return new Gt(e);if(Ic.isObject(e))if(this.satoshis=e.satoshis,d.Buffer.isBuffer(e.script))this._scriptBuffer=e.script;else{var t;Ic.isString(e.script)&&Ac.isHexa(e.script)?t=k1.Buffer.from(e.script,"hex"):t=e.script,this.setScript(t)}else throw new TypeError("Unrecognized argument for Output")}Object.defineProperty(Gt.prototype,"script",{configurable:!1,enumerable:!0,get:function(){return this._script?this._script:(this.setScriptFromBuffer(this._scriptBuffer),this._script)}});Object.defineProperty(Gt.prototype,"satoshis",{configurable:!1,enumerable:!0,get:function(){return this._satoshis},set:function(e){e instanceof mp?(this._satoshisBN=e,this._satoshis=e.toNumber()):Ic.isString(e)?(this._satoshis=parseInt(e),this._satoshisBN=mp.fromNumber(this._satoshis)):(bp.checkArgument(Ac.isNaturalNumber(e),"Output satoshis is not a natural number"),this._satoshisBN=mp.fromNumber(e),this._satoshis=e),bp.checkState(Ac.isNaturalNumber(this._satoshis),"Output satoshis is not a natural number")}});Gt.prototype.invalidSatoshis=function(){return this._satoshis>p6?"transaction txout satoshis greater than max safe integer":this._satoshis!==this._satoshisBN.toNumber()?"transaction txout satoshis has corrupted value":this._satoshis<0?"transaction txout negative":!1};Object.defineProperty(Gt.prototype,"satoshisBN",{configurable:!1,enumerable:!0,get:function(){return this._satoshisBN},set:function(e){this._satoshisBN=e,this._satoshis=e.toNumber(),bp.checkState(Ac.isNaturalNumber(this._satoshis),"Output satoshis is not a natural number")}});Gt.prototype.toObject=Gt.prototype.toJSON=function(){var t={satoshis:this.satoshis};return t.script=this._scriptBuffer.toString("hex"),t};Gt.fromObject=function(e){return new Gt(e)};Gt.prototype.setScriptFromBuffer=function(e){this._scriptBuffer=e;try{this._script=vp.fromBuffer(this._scriptBuffer),this._script._isOutput=!0}catch(t){if(t instanceof d6.Script.InvalidBuffer)this._script=null;else throw t}};Gt.prototype.setScript=function(e){if(e instanceof vp)this._scriptBuffer=e.toBuffer(),this._script=e,this._script._isOutput=!0;else if(Ic.isString(e))this._script=vp.fromString(e),this._scriptBuffer=this._script.toBuffer(),this._script._isOutput=!0;else if(d.Buffer.isBuffer(e))this.setScriptFromBuffer(e);else throw new TypeError("Invalid argument type: script");return this};Gt.prototype.inspect=function(){var e;return this.script?e=this.script.inspect():e=this._scriptBuffer.toString("hex"),"<Output ("+this.satoshis+" sats) "+e+">"};Gt.fromBufferReader=function(e){var t={};t.satoshis=e.readUInt64LEBN();var r=e.readVarintNum();return r!==0?t.script=e.read(r):t.script=k1.Buffer.from([]),new Gt(t)};Gt.prototype.toBufferWriter=function(e){e||(e=new l6),e.writeUInt64LEBN(this._satoshisBN);var t=this._scriptBuffer;return e.writeVarintNum(t.length),e.write(t),e};Gt.prototype.getSize=function(){var e=this.script.toBuffer().length,t=h6(e).toBuffer().length;return 8+t+e};C1.exports=Gt});var Ua=B((H5,L1)=>{"use strict";p();var yr=Er(),ln=ci(),g6=or(),y6=Or(),m6=ta(),vi=er(),v6=Ze(),_p=Fe(),ze=function e(t){if(!(this instanceof e))return new e(t);t&&this.set(t)};Object.defineProperty(ze.prototype,"k",{get:function(){return this._k},set:function(e){this._k=e,this._kFresh=!0},enumerable:!0,configurable:!0});ze.prototype.set=function(e){if(this.hashbuf=e.hashbuf||this.hashbuf,this.endian=e.endian||this.endian,this.privkey=e.privkey||this.privkey,this.pubkey=e.pubkey||(this.privkey?this.privkey.publicKey:this.pubkey),e.sig)if(d.Buffer.isBuffer(e.sig)){var t=or();this.sig=t.fromDER(e.sig)}else this.sig=e.sig;else this.sig=this.sig;return e.k&&(this.k=e.k),this.verified=e.verified||this.verified,this};ze.prototype.privkey2pubkey=function(){this.pubkey=this.privkey.toPublicKey()};ze.prototype.calci=function(){for(var e=0;e<4;e++){this.sig.i=e;var t;try{t=this.toPublicKey()}catch(r){console.error(r);continue}if(t.point.eq(this.pubkey.point))return this.sig.compressed=this.pubkey.compressed,this}throw this.sig.i=void 0,new Error("Unable to find valid recovery factor")};ze.fromString=function(e){var t=JSON.parse(e);return new ze(t)};ze.prototype.randomK=function(){var e=ln.getN(),t;do t=yr.fromBuffer(m6.getRandomBuffer(32));while(!(t.lt(e)&&t.gt(yr.Zero)));return this.k=t,this};ze.prototype.deterministicK=function(e){v6.isUndefined(e)&&(e=0);var t=d.Buffer.alloc(32);t.fill(1);var r=d.Buffer.alloc(32);r.fill(0);var n=this.privkey.bn.toBuffer({size:32}),i=this.endian==="little"?d.Buffer.from(this.hashbuf).reverse():this.hashbuf;r=vi.sha256hmac(d.Buffer.concat([t,d.Buffer.from([0]),n,i]),r),t=vi.sha256hmac(t,r),r=vi.sha256hmac(d.Buffer.concat([t,d.Buffer.from([1]),n,i]),r),t=vi.sha256hmac(t,r),t=vi.sha256hmac(t,r);for(var o=yr.fromBuffer(t),s=ln.getN(),a=0;a<e||!(o.lt(s)&&o.gt(yr.Zero));a++)r=vi.sha256hmac(d.Buffer.concat([t,d.Buffer.from([0])]),r),t=vi.sha256hmac(t,r),t=vi.sha256hmac(t,r),o=yr.fromBuffer(t);return this.k=o,this};ze.prototype.toPublicKey=function(){var e=this.sig.i;_p.checkArgument(e===0||e===1||e===2||e===3,new Error("i must be equal to 0, 1, 2, or 3"));var t=yr.fromBuffer(this.hashbuf),r=this.sig.r,n=this.sig.s,i=e&1,o=e>>1,s=ln.getN(),a=ln.getG(),f=o?r.add(s):r,l=ln.fromX(i,f),y=l.mul(s);if(!y.isInfinity())throw new Error("nR is not a valid curve point");var g=t.neg().umod(s),v=r.invm(s),E=l.mul(n).add(a.mul(g)).mul(v),T=y6.fromPoint(E,this.sig.compressed);return T};ze.prototype.sigError=function(){if(!d.Buffer.isBuffer(this.hashbuf)||this.hashbuf.length!==32)return"hashbuf must be a 32 byte buffer";var e=this.sig.r,t=this.sig.s,r=ln.getN();try{if(e.lte(yr.Zero)||t.lte(yr.Zero)||e.gte(r)||t.gte(r))return"r and s not in range";var n=yr.fromBuffer(this.hashbuf,this.endian?{endian:this.endian}:void 0),i=t.invm(r),o=i.mul(n).umod(r),s=i.mul(e).umod(r),a=ln.getG().mulAdd(o,this.pubkey.point,s);return a.isInfinity()?"p is infinity":a.getX().umod(r).cmp(e)!==0?"Invalid signature":!1}catch(f){return"Signature security validation failed: "+f.message}};ze.toLowS=function(e){return e.gt(yr.fromBuffer(d.Buffer.from("7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0","hex")))&&(e=ln.getN().sub(e)),e};ze.prototype._findSignature=function(e,t){var r=ln.getN(),n=ln.getG(),i=0,o,s,a,f;do(!this.k||!this._kFresh||i>0)&&this.deterministicK(i),i++,o=this.k,s=n.mul(o),a=s.x.umod(r),f=o.invm(r).mul(t.add(e.mul(a))).umod(r);while(a.cmp(yr.Zero)<=0||f.cmp(yr.Zero)<=0);return this._kFresh=!1,f=ze.toLowS(f),{s:f,r:a}};ze.prototype.sign=function(){var e=this.hashbuf,t=this.privkey,r=t.bn;_p.checkState(e&&t&&r,new Error("invalid parameters")),_p.checkState(d.Buffer.isBuffer(e)&&e.length===32,new Error("hashbuf must be a 32 byte buffer"));var n=yr.fromBuffer(e,this.endian?{endian:this.endian}:void 0),i=this._findSignature(r,n);return i.compressed=this.pubkey.compressed,this.sig=new g6(i),this};ze.prototype.signRandomK=function(){return this.randomK(),this.sign()};ze.prototype.toString=function(){var e={};return this.hashbuf&&(e.hashbuf=this.hashbuf.toString("hex")),this.privkey&&(e.privkey=this.privkey.toString()),this.pubkey&&(e.pubkey=this.pubkey.toString()),this.sig&&(e.sig=this.sig.toString()),this.k&&(e.k=this.k.toString()),JSON.stringify(e)};ze.prototype.verify=function(){return this.verified=!this.sigError(),this.verified};ze.prototype.verifyBool=function(){return this.verify()===!0};ze.sign=function(e,t,r){return ze().set({hashbuf:e,endian:r,privkey:t}).sign().sig};ze.signWithCalcI=function(e,t,r){return ze().set({hashbuf:e,endian:r,privkey:t}).sign().calci().sig};ze.signRandomK=function(e,t,r){return ze().set({hashbuf:e,endian:r,privkey:t}).signRandomK().sig};ze.verify=function(e,t,r,n){return ze().set({hashbuf:e,endian:n,sig:t,pubkey:r}).verify()};L1.exports=ze});var os=B((K5,q1)=>{"use strict";p();var bi=Ze(),b6=Fe(),Fa=Qn(),_6=is(),Sp=Mt(),U1=gr(),Oc=Hr(),S6=_i(),D1=Ln(),Rc=4294967295,w6=Rc-2,F1=Rc,E6=Rc-1;function Ye(e){if(!(this instanceof Ye))return new Ye(e);if(e)return this._fromObject(e)}Ye.MAXINT=Rc;Ye.DEFAULT_SEQNUMBER=F1;Ye.DEFAULT_LOCKTIME_SEQNUMBER=E6;Ye.DEFAULT_RBF_SEQNUMBER=w6;Ye.BASE_SIZE=40;Object.defineProperty(Ye.prototype,"script",{configurable:!1,enumerable:!0,get:function(){return this.isNull()?null:(this._script||(this._script=new Oc(this._scriptBuffer),this._script._isInput=!0),this._script)}});Ye.fromObject=function(e){b6.checkArgument(bi.isObject(e));var t=new Ye;return t._fromObject(e)};Ye.prototype._fromObject=function(e){var t;if(bi.isString(e.prevTxId)&&U1.isHexa(e.prevTxId)?t=Sp.Buffer.from(e.prevTxId,"hex"):t=e.prevTxId,this.output=e.output?e.output instanceof D1?e.output:new D1(e.output):void 0,this.prevTxId=t||e.txidbuf,this.outputIndex=bi.isUndefined(e.outputIndex)?e.txoutnum:e.outputIndex,this.sequenceNumber=bi.isUndefined(e.sequenceNumber)?bi.isUndefined(e.seqnum)?F1:e.seqnum:e.sequenceNumber,bi.isUndefined(e.script)&&bi.isUndefined(e.scriptBuffer))throw new Fa.Transaction.Input.MissingScript;return this.setScript(e.scriptBuffer||e.script),this};Ye.prototype.toObject=Ye.prototype.toJSON=function(){var t={prevTxId:this.prevTxId.toString("hex"),outputIndex:this.outputIndex,sequenceNumber:this.sequenceNumber,script:this._scriptBuffer.toString("hex")};return this.script&&(t.scriptString=this.script.toString()),this.output&&(t.output=this.output.toObject()),t};Ye.fromBufferReader=function(e){var t=new Ye;return t.prevTxId=e.readReverse(32),t.outputIndex=e.readUInt32LE(),t._scriptBuffer=e.readVarLengthBuffer(),t.sequenceNumber=e.readUInt32LE(),t};Ye.prototype.toBufferWriter=function(e){e||(e=new _6),e.writeReverse(this.prevTxId),e.writeUInt32LE(this.outputIndex);var t=this._scriptBuffer;return e.writeVarintNum(t.length),e.write(t),e.writeUInt32LE(this.sequenceNumber),e};Ye.prototype.setScript=function(e){if(this._script=null,e instanceof Oc)this._script=e,this._script._isInput=!0,this._scriptBuffer=e.toBuffer();else if(e===null)this._script=Oc.empty(),this._script._isInput=!0,this._scriptBuffer=this._script.toBuffer();else if(U1.isHexa(e))this._scriptBuffer=Sp.Buffer.from(e,"hex");else if(bi.isString(e))this._script=new Oc(e),this._script._isInput=!0,this._scriptBuffer=this._script.toBuffer();else if(d.Buffer.isBuffer(e))this._scriptBuffer=Sp.Buffer.from(e);else throw new TypeError("Invalid argument type: script");return this};Ye.prototype.getSignatures=function(){throw new Fa.AbstractMethodInvoked("Trying to sign unsupported output type (only P2PKH and P2SH multisig inputs are supported) for input: "+JSON.stringify(this))};Ye.prototype.isFullySigned=function(){throw new Fa.AbstractMethodInvoked("Input#isFullySigned")};Ye.prototype.isFinal=function(){return this.sequenceNumber===Ye.MAXINT};Ye.prototype.addSignature=function(){throw new Fa.AbstractMethodInvoked("Input#addSignature")};Ye.prototype.clearSignatures=function(){throw new Fa.AbstractMethodInvoked("Input#clearSignatures")};Ye.prototype.isValidSignature=function(e,t){return t.signature.nhashtype=t.sigtype,S6.verify(e,t.signature,t.publicKey,t.inputIndex,this.output.script,this.output.satoshisBN)};Ye.prototype.isNull=function(){return this.prevTxId.toString("hex")==="0000000000000000000000000000000000000000000000000000000000000000"&&this.outputIndex===4294967295};Ye.prototype._estimateSize=function(){return this.toBufferWriter().toBuffer().length};q1.exports=Ye});var ss=B((V5,H1)=>{"use strict";p();H1.exports=function(t,r){r&&(t.super_=r,t.prototype=Object.create(r.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}});var us=B((z5,G1)=>{"use strict";p();var as=Ze(),Rr=Fe(),x6=ss(),j1=gr(),K1=Or(),I6=Qn(),qa=or();function jr(e){if(!(this instanceof jr))return new jr(e);if(e instanceof jr)return e;if(as.isObject(e))return this._fromObject(e);throw new I6.InvalidArgument("TransactionSignatures must be instantiated from an object")}x6(jr,qa);jr.prototype._fromObject=function(e){return this._checkObjectArgs(e),this.publicKey=new K1(e.publicKey),this.prevTxId=d.Buffer.isBuffer(e.prevTxId)?e.prevTxId:d.Buffer.from(e.prevTxId,"hex"),this.outputIndex=e.outputIndex,this.inputIndex=e.inputIndex,this.signature=e.signature instanceof qa?e.signature:d.Buffer.isBuffer(e.signature)?qa.fromBuffer(e.signature):qa.fromString(e.signature),this.sigtype=e.sigtype,this};jr.prototype._checkObjectArgs=function(e){Rr.checkArgument(K1(e.publicKey),"publicKey"),Rr.checkArgument(!as.isUndefined(e.inputIndex),"inputIndex"),Rr.checkArgument(!as.isUndefined(e.outputIndex),"outputIndex"),Rr.checkState(as.isNumber(e.inputIndex),"inputIndex must be a number"),Rr.checkState(as.isNumber(e.outputIndex),"outputIndex must be a number"),Rr.checkArgument(e.signature,"signature"),Rr.checkArgument(e.prevTxId,"prevTxId"),Rr.checkState(e.signature instanceof qa||d.Buffer.isBuffer(e.signature)||j1.isHexa(e.signature),"signature must be a buffer or hexa value"),Rr.checkState(d.Buffer.isBuffer(e.prevTxId)||j1.isHexa(e.prevTxId),"prevTxId must be a buffer or hexa value"),Rr.checkArgument(e.sigtype,"sigtype"),Rr.checkState(as.isNumber(e.sigtype),"sigtype must be a number")};jr.prototype.toObject=jr.prototype.toJSON=function(){return{publicKey:this.publicKey.toString(),prevTxId:this.prevTxId.toString("hex"),outputIndex:this.outputIndex,inputIndex:this.inputIndex,signature:this.signature.toString(),sigtype:this.sigtype}};jr.fromObject=function(e){return Rr.checkArgument(e),new jr(e)};G1.exports=jr});var $1=B(($5,Y1)=>{"use strict";p();var A6=ss(),W1=Fe(),wp=os(),O6=Ln(),R6=_i(),z1=Hr(),V1=or(),T6=us();function Dn(){wp.apply(this,arguments)}A6(Dn,wp);Dn.prototype.getSignatures=function(e,t,r,n){W1.checkState(this.output instanceof O6),n=n||V1.SIGHASH_ALL|V1.SIGHASH_FORKID;var i=t.toPublicKey();return i.toString()===this.output.script.getPublicKey().toString("hex")?[new T6({publicKey:i,prevTxId:this.prevTxId,outputIndex:this.outputIndex,inputIndex:r,signature:R6.sign(e,t,n,r,this.output.script,this.output.satoshisBN),sigtype:n})]:[]};Dn.prototype.addSignature=function(e,t){return W1.checkState(this.isValidSignature(e,t),"Signature is invalid"),this.setScript(z1.buildPublicKeyIn(t.signature.toDER(),t.sigtype)),this};Dn.prototype.clearSignatures=function(){return this.setScript(z1.empty()),this};Dn.prototype.isFullySigned=function(){return this.script.isPublicKeyIn()};Dn.SCRIPT_MAX_SIZE=74;Dn.prototype._estimateSize=function(){return wp.BASE_SIZE+Dn.SCRIPT_MAX_SIZE};Y1.exports=Dn});var ex=B((X5,Q1)=>{"use strict";p();var P6=ss(),X1=Fe(),B6=er(),Ep=os(),N6=Ln(),M6=_i(),J1=Hr(),Z1=or(),k6=us();function Un(){Ep.apply(this,arguments)}P6(Un,Ep);Un.prototype.getSignatures=function(e,t,r,n,i){X1.checkState(this.output instanceof N6),i=i||B6.sha256ripemd160(t.publicKey.toBuffer()),n=n||Z1.SIGHASH_ALL|Z1.SIGHASH_FORKID;var o=this.output.script.chunks[2]&&this.output.script.chunks[2].buf;return o&&i.equals(o)?[new k6({publicKey:t.publicKey,prevTxId:this.prevTxId,outputIndex:this.outputIndex,inputIndex:r,signature:M6.sign(e,t,n,r,this.output.script,this.output.satoshisBN),sigtype:n})]:[]};Un.prototype.addSignature=function(e,t){return X1.checkState(this.isValidSignature(e,t),"Signature is invalid"),this.setScript(J1.buildPublicKeyHashIn(t.publicKey,t.signature.toDER(),t.sigtype)),this};Un.prototype.clearSignatures=function(){return this.setScript(J1.empty()),this};Un.prototype.isFullySigned=function(){return this.script.isPublicKeyHashIn()};Un.SCRIPT_MAX_SIZE=108;Un.prototype._estimateSize=function(){return Ep.BASE_SIZE+Un.SCRIPT_MAX_SIZE};Q1.exports=Un});var nx=B((Q5,rx)=>{"use strict";p();var Kr=Ze(),C6=ss(),Pc=os(),L6=Ln(),Ha=Fe(),tx=Hr(),Tc=or(),xp=_i(),Ip=us(),D6=Or(),U6=Da();function Lt(e,t,r,n){Pc.apply(this,arguments);var i=this;t=t||e.publicKeys,r=r||e.threshold,n=n||e.signatures,this.publicKeys=t.map(o=>o.toString("hex")).sort().map(o=>new D6(o)),Ha.checkState(tx.buildMultisigOut(this.publicKeys,r).equals(this.output.script),"Provided public keys don't match to the provided output script"),this.publicKeyIndex={},Kr.each(this.publicKeys,function(o,s){i.publicKeyIndex[o.toString()]=s}),this.threshold=r,this.signatures=n?this._deserializeSignatures(n):new Array(this.publicKeys.length)}C6(Lt,Pc);Lt.prototype.toObject=function(){var e=Pc.prototype.toObject.apply(this,arguments);return e.threshold=this.threshold,e.publicKeys=Kr.map(this.publicKeys,function(t){return t.toString()}),e.signatures=this._serializeSignatures(),e};Lt.prototype._deserializeSignatures=function(e){return Kr.map(e,function(t){if(t)return new Ip(t)})};Lt.prototype._serializeSignatures=function(){return Kr.map(this.signatures,function(e){if(e)return e.toObject()})};Lt.prototype.getSignatures=function(e,t,r,n){Ha.checkState(this.output instanceof L6),n=n||Tc.SIGHASH_ALL|Tc.SIGHASH_FORKID;var i=this,o=[];return Kr.each(this.publicKeys,function(s){s.toString()===t.publicKey.toString()&&o.push(new Ip({publicKey:t.publicKey,prevTxId:i.prevTxId,outputIndex:i.outputIndex,inputIndex:r,signature:xp.sign(e,t,n,r,i.output.script,i.output.satoshisBN),sigtype:n}))}),o};Lt.prototype.addSignature=function(e,t){return Ha.checkState(!this.isFullySigned(),"All needed signatures have already been added"),Ha.checkArgument(!Kr.isUndefined(this.publicKeyIndex[t.publicKey.toString()]),"Signature has no matching public key"),Ha.checkState(this.isValidSignature(e,t)),this.signatures[this.publicKeyIndex[t.publicKey.toString()]]=t,this._updateScript(),this};Lt.prototype._updateScript=function(){return this.setScript(tx.buildMultisigIn(this.publicKeys,this.threshold,this._createSignatures())),this};Lt.prototype._createSignatures=function(){return Kr.map(Kr.filter(this.signatures,function(e){return!Kr.isUndefined(e)}),function(e){return d.Buffer.concat([e.signature.toDER(),d.Buffer.from([e.sigtype&255])])})};Lt.prototype.clearSignatures=function(){this.signatures=new Array(this.publicKeys.length),this._updateScript()};Lt.prototype.isFullySigned=function(){return this.countSignatures()===this.threshold};Lt.prototype.countMissingSignatures=function(){return this.threshold-this.countSignatures()};Lt.prototype.countSignatures=function(){return Kr.reduce(this.signatures,function(e,t){return e+!!t},0)};Lt.prototype.publicKeysWithoutSignature=function(){var e=this;return Kr.filter(this.publicKeys,function(t){return!e.signatures[e.publicKeyIndex[t.toString()]]})};Lt.prototype.isValidSignature=function(e,t){return t.signature.nhashtype=t.sigtype,xp.verify(e,t.signature,t.publicKey,t.inputIndex,this.output.script,this.output.satoshisBN)};Lt.normalizeSignatures=function(e,t,r,n,i){return i.map(function(o){var s=null;return n=n.filter(function(a){if(s)return!0;var f=new Ip({signature:Tc.fromTxFormat(a),publicKey:o,prevTxId:t.prevTxId,outputIndex:t.outputIndex,inputIndex:r,sigtype:Tc.SIGHASH_ALL});f.signature.nhashtype=f.sigtype;var l=xp.verify(e,f.signature,f.publicKey,f.inputIndex,t.output.script);return l?(s=f,!1):!0}),s||null})};Lt.SIGNATURE_SIZE=73;Lt.prototype._estimateSize=function(){var e=1+this.threshold*Lt.SIGNATURE_SIZE;return Pc.BASE_SIZE+U6(e).toBuffer().length+e};rx.exports=Lt});var ux=B((tq,ax)=>{"use strict";p();var Gr=Ze(),F6=ss(),Bc=os(),q6=Ln(),ja=Fe(),Ap=Hr(),ix=or(),ox=_i(),sx=us(),H6=Or(),j6=Da();function Bt(e,t,r,n){Bc.apply(this,arguments);var i=this;t=t||e.publicKeys,r=r||e.threshold,n=n||e.signatures,this.publicKeys=t.map(o=>o.toString("hex")).sort().map(o=>new H6(o)),this.redeemScript=Ap.buildMultisigOut(this.publicKeys,r),ja.checkState(Ap.buildScriptHashOut(this.redeemScript).equals(this.output.script),"Provided public keys don't hash to the provided output"),this.publicKeyIndex={},Gr.each(this.publicKeys,function(o,s){i.publicKeyIndex[o.toString()]=s}),this.threshold=r,this.signatures=n?this._deserializeSignatures(n):new Array(this.publicKeys.length)}F6(Bt,Bc);Bt.prototype.toObject=function(){var e=Bc.prototype.toObject.apply(this,arguments);return e.threshold=this.threshold,e.publicKeys=Gr.map(this.publicKeys,function(t){return t.toString()}),e.signatures=this._serializeSignatures(),e};Bt.prototype._deserializeSignatures=function(e){return Gr.map(e,function(t){if(t)return new sx(t)})};Bt.prototype._serializeSignatures=function(){return Gr.map(this.signatures,function(e){if(e)return e.toObject()})};Bt.prototype.getSignatures=function(e,t,r,n){ja.checkState(this.output instanceof q6),n=n||ix.SIGHASH_ALL|ix.SIGHASH_FORKID;var i=this,o=[];return Gr.each(this.publicKeys,function(s){s.toString()===t.publicKey.toString()&&o.push(new sx({publicKey:t.publicKey,prevTxId:i.prevTxId,outputIndex:i.outputIndex,inputIndex:r,signature:ox.sign(e,t,n,r,i.redeemScript,i.output.satoshisBN),sigtype:n}))}),o};Bt.prototype.addSignature=function(e,t){return ja.checkState(!this.isFullySigned(),"All needed signatures have already been added"),ja.checkArgument(!Gr.isUndefined(this.publicKeyIndex[t.publicKey.toString()]),"Signature has no matching public key"),ja.checkState(this.isValidSignature(e,t)),this.signatures[this.publicKeyIndex[t.publicKey.toString()]]=t,this._updateScript(),this};Bt.prototype._updateScript=function(){return this.setScript(Ap.buildP2SHMultisigIn(this.publicKeys,this.threshold,this._createSignatures(),{cachedMultisig:this.redeemScript})),this};Bt.prototype._createSignatures=function(){return Gr.map(Gr.filter(this.signatures,function(e){return!Gr.isUndefined(e)}),function(e){return d.Buffer.concat([e.signature.toDER(),d.Buffer.from([e.sigtype&255])])})};Bt.prototype.clearSignatures=function(){this.signatures=new Array(this.publicKeys.length),this._updateScript()};Bt.prototype.isFullySigned=function(){return this.countSignatures()===this.threshold};Bt.prototype.countMissingSignatures=function(){return this.threshold-this.countSignatures()};Bt.prototype.countSignatures=function(){return Gr.reduce(this.signatures,function(e,t){return e+!!t},0)};Bt.prototype.publicKeysWithoutSignature=function(){var e=this;return Gr.filter(this.publicKeys,function(t){return!e.signatures[e.publicKeyIndex[t.toString()]]})};Bt.prototype.isValidSignature=function(e,t){return t.signature.nhashtype=t.sigtype,ox.verify(e,t.signature,t.publicKey,t.inputIndex,this.redeemScript,this.output.satoshisBN)};Bt.SIGNATURE_SIZE=73;Bt.PUBKEY_SIZE=34;Bt.prototype._estimateSize=function(){var e=this.publicKeys.length*Bt.PUBKEY_SIZE,t=this.threshold*Bt.SIGNATURE_SIZE,r=3+e,n=r<=75?1:r<=255?2:3,i=t+1+n+r;return Bc.BASE_SIZE+j6(i).toBuffer().length+i};ax.exports=Bt});var Nc=B((nq,fs)=>{p();fs.exports=os();fs.exports.PublicKey=$1();fs.exports.PublicKeyHash=ex();fs.exports.MultiSig=nx();fs.exports.MultiSigScriptHash=ux()});var _i=B((oq,dx)=>{"use strict";p();var K6=Mt(),cr=or(),Ka=Hr(),G6=Ln(),V6=Ca(),Ga=is(),fx=Er(),Mc=er(),cx=Ua(),Op=Fe(),Rp=kc(),Si=Ze(),lx=d.Buffer.from("0000000000000000000000000000000000000000000000000000000000000001","hex"),W6="ffffffffffffffff",z6=Rp.SCRIPT_ENABLE_SIGHASH_FORKID,Y6=function(e,t,r,n,i){var o=e.inputs[r];Op.checkArgument(i instanceof fx,"For ForkId=0 signatures, satoshis or complete input must be provided");function s(L){var F=new Ga;Si.each(L.inputs,function(G){F.writeReverse(G.prevTxId),F.writeUInt32LE(G.outputIndex)});var V=F.toBuffer(),z=Mc.sha256sha256(V);return z}function a(L){var F=new Ga;Si.each(L.inputs,function(G){F.writeUInt32LE(G.sequenceNumber)});var V=F.toBuffer(),z=Mc.sha256sha256(V);return z}function f(L,F){var V=new Ga;Si.isUndefined(F)?Si.each(L.outputs,function(ie){ie.toBufferWriter(V)}):L.outputs[F].toBufferWriter(V);var z=V.toBuffer(),G=Mc.sha256sha256(z);return G}var l=d.Buffer.alloc(32),y=d.Buffer.alloc(32),g=d.Buffer.alloc(32);t&cr.SIGHASH_ANYONECANPAY||(l=s(e)),!(t&cr.SIGHASH_ANYONECANPAY)&&(t&31)!==cr.SIGHASH_SINGLE&&(t&31)!==cr.SIGHASH_NONE&&(y=a(e)),(t&31)!==cr.SIGHASH_SINGLE&&(t&31)!==cr.SIGHASH_NONE?g=f(e):(t&31)===cr.SIGHASH_SINGLE&&r<e.outputs.length&&(g=f(e,r));var v=new Ga;v.writeInt32LE(e.version),v.write(l),v.write(y),v.writeReverse(o.prevTxId),v.writeUInt32LE(o.outputIndex);var E=n.toBuffer();v.writeVarintNum(E.length),v.write(E),v.writeUInt64LEBN(i);var T=o.sequenceNumber;v.writeUInt32LE(T),v.write(g),v.writeUInt32LE(e.nLockTime),v.writeUInt32LE(t>>>0);var M=v.toBuffer();return M},hx=function(t,r,n,i,o,s){var a=Pp(),f=Nc();Si.isUndefined(s)&&(s=z6);var l=a.shallowCopy(t);if(i instanceof Ka||(i=new Ka(i)),s&Rp.SCRIPT_ENABLE_REPLAY_PROTECTION){var y=r>>8,g=16711680|y^57005;r=g<<8|r&255}if(r&cr.SIGHASH_FORKID&&!(r&cr.SIGHASH_CHRONICLE)&&s&Rp.SCRIPT_ENABLE_SIGHASH_FORKID)return Y6(l,r,n,i,o);i=new Ka(i),i.removeCodeseparators();var v;for(v=0;v<l.inputs.length;v++)l.inputs[v]=new f(l.inputs[v]).setScript(Ka.empty());if(l.inputs[n]=new f(l.inputs[n]).setScript(i),(r&31)===cr.SIGHASH_NONE||(r&31)===cr.SIGHASH_SINGLE)for(v=0;v<l.inputs.length;v++)v!==n&&(l.inputs[v].sequenceNumber=0);if((r&31)===cr.SIGHASH_NONE)l.outputs=[];else if((r&31)===cr.SIGHASH_SINGLE){if(n>=l.outputs.length)return lx;for(l.outputs.length=n+1,v=0;v<n;v++)l.outputs[v]=new G6({satoshis:fx.fromBuffer(K6.Buffer.from(W6,"hex")),script:Ka.empty()})}r&cr.SIGHASH_ANYONECANPAY&&(l.inputs=[l.inputs[n]]);var E=new Ga().write(l.toBuffer()).writeInt32LE(r).toBuffer();return E},Tp=function(t,r,n,i,o,s){var a=hx(t,r,n,i,o,s);if(a.compare(lx)===0)return a;var f=Mc.sha256sha256(a);return f=new V6(f).readReverse(),f};function $6(e,t,r,n,i,o,s){var a=Tp(e,r,n,i,o,s),f=cx.sign(a,t,"little").set({nhashtype:r});return f}function Z6(e,t,r,n,i,o,s){Op.checkArgument(!Si.isUndefined(e)),Op.checkArgument(!Si.isUndefined(t)&&!Si.isUndefined(t.nhashtype));var a=Tp(e,t.nhashtype,n,i,o,s);return cx.verify(a,t,r,"little")}dx.exports={sighashPreimage:hx,sighash:Tp,sign:$6,verify:Z6}});var Bp=B((aq,gx)=>{"use strict";p();var Fn=Ze(),Cc=Fe(),px=gr(),X6=Hr(),J6=io();function qn(e){if(!(this instanceof qn))return new qn(e);Cc.checkArgument(Fn.isObject(e),"Must provide an object from where to extract data");var t=e.address?new J6(e.address):void 0,r=e.txid?e.txid:e.txId;if(!r||!px.isHexaString(r)||r.length>64)throw new Error("Invalid TXID in object",e);var n=Fn.isUndefined(e.vout)?e.outputIndex:e.vout;if(!Fn.isNumber(n))throw new Error("Invalid outputIndex, received "+n);Cc.checkArgument(!Fn.isUndefined(e.scriptPubKey)||!Fn.isUndefined(e.script),"Must provide the scriptPubKey for that output!");var i=new X6(e.scriptPubKey||e.script);Cc.checkArgument(!Fn.isUndefined(e.amount)||!Fn.isUndefined(e.satoshis),"Must provide an amount for the output");var o=Fn.isUndefined(e.amount)?e.satoshis:Math.round(e.amount*1e8);Cc.checkArgument(Fn.isNumber(o),"Amount must be a number"),px.defineImmutable(this,{address:t,txId:r,outputIndex:n,script:i,satoshis:o})}qn.prototype.inspect=function(){return"<UnspentOutput: "+this.txId+":"+this.outputIndex+", satoshis: "+this.satoshis+", address: "+this.address+">"};qn.prototype.toString=function(){return this.txId+":"+this.outputIndex};qn.fromObject=function(e){return new qn(e)};qn.prototype.toObject=qn.prototype.toJSON=function(){return{address:this.address?this.address.toString():void 0,txid:this.txId,vout:this.outputIndex,scriptPubKey:this.script.toBuffer().toString("hex"),amount:Number.parseFloat((this.satoshis/1e8).toFixed(8))}};gx.exports=qn});var Pp=B((fq,Ex)=>{"use strict";p();var ge=Ze(),Vt=Fe(),Q6=Mt(),Ut=Qn(),mx=gr(),vx=Ca(),eC=is(),yx=Da(),bx=er(),Dc=or(),_x=_i(),tC=io(),Sx=Bp(),Dt=Nc(),rC=Dt.PublicKeyHash,nC=Dt.PublicKey,iC=Dt.MultiSigScriptHash,oC=Dt.MultiSig,Vr=Ln(),hn=Hr(),sC=oo(),Lc=Er(),aC=kc(),uC=aC.SCRIPT_ENABLE_SIGHASH_FORKID;function Y(e){if(!(this instanceof Y))return new Y(e);if(this.inputs=[],this.outputs=[],this._inputAmount=void 0,this._outputAmount=void 0,e){if(e instanceof Y)return Y.shallowCopy(e);if(mx.isHexa(e))this.fromString(e);else if(d.Buffer.isBuffer(e))this.fromBuffer(e);else if(ge.isObject(e))this.fromObject(e);else throw new Ut.InvalidArgument("Must provide an object or string to deserialize a transaction")}else this._newTransaction()}var fC=1,cC=0,lC=1e6;Y.DUST_AMOUNT=546;Y.FEE_SECURITY_MARGIN=150;Y.MAX_MONEY=21e6*1e8;Y.NLOCKTIME_BLOCKHEIGHT_LIMIT=5e8;Y.NLOCKTIME_MAX_VALUE=4294967295;Y.FEE_PER_KB=500;Y.CHANGE_OUTPUT_MAX_SIZE=62;Y.shallowCopy=function(e){var t=new Y(e.toBuffer());return t};var wx={configurable:!1,enumerable:!0,get:function(){return this._hash=new vx(this._getHash()).readReverse().toString("hex"),this._hash}};Object.defineProperty(Y.prototype,"hash",wx);Object.defineProperty(Y.prototype,"id",wx);var Np={configurable:!1,enumerable:!0,get:function(){return this._getInputAmount()}};Object.defineProperty(Y.prototype,"inputAmount",Np);Np.get=function(){return this._getOutputAmount()};Object.defineProperty(Y.prototype,"outputAmount",Np);Y.prototype._getHash=function(){return bx.sha256sha256(this.toBuffer())};Y.prototype.serialize=function(e){return e===!0||e&&e.disableAll?this.uncheckedSerialize():this.checkedSerialize(e)};Y.prototype.uncheckedSerialize=Y.prototype.toString=function(){return this.toBuffer().toString("hex")};Y.prototype.checkedSerialize=function(e){var t=this.getSerializationError(e);if(t)throw t.message+=" - For more information please see: https://bsv.io/api/lib/transaction#serialization-checks",t;return this.uncheckedSerialize()};Y.prototype.invalidSatoshis=function(){for(var e=!1,t=0;t<this.outputs.length;t++)this.outputs[t].invalidSatoshis()&&(e=!0);return e};Y.prototype.getSerializationError=function(e){if(e=e||{},this.invalidSatoshis())return new Ut.Transaction.InvalidSatoshis;var t=this._getUnspentValue(),r;return t<0?e.disableMoreOutputThanInput||(r=new Ut.Transaction.InvalidOutputAmountSum):r=this._hasFeeError(e,t),r||this._hasDustOutputs(e)||this._isMissingSignatures(e)};Y.prototype._hasFeeError=function(e,t){if(!ge.isUndefined(this._fee)&&this._fee!==t)return new Ut.Transaction.FeeError.Different("Unspent value is "+t+" but specified fee is "+this._fee);if(!e.disableLargeFees){var r=Math.floor(Y.FEE_SECURITY_MARGIN*this._estimateFee());if(t>r)return this._missingChange()?new Ut.Transaction.ChangeAddressMissing("Fee is too large and no change address was provided"):new Ut.Transaction.FeeError.TooLarge("expected less than "+r+" but got "+t)}};Y.prototype._missingChange=function(){return!this._changeScript};Y.prototype._hasDustOutputs=function(e){if(!e.disableDustOutputs){var t,r;for(t in this.outputs)if(r=this.outputs[t],r.satoshis<Y.DUST_AMOUNT&&!r.script.isDataOut()&&!r.script.isSafeDataOut())return new Ut.Transaction.DustOutputs}};Y.prototype._isMissingSignatures=function(e){if(!e.disableIsFullySigned&&!this.isFullySigned())return new Ut.Transaction.MissingSignatures};Y.prototype.inspect=function(){return"<Transaction: "+this.uncheckedSerialize()+">"};Y.prototype.toBuffer=function(){var e=new eC;return this.toBufferWriter(e).toBuffer()};Y.prototype.toBufferWriter=function(e){return e.writeInt32LE(this.version),e.writeVarintNum(this.inputs.length),ge.each(this.inputs,function(t){t.toBufferWriter(e)}),e.writeVarintNum(this.outputs.length),ge.each(this.outputs,function(t){t.toBufferWriter(e)}),e.writeUInt32LE(this.nLockTime),e};Y.prototype.fromBuffer=function(e){var t=new vx(e);return this.fromBufferReader(t)};Y.prototype.fromBufferReader=function(e){Vt.checkArgument(!e.finished(),"No transaction data received");var t,r,n;for(this.version=e.readInt32LE(),r=e.readVarintNum(),t=0;t<r;t++){var i=Dt.fromBufferReader(e);this.inputs.push(i)}for(n=e.readVarintNum(),t=0;t<n;t++)this.outputs.push(Vr.fromBufferReader(e));return this.nLockTime=e.readUInt32LE(),this};Y.prototype.toObject=Y.prototype.toJSON=function(){var t=[];this.inputs.forEach(function(i){t.push(i.toObject())});var r=[];this.outputs.forEach(function(i){r.push(i.toObject())});var n={hash:this.hash,version:this.version,inputs:t,outputs:r,nLockTime:this.nLockTime};return this._changeScript&&(n.changeScript=this._changeScript.toString()),ge.isUndefined(this._changeIndex)||(n.changeIndex=this._changeIndex),ge.isUndefined(this._fee)||(n.fee=this._fee),n};Y.prototype.fromObject=function(t){Vt.checkArgument(ge.isObject(t)||t instanceof Y);var r=this,n;return t instanceof Y?n=t.toObject():n=t,ge.each(n.inputs,function(i){if(!i.output||!i.output.script){r.uncheckedAddInput(new Dt(i));return}var o=new hn(i.output.script),s;if(o.isPublicKeyHashOut())s=new Dt.PublicKeyHash(i);else if(o.isScriptHashOut()&&i.publicKeys&&i.threshold)s=new Dt.MultiSigScriptHash(i,i.publicKeys,i.threshold,i.signatures);else if(o.isPublicKeyOut())s=new Dt.PublicKey(i);else throw new Ut.Transaction.Input.UnsupportedScript(i.output.script);r.addInput(s)}),ge.each(n.outputs,function(i){r.addOutput(new Vr(i))}),n.changeIndex&&(this._changeIndex=n.changeIndex),n.changeScript&&(this._changeScript=new hn(n.changeScript)),n.fee&&(this._fee=n.fee),this.nLockTime=n.nLockTime,this.version=n.version,this._checkConsistency(t),this};Y.prototype._checkConsistency=function(e){ge.isUndefined(this._changeIndex)||(Vt.checkState(this._changeScript,"Change script is expected."),Vt.checkState(this.outputs[this._changeIndex],"Change index points to undefined output."),Vt.checkState(this.outputs[this._changeIndex].script.toString()===this._changeScript.toString(),"Change output has an unexpected script.")),e&&e.hash&&Vt.checkState(e.hash===this.hash,"Hash in object does not match transaction hash.")};Y.prototype.lockUntilDate=function(e){if(Vt.checkArgument(e),ge.isNumber(e)&&e<Y.NLOCKTIME_BLOCKHEIGHT_LIMIT)throw new Ut.Transaction.LockTimeTooEarly;ge.isDate(e)&&(e=e.getTime()/1e3);for(var t=0;t<this.inputs.length;t++)this.inputs[t].sequenceNumber===Dt.DEFAULT_SEQNUMBER&&(this.inputs[t].sequenceNumber=Dt.DEFAULT_LOCKTIME_SEQNUMBER);return this.nLockTime=e,this};Y.prototype.lockUntilBlockHeight=function(e){if(Vt.checkArgument(ge.isNumber(e)),e>=Y.NLOCKTIME_BLOCKHEIGHT_LIMIT)throw new Ut.Transaction.BlockHeightTooHigh;if(e<0)throw new Ut.Transaction.NLockTimeOutOfRange;for(var t=0;t<this.inputs.length;t++)this.inputs[t].sequenceNumber===Dt.DEFAULT_SEQNUMBER&&(this.inputs[t].sequenceNumber=Dt.DEFAULT_LOCKTIME_SEQNUMBER);return this.nLockTime=e,this};Y.prototype.getLockTime=function(){return this.nLockTime?this.nLockTime<Y.NLOCKTIME_BLOCKHEIGHT_LIMIT?this.nLockTime:new Date(1e3*this.nLockTime):null};Y.prototype.fromString=function(e){this.fromBuffer(Q6.Buffer.from(e,"hex"))};Y.prototype._newTransaction=function(){this.version=fC,this.nLockTime=cC};Y.prototype.from=function(e,t,r){if(ge.isArray(e)){var n=this;return ge.each(e,function(o){n.from(o,t,r)}),this}var i=ge.some(this.inputs,function(o){return o.prevTxId.toString("hex")===e.txId&&o.outputIndex===e.outputIndex});return i?this:(t&&r?this._fromMultisigUtxo(e,t,r):this._fromNonP2SH(e),this)};Y.prototype._fromNonP2SH=function(e){var t;e=new Sx(e),e.script.isPublicKeyHashOutPrefix()?t=rC:e.script.isPublicKeyOut()?t=nC:t=Dt,this.addInput(new t({output:new Vr({script:e.script,satoshis:e.satoshis}),prevTxId:e.txId,outputIndex:e.outputIndex,script:hn.empty()}))};Y.prototype._fromMultisigUtxo=function(e,t,r){Vt.checkArgument(r<=t.length,"Number of required signatures must be greater than the number of public keys");var n;if(e=new Sx(e),e.script.isMultisigOut())n=oC;else if(e.script.isScriptHashOut())n=iC;else throw new Ut.Transaction.Input.UnsupportedScript(e.script.toString());this.addInput(new n({output:new Vr({script:e.script,satoshis:e.satoshis}),prevTxId:e.txId,outputIndex:e.outputIndex,script:hn.empty()},t,r))};Y.prototype.addInput=function(e,t,r){if(Vt.checkArgumentType(e,Dt,"input"),!e.output&&(ge.isUndefined(t)||ge.isUndefined(r)))throw new Ut.Transaction.NeedMoreInfo("Need information about the UTXO script and satoshis");return!e.output&&t&&!ge.isUndefined(r)&&(t=t instanceof hn?t:new hn(t),Vt.checkArgumentType(r,"number","satoshis"),e.output=new Vr({script:t,satoshis:r})),this.uncheckedAddInput(e)};Y.prototype.uncheckedAddInput=function(e){return Vt.checkArgumentType(e,Dt,"input"),this.inputs.push(e),this._inputAmount=void 0,this._updateChangeOutput(),this};Y.prototype.hasAllUtxoInfo=function(){return ge.every(this.inputs.map(function(e){return!!e.output}))};Y.prototype.fee=function(e){return Vt.checkArgument(ge.isNumber(e),"amount must be a number"),this._fee=e,this._updateChangeOutput(),this};Y.prototype.feePerKb=function(e){return Vt.checkArgument(ge.isNumber(e),"amount must be a number"),this._feePerKb=e,this._updateChangeOutput(),this};Y.prototype.change=function(e){return Vt.checkArgument(e,"address is required"),this._changeScript=hn.fromAddress(e),this._updateChangeOutput(),this};Y.prototype.getChangeOutput=function(){return ge.isUndefined(this._changeIndex)?null:this.outputs[this._changeIndex]};Y.prototype.to=function(e,t){if(ge.isArray(e)){var r=this;return ge.each(e,function(n){r.to(n.address,n.satoshis)}),this}return Vt.checkArgument(mx.isNaturalNumber(t),"Amount is expected to be a positive integer"),this.addOutput(new Vr({script:hn(new tC(e)),satoshis:t})),this};Y.prototype.addData=function(e){return this.addOutput(new Vr({script:hn.buildDataOut(e),satoshis:0})),this};Y.prototype.addSafeData=function(e){return this.addOutput(new Vr({script:hn.buildSafeDataOut(e),satoshis:0})),this};Y.prototype.addOutput=function(e){return Vt.checkArgumentType(e,Vr,"output"),this._addOutput(e),this._updateChangeOutput(),this};Y.prototype.clearOutputs=function(){return this.outputs=[],this._clearSignatures(),this._outputAmount=void 0,this._changeIndex=void 0,this._updateChangeOutput(),this};Y.prototype._addOutput=function(e){this.outputs.push(e),this._outputAmount=void 0};Y.prototype._getOutputAmount=function(){if(ge.isUndefined(this._outputAmount)){var e=this;this._outputAmount=0,ge.each(this.outputs,function(t){e._outputAmount+=t.satoshis})}return this._outputAmount};Y.prototype._getInputAmount=function(){if(ge.isUndefined(this._inputAmount)){var e=this;this._inputAmount=0,ge.each(this.inputs,function(t){if(ge.isUndefined(t.output))throw new Ut.Transaction.Input.MissingPreviousOutput;e._inputAmount+=t.output.satoshis})}return this._inputAmount};Y.prototype._updateChangeOutput=function(){if(this._changeScript){this._clearSignatures(),ge.isUndefined(this._changeIndex)||this._removeOutput(this._changeIndex),this._changeIndex=this.outputs.length,this._addOutput(new Vr({script:this._changeScript,satoshis:0}));var e=this._getUnspentValue(),t=this.getFee(),r=e-t;this._removeOutput(this._changeIndex),this._changeIndex=void 0,r>=Y.DUST_AMOUNT&&(this._changeIndex=this.outputs.length,this._addOutput(new Vr({script:this._changeScript,satoshis:r})))}};Y.prototype.getFee=function(){return this.isCoinbase()?0:ge.isUndefined(this._fee)?this._changeScript?this._estimateFee():this._getUnspentValue():this._fee};Y.prototype._estimateFee=function(){var e=this._estimateSize();return Math.ceil(e/1e3*(this._feePerKb||Y.FEE_PER_KB))};Y.prototype._getUnspentValue=function(){return this._getInputAmount()-this._getOutputAmount()};Y.prototype._clearSignatures=function(){ge.each(this.inputs,function(e){e.clearSignatures!==Dt.prototype.clearSignatures&&e.clearSignatures()})};Y.prototype._estimateSize=function(){var e=8;return e+=yx(this.inputs.length).toBuffer().length,e+=yx(this.outputs.length).toBuffer().length,ge.each(this.inputs,function(t){e+=t._estimateSize()}),ge.each(this.outputs,function(t){e+=t.getSize()}),e};Y.prototype._removeOutput=function(e){var t=this.outputs[e];this.outputs=ge.without(this.outputs,t),this._outputAmount=void 0};Y.prototype.removeOutput=function(e){this._removeOutput(e),this._updateChangeOutput()};Y.prototype.sort=function(){return this.sortInputs(function(e){var t=Array.prototype.concat.apply([],e);return t.sort(function(r,n){return r.prevTxId.compare(n.prevTxId)||r.outputIndex-n.outputIndex}),t}),this.sortOutputs(function(e){var t=Array.prototype.concat.apply([],e);return t.sort(function(r,n){return r.satoshis-n.satoshis||r.script.toBuffer().compare(n.script.toBuffer())}),t}),this};Y.prototype.shuffleOutputs=function(){return this.sortOutputs(ge.shuffle)};Y.prototype.sortOutputs=function(e){var t=e(this.outputs);return this._newOutputOrder(t)};Y.prototype.sortInputs=function(e){return this.inputs=e(this.inputs),this._clearSignatures(),this};Y.prototype._newOutputOrder=function(e){var t=this.outputs.length!==e.length||ge.difference(this.outputs,e).length!==0;if(t)throw new Ut.Transaction.InvalidSorting;if(!ge.isUndefined(this._changeIndex)){var r=this.outputs[this._changeIndex];this._changeIndex=e.indexOf(r)}return this.outputs=e,this};Y.prototype.removeInput=function(e,t){var r;if(!t&&ge.isNumber(e)?r=e:r=ge.findIndex(this.inputs,function(i){return i.prevTxId.toString("hex")===e&&i.outputIndex===t}),r<0||r>=this.inputs.length)throw new Ut.Transaction.InvalidIndex(r,this.inputs.length);var n=this.inputs[r];this.inputs=ge.without(this.inputs,n),this._inputAmount=void 0,this._updateChangeOutput()};Y.prototype.sign=function(e,t){Vt.checkState(this.hasAllUtxoInfo(),"Not all utxo information is available to sign the transaction.");var r=this;return ge.isArray(e)?(ge.each(e,function(n){r.sign(n,t)}),this):(ge.each(this.getSignatures(e,t),function(n){r.applySignature(n)}),this)};Y.prototype.getSignatures=function(e,t){e=new sC(e),t=t||Dc.SIGHASH_ALL|Dc.SIGHASH_FORKID;var r=this,n=[],i=bx.sha256ripemd160(e.publicKey.toBuffer());return ge.each(this.inputs,function(s,a){ge.each(s.getSignatures(r,e,a,t,i),function(f){n.push(f)})}),n};Y.prototype.applySignature=function(e){return this.inputs[e.inputIndex].addSignature(this,e),this};Y.prototype.isFullySigned=function(){return ge.each(this.inputs,function(e){if(e.isFullySigned===Dt.prototype.isFullySigned)throw new Ut.Transaction.UnableToVerifySignature("Unrecognized script kind, or not enough information to execute script.This usually happens when creating a transaction from a serialized transaction")}),ge.every(ge.map(this.inputs,function(e){return e.isFullySigned()}))};Y.prototype.isValidSignature=function(e){var t=this;if(this.inputs[e.inputIndex].isValidSignature===Dt.prototype.isValidSignature)throw new Ut.Transaction.UnableToVerifySignature("Unrecognized script kind, or not enough information to execute script.This usually happens when creating a transaction from a serialized transaction");return this.inputs[e.inputIndex].isValidSignature(t,e)};Y.prototype.verifySignature=function(e,t,r,n,i,o){return _x.verify(this,e,t,r,n,i,o)};Y.prototype.verify=function(){if(this.inputs.length===0)return"transaction txins empty";if(this.outputs.length===0)return"transaction txouts empty";for(var e=new Lc(0),t=0;t<this.outputs.length;t++){var r=this.outputs[t];if(r.invalidSatoshis())return"transaction txout "+t+" satoshis is invalid";if(r._satoshisBN.gt(new Lc(Y.MAX_MONEY,10)))return"transaction txout "+t+" greater than MAX_MONEY";if(e=e.add(r._satoshisBN),e.gt(new Lc(Y.MAX_MONEY)))return"transaction txout "+t+" total output greater than MAX_MONEY"}if(this.toBuffer().length>lC)return"transaction over the maximum block size";var n={};for(t=0;t<this.inputs.length;t++){var i=this.inputs[t],o=i.prevTxId+":"+i.outputIndex;if(!ge.isUndefined(n[o]))return"transaction input "+t+" duplicate input";n[o]=!0}var s=this.isCoinbase();if(s){var a=this.inputs[0]._scriptBuffer;if(a.length<2||a.length>100)return"coinbase transaction script size invalid"}else for(t=0;t<this.inputs.length;t++)if(this.inputs[t].isNull())return"transaction input "+t+" has null input";return!0};Y.prototype.isCoinbase=function(){return this.inputs.length===1&&this.inputs[0].isNull()};Y.prototype.sighash=function(e,t,r,n,i){t=t||Dc.SIGHASH_ALL|Dc.SIGHASH_FORKID;var o=this.inputs[e];if(!o)throw new Error("Input index "+e+" does not exist");return!r&&o.output&&(r=o.output.script),!n&&o.output&&(n=new Lc(o.output.satoshis)),i=i||uC,_x.sighash(this,t,e,r,n,i)};Ex.exports=Y});var Mp=B((lq,so)=>{p();so.exports=Pp();so.exports.Input=Nc();so.exports.Output=Ln();so.exports.UnspentOutput=Bp();so.exports.Signature=us();so.exports.Sighash=_i()});var kc=B((dq,Rx)=>{"use strict";p();var Uc=Ze(),Fc=yp(),N=dp(),ce=Er(),Va=er(),Hn=or(),kp=Or();function xx(e){return e.map(function(t){return d.Buffer.isBuffer(t)?d.Buffer.from(t):t})}var P=function e(t){if(!(this instanceof e))return new e(t);t?(this.initialize(),this.set(t)):this.initialize()};P.prototype._verifyCore=function(e,t,r,n,i,o){var s=Mp();if(Uc.isUndefined(r)&&(r=new s),Uc.isUndefined(n)&&(n=0),Uc.isUndefined(i)&&(i=P.currentConsensusFlags(),o||(i&=~P.SCRIPT_ENABLE_SIGHASH_FORKID)),i&P.SCRIPT_ENABLE_SIGHASH_FORKID&&(i|=P.SCRIPT_VERIFY_STRICTENC,!o))throw new Error("internal error - need satoshisBN to verify FORKID transactions");this.set({script:e,tx:r,nin:n,flags:i,satoshisBN:o});var a;if((i&P.SCRIPT_UTXO_AFTER_CHRONICLE)!==0&&(i&P.SCRIPT_UTXO_AFTER_GENESIS)===0)return this.errstr="SCRIPT_ERR_INVALID_FLAGS",!1;if((i&P.SCRIPT_VERIFY_SIGPUSHONLY)!==0){var f=(i&P.SCRIPT_CHRONICLE)!==0,l=(i&P.SCRIPT_GENESIS)!==0&&!f||f&&Ox(i,r);if(l&&!e.isPushOnly())return this.errstr="SCRIPT_ERR_SIG_PUSHONLY",!1}if(!this.evaluate())return!1;var y=(i&P.SCRIPT_VERIFY_P2SH)!==0&&(i&P.SCRIPT_UTXO_AFTER_GENESIS)===0;y&&(a=this.stack.slice());var g=this.stack;if(this.initialize(),this.set({script:t,stack:g,tx:r,nin:n,flags:i,satoshisBN:o}),!this.evaluate())return!1;if(this.stack.length===0)return this.errstr="SCRIPT_ERR_EVAL_FALSE_NO_RESULT",!1;var v=this.stack[this.stack.length-1];if(!P.castToBool(v))return this.errstr="SCRIPT_ERR_EVAL_FALSE_IN_STACK",!1;if(y&&t.isScriptHashOut()){if(!e.isPushOnly())return this.errstr="SCRIPT_ERR_SIG_PUSHONLY",!1;if(a.length===0)throw new Error("internal error - stack copy empty");var E=a[a.length-1],T=Fc.fromBuffer(E);if(a.pop(),this.initialize(),this.set({script:T,stack:a,tx:r,nin:n,flags:i,satoshisBN:o}),!this.evaluate())return!1;if(a.length===0)return this.errstr="SCRIPT_ERR_EVAL_FALSE_NO_P2SH_STACK",!1;if(!P.castToBool(a[a.length-1]))return this.errstr="SCRIPT_ERR_EVAL_FALSE_IN_P2SH_STACK",!1}if((i&P.SCRIPT_VERIFY_CLEANSTACK)!==0){if((i&P.SCRIPT_VERIFY_P2SH)===0)return this.errstr="SCRIPT_ERR_INVALID_FLAGS",!1;if(this.enforceNonMalleability()&&this.stack.length!==1)return this.errstr="SCRIPT_ERR_CLEANSTACK",!1}return!0};Rx.exports=P;P.prototype.initialize=function(e){this.stack=[],this.altstack=[],this.pc=0,this.pbegincodehash=0,this.nOpCount=0,this.returned=!1,this.nonTopLevelReturnAfterGenesis=!1,this.vfExec=[],this.vfElse=[],this.errstr="",this.flags=0};P.prototype.set=function(e){this.script=e.script||this.script,this.tx=e.tx||this.tx,this.nin=typeof e.nin<"u"?e.nin:this.nin,this.satoshisBN=e.satoshisBN||this.satoshisBN,this.stack=e.stack||this.stack,this.altstack=e.altstack||this.altstack,this.pc=typeof e.pc<"u"?e.pc:this.pc,this.pbegincodehash=typeof e.pbegincodehash<"u"?e.pbegincodehash:this.pbegincodehash,this.nOpCount=typeof e.nOpCount<"u"?e.nOpCount:this.nOpCount,this.returned=typeof e.returned<"u"?e.returned:this.returned,this.nonTopLevelReturnAfterGenesis=typeof e.nonTopLevelReturnAfterGenesis<"u"?e.nonTopLevelReturnAfterGenesis:this.nonTopLevelReturnAfterGenesis,this.vfExec=e.vfExec||this.vfExec,this.vfElse=e.vfElse||this.vfElse,this.errstr=e.errstr||this.errstr,this.flags=typeof e.flags<"u"?e.flags:this.flags};P.true=d.Buffer.from([1]);P.false=d.Buffer.from([]);P.MAX_SCRIPT_ELEMENT_SIZE=520;P.MAXIMUM_ELEMENT_SIZE=4;P.MAX_OPS_PER_SCRIPT=500;P.MAX_SCRIPT_SIZE=1e4;P.UNLIMITED=Number.MAX_SAFE_INTEGER;P.MAX_SCRIPT_NUM_LENGTH_AFTER_GENESIS=75e4;P.MAX_SCRIPT_NUM_LENGTH_AFTER_CHRONICLE=32e6;P.MAX_PUBKEYS_PER_MULTISIG_AFTER_GENESIS=4294967295;P.MAX_STACK_SIZE=1e3;P.MAX_STACK_MEMORY_USAGE_AFTER_GENESIS=P.UNLIMITED;P.STACK_MEMORY_USAGE_POLICY=100*1024*1024;P.STACK_ELEMENT_OVERHEAD=32;P.LOCKTIME_THRESHOLD=5e8;P.LOCKTIME_THRESHOLD_BN=new ce(P.LOCKTIME_THRESHOLD);P.useGenesisLimits=function(e){return e=e||2147483647,P.MAX_SCRIPT_ELEMENT_SIZE=e,P.MAX_OPS_PER_SCRIPT=e,P.MAX_SCRIPT_SIZE=e,P};P.getLimits=function(){return{maxScriptElementSize:P.MAX_SCRIPT_ELEMENT_SIZE,maximumElementSize:P.MAXIMUM_ELEMENT_SIZE,maxOpsPerScript:P.MAX_OPS_PER_SCRIPT,maxScriptSize:P.MAX_SCRIPT_SIZE}};P.setLimits=function(e){return e=e||{},e.maxScriptElementSize!=null&&(P.MAX_SCRIPT_ELEMENT_SIZE=e.maxScriptElementSize),e.maximumElementSize!=null&&(P.MAXIMUM_ELEMENT_SIZE=e.maximumElementSize),e.maxOpsPerScript!=null&&(P.MAX_OPS_PER_SCRIPT=e.maxOpsPerScript),e.maxScriptSize!=null&&(P.MAX_SCRIPT_SIZE=e.maxScriptSize),P};P.SCRIPT_VERIFY_NONE=0;P.SCRIPT_VERIFY_P2SH=1;P.SCRIPT_VERIFY_STRICTENC=2;P.SCRIPT_VERIFY_DERSIG=4;P.SCRIPT_VERIFY_LOW_S=8;P.SCRIPT_VERIFY_NULLDUMMY=16;P.SCRIPT_VERIFY_SIGPUSHONLY=32;P.SCRIPT_VERIFY_MINIMALDATA=64;P.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS=128;P.SCRIPT_VERIFY_CLEANSTACK=256;P.SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY=512;P.SCRIPT_VERIFY_CHECKSEQUENCEVERIFY=1024;P.SCRIPT_VERIFY_MINIMALIF=8192;P.SCRIPT_VERIFY_NULLFAIL=16384;P.SCRIPT_VERIFY_COMPRESSED_PUBKEYTYPE=32768;P.SCRIPT_ENABLE_SIGHASH_FORKID=65536;P.SCRIPT_ENABLE_REPLAY_PROTECTION=1<<17;P.SCRIPT_ENABLE_MONOLITH_OPCODES=2048;P.SCRIPT_ENABLE_MAGNETIC_OPCODES=4096;P.SCRIPT_GENESIS=1<<18;P.SCRIPT_UTXO_AFTER_GENESIS=1<<19;P.SCRIPT_ENABLE_CHRONICLE=1<<20;P.SCRIPT_CHRONICLE=P.SCRIPT_ENABLE_CHRONICLE;P.SCRIPT_UTXO_AFTER_CHRONICLE=1<<21;P.CHRONICLE_ACTIVATION_HEIGHT=943816;P.ERA_SENSITIVE_ERRORS={SCRIPT_ERR_PUSH_SIZE:{cap:"stack element size (capped at 520 bytes pre-Genesis, unbounded after)",lifts:P.SCRIPT_UTXO_AFTER_GENESIS},SCRIPT_ERR_SCRIPT_SIZE:{cap:"total script size (capped at 10,000 bytes pre-Genesis, unbounded after)",lifts:P.SCRIPT_UTXO_AFTER_GENESIS},SCRIPT_ERR_OP_COUNT:{cap:"opcode count (capped at 201 pre-Genesis, unbounded after)",lifts:P.SCRIPT_UTXO_AFTER_GENESIS},SCRIPT_ERR_SCRIPTNUM_OVERFLOW:{cap:"script number width (4 bytes pre-Genesis, 750,000 after Genesis, 32,000,000 after Chronicle)",lifts:P.SCRIPT_UTXO_AFTER_GENESIS|P.SCRIPT_UTXO_AFTER_CHRONICLE}};P.ERA_FLAGS=P.SCRIPT_GENESIS|P.SCRIPT_UTXO_AFTER_GENESIS|P.SCRIPT_ENABLE_CHRONICLE|P.SCRIPT_UTXO_AFTER_CHRONICLE;P.eraDiagnostics=!(typeof x.default<"u"&&x.default.env&&x.default.env.BSV_NO_ERA_HINT==="1");var Cp=!1;P.prototype._eraDiagnose=function(e){if(e!==void 0){var t=P.ERA_SENSITIVE_ERRORS[this.errstr];if(t&&(e&t.lifts)===0){var r=t.cap;this.eraHint=this.errstr+" was produced under PRE-GENESIS limits: "+r+`.
68
+ `).concat(xc(e),`
69
+ `));var a=new wi({actual:e,expected:t,message:r,operator:i,stackStartFn:n});throw a.generatedMessage=s,a}}ut.match=function e(t,r,n){b1(t,r,n,e,"match")};ut.doesNotMatch=function e(t,r,n){b1(t,r,n,e,"doesNotMatch")};function _1(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];h1.apply(void 0,[_1,t.length].concat(t))}ut.strict=n6(_1,ut,{equal:ut.strictEqual,deepEqual:ut.deepStrictEqual,notEqual:ut.notStrictEqual,notDeepEqual:ut.notDeepStrictEqual});ut.strict.strict=ut.strict});var qa=B((B5,E1)=>{"use strict";g();var Fa=at(),w1=We(),as=Ar(),vt=function e(t){if(!(this instanceof e))return new e(t);if(!Fa.isUndefined(t))if(d.Buffer.isBuffer(t))this.set({buf:t});else if(Fa.isString(t)){var r=d.Buffer.from(t,"hex");if(r.length*2!==t.length)throw new TypeError("Invalid hex string");this.set({buf:r})}else if(Fa.isObject(t)){var n=t;this.set(n)}else throw new TypeError("Unrecognized argument for BufferReader")};vt.prototype.set=function(e){return this.buf=e.buf||this.buf||void 0,this.pos=e.pos||this.pos||0,this};vt.prototype.eof=function(){return this.pos>=this.buf.length};vt.prototype.finished=vt.prototype.eof;vt.prototype.read=function(e){w1.checkArgument(!Fa.isUndefined(e),"Must specify a length");var t=this.buf.slice(this.pos,this.pos+e);return this.pos=this.pos+e,t};vt.prototype.readAll=function(){var e=this.buf.slice(this.pos,this.buf.length);return this.pos=this.buf.length,e};vt.prototype.readUInt8=function(){var e=this.buf.readUInt8(this.pos);return this.pos=this.pos+1,e};vt.prototype.readUInt16BE=function(){var e=this.buf.readUInt16BE(this.pos);return this.pos=this.pos+2,e};vt.prototype.readUInt16LE=function(){var e=this.buf.readUInt16LE(this.pos);return this.pos=this.pos+2,e};vt.prototype.readUInt32BE=function(){var e=this.buf.readUInt32BE(this.pos);return this.pos=this.pos+4,e};vt.prototype.readUInt32LE=function(){var e=this.buf.readUInt32LE(this.pos);return this.pos=this.pos+4,e};vt.prototype.readInt32LE=function(){var e=this.buf.readInt32LE(this.pos);return this.pos=this.pos+4,e};vt.prototype.readUInt64BEBN=function(){var e=this.buf.slice(this.pos,this.pos+8),t=as.fromBuffer(e);return this.pos=this.pos+8,t};vt.prototype.readUInt64LEBN=function(){var e=this.buf.readUInt32LE(this.pos),t=this.buf.readUInt32LE(this.pos+4),r=t*4294967296+e,n;if(r<=9007199254740991)n=new as(r);else{var i=Array.prototype.slice.call(this.buf,this.pos,this.pos+8);n=new as(i,10,"le")}return this.pos=this.pos+8,n};vt.prototype.readVarintNum=function(){var e=this.readUInt8();switch(e){case 253:return this.readUInt16LE();case 254:return this.readUInt32LE();case 255:var t=this.readUInt64LEBN(),r=t.toNumber();if(r<=Math.pow(2,53))return r;throw new Error("number too large to retain precision - use readVarintBN");default:return e}};vt.prototype.readVarLengthBuffer=function(){var e=this.readVarintNum(),t=this.read(e);return w1.checkState(t.length===e,"Invalid length while reading varlength buffer. Expected to read: "+e+" and read "+t.length),t};vt.prototype.readVarintBuf=function(){var e=this.buf.readUInt8(this.pos);switch(e){case 253:return this.read(3);case 254:return this.read(5);case 255:return this.read(9);default:return this.read(1)}};vt.prototype.readVarintBN=function(){var e=this.readUInt8();switch(e){case 253:return new as(this.readUInt16LE());case 254:return new as(this.readUInt32LE());case 255:return this.readUInt64LEBN();default:return new as(e)}};vt.prototype.reverse=function(){for(var e=d.Buffer.alloc(this.buf.length),t=0;t<e.length;t++)e[t]=this.buf[this.buf.length-1-t];return this.buf=e,this};vt.prototype.readReverse=function(e){Fa.isUndefined(e)&&(e=this.buf.length);var t=this.buf.slice(this.pos,this.pos+e);return this.pos=this.pos+e,d.Buffer.from(t).reverse()};E1.exports=vt});var vp=B((M5,x1)=>{"use strict";g();var us=at(),Ha=We(),o6=vr();function Fe(e){if(!(this instanceof Fe))return new Fe(e);var t;if(us.isNumber(e))t=e;else if(us.isString(e))t=Fe.map[e];else throw new TypeError('Unrecognized num type: "'+typeof e+'" for Opcode');return o6.defineImmutable(this,{num:t}),this}Fe.fromBuffer=function(e){return Ha.checkArgument(d.Buffer.isBuffer(e)),new Fe(+("0x"+e.toString("hex")))};Fe.fromNumber=function(e){return Ha.checkArgument(us.isNumber(e)),new Fe(e)};Fe.fromString=function(e){Ha.checkArgument(us.isString(e));var t=Fe.map[e];if(typeof t>"u")throw new TypeError("Invalid opcodestr");return new Fe(t)};Fe.prototype.toHex=function(){return this.num.toString(16)};Fe.prototype.toBuffer=function(){return d.Buffer.from(this.toHex(),"hex")};Fe.prototype.toNumber=function(){return this.num};Fe.prototype.toString=function(){var e=Fe.reverseMap[this.num];if(typeof e>"u")throw new Error("Opcode does not have a string representation");return e};Fe.smallInt=function(e){return Ha.checkArgument(us.isNumber(e),"Invalid Argument: n should be number"),Ha.checkArgument(e>=0&&e<=16,"Invalid Argument: n must be between 0 and 16"),e===0?Fe("OP_0"):new Fe(Fe.map.OP_1+e-1)};Fe.map={OP_FALSE:0,OP_0:0,OP_PUSHDATA1:76,OP_PUSHDATA2:77,OP_PUSHDATA4:78,OP_1NEGATE:79,OP_RESERVED:80,OP_TRUE:81,OP_1:81,OP_2:82,OP_3:83,OP_4:84,OP_5:85,OP_6:86,OP_7:87,OP_8:88,OP_9:89,OP_10:90,OP_11:91,OP_12:92,OP_13:93,OP_14:94,OP_15:95,OP_16:96,OP_NOP:97,OP_VER:98,OP_IF:99,OP_NOTIF:100,OP_VERIF:101,OP_VERNOTIF:102,OP_ELSE:103,OP_ENDIF:104,OP_VERIFY:105,OP_RETURN:106,OP_TOALTSTACK:107,OP_FROMALTSTACK:108,OP_2DROP:109,OP_2DUP:110,OP_3DUP:111,OP_2OVER:112,OP_2ROT:113,OP_2SWAP:114,OP_IFDUP:115,OP_DEPTH:116,OP_DROP:117,OP_DUP:118,OP_NIP:119,OP_OVER:120,OP_PICK:121,OP_ROLL:122,OP_ROT:123,OP_SWAP:124,OP_TUCK:125,OP_CAT:126,OP_SPLIT:127,OP_NUM2BIN:128,OP_BIN2NUM:129,OP_SIZE:130,OP_INVERT:131,OP_AND:132,OP_OR:133,OP_XOR:134,OP_EQUAL:135,OP_EQUALVERIFY:136,OP_RESERVED1:137,OP_RESERVED2:138,OP_1ADD:139,OP_1SUB:140,OP_2MUL:141,OP_2DIV:142,OP_NEGATE:143,OP_ABS:144,OP_NOT:145,OP_0NOTEQUAL:146,OP_ADD:147,OP_SUB:148,OP_MUL:149,OP_DIV:150,OP_MOD:151,OP_LSHIFT:152,OP_RSHIFT:153,OP_BOOLAND:154,OP_BOOLOR:155,OP_NUMEQUAL:156,OP_NUMEQUALVERIFY:157,OP_NUMNOTEQUAL:158,OP_LESSTHAN:159,OP_GREATERTHAN:160,OP_LESSTHANOREQUAL:161,OP_GREATERTHANOREQUAL:162,OP_MIN:163,OP_MAX:164,OP_WITHIN:165,OP_RIPEMD160:166,OP_SHA1:167,OP_SHA256:168,OP_HASH160:169,OP_HASH256:170,OP_CODESEPARATOR:171,OP_CHECKSIG:172,OP_CHECKSIGVERIFY:173,OP_CHECKMULTISIG:174,OP_CHECKMULTISIGVERIFY:175,OP_CHECKLOCKTIMEVERIFY:177,OP_CHECKSEQUENCEVERIFY:178,OP_NOP1:176,OP_NOP2:177,OP_NOP3:178,OP_SUBSTR:179,OP_LEFT:180,OP_RIGHT:181,OP_LSHIFTNUM:182,OP_RSHIFTNUM:183,OP_NOP9:184,OP_NOP10:185,OP_PUBKEYHASH:253,OP_PUBKEY:254,OP_INVALIDOPCODE:255};Fe.reverseMap=[];for(mp in Fe.map)Fe.reverseMap[Fe.map[mp]]=mp;var mp;us.extend(Fe,Fe.map);Fe.isSmallIntOp=function(e){return e instanceof Fe&&(e=e.toNumber()),e===Fe.map.OP_0||e>=Fe.map.OP_1&&e<=Fe.map.OP_16};Fe.prototype.inspect=function(){return"<Opcode: "+this.toString()+", hex: "+this.toHex()+", decimal: "+this.num+">"};x1.exports=Fe});var fr=B((C5,A1)=>{"use strict";g();var oo=Ar(),s6=at(),ur=We(),a6=vr(),Ce=function e(t,r){if(!(this instanceof e))return new e(t,r);if(t instanceof oo)this.set({r:t,s:r});else if(t){var n=t;this.set(n)}};Ce.prototype.set=function(e){return this.r=e.r||this.r||void 0,this.s=e.s||this.s||void 0,this.i=typeof e.i<"u"?e.i:this.i,this.compressed=typeof e.compressed<"u"?e.compressed:this.compressed,this.nhashtype=e.nhashtype||this.nhashtype||void 0,this};Ce.fromCompact=function(e){ur.checkArgument(d.Buffer.isBuffer(e),"Argument is expected to be a Buffer");var t=new Ce,r=!0,n=e.slice(0,1)[0]-27-4;n<0&&(r=!1,n=n+4);var i=e.slice(1,33),o=e.slice(33,65);return ur.checkArgument(n===0||n===1||n===2||n===3,new Error("i must be 0, 1, 2, or 3")),ur.checkArgument(i.length===32,new Error("r must be 32 bytes")),ur.checkArgument(o.length===32,new Error("s must be 32 bytes")),t.compressed=r,t.i=n,t.r=oo.fromBuffer(i),t.s=oo.fromBuffer(o),t};Ce.fromDER=Ce.fromBuffer=function(e,t){var r=Ce.parseDER(e,t),n=new Ce;return n.r=r.r,n.s=r.s,n};Ce.fromTxFormat=function(e){var t=e.readUInt8(e.length-1),r=e.slice(0,e.length-1),n=Ce.fromDER(r,!1);return n.nhashtype=t,n};Ce.fromString=function(e){var t=d.Buffer.from(e,"hex");return Ce.fromDER(t)};function I1(e,t){ur.checkArgument(t.length>0,new Error("Length of "+e+" is zero")),ur.checkArgument(!(t[0]&128),new Error("Value of "+e+" is negative")),ur.checkArgument(!(t.length>1&&t[0]===0&&!(t[1]&128)),new Error("Value of "+e+" is excessively padded"))}Ce.parseDER=function(e,t){ur.checkArgument(d.Buffer.isBuffer(e),new Error("DER formatted signature should be a buffer")),s6.isUndefined(t)&&(t=!0);var r=e[0];ur.checkArgument(r===48,new Error("Header byte should be 0x30"));var n=e[1],i=e.slice(2).length;ur.checkArgument(!t||n===i,new Error("Length byte should length of what follows")),n=n<i?n:i;var o=e[2];ur.checkArgument(o===2,new Error("Integer byte for r should be 0x02"));var s=e[3],a=e.slice(4,4+s),f=oo.fromBuffer(a),l=e[4]===0;ur.checkArgument(s===a.length,new Error("Length of r incorrect"));var m=e[4+s+0];ur.checkArgument(m===2,new Error("Integer byte for s should be 0x02"));var y=e[4+s+1],p=e.slice(4+s+2,4+s+2+y),w=oo.fromBuffer(p),O=e[4+s+2]===0;ur.checkArgument(y===p.length,new Error("Length of s incorrect"));var M=4+s+2+y;ur.checkArgument(n===M-2,new Error("Length of signature incorrect")),t&&(I1("r",a),I1("s",p));var D={header:r,length:n,rheader:o,rlength:s,rneg:l,rbuf:a,r:f,sheader:m,slength:y,sneg:O,sbuf:p,s:w};return D};Ce.prototype.toCompact=function(e,t){if(e=typeof e=="number"?e:this.i,t=typeof t=="boolean"?t:this.compressed,!(e===0||e===1||e===2||e===3))throw new Error("i must be equal to 0, 1, 2, or 3");var r=e+27+4;t===!1&&(r=r-4);var n=d.Buffer.from([r]),i=this.r.toBuffer({size:32}),o=this.s.toBuffer({size:32});return d.Buffer.concat([n,i,o])};Ce.prototype.toBuffer=Ce.prototype.toDER=function(){var e=this.r.toBuffer(),t=this.s.toBuffer(),r=!!(e[0]&128),n=!!(t[0]&128),i=r?d.Buffer.concat([d.Buffer.from([0]),e]):e,o=n?d.Buffer.concat([d.Buffer.from([0]),t]):t,s=i.length,a=o.length,f=2+s+2+a,l=2,m=2,y=48,p=d.Buffer.concat([d.Buffer.from([y,f,l,s]),i,d.Buffer.from([m,a]),o]);return p};Ce.prototype.toString=function(){var e=this.toDER();return e.toString("hex")};Ce.isTxDER=function(e){if(e.length<9||e.length>73||e[0]!==48||e[1]!==e.length-3)return!1;var t=e[3];if(5+t>=e.length)return!1;var r=e[5+t];if(t+r+7!==e.length)return!1;var n=e.slice(4);if(e[2]!==2||t===0||n[0]&128||t>1&&n[0]===0&&!(n[1]&128))return!1;var i=e.slice(6+t);return!(e[6+t-2]!==2||r===0||i[0]&128||r>1&&i[0]===0&&!(i[1]&128))};Ce.prototype.hasLowS=function(){return!(this.s.lt(new oo(1))||this.s.gt(new oo("7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0","hex")))};Ce.prototype.hasDefinedHashtype=function(){if(!a6.isNaturalNumber(this.nhashtype))return!1;var e=this.nhashtype&31;return!(e<Ce.SIGHASH_ALL||e>Ce.SIGHASH_SINGLE)};Ce.prototype.toTxFormat=function(){var e=this.toDER(),t=d.Buffer.alloc(1);return t.writeUInt8(this.nhashtype,0),d.Buffer.concat([e,t])};Ce.SIGHASH_ALL=1;Ce.SIGHASH_NONE=2;Ce.SIGHASH_SINGLE=3;Ce.SIGHASH_CHRONICLE=32;Ce.SIGHASH_FORKID=64;Ce.SIGHASH_ANYONECANPAY=128;Ce.prototype.isCanonical=function(){var e=gi(),t=e.getN().shrn(1);return this.s.lte(t)};Ce.prototype.toCanonical=function(){if(this.isCanonical())return new Ce({r:this.r,s:this.s,i:this.i,compressed:this.compressed,nhashtype:this.nhashtype});var e=gi(),t=e.getN(),r=t.sub(this.s);return new Ce({r:this.r,s:r,i:this.i,compressed:this.compressed,nhashtype:this.nhashtype})};Ce.prototype.validate=function(){if(!this.r||!this.s)throw new Error("Signature missing r or s component");if(this.r.isZero())throw new Error("Signature r component is zero");if(this.s.isZero())throw new Error("Signature s component is zero");var e=gi(),t=e.getN();if(this.r.gte(t))throw new Error("Signature r component >= curve order");if(this.s.gte(t))throw new Error("Signature s component >= curve order");if(this.r.isNeg())throw new Error("Signature r component is negative");if(this.s.isNeg())throw new Error("Signature s component is negative");return!0};Ce.prototype.isValid=function(){try{return this.validate(),!0}catch{return!1}};Ce.prototype.applySecurityPatches=function(){var e=gi(),t=e.getN(),r=t.shrn(1);if(this.r.isZero()||this.s.isZero())throw new Error("Invalid signature: zero r or s");if(this.r.gte(t)||this.s.gte(t))throw new Error("Invalid signature: out of range");if(this.s.gt(r))throw new Error("Invalid signature: non-canonical (high) s");return this};A1.exports=Ce});var wp=B((D5,R1)=>{"use strict";g();var bp=Object.create(null),_p=[],Sp=!(typeof x.default<"u"&&x.default.env&&x.default.env.BSV_NO_DEPRECATION_WARNINGS==="1");function O1(e,t){if(!e||typeof e.what!="string"||e.what==="")throw new TypeError(t+"() requires { what: string }")}function u6(e){var t="[@smartledger/bsv] "+e.what+" is deprecated";return e.since&&(t+=" since "+e.since),t+=".",e.why&&(t+=" "+e.why.charAt(0).toUpperCase()+e.why.slice(1)+"."),e.use&&(t+=" Use "+e.use+" instead."),t+=e.removeIn?" It will be removed in "+e.removeIn+".":" A removal version has not been set; it will not be removed in a 9.x release.",t}function Hn(e){if(!e||!e.what)throw new TypeError("deprecate() requires { what }");if(bp[e.what])return!1;bp[e.what]=!0;var t=u6(e);return _p.push({what:e.what,since:e.since||null,removeIn:e.removeIn||null,use:e.use||null,message:t}),Sp&&console.warn(t),!0}Hn.fn=function(e,t){if(typeof e!="function")throw new TypeError("deprecate.fn() requires a function");O1(t,"deprecate.fn");var r=function(){return Hn(t),e.apply(this,arguments)};return Object.defineProperty(r,"name",{value:e.name,configurable:!0}),Object.defineProperty(r,"length",{value:e.length,configurable:!0}),r.__wrapped=e,r.__deprecation=t,r};Hn.property=function(e,t,r,n){O1(n,"deprecate.property");var i,o=!1;return Object.defineProperty(e,t,{configurable:!0,enumerable:!0,get:function(){return Hn(n),o||(i=r(),o=!0),i}}),e};Hn.fired=function(){return _p.slice()};Hn.setEnabled=function(e){Sp=!!e};Hn.isEnabled=function(){return Sp};Hn.reset=function(){bp=Object.create(null),_p.length=0};R1.exports=Hn});var Ip=B((F5,N1)=>{"use strict";g();var f6=Aa(),jr=uo(),c6=qa(),Ep=nr(),X=vp(),ao=Pr(),so=fr(),T1=Ea(),lt=We(),Le=at(),xp=ii(),l6=wp(),P1=Lt(),h6=vr(),q=function e(t){if(!(this instanceof e))return new e(t);if(this.chunks=[],d.Buffer.isBuffer(t))return e.fromBuffer(t);if(t instanceof jr)return e.fromAddress(t);if(t instanceof e)return e.fromBuffer(t.toBuffer());if(Le.isString(t))return e.fromString(t);Le.isObject(t)&&Le.isArray(t.chunks)&&this.set(t)};q.prototype.set=function(e){return lt.checkArgument(Le.isObject(e)),lt.checkArgument(Le.isArray(e.chunks)),this.chunks=e.chunks,this};q.fromBuffer=function(e){var t=new q;t.chunks=[];for(var r=new c6(e);!r.finished();)try{var n=r.readUInt8(),i,o;n>0&&n<X.OP_PUSHDATA1?(i=n,t.chunks.push({buf:r.read(i),len:i,opcodenum:n})):n===X.OP_PUSHDATA1?(i=r.readUInt8(),o=r.read(i),t.chunks.push({buf:o,len:i,opcodenum:n})):n===X.OP_PUSHDATA2?(i=r.readUInt16LE(),o=r.read(i),t.chunks.push({buf:o,len:i,opcodenum:n})):n===X.OP_PUSHDATA4?(i=r.readUInt32LE(),o=r.read(i),t.chunks.push({buf:o,len:i,opcodenum:n})):t.chunks.push({opcodenum:n})}catch(s){throw s instanceof RangeError?new xp.Script.InvalidBuffer(e.toString("hex")):s}return t};q.prototype.toBuffer=function(){var e=this.chunks,t=0,r,n,i;for(r=0;r<e.length;r++)n=e[r],i=n.opcodenum,t+=1,n.buf&&(i<X.OP_PUSHDATA1?t+=Tc(n.buf):i===X.OP_PUSHDATA1?t+=1+Tc(n.buf):i===X.OP_PUSHDATA2?t+=2+Tc(n.buf):i===X.OP_PUSHDATA4&&(t+=4+Tc(n.buf)));var o=d.Buffer.alloc(t),s=0;for(r=0;r<e.length;r++)n=e[r],i=n.opcodenum,s=o.writeUInt8(n.opcodenum,s),n.buf&&(i<X.OP_PUSHDATA1?s+=n.buf.copy(o,s):i===X.OP_PUSHDATA1?(s=o.writeUInt8(n.len,s),s+=n.buf.copy(o,s)):i===X.OP_PUSHDATA2?(s=o.writeUInt16LE(n.len,s),s+=n.buf.copy(o,s)):i===X.OP_PUSHDATA4&&(s=o.writeUInt32LE(n.len,s),s+=n.buf.copy(o,s)));return o};function Tc(e){if(!d.Buffer.isBuffer(e))throw new f6.AssertionError({message:"chunk data must be a Buffer",actual:e,expected:"Buffer",operator:"isBuffer"});return e.length}function B1(e){if(/^0x[0-9a-fA-F]{2}$/.test(e)){var t=parseInt(e.slice(2),16);return t>X.OP_PUSHDATA4?t:void 0}}q.fromASM=function(e){var t=new q;if(t.chunks=[],e==="")return t;for(var r=e.split(" "),n=0;n<r.length;){var i=r[n],o=X(i),s=o.toNumber(),a=B1(i);if(a!==void 0)t.chunks.push({opcodenum:a}),n=n+1;else if(i==="0")s=0,t.chunks.push({opcodenum:s}),n=n+1;else if(i==="-1")s=X.OP_1NEGATE,t.chunks.push({opcodenum:s}),n=n+1;else if(Le.isUndefined(s)){var f=d.Buffer.from(r[n],"hex");if(f.toString("hex")!==r[n])throw new Error("invalid hex string in script");var l=f.length;l>=0&&l<X.OP_PUSHDATA1?s=l:l<Math.pow(2,8)?s=X.OP_PUSHDATA1:l<Math.pow(2,16)?s=X.OP_PUSHDATA2:l<Math.pow(2,32)&&(s=X.OP_PUSHDATA4),t.chunks.push({buf:f,len:f.length,opcodenum:s}),n=n+1}else t.chunks.push({opcodenum:s}),n=n+1}return t};var d6=/^(?:[0-9a-fA-F]{2})*$/;q.fromHex=function(e){return typeof e=="string"&&!d6.test(e)&&l6({what:"Script.fromHex() with a string that is not whole hex",since:"9.17.0",removeIn:"10.0.0",why:"Buffer.from() stops at the first character it cannot decode, so the script is silently truncated",use:"a round-trip check, Script.fromHex(h).toHex() === h.toLowerCase()"}),new q(P1.Buffer.from(e,"hex"))};q.fromString=function(e){if(h6.isHexa(e)||e.length===0)return new q(P1.Buffer.from(e,"hex"));var t=new q;t.chunks=[];for(var r=e.split(" "),n=0;n<r.length;){var i=r[n],o=X(i),s=o.toNumber(),a=B1(i);if(a!==void 0)t.chunks.push({opcodenum:a}),n=n+1;else if(Le.isUndefined(s))if(s=parseInt(i),s>0&&s<X.OP_PUSHDATA1)t.chunks.push({buf:d.Buffer.from(r[n+1].slice(2),"hex"),len:s,opcodenum:s}),n=n+2;else throw new Error("Invalid script: "+JSON.stringify(e));else if(s===X.OP_PUSHDATA1||s===X.OP_PUSHDATA2||s===X.OP_PUSHDATA4){if(r[n+2].slice(0,2)!=="0x")throw new Error("Pushdata data must start with 0x");t.chunks.push({buf:d.Buffer.from(r[n+2].slice(2),"hex"),len:parseInt(r[n+1]),opcodenum:s}),n=n+3}else t.chunks.push({opcodenum:s}),n=n+1}return t};q.prototype._chunkToString=function(e,t){var r=e.opcodenum,n=t==="asm",i="";if(e.buf){var s=r===X.OP_PUSHDATA1||r===X.OP_PUSHDATA2||r===X.OP_PUSHDATA4;!n&&s&&(i=i+" "+X(r).toString()),e.len>0?n?i=i+" "+e.buf.toString("hex"):i=i+" "+e.len+" 0x"+e.buf.toString("hex"):n?i=i+" 0":s?i=i+" 0 0x":i=i+" OP_0"}else if(typeof X.reverseMap[r]<"u")n?r===0?i=i+" 0":r===79?i=i+" -1":i=i+" "+X(r).toString():i=i+" "+X(r).toString();else{var o=r.toString(16);o.length%2!==0&&(o="0"+o),i=i+" 0x"+o}return i};q.prototype.toASM=function(){for(var e="",t=0;t<this.chunks.length;t++){var r=this.chunks[t];e+=this._chunkToString(r,"asm")}return e.substr(1)};q.prototype.toString=function(){for(var e="",t=0;t<this.chunks.length;t++){var r=this.chunks[t];e+=this._chunkToString(r)}return e.substr(1)};q.prototype.toHex=function(){return this.toBuffer().toString("hex")};q.prototype.inspect=function(){return"<Script: "+this.toString()+">"};q.prototype.isPublicKeyHashOut=function(){return!!(this.chunks.length===5&&this.chunks[0].opcodenum===X.OP_DUP&&this.chunks[1].opcodenum===X.OP_HASH160&&this.chunks[2].buf&&this.chunks[2].buf.length===20&&this.chunks[3].opcodenum===X.OP_EQUALVERIFY&&this.chunks[4].opcodenum===X.OP_CHECKSIG)};q.prototype.isPublicKeyHashOutPrefix=function(){return!!(this.chunks.length>=5&&this.chunks[0].opcodenum===X.OP_DUP&&this.chunks[1].opcodenum===X.OP_HASH160&&this.chunks[2].buf&&this.chunks[2].buf.length===20&&this.chunks[3].opcodenum===X.OP_EQUALVERIFY&&this.chunks[4].opcodenum===X.OP_CHECKSIG)};q.prototype.isPublicKeyHashIn=function(){if(this.chunks.length===2){var e=this.chunks[0].buf,t=this.chunks[1].buf;if(e&&e.length&&e[0]===48&&t&&t.length){var r=t[0];if((r===4||r===6||r===7)&&t.length===65)return!0;if((r===3||r===2)&&t.length===33)return!0}}return!1};q.prototype.getPublicKey=function(){return lt.checkState(this.isPublicKeyOut(),"Can't retrieve PublicKey from a non-PK output"),this.chunks[0].buf};q.prototype.getPublicKeyHash=function(){return lt.checkState(this.isPublicKeyHashOut(),"Can't retrieve PublicKeyHash from a non-PKH output"),this.chunks[2].buf};q.prototype.isPublicKeyOut=function(){if(this.chunks.length===2&&this.chunks[0].buf&&this.chunks[0].buf.length&&this.chunks[1].opcodenum===X.OP_CHECKSIG){var e=this.chunks[0].buf,t=e[0],r=!1;if(((t===4||t===6||t===7)&&e.length===65||(t===3||t===2)&&e.length===33)&&(r=!0),r)return ao.isValid(e)}return!1};q.prototype.isPublicKeyIn=function(){if(this.chunks.length===1){var e=this.chunks[0].buf;if(e&&e.length&&e[0]===48)return!0}return!1};q.prototype.isScriptHashOut=function(){var e=this.toBuffer();return e.length===23&&e[0]===X.OP_HASH160&&e[1]===20&&e[e.length-1]===X.OP_EQUAL};q.prototype.isScriptHashIn=function(){if(this.chunks.length<=1)return!1;var e=this.chunks[this.chunks.length-1],t=e.buf;if(!t)return!1;var r;try{r=q.fromBuffer(t)}catch(i){if(i instanceof xp.Script.InvalidBuffer)return!1;throw i}var n=r.classify();return n!==q.types.UNKNOWN};q.prototype.isMultisigOut=function(){return this.chunks.length>3&&X.isSmallIntOp(this.chunks[0].opcodenum)&&this.chunks.slice(1,this.chunks.length-2).every(function(e){return e.buf&&d.Buffer.isBuffer(e.buf)})&&X.isSmallIntOp(this.chunks[this.chunks.length-2].opcodenum)&&this.chunks[this.chunks.length-1].opcodenum===X.OP_CHECKMULTISIG};q.prototype.isMultisigIn=function(){return this.chunks.length>=2&&this.chunks[0].opcodenum===0&&this.chunks.slice(1,this.chunks.length).every(function(e){return e.buf&&d.Buffer.isBuffer(e.buf)&&so.isTxDER(e.buf)})};q.prototype.isDataOut=function(){var e=this.chunks.length>=1&&this.chunks[0].opcodenum===X.OP_RETURN;if(!e)return!1;var t=this.chunks.slice(1),r=new q({chunks:t});return r.isPushOnly()};q.prototype.isSafeDataOut=function(){if(this.chunks.length<2||this.chunks[0].opcodenum!==X.OP_FALSE)return!1;var e=this.chunks.slice(1),t=new q({chunks:e});return t.isDataOut()};q.prototype.getData=function(){if(this.isSafeDataOut()){var e=this.chunks.slice(2),t=e.map(r=>r.buf);return t}if(this.isDataOut()||this.isScriptHashOut())return Le.isUndefined(this.chunks[1])?d.Buffer.alloc(0):d.Buffer.from(this.chunks[1].buf);if(this.isPublicKeyHashOut())return d.Buffer.from(this.chunks[2].buf);throw new Error("Unrecognized script type to get data from")};q.prototype.isPushOnly=function(){return Le.every(this.chunks,function(e){return e.opcodenum<=X.OP_16||e.opcodenum===X.OP_PUSHDATA1||e.opcodenum===X.OP_PUSHDATA2||e.opcodenum===X.OP_PUSHDATA4})};q.types={};q.types.UNKNOWN="Unknown";q.types.PUBKEY_OUT="Pay to public key";q.types.PUBKEY_IN="Spend from public key";q.types.PUBKEYHASH_OUT="Pay to public key hash";q.types.PUBKEYHASH_IN="Spend from public key hash";q.types.SCRIPTHASH_OUT="Pay to script hash";q.types.SCRIPTHASH_IN="Spend from script hash";q.types.MULTISIG_OUT="Pay to multisig";q.types.MULTISIG_IN="Spend from multisig";q.types.DATA_OUT="Data push";q.types.SAFE_DATA_OUT="Safe data push";q.OP_RETURN_STANDARD_SIZE=220;q.prototype.classify=function(){if(this._isInput)return this.classifyInput();if(this._isOutput)return this.classifyOutput();var e=this.classifyOutput();return e!==q.types.UNKNOWN?e:this.classifyInput()};q.outputIdentifiers={};q.outputIdentifiers.PUBKEY_OUT=q.prototype.isPublicKeyOut;q.outputIdentifiers.PUBKEYHASH_OUT=q.prototype.isPublicKeyHashOut;q.outputIdentifiers.MULTISIG_OUT=q.prototype.isMultisigOut;q.outputIdentifiers.SCRIPTHASH_OUT=q.prototype.isScriptHashOut;q.outputIdentifiers.DATA_OUT=q.prototype.isDataOut;q.outputIdentifiers.SAFE_DATA_OUT=q.prototype.isSafeDataOut;q.prototype.classifyOutput=function(){for(var e in q.outputIdentifiers)if(q.outputIdentifiers[e].bind(this)())return q.types[e];return q.types.UNKNOWN};q.inputIdentifiers={};q.inputIdentifiers.PUBKEY_IN=q.prototype.isPublicKeyIn;q.inputIdentifiers.PUBKEYHASH_IN=q.prototype.isPublicKeyHashIn;q.inputIdentifiers.MULTISIG_IN=q.prototype.isMultisigIn;q.inputIdentifiers.SCRIPTHASH_IN=q.prototype.isScriptHashIn;q.prototype.classifyInput=function(){for(var e in q.inputIdentifiers)if(q.inputIdentifiers[e].bind(this)())return q.types[e];return q.types.UNKNOWN};q.prototype.isStandard=function(){return this.classify()!==q.types.UNKNOWN};q.prototype.prepend=function(e){return this._addByType(e,!0),this};q.prototype.equals=function(e){if(lt.checkState(e instanceof q,"Must provide another script"),this.chunks.length!==e.chunks.length)return!1;var t;for(t=0;t<this.chunks.length;t++){if(d.Buffer.isBuffer(this.chunks[t].buf)&&!d.Buffer.isBuffer(e.chunks[t].buf)||d.Buffer.isBuffer(this.chunks[t].buf)&&!this.chunks[t].buf.equals(e.chunks[t].buf))return!1;if(this.chunks[t].opcodenum!==e.chunks[t].opcodenum)return!1}return!0};q.prototype.add=function(e){return this._addByType(e,!1),this};q.prototype._addByType=function(e,t){if(typeof e=="string")this._addOpcode(e,t);else if(typeof e=="number")this._addOpcode(e,t);else if(e instanceof X)this._addOpcode(e,t);else if(d.Buffer.isBuffer(e))this._addBuffer(e,t);else if(e instanceof q)this.chunks=this.chunks.concat(e.chunks);else if(typeof e=="object")this._insertAtPosition(e,t);else throw new Error("Invalid script chunk")};q.prototype._insertAtPosition=function(e,t){t?this.chunks.unshift(e):this.chunks.push(e)};q.prototype._addOpcode=function(e,t){var r;return typeof e=="number"?r=e:e instanceof X?r=e.toNumber():r=X(e).toNumber(),this._insertAtPosition({opcodenum:r},t),this};q.prototype._addBuffer=function(e,t){var r,n=e.length;if(n>=0&&n<X.OP_PUSHDATA1)r=n;else if(n<Math.pow(2,8))r=X.OP_PUSHDATA1;else if(n<Math.pow(2,16))r=X.OP_PUSHDATA2;else if(n<Math.pow(2,32))r=X.OP_PUSHDATA4;else throw new Error("You can't push that much data");return this._insertAtPosition({buf:e,len:n,opcodenum:r},t),this};q.prototype.removeCodeseparators=function(){for(var e=[],t=0;t<this.chunks.length;t++)this.chunks[t].opcodenum!==X.OP_CODESEPARATOR&&e.push(this.chunks[t]);return this.chunks=e,this};q.buildMultisigOut=function(e,t,r){lt.checkArgument(t<=e.length,"Number of required signatures must be less than or equal to the number of public keys"),r=r||{};var n=new q;n.add(X.smallInt(t)),e=Le.map(e,ao);var i=e;r.noSorting||(i=e.map(a=>a.toString("hex")).sort().map(a=>new ao(a)));for(var o=0;o<i.length;o++){var s=i[o];n.add(s.toBuffer())}return n.add(X.smallInt(e.length)),n.add(X.OP_CHECKMULTISIG),n};q.buildMultisigIn=function(e,t,r,n){lt.checkArgument(Le.isArray(e)),lt.checkArgument(Le.isNumber(t)),lt.checkArgument(Le.isArray(r)),n=n||{};var i=new q;return i.add(X.OP_0),Le.each(r,function(o){lt.checkArgument(d.Buffer.isBuffer(o),"Signatures must be an array of Buffers"),i.add(o)}),i};q.buildP2SHMultisigIn=function(e,t,r,n){lt.checkArgument(Le.isArray(e)),lt.checkArgument(Le.isNumber(t)),lt.checkArgument(Le.isArray(r)),n=n||{};var i=new q;return i.add(X.OP_0),Le.each(r,function(o){lt.checkArgument(d.Buffer.isBuffer(o),"Signatures must be an array of Buffers"),i.add(o)}),i.add((n.cachedMultisig||q.buildMultisigOut(e,t,n)).toBuffer()),i};q.buildPublicKeyHashOut=function(e){lt.checkArgument(!Le.isUndefined(e)),lt.checkArgument(e instanceof ao||e instanceof jr||Le.isString(e)),e instanceof ao?e=e.toAddress():Le.isString(e)&&(e=new jr(e));var t=new q;return t.add(X.OP_DUP).add(X.OP_HASH160).add(e.hashBuffer).add(X.OP_EQUALVERIFY).add(X.OP_CHECKSIG),t._network=e.network,t};q.buildPublicKeyOut=function(e){lt.checkArgument(e instanceof ao);var t=new q;return t.add(e.toBuffer()).add(X.OP_CHECKSIG),t};q.buildDataOut=function(e,t){lt.checkArgument(Le.isUndefined(e)||Le.isString(e)||Le.isArray(e)||d.Buffer.isBuffer(e));var r=e;Le.isArray(r)||(r=[e]);var n=new q;n.add(X.OP_RETURN);for(let i of r)lt.checkArgument(Le.isUndefined(i)||Le.isString(i)||d.Buffer.isBuffer(i)),Le.isString(i)&&(i=d.Buffer.from(i,t)),Le.isUndefined(i)||n.add(i);return n};q.buildSafeDataOut=function(e,t){var r=q.buildDataOut(e,t),n=new q;return n.add(X.OP_FALSE),n.add(r),n};q.buildScriptHashOut=function(e){lt.checkArgument(e instanceof q||e instanceof jr&&e.isPayToScriptHash());var t=new q;return t.add(X.OP_HASH160).add(e instanceof jr?e.hashBuffer:Ep.sha256ripemd160(e.toBuffer())).add(X.OP_EQUAL),t._network=e._network||e.network,t};q.buildPublicKeyIn=function(e,t){lt.checkArgument(e instanceof so||d.Buffer.isBuffer(e)),lt.checkArgument(Le.isUndefined(t)||Le.isNumber(t)),e instanceof so&&(e=e.toBuffer());var r=new q;return r.add(d.Buffer.concat([e,d.Buffer.from([(t||so.SIGHASH_ALL)&255])])),r};q.buildPublicKeyHashIn=function(e,t,r){lt.checkArgument(t instanceof so||d.Buffer.isBuffer(t)),lt.checkArgument(Le.isUndefined(r)||Le.isNumber(r)),t instanceof so&&(t=t.toBuffer());var n=new q().add(d.Buffer.concat([t,d.Buffer.from([(r||so.SIGHASH_ALL)&255])])).add(new ao(e).toBuffer());return n};q.empty=function(){return new q};q.prototype.toScriptHashOut=function(){return q.buildScriptHashOut(this)};q.fromAddress=function(e){if(e=jr(e),e.isPayToScriptHash())return q.buildScriptHashOut(e);if(e.isPayToPublicKeyHash())return q.buildPublicKeyHashOut(e);throw new xp.Script.UnrecognizedAddress(e)};q.prototype.getAddressInfo=function(e){if(this._isInput)return this._getInputAddressInfo();if(this._isOutput)return this._getOutputAddressInfo();var t=this._getOutputAddressInfo();return t||this._getInputAddressInfo()};q.prototype._getOutputAddressInfo=function(){var e={};if(this.isScriptHashOut())e.hashBuffer=this.getData(),e.type=jr.PayToScriptHash;else if(this.isPublicKeyHashOut())e.hashBuffer=this.getData(),e.type=jr.PayToPublicKeyHash;else return!1;return e};q.prototype._getInputAddressInfo=function(){var e={};if(this.isPublicKeyHashIn())e.hashBuffer=Ep.sha256ripemd160(this.chunks[1].buf),e.type=jr.PayToPublicKeyHash;else if(this.isScriptHashIn())e.hashBuffer=Ep.sha256ripemd160(this.chunks[this.chunks.length-1].buf),e.type=jr.PayToScriptHash;else return!1;return e};q.prototype.toAddress=function(e){var t=this.getAddressInfo();return t?(t.network=T1.get(e)||this._network||T1.defaultNetwork,new jr(t)):!1};q.prototype.findAndDelete=function(e){for(var t=e.toBuffer(),r=t.length?t[0]:-1,n=0;n<this.chunks.length;n++){var i=this.chunks[n];if(!(i.opcodenum!==r&&p6(i))){var o=q({chunks:[i]}).toBuffer();t.equals(o)&&(this.chunks.splice(n,1),n--)}}return this};function p6(e){var t=e.opcodenum;if(typeof t!="number"||!Number.isInteger(t)||t<0||t>255)return!1;if(!e.buf||t>X.OP_PUSHDATA4)return!0;if(!d.Buffer.isBuffer(e.buf))return!1;var r=e.len;return t===X.OP_PUSHDATA1?Number.isInteger(r)&&r>=0&&r<=255:t===X.OP_PUSHDATA2?Number.isInteger(r)&&r>=0&&r<=65535:t===X.OP_PUSHDATA4?Number.isInteger(r)&&r>=0&&r<=4294967295:!0}q.prototype.checkMinimalPush=function(e){var t=this.chunks[e],r=t.buf,n=t.opcodenum;return r?r.length===0?n===X.OP_0:r.length===1&&r[0]>=1&&r[0]<=16?n===X.OP_1+(r[0]-1):r.length===1&&r[0]===129?n===X.OP_1NEGATE:r.length<=75?n===r.length:r.length<=255?n===X.OP_PUSHDATA1:r.length<=65535?n===X.OP_PUSHDATA2:!0:!0};q.prototype._decodeOP_N=function(e){if(e===X.OP_0)return 0;if(e>=X.OP_1&&e<=X.OP_16)return e-(X.OP_1-1);throw new Error("Invalid opcode: "+JSON.stringify(e))};q.prototype.getSignatureOperationsCount=function(e){e=Le.isUndefined(e)?!0:e;var t=this,r=0,n=X.OP_INVALIDOPCODE;return Le.each(t.chunks,function(o){var s=o.opcodenum;s===X.OP_CHECKSIG||s===X.OP_CHECKSIGVERIFY?r++:(s===X.OP_CHECKMULTISIG||s===X.OP_CHECKMULTISIGVERIFY)&&(e&&n>=X.OP_1&&n<=X.OP_16?r+=t._decodeOP_N(n):r+=20),n=s}),r};N1.exports=q});var fs=B((H5,k1)=>{"use strict";g();var M1=Aa(),bt=function e(t){if(!(this instanceof e))return new e(t);this.bufLen=0,t?this.set(t):this.bufs=[]};bt.prototype.set=function(e){return this.bufs=e.bufs||this.bufs||[],this.bufLen=this.bufs.reduce(function(t,r){return t+r.length},0),this};bt.prototype.toBuffer=function(){return this.concat()};bt.prototype.concat=function(){return d.Buffer.concat(this.bufs,this.bufLen)};bt.prototype.write=function(e){return M1(d.Buffer.isBuffer(e)),this.bufs.push(e),this.bufLen+=e.length,this};bt.prototype.writeReverse=function(e){return M1(d.Buffer.isBuffer(e)),this.bufs.push(d.Buffer.from(e).reverse()),this.bufLen+=e.length,this};bt.prototype.writeUInt8=function(e){var t=d.Buffer.alloc(1);return t.writeUInt8(e,0),this.write(t),this};bt.prototype.writeUInt16BE=function(e){var t=d.Buffer.alloc(2);return t.writeUInt16BE(e,0),this.write(t),this};bt.prototype.writeUInt16LE=function(e){var t=d.Buffer.alloc(2);return t.writeUInt16LE(e,0),this.write(t),this};bt.prototype.writeUInt32BE=function(e){var t=d.Buffer.alloc(4);return t.writeUInt32BE(e,0),this.write(t),this};bt.prototype.writeInt32LE=function(e){var t=d.Buffer.alloc(4);return t.writeInt32LE(e,0),this.write(t),this};bt.prototype.writeUInt32LE=function(e){var t=d.Buffer.alloc(4);return t.writeUInt32LE(e,0),this.write(t),this};bt.prototype.writeUInt64BEBN=function(e){var t=e.toBuffer({size:8});return this.write(t),this};bt.prototype.writeUInt64LEBN=function(e){var t=e.toBuffer({size:8});return this.writeReverse(t),this};bt.prototype.writeVarintNum=function(e){var t=bt.varintBufNum(e);return this.write(t),this};bt.prototype.writeVarintBN=function(e){var t=bt.varintBufBN(e);return this.write(t),this};bt.varintBufNum=function(e){var t;return e<253?(t=d.Buffer.alloc(1),t.writeUInt8(e,0)):e<65536?(t=d.Buffer.alloc(3),t.writeUInt8(253,0),t.writeUInt16LE(e,1)):e<4294967296?(t=d.Buffer.alloc(5),t.writeUInt8(254,0),t.writeUInt32LE(e,1)):(t=d.Buffer.alloc(9),t.writeUInt8(255,0),t.writeInt32LE(e&-1,1),t.writeUInt32LE(Math.floor(e/4294967296),5)),t};bt.varintBufBN=function(e){var t,r=e.toNumber();if(r<253)t=d.Buffer.alloc(1),t.writeUInt8(r,0);else if(r<65536)t=d.Buffer.alloc(3),t.writeUInt8(253,0),t.writeUInt16LE(r,1);else if(r<4294967296)t=d.Buffer.alloc(5),t.writeUInt8(254,0),t.writeUInt32LE(r,1);else{var n=new bt;n.writeUInt8(255),n.writeUInt64LEBN(e),t=n.concat()}return t};k1.exports=bt});var ja=B((K5,D1)=>{"use strict";g();var C1=fs(),L1=qa(),g6=Ar(),Kr=function e(t){if(!(this instanceof e))return new e(t);if(d.Buffer.isBuffer(t))this.buf=t;else if(typeof t=="number"){var r=t;this.fromNumber(r)}else if(t instanceof g6){var n=t;this.fromBN(n)}else if(t){var i=t;this.set(i)}};Kr.prototype.set=function(e){return this.buf=e.buf||this.buf,this};Kr.prototype.fromString=function(e){return this.set({buf:d.Buffer.from(e,"hex")}),this};Kr.prototype.toString=function(){return this.buf.toString("hex")};Kr.prototype.fromBuffer=function(e){return this.buf=e,this};Kr.prototype.fromBufferReader=function(e){return this.buf=e.readVarintBuf(),this};Kr.prototype.fromBN=function(e){return this.buf=C1().writeVarintBN(e).concat(),this};Kr.prototype.fromNumber=function(e){return this.buf=C1().writeVarintNum(e).concat(),this};Kr.prototype.toBuffer=function(){return this.buf};Kr.prototype.toBN=function(){return L1(this.buf).readVarintBN()};Kr.prototype.toNumber=function(){return L1(this.buf).readVarintNum()};D1.exports=Kr});var jn=B((V5,F1)=>{"use strict";g();var Pc=at(),Ap=Ar(),U1=Lt(),Bc=vr(),y6=fs(),m6=ja(),Op=Gr(),Rp=We(),v6=ii(),b6=9007199254740991;function Wt(e){if(!(this instanceof Wt))return new Wt(e);if(Pc.isObject(e))if(this.satoshis=e.satoshis,d.Buffer.isBuffer(e.script))this._scriptBuffer=e.script;else{var t;Pc.isString(e.script)&&Bc.isHexa(e.script)?t=U1.Buffer.from(e.script,"hex"):t=e.script,this.setScript(t)}else throw new TypeError("Unrecognized argument for Output")}Object.defineProperty(Wt.prototype,"script",{configurable:!1,enumerable:!0,get:function(){return this._script?this._script:(this.setScriptFromBuffer(this._scriptBuffer),this._script)}});Object.defineProperty(Wt.prototype,"satoshis",{configurable:!1,enumerable:!0,get:function(){return this._satoshis},set:function(e){e instanceof Ap?(this._satoshisBN=e,this._satoshis=e.toNumber()):Pc.isString(e)?(this._satoshis=parseInt(e),this._satoshisBN=Ap.fromNumber(this._satoshis)):(Rp.checkArgument(Bc.isNaturalNumber(e),"Output satoshis is not a natural number"),this._satoshisBN=Ap.fromNumber(e),this._satoshis=e),Rp.checkState(Bc.isNaturalNumber(this._satoshis),"Output satoshis is not a natural number")}});Wt.prototype.invalidSatoshis=function(){return this._satoshis>b6?"transaction txout satoshis greater than max safe integer":this._satoshis!==this._satoshisBN.toNumber()?"transaction txout satoshis has corrupted value":this._satoshis<0?"transaction txout negative":!1};Object.defineProperty(Wt.prototype,"satoshisBN",{configurable:!1,enumerable:!0,get:function(){return this._satoshisBN},set:function(e){this._satoshisBN=e,this._satoshis=e.toNumber(),Rp.checkState(Bc.isNaturalNumber(this._satoshis),"Output satoshis is not a natural number")}});Wt.prototype.toObject=Wt.prototype.toJSON=function(){var t={satoshis:this.satoshis};return t.script=this._scriptBuffer.toString("hex"),t};Wt.fromObject=function(e){return new Wt(e)};Wt.prototype.setScriptFromBuffer=function(e){this._scriptBuffer=e;try{this._script=Op.fromBuffer(this._scriptBuffer),this._script._isOutput=!0}catch(t){if(t instanceof v6.Script.InvalidBuffer)this._script=null;else throw t}};Wt.prototype.setScript=function(e){if(e instanceof Op)this._scriptBuffer=e.toBuffer(),this._script=e,this._script._isOutput=!0;else if(Pc.isString(e))this._script=Op.fromString(e),this._scriptBuffer=this._script.toBuffer(),this._script._isOutput=!0;else if(d.Buffer.isBuffer(e))this.setScriptFromBuffer(e);else throw new TypeError("Invalid argument type: script");return this};Wt.prototype.inspect=function(){var e;return this.script?e=this.script.inspect():e=this._scriptBuffer.toString("hex"),"<Output ("+this.satoshis+" sats) "+e+">"};Wt.fromBufferReader=function(e){var t={};t.satoshis=e.readUInt64LEBN();var r=e.readVarintNum();return r!==0?t.script=e.read(r):t.script=U1.Buffer.from([]),new Wt(t)};Wt.prototype.toBufferWriter=function(e){e||(e=new y6),e.writeUInt64LEBN(this._satoshisBN);var t=this._scriptBuffer;return e.writeVarintNum(t.length),e.write(t),e};Wt.prototype.getSize=function(){var e=this.script.toBuffer().length,t=m6(e).toBuffer().length;return 8+t+e};F1.exports=Wt});var Ka=B((z5,q1)=>{"use strict";g();var br=Ar(),gn=gi(),_6=fr(),S6=Pr(),w6=sa(),Ei=nr(),E6=at(),Tp=We(),tt=function e(t){if(!(this instanceof e))return new e(t);t&&this.set(t)};Object.defineProperty(tt.prototype,"k",{get:function(){return this._k},set:function(e){this._k=e,this._kFresh=!0},enumerable:!0,configurable:!0});tt.prototype.set=function(e){if(this.hashbuf=e.hashbuf||this.hashbuf,this.endian=e.endian||this.endian,this.privkey=e.privkey||this.privkey,this.pubkey=e.pubkey||(this.privkey?this.privkey.publicKey:this.pubkey),e.sig)if(d.Buffer.isBuffer(e.sig)){var t=fr();this.sig=t.fromDER(e.sig)}else this.sig=e.sig;else this.sig=this.sig;return e.k&&(this.k=e.k),this.verified=e.verified||this.verified,this};tt.prototype.privkey2pubkey=function(){this.pubkey=this.privkey.toPublicKey()};tt.prototype.calci=function(){for(var e=0;e<4;e++){this.sig.i=e;var t;try{t=this.toPublicKey()}catch(r){console.error(r);continue}if(t.point.eq(this.pubkey.point))return this.sig.compressed=this.pubkey.compressed,this}throw this.sig.i=void 0,new Error("Unable to find valid recovery factor")};tt.fromString=function(e){var t=JSON.parse(e);return new tt(t)};tt.prototype.randomK=function(){var e=gn.getN(),t;do t=br.fromBuffer(w6.getRandomBuffer(32));while(!(t.lt(e)&&t.gt(br.Zero)));return this.k=t,this};tt.prototype.deterministicK=function(e){E6.isUndefined(e)&&(e=0);var t=d.Buffer.alloc(32);t.fill(1);var r=d.Buffer.alloc(32);r.fill(0);var n=this.privkey.bn.toBuffer({size:32}),i=this.endian==="little"?d.Buffer.from(this.hashbuf).reverse():this.hashbuf;r=Ei.sha256hmac(d.Buffer.concat([t,d.Buffer.from([0]),n,i]),r),t=Ei.sha256hmac(t,r),r=Ei.sha256hmac(d.Buffer.concat([t,d.Buffer.from([1]),n,i]),r),t=Ei.sha256hmac(t,r),t=Ei.sha256hmac(t,r);for(var o=br.fromBuffer(t),s=gn.getN(),a=0;a<e||!(o.lt(s)&&o.gt(br.Zero));a++)r=Ei.sha256hmac(d.Buffer.concat([t,d.Buffer.from([0])]),r),t=Ei.sha256hmac(t,r),t=Ei.sha256hmac(t,r),o=br.fromBuffer(t);return this.k=o,this};tt.prototype.toPublicKey=function(){var e=this.sig.i;Tp.checkArgument(e===0||e===1||e===2||e===3,new Error("i must be equal to 0, 1, 2, or 3"));var t=br.fromBuffer(this.hashbuf),r=this.sig.r,n=this.sig.s,i=e&1,o=e>>1,s=gn.getN(),a=gn.getG(),f=o?r.add(s):r,l=gn.fromX(i,f),m=l.mul(s);if(!m.isInfinity())throw new Error("nR is not a valid curve point");var y=t.neg().umod(s),p=r.invm(s),w=l.mul(n).add(a.mul(y)).mul(p),O=S6.fromPoint(w,this.sig.compressed);return O};tt.prototype.sigError=function(){if(!d.Buffer.isBuffer(this.hashbuf)||this.hashbuf.length!==32)return"hashbuf must be a 32 byte buffer";var e=this.sig.r,t=this.sig.s,r=gn.getN();try{if(e.lte(br.Zero)||t.lte(br.Zero)||e.gte(r)||t.gte(r))return"r and s not in range";var n=br.fromBuffer(this.hashbuf,this.endian?{endian:this.endian}:void 0),i=t.invm(r),o=i.mul(n).umod(r),s=i.mul(e).umod(r),a=gn.getG().mulAdd(o,this.pubkey.point,s);return a.isInfinity()?"p is infinity":a.getX().umod(r).cmp(e)!==0?"Invalid signature":!1}catch(f){return"Signature security validation failed: "+f.message}};tt.toLowS=function(e){return e.gt(br.fromBuffer(d.Buffer.from("7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0","hex")))&&(e=gn.getN().sub(e)),e};tt.prototype._findSignature=function(e,t){var r=gn.getN(),n=gn.getG(),i=0,o,s,a,f;do(!this.k||!this._kFresh||i>0)&&this.deterministicK(i),i++,o=this.k,s=n.mul(o),a=s.x.umod(r),f=o.invm(r).mul(t.add(e.mul(a))).umod(r);while(a.cmp(br.Zero)<=0||f.cmp(br.Zero)<=0);return this._kFresh=!1,f=tt.toLowS(f),{s:f,r:a}};tt.prototype.sign=function(){var e=this.hashbuf,t=this.privkey,r=t.bn;Tp.checkState(e&&t&&r,new Error("invalid parameters")),Tp.checkState(d.Buffer.isBuffer(e)&&e.length===32,new Error("hashbuf must be a 32 byte buffer"));var n=br.fromBuffer(e,this.endian?{endian:this.endian}:void 0),i=this._findSignature(r,n);return i.compressed=this.pubkey.compressed,this.sig=new _6(i),this};tt.prototype.signRandomK=function(){return this.randomK(),this.sign()};tt.prototype.toString=function(){var e={};return this.hashbuf&&(e.hashbuf=this.hashbuf.toString("hex")),this.privkey&&(e.privkey=this.privkey.toString()),this.pubkey&&(e.pubkey=this.pubkey.toString()),this.sig&&(e.sig=this.sig.toString()),this.k&&(e.k=this.k.toString()),JSON.stringify(e)};tt.prototype.verify=function(){return this.verified=!this.sigError(),this.verified};tt.prototype.verifyBool=function(){return this.verify()===!0};tt.sign=function(e,t,r){return tt().set({hashbuf:e,endian:r,privkey:t}).sign().sig};tt.signWithCalcI=function(e,t,r){return tt().set({hashbuf:e,endian:r,privkey:t}).sign().calci().sig};tt.signRandomK=function(e,t,r){return tt().set({hashbuf:e,endian:r,privkey:t}).signRandomK().sig};tt.verify=function(e,t,r,n){return tt().set({hashbuf:e,endian:n,sig:t,pubkey:r}).verify()};q1.exports=tt});var cs=B(($5,G1)=>{"use strict";g();var xi=at(),x6=We(),Ga=ii(),I6=fs(),Pp=Lt(),j1=vr(),Nc=Gr(),A6=Ii(),H1=jn(),Mc=4294967295,O6=Mc-2,K1=Mc,R6=Mc-1;function rt(e){if(!(this instanceof rt))return new rt(e);if(e)return this._fromObject(e)}rt.MAXINT=Mc;rt.DEFAULT_SEQNUMBER=K1;rt.DEFAULT_LOCKTIME_SEQNUMBER=R6;rt.DEFAULT_RBF_SEQNUMBER=O6;rt.BASE_SIZE=40;Object.defineProperty(rt.prototype,"script",{configurable:!1,enumerable:!0,get:function(){return this.isNull()?null:(this._script||(this._script=new Nc(this._scriptBuffer),this._script._isInput=!0),this._script)}});rt.fromObject=function(e){x6.checkArgument(xi.isObject(e));var t=new rt;return t._fromObject(e)};rt.prototype._fromObject=function(e){var t;if(xi.isString(e.prevTxId)&&j1.isHexa(e.prevTxId)?t=Pp.Buffer.from(e.prevTxId,"hex"):t=e.prevTxId,this.output=e.output?e.output instanceof H1?e.output:new H1(e.output):void 0,this.prevTxId=t||e.txidbuf,this.outputIndex=xi.isUndefined(e.outputIndex)?e.txoutnum:e.outputIndex,this.sequenceNumber=xi.isUndefined(e.sequenceNumber)?xi.isUndefined(e.seqnum)?K1:e.seqnum:e.sequenceNumber,xi.isUndefined(e.script)&&xi.isUndefined(e.scriptBuffer))throw new Ga.Transaction.Input.MissingScript;return this.setScript(e.scriptBuffer||e.script),this};rt.prototype.toObject=rt.prototype.toJSON=function(){var t={prevTxId:this.prevTxId.toString("hex"),outputIndex:this.outputIndex,sequenceNumber:this.sequenceNumber,script:this._scriptBuffer.toString("hex")};return this.script&&(t.scriptString=this.script.toString()),this.output&&(t.output=this.output.toObject()),t};rt.fromBufferReader=function(e){var t=new rt;return t.prevTxId=e.readReverse(32),t.outputIndex=e.readUInt32LE(),t._scriptBuffer=e.readVarLengthBuffer(),t.sequenceNumber=e.readUInt32LE(),t};rt.prototype.toBufferWriter=function(e){e||(e=new I6),e.writeReverse(this.prevTxId),e.writeUInt32LE(this.outputIndex);var t=this._scriptBuffer;return e.writeVarintNum(t.length),e.write(t),e.writeUInt32LE(this.sequenceNumber),e};rt.prototype.setScript=function(e){if(this._script=null,e instanceof Nc)this._script=e,this._script._isInput=!0,this._scriptBuffer=e.toBuffer();else if(e===null)this._script=Nc.empty(),this._script._isInput=!0,this._scriptBuffer=this._script.toBuffer();else if(j1.isHexa(e))this._scriptBuffer=Pp.Buffer.from(e,"hex");else if(xi.isString(e))this._script=new Nc(e),this._script._isInput=!0,this._scriptBuffer=this._script.toBuffer();else if(d.Buffer.isBuffer(e))this._scriptBuffer=Pp.Buffer.from(e);else throw new TypeError("Invalid argument type: script");return this};rt.prototype.getSignatures=function(){throw new Ga.AbstractMethodInvoked("Trying to sign unsupported output type (only P2PKH and P2SH multisig inputs are supported) for input: "+JSON.stringify(this))};rt.prototype.isFullySigned=function(){throw new Ga.AbstractMethodInvoked("Input#isFullySigned")};rt.prototype.isFinal=function(){return this.sequenceNumber===rt.MAXINT};rt.prototype.addSignature=function(){throw new Ga.AbstractMethodInvoked("Input#addSignature")};rt.prototype.clearSignatures=function(){throw new Ga.AbstractMethodInvoked("Input#clearSignatures")};rt.prototype.isValidSignature=function(e,t){return t.signature.nhashtype=t.sigtype,A6.verify(e,t.signature,t.publicKey,t.inputIndex,this.output.script,this.output.satoshisBN)};rt.prototype.isNull=function(){return this.prevTxId.toString("hex")==="0000000000000000000000000000000000000000000000000000000000000000"&&this.outputIndex===4294967295};rt.prototype._estimateSize=function(){return this.toBufferWriter().toBuffer().length};G1.exports=rt});var ls=B((X5,V1)=>{"use strict";g();V1.exports=function(t,r){r&&(t.super_=r,t.prototype=Object.create(r.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}});var ds=B((Q5,Y1)=>{"use strict";g();var hs=at(),Br=We(),T6=ls(),W1=vr(),z1=Pr(),P6=ii(),Va=fr();function Vr(e){if(!(this instanceof Vr))return new Vr(e);if(e instanceof Vr)return e;if(hs.isObject(e))return this._fromObject(e);throw new P6.InvalidArgument("TransactionSignatures must be instantiated from an object")}T6(Vr,Va);Vr.prototype._fromObject=function(e){return this._checkObjectArgs(e),this.publicKey=new z1(e.publicKey),this.prevTxId=d.Buffer.isBuffer(e.prevTxId)?e.prevTxId:d.Buffer.from(e.prevTxId,"hex"),this.outputIndex=e.outputIndex,this.inputIndex=e.inputIndex,this.signature=e.signature instanceof Va?e.signature:d.Buffer.isBuffer(e.signature)?Va.fromBuffer(e.signature):Va.fromString(e.signature),this.sigtype=e.sigtype,this};Vr.prototype._checkObjectArgs=function(e){Br.checkArgument(z1(e.publicKey),"publicKey"),Br.checkArgument(!hs.isUndefined(e.inputIndex),"inputIndex"),Br.checkArgument(!hs.isUndefined(e.outputIndex),"outputIndex"),Br.checkState(hs.isNumber(e.inputIndex),"inputIndex must be a number"),Br.checkState(hs.isNumber(e.outputIndex),"outputIndex must be a number"),Br.checkArgument(e.signature,"signature"),Br.checkArgument(e.prevTxId,"prevTxId"),Br.checkState(e.signature instanceof Va||d.Buffer.isBuffer(e.signature)||W1.isHexa(e.signature),"signature must be a buffer or hexa value"),Br.checkState(d.Buffer.isBuffer(e.prevTxId)||W1.isHexa(e.prevTxId),"prevTxId must be a buffer or hexa value"),Br.checkArgument(e.sigtype,"sigtype"),Br.checkState(hs.isNumber(e.sigtype),"sigtype must be a number")};Vr.prototype.toObject=Vr.prototype.toJSON=function(){return{publicKey:this.publicKey.toString(),prevTxId:this.prevTxId.toString("hex"),outputIndex:this.outputIndex,inputIndex:this.inputIndex,signature:this.signature.toString(),sigtype:this.sigtype}};Vr.fromObject=function(e){return Br.checkArgument(e),new Vr(e)};Y1.exports=Vr});var Q1=B((tq,J1)=>{"use strict";g();var B6=ls(),Z1=We(),Bp=cs(),N6=jn(),M6=Ii(),X1=Gr(),$1=fr(),k6=ds();function Kn(){Bp.apply(this,arguments)}B6(Kn,Bp);Kn.prototype.getSignatures=function(e,t,r,n){Z1.checkState(this.output instanceof N6),n=n||$1.SIGHASH_ALL|$1.SIGHASH_FORKID;var i=t.toPublicKey();return i.toString()===this.output.script.getPublicKey().toString("hex")?[new k6({publicKey:i,prevTxId:this.prevTxId,outputIndex:this.outputIndex,inputIndex:r,signature:M6.sign(e,t,n,r,this.output.script,this.output.satoshisBN),sigtype:n})]:[]};Kn.prototype.addSignature=function(e,t){return Z1.checkState(this.isValidSignature(e,t),"Signature is invalid"),this.setScript(X1.buildPublicKeyIn(t.signature.toDER(),t.sigtype)),this};Kn.prototype.clearSignatures=function(){return this.setScript(X1.empty()),this};Kn.prototype.isFullySigned=function(){return this.script.isPublicKeyIn()};Kn.SCRIPT_MAX_SIZE=74;Kn.prototype._estimateSize=function(){return Bp.BASE_SIZE+Kn.SCRIPT_MAX_SIZE};J1.exports=Kn});var ix=B((nq,nx)=>{"use strict";g();var C6=ls(),tx=We(),L6=nr(),Np=cs(),D6=jn(),U6=Ii(),rx=Gr(),ex=fr(),F6=ds();function Gn(){Np.apply(this,arguments)}C6(Gn,Np);Gn.prototype.getSignatures=function(e,t,r,n,i){tx.checkState(this.output instanceof D6),i=i||L6.sha256ripemd160(t.publicKey.toBuffer()),n=n||ex.SIGHASH_ALL|ex.SIGHASH_FORKID;var o=this.output.script.chunks[2]&&this.output.script.chunks[2].buf;return o&&i.equals(o)?[new F6({publicKey:t.publicKey,prevTxId:this.prevTxId,outputIndex:this.outputIndex,inputIndex:r,signature:U6.sign(e,t,n,r,this.output.script,this.output.satoshisBN),sigtype:n})]:[]};Gn.prototype.addSignature=function(e,t){return tx.checkState(this.isValidSignature(e,t),"Signature is invalid"),this.setScript(rx.buildPublicKeyHashIn(t.publicKey,t.signature.toDER(),t.sigtype)),this};Gn.prototype.clearSignatures=function(){return this.setScript(rx.empty()),this};Gn.prototype.isFullySigned=function(){return this.script.isPublicKeyHashIn()};Gn.SCRIPT_MAX_SIZE=108;Gn.prototype._estimateSize=function(){return Np.BASE_SIZE+Gn.SCRIPT_MAX_SIZE};nx.exports=Gn});var ax=B((oq,sx)=>{"use strict";g();var Wr=at(),q6=ls(),Cc=cs(),H6=jn(),Wa=We(),ox=Gr(),kc=fr(),Mp=Ii(),kp=ds(),j6=Pr(),K6=ja();function Ft(e,t,r,n){Cc.apply(this,arguments);var i=this;t=t||e.publicKeys,r=r||e.threshold,n=n||e.signatures,this.publicKeys=t.map(o=>o.toString("hex")).sort().map(o=>new j6(o)),Wa.checkState(ox.buildMultisigOut(this.publicKeys,r).equals(this.output.script),"Provided public keys don't match to the provided output script"),this.publicKeyIndex={},Wr.each(this.publicKeys,function(o,s){i.publicKeyIndex[o.toString()]=s}),this.threshold=r,this.signatures=n?this._deserializeSignatures(n):new Array(this.publicKeys.length)}q6(Ft,Cc);Ft.prototype.toObject=function(){var e=Cc.prototype.toObject.apply(this,arguments);return e.threshold=this.threshold,e.publicKeys=Wr.map(this.publicKeys,function(t){return t.toString()}),e.signatures=this._serializeSignatures(),e};Ft.prototype._deserializeSignatures=function(e){return Wr.map(e,function(t){if(t)return new kp(t)})};Ft.prototype._serializeSignatures=function(){return Wr.map(this.signatures,function(e){if(e)return e.toObject()})};Ft.prototype.getSignatures=function(e,t,r,n){Wa.checkState(this.output instanceof H6),n=n||kc.SIGHASH_ALL|kc.SIGHASH_FORKID;var i=this,o=[];return Wr.each(this.publicKeys,function(s){s.toString()===t.publicKey.toString()&&o.push(new kp({publicKey:t.publicKey,prevTxId:i.prevTxId,outputIndex:i.outputIndex,inputIndex:r,signature:Mp.sign(e,t,n,r,i.output.script,i.output.satoshisBN),sigtype:n}))}),o};Ft.prototype.addSignature=function(e,t){return Wa.checkState(!this.isFullySigned(),"All needed signatures have already been added"),Wa.checkArgument(!Wr.isUndefined(this.publicKeyIndex[t.publicKey.toString()]),"Signature has no matching public key"),Wa.checkState(this.isValidSignature(e,t)),this.signatures[this.publicKeyIndex[t.publicKey.toString()]]=t,this._updateScript(),this};Ft.prototype._updateScript=function(){return this.setScript(ox.buildMultisigIn(this.publicKeys,this.threshold,this._createSignatures())),this};Ft.prototype._createSignatures=function(){return Wr.map(Wr.filter(this.signatures,function(e){return!Wr.isUndefined(e)}),function(e){return d.Buffer.concat([e.signature.toDER(),d.Buffer.from([e.sigtype&255])])})};Ft.prototype.clearSignatures=function(){this.signatures=new Array(this.publicKeys.length),this._updateScript()};Ft.prototype.isFullySigned=function(){return this.countSignatures()===this.threshold};Ft.prototype.countMissingSignatures=function(){return this.threshold-this.countSignatures()};Ft.prototype.countSignatures=function(){return Wr.reduce(this.signatures,function(e,t){return e+!!t},0)};Ft.prototype.publicKeysWithoutSignature=function(){var e=this;return Wr.filter(this.publicKeys,function(t){return!e.signatures[e.publicKeyIndex[t.toString()]]})};Ft.prototype.isValidSignature=function(e,t){return t.signature.nhashtype=t.sigtype,Mp.verify(e,t.signature,t.publicKey,t.inputIndex,this.output.script,this.output.satoshisBN)};Ft.normalizeSignatures=function(e,t,r,n,i){return i.map(function(o){var s=null;return n=n.filter(function(a){if(s)return!0;var f=new kp({signature:kc.fromTxFormat(a),publicKey:o,prevTxId:t.prevTxId,outputIndex:t.outputIndex,inputIndex:r,sigtype:kc.SIGHASH_ALL});f.signature.nhashtype=f.sigtype;var l=Mp.verify(e,f.signature,f.publicKey,f.inputIndex,t.output.script);return l?(s=f,!1):!0}),s||null})};Ft.SIGNATURE_SIZE=73;Ft.prototype._estimateSize=function(){var e=1+this.threshold*Ft.SIGNATURE_SIZE;return Cc.BASE_SIZE+K6(e).toBuffer().length+e};sx.exports=Ft});var hx=B((aq,lx)=>{"use strict";g();var zr=at(),G6=ls(),Lc=cs(),V6=jn(),za=We(),Cp=Gr(),ux=fr(),fx=Ii(),cx=ds(),W6=Pr(),z6=ja();function kt(e,t,r,n){Lc.apply(this,arguments);var i=this;t=t||e.publicKeys,r=r||e.threshold,n=n||e.signatures,this.publicKeys=t.map(o=>o.toString("hex")).sort().map(o=>new W6(o)),this.redeemScript=Cp.buildMultisigOut(this.publicKeys,r),za.checkState(Cp.buildScriptHashOut(this.redeemScript).equals(this.output.script),"Provided public keys don't hash to the provided output"),this.publicKeyIndex={},zr.each(this.publicKeys,function(o,s){i.publicKeyIndex[o.toString()]=s}),this.threshold=r,this.signatures=n?this._deserializeSignatures(n):new Array(this.publicKeys.length)}G6(kt,Lc);kt.prototype.toObject=function(){var e=Lc.prototype.toObject.apply(this,arguments);return e.threshold=this.threshold,e.publicKeys=zr.map(this.publicKeys,function(t){return t.toString()}),e.signatures=this._serializeSignatures(),e};kt.prototype._deserializeSignatures=function(e){return zr.map(e,function(t){if(t)return new cx(t)})};kt.prototype._serializeSignatures=function(){return zr.map(this.signatures,function(e){if(e)return e.toObject()})};kt.prototype.getSignatures=function(e,t,r,n){za.checkState(this.output instanceof V6),n=n||ux.SIGHASH_ALL|ux.SIGHASH_FORKID;var i=this,o=[];return zr.each(this.publicKeys,function(s){s.toString()===t.publicKey.toString()&&o.push(new cx({publicKey:t.publicKey,prevTxId:i.prevTxId,outputIndex:i.outputIndex,inputIndex:r,signature:fx.sign(e,t,n,r,i.redeemScript,i.output.satoshisBN),sigtype:n}))}),o};kt.prototype.addSignature=function(e,t){return za.checkState(!this.isFullySigned(),"All needed signatures have already been added"),za.checkArgument(!zr.isUndefined(this.publicKeyIndex[t.publicKey.toString()]),"Signature has no matching public key"),za.checkState(this.isValidSignature(e,t)),this.signatures[this.publicKeyIndex[t.publicKey.toString()]]=t,this._updateScript(),this};kt.prototype._updateScript=function(){return this.setScript(Cp.buildP2SHMultisigIn(this.publicKeys,this.threshold,this._createSignatures(),{cachedMultisig:this.redeemScript})),this};kt.prototype._createSignatures=function(){return zr.map(zr.filter(this.signatures,function(e){return!zr.isUndefined(e)}),function(e){return d.Buffer.concat([e.signature.toDER(),d.Buffer.from([e.sigtype&255])])})};kt.prototype.clearSignatures=function(){this.signatures=new Array(this.publicKeys.length),this._updateScript()};kt.prototype.isFullySigned=function(){return this.countSignatures()===this.threshold};kt.prototype.countMissingSignatures=function(){return this.threshold-this.countSignatures()};kt.prototype.countSignatures=function(){return zr.reduce(this.signatures,function(e,t){return e+!!t},0)};kt.prototype.publicKeysWithoutSignature=function(){var e=this;return zr.filter(this.publicKeys,function(t){return!e.signatures[e.publicKeyIndex[t.toString()]]})};kt.prototype.isValidSignature=function(e,t){return t.signature.nhashtype=t.sigtype,fx.verify(e,t.signature,t.publicKey,t.inputIndex,this.redeemScript,this.output.satoshisBN)};kt.SIGNATURE_SIZE=73;kt.PUBKEY_SIZE=34;kt.prototype._estimateSize=function(){var e=this.publicKeys.length*kt.PUBKEY_SIZE,t=this.threshold*kt.SIGNATURE_SIZE,r=3+e,n=r<=75?1:r<=255?2:3,i=t+1+n+r;return Lc.BASE_SIZE+z6(i).toBuffer().length+i};lx.exports=kt});var Dc=B((fq,ps)=>{g();ps.exports=cs();ps.exports.PublicKey=Q1();ps.exports.PublicKeyHash=ix();ps.exports.MultiSig=ax();ps.exports.MultiSigScriptHash=hx()});var Ii=B((lq,mx)=>{"use strict";g();var Y6=Lt(),dr=fr(),Ya=Gr(),$6=jn(),Z6=qa(),$a=fs(),dx=Ar(),Uc=nr(),px=Ka(),Lp=We(),Dp=Fc(),Ai=at(),gx=d.Buffer.from("0000000000000000000000000000000000000000000000000000000000000001","hex"),X6="ffffffffffffffff",J6=Dp.SCRIPT_ENABLE_SIGHASH_FORKID,Q6=function(e,t,r,n,i){var o=e.inputs[r];Lp.checkArgument(i instanceof dx,"For ForkId=0 signatures, satoshis or complete input must be provided");function s(D){var F=new $a;Ai.each(D.inputs,function(Q){F.writeReverse(Q.prevTxId),F.writeUInt32LE(Q.outputIndex)});var V=F.toBuffer(),Y=Uc.sha256sha256(V);return Y}function a(D){var F=new $a;Ai.each(D.inputs,function(Q){F.writeUInt32LE(Q.sequenceNumber)});var V=F.toBuffer(),Y=Uc.sha256sha256(V);return Y}function f(D,F){var V=new $a;Ai.isUndefined(F)?Ai.each(D.outputs,function(ce){ce.toBufferWriter(V)}):D.outputs[F].toBufferWriter(V);var Y=V.toBuffer(),Q=Uc.sha256sha256(Y);return Q}var l=d.Buffer.alloc(32),m=d.Buffer.alloc(32),y=d.Buffer.alloc(32);t&dr.SIGHASH_ANYONECANPAY||(l=s(e)),!(t&dr.SIGHASH_ANYONECANPAY)&&(t&31)!==dr.SIGHASH_SINGLE&&(t&31)!==dr.SIGHASH_NONE&&(m=a(e)),(t&31)!==dr.SIGHASH_SINGLE&&(t&31)!==dr.SIGHASH_NONE?y=f(e):(t&31)===dr.SIGHASH_SINGLE&&r<e.outputs.length&&(y=f(e,r));var p=new $a;p.writeInt32LE(e.version),p.write(l),p.write(m),p.writeReverse(o.prevTxId),p.writeUInt32LE(o.outputIndex);var w=n.toBuffer();p.writeVarintNum(w.length),p.write(w),p.writeUInt64LEBN(i);var O=o.sequenceNumber;p.writeUInt32LE(O),p.write(y),p.writeUInt32LE(e.nLockTime),p.writeUInt32LE(t>>>0);var M=p.toBuffer();return M},yx=function(t,r,n,i,o,s){var a=Fp(),f=Dc();Ai.isUndefined(s)&&(s=J6);var l=a.shallowCopy(t);if(i instanceof Ya||(i=new Ya(i)),s&Dp.SCRIPT_ENABLE_REPLAY_PROTECTION){var m=r>>8,y=16711680|m^57005;r=y<<8|r&255}if(r&dr.SIGHASH_FORKID&&!(r&dr.SIGHASH_CHRONICLE)&&s&Dp.SCRIPT_ENABLE_SIGHASH_FORKID)return Q6(l,r,n,i,o);i=new Ya(i),i.removeCodeseparators();var p;for(p=0;p<l.inputs.length;p++)l.inputs[p]=new f(l.inputs[p]).setScript(Ya.empty());if(l.inputs[n]=new f(l.inputs[n]).setScript(i),(r&31)===dr.SIGHASH_NONE||(r&31)===dr.SIGHASH_SINGLE)for(p=0;p<l.inputs.length;p++)p!==n&&(l.inputs[p].sequenceNumber=0);if((r&31)===dr.SIGHASH_NONE)l.outputs=[];else if((r&31)===dr.SIGHASH_SINGLE){if(n>=l.outputs.length)return gx;for(l.outputs.length=n+1,p=0;p<n;p++)l.outputs[p]=new $6({satoshis:dx.fromBuffer(Y6.Buffer.from(X6,"hex")),script:Ya.empty()})}r&dr.SIGHASH_ANYONECANPAY&&(l.inputs=[l.inputs[n]]);var w=new $a().write(l.toBuffer()).writeInt32LE(r).toBuffer();return w},Up=function(t,r,n,i,o,s){var a=yx(t,r,n,i,o,s);if(a.compare(gx)===0)return a;var f=Uc.sha256sha256(a);return f=new Z6(f).readReverse(),f};function eC(e,t,r,n,i,o,s){var a=Up(e,r,n,i,o,s),f=px.sign(a,t,"little").set({nhashtype:r});return f}function tC(e,t,r,n,i,o,s){Lp.checkArgument(!Ai.isUndefined(e)),Lp.checkArgument(!Ai.isUndefined(t)&&!Ai.isUndefined(t.nhashtype));var a=Up(e,t.nhashtype,n,i,o,s);return px.verify(a,t,r,"little")}mx.exports={sighashPreimage:yx,sighash:Up,sign:eC,verify:tC}});var qp=B((dq,bx)=>{"use strict";g();var Vn=at(),qc=We(),vx=vr(),rC=Gr(),nC=uo();function Wn(e){if(!(this instanceof Wn))return new Wn(e);qc.checkArgument(Vn.isObject(e),"Must provide an object from where to extract data");var t=e.address?new nC(e.address):void 0,r=e.txid?e.txid:e.txId;if(!r||!vx.isHexaString(r)||r.length>64)throw new Error("Invalid TXID in object",e);var n=Vn.isUndefined(e.vout)?e.outputIndex:e.vout;if(!Vn.isNumber(n))throw new Error("Invalid outputIndex, received "+n);qc.checkArgument(!Vn.isUndefined(e.scriptPubKey)||!Vn.isUndefined(e.script),"Must provide the scriptPubKey for that output!");var i=new rC(e.scriptPubKey||e.script);qc.checkArgument(!Vn.isUndefined(e.amount)||!Vn.isUndefined(e.satoshis),"Must provide an amount for the output");var o=Vn.isUndefined(e.amount)?e.satoshis:Math.round(e.amount*1e8);qc.checkArgument(Vn.isNumber(o),"Amount must be a number"),vx.defineImmutable(this,{address:t,txId:r,outputIndex:n,script:i,satoshis:o})}Wn.prototype.inspect=function(){return"<UnspentOutput: "+this.txId+":"+this.outputIndex+", satoshis: "+this.satoshis+", address: "+this.address+">"};Wn.prototype.toString=function(){return this.txId+":"+this.outputIndex};Wn.fromObject=function(e){return new Wn(e)};Wn.prototype.toObject=Wn.prototype.toJSON=function(){return{address:this.address?this.address.toString():void 0,txid:this.txId,vout:this.outputIndex,scriptPubKey:this.script.toBuffer().toString("hex"),amount:Number.parseFloat((this.satoshis/1e8).toFixed(8))}};bx.exports=Wn});var Fp=B((gq,Ox)=>{"use strict";g();var me=at(),zt=We(),iC=Lt(),Ht=ii(),Sx=vr(),wx=qa(),oC=fs(),_x=ja(),Ex=nr(),jc=fr(),xx=Ii(),sC=uo(),Ix=qp(),qt=Dc(),aC=qt.PublicKeyHash,uC=qt.PublicKey,fC=qt.MultiSigScriptHash,cC=qt.MultiSig,Yr=jn(),yn=Gr(),lC=fo(),Hc=Ar(),hC=Fc(),dC=hC.SCRIPT_ENABLE_SIGHASH_FORKID;function Z(e){if(!(this instanceof Z))return new Z(e);if(this.inputs=[],this.outputs=[],this._inputAmount=void 0,this._outputAmount=void 0,e){if(e instanceof Z)return Z.shallowCopy(e);if(Sx.isHexa(e))this.fromString(e);else if(d.Buffer.isBuffer(e))this.fromBuffer(e);else if(me.isObject(e))this.fromObject(e);else throw new Ht.InvalidArgument("Must provide an object or string to deserialize a transaction")}else this._newTransaction()}var pC=1,gC=0,yC=1e6;Z.DUST_AMOUNT=546;Z.FEE_SECURITY_MARGIN=150;Z.MAX_MONEY=21e6*1e8;Z.NLOCKTIME_BLOCKHEIGHT_LIMIT=5e8;Z.NLOCKTIME_MAX_VALUE=4294967295;Z.FEE_PER_KB=500;Z.CHANGE_OUTPUT_MAX_SIZE=62;Z.shallowCopy=function(e){var t=new Z(e.toBuffer());return t};var Ax={configurable:!1,enumerable:!0,get:function(){return this._hash=new wx(this._getHash()).readReverse().toString("hex"),this._hash}};Object.defineProperty(Z.prototype,"hash",Ax);Object.defineProperty(Z.prototype,"id",Ax);var Hp={configurable:!1,enumerable:!0,get:function(){return this._getInputAmount()}};Object.defineProperty(Z.prototype,"inputAmount",Hp);Hp.get=function(){return this._getOutputAmount()};Object.defineProperty(Z.prototype,"outputAmount",Hp);Z.prototype._getHash=function(){return Ex.sha256sha256(this.toBuffer())};Z.prototype.serialize=function(e){return e===!0||e&&e.disableAll?this.uncheckedSerialize():this.checkedSerialize(e)};Z.prototype.uncheckedSerialize=Z.prototype.toString=function(){return this.toBuffer().toString("hex")};Z.prototype.checkedSerialize=function(e){var t=this.getSerializationError(e);if(t)throw t.message+=" - For more information please see: https://bsv.io/api/lib/transaction#serialization-checks",t;return this.uncheckedSerialize()};Z.prototype.invalidSatoshis=function(){for(var e=!1,t=0;t<this.outputs.length;t++)this.outputs[t].invalidSatoshis()&&(e=!0);return e};Z.prototype.getSerializationError=function(e){if(e=e||{},this.invalidSatoshis())return new Ht.Transaction.InvalidSatoshis;var t=this._getUnspentValue(),r;return t<0?e.disableMoreOutputThanInput||(r=new Ht.Transaction.InvalidOutputAmountSum):r=this._hasFeeError(e,t),r||this._hasDustOutputs(e)||this._isMissingSignatures(e)};Z.prototype._hasFeeError=function(e,t){if(!me.isUndefined(this._fee)&&this._fee!==t)return new Ht.Transaction.FeeError.Different("Unspent value is "+t+" but specified fee is "+this._fee);if(!e.disableLargeFees){var r=Math.floor(Z.FEE_SECURITY_MARGIN*this._estimateFee());if(t>r)return this._missingChange()?new Ht.Transaction.ChangeAddressMissing("Fee is too large and no change address was provided"):new Ht.Transaction.FeeError.TooLarge("expected less than "+r+" but got "+t)}};Z.prototype._missingChange=function(){return!this._changeScript};Z.prototype._hasDustOutputs=function(e){if(!e.disableDustOutputs){var t,r;for(t in this.outputs)if(r=this.outputs[t],r.satoshis<Z.DUST_AMOUNT&&!r.script.isDataOut()&&!r.script.isSafeDataOut())return new Ht.Transaction.DustOutputs}};Z.prototype._isMissingSignatures=function(e){if(!e.disableIsFullySigned&&!this.isFullySigned())return new Ht.Transaction.MissingSignatures};Z.prototype.inspect=function(){return"<Transaction: "+this.uncheckedSerialize()+">"};Z.prototype.toBuffer=function(){var e=new oC;return this.toBufferWriter(e).toBuffer()};Z.prototype.toBufferWriter=function(e){return e.writeInt32LE(this.version),e.writeVarintNum(this.inputs.length),me.each(this.inputs,function(t){t.toBufferWriter(e)}),e.writeVarintNum(this.outputs.length),me.each(this.outputs,function(t){t.toBufferWriter(e)}),e.writeUInt32LE(this.nLockTime),e};Z.prototype.fromBuffer=function(e){var t=new wx(e);return this.fromBufferReader(t)};Z.prototype.fromBufferReader=function(e){zt.checkArgument(!e.finished(),"No transaction data received");var t,r,n;for(this.version=e.readInt32LE(),r=e.readVarintNum(),t=0;t<r;t++){var i=qt.fromBufferReader(e);this.inputs.push(i)}for(n=e.readVarintNum(),t=0;t<n;t++)this.outputs.push(Yr.fromBufferReader(e));return this.nLockTime=e.readUInt32LE(),this};Z.prototype.toObject=Z.prototype.toJSON=function(){var t=[];this.inputs.forEach(function(i){t.push(i.toObject())});var r=[];this.outputs.forEach(function(i){r.push(i.toObject())});var n={hash:this.hash,version:this.version,inputs:t,outputs:r,nLockTime:this.nLockTime};return this._changeScript&&(n.changeScript=this._changeScript.toString()),me.isUndefined(this._changeIndex)||(n.changeIndex=this._changeIndex),me.isUndefined(this._fee)||(n.fee=this._fee),n};Z.prototype.fromObject=function(t){zt.checkArgument(me.isObject(t)||t instanceof Z);var r=this,n;return t instanceof Z?n=t.toObject():n=t,me.each(n.inputs,function(i){if(!i.output||!i.output.script){r.uncheckedAddInput(new qt(i));return}var o=new yn(i.output.script),s;if(o.isPublicKeyHashOut())s=new qt.PublicKeyHash(i);else if(o.isScriptHashOut()&&i.publicKeys&&i.threshold)s=new qt.MultiSigScriptHash(i,i.publicKeys,i.threshold,i.signatures);else if(o.isPublicKeyOut())s=new qt.PublicKey(i);else throw new Ht.Transaction.Input.UnsupportedScript(i.output.script);r.addInput(s)}),me.each(n.outputs,function(i){r.addOutput(new Yr(i))}),n.changeIndex&&(this._changeIndex=n.changeIndex),n.changeScript&&(this._changeScript=new yn(n.changeScript)),n.fee&&(this._fee=n.fee),this.nLockTime=n.nLockTime,this.version=n.version,this._checkConsistency(t),this};Z.prototype._checkConsistency=function(e){me.isUndefined(this._changeIndex)||(zt.checkState(this._changeScript,"Change script is expected."),zt.checkState(this.outputs[this._changeIndex],"Change index points to undefined output."),zt.checkState(this.outputs[this._changeIndex].script.toString()===this._changeScript.toString(),"Change output has an unexpected script.")),e&&e.hash&&zt.checkState(e.hash===this.hash,"Hash in object does not match transaction hash.")};Z.prototype.lockUntilDate=function(e){if(zt.checkArgument(e),me.isNumber(e)&&e<Z.NLOCKTIME_BLOCKHEIGHT_LIMIT)throw new Ht.Transaction.LockTimeTooEarly;me.isDate(e)&&(e=e.getTime()/1e3);for(var t=0;t<this.inputs.length;t++)this.inputs[t].sequenceNumber===qt.DEFAULT_SEQNUMBER&&(this.inputs[t].sequenceNumber=qt.DEFAULT_LOCKTIME_SEQNUMBER);return this.nLockTime=e,this};Z.prototype.lockUntilBlockHeight=function(e){if(zt.checkArgument(me.isNumber(e)),e>=Z.NLOCKTIME_BLOCKHEIGHT_LIMIT)throw new Ht.Transaction.BlockHeightTooHigh;if(e<0)throw new Ht.Transaction.NLockTimeOutOfRange;for(var t=0;t<this.inputs.length;t++)this.inputs[t].sequenceNumber===qt.DEFAULT_SEQNUMBER&&(this.inputs[t].sequenceNumber=qt.DEFAULT_LOCKTIME_SEQNUMBER);return this.nLockTime=e,this};Z.prototype.getLockTime=function(){return this.nLockTime?this.nLockTime<Z.NLOCKTIME_BLOCKHEIGHT_LIMIT?this.nLockTime:new Date(1e3*this.nLockTime):null};Z.prototype.fromString=function(e){this.fromBuffer(iC.Buffer.from(e,"hex"))};Z.prototype._newTransaction=function(){this.version=pC,this.nLockTime=gC};Z.prototype.from=function(e,t,r){if(me.isArray(e)){var n=this;return me.each(e,function(o){n.from(o,t,r)}),this}var i=me.some(this.inputs,function(o){return o.prevTxId.toString("hex")===e.txId&&o.outputIndex===e.outputIndex});return i?this:(t&&r?this._fromMultisigUtxo(e,t,r):this._fromNonP2SH(e),this)};Z.prototype._fromNonP2SH=function(e){var t;e=new Ix(e),e.script.isPublicKeyHashOutPrefix()?t=aC:e.script.isPublicKeyOut()?t=uC:t=qt,this.addInput(new t({output:new Yr({script:e.script,satoshis:e.satoshis}),prevTxId:e.txId,outputIndex:e.outputIndex,script:yn.empty()}))};Z.prototype._fromMultisigUtxo=function(e,t,r){zt.checkArgument(r<=t.length,"Number of required signatures must be greater than the number of public keys");var n;if(e=new Ix(e),e.script.isMultisigOut())n=cC;else if(e.script.isScriptHashOut())n=fC;else throw new Ht.Transaction.Input.UnsupportedScript(e.script.toString());this.addInput(new n({output:new Yr({script:e.script,satoshis:e.satoshis}),prevTxId:e.txId,outputIndex:e.outputIndex,script:yn.empty()},t,r))};Z.prototype.addInput=function(e,t,r){if(zt.checkArgumentType(e,qt,"input"),!e.output&&(me.isUndefined(t)||me.isUndefined(r)))throw new Ht.Transaction.NeedMoreInfo("Need information about the UTXO script and satoshis");return!e.output&&t&&!me.isUndefined(r)&&(t=t instanceof yn?t:new yn(t),zt.checkArgumentType(r,"number","satoshis"),e.output=new Yr({script:t,satoshis:r})),this.uncheckedAddInput(e)};Z.prototype.uncheckedAddInput=function(e){return zt.checkArgumentType(e,qt,"input"),this.inputs.push(e),this._inputAmount=void 0,this._updateChangeOutput(),this};Z.prototype.hasAllUtxoInfo=function(){return me.every(this.inputs.map(function(e){return!!e.output}))};Z.prototype.fee=function(e){return zt.checkArgument(me.isNumber(e),"amount must be a number"),this._fee=e,this._updateChangeOutput(),this};Z.prototype.feePerKb=function(e){return zt.checkArgument(me.isNumber(e),"amount must be a number"),this._feePerKb=e,this._updateChangeOutput(),this};Z.prototype.change=function(e){return zt.checkArgument(e,"address is required"),this._changeScript=yn.fromAddress(e),this._updateChangeOutput(),this};Z.prototype.getChangeOutput=function(){return me.isUndefined(this._changeIndex)?null:this.outputs[this._changeIndex]};Z.prototype.to=function(e,t){if(me.isArray(e)){var r=this;return me.each(e,function(n){r.to(n.address,n.satoshis)}),this}return zt.checkArgument(Sx.isNaturalNumber(t),"Amount is expected to be a positive integer"),this.addOutput(new Yr({script:yn(new sC(e)),satoshis:t})),this};Z.prototype.addData=function(e){return this.addOutput(new Yr({script:yn.buildDataOut(e),satoshis:0})),this};Z.prototype.addSafeData=function(e){return this.addOutput(new Yr({script:yn.buildSafeDataOut(e),satoshis:0})),this};Z.prototype.addOutput=function(e){return zt.checkArgumentType(e,Yr,"output"),this._addOutput(e),this._updateChangeOutput(),this};Z.prototype.clearOutputs=function(){return this.outputs=[],this._clearSignatures(),this._outputAmount=void 0,this._changeIndex=void 0,this._updateChangeOutput(),this};Z.prototype._addOutput=function(e){this.outputs.push(e),this._outputAmount=void 0};Z.prototype._getOutputAmount=function(){if(me.isUndefined(this._outputAmount)){var e=this;this._outputAmount=0,me.each(this.outputs,function(t){e._outputAmount+=t.satoshis})}return this._outputAmount};Z.prototype._getInputAmount=function(){if(me.isUndefined(this._inputAmount)){var e=this;this._inputAmount=0,me.each(this.inputs,function(t){if(me.isUndefined(t.output))throw new Ht.Transaction.Input.MissingPreviousOutput;e._inputAmount+=t.output.satoshis})}return this._inputAmount};Z.prototype._updateChangeOutput=function(){if(this._changeScript){this._clearSignatures(),me.isUndefined(this._changeIndex)||this._removeOutput(this._changeIndex),this._changeIndex=this.outputs.length,this._addOutput(new Yr({script:this._changeScript,satoshis:0}));var e=this._getUnspentValue(),t=this.getFee(),r=e-t;this._removeOutput(this._changeIndex),this._changeIndex=void 0,r>=Z.DUST_AMOUNT&&(this._changeIndex=this.outputs.length,this._addOutput(new Yr({script:this._changeScript,satoshis:r})))}};Z.prototype.getFee=function(){return this.isCoinbase()?0:me.isUndefined(this._fee)?this._changeScript?this._estimateFee():this._getUnspentValue():this._fee};Z.prototype._estimateFee=function(){var e=this._estimateSize();return Math.ceil(e/1e3*(this._feePerKb||Z.FEE_PER_KB))};Z.prototype._getUnspentValue=function(){return this._getInputAmount()-this._getOutputAmount()};Z.prototype._clearSignatures=function(){me.each(this.inputs,function(e){e.clearSignatures!==qt.prototype.clearSignatures&&e.clearSignatures()})};Z.prototype._estimateSize=function(){var e=8;return e+=_x(this.inputs.length).toBuffer().length,e+=_x(this.outputs.length).toBuffer().length,me.each(this.inputs,function(t){e+=t._estimateSize()}),me.each(this.outputs,function(t){e+=t.getSize()}),e};Z.prototype._removeOutput=function(e){var t=this.outputs[e];this.outputs=me.without(this.outputs,t),this._outputAmount=void 0};Z.prototype.removeOutput=function(e){this._removeOutput(e),this._updateChangeOutput()};Z.prototype.sort=function(){return this.sortInputs(function(e){var t=Array.prototype.concat.apply([],e);return t.sort(function(r,n){return r.prevTxId.compare(n.prevTxId)||r.outputIndex-n.outputIndex}),t}),this.sortOutputs(function(e){var t=Array.prototype.concat.apply([],e);return t.sort(function(r,n){return r.satoshis-n.satoshis||r.script.toBuffer().compare(n.script.toBuffer())}),t}),this};Z.prototype.shuffleOutputs=function(){return this.sortOutputs(me.shuffle)};Z.prototype.sortOutputs=function(e){var t=e(this.outputs);return this._newOutputOrder(t)};Z.prototype.sortInputs=function(e){return this.inputs=e(this.inputs),this._clearSignatures(),this};Z.prototype._newOutputOrder=function(e){var t=this.outputs.length!==e.length||me.difference(this.outputs,e).length!==0;if(t)throw new Ht.Transaction.InvalidSorting;if(!me.isUndefined(this._changeIndex)){var r=this.outputs[this._changeIndex];this._changeIndex=e.indexOf(r)}return this.outputs=e,this};Z.prototype.removeInput=function(e,t){var r;if(!t&&me.isNumber(e)?r=e:r=me.findIndex(this.inputs,function(i){return i.prevTxId.toString("hex")===e&&i.outputIndex===t}),r<0||r>=this.inputs.length)throw new Ht.Transaction.InvalidIndex(r,this.inputs.length);var n=this.inputs[r];this.inputs=me.without(this.inputs,n),this._inputAmount=void 0,this._updateChangeOutput()};Z.prototype.sign=function(e,t){zt.checkState(this.hasAllUtxoInfo(),"Not all utxo information is available to sign the transaction.");var r=this;return me.isArray(e)?(me.each(e,function(n){r.sign(n,t)}),this):(me.each(this.getSignatures(e,t),function(n){r.applySignature(n)}),this)};Z.prototype.getSignatures=function(e,t){e=new lC(e),t=t||jc.SIGHASH_ALL|jc.SIGHASH_FORKID;var r=this,n=[],i=Ex.sha256ripemd160(e.publicKey.toBuffer());return me.each(this.inputs,function(s,a){me.each(s.getSignatures(r,e,a,t,i),function(f){n.push(f)})}),n};Z.prototype.applySignature=function(e){return this.inputs[e.inputIndex].addSignature(this,e),this};Z.prototype.isFullySigned=function(){return me.each(this.inputs,function(e){if(e.isFullySigned===qt.prototype.isFullySigned)throw new Ht.Transaction.UnableToVerifySignature("Unrecognized script kind, or not enough information to execute script.This usually happens when creating a transaction from a serialized transaction")}),me.every(me.map(this.inputs,function(e){return e.isFullySigned()}))};Z.prototype.isValidSignature=function(e){var t=this;if(this.inputs[e.inputIndex].isValidSignature===qt.prototype.isValidSignature)throw new Ht.Transaction.UnableToVerifySignature("Unrecognized script kind, or not enough information to execute script.This usually happens when creating a transaction from a serialized transaction");return this.inputs[e.inputIndex].isValidSignature(t,e)};Z.prototype.verifySignature=function(e,t,r,n,i,o){return xx.verify(this,e,t,r,n,i,o)};Z.prototype.verify=function(){if(this.inputs.length===0)return"transaction txins empty";if(this.outputs.length===0)return"transaction txouts empty";for(var e=new Hc(0),t=0;t<this.outputs.length;t++){var r=this.outputs[t];if(r.invalidSatoshis())return"transaction txout "+t+" satoshis is invalid";if(r._satoshisBN.gt(new Hc(Z.MAX_MONEY,10)))return"transaction txout "+t+" greater than MAX_MONEY";if(e=e.add(r._satoshisBN),e.gt(new Hc(Z.MAX_MONEY)))return"transaction txout "+t+" total output greater than MAX_MONEY"}if(this.toBuffer().length>yC)return"transaction over the maximum block size";var n={};for(t=0;t<this.inputs.length;t++){var i=this.inputs[t],o=i.prevTxId+":"+i.outputIndex;if(!me.isUndefined(n[o]))return"transaction input "+t+" duplicate input";n[o]=!0}var s=this.isCoinbase();if(s){var a=this.inputs[0]._scriptBuffer;if(a.length<2||a.length>100)return"coinbase transaction script size invalid"}else for(t=0;t<this.inputs.length;t++)if(this.inputs[t].isNull())return"transaction input "+t+" has null input";return!0};Z.prototype.isCoinbase=function(){return this.inputs.length===1&&this.inputs[0].isNull()};Z.prototype.sighash=function(e,t,r,n,i){t=t||jc.SIGHASH_ALL|jc.SIGHASH_FORKID;var o=this.inputs[e];if(!o)throw new Error("Input index "+e+" does not exist");return!r&&o.output&&(r=o.output.script),!n&&o.output&&(n=new Hc(o.output.satoshis)),i=i||dC,xx.sighash(this,t,e,r,n,i)};Ox.exports=Z});var jp=B((mq,co)=>{g();co.exports=Fp();co.exports.Input=Dc();co.exports.Output=jn();co.exports.UnspentOutput=qp();co.exports.Signature=ds();co.exports.Sighash=Ii()});var Fc=B((bq,Nx)=>{"use strict";g();var Kc=at(),Gc=Ip(),k=vp(),le=Ar(),Za=nr(),zn=fr(),Kp=Pr();function Rx(e){return e.map(function(t){return d.Buffer.isBuffer(t)?d.Buffer.from(t):t})}var R=function e(t){if(!(this instanceof e))return new e(t);t?(this.initialize(),this.set(t)):this.initialize()};R.prototype._verifyCore=function(e,t,r,n,i,o){var s=jp();if(Kc.isUndefined(r)&&(r=new s),Kc.isUndefined(n)&&(n=0),Kc.isUndefined(i)&&(i=R.currentConsensusFlags(),o||(i&=~R.SCRIPT_ENABLE_SIGHASH_FORKID)),i&R.SCRIPT_ENABLE_SIGHASH_FORKID&&(i|=R.SCRIPT_VERIFY_STRICTENC,!o))throw new Error("internal error - need satoshisBN to verify FORKID transactions");this.set({script:e,tx:r,nin:n,flags:i,satoshisBN:o});var a;if((i&R.SCRIPT_UTXO_AFTER_CHRONICLE)!==0&&(i&R.SCRIPT_UTXO_AFTER_GENESIS)===0)return this.errstr="SCRIPT_ERR_INVALID_FLAGS",!1;if((i&R.SCRIPT_VERIFY_SIGPUSHONLY)!==0){var f=(i&R.SCRIPT_CHRONICLE)!==0,l=(i&R.SCRIPT_GENESIS)!==0&&!f||f&&Bx(i,r);if(l&&!e.isPushOnly())return this.errstr="SCRIPT_ERR_SIG_PUSHONLY",!1}if(!this.evaluate())return!1;var m=(i&R.SCRIPT_VERIFY_P2SH)!==0&&(i&R.SCRIPT_UTXO_AFTER_GENESIS)===0;m&&(a=this.stack.slice());var y=this.stack;if(this.initialize(),this.set({script:t,stack:y,tx:r,nin:n,flags:i,satoshisBN:o}),!this.evaluate())return!1;if(this.stack.length===0)return this.errstr="SCRIPT_ERR_EVAL_FALSE_NO_RESULT",!1;var p=this.stack[this.stack.length-1];if(!R.castToBool(p))return this.errstr="SCRIPT_ERR_EVAL_FALSE_IN_STACK",!1;if(m&&t.isScriptHashOut()){if(!e.isPushOnly())return this.errstr="SCRIPT_ERR_SIG_PUSHONLY",!1;if(a.length===0)throw new Error("internal error - stack copy empty");var w=a[a.length-1],O=Gc.fromBuffer(w);if(a.pop(),this.initialize(),this.set({script:O,stack:a,tx:r,nin:n,flags:i,satoshisBN:o}),!this.evaluate())return!1;if(a.length===0)return this.errstr="SCRIPT_ERR_EVAL_FALSE_NO_P2SH_STACK",!1;if(!R.castToBool(a[a.length-1]))return this.errstr="SCRIPT_ERR_EVAL_FALSE_IN_P2SH_STACK",!1}if((i&R.SCRIPT_VERIFY_CLEANSTACK)!==0){if((i&R.SCRIPT_VERIFY_P2SH)===0)return this.errstr="SCRIPT_ERR_INVALID_FLAGS",!1;if(this.enforceNonMalleability()&&this.stack.length!==1)return this.errstr="SCRIPT_ERR_CLEANSTACK",!1}return!0};Nx.exports=R;R.prototype.initialize=function(e){this.stack=[],this.altstack=[],this.pc=0,this.pbegincodehash=0,this.nOpCount=0,this.returned=!1,this.nonTopLevelReturnAfterGenesis=!1,this.vfExec=[],this.vfElse=[],this.errstr="",this.flags=0};R.prototype.set=function(e){this.script=e.script||this.script,this.tx=e.tx||this.tx,this.nin=typeof e.nin<"u"?e.nin:this.nin,this.satoshisBN=e.satoshisBN||this.satoshisBN,this.stack=e.stack||this.stack,this.altstack=e.altstack||this.altstack,this.pc=typeof e.pc<"u"?e.pc:this.pc,this.pbegincodehash=typeof e.pbegincodehash<"u"?e.pbegincodehash:this.pbegincodehash,this.nOpCount=typeof e.nOpCount<"u"?e.nOpCount:this.nOpCount,this.returned=typeof e.returned<"u"?e.returned:this.returned,this.nonTopLevelReturnAfterGenesis=typeof e.nonTopLevelReturnAfterGenesis<"u"?e.nonTopLevelReturnAfterGenesis:this.nonTopLevelReturnAfterGenesis,this.vfExec=e.vfExec||this.vfExec,this.vfElse=e.vfElse||this.vfElse,this.errstr=e.errstr||this.errstr,this.flags=typeof e.flags<"u"?e.flags:this.flags};R.true=d.Buffer.from([1]);R.false=d.Buffer.from([]);R.MAX_SCRIPT_ELEMENT_SIZE=520;R.MAXIMUM_ELEMENT_SIZE=4;R.MAX_OPS_PER_SCRIPT=500;R.MAX_SCRIPT_SIZE=1e4;R.UNLIMITED=Number.MAX_SAFE_INTEGER;R.MAX_SCRIPT_NUM_LENGTH_AFTER_GENESIS=75e4;R.MAX_SCRIPT_NUM_LENGTH_AFTER_CHRONICLE=32e6;R.MAX_PUBKEYS_PER_MULTISIG_AFTER_GENESIS=4294967295;R.MAX_STACK_SIZE=1e3;R.MAX_STACK_MEMORY_USAGE_AFTER_GENESIS=R.UNLIMITED;R.STACK_MEMORY_USAGE_POLICY=100*1024*1024;R.STACK_ELEMENT_OVERHEAD=32;R.LOCKTIME_THRESHOLD=5e8;R.LOCKTIME_THRESHOLD_BN=new le(R.LOCKTIME_THRESHOLD);R.useGenesisLimits=function(e){return e=e||2147483647,R.MAX_SCRIPT_ELEMENT_SIZE=e,R.MAX_OPS_PER_SCRIPT=e,R.MAX_SCRIPT_SIZE=e,R};R.getLimits=function(){return{maxScriptElementSize:R.MAX_SCRIPT_ELEMENT_SIZE,maximumElementSize:R.MAXIMUM_ELEMENT_SIZE,maxOpsPerScript:R.MAX_OPS_PER_SCRIPT,maxScriptSize:R.MAX_SCRIPT_SIZE}};R.setLimits=function(e){return e=e||{},e.maxScriptElementSize!=null&&(R.MAX_SCRIPT_ELEMENT_SIZE=e.maxScriptElementSize),e.maximumElementSize!=null&&(R.MAXIMUM_ELEMENT_SIZE=e.maximumElementSize),e.maxOpsPerScript!=null&&(R.MAX_OPS_PER_SCRIPT=e.maxOpsPerScript),e.maxScriptSize!=null&&(R.MAX_SCRIPT_SIZE=e.maxScriptSize),R};R.SCRIPT_VERIFY_NONE=0;R.SCRIPT_VERIFY_P2SH=1;R.SCRIPT_VERIFY_STRICTENC=2;R.SCRIPT_VERIFY_DERSIG=4;R.SCRIPT_VERIFY_LOW_S=8;R.SCRIPT_VERIFY_NULLDUMMY=16;R.SCRIPT_VERIFY_SIGPUSHONLY=32;R.SCRIPT_VERIFY_MINIMALDATA=64;R.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS=128;R.SCRIPT_VERIFY_CLEANSTACK=256;R.SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY=512;R.SCRIPT_VERIFY_CHECKSEQUENCEVERIFY=1024;R.SCRIPT_VERIFY_MINIMALIF=8192;R.SCRIPT_VERIFY_NULLFAIL=16384;R.SCRIPT_VERIFY_COMPRESSED_PUBKEYTYPE=32768;R.SCRIPT_ENABLE_SIGHASH_FORKID=65536;R.SCRIPT_ENABLE_REPLAY_PROTECTION=1<<17;R.SCRIPT_ENABLE_MONOLITH_OPCODES=2048;R.SCRIPT_ENABLE_MAGNETIC_OPCODES=4096;R.SCRIPT_GENESIS=1<<18;R.SCRIPT_UTXO_AFTER_GENESIS=1<<19;R.SCRIPT_ENABLE_CHRONICLE=1<<20;R.SCRIPT_CHRONICLE=R.SCRIPT_ENABLE_CHRONICLE;R.SCRIPT_UTXO_AFTER_CHRONICLE=1<<21;R.CHRONICLE_ACTIVATION_HEIGHT=943816;R.ERA_SENSITIVE_ERRORS={SCRIPT_ERR_PUSH_SIZE:{cap:"stack element size (capped at 520 bytes pre-Genesis, unbounded after)",lifts:R.SCRIPT_UTXO_AFTER_GENESIS},SCRIPT_ERR_SCRIPT_SIZE:{cap:"total script size (capped at 10,000 bytes pre-Genesis, unbounded after)",lifts:R.SCRIPT_UTXO_AFTER_GENESIS},SCRIPT_ERR_OP_COUNT:{cap:"opcode count (capped at 201 pre-Genesis, unbounded after)",lifts:R.SCRIPT_UTXO_AFTER_GENESIS},SCRIPT_ERR_SCRIPTNUM_OVERFLOW:{cap:"script number width (4 bytes pre-Genesis, 750,000 after Genesis, 32,000,000 after Chronicle)",lifts:R.SCRIPT_UTXO_AFTER_GENESIS|R.SCRIPT_UTXO_AFTER_CHRONICLE}};R.ERA_FLAGS=R.SCRIPT_GENESIS|R.SCRIPT_UTXO_AFTER_GENESIS|R.SCRIPT_ENABLE_CHRONICLE|R.SCRIPT_UTXO_AFTER_CHRONICLE;R.eraDiagnostics=!(typeof x.default<"u"&&x.default.env&&x.default.env.BSV_NO_ERA_HINT==="1");var Gp=!1;R.prototype._eraDiagnose=function(e){if(e!==void 0){var t=R.ERA_SENSITIVE_ERRORS[this.errstr];if(t&&(e&t.lifts)===0){var r=t.cap;this.eraHint=this.errstr+" was produced under PRE-GENESIS limits: "+r+`.
70
70
  The flags passed to verify() (0x`+(e>>>0).toString(16)+`) carry no era bit, so those caps applied regardless of which feature opcodes were enabled.
71
- To validate against BSV as it is today, omit the flags argument or pass Interpreter.mainnetFlags(). If you are deliberately testing pre-Genesis consensus this failure is correct \u2014 set Interpreter.eraDiagnostics = false (or BSV_NO_ERA_HINT=1) to silence this.`,P.eraDiagnostics&&!Cp&&(Cp=!0,console.warn(`
71
+ To validate against BSV as it is today, omit the flags argument or pass Interpreter.mainnetFlags(). If you are deliberately testing pre-Genesis consensus this failure is correct \u2014 set Interpreter.eraDiagnostics = false (or BSV_NO_ERA_HINT=1) to silence this.`,R.eraDiagnostics&&!Gp&&(Gp=!0,console.warn(`
72
72
  [@smartledger/bsv] `+this.eraHint+`
73
73
  (shown once per process)
74
- `))}}};P.prototype.verify=function(e,t,r,n,i,o){this.eraHint=null;var s=this._verifyCore(e,t,r,n,i,o);return s||this._eraDiagnose(i),s};P._resetEraWarning=function(){Cp=!1};P.mainnetFlags=function(e){e=e||{};var t=P.SCRIPT_VERIFY_P2SH|P.SCRIPT_VERIFY_STRICTENC|P.SCRIPT_VERIFY_DERSIG|P.SCRIPT_VERIFY_SIGPUSHONLY|P.SCRIPT_VERIFY_LOW_S|P.SCRIPT_VERIFY_NULLFAIL|P.SCRIPT_VERIFY_MINIMALDATA|P.SCRIPT_ENABLE_SIGHASH_FORKID|P.SCRIPT_ENABLE_MAGNETIC_OPCODES|P.SCRIPT_ENABLE_MONOLITH_OPCODES|P.SCRIPT_GENESIS|P.SCRIPT_UTXO_AFTER_GENESIS;return e.afterChronicle!==!1&&(t|=P.SCRIPT_ENABLE_CHRONICLE|P.SCRIPT_UTXO_AFTER_CHRONICLE),t};P.currentConsensusFlags=function(){return P.SCRIPT_ENABLE_MONOLITH_OPCODES|P.SCRIPT_ENABLE_MAGNETIC_OPCODES|P.SCRIPT_GENESIS|P.SCRIPT_UTXO_AFTER_GENESIS|P.SCRIPT_ENABLE_CHRONICLE|P.SCRIPT_UTXO_AFTER_CHRONICLE|P.SCRIPT_ENABLE_SIGHASH_FORKID|P.SCRIPT_VERIFY_SIGPUSHONLY|P.SCRIPT_VERIFY_LOW_S|P.SCRIPT_VERIFY_NULLFAIL};P.useMainnetConsensus=function(e){return e=e||{},P.useGenesisLimits(e.max),P.mainnetFlags(e)};P.SEQUENCE_LOCKTIME_DISABLE_FLAG=1<<31;P.SEQUENCE_LOCKTIME_TYPE_FLAG=1<<22;P.SEQUENCE_LOCKTIME_MASK=65535;P.castToBool=function(e){for(var t=0;t<e.length;t++)if(e[t]!==0)return!(t===e.length-1&&e[t]===128);return!1};function Ox(e,t){return(e&P.SCRIPT_CHRONICLE)===0?!0:!(t&&(t.version|0)>1)}P.prototype.enforceNonMalleability=function(){return Ox(this.flags,this.tx)};P.prototype.checkSignatureEncoding=function(e){var t;if(e.length===0)return!0;if((this.flags&(P.SCRIPT_VERIFY_DERSIG|P.SCRIPT_VERIFY_LOW_S|P.SCRIPT_VERIFY_STRICTENC))!==0&&!Hn.isTxDER(e))return this.errstr="SCRIPT_ERR_SIG_DER_INVALID_FORMAT",!1;if((this.flags&P.SCRIPT_VERIFY_LOW_S)!==0&&(t=Hn.fromTxFormat(e),!t.hasLowS()&&this.enforceNonMalleability()))return this.errstr="SCRIPT_ERR_SIG_DER_HIGH_S",!1;if((this.flags&P.SCRIPT_VERIFY_STRICTENC)!==0){if(t=Hn.fromTxFormat(e),!t.hasDefinedHashtype())return this.errstr="SCRIPT_ERR_SIG_HASHTYPE",!1;if(!(this.flags&P.SCRIPT_ENABLE_SIGHASH_FORKID)&&t.nhashtype&Hn.SIGHASH_FORKID)return this.errstr="SCRIPT_ERR_ILLEGAL_FORKID",!1;if(!(this.flags&P.SCRIPT_CHRONICLE)&&t.nhashtype&Hn.SIGHASH_CHRONICLE)return this.errstr="SCRIPT_ERR_ILLEGAL_CHRONICLE",!1;if(this.flags&P.SCRIPT_ENABLE_SIGHASH_FORKID&&!(t.nhashtype&Hn.SIGHASH_FORKID))return this.errstr="SCRIPT_ERR_MUST_USE_FORKID",!1}return!0};function Ix(e,t,r){var n=t.length?t[t.length-1]:0;return(!(r&P.SCRIPT_ENABLE_SIGHASH_FORKID)||!(n&Hn.SIGHASH_FORKID))&&e.findAndDelete(new Fc().add(t)),e}P.prototype.checkPubkeyEncoding=function(e){return(this.flags&P.SCRIPT_VERIFY_STRICTENC)!==0&&!kp.isValid(e)?(this.errstr="SCRIPT_ERR_PUBKEYTYPE",!1):!0};P.prototype.isAfterGenesis=function(){return(this.flags&P.SCRIPT_UTXO_AFTER_GENESIS)!==0};P.prototype.isAfterChronicle=function(){return(this.flags&(P.SCRIPT_UTXO_AFTER_CHRONICLE|P.SCRIPT_ENABLE_CHRONICLE))!==0};P.prototype.maxScriptElementSize=function(){return this.isAfterGenesis()?P.UNLIMITED:P.MAX_SCRIPT_ELEMENT_SIZE};P.prototype.maxScriptSize=function(){return this.isAfterGenesis()?P.UNLIMITED:P.MAX_SCRIPT_SIZE};P.prototype.maxOpsPerScript=function(){return this.isAfterGenesis()?P.UNLIMITED:P.MAX_OPS_PER_SCRIPT};P.prototype.maxScriptNumLength=function(){return this.isAfterChronicle()?P.MAX_SCRIPT_NUM_LENGTH_AFTER_CHRONICLE:this.isAfterGenesis()?P.MAX_SCRIPT_NUM_LENGTH_AFTER_GENESIS:P.MAXIMUM_ELEMENT_SIZE};P.prototype.maxStackSize=function(){return this.isAfterGenesis()?P.UNLIMITED:P.MAX_STACK_SIZE};P.prototype.maxStackMemoryUsage=function(){return this.isAfterGenesis()?P.MAX_STACK_MEMORY_USAGE_AFTER_GENESIS:P.UNLIMITED};P.prototype.stackMemoryUsage=function(){let e=P.STACK_ELEMENT_OVERHEAD,t=(this.stack.length+this.altstack.length)*e;for(let r=0;r<this.stack.length;r++)t+=this.stack[r].length;for(let r=0;r<this.altstack.length;r++)t+=this.altstack[r].length;return t};P.prototype.checkStackLimits=function(){if(this.stack.length+this.altstack.length>this.maxStackSize())return"SCRIPT_ERR_STACK_SIZE";let e=this.maxStackMemoryUsage();return e!==P.UNLIMITED&&this.stackMemoryUsage()>e?"SCRIPT_ERR_STACK_SIZE":null};P.prototype.maxPubKeysPerMultisig=function(){return this.isAfterGenesis()?P.MAX_PUBKEYS_PER_MULTISIG_AFTER_GENESIS:20};P._isMinimallyEncoded=function(e,t){return t=t||P.MAXIMUM_ELEMENT_SIZE,!(e.length>t||e.length>0&&(e[e.length-1]&127)===0&&(e.length<=1||(e[e.length-2]&128)===0))};P._minimallyEncode=function(e){if(e.length===0)return e;var t=e[e.length-1];if(t&127)return e;if(e.length===1)return d.Buffer.from("");if(e[e.length-2]&128)return e;e=d.Buffer.from(e);for(var r=e.length-1;r>0;r--)if(e[r-1]!==0)return e[r-1]&128?e[r++]=t:e[r-1]|=t,e.slice(0,r);return d.Buffer.from("")};P.prototype.evaluate=function(){if(this.script.toBuffer().length>this.maxScriptSize())return this.errstr="SCRIPT_ERR_SCRIPT_SIZE",!1;try{for(;this.pc<this.script.chunks.length;){let r={pc:this.pc,opcode:N.fromNumber(this.script.chunks[this.pc].opcodenum)};var e=this.step();if(!e)return!1;if(this._callbackStep(r),this.returned)return!0;let n=this.checkStackLimits();if(n)return this.errstr=n,!1}let t=this.checkStackLimits();if(t)return this.errstr=t,!1}catch(t){return this.errstr=t.scriptErr||"SCRIPT_ERR_UNKNOWN_ERROR: "+t,!1}return this.vfExec.length>0?(this.errstr="SCRIPT_ERR_UNBALANCED_CONDITIONAL",!1):!0};P.prototype._callbackStep=function(e){if(typeof this.stepListener=="function")try{this.stepListener(e,xx(this.stack),xx(this.altstack))}catch(t){console.log(`Error in Step callback:${t}`)}};P.prototype.checkLockTime=function(e){if(!(this.tx.nLockTime<P.LOCKTIME_THRESHOLD&&e.lt(P.LOCKTIME_THRESHOLD_BN)||this.tx.nLockTime>=P.LOCKTIME_THRESHOLD&&e.gte(P.LOCKTIME_THRESHOLD_BN))||e.gt(new ce(this.tx.nLockTime)))return!1;var t=this.tx.inputs[this.nin];return!(!t||t.isFinal())};P.prototype.checkSequence=function(e){var t=this.tx.inputs[this.nin];if(!t)return!1;var r=t.sequenceNumber;if(this.tx.version<2||r&P.SEQUENCE_LOCKTIME_DISABLE_FLAG)return!1;var n=P.SEQUENCE_LOCKTIME_TYPE_FLAG|P.SEQUENCE_LOCKTIME_MASK,i=new ce(r&n),o=e.and(new ce(n)),s=new ce(P.SEQUENCE_LOCKTIME_TYPE_FLAG);return!(!(i.lt(s)&&o.lt(s)||i.gte(s)&&o.gte(s))||o.gt(i))};function Ax(e){var t=d.Buffer.alloc(4);return t.writeInt32LE(e|0,0),t}P.prototype.step=function(){var e=this;function t(Ce){return e.stack[e.stack.length+Ce]}function r(Ce){switch(Ce){case N.OP_2MUL:case N.OP_2DIV:if(!e.isAfterChronicle())return!0;break;case N.OP_INVERT:case N.OP_MUL:case N.OP_LSHIFT:case N.OP_RSHIFT:case N.OP_DIV:case N.OP_MOD:case N.OP_SPLIT:case N.OP_CAT:case N.OP_AND:case N.OP_OR:case N.OP_XOR:case N.OP_BIN2NUM:case N.OP_NUM2BIN:return!1;default:break}return!1}var n=(this.flags&P.SCRIPT_VERIFY_MINIMALDATA)!==0&&this.enforceNonMalleability(),i,o,s,a,f,l,y,g,v,E,T,M,L,F,V,z,G,ie=this.script.chunks[this.pc];this.pc++;var te=ie.opcodenum,pe=this.vfExec.indexOf(!1)===-1&&(!this.nonTopLevelReturnAfterGenesis||te===N.OP_RETURN);if(Uc.isUndefined(te))return this.errstr="SCRIPT_ERR_UNDEFINED_OPCODE",!1;if(ie.buf&&ie.buf.length>this.maxScriptElementSize())return this.errstr="SCRIPT_ERR_PUSH_SIZE",!1;if(te>N.OP_16&&++this.nOpCount>this.maxOpsPerScript())return this.errstr="SCRIPT_ERR_OP_COUNT",!1;if(r(te)&&(!this.isAfterGenesis()||pe))return this.errstr="SCRIPT_ERR_DISABLED_OPCODE",!1;if(pe&&te>=0&&te<=N.OP_PUSHDATA4){if(n&&!this.script.checkMinimalPush(this.pc-1))return this.errstr="SCRIPT_ERR_MINIMALDATA",!1;if(!ie.buf)this.stack.push(P.false);else{if(ie.len!==ie.buf.length)return this.errstr="SCRIPT_ERR_BAD_OPCODE",!1;this.stack.push(ie.buf)}}else if(pe||N.OP_IF<=te&&te<=N.OP_ENDIF)switch(te){case N.OP_1NEGATE:case N.OP_1:case N.OP_2:case N.OP_3:case N.OP_4:case N.OP_5:case N.OP_6:case N.OP_7:case N.OP_8:case N.OP_9:case N.OP_10:case N.OP_11:case N.OP_12:case N.OP_13:case N.OP_14:case N.OP_15:case N.OP_16:f=te-(N.OP_1-1),i=new ce(f).toScriptNumBuffer(),this.stack.push(i);break;case N.OP_NOP:break;case N.OP_NOP2:case N.OP_CHECKLOCKTIMEVERIFY:if(!(this.flags&P.SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY)||this.isAfterGenesis()){if(this.flags&P.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS)return this.errstr="SCRIPT_ERR_DISCOURAGE_UPGRADABLE_NOPS",!1;break}if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;var fe=ce.fromScriptNumBuffer(this.stack[this.stack.length-1],n,5);if(fe.lt(new ce(0)))return this.errstr="SCRIPT_ERR_NEGATIVE_LOCKTIME",!1;if(!this.checkLockTime(fe))return this.errstr="SCRIPT_ERR_UNSATISFIED_LOCKTIME",!1;break;case N.OP_NOP3:case N.OP_CHECKSEQUENCEVERIFY:if(!(this.flags&P.SCRIPT_VERIFY_CHECKSEQUENCEVERIFY)||this.isAfterGenesis()){if(this.flags&P.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS)return this.errstr="SCRIPT_ERR_DISCOURAGE_UPGRADABLE_NOPS",!1;break}if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;var ye=ce.fromScriptNumBuffer(t(-1),n,5);if(ye.lt(new ce(0)))return this.errstr="SCRIPT_ERR_NEGATIVE_LOCKTIME",!1;if((ye&P.SEQUENCE_LOCKTIME_DISABLE_FLAG)!==0)break;if(!this.checkSequence(ye))return this.errstr="SCRIPT_ERR_UNSATISFIED_LOCKTIME",!1;break;case N.OP_NOP1:case N.OP_NOP9:case N.OP_NOP10:if(this.flags&P.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS)return this.errstr="SCRIPT_ERR_DISCOURAGE_UPGRADABLE_NOPS",!1;break;case N.OP_LSHIFTNUM:case N.OP_RSHIFTNUM:if(!this.isAfterChronicle()){if(this.flags&P.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS)return this.errstr="SCRIPT_ERR_DISCOURAGE_UPGRADABLE_NOPS",!1;break}if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;var I=this.maxScriptNumLength(),u=ce.fromScriptNumBuffer(t(-1),n,I);if(u.isNeg())return this.errstr="SCRIPT_ERR_INVALID_NUMBER_RANGE",!1;this.stack.pop();var h=ce.fromScriptNumBuffer(t(-1),n,I);this.stack.pop();var m=u.toNumber(),S=h.isNeg(),w=h.abs(),R;if(te===N.OP_LSHIFTNUM){var A=h.toScriptNumBuffer().length;if(A+Math.floor(m/8)>I)return this.errstr="SCRIPT_ERR_SCRIPTNUM_OVERFLOW",!1;R=w.shln(m)}else R=m>=w.bitLength()?new ce(0):w.shrn(m);if(S&&!R.isZero()&&(R=R.neg()),R.toScriptNumBuffer().length>I)return this.errstr="SCRIPT_ERR_SCRIPTNUM_OVERFLOW",!1;this.stack.push(R.toScriptNumBuffer());break;case N.OP_VER:if(!this.isAfterChronicle())return this.errstr="SCRIPT_ERR_BAD_OPCODE",!1;if(this.tx==null)return this.errstr="SCRIPT_ERR_UNKNOWN_ERROR",!1;this.stack.push(Ax(this.tx.version));break;case N.OP_VERIF:case N.OP_VERNOTIF:if(!this.isAfterChronicle()){if(this.isAfterGenesis()&&!pe)break;return this.errstr="SCRIPT_ERR_BAD_OPCODE",!1}if(z=!1,pe){if(this.stack.length<1)return this.errstr="SCRIPT_ERR_UNBALANCED_CONDITIONAL",!1;if(this.tx==null)return this.errstr="SCRIPT_ERR_UNKNOWN_ERROR",!1;i=t(-1),z=i.length===4&&i.equals(Ax(this.tx.version)),te===N.OP_VERNOTIF&&(z=!z),this.stack.pop()}this.vfExec.push(z),this.vfElse.push(!1);break;case N.OP_IF:case N.OP_NOTIF:if(z=!1,pe){if(this.stack.length<1)return this.errstr="SCRIPT_ERR_UNBALANCED_CONDITIONAL",!1;if(i=t(-1),this.flags&P.SCRIPT_VERIFY_MINIMALIF&&(i.length>1||i.length===1&&i[0]!==1)&&this.enforceNonMalleability())return this.errstr="SCRIPT_ERR_MINIMALIF",!1;z=P.castToBool(i),te===N.OP_NOTIF&&(z=!z),this.stack.pop()}this.vfExec.push(z),this.vfElse.push(!1);break;case N.OP_ELSE:if(this.vfExec.length===0||this.vfElse[this.vfElse.length-1]&&this.isAfterGenesis())return this.errstr="SCRIPT_ERR_UNBALANCED_CONDITIONAL",!1;this.vfExec[this.vfExec.length-1]=!this.vfExec[this.vfExec.length-1],this.vfElse[this.vfElse.length-1]=!0;break;case N.OP_ENDIF:if(this.vfExec.length===0)return this.errstr="SCRIPT_ERR_UNBALANCED_CONDITIONAL",!1;this.vfExec.pop(),this.vfElse.pop();break;case N.OP_VERIFY:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(i=t(-1),z=P.castToBool(i),z)this.stack.pop();else return this.errstr="SCRIPT_ERR_VERIFY",!1;break;case N.OP_RETURN:if(this.isAfterGenesis()){if(this.vfExec.length===0){this.returned=!0;break}this.nonTopLevelReturnAfterGenesis=!0;break}return this.errstr="SCRIPT_ERR_OP_RETURN",!1;case N.OP_TOALTSTACK:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.altstack.push(this.stack.pop());break;case N.OP_FROMALTSTACK:if(this.altstack.length<1)return this.errstr="SCRIPT_ERR_INVALID_ALTSTACK_OPERATION",!1;this.stack.push(this.altstack.pop());break;case N.OP_2DROP:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.pop(),this.stack.pop();break;case N.OP_2DUP:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;o=t(-2),s=t(-1),this.stack.push(d.Buffer.from(o)),this.stack.push(d.Buffer.from(s));break;case N.OP_3DUP:if(this.stack.length<3)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;o=t(-3),s=t(-2);var _=t(-1);this.stack.push(d.Buffer.from(o)),this.stack.push(d.Buffer.from(s)),this.stack.push(d.Buffer.from(_));break;case N.OP_2OVER:if(this.stack.length<4)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;o=t(-4),s=t(-3),this.stack.push(d.Buffer.from(o)),this.stack.push(d.Buffer.from(s));break;case N.OP_2ROT:if(this.stack.length<6)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;a=this.stack.splice(this.stack.length-6,2),this.stack.push(a[0]),this.stack.push(a[1]);break;case N.OP_2SWAP:if(this.stack.length<4)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;a=this.stack.splice(this.stack.length-4,2),this.stack.push(a[0]),this.stack.push(a[1]);break;case N.OP_IFDUP:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;i=t(-1),z=P.castToBool(i),z&&this.stack.push(d.Buffer.from(i));break;case N.OP_DEPTH:i=new ce(this.stack.length).toScriptNumBuffer(),this.stack.push(i);break;case N.OP_DROP:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.pop();break;case N.OP_DUP:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.push(d.Buffer.from(t(-1)));break;case N.OP_NIP:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.splice(this.stack.length-2,1);break;case N.OP_OVER:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.push(d.Buffer.from(t(-2)));break;case N.OP_PICK:case N.OP_ROLL:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(i=t(-1),g=ce.fromScriptNumBuffer(i,n,this.maxScriptNumLength()),f=g.toNumber(),this.stack.pop(),f<0||f>=this.stack.length)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;i=t(-f-1),te===N.OP_ROLL&&this.stack.splice(this.stack.length-f-1,1),this.stack.push(d.Buffer.from(i));break;case N.OP_ROT:if(this.stack.length<3)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;l=t(-3),y=t(-2);var c=t(-1);this.stack[this.stack.length-3]=y,this.stack[this.stack.length-2]=c,this.stack[this.stack.length-1]=l;break;case N.OP_SWAP:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;l=t(-2),y=t(-1),this.stack[this.stack.length-2]=y,this.stack[this.stack.length-1]=l;break;case N.OP_TUCK:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.splice(this.stack.length-2,0,d.Buffer.from(t(-1)));break;case N.OP_SIZE:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;g=new ce(t(-1).length),this.stack.push(g.toScriptNumBuffer());break;case N.OP_AND:case N.OP_OR:case N.OP_XOR:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(o=t(-2),s=t(-1),o.length!==s.length)return this.errstr="SCRIPT_ERR_INVALID_OPERAND_SIZE",!1;switch(a=d.Buffer.alloc(o.length),te){case N.OP_AND:for(let Ce=0;Ce<o.length;Ce++)a[Ce]=o[Ce]&s[Ce];break;case N.OP_OR:for(let Ce=0;Ce<o.length;Ce++)a[Ce]=o[Ce]|s[Ce];break;case N.OP_XOR:for(let Ce=0;Ce<o.length;Ce++)a[Ce]=o[Ce]^s[Ce];break;default:break}this.stack.pop(),this.stack[this.stack.length-1]=a;break;case N.OP_INVERT:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;i=t(-1),o=d.Buffer.alloc(i.length);for(let Ce=0;Ce<i.length;Ce++)o[Ce]=~i[Ce]&255;this.stack[this.stack.length-1]=o;break;case N.OP_LSHIFT:case N.OP_RSHIFT:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(o=t(-2),E=ce.fromScriptNumBuffer(t(-1),n,this.maxScriptNumLength()),E.cmpn(0)<0)return this.errstr="SCRIPT_ERR_INVALID_NUMBER_RANGE",!1;this.stack.pop(),this.stack.pop();var b=d.Buffer.alloc(o.length);if(E.lt(new ce(o.length).muln(8)))for(var k=E.toNumber(),U=Math.floor(k/8),K=k%8,W=te===N.OP_LSHIFT,ee=0;ee<o.length;ee++){var X=W?ee+U:ee-U,le=X>=0&&X<o.length?o[X]:0,ae=W?X+1:X-1,O=K&&ae>=0&&ae<o.length?o[ae]:0;b[ee]=W?(le<<K|O>>8-K)&255:(le>>K|O<<8-K)&255}this.stack.push(b);break;case N.OP_EQUAL:case N.OP_EQUALVERIFY:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;o=t(-2),s=t(-1);var C=o.toString("hex")===s.toString("hex");if(this.stack.pop(),this.stack.pop(),this.stack.push(C?P.true:P.false),te===N.OP_EQUALVERIFY)if(C)this.stack.pop();else return this.errstr="SCRIPT_ERR_EQUALVERIFY",!1;break;case N.OP_2MUL:case N.OP_2DIV:case N.OP_1ADD:case N.OP_1SUB:case N.OP_NEGATE:case N.OP_ABS:case N.OP_NOT:case N.OP_0NOTEQUAL:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;switch(i=t(-1),g=ce.fromScriptNumBuffer(i,n,this.maxScriptNumLength()),te){case N.OP_2MUL:g=g.mul(new ce(2));break;case N.OP_2DIV:g=g.div(new ce(2));break;case N.OP_1ADD:g=g.add(ce.One);break;case N.OP_1SUB:g=g.sub(ce.One);break;case N.OP_NEGATE:g=g.neg();break;case N.OP_ABS:g.cmp(ce.Zero)<0&&(g=g.neg());break;case N.OP_NOT:g=new ce((g.cmp(ce.Zero)===0)+0);break;case N.OP_0NOTEQUAL:g=new ce((g.cmp(ce.Zero)!==0)+0);break}this.stack.pop(),this.stack.push(g.toScriptNumBuffer());break;case N.OP_ADD:case N.OP_SUB:case N.OP_MUL:case N.OP_MOD:case N.OP_DIV:case N.OP_BOOLAND:case N.OP_BOOLOR:case N.OP_NUMEQUAL:case N.OP_NUMEQUALVERIFY:case N.OP_NUMNOTEQUAL:case N.OP_LESSTHAN:case N.OP_GREATERTHAN:case N.OP_LESSTHANOREQUAL:case N.OP_GREATERTHANOREQUAL:case N.OP_MIN:case N.OP_MAX:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;switch(v=ce.fromScriptNumBuffer(t(-2),n,this.maxScriptNumLength()),E=ce.fromScriptNumBuffer(t(-1),n,this.maxScriptNumLength()),g=new ce(0),te){case N.OP_ADD:g=v.add(E);break;case N.OP_SUB:g=v.sub(E);break;case N.OP_MUL:g=v.mul(E);break;case N.OP_DIV:if(E.cmp(ce.Zero)===0)return this.errstr="SCRIPT_ERR_DIV_BY_ZERO",!1;g=v.div(E);break;case N.OP_MOD:if(E.cmp(ce.Zero)===0)return this.errstr="SCRIPT_ERR_MOD_BY_ZERO",!1;g=v.mod(E);break;case N.OP_BOOLAND:g=new ce((v.cmp(ce.Zero)!==0&&E.cmp(ce.Zero)!==0)+0);break;case N.OP_BOOLOR:g=new ce((v.cmp(ce.Zero)!==0||E.cmp(ce.Zero)!==0)+0);break;case N.OP_NUMEQUAL:g=new ce((v.cmp(E)===0)+0);break;case N.OP_NUMEQUALVERIFY:g=new ce((v.cmp(E)===0)+0);break;case N.OP_NUMNOTEQUAL:g=new ce((v.cmp(E)!==0)+0);break;case N.OP_LESSTHAN:g=new ce((v.cmp(E)<0)+0);break;case N.OP_GREATERTHAN:g=new ce((v.cmp(E)>0)+0);break;case N.OP_LESSTHANOREQUAL:g=new ce((v.cmp(E)<=0)+0);break;case N.OP_GREATERTHANOREQUAL:g=new ce((v.cmp(E)>=0)+0);break;case N.OP_MIN:g=v.cmp(E)<0?v:E;break;case N.OP_MAX:g=v.cmp(E)>0?v:E;break}if(this.stack.pop(),this.stack.pop(),this.stack.push(g.toScriptNumBuffer()),te===N.OP_NUMEQUALVERIFY)if(P.castToBool(t(-1)))this.stack.pop();else return this.errstr="SCRIPT_ERR_NUMEQUALVERIFY",!1;break;case N.OP_WITHIN:if(this.stack.length<3)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;v=ce.fromScriptNumBuffer(t(-3),n,this.maxScriptNumLength()),E=ce.fromScriptNumBuffer(t(-2),n,this.maxScriptNumLength());var D=ce.fromScriptNumBuffer(t(-1),n,this.maxScriptNumLength());z=E.cmp(v)<=0&&v.cmp(D)<0,this.stack.pop(),this.stack.pop(),this.stack.pop(),this.stack.push(z?P.true:P.false);break;case N.OP_RIPEMD160:case N.OP_SHA1:case N.OP_SHA256:case N.OP_HASH160:case N.OP_HASH256:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;i=t(-1);var H;te===N.OP_RIPEMD160?H=Va.ripemd160(i):te===N.OP_SHA1?H=Va.sha1(i):te===N.OP_SHA256?H=Va.sha256(i):te===N.OP_HASH160?H=Va.sha256ripemd160(i):te===N.OP_HASH256&&(H=Va.sha256sha256(i)),this.stack.pop(),this.stack.push(H);break;case N.OP_CODESEPARATOR:this.pbegincodehash=this.pc;break;case N.OP_CHECKSIG:case N.OP_CHECKSIGVERIFY:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(T=t(-2),M=t(-1),!this.checkSignatureEncoding(T)||!this.checkPubkeyEncoding(M))return!1;L=new Fc().set({chunks:this.script.chunks.slice(this.pbegincodehash)}),Ix(L,T,this.flags);try{F=Hn.fromTxFormat(T),V=kp.fromBuffer(M,!1),G=this.tx.verifySignature(F,V,this.nin,L,this.satoshisBN,this.flags)}catch{G=!1}if(!G&&this.flags&P.SCRIPT_VERIFY_NULLFAIL&&T.length&&this.enforceNonMalleability())return this.errstr="SCRIPT_ERR_NULLFAIL",!1;if(this.stack.pop(),this.stack.pop(),this.stack.push(G?P.true:P.false),te===N.OP_CHECKSIGVERIFY)if(G)this.stack.pop();else return this.errstr="SCRIPT_ERR_CHECKSIGVERIFY",!1;break;case N.OP_CHECKMULTISIG:case N.OP_CHECKMULTISIGVERIFY:var Q=1;if(this.stack.length<Q)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;var J=ce.fromScriptNumBuffer(t(-Q),n,4).toNumber();if(J<0||J>this.maxPubKeysPerMultisig())return this.errstr="SCRIPT_ERR_PUBKEY_COUNT",!1;if(this.nOpCount+=J,this.nOpCount>this.maxOpsPerScript())return this.errstr="SCRIPT_ERR_OP_COUNT",!1;var re=++Q;Q+=J;var ue=J+2;if(this.stack.length<Q)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;var oe=ce.fromScriptNumBuffer(t(-Q),n,4).toNumber();if(oe<0||oe>J)return this.errstr="SCRIPT_ERR_SIG_COUNT",!1;var se=++Q;if(Q+=oe,this.stack.length<Q)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;L=new Fc().set({chunks:this.script.chunks.slice(this.pbegincodehash)});for(var be=0;be<oe;be++)T=t(-se-be),Ix(L,T,this.flags);for(G=!0;G&&oe>0;){if(T=t(-se),M=t(-re),!this.checkSignatureEncoding(T)||!this.checkPubkeyEncoding(M))return!1;var we;try{F=Hn.fromTxFormat(T),V=kp.fromBuffer(M,!1),we=this.tx.verifySignature(F,V,this.nin,L,this.satoshisBN,this.flags)}catch{we=!1}we&&(se++,oe--),re++,J--,oe>J&&(G=!1)}for(;Q-- >1;){if(!G&&this.flags&P.SCRIPT_VERIFY_NULLFAIL&&!ue&&t(-1).length&&this.enforceNonMalleability())return this.errstr="SCRIPT_ERR_NULLFAIL",!1;ue>0&&ue--,this.stack.pop()}if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(this.flags&P.SCRIPT_VERIFY_NULLDUMMY&&t(-1).length&&this.enforceNonMalleability())return this.errstr="SCRIPT_ERR_SIG_NULLDUMMY",!1;if(this.stack.pop(),this.stack.push(G?P.true:P.false),te===N.OP_CHECKMULTISIGVERIFY)if(G)this.stack.pop();else return this.errstr="SCRIPT_ERR_CHECKMULTISIGVERIFY",!1;break;case N.OP_CAT:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(o=t(-2),s=t(-1),o.length+s.length>this.maxScriptElementSize())return this.errstr="SCRIPT_ERR_PUSH_SIZE",!1;this.stack[this.stack.length-2]=d.Buffer.concat([o,s]),this.stack.pop();break;case N.OP_SPLIT:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;o=t(-2);var Re=ce.fromScriptNumBuffer(t(-1),n,this.maxScriptNumLength()).toNumber();if(Re<0||Re>o.length)return this.errstr="SCRIPT_ERR_INVALID_SPLIT_RANGE",!1;var he=d.Buffer.from(o);this.stack[this.stack.length-2]=he.slice(0,Re),this.stack[this.stack.length-1]=he.slice(Re);break;case N.OP_LEFT:case N.OP_RIGHT:if(!this.isAfterChronicle()){if(this.flags&P.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS)return this.errstr="SCRIPT_ERR_DISCOURAGE_UPGRADABLE_NOPS",!1;break}if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(o=t(-2),f=ce.fromScriptNumBuffer(t(-1),n,this.maxScriptNumLength()).toNumber(),f<0||f>o.length)return this.errstr="SCRIPT_ERR_INVALID_NUMBER_RANGE",!1;this.stack.pop(),te===N.OP_LEFT?this.stack[this.stack.length-1]=d.Buffer.from(o).slice(0,f):this.stack[this.stack.length-1]=d.Buffer.from(o).slice(o.length-f);break;case N.OP_SUBSTR:if(!this.isAfterChronicle()){if(this.flags&P.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS)return this.errstr="SCRIPT_ERR_DISCOURAGE_UPGRADABLE_NOPS",!1;break}if(this.stack.length<3)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;o=t(-3);var me=ce.fromScriptNumBuffer(t(-1),n,this.maxScriptNumLength()).toNumber(),_e=ce.fromScriptNumBuffer(t(-2),n,this.maxScriptNumLength()).toNumber();if(_e<0||_e>=o.length||me<0||me>o.length-_e)return this.errstr="SCRIPT_ERR_INVALID_NUMBER_RANGE",!1;this.stack.pop(),this.stack.pop(),this.stack[this.stack.length-1]=d.Buffer.from(o).slice(_e,_e+me);break;case N.OP_NUM2BIN:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;var Ft=ce.fromScriptNumBuffer(t(-1),n,this.maxScriptNumLength());if(Ft.cmpn(0)<0||Ft.gt(new ce(2147483647)))return this.errstr="SCRIPT_ERR_PUSH_SIZE",!1;var Ue=Ft.toNumber();if(Ue>this.maxScriptElementSize())return this.errstr="SCRIPT_ERR_PUSH_SIZE",!1;this.stack.pop();var Ee=t(-1);if(Ee=P._minimallyEncode(Ee),Ee.length>Ue)return this.errstr="SCRIPT_ERR_IMPOSSIBLE_ENCODING",!1;if(Ee.length===Ue){this.stack[this.stack.length-1]=Ee;break}var Ei=0;Ee.length>0&&(Ee=d.Buffer.from(Ee),Ei=Ee[Ee.length-1]&128,Ee[Ee.length-1]&=127);var je=d.Buffer.alloc(Ue);Ee.copy(je,0);for(var Qe=Ee.length-1;Qe++<Ue-2;)je[Qe]=0;je[Qe]=Ei,this.stack[this.stack.length-1]=je;break;case N.OP_BIN2NUM:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(o=t(-1),s=P._minimallyEncode(o),this.stack[this.stack.length-1]=s,!P._isMinimallyEncoded(s,this.maxScriptNumLength()))return this.errstr="SCRIPT_ERR_INVALID_NUMBER_RANGE",!1;break;default:return this.errstr="SCRIPT_ERR_BAD_OPCODE",!1}return!0}});var Hr=B((gq,Lp)=>{p();Lp.exports=yp();Lp.exports.Interpreter=kc()});var io=B((mq,Nx)=>{"use strict";p();var Dp=Ze(),jn=Fe(),hC=Qn(),Tx=Wd(),Tr=va(),Px=er(),Bx=gr(),Up=Or();function ne(e,t,r){if(!(this instanceof ne))return new ne(e,t,r);if(Dp.isArray(e)&&Dp.isNumber(t))return ne.createMultisig(e,t,r);if(e instanceof ne)return e;if(jn.checkArgument(e,"First argument is required, please include address data.","guide/address.html"),t&&!Tr.get(t))throw new TypeError('Second argument must be "livenet", "testnet", or "regtest".');if(r&&r!==ne.PayToPublicKeyHash&&r!==ne.PayToScriptHash)throw new TypeError('Third argument must be "pubkeyhash" or "scripthash".');var n=this._classifyArguments(e,t,r);return n.network=n.network||Tr.get(t)||Tr.defaultNetwork,n.type=n.type||r||ne.PayToPublicKeyHash,Bx.defineImmutable(this,{hashBuffer:n.hashBuffer,network:n.network,type:n.type}),this}ne.prototype._classifyArguments=function(e,t,r){if((e instanceof d.Buffer||e instanceof Uint8Array)&&e.length===20)return ne._transformHash(e);if((e instanceof d.Buffer||e instanceof Uint8Array)&&e.length===21)return ne._transformBuffer(e,t,r);if(e instanceof Up)return ne._transformPublicKey(e);if(e instanceof Wa())return ne._transformScript(e,t);if(typeof e=="string")return ne._transformString(e,t,r);if(Dp.isObject(e))return ne._transformObject(e);throw new TypeError("First argument is an unrecognized data format.")};ne.PayToPublicKeyHash="pubkeyhash";ne.PayToScriptHash="scripthash";ne._transformHash=function(e){var t={};if(!(e instanceof d.Buffer)&&!(e instanceof Uint8Array))throw new TypeError("Address supplied is not a buffer.");if(e.length!==20)throw new TypeError("Address hashbuffers must be exactly 20 bytes.");return t.hashBuffer=e,t};ne._transformObject=function(e){return jn.checkArgument(e.hash||e.hashBuffer,"Must provide a `hash` or `hashBuffer` property"),jn.checkArgument(e.type,"Must provide a `type` property"),{hashBuffer:e.hash?d.Buffer.from(e.hash,"hex"):e.hashBuffer,network:Tr.get(e.network)||Tr.defaultNetwork,type:e.type}};ne._classifyFromVersion=function(e){var t={},r=Tr.get(e[0],"pubkeyhash"),n=Tr.get(e[0],"scripthash");return r?(t.network=r,t.type=ne.PayToPublicKeyHash):n&&(t.network=n,t.type=ne.PayToScriptHash),t};ne._transformBuffer=function(e,t,r){var n={};if(!(e instanceof d.Buffer)&&!(e instanceof Uint8Array))throw new TypeError("Address supplied is not a buffer.");if(e.length!==21)throw new TypeError("Address buffers must be exactly 21 bytes.");var i=Tr.get(t),o=ne._classifyFromVersion(e);if(t&&!i)throw new TypeError("Unknown network");if(!o.network||i&&i!==o.network)throw new TypeError("Address has mismatched network type.");if(!o.type||r&&r!==o.type)throw new TypeError("Address has mismatched type.");return n.hashBuffer=e.slice(1),n.network=o.network,n.type=o.type,n};ne._transformPublicKey=function(e){var t={};if(!(e instanceof Up))throw new TypeError("Address must be an instance of PublicKey.");return t.hashBuffer=Px.sha256ripemd160(e.toBuffer()),t.type=ne.PayToPublicKeyHash,t};ne._transformScript=function(e,t){jn.checkArgument(e instanceof Wa(),"script must be a Script instance");var r=e.getAddressInfo(t);if(!r)throw new hC.Script.CantDeriveAddress(e);return r};ne.createMultisig=function(e,t,r){return r=r||e[0].network||Tr.defaultNetwork,ne.payingTo(Wa().buildMultisigOut(e,t),r)};ne._transformString=function(e,t,r){if(typeof e!="string")throw new TypeError("data parameter supplied is not a string.");if(e.length<27)throw new Error("Invalid Address string provided");e=e.trim();var n=Tr.get(t);if(t&&!n)throw new TypeError("Unknown network");var i=Tx.decode(e);return ne._transformBuffer(i,t,r)};ne.fromPublicKey=function(e,t){var r=ne._transformPublicKey(e);return t=t||Tr.defaultNetwork,new ne(r.hashBuffer,t,r.type)};ne.fromPrivateKey=function(e,t){let r=Up.fromPrivateKey(e);return t=t||e.network||Tr.defaultNetwork,ne.fromPublicKey(r,t)};ne.fromPublicKeyHash=function(e,t){var r=ne._transformHash(e);return new ne(r.hashBuffer,t,ne.PayToPublicKeyHash)};ne.fromScriptHash=function(e,t){jn.checkArgument(e,"hash parameter is required");var r=ne._transformHash(e);return new ne(r.hashBuffer,t,ne.PayToScriptHash)};ne.payingTo=function(e,t){return jn.checkArgument(e,"script is required"),jn.checkArgument(e instanceof Wa(),"script must be instance of Script"),ne.fromScriptHash(Px.sha256ripemd160(e.toBuffer()),t)};ne.fromScript=function(e,t){jn.checkArgument(e instanceof Wa(),"script must be a Script instance");var r=ne._transformScript(e,t);return new ne(r.hashBuffer,t,r.type)};ne.fromBuffer=function(e,t,r){var n=ne._transformBuffer(e,t,r);return new ne(n.hashBuffer,n.network,n.type)};ne.fromHex=function(e,t,r){return ne.fromBuffer(d.Buffer.from(e,"hex"),t,r)};ne.fromString=function(e,t,r){var n=ne._transformString(e,t,r);return new ne(n.hashBuffer,n.network,n.type)};ne.fromObject=function(t){jn.checkState(Bx.isHexa(t.hash),'Unexpected hash property, "'+t.hash+'", expected to be hex.');var r=d.Buffer.from(t.hash,"hex");return new ne(r,t.network,t.type)};ne.getValidationError=function(e,t,r){var n;try{new ne(e,t,r)}catch(i){n=i}return n};ne.isValid=function(e,t,r){return!ne.getValidationError(e,t,r)};ne.prototype.isPayToPublicKeyHash=function(){return this.type===ne.PayToPublicKeyHash};ne.prototype.isPayToScriptHash=function(){return this.type===ne.PayToScriptHash};ne.prototype.toBuffer=function(){var e=d.Buffer.from([this.network[this.type]]),t=d.Buffer.concat([e,this.hashBuffer]);return t};ne.prototype.toHex=function(){return this.toBuffer().toString("hex")};ne.prototype.toObject=ne.prototype.toJSON=function(){return{hash:this.hashBuffer.toString("hex"),type:this.type,network:this.network.toString()}};ne.prototype.inspect=function(){return"<Address: "+this.toString()+", type: "+this.type+", network: "+this.network+">"};ne.prototype.toString=function(){return Tx.encode(this.toBuffer())};Nx.exports=ne;function Wa(){return Hr()}});var oo=B((bq,Lx)=>{"use strict";p();var qc=Ze(),dC=io(),Mx=Wd(),wi=Er(),kx=gr(),dn=va(),qp=ci(),pC=Or(),gC=ta(),Cx=Fe(),Fp="[REDACTED]";function ve(e,t){if(!(this instanceof ve))return new ve(e,t);if(e instanceof ve)return e;var r=this._classifyArguments(e,t);if(!r.bn||r.bn.cmp(new wi(0))===0)throw new TypeError("Number can not be equal to zero, undefined, null or false");if(!r.bn.lt(qp.getN()))throw new TypeError("Number must be less than N");if(typeof r.network>"u")throw new TypeError('Must specify the network ("livenet" or "testnet")');return kx.defineImmutable(this,{bn:r.bn,compressed:r.compressed,network:r.network}),Object.defineProperty(this,"publicKey",{configurable:!1,enumerable:!0,get:this.toPublicKey.bind(this)}),this}ve.prototype._classifyArguments=function(e,t){var r={compressed:!0,network:t?dn.get(t):dn.defaultNetwork};if(qc.isUndefined(e)||qc.isNull(e))r.bn=ve._getRandomBN();else if(e instanceof wi)r.bn=e;else if(e instanceof d.Buffer||e instanceof Uint8Array)r=ve._transformBuffer(e,t);else if(e.bn&&e.network)r=ve._transformObject(e);else if(!t&&dn.get(e))r.bn=ve._getRandomBN(),r.network=dn.get(e);else if(typeof e=="string")kx.isHexa(e)?r.bn=new wi(d.Buffer.from(e,"hex")):r=ve._transformWIF(e,t);else throw new TypeError("First argument is an unrecognized data type.");return r};ve._getRandomBN=function(){var e,t;do{var r=gC.getRandomBuffer(32);t=wi.fromBuffer(r),e=t.lt(qp.getN())}while(!e);return t};ve._transformBuffer=function(e,t){var r={};if(e.length===32)return ve._transformBNBuffer(e,t);if(r.network=dn.get(e[0],"privatekey"),!r.network)throw new Error("Invalid network");if(t&&r.network!==dn.get(t))throw new TypeError("Private key network mismatch");if(e.length===34&&e[33]===1)r.compressed=!0;else if(e.length===33)r.compressed=!1;else throw new Error("Length of buffer must be 33 (uncompressed) or 34 (compressed)");return r.bn=wi.fromBuffer(e.slice(1,33)),r};ve._transformBNBuffer=function(e,t,r){var n={};return n.network=dn.get(t)||dn.defaultNetwork,n.bn=wi.fromBuffer(e),n.compressed=r===void 0?!0:!!r,n};ve._transformWIF=function(e,t){return ve._transformBuffer(Mx.decode(e),t)};ve.fromBuffer=function(e,t,r){return r!==void 0&&e&&e.length===32?new ve(ve._transformBNBuffer(e,t,r)):new ve(e,t)};ve.fromHex=function(e,t,r){return ve.fromBuffer(d.Buffer.from(e,"hex"),t,r)};ve._transformObject=function(e){if(e.bn instanceof wi)return{bn:e.bn,network:dn.get(e.network),compressed:e.compressed};if(typeof e.bn!="string"||!e.bn.length)throw new TypeError("Invalid private key: `bn` must be a hex string");if(e.bn===Fp)throw new TypeError('Invalid private key: `bn` is "'+Fp+'". JSON.stringify() redacts the secret on purpose \u2014 use toObject() for a round-trippable export, or toWIF().');if(!/^[0-9a-fA-F]+$/.test(e.bn))throw new TypeError("Invalid private key: `bn` is not hexadecimal");var t=new wi(e.bn,"hex");if(t.isZero()||t.gte(qp.getN()))throw new TypeError("Invalid private key: outside the range of valid keys");var r=dn.get(e.network);return{bn:t,network:r,compressed:e.compressed}};ve.fromString=ve.fromWIF=function(e,t){return Cx.checkArgument(qc.isString(e),"First argument is expected to be a string."),new ve(e,t)};ve.fromObject=ve.fromJSON=function(e){return Cx.checkArgument(qc.isObject(e),"First argument is expected to be an object."),new ve(e)};ve.fromRandom=function(e){var t=ve._getRandomBN();return new ve(t,e)};ve.getValidationError=function(e,t){var r;try{new ve(e,t)}catch(n){r=n}return r};ve.isValid=function(e,t){return e?!ve.getValidationError(e,t):!1};ve.prototype.toString=function(){return this.toWIF()};ve.prototype.toWIF=function(){var e=this.network,t=this.compressed,r;return t?r=d.Buffer.concat([d.Buffer.from([e.privatekey]),this.bn.toBuffer({size:32}),d.Buffer.from([1])]):r=d.Buffer.concat([d.Buffer.from([e.privatekey]),this.bn.toBuffer({size:32})]),Mx.encode(r)};ve.prototype.toBigNumber=function(){return this.bn};ve.prototype.toBuffer=function(){return this.bn.toBuffer({size:32})};ve.prototype.toHex=function(){return this.toBuffer().toString("hex")};ve.prototype.toPublicKey=function(){return this._pubkey||(this._pubkey=pC.fromPrivateKey(this)),this._pubkey};ve.prototype.toAddress=function(e){var t=this.toPublicKey();return dC.fromPublicKey(t,e||this.network)};ve.prototype.toObject=function(){return{bn:this.bn.toString("hex"),compressed:this.compressed,network:this.network.toString()}};ve.prototype.toJSON=function(){return{bn:Fp,compressed:this.compressed,network:this.network.toString()}};ve.prototype.inspect=function(){var e=this.compressed?"":", uncompressed";return"<PrivateKey: "+this.toHex()+", network: "+this.network+e+">"};Lx.exports=ve});var Or=B((Sq,Ux)=>{"use strict";p();var cs=Er(),ls=ci(),yC=er(),mC=gr(),Dx=va(),Hp=Ze(),ao=Fe();function de(e,t){if(!(this instanceof de))return new de(e,t);if(ao.checkArgument(e,"First argument is required, please include public key data."),e instanceof de)return e;t=t||{};var r=this._classifyArgs(e,t);return r.point.validate(),mC.defineImmutable(this,{point:r.point,compressed:r.compressed,network:r.network||Dx.defaultNetwork}),this}de.prototype._classifyArgs=function(e,t){var r={compressed:Hp.isUndefined(t.compressed)||t.compressed};if(e instanceof ls)r.point=e;else if(e.x&&e.y)r=de._transformObject(e);else if(typeof e=="string")r=de._transformDER(d.Buffer.from(e,"hex"));else if(de._isBuffer(e))r=de._transformDER(e);else if(de._isPrivateKey(e))r=de._transformPrivateKey(e);else throw new TypeError("First argument is an unrecognized data format.");return r.network||(r.network=Hp.isUndefined(t.network)?void 0:Dx.get(t.network)),r};de._isPrivateKey=function(e){var t=oo();return e instanceof t};de._isBuffer=function(e){return e instanceof d.Buffer||e instanceof Uint8Array};de._transformPrivateKey=function(e){ao.checkArgument(de._isPrivateKey(e),"Must be an instance of PrivateKey");var t={};return t.point=ls.getG().mul(e.bn),t.compressed=e.compressed,t.network=e.network,t};de._transformDER=function(e,t){ao.checkArgument(de._isBuffer(e),"Must be a buffer of DER encoded public key");var r={};t=Hp.isUndefined(t)?!0:t;var n,i,o,s;if(e[0]===4||!t&&(e[0]===6||e[0]===7)){if(o=e.slice(1,33),s=e.slice(33,65),o.length!==32||s.length!==32||e.length!==65)throw new TypeError("Length of x and y must be 32 bytes");n=new cs(o),i=new cs(s),r.point=new ls(n,i),r.compressed=!1}else if(e[0]===3)o=e.slice(1),n=new cs(o),r=de._transformX(!0,n),r.compressed=!0;else if(e[0]===2)o=e.slice(1),n=new cs(o),r=de._transformX(!1,n),r.compressed=!0;else throw new TypeError("Invalid DER format public key");return r};de._transformX=function(e,t){ao.checkArgument(typeof e=="boolean","Must specify whether y is odd or not (true or false)");var r={};return r.point=ls.fromX(e,t),r};de._transformObject=function(e){var t=new cs(e.x,"hex"),r=new cs(e.y,"hex"),n=new ls(t,r);return new de(n,{compressed:e.compressed})};de.fromPrivateKey=function(e){ao.checkArgument(de._isPrivateKey(e),"Must be an instance of PrivateKey");var t=de._transformPrivateKey(e);return new de(t.point,{compressed:t.compressed,network:t.network})};de.fromDER=de.fromBuffer=function(e,t){ao.checkArgument(de._isBuffer(e),"Must be a buffer of DER encoded public key");var r=de._transformDER(e,t);return new de(r.point,{compressed:r.compressed})};de.fromPoint=function(e,t){return ao.checkArgument(e instanceof ls,"First argument must be an instance of Point."),new de(e,{compressed:t})};de.fromHex=de.fromString=function(e,t){var r=d.Buffer.from(e,t||"hex"),n=de._transformDER(r);return new de(n.point,{compressed:n.compressed})};de.fromX=function(e,t){var r=de._transformX(e,t);return new de(r.point,{compressed:r.compressed})};de.getValidationError=function(e){var t;try{new de(e)}catch(r){t=r}return t};de.isValid=function(e){return!de.getValidationError(e)};de.prototype.toObject=de.prototype.toJSON=function(){return{x:this.point.getX().toString("hex",2),y:this.point.getY().toString("hex",2),compressed:this.compressed}};de.prototype.toBuffer=de.prototype.toDER=function(){var e=this.point.getX(),t=this.point.getY(),r=e.toBuffer({size:32}),n=t.toBuffer({size:32}),i;if(this.compressed){var o=n[n.length-1]%2;return o?i=d.Buffer.from([3]):i=d.Buffer.from([2]),d.Buffer.concat([i,r])}else return i=d.Buffer.from([4]),d.Buffer.concat([i,r,n])};de.prototype._getID=function(){return yC.sha256ripemd160(this.toBuffer())};de.prototype.toAddress=function(e){var t=io();return t.fromPublicKey(this,e||this.network)};de.prototype.toString=de.prototype.toHex=function(){return this.toDER().toString("hex")};de.prototype.inspect=function(){return"<PublicKey: "+this.toHex()+(this.compressed?"":", uncompressed")+">"};Ux.exports=de});var za=B((Eq,qx)=>{"use strict";p();var Fx=ta();function vC(){var e=Fx.getRandomBuffer(16);e[6]=e[6]&15|64,e[8]=e[8]&63|128;var t=e.toString("hex");return[t.substring(0,8),t.substring(8,12),t.substring(12,16),t.substring(16,20),t.substring(20,32)].join("-")}function bC(e){return Fx.getRandomBuffer(Math.ceil(e/2)).toString("hex").substring(0,e)}qx.exports={uuid4:vC,randomHex:bC}});var Vx=B((Aq,Gx)=>{"use strict";p();var Ya=Or(),jp=er(),Kp=Ua(),Hx=or(),Gp=oo(),Nt=Fe(),Iq=Ze(),_C=za();function jx(e,t){if(t=t||{},t.issuerPublicKey)return t.issuerPublicKey instanceof Ya?t.issuerPublicKey:Ya.fromString(t.issuerPublicKey);var r=e&&e.issuer;if(typeof r!="string")return null;try{var n=r.split("#")[0].split(":")[2];return n?Ya.fromString(n):null}catch{return null}}var hs={PROPERTY_TITLE:"PropertyTitle",VEHICLE_TITLE:"VehicleTitle",INTELLECTUAL_PROPERTY:"IntellectualProperty",MUSIC_LICENSE:"MusicLicense",SOFTWARE_LICENSE:"SoftwareLicense",FINANCIAL_INSTRUMENT:"FinancialInstrument",PROMISSORY_NOTE:"PromissoryNote",BOND:"Bond",EQUITY_SHARE:"EquityShare",PROFESSIONAL_LICENSE:"ProfessionalLicense",REGULATORY_PERMIT:"RegulatoryPermit",ACCESS_RIGHT:"AccessRight",VOTING_RIGHT:"VotingRight",ROYALTY_RIGHT:"RoyaltyRight",USAGE_RIGHT:"UsageRight"},Kx={create:function(e,t,r,n,i,o){o=o||{},Nt.checkArgument(typeof e=="string","Right type must be string"),Nt.checkArgument(typeof t=="string","Issuer DID must be string"),Nt.checkArgument(typeof r=="string","Subject DID must be string"),Nt.checkArgument(n&&typeof n=="object","Claim must be object");var s=Object.values(hs);Nt.checkArgument(s.includes(e),"Invalid right type: "+e);var a={"@context":["https://www.w3.org/2018/credentials/v1","https://smartledger.technology/contexts/ltp/v1"],id:"urn:uuid:"+this._generateUUID(),type:["VerifiableCredential","LegalRightToken",e],issuer:t,issuanceDate:new Date().toISOString(),credentialSubject:{id:r,rightType:e,claim:n,jurisdiction:o.jurisdiction||"US",purpose:o.purpose||"legal_right",validFrom:o.validFrom||new Date().toISOString(),validUntil:o.validUntil||null,transferable:o.transferable!==!1,revocable:o.revocable!==!1}};return o.metadata&&(a.credentialSubject.metadata=o.metadata),a},prepareRightToken:function(e,t,r,n,i,o){o=o||{},Nt.checkArgument(typeof e=="string","Right type must be string"),Nt.checkArgument(typeof t=="string","Issuer DID must be string"),Nt.checkArgument(typeof r=="string","Subject DID must be string"),Nt.checkArgument(n&&typeof n=="object","Claim must be object"),Nt.checkArgument(i instanceof Gp,"Invalid issuer private key");var s=Object.values(hs);Nt.checkArgument(s.includes(e),"Invalid right type: "+e);try{var a=this.create(e,t,r,n,i,o),f=this._signToken(a,i);return{success:!0,rightToken:f,tokenHash:f.tokenHash,metadata:{type:e,issuer:t,subject:r,transferable:a.credentialSubject.transferable,revocable:a.credentialSubject.revocable,jurisdiction:a.credentialSubject.jurisdiction},externalOperations:{storeToken:{endpoint:"POST /rights/tokens",data:{token:f,metadata:{type:e,issuer:t,subject:r,transferable:a.credentialSubject.transferable,revocable:a.credentialSubject.revocable,jurisdiction:a.credentialSubject.jurisdiction}}},indexToken:{endpoint:"POST /rights/index",data:{tokenId:f.id,tokenHash:f.tokenHash,type:e,issuer:t,subject:r,issuedAt:f.issuanceDate}},notifyParties:{endpoint:"POST /notifications/right-issued",data:{tokenId:f.id,issuer:t,subject:r,rightType:e}}}}}catch(l){return{success:!1,error:l.message}}},prepareRightTokenVerification:function(e,t){t=t||{};try{var r=[],n=[];this._validateTokenStructure(e,r),this._verifyTokenSignature(e,r,t),this._validateTokenTemporal(e,r,n),this._validateRightType(e,r),t.requireJurisdiction&&this._validateJurisdiction(e,t.allowedJurisdictions,r);var i={valid:r.length===0,errors:r,warnings:n,issuerDID:e.issuer,subjectDID:e.credentialSubject?e.credentialSubject.id:null,rightType:e.credentialSubject?e.credentialSubject.rightType:null,transferable:e.credentialSubject?e.credentialSubject.transferable:null,revocable:e.credentialSubject?e.credentialSubject.revocable:null,verifiedAt:new Date().toISOString()};return{success:!0,verification:i,externalOperations:{recordVerification:{endpoint:"POST /rights/verification-record",data:{tokenId:e.id,result:i.valid,errors:r,warnings:n,verifiedAt:i.verifiedAt}},auditVerification:{endpoint:"POST /audit/right-verification",data:{tokenId:e.id,rightType:i.rightType,issuer:i.issuerDID,subject:i.subjectDID,result:i.valid,verifiedAt:i.verifiedAt}},updateTokenStatus:i.valid?{endpoint:"PUT /rights/tokens/"+e.id+"/status",data:{status:"VERIFIED",verifiedAt:i.verifiedAt}}:null}}}catch(o){return{success:!1,error:"Verification preparation failed: "+o.message}}},prepareRightTokenTransfer:function(e,t,r,n){n=n||{},Nt.checkArgument(e&&typeof e=="object","Invalid token"),Nt.checkArgument(typeof t=="string","New owner DID must be string"),Nt.checkArgument(r instanceof Gp,"Invalid current owner key");try{var i=this.prepareRightTokenVerification(e,{});if(!i.success||!i.verification.valid)return{success:!1,error:"Cannot transfer invalid token: "+i.verification.errors.join(", ")};if(!e.credentialSubject.transferable)return{success:!1,error:"Token is not transferable"};var o=e.credentialSubject&&e.credentialSubject.id,s=jx({issuer:o},{issuerPublicKey:n.currentOwnerPublicKey});if(!s)return{success:!1,error:"Cannot resolve current owner public key from token.credentialSubject.id; pass options.currentOwnerPublicKey"};if(r.toPublicKey().toString()!==s.toString())return{success:!1,error:"Unauthorized transfer: signing key does not match the current owner"};var a={"@context":["https://www.w3.org/2018/credentials/v1","https://smartledger.technology/contexts/ltp/v1"],id:"urn:uuid:"+this._generateUUID(),type:["VerifiableCredential","LegalRightTransfer"],issuer:e.credentialSubject.id,issuanceDate:new Date().toISOString(),credentialSubject:{id:t,originalToken:e.id,transferFrom:e.credentialSubject.id,transferTo:t,transferDate:new Date().toISOString(),transferReason:n.reason||"ownership_transfer",consideration:n.consideration||null}},f=this._signToken(a,r),l=JSON.parse(JSON.stringify(e));l.id="urn:uuid:"+this._generateUUID(),l.issuanceDate=new Date().toISOString(),l.credentialSubject.id=t,l.credentialSubject.transferHistory=l.credentialSubject.transferHistory||[],l.credentialSubject.transferHistory.push({transferId:f.id,transferDate:f.issuanceDate,from:e.credentialSubject.id,to:t}),delete l.proof;var y=this._signToken(l,r);return{success:!0,newToken:y,transferProof:f,transferId:f.id,externalOperations:{recordTransfer:{endpoint:"POST /rights/transfers",data:{originalTokenId:e.id,newTokenId:y.id,transferProof:f,fromOwner:e.credentialSubject.id,toOwner:t,transferDate:f.issuanceDate}},updateOwnership:{endpoint:"PUT /rights/tokens/"+e.id+"/ownership",data:{newOwner:t,transferId:f.id,transferDate:f.issuanceDate,previousOwner:e.credentialSubject.id}},notifyParties:{endpoint:"POST /notifications/right-transferred",data:{originalTokenId:e.id,newTokenId:y.id,fromOwner:e.credentialSubject.id,toOwner:t,rightType:e.credentialSubject.rightType}},auditTransfer:{endpoint:"POST /audit/right-transfer",data:{originalTokenId:e.id,newTokenId:y.id,transferId:f.id,fromOwner:e.credentialSubject.id,toOwner:t,transferredAt:f.issuanceDate}}}}}catch(g){return{success:!1,error:g.message}}},prepareObligationToken:function(e,t,r,n){Nt.checkArgument(e&&typeof e=="object","Invalid right token"),Nt.checkArgument(typeof t=="string","Obligor DID must be string"),Nt.checkArgument(r&&typeof r=="object","Obligation must be object"),Nt.checkArgument(n instanceof Gp,"Invalid issuer key");try{var i={"@context":["https://www.w3.org/2018/credentials/v1","https://smartledger.technology/contexts/ltp/v1"],id:"urn:uuid:"+this._generateUUID(),type:["VerifiableCredential","LegalObligationToken"],issuer:e.issuer,issuanceDate:new Date().toISOString(),credentialSubject:{id:t,obligationType:"correlative_obligation",correlativeRight:e.id,rightHolder:e.credentialSubject.id,obligation:r,jurisdiction:e.credentialSubject.jurisdiction,purpose:e.credentialSubject.purpose}},o=this._signToken(i,n);return{success:!0,obligationToken:o,correlativeRight:e.id,externalOperations:{storeObligation:{endpoint:"POST /obligations/tokens",data:{obligationToken:o,correlativeRightId:e.id,obligor:t,rightHolder:e.credentialSubject.id}},linkToRight:{endpoint:"POST /rights/tokens/"+e.id+"/obligations",data:{obligationId:o.id,obligor:t,obligationType:"correlative_obligation"}},notifyObligor:{endpoint:"POST /notifications/obligation-created",data:{obligationId:o.id,obligor:t,rightHolder:e.credentialSubject.id,correlativeRight:e.id}}}}}catch(s){return{success:!1,error:s.message}}},prepareRightTypeValidation:function(e){Nt.checkArgument(typeof e=="string","Right type must be string");var t=Object.values(hs),r=t.includes(e);return{success:!0,validation:{type:e,valid:r,availableTypes:t,category:this._categorizeRightType(e),description:this._getRightTypeDescription(e)},externalOperations:{validateType:{endpoint:"POST /rights/validate-type",data:{type:e,valid:r}}}}},_categorizeRightType:function(e){var t={PropertyTitle:"PROPERTY_RIGHT",VehicleTitle:"PROPERTY_RIGHT",IntellectualProperty:"IP_RIGHT",MusicLicense:"IP_RIGHT",SoftwareLicense:"IP_RIGHT",FinancialInstrument:"FINANCIAL_RIGHT",PromissoryNote:"FINANCIAL_RIGHT",Bond:"FINANCIAL_RIGHT",EquityShare:"FINANCIAL_RIGHT",ProfessionalLicense:"LICENSE_RIGHT",RegulatoryPermit:"LICENSE_RIGHT",AccessRight:"ACCESS_RIGHT",VotingRight:"GOVERNANCE_RIGHT",RoyaltyRight:"IP_RIGHT",UsageRight:"ACCESS_RIGHT"};return t[e]||"UNKNOWN"},_getRightTypeDescription:function(e){var t={PropertyTitle:"Legal ownership of real estate property",VehicleTitle:"Legal ownership of motor vehicle",IntellectualProperty:"Rights to intellectual property assets",MusicLicense:"License for music performance and usage",SoftwareLicense:"License for software usage and distribution",FinancialInstrument:"Rights related to financial instruments",PromissoryNote:"Promise to pay a specified amount",Bond:"Debt security representing loan",EquityShare:"Ownership stake in company",ProfessionalLicense:"License for professional practice",RegulatoryPermit:"Permit for regulated activities",AccessRight:"Right to access resources or locations",VotingRight:"Right to participate in governance",RoyaltyRight:"Right to receive royalty payments",UsageRight:"Right to use specific assets or services"};return t[e]||"Unknown right type"},getRightTypes:function(){return hs},verifyToken:function(e,t){var r=[];try{if(Nt.checkArgument(e&&typeof e=="object","Invalid token"),!e.proof||!e.proof.jws)return r.push("Missing signature proof"),{valid:!1,errors:r};var n=t instanceof Ya?t:Ya.fromString(t),i=this._canonicalizeToken(e),o=jp.sha256(d.Buffer.from(i));if(e.tokenHash&&e.tokenHash!==o.toString("hex"))return r.push("Token hash mismatch"),{valid:!1,errors:r};var s=e.proof.jws.split(".");if(s.length!==3||!s[2])return r.push("Malformed JWS"),{valid:!1,errors:r};var a=Hx.fromDER(d.Buffer.from(s[2],"base64url")),f=new Kp;return f.hashbuf=o,f.sig=a,f.pubkey=n,f.verify()||r.push("Signature verification failed"),{valid:r.length===0,errors:r,tokenHash:o.toString("hex"),verifiedAt:new Date().toISOString()}}catch(l){return r.push(l.message),{valid:!1,errors:r}}},_signToken:function(e,t){var r=this._canonicalizeToken(e),n=jp.sha256(d.Buffer.from(r)),i=new Kp;i.hashbuf=n,i.privkey=t,i.pubkey=t.toPublicKey(),i.sign();var o=i.sig,s={type:"EcdsaSecp256k1Signature2019",created:new Date().toISOString(),verificationMethod:"did:smartledger:"+t.toPublicKey().toString()+"#keys-1",proofPurpose:"assertionMethod",jws:this._createJWS(n,o)},a=JSON.parse(JSON.stringify(e));return a.proof=s,a.tokenHash=n.toString("hex"),a},_createJWS:function(e,t){var r={alg:"ES256K",typ:"JWT"},n=d.Buffer.from(JSON.stringify(r)).toString("base64url"),i=t.toDER().toString("base64url");return n+".."+i},_canonicalizeToken:function(e){var t=JSON.parse(JSON.stringify(e));return delete t.proof,delete t.tokenHash,JSON.stringify(this._sortObjectKeys(t))},_sortObjectKeys:function(e){if(Array.isArray(e))return e.map(this._sortObjectKeys.bind(this));if(e!==null&&typeof e=="object"){var t={};return Object.keys(e).sort().forEach(function(r){t[r]=this._sortObjectKeys(e[r])}.bind(this)),t}return e},_validateTokenStructure:function(e,t){e["@context"]||t.push("Missing @context"),e.id||t.push("Missing id"),(!e.type||!Array.isArray(e.type))&&t.push("Missing or invalid type"),e.issuer||t.push("Missing issuer"),e.issuanceDate||t.push("Missing issuanceDate"),e.credentialSubject||t.push("Missing credentialSubject"),e.proof||t.push("Missing proof")},_verifyTokenSignature:function(e,t,r){try{if(!e.proof||!e.proof.jws){t.push("Missing signature proof");return}var n=this._canonicalizeToken(e),i=jp.sha256(d.Buffer.from(n));if(e.tokenHash&&e.tokenHash!==i.toString("hex")){t.push("Token hash mismatch");return}var o=jx(e,r);if(!o){t.push("Signature not verified: issuer public key could not be resolved from token.issuer; pass options.issuerPublicKey");return}var s=e.proof.jws.split(".");if(s.length!==3||!s[2]){t.push("Malformed JWS");return}var a=Hx.fromDER(d.Buffer.from(s[2],"base64url")),f=new Kp;f.hashbuf=i,f.sig=a,f.pubkey=o,f.verify()!==!0&&t.push("Signature verification failed")}catch(l){t.push("Signature verification failed: "+l.message)}},_validateTokenTemporal:function(e,t,r){var n=new Date,i=new Date(e.issuanceDate);if(i>n&&t.push("Token issued in the future"),e.credentialSubject.validFrom){var o=new Date(e.credentialSubject.validFrom);n<o&&r.push("Token not yet valid")}if(e.credentialSubject.validUntil){var s=new Date(e.credentialSubject.validUntil);n>s&&t.push("Token expired")}},_validateRightType:function(e,t){if(!e.credentialSubject.rightType){t.push("Missing rightType");return}var r=Object.values(hs);r.includes(e.credentialSubject.rightType)||t.push("Invalid right type: "+e.credentialSubject.rightType)},_validateJurisdiction:function(e,t,r){if(!e.credentialSubject.jurisdiction){r.push("Missing jurisdiction");return}t&&Array.isArray(t)&&(t.includes(e.credentialSubject.jurisdiction)||r.push("Jurisdiction not allowed: "+e.credentialSubject.jurisdiction))},_generateUUID:function(){return _C.uuid4()}};Kx.RightTypes=hs;Gx.exports=Kx});var Yx=B((Rq,zx)=>{"use strict";p();var Wx={};Wx.stringify=function(e){return Vp(e,[])};function Vp(e,t){if(e===null)return"null";var r=typeof e;if(r==="boolean")return e?"true":"false";if(r==="number"){if(!isFinite(e))throw new Error("Cannot canonicalize non-finite number: "+e);return JSON.stringify(e)}if(r==="string")return JSON.stringify(e);if(r==="bigint")throw new Error("Cannot canonicalize bigint; represent it as a string");if(Array.isArray(e)||r==="object"){if(t.indexOf(e)!==-1)throw new Error("Cannot canonicalize a circular structure");t.push(e);var n;if(Array.isArray(e))n="["+e.map(function(o){return o===void 0?"null":Vp(o,t)}).join(",")+"]";else{var i=Object.keys(e).filter(function(o){return e[o]!==void 0&&typeof e[o]!="function"}).sort();n="{"+i.map(function(o){return JSON.stringify(o)+":"+Vp(e[o],t)}).join(",")+"}"}return t.pop(),n}throw new Error("Cannot canonicalize value of type: "+r)}zx.exports=Wx});var Xx=B((Pq,Zx)=>{"use strict";p();var Wp=Object.create(null),zp=[],Yp=!(typeof x.default<"u"&&x.default.env&&x.default.env.BSV_NO_DEPRECATION_WARNINGS==="1");function $x(e,t){if(!e||typeof e.what!="string"||e.what==="")throw new TypeError(t+"() requires { what: string }")}function SC(e){var t="[@smartledger/bsv] "+e.what+" is deprecated";return e.since&&(t+=" since "+e.since),t+=".",e.why&&(t+=" "+e.why.charAt(0).toUpperCase()+e.why.slice(1)+"."),e.use&&(t+=" Use "+e.use+" instead."),t+=e.removeIn?" It will be removed in "+e.removeIn+".":" A removal version has not been set; it will not be removed in a 9.x release.",t}function Kn(e){if(!e||!e.what)throw new TypeError("deprecate() requires { what }");if(Wp[e.what])return!1;Wp[e.what]=!0;var t=SC(e);return zp.push({what:e.what,since:e.since||null,removeIn:e.removeIn||null,use:e.use||null,message:t}),Yp&&console.warn(t),!0}Kn.fn=function(e,t){if(typeof e!="function")throw new TypeError("deprecate.fn() requires a function");$x(t,"deprecate.fn");var r=function(){return Kn(t),e.apply(this,arguments)};return Object.defineProperty(r,"name",{value:e.name,configurable:!0}),Object.defineProperty(r,"length",{value:e.length,configurable:!0}),r.__wrapped=e,r.__deprecation=t,r};Kn.property=function(e,t,r,n){$x(n,"deprecate.property");var i,o=!1;return Object.defineProperty(e,t,{configurable:!0,enumerable:!0,get:function(){return Kn(n),o||(i=r(),o=!0),i}}),e};Kn.fired=function(){return zp.slice()};Kn.setEnabled=function(e){Yp=!!e};Kn.isEnabled=function(){return Yp};Kn.reset=function(){Wp=Object.create(null),zp.length=0};Zx.exports=Kn});var Qx=B((Nq,Jx)=>{"use strict";p();var ds=er(),lr=Fe(),wC=za(),EC=Yx(),xC=Xx(),uo={PropertyTitle:{title:"Property Title",description:"Real estate property ownership title",type:"object",required:["propertyId","address","ownershipType"],properties:{propertyId:{type:"string",description:"Unique property identifier"},address:{type:"object",required:["street","city","state","country"],properties:{street:{type:"string"},city:{type:"string"},state:{type:"string"},country:{type:"string"},postalCode:{type:"string"}}},ownershipType:{type:"string",enum:["fee_simple","leasehold","joint_tenancy","tenancy_in_common"]},titleNumber:{type:"string"},registeredDate:{type:"string",format:"date-time"},legalDescription:{type:"string"},encumbrances:{type:"array",items:{type:"object",properties:{type:{type:"string"},amount:{type:"number"},description:{type:"string"}}}}}},VehicleTitle:{title:"Vehicle Title",description:"Motor vehicle ownership title",type:"object",required:["vin","make","model","year"],properties:{vin:{type:"string",pattern:"^[A-HJ-NPR-Z0-9]{17}$",description:"Vehicle Identification Number"},make:{type:"string"},model:{type:"string"},year:{type:"integer",minimum:1900,maximum:2030},titleNumber:{type:"string"},registeredState:{type:"string"},mileage:{type:"integer",minimum:0},color:{type:"string"},fuelType:{type:"string",enum:["gasoline","diesel","electric","hybrid","other"]},liens:{type:"array",items:{type:"object",properties:{lienholderName:{type:"string"},lienAmount:{type:"number"},lienDate:{type:"string",format:"date"}}}}}},PromissoryNote:{title:"Promissory Note",description:"Legal promise to pay a specified amount",type:"object",required:["principal","interestRate","maturityDate","borrower","lender"],properties:{principalAmount:{type:"number",minimum:0,description:"Principal amount in base currency units"},currency:{type:"string",default:"USD"},interestRate:{type:"number",minimum:0,maximum:100,description:"Annual interest rate percentage"},maturityDate:{type:"string",format:"date",description:"Date when principal and interest are due"},payee:{type:"string",description:"DID of the payee (creditor)"},payor:{type:"string",description:"DID of the payor (debtor)"},paymentSchedule:{type:"string",enum:["lump_sum","monthly","quarterly","annually"]},collateral:{type:"array",items:{type:"object",properties:{description:{type:"string"},value:{type:"number"},type:{type:"string"}}}},defaultProvisions:{type:"string"},governingLaw:{type:"string"}}},IntellectualProperty:{title:"Intellectual Property",description:"Intellectual property rights and licensing",type:"object",required:["ipType","title","registrationNumber"],properties:{ipType:{type:"string",enum:["patent","trademark","copyright","trade_secret"]},title:{type:"string"},creator:{type:"string",description:"Creator DID"},registrationNumber:{type:"string"},registrationDate:{type:"string",format:"date"},expirationDate:{type:"string",format:"date"},jurisdiction:{type:"string"},description:{type:"string"},claims:{type:"array",items:{type:"string"}},priorArt:{type:"array",items:{type:"object",properties:{reference:{type:"string"},date:{type:"string",format:"date"},relevance:{type:"string"}}}}}},ProfessionalLicense:{title:"Professional License",description:"Professional practice license or certification",type:"object",required:["licenseType","licenseNumber","issuingAuthority","expirationDate"],properties:{licenseType:{type:"string"},licenseNumber:{type:"string"},issuingAuthority:{type:"string"},licensee:{type:"string",description:"Licensee DID"},issueDate:{type:"string",format:"date"},expirationDate:{type:"string",format:"date"},renewalDate:{type:"string",format:"date"},jurisdiction:{type:"string"},scope:{type:"string"},restrictions:{type:"array",items:{type:"string"}},continuing_education:{type:"object",properties:{hours_required:{type:"integer"},deadline:{type:"string",format:"date"},completed_hours:{type:"integer"}}}}},MusicLicense:{title:"Music License",description:"Music performance and usage licensing",type:"object",required:["songTitle","artist","licenseType","royaltyRate"],properties:{workTitle:{type:"string"},composer:{type:"string",description:"Composer DID"},performer:{type:"string",description:"Performer DID"},licenseType:{type:"string",enum:["mechanical","performance","synchronization","master_use"]},territory:{type:"string"},duration:{type:"string"},royaltyRate:{type:"number",minimum:0,maximum:100},advancePayment:{type:"number",minimum:0},exclusivity:{type:"boolean"},mediaTypes:{type:"array",items:{type:"string",enum:["cd","vinyl","digital","streaming","broadcast","film","tv"]}},usage_restrictions:{type:"string"},copyrightNotice:{type:"string"}}}},IC={prepareClaimValidation:function(e,t){try{lr.checkArgument(e&&typeof e=="object","Invalid claim"),lr.checkArgument(typeof t=="string","Schema name must be string");var r=uo[t];if(!r)return{success:!1,error:"Unknown schema: "+t};var n=[],i=[];this._validateObject(e,r,"",n,i);var o={valid:n.length===0,errors:n,warnings:i,schema:t,claimHash:ds.sha256(d.Buffer.from(this._canonicalizeWith(e,this.CANONICALIZATION.LEGACY))).toString("hex"),canonical:this._canonicalizeWith(e,this.CANONICALIZATION.LEGACY)};return{success:!0,validation:o,claim:e,schema:r,externalOperations:{store:{endpoint:"POST /claims/validate",data:{claim:e,validation:o,schema:t}},index:{endpoint:"POST /claims/index",data:{claimHash:o.claimHash,schemaName:t,valid:o.valid}}}}}catch(s){return{success:!1,error:"Validation preparation failed: "+s.message}}},prepareClaimAttestation:function(e,t,r){try{lr.checkArgument(e&&typeof e=="object","Invalid claim"),lr.checkArgument(typeof t=="string","Schema name must be string"),lr.checkArgument(r&&typeof r=="object","Invalid attestor");var n=this.prepareClaimValidation(e,t);if(!n.success||!n.validation.valid)return{success:!1,error:"Cannot attest invalid claim",validation:n};var i={type:"LTP_CLAIM_ATTESTATION",claimHash:n.validation.claimHash,schemaName:t,attestor:{did:r.did||r.id,name:r.name||"Unknown",authority:r.authority||null,jurisdiction:r.jurisdiction||null},attestedAt:new Date().toISOString(),confidence:r.confidence||100,evidence:r.evidence||null,notes:r.notes||null},o=ds.sha256(d.Buffer.from(this._canonicalizeWith(i,this.CANONICALIZATION.LEGACY))).toString("hex");return i.attestationHash=o,{success:!0,attestation:i,claim:e,validation:n.validation,externalOperations:{storeAttestation:{endpoint:"POST /claims/"+n.validation.claimHash+"/attestations",data:i},notifyStakeholders:{endpoint:"POST /notifications/claim-attested",data:{claimHash:n.validation.claimHash,attestorDid:i.attestor.did,attestationHash:o}}}}}catch(s){return{success:!1,error:"Attestation preparation failed: "+s.message}}},prepareClaimDispute:function(e,t,r){try{lr.checkArgument(typeof e=="string","Claim hash must be string"),lr.checkArgument(t&&typeof t=="object","Invalid disputant"),lr.checkArgument(r&&typeof r=="object","Invalid dispute");var n={type:"LTP_CLAIM_DISPUTE",claimHash:e,disputant:{did:t.did||t.id,name:t.name||"Unknown",jurisdiction:t.jurisdiction||null},dispute:{reason:r.reason||"UNSPECIFIED",category:r.category||"ACCURACY",description:r.description||"",evidence:r.evidence||null,requestedAction:r.requestedAction||"REVIEW"},disputedAt:new Date().toISOString(),status:"FILED",priority:r.priority||"NORMAL"},i=ds.sha256(d.Buffer.from(this._canonicalizeWith(n,this.CANONICALIZATION.LEGACY))).toString("hex");return n.disputeHash=i,{success:!0,dispute:n,disputeId:this._generateDisputeId(e),externalOperations:{fileDispute:{endpoint:"POST /claims/"+e+"/disputes",data:n},notifyStakeholders:{endpoint:"POST /notifications/claim-disputed",data:{claimHash:e,disputantDid:n.disputant.did,disputeHash:i}},escalate:{endpoint:"POST /disputes/escalate",data:{disputeHash:i,priority:n.priority}}}}}catch(o){return{success:!1,error:"Dispute preparation failed: "+o.message}}},prepareBulkClaimValidation:function(e,t){try{lr.checkArgument(Array.isArray(e),"Claims must be array"),lr.checkArgument(typeof t=="string","Schema name must be string");var r=[],n=[],i=0;e.forEach(function(a,f){try{var l=this.prepareClaimValidation(a,t);l.success&&l.validation.valid&&i++,r.push({index:f,result:l})}catch(y){n.push({index:f,error:y.message})}}.bind(this));var o=this._generateBatchId(),s=ds.sha256(d.Buffer.from(JSON.stringify(r.map(a=>a.result.validation.claimHash)))).toString("hex");return{success:!0,batchId:o,batchHash:s,totalClaims:e.length,validClaims:i,invalidClaims:e.length-i,validations:r,errors:n,externalOperations:{storeBatch:{endpoint:"POST /claims/batch-validate",data:{batchId:o,batchHash:s,schemaName:t,validations:r}},generateReport:{endpoint:"POST /reports/bulk-validation",data:{batchId:o,summary:{total:e.length,valid:i,invalid:e.length-i}}}}}}catch(a){return{success:!1,error:"Bulk validation preparation failed: "+a.message}}},CANONICALIZATION:{JCS:"jcs",LEGACY:"legacy"},canonicalize:function(e,t){return this._canonicalizeWith(e,this._resolveCanonicalization(t,"LTP.Claim.canonicalize"))},hash:function(e,t){var r=this._canonicalizeWith(e,this._resolveCanonicalization(t,"LTP.Claim.hash"));return ds.sha256(d.Buffer.from(r)).toString("hex")},_canonicalizeWith:function(e,t){if(lr.checkArgument(e&&typeof e=="object","Invalid claim"),t===this.CANONICALIZATION.JCS)return EC.stringify(e);var r=this._sortObjectKeys(e);return JSON.stringify(r)},_resolveCanonicalization:function(e,t){return e===void 0?(xC({what:t+"() without a canonicalization argument",since:"9.2.0",removeIn:"10.0.0",use:t+"(claim, bsv.LTP.Claim.CANONICALIZATION.JCS)",why:"the default sorted-key form is not RFC 8785, so other implementations compute a different claim hash"}),this.CANONICALIZATION.LEGACY):(lr.checkArgument(e===this.CANONICALIZATION.JCS||e===this.CANONICALIZATION.LEGACY,"Unknown canonicalization: "+e+". Expected 'jcs' or 'legacy' (bsv.LTP.Claim.CANONICALIZATION)"),e)},prepareClaimTemplate:function(e,t){t=t||{};try{var r=uo[e];if(!r)return{success:!1,error:"Unknown schema: "+e};var n=this._createTemplateFromSchema(r),i=this._generateFormStructure(r);return{success:!0,schemaName:e,template:n,schema:r,formStructure:i,validation:{required:r.required||[],patterns:this._extractPatterns(r),enums:this._extractEnums(r)},externalOperations:{generateForm:{endpoint:"POST /forms/generate",data:{schemaName:e,formStructure:i,template:n}},saveTemplate:{endpoint:"POST /templates/claim",data:{schemaName:e,template:n,customizations:t.customizations||{}}}}}}catch(o){return{success:!1,error:"Template preparation failed: "+o.message}}},getSchemas:function(){return uo},getSchemaNames:function(){return Object.keys(uo)},getSchema:function(e){return uo[e]||null},addSchema:function(e,t){lr.checkArgument(typeof e=="string","Schema name must be string"),lr.checkArgument(t&&typeof t=="object","Invalid schema"),uo[e]=t},createTemplate:function(e){var t=uo[e];if(!t)throw new Error("Unknown schema: "+e);return this._createTemplateFromSchema(t)},_generateDisputeId:function(e){var t="dispute_"+e+"_"+Date.now();return ds.sha256(d.Buffer.from(t)).toString("hex").substring(0,16)},_generateBatchId:function(){return wC.randomHex(16)},_generateFormStructure:function(e){var t={type:"form",title:e.title||"Legal Claim Form",description:e.description||"",fields:[]};return e.properties&&Object.keys(e.properties).forEach(function(r){var n=e.properties[r],i={name:r,label:this._humanizeFieldName(r),type:this._mapSchemaTypeToFormType(n),required:e.required&&e.required.includes(r),validation:this._extractFieldValidation(n)};n.enum&&(i.options=n.enum.map(function(o){return{value:o,label:this._humanizeValue(o)}}.bind(this))),t.fields.push(i)}.bind(this)),t},_extractPatterns:function(e){var t={};return e.properties&&Object.keys(e.properties).forEach(function(r){var n=e.properties[r];n.pattern&&(t[r]=n.pattern)}),t},_extractEnums:function(e){var t={};return e.properties&&Object.keys(e.properties).forEach(function(r){var n=e.properties[r];n.enum&&(t[r]=n.enum)}),t},_mapSchemaTypeToFormType:function(e){switch(e.type){case"string":return e.enum?"select":e.format==="date"?"date":e.format==="date-time"?"datetime":"text";case"number":case"integer":return"number";case"boolean":return"checkbox";case"array":return"list";case"object":return"fieldset";default:return"text"}},_extractFieldValidation:function(e){var t={};return e.pattern&&(t.pattern=e.pattern),e.minimum!==void 0&&(t.min=e.minimum),e.maximum!==void 0&&(t.max=e.maximum),e.format&&(t.format=e.format),t},_humanizeFieldName:function(e){return e.replace(/([A-Z])/g," $1").replace(/^./,function(t){return t.toUpperCase()}).replace(/_/g," ")},_humanizeValue:function(e){return e.replace(/_/g," ").replace(/\b\w/g,function(t){return t.toUpperCase()})},_validateObject:function(e,t,r,n,i){t.type==="object"?(t.required&&Array.isArray(t.required)&&t.required.forEach(function(o){e.hasOwnProperty(o)||n.push("Missing required field: "+this._getFieldPath(r,o))}.bind(this)),t.properties&&Object.keys(e).forEach(function(o){var s=this._getFieldPath(r,o),a=t.properties[o];a?this._validateValue(e[o],a,s,n,i):i.push("Unknown field: "+s)}.bind(this))):this._validateValue(e,t,r,n,i)},_validateValue:function(e,t,r,n,i){if(t.type){var o=Array.isArray(e)?"array":typeof e;if(o!==t.type){n.push("Invalid type for "+r+": expected "+t.type+", got "+o);return}}if(t.type==="string"&&(t.pattern&&!new RegExp(t.pattern).test(e)&&n.push("Value does not match pattern for "+r),t.enum&&!t.enum.includes(e)&&n.push("Invalid enum value for "+r+": "+e),t.format==="date"&&!this._isValidDate(e)&&n.push("Invalid date format for "+r),t.format==="date-time"&&!this._isValidDateTime(e)&&n.push("Invalid date-time format for "+r)),(t.type==="number"||t.type==="integer")&&(t.minimum!==void 0&&e<t.minimum&&n.push("Value below minimum for "+r+": "+e+" < "+t.minimum),t.maximum!==void 0&&e>t.maximum&&n.push("Value above maximum for "+r+": "+e+" > "+t.maximum),t.type==="integer"&&!Number.isInteger(e)&&n.push("Value must be integer for "+r)),t.type==="array"&&t.items)for(var s=0;s<e.length;s++)this._validateValue(e[s],t.items,r+"["+s+"]",n,i);t.type==="object"&&this._validateObject(e,t,r,n,i)},_sortObjectKeys:function(e){if(Array.isArray(e))return e.map(this._sortObjectKeys.bind(this));if(e!==null&&typeof e=="object"){var t={};return Object.keys(e).sort().forEach(function(r){t[r]=this._sortObjectKeys(e[r])}.bind(this)),t}return e},_createTemplateFromSchema:function(e){if(e.type==="object"){var t={};return e.properties&&Object.keys(e.properties).forEach(function(r){var n=e.properties[r];t[r]=this._getDefaultValue(n)}.bind(this)),t}return this._getDefaultValue(e)},_getDefaultValue:function(e){if(e.default!==void 0)return e.default;switch(e.type){case"string":return e.enum?e.enum[0]:e.format==="date"?"2023-01-01":e.format==="date-time"?new Date().toISOString():"PLACEHOLDER_STRING";case"number":case"integer":return e.minimum||0;case"boolean":return!1;case"array":return[];case"object":return this._createTemplateFromSchema(e);default:return null}},_getFieldPath:function(e,t){return e?e+"."+t:t},_isValidDate:function(e){var t=new Date(e);return!isNaN(t.getTime())&&e.match(/^\d{4}-\d{2}-\d{2}$/)},_isValidDateTime:function(e){var t=new Date(e);return!isNaN(t.getTime())}};Jx.exports=IC});var tI=B((kq,eI)=>{"use strict";p();var $a=er(),ps=Fe(),AC={prepareTokenCommitment:function(e,t){t=t||{},ps.checkArgument(e&&typeof e=="object","Invalid token");try{var r=this._createCommitment(e,t),n=this._formatOpReturn(r,t),i=this._createTxTemplate(n,t);return{success:!0,commitment:r,opReturnData:n,txTemplate:i,preparedAt:new Date().toISOString(),metadata:{tokenId:e.id,purpose:t.purpose||"legal_token_anchor",version:"LTP.v1"}}}catch(o){return{success:!1,error:o.message}}},prepareBatchCommitment:function(e,t){t=t||{},ps.checkArgument(Array.isArray(e),"Tokens must be array");try{var r=this._createBatchCommitment(e,t),n=this._formatOpReturn(r,t),i=this._createTxTemplate(n,t);return{success:!0,batchCommitment:r,opReturnData:n,txTemplate:i,tokenCount:e.length,preparedAt:new Date().toISOString(),metadata:{purpose:t.purpose||"legal_token_batch_anchor",version:"LTP.v1"}}}catch(o){return{success:!1,error:o.message}}},verifyTokenAnchor:function(e,t,r){ps.checkArgument(e&&typeof e=="object","Invalid token"),ps.checkArgument(typeof t=="string","Transaction ID must be string");try{var n=this._createCommitment(e,{}),i=this._extractOpReturn(r);if(!i)return{valid:!1,error:"No OP_RETURN data found in transaction"};var o=this._verifyCommitment(n,i);return{valid:o,chainVerified:!1,txid:t,commitment:n,anchorData:i,verifiedAt:new Date().toISOString()}}catch(s){return{valid:!1,error:s.message}}},formatRevocation:function(e,t){ps.checkArgument(typeof e=="string","Token ID must be string"),ps.checkArgument(t&&typeof t=="object","Invalid revocation data");try{var r={type:"LTP_REVOCATION",tokenId:e,reason:t.reason||"UNSPECIFIED",revokedBy:t.revokedBy||"UNKNOWN",revokedAt:new Date().toISOString(),effectiveDate:t.effectiveDate||new Date().toISOString(),legalBasis:t.legalBasis||null,evidence:t.evidence||null},n=$a.sha256(d.Buffer.from(JSON.stringify(r))).toString("hex");return{success:!0,revocation:r,revocationHash:n,opReturnData:this._formatOpReturn({hash:n,type:"REVOCATION"},{})}}catch(i){return{success:!1,error:i.message}}},_createCommitment:function(e,t){var r=this._canonicalizeToken(e),n={type:"LTP_TOKEN",tokenHash:$a.sha256(d.Buffer.from(r)).toString("hex"),tokenId:e.id,timestamp:new Date().toISOString(),purpose:t.purpose||"legal_token"},i=$a.sha256(d.Buffer.from(JSON.stringify(n))).toString("hex");return{hash:i,data:n,canonical:r}},_createBatchCommitment:function(e,t){var r=[],n=[];e.forEach(function(a){var f=this._createCommitment(a,t);r.push(f.hash),n.push(a.id)}.bind(this));var i=this._createMerkleRoot(r),o={type:"LTP_BATCH",merkleRoot:i,tokenCount:e.length,tokenIds:n,timestamp:new Date().toISOString(),purpose:t.purpose||"batch_anchor"},s=$a.sha256(d.Buffer.from(JSON.stringify(o))).toString("hex");return{hash:s,data:o,merkleRoot:i,tokenHashes:r}},_formatOpReturn:function(e,t){var r=t.prefix||"LTP.v1",n=e.hash;return{prefix:r,data:n,full:r+"."+n,bytes:d.Buffer.from(r+"."+n,"utf8"),size:d.Buffer.from(r+"."+n,"utf8").length}},_createTxTemplate:function(e,t){try{var r={version:1,inputs:[],outputs:[{satoshis:0,script:"OP_RETURN "+e.data}],locktime:0};return t.feeOutput&&r.outputs.push(t.feeOutput),{template:r,opReturn:e,estimatedSize:this._estimateSize(r),instructions:{step1:"Add input UTXOs to cover fees",step2:"Add change output if needed",step3:"Sign transaction with appropriate keys",step4:"Broadcast to BSV network"}}}catch(n){throw new Error("Failed to create transaction template: "+n.message)}},_extractOpReturn:function(e){try{if(!e||!e.outputs)return null;for(var t=0;t<e.outputs.length;t++){var r=e.outputs[t];if(r.script&&r.script.startsWith("OP_RETURN")){var n=r.script.replace("OP_RETURN ","");return{raw:n,decoded:d.Buffer.from(n,"hex").toString("utf8")}}}return null}catch{return null}},_verifyCommitment:function(e,t){try{return!t||!t.decoded?!1:t.decoded.includes(e.hash)}catch{return!1}},_canonicalizeToken:function(e){var t=JSON.parse(JSON.stringify(e));return delete t.proof,delete t.tokenHash,delete t.anchorTx,delete t.anchorBlock,JSON.stringify(this._sortObjectKeys(t))},_createMerkleRoot:function(e){if(e.length===0)return null;if(e.length===1)return e[0];for(var t=e.slice();t.length>1;){for(var r=[],n=0;n<t.length;n+=2){var i=t[n],o=t[n+1]||i,s=d.Buffer.concat([d.Buffer.from(i,"hex"),d.Buffer.from(o,"hex")]),a=$a.sha256(s).toString("hex");r.push(a)}t=r}return t[0]},_estimateSize:function(e){var t=10,r=e.outputs.length*34,n=148;return{base:t+r,withOneInput:t+r+n,bytesPerInput:n}},_sortObjectKeys:function(e){if(Array.isArray(e))return e.map(this._sortObjectKeys.bind(this));if(e!==null&&typeof e=="object"){var t={};return Object.keys(e).sort().forEach(function(r){t[r]=this._sortObjectKeys(e[r])}.bind(this)),t}return e}};eI.exports=AC});var iI=B((Lq,nI)=>{"use strict";p();var OC=Or(),Wr=er(),rI=Ua(),RC=or(),TC=oo(),sr=Fe(),PC={prepareSignatureProof:function(e,t,r){r=r||{},sr.checkArgument(e&&typeof e=="object","Invalid token"),sr.checkArgument(t instanceof TC,"Invalid private key");try{var n=this._canonicalizeForSigning(e),i=Wr.sha256(d.Buffer.from(n)),o=new rI;o.hashbuf=i,o.privkey=t,o.pubkey=t.toPublicKey(),o.sign();var s=o.sig,a={type:"EcdsaSecp256k1Signature2019",created:new Date().toISOString(),verificationMethod:"did:smartledger:"+t.toPublicKey().toString()+"#keys-1",proofPurpose:r.purpose||"assertionMethod",jws:this._createJWS(i,s),proofValue:s.toDER().toString("hex")};return{success:!0,proof:a,tokenHash:i.toString("hex"),canonical:n,signingKey:{publicKey:t.toPublicKey().toString(),keyId:"did:smartledger:"+t.toPublicKey().toString()+"#keys-1"},externalOperations:{storeProof:{endpoint:"POST /proofs/signature",data:{tokenHash:i.toString("hex"),proof:a,signingKey:t.toPublicKey().toString()}},verifyProof:{endpoint:"POST /proofs/verify-signature",data:{tokenHash:i.toString("hex"),signature:s.toDER().toString("hex"),publicKey:t.toPublicKey().toString()}}}}}catch(f){return{success:!1,error:f.message}}},prepareSignatureVerification:function(e,t){try{if(sr.checkArgument(e&&typeof e=="object","Invalid token"),sr.checkArgument(typeof t=="string","Public key must be string"),!e.proof)return{success:!1,error:"No proof found in token"};var r=this._canonicalizeForSigning(e),n=Wr.sha256(d.Buffer.from(r)),i=RC.fromDER(d.Buffer.from(e.proof.proofValue,"hex")),o={tokenHash:n.toString("hex"),signature:i.toDER().toString("hex"),publicKey:t,proof:e.proof,canonical:r},s=new rI;s.hashbuf=n,s.sig=i,s.pubkey=OC.fromString(t);var a=s.verify()===!0;return{success:!0,verification:{valid:a,tokenHash:n.toString("hex"),signatureValid:a,publicKey:t,verifiedAt:new Date().toISOString()},verificationData:o,externalOperations:{recordVerification:{endpoint:"POST /proofs/verification-record",data:{tokenHash:n.toString("hex"),result:a,publicKey:t,verifiedAt:new Date().toISOString()}},auditVerification:{endpoint:"POST /audit/proof-verification",data:{tokenId:e.id,proofType:e.proof.type,result:a,verifier:t}}}}}catch(f){return{success:!1,error:f.message}}},prepareSelectiveDisclosure:function(e,t,r){sr.checkArgument(e&&typeof e=="object","Invalid token"),sr.checkArgument(Array.isArray(t),"Revealed fields must be array"),sr.checkArgument(typeof r=="string","Nonce must be string");try{var n=this._createFieldCommitments(e,r),i=this._createMerkleTree(n),o=[],s=[];t.forEach(function(f){var l=this._getNestedValue(e,f),y=this._findFieldCommitment(n,f);if(y){o.push({path:f,value:l,commitment:y.hash,salt:y.salt});var g=this._generateMerkleProof(i,y.index);s.push({path:f,leafIndex:y.index,proof:g})}}.bind(this));var a={type:"LegalTokenSelectiveDisclosure",created:new Date().toISOString(),proofPurpose:"selectiveDisclosure",verificationMethod:e.proof?e.proof.verificationMethod:null,nonce:r,merkleRoot:i.root,disclosures:o,merkleProofs:s,totalFields:n.length};return{success:!0,proof:a,hiddenFieldCount:n.length-o.length,revealedFieldCount:o.length,externalOperations:{storeDisclosure:{endpoint:"POST /proofs/selective-disclosure",data:{tokenId:e.id,proof:a,merkleRoot:i.root}},verifyDisclosure:{endpoint:"POST /proofs/verify-disclosure",data:{proof:a,expectedNonce:r}},auditDisclosure:{endpoint:"POST /audit/selective-disclosure",data:{tokenId:e.id,revealedFields:t,totalFields:n.length,disclosedAt:new Date().toISOString()}}}}}catch(f){return{success:!1,error:f.message}}},prepareSelectiveDisclosureVerification:function(e,t){try{if(sr.checkArgument(e&&typeof e=="object","Invalid proof"),sr.checkArgument(typeof t=="string","Expected nonce must be string"),e.nonce!==t)return{success:!1,error:"Nonce mismatch"};var r=[],n=[];e.disclosures.forEach(function(o,s){var a=e.merkleProofs[s],f=this._hashField(o.path,o.value,o.salt);if(f!==o.commitment){n.push("Invalid commitment for field: "+o.path);return}var l=this._verifyMerkleProof(o.commitment,a.leafIndex,a.proof,e.merkleRoot);l?r.push({path:o.path,value:o.value,verified:!0}):n.push("Invalid Merkle proof for field: "+o.path)}.bind(this));var i={valid:n.length===0,errors:n,disclosures:r,merkleRoot:e.merkleRoot,totalFields:e.totalFields,verifiedAt:new Date().toISOString()};return{success:!0,verification:i,externalOperations:{recordVerification:{endpoint:"POST /proofs/disclosure-verification",data:{proofId:e.id||"unknown",result:i.valid,verifiedFields:r.length,totalFields:e.totalFields,verifiedAt:i.verifiedAt}},auditVerification:{endpoint:"POST /audit/disclosure-verification",data:{merkleRoot:e.merkleRoot,disclosuresVerified:r.length,errors:n.length,result:i.valid}}}}}catch(o){return{success:!1,error:o.message}}},prepareLegalValidityProof:function(e,t,r){sr.checkArgument(e&&typeof e=="object","Invalid token"),sr.checkArgument(t&&typeof t=="object","Invalid jurisdiction"),sr.checkArgument(typeof r=="string","Nonce must be string");try{var n=t.requirements||[],i=[],o=!0;n.forEach(function(a){var f=this._checkLegalRequirement(e,a);i.push(f),f.satisfied||(o=!1)}.bind(this));var s={type:"LegalValidityProof",created:new Date().toISOString(),proofPurpose:"legalValidity",jurisdiction:t.code,nonce:r,valid:o,checks:i,complianceHash:this._hashCompliance(e,t,r)};return{success:!0,proof:s,valid:o,complianceReport:{jurisdiction:t.code,totalRequirements:n.length,satisfiedRequirements:i.filter(a=>a.satisfied).length,failedRequirements:i.filter(a=>!a.satisfied).length,overallCompliance:o},externalOperations:{submitCompliance:{endpoint:"POST /compliance/legal-validity",data:{tokenId:e.id,jurisdiction:t.code,proof:s,complianceReport:{jurisdiction:t.code,totalRequirements:n.length,satisfiedRequirements:i.filter(a=>a.satisfied).length,failedRequirements:i.filter(a=>!a.satisfied).length,overallCompliance:o}}},auditCompliance:{endpoint:"POST /audit/compliance-check",data:{tokenId:e.id,jurisdiction:t.code,result:o,checkedAt:new Date().toISOString(),requirements:i}},notifyRegulator:o?null:{endpoint:"POST /notifications/compliance-failure",data:{tokenId:e.id,jurisdiction:t.code,failedRequirements:i.filter(a=>!a.satisfied)}}}}}catch(a){return{success:!1,error:a.message}}},prepareZeroKnowledgeProof:function(e,t,r){sr.checkArgument(e&&typeof e=="object","Invalid token"),sr.checkArgument(t&&typeof t=="object","Invalid statement"),sr.checkArgument(typeof r=="string","Nonce must be string");try{var n=Wr.sha256(d.Buffer.from(this._canonicalizeForSigning(e)+r)).toString("hex"),i={type:"LegalTokenZKProof",created:new Date().toISOString(),proofPurpose:"zeroKnowledge",statement:{claim:t.claim||"UNSPECIFIED",predicate:t.predicate||"SATISFIES",threshold:t.threshold||null},commitment:n,nonce:r,proofData:this._generateZKProofData(e,t,r)};return{success:!0,proof:i,commitment:n,externalOperations:{storeZKProof:{endpoint:"POST /proofs/zero-knowledge",data:{tokenId:e.id,proof:i,statement:t}},verifyZKProof:{endpoint:"POST /proofs/verify-zk",data:{proof:i,expectedNonce:r}},auditZKProof:{endpoint:"POST /audit/zk-proof",data:{tokenId:e.id,statement:t.claim,proofGenerated:new Date().toISOString()}}}}}catch(o){return{success:!1,error:o.message}}},_generateZKProofData:function(e,t,r){var n={challenge:Wr.sha256(d.Buffer.from(t.claim+r)).toString("hex"),response:Wr.sha256(d.Buffer.from(this._canonicalizeForSigning(e)+t.claim)).toString("hex"),witness:Wr.sha256(d.Buffer.from(r+e.id+t.predicate)).toString("hex")};return n},_createJWS:function(e,t){var r={alg:"ES256K",typ:"JWT"},n=d.Buffer.from(JSON.stringify(r)).toString("base64url"),i=e.toString("base64url"),o=t.toDER().toString("base64url");return n+".."+o},_canonicalizeForSigning:function(e){var t=JSON.parse(JSON.stringify(e));delete t.proof,delete t.tokenHash;var r=this._sortObjectKeys(t);return JSON.stringify(r)},_createFieldCommitments:function(e,t){var r=[],n=0;return this._traverseObject(e,"",function(i,o){if(i!=="proof"&&i!=="tokenHash"){var s=Wr.sha256(d.Buffer.from(t+i+n)).toString("hex"),a=this._hashField(i,o,s);r.push({path:i,value:o,salt:s,hash:a,index:n}),n++}}.bind(this)),r},_hashField:function(e,t,r){var n=e+":"+JSON.stringify(t)+":"+r;return Wr.sha256(d.Buffer.from(n)).toString("hex")},_createMerkleTree:function(e){var t=e.map(function(y){return y.hash});if(t.length===0)return{root:null,levels:[]};for(var r=[t],n=t;n.length>1;){for(var i=[],o=0;o<n.length;o+=2){var s=n[o],a=n[o+1]||s,f=d.Buffer.concat([d.Buffer.from(s,"hex"),d.Buffer.from(a,"hex")]),l=Wr.sha256(f).toString("hex");i.push(l)}r.push(i),n=i}return{root:n[0],levels:r}},_generateMerkleProof:function(e,t){for(var r=[],n=t,i=0;i<e.levels.length-1;i++){var o=e.levels[i],s=n%2===0,a=s?n+1:n-1;a<o.length&&r.push({hash:o[a],isLeft:!s}),n=Math.floor(n/2)}return r},_verifyMerkleProof:function(e,t,r,n){for(var i=e,o=t,s=0;s<r.length;s++){var a=r[s],f=o%2===0,l;a.isLeft?l=d.Buffer.concat([d.Buffer.from(a.hash,"hex"),d.Buffer.from(i,"hex")]):l=d.Buffer.concat([d.Buffer.from(i,"hex"),d.Buffer.from(a.hash,"hex")]),i=Wr.sha256(l).toString("hex"),o=Math.floor(o/2)}return i===n},_traverseObject:function(e,t,r){Array.isArray(e)?e.forEach(function(n,i){var o=t+"["+i+"]";this._traverseObject(n,o,r)}.bind(this)):e!==null&&typeof e=="object"?Object.keys(e).forEach(function(n){var i=t?t+"."+n:n;this._traverseObject(e[n],i,r)}.bind(this)):r(t,e)},_getNestedValue:function(e,t){return t.split(".").reduce(function(r,n){return r&&r[n]},e)},_findFieldCommitment:function(e,t){return e.find(function(r){return r.path===t})},_checkLegalRequirement:function(e,t){switch(t.type){case"field_present":var r=this._getNestedValue(e,t.field);return{requirement:t.type,field:t.field,satisfied:r!=null};case"field_value":var r=this._getNestedValue(e,t.field);return{requirement:t.type,field:t.field,satisfied:r===t.expectedValue};case"temporal_validity":var n=new Date,i=new Date(e.issuanceDate);return{requirement:t.type,satisfied:i<=n};default:return{requirement:t.type,satisfied:!1,error:"Unknown requirement type"}}},_hashCompliance:function(e,t,r){var n={tokenId:e.id,jurisdiction:t.code,nonce:r,timestamp:new Date().toISOString()};return Wr.sha256(d.Buffer.from(JSON.stringify(n))).toString("hex")},_sortObjectKeys:function(e){if(Array.isArray(e))return e.map(this._sortObjectKeys.bind(this));if(e!==null&&typeof e=="object"){var t={};return Object.keys(e).sort().forEach(function(r){t[r]=this._sortObjectKeys(e[r])}.bind(this)),t}return e}};nI.exports=PC});var aI=B((qq,sI)=>{"use strict";p();var Za=er(),Uq=io(),Fq=Mp(),hr=Fe(),oI=za(),BC={prepareRegistry:function(e){e=e||{},hr.checkArgument(typeof e=="object","Config must be object");var t={id:e.id||this._generateRegistryId(),name:e.name||"Legal Token Registry",jurisdiction:e.jurisdiction||"GLOBAL",authority:e.authority||null,created:new Date().toISOString(),version:"1.0.0",config:{allowPublicRegistration:e.allowPublicRegistration||!1,requireApproval:e.requireApproval||!0,enableRevocation:e.enableRevocation!==!1,enableAuditTrail:e.enableAuditTrail!==!1,retentionPeriod:e.retentionPeriod||"7Y",complianceLevel:e.complianceLevel||"STANDARD"},dataStructure:{tokens:"Map<tokenId, registrationRecord>",revocations:"Map<tokenId, revocationRecord>",auditLog:"Array<auditEntry>",statistics:{totalTokens:0,activeTokens:0,revokedTokens:0,registrations:0}},externalStorage:{required:!0,type:"database_or_blockchain",endpoints:{store:"POST /registry/{id}/tokens",retrieve:"GET /registry/{id}/tokens/{tokenId}",search:"GET /registry/{id}/search",revoke:"POST /registry/{id}/revocations"}}},r=this._prepareAuditEntry({action:"REGISTRY_CREATED",actor:e.authority,timestamp:t.created,metadata:{jurisdiction:t.jurisdiction,config:t.config}});return{success:!0,registry:t,initialAudit:r,instructions:{step1:"Store registry configuration in external system",step2:"Initialize token storage with provided data structure",step3:"Set up audit logging with provided templates",step4:"Configure external endpoints for registry operations"}}},prepareTokenRegistration:function(e,t,r){r=r||{},hr.checkArgument(e&&typeof e=="object","Invalid token"),hr.checkArgument(t&&typeof t=="object","Invalid registry config");try{var n=this._validateTokenForRegistration(e,t);if(!n.valid)return{success:!1,error:"Token validation failed: "+n.error};var i={tokenId:e.id,tokenHash:this._hashToken(e),token:e,status:t.requireApproval?"PENDING":"ACTIVE",registeredBy:r.registeredBy||"UNKNOWN",registeredAt:new Date().toISOString(),approvedBy:null,approvedAt:null,metadata:r.metadata||{},compliance:{jurisdiction:e.jurisdiction||t.jurisdiction,level:this._calculateComplianceLevel(e),checks:n.checks||[]}},o=this._prepareAuditEntry({action:"TOKEN_REGISTERED",actor:r.registeredBy,tokenId:e.id,timestamp:i.registeredAt,metadata:{status:i.status,tokenType:e.type,compliance:i.compliance}});return{success:!0,registrationRecord:i,auditEntry:o,registrationId:this._generateRegistrationId(e.id),validation:n,externalOperations:{store:{endpoint:"POST /registry/"+t.id+"/tokens",data:i},audit:{endpoint:"POST /registry/"+t.id+"/audit",data:o}}}}catch(s){return{success:!1,error:s.message}}},prepareTokenApproval:function(e,t,r){try{hr.checkArgument(typeof e=="string","Token ID must be string"),hr.checkArgument(typeof t=="string","Approver must be string"),hr.checkArgument(r&&typeof r=="object","Invalid registry config");var n={tokenId:e,status:"ACTIVE",approvedBy:t,approvedAt:new Date().toISOString()},i=this._prepareAuditEntry({action:"TOKEN_APPROVED",actor:t,tokenId:e,timestamp:n.approvedAt});return{success:!0,approvalData:n,auditEntry:i,externalOperations:{update:{endpoint:"PUT /registry/"+r.id+"/tokens/"+e+"/status",data:n},audit:{endpoint:"POST /registry/"+r.id+"/audit",data:i}}}}catch(o){return{success:!1,error:o.message}}},prepareTokenRevocation:function(e,t,r){try{if(hr.checkArgument(typeof e=="string","Token ID must be string"),hr.checkArgument(t&&typeof t=="object","Invalid revocation"),hr.checkArgument(r&&typeof r=="object","Invalid registry config"),!r.enableRevocation)return{success:!1,error:"Revocation is disabled for this registry"};var n={tokenId:e,reason:t.reason||"UNSPECIFIED",revokedBy:t.revokedBy||"UNKNOWN",revokedAt:new Date().toISOString(),effectiveDate:t.effectiveDate||new Date().toISOString(),legalBasis:t.legalBasis||null,evidence:t.evidence||null,revocationHash:this._generateRevocationHash(e,t)},i={tokenId:e,status:"REVOKED",revokedAt:n.revokedAt,revocationReason:n.reason},o=this._prepareAuditEntry({action:"TOKEN_REVOKED",actor:t.revokedBy,tokenId:e,timestamp:n.revokedAt,metadata:{reason:n.reason,legalBasis:n.legalBasis}});return{success:!0,revocationRecord:n,statusUpdate:i,auditEntry:o,revocationId:this._generateRevocationId(e),externalOperations:{storeRevocation:{endpoint:"POST /registry/"+r.id+"/revocations",data:n},updateStatus:{endpoint:"PUT /registry/"+r.id+"/tokens/"+e+"/status",data:i},audit:{endpoint:"POST /registry/"+r.id+"/audit",data:o}}}}catch(s){return{success:!1,error:s.message}}},prepareTokenStatusQuery:function(e,t){try{return hr.checkArgument(typeof e=="string","Token ID must be string"),hr.checkArgument(t&&typeof t=="object","Invalid registry config"),{success:!0,query:{tokenId:e,registryId:t.id},externalOperations:{retrieve:{endpoint:"GET /registry/"+t.id+"/tokens/"+e,method:"GET"},checkRevocation:{endpoint:"GET /registry/"+t.id+"/revocations/"+e,method:"GET"}},expectedResponse:{found:"boolean",status:"string (PENDING|ACTIVE|REVOKED)",registeredAt:"ISO datetime",registeredBy:"string",approvedAt:"ISO datetime or null",approvedBy:"string or null",revokedAt:"ISO datetime or null",revocationReason:"string or null",compliance:"object",revocation:"object or null"}}}catch(r){return{success:!1,error:r.message}}},prepareTokenSearch:function(e,t){e=e||{};try{hr.checkArgument(t&&typeof t=="object","Invalid registry config");var r=[];e.status&&r.push("status="+encodeURIComponent(e.status)),e.type&&r.push("type="+encodeURIComponent(e.type)),e.registeredBy&&r.push("registeredBy="+encodeURIComponent(e.registeredBy)),e.jurisdiction&&r.push("jurisdiction="+encodeURIComponent(e.jurisdiction)),e.dateFrom&&r.push("dateFrom="+encodeURIComponent(e.dateFrom)),e.dateTo&&r.push("dateTo="+encodeURIComponent(e.dateTo)),e.includeTokens&&r.push("includeTokens=true"),e.sortBy&&r.push("sortBy="+encodeURIComponent(e.sortBy)),e.sortOrder&&r.push("sortOrder="+encodeURIComponent(e.sortOrder));var n=e.offset||0,i=e.limit||100;r.push("offset="+n),r.push("limit="+i);var o=r.length>0?"?"+r.join("&"):"";return{success:!0,searchCriteria:e,externalOperations:{search:{endpoint:"GET /registry/"+t.id+"/search"+o,method:"GET"}},expectedResponse:{success:"boolean",results:"Array<tokenRecord>",totalCount:"number",totalRegistrations:"number",offset:"number",limit:"number",hasMore:"boolean"}}}catch(s){return{success:!1,error:s.message}}},prepareStatisticsQuery:function(e){return hr.checkArgument(e&&typeof e=="object","Invalid registry config"),{success:!0,query:{registryId:e.id},externalOperations:{getStatistics:{endpoint:"GET /registry/"+e.id+"/statistics",method:"GET"}},expectedResponse:{id:"string",name:"string",jurisdiction:"string",created:"ISO datetime",statistics:{totalTokens:"number",activeTokens:"number",revokedTokens:"number",registrations:"number"},auditEntries:"number",lastActivity:"ISO datetime"}}},prepareAuditLogQuery:function(e,t){if(t=t||{},hr.checkArgument(e&&typeof e=="object","Invalid registry config"),!e.enableAuditTrail)return{success:!1,error:"Audit trail is disabled"};var r=[];t.action&&r.push("action="+encodeURIComponent(t.action)),t.actor&&r.push("actor="+encodeURIComponent(t.actor)),t.tokenId&&r.push("tokenId="+encodeURIComponent(t.tokenId)),t.dateFrom&&r.push("dateFrom="+encodeURIComponent(t.dateFrom)),t.dateTo&&r.push("dateTo="+encodeURIComponent(t.dateTo));var n=t.offset||0,i=t.limit||100;r.push("offset="+n),r.push("limit="+i);var o=r.length>0?"?"+r.join("&"):"";return{success:!0,auditOptions:t,externalOperations:{getAuditLog:{endpoint:"GET /registry/"+e.id+"/audit"+o,method:"GET"}},expectedResponse:{success:"boolean",entries:"Array<auditEntry>",totalEntries:"number",offset:"number",limit:"number",hasMore:"boolean"}}},_generateRegistryId:function(){return"reg_"+oI.randomHex(16)},_generateRegistrationId:function(e){var t="reg_"+e+"_"+Date.now();return Za.sha256(d.Buffer.from(t)).toString("hex").substring(0,16)},_generateRevocationId:function(e){var t="rev_"+e+"_"+Date.now();return Za.sha256(d.Buffer.from(t)).toString("hex").substring(0,16)},_hashToken:function(e){var t=JSON.parse(JSON.stringify(e));return delete t.proof,delete t.tokenHash,Za.sha256(d.Buffer.from(JSON.stringify(t))).toString("hex")},_generateRevocationHash:function(e,t){var r=e+(t.reason||"")+(t.revokedBy||"")+Date.now();return Za.sha256(d.Buffer.from(r)).toString("hex")},_validateTokenForRegistration:function(e,t){var r=[],n=!0;return e.id?r.push({field:"id",valid:!0}):(r.push({field:"id",valid:!1,error:"Missing token ID"}),n=!1),e.type?r.push({field:"type",valid:!0}):(r.push({field:"type",valid:!1,error:"Missing token type"}),n=!1),e.issuanceDate?r.push({field:"issuanceDate",valid:!0}):(r.push({field:"issuanceDate",valid:!1,error:"Missing issuance date"}),n=!1),e.proof?r.push({field:"proof",valid:!0}):(r.push({field:"proof",valid:!1,error:"Missing cryptographic proof"}),n=!1),{valid:n,checks:r}},_calculateComplianceLevel:function(e){var t="BASIC";return e.proof&&e.proof.type&&(t="STANDARD"),e.jurisdiction&&e.legalBasis&&(t="ENHANCED"),e.attestations&&e.attestations.length>0&&(t="PREMIUM"),t},_prepareAuditEntry:function(e){var t={id:this._generateAuditId(),action:e.action,actor:e.actor||"SYSTEM",tokenId:e.tokenId||null,timestamp:e.timestamp||new Date().toISOString(),metadata:e.metadata||{},hash:this._generateAuditHash(e)};return t},_generateAuditId:function(){return"audit_"+oI.randomHex(32)},_generateAuditHash:function(e){var t=(e.action||"")+(e.actor||"")+(e.tokenId||"")+(e.timestamp||"");return Za.sha256(d.Buffer.from(t)).toString("hex").substring(0,16)}};sI.exports=BC});var lI=B((jq,cI)=>{"use strict";p();var $p=Or(),Zp=er(),uI=Ua(),NC=or(),fI=oo(),mr=Fe(),MC=za();function kC(e,t){if(t=t||{},t.issuerPublicKey)return t.issuerPublicKey instanceof $p?t.issuerPublicKey:$p.fromString(t.issuerPublicKey);var r=e&&e.issuer;if(typeof r!="string")return null;try{var n=r.split("#")[0].split(":")[2];return n?$p.fromString(n):null}catch{return null}}var Hc={CORRELATIVE_OBLIGATION:"CorrelativeObligation",CONTRACTUAL_OBLIGATION:"ContractualObligation",PAYMENT_OBLIGATION:"PaymentObligation",DELIVERY_OBLIGATION:"DeliveryObligation",PERFORMANCE_OBLIGATION:"PerformanceObligation",MAINTENANCE_OBLIGATION:"MaintenanceObligation",COMPLIANCE_OBLIGATION:"ComplianceObligation",REPORTING_OBLIGATION:"ReportingObligation",CONFIDENTIALITY_OBLIGATION:"ConfidentialityObligation",NON_COMPETE_OBLIGATION:"NonCompeteObligation",INDEMNIFICATION_OBLIGATION:"IndemnificationObligation",WARRANTY_OBLIGATION:"WarrantyObligation",SUPPORT_OBLIGATION:"SupportObligation",REGULATORY_OBLIGATION:"RegulatoryObligation",FIDUCIARY_OBLIGATION:"FiduciaryObligation"},gs={CRITICAL:"CRITICAL",HIGH:"HIGH",MEDIUM:"MEDIUM",LOW:"LOW",DEFERRED:"DEFERRED"},dr={PENDING:"PENDING",ACTIVE:"ACTIVE",IN_PROGRESS:"IN_PROGRESS",COMPLETED:"COMPLETED",OVERDUE:"OVERDUE",BREACHED:"BREACHED",WAIVED:"WAIVED",TERMINATED:"TERMINATED"},jc={prepareObligationToken:function(e,t,r,n,i,o){o=o||{},mr.checkArgument(typeof e=="string","Obligation type must be string"),mr.checkArgument(typeof t=="string","Issuer DID must be string"),mr.checkArgument(typeof r=="string","Obligor DID must be string"),mr.checkArgument(n&&typeof n=="object","Obligation must be object"),mr.checkArgument(i instanceof fI,"Invalid issuer private key");var s=Object.values(Hc);mr.checkArgument(s.includes(e),"Invalid obligation type: "+e);try{var a={"@context":["https://www.w3.org/2018/credentials/v1","https://smartledger.technology/contexts/ltp/v1"],id:"urn:uuid:"+this._generateUUID(),type:["VerifiableCredential","LegalObligationToken",e],issuer:t,issuanceDate:new Date().toISOString(),credentialSubject:{id:r,obligationType:e,obligation:n,jurisdiction:o.jurisdiction||"US",priority:o.priority||gs.MEDIUM,status:dr.PENDING,dueDate:o.dueDate||null,effectiveDate:o.effectiveDate||new Date().toISOString(),expirationDate:o.expirationDate||null,correlativeRight:o.correlativeRight||null,rightHolder:o.rightHolder||null,enforceable:o.enforceable!==!1,penalties:o.penalties||null,remedies:o.remedies||null}};o.metadata&&(a.credentialSubject.metadata=o.metadata);var f=this._signToken(a,i);return{success:!0,obligationToken:f,tokenHash:f.tokenHash,metadata:{type:e,issuer:t,obligor:r,priority:a.credentialSubject.priority,status:a.credentialSubject.status,jurisdiction:a.credentialSubject.jurisdiction,dueDate:a.credentialSubject.dueDate,correlativeRight:a.credentialSubject.correlativeRight},externalOperations:{storeToken:{endpoint:"POST /obligations/tokens",data:{token:f,metadata:{type:e,issuer:t,obligor:r,priority:a.credentialSubject.priority,status:a.credentialSubject.status,jurisdiction:a.credentialSubject.jurisdiction,dueDate:a.credentialSubject.dueDate,correlativeRight:a.credentialSubject.correlativeRight}}},indexToken:{endpoint:"POST /obligations/index",data:{tokenId:f.id,tokenHash:f.tokenHash,type:e,issuer:t,obligor:r,issuedAt:f.issuanceDate,dueDate:a.credentialSubject.dueDate,priority:a.credentialSubject.priority}},notifyObligor:{endpoint:"POST /notifications/obligation-issued",data:{tokenId:f.id,issuer:t,obligor:r,obligationType:e,dueDate:a.credentialSubject.dueDate,priority:a.credentialSubject.priority}},scheduleReminders:a.credentialSubject.dueDate?{endpoint:"POST /obligations/schedule-reminders",data:{tokenId:f.id,obligor:r,dueDate:a.credentialSubject.dueDate,reminderSchedule:o.reminderSchedule||["7d","3d","1d"]}}:null}}}catch(l){return{success:!1,error:l.message}}},prepareObligationVerification:function(e,t){t=t||{};try{var r=[],n=[];this._validateTokenStructure(e,r),this._verifyTokenSignature(e,r,t),this._validateTokenTemporal(e,r,n),this._validateObligationType(e,r),this._validateObligationStatus(e,r,n),this._validateObligationPriority(e,n);var i={valid:r.length===0,errors:r,warnings:n,issuerDID:e.issuer,obligorDID:e.credentialSubject?e.credentialSubject.id:null,obligationType:e.credentialSubject?e.credentialSubject.obligationType:null,status:e.credentialSubject?e.credentialSubject.status:null,priority:e.credentialSubject?e.credentialSubject.priority:null,isOverdue:this._checkIfOverdue(e),verifiedAt:new Date().toISOString()};return{success:!0,verification:i,externalOperations:{recordVerification:{endpoint:"POST /obligations/verification-record",data:{tokenId:e.id,result:i.valid,errors:r,warnings:n,verifiedAt:i.verifiedAt,isOverdue:i.isOverdue}},auditVerification:{endpoint:"POST /audit/obligation-verification",data:{tokenId:e.id,obligationType:i.obligationType,issuer:i.issuerDID,obligor:i.obligorDID,result:i.valid,verifiedAt:i.verifiedAt}},updateStatus:i.isOverdue&&e.credentialSubject.status===dr.ACTIVE?{endpoint:"PUT /obligations/tokens/"+e.id+"/status",data:{status:dr.OVERDUE,updatedAt:i.verifiedAt,reason:"Due date passed"}}:null}}}catch(o){return{success:!1,error:"Verification preparation failed: "+o.message}}},prepareObligationFulfillment:function(e,t,r,n){n=n||{},mr.checkArgument(e&&typeof e=="object","Invalid token"),mr.checkArgument(t&&typeof t=="object","Invalid fulfillment"),mr.checkArgument(r instanceof fI,"Invalid obligor key");try{var i=this.prepareObligationVerification(e,{});if(!i.success||!i.verification.valid)return{success:!1,error:"Cannot fulfill invalid obligation: "+i.verification.errors.join(", ")};if(e.credentialSubject.status===dr.COMPLETED)return{success:!1,error:"Obligation already fulfilled"};if(e.credentialSubject.status===dr.TERMINATED)return{success:!1,error:"Obligation has been terminated"};var o={"@context":["https://www.w3.org/2018/credentials/v1","https://smartledger.technology/contexts/ltp/v1"],id:"urn:uuid:"+this._generateUUID(),type:["VerifiableCredential","ObligationFulfillment"],issuer:e.credentialSubject.id,issuanceDate:new Date().toISOString(),credentialSubject:{id:e.id,fulfillmentType:t.type||"FULL_FULFILLMENT",fulfillmentDate:new Date().toISOString(),evidence:t.evidence||null,description:t.description||"",completionPercentage:t.completionPercentage||100,attestations:t.attestations||[],notes:t.notes||null}},s=this._signToken(o,r),a=o.credentialSubject.completionPercentage>=100?dr.COMPLETED:dr.IN_PROGRESS;return{success:!0,fulfillmentRecord:s,newStatus:a,fulfillmentId:s.id,externalOperations:{recordFulfillment:{endpoint:"POST /obligations/fulfillments",data:{obligationId:e.id,fulfillmentRecord:s,obligor:e.credentialSubject.id,fulfillmentDate:o.credentialSubject.fulfillmentDate,completionPercentage:o.credentialSubject.completionPercentage}},updateStatus:{endpoint:"PUT /obligations/tokens/"+e.id+"/status",data:{status:a,fulfillmentId:s.id,updatedAt:o.credentialSubject.fulfillmentDate,completionPercentage:o.credentialSubject.completionPercentage}},notifyRightHolder:e.credentialSubject.rightHolder?{endpoint:"POST /notifications/obligation-fulfilled",data:{obligationId:e.id,fulfillmentId:s.id,obligor:e.credentialSubject.id,rightHolder:e.credentialSubject.rightHolder,completionPercentage:o.credentialSubject.completionPercentage,newStatus:a}}:null,auditFulfillment:{endpoint:"POST /audit/obligation-fulfillment",data:{obligationId:e.id,fulfillmentId:s.id,obligor:e.credentialSubject.id,fulfilledAt:o.credentialSubject.fulfillmentDate,completionPercentage:o.credentialSubject.completionPercentage}}}}}catch(f){return{success:!1,error:f.message}}},prepareObligationBreachAssessment:function(e,t,r){mr.checkArgument(e&&typeof e=="object","Invalid token"),mr.checkArgument(t&&typeof t=="object","Invalid breach details"),mr.checkArgument(r&&typeof r=="object","Invalid assessor");try{var n={"@context":["https://www.w3.org/2018/credentials/v1","https://smartledger.technology/contexts/ltp/v1"],id:"urn:uuid:"+this._generateUUID(),type:["VerifiableCredential","ObligationBreachAssessment"],issuer:r.did||r.id,issuanceDate:new Date().toISOString(),credentialSubject:{id:e.id,breachType:t.type||"MATERIAL_BREACH",breachDate:t.date||new Date().toISOString(),description:t.description||"",severity:t.severity||"MODERATE",evidence:t.evidence||[],assessor:{did:r.did||r.id,name:r.name||"Unknown",authority:r.authority||null,jurisdiction:r.jurisdiction||null},damages:t.damages||null,recommendedRemedies:t.recommendedRemedies||[],assessmentDate:new Date().toISOString()}},i=Zp.sha256(d.Buffer.from(JSON.stringify(n))).toString("hex");return n.credentialSubject.assessmentHash=i,{success:!0,breachAssessment:n,breachId:n.id,severity:t.severity||"MODERATE",externalOperations:{recordBreach:{endpoint:"POST /obligations/breaches",data:{obligationId:e.id,breachAssessment:n,obligor:e.credentialSubject.id,rightHolder:e.credentialSubject.rightHolder,breachDate:t.date||new Date().toISOString(),severity:t.severity||"MODERATE"}},updateStatus:{endpoint:"PUT /obligations/tokens/"+e.id+"/status",data:{status:dr.BREACHED,breachId:n.id,breachDate:t.date||new Date().toISOString(),updatedAt:new Date().toISOString()}},notifyParties:{endpoint:"POST /notifications/obligation-breached",data:{obligationId:e.id,breachId:n.id,obligor:e.credentialSubject.id,rightHolder:e.credentialSubject.rightHolder,breachType:t.type||"MATERIAL_BREACH",severity:t.severity||"MODERATE"}},escalateBreach:t.severity==="CRITICAL"?{endpoint:"POST /legal/escalate-breach",data:{obligationId:e.id,breachId:n.id,severity:t.severity,jurisdiction:e.credentialSubject.jurisdiction}}:null,auditBreach:{endpoint:"POST /audit/obligation-breach",data:{obligationId:e.id,breachId:n.id,obligor:e.credentialSubject.id,assessedAt:n.credentialSubject.assessmentDate,severity:t.severity||"MODERATE"}}}}}catch(o){return{success:!1,error:o.message}}},prepareObligationMonitoringReport:function(e,t){t=t||{},mr.checkArgument(Array.isArray(e),"Obligations must be array");try{var r={reportId:"rpt_"+this._generateUUID(),generatedAt:new Date().toISOString(),criteria:t,summary:{totalObligations:e.length,byStatus:{},byPriority:{},byType:{},overdue:0,dueSoon:0,completed:0},obligations:[],alerts:[],recommendations:[]},n=new Date,i=new Date(n.getTime()+10080*60*1e3);return e.forEach(function(o){var s={id:o.id,type:o.credentialSubject.obligationType,status:o.credentialSubject.status,priority:o.credentialSubject.priority,obligor:o.credentialSubject.id,dueDate:o.credentialSubject.dueDate,isOverdue:this._checkIfOverdue(o),isDueSoon:!1};if(o.credentialSubject.dueDate){var a=new Date(o.credentialSubject.dueDate);s.isDueSoon=a<=i&&a>n}r.summary.byStatus[s.status]=(r.summary.byStatus[s.status]||0)+1,r.summary.byPriority[s.priority]=(r.summary.byPriority[s.priority]||0)+1,r.summary.byType[s.type]=(r.summary.byType[s.type]||0)+1,s.isOverdue&&r.summary.overdue++,s.isDueSoon&&r.summary.dueSoon++,s.status===dr.COMPLETED&&r.summary.completed++,s.isOverdue&&s.priority===gs.CRITICAL&&r.alerts.push({type:"CRITICAL_OVERDUE",obligationId:o.id,message:"Critical obligation is overdue",priority:"HIGH"}),s.isDueSoon&&s.priority===gs.HIGH&&r.alerts.push({type:"HIGH_PRIORITY_DUE_SOON",obligationId:o.id,message:"High priority obligation due soon",priority:"MEDIUM"}),r.obligations.push(s)}.bind(this)),r.summary.overdue>0&&r.recommendations.push({type:"OVERDUE_MANAGEMENT",message:"Consider prioritizing overdue obligations",count:r.summary.overdue}),r.summary.dueSoon>5&&r.recommendations.push({type:"WORKLOAD_MANAGEMENT",message:"High number of obligations due soon - consider workload distribution",count:r.summary.dueSoon}),{success:!0,report:r,externalOperations:{storeReport:{endpoint:"POST /obligations/monitoring-reports",data:{report:r,generatedAt:r.generatedAt}},sendAlerts:r.alerts.length>0?{endpoint:"POST /notifications/obligation-alerts",data:{reportId:r.reportId,alerts:r.alerts,summary:r.summary}}:null,updateDashboard:{endpoint:"PUT /dashboard/obligation-metrics",data:{summary:r.summary,lastUpdated:r.generatedAt}}}}}catch(o){return{success:!1,error:o.message}}},getObligationTypes:function(){return Hc},getObligationPriority:function(){return gs},getObligationStatus:function(){return dr},_signToken:function(e,t){var r=this._canonicalizeToken(e),n=Zp.sha256(d.Buffer.from(r)),i=new uI;i.hashbuf=n,i.privkey=t,i.pubkey=t.toPublicKey(),i.sign();var o=i.sig,s={type:"EcdsaSecp256k1Signature2019",created:new Date().toISOString(),verificationMethod:"did:smartledger:"+t.toPublicKey().toString()+"#keys-1",proofPurpose:"assertionMethod",jws:this._createJWS(n,o)},a=JSON.parse(JSON.stringify(e));return a.proof=s,a.tokenHash=n.toString("hex"),a},_createJWS:function(e,t){var r={alg:"ES256K",typ:"JWT"},n=d.Buffer.from(JSON.stringify(r)).toString("base64url"),i=e.toString("base64url"),o=t.toDER().toString("base64url");return n+".."+o},_canonicalizeToken:function(e){var t=JSON.parse(JSON.stringify(e));return delete t.proof,delete t.tokenHash,JSON.stringify(this._sortObjectKeys(t))},_sortObjectKeys:function(e){if(Array.isArray(e))return e.map(this._sortObjectKeys.bind(this));if(e!==null&&typeof e=="object"){var t={};return Object.keys(e).sort().forEach(function(r){t[r]=this._sortObjectKeys(e[r])}.bind(this)),t}return e},_validateTokenStructure:function(e,t){e["@context"]||t.push("Missing @context"),e.id||t.push("Missing id"),(!e.type||!Array.isArray(e.type))&&t.push("Missing or invalid type"),e.issuer||t.push("Missing issuer"),e.issuanceDate||t.push("Missing issuanceDate"),e.credentialSubject||t.push("Missing credentialSubject"),e.proof||t.push("Missing proof")},_verifyTokenSignature:function(e,t,r){try{if(!e.proof||!e.proof.jws){t.push("Missing signature proof");return}var n=this._canonicalizeToken(e),i=Zp.sha256(d.Buffer.from(n));if(e.tokenHash&&e.tokenHash!==i.toString("hex")){t.push("Token hash mismatch");return}var o=kC(e,r);if(!o){t.push("Signature not verified: issuer public key could not be resolved from token.issuer; pass options.issuerPublicKey");return}var s=e.proof.jws.split(".");if(s.length!==3||!s[2]){t.push("Malformed JWS");return}var a=NC.fromDER(d.Buffer.from(s[2],"base64url")),f=new uI;f.hashbuf=i,f.sig=a,f.pubkey=o,f.verify()!==!0&&t.push("Signature verification failed")}catch(l){t.push("Signature verification failed: "+l.message)}},_validateTokenTemporal:function(e,t,r){var n=new Date,i=new Date(e.issuanceDate);if(i>n&&t.push("Token issued in the future"),e.credentialSubject.effectiveDate){var o=new Date(e.credentialSubject.effectiveDate);n<o&&r.push("Obligation not yet effective")}if(e.credentialSubject.expirationDate){var s=new Date(e.credentialSubject.expirationDate);n>s&&t.push("Obligation expired")}},_validateObligationType:function(e,t){if(!e.credentialSubject.obligationType){t.push("Missing obligationType");return}var r=Object.values(Hc);r.includes(e.credentialSubject.obligationType)||t.push("Invalid obligation type: "+e.credentialSubject.obligationType)},_validateObligationStatus:function(e,t,r){if(!e.credentialSubject.status){t.push("Missing status");return}var n=Object.values(dr);n.includes(e.credentialSubject.status)||t.push("Invalid obligation status: "+e.credentialSubject.status),this._checkIfOverdue(e)&&e.credentialSubject.status===dr.ACTIVE&&r.push("Obligation is overdue but status is still ACTIVE")},_validateObligationPriority:function(e,t){if(e.credentialSubject.priority){var r=Object.values(gs);r.includes(e.credentialSubject.priority)||t.push("Invalid obligation priority: "+e.credentialSubject.priority)}},_checkIfOverdue:function(e){if(!e.credentialSubject.dueDate)return!1;var t=new Date,r=new Date(e.credentialSubject.dueDate);return t>r&&e.credentialSubject.status!==dr.COMPLETED},_generateUUID:function(){return MC.uuid4()}};jc.ObligationTypes=Hc;jc.ObligationPriority=gs;jc.ObligationStatus=dr;cI.exports=jc});var dI=B((Gq,hI)=>{"use strict";p();var fo=Vx(),Kc=Qx(),Xa=tI(),Xp=iI(),pn=aI(),CC=lI(),Jp=oo(),vr=Fe(),Be=function(e){return this instanceof Be?(this.config=e||{},this.registry=null,this.config.registry&&(this.registry=pn.createRegistry(this.config.registry)),this):new Be(e)};Be.prototype.createRightToken=function(e,t,r){vr.checkArgument(e&&typeof e=="object","Invalid right data"),vr.checkArgument(t instanceof Jp,"Invalid private key"),r=r||{};try{var n=fo.create(e.type,e.owner,e.owner,e,t,r);if(!n)return{success:!1,error:"Failed to create token"};if(r.addProof!==!1&&(n=fo._signToken(n,t)),r.anchor){var i=Xa.anchorToken(n,r.anchor);i.success&&(n.anchorTx=i.txid,n.anchorBlock=i.blockHeight)}if(this.registry&&r.register!==!1){var o=pn.registerToken(this.registry,n,{registeredBy:r.registeredBy||"SYSTEM"});o.success&&(n.registrationId=o.registrationId,n.registrationStatus=o.status)}return{success:!0,token:n,type:"LegalRightToken"}}catch(s){return{success:!1,error:s.message}}};Be.prototype.validateClaim=function(e,t){return Kc.validate(e,t)};Be.prototype.createSelectiveDisclosure=function(e,t,r){return Xp.prepareSelectiveDisclosure(e,t,r)};Be.prototype.verifyToken=function(e,t){return!e||!e.proof?{valid:!1,error:"No proof found in token"}:fo.verifyToken(e,t)};Be.prototype.transferRight=function(e,t,r,n){vr.checkArgument(e&&typeof e=="object","Invalid token"),vr.checkArgument(typeof t=="string","New owner must be string"),vr.checkArgument(r instanceof Jp,"Invalid owner key"),n=n||{};try{var i=this.verifyToken(e,r.toPublicKey().toString());if(!i.valid)return{success:!1,error:"Invalid token or ownership proof"};var o=fo.prepareRightTokenTransfer(e,t,r,n);if(!o.success)return{success:!1,error:o.error};var s=o.newToken,a=o.transferProof;if(n.anchor){var f=Xa.anchorToken(s,n.anchor);f.success&&(s.transferAnchorTx=f.txid)}if(this.registry){var l=pn.registerToken(this.registry,s,{registeredBy:n.registeredBy||t,metadata:{transferFrom:e.owner,transferTo:t,originalTokenId:e.id}});l.success&&(s.registrationId=l.registrationId)}return{success:!0,token:s,transferId:a.id,transferredAt:a.issuanceDate,transferProof:a}}catch(y){return{success:!1,error:y.message}}};Be.prototype.createObligation=function(e,t,r){vr.checkArgument(e&&typeof e=="object","Invalid right token"),vr.checkArgument(t&&typeof t=="object","Invalid obligation data"),vr.checkArgument(r instanceof Jp,"Invalid private key");try{var n=fo.prepareObligationToken(e,t.obligor,t,r);return n.success?{success:!0,obligation:n.obligationToken,rightTokenId:e.id}:{success:!1,error:n.error}}catch(i){return{success:!1,error:i.message}}};Be.prototype.revokeToken=function(e,t,r){return vr.checkArgument(typeof e=="string","Token ID must be string"),vr.checkArgument(t&&typeof t=="object","Invalid revocation data"),vr.checkArgument(typeof r=="string","Authority must be string"),this.registry?pn.revokeToken(this.registry,e,{reason:t.reason,revokedBy:r,legalBasis:t.legalBasis,evidence:t.evidence}):{success:!1,error:"No registry available for revocation"}};Be.prototype.checkTokenStatus=function(e){return vr.checkArgument(typeof e=="string","Token ID must be string"),this.registry?pn.checkTokenStatus(this.registry,e):{found:!1,error:"No registry available"}};Be.prototype.searchTokens=function(e){return this.registry?pn.searchTokens(this.registry,e):{success:!1,error:"No registry available"}};Be.prototype.getRegistryStats=function(){return this.registry?pn.getStatistics(this.registry):{error:"No registry available"}};Be.prototype.createLegalValidityProof=function(e,t,r){return Xp.prepareLegalValidityProof(e,t,r)};Be.prototype.anchorTokenBatch=function(e,t){return Xa.anchorBatch(e,t)};Be.prototype.verifyAnchor=function(e,t){return Xa.verifyAnchor(e,t)};Be.prototype.getRightTypes=function(){return fo.getRightTypes()};Be.prototype.getClaimSchemas=function(){return Kc.getSchemas()};Be.prototype.createRegistry=function(e){return this.registry=pn.createRegistry(e),this.registry};Be.prototype.setRegistry=function(e){vr.checkArgument(e&&typeof e=="object","Invalid registry"),this.registry=e};Be.create=function(e){return new Be(e)};Be.createRightToken=function(e,t,r){var n=new Be;return n.createRightToken(e,t,r)};Be.validateClaim=function(e,t){return Kc.validate(e,t)};Be.verifyToken=function(e,t){var r=new Be;return r.verifyToken(e,t)};Be.createRegistry=function(e){return pn.createRegistry(e)};Be.Right=fo;Be.Claim=Kc;Be.Anchor=Xa;Be.Proof=Xp;Be.Registry=pn;Be.Obligation=CC;hI.exports=Be});var LC=B((Wq,pI)=>{p();pI.exports=dI()});return LC();})();
74
+ `))}}};R.prototype.verify=function(e,t,r,n,i,o){this.eraHint=null;var s=this._verifyCore(e,t,r,n,i,o);return s||this._eraDiagnose(i),s};R._resetEraWarning=function(){Gp=!1};R.mainnetFlags=function(e){e=e||{};var t=R.SCRIPT_VERIFY_P2SH|R.SCRIPT_VERIFY_STRICTENC|R.SCRIPT_VERIFY_DERSIG|R.SCRIPT_VERIFY_SIGPUSHONLY|R.SCRIPT_VERIFY_LOW_S|R.SCRIPT_VERIFY_NULLFAIL|R.SCRIPT_VERIFY_MINIMALDATA|R.SCRIPT_ENABLE_SIGHASH_FORKID|R.SCRIPT_ENABLE_MAGNETIC_OPCODES|R.SCRIPT_ENABLE_MONOLITH_OPCODES|R.SCRIPT_GENESIS|R.SCRIPT_UTXO_AFTER_GENESIS;return e.afterChronicle!==!1&&(t|=R.SCRIPT_ENABLE_CHRONICLE|R.SCRIPT_UTXO_AFTER_CHRONICLE),t};R.currentConsensusFlags=function(){return R.SCRIPT_ENABLE_MONOLITH_OPCODES|R.SCRIPT_ENABLE_MAGNETIC_OPCODES|R.SCRIPT_GENESIS|R.SCRIPT_UTXO_AFTER_GENESIS|R.SCRIPT_ENABLE_CHRONICLE|R.SCRIPT_UTXO_AFTER_CHRONICLE|R.SCRIPT_ENABLE_SIGHASH_FORKID|R.SCRIPT_VERIFY_SIGPUSHONLY|R.SCRIPT_VERIFY_LOW_S|R.SCRIPT_VERIFY_NULLFAIL};R.useMainnetConsensus=function(e){return e=e||{},R.useGenesisLimits(e.max),R.mainnetFlags(e)};R.SEQUENCE_LOCKTIME_DISABLE_FLAG=1<<31;R.SEQUENCE_LOCKTIME_TYPE_FLAG=1<<22;R.SEQUENCE_LOCKTIME_MASK=65535;R.castToBool=function(e){for(var t=0;t<e.length;t++)if(e[t]!==0)return!(t===e.length-1&&e[t]===128);return!1};function Bx(e,t){return(e&R.SCRIPT_CHRONICLE)===0?!0:!(t&&(t.version|0)>1)}R.prototype.enforceNonMalleability=function(){return Bx(this.flags,this.tx)};R.prototype.checkSignatureEncoding=function(e){var t;if(e.length===0)return!0;if((this.flags&(R.SCRIPT_VERIFY_DERSIG|R.SCRIPT_VERIFY_LOW_S|R.SCRIPT_VERIFY_STRICTENC))!==0&&!zn.isTxDER(e))return this.errstr="SCRIPT_ERR_SIG_DER_INVALID_FORMAT",!1;if((this.flags&R.SCRIPT_VERIFY_LOW_S)!==0&&(t=zn.fromTxFormat(e),!t.hasLowS()&&this.enforceNonMalleability()))return this.errstr="SCRIPT_ERR_SIG_DER_HIGH_S",!1;if((this.flags&R.SCRIPT_VERIFY_STRICTENC)!==0){if(t=zn.fromTxFormat(e),!t.hasDefinedHashtype())return this.errstr="SCRIPT_ERR_SIG_HASHTYPE",!1;if(!(this.flags&R.SCRIPT_ENABLE_SIGHASH_FORKID)&&t.nhashtype&zn.SIGHASH_FORKID)return this.errstr="SCRIPT_ERR_ILLEGAL_FORKID",!1;if(!(this.flags&R.SCRIPT_CHRONICLE)&&t.nhashtype&zn.SIGHASH_CHRONICLE)return this.errstr="SCRIPT_ERR_ILLEGAL_CHRONICLE",!1;if(this.flags&R.SCRIPT_ENABLE_SIGHASH_FORKID&&!(t.nhashtype&zn.SIGHASH_FORKID))return this.errstr="SCRIPT_ERR_MUST_USE_FORKID",!1}return!0};function Tx(e,t,r){var n=t.length?t[t.length-1]:0;return(!(r&R.SCRIPT_ENABLE_SIGHASH_FORKID)||!(n&zn.SIGHASH_FORKID))&&e.findAndDelete(new Gc().add(t)),e}R.prototype.checkPubkeyEncoding=function(e){return(this.flags&R.SCRIPT_VERIFY_STRICTENC)!==0&&!Kp.isValid(e)?(this.errstr="SCRIPT_ERR_PUBKEYTYPE",!1):!0};R.prototype.isAfterGenesis=function(){return(this.flags&R.SCRIPT_UTXO_AFTER_GENESIS)!==0};R.prototype.isAfterChronicle=function(){return(this.flags&(R.SCRIPT_UTXO_AFTER_CHRONICLE|R.SCRIPT_ENABLE_CHRONICLE))!==0};R.prototype.maxScriptElementSize=function(){return this.isAfterGenesis()?R.UNLIMITED:R.MAX_SCRIPT_ELEMENT_SIZE};R.prototype.maxScriptSize=function(){return this.isAfterGenesis()?R.UNLIMITED:R.MAX_SCRIPT_SIZE};R.prototype.maxOpsPerScript=function(){return this.isAfterGenesis()?R.UNLIMITED:R.MAX_OPS_PER_SCRIPT};R.prototype.maxScriptNumLength=function(){return this.isAfterChronicle()?R.MAX_SCRIPT_NUM_LENGTH_AFTER_CHRONICLE:this.isAfterGenesis()?R.MAX_SCRIPT_NUM_LENGTH_AFTER_GENESIS:R.MAXIMUM_ELEMENT_SIZE};R.prototype.maxStackSize=function(){return this.isAfterGenesis()?R.UNLIMITED:R.MAX_STACK_SIZE};R.prototype.maxStackMemoryUsage=function(){return this.isAfterGenesis()?R.MAX_STACK_MEMORY_USAGE_AFTER_GENESIS:R.UNLIMITED};R.prototype.stackMemoryUsage=function(){let e=R.STACK_ELEMENT_OVERHEAD,t=(this.stack.length+this.altstack.length)*e;for(let r=0;r<this.stack.length;r++)t+=this.stack[r].length;for(let r=0;r<this.altstack.length;r++)t+=this.altstack[r].length;return t};R.prototype.checkStackLimits=function(){if(this.stack.length+this.altstack.length>this.maxStackSize())return"SCRIPT_ERR_STACK_SIZE";let e=this.maxStackMemoryUsage();return e!==R.UNLIMITED&&this.stackMemoryUsage()>e?"SCRIPT_ERR_STACK_SIZE":null};R.prototype.maxPubKeysPerMultisig=function(){return this.isAfterGenesis()?R.MAX_PUBKEYS_PER_MULTISIG_AFTER_GENESIS:20};R._isMinimallyEncoded=function(e,t){return t=t||R.MAXIMUM_ELEMENT_SIZE,!(e.length>t||e.length>0&&(e[e.length-1]&127)===0&&(e.length<=1||(e[e.length-2]&128)===0))};R._minimallyEncode=function(e){if(e.length===0)return e;var t=e[e.length-1];if(t&127)return e;if(e.length===1)return d.Buffer.from("");if(e[e.length-2]&128)return e;e=d.Buffer.from(e);for(var r=e.length-1;r>0;r--)if(e[r-1]!==0)return e[r-1]&128?e[r++]=t:e[r-1]|=t,e.slice(0,r);return d.Buffer.from("")};R.prototype.evaluate=function(){if(this.script.toBuffer().length>this.maxScriptSize())return this.errstr="SCRIPT_ERR_SCRIPT_SIZE",!1;try{for(;this.pc<this.script.chunks.length;){let r={pc:this.pc,opcode:k.fromNumber(this.script.chunks[this.pc].opcodenum)};var e=this.step();if(!e)return!1;if(this._callbackStep(r),this.returned)return!0;let n=this.checkStackLimits();if(n)return this.errstr=n,!1}let t=this.checkStackLimits();if(t)return this.errstr=t,!1}catch(t){return this.errstr=t.scriptErr||"SCRIPT_ERR_UNKNOWN_ERROR: "+t,!1}return this.vfExec.length>0?(this.errstr="SCRIPT_ERR_UNBALANCED_CONDITIONAL",!1):!0};R.prototype._callbackStep=function(e){if(typeof this.stepListener=="function")try{this.stepListener(e,Rx(this.stack),Rx(this.altstack))}catch(t){console.log(`Error in Step callback:${t}`)}};R.prototype.checkLockTime=function(e){if(!(this.tx.nLockTime<R.LOCKTIME_THRESHOLD&&e.lt(R.LOCKTIME_THRESHOLD_BN)||this.tx.nLockTime>=R.LOCKTIME_THRESHOLD&&e.gte(R.LOCKTIME_THRESHOLD_BN))||e.gt(new le(this.tx.nLockTime)))return!1;var t=this.tx.inputs[this.nin];return!(!t||t.isFinal())};R.prototype.checkSequence=function(e){var t=this.tx.inputs[this.nin];if(!t)return!1;var r=t.sequenceNumber;if(this.tx.version<2||r&R.SEQUENCE_LOCKTIME_DISABLE_FLAG)return!1;var n=R.SEQUENCE_LOCKTIME_TYPE_FLAG|R.SEQUENCE_LOCKTIME_MASK,i=new le(r&n),o=e.and(new le(n)),s=new le(R.SEQUENCE_LOCKTIME_TYPE_FLAG);return!(!(i.lt(s)&&o.lt(s)||i.gte(s)&&o.gte(s))||o.gt(i))};function Px(e){var t=d.Buffer.alloc(4);return t.writeInt32LE(e|0,0),t}R.prototype.step=function(){var e=this;function t(ie){return e.stack[e.stack.length+ie]}function r(ie){switch(ie){case k.OP_2MUL:case k.OP_2DIV:if(!e.isAfterChronicle())return!0;break;case k.OP_INVERT:case k.OP_MUL:case k.OP_LSHIFT:case k.OP_RSHIFT:case k.OP_DIV:case k.OP_MOD:case k.OP_SPLIT:case k.OP_CAT:case k.OP_AND:case k.OP_OR:case k.OP_XOR:case k.OP_BIN2NUM:case k.OP_NUM2BIN:return!1;default:break}return!1}var n=(this.flags&R.SCRIPT_VERIFY_MINIMALDATA)!==0&&this.enforceNonMalleability(),i,o,s,a,f,l,m,y,p,w,O,M,D,F,V,Y,Q,ce=this.script.chunks[this.pc];this.pc++;var ee=ce.opcodenum,de=this.vfExec.indexOf(!1)===-1&&(!this.nonTopLevelReturnAfterGenesis||ee===k.OP_RETURN);if(Kc.isUndefined(ee))return this.errstr="SCRIPT_ERR_UNDEFINED_OPCODE",!1;if(ce.buf&&ce.buf.length>this.maxScriptElementSize())return this.errstr="SCRIPT_ERR_PUSH_SIZE",!1;if(ee>k.OP_16&&++this.nOpCount>this.maxOpsPerScript())return this.errstr="SCRIPT_ERR_OP_COUNT",!1;if(r(ee)&&(!this.isAfterGenesis()||de))return this.errstr="SCRIPT_ERR_DISABLED_OPCODE",!1;if(de&&ee>=0&&ee<=k.OP_PUSHDATA4){if(n&&!this.script.checkMinimalPush(this.pc-1))return this.errstr="SCRIPT_ERR_MINIMALDATA",!1;if(!ce.buf)this.stack.push(R.false);else{if(ce.len!==ce.buf.length)return this.errstr="SCRIPT_ERR_BAD_OPCODE",!1;this.stack.push(ce.buf)}}else if(de||k.OP_IF<=ee&&ee<=k.OP_ENDIF)switch(ee){case k.OP_1NEGATE:case k.OP_1:case k.OP_2:case k.OP_3:case k.OP_4:case k.OP_5:case k.OP_6:case k.OP_7:case k.OP_8:case k.OP_9:case k.OP_10:case k.OP_11:case k.OP_12:case k.OP_13:case k.OP_14:case k.OP_15:case k.OP_16:f=ee-(k.OP_1-1),i=new le(f).toScriptNumBuffer(),this.stack.push(i);break;case k.OP_NOP:break;case k.OP_NOP2:case k.OP_CHECKLOCKTIMEVERIFY:if(!(this.flags&R.SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY)||this.isAfterGenesis()){if(this.flags&R.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS)return this.errstr="SCRIPT_ERR_DISCOURAGE_UPGRADABLE_NOPS",!1;break}if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;var pe=le.fromScriptNumBuffer(this.stack[this.stack.length-1],n,5);if(pe.lt(new le(0)))return this.errstr="SCRIPT_ERR_NEGATIVE_LOCKTIME",!1;if(!this.checkLockTime(pe))return this.errstr="SCRIPT_ERR_UNSATISFIED_LOCKTIME",!1;break;case k.OP_NOP3:case k.OP_CHECKSEQUENCEVERIFY:if(!(this.flags&R.SCRIPT_VERIFY_CHECKSEQUENCEVERIFY)||this.isAfterGenesis()){if(this.flags&R.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS)return this.errstr="SCRIPT_ERR_DISCOURAGE_UPGRADABLE_NOPS",!1;break}if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;var xe=le.fromScriptNumBuffer(t(-1),n,5);if(xe.lt(new le(0)))return this.errstr="SCRIPT_ERR_NEGATIVE_LOCKTIME",!1;if((xe&R.SEQUENCE_LOCKTIME_DISABLE_FLAG)!==0)break;if(!this.checkSequence(xe))return this.errstr="SCRIPT_ERR_UNSATISFIED_LOCKTIME",!1;break;case k.OP_NOP1:case k.OP_NOP9:case k.OP_NOP10:if(this.flags&R.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS)return this.errstr="SCRIPT_ERR_DISCOURAGE_UPGRADABLE_NOPS",!1;break;case k.OP_LSHIFTNUM:case k.OP_RSHIFTNUM:if(!this.isAfterChronicle()){if(this.flags&R.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS)return this.errstr="SCRIPT_ERR_DISCOURAGE_UPGRADABLE_NOPS",!1;break}if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;var I=this.maxScriptNumLength(),u=le.fromScriptNumBuffer(t(-1),n,I);if(u.isNeg())return this.errstr="SCRIPT_ERR_INVALID_NUMBER_RANGE",!1;this.stack.pop();var h=le.fromScriptNumBuffer(t(-1),n,I);this.stack.pop();var v=u.toNumber(),_=h.isNeg(),S=h.abs(),T;if(ee===k.OP_LSHIFTNUM){var P=h.toScriptNumBuffer().length;if(P+Math.floor(v/8)>I)return this.errstr="SCRIPT_ERR_SCRIPTNUM_OVERFLOW",!1;T=S.shln(v)}else T=v>=S.bitLength()?new le(0):S.shrn(v);if(_&&!T.isZero()&&(T=T.neg()),T.toScriptNumBuffer().length>I)return this.errstr="SCRIPT_ERR_SCRIPTNUM_OVERFLOW",!1;this.stack.push(T.toScriptNumBuffer());break;case k.OP_VER:if(!this.isAfterChronicle())return this.errstr="SCRIPT_ERR_BAD_OPCODE",!1;if(this.tx==null)return this.errstr="SCRIPT_ERR_UNKNOWN_ERROR",!1;this.stack.push(Px(this.tx.version));break;case k.OP_VERIF:case k.OP_VERNOTIF:if(!this.isAfterChronicle()){if(this.isAfterGenesis()&&!de)break;return this.errstr="SCRIPT_ERR_BAD_OPCODE",!1}if(Y=!1,de){if(this.stack.length<1)return this.errstr="SCRIPT_ERR_UNBALANCED_CONDITIONAL",!1;if(this.tx==null)return this.errstr="SCRIPT_ERR_UNKNOWN_ERROR",!1;i=t(-1),Y=i.length===4&&i.equals(Px(this.tx.version)),ee===k.OP_VERNOTIF&&(Y=!Y),this.stack.pop()}this.vfExec.push(Y),this.vfElse.push(!1);break;case k.OP_IF:case k.OP_NOTIF:if(Y=!1,de){if(this.stack.length<1)return this.errstr="SCRIPT_ERR_UNBALANCED_CONDITIONAL",!1;if(i=t(-1),this.flags&R.SCRIPT_VERIFY_MINIMALIF&&(i.length>1||i.length===1&&i[0]!==1)&&this.enforceNonMalleability())return this.errstr="SCRIPT_ERR_MINIMALIF",!1;Y=R.castToBool(i),ee===k.OP_NOTIF&&(Y=!Y),this.stack.pop()}this.vfExec.push(Y),this.vfElse.push(!1);break;case k.OP_ELSE:if(this.vfExec.length===0||this.vfElse[this.vfElse.length-1]&&this.isAfterGenesis())return this.errstr="SCRIPT_ERR_UNBALANCED_CONDITIONAL",!1;this.vfExec[this.vfExec.length-1]=!this.vfExec[this.vfExec.length-1],this.vfElse[this.vfElse.length-1]=!0;break;case k.OP_ENDIF:if(this.vfExec.length===0)return this.errstr="SCRIPT_ERR_UNBALANCED_CONDITIONAL",!1;this.vfExec.pop(),this.vfElse.pop();break;case k.OP_VERIFY:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(i=t(-1),Y=R.castToBool(i),Y)this.stack.pop();else return this.errstr="SCRIPT_ERR_VERIFY",!1;break;case k.OP_RETURN:if(this.isAfterGenesis()){if(this.vfExec.length===0){this.returned=!0;break}this.nonTopLevelReturnAfterGenesis=!0;break}return this.errstr="SCRIPT_ERR_OP_RETURN",!1;case k.OP_TOALTSTACK:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.altstack.push(this.stack.pop());break;case k.OP_FROMALTSTACK:if(this.altstack.length<1)return this.errstr="SCRIPT_ERR_INVALID_ALTSTACK_OPERATION",!1;this.stack.push(this.altstack.pop());break;case k.OP_2DROP:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.pop(),this.stack.pop();break;case k.OP_2DUP:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;o=t(-2),s=t(-1),this.stack.push(d.Buffer.from(o)),this.stack.push(d.Buffer.from(s));break;case k.OP_3DUP:if(this.stack.length<3)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;o=t(-3),s=t(-2);var E=t(-1);this.stack.push(d.Buffer.from(o)),this.stack.push(d.Buffer.from(s)),this.stack.push(d.Buffer.from(E));break;case k.OP_2OVER:if(this.stack.length<4)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;o=t(-4),s=t(-3),this.stack.push(d.Buffer.from(o)),this.stack.push(d.Buffer.from(s));break;case k.OP_2ROT:if(this.stack.length<6)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;a=this.stack.splice(this.stack.length-6,2),this.stack.push(a[0]),this.stack.push(a[1]);break;case k.OP_2SWAP:if(this.stack.length<4)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;a=this.stack.splice(this.stack.length-4,2),this.stack.push(a[0]),this.stack.push(a[1]);break;case k.OP_IFDUP:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;i=t(-1),Y=R.castToBool(i),Y&&this.stack.push(d.Buffer.from(i));break;case k.OP_DEPTH:i=new le(this.stack.length).toScriptNumBuffer(),this.stack.push(i);break;case k.OP_DROP:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.pop();break;case k.OP_DUP:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.push(d.Buffer.from(t(-1)));break;case k.OP_NIP:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.splice(this.stack.length-2,1);break;case k.OP_OVER:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.push(d.Buffer.from(t(-2)));break;case k.OP_PICK:case k.OP_ROLL:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(i=t(-1),y=le.fromScriptNumBuffer(i,n,this.maxScriptNumLength()),f=y.toNumber(),this.stack.pop(),f<0||f>=this.stack.length)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;i=t(-f-1),ee===k.OP_ROLL&&this.stack.splice(this.stack.length-f-1,1),this.stack.push(d.Buffer.from(i));break;case k.OP_ROT:if(this.stack.length<3)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;l=t(-3),m=t(-2);var c=t(-1);this.stack[this.stack.length-3]=m,this.stack[this.stack.length-2]=c,this.stack[this.stack.length-1]=l;break;case k.OP_SWAP:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;l=t(-2),m=t(-1),this.stack[this.stack.length-2]=m,this.stack[this.stack.length-1]=l;break;case k.OP_TUCK:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.splice(this.stack.length-2,0,d.Buffer.from(t(-1)));break;case k.OP_SIZE:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;y=new le(t(-1).length),this.stack.push(y.toScriptNumBuffer());break;case k.OP_AND:case k.OP_OR:case k.OP_XOR:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(o=t(-2),s=t(-1),o.length!==s.length)return this.errstr="SCRIPT_ERR_INVALID_OPERAND_SIZE",!1;switch(a=d.Buffer.alloc(o.length),ee){case k.OP_AND:for(let ie=0;ie<o.length;ie++)a[ie]=o[ie]&s[ie];break;case k.OP_OR:for(let ie=0;ie<o.length;ie++)a[ie]=o[ie]|s[ie];break;case k.OP_XOR:for(let ie=0;ie<o.length;ie++)a[ie]=o[ie]^s[ie];break;default:break}this.stack.pop(),this.stack[this.stack.length-1]=a;break;case k.OP_INVERT:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;i=t(-1),o=d.Buffer.alloc(i.length);for(let ie=0;ie<i.length;ie++)o[ie]=~i[ie]&255;this.stack[this.stack.length-1]=o;break;case k.OP_LSHIFT:case k.OP_RSHIFT:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(o=t(-2),w=le.fromScriptNumBuffer(t(-1),n,this.maxScriptNumLength()),w.cmpn(0)<0)return this.errstr="SCRIPT_ERR_INVALID_NUMBER_RANGE",!1;this.stack.pop(),this.stack.pop();var b=d.Buffer.alloc(o.length);if(w.lt(new le(o.length).muln(8)))for(var C=w.toNumber(),N=Math.floor(C/8),L=C%8,K=ee===k.OP_LSHIFT,z=0;z<o.length;z++){var W=K?z+N:z-N,te=W>=0&&W<o.length?o[W]:0,re=K?W+1:W-1,se=L&&re>=0&&re<o.length?o[re]:0;b[z]=K?(te<<L|se>>8-L)&255:(te>>L|se<<8-L)&255}this.stack.push(b);break;case k.OP_EQUAL:case k.OP_EQUALVERIFY:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;o=t(-2),s=t(-1);var Ie=o.toString("hex")===s.toString("hex");if(this.stack.pop(),this.stack.pop(),this.stack.push(Ie?R.true:R.false),ee===k.OP_EQUALVERIFY)if(Ie)this.stack.pop();else return this.errstr="SCRIPT_ERR_EQUALVERIFY",!1;break;case k.OP_2MUL:case k.OP_2DIV:case k.OP_1ADD:case k.OP_1SUB:case k.OP_NEGATE:case k.OP_ABS:case k.OP_NOT:case k.OP_0NOTEQUAL:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;switch(i=t(-1),y=le.fromScriptNumBuffer(i,n,this.maxScriptNumLength()),ee){case k.OP_2MUL:y=y.mul(new le(2));break;case k.OP_2DIV:y=y.div(new le(2));break;case k.OP_1ADD:y=y.add(le.One);break;case k.OP_1SUB:y=y.sub(le.One);break;case k.OP_NEGATE:y=y.neg();break;case k.OP_ABS:y.cmp(le.Zero)<0&&(y=y.neg());break;case k.OP_NOT:y=new le((y.cmp(le.Zero)===0)+0);break;case k.OP_0NOTEQUAL:y=new le((y.cmp(le.Zero)!==0)+0);break}this.stack.pop(),this.stack.push(y.toScriptNumBuffer());break;case k.OP_ADD:case k.OP_SUB:case k.OP_MUL:case k.OP_MOD:case k.OP_DIV:case k.OP_BOOLAND:case k.OP_BOOLOR:case k.OP_NUMEQUAL:case k.OP_NUMEQUALVERIFY:case k.OP_NUMNOTEQUAL:case k.OP_LESSTHAN:case k.OP_GREATERTHAN:case k.OP_LESSTHANOREQUAL:case k.OP_GREATERTHANOREQUAL:case k.OP_MIN:case k.OP_MAX:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;switch(p=le.fromScriptNumBuffer(t(-2),n,this.maxScriptNumLength()),w=le.fromScriptNumBuffer(t(-1),n,this.maxScriptNumLength()),y=new le(0),ee){case k.OP_ADD:y=p.add(w);break;case k.OP_SUB:y=p.sub(w);break;case k.OP_MUL:y=p.mul(w);break;case k.OP_DIV:if(w.cmp(le.Zero)===0)return this.errstr="SCRIPT_ERR_DIV_BY_ZERO",!1;y=p.div(w);break;case k.OP_MOD:if(w.cmp(le.Zero)===0)return this.errstr="SCRIPT_ERR_MOD_BY_ZERO",!1;y=p.mod(w);break;case k.OP_BOOLAND:y=new le((p.cmp(le.Zero)!==0&&w.cmp(le.Zero)!==0)+0);break;case k.OP_BOOLOR:y=new le((p.cmp(le.Zero)!==0||w.cmp(le.Zero)!==0)+0);break;case k.OP_NUMEQUAL:y=new le((p.cmp(w)===0)+0);break;case k.OP_NUMEQUALVERIFY:y=new le((p.cmp(w)===0)+0);break;case k.OP_NUMNOTEQUAL:y=new le((p.cmp(w)!==0)+0);break;case k.OP_LESSTHAN:y=new le((p.cmp(w)<0)+0);break;case k.OP_GREATERTHAN:y=new le((p.cmp(w)>0)+0);break;case k.OP_LESSTHANOREQUAL:y=new le((p.cmp(w)<=0)+0);break;case k.OP_GREATERTHANOREQUAL:y=new le((p.cmp(w)>=0)+0);break;case k.OP_MIN:y=p.cmp(w)<0?p:w;break;case k.OP_MAX:y=p.cmp(w)>0?p:w;break}if(this.stack.pop(),this.stack.pop(),this.stack.push(y.toScriptNumBuffer()),ee===k.OP_NUMEQUALVERIFY)if(R.castToBool(t(-1)))this.stack.pop();else return this.errstr="SCRIPT_ERR_NUMEQUALVERIFY",!1;break;case k.OP_WITHIN:if(this.stack.length<3)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;p=le.fromScriptNumBuffer(t(-3),n,this.maxScriptNumLength()),w=le.fromScriptNumBuffer(t(-2),n,this.maxScriptNumLength());var ue=le.fromScriptNumBuffer(t(-1),n,this.maxScriptNumLength());Y=w.cmp(p)<=0&&p.cmp(ue)<0,this.stack.pop(),this.stack.pop(),this.stack.pop(),this.stack.push(Y?R.true:R.false);break;case k.OP_RIPEMD160:case k.OP_SHA1:case k.OP_SHA256:case k.OP_HASH160:case k.OP_HASH256:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;i=t(-1);var fe;ee===k.OP_RIPEMD160?fe=Za.ripemd160(i):ee===k.OP_SHA1?fe=Za.sha1(i):ee===k.OP_SHA256?fe=Za.sha256(i):ee===k.OP_HASH160?fe=Za.sha256ripemd160(i):ee===k.OP_HASH256&&(fe=Za.sha256sha256(i)),this.stack.pop(),this.stack.push(fe);break;case k.OP_CODESEPARATOR:this.pbegincodehash=this.pc;break;case k.OP_CHECKSIG:case k.OP_CHECKSIGVERIFY:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(O=t(-2),M=t(-1),!this.checkSignatureEncoding(O)||!this.checkPubkeyEncoding(M))return!1;D=new Gc().set({chunks:this.script.chunks.slice(this.pbegincodehash)}),Tx(D,O,this.flags);try{F=zn.fromTxFormat(O),V=Kp.fromBuffer(M,!1),Q=this.tx.verifySignature(F,V,this.nin,D,this.satoshisBN,this.flags)}catch{Q=!1}if(!Q&&this.flags&R.SCRIPT_VERIFY_NULLFAIL&&O.length&&this.enforceNonMalleability())return this.errstr="SCRIPT_ERR_NULLFAIL",!1;if(this.stack.pop(),this.stack.pop(),this.stack.push(Q?R.true:R.false),ee===k.OP_CHECKSIGVERIFY)if(Q)this.stack.pop();else return this.errstr="SCRIPT_ERR_CHECKSIGVERIFY",!1;break;case k.OP_CHECKMULTISIG:case k.OP_CHECKMULTISIGVERIFY:var Oe=1;if(this.stack.length<Oe)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;var ve=le.fromScriptNumBuffer(t(-Oe),n,4).toNumber();if(ve<0||ve>this.maxPubKeysPerMultisig())return this.errstr="SCRIPT_ERR_PUBKEY_COUNT",!1;if(this.nOpCount+=ve,this.nOpCount>this.maxOpsPerScript())return this.errstr="SCRIPT_ERR_OP_COUNT",!1;var Ee=++Oe;Oe+=ve;var ke=ve+2;if(this.stack.length<Oe)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;var _e=le.fromScriptNumBuffer(t(-Oe),n,4).toNumber();if(_e<0||_e>ve)return this.errstr="SCRIPT_ERR_SIG_COUNT",!1;var He=++Oe;if(Oe+=_e,this.stack.length<Oe)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;D=new Gc().set({chunks:this.script.chunks.slice(this.pbegincodehash)});for(var Zt=0;Zt<_e;Zt++)O=t(-He-Zt),Tx(D,O,this.flags);for(Q=!0;Q&&_e>0;){if(O=t(-He),M=t(-Ee),!this.checkSignatureEncoding(O)||!this.checkPubkeyEncoding(M))return!1;var ze;try{F=zn.fromTxFormat(O),V=Kp.fromBuffer(M,!1),ze=this.tx.verifySignature(F,V,this.nin,D,this.satoshisBN,this.flags)}catch{ze=!1}ze&&(He++,_e--),Ee++,ve--,_e>ve&&(Q=!1)}for(;Oe-- >1;){if(!Q&&this.flags&R.SCRIPT_VERIFY_NULLFAIL&&!ke&&t(-1).length&&this.enforceNonMalleability())return this.errstr="SCRIPT_ERR_NULLFAIL",!1;ke>0&&ke--,this.stack.pop()}if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(this.flags&R.SCRIPT_VERIFY_NULLDUMMY&&t(-1).length&&this.enforceNonMalleability())return this.errstr="SCRIPT_ERR_SIG_NULLDUMMY",!1;if(this.stack.pop(),this.stack.push(Q?R.true:R.false),ee===k.OP_CHECKMULTISIGVERIFY)if(Q)this.stack.pop();else return this.errstr="SCRIPT_ERR_CHECKMULTISIGVERIFY",!1;break;case k.OP_CAT:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(o=t(-2),s=t(-1),o.length+s.length>this.maxScriptElementSize())return this.errstr="SCRIPT_ERR_PUSH_SIZE",!1;this.stack[this.stack.length-2]=d.Buffer.concat([o,s]),this.stack.pop();break;case k.OP_SPLIT:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;o=t(-2);var Ge=le.fromScriptNumBuffer(t(-1),n,this.maxScriptNumLength()).toNumber();if(Ge<0||Ge>o.length)return this.errstr="SCRIPT_ERR_INVALID_SPLIT_RANGE",!1;var Zr=d.Buffer.from(o);this.stack[this.stack.length-2]=Zr.slice(0,Ge),this.stack[this.stack.length-1]=Zr.slice(Ge);break;case k.OP_LEFT:case k.OP_RIGHT:if(!this.isAfterChronicle()){if(this.flags&R.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS)return this.errstr="SCRIPT_ERR_DISCOURAGE_UPGRADABLE_NOPS",!1;break}if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(o=t(-2),f=le.fromScriptNumBuffer(t(-1),n,this.maxScriptNumLength()).toNumber(),f<0||f>o.length)return this.errstr="SCRIPT_ERR_INVALID_NUMBER_RANGE",!1;this.stack.pop(),ee===k.OP_LEFT?this.stack[this.stack.length-1]=d.Buffer.from(o).slice(0,f):this.stack[this.stack.length-1]=d.Buffer.from(o).slice(o.length-f);break;case k.OP_SUBSTR:if(!this.isAfterChronicle()){if(this.flags&R.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS)return this.errstr="SCRIPT_ERR_DISCOURAGE_UPGRADABLE_NOPS",!1;break}if(this.stack.length<3)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;o=t(-3);var nt=le.fromScriptNumBuffer(t(-1),n,this.maxScriptNumLength()).toNumber(),A=le.fromScriptNumBuffer(t(-2),n,this.maxScriptNumLength()).toNumber();if(A<0||A>=o.length||nt<0||nt>o.length-A)return this.errstr="SCRIPT_ERR_INVALID_NUMBER_RANGE",!1;this.stack.pop(),this.stack.pop(),this.stack[this.stack.length-1]=d.Buffer.from(o).slice(A,A+nt);break;case k.OP_NUM2BIN:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;var U=le.fromScriptNumBuffer(t(-1),n,this.maxScriptNumLength());if(U.cmpn(0)<0||U.gt(new le(2147483647)))return this.errstr="SCRIPT_ERR_PUSH_SIZE",!1;var H=U.toNumber();if(H>this.maxScriptElementSize())return this.errstr="SCRIPT_ERR_PUSH_SIZE",!1;this.stack.pop();var G=t(-1);if(G=R._minimallyEncode(G),G.length>H)return this.errstr="SCRIPT_ERR_IMPOSSIBLE_ENCODING",!1;if(G.length===H){this.stack[this.stack.length-1]=G;break}var ne=0;G.length>0&&(G=d.Buffer.from(G),ne=G[G.length-1]&128,G[G.length-1]&=127);var $=d.Buffer.alloc(H);G.copy($,0);for(var oe=G.length-1;oe++<H-2;)$[oe]=0;$[oe]=ne,this.stack[this.stack.length-1]=$;break;case k.OP_BIN2NUM:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(o=t(-1),s=R._minimallyEncode(o),this.stack[this.stack.length-1]=s,!R._isMinimallyEncoded(s,this.maxScriptNumLength()))return this.errstr="SCRIPT_ERR_INVALID_NUMBER_RANGE",!1;break;default:return this.errstr="SCRIPT_ERR_BAD_OPCODE",!1}return!0}});var Gr=B((Sq,Vp)=>{g();Vp.exports=Ip();Vp.exports.Interpreter=Fc()});var uo=B((Eq,Lx)=>{"use strict";g();var Wp=at(),Yn=We(),mC=ii(),Mx=Xd(),Nr=Ea(),kx=nr(),Cx=vr(),zp=Pr();function ae(e,t,r){if(!(this instanceof ae))return new ae(e,t,r);if(Wp.isArray(e)&&Wp.isNumber(t))return ae.createMultisig(e,t,r);if(e instanceof ae)return e;if(Yn.checkArgument(e,"First argument is required, please include address data.","guide/address.html"),t&&!Nr.get(t))throw new TypeError('Second argument must be "livenet", "testnet", or "regtest".');if(r&&r!==ae.PayToPublicKeyHash&&r!==ae.PayToScriptHash)throw new TypeError('Third argument must be "pubkeyhash" or "scripthash".');var n=this._classifyArguments(e,t,r);return n.network=n.network||Nr.get(t)||Nr.defaultNetwork,n.type=n.type||r||ae.PayToPublicKeyHash,Cx.defineImmutable(this,{hashBuffer:n.hashBuffer,network:n.network,type:n.type}),this}ae.prototype._classifyArguments=function(e,t,r){if((e instanceof d.Buffer||e instanceof Uint8Array)&&e.length===20)return ae._transformHash(e);if((e instanceof d.Buffer||e instanceof Uint8Array)&&e.length===21)return ae._transformBuffer(e,t,r);if(e instanceof zp)return ae._transformPublicKey(e);if(e instanceof Xa())return ae._transformScript(e,t);if(typeof e=="string")return ae._transformString(e,t,r);if(Wp.isObject(e))return ae._transformObject(e);throw new TypeError("First argument is an unrecognized data format.")};ae.PayToPublicKeyHash="pubkeyhash";ae.PayToScriptHash="scripthash";ae._transformHash=function(e){var t={};if(!(e instanceof d.Buffer)&&!(e instanceof Uint8Array))throw new TypeError("Address supplied is not a buffer.");if(e.length!==20)throw new TypeError("Address hashbuffers must be exactly 20 bytes.");return t.hashBuffer=e,t};ae._transformObject=function(e){return Yn.checkArgument(e.hash||e.hashBuffer,"Must provide a `hash` or `hashBuffer` property"),Yn.checkArgument(e.type,"Must provide a `type` property"),{hashBuffer:e.hash?d.Buffer.from(e.hash,"hex"):e.hashBuffer,network:Nr.get(e.network)||Nr.defaultNetwork,type:e.type}};ae._classifyFromVersion=function(e){var t={},r=Nr.get(e[0],"pubkeyhash"),n=Nr.get(e[0],"scripthash");return r?(t.network=r,t.type=ae.PayToPublicKeyHash):n&&(t.network=n,t.type=ae.PayToScriptHash),t};ae._transformBuffer=function(e,t,r){var n={};if(!(e instanceof d.Buffer)&&!(e instanceof Uint8Array))throw new TypeError("Address supplied is not a buffer.");if(e.length!==21)throw new TypeError("Address buffers must be exactly 21 bytes.");var i=Nr.get(t),o=ae._classifyFromVersion(e);if(t&&!i)throw new TypeError("Unknown network");if(!o.network||i&&i!==o.network)throw new TypeError("Address has mismatched network type.");if(!o.type||r&&r!==o.type)throw new TypeError("Address has mismatched type.");return n.hashBuffer=e.slice(1),n.network=o.network,n.type=o.type,n};ae._transformPublicKey=function(e){var t={};if(!(e instanceof zp))throw new TypeError("Address must be an instance of PublicKey.");return t.hashBuffer=kx.sha256ripemd160(e.toBuffer()),t.type=ae.PayToPublicKeyHash,t};ae._transformScript=function(e,t){Yn.checkArgument(e instanceof Xa(),"script must be a Script instance");var r=e.getAddressInfo(t);if(!r)throw new mC.Script.CantDeriveAddress(e);return r};ae.createMultisig=function(e,t,r){return r=r||e[0].network||Nr.defaultNetwork,ae.payingTo(Xa().buildMultisigOut(e,t),r)};ae._transformString=function(e,t,r){if(typeof e!="string")throw new TypeError("data parameter supplied is not a string.");if(e.length<27)throw new Error("Invalid Address string provided");e=e.trim();var n=Nr.get(t);if(t&&!n)throw new TypeError("Unknown network");var i=Mx.decode(e);return ae._transformBuffer(i,t,r)};ae.fromPublicKey=function(e,t){var r=ae._transformPublicKey(e);return t=t||Nr.defaultNetwork,new ae(r.hashBuffer,t,r.type)};ae.fromPrivateKey=function(e,t){let r=zp.fromPrivateKey(e);return t=t||e.network||Nr.defaultNetwork,ae.fromPublicKey(r,t)};ae.fromPublicKeyHash=function(e,t){var r=ae._transformHash(e);return new ae(r.hashBuffer,t,ae.PayToPublicKeyHash)};ae.fromScriptHash=function(e,t){Yn.checkArgument(e,"hash parameter is required");var r=ae._transformHash(e);return new ae(r.hashBuffer,t,ae.PayToScriptHash)};ae.payingTo=function(e,t){return Yn.checkArgument(e,"script is required"),Yn.checkArgument(e instanceof Xa(),"script must be instance of Script"),ae.fromScriptHash(kx.sha256ripemd160(e.toBuffer()),t)};ae.fromScript=function(e,t){Yn.checkArgument(e instanceof Xa(),"script must be a Script instance");var r=ae._transformScript(e,t);return new ae(r.hashBuffer,t,r.type)};ae.fromBuffer=function(e,t,r){var n=ae._transformBuffer(e,t,r);return new ae(n.hashBuffer,n.network,n.type)};ae.fromHex=function(e,t,r){return ae.fromBuffer(d.Buffer.from(e,"hex"),t,r)};ae.fromString=function(e,t,r){var n=ae._transformString(e,t,r);return new ae(n.hashBuffer,n.network,n.type)};ae.fromObject=function(t){Yn.checkState(Cx.isHexa(t.hash),'Unexpected hash property, "'+t.hash+'", expected to be hex.');var r=d.Buffer.from(t.hash,"hex");return new ae(r,t.network,t.type)};ae.getValidationError=function(e,t,r){var n;try{new ae(e,t,r)}catch(i){n=i}return n};ae.isValid=function(e,t,r){return!ae.getValidationError(e,t,r)};ae.prototype.isPayToPublicKeyHash=function(){return this.type===ae.PayToPublicKeyHash};ae.prototype.isPayToScriptHash=function(){return this.type===ae.PayToScriptHash};ae.prototype.toBuffer=function(){var e=d.Buffer.from([this.network[this.type]]),t=d.Buffer.concat([e,this.hashBuffer]);return t};ae.prototype.toHex=function(){return this.toBuffer().toString("hex")};ae.prototype.toObject=ae.prototype.toJSON=function(){return{hash:this.hashBuffer.toString("hex"),type:this.type,network:this.network.toString()}};ae.prototype.inspect=function(){return"<Address: "+this.toString()+", type: "+this.type+", network: "+this.network+">"};ae.prototype.toString=function(){return Mx.encode(this.toBuffer())};Lx.exports=ae;function Xa(){return Gr()}});var fo=B((Iq,qx)=>{"use strict";g();var Vc=at(),vC=uo(),Dx=Xd(),Oi=Ar(),Ux=vr(),mn=Ea(),$p=gi(),bC=Pr(),_C=sa(),Fx=We(),Yp="[REDACTED]";function Se(e,t){if(!(this instanceof Se))return new Se(e,t);if(e instanceof Se)return e;var r=this._classifyArguments(e,t);if(!r.bn||r.bn.cmp(new Oi(0))===0)throw new TypeError("Number can not be equal to zero, undefined, null or false");if(!r.bn.lt($p.getN()))throw new TypeError("Number must be less than N");if(typeof r.network>"u")throw new TypeError('Must specify the network ("livenet" or "testnet")');return Ux.defineImmutable(this,{bn:r.bn,compressed:r.compressed,network:r.network}),Object.defineProperty(this,"publicKey",{configurable:!1,enumerable:!0,get:this.toPublicKey.bind(this)}),this}Se.prototype._classifyArguments=function(e,t){var r={compressed:!0,network:t?mn.get(t):mn.defaultNetwork};if(Vc.isUndefined(e)||Vc.isNull(e))r.bn=Se._getRandomBN();else if(e instanceof Oi)r.bn=e;else if(e instanceof d.Buffer||e instanceof Uint8Array)r=Se._transformBuffer(e,t);else if(e.bn&&e.network)r=Se._transformObject(e);else if(!t&&mn.get(e))r.bn=Se._getRandomBN(),r.network=mn.get(e);else if(typeof e=="string")Ux.isHexa(e)?r.bn=new Oi(d.Buffer.from(e,"hex")):r=Se._transformWIF(e,t);else throw new TypeError("First argument is an unrecognized data type.");return r};Se._getRandomBN=function(){var e,t;do{var r=_C.getRandomBuffer(32);t=Oi.fromBuffer(r),e=t.lt($p.getN())}while(!e);return t};Se._transformBuffer=function(e,t){var r={};if(e.length===32)return Se._transformBNBuffer(e,t);if(r.network=mn.get(e[0],"privatekey"),!r.network)throw new Error("Invalid network");if(t&&r.network!==mn.get(t))throw new TypeError("Private key network mismatch");if(e.length===34&&e[33]===1)r.compressed=!0;else if(e.length===33)r.compressed=!1;else throw new Error("Length of buffer must be 33 (uncompressed) or 34 (compressed)");return r.bn=Oi.fromBuffer(e.slice(1,33)),r};Se._transformBNBuffer=function(e,t,r){var n={};return n.network=mn.get(t)||mn.defaultNetwork,n.bn=Oi.fromBuffer(e),n.compressed=r===void 0?!0:!!r,n};Se._transformWIF=function(e,t){return Se._transformBuffer(Dx.decode(e),t)};Se.fromBuffer=function(e,t,r){return r!==void 0&&e&&e.length===32?new Se(Se._transformBNBuffer(e,t,r)):new Se(e,t)};Se.fromHex=function(e,t,r){return Se.fromBuffer(d.Buffer.from(e,"hex"),t,r)};Se._transformObject=function(e){if(e.bn instanceof Oi)return{bn:e.bn,network:mn.get(e.network),compressed:e.compressed};if(typeof e.bn!="string"||!e.bn.length)throw new TypeError("Invalid private key: `bn` must be a hex string");if(e.bn===Yp)throw new TypeError('Invalid private key: `bn` is "'+Yp+'". JSON.stringify() redacts the secret on purpose \u2014 use toObject() for a round-trippable export, or toWIF().');if(!/^[0-9a-fA-F]+$/.test(e.bn))throw new TypeError("Invalid private key: `bn` is not hexadecimal");var t=new Oi(e.bn,"hex");if(t.isZero()||t.gte($p.getN()))throw new TypeError("Invalid private key: outside the range of valid keys");var r=mn.get(e.network);return{bn:t,network:r,compressed:e.compressed}};Se.fromString=Se.fromWIF=function(e,t){return Fx.checkArgument(Vc.isString(e),"First argument is expected to be a string."),new Se(e,t)};Se.fromObject=Se.fromJSON=function(e){return Fx.checkArgument(Vc.isObject(e),"First argument is expected to be an object."),new Se(e)};Se.fromRandom=function(e){var t=Se._getRandomBN();return new Se(t,e)};Se.getValidationError=function(e,t){var r;try{new Se(e,t)}catch(n){r=n}return r};Se.isValid=function(e,t){return e?!Se.getValidationError(e,t):!1};Se.prototype.toString=function(){return this.toWIF()};Se.prototype.toWIF=function(){var e=this.network,t=this.compressed,r;return t?r=d.Buffer.concat([d.Buffer.from([e.privatekey]),this.bn.toBuffer({size:32}),d.Buffer.from([1])]):r=d.Buffer.concat([d.Buffer.from([e.privatekey]),this.bn.toBuffer({size:32})]),Dx.encode(r)};Se.prototype.toBigNumber=function(){return this.bn};Se.prototype.toBuffer=function(){return this.bn.toBuffer({size:32})};Se.prototype.toHex=function(){return this.toBuffer().toString("hex")};Se.prototype.toPublicKey=function(){return this._pubkey||(this._pubkey=bC.fromPrivateKey(this)),this._pubkey};Se.prototype.toAddress=function(e){var t=this.toPublicKey();return vC.fromPublicKey(t,e||this.network)};Se.prototype.toObject=function(){return{bn:this.bn.toString("hex"),compressed:this.compressed,network:this.network.toString()}};Se.prototype.toJSON=function(){return{bn:Yp,compressed:this.compressed,network:this.network.toString()}};Se.prototype.inspect=function(){var e=this.compressed?"":", uncompressed";return"<PrivateKey: "+this.toHex()+", network: "+this.network+e+">"};qx.exports=Se});var Pr=B((Oq,jx)=>{"use strict";g();var gs=Ar(),ys=gi(),SC=nr(),wC=vr(),Hx=Ea(),Zp=at(),lo=We();function ge(e,t){if(!(this instanceof ge))return new ge(e,t);if(lo.checkArgument(e,"First argument is required, please include public key data."),e instanceof ge)return e;t=t||{};var r=this._classifyArgs(e,t);return r.point.validate(),wC.defineImmutable(this,{point:r.point,compressed:r.compressed,network:r.network||Hx.defaultNetwork}),this}ge.prototype._classifyArgs=function(e,t){var r={compressed:Zp.isUndefined(t.compressed)||t.compressed};if(e instanceof ys)r.point=e;else if(e.x&&e.y)r=ge._transformObject(e);else if(typeof e=="string")r=ge._transformDER(d.Buffer.from(e,"hex"));else if(ge._isBuffer(e))r=ge._transformDER(e);else if(ge._isPrivateKey(e))r=ge._transformPrivateKey(e);else throw new TypeError("First argument is an unrecognized data format.");return r.network||(r.network=Zp.isUndefined(t.network)?void 0:Hx.get(t.network)),r};ge._isPrivateKey=function(e){var t=fo();return e instanceof t};ge._isBuffer=function(e){return e instanceof d.Buffer||e instanceof Uint8Array};ge._transformPrivateKey=function(e){lo.checkArgument(ge._isPrivateKey(e),"Must be an instance of PrivateKey");var t={};return t.point=ys.getG().mul(e.bn),t.compressed=e.compressed,t.network=e.network,t};ge._transformDER=function(e,t){lo.checkArgument(ge._isBuffer(e),"Must be a buffer of DER encoded public key");var r={};t=Zp.isUndefined(t)?!0:t;var n,i,o,s;if(e[0]===4||!t&&(e[0]===6||e[0]===7)){if(o=e.slice(1,33),s=e.slice(33,65),o.length!==32||s.length!==32||e.length!==65)throw new TypeError("Length of x and y must be 32 bytes");n=new gs(o),i=new gs(s),r.point=new ys(n,i),r.compressed=!1}else if(e[0]===3)o=e.slice(1),n=new gs(o),r=ge._transformX(!0,n),r.compressed=!0;else if(e[0]===2)o=e.slice(1),n=new gs(o),r=ge._transformX(!1,n),r.compressed=!0;else throw new TypeError("Invalid DER format public key");return r};ge._transformX=function(e,t){lo.checkArgument(typeof e=="boolean","Must specify whether y is odd or not (true or false)");var r={};return r.point=ys.fromX(e,t),r};ge._transformObject=function(e){var t=new gs(e.x,"hex"),r=new gs(e.y,"hex"),n=new ys(t,r);return new ge(n,{compressed:e.compressed})};ge.fromPrivateKey=function(e){lo.checkArgument(ge._isPrivateKey(e),"Must be an instance of PrivateKey");var t=ge._transformPrivateKey(e);return new ge(t.point,{compressed:t.compressed,network:t.network})};ge.fromDER=ge.fromBuffer=function(e,t){lo.checkArgument(ge._isBuffer(e),"Must be a buffer of DER encoded public key");var r=ge._transformDER(e,t);return new ge(r.point,{compressed:r.compressed})};ge.fromPoint=function(e,t){return lo.checkArgument(e instanceof ys,"First argument must be an instance of Point."),new ge(e,{compressed:t})};ge.fromHex=ge.fromString=function(e,t){var r=d.Buffer.from(e,t||"hex"),n=ge._transformDER(r);return new ge(n.point,{compressed:n.compressed})};ge.fromX=function(e,t){var r=ge._transformX(e,t);return new ge(r.point,{compressed:r.compressed})};ge.getValidationError=function(e){var t;try{new ge(e)}catch(r){t=r}return t};ge.isValid=function(e){return!ge.getValidationError(e)};ge.prototype.toObject=ge.prototype.toJSON=function(){return{x:this.point.getX().toString("hex",2),y:this.point.getY().toString("hex",2),compressed:this.compressed}};ge.prototype.toBuffer=ge.prototype.toDER=function(){var e=this.point.getX(),t=this.point.getY(),r=e.toBuffer({size:32}),n=t.toBuffer({size:32}),i;if(this.compressed){var o=n[n.length-1]%2;return o?i=d.Buffer.from([3]):i=d.Buffer.from([2]),d.Buffer.concat([i,r])}else return i=d.Buffer.from([4]),d.Buffer.concat([i,r,n])};ge.prototype._getID=function(){return SC.sha256ripemd160(this.toBuffer())};ge.prototype.toAddress=function(e){var t=uo();return t.fromPublicKey(this,e||this.network)};ge.prototype.toString=ge.prototype.toHex=function(){return this.toDER().toString("hex")};ge.prototype.inspect=function(){return"<PublicKey: "+this.toHex()+(this.compressed?"":", uncompressed")+">"};jx.exports=ge});var Ja=B((Tq,Gx)=>{"use strict";g();var Kx=sa();function EC(){var e=Kx.getRandomBuffer(16);e[6]=e[6]&15|64,e[8]=e[8]&63|128;var t=e.toString("hex");return[t.substring(0,8),t.substring(8,12),t.substring(12,16),t.substring(16,20),t.substring(20,32)].join("-")}function xC(e){return Kx.getRandomBuffer(Math.ceil(e/2)).toString("hex").substring(0,e)}Gx.exports={uuid4:EC,randomHex:xC}});var $x=B((Nq,Yx)=>{"use strict";g();var Qa=Pr(),Xp=nr(),Jp=Ka(),Vx=fr(),Qp=fo(),Ct=We(),Bq=at(),IC=Ja();function Wx(e,t){if(t=t||{},t.issuerPublicKey)return t.issuerPublicKey instanceof Qa?t.issuerPublicKey:Qa.fromString(t.issuerPublicKey);var r=e&&e.issuer;if(typeof r!="string")return null;try{var n=r.split("#")[0].split(":")[2];return n?Qa.fromString(n):null}catch{return null}}var ms={PROPERTY_TITLE:"PropertyTitle",VEHICLE_TITLE:"VehicleTitle",INTELLECTUAL_PROPERTY:"IntellectualProperty",MUSIC_LICENSE:"MusicLicense",SOFTWARE_LICENSE:"SoftwareLicense",FINANCIAL_INSTRUMENT:"FinancialInstrument",PROMISSORY_NOTE:"PromissoryNote",BOND:"Bond",EQUITY_SHARE:"EquityShare",PROFESSIONAL_LICENSE:"ProfessionalLicense",REGULATORY_PERMIT:"RegulatoryPermit",ACCESS_RIGHT:"AccessRight",VOTING_RIGHT:"VotingRight",ROYALTY_RIGHT:"RoyaltyRight",USAGE_RIGHT:"UsageRight"},zx={create:function(e,t,r,n,i,o){o=o||{},Ct.checkArgument(typeof e=="string","Right type must be string"),Ct.checkArgument(typeof t=="string","Issuer DID must be string"),Ct.checkArgument(typeof r=="string","Subject DID must be string"),Ct.checkArgument(n&&typeof n=="object","Claim must be object");var s=Object.values(ms);Ct.checkArgument(s.includes(e),"Invalid right type: "+e);var a={"@context":["https://www.w3.org/2018/credentials/v1","https://smartledger.technology/contexts/ltp/v1"],id:"urn:uuid:"+this._generateUUID(),type:["VerifiableCredential","LegalRightToken",e],issuer:t,issuanceDate:new Date().toISOString(),credentialSubject:{id:r,rightType:e,claim:n,jurisdiction:o.jurisdiction||"US",purpose:o.purpose||"legal_right",validFrom:o.validFrom||new Date().toISOString(),validUntil:o.validUntil||null,transferable:o.transferable!==!1,revocable:o.revocable!==!1}};return o.metadata&&(a.credentialSubject.metadata=o.metadata),a},prepareRightToken:function(e,t,r,n,i,o){o=o||{},Ct.checkArgument(typeof e=="string","Right type must be string"),Ct.checkArgument(typeof t=="string","Issuer DID must be string"),Ct.checkArgument(typeof r=="string","Subject DID must be string"),Ct.checkArgument(n&&typeof n=="object","Claim must be object"),Ct.checkArgument(i instanceof Qp,"Invalid issuer private key");var s=Object.values(ms);Ct.checkArgument(s.includes(e),"Invalid right type: "+e);try{var a=this.create(e,t,r,n,i,o),f=this._signToken(a,i);return{success:!0,rightToken:f,tokenHash:f.tokenHash,metadata:{type:e,issuer:t,subject:r,transferable:a.credentialSubject.transferable,revocable:a.credentialSubject.revocable,jurisdiction:a.credentialSubject.jurisdiction},externalOperations:{storeToken:{endpoint:"POST /rights/tokens",data:{token:f,metadata:{type:e,issuer:t,subject:r,transferable:a.credentialSubject.transferable,revocable:a.credentialSubject.revocable,jurisdiction:a.credentialSubject.jurisdiction}}},indexToken:{endpoint:"POST /rights/index",data:{tokenId:f.id,tokenHash:f.tokenHash,type:e,issuer:t,subject:r,issuedAt:f.issuanceDate}},notifyParties:{endpoint:"POST /notifications/right-issued",data:{tokenId:f.id,issuer:t,subject:r,rightType:e}}}}}catch(l){return{success:!1,error:l.message}}},prepareRightTokenVerification:function(e,t){t=t||{};try{var r=[],n=[];this._validateTokenStructure(e,r),this._verifyTokenSignature(e,r,t),this._validateTokenTemporal(e,r,n),this._validateRightType(e,r),t.requireJurisdiction&&this._validateJurisdiction(e,t.allowedJurisdictions,r);var i={valid:r.length===0,errors:r,warnings:n,issuerDID:e.issuer,subjectDID:e.credentialSubject?e.credentialSubject.id:null,rightType:e.credentialSubject?e.credentialSubject.rightType:null,transferable:e.credentialSubject?e.credentialSubject.transferable:null,revocable:e.credentialSubject?e.credentialSubject.revocable:null,verifiedAt:new Date().toISOString()};return{success:!0,verification:i,externalOperations:{recordVerification:{endpoint:"POST /rights/verification-record",data:{tokenId:e.id,result:i.valid,errors:r,warnings:n,verifiedAt:i.verifiedAt}},auditVerification:{endpoint:"POST /audit/right-verification",data:{tokenId:e.id,rightType:i.rightType,issuer:i.issuerDID,subject:i.subjectDID,result:i.valid,verifiedAt:i.verifiedAt}},updateTokenStatus:i.valid?{endpoint:"PUT /rights/tokens/"+e.id+"/status",data:{status:"VERIFIED",verifiedAt:i.verifiedAt}}:null}}}catch(o){return{success:!1,error:"Verification preparation failed: "+o.message}}},prepareRightTokenTransfer:function(e,t,r,n){n=n||{},Ct.checkArgument(e&&typeof e=="object","Invalid token"),Ct.checkArgument(typeof t=="string","New owner DID must be string"),Ct.checkArgument(r instanceof Qp,"Invalid current owner key");try{var i=this.prepareRightTokenVerification(e,{});if(!i.success||!i.verification.valid)return{success:!1,error:"Cannot transfer invalid token: "+i.verification.errors.join(", ")};if(!e.credentialSubject.transferable)return{success:!1,error:"Token is not transferable"};var o=e.credentialSubject&&e.credentialSubject.id,s=Wx({issuer:o},{issuerPublicKey:n.currentOwnerPublicKey});if(!s)return{success:!1,error:"Cannot resolve current owner public key from token.credentialSubject.id; pass options.currentOwnerPublicKey"};if(r.toPublicKey().toString()!==s.toString())return{success:!1,error:"Unauthorized transfer: signing key does not match the current owner"};var a={"@context":["https://www.w3.org/2018/credentials/v1","https://smartledger.technology/contexts/ltp/v1"],id:"urn:uuid:"+this._generateUUID(),type:["VerifiableCredential","LegalRightTransfer"],issuer:e.credentialSubject.id,issuanceDate:new Date().toISOString(),credentialSubject:{id:t,originalToken:e.id,transferFrom:e.credentialSubject.id,transferTo:t,transferDate:new Date().toISOString(),transferReason:n.reason||"ownership_transfer",consideration:n.consideration||null}},f=this._signToken(a,r),l=JSON.parse(JSON.stringify(e));l.id="urn:uuid:"+this._generateUUID(),l.issuanceDate=new Date().toISOString(),l.credentialSubject.id=t,l.credentialSubject.transferHistory=l.credentialSubject.transferHistory||[],l.credentialSubject.transferHistory.push({transferId:f.id,transferDate:f.issuanceDate,from:e.credentialSubject.id,to:t}),delete l.proof;var m=this._signToken(l,r);return{success:!0,newToken:m,transferProof:f,transferId:f.id,externalOperations:{recordTransfer:{endpoint:"POST /rights/transfers",data:{originalTokenId:e.id,newTokenId:m.id,transferProof:f,fromOwner:e.credentialSubject.id,toOwner:t,transferDate:f.issuanceDate}},updateOwnership:{endpoint:"PUT /rights/tokens/"+e.id+"/ownership",data:{newOwner:t,transferId:f.id,transferDate:f.issuanceDate,previousOwner:e.credentialSubject.id}},notifyParties:{endpoint:"POST /notifications/right-transferred",data:{originalTokenId:e.id,newTokenId:m.id,fromOwner:e.credentialSubject.id,toOwner:t,rightType:e.credentialSubject.rightType}},auditTransfer:{endpoint:"POST /audit/right-transfer",data:{originalTokenId:e.id,newTokenId:m.id,transferId:f.id,fromOwner:e.credentialSubject.id,toOwner:t,transferredAt:f.issuanceDate}}}}}catch(y){return{success:!1,error:y.message}}},prepareObligationToken:function(e,t,r,n){Ct.checkArgument(e&&typeof e=="object","Invalid right token"),Ct.checkArgument(typeof t=="string","Obligor DID must be string"),Ct.checkArgument(r&&typeof r=="object","Obligation must be object"),Ct.checkArgument(n instanceof Qp,"Invalid issuer key");try{var i={"@context":["https://www.w3.org/2018/credentials/v1","https://smartledger.technology/contexts/ltp/v1"],id:"urn:uuid:"+this._generateUUID(),type:["VerifiableCredential","LegalObligationToken"],issuer:e.issuer,issuanceDate:new Date().toISOString(),credentialSubject:{id:t,obligationType:"correlative_obligation",correlativeRight:e.id,rightHolder:e.credentialSubject.id,obligation:r,jurisdiction:e.credentialSubject.jurisdiction,purpose:e.credentialSubject.purpose}},o=this._signToken(i,n);return{success:!0,obligationToken:o,correlativeRight:e.id,externalOperations:{storeObligation:{endpoint:"POST /obligations/tokens",data:{obligationToken:o,correlativeRightId:e.id,obligor:t,rightHolder:e.credentialSubject.id}},linkToRight:{endpoint:"POST /rights/tokens/"+e.id+"/obligations",data:{obligationId:o.id,obligor:t,obligationType:"correlative_obligation"}},notifyObligor:{endpoint:"POST /notifications/obligation-created",data:{obligationId:o.id,obligor:t,rightHolder:e.credentialSubject.id,correlativeRight:e.id}}}}}catch(s){return{success:!1,error:s.message}}},prepareRightTypeValidation:function(e){Ct.checkArgument(typeof e=="string","Right type must be string");var t=Object.values(ms),r=t.includes(e);return{success:!0,validation:{type:e,valid:r,availableTypes:t,category:this._categorizeRightType(e),description:this._getRightTypeDescription(e)},externalOperations:{validateType:{endpoint:"POST /rights/validate-type",data:{type:e,valid:r}}}}},_categorizeRightType:function(e){var t={PropertyTitle:"PROPERTY_RIGHT",VehicleTitle:"PROPERTY_RIGHT",IntellectualProperty:"IP_RIGHT",MusicLicense:"IP_RIGHT",SoftwareLicense:"IP_RIGHT",FinancialInstrument:"FINANCIAL_RIGHT",PromissoryNote:"FINANCIAL_RIGHT",Bond:"FINANCIAL_RIGHT",EquityShare:"FINANCIAL_RIGHT",ProfessionalLicense:"LICENSE_RIGHT",RegulatoryPermit:"LICENSE_RIGHT",AccessRight:"ACCESS_RIGHT",VotingRight:"GOVERNANCE_RIGHT",RoyaltyRight:"IP_RIGHT",UsageRight:"ACCESS_RIGHT"};return t[e]||"UNKNOWN"},_getRightTypeDescription:function(e){var t={PropertyTitle:"Legal ownership of real estate property",VehicleTitle:"Legal ownership of motor vehicle",IntellectualProperty:"Rights to intellectual property assets",MusicLicense:"License for music performance and usage",SoftwareLicense:"License for software usage and distribution",FinancialInstrument:"Rights related to financial instruments",PromissoryNote:"Promise to pay a specified amount",Bond:"Debt security representing loan",EquityShare:"Ownership stake in company",ProfessionalLicense:"License for professional practice",RegulatoryPermit:"Permit for regulated activities",AccessRight:"Right to access resources or locations",VotingRight:"Right to participate in governance",RoyaltyRight:"Right to receive royalty payments",UsageRight:"Right to use specific assets or services"};return t[e]||"Unknown right type"},getRightTypes:function(){return ms},verifyToken:function(e,t){var r=[];try{if(Ct.checkArgument(e&&typeof e=="object","Invalid token"),!e.proof||!e.proof.jws)return r.push("Missing signature proof"),{valid:!1,errors:r};var n=t instanceof Qa?t:Qa.fromString(t),i=this._canonicalizeToken(e),o=Xp.sha256(d.Buffer.from(i));if(e.tokenHash&&e.tokenHash!==o.toString("hex"))return r.push("Token hash mismatch"),{valid:!1,errors:r};var s=e.proof.jws.split(".");if(s.length!==3||!s[2])return r.push("Malformed JWS"),{valid:!1,errors:r};var a=Vx.fromDER(d.Buffer.from(s[2],"base64url")),f=new Jp;return f.hashbuf=o,f.sig=a,f.pubkey=n,f.verify()||r.push("Signature verification failed"),{valid:r.length===0,errors:r,tokenHash:o.toString("hex"),verifiedAt:new Date().toISOString()}}catch(l){return r.push(l.message),{valid:!1,errors:r}}},_signToken:function(e,t){var r=this._canonicalizeToken(e),n=Xp.sha256(d.Buffer.from(r)),i=new Jp;i.hashbuf=n,i.privkey=t,i.pubkey=t.toPublicKey(),i.sign();var o=i.sig,s={type:"EcdsaSecp256k1Signature2019",created:new Date().toISOString(),verificationMethod:"did:smartledger:"+t.toPublicKey().toString()+"#keys-1",proofPurpose:"assertionMethod",jws:this._createJWS(n,o)},a=JSON.parse(JSON.stringify(e));return a.proof=s,a.tokenHash=n.toString("hex"),a},_createJWS:function(e,t){var r={alg:"ES256K",typ:"JWT"},n=d.Buffer.from(JSON.stringify(r)).toString("base64url"),i=t.toDER().toString("base64url");return n+".."+i},_canonicalizeToken:function(e){var t=JSON.parse(JSON.stringify(e));return delete t.proof,delete t.tokenHash,JSON.stringify(this._sortObjectKeys(t))},_sortObjectKeys:function(e){if(Array.isArray(e))return e.map(this._sortObjectKeys.bind(this));if(e!==null&&typeof e=="object"){var t={};return Object.keys(e).sort().forEach(function(r){t[r]=this._sortObjectKeys(e[r])}.bind(this)),t}return e},_validateTokenStructure:function(e,t){e["@context"]||t.push("Missing @context"),e.id||t.push("Missing id"),(!e.type||!Array.isArray(e.type))&&t.push("Missing or invalid type"),e.issuer||t.push("Missing issuer"),e.issuanceDate||t.push("Missing issuanceDate"),e.credentialSubject||t.push("Missing credentialSubject"),e.proof||t.push("Missing proof")},_verifyTokenSignature:function(e,t,r){try{if(!e.proof||!e.proof.jws){t.push("Missing signature proof");return}var n=this._canonicalizeToken(e),i=Xp.sha256(d.Buffer.from(n));if(e.tokenHash&&e.tokenHash!==i.toString("hex")){t.push("Token hash mismatch");return}var o=Wx(e,r);if(!o){t.push("Signature not verified: issuer public key could not be resolved from token.issuer; pass options.issuerPublicKey");return}var s=e.proof.jws.split(".");if(s.length!==3||!s[2]){t.push("Malformed JWS");return}var a=Vx.fromDER(d.Buffer.from(s[2],"base64url")),f=new Jp;f.hashbuf=i,f.sig=a,f.pubkey=o,f.verify()!==!0&&t.push("Signature verification failed")}catch(l){t.push("Signature verification failed: "+l.message)}},_validateTokenTemporal:function(e,t,r){var n=new Date,i=new Date(e.issuanceDate);if(i>n&&t.push("Token issued in the future"),e.credentialSubject.validFrom){var o=new Date(e.credentialSubject.validFrom);n<o&&r.push("Token not yet valid")}if(e.credentialSubject.validUntil){var s=new Date(e.credentialSubject.validUntil);n>s&&t.push("Token expired")}},_validateRightType:function(e,t){if(!e.credentialSubject.rightType){t.push("Missing rightType");return}var r=Object.values(ms);r.includes(e.credentialSubject.rightType)||t.push("Invalid right type: "+e.credentialSubject.rightType)},_validateJurisdiction:function(e,t,r){if(!e.credentialSubject.jurisdiction){r.push("Missing jurisdiction");return}t&&Array.isArray(t)&&(t.includes(e.credentialSubject.jurisdiction)||r.push("Jurisdiction not allowed: "+e.credentialSubject.jurisdiction))},_generateUUID:function(){return IC.uuid4()}};zx.RightTypes=ms;Yx.exports=zx});var Jx=B((kq,Xx)=>{"use strict";g();var Zx={};Zx.stringify=function(e){return e0(e,[])};function e0(e,t){if(e===null)return"null";var r=typeof e;if(r==="boolean")return e?"true":"false";if(r==="number"){if(!isFinite(e))throw new Error("Cannot canonicalize non-finite number: "+e);return JSON.stringify(e)}if(r==="string")return JSON.stringify(e);if(r==="bigint")throw new Error("Cannot canonicalize bigint; represent it as a string");if(Array.isArray(e)||r==="object"){if(t.indexOf(e)!==-1)throw new Error("Cannot canonicalize a circular structure");t.push(e);var n;if(Array.isArray(e))n="["+e.map(function(o){return o===void 0?"null":e0(o,t)}).join(",")+"]";else{var i=Object.keys(e).filter(function(o){return e[o]!==void 0&&typeof e[o]!="function"}).sort();n="{"+i.map(function(o){return JSON.stringify(o)+":"+e0(e[o],t)}).join(",")+"}"}return t.pop(),n}throw new Error("Cannot canonicalize value of type: "+r)}Xx.exports=Zx});var eI=B((Lq,Qx)=>{"use strict";g();var vs=nr(),pr=We(),AC=Ja(),OC=Jx(),RC=wp(),ho={PropertyTitle:{title:"Property Title",description:"Real estate property ownership title",type:"object",required:["propertyId","address","ownershipType"],properties:{propertyId:{type:"string",description:"Unique property identifier"},address:{type:"object",required:["street","city","state","country"],properties:{street:{type:"string"},city:{type:"string"},state:{type:"string"},country:{type:"string"},postalCode:{type:"string"}}},ownershipType:{type:"string",enum:["fee_simple","leasehold","joint_tenancy","tenancy_in_common"]},titleNumber:{type:"string"},registeredDate:{type:"string",format:"date-time"},legalDescription:{type:"string"},encumbrances:{type:"array",items:{type:"object",properties:{type:{type:"string"},amount:{type:"number"},description:{type:"string"}}}}}},VehicleTitle:{title:"Vehicle Title",description:"Motor vehicle ownership title",type:"object",required:["vin","make","model","year"],properties:{vin:{type:"string",pattern:"^[A-HJ-NPR-Z0-9]{17}$",description:"Vehicle Identification Number"},make:{type:"string"},model:{type:"string"},year:{type:"integer",minimum:1900,maximum:2030},titleNumber:{type:"string"},registeredState:{type:"string"},mileage:{type:"integer",minimum:0},color:{type:"string"},fuelType:{type:"string",enum:["gasoline","diesel","electric","hybrid","other"]},liens:{type:"array",items:{type:"object",properties:{lienholderName:{type:"string"},lienAmount:{type:"number"},lienDate:{type:"string",format:"date"}}}}}},PromissoryNote:{title:"Promissory Note",description:"Legal promise to pay a specified amount",type:"object",required:["principal","interestRate","maturityDate","borrower","lender"],properties:{principalAmount:{type:"number",minimum:0,description:"Principal amount in base currency units"},currency:{type:"string",default:"USD"},interestRate:{type:"number",minimum:0,maximum:100,description:"Annual interest rate percentage"},maturityDate:{type:"string",format:"date",description:"Date when principal and interest are due"},payee:{type:"string",description:"DID of the payee (creditor)"},payor:{type:"string",description:"DID of the payor (debtor)"},paymentSchedule:{type:"string",enum:["lump_sum","monthly","quarterly","annually"]},collateral:{type:"array",items:{type:"object",properties:{description:{type:"string"},value:{type:"number"},type:{type:"string"}}}},defaultProvisions:{type:"string"},governingLaw:{type:"string"}}},IntellectualProperty:{title:"Intellectual Property",description:"Intellectual property rights and licensing",type:"object",required:["ipType","title","registrationNumber"],properties:{ipType:{type:"string",enum:["patent","trademark","copyright","trade_secret"]},title:{type:"string"},creator:{type:"string",description:"Creator DID"},registrationNumber:{type:"string"},registrationDate:{type:"string",format:"date"},expirationDate:{type:"string",format:"date"},jurisdiction:{type:"string"},description:{type:"string"},claims:{type:"array",items:{type:"string"}},priorArt:{type:"array",items:{type:"object",properties:{reference:{type:"string"},date:{type:"string",format:"date"},relevance:{type:"string"}}}}}},ProfessionalLicense:{title:"Professional License",description:"Professional practice license or certification",type:"object",required:["licenseType","licenseNumber","issuingAuthority","expirationDate"],properties:{licenseType:{type:"string"},licenseNumber:{type:"string"},issuingAuthority:{type:"string"},licensee:{type:"string",description:"Licensee DID"},issueDate:{type:"string",format:"date"},expirationDate:{type:"string",format:"date"},renewalDate:{type:"string",format:"date"},jurisdiction:{type:"string"},scope:{type:"string"},restrictions:{type:"array",items:{type:"string"}},continuing_education:{type:"object",properties:{hours_required:{type:"integer"},deadline:{type:"string",format:"date"},completed_hours:{type:"integer"}}}}},MusicLicense:{title:"Music License",description:"Music performance and usage licensing",type:"object",required:["songTitle","artist","licenseType","royaltyRate"],properties:{workTitle:{type:"string"},composer:{type:"string",description:"Composer DID"},performer:{type:"string",description:"Performer DID"},licenseType:{type:"string",enum:["mechanical","performance","synchronization","master_use"]},territory:{type:"string"},duration:{type:"string"},royaltyRate:{type:"number",minimum:0,maximum:100},advancePayment:{type:"number",minimum:0},exclusivity:{type:"boolean"},mediaTypes:{type:"array",items:{type:"string",enum:["cd","vinyl","digital","streaming","broadcast","film","tv"]}},usage_restrictions:{type:"string"},copyrightNotice:{type:"string"}}}},TC={prepareClaimValidation:function(e,t){try{pr.checkArgument(e&&typeof e=="object","Invalid claim"),pr.checkArgument(typeof t=="string","Schema name must be string");var r=ho[t];if(!r)return{success:!1,error:"Unknown schema: "+t};var n=[],i=[];this._validateObject(e,r,"",n,i);var o={valid:n.length===0,errors:n,warnings:i,schema:t,claimHash:vs.sha256(d.Buffer.from(this._canonicalizeWith(e,this.CANONICALIZATION.LEGACY))).toString("hex"),canonical:this._canonicalizeWith(e,this.CANONICALIZATION.LEGACY)};return{success:!0,validation:o,claim:e,schema:r,externalOperations:{store:{endpoint:"POST /claims/validate",data:{claim:e,validation:o,schema:t}},index:{endpoint:"POST /claims/index",data:{claimHash:o.claimHash,schemaName:t,valid:o.valid}}}}}catch(s){return{success:!1,error:"Validation preparation failed: "+s.message}}},prepareClaimAttestation:function(e,t,r){try{pr.checkArgument(e&&typeof e=="object","Invalid claim"),pr.checkArgument(typeof t=="string","Schema name must be string"),pr.checkArgument(r&&typeof r=="object","Invalid attestor");var n=this.prepareClaimValidation(e,t);if(!n.success||!n.validation.valid)return{success:!1,error:"Cannot attest invalid claim",validation:n};var i={type:"LTP_CLAIM_ATTESTATION",claimHash:n.validation.claimHash,schemaName:t,attestor:{did:r.did||r.id,name:r.name||"Unknown",authority:r.authority||null,jurisdiction:r.jurisdiction||null},attestedAt:new Date().toISOString(),confidence:r.confidence||100,evidence:r.evidence||null,notes:r.notes||null},o=vs.sha256(d.Buffer.from(this._canonicalizeWith(i,this.CANONICALIZATION.LEGACY))).toString("hex");return i.attestationHash=o,{success:!0,attestation:i,claim:e,validation:n.validation,externalOperations:{storeAttestation:{endpoint:"POST /claims/"+n.validation.claimHash+"/attestations",data:i},notifyStakeholders:{endpoint:"POST /notifications/claim-attested",data:{claimHash:n.validation.claimHash,attestorDid:i.attestor.did,attestationHash:o}}}}}catch(s){return{success:!1,error:"Attestation preparation failed: "+s.message}}},prepareClaimDispute:function(e,t,r){try{pr.checkArgument(typeof e=="string","Claim hash must be string"),pr.checkArgument(t&&typeof t=="object","Invalid disputant"),pr.checkArgument(r&&typeof r=="object","Invalid dispute");var n={type:"LTP_CLAIM_DISPUTE",claimHash:e,disputant:{did:t.did||t.id,name:t.name||"Unknown",jurisdiction:t.jurisdiction||null},dispute:{reason:r.reason||"UNSPECIFIED",category:r.category||"ACCURACY",description:r.description||"",evidence:r.evidence||null,requestedAction:r.requestedAction||"REVIEW"},disputedAt:new Date().toISOString(),status:"FILED",priority:r.priority||"NORMAL"},i=vs.sha256(d.Buffer.from(this._canonicalizeWith(n,this.CANONICALIZATION.LEGACY))).toString("hex");return n.disputeHash=i,{success:!0,dispute:n,disputeId:this._generateDisputeId(e),externalOperations:{fileDispute:{endpoint:"POST /claims/"+e+"/disputes",data:n},notifyStakeholders:{endpoint:"POST /notifications/claim-disputed",data:{claimHash:e,disputantDid:n.disputant.did,disputeHash:i}},escalate:{endpoint:"POST /disputes/escalate",data:{disputeHash:i,priority:n.priority}}}}}catch(o){return{success:!1,error:"Dispute preparation failed: "+o.message}}},prepareBulkClaimValidation:function(e,t){try{pr.checkArgument(Array.isArray(e),"Claims must be array"),pr.checkArgument(typeof t=="string","Schema name must be string");var r=[],n=[],i=0;e.forEach(function(a,f){try{var l=this.prepareClaimValidation(a,t);l.success&&l.validation.valid&&i++,r.push({index:f,result:l})}catch(m){n.push({index:f,error:m.message})}}.bind(this));var o=this._generateBatchId(),s=vs.sha256(d.Buffer.from(JSON.stringify(r.map(a=>a.result.validation.claimHash)))).toString("hex");return{success:!0,batchId:o,batchHash:s,totalClaims:e.length,validClaims:i,invalidClaims:e.length-i,validations:r,errors:n,externalOperations:{storeBatch:{endpoint:"POST /claims/batch-validate",data:{batchId:o,batchHash:s,schemaName:t,validations:r}},generateReport:{endpoint:"POST /reports/bulk-validation",data:{batchId:o,summary:{total:e.length,valid:i,invalid:e.length-i}}}}}}catch(a){return{success:!1,error:"Bulk validation preparation failed: "+a.message}}},CANONICALIZATION:{JCS:"jcs",LEGACY:"legacy"},canonicalize:function(e,t){return this._canonicalizeWith(e,this._resolveCanonicalization(t,"LTP.Claim.canonicalize"))},hash:function(e,t){var r=this._canonicalizeWith(e,this._resolveCanonicalization(t,"LTP.Claim.hash"));return vs.sha256(d.Buffer.from(r)).toString("hex")},_canonicalizeWith:function(e,t){if(pr.checkArgument(e&&typeof e=="object","Invalid claim"),t===this.CANONICALIZATION.JCS)return OC.stringify(e);var r=this._sortObjectKeys(e);return JSON.stringify(r)},_resolveCanonicalization:function(e,t){return e===void 0?(RC({what:t+"() without a canonicalization argument",since:"9.2.0",removeIn:"10.0.0",use:t+"(claim, bsv.LTP.Claim.CANONICALIZATION.JCS)",why:"the default sorted-key form is not RFC 8785, so other implementations compute a different claim hash"}),this.CANONICALIZATION.LEGACY):(pr.checkArgument(e===this.CANONICALIZATION.JCS||e===this.CANONICALIZATION.LEGACY,"Unknown canonicalization: "+e+". Expected 'jcs' or 'legacy' (bsv.LTP.Claim.CANONICALIZATION)"),e)},prepareClaimTemplate:function(e,t){t=t||{};try{var r=ho[e];if(!r)return{success:!1,error:"Unknown schema: "+e};var n=this._createTemplateFromSchema(r),i=this._generateFormStructure(r);return{success:!0,schemaName:e,template:n,schema:r,formStructure:i,validation:{required:r.required||[],patterns:this._extractPatterns(r),enums:this._extractEnums(r)},externalOperations:{generateForm:{endpoint:"POST /forms/generate",data:{schemaName:e,formStructure:i,template:n}},saveTemplate:{endpoint:"POST /templates/claim",data:{schemaName:e,template:n,customizations:t.customizations||{}}}}}}catch(o){return{success:!1,error:"Template preparation failed: "+o.message}}},getSchemas:function(){return ho},getSchemaNames:function(){return Object.keys(ho)},getSchema:function(e){return ho[e]||null},addSchema:function(e,t){pr.checkArgument(typeof e=="string","Schema name must be string"),pr.checkArgument(t&&typeof t=="object","Invalid schema"),ho[e]=t},createTemplate:function(e){var t=ho[e];if(!t)throw new Error("Unknown schema: "+e);return this._createTemplateFromSchema(t)},_generateDisputeId:function(e){var t="dispute_"+e+"_"+Date.now();return vs.sha256(d.Buffer.from(t)).toString("hex").substring(0,16)},_generateBatchId:function(){return AC.randomHex(16)},_generateFormStructure:function(e){var t={type:"form",title:e.title||"Legal Claim Form",description:e.description||"",fields:[]};return e.properties&&Object.keys(e.properties).forEach(function(r){var n=e.properties[r],i={name:r,label:this._humanizeFieldName(r),type:this._mapSchemaTypeToFormType(n),required:e.required&&e.required.includes(r),validation:this._extractFieldValidation(n)};n.enum&&(i.options=n.enum.map(function(o){return{value:o,label:this._humanizeValue(o)}}.bind(this))),t.fields.push(i)}.bind(this)),t},_extractPatterns:function(e){var t={};return e.properties&&Object.keys(e.properties).forEach(function(r){var n=e.properties[r];n.pattern&&(t[r]=n.pattern)}),t},_extractEnums:function(e){var t={};return e.properties&&Object.keys(e.properties).forEach(function(r){var n=e.properties[r];n.enum&&(t[r]=n.enum)}),t},_mapSchemaTypeToFormType:function(e){switch(e.type){case"string":return e.enum?"select":e.format==="date"?"date":e.format==="date-time"?"datetime":"text";case"number":case"integer":return"number";case"boolean":return"checkbox";case"array":return"list";case"object":return"fieldset";default:return"text"}},_extractFieldValidation:function(e){var t={};return e.pattern&&(t.pattern=e.pattern),e.minimum!==void 0&&(t.min=e.minimum),e.maximum!==void 0&&(t.max=e.maximum),e.format&&(t.format=e.format),t},_humanizeFieldName:function(e){return e.replace(/([A-Z])/g," $1").replace(/^./,function(t){return t.toUpperCase()}).replace(/_/g," ")},_humanizeValue:function(e){return e.replace(/_/g," ").replace(/\b\w/g,function(t){return t.toUpperCase()})},_validateObject:function(e,t,r,n,i){t.type==="object"?(t.required&&Array.isArray(t.required)&&t.required.forEach(function(o){e.hasOwnProperty(o)||n.push("Missing required field: "+this._getFieldPath(r,o))}.bind(this)),t.properties&&Object.keys(e).forEach(function(o){var s=this._getFieldPath(r,o),a=t.properties[o];a?this._validateValue(e[o],a,s,n,i):i.push("Unknown field: "+s)}.bind(this))):this._validateValue(e,t,r,n,i)},_validateValue:function(e,t,r,n,i){if(t.type){var o=Array.isArray(e)?"array":typeof e;if(o!==t.type){n.push("Invalid type for "+r+": expected "+t.type+", got "+o);return}}if(t.type==="string"&&(t.pattern&&!new RegExp(t.pattern).test(e)&&n.push("Value does not match pattern for "+r),t.enum&&!t.enum.includes(e)&&n.push("Invalid enum value for "+r+": "+e),t.format==="date"&&!this._isValidDate(e)&&n.push("Invalid date format for "+r),t.format==="date-time"&&!this._isValidDateTime(e)&&n.push("Invalid date-time format for "+r)),(t.type==="number"||t.type==="integer")&&(t.minimum!==void 0&&e<t.minimum&&n.push("Value below minimum for "+r+": "+e+" < "+t.minimum),t.maximum!==void 0&&e>t.maximum&&n.push("Value above maximum for "+r+": "+e+" > "+t.maximum),t.type==="integer"&&!Number.isInteger(e)&&n.push("Value must be integer for "+r)),t.type==="array"&&t.items)for(var s=0;s<e.length;s++)this._validateValue(e[s],t.items,r+"["+s+"]",n,i);t.type==="object"&&this._validateObject(e,t,r,n,i)},_sortObjectKeys:function(e){if(Array.isArray(e))return e.map(this._sortObjectKeys.bind(this));if(e!==null&&typeof e=="object"){var t={};return Object.keys(e).sort().forEach(function(r){t[r]=this._sortObjectKeys(e[r])}.bind(this)),t}return e},_createTemplateFromSchema:function(e){if(e.type==="object"){var t={};return e.properties&&Object.keys(e.properties).forEach(function(r){var n=e.properties[r];t[r]=this._getDefaultValue(n)}.bind(this)),t}return this._getDefaultValue(e)},_getDefaultValue:function(e){if(e.default!==void 0)return e.default;switch(e.type){case"string":return e.enum?e.enum[0]:e.format==="date"?"2023-01-01":e.format==="date-time"?new Date().toISOString():"PLACEHOLDER_STRING";case"number":case"integer":return e.minimum||0;case"boolean":return!1;case"array":return[];case"object":return this._createTemplateFromSchema(e);default:return null}},_getFieldPath:function(e,t){return e?e+"."+t:t},_isValidDate:function(e){var t=new Date(e);return!isNaN(t.getTime())&&e.match(/^\d{4}-\d{2}-\d{2}$/)},_isValidDateTime:function(e){var t=new Date(e);return!isNaN(t.getTime())}};Qx.exports=TC});var rI=B((Uq,tI)=>{"use strict";g();var eu=nr(),bs=We(),PC={prepareTokenCommitment:function(e,t){t=t||{},bs.checkArgument(e&&typeof e=="object","Invalid token");try{var r=this._createCommitment(e,t),n=this._formatOpReturn(r,t),i=this._createTxTemplate(n,t);return{success:!0,commitment:r,opReturnData:n,txTemplate:i,preparedAt:new Date().toISOString(),metadata:{tokenId:e.id,purpose:t.purpose||"legal_token_anchor",version:"LTP.v1"}}}catch(o){return{success:!1,error:o.message}}},prepareBatchCommitment:function(e,t){t=t||{},bs.checkArgument(Array.isArray(e),"Tokens must be array");try{var r=this._createBatchCommitment(e,t),n=this._formatOpReturn(r,t),i=this._createTxTemplate(n,t);return{success:!0,batchCommitment:r,opReturnData:n,txTemplate:i,tokenCount:e.length,preparedAt:new Date().toISOString(),metadata:{purpose:t.purpose||"legal_token_batch_anchor",version:"LTP.v1"}}}catch(o){return{success:!1,error:o.message}}},verifyTokenAnchor:function(e,t,r){bs.checkArgument(e&&typeof e=="object","Invalid token"),bs.checkArgument(typeof t=="string","Transaction ID must be string");try{var n=this._createCommitment(e,{}),i=this._extractOpReturn(r);if(!i)return{valid:!1,error:"No OP_RETURN data found in transaction"};var o=this._verifyCommitment(n,i);return{valid:o,chainVerified:!1,txid:t,commitment:n,anchorData:i,verifiedAt:new Date().toISOString()}}catch(s){return{valid:!1,error:s.message}}},formatRevocation:function(e,t){bs.checkArgument(typeof e=="string","Token ID must be string"),bs.checkArgument(t&&typeof t=="object","Invalid revocation data");try{var r={type:"LTP_REVOCATION",tokenId:e,reason:t.reason||"UNSPECIFIED",revokedBy:t.revokedBy||"UNKNOWN",revokedAt:new Date().toISOString(),effectiveDate:t.effectiveDate||new Date().toISOString(),legalBasis:t.legalBasis||null,evidence:t.evidence||null},n=eu.sha256(d.Buffer.from(JSON.stringify(r))).toString("hex");return{success:!0,revocation:r,revocationHash:n,opReturnData:this._formatOpReturn({hash:n,type:"REVOCATION"},{})}}catch(i){return{success:!1,error:i.message}}},_createCommitment:function(e,t){var r=this._canonicalizeToken(e),n={type:"LTP_TOKEN",tokenHash:eu.sha256(d.Buffer.from(r)).toString("hex"),tokenId:e.id,timestamp:new Date().toISOString(),purpose:t.purpose||"legal_token"},i=eu.sha256(d.Buffer.from(JSON.stringify(n))).toString("hex");return{hash:i,data:n,canonical:r}},_createBatchCommitment:function(e,t){var r=[],n=[];e.forEach(function(a){var f=this._createCommitment(a,t);r.push(f.hash),n.push(a.id)}.bind(this));var i=this._createMerkleRoot(r),o={type:"LTP_BATCH",merkleRoot:i,tokenCount:e.length,tokenIds:n,timestamp:new Date().toISOString(),purpose:t.purpose||"batch_anchor"},s=eu.sha256(d.Buffer.from(JSON.stringify(o))).toString("hex");return{hash:s,data:o,merkleRoot:i,tokenHashes:r}},_formatOpReturn:function(e,t){var r=t.prefix||"LTP.v1",n=e.hash;return{prefix:r,data:n,full:r+"."+n,bytes:d.Buffer.from(r+"."+n,"utf8"),size:d.Buffer.from(r+"."+n,"utf8").length}},_createTxTemplate:function(e,t){try{var r={version:1,inputs:[],outputs:[{satoshis:0,script:"OP_RETURN "+e.data}],locktime:0};return t.feeOutput&&r.outputs.push(t.feeOutput),{template:r,opReturn:e,estimatedSize:this._estimateSize(r),instructions:{step1:"Add input UTXOs to cover fees",step2:"Add change output if needed",step3:"Sign transaction with appropriate keys",step4:"Broadcast to BSV network"}}}catch(n){throw new Error("Failed to create transaction template: "+n.message)}},_extractOpReturn:function(e){try{if(!e||!e.outputs)return null;for(var t=0;t<e.outputs.length;t++){var r=e.outputs[t];if(r.script&&r.script.startsWith("OP_RETURN")){var n=r.script.replace("OP_RETURN ","");return{raw:n,decoded:d.Buffer.from(n,"hex").toString("utf8")}}}return null}catch{return null}},_verifyCommitment:function(e,t){try{return!t||!t.decoded?!1:t.decoded.includes(e.hash)}catch{return!1}},_canonicalizeToken:function(e){var t=JSON.parse(JSON.stringify(e));return delete t.proof,delete t.tokenHash,delete t.anchorTx,delete t.anchorBlock,JSON.stringify(this._sortObjectKeys(t))},_createMerkleRoot:function(e){if(e.length===0)return null;if(e.length===1)return e[0];for(var t=e.slice();t.length>1;){for(var r=[],n=0;n<t.length;n+=2){var i=t[n],o=t[n+1]||i,s=d.Buffer.concat([d.Buffer.from(i,"hex"),d.Buffer.from(o,"hex")]),a=eu.sha256(s).toString("hex");r.push(a)}t=r}return t[0]},_estimateSize:function(e){var t=10,r=e.outputs.length*34,n=148;return{base:t+r,withOneInput:t+r+n,bytesPerInput:n}},_sortObjectKeys:function(e){if(Array.isArray(e))return e.map(this._sortObjectKeys.bind(this));if(e!==null&&typeof e=="object"){var t={};return Object.keys(e).sort().forEach(function(r){t[r]=this._sortObjectKeys(e[r])}.bind(this)),t}return e}};tI.exports=PC});var oI=B((qq,iI)=>{"use strict";g();var BC=Pr(),$r=nr(),nI=Ka(),NC=fr(),MC=fo(),cr=We(),kC={prepareSignatureProof:function(e,t,r){r=r||{},cr.checkArgument(e&&typeof e=="object","Invalid token"),cr.checkArgument(t instanceof MC,"Invalid private key");try{var n=this._canonicalizeForSigning(e),i=$r.sha256(d.Buffer.from(n)),o=new nI;o.hashbuf=i,o.privkey=t,o.pubkey=t.toPublicKey(),o.sign();var s=o.sig,a={type:"EcdsaSecp256k1Signature2019",created:new Date().toISOString(),verificationMethod:"did:smartledger:"+t.toPublicKey().toString()+"#keys-1",proofPurpose:r.purpose||"assertionMethod",jws:this._createJWS(i,s),proofValue:s.toDER().toString("hex")};return{success:!0,proof:a,tokenHash:i.toString("hex"),canonical:n,signingKey:{publicKey:t.toPublicKey().toString(),keyId:"did:smartledger:"+t.toPublicKey().toString()+"#keys-1"},externalOperations:{storeProof:{endpoint:"POST /proofs/signature",data:{tokenHash:i.toString("hex"),proof:a,signingKey:t.toPublicKey().toString()}},verifyProof:{endpoint:"POST /proofs/verify-signature",data:{tokenHash:i.toString("hex"),signature:s.toDER().toString("hex"),publicKey:t.toPublicKey().toString()}}}}}catch(f){return{success:!1,error:f.message}}},prepareSignatureVerification:function(e,t){try{if(cr.checkArgument(e&&typeof e=="object","Invalid token"),cr.checkArgument(typeof t=="string","Public key must be string"),!e.proof)return{success:!1,error:"No proof found in token"};var r=this._canonicalizeForSigning(e),n=$r.sha256(d.Buffer.from(r)),i=NC.fromDER(d.Buffer.from(e.proof.proofValue,"hex")),o={tokenHash:n.toString("hex"),signature:i.toDER().toString("hex"),publicKey:t,proof:e.proof,canonical:r},s=new nI;s.hashbuf=n,s.sig=i,s.pubkey=BC.fromString(t);var a=s.verify()===!0;return{success:!0,verification:{valid:a,tokenHash:n.toString("hex"),signatureValid:a,publicKey:t,verifiedAt:new Date().toISOString()},verificationData:o,externalOperations:{recordVerification:{endpoint:"POST /proofs/verification-record",data:{tokenHash:n.toString("hex"),result:a,publicKey:t,verifiedAt:new Date().toISOString()}},auditVerification:{endpoint:"POST /audit/proof-verification",data:{tokenId:e.id,proofType:e.proof.type,result:a,verifier:t}}}}}catch(f){return{success:!1,error:f.message}}},prepareSelectiveDisclosure:function(e,t,r){cr.checkArgument(e&&typeof e=="object","Invalid token"),cr.checkArgument(Array.isArray(t),"Revealed fields must be array"),cr.checkArgument(typeof r=="string","Nonce must be string");try{var n=this._createFieldCommitments(e,r),i=this._createMerkleTree(n),o=[],s=[];t.forEach(function(f){var l=this._getNestedValue(e,f),m=this._findFieldCommitment(n,f);if(m){o.push({path:f,value:l,commitment:m.hash,salt:m.salt});var y=this._generateMerkleProof(i,m.index);s.push({path:f,leafIndex:m.index,proof:y})}}.bind(this));var a={type:"LegalTokenSelectiveDisclosure",created:new Date().toISOString(),proofPurpose:"selectiveDisclosure",verificationMethod:e.proof?e.proof.verificationMethod:null,nonce:r,merkleRoot:i.root,disclosures:o,merkleProofs:s,totalFields:n.length};return{success:!0,proof:a,hiddenFieldCount:n.length-o.length,revealedFieldCount:o.length,externalOperations:{storeDisclosure:{endpoint:"POST /proofs/selective-disclosure",data:{tokenId:e.id,proof:a,merkleRoot:i.root}},verifyDisclosure:{endpoint:"POST /proofs/verify-disclosure",data:{proof:a,expectedNonce:r}},auditDisclosure:{endpoint:"POST /audit/selective-disclosure",data:{tokenId:e.id,revealedFields:t,totalFields:n.length,disclosedAt:new Date().toISOString()}}}}}catch(f){return{success:!1,error:f.message}}},prepareSelectiveDisclosureVerification:function(e,t){try{if(cr.checkArgument(e&&typeof e=="object","Invalid proof"),cr.checkArgument(typeof t=="string","Expected nonce must be string"),e.nonce!==t)return{success:!1,error:"Nonce mismatch"};var r=[],n=[];e.disclosures.forEach(function(o,s){var a=e.merkleProofs[s],f=this._hashField(o.path,o.value,o.salt);if(f!==o.commitment){n.push("Invalid commitment for field: "+o.path);return}var l=this._verifyMerkleProof(o.commitment,a.leafIndex,a.proof,e.merkleRoot);l?r.push({path:o.path,value:o.value,verified:!0}):n.push("Invalid Merkle proof for field: "+o.path)}.bind(this));var i={valid:n.length===0,errors:n,disclosures:r,merkleRoot:e.merkleRoot,totalFields:e.totalFields,verifiedAt:new Date().toISOString()};return{success:!0,verification:i,externalOperations:{recordVerification:{endpoint:"POST /proofs/disclosure-verification",data:{proofId:e.id||"unknown",result:i.valid,verifiedFields:r.length,totalFields:e.totalFields,verifiedAt:i.verifiedAt}},auditVerification:{endpoint:"POST /audit/disclosure-verification",data:{merkleRoot:e.merkleRoot,disclosuresVerified:r.length,errors:n.length,result:i.valid}}}}}catch(o){return{success:!1,error:o.message}}},prepareLegalValidityProof:function(e,t,r){cr.checkArgument(e&&typeof e=="object","Invalid token"),cr.checkArgument(t&&typeof t=="object","Invalid jurisdiction"),cr.checkArgument(typeof r=="string","Nonce must be string");try{var n=t.requirements||[],i=[],o=!0;n.forEach(function(a){var f=this._checkLegalRequirement(e,a);i.push(f),f.satisfied||(o=!1)}.bind(this));var s={type:"LegalValidityProof",created:new Date().toISOString(),proofPurpose:"legalValidity",jurisdiction:t.code,nonce:r,valid:o,checks:i,complianceHash:this._hashCompliance(e,t,r)};return{success:!0,proof:s,valid:o,complianceReport:{jurisdiction:t.code,totalRequirements:n.length,satisfiedRequirements:i.filter(a=>a.satisfied).length,failedRequirements:i.filter(a=>!a.satisfied).length,overallCompliance:o},externalOperations:{submitCompliance:{endpoint:"POST /compliance/legal-validity",data:{tokenId:e.id,jurisdiction:t.code,proof:s,complianceReport:{jurisdiction:t.code,totalRequirements:n.length,satisfiedRequirements:i.filter(a=>a.satisfied).length,failedRequirements:i.filter(a=>!a.satisfied).length,overallCompliance:o}}},auditCompliance:{endpoint:"POST /audit/compliance-check",data:{tokenId:e.id,jurisdiction:t.code,result:o,checkedAt:new Date().toISOString(),requirements:i}},notifyRegulator:o?null:{endpoint:"POST /notifications/compliance-failure",data:{tokenId:e.id,jurisdiction:t.code,failedRequirements:i.filter(a=>!a.satisfied)}}}}}catch(a){return{success:!1,error:a.message}}},prepareZeroKnowledgeProof:function(e,t,r){cr.checkArgument(e&&typeof e=="object","Invalid token"),cr.checkArgument(t&&typeof t=="object","Invalid statement"),cr.checkArgument(typeof r=="string","Nonce must be string");try{var n=$r.sha256(d.Buffer.from(this._canonicalizeForSigning(e)+r)).toString("hex"),i={type:"LegalTokenZKProof",created:new Date().toISOString(),proofPurpose:"zeroKnowledge",statement:{claim:t.claim||"UNSPECIFIED",predicate:t.predicate||"SATISFIES",threshold:t.threshold||null},commitment:n,nonce:r,proofData:this._generateZKProofData(e,t,r)};return{success:!0,proof:i,commitment:n,externalOperations:{storeZKProof:{endpoint:"POST /proofs/zero-knowledge",data:{tokenId:e.id,proof:i,statement:t}},verifyZKProof:{endpoint:"POST /proofs/verify-zk",data:{proof:i,expectedNonce:r}},auditZKProof:{endpoint:"POST /audit/zk-proof",data:{tokenId:e.id,statement:t.claim,proofGenerated:new Date().toISOString()}}}}}catch(o){return{success:!1,error:o.message}}},_generateZKProofData:function(e,t,r){var n={challenge:$r.sha256(d.Buffer.from(t.claim+r)).toString("hex"),response:$r.sha256(d.Buffer.from(this._canonicalizeForSigning(e)+t.claim)).toString("hex"),witness:$r.sha256(d.Buffer.from(r+e.id+t.predicate)).toString("hex")};return n},_createJWS:function(e,t){var r={alg:"ES256K",typ:"JWT"},n=d.Buffer.from(JSON.stringify(r)).toString("base64url"),i=e.toString("base64url"),o=t.toDER().toString("base64url");return n+".."+o},_canonicalizeForSigning:function(e){var t=JSON.parse(JSON.stringify(e));delete t.proof,delete t.tokenHash;var r=this._sortObjectKeys(t);return JSON.stringify(r)},_createFieldCommitments:function(e,t){var r=[],n=0;return this._traverseObject(e,"",function(i,o){if(i!=="proof"&&i!=="tokenHash"){var s=$r.sha256(d.Buffer.from(t+i+n)).toString("hex"),a=this._hashField(i,o,s);r.push({path:i,value:o,salt:s,hash:a,index:n}),n++}}.bind(this)),r},_hashField:function(e,t,r){var n=e+":"+JSON.stringify(t)+":"+r;return $r.sha256(d.Buffer.from(n)).toString("hex")},_createMerkleTree:function(e){var t=e.map(function(m){return m.hash});if(t.length===0)return{root:null,levels:[]};for(var r=[t],n=t;n.length>1;){for(var i=[],o=0;o<n.length;o+=2){var s=n[o],a=n[o+1]||s,f=d.Buffer.concat([d.Buffer.from(s,"hex"),d.Buffer.from(a,"hex")]),l=$r.sha256(f).toString("hex");i.push(l)}r.push(i),n=i}return{root:n[0],levels:r}},_generateMerkleProof:function(e,t){for(var r=[],n=t,i=0;i<e.levels.length-1;i++){var o=e.levels[i],s=n%2===0,a=s?n+1:n-1;a<o.length&&r.push({hash:o[a],isLeft:!s}),n=Math.floor(n/2)}return r},_verifyMerkleProof:function(e,t,r,n){for(var i=e,o=t,s=0;s<r.length;s++){var a=r[s],f=o%2===0,l;a.isLeft?l=d.Buffer.concat([d.Buffer.from(a.hash,"hex"),d.Buffer.from(i,"hex")]):l=d.Buffer.concat([d.Buffer.from(i,"hex"),d.Buffer.from(a.hash,"hex")]),i=$r.sha256(l).toString("hex"),o=Math.floor(o/2)}return i===n},_traverseObject:function(e,t,r){Array.isArray(e)?e.forEach(function(n,i){var o=t+"["+i+"]";this._traverseObject(n,o,r)}.bind(this)):e!==null&&typeof e=="object"?Object.keys(e).forEach(function(n){var i=t?t+"."+n:n;this._traverseObject(e[n],i,r)}.bind(this)):r(t,e)},_getNestedValue:function(e,t){return t.split(".").reduce(function(r,n){return r&&r[n]},e)},_findFieldCommitment:function(e,t){return e.find(function(r){return r.path===t})},_checkLegalRequirement:function(e,t){switch(t.type){case"field_present":var r=this._getNestedValue(e,t.field);return{requirement:t.type,field:t.field,satisfied:r!=null};case"field_value":var r=this._getNestedValue(e,t.field);return{requirement:t.type,field:t.field,satisfied:r===t.expectedValue};case"temporal_validity":var n=new Date,i=new Date(e.issuanceDate);return{requirement:t.type,satisfied:i<=n};default:return{requirement:t.type,satisfied:!1,error:"Unknown requirement type"}}},_hashCompliance:function(e,t,r){var n={tokenId:e.id,jurisdiction:t.code,nonce:r,timestamp:new Date().toISOString()};return $r.sha256(d.Buffer.from(JSON.stringify(n))).toString("hex")},_sortObjectKeys:function(e){if(Array.isArray(e))return e.map(this._sortObjectKeys.bind(this));if(e!==null&&typeof e=="object"){var t={};return Object.keys(e).sort().forEach(function(r){t[r]=this._sortObjectKeys(e[r])}.bind(this)),t}return e}};iI.exports=kC});var uI=B((Gq,aI)=>{"use strict";g();var tu=nr(),jq=uo(),Kq=jp(),gr=We(),sI=Ja(),CC={prepareRegistry:function(e){e=e||{},gr.checkArgument(typeof e=="object","Config must be object");var t={id:e.id||this._generateRegistryId(),name:e.name||"Legal Token Registry",jurisdiction:e.jurisdiction||"GLOBAL",authority:e.authority||null,created:new Date().toISOString(),version:"1.0.0",config:{allowPublicRegistration:e.allowPublicRegistration||!1,requireApproval:e.requireApproval||!0,enableRevocation:e.enableRevocation!==!1,enableAuditTrail:e.enableAuditTrail!==!1,retentionPeriod:e.retentionPeriod||"7Y",complianceLevel:e.complianceLevel||"STANDARD"},dataStructure:{tokens:"Map<tokenId, registrationRecord>",revocations:"Map<tokenId, revocationRecord>",auditLog:"Array<auditEntry>",statistics:{totalTokens:0,activeTokens:0,revokedTokens:0,registrations:0}},externalStorage:{required:!0,type:"database_or_blockchain",endpoints:{store:"POST /registry/{id}/tokens",retrieve:"GET /registry/{id}/tokens/{tokenId}",search:"GET /registry/{id}/search",revoke:"POST /registry/{id}/revocations"}}},r=this._prepareAuditEntry({action:"REGISTRY_CREATED",actor:e.authority,timestamp:t.created,metadata:{jurisdiction:t.jurisdiction,config:t.config}});return{success:!0,registry:t,initialAudit:r,instructions:{step1:"Store registry configuration in external system",step2:"Initialize token storage with provided data structure",step3:"Set up audit logging with provided templates",step4:"Configure external endpoints for registry operations"}}},prepareTokenRegistration:function(e,t,r){r=r||{},gr.checkArgument(e&&typeof e=="object","Invalid token"),gr.checkArgument(t&&typeof t=="object","Invalid registry config");try{var n=this._validateTokenForRegistration(e,t);if(!n.valid)return{success:!1,error:"Token validation failed: "+n.error};var i={tokenId:e.id,tokenHash:this._hashToken(e),token:e,status:t.requireApproval?"PENDING":"ACTIVE",registeredBy:r.registeredBy||"UNKNOWN",registeredAt:new Date().toISOString(),approvedBy:null,approvedAt:null,metadata:r.metadata||{},compliance:{jurisdiction:e.jurisdiction||t.jurisdiction,level:this._calculateComplianceLevel(e),checks:n.checks||[]}},o=this._prepareAuditEntry({action:"TOKEN_REGISTERED",actor:r.registeredBy,tokenId:e.id,timestamp:i.registeredAt,metadata:{status:i.status,tokenType:e.type,compliance:i.compliance}});return{success:!0,registrationRecord:i,auditEntry:o,registrationId:this._generateRegistrationId(e.id),validation:n,externalOperations:{store:{endpoint:"POST /registry/"+t.id+"/tokens",data:i},audit:{endpoint:"POST /registry/"+t.id+"/audit",data:o}}}}catch(s){return{success:!1,error:s.message}}},prepareTokenApproval:function(e,t,r){try{gr.checkArgument(typeof e=="string","Token ID must be string"),gr.checkArgument(typeof t=="string","Approver must be string"),gr.checkArgument(r&&typeof r=="object","Invalid registry config");var n={tokenId:e,status:"ACTIVE",approvedBy:t,approvedAt:new Date().toISOString()},i=this._prepareAuditEntry({action:"TOKEN_APPROVED",actor:t,tokenId:e,timestamp:n.approvedAt});return{success:!0,approvalData:n,auditEntry:i,externalOperations:{update:{endpoint:"PUT /registry/"+r.id+"/tokens/"+e+"/status",data:n},audit:{endpoint:"POST /registry/"+r.id+"/audit",data:i}}}}catch(o){return{success:!1,error:o.message}}},prepareTokenRevocation:function(e,t,r){try{if(gr.checkArgument(typeof e=="string","Token ID must be string"),gr.checkArgument(t&&typeof t=="object","Invalid revocation"),gr.checkArgument(r&&typeof r=="object","Invalid registry config"),!r.enableRevocation)return{success:!1,error:"Revocation is disabled for this registry"};var n={tokenId:e,reason:t.reason||"UNSPECIFIED",revokedBy:t.revokedBy||"UNKNOWN",revokedAt:new Date().toISOString(),effectiveDate:t.effectiveDate||new Date().toISOString(),legalBasis:t.legalBasis||null,evidence:t.evidence||null,revocationHash:this._generateRevocationHash(e,t)},i={tokenId:e,status:"REVOKED",revokedAt:n.revokedAt,revocationReason:n.reason},o=this._prepareAuditEntry({action:"TOKEN_REVOKED",actor:t.revokedBy,tokenId:e,timestamp:n.revokedAt,metadata:{reason:n.reason,legalBasis:n.legalBasis}});return{success:!0,revocationRecord:n,statusUpdate:i,auditEntry:o,revocationId:this._generateRevocationId(e),externalOperations:{storeRevocation:{endpoint:"POST /registry/"+r.id+"/revocations",data:n},updateStatus:{endpoint:"PUT /registry/"+r.id+"/tokens/"+e+"/status",data:i},audit:{endpoint:"POST /registry/"+r.id+"/audit",data:o}}}}catch(s){return{success:!1,error:s.message}}},prepareTokenStatusQuery:function(e,t){try{return gr.checkArgument(typeof e=="string","Token ID must be string"),gr.checkArgument(t&&typeof t=="object","Invalid registry config"),{success:!0,query:{tokenId:e,registryId:t.id},externalOperations:{retrieve:{endpoint:"GET /registry/"+t.id+"/tokens/"+e,method:"GET"},checkRevocation:{endpoint:"GET /registry/"+t.id+"/revocations/"+e,method:"GET"}},expectedResponse:{found:"boolean",status:"string (PENDING|ACTIVE|REVOKED)",registeredAt:"ISO datetime",registeredBy:"string",approvedAt:"ISO datetime or null",approvedBy:"string or null",revokedAt:"ISO datetime or null",revocationReason:"string or null",compliance:"object",revocation:"object or null"}}}catch(r){return{success:!1,error:r.message}}},prepareTokenSearch:function(e,t){e=e||{};try{gr.checkArgument(t&&typeof t=="object","Invalid registry config");var r=[];e.status&&r.push("status="+encodeURIComponent(e.status)),e.type&&r.push("type="+encodeURIComponent(e.type)),e.registeredBy&&r.push("registeredBy="+encodeURIComponent(e.registeredBy)),e.jurisdiction&&r.push("jurisdiction="+encodeURIComponent(e.jurisdiction)),e.dateFrom&&r.push("dateFrom="+encodeURIComponent(e.dateFrom)),e.dateTo&&r.push("dateTo="+encodeURIComponent(e.dateTo)),e.includeTokens&&r.push("includeTokens=true"),e.sortBy&&r.push("sortBy="+encodeURIComponent(e.sortBy)),e.sortOrder&&r.push("sortOrder="+encodeURIComponent(e.sortOrder));var n=e.offset||0,i=e.limit||100;r.push("offset="+n),r.push("limit="+i);var o=r.length>0?"?"+r.join("&"):"";return{success:!0,searchCriteria:e,externalOperations:{search:{endpoint:"GET /registry/"+t.id+"/search"+o,method:"GET"}},expectedResponse:{success:"boolean",results:"Array<tokenRecord>",totalCount:"number",totalRegistrations:"number",offset:"number",limit:"number",hasMore:"boolean"}}}catch(s){return{success:!1,error:s.message}}},prepareStatisticsQuery:function(e){return gr.checkArgument(e&&typeof e=="object","Invalid registry config"),{success:!0,query:{registryId:e.id},externalOperations:{getStatistics:{endpoint:"GET /registry/"+e.id+"/statistics",method:"GET"}},expectedResponse:{id:"string",name:"string",jurisdiction:"string",created:"ISO datetime",statistics:{totalTokens:"number",activeTokens:"number",revokedTokens:"number",registrations:"number"},auditEntries:"number",lastActivity:"ISO datetime"}}},prepareAuditLogQuery:function(e,t){if(t=t||{},gr.checkArgument(e&&typeof e=="object","Invalid registry config"),!e.enableAuditTrail)return{success:!1,error:"Audit trail is disabled"};var r=[];t.action&&r.push("action="+encodeURIComponent(t.action)),t.actor&&r.push("actor="+encodeURIComponent(t.actor)),t.tokenId&&r.push("tokenId="+encodeURIComponent(t.tokenId)),t.dateFrom&&r.push("dateFrom="+encodeURIComponent(t.dateFrom)),t.dateTo&&r.push("dateTo="+encodeURIComponent(t.dateTo));var n=t.offset||0,i=t.limit||100;r.push("offset="+n),r.push("limit="+i);var o=r.length>0?"?"+r.join("&"):"";return{success:!0,auditOptions:t,externalOperations:{getAuditLog:{endpoint:"GET /registry/"+e.id+"/audit"+o,method:"GET"}},expectedResponse:{success:"boolean",entries:"Array<auditEntry>",totalEntries:"number",offset:"number",limit:"number",hasMore:"boolean"}}},_generateRegistryId:function(){return"reg_"+sI.randomHex(16)},_generateRegistrationId:function(e){var t="reg_"+e+"_"+Date.now();return tu.sha256(d.Buffer.from(t)).toString("hex").substring(0,16)},_generateRevocationId:function(e){var t="rev_"+e+"_"+Date.now();return tu.sha256(d.Buffer.from(t)).toString("hex").substring(0,16)},_hashToken:function(e){var t=JSON.parse(JSON.stringify(e));return delete t.proof,delete t.tokenHash,tu.sha256(d.Buffer.from(JSON.stringify(t))).toString("hex")},_generateRevocationHash:function(e,t){var r=e+(t.reason||"")+(t.revokedBy||"")+Date.now();return tu.sha256(d.Buffer.from(r)).toString("hex")},_validateTokenForRegistration:function(e,t){var r=[],n=!0;return e.id?r.push({field:"id",valid:!0}):(r.push({field:"id",valid:!1,error:"Missing token ID"}),n=!1),e.type?r.push({field:"type",valid:!0}):(r.push({field:"type",valid:!1,error:"Missing token type"}),n=!1),e.issuanceDate?r.push({field:"issuanceDate",valid:!0}):(r.push({field:"issuanceDate",valid:!1,error:"Missing issuance date"}),n=!1),e.proof?r.push({field:"proof",valid:!0}):(r.push({field:"proof",valid:!1,error:"Missing cryptographic proof"}),n=!1),{valid:n,checks:r}},_calculateComplianceLevel:function(e){var t="BASIC";return e.proof&&e.proof.type&&(t="STANDARD"),e.jurisdiction&&e.legalBasis&&(t="ENHANCED"),e.attestations&&e.attestations.length>0&&(t="PREMIUM"),t},_prepareAuditEntry:function(e){var t={id:this._generateAuditId(),action:e.action,actor:e.actor||"SYSTEM",tokenId:e.tokenId||null,timestamp:e.timestamp||new Date().toISOString(),metadata:e.metadata||{},hash:this._generateAuditHash(e)};return t},_generateAuditId:function(){return"audit_"+sI.randomHex(32)},_generateAuditHash:function(e){var t=(e.action||"")+(e.actor||"")+(e.tokenId||"")+(e.timestamp||"");return tu.sha256(d.Buffer.from(t)).toString("hex").substring(0,16)}};aI.exports=CC});var hI=B((Wq,lI)=>{"use strict";g();var t0=Pr(),r0=nr(),fI=Ka(),LC=fr(),cI=fo(),_r=We(),DC=Ja();function UC(e,t){if(t=t||{},t.issuerPublicKey)return t.issuerPublicKey instanceof t0?t.issuerPublicKey:t0.fromString(t.issuerPublicKey);var r=e&&e.issuer;if(typeof r!="string")return null;try{var n=r.split("#")[0].split(":")[2];return n?t0.fromString(n):null}catch{return null}}var Wc={CORRELATIVE_OBLIGATION:"CorrelativeObligation",CONTRACTUAL_OBLIGATION:"ContractualObligation",PAYMENT_OBLIGATION:"PaymentObligation",DELIVERY_OBLIGATION:"DeliveryObligation",PERFORMANCE_OBLIGATION:"PerformanceObligation",MAINTENANCE_OBLIGATION:"MaintenanceObligation",COMPLIANCE_OBLIGATION:"ComplianceObligation",REPORTING_OBLIGATION:"ReportingObligation",CONFIDENTIALITY_OBLIGATION:"ConfidentialityObligation",NON_COMPETE_OBLIGATION:"NonCompeteObligation",INDEMNIFICATION_OBLIGATION:"IndemnificationObligation",WARRANTY_OBLIGATION:"WarrantyObligation",SUPPORT_OBLIGATION:"SupportObligation",REGULATORY_OBLIGATION:"RegulatoryObligation",FIDUCIARY_OBLIGATION:"FiduciaryObligation"},_s={CRITICAL:"CRITICAL",HIGH:"HIGH",MEDIUM:"MEDIUM",LOW:"LOW",DEFERRED:"DEFERRED"},yr={PENDING:"PENDING",ACTIVE:"ACTIVE",IN_PROGRESS:"IN_PROGRESS",COMPLETED:"COMPLETED",OVERDUE:"OVERDUE",BREACHED:"BREACHED",WAIVED:"WAIVED",TERMINATED:"TERMINATED"},zc={prepareObligationToken:function(e,t,r,n,i,o){o=o||{},_r.checkArgument(typeof e=="string","Obligation type must be string"),_r.checkArgument(typeof t=="string","Issuer DID must be string"),_r.checkArgument(typeof r=="string","Obligor DID must be string"),_r.checkArgument(n&&typeof n=="object","Obligation must be object"),_r.checkArgument(i instanceof cI,"Invalid issuer private key");var s=Object.values(Wc);_r.checkArgument(s.includes(e),"Invalid obligation type: "+e);try{var a={"@context":["https://www.w3.org/2018/credentials/v1","https://smartledger.technology/contexts/ltp/v1"],id:"urn:uuid:"+this._generateUUID(),type:["VerifiableCredential","LegalObligationToken",e],issuer:t,issuanceDate:new Date().toISOString(),credentialSubject:{id:r,obligationType:e,obligation:n,jurisdiction:o.jurisdiction||"US",priority:o.priority||_s.MEDIUM,status:yr.PENDING,dueDate:o.dueDate||null,effectiveDate:o.effectiveDate||new Date().toISOString(),expirationDate:o.expirationDate||null,correlativeRight:o.correlativeRight||null,rightHolder:o.rightHolder||null,enforceable:o.enforceable!==!1,penalties:o.penalties||null,remedies:o.remedies||null}};o.metadata&&(a.credentialSubject.metadata=o.metadata);var f=this._signToken(a,i);return{success:!0,obligationToken:f,tokenHash:f.tokenHash,metadata:{type:e,issuer:t,obligor:r,priority:a.credentialSubject.priority,status:a.credentialSubject.status,jurisdiction:a.credentialSubject.jurisdiction,dueDate:a.credentialSubject.dueDate,correlativeRight:a.credentialSubject.correlativeRight},externalOperations:{storeToken:{endpoint:"POST /obligations/tokens",data:{token:f,metadata:{type:e,issuer:t,obligor:r,priority:a.credentialSubject.priority,status:a.credentialSubject.status,jurisdiction:a.credentialSubject.jurisdiction,dueDate:a.credentialSubject.dueDate,correlativeRight:a.credentialSubject.correlativeRight}}},indexToken:{endpoint:"POST /obligations/index",data:{tokenId:f.id,tokenHash:f.tokenHash,type:e,issuer:t,obligor:r,issuedAt:f.issuanceDate,dueDate:a.credentialSubject.dueDate,priority:a.credentialSubject.priority}},notifyObligor:{endpoint:"POST /notifications/obligation-issued",data:{tokenId:f.id,issuer:t,obligor:r,obligationType:e,dueDate:a.credentialSubject.dueDate,priority:a.credentialSubject.priority}},scheduleReminders:a.credentialSubject.dueDate?{endpoint:"POST /obligations/schedule-reminders",data:{tokenId:f.id,obligor:r,dueDate:a.credentialSubject.dueDate,reminderSchedule:o.reminderSchedule||["7d","3d","1d"]}}:null}}}catch(l){return{success:!1,error:l.message}}},prepareObligationVerification:function(e,t){t=t||{};try{var r=[],n=[];this._validateTokenStructure(e,r),this._verifyTokenSignature(e,r,t),this._validateTokenTemporal(e,r,n),this._validateObligationType(e,r),this._validateObligationStatus(e,r,n),this._validateObligationPriority(e,n);var i={valid:r.length===0,errors:r,warnings:n,issuerDID:e.issuer,obligorDID:e.credentialSubject?e.credentialSubject.id:null,obligationType:e.credentialSubject?e.credentialSubject.obligationType:null,status:e.credentialSubject?e.credentialSubject.status:null,priority:e.credentialSubject?e.credentialSubject.priority:null,isOverdue:this._checkIfOverdue(e),verifiedAt:new Date().toISOString()};return{success:!0,verification:i,externalOperations:{recordVerification:{endpoint:"POST /obligations/verification-record",data:{tokenId:e.id,result:i.valid,errors:r,warnings:n,verifiedAt:i.verifiedAt,isOverdue:i.isOverdue}},auditVerification:{endpoint:"POST /audit/obligation-verification",data:{tokenId:e.id,obligationType:i.obligationType,issuer:i.issuerDID,obligor:i.obligorDID,result:i.valid,verifiedAt:i.verifiedAt}},updateStatus:i.isOverdue&&e.credentialSubject.status===yr.ACTIVE?{endpoint:"PUT /obligations/tokens/"+e.id+"/status",data:{status:yr.OVERDUE,updatedAt:i.verifiedAt,reason:"Due date passed"}}:null}}}catch(o){return{success:!1,error:"Verification preparation failed: "+o.message}}},prepareObligationFulfillment:function(e,t,r,n){n=n||{},_r.checkArgument(e&&typeof e=="object","Invalid token"),_r.checkArgument(t&&typeof t=="object","Invalid fulfillment"),_r.checkArgument(r instanceof cI,"Invalid obligor key");try{var i=this.prepareObligationVerification(e,{});if(!i.success||!i.verification.valid)return{success:!1,error:"Cannot fulfill invalid obligation: "+i.verification.errors.join(", ")};if(e.credentialSubject.status===yr.COMPLETED)return{success:!1,error:"Obligation already fulfilled"};if(e.credentialSubject.status===yr.TERMINATED)return{success:!1,error:"Obligation has been terminated"};var o={"@context":["https://www.w3.org/2018/credentials/v1","https://smartledger.technology/contexts/ltp/v1"],id:"urn:uuid:"+this._generateUUID(),type:["VerifiableCredential","ObligationFulfillment"],issuer:e.credentialSubject.id,issuanceDate:new Date().toISOString(),credentialSubject:{id:e.id,fulfillmentType:t.type||"FULL_FULFILLMENT",fulfillmentDate:new Date().toISOString(),evidence:t.evidence||null,description:t.description||"",completionPercentage:t.completionPercentage||100,attestations:t.attestations||[],notes:t.notes||null}},s=this._signToken(o,r),a=o.credentialSubject.completionPercentage>=100?yr.COMPLETED:yr.IN_PROGRESS;return{success:!0,fulfillmentRecord:s,newStatus:a,fulfillmentId:s.id,externalOperations:{recordFulfillment:{endpoint:"POST /obligations/fulfillments",data:{obligationId:e.id,fulfillmentRecord:s,obligor:e.credentialSubject.id,fulfillmentDate:o.credentialSubject.fulfillmentDate,completionPercentage:o.credentialSubject.completionPercentage}},updateStatus:{endpoint:"PUT /obligations/tokens/"+e.id+"/status",data:{status:a,fulfillmentId:s.id,updatedAt:o.credentialSubject.fulfillmentDate,completionPercentage:o.credentialSubject.completionPercentage}},notifyRightHolder:e.credentialSubject.rightHolder?{endpoint:"POST /notifications/obligation-fulfilled",data:{obligationId:e.id,fulfillmentId:s.id,obligor:e.credentialSubject.id,rightHolder:e.credentialSubject.rightHolder,completionPercentage:o.credentialSubject.completionPercentage,newStatus:a}}:null,auditFulfillment:{endpoint:"POST /audit/obligation-fulfillment",data:{obligationId:e.id,fulfillmentId:s.id,obligor:e.credentialSubject.id,fulfilledAt:o.credentialSubject.fulfillmentDate,completionPercentage:o.credentialSubject.completionPercentage}}}}}catch(f){return{success:!1,error:f.message}}},prepareObligationBreachAssessment:function(e,t,r){_r.checkArgument(e&&typeof e=="object","Invalid token"),_r.checkArgument(t&&typeof t=="object","Invalid breach details"),_r.checkArgument(r&&typeof r=="object","Invalid assessor");try{var n={"@context":["https://www.w3.org/2018/credentials/v1","https://smartledger.technology/contexts/ltp/v1"],id:"urn:uuid:"+this._generateUUID(),type:["VerifiableCredential","ObligationBreachAssessment"],issuer:r.did||r.id,issuanceDate:new Date().toISOString(),credentialSubject:{id:e.id,breachType:t.type||"MATERIAL_BREACH",breachDate:t.date||new Date().toISOString(),description:t.description||"",severity:t.severity||"MODERATE",evidence:t.evidence||[],assessor:{did:r.did||r.id,name:r.name||"Unknown",authority:r.authority||null,jurisdiction:r.jurisdiction||null},damages:t.damages||null,recommendedRemedies:t.recommendedRemedies||[],assessmentDate:new Date().toISOString()}},i=r0.sha256(d.Buffer.from(JSON.stringify(n))).toString("hex");return n.credentialSubject.assessmentHash=i,{success:!0,breachAssessment:n,breachId:n.id,severity:t.severity||"MODERATE",externalOperations:{recordBreach:{endpoint:"POST /obligations/breaches",data:{obligationId:e.id,breachAssessment:n,obligor:e.credentialSubject.id,rightHolder:e.credentialSubject.rightHolder,breachDate:t.date||new Date().toISOString(),severity:t.severity||"MODERATE"}},updateStatus:{endpoint:"PUT /obligations/tokens/"+e.id+"/status",data:{status:yr.BREACHED,breachId:n.id,breachDate:t.date||new Date().toISOString(),updatedAt:new Date().toISOString()}},notifyParties:{endpoint:"POST /notifications/obligation-breached",data:{obligationId:e.id,breachId:n.id,obligor:e.credentialSubject.id,rightHolder:e.credentialSubject.rightHolder,breachType:t.type||"MATERIAL_BREACH",severity:t.severity||"MODERATE"}},escalateBreach:t.severity==="CRITICAL"?{endpoint:"POST /legal/escalate-breach",data:{obligationId:e.id,breachId:n.id,severity:t.severity,jurisdiction:e.credentialSubject.jurisdiction}}:null,auditBreach:{endpoint:"POST /audit/obligation-breach",data:{obligationId:e.id,breachId:n.id,obligor:e.credentialSubject.id,assessedAt:n.credentialSubject.assessmentDate,severity:t.severity||"MODERATE"}}}}}catch(o){return{success:!1,error:o.message}}},prepareObligationMonitoringReport:function(e,t){t=t||{},_r.checkArgument(Array.isArray(e),"Obligations must be array");try{var r={reportId:"rpt_"+this._generateUUID(),generatedAt:new Date().toISOString(),criteria:t,summary:{totalObligations:e.length,byStatus:{},byPriority:{},byType:{},overdue:0,dueSoon:0,completed:0},obligations:[],alerts:[],recommendations:[]},n=new Date,i=new Date(n.getTime()+10080*60*1e3);return e.forEach(function(o){var s={id:o.id,type:o.credentialSubject.obligationType,status:o.credentialSubject.status,priority:o.credentialSubject.priority,obligor:o.credentialSubject.id,dueDate:o.credentialSubject.dueDate,isOverdue:this._checkIfOverdue(o),isDueSoon:!1};if(o.credentialSubject.dueDate){var a=new Date(o.credentialSubject.dueDate);s.isDueSoon=a<=i&&a>n}r.summary.byStatus[s.status]=(r.summary.byStatus[s.status]||0)+1,r.summary.byPriority[s.priority]=(r.summary.byPriority[s.priority]||0)+1,r.summary.byType[s.type]=(r.summary.byType[s.type]||0)+1,s.isOverdue&&r.summary.overdue++,s.isDueSoon&&r.summary.dueSoon++,s.status===yr.COMPLETED&&r.summary.completed++,s.isOverdue&&s.priority===_s.CRITICAL&&r.alerts.push({type:"CRITICAL_OVERDUE",obligationId:o.id,message:"Critical obligation is overdue",priority:"HIGH"}),s.isDueSoon&&s.priority===_s.HIGH&&r.alerts.push({type:"HIGH_PRIORITY_DUE_SOON",obligationId:o.id,message:"High priority obligation due soon",priority:"MEDIUM"}),r.obligations.push(s)}.bind(this)),r.summary.overdue>0&&r.recommendations.push({type:"OVERDUE_MANAGEMENT",message:"Consider prioritizing overdue obligations",count:r.summary.overdue}),r.summary.dueSoon>5&&r.recommendations.push({type:"WORKLOAD_MANAGEMENT",message:"High number of obligations due soon - consider workload distribution",count:r.summary.dueSoon}),{success:!0,report:r,externalOperations:{storeReport:{endpoint:"POST /obligations/monitoring-reports",data:{report:r,generatedAt:r.generatedAt}},sendAlerts:r.alerts.length>0?{endpoint:"POST /notifications/obligation-alerts",data:{reportId:r.reportId,alerts:r.alerts,summary:r.summary}}:null,updateDashboard:{endpoint:"PUT /dashboard/obligation-metrics",data:{summary:r.summary,lastUpdated:r.generatedAt}}}}}catch(o){return{success:!1,error:o.message}}},getObligationTypes:function(){return Wc},getObligationPriority:function(){return _s},getObligationStatus:function(){return yr},_signToken:function(e,t){var r=this._canonicalizeToken(e),n=r0.sha256(d.Buffer.from(r)),i=new fI;i.hashbuf=n,i.privkey=t,i.pubkey=t.toPublicKey(),i.sign();var o=i.sig,s={type:"EcdsaSecp256k1Signature2019",created:new Date().toISOString(),verificationMethod:"did:smartledger:"+t.toPublicKey().toString()+"#keys-1",proofPurpose:"assertionMethod",jws:this._createJWS(n,o)},a=JSON.parse(JSON.stringify(e));return a.proof=s,a.tokenHash=n.toString("hex"),a},_createJWS:function(e,t){var r={alg:"ES256K",typ:"JWT"},n=d.Buffer.from(JSON.stringify(r)).toString("base64url"),i=e.toString("base64url"),o=t.toDER().toString("base64url");return n+".."+o},_canonicalizeToken:function(e){var t=JSON.parse(JSON.stringify(e));return delete t.proof,delete t.tokenHash,JSON.stringify(this._sortObjectKeys(t))},_sortObjectKeys:function(e){if(Array.isArray(e))return e.map(this._sortObjectKeys.bind(this));if(e!==null&&typeof e=="object"){var t={};return Object.keys(e).sort().forEach(function(r){t[r]=this._sortObjectKeys(e[r])}.bind(this)),t}return e},_validateTokenStructure:function(e,t){e["@context"]||t.push("Missing @context"),e.id||t.push("Missing id"),(!e.type||!Array.isArray(e.type))&&t.push("Missing or invalid type"),e.issuer||t.push("Missing issuer"),e.issuanceDate||t.push("Missing issuanceDate"),e.credentialSubject||t.push("Missing credentialSubject"),e.proof||t.push("Missing proof")},_verifyTokenSignature:function(e,t,r){try{if(!e.proof||!e.proof.jws){t.push("Missing signature proof");return}var n=this._canonicalizeToken(e),i=r0.sha256(d.Buffer.from(n));if(e.tokenHash&&e.tokenHash!==i.toString("hex")){t.push("Token hash mismatch");return}var o=UC(e,r);if(!o){t.push("Signature not verified: issuer public key could not be resolved from token.issuer; pass options.issuerPublicKey");return}var s=e.proof.jws.split(".");if(s.length!==3||!s[2]){t.push("Malformed JWS");return}var a=LC.fromDER(d.Buffer.from(s[2],"base64url")),f=new fI;f.hashbuf=i,f.sig=a,f.pubkey=o,f.verify()!==!0&&t.push("Signature verification failed")}catch(l){t.push("Signature verification failed: "+l.message)}},_validateTokenTemporal:function(e,t,r){var n=new Date,i=new Date(e.issuanceDate);if(i>n&&t.push("Token issued in the future"),e.credentialSubject.effectiveDate){var o=new Date(e.credentialSubject.effectiveDate);n<o&&r.push("Obligation not yet effective")}if(e.credentialSubject.expirationDate){var s=new Date(e.credentialSubject.expirationDate);n>s&&t.push("Obligation expired")}},_validateObligationType:function(e,t){if(!e.credentialSubject.obligationType){t.push("Missing obligationType");return}var r=Object.values(Wc);r.includes(e.credentialSubject.obligationType)||t.push("Invalid obligation type: "+e.credentialSubject.obligationType)},_validateObligationStatus:function(e,t,r){if(!e.credentialSubject.status){t.push("Missing status");return}var n=Object.values(yr);n.includes(e.credentialSubject.status)||t.push("Invalid obligation status: "+e.credentialSubject.status),this._checkIfOverdue(e)&&e.credentialSubject.status===yr.ACTIVE&&r.push("Obligation is overdue but status is still ACTIVE")},_validateObligationPriority:function(e,t){if(e.credentialSubject.priority){var r=Object.values(_s);r.includes(e.credentialSubject.priority)||t.push("Invalid obligation priority: "+e.credentialSubject.priority)}},_checkIfOverdue:function(e){if(!e.credentialSubject.dueDate)return!1;var t=new Date,r=new Date(e.credentialSubject.dueDate);return t>r&&e.credentialSubject.status!==yr.COMPLETED},_generateUUID:function(){return DC.uuid4()}};zc.ObligationTypes=Wc;zc.ObligationPriority=_s;zc.ObligationStatus=yr;lI.exports=zc});var pI=B((Yq,dI)=>{"use strict";g();var po=$x(),Yc=eI(),ru=rI(),n0=oI(),vn=uI(),FC=hI(),i0=fo(),Sr=We(),De=function(e){return this instanceof De?(this.config=e||{},this.registry=null,this.config.registry&&(this.registry=vn.createRegistry(this.config.registry)),this):new De(e)};De.prototype.createRightToken=function(e,t,r){Sr.checkArgument(e&&typeof e=="object","Invalid right data"),Sr.checkArgument(t instanceof i0,"Invalid private key"),r=r||{};try{var n=po.create(e.type,e.owner,e.owner,e,t,r);if(!n)return{success:!1,error:"Failed to create token"};if(r.addProof!==!1&&(n=po._signToken(n,t)),r.anchor){var i=ru.anchorToken(n,r.anchor);i.success&&(n.anchorTx=i.txid,n.anchorBlock=i.blockHeight)}if(this.registry&&r.register!==!1){var o=vn.registerToken(this.registry,n,{registeredBy:r.registeredBy||"SYSTEM"});o.success&&(n.registrationId=o.registrationId,n.registrationStatus=o.status)}return{success:!0,token:n,type:"LegalRightToken"}}catch(s){return{success:!1,error:s.message}}};De.prototype.validateClaim=function(e,t){return Yc.validate(e,t)};De.prototype.createSelectiveDisclosure=function(e,t,r){return n0.prepareSelectiveDisclosure(e,t,r)};De.prototype.verifyToken=function(e,t){return!e||!e.proof?{valid:!1,error:"No proof found in token"}:po.verifyToken(e,t)};De.prototype.transferRight=function(e,t,r,n){Sr.checkArgument(e&&typeof e=="object","Invalid token"),Sr.checkArgument(typeof t=="string","New owner must be string"),Sr.checkArgument(r instanceof i0,"Invalid owner key"),n=n||{};try{var i=this.verifyToken(e,r.toPublicKey().toString());if(!i.valid)return{success:!1,error:"Invalid token or ownership proof"};var o=po.prepareRightTokenTransfer(e,t,r,n);if(!o.success)return{success:!1,error:o.error};var s=o.newToken,a=o.transferProof;if(n.anchor){var f=ru.anchorToken(s,n.anchor);f.success&&(s.transferAnchorTx=f.txid)}if(this.registry){var l=vn.registerToken(this.registry,s,{registeredBy:n.registeredBy||t,metadata:{transferFrom:e.owner,transferTo:t,originalTokenId:e.id}});l.success&&(s.registrationId=l.registrationId)}return{success:!0,token:s,transferId:a.id,transferredAt:a.issuanceDate,transferProof:a}}catch(m){return{success:!1,error:m.message}}};De.prototype.createObligation=function(e,t,r){Sr.checkArgument(e&&typeof e=="object","Invalid right token"),Sr.checkArgument(t&&typeof t=="object","Invalid obligation data"),Sr.checkArgument(r instanceof i0,"Invalid private key");try{var n=po.prepareObligationToken(e,t.obligor,t,r);return n.success?{success:!0,obligation:n.obligationToken,rightTokenId:e.id}:{success:!1,error:n.error}}catch(i){return{success:!1,error:i.message}}};De.prototype.revokeToken=function(e,t,r){return Sr.checkArgument(typeof e=="string","Token ID must be string"),Sr.checkArgument(t&&typeof t=="object","Invalid revocation data"),Sr.checkArgument(typeof r=="string","Authority must be string"),this.registry?vn.revokeToken(this.registry,e,{reason:t.reason,revokedBy:r,legalBasis:t.legalBasis,evidence:t.evidence}):{success:!1,error:"No registry available for revocation"}};De.prototype.checkTokenStatus=function(e){return Sr.checkArgument(typeof e=="string","Token ID must be string"),this.registry?vn.checkTokenStatus(this.registry,e):{found:!1,error:"No registry available"}};De.prototype.searchTokens=function(e){return this.registry?vn.searchTokens(this.registry,e):{success:!1,error:"No registry available"}};De.prototype.getRegistryStats=function(){return this.registry?vn.getStatistics(this.registry):{error:"No registry available"}};De.prototype.createLegalValidityProof=function(e,t,r){return n0.prepareLegalValidityProof(e,t,r)};De.prototype.anchorTokenBatch=function(e,t){return ru.anchorBatch(e,t)};De.prototype.verifyAnchor=function(e,t){return ru.verifyAnchor(e,t)};De.prototype.getRightTypes=function(){return po.getRightTypes()};De.prototype.getClaimSchemas=function(){return Yc.getSchemas()};De.prototype.createRegistry=function(e){return this.registry=vn.createRegistry(e),this.registry};De.prototype.setRegistry=function(e){Sr.checkArgument(e&&typeof e=="object","Invalid registry"),this.registry=e};De.create=function(e){return new De(e)};De.createRightToken=function(e,t,r){var n=new De;return n.createRightToken(e,t,r)};De.validateClaim=function(e,t){return Yc.validate(e,t)};De.verifyToken=function(e,t){var r=new De;return r.verifyToken(e,t)};De.createRegistry=function(e){return vn.createRegistry(e)};De.Right=po;De.Claim=Yc;De.Anchor=ru;De.Proof=n0;De.Registry=vn;De.Obligation=FC;dI.exports=De});var qC=B((Zq,gI)=>{g();gI.exports=pI()});return qC();})();
75
75
  if(typeof module!=="undefined"&&module.exports){module.exports=bsvLTP}else if(typeof define==="function"&&define.amd){define([],function(){return bsvLTP})}