@btc-vision/transaction 1.6.6 → 1.6.7

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/browser/index.js CHANGED
@@ -1,2 +1,2 @@
1
1
  /*! For license information please see index.js.LICENSE.txt */
2
- var t,e,r={41:(t,e,r)=>{var n=r(655),i=r(8068),o=r(9675),a=r(5795);t.exports=function(t,e,r){if(!t||"object"!=typeof t&&"function"!=typeof t)throw new o("`obj` must be an object or a function`");if("string"!=typeof e&&"symbol"!=typeof e)throw new o("`property` must be a string or a symbol`");if(arguments.length>3&&"boolean"!=typeof arguments[3]&&null!==arguments[3])throw new o("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&"boolean"!=typeof arguments[4]&&null!==arguments[4])throw new o("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&"boolean"!=typeof arguments[5]&&null!==arguments[5])throw new o("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&"boolean"!=typeof arguments[6])throw new o("`loose`, if provided, must be a boolean");var s=arguments.length>3?arguments[3]:null,u=arguments.length>4?arguments[4]:null,f=arguments.length>5?arguments[5]:null,c=arguments.length>6&&arguments[6],l=!!a&&a(t,e);if(n)n(t,e,{configurable:null===f&&l?l.configurable:!f,enumerable:null===s&&l?l.enumerable:!s,value:r,writable:null===u&&l?l.writable:!u});else{if(!c&&(s||u||f))throw new i("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.");t[e]=r}}},76:t=>{t.exports=Function.prototype.call},251:(t,e)=>{e.read=function(t,e,r,n,i){var o,a,s=8*i-n-1,u=(1<<s)-1,f=u>>1,c=-7,l=r?i-1:0,h=r?-1:1,p=t[e+l];for(l+=h,o=p&(1<<-c)-1,p>>=-c,c+=s;c>0;o=256*o+t[e+l],l+=h,c-=8);for(a=o&(1<<-c)-1,o>>=-c,c+=n;c>0;a=256*a+t[e+l],l+=h,c-=8);if(0===o)o=1-f;else{if(o===u)return a?NaN:1/0*(p?-1:1);a+=Math.pow(2,n),o-=f}return(p?-1:1)*a*Math.pow(2,o-n)},e.write=function(t,e,r,n,i,o){var a,s,u,f=8*o-i-1,c=(1<<f)-1,l=c>>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:o-1,d=n?1:-1,y=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,a=c):(a=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-a))<1&&(a--,u*=2),(e+=a+l>=1?h/u:h*Math.pow(2,1-l))*u>=2&&(a++,u/=2),a+l>=c?(s=0,a=c):a+l>=1?(s=(e*u-1)*Math.pow(2,i),a+=l):(s=e*Math.pow(2,l-1)*Math.pow(2,i),a=0));i>=8;t[r+p]=255&s,p+=d,s/=256,i-=8);for(a=a<<i|s,f+=i;f>0;t[r+p]=255&a,p+=d,a/=256,f-=8);t[r+p-d]|=128*y}},320:(t,e,r)=>{var n=r(320);t.exports=function(t){return(new n).update(t).digest()}},392:(t,e,r)=>{var n=r(2861).Buffer,i=r(5377);function o(t,e){this._block=n.alloc(t),this._finalSize=e,this._blockSize=t,this._len=0}o.prototype.update=function(t,e){t=i(t,e||"utf8");for(var r=this._block,n=this._blockSize,o=t.length,a=this._len,s=0;s<o;){for(var u=a%n,f=Math.min(o-s,n-u),c=0;c<f;c++)r[u+c]=t[s+c];s+=f,(a+=f)%n===0&&this._update(r)}return this._len+=o,this},o.prototype.digest=function(t){var e=this._len%this._blockSize;this._block[e]=128,this._block.fill(0,e+1),e>=this._finalSize&&(this._update(this._block),this._block.fill(0));var r=8*this._len;if(r<=4294967295)this._block.writeUInt32BE(r,this._blockSize-4);else{var n=(4294967295&r)>>>0,i=(r-n)/4294967296;this._block.writeUInt32BE(i,this._blockSize-8),this._block.writeUInt32BE(n,this._blockSize-4)}this._update(this._block);var o=this._hash();return t?o.toString(t):o},o.prototype._update=function(){throw new Error("_update must be implemented by subclass")},t.exports=o},414:t=>{t.exports=Math.round},453:(t,e,r)=>{var n,i=r(9612),o=r(9383),a=r(1237),s=r(9290),u=r(9538),f=r(8068),c=r(9675),l=r(5345),h=r(1514),p=r(8968),d=r(6188),y=r(8002),b=r(5880),g=r(414),v=r(3093),w=Function,m=function(t){try{return w('"use strict"; return ('+t+").constructor;")()}catch(t){}},S=r(5795),_=r(655),E=function(){throw new c},k=S?function(){try{return E}catch(t){try{return S(arguments,"callee").get}catch(t){return E}}}():E,O=r(4039)(),T=r(3628),A=r(1064),I=r(8648),P=r(1002),x=r(76),B={},R="undefined"!=typeof Uint8Array&&T?T(Uint8Array):n,U={__proto__:null,"%AggregateError%":"undefined"==typeof AggregateError?n:AggregateError,"%Array%":Array,"%ArrayBuffer%":"undefined"==typeof ArrayBuffer?n:ArrayBuffer,"%ArrayIteratorPrototype%":O&&T?T([][Symbol.iterator]()):n,"%AsyncFromSyncIteratorPrototype%":n,"%AsyncFunction%":B,"%AsyncGenerator%":B,"%AsyncGeneratorFunction%":B,"%AsyncIteratorPrototype%":B,"%Atomics%":"undefined"==typeof Atomics?n:Atomics,"%BigInt%":"undefined"==typeof BigInt?n:BigInt,"%BigInt64Array%":"undefined"==typeof BigInt64Array?n:BigInt64Array,"%BigUint64Array%":"undefined"==typeof BigUint64Array?n:BigUint64Array,"%Boolean%":Boolean,"%DataView%":"undefined"==typeof DataView?n:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":o,"%eval%":eval,"%EvalError%":a,"%Float16Array%":"undefined"==typeof Float16Array?n:Float16Array,"%Float32Array%":"undefined"==typeof Float32Array?n:Float32Array,"%Float64Array%":"undefined"==typeof Float64Array?n:Float64Array,"%FinalizationRegistry%":"undefined"==typeof FinalizationRegistry?n:FinalizationRegistry,"%Function%":w,"%GeneratorFunction%":B,"%Int8Array%":"undefined"==typeof Int8Array?n:Int8Array,"%Int16Array%":"undefined"==typeof Int16Array?n:Int16Array,"%Int32Array%":"undefined"==typeof Int32Array?n:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":O&&T?T(T([][Symbol.iterator]())):n,"%JSON%":"object"==typeof JSON?JSON:n,"%Map%":"undefined"==typeof Map?n:Map,"%MapIteratorPrototype%":"undefined"!=typeof Map&&O&&T?T((new Map)[Symbol.iterator]()):n,"%Math%":Math,"%Number%":Number,"%Object%":i,"%Object.getOwnPropertyDescriptor%":S,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":"undefined"==typeof Promise?n:Promise,"%Proxy%":"undefined"==typeof Proxy?n:Proxy,"%RangeError%":s,"%ReferenceError%":u,"%Reflect%":"undefined"==typeof Reflect?n:Reflect,"%RegExp%":RegExp,"%Set%":"undefined"==typeof Set?n:Set,"%SetIteratorPrototype%":"undefined"!=typeof Set&&O&&T?T((new Set)[Symbol.iterator]()):n,"%SharedArrayBuffer%":"undefined"==typeof SharedArrayBuffer?n:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":O&&T?T(""[Symbol.iterator]()):n,"%Symbol%":O?Symbol:n,"%SyntaxError%":f,"%ThrowTypeError%":k,"%TypedArray%":R,"%TypeError%":c,"%Uint8Array%":"undefined"==typeof Uint8Array?n:Uint8Array,"%Uint8ClampedArray%":"undefined"==typeof Uint8ClampedArray?n:Uint8ClampedArray,"%Uint16Array%":"undefined"==typeof Uint16Array?n:Uint16Array,"%Uint32Array%":"undefined"==typeof Uint32Array?n:Uint32Array,"%URIError%":l,"%WeakMap%":"undefined"==typeof WeakMap?n:WeakMap,"%WeakRef%":"undefined"==typeof WeakRef?n:WeakRef,"%WeakSet%":"undefined"==typeof WeakSet?n:WeakSet,"%Function.prototype.call%":x,"%Function.prototype.apply%":P,"%Object.defineProperty%":_,"%Object.getPrototypeOf%":A,"%Math.abs%":h,"%Math.floor%":p,"%Math.max%":d,"%Math.min%":y,"%Math.pow%":b,"%Math.round%":g,"%Math.sign%":v,"%Reflect.getPrototypeOf%":I};if(T)try{null.error}catch(t){var N=T(T(t));U["%Error.prototype%"]=N}var j=function t(e){var r;if("%AsyncFunction%"===e)r=m("async function () {}");else if("%GeneratorFunction%"===e)r=m("function* () {}");else if("%AsyncGeneratorFunction%"===e)r=m("async function* () {}");else if("%AsyncGenerator%"===e){var n=t("%AsyncGeneratorFunction%");n&&(r=n.prototype)}else if("%AsyncIteratorPrototype%"===e){var i=t("%AsyncGenerator%");i&&T&&(r=T(i.prototype))}return U[e]=r,r},L={__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"]},C=r(6743),F=r(9957),D=C.call(x,Array.prototype.concat),H=C.call(P,Array.prototype.splice),M=C.call(x,String.prototype.replace),K=C.call(x,String.prototype.slice),V=C.call(x,RegExp.prototype.exec),W=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,G=/\\(\\)?/g,q=function(t,e){var r,n=t;if(F(L,n)&&(n="%"+(r=L[n])[0]+"%"),F(U,n)){var i=U[n];if(i===B&&(i=j(n)),void 0===i&&!e)throw new c("intrinsic "+t+" exists, but is not available. Please file an issue!");return{alias:r,name:n,value:i}}throw new f("intrinsic "+t+" does not exist!")};t.exports=function(t,e){if("string"!=typeof t||0===t.length)throw new c("intrinsic name must be a non-empty string");if(arguments.length>1&&"boolean"!=typeof e)throw new c('"allowMissing" argument must be a boolean');if(null===V(/^%?[^%]*%?$/,t))throw new f("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var r=function(t){var e=K(t,0,1),r=K(t,-1);if("%"===e&&"%"!==r)throw new f("invalid intrinsic syntax, expected closing `%`");if("%"===r&&"%"!==e)throw new f("invalid intrinsic syntax, expected opening `%`");var n=[];return M(t,W,function(t,e,r,i){n[n.length]=r?M(i,G,"$1"):e||t}),n}(t),n=r.length>0?r[0]:"",i=q("%"+n+"%",e),o=i.name,a=i.value,s=!1,u=i.alias;u&&(n=u[0],H(r,D([0,1],u)));for(var l=1,h=!0;l<r.length;l+=1){var p=r[l],d=K(p,0,1),y=K(p,-1);if(('"'===d||"'"===d||"`"===d||'"'===y||"'"===y||"`"===y)&&d!==y)throw new f("property names with quotes must have matching quotes");if("constructor"!==p&&h||(s=!0),F(U,o="%"+(n+="."+p)+"%"))a=U[o];else if(null!=a){if(!(p in a)){if(!e)throw new c("base intrinsic for "+t+" exists, but the property is not available.");return}if(S&&l+1>=r.length){var b=S(a,p);a=(h=!!b)&&"get"in b&&!("originalValue"in b.get)?b.get:a[p]}else h=F(a,p),a=a[p];h&&!s&&(U[o]=a)}}return a}},487:(t,e,r)=>{var n=r(6897),i=r(655),o=r(3126),a=r(2205);t.exports=function(t){var e=o(arguments),r=t.length-(arguments.length-1);return n(e,1+(r>0?r:0),!0)},i?i(t.exports,"apply",{value:a}):t.exports.apply=a},537:(t,e,r)=>{var n=r(5606),i=Object.getOwnPropertyDescriptors||function(t){for(var e=Object.keys(t),r={},n=0;n<e.length;n++)r[e[n]]=Object.getOwnPropertyDescriptor(t,e[n]);return r},o=/%[sdj%]/g;e.format=function(t){if(!w(t)){for(var e=[],r=0;r<arguments.length;r++)e.push(f(arguments[r]));return e.join(" ")}r=1;for(var n=arguments,i=n.length,a=String(t).replace(o,function(t){if("%%"===t)return"%";if(r>=i)return t;switch(t){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(t){return"[Circular]"}default:return t}}),s=n[r];r<i;s=n[++r])g(s)||!_(s)?a+=" "+s:a+=" "+f(s);return a},e.deprecate=function(t,r){if(void 0!==n&&!0===n.noDeprecation)return t;if(void 0===n)return function(){return e.deprecate(t,r).apply(this,arguments)};var i=!1;return function(){if(!i){if(n.throwDeprecation)throw new Error(r);n.traceDeprecation?console.trace(r):console.error(r),i=!0}return t.apply(this,arguments)}};var a={},s=/^$/;if(n.env.NODE_DEBUG){var u=n.env.NODE_DEBUG;u=u.replace(/[|\\{}()[\]^$+?.]/g,"\\$&").replace(/\*/g,".*").replace(/,/g,"$|^").toUpperCase(),s=new RegExp("^"+u+"$","i")}function f(t,r){var n={seen:[],stylize:l};return arguments.length>=3&&(n.depth=arguments[2]),arguments.length>=4&&(n.colors=arguments[3]),b(r)?n.showHidden=r:r&&e._extend(n,r),m(n.showHidden)&&(n.showHidden=!1),m(n.depth)&&(n.depth=2),m(n.colors)&&(n.colors=!1),m(n.customInspect)&&(n.customInspect=!0),n.colors&&(n.stylize=c),h(n,t,n.depth)}function c(t,e){var r=f.styles[e];return r?"["+f.colors[r][0]+"m"+t+"["+f.colors[r][1]+"m":t}function l(t,e){return t}function h(t,r,n){if(t.customInspect&&r&&O(r.inspect)&&r.inspect!==e.inspect&&(!r.constructor||r.constructor.prototype!==r)){var i=r.inspect(n,t);return w(i)||(i=h(t,i,n)),i}var o=function(t,e){if(m(e))return t.stylize("undefined","undefined");if(w(e)){var r="'"+JSON.stringify(e).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return t.stylize(r,"string")}return v(e)?t.stylize(""+e,"number"):b(e)?t.stylize(""+e,"boolean"):g(e)?t.stylize("null","null"):void 0}(t,r);if(o)return o;var a=Object.keys(r),s=function(t){var e={};return t.forEach(function(t,r){e[t]=!0}),e}(a);if(t.showHidden&&(a=Object.getOwnPropertyNames(r)),k(r)&&(a.indexOf("message")>=0||a.indexOf("description")>=0))return p(r);if(0===a.length){if(O(r)){var u=r.name?": "+r.name:"";return t.stylize("[Function"+u+"]","special")}if(S(r))return t.stylize(RegExp.prototype.toString.call(r),"regexp");if(E(r))return t.stylize(Date.prototype.toString.call(r),"date");if(k(r))return p(r)}var f,c="",l=!1,_=["{","}"];return y(r)&&(l=!0,_=["[","]"]),O(r)&&(c=" [Function"+(r.name?": "+r.name:"")+"]"),S(r)&&(c=" "+RegExp.prototype.toString.call(r)),E(r)&&(c=" "+Date.prototype.toUTCString.call(r)),k(r)&&(c=" "+p(r)),0!==a.length||l&&0!=r.length?n<0?S(r)?t.stylize(RegExp.prototype.toString.call(r),"regexp"):t.stylize("[Object]","special"):(t.seen.push(r),f=l?function(t,e,r,n,i){for(var o=[],a=0,s=e.length;a<s;++a)P(e,String(a))?o.push(d(t,e,r,n,String(a),!0)):o.push("");return i.forEach(function(i){i.match(/^\d+$/)||o.push(d(t,e,r,n,i,!0))}),o}(t,r,n,s,a):a.map(function(e){return d(t,r,n,s,e,l)}),t.seen.pop(),function(t,e,r){return t.reduce(function(t,e){return e.indexOf("\n"),t+e.replace(/\u001b\[\d\d?m/g,"").length+1},0)>60?r[0]+(""===e?"":e+"\n ")+" "+t.join(",\n ")+" "+r[1]:r[0]+e+" "+t.join(", ")+" "+r[1]}(f,c,_)):_[0]+c+_[1]}function p(t){return"["+Error.prototype.toString.call(t)+"]"}function d(t,e,r,n,i,o){var a,s,u;if((u=Object.getOwnPropertyDescriptor(e,i)||{value:e[i]}).get?s=u.set?t.stylize("[Getter/Setter]","special"):t.stylize("[Getter]","special"):u.set&&(s=t.stylize("[Setter]","special")),P(n,i)||(a="["+i+"]"),s||(t.seen.indexOf(u.value)<0?(s=g(r)?h(t,u.value,null):h(t,u.value,r-1)).indexOf("\n")>-1&&(s=o?s.split("\n").map(function(t){return" "+t}).join("\n").slice(2):"\n"+s.split("\n").map(function(t){return" "+t}).join("\n")):s=t.stylize("[Circular]","special")),m(a)){if(o&&i.match(/^\d+$/))return s;(a=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(a=a.slice(1,-1),a=t.stylize(a,"name")):(a=a.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),a=t.stylize(a,"string"))}return a+": "+s}function y(t){return Array.isArray(t)}function b(t){return"boolean"==typeof t}function g(t){return null===t}function v(t){return"number"==typeof t}function w(t){return"string"==typeof t}function m(t){return void 0===t}function S(t){return _(t)&&"[object RegExp]"===T(t)}function _(t){return"object"==typeof t&&null!==t}function E(t){return _(t)&&"[object Date]"===T(t)}function k(t){return _(t)&&("[object Error]"===T(t)||t instanceof Error)}function O(t){return"function"==typeof t}function T(t){return Object.prototype.toString.call(t)}function A(t){return t<10?"0"+t.toString(10):t.toString(10)}e.debuglog=function(t){if(t=t.toUpperCase(),!a[t])if(s.test(t)){var r=n.pid;a[t]=function(){var n=e.format.apply(e,arguments);console.error("%s %d: %s",t,r,n)}}else a[t]=function(){};return a[t]},e.inspect=f,f.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]},f.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},e.types=r(9032),e.isArray=y,e.isBoolean=b,e.isNull=g,e.isNullOrUndefined=function(t){return null==t},e.isNumber=v,e.isString=w,e.isSymbol=function(t){return"symbol"==typeof t},e.isUndefined=m,e.isRegExp=S,e.types.isRegExp=S,e.isObject=_,e.isDate=E,e.types.isDate=E,e.isError=k,e.types.isNativeError=k,e.isFunction=O,e.isPrimitive=function(t){return null===t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||"symbol"==typeof t||void 0===t},e.isBuffer=r(1135);var I=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function P(t,e){return Object.prototype.hasOwnProperty.call(t,e)}e.log=function(){console.log("%s - %s",function(){var t=new Date,e=[A(t.getHours()),A(t.getMinutes()),A(t.getSeconds())].join(":");return[t.getDate(),I[t.getMonth()],e].join(" ")}(),e.format.apply(e,arguments))},e.inherits=r(6698),e._extend=function(t,e){if(!e||!_(e))return t;for(var r=Object.keys(e),n=r.length;n--;)t[r[n]]=e[r[n]];return t};var x="undefined"!=typeof Symbol?Symbol("util.promisify.custom"):void 0;function B(t,e){if(!t){var r=new Error("Promise was rejected with a falsy value");r.reason=t,t=r}return e(t)}e.promisify=function(t){if("function"!=typeof t)throw new TypeError('The "original" argument must be of type Function');if(x&&t[x]){var e;if("function"!=typeof(e=t[x]))throw new TypeError('The "util.promisify.custom" argument must be of type Function');return Object.defineProperty(e,x,{value:e,enumerable:!1,writable:!1,configurable:!0}),e}function e(){for(var e,r,n=new Promise(function(t,n){e=t,r=n}),i=[],o=0;o<arguments.length;o++)i.push(arguments[o]);i.push(function(t,n){t?r(t):e(n)});try{t.apply(this,i)}catch(t){r(t)}return n}return Object.setPrototypeOf(e,Object.getPrototypeOf(t)),x&&Object.defineProperty(e,x,{value:e,enumerable:!1,writable:!1,configurable:!0}),Object.defineProperties(e,i(t))},e.promisify.custom=x,e.callbackify=function(t){if("function"!=typeof t)throw new TypeError('The "original" argument must be of type Function');function e(){for(var e=[],r=0;r<arguments.length;r++)e.push(arguments[r]);var i=e.pop();if("function"!=typeof i)throw new TypeError("The last argument must be of type Function");var o=this,a=function(){return i.apply(o,arguments)};t.apply(this,e).then(function(t){n.nextTick(a.bind(null,null,t))},function(t){n.nextTick(B.bind(null,t,a))})}return Object.setPrototypeOf(e,Object.getPrototypeOf(t)),Object.defineProperties(e,i(t)),e}},592:(t,e,r)=>{var n=r(655),i=function(){return!!n};i.hasArrayLengthDefineBug=function(){if(!n)return null;try{return 1!==n([],"length",{value:1}).length}catch(t){return!0}},t.exports=i},655:t=>{var e=Object.defineProperty||!1;if(e)try{e({},"a",{value:1})}catch(t){e=!1}t.exports=e},709:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),e.testEcc=void 0;const i=t=>n.from(t,"hex");function o(t){if(!t)throw new Error("ecc library invalid")}e.testEcc=function(t){o(t.isPoint(i("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),o(!t.isPoint(i("030000000000000000000000000000000000000000000000000000000000000005"))),o(t.isPrivate(i("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),o(t.isPrivate(i("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"))),o(!t.isPrivate(i("0000000000000000000000000000000000000000000000000000000000000000"))),o(!t.isPrivate(i("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"))),o(!t.isPrivate(i("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364142"))),o(n.from(t.privateAdd(i("0000000000000000000000000000000000000000000000000000000000000001"),i("0000000000000000000000000000000000000000000000000000000000000000"))).equals(i("0000000000000000000000000000000000000000000000000000000000000001"))),o(null===t.privateAdd(i("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd036413e"),i("0000000000000000000000000000000000000000000000000000000000000003"))),o(n.from(t.privateAdd(i("e211078564db65c3ce7704f08262b1f38f1ef412ad15b5ac2d76657a63b2c500"),i("b51fbb69051255d1becbd683de5848242a89c229348dd72896a87ada94ae8665"))).equals(i("9730c2ee69edbb958d42db7460bafa18fef9d955325aec99044c81c8282b0a24"))),o(n.from(t.privateNegate(i("0000000000000000000000000000000000000000000000000000000000000001"))).equals(i("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"))),o(n.from(t.privateNegate(i("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd036413e"))).equals(i("0000000000000000000000000000000000000000000000000000000000000003"))),o(n.from(t.privateNegate(i("b1121e4088a66a28f5b6b0f5844943ecd9f610196d7bb83b25214b60452c09af"))).equals(i("4eede1bf775995d70a494f0a7bb6bc11e0b8cccd41cce8009ab1132c8b0a3792"))),o(n.from(t.pointCompress(i("0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"),!0)).equals(i("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),o(n.from(t.pointCompress(i("0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"),!1)).equals(i("0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"))),o(n.from(t.pointCompress(i("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),!0)).equals(i("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),o(n.from(t.pointCompress(i("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),!1)).equals(i("0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"))),o(n.from(t.pointFromScalar(i("b1121e4088a66a28f5b6b0f5844943ecd9f610196d7bb83b25214b60452c09af"))).equals(i("02b07ba9dca9523b7ef4bd97703d43d20399eb698e194704791a25ce77a400df99"))),o(null===t.xOnlyPointAddTweak(i("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),i("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140")));let e=t.xOnlyPointAddTweak(i("1617d38ed8d8657da4d4761e8057bc396ea9e4b9d29776d4be096016dbd2509b"),i("a8397a935f0dfceba6ba9618f6451ef4d80637abf4e6af2669fbc9de6a8fd2ac"));o(n.from(e.xOnlyPubkey).equals(i("e478f99dab91052ab39a33ea35fd5e6e4933f4d28023cd597c9a1f6760346adf"))&&1===e.parity),e=t.xOnlyPointAddTweak(i("2c0b7cf95324a07d05398b240174dc0c2be444d96b159aa6c7f7b1e668680991"),i("823c3cd2142744b075a87eade7e1b8678ba308d566226a0056ca2b7a76f86b47")),o(n.from(e.xOnlyPubkey).equals(i("9534f8dc8c6deda2dc007655981c78b49c5d96c778fbf363462a11ec9dfd948c"))&&0===e.parity),o(n.from(t.sign(i("5e9f0a0d593efdcf78ac923bc3313e4e7d408d574354ee2b3288c0da9fbba6ed"),i("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"))).equals(i("54c4a33c6423d689378f160a7ff8b61330444abb58fb470f96ea16d99d4a2fed07082304410efa6b2943111b6a4e0aaa7b7db55a07e9861d1fb3cb1f421044a5"))),o(t.verify(i("5e9f0a0d593efdcf78ac923bc3313e4e7d408d574354ee2b3288c0da9fbba6ed"),i("0379be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),i("54c4a33c6423d689378f160a7ff8b61330444abb58fb470f96ea16d99d4a2fed07082304410efa6b2943111b6a4e0aaa7b7db55a07e9861d1fb3cb1f421044a5"))),t.signSchnorr&&o(n.from(t.signSchnorr(i("7e2d58d8b3bcdf1abadec7829054f90dda9805aab56c77333024b9d0a508b75c"),i("c90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b14e5c9"),i("c87aa53824b4d7ae2eb035a2b5bbbccc080e76cdc6d1692c4b0b62d798e6d906"))).equals(i("5831aaeed7b44bb74e5eab94ba9d4294c49bcf2a60728d8b4c200f50dd313c1bab745879a5ad954a72c45a91c3a51d3c7adea98d82f8481e0e1e03674a6f3fb7"))),t.verifySchnorr&&o(t.verifySchnorr(i("7e2d58d8b3bcdf1abadec7829054f90dda9805aab56c77333024b9d0a508b75c"),i("dd308afec5777e13121fa72b9cc1b7cc0139715309b086c960e18fd969774eb8"),i("5831aaeed7b44bb74e5eab94ba9d4294c49bcf2a60728d8b4c200f50dd313c1bab745879a5ad954a72c45a91c3a51d3c7adea98d82f8481e0e1e03674a6f3fb7")))}},953:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.maybe=e.Boolean=e.Array=e.Buffer256bit=e.Network=e.typeforce=void 0,e.typeforce=r(8676),e.Network=e.typeforce.compile({messagePrefix:e.typeforce.oneOf(e.typeforce.Buffer,e.typeforce.String),bip32:{public:e.typeforce.UInt32,private:e.typeforce.UInt32},pubKeyHash:e.typeforce.UInt8,scriptHash:e.typeforce.UInt8,wif:e.typeforce.UInt8}),e.Buffer256bit=e.typeforce.BufferN(32),e.Array=e.typeforce.Array,e.Boolean=e.typeforce.Boolean,e.maybe=e.typeforce.maybe},968:t=>{t.exports=function(){throw new Error("Readable.from is not available in the browser")}},1002:t=>{t.exports=Function.prototype.apply},1061:(t,e,r)=>{var n=r(2113);function i(t){return t.name||t.toString().match(/function (.*?)\s*\(/)[1]}function o(t){return n.Nil(t)?"":i(t.constructor)}function a(t,e){Error.captureStackTrace&&Error.captureStackTrace(t,e)}function s(t){return n.Function(t)?t.toJSON?t.toJSON():i(t):n.Array(t)?"Array":t&&n.Object(t)?"Object":void 0!==t?t:""}function u(t,e,r){var i=function(t){return n.Function(t)?"":n.String(t)?JSON.stringify(t):t&&n.Object(t)?"":t}(e);return"Expected "+s(t)+", got"+(""!==r?" "+r:"")+(""!==i?" "+i:"")}function f(t,e,r){r=r||o(e),this.message=u(t,e,r),a(this,f),this.__type=t,this.__value=e,this.__valueTypeName=r}function c(t,e,r,n,i){t?(i=i||o(n),this.message=function(t,e,r,n,i){var o='" of type ';return"key"===e&&(o='" with key type '),u('property "'+s(r)+o+s(t),n,i)}(t,r,e,n,i)):this.message='Unexpected property "'+e+'"',a(this,f),this.__label=r,this.__property=e,this.__type=t,this.__value=n,this.__valueTypeName=i}f.prototype=Object.create(Error.prototype),f.prototype.constructor=f,c.prototype=Object.create(Error.prototype),c.prototype.constructor=f,t.exports={TfTypeError:f,TfPropertyTypeError:c,tfCustomError:function(t,e){return new f(t,{},e)},tfSubError:function(t,e,r){return t instanceof c?(e=e+"."+t.__property,t=new c(t.__type,e,t.__label,t.__value,t.__valueTypeName)):t instanceof f&&(t=new c(t.__type,e,r,t.__value,t.__valueTypeName)),a(t),t},tfJSON:s,getValueTypeName:o}},1064:(t,e,r)=>{var n=r(9612);t.exports=n.getPrototypeOf||null},1093:t=>{var e=Object.prototype.toString;t.exports=function(t){var r=e.call(t),n="[object Arguments]"===r;return n||(n="[object Array]"!==r&&null!==t&&"object"==typeof t&&"number"==typeof t.length&&t.length>=0&&"[object Function]"===e.call(t.callee)),n}},1135:t=>{t.exports=function(t){return t&&"object"==typeof t&&"function"==typeof t.copy&&"function"==typeof t.fill&&"function"==typeof t.readUInt8}},1181:(t,e,r)=>{t.exports=r(7007).EventEmitter},1189:(t,e,r)=>{var n=Array.prototype.slice,i=r(1093),o=Object.keys,a=o?function(t){return o(t)}:r(8875),s=Object.keys;a.shim=function(){if(Object.keys){var t=function(){var t=Object.keys(arguments);return t&&t.length===arguments.length}(1,2);t||(Object.keys=function(t){return i(t)?s(n.call(t)):s(t)})}else Object.keys=a;return Object.keys||a},t.exports=a},1237:t=>{t.exports=EvalError},1333:t=>{t.exports=function(){if("function"!=typeof Symbol||"function"!=typeof Object.getOwnPropertySymbols)return!1;if("symbol"==typeof Symbol.iterator)return!0;var t={},e=Symbol("test"),r=Object(e);if("string"==typeof e)return!1;if("[object Symbol]"!==Object.prototype.toString.call(e))return!1;if("[object Symbol]"!==Object.prototype.toString.call(r))return!1;for(var n in t[e]=42,t)return!1;if("function"==typeof Object.keys&&0!==Object.keys(t).length)return!1;if("function"==typeof Object.getOwnPropertyNames&&0!==Object.getOwnPropertyNames(t).length)return!1;var i=Object.getOwnPropertySymbols(t);if(1!==i.length||i[0]!==e)return!1;if(!Object.prototype.propertyIsEnumerable.call(t,e))return!1;if("function"==typeof Object.getOwnPropertyDescriptor){var o=Object.getOwnPropertyDescriptor(t,e);if(42!==o.value||!0!==o.enumerable)return!1}return!0}},1396:(t,e,r)=>{t.exports=r(7007).EventEmitter},1447:(t,e,r)=>{var n=r(9805),i=r(3269),o=r(4823),a=r(7293),s=r(1998),u=-2,f=12,c=30;function l(t){return(t>>>24&255)+(t>>>8&65280)+((65280&t)<<8)+((255&t)<<24)}function h(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new n.Buf16(320),this.work=new n.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function p(t){var e;return t&&t.state?(e=t.state,t.total_in=t.total_out=e.total=0,t.msg="",e.wrap&&(t.adler=1&e.wrap),e.mode=1,e.last=0,e.havedict=0,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new n.Buf32(852),e.distcode=e.distdyn=new n.Buf32(592),e.sane=1,e.back=-1,0):u}function d(t){var e;return t&&t.state?((e=t.state).wsize=0,e.whave=0,e.wnext=0,p(t)):u}function y(t,e){var r,n;return t&&t.state?(n=t.state,e<0?(r=0,e=-e):(r=1+(e>>4),e<48&&(e&=15)),e&&(e<8||e>15)?u:(null!==n.window&&n.wbits!==e&&(n.window=null),n.wrap=r,n.wbits=e,d(t))):u}function b(t,e){var r,n;return t?(n=new h,t.state=n,n.window=null,0!==(r=y(t,e))&&(t.state=null),r):u}var g,v,w=!0;function m(t){if(w){var e;for(g=new n.Buf32(512),v=new n.Buf32(32),e=0;e<144;)t.lens[e++]=8;for(;e<256;)t.lens[e++]=9;for(;e<280;)t.lens[e++]=7;for(;e<288;)t.lens[e++]=8;for(s(1,t.lens,0,288,g,0,t.work,{bits:9}),e=0;e<32;)t.lens[e++]=5;s(2,t.lens,0,32,v,0,t.work,{bits:5}),w=!1}t.lencode=g,t.lenbits=9,t.distcode=v,t.distbits=5}function S(t,e,r,i){var o,a=t.state;return null===a.window&&(a.wsize=1<<a.wbits,a.wnext=0,a.whave=0,a.window=new n.Buf8(a.wsize)),i>=a.wsize?(n.arraySet(a.window,e,r-a.wsize,a.wsize,0),a.wnext=0,a.whave=a.wsize):((o=a.wsize-a.wnext)>i&&(o=i),n.arraySet(a.window,e,r-i,o,a.wnext),(i-=o)?(n.arraySet(a.window,e,r-i,i,0),a.wnext=i,a.whave=a.wsize):(a.wnext+=o,a.wnext===a.wsize&&(a.wnext=0),a.whave<a.wsize&&(a.whave+=o))),0}e.inflateReset=d,e.inflateReset2=y,e.inflateResetKeep=p,e.inflateInit=function(t){return b(t,15)},e.inflateInit2=b,e.inflate=function(t,e){var r,h,p,d,y,b,g,v,w,_,E,k,O,T,A,I,P,x,B,R,U,N,j,L,C=0,F=new n.Buf8(4),D=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!t||!t.state||!t.output||!t.input&&0!==t.avail_in)return u;(r=t.state).mode===f&&(r.mode=13),y=t.next_out,p=t.output,g=t.avail_out,d=t.next_in,h=t.input,b=t.avail_in,v=r.hold,w=r.bits,_=b,E=g,N=0;t:for(;;)switch(r.mode){case 1:if(0===r.wrap){r.mode=13;break}for(;w<16;){if(0===b)break t;b--,v+=h[d++]<<w,w+=8}if(2&r.wrap&&35615===v){r.check=0,F[0]=255&v,F[1]=v>>>8&255,r.check=o(r.check,F,2,0),v=0,w=0,r.mode=2;break}if(r.flags=0,r.head&&(r.head.done=!1),!(1&r.wrap)||(((255&v)<<8)+(v>>8))%31){t.msg="incorrect header check",r.mode=c;break}if(8!=(15&v)){t.msg="unknown compression method",r.mode=c;break}if(w-=4,U=8+(15&(v>>>=4)),0===r.wbits)r.wbits=U;else if(U>r.wbits){t.msg="invalid window size",r.mode=c;break}r.dmax=1<<U,t.adler=r.check=1,r.mode=512&v?10:f,v=0,w=0;break;case 2:for(;w<16;){if(0===b)break t;b--,v+=h[d++]<<w,w+=8}if(r.flags=v,8!=(255&r.flags)){t.msg="unknown compression method",r.mode=c;break}if(57344&r.flags){t.msg="unknown header flags set",r.mode=c;break}r.head&&(r.head.text=v>>8&1),512&r.flags&&(F[0]=255&v,F[1]=v>>>8&255,r.check=o(r.check,F,2,0)),v=0,w=0,r.mode=3;case 3:for(;w<32;){if(0===b)break t;b--,v+=h[d++]<<w,w+=8}r.head&&(r.head.time=v),512&r.flags&&(F[0]=255&v,F[1]=v>>>8&255,F[2]=v>>>16&255,F[3]=v>>>24&255,r.check=o(r.check,F,4,0)),v=0,w=0,r.mode=4;case 4:for(;w<16;){if(0===b)break t;b--,v+=h[d++]<<w,w+=8}r.head&&(r.head.xflags=255&v,r.head.os=v>>8),512&r.flags&&(F[0]=255&v,F[1]=v>>>8&255,r.check=o(r.check,F,2,0)),v=0,w=0,r.mode=5;case 5:if(1024&r.flags){for(;w<16;){if(0===b)break t;b--,v+=h[d++]<<w,w+=8}r.length=v,r.head&&(r.head.extra_len=v),512&r.flags&&(F[0]=255&v,F[1]=v>>>8&255,r.check=o(r.check,F,2,0)),v=0,w=0}else r.head&&(r.head.extra=null);r.mode=6;case 6:if(1024&r.flags&&((k=r.length)>b&&(k=b),k&&(r.head&&(U=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Array(r.head.extra_len)),n.arraySet(r.head.extra,h,d,k,U)),512&r.flags&&(r.check=o(r.check,h,k,d)),b-=k,d+=k,r.length-=k),r.length))break t;r.length=0,r.mode=7;case 7:if(2048&r.flags){if(0===b)break t;k=0;do{U=h[d+k++],r.head&&U&&r.length<65536&&(r.head.name+=String.fromCharCode(U))}while(U&&k<b);if(512&r.flags&&(r.check=o(r.check,h,k,d)),b-=k,d+=k,U)break t}else r.head&&(r.head.name=null);r.length=0,r.mode=8;case 8:if(4096&r.flags){if(0===b)break t;k=0;do{U=h[d+k++],r.head&&U&&r.length<65536&&(r.head.comment+=String.fromCharCode(U))}while(U&&k<b);if(512&r.flags&&(r.check=o(r.check,h,k,d)),b-=k,d+=k,U)break t}else r.head&&(r.head.comment=null);r.mode=9;case 9:if(512&r.flags){for(;w<16;){if(0===b)break t;b--,v+=h[d++]<<w,w+=8}if(v!==(65535&r.check)){t.msg="header crc mismatch",r.mode=c;break}v=0,w=0}r.head&&(r.head.hcrc=r.flags>>9&1,r.head.done=!0),t.adler=r.check=0,r.mode=f;break;case 10:for(;w<32;){if(0===b)break t;b--,v+=h[d++]<<w,w+=8}t.adler=r.check=l(v),v=0,w=0,r.mode=11;case 11:if(0===r.havedict)return t.next_out=y,t.avail_out=g,t.next_in=d,t.avail_in=b,r.hold=v,r.bits=w,2;t.adler=r.check=1,r.mode=f;case f:if(5===e||6===e)break t;case 13:if(r.last){v>>>=7&w,w-=7&w,r.mode=27;break}for(;w<3;){if(0===b)break t;b--,v+=h[d++]<<w,w+=8}switch(r.last=1&v,w-=1,3&(v>>>=1)){case 0:r.mode=14;break;case 1:if(m(r),r.mode=20,6===e){v>>>=2,w-=2;break t}break;case 2:r.mode=17;break;case 3:t.msg="invalid block type",r.mode=c}v>>>=2,w-=2;break;case 14:for(v>>>=7&w,w-=7&w;w<32;){if(0===b)break t;b--,v+=h[d++]<<w,w+=8}if((65535&v)!=(v>>>16^65535)){t.msg="invalid stored block lengths",r.mode=c;break}if(r.length=65535&v,v=0,w=0,r.mode=15,6===e)break t;case 15:r.mode=16;case 16:if(k=r.length){if(k>b&&(k=b),k>g&&(k=g),0===k)break t;n.arraySet(p,h,d,k,y),b-=k,d+=k,g-=k,y+=k,r.length-=k;break}r.mode=f;break;case 17:for(;w<14;){if(0===b)break t;b--,v+=h[d++]<<w,w+=8}if(r.nlen=257+(31&v),v>>>=5,w-=5,r.ndist=1+(31&v),v>>>=5,w-=5,r.ncode=4+(15&v),v>>>=4,w-=4,r.nlen>286||r.ndist>30){t.msg="too many length or distance symbols",r.mode=c;break}r.have=0,r.mode=18;case 18:for(;r.have<r.ncode;){for(;w<3;){if(0===b)break t;b--,v+=h[d++]<<w,w+=8}r.lens[D[r.have++]]=7&v,v>>>=3,w-=3}for(;r.have<19;)r.lens[D[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,j={bits:r.lenbits},N=s(0,r.lens,0,19,r.lencode,0,r.work,j),r.lenbits=j.bits,N){t.msg="invalid code lengths set",r.mode=c;break}r.have=0,r.mode=19;case 19:for(;r.have<r.nlen+r.ndist;){for(;I=(C=r.lencode[v&(1<<r.lenbits)-1])>>>16&255,P=65535&C,!((A=C>>>24)<=w);){if(0===b)break t;b--,v+=h[d++]<<w,w+=8}if(P<16)v>>>=A,w-=A,r.lens[r.have++]=P;else{if(16===P){for(L=A+2;w<L;){if(0===b)break t;b--,v+=h[d++]<<w,w+=8}if(v>>>=A,w-=A,0===r.have){t.msg="invalid bit length repeat",r.mode=c;break}U=r.lens[r.have-1],k=3+(3&v),v>>>=2,w-=2}else if(17===P){for(L=A+3;w<L;){if(0===b)break t;b--,v+=h[d++]<<w,w+=8}w-=A,U=0,k=3+(7&(v>>>=A)),v>>>=3,w-=3}else{for(L=A+7;w<L;){if(0===b)break t;b--,v+=h[d++]<<w,w+=8}w-=A,U=0,k=11+(127&(v>>>=A)),v>>>=7,w-=7}if(r.have+k>r.nlen+r.ndist){t.msg="invalid bit length repeat",r.mode=c;break}for(;k--;)r.lens[r.have++]=U}}if(r.mode===c)break;if(0===r.lens[256]){t.msg="invalid code -- missing end-of-block",r.mode=c;break}if(r.lenbits=9,j={bits:r.lenbits},N=s(1,r.lens,0,r.nlen,r.lencode,0,r.work,j),r.lenbits=j.bits,N){t.msg="invalid literal/lengths set",r.mode=c;break}if(r.distbits=6,r.distcode=r.distdyn,j={bits:r.distbits},N=s(2,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,j),r.distbits=j.bits,N){t.msg="invalid distances set",r.mode=c;break}if(r.mode=20,6===e)break t;case 20:r.mode=21;case 21:if(b>=6&&g>=258){t.next_out=y,t.avail_out=g,t.next_in=d,t.avail_in=b,r.hold=v,r.bits=w,a(t,E),y=t.next_out,p=t.output,g=t.avail_out,d=t.next_in,h=t.input,b=t.avail_in,v=r.hold,w=r.bits,r.mode===f&&(r.back=-1);break}for(r.back=0;I=(C=r.lencode[v&(1<<r.lenbits)-1])>>>16&255,P=65535&C,!((A=C>>>24)<=w);){if(0===b)break t;b--,v+=h[d++]<<w,w+=8}if(I&&!(240&I)){for(x=A,B=I,R=P;I=(C=r.lencode[R+((v&(1<<x+B)-1)>>x)])>>>16&255,P=65535&C,!(x+(A=C>>>24)<=w);){if(0===b)break t;b--,v+=h[d++]<<w,w+=8}v>>>=x,w-=x,r.back+=x}if(v>>>=A,w-=A,r.back+=A,r.length=P,0===I){r.mode=26;break}if(32&I){r.back=-1,r.mode=f;break}if(64&I){t.msg="invalid literal/length code",r.mode=c;break}r.extra=15&I,r.mode=22;case 22:if(r.extra){for(L=r.extra;w<L;){if(0===b)break t;b--,v+=h[d++]<<w,w+=8}r.length+=v&(1<<r.extra)-1,v>>>=r.extra,w-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=23;case 23:for(;I=(C=r.distcode[v&(1<<r.distbits)-1])>>>16&255,P=65535&C,!((A=C>>>24)<=w);){if(0===b)break t;b--,v+=h[d++]<<w,w+=8}if(!(240&I)){for(x=A,B=I,R=P;I=(C=r.distcode[R+((v&(1<<x+B)-1)>>x)])>>>16&255,P=65535&C,!(x+(A=C>>>24)<=w);){if(0===b)break t;b--,v+=h[d++]<<w,w+=8}v>>>=x,w-=x,r.back+=x}if(v>>>=A,w-=A,r.back+=A,64&I){t.msg="invalid distance code",r.mode=c;break}r.offset=P,r.extra=15&I,r.mode=24;case 24:if(r.extra){for(L=r.extra;w<L;){if(0===b)break t;b--,v+=h[d++]<<w,w+=8}r.offset+=v&(1<<r.extra)-1,v>>>=r.extra,w-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){t.msg="invalid distance too far back",r.mode=c;break}r.mode=25;case 25:if(0===g)break t;if(k=E-g,r.offset>k){if((k=r.offset-k)>r.whave&&r.sane){t.msg="invalid distance too far back",r.mode=c;break}k>r.wnext?(k-=r.wnext,O=r.wsize-k):O=r.wnext-k,k>r.length&&(k=r.length),T=r.window}else T=p,O=y-r.offset,k=r.length;k>g&&(k=g),g-=k,r.length-=k;do{p[y++]=T[O++]}while(--k);0===r.length&&(r.mode=21);break;case 26:if(0===g)break t;p[y++]=r.length,g--,r.mode=21;break;case 27:if(r.wrap){for(;w<32;){if(0===b)break t;b--,v|=h[d++]<<w,w+=8}if(E-=g,t.total_out+=E,r.total+=E,E&&(t.adler=r.check=r.flags?o(r.check,p,E,y-E):i(r.check,p,E,y-E)),E=g,(r.flags?v:l(v))!==r.check){t.msg="incorrect data check",r.mode=c;break}v=0,w=0}r.mode=28;case 28:if(r.wrap&&r.flags){for(;w<32;){if(0===b)break t;b--,v+=h[d++]<<w,w+=8}if(v!==(4294967295&r.total)){t.msg="incorrect length check",r.mode=c;break}v=0,w=0}r.mode=29;case 29:N=1;break t;case c:N=-3;break t;case 31:return-4;default:return u}return t.next_out=y,t.avail_out=g,t.next_in=d,t.avail_in=b,r.hold=v,r.bits=w,(r.wsize||E!==t.avail_out&&r.mode<c&&(r.mode<27||4!==e))&&S(t,t.output,t.next_out,E-t.avail_out)?(r.mode=31,-4):(_-=t.avail_in,E-=t.avail_out,t.total_in+=_,t.total_out+=E,r.total+=E,r.wrap&&E&&(t.adler=r.check=r.flags?o(r.check,p,E,t.next_out-E):i(r.check,p,E,t.next_out-E)),t.data_type=r.bits+(r.last?64:0)+(r.mode===f?128:0)+(20===r.mode||15===r.mode?256:0),(0===_&&0===E||4===e)&&0===N&&(N=-5),N)},e.inflateEnd=function(t){if(!t||!t.state)return u;var e=t.state;return e.window&&(e.window=null),t.state=null,0},e.inflateGetHeader=function(t,e){var r;return t&&t.state&&2&(r=t.state).wrap?(r.head=e,e.done=!1,0):u},e.inflateSetDictionary=function(t,e){var r,n=e.length;return t&&t.state?0!==(r=t.state).wrap&&11!==r.mode?u:11===r.mode&&i(1,e,n,0)!==r.check?-3:S(t,e,n,n)?(r.mode=31,-4):(r.havedict=1,0):u},e.inflateInfo="pako inflate (from Nodeca project)"},1468:(t,e,r)=>{var n=r(5606);function i(t,e){a(t,e),o(t)}function o(t){t._writableState&&!t._writableState.emitClose||t._readableState&&!t._readableState.emitClose||t.emit("close")}function a(t,e){t.emit("error",e)}t.exports={destroy:function(t,e){var r=this,s=this._readableState&&this._readableState.destroyed,u=this._writableState&&this._writableState.destroyed;return s||u?(e?e(t):t&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,n.nextTick(a,this,t)):n.nextTick(a,this,t)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(t||null,function(t){!e&&t?r._writableState?r._writableState.errorEmitted?n.nextTick(o,r):(r._writableState.errorEmitted=!0,n.nextTick(i,r,t)):n.nextTick(i,r,t):e?(n.nextTick(o,r),e(t)):n.nextTick(o,r)}),this)},undestroy:function(){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)},errorOrDestroy:function(t,e){var r=t._readableState,n=t._writableState;r&&r.autoDestroy||n&&n.autoDestroy?t.destroy(e):t.emit("error",e)}}},1484:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.isHash=e.validateObject=e.memoized=e.notImplemented=e.createHmacDrbg=e.bitMask=e.bitSet=e.bitGet=e.bitLen=e.aInRange=e.inRange=e.asciiToBytes=e.copyBytes=e.equalBytes=e.ensureBytes=e.numberToVarBytesBE=e.numberToBytesLE=e.numberToBytesBE=e.bytesToNumberLE=e.bytesToNumberBE=e.hexToNumber=e.numberToHexUnpadded=e.abool=e.utf8ToBytes=e.randomBytes=e.isBytes=e.hexToBytes=e.concatBytes=e.bytesToUtf8=e.bytesToHex=e.anumber=e.abytes=void 0;const n=r(8627);e.abytes=n.abytes,e.anumber=n.anumber,e.bytesToHex=n.bytesToHex,e.bytesToUtf8=n.bytesToUtf8,e.concatBytes=n.concatBytes,e.hexToBytes=n.hexToBytes,e.isBytes=n.isBytes,e.randomBytes=n.randomBytes,e.utf8ToBytes=n.utf8ToBytes,e.abool=n.abool,e.numberToHexUnpadded=n.numberToHexUnpadded,e.hexToNumber=n.hexToNumber,e.bytesToNumberBE=n.bytesToNumberBE,e.bytesToNumberLE=n.bytesToNumberLE,e.numberToBytesBE=n.numberToBytesBE,e.numberToBytesLE=n.numberToBytesLE,e.numberToVarBytesBE=n.numberToVarBytesBE,e.ensureBytes=n.ensureBytes,e.equalBytes=n.equalBytes,e.copyBytes=n.copyBytes,e.asciiToBytes=n.asciiToBytes,e.inRange=n.inRange,e.aInRange=n.aInRange,e.bitLen=n.bitLen,e.bitGet=n.bitGet,e.bitSet=n.bitSet,e.bitMask=n.bitMask,e.createHmacDrbg=n.createHmacDrbg,e.notImplemented=n.notImplemented,e.memoized=n.memoized,e.validateObject=n.validateObject,e.isHash=n.isHash},1514:t=>{t.exports=Math.abs},1603:(t,e,r)=>{(e=t.exports=r(6736)).Stream=e,e.Readable=e,e.Writable=r(2192),e.Duplex=r(2818),e.Transform=r(3054),e.PassThrough=r(5860),e.finished=r(5826),e.pipeline=r(9434)},1705:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.DER=e.DERErr=void 0,e._splitEndoScalar=f,e._normFnElement=v,e.weierstrassN=w,e.SWUFpSqrtRatio=S,e.mapToCurveSimpleSWU=function(t,e){(0,s.validateField)(t);const{A:r,B:n,Z:i}=e;if(!t.isValid(r)||!t.isValid(n)||!t.isValid(i))throw new Error("mapToCurveSimpleSWU: invalid opts");const o=S(t,i);if(!t.isOdd)throw new Error("Field does not have .isOdd()");return e=>{let a,u,f,c,l,h,p,d;a=t.sqr(e),a=t.mul(a,i),u=t.sqr(a),u=t.add(u,a),f=t.add(u,t.ONE),f=t.mul(f,n),c=t.cmov(i,t.neg(u),!t.eql(u,t.ZERO)),c=t.mul(c,r),u=t.sqr(f),h=t.sqr(c),l=t.mul(h,r),u=t.add(u,l),u=t.mul(u,f),h=t.mul(h,c),l=t.mul(h,n),u=t.add(u,l),p=t.mul(a,f);const{isValid:y,value:b}=o(u,h);d=t.mul(a,e),d=t.mul(d,b),p=t.cmov(p,f,y),d=t.cmov(d,b,y);const g=t.isOdd(e)===t.isOdd(d);d=t.cmov(t.neg(d),d,g);const v=(0,s.FpInvertBatch)(t,[c],!0)[0];return p=t.mul(p,v),{x:p,y:d}}},e.ecdh=E,e.ecdsa=k,e.weierstrassPoints=function(t){const{CURVE:e,curveOpts:r}=O(t);return function(t,e){const{Fp:r,Fn:n}=e;const i=T(r,t.a,t.b);return Object.assign({},{CURVE:t,Point:e,ProjectivePoint:e,normPrivateKeyToScalar:t=>v(n,t),weierstrassEquation:i,isWithinCurveOrder:function(t){return(0,o.inRange)(t,d,n.ORDER)}})}(t,w(e,r))},e._legacyHelperEquat=T,e.weierstrass=function(t){const{CURVE:e,curveOpts:r,hash:n,ecdsaOpts:i}=function(t){const{CURVE:e,curveOpts:r}=O(t),n={hmac:t.hmac,randomBytes:t.randomBytes,lowS:t.lowS,bits2int:t.bits2int,bits2int_modN:t.bits2int_modN};return{CURVE:e,curveOpts:r,hash:t.hash,ecdsaOpts:n}}(t);return function(t,e){const r=e.Point;return Object.assign({},e,{ProjectivePoint:r,CURVE:Object.assign({},t,(0,s.nLength)(r.Fn.ORDER,r.Fn.BITS))})}(t,k(w(e,r),n,i))};const n=r(9615),i=r(9175),o=r(8627),a=r(2422),s=r(4967),u=(t,e)=>(t+(t>=0?e:-e)/y)/e;function f(t,e,r){const[[n,i],[a,s]]=e,f=u(s*t,r),c=u(-i*t,r);let l=t-f*n-c*a,h=-f*i-c*s;const y=l<p,b=h<p;y&&(l=-l),b&&(h=-h);const g=(0,o.bitMask)(Math.ceil((0,o.bitLen)(r)/2))+d;if(l<p||l>=g||h<p||h>=g)throw new Error("splitScalar (endomorphism): failed, k="+t);return{k1neg:y,k1:l,k2neg:b,k2:h}}function c(t){if(!["compact","recovered","der"].includes(t))throw new Error('Signature format must be "compact", "recovered", or "der"');return t}function l(t,e){const r={};for(let n of Object.keys(e))r[n]=void 0===t[n]?e[n]:t[n];return(0,o._abool2)(r.lowS,"lowS"),(0,o._abool2)(r.prehash,"prehash"),void 0!==r.format&&c(r.format),r}class h extends Error{constructor(t=""){super(t)}}e.DERErr=h,e.DER={Err:h,_tlv:{encode:(t,r)=>{const{Err:n}=e.DER;if(t<0||t>256)throw new n("tlv.encode: wrong tag");if(1&r.length)throw new n("tlv.encode: unpadded data");const i=r.length/2,a=(0,o.numberToHexUnpadded)(i);if(a.length/2&128)throw new n("tlv.encode: long form length too big");const s=i>127?(0,o.numberToHexUnpadded)(a.length/2|128):"";return(0,o.numberToHexUnpadded)(t)+s+a+r},decode(t,r){const{Err:n}=e.DER;let i=0;if(t<0||t>256)throw new n("tlv.encode: wrong tag");if(r.length<2||r[i++]!==t)throw new n("tlv.decode: wrong tlv");const o=r[i++];let a=0;if(128&o){const t=127&o;if(!t)throw new n("tlv.decode(long): indefinite length not supported");if(t>4)throw new n("tlv.decode(long): byte length is too big");const e=r.subarray(i,i+t);if(e.length!==t)throw new n("tlv.decode: length bytes not complete");if(0===e[0])throw new n("tlv.decode(long): zero leftmost byte");for(const t of e)a=a<<8|t;if(i+=t,a<128)throw new n("tlv.decode(long): not minimal encoding")}else a=o;const s=r.subarray(i,i+a);if(s.length!==a)throw new n("tlv.decode: wrong value length");return{v:s,l:r.subarray(i+a)}}},_int:{encode(t){const{Err:r}=e.DER;if(t<p)throw new r("integer: negative integers are not allowed");let n=(0,o.numberToHexUnpadded)(t);if(8&Number.parseInt(n[0],16)&&(n="00"+n),1&n.length)throw new r("unexpected DER parsing assertion: unpadded hex");return n},decode(t){const{Err:r}=e.DER;if(128&t[0])throw new r("invalid signature integer: negative");if(0===t[0]&&!(128&t[1]))throw new r("invalid signature integer: unnecessary leading zero");return(0,o.bytesToNumberBE)(t)}},toSig(t){const{Err:r,_int:n,_tlv:i}=e.DER,a=(0,o.ensureBytes)("signature",t),{v:s,l:u}=i.decode(48,a);if(u.length)throw new r("invalid signature: left bytes after parsing");const{v:f,l:c}=i.decode(2,s),{v:l,l:h}=i.decode(2,c);if(h.length)throw new r("invalid signature: left bytes after parsing");return{r:n.decode(f),s:n.decode(l)}},hexFromSig(t){const{_tlv:r,_int:n}=e.DER,i=r.encode(2,n.encode(t.r))+r.encode(2,n.encode(t.s));return r.encode(48,i)}};const p=BigInt(0),d=BigInt(1),y=BigInt(2),b=BigInt(3),g=BigInt(4);function v(t,e){const{BYTES:r}=t;let n;if("bigint"==typeof e)n=e;else{let i=(0,o.ensureBytes)("private key",e);try{n=t.fromBytes(i)}catch(t){throw new Error(`invalid private key: expected ui8a of size ${r}, got ${typeof e}`)}}if(!t.isValidNot0(n))throw new Error("invalid private key: out of range [1..N-1]");return n}function w(t,e={}){const r=(0,a._createCurveFields)("weierstrass",t,e),{Fp:n,Fn:i}=r;let s=r.CURVE;const{h:u,n:c}=s;(0,o._validateObject)(e,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object",wrapPrivateKey:"boolean"});const{endo:l}=e;if(l&&(!n.is0(s.a)||"bigint"!=typeof l.beta||!Array.isArray(l.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');const h=_(n,i);function y(){if(!n.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}const w=e.toBytes||function(t,e,r){const{x:i,y:a}=e.toAffine(),s=n.toBytes(i);if((0,o._abool2)(r,"isCompressed"),r){y();const t=!n.isOdd(a);return(0,o.concatBytes)(m(t),s)}return(0,o.concatBytes)(Uint8Array.of(4),s,n.toBytes(a))},S=e.fromBytes||function(t){(0,o._abytes2)(t,void 0,"Point");const{publicKey:e,publicKeyUncompressed:r}=h,i=t.length,a=t[0],s=t.subarray(1);if(i!==e||2!==a&&3!==a){if(i===r&&4===a){const t=n.BYTES,e=n.fromBytes(s.subarray(0,t)),r=n.fromBytes(s.subarray(t,2*t));if(!k(e,r))throw new Error("bad point: is not on curve");return{x:e,y:r}}throw new Error(`bad point: got length ${i}, expected compressed=${e} or uncompressed=${r}`)}{const t=n.fromBytes(s);if(!n.isValid(t))throw new Error("bad point: is not on curve, wrong x");const e=E(t);let r;try{r=n.sqrt(e)}catch(t){const e=t instanceof Error?": "+t.message:"";throw new Error("bad point: is not on curve, sqrt error"+e)}return y(),!(1&~a)!==n.isOdd(r)&&(r=n.neg(r)),{x:t,y:r}}};function E(t){const e=n.sqr(t),r=n.mul(e,t);return n.add(n.add(r,n.mul(t,s.a)),s.b)}function k(t,e){const r=n.sqr(e),i=E(t);return n.eql(r,i)}if(!k(s.Gx,s.Gy))throw new Error("bad curve params: generator point");const O=n.mul(n.pow(s.a,b),g),T=n.mul(n.sqr(s.b),BigInt(27));if(n.is0(n.add(O,T)))throw new Error("bad curve params: a or b");function A(t,e,r=!1){if(!n.isValid(e)||r&&n.is0(e))throw new Error(`bad point coordinate ${t}`);return e}function I(t){if(!(t instanceof U))throw new Error("ProjectivePoint expected")}function P(t){if(!l||!l.basises)throw new Error("no endo");return f(t,l.basises,i.ORDER)}const x=(0,o.memoized)((t,e)=>{const{X:r,Y:i,Z:o}=t;if(n.eql(o,n.ONE))return{x:r,y:i};const a=t.is0();null==e&&(e=a?n.ONE:n.inv(o));const s=n.mul(r,e),u=n.mul(i,e),f=n.mul(o,e);if(a)return{x:n.ZERO,y:n.ZERO};if(!n.eql(f,n.ONE))throw new Error("invZ was invalid");return{x:s,y:u}}),B=(0,o.memoized)(t=>{if(t.is0()){if(e.allowInfinityPoint&&!n.is0(t.Y))return;throw new Error("bad point: ZERO")}const{x:r,y:i}=t.toAffine();if(!n.isValid(r)||!n.isValid(i))throw new Error("bad point: x or y not field elements");if(!k(r,i))throw new Error("bad point: equation left != right");if(!t.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});function R(t,e,r,i,o){return r=new U(n.mul(r.X,t),r.Y,r.Z),e=(0,a.negateCt)(i,e),r=(0,a.negateCt)(o,r),e.add(r)}class U{constructor(t,e,r){this.X=A("x",t),this.Y=A("y",e,!0),this.Z=A("z",r),Object.freeze(this)}static CURVE(){return s}static fromAffine(t){const{x:e,y:r}=t||{};if(!t||!n.isValid(e)||!n.isValid(r))throw new Error("invalid affine point");if(t instanceof U)throw new Error("projective point not allowed");return n.is0(e)&&n.is0(r)?U.ZERO:new U(e,r,n.ONE)}static fromBytes(t){const e=U.fromAffine(S((0,o._abytes2)(t,void 0,"point")));return e.assertValidity(),e}static fromHex(t){return U.fromBytes((0,o.ensureBytes)("pointHex",t))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(t=8,e=!0){return j.createCache(this,t),e||this.multiply(b),this}assertValidity(){B(this)}hasEvenY(){const{y:t}=this.toAffine();if(!n.isOdd)throw new Error("Field doesn't support isOdd");return!n.isOdd(t)}equals(t){I(t);const{X:e,Y:r,Z:i}=this,{X:o,Y:a,Z:s}=t,u=n.eql(n.mul(e,s),n.mul(o,i)),f=n.eql(n.mul(r,s),n.mul(a,i));return u&&f}negate(){return new U(this.X,n.neg(this.Y),this.Z)}double(){const{a:t,b:e}=s,r=n.mul(e,b),{X:i,Y:o,Z:a}=this;let u=n.ZERO,f=n.ZERO,c=n.ZERO,l=n.mul(i,i),h=n.mul(o,o),p=n.mul(a,a),d=n.mul(i,o);return d=n.add(d,d),c=n.mul(i,a),c=n.add(c,c),u=n.mul(t,c),f=n.mul(r,p),f=n.add(u,f),u=n.sub(h,f),f=n.add(h,f),f=n.mul(u,f),u=n.mul(d,u),c=n.mul(r,c),p=n.mul(t,p),d=n.sub(l,p),d=n.mul(t,d),d=n.add(d,c),c=n.add(l,l),l=n.add(c,l),l=n.add(l,p),l=n.mul(l,d),f=n.add(f,l),p=n.mul(o,a),p=n.add(p,p),l=n.mul(p,d),u=n.sub(u,l),c=n.mul(p,h),c=n.add(c,c),c=n.add(c,c),new U(u,f,c)}add(t){I(t);const{X:e,Y:r,Z:i}=this,{X:o,Y:a,Z:u}=t;let f=n.ZERO,c=n.ZERO,l=n.ZERO;const h=s.a,p=n.mul(s.b,b);let d=n.mul(e,o),y=n.mul(r,a),g=n.mul(i,u),v=n.add(e,r),w=n.add(o,a);v=n.mul(v,w),w=n.add(d,y),v=n.sub(v,w),w=n.add(e,i);let m=n.add(o,u);return w=n.mul(w,m),m=n.add(d,g),w=n.sub(w,m),m=n.add(r,i),f=n.add(a,u),m=n.mul(m,f),f=n.add(y,g),m=n.sub(m,f),l=n.mul(h,w),f=n.mul(p,g),l=n.add(f,l),f=n.sub(y,l),l=n.add(y,l),c=n.mul(f,l),y=n.add(d,d),y=n.add(y,d),g=n.mul(h,g),w=n.mul(p,w),y=n.add(y,g),g=n.sub(d,g),g=n.mul(h,g),w=n.add(w,g),d=n.mul(y,w),c=n.add(c,d),d=n.mul(m,w),f=n.mul(v,f),f=n.sub(f,d),d=n.mul(v,y),l=n.mul(m,l),l=n.add(l,d),new U(f,c,l)}subtract(t){return this.add(t.negate())}is0(){return this.equals(U.ZERO)}multiply(t){const{endo:r}=e;if(!i.isValidNot0(t))throw new Error("invalid scalar: out of range");let n,o;const s=t=>j.cached(this,t,t=>(0,a.normalizeZ)(U,t));if(r){const{k1neg:e,k1:i,k2neg:a,k2:u}=P(t),{p:f,f:c}=s(i),{p:l,f:h}=s(u);o=c.add(h),n=R(r.beta,f,l,e,a)}else{const{p:e,f:r}=s(t);n=e,o=r}return(0,a.normalizeZ)(U,[n,o])[0]}multiplyUnsafe(t){const{endo:r}=e,n=this;if(!i.isValid(t))throw new Error("invalid scalar: out of range");if(t===p||n.is0())return U.ZERO;if(t===d)return n;if(j.hasCache(this))return this.multiply(t);if(r){const{k1neg:e,k1:i,k2neg:o,k2:s}=P(t),{p1:u,p2:f}=(0,a.mulEndoUnsafe)(U,n,i,s);return R(r.beta,u,f,e,o)}return j.unsafe(n,t)}multiplyAndAddUnsafe(t,e,r){const n=this.multiplyUnsafe(e).add(t.multiplyUnsafe(r));return n.is0()?void 0:n}toAffine(t){return x(this,t)}isTorsionFree(){const{isTorsionFree:t}=e;return u===d||(t?t(U,this):j.unsafe(this,c).is0())}clearCofactor(){const{clearCofactor:t}=e;return u===d?this:t?t(U,this):this.multiplyUnsafe(u)}isSmallOrder(){return this.multiplyUnsafe(u).is0()}toBytes(t=!0){return(0,o._abool2)(t,"isCompressed"),this.assertValidity(),w(U,this,t)}toHex(t=!0){return(0,o.bytesToHex)(this.toBytes(t))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}get px(){return this.X}get py(){return this.X}get pz(){return this.Z}toRawBytes(t=!0){return this.toBytes(t)}_setWindowSize(t){this.precompute(t)}static normalizeZ(t){return(0,a.normalizeZ)(U,t)}static msm(t,e){return(0,a.pippenger)(U,i,t,e)}static fromPrivateKey(t){return U.BASE.multiply(v(i,t))}}U.BASE=new U(s.Gx,s.Gy,n.ONE),U.ZERO=new U(n.ZERO,n.ONE,n.ZERO),U.Fp=n,U.Fn=i;const N=i.BITS,j=new a.wNAF(U,e.endo?Math.ceil(N/2):N);return U.BASE.precompute(8),U}function m(t){return Uint8Array.of(t?2:3)}function S(t,e){const r=t.ORDER;let n=p;for(let t=r-d;t%y===p;t/=y)n+=d;const i=n,o=y<<i-d-d,a=o*y,s=(r-d)/a,u=(s-d)/y,f=a-d,c=o,l=t.pow(e,s),h=t.pow(e,(s+d)/y);let v=(e,r)=>{let n=l,o=t.pow(r,f),a=t.sqr(o);a=t.mul(a,r);let s=t.mul(e,a);s=t.pow(s,u),s=t.mul(s,o),o=t.mul(s,r),a=t.mul(s,e);let p=t.mul(a,o);s=t.pow(p,c);let b=t.eql(s,t.ONE);o=t.mul(a,h),s=t.mul(p,n),a=t.cmov(o,a,b),p=t.cmov(s,p,b);for(let e=i;e>d;e--){let r=e-y;r=y<<r-d;let i=t.pow(p,r);const s=t.eql(i,t.ONE);o=t.mul(a,n),n=t.mul(n,n),i=t.mul(p,n),a=t.cmov(o,a,s),p=t.cmov(i,p,s)}return{isValid:b,value:a}};if(t.ORDER%g===b){const r=(t.ORDER-b)/g,n=t.sqrt(t.neg(e));v=(e,i)=>{let o=t.sqr(i);const a=t.mul(e,i);o=t.mul(o,a);let s=t.pow(o,r);s=t.mul(s,a);const u=t.mul(s,n),f=t.mul(t.sqr(s),i),c=t.eql(f,e);return{isValid:c,value:t.cmov(u,s,c)}}}return v}function _(t,e){return{secretKey:e.BYTES,publicKey:1+t.BYTES,publicKeyUncompressed:1+2*t.BYTES,publicKeyHasPrefix:!0,signature:2*e.BYTES}}function E(t,e={}){const{Fn:r}=t,n=e.randomBytes||o.randomBytes,i=Object.assign(_(t.Fp,r),{seed:(0,s.getMinHashLength)(r.ORDER)});function a(t){try{return!!v(r,t)}catch(t){return!1}}function u(t=n(i.seed)){return(0,s.mapHashToField)((0,o._abytes2)(t,i.seed,"seed"),r.ORDER)}function f(e,n=!0){return t.BASE.multiply(v(r,e)).toBytes(n)}function c(e){if("bigint"==typeof e)return!1;if(e instanceof t)return!0;const{secretKey:n,publicKey:a,publicKeyUncompressed:s}=i;if(r.allowedLengths||n===a)return;const u=(0,o.ensureBytes)("key",e).length;return u===a||u===s}const l={isValidSecretKey:a,isValidPublicKey:function(e,r){const{publicKey:n,publicKeyUncompressed:o}=i;try{const i=e.length;return!(!0===r&&i!==n||!1===r&&i!==o||!t.fromBytes(e))}catch(t){return!1}},randomSecretKey:u,isValidPrivateKey:a,randomPrivateKey:u,normPrivateKeyToScalar:t=>v(r,t),precompute:(e=8,r=t.BASE)=>r.precompute(e,!1)};return Object.freeze({getPublicKey:f,getSharedSecret:function(e,n,i=!0){if(!0===c(e))throw new Error("first arg must be private key");if(!1===c(n))throw new Error("second arg must be public key");const o=v(r,e);return t.fromHex(n).multiply(o).toBytes(i)},keygen:function(t){const e=u(t);return{secretKey:e,publicKey:f(e)}},Point:t,utils:l,lengths:i})}function k(t,r,a={}){(0,i.ahash)(r),(0,o._validateObject)(a,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});const s=a.randomBytes||o.randomBytes,u=a.hmac||((t,...e)=>(0,n.hmac)(r,t,(0,o.concatBytes)(...e))),{Fp:f,Fn:h}=t,{ORDER:b,BITS:g}=h,{keygen:w,getPublicKey:S,getSharedSecret:_,utils:k,lengths:O}=E(t,a),T={prehash:!1,lowS:"boolean"==typeof a.lowS&&a.lowS,format:void 0,extraEntropy:!1},A="compact";function I(t){return t>b>>d}function P(t,e){if(!h.isValidNot0(e))throw new Error(`invalid signature ${t}: out of range 1..Point.Fn.ORDER`);return e}class x{constructor(t,e,r){this.r=P("r",t),this.s=P("s",e),null!=r&&(this.recovery=r),Object.freeze(this)}static fromBytes(t,r=A){let n;if(function(t,e){c(e);const r=O.signature,n="compact"===e?r:"recovered"===e?r+1:void 0;(0,o._abytes2)(t,n,`${e} signature`)}(t,r),"der"===r){const{r,s:n}=e.DER.toSig((0,o._abytes2)(t));return new x(r,n)}"recovered"===r&&(n=t[0],r="compact",t=t.subarray(1));const i=h.BYTES,a=t.subarray(0,i),s=t.subarray(i,2*i);return new x(h.fromBytes(a),h.fromBytes(s),n)}static fromHex(t,e){return this.fromBytes((0,o.hexToBytes)(t),e)}addRecoveryBit(t){return new x(this.r,this.s,t)}recoverPublicKey(e){const r=f.ORDER,{r:n,s:i,recovery:a}=this;if(null==a||![0,1,2,3].includes(a))throw new Error("recovery id invalid");if(b*y<r&&a>1)throw new Error("recovery id is ambiguous for h>1 curve");const s=2===a||3===a?n+b:n;if(!f.isValid(s))throw new Error("recovery id 2 or 3 invalid");const u=f.toBytes(s),c=t.fromBytes((0,o.concatBytes)(m(!(1&a)),u)),l=h.inv(s),p=R((0,o.ensureBytes)("msgHash",e)),d=h.create(-p*l),g=h.create(i*l),v=t.BASE.multiplyUnsafe(d).add(c.multiplyUnsafe(g));if(v.is0())throw new Error("point at infinify");return v.assertValidity(),v}hasHighS(){return I(this.s)}toBytes(t=A){if(c(t),"der"===t)return(0,o.hexToBytes)(e.DER.hexFromSig(this));const r=h.toBytes(this.r),n=h.toBytes(this.s);if("recovered"===t){if(null==this.recovery)throw new Error("recovery bit must be present");return(0,o.concatBytes)(Uint8Array.of(this.recovery),r,n)}return(0,o.concatBytes)(r,n)}toHex(t){return(0,o.bytesToHex)(this.toBytes(t))}assertValidity(){}static fromCompact(t){return x.fromBytes((0,o.ensureBytes)("sig",t),"compact")}static fromDER(t){return x.fromBytes((0,o.ensureBytes)("sig",t),"der")}normalizeS(){return this.hasHighS()?new x(this.r,h.neg(this.s),this.recovery):this}toDERRawBytes(){return this.toBytes("der")}toDERHex(){return(0,o.bytesToHex)(this.toBytes("der"))}toCompactRawBytes(){return this.toBytes("compact")}toCompactHex(){return(0,o.bytesToHex)(this.toBytes("compact"))}}const B=a.bits2int||function(t){if(t.length>8192)throw new Error("input is too large");const e=(0,o.bytesToNumberBE)(t),r=8*t.length-g;return r>0?e>>BigInt(r):e},R=a.bits2int_modN||function(t){return h.create(B(t))},U=(0,o.bitMask)(g);function N(t){return(0,o.aInRange)("num < 2^"+g,t,p,U),h.toBytes(t)}function j(t,e){return(0,o._abytes2)(t,void 0,"message"),e?(0,o._abytes2)(r(t),void 0,"prehashed message"):t}return Object.freeze({keygen:w,getPublicKey:S,getSharedSecret:_,utils:k,lengths:O,Point:t,sign:function(e,n,i={}){e=(0,o.ensureBytes)("message",e);const{seed:a,k2sig:f}=function(e,r,n){if(["recovered","canonical"].some(t=>t in n))throw new Error("sign() legacy options not supported");const{lowS:i,prehash:a,extraEntropy:u}=l(n,T);e=j(e,a);const f=R(e),c=v(h,r),y=[N(c),N(f)];if(null!=u&&!1!==u){const t=!0===u?s(O.secretKey):u;y.push((0,o.ensureBytes)("extraEntropy",t))}const b=(0,o.concatBytes)(...y),g=f;return{seed:b,k2sig:function(e){const r=B(e);if(!h.isValidNot0(r))return;const n=h.inv(r),o=t.BASE.multiply(r).toAffine(),a=h.create(o.x);if(a===p)return;const s=h.create(n*h.create(g+a*c));if(s===p)return;let u=(o.x===a?0:2)|Number(o.y&d),f=s;return i&&I(s)&&(f=h.neg(s),u^=1),new x(a,f,u)}}}(e,n,i);return(0,o.createHmacDrbg)(r.outputLen,h.BYTES,u)(a,f)},verify:function(r,n,i,a={}){const{lowS:s,prehash:u,format:f}=l(a,T);if(i=(0,o.ensureBytes)("publicKey",i),n=j((0,o.ensureBytes)("message",n),u),"strict"in a)throw new Error("options.strict was renamed to lowS");const c=void 0===f?function(t){let r;const n="string"==typeof t||(0,o.isBytes)(t),i=!n&&null!==t&&"object"==typeof t&&"bigint"==typeof t.r&&"bigint"==typeof t.s;if(!n&&!i)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");if(i)r=new x(t.r,t.s);else if(n){try{r=x.fromBytes((0,o.ensureBytes)("sig",t),"der")}catch(t){if(!(t instanceof e.DER.Err))throw t}if(!r)try{r=x.fromBytes((0,o.ensureBytes)("sig",t),"compact")}catch(t){return!1}}return r||!1}(r):x.fromBytes((0,o.ensureBytes)("sig",r),f);if(!1===c)return!1;try{const e=t.fromBytes(i);if(s&&c.hasHighS())return!1;const{r,s:o}=c,a=R(n),u=h.inv(o),f=h.create(a*u),l=h.create(r*u),p=t.BASE.multiplyUnsafe(f).add(e.multiplyUnsafe(l));return!p.is0()&&h.create(p.x)===r}catch(t){return!1}},recoverPublicKey:function(t,e,r={}){const{prehash:n}=l(r,T);return e=j(e,n),x.fromBytes(t,"recovered").recoverPublicKey(e).toBytes()},Signature:x,hash:r})}function O(t){const e={a:t.a,b:t.b,p:t.Fp.ORDER,n:t.n,h:t.h,Gx:t.Gx,Gy:t.Gy},r=t.Fp;let n=t.allowedPrivateKeyLengths?Array.from(new Set(t.allowedPrivateKeyLengths.map(t=>Math.ceil(t/2)))):void 0;return{CURVE:e,curveOpts:{Fp:r,Fn:(0,s.Field)(e.n,{BITS:t.nBitLength,allowedLengths:n,modFromBytes:t.wrapPrivateKey}),allowInfinityPoint:t.allowInfinityPoint,endo:t.endo,isTorsionFree:t.isTorsionFree,clearCofactor:t.clearCofactor,fromBytes:t.fromBytes,toBytes:t.toBytes}}}function T(t,e,r){return function(n){const i=t.sqr(n),o=t.mul(i,n);return t.add(t.add(o,t.mul(n,e)),r)}}},1761:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e._DST_scalar=void 0,e.expand_message_xmd=c,e.expand_message_xof=l,e.hash_to_field=h,e.isogenyMap=function(t,e){const r=e.map(t=>Array.from(t).reverse());return(e,n)=>{const[o,a,s,u]=r.map(r=>r.reduce((r,n)=>t.add(t.mul(r,e),n))),[f,c]=(0,i.FpInvertBatch)(t,[a,u],!0);return e=t.mul(o,f),n=t.mul(n,t.mul(s,c)),{x:e,y:n}}},e.createHasher=function(t,r,n){if("function"!=typeof r)throw new Error("mapToCurve() must be defined");function i(e){return t.fromAffine(r(e))}function o(e){const r=e.clearCofactor();return r.equals(t.ZERO)?t.ZERO:(r.assertValidity(),r)}return{defaults:n,hashToCurve(t,e){const r=h(t,2,Object.assign({},n,e)),a=i(r[0]),s=i(r[1]);return o(a.add(s))},encodeToCurve(t,e){const r=n.encodeDST?{DST:n.encodeDST}:{};return o(i(h(t,1,Object.assign({},n,r,e))[0]))},mapToCurve(t){if(!Array.isArray(t))throw new Error("expected array of bigints");for(const e of t)if("bigint"!=typeof e)throw new Error("expected array of bigints");return o(i(t))},hashToScalar(r,i){const o=t.Fn.ORDER;return h(r,1,Object.assign({},n,{p:o,m:1,DST:e._DST_scalar},i))[0][0]}}};const n=r(8627),i=r(4967),o=n.bytesToNumberBE;function a(t,e){if(u(t),u(e),t<0||t>=1<<8*e)throw new Error("invalid I2OSP input: "+t);const r=Array.from({length:e}).fill(0);for(let n=e-1;n>=0;n--)r[n]=255&t,t>>>=8;return new Uint8Array(r)}function s(t,e){const r=new Uint8Array(t.length);for(let n=0;n<t.length;n++)r[n]=t[n]^e[n];return r}function u(t){if(!Number.isSafeInteger(t))throw new Error("number expected")}function f(t){if(!(0,n.isBytes)(t)&&"string"!=typeof t)throw new Error("DST must be Uint8Array or string");return"string"==typeof t?(0,n.utf8ToBytes)(t):t}function c(t,e,r,i){(0,n.abytes)(t),u(r),(e=f(e)).length>255&&(e=i((0,n.concatBytes)((0,n.utf8ToBytes)("H2C-OVERSIZE-DST-"),e)));const{outputLen:o,blockLen:c}=i,l=Math.ceil(r/o);if(r>65535||l>255)throw new Error("expand_message_xmd: invalid lenInBytes");const h=(0,n.concatBytes)(e,a(e.length,1)),p=a(0,c),d=a(r,2),y=new Array(l),b=i((0,n.concatBytes)(p,t,d,a(0,1),h));y[0]=i((0,n.concatBytes)(b,a(1,1),h));for(let t=1;t<=l;t++){const e=[s(b,y[t-1]),a(t+1,1),h];y[t]=i((0,n.concatBytes)(...e))}return(0,n.concatBytes)(...y).slice(0,r)}function l(t,e,r,i,o){if((0,n.abytes)(t),u(r),(e=f(e)).length>255){const t=Math.ceil(2*i/8);e=o.create({dkLen:t}).update((0,n.utf8ToBytes)("H2C-OVERSIZE-DST-")).update(e).digest()}if(r>65535||e.length>255)throw new Error("expand_message_xof: invalid lenInBytes");return o.create({dkLen:r}).update(t).update(a(r,2)).update(e).update(a(e.length,1)).digest()}function h(t,e,r){(0,n._validateObject)(r,{p:"bigint",m:"number",k:"number",hash:"function"});const{p:a,k:s,m:f,hash:h,expand:p,DST:d}=r;if(!(0,n.isHash)(r.hash))throw new Error("expected valid hash");(0,n.abytes)(t),u(e);const y=a.toString(2).length,b=Math.ceil((y+s)/8),g=e*f*b;let v;if("xmd"===p)v=c(t,d,g,h);else if("xof"===p)v=l(t,d,g,s,h);else{if("_internal_pass"!==p)throw new Error('expand must be "xmd" or "xof"');v=t}const w=new Array(e);for(let t=0;t<e;t++){const e=new Array(f);for(let r=0;r<f;r++){const n=b*(r+t*f),s=v.subarray(n,n+b);e[r]=(0,i.mod)(o(s),a)}w[t]=e}return w}e._DST_scalar=(0,n.utf8ToBytes)("HashToScalar-")},1766:(t,e,r)=>{function n(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function i(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?n(Object(r),!0).forEach(function(e){o(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):n(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function o(t,e,r){return(e=s(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function a(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,s(n.key),n)}}function s(t){var e=function(t){if("object"!=typeof t||null===t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==typeof e?e:String(e)}var u=r(8287).Buffer,f=r(3779).inspect,c=f&&f.custom||"inspect";function l(t,e,r){u.prototype.copy.call(t,e,r)}t.exports=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.head=null,this.tail=null,this.length=0}var e,r;return e=t,r=[{key:"push",value:function(t){var e={data:t,next:null};this.length>0?this.tail.next=e:this.head=e,this.tail=e,++this.length}},{key:"unshift",value:function(t){var e={data:t,next:this.head};0===this.length&&(this.tail=e),this.head=e,++this.length}},{key:"shift",value:function(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(t){if(0===this.length)return"";for(var e=this.head,r=""+e.data;e=e.next;)r+=t+e.data;return r}},{key:"concat",value:function(t){if(0===this.length)return u.alloc(0);for(var e=u.allocUnsafe(t>>>0),r=this.head,n=0;r;)l(r.data,e,n),n+=r.data.length,r=r.next;return e}},{key:"consume",value:function(t,e){var r;return t<this.head.data.length?(r=this.head.data.slice(0,t),this.head.data=this.head.data.slice(t)):r=t===this.head.data.length?this.shift():e?this._getString(t):this._getBuffer(t),r}},{key:"first",value:function(){return this.head.data}},{key:"_getString",value:function(t){var e=this.head,r=1,n=e.data;for(t-=n.length;e=e.next;){var i=e.data,o=t>i.length?i.length:t;if(o===i.length?n+=i:n+=i.slice(0,t),0===(t-=o)){o===i.length?(++r,e.next?this.head=e.next:this.head=this.tail=null):(this.head=e,e.data=i.slice(o));break}++r}return this.length-=r,n}},{key:"_getBuffer",value:function(t){var e=u.allocUnsafe(t),r=this.head,n=1;for(r.data.copy(e),t-=r.data.length;r=r.next;){var i=r.data,o=t>i.length?i.length:t;if(i.copy(e,e.length-t,0,o),0===(t-=o)){o===i.length?(++n,r.next?this.head=r.next:this.head=this.tail=null):(this.head=r,r.data=i.slice(o));break}++n}return this.length-=n,e}},{key:c,value:function(t,e){return f(this,i(i({},e),{},{depth:0,customInspect:!1}))}}],r&&a(e.prototype,r),Object.defineProperty(e,"prototype",{writable:!1}),t}()},1998:(t,e,r)=>{var n=r(9805),i=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],o=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],a=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],s=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];t.exports=function(t,e,r,u,f,c,l,h){var p,d,y,b,g,v,w,m,S,_=h.bits,E=0,k=0,O=0,T=0,A=0,I=0,P=0,x=0,B=0,R=0,U=null,N=0,j=new n.Buf16(16),L=new n.Buf16(16),C=null,F=0;for(E=0;E<=15;E++)j[E]=0;for(k=0;k<u;k++)j[e[r+k]]++;for(A=_,T=15;T>=1&&0===j[T];T--);if(A>T&&(A=T),0===T)return f[c++]=20971520,f[c++]=20971520,h.bits=1,0;for(O=1;O<T&&0===j[O];O++);for(A<O&&(A=O),x=1,E=1;E<=15;E++)if(x<<=1,(x-=j[E])<0)return-1;if(x>0&&(0===t||1!==T))return-1;for(L[1]=0,E=1;E<15;E++)L[E+1]=L[E]+j[E];for(k=0;k<u;k++)0!==e[r+k]&&(l[L[e[r+k]]++]=k);if(0===t?(U=C=l,v=19):1===t?(U=i,N-=257,C=o,F-=257,v=256):(U=a,C=s,v=-1),R=0,k=0,E=O,g=c,I=A,P=0,y=-1,b=(B=1<<A)-1,1===t&&B>852||2===t&&B>592)return 1;for(;;){w=E-P,l[k]<v?(m=0,S=l[k]):l[k]>v?(m=C[F+l[k]],S=U[N+l[k]]):(m=96,S=0),p=1<<E-P,O=d=1<<I;do{f[g+(R>>P)+(d-=p)]=w<<24|m<<16|S}while(0!==d);for(p=1<<E-1;R&p;)p>>=1;if(0!==p?(R&=p-1,R+=p):R=0,k++,0===--j[E]){if(E===T)break;E=e[r+l[k]]}if(E>A&&(R&b)!==y){for(0===P&&(P=A),g+=O,x=1<<(I=E-P);I+P<T&&!((x-=j[I+P])<=0);)I++,x<<=1;if(B+=1<<I,1===t&&B>852||2===t&&B>592)return 1;f[y=R&b]=A<<24|I<<16|g-c}}return 0!==R&&(f[g+R]=E-P<<24|64<<16),h.bits=A,0}},1999:(t,e,r)=>{var n,i=r(5606);function o(t){var e=this;this.next=null,this.entry=null,this.finish=function(){!function(t,e){var r=t.entry;for(t.entry=null;r;){var n=r.callback;e.pendingcb--,n(undefined),r=r.next}e.corkedRequestsFree.next=t}(e,t)}}t.exports=O,O.WritableState=k;var a,s={deprecate:r(4643)},u=r(1396),f=r(8287).Buffer,c=(void 0!==r.g?r.g:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{}).Uint8Array||function(){},l=r(4347),h=r(6644).getHighWaterMark,p=r(2463).F,d=p.ERR_INVALID_ARG_TYPE,y=p.ERR_METHOD_NOT_IMPLEMENTED,b=p.ERR_MULTIPLE_CALLBACK,g=p.ERR_STREAM_CANNOT_PIPE,v=p.ERR_STREAM_DESTROYED,w=p.ERR_STREAM_NULL_VALUES,m=p.ERR_STREAM_WRITE_AFTER_END,S=p.ERR_UNKNOWN_ENCODING,_=l.errorOrDestroy;function E(){}function k(t,e,a){n=n||r(8101),t=t||{},"boolean"!=typeof a&&(a=e instanceof n),this.objectMode=!!t.objectMode,a&&(this.objectMode=this.objectMode||!!t.writableObjectMode),this.highWaterMark=h(this,t,"writableHighWaterMark",a),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var s=!1===t.decodeStrings;this.decodeStrings=!s,this.defaultEncoding=t.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(t){!function(t,e){var r=t._writableState,n=r.sync,o=r.writecb;if("function"!=typeof o)throw new b;if(function(t){t.writing=!1,t.writecb=null,t.length-=t.writelen,t.writelen=0}(r),e)!function(t,e,r,n,o){--e.pendingcb,r?(i.nextTick(o,n),i.nextTick(B,t,e),t._writableState.errorEmitted=!0,_(t,n)):(o(n),t._writableState.errorEmitted=!0,_(t,n),B(t,e))}(t,r,n,e,o);else{var a=P(r)||t.destroyed;a||r.corked||r.bufferProcessing||!r.bufferedRequest||I(t,r),n?i.nextTick(A,t,r,a,o):A(t,r,a,o)}}(e,t)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=!1!==t.emitClose,this.autoDestroy=!!t.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new o(this)}function O(t){var e=this instanceof(n=n||r(8101));if(!e&&!a.call(O,this))return new O(t);this._writableState=new k(t,this,e),this.writable=!0,t&&("function"==typeof t.write&&(this._write=t.write),"function"==typeof t.writev&&(this._writev=t.writev),"function"==typeof t.destroy&&(this._destroy=t.destroy),"function"==typeof t.final&&(this._final=t.final)),u.call(this)}function T(t,e,r,n,i,o,a){e.writelen=n,e.writecb=a,e.writing=!0,e.sync=!0,e.destroyed?e.onwrite(new v("write")):r?t._writev(i,e.onwrite):t._write(i,o,e.onwrite),e.sync=!1}function A(t,e,r,n){r||function(t,e){0===e.length&&e.needDrain&&(e.needDrain=!1,t.emit("drain"))}(t,e),e.pendingcb--,n(),B(t,e)}function I(t,e){e.bufferProcessing=!0;var r=e.bufferedRequest;if(t._writev&&r&&r.next){var n=e.bufferedRequestCount,i=new Array(n),a=e.corkedRequestsFree;a.entry=r;for(var s=0,u=!0;r;)i[s]=r,r.isBuf||(u=!1),r=r.next,s+=1;i.allBuffers=u,T(t,e,!0,e.length,i,"",a.finish),e.pendingcb++,e.lastBufferedRequest=null,a.next?(e.corkedRequestsFree=a.next,a.next=null):e.corkedRequestsFree=new o(e),e.bufferedRequestCount=0}else{for(;r;){var f=r.chunk,c=r.encoding,l=r.callback;if(T(t,e,!1,e.objectMode?1:f.length,f,c,l),r=r.next,e.bufferedRequestCount--,e.writing)break}null===r&&(e.lastBufferedRequest=null)}e.bufferedRequest=r,e.bufferProcessing=!1}function P(t){return t.ending&&0===t.length&&null===t.bufferedRequest&&!t.finished&&!t.writing}function x(t,e){t._final(function(r){e.pendingcb--,r&&_(t,r),e.prefinished=!0,t.emit("prefinish"),B(t,e)})}function B(t,e){var r=P(e);if(r&&(function(t,e){e.prefinished||e.finalCalled||("function"!=typeof t._final||e.destroyed?(e.prefinished=!0,t.emit("prefinish")):(e.pendingcb++,e.finalCalled=!0,i.nextTick(x,t,e)))}(t,e),0===e.pendingcb&&(e.finished=!0,t.emit("finish"),e.autoDestroy))){var n=t._readableState;(!n||n.autoDestroy&&n.endEmitted)&&t.destroy()}return r}r(6698)(O,u),k.prototype.getBuffer=function(){for(var t=this.bufferedRequest,e=[];t;)e.push(t),t=t.next;return e},function(){try{Object.defineProperty(k.prototype,"buffer",{get:s.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(t){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(a=Function.prototype[Symbol.hasInstance],Object.defineProperty(O,Symbol.hasInstance,{value:function(t){return!!a.call(this,t)||this===O&&t&&t._writableState instanceof k}})):a=function(t){return t instanceof this},O.prototype.pipe=function(){_(this,new g)},O.prototype.write=function(t,e,r){var n,o=this._writableState,a=!1,s=!o.objectMode&&(n=t,f.isBuffer(n)||n instanceof c);return s&&!f.isBuffer(t)&&(t=function(t){return f.from(t)}(t)),"function"==typeof e&&(r=e,e=null),s?e="buffer":e||(e=o.defaultEncoding),"function"!=typeof r&&(r=E),o.ending?function(t,e){var r=new m;_(t,r),i.nextTick(e,r)}(this,r):(s||function(t,e,r,n){var o;return null===r?o=new w:"string"==typeof r||e.objectMode||(o=new d("chunk",["string","Buffer"],r)),!o||(_(t,o),i.nextTick(n,o),!1)}(this,o,t,r))&&(o.pendingcb++,a=function(t,e,r,n,i,o){if(!r){var a=function(t,e,r){return t.objectMode||!1===t.decodeStrings||"string"!=typeof e||(e=f.from(e,r)),e}(e,n,i);n!==a&&(r=!0,i="buffer",n=a)}var s=e.objectMode?1:n.length;e.length+=s;var u=e.length<e.highWaterMark;if(u||(e.needDrain=!0),e.writing||e.corked){var c=e.lastBufferedRequest;e.lastBufferedRequest={chunk:n,encoding:i,isBuf:r,callback:o,next:null},c?c.next=e.lastBufferedRequest:e.bufferedRequest=e.lastBufferedRequest,e.bufferedRequestCount+=1}else T(t,e,!1,s,n,i,o);return u}(this,o,s,t,e,r)),a},O.prototype.cork=function(){this._writableState.corked++},O.prototype.uncork=function(){var t=this._writableState;t.corked&&(t.corked--,t.writing||t.corked||t.bufferProcessing||!t.bufferedRequest||I(this,t))},O.prototype.setDefaultEncoding=function(t){if("string"==typeof t&&(t=t.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((t+"").toLowerCase())>-1))throw new S(t);return this._writableState.defaultEncoding=t,this},Object.defineProperty(O.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(O.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),O.prototype._write=function(t,e,r){r(new y("_write()"))},O.prototype._writev=null,O.prototype.end=function(t,e,r){var n=this._writableState;return"function"==typeof t?(r=t,t=null,e=null):"function"==typeof e&&(r=e,e=null),null!=t&&this.write(t,e),n.corked&&(n.corked=1,this.uncork()),n.ending||function(t,e,r){e.ending=!0,B(t,e),r&&(e.finished?i.nextTick(r):t.once("finish",r)),e.ended=!0,t.writable=!1}(this,n,r),this},Object.defineProperty(O.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(O.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(t){this._writableState&&(this._writableState.destroyed=t)}}),O.prototype.destroy=l.destroy,O.prototype._undestroy=l.undestroy,O.prototype._destroy=function(t,e){e(t)}},2006:t=>{var e={}.toString;t.exports=Array.isArray||function(t){return"[object Array]"==e.call(t)}},2113:t=>{var e={Array:function(t){return null!=t&&t.constructor===Array},Boolean:function(t){return"boolean"==typeof t},Function:function(t){return"function"==typeof t},Nil:function(t){return null==t},Number:function(t){return"number"==typeof t},Object:function(t){return"object"==typeof t},String:function(t){return"string"==typeof t},"":function(){return!0}};for(var r in e.Null=e.Nil,e)e[r].toJSON=function(t){return t}.bind(null,r);t.exports=e},2192:(t,e,r)=>{var n,i=r(5606);function o(t){var e=this;this.next=null,this.entry=null,this.finish=function(){!function(t,e){var r=t.entry;for(t.entry=null;r;){var n=r.callback;e.pendingcb--,n(undefined),r=r.next}e.corkedRequestsFree.next=t}(e,t)}}t.exports=O,O.WritableState=k;var a,s={deprecate:r(4643)},u=r(1181),f=r(8287).Buffer,c=(void 0!==r.g?r.g:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{}).Uint8Array||function(){},l=r(1468),h=r(8775).getHighWaterMark,p=r(2260).F,d=p.ERR_INVALID_ARG_TYPE,y=p.ERR_METHOD_NOT_IMPLEMENTED,b=p.ERR_MULTIPLE_CALLBACK,g=p.ERR_STREAM_CANNOT_PIPE,v=p.ERR_STREAM_DESTROYED,w=p.ERR_STREAM_NULL_VALUES,m=p.ERR_STREAM_WRITE_AFTER_END,S=p.ERR_UNKNOWN_ENCODING,_=l.errorOrDestroy;function E(){}function k(t,e,a){n=n||r(2818),t=t||{},"boolean"!=typeof a&&(a=e instanceof n),this.objectMode=!!t.objectMode,a&&(this.objectMode=this.objectMode||!!t.writableObjectMode),this.highWaterMark=h(this,t,"writableHighWaterMark",a),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var s=!1===t.decodeStrings;this.decodeStrings=!s,this.defaultEncoding=t.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(t){!function(t,e){var r=t._writableState,n=r.sync,o=r.writecb;if("function"!=typeof o)throw new b;if(function(t){t.writing=!1,t.writecb=null,t.length-=t.writelen,t.writelen=0}(r),e)!function(t,e,r,n,o){--e.pendingcb,r?(i.nextTick(o,n),i.nextTick(B,t,e),t._writableState.errorEmitted=!0,_(t,n)):(o(n),t._writableState.errorEmitted=!0,_(t,n),B(t,e))}(t,r,n,e,o);else{var a=P(r)||t.destroyed;a||r.corked||r.bufferProcessing||!r.bufferedRequest||I(t,r),n?i.nextTick(A,t,r,a,o):A(t,r,a,o)}}(e,t)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=!1!==t.emitClose,this.autoDestroy=!!t.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new o(this)}function O(t){var e=this instanceof(n=n||r(2818));if(!e&&!a.call(O,this))return new O(t);this._writableState=new k(t,this,e),this.writable=!0,t&&("function"==typeof t.write&&(this._write=t.write),"function"==typeof t.writev&&(this._writev=t.writev),"function"==typeof t.destroy&&(this._destroy=t.destroy),"function"==typeof t.final&&(this._final=t.final)),u.call(this)}function T(t,e,r,n,i,o,a){e.writelen=n,e.writecb=a,e.writing=!0,e.sync=!0,e.destroyed?e.onwrite(new v("write")):r?t._writev(i,e.onwrite):t._write(i,o,e.onwrite),e.sync=!1}function A(t,e,r,n){r||function(t,e){0===e.length&&e.needDrain&&(e.needDrain=!1,t.emit("drain"))}(t,e),e.pendingcb--,n(),B(t,e)}function I(t,e){e.bufferProcessing=!0;var r=e.bufferedRequest;if(t._writev&&r&&r.next){var n=e.bufferedRequestCount,i=new Array(n),a=e.corkedRequestsFree;a.entry=r;for(var s=0,u=!0;r;)i[s]=r,r.isBuf||(u=!1),r=r.next,s+=1;i.allBuffers=u,T(t,e,!0,e.length,i,"",a.finish),e.pendingcb++,e.lastBufferedRequest=null,a.next?(e.corkedRequestsFree=a.next,a.next=null):e.corkedRequestsFree=new o(e),e.bufferedRequestCount=0}else{for(;r;){var f=r.chunk,c=r.encoding,l=r.callback;if(T(t,e,!1,e.objectMode?1:f.length,f,c,l),r=r.next,e.bufferedRequestCount--,e.writing)break}null===r&&(e.lastBufferedRequest=null)}e.bufferedRequest=r,e.bufferProcessing=!1}function P(t){return t.ending&&0===t.length&&null===t.bufferedRequest&&!t.finished&&!t.writing}function x(t,e){t._final(function(r){e.pendingcb--,r&&_(t,r),e.prefinished=!0,t.emit("prefinish"),B(t,e)})}function B(t,e){var r=P(e);if(r&&(function(t,e){e.prefinished||e.finalCalled||("function"!=typeof t._final||e.destroyed?(e.prefinished=!0,t.emit("prefinish")):(e.pendingcb++,e.finalCalled=!0,i.nextTick(x,t,e)))}(t,e),0===e.pendingcb&&(e.finished=!0,t.emit("finish"),e.autoDestroy))){var n=t._readableState;(!n||n.autoDestroy&&n.endEmitted)&&t.destroy()}return r}r(6698)(O,u),k.prototype.getBuffer=function(){for(var t=this.bufferedRequest,e=[];t;)e.push(t),t=t.next;return e},function(){try{Object.defineProperty(k.prototype,"buffer",{get:s.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(t){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(a=Function.prototype[Symbol.hasInstance],Object.defineProperty(O,Symbol.hasInstance,{value:function(t){return!!a.call(this,t)||this===O&&t&&t._writableState instanceof k}})):a=function(t){return t instanceof this},O.prototype.pipe=function(){_(this,new g)},O.prototype.write=function(t,e,r){var n,o=this._writableState,a=!1,s=!o.objectMode&&(n=t,f.isBuffer(n)||n instanceof c);return s&&!f.isBuffer(t)&&(t=function(t){return f.from(t)}(t)),"function"==typeof e&&(r=e,e=null),s?e="buffer":e||(e=o.defaultEncoding),"function"!=typeof r&&(r=E),o.ending?function(t,e){var r=new m;_(t,r),i.nextTick(e,r)}(this,r):(s||function(t,e,r,n){var o;return null===r?o=new w:"string"==typeof r||e.objectMode||(o=new d("chunk",["string","Buffer"],r)),!o||(_(t,o),i.nextTick(n,o),!1)}(this,o,t,r))&&(o.pendingcb++,a=function(t,e,r,n,i,o){if(!r){var a=function(t,e,r){return t.objectMode||!1===t.decodeStrings||"string"!=typeof e||(e=f.from(e,r)),e}(e,n,i);n!==a&&(r=!0,i="buffer",n=a)}var s=e.objectMode?1:n.length;e.length+=s;var u=e.length<e.highWaterMark;if(u||(e.needDrain=!0),e.writing||e.corked){var c=e.lastBufferedRequest;e.lastBufferedRequest={chunk:n,encoding:i,isBuf:r,callback:o,next:null},c?c.next=e.lastBufferedRequest:e.bufferedRequest=e.lastBufferedRequest,e.bufferedRequestCount+=1}else T(t,e,!1,s,n,i,o);return u}(this,o,s,t,e,r)),a},O.prototype.cork=function(){this._writableState.corked++},O.prototype.uncork=function(){var t=this._writableState;t.corked&&(t.corked--,t.writing||t.corked||t.bufferProcessing||!t.bufferedRequest||I(this,t))},O.prototype.setDefaultEncoding=function(t){if("string"==typeof t&&(t=t.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((t+"").toLowerCase())>-1))throw new S(t);return this._writableState.defaultEncoding=t,this},Object.defineProperty(O.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(O.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),O.prototype._write=function(t,e,r){r(new y("_write()"))},O.prototype._writev=null,O.prototype.end=function(t,e,r){var n=this._writableState;return"function"==typeof t?(r=t,t=null,e=null):"function"==typeof e&&(r=e,e=null),null!=t&&this.write(t,e),n.corked&&(n.corked=1,this.uncork()),n.ending||function(t,e,r){e.ending=!0,B(t,e),r&&(e.finished?i.nextTick(r):t.once("finish",r)),e.ended=!0,t.writable=!1}(this,n,r),this},Object.defineProperty(O.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(O.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(t){this._writableState&&(this._writableState.destroyed=t)}}),O.prototype.destroy=l.destroy,O.prototype._undestroy=l.undestroy,O.prototype._destroy=function(t,e){e(t)}},2205:(t,e,r)=>{var n=r(6743),i=r(1002),o=r(3144);t.exports=function(){return o(n,i,arguments)}},2260:t=>{var e={};function r(t,r,n){n||(n=Error);var i=function(t){var e,n;function i(e,n,i){return t.call(this,function(t,e,n){return"string"==typeof r?r:r(t,e,n)}(e,n,i))||this}return n=t,(e=i).prototype=Object.create(n.prototype),e.prototype.constructor=e,e.__proto__=n,i}(n);i.prototype.name=n.name,i.prototype.code=t,e[t]=i}function n(t,e){if(Array.isArray(t)){var r=t.length;return t=t.map(function(t){return String(t)}),r>2?"one of ".concat(e," ").concat(t.slice(0,r-1).join(", "),", or ")+t[r-1]:2===r?"one of ".concat(e," ").concat(t[0]," or ").concat(t[1]):"of ".concat(e," ").concat(t[0])}return"of ".concat(e," ").concat(String(t))}r("ERR_INVALID_OPT_VALUE",function(t,e){return'The value "'+e+'" is invalid for option "'+t+'"'},TypeError),r("ERR_INVALID_ARG_TYPE",function(t,e,r){var i,o,a;if("string"==typeof e&&(a="not ",e.substr(0,4)===a)?(i="must not be",e=e.replace(/^not /,"")):i="must be",function(t,e,r){return(void 0===r||r>t.length)&&(r=t.length),t.substring(r-9,r)===e}(t," argument"))o="The ".concat(t," ").concat(i," ").concat(n(e,"type"));else{var s=function(t,e,r){return"number"!=typeof r&&(r=0),!(r+1>t.length)&&-1!==t.indexOf(".",r)}(t)?"property":"argument";o='The "'.concat(t,'" ').concat(s," ").concat(i," ").concat(n(e,"type"))}return o+". Received type ".concat(typeof r)},TypeError),r("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),r("ERR_METHOD_NOT_IMPLEMENTED",function(t){return"The "+t+" method is not implemented"}),r("ERR_STREAM_PREMATURE_CLOSE","Premature close"),r("ERR_STREAM_DESTROYED",function(t){return"Cannot call "+t+" after a stream was destroyed"}),r("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),r("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),r("ERR_STREAM_WRITE_AFTER_END","write after end"),r("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),r("ERR_UNKNOWN_ENCODING",function(t){return"Unknown encoding: "+t},TypeError),r("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),t.exports.F=e},2299:(t,e,r)=>{function n(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,i,o,a,s=[],u=!0,f=!1;try{if(o=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=o.call(r)).done)&&(s.push(n.value),s.length!==e);u=!0);}catch(t){f=!0,i=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(f)throw i}}return s}}(t,e)||function(t,e){if(t){if("string"==typeof t)return i(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?i(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function i(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function o(t){return o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},o(t)}var a=void 0!==/a/g.flags,s=function(t){var e=[];return t.forEach(function(t){return e.push(t)}),e},u=function(t){var e=[];return t.forEach(function(t,r){return e.push([r,t])}),e},f=Object.is?Object.is:r(7653),c=Object.getOwnPropertySymbols?Object.getOwnPropertySymbols:function(){return[]},l=Number.isNaN?Number.isNaN:r(4133);function h(t){return t.call.bind(t)}var p=h(Object.prototype.hasOwnProperty),d=h(Object.prototype.propertyIsEnumerable),y=h(Object.prototype.toString),b=r(537).types,g=b.isAnyArrayBuffer,v=b.isArrayBufferView,w=b.isDate,m=b.isMap,S=b.isRegExp,_=b.isSet,E=b.isNativeError,k=b.isBoxedPrimitive,O=b.isNumberObject,T=b.isStringObject,A=b.isBooleanObject,I=b.isBigIntObject,P=b.isSymbolObject,x=b.isFloat32Array,B=b.isFloat64Array;function R(t){if(0===t.length||t.length>10)return!0;for(var e=0;e<t.length;e++){var r=t.charCodeAt(e);if(r<48||r>57)return!0}return 10===t.length&&t>=Math.pow(2,32)}function U(t){return Object.keys(t).filter(R).concat(c(t).filter(Object.prototype.propertyIsEnumerable.bind(t)))}function N(t,e){if(t===e)return 0;for(var r=t.length,n=e.length,i=0,o=Math.min(r,n);i<o;++i)if(t[i]!==e[i]){r=t[i],n=e[i];break}return r<n?-1:n<r?1:0}function j(t,e,r,n){if(t===e)return 0!==t||!r||f(t,e);if(r){if("object"!==o(t))return"number"==typeof t&&l(t)&&l(e);if("object"!==o(e)||null===t||null===e)return!1;if(Object.getPrototypeOf(t)!==Object.getPrototypeOf(e))return!1}else{if(null===t||"object"!==o(t))return(null===e||"object"!==o(e))&&t==e;if(null===e||"object"!==o(e))return!1}var i,s,u=y(t);if(u!==y(e))return!1;if(Array.isArray(t)){if(t.length!==e.length)return!1;var c=U(t),h=U(e);return c.length===h.length&&C(t,e,r,n,1,c)}if("[object Object]"===u&&(!m(t)&&m(e)||!_(t)&&_(e)))return!1;if(w(t)){if(!w(e)||Date.prototype.getTime.call(t)!==Date.prototype.getTime.call(e))return!1}else if(S(t)){if(!S(e)||!function(t,e){return a?t.source===e.source&&t.flags===e.flags:RegExp.prototype.toString.call(t)===RegExp.prototype.toString.call(e)}(t,e))return!1}else if(E(t)||t instanceof Error){if(t.message!==e.message||t.name!==e.name)return!1}else{if(v(t)){if(r||!x(t)&&!B(t)){if(!function(t,e){return t.byteLength===e.byteLength&&0===N(new Uint8Array(t.buffer,t.byteOffset,t.byteLength),new Uint8Array(e.buffer,e.byteOffset,e.byteLength))}(t,e))return!1}else if(!function(t,e){if(t.byteLength!==e.byteLength)return!1;for(var r=0;r<t.byteLength;r++)if(t[r]!==e[r])return!1;return!0}(t,e))return!1;var p=U(t),d=U(e);return p.length===d.length&&C(t,e,r,n,0,p)}if(_(t))return!(!_(e)||t.size!==e.size)&&C(t,e,r,n,2);if(m(t))return!(!m(e)||t.size!==e.size)&&C(t,e,r,n,3);if(g(t)){if(s=e,(i=t).byteLength!==s.byteLength||0!==N(new Uint8Array(i),new Uint8Array(s)))return!1}else if(k(t)&&!function(t,e){return O(t)?O(e)&&f(Number.prototype.valueOf.call(t),Number.prototype.valueOf.call(e)):T(t)?T(e)&&String.prototype.valueOf.call(t)===String.prototype.valueOf.call(e):A(t)?A(e)&&Boolean.prototype.valueOf.call(t)===Boolean.prototype.valueOf.call(e):I(t)?I(e)&&BigInt.prototype.valueOf.call(t)===BigInt.prototype.valueOf.call(e):P(e)&&Symbol.prototype.valueOf.call(t)===Symbol.prototype.valueOf.call(e)}(t,e))return!1}return C(t,e,r,n,0)}function L(t,e){return e.filter(function(e){return d(t,e)})}function C(t,e,r,i,a,f){if(5===arguments.length){f=Object.keys(t);var l=Object.keys(e);if(f.length!==l.length)return!1}for(var h=0;h<f.length;h++)if(!p(e,f[h]))return!1;if(r&&5===arguments.length){var y=c(t);if(0!==y.length){var b=0;for(h=0;h<y.length;h++){var g=y[h];if(d(t,g)){if(!d(e,g))return!1;f.push(g),b++}else if(d(e,g))return!1}var v=c(e);if(y.length!==v.length&&L(e,v).length!==b)return!1}else{var w=c(e);if(0!==w.length&&0!==L(e,w).length)return!1}}if(0===f.length&&(0===a||1===a&&0===t.length||0===t.size))return!0;if(void 0===i)i={val1:new Map,val2:new Map,position:0};else{var m=i.val1.get(t);if(void 0!==m){var S=i.val2.get(e);if(void 0!==S)return m===S}i.position++}i.val1.set(t,i.position),i.val2.set(e,i.position);var _=function(t,e,r,i,a,f){var c=0;if(2===f){if(!function(t,e,r,n){for(var i=null,a=s(t),u=0;u<a.length;u++){var f=a[u];if("object"===o(f)&&null!==f)null===i&&(i=new Set),i.add(f);else if(!e.has(f)){if(r)return!1;if(!H(t,e,f))return!1;null===i&&(i=new Set),i.add(f)}}if(null!==i){for(var c=s(e),l=0;l<c.length;l++){var h=c[l];if("object"===o(h)&&null!==h){if(!F(i,h,r,n))return!1}else if(!r&&!t.has(h)&&!F(i,h,r,n))return!1}return 0===i.size}return!0}(t,e,r,a))return!1}else if(3===f){if(!function(t,e,r,i){for(var a=null,s=u(t),f=0;f<s.length;f++){var c=n(s[f],2),l=c[0],h=c[1];if("object"===o(l)&&null!==l)null===a&&(a=new Set),a.add(l);else{var p=e.get(l);if(void 0===p&&!e.has(l)||!j(h,p,r,i)){if(r)return!1;if(!M(t,e,l,h,i))return!1;null===a&&(a=new Set),a.add(l)}}}if(null!==a){for(var d=u(e),y=0;y<d.length;y++){var b=n(d[y],2),g=b[0],v=b[1];if("object"===o(g)&&null!==g){if(!K(a,t,g,v,r,i))return!1}else if(!(r||t.has(g)&&j(t.get(g),v,!1,i)||K(a,t,g,v,!1,i)))return!1}return 0===a.size}return!0}(t,e,r,a))return!1}else if(1===f)for(;c<t.length;c++){if(!p(t,c)){if(p(e,c))return!1;for(var l=Object.keys(t);c<l.length;c++){var h=l[c];if(!p(e,h)||!j(t[h],e[h],r,a))return!1}return l.length===Object.keys(e).length}if(!p(e,c)||!j(t[c],e[c],r,a))return!1}for(c=0;c<i.length;c++){var d=i[c];if(!j(t[d],e[d],r,a))return!1}return!0}(t,e,r,f,i,a);return i.val1.delete(t),i.val2.delete(e),_}function F(t,e,r,n){for(var i=s(t),o=0;o<i.length;o++){var a=i[o];if(j(e,a,r,n))return t.delete(a),!0}return!1}function D(t){switch(o(t)){case"undefined":return null;case"object":return;case"symbol":return!1;case"string":t=+t;case"number":if(l(t))return!1}return!0}function H(t,e,r){var n=D(r);return null!=n?n:e.has(n)&&!t.has(n)}function M(t,e,r,n,i){var o=D(r);if(null!=o)return o;var a=e.get(o);return!(void 0===a&&!e.has(o)||!j(n,a,!1,i))&&!t.has(o)&&j(n,a,!1,i)}function K(t,e,r,n,i,o){for(var a=s(t),u=0;u<a.length;u++){var f=a[u];if(j(r,f,i,o)&&j(n,e.get(f),i,o))return t.delete(f),!0}return!1}t.exports={isDeepEqual:function(t,e){return j(t,e,!1)},isDeepStrictEqual:function(t,e){return j(t,e,!0)}}},2318:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.toBig=e.shrSL=e.shrSH=e.rotrSL=e.rotrSH=e.rotrBL=e.rotrBH=e.rotr32L=e.rotr32H=e.rotlSL=e.rotlSH=e.rotlBL=e.rotlBH=e.add5L=e.add5H=e.add4L=e.add4H=e.add3L=e.add3H=void 0,e.add=w,e.fromBig=i,e.split=o;const r=BigInt(2**32-1),n=BigInt(32);function i(t,e=!1){return e?{h:Number(t&r),l:Number(t>>n&r)}:{h:0|Number(t>>n&r),l:0|Number(t&r)}}function o(t,e=!1){const r=t.length;let n=new Uint32Array(r),o=new Uint32Array(r);for(let a=0;a<r;a++){const{h:r,l:s}=i(t[a],e);[n[a],o[a]]=[r,s]}return[n,o]}const a=(t,e)=>BigInt(t>>>0)<<n|BigInt(e>>>0);e.toBig=a;const s=(t,e,r)=>t>>>r;e.shrSH=s;const u=(t,e,r)=>t<<32-r|e>>>r;e.shrSL=u;const f=(t,e,r)=>t>>>r|e<<32-r;e.rotrSH=f;const c=(t,e,r)=>t<<32-r|e>>>r;e.rotrSL=c;const l=(t,e,r)=>t<<64-r|e>>>r-32;e.rotrBH=l;const h=(t,e,r)=>t>>>r-32|e<<64-r;e.rotrBL=h;const p=(t,e)=>e;e.rotr32H=p;const d=(t,e)=>t;e.rotr32L=d;const y=(t,e,r)=>t<<r|e>>>32-r;e.rotlSH=y;const b=(t,e,r)=>e<<r|t>>>32-r;e.rotlSL=b;const g=(t,e,r)=>e<<r-32|t>>>64-r;e.rotlBH=g;const v=(t,e,r)=>t<<r-32|e>>>64-r;function w(t,e,r,n){const i=(e>>>0)+(n>>>0);return{h:t+r+(i/2**32|0)|0,l:0|i}}e.rotlBL=v;const m=(t,e,r)=>(t>>>0)+(e>>>0)+(r>>>0);e.add3L=m;const S=(t,e,r,n)=>e+r+n+(t/2**32|0)|0;e.add3H=S;const _=(t,e,r,n)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0);e.add4L=_;const E=(t,e,r,n,i)=>e+r+n+i+(t/2**32|0)|0;e.add4H=E;const k=(t,e,r,n,i)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0)+(i>>>0);e.add5L=k;const O=(t,e,r,n,i,o)=>e+r+n+i+o+(t/2**32|0)|0;e.add5H=O;const T={fromBig:i,split:o,toBig:a,shrSH:s,shrSL:u,rotrSH:f,rotrSL:c,rotrBH:l,rotrBL:h,rotr32H:p,rotr32L:d,rotlSH:y,rotlSL:b,rotlBH:g,rotlBL:v,add:w,add3L:m,add3H:S,add4L:_,add4H:E,add5H:O,add5L:k};e.default=T},2343:(t,e)=>{e.p2=e.I=void 0;const r="qpzry9x8gf2tvdw0s3jn54khce6mua7l",n={};for(let t=0;t<32;t++){const e=r.charAt(t);n[e]=t}function i(t){const e=t>>25;return(33554431&t)<<5^996825010&-(1&e)^642813549&-(e>>1&1)^513874426&-(e>>2&1)^1027748829&-(e>>3&1)^705979059&-(e>>4&1)}function o(t){let e=1;for(let r=0;r<t.length;++r){const n=t.charCodeAt(r);if(n<33||n>126)return"Invalid prefix ("+t+")";e=i(e)^n>>5}e=i(e);for(let r=0;r<t.length;++r){const n=t.charCodeAt(r);e=i(e)^31&n}return e}function a(t,e,r,n){let i=0,o=0;const a=(1<<r)-1,s=[];for(let n=0;n<t.length;++n)for(i=i<<e|t[n],o+=e;o>=r;)o-=r,s.push(i>>o&a);if(n)o>0&&s.push(i<<r-o&a);else{if(o>=e)return"Excess padding";if(i<<r-o&a)return"Non-zero padding"}return s}function s(t){return a(t,8,5,!0)}function u(t){const e=a(t,5,8,!1);if(Array.isArray(e))return e}function f(t){const e=a(t,5,8,!1);if(Array.isArray(e))return e;throw new Error(e)}function c(t){let e;function a(t,r){if(r=r||90,t.length<8)return t+" too short";if(t.length>r)return"Exceeds length limit";const a=t.toLowerCase(),s=t.toUpperCase();if(t!==a&&t!==s)return"Mixed-case string "+t;const u=(t=a).lastIndexOf("1");if(-1===u)return"No separator character for "+t;if(0===u)return"Missing prefix for "+t;const f=t.slice(0,u),c=t.slice(u+1);if(c.length<6)return"Data too short";let l=o(f);if("string"==typeof l)return l;const h=[];for(let t=0;t<c.length;++t){const e=c.charAt(t),r=n[e];if(void 0===r)return"Unknown character "+e;l=i(l)^r,t+6>=c.length||h.push(r)}return l!==e?"Invalid checksum for "+t:{prefix:f,words:h}}return e="bech32"===t?1:734539939,{decodeUnsafe:function(t,e){const r=a(t,e);if("object"==typeof r)return r},decode:function(t,e){const r=a(t,e);if("object"==typeof r)return r;throw new Error(r)},encode:function(t,n,a){if(a=a||90,t.length+7+n.length>a)throw new TypeError("Exceeds length limit");let s=o(t=t.toLowerCase());if("string"==typeof s)throw new Error(s);let u=t+"1";for(let t=0;t<n.length;++t){const e=n[t];if(e>>5)throw new Error("Non 5-bit word");s=i(s)^e,u+=r.charAt(e)}for(let t=0;t<6;++t)s=i(s);s^=e;for(let t=0;t<6;++t)u+=r.charAt(s>>5*(5-t)&31);return u},toWords:s,fromWordsUnsafe:u,fromWords:f}}e.I=c("bech32"),e.p2=c("bech32m")},2382:()=>{},2389:(t,e,r)=>{function n(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function i(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?n(Object(r),!0).forEach(function(e){o(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):n(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function o(t,e,r){return(e=s(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function a(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,s(n.key),n)}}function s(t){var e=function(t){if("object"!=typeof t||null===t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==typeof e?e:String(e)}var u=r(8287).Buffer,f=r(8460).inspect,c=f&&f.custom||"inspect";function l(t,e,r){u.prototype.copy.call(t,e,r)}t.exports=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.head=null,this.tail=null,this.length=0}var e,r;return e=t,r=[{key:"push",value:function(t){var e={data:t,next:null};this.length>0?this.tail.next=e:this.head=e,this.tail=e,++this.length}},{key:"unshift",value:function(t){var e={data:t,next:this.head};0===this.length&&(this.tail=e),this.head=e,++this.length}},{key:"shift",value:function(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(t){if(0===this.length)return"";for(var e=this.head,r=""+e.data;e=e.next;)r+=t+e.data;return r}},{key:"concat",value:function(t){if(0===this.length)return u.alloc(0);for(var e=u.allocUnsafe(t>>>0),r=this.head,n=0;r;)l(r.data,e,n),n+=r.data.length,r=r.next;return e}},{key:"consume",value:function(t,e){var r;return t<this.head.data.length?(r=this.head.data.slice(0,t),this.head.data=this.head.data.slice(t)):r=t===this.head.data.length?this.shift():e?this._getString(t):this._getBuffer(t),r}},{key:"first",value:function(){return this.head.data}},{key:"_getString",value:function(t){var e=this.head,r=1,n=e.data;for(t-=n.length;e=e.next;){var i=e.data,o=t>i.length?i.length:t;if(o===i.length?n+=i:n+=i.slice(0,t),0===(t-=o)){o===i.length?(++r,e.next?this.head=e.next:this.head=this.tail=null):(this.head=e,e.data=i.slice(o));break}++r}return this.length-=r,n}},{key:"_getBuffer",value:function(t){var e=u.allocUnsafe(t),r=this.head,n=1;for(r.data.copy(e),t-=r.data.length;r=r.next;){var i=r.data,o=t>i.length?i.length:t;if(i.copy(e,e.length-t,0,o),0===(t-=o)){o===i.length?(++n,r.next?this.head=r.next:this.head=this.tail=null):(this.head=r,r.data=i.slice(o));break}++n}return this.length-=n,e}},{key:c,value:function(t,e){return f(this,i(i({},e),{},{depth:0,customInspect:!1}))}}],r&&a(e.prototype,r),Object.defineProperty(e,"prototype",{writable:!1}),t}()},2422:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.wNAF=void 0,e.negateCt=s,e.normalizeZ=function(t,e){const r=(0,i.FpInvertBatch)(t.Fp,e.map(t=>t.Z));return e.map((e,n)=>t.fromAffine(e.toAffine(r[n])))},e.mulEndoUnsafe=function(t,e,r,n){let i=e,s=t.ZERO,u=t.ZERO;for(;r>o||n>o;)r&a&&(s=s.add(i)),n&a&&(u=u.add(i)),i=i.double(),r>>=a,n>>=a;return{p1:s,p2:u}},e.pippenger=function(t,e,r,i){l(r,t),h(i,e);const o=r.length,a=i.length;if(o!==a)throw new Error("arrays of points and scalars must have equal length");const s=t.ZERO,u=(0,n.bitLen)(BigInt(o));let f=1;u>12?f=u-3:u>4?f=u-2:u>0&&(f=2);const c=(0,n.bitMask)(f),p=new Array(Number(c)+1).fill(s);let d=s;for(let t=Math.floor((e.BITS-1)/f)*f;t>=0;t-=f){p.fill(s);for(let e=0;e<a;e++){const n=i[e],o=Number(n>>BigInt(t)&c);p[o]=p[o].add(r[e])}let e=s;for(let t=p.length-1,r=s;t>0;t--)r=r.add(p[t]),e=e.add(r);if(d=d.add(e),0!==t)for(let t=0;t<f;t++)d=d.double()}return d},e.precomputeMSMUnsafe=function(t,e,r,i){u(i,e.BITS),l(r,t);const o=t.ZERO,a=2**i-1,s=Math.ceil(e.BITS/i),f=(0,n.bitMask)(i),c=r.map(t=>{const e=[];for(let r=0,n=t;r<a;r++)e.push(n),n=n.add(t);return e});return t=>{if(h(t,e),t.length>r.length)throw new Error("array of scalars must be smaller than array of points");let n=o;for(let e=0;e<s;e++){if(n!==o)for(let t=0;t<i;t++)n=n.double();const r=BigInt(s*i-(e+1)*i);for(let e=0;e<t.length;e++){const i=t[e],o=Number(i>>r&f);o&&(n=n.add(c[e][o-1]))}}return n}},e.validateBasic=function(t){return(0,i.validateField)(t.Fp),(0,n.validateObject)(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...(0,i.nLength)(t.n,t.nBitLength),...t,p:t.Fp.ORDER})},e._createCurveFields=function(t,e,r={},n){if(void 0===n&&(n="edwards"===t),!e||"object"!=typeof e)throw new Error(`expected valid ${t} CURVE object`);for(const t of["p","n","h"]){const r=e[t];if(!("bigint"==typeof r&&r>o))throw new Error(`CURVE.${t} must be positive bigint`)}const i=g(e.p,r.Fp,n),a=g(e.n,r.Fn,n),s=["Gx","Gy","a","weierstrass"===t?"b":"d"];for(const t of s)if(!i.isValid(e[t]))throw new Error(`CURVE.${t} must be valid field element of CURVE.Fp`);return{CURVE:e=Object.freeze(Object.assign({},e)),Fp:i,Fn:a}};const n=r(8627),i=r(4967),o=BigInt(0),a=BigInt(1);function s(t,e){const r=e.negate();return t?r:e}function u(t,e){if(!Number.isSafeInteger(t)||t<=0||t>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+t)}function f(t,e){u(t,e);const r=2**t;return{windows:Math.ceil(e/t)+1,windowSize:2**(t-1),mask:(0,n.bitMask)(t),maxNumber:r,shiftBy:BigInt(t)}}function c(t,e,r){const{windowSize:n,mask:i,maxNumber:o,shiftBy:s}=r;let u=Number(t&i),f=t>>s;u>n&&(u-=o,f+=a);const c=e*n;return{nextN:f,offset:c+Math.abs(u)-1,isZero:0===u,isNeg:u<0,isNegF:e%2!=0,offsetF:c}}function l(t,e){if(!Array.isArray(t))throw new Error("array expected");t.forEach((t,r)=>{if(!(t instanceof e))throw new Error("invalid point at index "+r)})}function h(t,e){if(!Array.isArray(t))throw new Error("array of scalars expected");t.forEach((t,r)=>{if(!e.isValid(t))throw new Error("invalid scalar at index "+r)})}const p=new WeakMap,d=new WeakMap;function y(t){return d.get(t)||1}function b(t){if(t!==o)throw new Error("invalid wNAF")}function g(t,e,r){if(e){if(e.ORDER!==t)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return(0,i.validateField)(e),e}return(0,i.Field)(t,{isLE:r})}e.wNAF=class{constructor(t,e){this.BASE=t.BASE,this.ZERO=t.ZERO,this.Fn=t.Fn,this.bits=e}_unsafeLadder(t,e,r=this.ZERO){let n=t;for(;e>o;)e&a&&(r=r.add(n)),n=n.double(),e>>=a;return r}precomputeWindow(t,e){const{windows:r,windowSize:n}=f(e,this.bits),i=[];let o=t,a=o;for(let t=0;t<r;t++){a=o,i.push(a);for(let t=1;t<n;t++)a=a.add(o),i.push(a);o=a.double()}return i}wNAF(t,e,r){if(!this.Fn.isValid(r))throw new Error("invalid scalar");let n=this.ZERO,i=this.BASE;const o=f(t,this.bits);for(let t=0;t<o.windows;t++){const{nextN:a,offset:u,isZero:f,isNeg:l,isNegF:h,offsetF:p}=c(r,t,o);r=a,f?i=i.add(s(h,e[p])):n=n.add(s(l,e[u]))}return b(r),{p:n,f:i}}wNAFUnsafe(t,e,r,n=this.ZERO){const i=f(t,this.bits);for(let t=0;t<i.windows&&r!==o;t++){const{nextN:o,offset:a,isZero:s,isNeg:u}=c(r,t,i);if(r=o,!s){const t=e[a];n=n.add(u?t.negate():t)}}return b(r),n}getPrecomputes(t,e,r){let n=p.get(e);return n||(n=this.precomputeWindow(e,t),1!==t&&("function"==typeof r&&(n=r(n)),p.set(e,n))),n}cached(t,e,r){const n=y(t);return this.wNAF(n,this.getPrecomputes(n,t,r),e)}unsafe(t,e,r,n){const i=y(t);return 1===i?this._unsafeLadder(t,e,n):this.wNAFUnsafe(i,this.getPrecomputes(i,t,r),e,n)}createCache(t,e){u(e,this.bits),d.set(t,e),p.delete(t)}hasCache(t){return 1!==y(t)}}},2463:t=>{var e={};function r(t,r,n){n||(n=Error);var i=function(t){var e,n;function i(e,n,i){return t.call(this,function(t,e,n){return"string"==typeof r?r:r(t,e,n)}(e,n,i))||this}return n=t,(e=i).prototype=Object.create(n.prototype),e.prototype.constructor=e,e.__proto__=n,i}(n);i.prototype.name=n.name,i.prototype.code=t,e[t]=i}function n(t,e){if(Array.isArray(t)){var r=t.length;return t=t.map(function(t){return String(t)}),r>2?"one of ".concat(e," ").concat(t.slice(0,r-1).join(", "),", or ")+t[r-1]:2===r?"one of ".concat(e," ").concat(t[0]," or ").concat(t[1]):"of ".concat(e," ").concat(t[0])}return"of ".concat(e," ").concat(String(t))}r("ERR_INVALID_OPT_VALUE",function(t,e){return'The value "'+e+'" is invalid for option "'+t+'"'},TypeError),r("ERR_INVALID_ARG_TYPE",function(t,e,r){var i,o,a;if("string"==typeof e&&(a="not ",e.substr(0,4)===a)?(i="must not be",e=e.replace(/^not /,"")):i="must be",function(t,e,r){return(void 0===r||r>t.length)&&(r=t.length),t.substring(r-9,r)===e}(t," argument"))o="The ".concat(t," ").concat(i," ").concat(n(e,"type"));else{var s=function(t,e,r){return"number"!=typeof r&&(r=0),!(r+1>t.length)&&-1!==t.indexOf(".",r)}(t)?"property":"argument";o='The "'.concat(t,'" ').concat(s," ").concat(i," ").concat(n(e,"type"))}return o+". Received type ".concat(typeof r)},TypeError),r("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),r("ERR_METHOD_NOT_IMPLEMENTED",function(t){return"The "+t+" method is not implemented"}),r("ERR_STREAM_PREMATURE_CLOSE","Premature close"),r("ERR_STREAM_DESTROYED",function(t){return"Cannot call "+t+" after a stream was destroyed"}),r("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),r("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),r("ERR_STREAM_WRITE_AFTER_END","write after end"),r("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),r("ERR_UNKNOWN_ENCODING",function(t){return"Unknown encoding: "+t},TypeError),r("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),t.exports.F=e},2464:(t,e,r)=>{var n=r(8452),i=r(6642);t.exports=function(){var t=i();return n(Number,{isNaN:t},{isNaN:function(){return Number.isNaN!==t}}),t}},2577:(t,e,r)=>{var n=r(7108),i=r(8212);t.exports=i(function(t){var e=n("sha256").update(t).digest();return n("sha256").update(e).digest()})},2682:(t,e,r)=>{var n=r(9600),i=Object.prototype.toString,o=Object.prototype.hasOwnProperty;t.exports=function(t,e,r){if(!n(e))throw new TypeError("iterator must be a function");var a;arguments.length>=3&&(a=r),function(t){return"[object Array]"===i.call(t)}(t)?function(t,e,r){for(var n=0,i=t.length;n<i;n++)o.call(t,n)&&(null==r?e(t[n],n,t):e.call(r,t[n],n,t))}(t,e,a):"string"==typeof t?function(t,e,r){for(var n=0,i=t.length;n<i;n++)null==r?e(t.charAt(n),n,t):e.call(r,t.charAt(n),n,t)}(t,e,a):function(t,e,r){for(var n in t)o.call(t,n)&&(null==r?e(t[n],n,t):e.call(r,t[n],n,t))}(t,e,a)}},2802:(t,e,r)=>{t.exports=function(e){var r=e.toLowerCase(),n=t.exports[r];if(!n)throw new Error(r+" is not supported (we accept pull requests)");return new n},t.exports.sha=r(7816),t.exports.sha1=r(3737),t.exports.sha224=r(6710),t.exports.sha256=r(4107),t.exports.sha384=r(2827),t.exports.sha512=r(2890)},2818:(t,e,r)=>{var n=r(5606),i=Object.keys||function(t){var e=[];for(var r in t)e.push(r);return e};t.exports=c;var o=r(6736),a=r(2192);r(6698)(c,o);for(var s=i(a.prototype),u=0;u<s.length;u++){var f=s[u];c.prototype[f]||(c.prototype[f]=a.prototype[f])}function c(t){if(!(this instanceof c))return new c(t);o.call(this,t),a.call(this,t),this.allowHalfOpen=!0,t&&(!1===t.readable&&(this.readable=!1),!1===t.writable&&(this.writable=!1),!1===t.allowHalfOpen&&(this.allowHalfOpen=!1,this.once("end",l)))}function l(){this._writableState.ended||n.nextTick(h,this)}function h(t){t.end()}Object.defineProperty(c.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(c.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(c.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(c.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._readableState&&void 0!==this._writableState&&this._readableState.destroyed&&this._writableState.destroyed},set:function(t){void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed=t,this._writableState.destroyed=t)}})},2827:(t,e,r)=>{var n=r(6698),i=r(2890),o=r(392),a=r(2861).Buffer,s=new Array(160);function u(){this.init(),this._w=s,o.call(this,128,112)}n(u,i),u.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},u.prototype._hash=function(){var t=a.allocUnsafe(48);function e(e,r,n){t.writeInt32BE(e,n),t.writeInt32BE(r,n+4)}return e(this._ah,this._al,0),e(this._bh,this._bl,8),e(this._ch,this._cl,16),e(this._dh,this._dl,24),e(this._eh,this._el,32),e(this._fh,this._fl,40),t},t.exports=u},2861:(t,e,r)=>{var n=r(8287),i=n.Buffer;function o(t,e){for(var r in t)e[r]=t[r]}function a(t,e,r){return i(t,e,r)}i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?t.exports=n:(o(n,e),e.Buffer=a),a.prototype=Object.create(i.prototype),o(i,a),a.from=function(t,e,r){if("number"==typeof t)throw new TypeError("Argument must not be a number");return i(t,e,r)},a.alloc=function(t,e,r){if("number"!=typeof t)throw new TypeError("Argument must be a number");var n=i(t);return void 0!==e?"string"==typeof r?n.fill(e,r):n.fill(e):n.fill(0),n},a.allocUnsafe=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return i(t)},a.allocUnsafeSlow=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return n.SlowBuffer(t)}},2890:(t,e,r)=>{var n=r(6698),i=r(392),o=r(2861).Buffer,a=[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],s=new Array(160);function u(){this.init(),this._w=s,i.call(this,128,112)}function f(t,e,r){return r^t&(e^r)}function c(t,e,r){return t&e|r&(t|e)}function l(t,e){return(t>>>28|e<<4)^(e>>>2|t<<30)^(e>>>7|t<<25)}function h(t,e){return(t>>>14|e<<18)^(t>>>18|e<<14)^(e>>>9|t<<23)}function p(t,e){return(t>>>1|e<<31)^(t>>>8|e<<24)^t>>>7}function d(t,e){return(t>>>1|e<<31)^(t>>>8|e<<24)^(t>>>7|e<<25)}function y(t,e){return(t>>>19|e<<13)^(e>>>29|t<<3)^t>>>6}function b(t,e){return(t>>>19|e<<13)^(e>>>29|t<<3)^(t>>>6|e<<26)}function g(t,e){return t>>>0<e>>>0?1:0}n(u,i),u.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},u.prototype._update=function(t){for(var e=this._w,r=0|this._ah,n=0|this._bh,i=0|this._ch,o=0|this._dh,s=0|this._eh,u=0|this._fh,v=0|this._gh,w=0|this._hh,m=0|this._al,S=0|this._bl,_=0|this._cl,E=0|this._dl,k=0|this._el,O=0|this._fl,T=0|this._gl,A=0|this._hl,I=0;I<32;I+=2)e[I]=t.readInt32BE(4*I),e[I+1]=t.readInt32BE(4*I+4);for(;I<160;I+=2){var P=e[I-30],x=e[I-30+1],B=p(P,x),R=d(x,P),U=y(P=e[I-4],x=e[I-4+1]),N=b(x,P),j=e[I-14],L=e[I-14+1],C=e[I-32],F=e[I-32+1],D=R+L|0,H=B+j+g(D,R)|0;H=(H=H+U+g(D=D+N|0,N)|0)+C+g(D=D+F|0,F)|0,e[I]=H,e[I+1]=D}for(var M=0;M<160;M+=2){H=e[M],D=e[M+1];var K=c(r,n,i),V=c(m,S,_),W=l(r,m),G=l(m,r),q=h(s,k),z=h(k,s),Z=a[M],X=a[M+1],Y=f(s,u,v),$=f(k,O,T),J=A+z|0,Q=w+q+g(J,A)|0;Q=(Q=(Q=Q+Y+g(J=J+$|0,$)|0)+Z+g(J=J+X|0,X)|0)+H+g(J=J+D|0,D)|0;var tt=G+V|0,et=W+K+g(tt,G)|0;w=v,A=T,v=u,T=O,u=s,O=k,s=o+Q+g(k=E+J|0,E)|0,o=i,E=_,i=n,_=S,n=r,S=m,r=Q+et+g(m=J+tt|0,J)|0}this._al=this._al+m|0,this._bl=this._bl+S|0,this._cl=this._cl+_|0,this._dl=this._dl+E|0,this._el=this._el+k|0,this._fl=this._fl+O|0,this._gl=this._gl+T|0,this._hl=this._hl+A|0,this._ah=this._ah+r+g(this._al,m)|0,this._bh=this._bh+n+g(this._bl,S)|0,this._ch=this._ch+i+g(this._cl,_)|0,this._dh=this._dh+o+g(this._dl,E)|0,this._eh=this._eh+s+g(this._el,k)|0,this._fh=this._fh+u+g(this._fl,O)|0,this._gh=this._gh+v+g(this._gl,T)|0,this._hh=this._hh+w+g(this._hl,A)|0},u.prototype._hash=function(){var t=o.allocUnsafe(64);function e(e,r,n){t.writeInt32BE(e,n),t.writeInt32BE(r,n+4)}return e(this._ah,this._al,0),e(this._bh,this._bl,8),e(this._ch,this._cl,16),e(this._dh,this._dl,24),e(this._eh,this._el,32),e(this._fh,this._fl,40),e(this._gh,this._gl,48),e(this._hh,this._hl,56),t},t.exports=u},3003:t=>{t.exports=function(t){return t!=t}},3054:(t,e,r)=>{t.exports=c;var n=r(2260).F,i=n.ERR_METHOD_NOT_IMPLEMENTED,o=n.ERR_MULTIPLE_CALLBACK,a=n.ERR_TRANSFORM_ALREADY_TRANSFORMING,s=n.ERR_TRANSFORM_WITH_LENGTH_0,u=r(2818);function f(t,e){var r=this._transformState;r.transforming=!1;var n=r.writecb;if(null===n)return this.emit("error",new o);r.writechunk=null,r.writecb=null,null!=e&&this.push(e),n(t);var i=this._readableState;i.reading=!1,(i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}function c(t){if(!(this instanceof c))return new c(t);u.call(this,t),this._transformState={afterTransform:f.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,t&&("function"==typeof t.transform&&(this._transform=t.transform),"function"==typeof t.flush&&(this._flush=t.flush)),this.on("prefinish",l)}function l(){var t=this;"function"!=typeof this._flush||this._readableState.destroyed?h(this,null,null):this._flush(function(e,r){h(t,e,r)})}function h(t,e,r){if(e)return t.emit("error",e);if(null!=r&&t.push(r),t._writableState.length)throw new s;if(t._transformState.transforming)throw new a;return t.push(null)}r(6698)(c,u),c.prototype.push=function(t,e){return this._transformState.needTransform=!1,u.prototype.push.call(this,t,e)},c.prototype._transform=function(t,e,r){r(new i("_transform()"))},c.prototype._write=function(t,e,r){var n=this._transformState;if(n.writecb=r,n.writechunk=t,n.writeencoding=e,!n.transforming){var i=this._readableState;(n.needTransform||i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}},c.prototype._read=function(t){var e=this._transformState;null===e.writechunk||e.transforming?e.needTransform=!0:(e.transforming=!0,this._transform(e.writechunk,e.writeencoding,e.afterTransform))},c.prototype._destroy=function(t,e){u.prototype._destroy.call(this,t,function(t){e(t)})}},3093:(t,e,r)=>{var n=r(4459);t.exports=function(t){return n(t)||0===t?t:t<0?-1:1}},3126:(t,e,r)=>{var n=r(6743),i=r(9675),o=r(76),a=r(3144);t.exports=function(t){if(t.length<1||"function"!=typeof t[0])throw new i("a function is required");return a(n,o,t)}},3144:(t,e,r)=>{var n=r(6743),i=r(1002),o=r(76),a=r(7119);t.exports=a||n.call(o,i)},3209:(t,e,r)=>{var n=r(5606),i=65536,o=r(2861).Buffer,a=r.g.crypto||r.g.msCrypto;a&&a.getRandomValues?t.exports=function(t,e){if(t>4294967295)throw new RangeError("requested too many random bytes");var r=o.allocUnsafe(t);if(t>0)if(t>i)for(var s=0;s<t;s+=i)a.getRandomValues(r.slice(s,s+i));else a.getRandomValues(r);return"function"==typeof e?n.nextTick(function(){e(null,r)}):r}:t.exports=function(){throw new Error("Secure random number generation is not supported by this browser.\nUse Chrome, Firefox or Internet Explorer 11")}},3269:t=>{t.exports=function(t,e,r,n){for(var i=65535&t,o=t>>>16&65535,a=0;0!==r;){r-=a=r>2e3?2e3:r;do{o=o+(i=i+e[n++]|0)|0}while(--a);i%=65521,o%=65521}return i|o<<16}},3513:(t,e,r)=>{var n=r(8510),i=r(4967),o=r(1484);function a(t){var e=Object.create(null);return t&&Object.keys(t).forEach(function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,n.get?n:{enumerable:!0,get:function(){return t[r]}})}}),e.default=t,Object.freeze(e)}var s=a(i),u=a(o);const f=n.secp256k1.ProjectivePoint,c="Expected Private",l="Expected Point",h="Expected Tweak",p="Expected Signature",d="Expected Extra Data (32 bytes)",y="Expected Scalar",b=new Uint8Array([255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,186,174,220,230,175,72,160,59,191,210,94,140,208,54,65,65]),g=new Uint8Array(32),v=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,69,81,35,25,80,183,95,196,64,45,161,114,47,201,186,238]),w=BigInt(1);function m(t,e){for(let r=0;r<32;++r)if(t[r]!==e[r])return t[r]<e[r]?-1:1;return 0}function S(t){return 0===m(t,g)}function _(t){return t instanceof Uint8Array&&32===t.length&&!(m(t,b)>=0)}function E(t){return t instanceof Uint8Array&&64===t.length&&m(t.subarray(0,32),b)<0&&m(t.subarray(32,64),b)<0}function k(t){return t instanceof Uint8Array&&32===t.length}function O(t){return void 0===t||t instanceof Uint8Array&&32===t.length}function T(t){let e;if("bigint"==typeof t)e=t;else if("number"==typeof t&&Number.isSafeInteger(t)&&t>=0)e=BigInt(t);else if("string"==typeof t){if(64!==t.length)throw new Error("Expected 32 bytes of private scalar");e=u.hexToNumber(t)}else{if(!(t instanceof Uint8Array))throw new TypeError("Expected valid private scalar");if(32!==t.length)throw new Error("Expected 32 bytes of private scalar");e=u.bytesToNumberBE(t)}if(e<0)throw new Error("Expected private scalar >= 0");return e}function A(t){return n.secp256k1.utils.normPrivateKeyToScalar(t)}function I(t,e,r){const n=R(t),i=T(e),o=f.BASE.multiplyAndAddUnsafe(n,i,w);if(!o)throw new Error("Tweaked point at infinity");return o.toRawBytes(r)}function P(t,e){return void 0===t?void 0===e||j(e):!!t}function x(t){try{return t()}catch(t){return null}}function B(t){return n.schnorr.utils.lift_x(u.bytesToNumberBE(t))}function R(t){return 32===t.length?B(t):f.fromHex(t)}function U(t,e){if(32===t.length!==e)return!1;try{return e?!!B(t):!!f.fromHex(t)}catch(t){return!1}}function N(t){return U(t,!1)}function j(t){return U(t,!1)&&33===t.length}function L(t){return n.secp256k1.utils.isValidPrivateKey(t)}function C(t){return U(t,!0)}function F(t){if(!N(t))throw new Error(l);return t.slice(1,33)}function D(t,e){if(!L(t))throw new Error(c);return x(()=>n.secp256k1.getPublicKey(t,P(e)))}e.isPoint=N,e.isPointCompressed=j,e.isPrivate=L,e.isXOnlyPoint=C,e.pointAdd=function(t,e,r){if(!N(t)||!N(e))throw new Error(l);return x(()=>{const n=R(t),i=R(e);return n.equals(i.negate())?null:n.add(i).toRawBytes(P(r,t))})},e.pointAddScalar=function(t,e,r){if(!N(t))throw new Error(l);if(!_(e))throw new Error(h);return x(()=>I(t,e,P(r,t)))},e.pointCompress=function(t,e){if(!N(t))throw new Error(l);return R(t).toRawBytes(P(e,t))},e.pointFromScalar=D,e.pointMultiply=function(t,e,r){if(!N(t))throw new Error(l);if(!_(e))throw new Error(h);return x(()=>function(t,e,r){const n=R(t),i="string"==typeof e?e:u.bytesToHex(e),o=u.hexToNumber(i);return n.multiply(o).toRawBytes(r)}(t,e,P(r,t)))},e.privateAdd=function(t,e){if(!L(t))throw new Error(c);if(!_(e))throw new Error(h);return x(()=>function(t,e){const r=A(t),i=T(e),o=u.numberToBytesBE(s.mod(r+i,n.secp256k1.CURVE.n),32);return n.secp256k1.utils.isValidPrivateKey(o)?o:null}(t,e))},e.privateNegate=function(t){if(!L(t))throw new Error(c);return function(t){const e=A(t),r=u.numberToBytesBE(n.secp256k1.CURVE.n-e,32);return n.secp256k1.utils.isValidPrivateKey(r)?r:null}(t)},e.privateSub=function(t,e){if(!L(t))throw new Error(c);if(!_(e))throw new Error(h);return x(()=>function(t,e){const r=A(t),i=T(e),o=u.numberToBytesBE(s.mod(r-i,n.secp256k1.CURVE.n),32);return n.secp256k1.utils.isValidPrivateKey(o)?o:null}(t,e))},e.recover=function(t,e,r,i){if(!k(t))throw new Error("Expected Hash");if(!E(e)||!function(t){return!(S(t.subarray(0,32))||S(t.subarray(32,64)))}(e))throw new Error(p);if(2&r&&!function(t){return t instanceof Uint8Array&&64===t.length&&m(t.subarray(0,32),v)<0}(e))throw new Error("Bad Recovery Id");if(!C(e.subarray(0,32)))throw new Error(p);const o=n.secp256k1.Signature.fromCompact(e).addRecoveryBit(r).recoverPublicKey(t);if(!o)throw new Error(p);return o.toRawBytes(P(i))},e.sign=function(t,e,r){if(!L(e))throw new Error(c);if(!k(t))throw new Error(y);if(!O(r))throw new Error(d);return n.secp256k1.sign(t,e,{extraEntropy:r}).toCompactRawBytes()},e.signRecoverable=function(t,e,r){if(!L(e))throw new Error(c);if(!k(t))throw new Error(y);if(!O(r))throw new Error(d);const i=n.secp256k1.sign(t,e,{extraEntropy:r});return{signature:i.toCompactRawBytes(),recoveryId:i.recovery}},e.signSchnorr=function(t,e,r){if(!L(e))throw new Error(c);if(!k(t))throw new Error(y);if(!O(r))throw new Error(d);return n.schnorr.sign(t,e,r)},e.verify=function(t,e,r,i){if(!N(e))throw new Error(l);if(!E(r))throw new Error(p);if(!k(t))throw new Error(y);return n.secp256k1.verify(r,t,e,{lowS:i})},e.verifySchnorr=function(t,e,r){if(!C(e))throw new Error(l);if(!E(r))throw new Error(p);if(!k(t))throw new Error(y);return n.schnorr.verify(r,t,e)},e.xOnlyPointAddTweak=function(t,e){if(!C(t))throw new Error(l);if(!_(e))throw new Error(h);return x(()=>{const r=I(t,e,!0);return{parity:r[0]%2==1?1:0,xOnlyPubkey:r.slice(1)}})},e.xOnlyPointFromPoint=F,e.xOnlyPointFromScalar=function(t){if(!L(t))throw new Error(c);return F(D(t))}},3516:(t,e,r)=>{var n=r(2861).Buffer,i=n.isEncoding||function(t){switch((t=""+t)&&t.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function o(t){var e;switch(this.encoding=function(t){var e=function(t){if(!t)return"utf8";for(var e;;)switch(t){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return t;default:if(e)return;t=(""+t).toLowerCase(),e=!0}}(t);if("string"!=typeof e&&(n.isEncoding===i||!i(t)))throw new Error("Unknown encoding: "+t);return e||t}(t),this.encoding){case"utf16le":this.text=u,this.end=f,e=4;break;case"utf8":this.fillLast=s,e=4;break;case"base64":this.text=c,this.end=l,e=3;break;default:return this.write=h,void(this.end=p)}this.lastNeed=0,this.lastTotal=0,this.lastChar=n.allocUnsafe(e)}function a(t){return t<=127?0:t>>5==6?2:t>>4==14?3:t>>3==30?4:t>>6==2?-1:-2}function s(t){var e=this.lastTotal-this.lastNeed,r=function(t,e){if(128!=(192&e[0]))return t.lastNeed=0,"�";if(t.lastNeed>1&&e.length>1){if(128!=(192&e[1]))return t.lastNeed=1,"�";if(t.lastNeed>2&&e.length>2&&128!=(192&e[2]))return t.lastNeed=2,"�"}}(this,t);return void 0!==r?r:this.lastNeed<=t.length?(t.copy(this.lastChar,e,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(t.copy(this.lastChar,e,0,t.length),void(this.lastNeed-=t.length))}function u(t,e){if((t.length-e)%2==0){var r=t.toString("utf16le",e);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=t[t.length-1],t.toString("utf16le",e,t.length-1)}function f(t){var e=t&&t.length?this.write(t):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return e+this.lastChar.toString("utf16le",0,r)}return e}function c(t,e){var r=(t.length-e)%3;return 0===r?t.toString("base64",e):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=t[t.length-1]:(this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1]),t.toString("base64",e,t.length-r))}function l(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+this.lastChar.toString("base64",0,3-this.lastNeed):e}function h(t){return t.toString(this.encoding)}function p(t){return t&&t.length?this.write(t):""}e.I=o,o.prototype.write=function(t){if(0===t.length)return"";var e,r;if(this.lastNeed){if(void 0===(e=this.fillLast(t)))return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r<t.length?e?e+this.text(t,r):this.text(t,r):e||""},o.prototype.end=function(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+"�":e},o.prototype.text=function(t,e){var r=function(t,e,r){var n=e.length-1;if(n<r)return 0;var i=a(e[n]);return i>=0?(i>0&&(t.lastNeed=i-1),i):--n<r||-2===i?0:(i=a(e[n]))>=0?(i>0&&(t.lastNeed=i-2),i):--n<r||-2===i?0:(i=a(e[n]))>=0?(i>0&&(2===i?i=0:t.lastNeed=i-3),i):0}(this,t,e);if(!this.lastNeed)return t.toString("utf8",e);this.lastTotal=r;var n=t.length-(r-this.lastNeed);return t.copy(this.lastChar,0,n),t.toString("utf8",e,n)},o.prototype.fillLast=function(t){if(this.lastNeed<=t.length)return t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,t.length),this.lastNeed-=t.length}},3562:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.getHash=function(t){return{hash:t}},e.createCurve=function(t,e){const r=e=>(0,n.weierstrass)({...t,hash:e});return{...r(e),create:r}};const n=r(1705)},3628:(t,e,r)=>{var n=r(8648),i=r(1064),o=r(7176);t.exports=n?function(t){return n(t)}:i?function(t){if(!t||"object"!=typeof t&&"function"!=typeof t)throw new TypeError("getProto: not an object");return i(t)}:o?function(t){return o(t)}:null},3665:(t,e,r)=>{var n=r(9805);function i(t){for(var e=t.length;--e>=0;)t[e]=0}var o=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],a=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],s=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],u=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],f=new Array(576);i(f);var c=new Array(60);i(c);var l=new Array(512);i(l);var h=new Array(256);i(h);var p=new Array(29);i(p);var d,y,b,g=new Array(30);function v(t,e,r,n,i){this.static_tree=t,this.extra_bits=e,this.extra_base=r,this.elems=n,this.max_length=i,this.has_stree=t&&t.length}function w(t,e){this.dyn_tree=t,this.max_code=0,this.stat_desc=e}function m(t){return t<256?l[t]:l[256+(t>>>7)]}function S(t,e){t.pending_buf[t.pending++]=255&e,t.pending_buf[t.pending++]=e>>>8&255}function _(t,e,r){t.bi_valid>16-r?(t.bi_buf|=e<<t.bi_valid&65535,S(t,t.bi_buf),t.bi_buf=e>>16-t.bi_valid,t.bi_valid+=r-16):(t.bi_buf|=e<<t.bi_valid&65535,t.bi_valid+=r)}function E(t,e,r){_(t,r[2*e],r[2*e+1])}function k(t,e){var r=0;do{r|=1&t,t>>>=1,r<<=1}while(--e>0);return r>>>1}function O(t,e,r){var n,i,o=new Array(16),a=0;for(n=1;n<=15;n++)o[n]=a=a+r[n-1]<<1;for(i=0;i<=e;i++){var s=t[2*i+1];0!==s&&(t[2*i]=k(o[s]++,s))}}function T(t){var e;for(e=0;e<286;e++)t.dyn_ltree[2*e]=0;for(e=0;e<30;e++)t.dyn_dtree[2*e]=0;for(e=0;e<19;e++)t.bl_tree[2*e]=0;t.dyn_ltree[512]=1,t.opt_len=t.static_len=0,t.last_lit=t.matches=0}function A(t){t.bi_valid>8?S(t,t.bi_buf):t.bi_valid>0&&(t.pending_buf[t.pending++]=t.bi_buf),t.bi_buf=0,t.bi_valid=0}function I(t,e,r,n){var i=2*e,o=2*r;return t[i]<t[o]||t[i]===t[o]&&n[e]<=n[r]}function P(t,e,r){for(var n=t.heap[r],i=r<<1;i<=t.heap_len&&(i<t.heap_len&&I(e,t.heap[i+1],t.heap[i],t.depth)&&i++,!I(e,n,t.heap[i],t.depth));)t.heap[r]=t.heap[i],r=i,i<<=1;t.heap[r]=n}function x(t,e,r){var n,i,s,u,f=0;if(0!==t.last_lit)do{n=t.pending_buf[t.d_buf+2*f]<<8|t.pending_buf[t.d_buf+2*f+1],i=t.pending_buf[t.l_buf+f],f++,0===n?E(t,i,e):(E(t,(s=h[i])+256+1,e),0!==(u=o[s])&&_(t,i-=p[s],u),E(t,s=m(--n),r),0!==(u=a[s])&&_(t,n-=g[s],u))}while(f<t.last_lit);E(t,256,e)}function B(t,e){var r,n,i,o=e.dyn_tree,a=e.stat_desc.static_tree,s=e.stat_desc.has_stree,u=e.stat_desc.elems,f=-1;for(t.heap_len=0,t.heap_max=573,r=0;r<u;r++)0!==o[2*r]?(t.heap[++t.heap_len]=f=r,t.depth[r]=0):o[2*r+1]=0;for(;t.heap_len<2;)o[2*(i=t.heap[++t.heap_len]=f<2?++f:0)]=1,t.depth[i]=0,t.opt_len--,s&&(t.static_len-=a[2*i+1]);for(e.max_code=f,r=t.heap_len>>1;r>=1;r--)P(t,o,r);i=u;do{r=t.heap[1],t.heap[1]=t.heap[t.heap_len--],P(t,o,1),n=t.heap[1],t.heap[--t.heap_max]=r,t.heap[--t.heap_max]=n,o[2*i]=o[2*r]+o[2*n],t.depth[i]=(t.depth[r]>=t.depth[n]?t.depth[r]:t.depth[n])+1,o[2*r+1]=o[2*n+1]=i,t.heap[1]=i++,P(t,o,1)}while(t.heap_len>=2);t.heap[--t.heap_max]=t.heap[1],function(t,e){var r,n,i,o,a,s,u=e.dyn_tree,f=e.max_code,c=e.stat_desc.static_tree,l=e.stat_desc.has_stree,h=e.stat_desc.extra_bits,p=e.stat_desc.extra_base,d=e.stat_desc.max_length,y=0;for(o=0;o<=15;o++)t.bl_count[o]=0;for(u[2*t.heap[t.heap_max]+1]=0,r=t.heap_max+1;r<573;r++)(o=u[2*u[2*(n=t.heap[r])+1]+1]+1)>d&&(o=d,y++),u[2*n+1]=o,n>f||(t.bl_count[o]++,a=0,n>=p&&(a=h[n-p]),s=u[2*n],t.opt_len+=s*(o+a),l&&(t.static_len+=s*(c[2*n+1]+a)));if(0!==y){do{for(o=d-1;0===t.bl_count[o];)o--;t.bl_count[o]--,t.bl_count[o+1]+=2,t.bl_count[d]--,y-=2}while(y>0);for(o=d;0!==o;o--)for(n=t.bl_count[o];0!==n;)(i=t.heap[--r])>f||(u[2*i+1]!==o&&(t.opt_len+=(o-u[2*i+1])*u[2*i],u[2*i+1]=o),n--)}}(t,e),O(o,f,t.bl_count)}function R(t,e,r){var n,i,o=-1,a=e[1],s=0,u=7,f=4;for(0===a&&(u=138,f=3),e[2*(r+1)+1]=65535,n=0;n<=r;n++)i=a,a=e[2*(n+1)+1],++s<u&&i===a||(s<f?t.bl_tree[2*i]+=s:0!==i?(i!==o&&t.bl_tree[2*i]++,t.bl_tree[32]++):s<=10?t.bl_tree[34]++:t.bl_tree[36]++,s=0,o=i,0===a?(u=138,f=3):i===a?(u=6,f=3):(u=7,f=4))}function U(t,e,r){var n,i,o=-1,a=e[1],s=0,u=7,f=4;for(0===a&&(u=138,f=3),n=0;n<=r;n++)if(i=a,a=e[2*(n+1)+1],!(++s<u&&i===a)){if(s<f)do{E(t,i,t.bl_tree)}while(0!==--s);else 0!==i?(i!==o&&(E(t,i,t.bl_tree),s--),E(t,16,t.bl_tree),_(t,s-3,2)):s<=10?(E(t,17,t.bl_tree),_(t,s-3,3)):(E(t,18,t.bl_tree),_(t,s-11,7));s=0,o=i,0===a?(u=138,f=3):i===a?(u=6,f=3):(u=7,f=4)}}i(g);var N=!1;function j(t,e,r,i){_(t,0+(i?1:0),3),function(t,e,r){A(t),S(t,r),S(t,~r),n.arraySet(t.pending_buf,t.window,e,r,t.pending),t.pending+=r}(t,e,r)}e._tr_init=function(t){N||(function(){var t,e,r,n,i,u=new Array(16);for(r=0,n=0;n<28;n++)for(p[n]=r,t=0;t<1<<o[n];t++)h[r++]=n;for(h[r-1]=n,i=0,n=0;n<16;n++)for(g[n]=i,t=0;t<1<<a[n];t++)l[i++]=n;for(i>>=7;n<30;n++)for(g[n]=i<<7,t=0;t<1<<a[n]-7;t++)l[256+i++]=n;for(e=0;e<=15;e++)u[e]=0;for(t=0;t<=143;)f[2*t+1]=8,t++,u[8]++;for(;t<=255;)f[2*t+1]=9,t++,u[9]++;for(;t<=279;)f[2*t+1]=7,t++,u[7]++;for(;t<=287;)f[2*t+1]=8,t++,u[8]++;for(O(f,287,u),t=0;t<30;t++)c[2*t+1]=5,c[2*t]=k(t,5);d=new v(f,o,257,286,15),y=new v(c,a,0,30,15),b=new v(new Array(0),s,0,19,7)}(),N=!0),t.l_desc=new w(t.dyn_ltree,d),t.d_desc=new w(t.dyn_dtree,y),t.bl_desc=new w(t.bl_tree,b),t.bi_buf=0,t.bi_valid=0,T(t)},e._tr_stored_block=j,e._tr_flush_block=function(t,e,r,n){var i,o,a=0;t.level>0?(2===t.strm.data_type&&(t.strm.data_type=function(t){var e,r=4093624447;for(e=0;e<=31;e++,r>>>=1)if(1&r&&0!==t.dyn_ltree[2*e])return 0;if(0!==t.dyn_ltree[18]||0!==t.dyn_ltree[20]||0!==t.dyn_ltree[26])return 1;for(e=32;e<256;e++)if(0!==t.dyn_ltree[2*e])return 1;return 0}(t)),B(t,t.l_desc),B(t,t.d_desc),a=function(t){var e;for(R(t,t.dyn_ltree,t.l_desc.max_code),R(t,t.dyn_dtree,t.d_desc.max_code),B(t,t.bl_desc),e=18;e>=3&&0===t.bl_tree[2*u[e]+1];e--);return t.opt_len+=3*(e+1)+5+5+4,e}(t),i=t.opt_len+3+7>>>3,(o=t.static_len+3+7>>>3)<=i&&(i=o)):i=o=r+5,r+4<=i&&-1!==e?j(t,e,r,n):4===t.strategy||o===i?(_(t,2+(n?1:0),3),x(t,f,c)):(_(t,4+(n?1:0),3),function(t,e,r,n){var i;for(_(t,e-257,5),_(t,r-1,5),_(t,n-4,4),i=0;i<n;i++)_(t,t.bl_tree[2*u[i]+1],3);U(t,t.dyn_ltree,e-1),U(t,t.dyn_dtree,r-1)}(t,t.l_desc.max_code+1,t.d_desc.max_code+1,a+1),x(t,t.dyn_ltree,t.dyn_dtree)),T(t),n&&A(t)},e._tr_tally=function(t,e,r){return t.pending_buf[t.d_buf+2*t.last_lit]=e>>>8&255,t.pending_buf[t.d_buf+2*t.last_lit+1]=255&e,t.pending_buf[t.l_buf+t.last_lit]=255&r,t.last_lit++,0===e?t.dyn_ltree[2*r]++:(t.matches++,e--,t.dyn_ltree[2*(h[r]+256+1)]++,t.dyn_dtree[2*m(e)]++),t.last_lit===t.lit_bufsize-1},e._tr_align=function(t){_(t,2,3),E(t,256,f),function(t){16===t.bi_valid?(S(t,t.bi_buf),t.bi_buf=0,t.bi_valid=0):t.bi_valid>=8&&(t.pending_buf[t.pending++]=255&t.bi_buf,t.bi_buf>>=8,t.bi_valid-=8)}(t)}},3681:(t,e,r)=>{t.exports=i;var n=r(9083);function i(t){if(!(this instanceof i))return new i(t);n.call(this,t)}r(6698)(i,n),i.prototype._transform=function(t,e,r){r(null,t)}},3737:(t,e,r)=>{var n=r(6698),i=r(392),o=r(2861).Buffer,a=[1518500249,1859775393,-1894007588,-899497514],s=new Array(80);function u(){this.init(),this._w=s,i.call(this,64,56)}function f(t){return t<<1|t>>>31}function c(t){return t<<5|t>>>27}function l(t){return t<<30|t>>>2}function h(t,e,r,n){return 0===t?e&r|~e&n:2===t?e&r|e&n|r&n:e^r^n}n(u,i),u.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},u.prototype._update=function(t){for(var e=this._w,r=0|this._a,n=0|this._b,i=0|this._c,o=0|this._d,s=0|this._e,u=0;u<16;++u)e[u]=t.readInt32BE(4*u);for(;u<80;++u)e[u]=f(e[u-3]^e[u-8]^e[u-14]^e[u-16]);for(var p=0;p<80;++p){var d=~~(p/20),y=c(r)+h(d,n,i,o)+s+e[p]+a[d]|0;s=o,o=i,i=l(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},u.prototype._hash=function(){var t=o.allocUnsafe(20);return t.writeInt32BE(0|this._a,0),t.writeInt32BE(0|this._b,4),t.writeInt32BE(0|this._c,8),t.writeInt32BE(0|this._d,12),t.writeInt32BE(0|this._e,16),t},t.exports=u},3779:()=>{},3835:(t,e,r)=>{var n=r(9284);t.exports=n("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")},3918:(t,e,r)=>{var n=r(5606);function i(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function o(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?i(Object(r),!0).forEach(function(e){var n,i,o;n=t,i=e,o=r[e],(i=s(i))in n?Object.defineProperty(n,i,{value:o,enumerable:!0,configurable:!0,writable:!0}):n[i]=o}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):i(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function a(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,s(n.key),n)}}function s(t){var e=function(t){if("object"!==y(t)||null===t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!==y(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"===y(e)?e:String(e)}function u(t,e){if(e&&("object"===y(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return f(t)}function f(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function c(t){var e="function"==typeof Map?new Map:void 0;return c=function(t){if(null===t||!function(t){return-1!==Function.toString.call(t).indexOf("[native code]")}(t))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,r)}function r(){return l(t,arguments,d(this).constructor)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),p(r,t)},c(t)}function l(t,e,r){return l=h()?Reflect.construct.bind():function(t,e,r){var n=[null];n.push.apply(n,e);var i=new(Function.bind.apply(t,n));return r&&p(i,r.prototype),i},l.apply(null,arguments)}function h(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(t){return!1}}function p(t,e){return p=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},p(t,e)}function d(t){return d=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},d(t)}function y(t){return y="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},y(t)}var b=r(537).inspect,g=r(9597).codes.ERR_INVALID_ARG_TYPE;function v(t,e,r){return(void 0===r||r>t.length)&&(r=t.length),t.substring(r-e.length,r)===e}var w="",m="",S="",_="",E={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:"};function k(t){var e=Object.keys(t),r=Object.create(Object.getPrototypeOf(t));return e.forEach(function(e){r[e]=t[e]}),Object.defineProperty(r,"message",{value:t.message}),r}function O(t){return b(t,{compact:!1,customInspect:!1,depth:1e3,maxArrayLength:1/0,showHidden:!1,breakLength:1/0,showProxy:!1,sorted:!0,getters:!0})}var T=function(t,e){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&p(t,e)}(T,t);var r,i,s,c,l=(r=T,i=h(),function(){var t,e=d(r);if(i){var n=d(this).constructor;t=Reflect.construct(e,arguments,n)}else t=e.apply(this,arguments);return u(this,t)});function T(t){var e;if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,T),"object"!==y(t)||null===t)throw new g("options","Object",t);var r=t.message,i=t.operator,o=t.stackStartFn,a=t.actual,s=t.expected,c=Error.stackTraceLimit;if(Error.stackTraceLimit=0,null!=r)e=l.call(this,String(r));else if(n.stderr&&n.stderr.isTTY&&(n.stderr&&n.stderr.getColorDepth&&1!==n.stderr.getColorDepth()?(w="",m="",_="",S=""):(w="",m="",_="",S="")),"object"===y(a)&&null!==a&&"object"===y(s)&&null!==s&&"stack"in a&&a instanceof Error&&"stack"in s&&s instanceof Error&&(a=k(a),s=k(s)),"deepStrictEqual"===i||"strictEqual"===i)e=l.call(this,function(t,e,r){var i="",o="",a=0,s="",u=!1,f=O(t),c=f.split("\n"),l=O(e).split("\n"),h=0,p="";if("strictEqual"===r&&"object"===y(t)&&"object"===y(e)&&null!==t&&null!==e&&(r="strictEqualObject"),1===c.length&&1===l.length&&c[0]!==l[0]){var d=c[0].length+l[0].length;if(d<=10){if(!("object"===y(t)&&null!==t||"object"===y(e)&&null!==e||0===t&&0===e))return"".concat(E[r],"\n\n")+"".concat(c[0]," !== ").concat(l[0],"\n")}else if("strictEqualObject"!==r&&d<(n.stderr&&n.stderr.isTTY?n.stderr.columns:80)){for(;c[0][h]===l[0][h];)h++;h>2&&(p="\n ".concat(function(t,e){if(e=Math.floor(e),0==t.length||0==e)return"";var r=t.length*e;for(e=Math.floor(Math.log(e)/Math.log(2));e;)t+=t,e--;return t+t.substring(0,r-t.length)}(" ",h),"^"),h=0)}}for(var b=c[c.length-1],g=l[l.length-1];b===g&&(h++<2?s="\n ".concat(b).concat(s):i=b,c.pop(),l.pop(),0!==c.length&&0!==l.length);)b=c[c.length-1],g=l[l.length-1];var k=Math.max(c.length,l.length);if(0===k){var T=f.split("\n");if(T.length>30)for(T[26]="".concat(w,"...").concat(_);T.length>27;)T.pop();return"".concat(E.notIdentical,"\n\n").concat(T.join("\n"),"\n")}h>3&&(s="\n".concat(w,"...").concat(_).concat(s),u=!0),""!==i&&(s="\n ".concat(i).concat(s),i="");var A=0,I=E[r]+"\n".concat(m,"+ actual").concat(_," ").concat(S,"- expected").concat(_),P=" ".concat(w,"...").concat(_," Lines skipped");for(h=0;h<k;h++){var x=h-a;if(c.length<h+1)x>1&&h>2&&(x>4?(o+="\n".concat(w,"...").concat(_),u=!0):x>3&&(o+="\n ".concat(l[h-2]),A++),o+="\n ".concat(l[h-1]),A++),a=h,i+="\n".concat(S,"-").concat(_," ").concat(l[h]),A++;else if(l.length<h+1)x>1&&h>2&&(x>4?(o+="\n".concat(w,"...").concat(_),u=!0):x>3&&(o+="\n ".concat(c[h-2]),A++),o+="\n ".concat(c[h-1]),A++),a=h,o+="\n".concat(m,"+").concat(_," ").concat(c[h]),A++;else{var B=l[h],R=c[h],U=R!==B&&(!v(R,",")||R.slice(0,-1)!==B);U&&v(B,",")&&B.slice(0,-1)===R&&(U=!1,R+=","),U?(x>1&&h>2&&(x>4?(o+="\n".concat(w,"...").concat(_),u=!0):x>3&&(o+="\n ".concat(c[h-2]),A++),o+="\n ".concat(c[h-1]),A++),a=h,o+="\n".concat(m,"+").concat(_," ").concat(R),i+="\n".concat(S,"-").concat(_," ").concat(B),A+=2):(o+=i,i="",1!==x&&0!==h||(o+="\n ".concat(R),A++))}if(A>20&&h<k-2)return"".concat(I).concat(P,"\n").concat(o,"\n").concat(w,"...").concat(_).concat(i,"\n")+"".concat(w,"...").concat(_)}return"".concat(I).concat(u?P:"","\n").concat(o).concat(i).concat(s).concat(p)}(a,s,i));else if("notDeepStrictEqual"===i||"notStrictEqual"===i){var h=E[i],p=O(a).split("\n");if("notStrictEqual"===i&&"object"===y(a)&&null!==a&&(h=E.notStrictEqualObject),p.length>30)for(p[26]="".concat(w,"...").concat(_);p.length>27;)p.pop();e=1===p.length?l.call(this,"".concat(h," ").concat(p[0])):l.call(this,"".concat(h,"\n\n").concat(p.join("\n"),"\n"))}else{var d=O(a),b="",A=E[i];"notDeepEqual"===i||"notEqual"===i?(d="".concat(E[i],"\n\n").concat(d)).length>1024&&(d="".concat(d.slice(0,1021),"...")):(b="".concat(O(s)),d.length>512&&(d="".concat(d.slice(0,509),"...")),b.length>512&&(b="".concat(b.slice(0,509),"...")),"deepEqual"===i||"equal"===i?d="".concat(A,"\n\n").concat(d,"\n\nshould equal\n\n"):b=" ".concat(i," ").concat(b)),e=l.call(this,"".concat(d).concat(b))}return Error.stackTraceLimit=c,e.generatedMessage=!r,Object.defineProperty(f(e),"name",{value:"AssertionError [ERR_ASSERTION]",enumerable:!1,writable:!0,configurable:!0}),e.code="ERR_ASSERTION",e.actual=a,e.expected=s,e.operator=i,Error.captureStackTrace&&Error.captureStackTrace(f(e),o),e.stack,e.name="AssertionError",u(e)}return s=T,(c=[{key:"toString",value:function(){return"".concat(this.name," [").concat(this.code,"]: ").concat(this.message)}},{key:e,value:function(t,e){return b(this,o(o({},e),{},{customInspect:!1,depth:0}))}}])&&a(s.prototype,c),Object.defineProperty(s,"prototype",{writable:!1}),T}(c(Error),b.custom);t.exports=T},4035:(t,e,r)=>{var n,i=r(6556),o=r(9092)(),a=r(9957),s=r(5795);if(o){var u=i("RegExp.prototype.exec"),f={},c=function(){throw f},l={toString:c,valueOf:c};"symbol"==typeof Symbol.toPrimitive&&(l[Symbol.toPrimitive]=c),n=function(t){if(!t||"object"!=typeof t)return!1;var e=s(t,"lastIndex");if(!e||!a(e,"value"))return!1;try{u(t,l)}catch(t){return t===f}}}else{var h=i("Object.prototype.toString");n=function(t){return!(!t||"object"!=typeof t&&"function"!=typeof t)&&"[object RegExp]"===h(t)}}t.exports=n},4039:(t,e,r)=>{var n="undefined"!=typeof Symbol&&Symbol,i=r(1333);t.exports=function(){return"function"==typeof n&&"function"==typeof Symbol&&"symbol"==typeof n("foo")&&"symbol"==typeof Symbol("bar")&&i()}},4107:(t,e,r)=>{var n=r(6698),i=r(392),o=r(2861).Buffer,a=[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],s=new Array(64);function u(){this.init(),this._w=s,i.call(this,64,56)}function f(t,e,r){return r^t&(e^r)}function c(t,e,r){return t&e|r&(t|e)}function l(t){return(t>>>2|t<<30)^(t>>>13|t<<19)^(t>>>22|t<<10)}function h(t){return(t>>>6|t<<26)^(t>>>11|t<<21)^(t>>>25|t<<7)}function p(t){return(t>>>7|t<<25)^(t>>>18|t<<14)^t>>>3}function d(t){return(t>>>17|t<<15)^(t>>>19|t<<13)^t>>>10}n(u,i),u.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},u.prototype._update=function(t){for(var e=this._w,r=0|this._a,n=0|this._b,i=0|this._c,o=0|this._d,s=0|this._e,u=0|this._f,y=0|this._g,b=0|this._h,g=0;g<16;++g)e[g]=t.readInt32BE(4*g);for(;g<64;++g)e[g]=d(e[g-2])+e[g-7]+p(e[g-15])+e[g-16]|0;for(var v=0;v<64;++v){var w=b+h(s)+f(s,u,y)+a[v]+e[v]|0,m=l(r)+c(r,n,i)|0;b=y,y=u,u=s,s=o+w|0,o=i,i=n,n=r,r=w+m|0}this._a=r+this._a|0,this._b=n+this._b|0,this._c=i+this._c|0,this._d=o+this._d|0,this._e=s+this._e|0,this._f=u+this._f|0,this._g=y+this._g|0,this._h=b+this._h|0},u.prototype._hash=function(){var t=o.allocUnsafe(32);return t.writeInt32BE(this._a,0),t.writeInt32BE(this._b,4),t.writeInt32BE(this._c,8),t.writeInt32BE(this._d,12),t.writeInt32BE(this._e,16),t.writeInt32BE(this._f,20),t.writeInt32BE(this._g,24),t.writeInt32BE(this._h,28),t},t.exports=u},4133:(t,e,r)=>{var n=r(487),i=r(8452),o=r(3003),a=r(6642),s=r(2464),u=n(a(),Number);i(u,{getPolyfill:a,implementation:o,shim:s}),t.exports=u},4148:(t,e,r)=>{var n=r(5606);function i(t){return i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},i(t)}function o(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,s(n.key),n)}}function a(t,e,r){return e&&o(t.prototype,e),r&&o(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function s(t){var e=function(t){if("object"!==i(t)||null===t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!==i(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"===i(e)?e:String(e)}var u,f,c=r(9597).codes,l=c.ERR_AMBIGUOUS_ARGUMENT,h=c.ERR_INVALID_ARG_TYPE,p=c.ERR_INVALID_ARG_VALUE,d=c.ERR_INVALID_RETURN_VALUE,y=c.ERR_MISSING_ARGS,b=r(3918),g=r(537).inspect,v=r(537).types,w=v.isPromise,m=v.isRegExp,S=r(9133)(),_=r(9394)(),E=r(8075)("RegExp.prototype.test");function k(){var t=r(2299);u=t.isDeepEqual,f=t.isDeepStrictEqual}new Map;var O=!1,T=t.exports=x,A={};function I(t){if(t.message instanceof Error)throw t.message;throw new b(t)}function P(t,e,r,n){if(!r){var i=!1;if(0===e)i=!0,n="No value argument passed to `assert.ok()`";else if(n instanceof Error)throw n;var o=new b({actual:r,expected:!0,message:n,operator:"==",stackStartFn:t});throw o.generatedMessage=i,o}}function x(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];P.apply(void 0,[x,e.length].concat(e))}T.fail=function t(e,r,i,o,a){var s,u=arguments.length;if(0===u?s="Failed":1===u?(i=e,e=void 0):(!1===O&&(O=!0,(n.emitWarning?n.emitWarning:console.warn.bind(console))("assert.fail() with more than one argument is deprecated. Please use assert.strictEqual() instead or only pass a message.","DeprecationWarning","DEP0094")),2===u&&(o="!=")),i instanceof Error)throw i;var f={actual:e,expected:r,operator:void 0===o?"fail":o,stackStartFn:a||t};void 0!==i&&(f.message=i);var c=new b(f);throw s&&(c.message=s,c.generatedMessage=!0),c},T.AssertionError=b,T.ok=x,T.equal=function t(e,r,n){if(arguments.length<2)throw new y("actual","expected");e!=r&&I({actual:e,expected:r,message:n,operator:"==",stackStartFn:t})},T.notEqual=function t(e,r,n){if(arguments.length<2)throw new y("actual","expected");e==r&&I({actual:e,expected:r,message:n,operator:"!=",stackStartFn:t})},T.deepEqual=function t(e,r,n){if(arguments.length<2)throw new y("actual","expected");void 0===u&&k(),u(e,r)||I({actual:e,expected:r,message:n,operator:"deepEqual",stackStartFn:t})},T.notDeepEqual=function t(e,r,n){if(arguments.length<2)throw new y("actual","expected");void 0===u&&k(),u(e,r)&&I({actual:e,expected:r,message:n,operator:"notDeepEqual",stackStartFn:t})},T.deepStrictEqual=function t(e,r,n){if(arguments.length<2)throw new y("actual","expected");void 0===u&&k(),f(e,r)||I({actual:e,expected:r,message:n,operator:"deepStrictEqual",stackStartFn:t})},T.notDeepStrictEqual=function t(e,r,n){if(arguments.length<2)throw new y("actual","expected");void 0===u&&k(),f(e,r)&&I({actual:e,expected:r,message:n,operator:"notDeepStrictEqual",stackStartFn:t})},T.strictEqual=function t(e,r,n){if(arguments.length<2)throw new y("actual","expected");_(e,r)||I({actual:e,expected:r,message:n,operator:"strictEqual",stackStartFn:t})},T.notStrictEqual=function t(e,r,n){if(arguments.length<2)throw new y("actual","expected");_(e,r)&&I({actual:e,expected:r,message:n,operator:"notStrictEqual",stackStartFn:t})};var B=a(function t(e,r,n){var i=this;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),r.forEach(function(t){t in e&&(void 0!==n&&"string"==typeof n[t]&&m(e[t])&&E(e[t],n[t])?i[t]=n[t]:i[t]=e[t])})});function R(t,e,r,n){if("function"!=typeof e){if(m(e))return E(e,t);if(2===arguments.length)throw new h("expected",["Function","RegExp"],e);if("object"!==i(t)||null===t){var o=new b({actual:t,expected:e,message:r,operator:"deepStrictEqual",stackStartFn:n});throw o.operator=n.name,o}var a=Object.keys(e);if(e instanceof Error)a.push("name","message");else if(0===a.length)throw new p("error",e,"may not be an empty object");return void 0===u&&k(),a.forEach(function(i){"string"==typeof t[i]&&m(e[i])&&E(e[i],t[i])||function(t,e,r,n,i,o){if(!(r in t)||!f(t[r],e[r])){if(!n){var a=new B(t,i),s=new B(e,i,t),u=new b({actual:a,expected:s,operator:"deepStrictEqual",stackStartFn:o});throw u.actual=t,u.expected=e,u.operator=o.name,u}I({actual:t,expected:e,message:n,operator:o.name,stackStartFn:o})}}(t,e,i,r,a,n)}),!0}return void 0!==e.prototype&&t instanceof e||!Error.isPrototypeOf(e)&&!0===e.call({},t)}function U(t){if("function"!=typeof t)throw new h("fn","Function",t);try{t()}catch(t){return t}return A}function N(t){return w(t)||null!==t&&"object"===i(t)&&"function"==typeof t.then&&"function"==typeof t.catch}function j(t){return Promise.resolve().then(function(){var e;if("function"==typeof t){if(!N(e=t()))throw new d("instance of Promise","promiseFn",e)}else{if(!N(t))throw new h("promiseFn",["Function","Promise"],t);e=t}return Promise.resolve().then(function(){return e}).then(function(){return A}).catch(function(t){return t})})}function L(t,e,r,n){if("string"==typeof r){if(4===arguments.length)throw new h("error",["Object","Error","Function","RegExp"],r);if("object"===i(e)&&null!==e){if(e.message===r)throw new l("error/message",'The error message "'.concat(e.message,'" is identical to the message.'))}else if(e===r)throw new l("error/message",'The error "'.concat(e,'" is identical to the message.'));n=r,r=void 0}else if(null!=r&&"object"!==i(r)&&"function"!=typeof r)throw new h("error",["Object","Error","Function","RegExp"],r);if(e===A){var o="";r&&r.name&&(o+=" (".concat(r.name,")")),o+=n?": ".concat(n):".";var a="rejects"===t.name?"rejection":"exception";I({actual:void 0,expected:r,operator:t.name,message:"Missing expected ".concat(a).concat(o),stackStartFn:t})}if(r&&!R(e,r,n,t))throw e}function C(t,e,r,n){if(e!==A){if("string"==typeof r&&(n=r,r=void 0),!r||R(e,r)){var i=n?": ".concat(n):".",o="doesNotReject"===t.name?"rejection":"exception";I({actual:e,expected:r,operator:t.name,message:"Got unwanted ".concat(o).concat(i,"\n")+'Actual message: "'.concat(e&&e.message,'"'),stackStartFn:t})}throw e}}function F(t,e,r,n,o){if(!m(e))throw new h("regexp","RegExp",e);var a="match"===o;if("string"!=typeof t||E(e,t)!==a){if(r instanceof Error)throw r;var s=!r;r=r||("string"!=typeof t?'The "string" argument must be of type string. Received type '+"".concat(i(t)," (").concat(g(t),")"):(a?"The input did not match the regular expression ":"The input was expected to not match the regular expression ")+"".concat(g(e),". Input:\n\n").concat(g(t),"\n"));var u=new b({actual:t,expected:e,message:r,operator:o,stackStartFn:n});throw u.generatedMessage=s,u}}function D(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];P.apply(void 0,[D,e.length].concat(e))}T.throws=function t(e){for(var r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];L.apply(void 0,[t,U(e)].concat(n))},T.rejects=function t(e){for(var r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];return j(e).then(function(e){return L.apply(void 0,[t,e].concat(n))})},T.doesNotThrow=function t(e){for(var r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];C.apply(void 0,[t,U(e)].concat(n))},T.doesNotReject=function t(e){for(var r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];return j(e).then(function(e){return C.apply(void 0,[t,e].concat(n))})},T.ifError=function t(e){if(null!=e){var r="ifError got unwanted exception: ";"object"===i(e)&&"string"==typeof e.message?0===e.message.length&&e.constructor?r+=e.constructor.name:r+=e.message:r+=g(e);var n=new b({actual:e,expected:null,operator:"ifError",message:r,stackStartFn:t}),o=e.stack;if("string"==typeof o){var a=o.split("\n");a.shift();for(var s=n.stack.split("\n"),u=0;u<a.length;u++){var f=s.indexOf(a[u]);if(-1!==f){s=s.slice(0,f);break}}n.stack="".concat(s.join("\n"),"\n").concat(a.join("\n"))}throw n}},T.match=function t(e,r,n){F(e,r,n,t,"match")},T.doesNotMatch=function t(e,r,n){F(e,r,n,t,"doesNotMatch")},T.strict=S(D,T,{equal:T.strictEqual,deepEqual:T.deepStrictEqual,notEqual:T.notStrictEqual,notDeepEqual:T.notDeepStrictEqual}),T.strict.strict=T.strict},4257:(t,e,r)=>{var n=r(2463).F.ERR_STREAM_PREMATURE_CLOSE;function i(){}t.exports=function t(e,r,o){if("function"==typeof r)return t(e,null,r);r||(r={}),o=function(t){var e=!1;return function(){if(!e){e=!0;for(var r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];t.apply(this,n)}}}(o||i);var a=r.readable||!1!==r.readable&&e.readable,s=r.writable||!1!==r.writable&&e.writable,u=function(){e.writable||c()},f=e._writableState&&e._writableState.finished,c=function(){s=!1,f=!0,a||o.call(e)},l=e._readableState&&e._readableState.endEmitted,h=function(){a=!1,l=!0,s||o.call(e)},p=function(t){o.call(e,t)},d=function(){var t;return a&&!l?(e._readableState&&e._readableState.ended||(t=new n),o.call(e,t)):s&&!f?(e._writableState&&e._writableState.ended||(t=new n),o.call(e,t)):void 0},y=function(){e.req.on("finish",c)};return function(t){return t.setHeader&&"function"==typeof t.abort}(e)?(e.on("complete",c),e.on("abort",d),e.req?y():e.on("request",y)):s&&!e._writableState&&(e.on("end",u),e.on("close",u)),e.on("end",h),e.on("finish",c),!1!==r.error&&e.on("error",p),e.on("close",d),function(){e.removeListener("complete",c),e.removeListener("abort",d),e.removeListener("request",y),e.req&&e.req.removeListener("finish",c),e.removeListener("end",u),e.removeListener("close",u),e.removeListener("finish",c),e.removeListener("end",h),e.removeListener("error",p),e.removeListener("close",d)}}},4347:(t,e,r)=>{var n=r(5606);function i(t,e){a(t,e),o(t)}function o(t){t._writableState&&!t._writableState.emitClose||t._readableState&&!t._readableState.emitClose||t.emit("close")}function a(t,e){t.emit("error",e)}t.exports={destroy:function(t,e){var r=this,s=this._readableState&&this._readableState.destroyed,u=this._writableState&&this._writableState.destroyed;return s||u?(e?e(t):t&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,n.nextTick(a,this,t)):n.nextTick(a,this,t)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(t||null,function(t){!e&&t?r._writableState?r._writableState.errorEmitted?n.nextTick(o,r):(r._writableState.errorEmitted=!0,n.nextTick(i,r,t)):n.nextTick(i,r,t):e?(n.nextTick(o,r),e(t)):n.nextTick(o,r)}),this)},undestroy:function(){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)},errorOrDestroy:function(t,e){var r=t._readableState,n=t._writableState;r&&r.autoDestroy||n&&n.autoDestroy?t.destroy(e):t.emit("error",e)}}},4372:(t,e,r)=>{var n=r(9675),i=r(6556)("TypedArray.prototype.buffer",!0),o=r(5680);t.exports=i||function(t){if(!o(t))throw new n("Not a Typed Array");return t.buffer}},4442:t=>{t.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},4459:t=>{t.exports=Number.isNaN||function(t){return t!=t}},4643:(t,e,r)=>{function n(t){try{if(!r.g.localStorage)return!1}catch(t){return!1}var e=r.g.localStorage[t];return null!=e&&"true"===String(e).toLowerCase()}t.exports=function(t,e){if(n("noDeprecation"))return t;var r=!1;return function(){if(!r){if(n("throwDeprecation"))throw new Error(e);n("traceDeprecation")?console.trace(e):console.warn(e),r=!0}return t.apply(this,arguments)}}},4674:t=>{t.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},4729:(t,e,r)=>{var n=r(2861).Buffer,i=r(1603).Transform;function o(t){i.call(this),this._block=n.allocUnsafe(t),this._blockSize=t,this._blockOffset=0,this._length=[0,0,0,0],this._finalized=!1}r(6698)(o,i),o.prototype._transform=function(t,e,r){var n=null;try{this.update(t,e)}catch(t){n=t}r(n)},o.prototype._flush=function(t){var e=null;try{this.push(this.digest())}catch(t){e=t}t(e)},o.prototype.update=function(t,e){if(function(t){if(!n.isBuffer(t)&&"string"!=typeof t)throw new TypeError("Data must be a string or a buffer")}(t),this._finalized)throw new Error("Digest already called");n.isBuffer(t)||(t=n.from(t,e));for(var r=this._block,i=0;this._blockOffset+t.length-i>=this._blockSize;){for(var o=this._blockOffset;o<this._blockSize;)r[o++]=t[i++];this._update(),this._blockOffset=0}for(;i<t.length;)r[this._blockOffset++]=t[i++];for(var a=0,s=8*t.length;s>0;++a)this._length[a]+=s,(s=this._length[a]/4294967296|0)>0&&(this._length[a]-=4294967296*s);return this},o.prototype._update=function(){throw new Error("_update is not implemented")},o.prototype.digest=function(t){if(this._finalized)throw new Error("Digest already called");this._finalized=!0;var e=this._digest();void 0!==t&&(e=e.toString(t)),this._block.fill(0),this._blockOffset=0;for(var r=0;r<4;++r)this._length[r]=0;return e},o.prototype._digest=function(){throw new Error("_digest is not implemented")},t.exports=o},4743:(t,e,r)=>{var n,i=r(5606);function o(t,e,r){return(e=function(t){var e=function(t){if("object"!=typeof t||null===t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var a=r(5826),s=Symbol("lastResolve"),u=Symbol("lastReject"),f=Symbol("error"),c=Symbol("ended"),l=Symbol("lastPromise"),h=Symbol("handlePromise"),p=Symbol("stream");function d(t,e){return{value:t,done:e}}function y(t){var e=t[s];if(null!==e){var r=t[p].read();null!==r&&(t[l]=null,t[s]=null,t[u]=null,e(d(r,!1)))}}function b(t){i.nextTick(y,t)}var g=Object.getPrototypeOf(function(){}),v=Object.setPrototypeOf((o(n={get stream(){return this[p]},next:function(){var t=this,e=this[f];if(null!==e)return Promise.reject(e);if(this[c])return Promise.resolve(d(void 0,!0));if(this[p].destroyed)return new Promise(function(e,r){i.nextTick(function(){t[f]?r(t[f]):e(d(void 0,!0))})});var r,n=this[l];if(n)r=new Promise(function(t,e){return function(r,n){t.then(function(){e[c]?r(d(void 0,!0)):e[h](r,n)},n)}}(n,this));else{var o=this[p].read();if(null!==o)return Promise.resolve(d(o,!1));r=new Promise(this[h])}return this[l]=r,r}},Symbol.asyncIterator,function(){return this}),o(n,"return",function(){var t=this;return new Promise(function(e,r){t[p].destroy(null,function(t){t?r(t):e(d(void 0,!0))})})}),n),g);t.exports=function(t){var e,r=Object.create(v,(o(e={},p,{value:t,writable:!0}),o(e,s,{value:null,writable:!0}),o(e,u,{value:null,writable:!0}),o(e,f,{value:null,writable:!0}),o(e,c,{value:t._readableState.endEmitted,writable:!0}),o(e,h,{value:function(t,e){var n=r[p].read();n?(r[l]=null,r[s]=null,r[u]=null,t(d(n,!1))):(r[s]=t,r[u]=e)},writable:!0}),e));return r[l]=null,a(t,function(t){if(t&&"ERR_STREAM_PREMATURE_CLOSE"!==t.code){var e=r[u];return null!==e&&(r[l]=null,r[s]=null,r[u]=null,e(t)),void(r[f]=t)}var n=r[s];null!==n&&(r[l]=null,r[s]=null,r[u]=null,n(d(void 0,!0))),r[c]=!0}),t.on("readable",b.bind(null,r)),r}},4823:t=>{var e=function(){for(var t,e=[],r=0;r<256;r++){t=r;for(var n=0;n<8;n++)t=1&t?3988292384^t>>>1:t>>>1;e[r]=t}return e}();t.exports=function(t,r,n,i){var o=e,a=i+n;t^=-1;for(var s=i;s<a;s++)t=t>>>8^o[255&(t^r[s])];return-1^t}},4967:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.isNegativeLE=void 0,e.mod=d,e.pow=function(t,e,r){return _(T(r),t,e)},e.pow2=function(t,e,r){let n=t;for(;e-- >i;)n*=n,n%=r;return n},e.invert=y,e.tonelliShanks=w,e.FpSqrt=m,e.validateField=function(t){const e=S.reduce((t,e)=>(t[e]="function",t),{ORDER:"bigint",MASK:"bigint",BYTES:"number",BITS:"number"});return(0,n._validateObject)(t,e),t},e.FpPow=_,e.FpInvertBatch=E,e.FpDiv=function(t,e,r){return t.mul(e,"bigint"==typeof r?y(r,t.ORDER):t.inv(r))},e.FpLegendre=k,e.FpIsSquare=function(t,e){return 1===k(t,e)},e.nLength=O,e.Field=T,e.FpSqrtOdd=function(t,e){if(!t.isOdd)throw new Error("Field doesn't have isOdd");const r=t.sqrt(e);return t.isOdd(r)?r:t.neg(r)},e.FpSqrtEven=function(t,e){if(!t.isOdd)throw new Error("Field doesn't have isOdd");const r=t.sqrt(e);return t.isOdd(r)?t.neg(r):r},e.hashToPrivateScalar=function(t,e,r=!1){const i=(t=(0,n.ensureBytes)("privateHash",t)).length,a=O(e).nByteLength+8;if(a<24||i<a||i>1024)throw new Error("hashToPrivateScalar: expected "+a+"-1024 bytes of input, got "+i);return d(r?(0,n.bytesToNumberLE)(t):(0,n.bytesToNumberBE)(t),e-o)+o},e.getFieldBytesLength=A,e.getMinHashLength=I,e.mapHashToField=function(t,e,r=!1){const i=t.length,a=A(e),s=I(e);if(i<16||i<s||i>1024)throw new Error("expected "+s+"-1024 bytes of input, got "+i);const u=d(r?(0,n.bytesToNumberLE)(t):(0,n.bytesToNumberBE)(t),e-o)+o;return r?(0,n.numberToBytesLE)(u,a):(0,n.numberToBytesBE)(u,a)};const n=r(8627),i=BigInt(0),o=BigInt(1),a=BigInt(2),s=BigInt(3),u=BigInt(4),f=BigInt(5),c=BigInt(7),l=BigInt(8),h=BigInt(9),p=BigInt(16);function d(t,e){const r=t%e;return r>=i?r:e+r}function y(t,e){if(t===i)throw new Error("invert: expected non-zero number");if(e<=i)throw new Error("invert: expected positive modulus, got "+e);let r=d(t,e),n=e,a=i,s=o,u=o,f=i;for(;r!==i;){const t=n/r,e=n%r,i=a-u*t,o=s-f*t;n=r,r=e,a=u,s=f,u=i,f=o}if(n!==o)throw new Error("invert: does not exist");return d(a,e)}function b(t,e,r){if(!t.eql(t.sqr(e),r))throw new Error("Cannot find square root")}function g(t,e){const r=(t.ORDER+o)/u,n=t.pow(e,r);return b(t,n,e),n}function v(t,e){const r=(t.ORDER-f)/l,n=t.mul(e,a),i=t.pow(n,r),o=t.mul(e,i),s=t.mul(t.mul(o,a),i),u=t.mul(o,t.sub(s,t.ONE));return b(t,u,e),u}function w(t){if(t<s)throw new Error("sqrt is not defined for small field");let e=t-o,r=0;for(;e%a===i;)e/=a,r++;let n=a;const u=T(t);for(;1===k(u,n);)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(1===r)return g;let f=u.pow(n,e);const c=(e+o)/a;return function(t,n){if(t.is0(n))return n;if(1!==k(t,n))throw new Error("Cannot find square root");let i=r,a=t.mul(t.ONE,f),s=t.pow(n,e),u=t.pow(n,c);for(;!t.eql(s,t.ONE);){if(t.is0(s))return t.ZERO;let e=1,r=t.sqr(s);for(;!t.eql(r,t.ONE);)if(e++,r=t.sqr(r),e===i)throw new Error("Cannot find square root");const n=o<<BigInt(i-e-1),f=t.pow(a,n);i=e,a=t.sqr(f),s=t.mul(s,a),u=t.mul(u,f)}return u}}function m(t){return t%u===s?g:t%l===f?v:t%p===h?function(t){const e=T(t),r=w(t),n=r(e,e.neg(e.ONE)),i=r(e,n),o=r(e,e.neg(n)),a=(t+c)/p;return(t,e)=>{let r=t.pow(e,a),s=t.mul(r,n);const u=t.mul(r,i),f=t.mul(r,o),c=t.eql(t.sqr(s),e),l=t.eql(t.sqr(u),e);r=t.cmov(r,s,c),s=t.cmov(f,u,l);const h=t.eql(t.sqr(s),e),p=t.cmov(r,s,h);return b(t,p,e),p}}(t):w(t)}e.isNegativeLE=(t,e)=>(d(t,e)&o)===o;const S=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function _(t,e,r){if(r<i)throw new Error("invalid exponent, negatives unsupported");if(r===i)return t.ONE;if(r===o)return e;let n=t.ONE,a=e;for(;r>i;)r&o&&(n=t.mul(n,a)),a=t.sqr(a),r>>=o;return n}function E(t,e,r=!1){const n=new Array(e.length).fill(r?t.ZERO:void 0),i=e.reduce((e,r,i)=>t.is0(r)?e:(n[i]=e,t.mul(e,r)),t.ONE),o=t.inv(i);return e.reduceRight((e,r,i)=>t.is0(r)?e:(n[i]=t.mul(e,n[i]),t.mul(e,r)),o),n}function k(t,e){const r=(t.ORDER-o)/a,n=t.pow(e,r),i=t.eql(n,t.ONE),s=t.eql(n,t.ZERO),u=t.eql(n,t.neg(t.ONE));if(!i&&!s&&!u)throw new Error("invalid Legendre symbol result");return i?1:s?0:-1}function O(t,e){void 0!==e&&(0,n.anumber)(e);const r=void 0!==e?e:t.toString(2).length;return{nBitLength:r,nByteLength:Math.ceil(r/8)}}function T(t,e,r=!1,a={}){if(t<=i)throw new Error("invalid field: expected ORDER > 0, got "+t);let s,u,f,c=!1;if("object"==typeof e&&null!=e){if(a.sqrt||r)throw new Error("cannot specify opts in two arguments");const t=e;t.BITS&&(s=t.BITS),t.sqrt&&(u=t.sqrt),"boolean"==typeof t.isLE&&(r=t.isLE),"boolean"==typeof t.modFromBytes&&(c=t.modFromBytes),f=t.allowedLengths}else"number"==typeof e&&(s=e),a.sqrt&&(u=a.sqrt);const{nBitLength:l,nByteLength:h}=O(t,s);if(h>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let p;const b=Object.freeze({ORDER:t,isLE:r,BITS:l,BYTES:h,MASK:(0,n.bitMask)(l),ZERO:i,ONE:o,allowedLengths:f,create:e=>d(e,t),isValid:e=>{if("bigint"!=typeof e)throw new Error("invalid field element: expected bigint, got "+typeof e);return i<=e&&e<t},is0:t=>t===i,isValidNot0:t=>!b.is0(t)&&b.isValid(t),isOdd:t=>(t&o)===o,neg:e=>d(-e,t),eql:(t,e)=>t===e,sqr:e=>d(e*e,t),add:(e,r)=>d(e+r,t),sub:(e,r)=>d(e-r,t),mul:(e,r)=>d(e*r,t),pow:(t,e)=>_(b,t,e),div:(e,r)=>d(e*y(r,t),t),sqrN:t=>t*t,addN:(t,e)=>t+e,subN:(t,e)=>t-e,mulN:(t,e)=>t*e,inv:e=>y(e,t),sqrt:u||(e=>(p||(p=m(t)),p(b,e))),toBytes:t=>r?(0,n.numberToBytesLE)(t,h):(0,n.numberToBytesBE)(t,h),fromBytes:(e,i=!0)=>{if(f){if(!f.includes(e.length)||e.length>h)throw new Error("Field.fromBytes: expected "+f+" bytes, got "+e.length);const t=new Uint8Array(h);t.set(e,r?0:t.length-e.length),e=t}if(e.length!==h)throw new Error("Field.fromBytes: expected "+h+" bytes, got "+e.length);let o=r?(0,n.bytesToNumberLE)(e):(0,n.bytesToNumberBE)(e);if(c&&(o=d(o,t)),!i&&!b.isValid(o))throw new Error("invalid field element: outside of range 0..ORDER");return o},invertBatch:t=>E(b,t),cmov:(t,e,r)=>r?e:t});return Object.freeze(b)}function A(t){if("bigint"!=typeof t)throw new Error("field order must be bigint");const e=t.toString(2).length;return Math.ceil(e/8)}function I(t){const e=A(t);return e+Math.ceil(e/2)}},5034:(t,e,r)=>{var n,i=r(5606);function o(t,e,r){return(e=function(t){var e=function(t){if("object"!=typeof t||null===t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var a=r(4257),s=Symbol("lastResolve"),u=Symbol("lastReject"),f=Symbol("error"),c=Symbol("ended"),l=Symbol("lastPromise"),h=Symbol("handlePromise"),p=Symbol("stream");function d(t,e){return{value:t,done:e}}function y(t){var e=t[s];if(null!==e){var r=t[p].read();null!==r&&(t[l]=null,t[s]=null,t[u]=null,e(d(r,!1)))}}function b(t){i.nextTick(y,t)}var g=Object.getPrototypeOf(function(){}),v=Object.setPrototypeOf((o(n={get stream(){return this[p]},next:function(){var t=this,e=this[f];if(null!==e)return Promise.reject(e);if(this[c])return Promise.resolve(d(void 0,!0));if(this[p].destroyed)return new Promise(function(e,r){i.nextTick(function(){t[f]?r(t[f]):e(d(void 0,!0))})});var r,n=this[l];if(n)r=new Promise(function(t,e){return function(r,n){t.then(function(){e[c]?r(d(void 0,!0)):e[h](r,n)},n)}}(n,this));else{var o=this[p].read();if(null!==o)return Promise.resolve(d(o,!1));r=new Promise(this[h])}return this[l]=r,r}},Symbol.asyncIterator,function(){return this}),o(n,"return",function(){var t=this;return new Promise(function(e,r){t[p].destroy(null,function(t){t?r(t):e(d(void 0,!0))})})}),n),g);t.exports=function(t){var e,r=Object.create(v,(o(e={},p,{value:t,writable:!0}),o(e,s,{value:null,writable:!0}),o(e,u,{value:null,writable:!0}),o(e,f,{value:null,writable:!0}),o(e,c,{value:t._readableState.endEmitted,writable:!0}),o(e,h,{value:function(t,e){var n=r[p].read();n?(r[l]=null,r[s]=null,r[u]=null,t(d(n,!1))):(r[s]=t,r[u]=e)},writable:!0}),e));return r[l]=null,a(t,function(t){if(t&&"ERR_STREAM_PREMATURE_CLOSE"!==t.code){var e=r[u];return null!==e&&(r[l]=null,r[s]=null,r[u]=null,e(t)),void(r[f]=t)}var n=r[s];null!==n&&(r[l]=null,r[s]=null,r[u]=null,n(d(void 0,!0))),r[c]=!0}),t.on("readable",b.bind(null,r)),r}},5049:t=>{t.exports=function(){throw new Error("Readable.from is not available in the browser")}},5145:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.crypto=void 0,e.crypto="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0},5170:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),e.ECPairFactory=e.networks=void 0;const i=r(5249);e.networks=i;const o=r(953),a=r(3209),s=r(8377),u=r(709),f=o.typeforce.maybe(o.typeforce.compile({compressed:o.maybe(o.Boolean),network:o.maybe(o.Network)}));e.ECPairFactory=function(t){function e(e,r){if(o.typeforce(o.Buffer256bit,e),!t.isPrivate(e))throw new TypeError("Private key not in range [1, n)");return o.typeforce(f,r),new c(e,void 0,r)}function r(e,r){return o.typeforce(t.isPoint,e),o.typeforce(f,r),new c(void 0,e,r)}(0,u.testEcc)(t);class c{__D;__Q;compressed;network;lowR;constructor(e,r,o){this.__D=e,this.__Q=r,this.lowR=!1,void 0===o&&(o={}),this.compressed=void 0===o.compressed||o.compressed,this.network=o.network||i.bitcoin,void 0!==r&&(this.__Q=n.from(t.pointCompress(r,this.compressed)))}get privateKey(){return this.__D}get publicKey(){if(!this.__Q){const e=t.pointFromScalar(this.__D,this.compressed);this.__Q=n.from(e)}return this.__Q}toWIF(){if(!this.__D)throw new Error("Missing private key");return s.encode(this.network.wif,this.__D,this.compressed)}tweak(t){return this.privateKey?this.tweakFromPrivateKey(t):this.tweakFromPublicKey(t)}sign(e,r){if(!this.__D)throw new Error("Missing private key");if(void 0===r&&(r=this.lowR),!1===r)return n.from(t.sign(e,this.__D));{let r=t.sign(e,this.__D);const i=n.alloc(32,0);let o=0;for(;r[0]>127;)o++,i.writeUIntLE(o,0,6),r=t.sign(e,this.__D,i);return n.from(r)}}signSchnorr(e){if(!this.privateKey)throw new Error("Missing private key");if(!t.signSchnorr)throw new Error("signSchnorr not supported by ecc library");return n.from(t.signSchnorr(e,this.privateKey))}verify(e,r){return t.verify(e,this.publicKey,r)}verifySchnorr(e,r){if(!t.verifySchnorr)throw new Error("verifySchnorr not supported by ecc library");return t.verifySchnorr(e,this.publicKey.subarray(1,33),r)}tweakFromPublicKey(e){const i=32===(o=this.publicKey).length?o:o.slice(1,33);var o;const a=t.xOnlyPointAddTweak(i,e);if(!a||null===a.xOnlyPubkey)throw new Error("Cannot tweak public key!");const s=n.from([0===a.parity?2:3]);return r(n.concat([s,a.xOnlyPubkey]),{network:this.network,compressed:this.compressed})}tweakFromPrivateKey(r){const i=3!==this.publicKey[0]&&(4!==this.publicKey[0]||1&~this.publicKey[64])?this.privateKey:t.privateNegate(this.privateKey),o=t.privateAdd(i,r);if(!o)throw new Error("Invalid tweaked private key!");return e(n.from(o),{network:this.network,compressed:this.compressed})}}return{isPoint:function(e){return t.isPoint(e)},fromPrivateKey:e,fromPublicKey:r,fromWIF:function(t,r){const n=s.decode(t),a=n.version;if(o.Array(r)){if(r=r.filter(t=>a===t.wif).pop(),!r)throw new Error("Unknown network version")}else if(r=r||i.bitcoin,a!==r.wif)throw new Error("Invalid network version");return e(n.privateKey,{compressed:n.compressed,network:r})},makeRandom:function(r){o.typeforce(f,r),void 0===r&&(r={});const n=r.rng||a;let i;do{i=n(32),o.typeforce(o.Buffer256bit,i)}while(!t.isPrivate(i));return e(i,r)}}}},5249:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.testnet=e.bitcoin=void 0,e.bitcoin={messagePrefix:"Bitcoin Signed Message:\n",bech32:"bc",bip32:{public:76067358,private:76066276},pubKeyHash:0,scriptHash:5,wif:128},e.testnet={messagePrefix:"Bitcoin Signed Message:\n",bech32:"tb",bip32:{public:70617039,private:70615956},pubKeyHash:111,scriptHash:196,wif:239}},5267:(t,e,r)=>{var n,i=r(2463).F,o=i.ERR_MISSING_ARGS,a=i.ERR_STREAM_DESTROYED;function s(t){if(t)throw t}function u(t){t()}function f(t,e){return t.pipe(e)}t.exports=function(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];var c,l=function(t){return t.length?"function"!=typeof t[t.length-1]?s:t.pop():s}(e);if(Array.isArray(e[0])&&(e=e[0]),e.length<2)throw new o("streams");var h=e.map(function(t,i){var o=i<e.length-1;return function(t,e,i,o){o=function(t){var e=!1;return function(){e||(e=!0,t.apply(void 0,arguments))}}(o);var s=!1;t.on("close",function(){s=!0}),void 0===n&&(n=r(4257)),n(t,{readable:e,writable:i},function(t){if(t)return o(t);s=!0,o()});var u=!1;return function(e){if(!s&&!u)return u=!0,function(t){return t.setHeader&&"function"==typeof t.abort}(t)?t.abort():"function"==typeof t.destroy?t.destroy():void o(e||new a("pipe"))}}(t,o,i>0,function(t){c||(c=t),t&&h.forEach(u),o||(h.forEach(u),l(c))})});return e.reduce(f)}},5345:t=>{t.exports=URIError},5377:(t,e,r)=>{var n=r(2861).Buffer,i=r(2006),o=r(4372),a=ArrayBuffer.isView||function(t){try{return o(t),!0}catch(t){return!1}},s="undefined"!=typeof Uint8Array,u="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof Uint8Array,f=u&&(n.prototype instanceof Uint8Array||n.TYPED_ARRAY_SUPPORT);t.exports=function(t,e){if(t instanceof n)return t;if("string"==typeof t)return n.from(t,e);if(u&&a(t)){if(0===t.byteLength)return n.alloc(0);if(f){var r=n.from(t.buffer,t.byteOffset,t.byteLength);if(r.byteLength===t.byteLength)return r}var o=t instanceof Uint8Array?t:new Uint8Array(t.buffer,t.byteOffset,t.byteLength),c=n.from(o);if(c.length===t.byteLength)return c}if(s&&t instanceof Uint8Array)return n.from(t);var l=i(t);if(l)for(var h=0;h<t.length;h+=1){var p=t[h];if("number"!=typeof p||p<0||p>255||~~p!==p)throw new RangeError("Array items must be numbers in the range 0-255.")}if(l||n.isBuffer(t)&&t.constructor&&"function"==typeof t.constructor.isBuffer&&t.constructor.isBuffer(t))return n.from(t);throw new TypeError('The "data" argument must be a string, an Array, a Buffer, a Uint8Array, or a DataView.')}},5606:t=>{var e,r,n=t.exports={};function i(){throw new Error("setTimeout has not been defined")}function o(){throw new Error("clearTimeout has not been defined")}function a(t){if(e===setTimeout)return setTimeout(t,0);if((e===i||!e)&&setTimeout)return e=setTimeout,setTimeout(t,0);try{return e(t,0)}catch(r){try{return e.call(null,t,0)}catch(r){return e.call(this,t,0)}}}!function(){try{e="function"==typeof setTimeout?setTimeout:i}catch(t){e=i}try{r="function"==typeof clearTimeout?clearTimeout:o}catch(t){r=o}}();var s,u=[],f=!1,c=-1;function l(){f&&s&&(f=!1,s.length?u=s.concat(u):c=-1,u.length&&h())}function h(){if(!f){var t=a(l);f=!0;for(var e=u.length;e;){for(s=u,u=[];++c<e;)s&&s[c].run();c=-1,e=u.length}s=null,f=!1,function(t){if(r===clearTimeout)return clearTimeout(t);if((r===o||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(t);try{return r(t)}catch(e){try{return r.call(null,t)}catch(e){return r.call(this,t)}}}(t)}}function p(t,e){this.fun=t,this.array=e}function d(){}n.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)e[r-1]=arguments[r];u.push(new p(t,e)),1!==u.length||f||a(h)},p.prototype.run=function(){this.fun.apply(null,this.array)},n.title="browser",n.browser=!0,n.env={},n.argv=[],n.version="",n.versions={},n.on=d,n.addListener=d,n.once=d,n.off=d,n.removeListener=d,n.removeAllListeners=d,n.emit=d,n.prependListener=d,n.prependOnceListener=d,n.listeners=function(t){return[]},n.binding=function(t){throw new Error("process.binding is not supported")},n.cwd=function(){return"/"},n.chdir=function(t){throw new Error("process.chdir is not supported")},n.umask=function(){return 0}},5680:(t,e,r)=>{var n=r(5767);t.exports=function(t){return!!n(t)}},5767:(t,e,r)=>{var n=r(2682),i=r(9209),o=r(487),a=r(6556),s=r(5795),u=r(3628),f=a("Object.prototype.toString"),c=r(9092)(),l="undefined"==typeof globalThis?r.g:globalThis,h=i(),p=a("String.prototype.slice"),d=a("Array.prototype.indexOf",!0)||function(t,e){for(var r=0;r<t.length;r+=1)if(t[r]===e)return r;return-1},y={__proto__:null};n(h,c&&s&&u?function(t){var e=new l[t];if(Symbol.toStringTag in e&&u){var r=u(e),n=s(r,Symbol.toStringTag);if(!n&&r){var i=u(r);n=s(i,Symbol.toStringTag)}y["$"+t]=o(n.get)}}:function(t){var e=new l[t],r=e.slice||e.set;r&&(y["$"+t]=o(r))}),t.exports=function(t){if(!t||"object"!=typeof t)return!1;if(!c){var e=p(f(t),8,-1);return d(h,e)>-1?e:"Object"===e&&function(t){var e=!1;return n(y,function(r,n){if(!e)try{r(t),e=p(n,1)}catch(t){}}),e}(t)}return s?function(t){var e=!1;return n(y,function(r,n){if(!e)try{"$"+r(t)===n&&(e=p(n,1))}catch(t){}}),e}(t):null}},5795:(t,e,r)=>{var n=r(6549);if(n)try{n([],"length")}catch(t){n=null}t.exports=n},5826:(t,e,r)=>{var n=r(2260).F.ERR_STREAM_PREMATURE_CLOSE;function i(){}t.exports=function t(e,r,o){if("function"==typeof r)return t(e,null,r);r||(r={}),o=function(t){var e=!1;return function(){if(!e){e=!0;for(var r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];t.apply(this,n)}}}(o||i);var a=r.readable||!1!==r.readable&&e.readable,s=r.writable||!1!==r.writable&&e.writable,u=function(){e.writable||c()},f=e._writableState&&e._writableState.finished,c=function(){s=!1,f=!0,a||o.call(e)},l=e._readableState&&e._readableState.endEmitted,h=function(){a=!1,l=!0,s||o.call(e)},p=function(t){o.call(e,t)},d=function(){var t;return a&&!l?(e._readableState&&e._readableState.ended||(t=new n),o.call(e,t)):s&&!f?(e._writableState&&e._writableState.ended||(t=new n),o.call(e,t)):void 0},y=function(){e.req.on("finish",c)};return function(t){return t.setHeader&&"function"==typeof t.abort}(e)?(e.on("complete",c),e.on("abort",d),e.req?y():e.on("request",y)):s&&!e._writableState&&(e.on("end",u),e.on("close",u)),e.on("end",h),e.on("finish",c),!1!==r.error&&e.on("error",p),e.on("close",d),function(){e.removeListener("complete",c),e.removeListener("abort",d),e.removeListener("request",y),e.req&&e.req.removeListener("finish",c),e.removeListener("end",u),e.removeListener("close",u),e.removeListener("finish",c),e.removeListener("end",h),e.removeListener("error",p),e.removeListener("close",d)}}},5860:(t,e,r)=>{t.exports=i;var n=r(3054);function i(t){if(!(this instanceof i))return new i(t);n.call(this,t)}r(6698)(i,n),i.prototype._transform=function(t,e,r){r(null,t)}},5880:t=>{t.exports=Math.pow},5974:(t,e,r)=>{var n=r(8287).Buffer,i=r(5606),o=r(4148),a=r(4442),s=r(8411),u=r(1447),f=r(9681);for(var c in f)e[c]=f[c];function l(t){if("number"!=typeof t||t<e.DEFLATE||t>e.UNZIP)throw new TypeError("Bad argument");this.dictionary=null,this.err=0,this.flush=0,this.init_done=!1,this.level=0,this.memLevel=0,this.mode=t,this.strategy=0,this.windowBits=0,this.write_in_progress=!1,this.pending_close=!1,this.gzip_id_bytes_read=0}e.NONE=0,e.DEFLATE=1,e.INFLATE=2,e.GZIP=3,e.GUNZIP=4,e.DEFLATERAW=5,e.INFLATERAW=6,e.UNZIP=7,l.prototype.close=function(){this.write_in_progress?this.pending_close=!0:(this.pending_close=!1,o(this.init_done,"close before init"),o(this.mode<=e.UNZIP),this.mode===e.DEFLATE||this.mode===e.GZIP||this.mode===e.DEFLATERAW?s.deflateEnd(this.strm):this.mode!==e.INFLATE&&this.mode!==e.GUNZIP&&this.mode!==e.INFLATERAW&&this.mode!==e.UNZIP||u.inflateEnd(this.strm),this.mode=e.NONE,this.dictionary=null)},l.prototype.write=function(t,e,r,n,i,o,a){return this._write(!0,t,e,r,n,i,o,a)},l.prototype.writeSync=function(t,e,r,n,i,o,a){return this._write(!1,t,e,r,n,i,o,a)},l.prototype._write=function(t,r,a,s,u,f,c,l){if(o.equal(arguments.length,8),o(this.init_done,"write before init"),o(this.mode!==e.NONE,"already finalized"),o.equal(!1,this.write_in_progress,"write already in progress"),o.equal(!1,this.pending_close,"close is pending"),this.write_in_progress=!0,o.equal(!1,void 0===r,"must provide flush value"),this.write_in_progress=!0,r!==e.Z_NO_FLUSH&&r!==e.Z_PARTIAL_FLUSH&&r!==e.Z_SYNC_FLUSH&&r!==e.Z_FULL_FLUSH&&r!==e.Z_FINISH&&r!==e.Z_BLOCK)throw new Error("Invalid flush value");if(null==a&&(a=n.alloc(0),u=0,s=0),this.strm.avail_in=u,this.strm.input=a,this.strm.next_in=s,this.strm.avail_out=l,this.strm.output=f,this.strm.next_out=c,this.flush=r,!t)return this._process(),this._checkError()?this._afterSync():void 0;var h=this;return i.nextTick(function(){h._process(),h._after()}),this},l.prototype._afterSync=function(){var t=this.strm.avail_out,e=this.strm.avail_in;return this.write_in_progress=!1,[e,t]},l.prototype._process=function(){var t=null;switch(this.mode){case e.DEFLATE:case e.GZIP:case e.DEFLATERAW:this.err=s.deflate(this.strm,this.flush);break;case e.UNZIP:switch(this.strm.avail_in>0&&(t=this.strm.next_in),this.gzip_id_bytes_read){case 0:if(null===t)break;if(31!==this.strm.input[t]){this.mode=e.INFLATE;break}if(this.gzip_id_bytes_read=1,t++,1===this.strm.avail_in)break;case 1:if(null===t)break;139===this.strm.input[t]?(this.gzip_id_bytes_read=2,this.mode=e.GUNZIP):this.mode=e.INFLATE;break;default:throw new Error("invalid number of gzip magic number bytes read")}case e.INFLATE:case e.GUNZIP:case e.INFLATERAW:for(this.err=u.inflate(this.strm,this.flush),this.err===e.Z_NEED_DICT&&this.dictionary&&(this.err=u.inflateSetDictionary(this.strm,this.dictionary),this.err===e.Z_OK?this.err=u.inflate(this.strm,this.flush):this.err===e.Z_DATA_ERROR&&(this.err=e.Z_NEED_DICT));this.strm.avail_in>0&&this.mode===e.GUNZIP&&this.err===e.Z_STREAM_END&&0!==this.strm.next_in[0];)this.reset(),this.err=u.inflate(this.strm,this.flush);break;default:throw new Error("Unknown mode "+this.mode)}},l.prototype._checkError=function(){switch(this.err){case e.Z_OK:case e.Z_BUF_ERROR:if(0!==this.strm.avail_out&&this.flush===e.Z_FINISH)return this._error("unexpected end of file"),!1;break;case e.Z_STREAM_END:break;case e.Z_NEED_DICT:return null==this.dictionary?this._error("Missing dictionary"):this._error("Bad dictionary"),!1;default:return this._error("Zlib error"),!1}return!0},l.prototype._after=function(){if(this._checkError()){var t=this.strm.avail_out,e=this.strm.avail_in;this.write_in_progress=!1,this.callback(e,t),this.pending_close&&this.close()}},l.prototype._error=function(t){this.strm.msg&&(t=this.strm.msg),this.onerror(t,this.err),this.write_in_progress=!1,this.pending_close&&this.close()},l.prototype.init=function(t,r,n,i,a){o(4===arguments.length||5===arguments.length,"init(windowBits, level, memLevel, strategy, [dictionary])"),o(t>=8&&t<=15,"invalid windowBits"),o(r>=-1&&r<=9,"invalid compression level"),o(n>=1&&n<=9,"invalid memlevel"),o(i===e.Z_FILTERED||i===e.Z_HUFFMAN_ONLY||i===e.Z_RLE||i===e.Z_FIXED||i===e.Z_DEFAULT_STRATEGY,"invalid strategy"),this._init(r,t,n,i,a),this._setDictionary()},l.prototype.params=function(){throw new Error("deflateParams Not supported")},l.prototype.reset=function(){this._reset(),this._setDictionary()},l.prototype._init=function(t,r,n,i,o){switch(this.level=t,this.windowBits=r,this.memLevel=n,this.strategy=i,this.flush=e.Z_NO_FLUSH,this.err=e.Z_OK,this.mode!==e.GZIP&&this.mode!==e.GUNZIP||(this.windowBits+=16),this.mode===e.UNZIP&&(this.windowBits+=32),this.mode!==e.DEFLATERAW&&this.mode!==e.INFLATERAW||(this.windowBits=-1*this.windowBits),this.strm=new a,this.mode){case e.DEFLATE:case e.GZIP:case e.DEFLATERAW:this.err=s.deflateInit2(this.strm,this.level,e.Z_DEFLATED,this.windowBits,this.memLevel,this.strategy);break;case e.INFLATE:case e.GUNZIP:case e.INFLATERAW:case e.UNZIP:this.err=u.inflateInit2(this.strm,this.windowBits);break;default:throw new Error("Unknown mode "+this.mode)}this.err!==e.Z_OK&&this._error("Init error"),this.dictionary=o,this.write_in_progress=!1,this.init_done=!0},l.prototype._setDictionary=function(){if(null!=this.dictionary){switch(this.err=e.Z_OK,this.mode){case e.DEFLATE:case e.DEFLATERAW:this.err=s.deflateSetDictionary(this.strm,this.dictionary)}this.err!==e.Z_OK&&this._error("Failed to set dictionary")}},l.prototype._reset=function(){switch(this.err=e.Z_OK,this.mode){case e.DEFLATE:case e.DEFLATERAW:case e.GZIP:this.err=s.deflateReset(this.strm);break;case e.INFLATE:case e.INFLATERAW:case e.GUNZIP:this.err=u.inflateReset(this.strm)}this.err!==e.Z_OK&&this._error("Failed to reset stream")},e.Zlib=l},6011:(t,e,r)=>{var n=r(8287).Buffer,i=r(6698),o=r(4729),a=new Array(16),s=[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],u=[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],f=[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],c=[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],l=[0,1518500249,1859775393,2400959708,2840853838],h=[1352829926,1548603684,1836072691,2053994217,0];function p(){o.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520}function d(t,e){return t<<e|t>>>32-e}function y(t,e,r,n,i,o,a,s){return d(t+(e^r^n)+o+a|0,s)+i|0}function b(t,e,r,n,i,o,a,s){return d(t+(e&r|~e&n)+o+a|0,s)+i|0}function g(t,e,r,n,i,o,a,s){return d(t+((e|~r)^n)+o+a|0,s)+i|0}function v(t,e,r,n,i,o,a,s){return d(t+(e&n|r&~n)+o+a|0,s)+i|0}function w(t,e,r,n,i,o,a,s){return d(t+(e^(r|~n))+o+a|0,s)+i|0}i(p,o),p.prototype._update=function(){for(var t=a,e=0;e<16;++e)t[e]=this._block.readInt32LE(4*e);for(var r=0|this._a,n=0|this._b,i=0|this._c,o=0|this._d,p=0|this._e,m=0|this._a,S=0|this._b,_=0|this._c,E=0|this._d,k=0|this._e,O=0;O<80;O+=1){var T,A;O<16?(T=y(r,n,i,o,p,t[s[O]],l[0],f[O]),A=w(m,S,_,E,k,t[u[O]],h[0],c[O])):O<32?(T=b(r,n,i,o,p,t[s[O]],l[1],f[O]),A=v(m,S,_,E,k,t[u[O]],h[1],c[O])):O<48?(T=g(r,n,i,o,p,t[s[O]],l[2],f[O]),A=g(m,S,_,E,k,t[u[O]],h[2],c[O])):O<64?(T=v(r,n,i,o,p,t[s[O]],l[3],f[O]),A=b(m,S,_,E,k,t[u[O]],h[3],c[O])):(T=w(r,n,i,o,p,t[s[O]],l[4],f[O]),A=y(m,S,_,E,k,t[u[O]],h[4],c[O])),r=p,p=o,o=d(i,10),i=n,n=T,m=k,k=E,E=d(_,10),_=S,S=A}var I=this._b+i+E|0;this._b=this._c+o+k|0,this._c=this._d+p+m|0,this._d=this._e+r+S|0,this._e=this._a+n+_|0,this._a=I},p.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var t=n.alloc?n.alloc(20):new n(20);return t.writeInt32LE(this._a,0),t.writeInt32LE(this._b,4),t.writeInt32LE(this._c,8),t.writeInt32LE(this._d,12),t.writeInt32LE(this._e,16),t},t.exports=p},6168:(t,e,r)=>{var n=r(2861).Buffer,i=r(8310).Transform,o=r(9579).I;function a(t){i.call(this),this.hashMode="string"==typeof t,this.hashMode?this[t]=this._finalOrDigest:this.final=this._finalOrDigest,this._final&&(this.__final=this._final,this._final=null),this._decoder=null,this._encoding=null}r(6698)(a,i);var s="undefined"!=typeof Uint8Array,u="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof Uint8Array&&ArrayBuffer.isView&&(n.prototype instanceof Uint8Array||n.TYPED_ARRAY_SUPPORT);a.prototype.update=function(t,e,r){var i=function(t,e){if(t instanceof n)return t;if("string"==typeof t)return n.from(t,e);if(u&&ArrayBuffer.isView(t)){if(0===t.byteLength)return n.alloc(0);var r=n.from(t.buffer,t.byteOffset,t.byteLength);if(r.byteLength===t.byteLength)return r}if(s&&t instanceof Uint8Array)return n.from(t);if(n.isBuffer(t)&&t.constructor&&"function"==typeof t.constructor.isBuffer&&t.constructor.isBuffer(t))return n.from(t);throw new TypeError('The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView.')}(t,e),o=this._update(i);return this.hashMode?this:(r&&(o=this._toString(o,r)),o)},a.prototype.setAutoPadding=function(){},a.prototype.getAuthTag=function(){throw new Error("trying to get auth tag in unsupported state")},a.prototype.setAuthTag=function(){throw new Error("trying to set auth tag in unsupported state")},a.prototype.setAAD=function(){throw new Error("trying to set aad in unsupported state")},a.prototype._transform=function(t,e,r){var n;try{this.hashMode?this._update(t):this.push(this._update(t))}catch(t){n=t}finally{r(n)}},a.prototype._flush=function(t){var e;try{this.push(this.__final())}catch(t){e=t}t(e)},a.prototype._finalOrDigest=function(t){var e=this.__final()||n.alloc(0);return t&&(e=this._toString(e,t,!0)),e},a.prototype._toString=function(t,e,r){if(this._decoder||(this._decoder=new o(e),this._encoding=e),this._encoding!==e)throw new Error("can’t switch encodings");var n=this._decoder.write(t);return r&&(n+=this._decoder.end()),n},t.exports=a},6188:t=>{t.exports=Math.max},6549:t=>{t.exports=Object.getOwnPropertyDescriptor},6556:(t,e,r)=>{var n=r(453),i=r(3126),o=i([n("%String.prototype.indexOf%")]);t.exports=function(t,e){var r=n(t,!!e);return"function"==typeof r&&o(t,".prototype.")>-1?i([r]):r}},6576:(t,e,r)=>{var n=r(9394),i=r(8452);t.exports=function(){var t=n();return i(Object,{is:t},{is:function(){return Object.is!==t}}),t}},6578:t=>{t.exports=["Float16Array","Float32Array","Float64Array","Int8Array","Int16Array","Int32Array","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array"]},6642:(t,e,r)=>{var n=r(3003);t.exports=function(){return Number.isNaN&&Number.isNaN(NaN)&&!Number.isNaN("a")?Number.isNaN:n}},6644:(t,e,r)=>{var n=r(2463).F.ERR_INVALID_OPT_VALUE;t.exports={getHighWaterMark:function(t,e,r,i){var o=function(t,e,r){return null!=t.highWaterMark?t.highWaterMark:e?t[r]:null}(e,i,r);if(null!=o){if(!isFinite(o)||Math.floor(o)!==o||o<0)throw new n(i?r:"highWaterMark",o);return Math.floor(o)}return t.objectMode?16:16384}}},6698:t=>{"function"==typeof Object.create?t.exports=function(t,e){e&&(t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:t.exports=function(t,e){if(e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}}},6710:(t,e,r)=>{var n=r(6698),i=r(4107),o=r(392),a=r(2861).Buffer,s=new Array(64);function u(){this.init(),this._w=s,o.call(this,64,56)}n(u,i),u.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},u.prototype._hash=function(){var t=a.allocUnsafe(28);return t.writeInt32BE(this._a,0),t.writeInt32BE(this._b,4),t.writeInt32BE(this._c,8),t.writeInt32BE(this._d,12),t.writeInt32BE(this._e,16),t.writeInt32BE(this._f,20),t.writeInt32BE(this._g,24),t},t.exports=u},6736:(t,e,r)=>{var n,i=r(5606);t.exports=O,O.ReadableState=k,r(7007).EventEmitter;var o,a=function(t,e){return t.listeners(e).length},s=r(1181),u=r(8287).Buffer,f=(void 0!==r.g?r.g:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{}).Uint8Array||function(){},c=r(2382);o=c&&c.debuglog?c.debuglog("stream"):function(){};var l,h,p,d=r(2389),y=r(1468),b=r(8775).getHighWaterMark,g=r(2260).F,v=g.ERR_INVALID_ARG_TYPE,w=g.ERR_STREAM_PUSH_AFTER_EOF,m=g.ERR_METHOD_NOT_IMPLEMENTED,S=g.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;r(6698)(O,s);var _=y.errorOrDestroy,E=["error","close","destroy","pause","resume"];function k(t,e,i){n=n||r(2818),t=t||{},"boolean"!=typeof i&&(i=e instanceof n),this.objectMode=!!t.objectMode,i&&(this.objectMode=this.objectMode||!!t.readableObjectMode),this.highWaterMark=b(this,t,"readableHighWaterMark",i),this.buffer=new d,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=!1!==t.emitClose,this.autoDestroy=!!t.autoDestroy,this.destroyed=!1,this.defaultEncoding=t.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,t.encoding&&(l||(l=r(7137).I),this.decoder=new l(t.encoding),this.encoding=t.encoding)}function O(t){if(n=n||r(2818),!(this instanceof O))return new O(t);var e=this instanceof n;this._readableState=new k(t,this,e),this.readable=!0,t&&("function"==typeof t.read&&(this._read=t.read),"function"==typeof t.destroy&&(this._destroy=t.destroy)),s.call(this)}function T(t,e,r,n,i){o("readableAddChunk",e);var a,s=t._readableState;if(null===e)s.reading=!1,function(t,e){if(o("onEofChunk"),!e.ended){if(e.decoder){var r=e.decoder.end();r&&r.length&&(e.buffer.push(r),e.length+=e.objectMode?1:r.length)}e.ended=!0,e.sync?x(t):(e.needReadable=!1,e.emittedReadable||(e.emittedReadable=!0,B(t)))}}(t,s);else if(i||(a=function(t,e){var r,n;return n=e,u.isBuffer(n)||n instanceof f||"string"==typeof e||void 0===e||t.objectMode||(r=new v("chunk",["string","Buffer","Uint8Array"],e)),r}(s,e)),a)_(t,a);else if(s.objectMode||e&&e.length>0)if("string"==typeof e||s.objectMode||Object.getPrototypeOf(e)===u.prototype||(e=function(t){return u.from(t)}(e)),n)s.endEmitted?_(t,new S):A(t,s,e,!0);else if(s.ended)_(t,new w);else{if(s.destroyed)return!1;s.reading=!1,s.decoder&&!r?(e=s.decoder.write(e),s.objectMode||0!==e.length?A(t,s,e,!1):R(t,s)):A(t,s,e,!1)}else n||(s.reading=!1,R(t,s));return!s.ended&&(s.length<s.highWaterMark||0===s.length)}function A(t,e,r,n){e.flowing&&0===e.length&&!e.sync?(e.awaitDrain=0,t.emit("data",r)):(e.length+=e.objectMode?1:r.length,n?e.buffer.unshift(r):e.buffer.push(r),e.needReadable&&x(t)),R(t,e)}Object.defineProperty(O.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._readableState&&this._readableState.destroyed},set:function(t){this._readableState&&(this._readableState.destroyed=t)}}),O.prototype.destroy=y.destroy,O.prototype._undestroy=y.undestroy,O.prototype._destroy=function(t,e){e(t)},O.prototype.push=function(t,e){var r,n=this._readableState;return n.objectMode?r=!0:"string"==typeof t&&((e=e||n.defaultEncoding)!==n.encoding&&(t=u.from(t,e),e=""),r=!0),T(this,t,e,!1,r)},O.prototype.unshift=function(t){return T(this,t,null,!0,!1)},O.prototype.isPaused=function(){return!1===this._readableState.flowing},O.prototype.setEncoding=function(t){l||(l=r(7137).I);var e=new l(t);this._readableState.decoder=e,this._readableState.encoding=this._readableState.decoder.encoding;for(var n=this._readableState.buffer.head,i="";null!==n;)i+=e.write(n.data),n=n.next;return this._readableState.buffer.clear(),""!==i&&this._readableState.buffer.push(i),this._readableState.length=i.length,this};var I=1073741824;function P(t,e){return t<=0||0===e.length&&e.ended?0:e.objectMode?1:t!=t?e.flowing&&e.length?e.buffer.head.data.length:e.length:(t>e.highWaterMark&&(e.highWaterMark=function(t){return t>=I?t=I:(t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++),t}(t)),t<=e.length?t:e.ended?e.length:(e.needReadable=!0,0))}function x(t){var e=t._readableState;o("emitReadable",e.needReadable,e.emittedReadable),e.needReadable=!1,e.emittedReadable||(o("emitReadable",e.flowing),e.emittedReadable=!0,i.nextTick(B,t))}function B(t){var e=t._readableState;o("emitReadable_",e.destroyed,e.length,e.ended),e.destroyed||!e.length&&!e.ended||(t.emit("readable"),e.emittedReadable=!1),e.needReadable=!e.flowing&&!e.ended&&e.length<=e.highWaterMark,C(t)}function R(t,e){e.readingMore||(e.readingMore=!0,i.nextTick(U,t,e))}function U(t,e){for(;!e.reading&&!e.ended&&(e.length<e.highWaterMark||e.flowing&&0===e.length);){var r=e.length;if(o("maybeReadMore read 0"),t.read(0),r===e.length)break}e.readingMore=!1}function N(t){var e=t._readableState;e.readableListening=t.listenerCount("readable")>0,e.resumeScheduled&&!e.paused?e.flowing=!0:t.listenerCount("data")>0&&t.resume()}function j(t){o("readable nexttick read 0"),t.read(0)}function L(t,e){o("resume",e.reading),e.reading||t.read(0),e.resumeScheduled=!1,t.emit("resume"),C(t),e.flowing&&!e.reading&&t.read(0)}function C(t){var e=t._readableState;for(o("flow",e.flowing);e.flowing&&null!==t.read(););}function F(t,e){return 0===e.length?null:(e.objectMode?r=e.buffer.shift():!t||t>=e.length?(r=e.decoder?e.buffer.join(""):1===e.buffer.length?e.buffer.first():e.buffer.concat(e.length),e.buffer.clear()):r=e.buffer.consume(t,e.decoder),r);var r}function D(t){var e=t._readableState;o("endReadable",e.endEmitted),e.endEmitted||(e.ended=!0,i.nextTick(H,e,t))}function H(t,e){if(o("endReadableNT",t.endEmitted,t.length),!t.endEmitted&&0===t.length&&(t.endEmitted=!0,e.readable=!1,e.emit("end"),t.autoDestroy)){var r=e._writableState;(!r||r.autoDestroy&&r.finished)&&e.destroy()}}function M(t,e){for(var r=0,n=t.length;r<n;r++)if(t[r]===e)return r;return-1}O.prototype.read=function(t){o("read",t),t=parseInt(t,10);var e=this._readableState,r=t;if(0!==t&&(e.emittedReadable=!1),0===t&&e.needReadable&&((0!==e.highWaterMark?e.length>=e.highWaterMark:e.length>0)||e.ended))return o("read: emitReadable",e.length,e.ended),0===e.length&&e.ended?D(this):x(this),null;if(0===(t=P(t,e))&&e.ended)return 0===e.length&&D(this),null;var n,i=e.needReadable;return o("need readable",i),(0===e.length||e.length-t<e.highWaterMark)&&o("length less than watermark",i=!0),e.ended||e.reading?o("reading or ended",i=!1):i&&(o("do read"),e.reading=!0,e.sync=!0,0===e.length&&(e.needReadable=!0),this._read(e.highWaterMark),e.sync=!1,e.reading||(t=P(r,e))),null===(n=t>0?F(t,e):null)?(e.needReadable=e.length<=e.highWaterMark,t=0):(e.length-=t,e.awaitDrain=0),0===e.length&&(e.ended||(e.needReadable=!0),r!==t&&e.ended&&D(this)),null!==n&&this.emit("data",n),n},O.prototype._read=function(t){_(this,new m("_read()"))},O.prototype.pipe=function(t,e){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=t;break;case 1:n.pipes=[n.pipes,t];break;default:n.pipes.push(t)}n.pipesCount+=1,o("pipe count=%d opts=%j",n.pipesCount,e);var s=e&&!1===e.end||t===i.stdout||t===i.stderr?y:u;function u(){o("onend"),t.end()}n.endEmitted?i.nextTick(s):r.once("end",s),t.on("unpipe",function e(i,a){o("onunpipe"),i===r&&a&&!1===a.hasUnpiped&&(a.hasUnpiped=!0,o("cleanup"),t.removeListener("close",p),t.removeListener("finish",d),t.removeListener("drain",f),t.removeListener("error",h),t.removeListener("unpipe",e),r.removeListener("end",u),r.removeListener("end",y),r.removeListener("data",l),c=!0,!n.awaitDrain||t._writableState&&!t._writableState.needDrain||f())});var f=function(t){return function(){var e=t._readableState;o("pipeOnDrain",e.awaitDrain),e.awaitDrain&&e.awaitDrain--,0===e.awaitDrain&&a(t,"data")&&(e.flowing=!0,C(t))}}(r);t.on("drain",f);var c=!1;function l(e){o("ondata");var i=t.write(e);o("dest.write",i),!1===i&&((1===n.pipesCount&&n.pipes===t||n.pipesCount>1&&-1!==M(n.pipes,t))&&!c&&(o("false write response, pause",n.awaitDrain),n.awaitDrain++),r.pause())}function h(e){o("onerror",e),y(),t.removeListener("error",h),0===a(t,"error")&&_(t,e)}function p(){t.removeListener("finish",d),y()}function d(){o("onfinish"),t.removeListener("close",p),y()}function y(){o("unpipe"),r.unpipe(t)}return r.on("data",l),function(t,e,r){if("function"==typeof t.prependListener)return t.prependListener(e,r);t._events&&t._events[e]?Array.isArray(t._events[e])?t._events[e].unshift(r):t._events[e]=[r,t._events[e]]:t.on(e,r)}(t,"error",h),t.once("close",p),t.once("finish",d),t.emit("pipe",r),n.flowing||(o("pipe resume"),r.resume()),t},O.prototype.unpipe=function(t){var e=this._readableState,r={hasUnpiped:!1};if(0===e.pipesCount)return this;if(1===e.pipesCount)return t&&t!==e.pipes||(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit("unpipe",this,r)),this;if(!t){var n=e.pipes,i=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var o=0;o<i;o++)n[o].emit("unpipe",this,{hasUnpiped:!1});return this}var a=M(e.pipes,t);return-1===a||(e.pipes.splice(a,1),e.pipesCount-=1,1===e.pipesCount&&(e.pipes=e.pipes[0]),t.emit("unpipe",this,r)),this},O.prototype.on=function(t,e){var r=s.prototype.on.call(this,t,e),n=this._readableState;return"data"===t?(n.readableListening=this.listenerCount("readable")>0,!1!==n.flowing&&this.resume()):"readable"===t&&(n.endEmitted||n.readableListening||(n.readableListening=n.needReadable=!0,n.flowing=!1,n.emittedReadable=!1,o("on readable",n.length,n.reading),n.length?x(this):n.reading||i.nextTick(j,this))),r},O.prototype.addListener=O.prototype.on,O.prototype.removeListener=function(t,e){var r=s.prototype.removeListener.call(this,t,e);return"readable"===t&&i.nextTick(N,this),r},O.prototype.removeAllListeners=function(t){var e=s.prototype.removeAllListeners.apply(this,arguments);return"readable"!==t&&void 0!==t||i.nextTick(N,this),e},O.prototype.resume=function(){var t=this._readableState;return t.flowing||(o("resume"),t.flowing=!t.readableListening,function(t,e){e.resumeScheduled||(e.resumeScheduled=!0,i.nextTick(L,t,e))}(this,t)),t.paused=!1,this},O.prototype.pause=function(){return o("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(o("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this},O.prototype.wrap=function(t){var e=this,r=this._readableState,n=!1;for(var i in t.on("end",function(){if(o("wrapped end"),r.decoder&&!r.ended){var t=r.decoder.end();t&&t.length&&e.push(t)}e.push(null)}),t.on("data",function(i){o("wrapped data"),r.decoder&&(i=r.decoder.write(i)),r.objectMode&&null==i||(r.objectMode||i&&i.length)&&(e.push(i)||(n=!0,t.pause()))}),t)void 0===this[i]&&"function"==typeof t[i]&&(this[i]=function(e){return function(){return t[e].apply(t,arguments)}}(i));for(var a=0;a<E.length;a++)t.on(E[a],this.emit.bind(this,E[a]));return this._read=function(e){o("wrapped _read",e),n&&(n=!1,t.resume())},this},"function"==typeof Symbol&&(O.prototype[Symbol.asyncIterator]=function(){return void 0===h&&(h=r(4743)),h(this)}),Object.defineProperty(O.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty(O.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty(O.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(t){this._readableState&&(this._readableState.flowing=t)}}),O._fromList=F,Object.defineProperty(O.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}}),"function"==typeof Symbol&&(O.from=function(t,e){return void 0===p&&(p=r(5049)),p(O,t,e)})},6743:(t,e,r)=>{var n=r(9353);t.exports=Function.prototype.bind||n},6891:(t,e,r)=>{var n,i=r(5606);t.exports=O,O.ReadableState=k,r(7007).EventEmitter;var o,a=function(t,e){return t.listeners(e).length},s=r(1396),u=r(8287).Buffer,f=(void 0!==r.g?r.g:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{}).Uint8Array||function(){},c=r(7199);o=c&&c.debuglog?c.debuglog("stream"):function(){};var l,h,p,d=r(1766),y=r(4347),b=r(6644).getHighWaterMark,g=r(2463).F,v=g.ERR_INVALID_ARG_TYPE,w=g.ERR_STREAM_PUSH_AFTER_EOF,m=g.ERR_METHOD_NOT_IMPLEMENTED,S=g.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;r(6698)(O,s);var _=y.errorOrDestroy,E=["error","close","destroy","pause","resume"];function k(t,e,i){n=n||r(8101),t=t||{},"boolean"!=typeof i&&(i=e instanceof n),this.objectMode=!!t.objectMode,i&&(this.objectMode=this.objectMode||!!t.readableObjectMode),this.highWaterMark=b(this,t,"readableHighWaterMark",i),this.buffer=new d,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=!1!==t.emitClose,this.autoDestroy=!!t.autoDestroy,this.destroyed=!1,this.defaultEncoding=t.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,t.encoding&&(l||(l=r(3516).I),this.decoder=new l(t.encoding),this.encoding=t.encoding)}function O(t){if(n=n||r(8101),!(this instanceof O))return new O(t);var e=this instanceof n;this._readableState=new k(t,this,e),this.readable=!0,t&&("function"==typeof t.read&&(this._read=t.read),"function"==typeof t.destroy&&(this._destroy=t.destroy)),s.call(this)}function T(t,e,r,n,i){o("readableAddChunk",e);var a,s=t._readableState;if(null===e)s.reading=!1,function(t,e){if(o("onEofChunk"),!e.ended){if(e.decoder){var r=e.decoder.end();r&&r.length&&(e.buffer.push(r),e.length+=e.objectMode?1:r.length)}e.ended=!0,e.sync?x(t):(e.needReadable=!1,e.emittedReadable||(e.emittedReadable=!0,B(t)))}}(t,s);else if(i||(a=function(t,e){var r,n;return n=e,u.isBuffer(n)||n instanceof f||"string"==typeof e||void 0===e||t.objectMode||(r=new v("chunk",["string","Buffer","Uint8Array"],e)),r}(s,e)),a)_(t,a);else if(s.objectMode||e&&e.length>0)if("string"==typeof e||s.objectMode||Object.getPrototypeOf(e)===u.prototype||(e=function(t){return u.from(t)}(e)),n)s.endEmitted?_(t,new S):A(t,s,e,!0);else if(s.ended)_(t,new w);else{if(s.destroyed)return!1;s.reading=!1,s.decoder&&!r?(e=s.decoder.write(e),s.objectMode||0!==e.length?A(t,s,e,!1):R(t,s)):A(t,s,e,!1)}else n||(s.reading=!1,R(t,s));return!s.ended&&(s.length<s.highWaterMark||0===s.length)}function A(t,e,r,n){e.flowing&&0===e.length&&!e.sync?(e.awaitDrain=0,t.emit("data",r)):(e.length+=e.objectMode?1:r.length,n?e.buffer.unshift(r):e.buffer.push(r),e.needReadable&&x(t)),R(t,e)}Object.defineProperty(O.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._readableState&&this._readableState.destroyed},set:function(t){this._readableState&&(this._readableState.destroyed=t)}}),O.prototype.destroy=y.destroy,O.prototype._undestroy=y.undestroy,O.prototype._destroy=function(t,e){e(t)},O.prototype.push=function(t,e){var r,n=this._readableState;return n.objectMode?r=!0:"string"==typeof t&&((e=e||n.defaultEncoding)!==n.encoding&&(t=u.from(t,e),e=""),r=!0),T(this,t,e,!1,r)},O.prototype.unshift=function(t){return T(this,t,null,!0,!1)},O.prototype.isPaused=function(){return!1===this._readableState.flowing},O.prototype.setEncoding=function(t){l||(l=r(3516).I);var e=new l(t);this._readableState.decoder=e,this._readableState.encoding=this._readableState.decoder.encoding;for(var n=this._readableState.buffer.head,i="";null!==n;)i+=e.write(n.data),n=n.next;return this._readableState.buffer.clear(),""!==i&&this._readableState.buffer.push(i),this._readableState.length=i.length,this};var I=1073741824;function P(t,e){return t<=0||0===e.length&&e.ended?0:e.objectMode?1:t!=t?e.flowing&&e.length?e.buffer.head.data.length:e.length:(t>e.highWaterMark&&(e.highWaterMark=function(t){return t>=I?t=I:(t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++),t}(t)),t<=e.length?t:e.ended?e.length:(e.needReadable=!0,0))}function x(t){var e=t._readableState;o("emitReadable",e.needReadable,e.emittedReadable),e.needReadable=!1,e.emittedReadable||(o("emitReadable",e.flowing),e.emittedReadable=!0,i.nextTick(B,t))}function B(t){var e=t._readableState;o("emitReadable_",e.destroyed,e.length,e.ended),e.destroyed||!e.length&&!e.ended||(t.emit("readable"),e.emittedReadable=!1),e.needReadable=!e.flowing&&!e.ended&&e.length<=e.highWaterMark,C(t)}function R(t,e){e.readingMore||(e.readingMore=!0,i.nextTick(U,t,e))}function U(t,e){for(;!e.reading&&!e.ended&&(e.length<e.highWaterMark||e.flowing&&0===e.length);){var r=e.length;if(o("maybeReadMore read 0"),t.read(0),r===e.length)break}e.readingMore=!1}function N(t){var e=t._readableState;e.readableListening=t.listenerCount("readable")>0,e.resumeScheduled&&!e.paused?e.flowing=!0:t.listenerCount("data")>0&&t.resume()}function j(t){o("readable nexttick read 0"),t.read(0)}function L(t,e){o("resume",e.reading),e.reading||t.read(0),e.resumeScheduled=!1,t.emit("resume"),C(t),e.flowing&&!e.reading&&t.read(0)}function C(t){var e=t._readableState;for(o("flow",e.flowing);e.flowing&&null!==t.read(););}function F(t,e){return 0===e.length?null:(e.objectMode?r=e.buffer.shift():!t||t>=e.length?(r=e.decoder?e.buffer.join(""):1===e.buffer.length?e.buffer.first():e.buffer.concat(e.length),e.buffer.clear()):r=e.buffer.consume(t,e.decoder),r);var r}function D(t){var e=t._readableState;o("endReadable",e.endEmitted),e.endEmitted||(e.ended=!0,i.nextTick(H,e,t))}function H(t,e){if(o("endReadableNT",t.endEmitted,t.length),!t.endEmitted&&0===t.length&&(t.endEmitted=!0,e.readable=!1,e.emit("end"),t.autoDestroy)){var r=e._writableState;(!r||r.autoDestroy&&r.finished)&&e.destroy()}}function M(t,e){for(var r=0,n=t.length;r<n;r++)if(t[r]===e)return r;return-1}O.prototype.read=function(t){o("read",t),t=parseInt(t,10);var e=this._readableState,r=t;if(0!==t&&(e.emittedReadable=!1),0===t&&e.needReadable&&((0!==e.highWaterMark?e.length>=e.highWaterMark:e.length>0)||e.ended))return o("read: emitReadable",e.length,e.ended),0===e.length&&e.ended?D(this):x(this),null;if(0===(t=P(t,e))&&e.ended)return 0===e.length&&D(this),null;var n,i=e.needReadable;return o("need readable",i),(0===e.length||e.length-t<e.highWaterMark)&&o("length less than watermark",i=!0),e.ended||e.reading?o("reading or ended",i=!1):i&&(o("do read"),e.reading=!0,e.sync=!0,0===e.length&&(e.needReadable=!0),this._read(e.highWaterMark),e.sync=!1,e.reading||(t=P(r,e))),null===(n=t>0?F(t,e):null)?(e.needReadable=e.length<=e.highWaterMark,t=0):(e.length-=t,e.awaitDrain=0),0===e.length&&(e.ended||(e.needReadable=!0),r!==t&&e.ended&&D(this)),null!==n&&this.emit("data",n),n},O.prototype._read=function(t){_(this,new m("_read()"))},O.prototype.pipe=function(t,e){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=t;break;case 1:n.pipes=[n.pipes,t];break;default:n.pipes.push(t)}n.pipesCount+=1,o("pipe count=%d opts=%j",n.pipesCount,e);var s=e&&!1===e.end||t===i.stdout||t===i.stderr?y:u;function u(){o("onend"),t.end()}n.endEmitted?i.nextTick(s):r.once("end",s),t.on("unpipe",function e(i,a){o("onunpipe"),i===r&&a&&!1===a.hasUnpiped&&(a.hasUnpiped=!0,o("cleanup"),t.removeListener("close",p),t.removeListener("finish",d),t.removeListener("drain",f),t.removeListener("error",h),t.removeListener("unpipe",e),r.removeListener("end",u),r.removeListener("end",y),r.removeListener("data",l),c=!0,!n.awaitDrain||t._writableState&&!t._writableState.needDrain||f())});var f=function(t){return function(){var e=t._readableState;o("pipeOnDrain",e.awaitDrain),e.awaitDrain&&e.awaitDrain--,0===e.awaitDrain&&a(t,"data")&&(e.flowing=!0,C(t))}}(r);t.on("drain",f);var c=!1;function l(e){o("ondata");var i=t.write(e);o("dest.write",i),!1===i&&((1===n.pipesCount&&n.pipes===t||n.pipesCount>1&&-1!==M(n.pipes,t))&&!c&&(o("false write response, pause",n.awaitDrain),n.awaitDrain++),r.pause())}function h(e){o("onerror",e),y(),t.removeListener("error",h),0===a(t,"error")&&_(t,e)}function p(){t.removeListener("finish",d),y()}function d(){o("onfinish"),t.removeListener("close",p),y()}function y(){o("unpipe"),r.unpipe(t)}return r.on("data",l),function(t,e,r){if("function"==typeof t.prependListener)return t.prependListener(e,r);t._events&&t._events[e]?Array.isArray(t._events[e])?t._events[e].unshift(r):t._events[e]=[r,t._events[e]]:t.on(e,r)}(t,"error",h),t.once("close",p),t.once("finish",d),t.emit("pipe",r),n.flowing||(o("pipe resume"),r.resume()),t},O.prototype.unpipe=function(t){var e=this._readableState,r={hasUnpiped:!1};if(0===e.pipesCount)return this;if(1===e.pipesCount)return t&&t!==e.pipes||(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit("unpipe",this,r)),this;if(!t){var n=e.pipes,i=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var o=0;o<i;o++)n[o].emit("unpipe",this,{hasUnpiped:!1});return this}var a=M(e.pipes,t);return-1===a||(e.pipes.splice(a,1),e.pipesCount-=1,1===e.pipesCount&&(e.pipes=e.pipes[0]),t.emit("unpipe",this,r)),this},O.prototype.on=function(t,e){var r=s.prototype.on.call(this,t,e),n=this._readableState;return"data"===t?(n.readableListening=this.listenerCount("readable")>0,!1!==n.flowing&&this.resume()):"readable"===t&&(n.endEmitted||n.readableListening||(n.readableListening=n.needReadable=!0,n.flowing=!1,n.emittedReadable=!1,o("on readable",n.length,n.reading),n.length?x(this):n.reading||i.nextTick(j,this))),r},O.prototype.addListener=O.prototype.on,O.prototype.removeListener=function(t,e){var r=s.prototype.removeListener.call(this,t,e);return"readable"===t&&i.nextTick(N,this),r},O.prototype.removeAllListeners=function(t){var e=s.prototype.removeAllListeners.apply(this,arguments);return"readable"!==t&&void 0!==t||i.nextTick(N,this),e},O.prototype.resume=function(){var t=this._readableState;return t.flowing||(o("resume"),t.flowing=!t.readableListening,function(t,e){e.resumeScheduled||(e.resumeScheduled=!0,i.nextTick(L,t,e))}(this,t)),t.paused=!1,this},O.prototype.pause=function(){return o("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(o("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this},O.prototype.wrap=function(t){var e=this,r=this._readableState,n=!1;for(var i in t.on("end",function(){if(o("wrapped end"),r.decoder&&!r.ended){var t=r.decoder.end();t&&t.length&&e.push(t)}e.push(null)}),t.on("data",function(i){o("wrapped data"),r.decoder&&(i=r.decoder.write(i)),r.objectMode&&null==i||(r.objectMode||i&&i.length)&&(e.push(i)||(n=!0,t.pause()))}),t)void 0===this[i]&&"function"==typeof t[i]&&(this[i]=function(e){return function(){return t[e].apply(t,arguments)}}(i));for(var a=0;a<E.length;a++)t.on(E[a],this.emit.bind(this,E[a]));return this._read=function(e){o("wrapped _read",e),n&&(n=!1,t.resume())},this},"function"==typeof Symbol&&(O.prototype[Symbol.asyncIterator]=function(){return void 0===h&&(h=r(5034)),h(this)}),Object.defineProperty(O.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty(O.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty(O.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(t){this._readableState&&(this._readableState.flowing=t)}}),O._fromList=F,Object.defineProperty(O.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}}),"function"==typeof Symbol&&(O.from=function(t,e){return void 0===p&&(p=r(968)),p(O,t,e)})},6897:(t,e,r)=>{var n=r(453),i=r(41),o=r(592)(),a=r(5795),s=r(9675),u=n("%Math.floor%");t.exports=function(t,e){if("function"!=typeof t)throw new s("`fn` is not a function");if("number"!=typeof e||e<0||e>4294967295||u(e)!==e)throw new s("`length` must be a positive 32-bit integer");var r=arguments.length>2&&!!arguments[2],n=!0,f=!0;if("length"in t&&a){var c=a(t,"length");c&&!c.configurable&&(n=!1),c&&!c.writable&&(f=!1)}return(n||f||!r)&&(o?i(t,"length",e,!0,!0):i(t,"length",e)),t}},7007:t=>{var e,r="object"==typeof Reflect?Reflect:null,n=r&&"function"==typeof r.apply?r.apply:function(t,e,r){return Function.prototype.apply.call(t,e,r)};e=r&&"function"==typeof r.ownKeys?r.ownKeys:Object.getOwnPropertySymbols?function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:function(t){return Object.getOwnPropertyNames(t)};var i=Number.isNaN||function(t){return t!=t};function o(){o.init.call(this)}t.exports=o,t.exports.once=function(t,e){return new Promise(function(r,n){function i(r){t.removeListener(e,o),n(r)}function o(){"function"==typeof t.removeListener&&t.removeListener("error",i),r([].slice.call(arguments))}y(t,e,o,{once:!0}),"error"!==e&&function(t,e){"function"==typeof t.on&&y(t,"error",e,{once:!0})}(t,i)})},o.EventEmitter=o,o.prototype._events=void 0,o.prototype._eventsCount=0,o.prototype._maxListeners=void 0;var a=10;function s(t){if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}function u(t){return void 0===t._maxListeners?o.defaultMaxListeners:t._maxListeners}function f(t,e,r,n){var i,o,a,f;if(s(r),void 0===(o=t._events)?(o=t._events=Object.create(null),t._eventsCount=0):(void 0!==o.newListener&&(t.emit("newListener",e,r.listener?r.listener:r),o=t._events),a=o[e]),void 0===a)a=o[e]=r,++t._eventsCount;else if("function"==typeof a?a=o[e]=n?[r,a]:[a,r]:n?a.unshift(r):a.push(r),(i=u(t))>0&&a.length>i&&!a.warned){a.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+a.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=t,c.type=e,c.count=a.length,f=c,console&&console.warn&&console.warn(f)}return t}function c(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function l(t,e,r){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},i=c.bind(n);return i.listener=r,n.wrapFn=i,i}function h(t,e,r){var n=t._events;if(void 0===n)return[];var i=n[e];return void 0===i?[]:"function"==typeof i?r?[i.listener||i]:[i]:r?function(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}(i):d(i,i.length)}function p(t){var e=this._events;if(void 0!==e){var r=e[t];if("function"==typeof r)return 1;if(void 0!==r)return r.length}return 0}function d(t,e){for(var r=new Array(e),n=0;n<e;++n)r[n]=t[n];return r}function y(t,e,r,n){if("function"==typeof t.on)n.once?t.once(e,r):t.on(e,r);else{if("function"!=typeof t.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t);t.addEventListener(e,function i(o){n.once&&t.removeEventListener(e,i),r(o)})}}Object.defineProperty(o,"defaultMaxListeners",{enumerable:!0,get:function(){return a},set:function(t){if("number"!=typeof t||t<0||i(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");a=t}}),o.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},o.prototype.setMaxListeners=function(t){if("number"!=typeof t||t<0||i(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},o.prototype.getMaxListeners=function(){return u(this)},o.prototype.emit=function(t){for(var e=[],r=1;r<arguments.length;r++)e.push(arguments[r]);var i="error"===t,o=this._events;if(void 0!==o)i=i&&void 0===o.error;else if(!i)return!1;if(i){var a;if(e.length>0&&(a=e[0]),a instanceof Error)throw a;var s=new Error("Unhandled error."+(a?" ("+a.message+")":""));throw s.context=a,s}var u=o[t];if(void 0===u)return!1;if("function"==typeof u)n(u,this,e);else{var f=u.length,c=d(u,f);for(r=0;r<f;++r)n(c[r],this,e)}return!0},o.prototype.addListener=function(t,e){return f(this,t,e,!1)},o.prototype.on=o.prototype.addListener,o.prototype.prependListener=function(t,e){return f(this,t,e,!0)},o.prototype.once=function(t,e){return s(e),this.on(t,l(this,t,e)),this},o.prototype.prependOnceListener=function(t,e){return s(e),this.prependListener(t,l(this,t,e)),this},o.prototype.removeListener=function(t,e){var r,n,i,o,a;if(s(e),void 0===(n=this._events))return this;if(void 0===(r=n[t]))return this;if(r===e||r.listener===e)0===--this._eventsCount?this._events=Object.create(null):(delete n[t],n.removeListener&&this.emit("removeListener",t,r.listener||e));else if("function"!=typeof r){for(i=-1,o=r.length-1;o>=0;o--)if(r[o]===e||r[o].listener===e){a=r[o].listener,i=o;break}if(i<0)return this;0===i?r.shift():function(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}(r,i),1===r.length&&(n[t]=r[0]),void 0!==n.removeListener&&this.emit("removeListener",t,a||e)}return this},o.prototype.off=o.prototype.removeListener,o.prototype.removeAllListeners=function(t){var e,r,n;if(void 0===(r=this._events))return this;if(void 0===r.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==r[t]&&(0===--this._eventsCount?this._events=Object.create(null):delete r[t]),this;if(0===arguments.length){var i,o=Object.keys(r);for(n=0;n<o.length;++n)"removeListener"!==(i=o[n])&&this.removeAllListeners(i);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(e=r[t]))this.removeListener(t,e);else if(void 0!==e)for(n=e.length-1;n>=0;n--)this.removeListener(t,e[n]);return this},o.prototype.listeners=function(t){return h(this,t,!0)},o.prototype.rawListeners=function(t){return h(this,t,!1)},o.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):p.call(t,e)},o.prototype.listenerCount=p,o.prototype.eventNames=function(){return this._eventsCount>0?e(this._events):[]}},7076:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.sha512_224=e.sha512_256=e.sha384=e.sha512=e.sha224=e.sha256=e.SHA512_256=e.SHA512_224=e.SHA384=e.SHA512=e.SHA224=e.SHA256=void 0;const n=r(7202),i=r(2318),o=r(9175),a=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]),s=new Uint32Array(64);class u extends n.HashMD{constructor(t=32){super(64,t,8,!1),this.A=0|n.SHA256_IV[0],this.B=0|n.SHA256_IV[1],this.C=0|n.SHA256_IV[2],this.D=0|n.SHA256_IV[3],this.E=0|n.SHA256_IV[4],this.F=0|n.SHA256_IV[5],this.G=0|n.SHA256_IV[6],this.H=0|n.SHA256_IV[7]}get(){const{A:t,B:e,C:r,D:n,E:i,F:o,G:a,H:s}=this;return[t,e,r,n,i,o,a,s]}set(t,e,r,n,i,o,a,s){this.A=0|t,this.B=0|e,this.C=0|r,this.D=0|n,this.E=0|i,this.F=0|o,this.G=0|a,this.H=0|s}process(t,e){for(let r=0;r<16;r++,e+=4)s[r]=t.getUint32(e,!1);for(let t=16;t<64;t++){const e=s[t-15],r=s[t-2],n=(0,o.rotr)(e,7)^(0,o.rotr)(e,18)^e>>>3,i=(0,o.rotr)(r,17)^(0,o.rotr)(r,19)^r>>>10;s[t]=i+s[t-7]+n+s[t-16]|0}let{A:r,B:i,C:u,D:f,E:c,F:l,G:h,H:p}=this;for(let t=0;t<64;t++){const e=p+((0,o.rotr)(c,6)^(0,o.rotr)(c,11)^(0,o.rotr)(c,25))+(0,n.Chi)(c,l,h)+a[t]+s[t]|0,d=((0,o.rotr)(r,2)^(0,o.rotr)(r,13)^(0,o.rotr)(r,22))+(0,n.Maj)(r,i,u)|0;p=h,h=l,l=c,c=f+e|0,f=u,u=i,i=r,r=e+d|0}r=r+this.A|0,i=i+this.B|0,u=u+this.C|0,f=f+this.D|0,c=c+this.E|0,l=l+this.F|0,h=h+this.G|0,p=p+this.H|0,this.set(r,i,u,f,c,l,h,p)}roundClean(){(0,o.clean)(s)}destroy(){this.set(0,0,0,0,0,0,0,0),(0,o.clean)(this.buffer)}}e.SHA256=u;class f extends u{constructor(){super(28),this.A=0|n.SHA224_IV[0],this.B=0|n.SHA224_IV[1],this.C=0|n.SHA224_IV[2],this.D=0|n.SHA224_IV[3],this.E=0|n.SHA224_IV[4],this.F=0|n.SHA224_IV[5],this.G=0|n.SHA224_IV[6],this.H=0|n.SHA224_IV[7]}}e.SHA224=f;const c=(()=>i.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(t=>BigInt(t))))(),l=(()=>c[0])(),h=(()=>c[1])(),p=new Uint32Array(80),d=new Uint32Array(80);class y extends n.HashMD{constructor(t=64){super(128,t,16,!1),this.Ah=0|n.SHA512_IV[0],this.Al=0|n.SHA512_IV[1],this.Bh=0|n.SHA512_IV[2],this.Bl=0|n.SHA512_IV[3],this.Ch=0|n.SHA512_IV[4],this.Cl=0|n.SHA512_IV[5],this.Dh=0|n.SHA512_IV[6],this.Dl=0|n.SHA512_IV[7],this.Eh=0|n.SHA512_IV[8],this.El=0|n.SHA512_IV[9],this.Fh=0|n.SHA512_IV[10],this.Fl=0|n.SHA512_IV[11],this.Gh=0|n.SHA512_IV[12],this.Gl=0|n.SHA512_IV[13],this.Hh=0|n.SHA512_IV[14],this.Hl=0|n.SHA512_IV[15]}get(){const{Ah:t,Al:e,Bh:r,Bl:n,Ch:i,Cl:o,Dh:a,Dl:s,Eh:u,El:f,Fh:c,Fl:l,Gh:h,Gl:p,Hh:d,Hl:y}=this;return[t,e,r,n,i,o,a,s,u,f,c,l,h,p,d,y]}set(t,e,r,n,i,o,a,s,u,f,c,l,h,p,d,y){this.Ah=0|t,this.Al=0|e,this.Bh=0|r,this.Bl=0|n,this.Ch=0|i,this.Cl=0|o,this.Dh=0|a,this.Dl=0|s,this.Eh=0|u,this.El=0|f,this.Fh=0|c,this.Fl=0|l,this.Gh=0|h,this.Gl=0|p,this.Hh=0|d,this.Hl=0|y}process(t,e){for(let r=0;r<16;r++,e+=4)p[r]=t.getUint32(e),d[r]=t.getUint32(e+=4);for(let t=16;t<80;t++){const e=0|p[t-15],r=0|d[t-15],n=i.rotrSH(e,r,1)^i.rotrSH(e,r,8)^i.shrSH(e,r,7),o=i.rotrSL(e,r,1)^i.rotrSL(e,r,8)^i.shrSL(e,r,7),a=0|p[t-2],s=0|d[t-2],u=i.rotrSH(a,s,19)^i.rotrBH(a,s,61)^i.shrSH(a,s,6),f=i.rotrSL(a,s,19)^i.rotrBL(a,s,61)^i.shrSL(a,s,6),c=i.add4L(o,f,d[t-7],d[t-16]),l=i.add4H(c,n,u,p[t-7],p[t-16]);p[t]=0|l,d[t]=0|c}let{Ah:r,Al:n,Bh:o,Bl:a,Ch:s,Cl:u,Dh:f,Dl:c,Eh:y,El:b,Fh:g,Fl:v,Gh:w,Gl:m,Hh:S,Hl:_}=this;for(let t=0;t<80;t++){const e=i.rotrSH(y,b,14)^i.rotrSH(y,b,18)^i.rotrBH(y,b,41),E=i.rotrSL(y,b,14)^i.rotrSL(y,b,18)^i.rotrBL(y,b,41),k=y&g^~y&w,O=b&v^~b&m,T=i.add5L(_,E,O,h[t],d[t]),A=i.add5H(T,S,e,k,l[t],p[t]),I=0|T,P=i.rotrSH(r,n,28)^i.rotrBH(r,n,34)^i.rotrBH(r,n,39),x=i.rotrSL(r,n,28)^i.rotrBL(r,n,34)^i.rotrBL(r,n,39),B=r&o^r&s^o&s,R=n&a^n&u^a&u;S=0|w,_=0|m,w=0|g,m=0|v,g=0|y,v=0|b,({h:y,l:b}=i.add(0|f,0|c,0|A,0|I)),f=0|s,c=0|u,s=0|o,u=0|a,o=0|r,a=0|n;const U=i.add3L(I,x,R);r=i.add3H(U,A,P,B),n=0|U}({h:r,l:n}=i.add(0|this.Ah,0|this.Al,0|r,0|n)),({h:o,l:a}=i.add(0|this.Bh,0|this.Bl,0|o,0|a)),({h:s,l:u}=i.add(0|this.Ch,0|this.Cl,0|s,0|u)),({h:f,l:c}=i.add(0|this.Dh,0|this.Dl,0|f,0|c)),({h:y,l:b}=i.add(0|this.Eh,0|this.El,0|y,0|b)),({h:g,l:v}=i.add(0|this.Fh,0|this.Fl,0|g,0|v)),({h:w,l:m}=i.add(0|this.Gh,0|this.Gl,0|w,0|m)),({h:S,l:_}=i.add(0|this.Hh,0|this.Hl,0|S,0|_)),this.set(r,n,o,a,s,u,f,c,y,b,g,v,w,m,S,_)}roundClean(){(0,o.clean)(p,d)}destroy(){(0,o.clean)(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}e.SHA512=y;class b extends y{constructor(){super(48),this.Ah=0|n.SHA384_IV[0],this.Al=0|n.SHA384_IV[1],this.Bh=0|n.SHA384_IV[2],this.Bl=0|n.SHA384_IV[3],this.Ch=0|n.SHA384_IV[4],this.Cl=0|n.SHA384_IV[5],this.Dh=0|n.SHA384_IV[6],this.Dl=0|n.SHA384_IV[7],this.Eh=0|n.SHA384_IV[8],this.El=0|n.SHA384_IV[9],this.Fh=0|n.SHA384_IV[10],this.Fl=0|n.SHA384_IV[11],this.Gh=0|n.SHA384_IV[12],this.Gl=0|n.SHA384_IV[13],this.Hh=0|n.SHA384_IV[14],this.Hl=0|n.SHA384_IV[15]}}e.SHA384=b;const g=Uint32Array.from([2352822216,424955298,1944164710,2312950998,502970286,855612546,1738396948,1479516111,258812777,2077511080,2011393907,79989058,1067287976,1780299464,286451373,2446758561]),v=Uint32Array.from([573645204,4230739756,2673172387,3360449730,596883563,1867755857,2520282905,1497426621,2519219938,2827943907,3193839141,1401305490,721525244,746961066,246885852,2177182882]);class w extends y{constructor(){super(28),this.Ah=0|g[0],this.Al=0|g[1],this.Bh=0|g[2],this.Bl=0|g[3],this.Ch=0|g[4],this.Cl=0|g[5],this.Dh=0|g[6],this.Dl=0|g[7],this.Eh=0|g[8],this.El=0|g[9],this.Fh=0|g[10],this.Fl=0|g[11],this.Gh=0|g[12],this.Gl=0|g[13],this.Hh=0|g[14],this.Hl=0|g[15]}}e.SHA512_224=w;class m extends y{constructor(){super(32),this.Ah=0|v[0],this.Al=0|v[1],this.Bh=0|v[2],this.Bl=0|v[3],this.Ch=0|v[4],this.Cl=0|v[5],this.Dh=0|v[6],this.Dl=0|v[7],this.Eh=0|v[8],this.El=0|v[9],this.Fh=0|v[10],this.Fl=0|v[11],this.Gh=0|v[12],this.Gl=0|v[13],this.Hh=0|v[14],this.Hl=0|v[15]}}e.SHA512_256=m,e.sha256=(0,o.createHasher)(()=>new u),e.sha224=(0,o.createHasher)(()=>new f),e.sha512=(0,o.createHasher)(()=>new y),e.sha384=(0,o.createHasher)(()=>new b),e.sha512_256=(0,o.createHasher)(()=>new m),e.sha512_224=(0,o.createHasher)(()=>new w)},7108:(t,e,r)=>{var n=r(6698),i=r(320),o=r(6011),a=r(2802),s=r(6168);function u(t){s.call(this,"digest"),this._hash=t}n(u,s),u.prototype._update=function(t){this._hash.update(t)},u.prototype._final=function(){return this._hash.digest()},t.exports=function(t){return"md5"===(t=t.toLowerCase())?new i:"rmd160"===t||"ripemd160"===t?new o:new u(a(t))}},7119:t=>{t.exports="undefined"!=typeof Reflect&&Reflect&&Reflect.apply},7137:(t,e,r)=>{var n=r(2861).Buffer,i=n.isEncoding||function(t){switch((t=""+t)&&t.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function o(t){var e;switch(this.encoding=function(t){var e=function(t){if(!t)return"utf8";for(var e;;)switch(t){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return t;default:if(e)return;t=(""+t).toLowerCase(),e=!0}}(t);if("string"!=typeof e&&(n.isEncoding===i||!i(t)))throw new Error("Unknown encoding: "+t);return e||t}(t),this.encoding){case"utf16le":this.text=u,this.end=f,e=4;break;case"utf8":this.fillLast=s,e=4;break;case"base64":this.text=c,this.end=l,e=3;break;default:return this.write=h,void(this.end=p)}this.lastNeed=0,this.lastTotal=0,this.lastChar=n.allocUnsafe(e)}function a(t){return t<=127?0:t>>5==6?2:t>>4==14?3:t>>3==30?4:t>>6==2?-1:-2}function s(t){var e=this.lastTotal-this.lastNeed,r=function(t,e){if(128!=(192&e[0]))return t.lastNeed=0,"�";if(t.lastNeed>1&&e.length>1){if(128!=(192&e[1]))return t.lastNeed=1,"�";if(t.lastNeed>2&&e.length>2&&128!=(192&e[2]))return t.lastNeed=2,"�"}}(this,t);return void 0!==r?r:this.lastNeed<=t.length?(t.copy(this.lastChar,e,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(t.copy(this.lastChar,e,0,t.length),void(this.lastNeed-=t.length))}function u(t,e){if((t.length-e)%2==0){var r=t.toString("utf16le",e);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=t[t.length-1],t.toString("utf16le",e,t.length-1)}function f(t){var e=t&&t.length?this.write(t):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return e+this.lastChar.toString("utf16le",0,r)}return e}function c(t,e){var r=(t.length-e)%3;return 0===r?t.toString("base64",e):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=t[t.length-1]:(this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1]),t.toString("base64",e,t.length-r))}function l(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+this.lastChar.toString("base64",0,3-this.lastNeed):e}function h(t){return t.toString(this.encoding)}function p(t){return t&&t.length?this.write(t):""}e.I=o,o.prototype.write=function(t){if(0===t.length)return"";var e,r;if(this.lastNeed){if(void 0===(e=this.fillLast(t)))return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r<t.length?e?e+this.text(t,r):this.text(t,r):e||""},o.prototype.end=function(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+"�":e},o.prototype.text=function(t,e){var r=function(t,e,r){var n=e.length-1;if(n<r)return 0;var i=a(e[n]);return i>=0?(i>0&&(t.lastNeed=i-1),i):--n<r||-2===i?0:(i=a(e[n]))>=0?(i>0&&(t.lastNeed=i-2),i):--n<r||-2===i?0:(i=a(e[n]))>=0?(i>0&&(2===i?i=0:t.lastNeed=i-3),i):0}(this,t,e);if(!this.lastNeed)return t.toString("utf8",e);this.lastTotal=r;var n=t.length-(r-this.lastNeed);return t.copy(this.lastChar,0,n),t.toString("utf8",e,n)},o.prototype.fillLast=function(t){if(this.lastNeed<=t.length)return t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,t.length),this.lastNeed-=t.length}},7176:(t,e,r)=>{var n,i=r(3126),o=r(5795);try{n=[].__proto__===Array.prototype}catch(t){if(!t||"object"!=typeof t||!("code"in t)||"ERR_PROTO_ACCESS"!==t.code)throw t}var a=!!n&&o&&o(Object.prototype,"__proto__"),s=Object,u=s.getPrototypeOf;t.exports=a&&"function"==typeof a.get?i([a.get]):"function"==typeof u&&function(t){return u(null==t?t:s(t))}},7199:()=>{},7202:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.SHA512_IV=e.SHA384_IV=e.SHA224_IV=e.SHA256_IV=e.HashMD=void 0,e.setBigUint64=i,e.Chi=function(t,e,r){return t&e^~t&r},e.Maj=function(t,e,r){return t&e^t&r^e&r};const n=r(9175);function i(t,e,r,n){if("function"==typeof t.setBigUint64)return t.setBigUint64(e,r,n);const i=BigInt(32),o=BigInt(4294967295),a=Number(r>>i&o),s=Number(r&o),u=n?4:0,f=n?0:4;t.setUint32(e+u,a,n),t.setUint32(e+f,s,n)}class o extends n.Hash{constructor(t,e,r,i){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=t,this.outputLen=e,this.padOffset=r,this.isLE=i,this.buffer=new Uint8Array(t),this.view=(0,n.createView)(this.buffer)}update(t){(0,n.aexists)(this),t=(0,n.toBytes)(t),(0,n.abytes)(t);const{view:e,buffer:r,blockLen:i}=this,o=t.length;for(let a=0;a<o;){const s=Math.min(i-this.pos,o-a);if(s===i){const e=(0,n.createView)(t);for(;i<=o-a;a+=i)this.process(e,a);continue}r.set(t.subarray(a,a+s),this.pos),this.pos+=s,a+=s,this.pos===i&&(this.process(e,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){(0,n.aexists)(this),(0,n.aoutput)(t,this),this.finished=!0;const{buffer:e,view:r,blockLen:o,isLE:a}=this;let{pos:s}=this;e[s++]=128,(0,n.clean)(this.buffer.subarray(s)),this.padOffset>o-s&&(this.process(r,0),s=0);for(let t=s;t<o;t++)e[t]=0;i(r,o-8,BigInt(8*this.length),a),this.process(r,0);const u=(0,n.createView)(t),f=this.outputLen;if(f%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const c=f/4,l=this.get();if(c>l.length)throw new Error("_sha2: outputLen bigger than state");for(let t=0;t<c;t++)u.setUint32(4*t,l[t],a)}digest(){const{buffer:t,outputLen:e}=this;this.digestInto(t);const r=t.slice(0,e);return this.destroy(),r}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:e,buffer:r,length:n,finished:i,destroyed:o,pos:a}=this;return t.destroyed=o,t.finished=i,t.length=n,t.pos=a,n%e&&t.buffer.set(r),t}clone(){return this._cloneInto()}}e.HashMD=o,e.SHA256_IV=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),e.SHA224_IV=Uint32Array.from([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]),e.SHA384_IV=Uint32Array.from([3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]),e.SHA512_IV=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209])},7244:(t,e,r)=>{var n=r(9092)(),i=r(6556)("Object.prototype.toString"),o=function(t){return!(n&&t&&"object"==typeof t&&Symbol.toStringTag in t)&&"[object Arguments]"===i(t)},a=function(t){return!!o(t)||null!==t&&"object"==typeof t&&"length"in t&&"number"==typeof t.length&&t.length>=0&&"[object Array]"!==i(t)&&"callee"in t&&"[object Function]"===i(t.callee)},s=function(){return o(arguments)}();o.isLegacyArguments=a,t.exports=s?o:a},7293:t=>{t.exports=function(t,e){var r,n,i,o,a,s,u,f,c,l,h,p,d,y,b,g,v,w,m,S,_,E,k,O,T;r=t.state,n=t.next_in,O=t.input,i=n+(t.avail_in-5),o=t.next_out,T=t.output,a=o-(e-t.avail_out),s=o+(t.avail_out-257),u=r.dmax,f=r.wsize,c=r.whave,l=r.wnext,h=r.window,p=r.hold,d=r.bits,y=r.lencode,b=r.distcode,g=(1<<r.lenbits)-1,v=(1<<r.distbits)-1;t:do{d<15&&(p+=O[n++]<<d,d+=8,p+=O[n++]<<d,d+=8),w=y[p&g];e:for(;;){if(p>>>=m=w>>>24,d-=m,0==(m=w>>>16&255))T[o++]=65535&w;else{if(!(16&m)){if(64&m){if(32&m){r.mode=12;break t}t.msg="invalid literal/length code",r.mode=30;break t}w=y[(65535&w)+(p&(1<<m)-1)];continue e}for(S=65535&w,(m&=15)&&(d<m&&(p+=O[n++]<<d,d+=8),S+=p&(1<<m)-1,p>>>=m,d-=m),d<15&&(p+=O[n++]<<d,d+=8,p+=O[n++]<<d,d+=8),w=b[p&v];;){if(p>>>=m=w>>>24,d-=m,16&(m=w>>>16&255)){if(_=65535&w,d<(m&=15)&&(p+=O[n++]<<d,(d+=8)<m&&(p+=O[n++]<<d,d+=8)),(_+=p&(1<<m)-1)>u){t.msg="invalid distance too far back",r.mode=30;break t}if(p>>>=m,d-=m,_>(m=o-a)){if((m=_-m)>c&&r.sane){t.msg="invalid distance too far back",r.mode=30;break t}if(E=0,k=h,0===l){if(E+=f-m,m<S){S-=m;do{T[o++]=h[E++]}while(--m);E=o-_,k=T}}else if(l<m){if(E+=f+l-m,(m-=l)<S){S-=m;do{T[o++]=h[E++]}while(--m);if(E=0,l<S){S-=m=l;do{T[o++]=h[E++]}while(--m);E=o-_,k=T}}}else if(E+=l-m,m<S){S-=m;do{T[o++]=h[E++]}while(--m);E=o-_,k=T}for(;S>2;)T[o++]=k[E++],T[o++]=k[E++],T[o++]=k[E++],S-=3;S&&(T[o++]=k[E++],S>1&&(T[o++]=k[E++]))}else{E=o-_;do{T[o++]=T[E++],T[o++]=T[E++],T[o++]=T[E++],S-=3}while(S>2);S&&(T[o++]=T[E++],S>1&&(T[o++]=T[E++]))}break}if(64&m){t.msg="invalid distance code",r.mode=30;break t}w=b[(65535&w)+(p&(1<<m)-1)]}}break}}while(n<i&&o<s);n-=S=d>>3,p&=(1<<(d-=S<<3))-1,t.next_in=n,t.next_out=o,t.avail_in=n<i?i-n+5:5-(n-i),t.avail_out=o<s?s-o+257:257-(o-s),r.hold=p,r.bits=d}},7526:(t,e)=>{e.byteLength=function(t){var e=s(t),r=e[0],n=e[1];return 3*(r+n)/4-n},e.toByteArray=function(t){var e,r,o=s(t),a=o[0],u=o[1],f=new i(function(t,e,r){return 3*(e+r)/4-r}(0,a,u)),c=0,l=u>0?a-4:a;for(r=0;r<l;r+=4)e=n[t.charCodeAt(r)]<<18|n[t.charCodeAt(r+1)]<<12|n[t.charCodeAt(r+2)]<<6|n[t.charCodeAt(r+3)],f[c++]=e>>16&255,f[c++]=e>>8&255,f[c++]=255&e;return 2===u&&(e=n[t.charCodeAt(r)]<<2|n[t.charCodeAt(r+1)]>>4,f[c++]=255&e),1===u&&(e=n[t.charCodeAt(r)]<<10|n[t.charCodeAt(r+1)]<<4|n[t.charCodeAt(r+2)]>>2,f[c++]=e>>8&255,f[c++]=255&e),f},e.fromByteArray=function(t){for(var e,n=t.length,i=n%3,o=[],a=16383,s=0,u=n-i;s<u;s+=a)o.push(f(t,s,s+a>u?u:s+a));return 1===i?(e=t[n-1],o.push(r[e>>2]+r[e<<4&63]+"==")):2===i&&(e=(t[n-2]<<8)+t[n-1],o.push(r[e>>10]+r[e>>4&63]+r[e<<2&63]+"=")),o.join("")};for(var r=[],n=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0;a<64;++a)r[a]=o[a],n[o.charCodeAt(a)]=a;function s(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function u(t){return r[t>>18&63]+r[t>>12&63]+r[t>>6&63]+r[63&t]}function f(t,e,r){for(var n,i=[],o=e;o<r;o+=3)n=(t[o]<<16&16711680)+(t[o+1]<<8&65280)+(255&t[o+2]),i.push(u(n));return i.join("")}n["-".charCodeAt(0)]=62,n["_".charCodeAt(0)]=63},7653:(t,e,r)=>{var n=r(8452),i=r(487),o=r(9211),a=r(9394),s=r(6576),u=i(a(),Object);n(u,{getPolyfill:a,implementation:o,shim:s}),t.exports=u},7816:(t,e,r)=>{var n=r(6698),i=r(392),o=r(2861).Buffer,a=[1518500249,1859775393,-1894007588,-899497514],s=new Array(80);function u(){this.init(),this._w=s,i.call(this,64,56)}function f(t){return t<<5|t>>>27}function c(t){return t<<30|t>>>2}function l(t,e,r,n){return 0===t?e&r|~e&n:2===t?e&r|e&n|r&n:e^r^n}n(u,i),u.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},u.prototype._update=function(t){for(var e=this._w,r=0|this._a,n=0|this._b,i=0|this._c,o=0|this._d,s=0|this._e,u=0;u<16;++u)e[u]=t.readInt32BE(4*u);for(;u<80;++u)e[u]=e[u-3]^e[u-8]^e[u-14]^e[u-16];for(var h=0;h<80;++h){var p=~~(h/20),d=f(r)+l(p,n,i,o)+s+e[h]+a[p]|0;s=o,o=i,i=c(n),n=r,r=d}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},u.prototype._hash=function(){var t=o.allocUnsafe(20);return t.writeInt32BE(0|this._a,0),t.writeInt32BE(0|this._b,4),t.writeInt32BE(0|this._c,8),t.writeInt32BE(0|this._d,12),t.writeInt32BE(0|this._e,16),t},t.exports=u},8002:t=>{t.exports=Math.min},8068:t=>{t.exports=SyntaxError},8075:(t,e,r)=>{var n=r(453),i=r(487),o=i(n("String.prototype.indexOf"));t.exports=function(t,e){var r=n(t,!!e);return"function"==typeof r&&o(t,".prototype.")>-1?i(r):r}},8101:(t,e,r)=>{var n=r(5606),i=Object.keys||function(t){var e=[];for(var r in t)e.push(r);return e};t.exports=c;var o=r(6891),a=r(1999);r(6698)(c,o);for(var s=i(a.prototype),u=0;u<s.length;u++){var f=s[u];c.prototype[f]||(c.prototype[f]=a.prototype[f])}function c(t){if(!(this instanceof c))return new c(t);o.call(this,t),a.call(this,t),this.allowHalfOpen=!0,t&&(!1===t.readable&&(this.readable=!1),!1===t.writable&&(this.writable=!1),!1===t.allowHalfOpen&&(this.allowHalfOpen=!1,this.once("end",l)))}function l(){this._writableState.ended||n.nextTick(h,this)}function h(t){t.end()}Object.defineProperty(c.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(c.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(c.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(c.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._readableState&&void 0!==this._writableState&&this._readableState.destroyed&&this._writableState.destroyed},set:function(t){void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed=t,this._writableState.destroyed=t)}})},8184:(t,e,r)=>{var n,i=r(6556),o=r(9721)(/^\s*(?:function)?\*/),a=r(9092)(),s=r(3628),u=i("Object.prototype.toString"),f=i("Function.prototype.toString");t.exports=function(t){if("function"!=typeof t)return!1;if(o(f(t)))return!0;if(!a)return"[object GeneratorFunction]"===u(t);if(!s)return!1;if(void 0===n){var e=function(){if(!a)return!1;try{return Function("return function*() {}")()}catch(t){}}();n=!!e&&s(e)}return s(t)===n}},8212:(t,e,r)=>{var n=r(3835),i=r(2861).Buffer;t.exports=function(t){function e(e){var r=e.slice(0,-4),n=e.slice(-4),i=t(r);if(!(n[0]^i[0]|n[1]^i[1]|n[2]^i[2]|n[3]^i[3]))return r}return{encode:function(e){var r=t(e);return n.encode(i.concat([e,r],e.length+4))},decode:function(t){var r=e(n.decode(t));if(!r)throw new Error("Invalid checksum");return r},decodeUnsafe:function(t){var r=n.decodeUnsafe(t);if(r)return e(r)}}}},8287:(t,e,r)=>{const n=r(7526),i=r(251),o="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;e.Buffer=u,e.SlowBuffer=function(t){return+t!=t&&(t=0),u.alloc(+t)},e.INSPECT_MAX_BYTES=50;const a=2147483647;function s(t){if(t>a)throw new RangeError('The value "'+t+'" is invalid for option "size"');const e=new Uint8Array(t);return Object.setPrototypeOf(e,u.prototype),e}function u(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return l(t)}return f(t,e,r)}function f(t,e,r){if("string"==typeof t)return function(t,e){if("string"==typeof e&&""!==e||(e="utf8"),!u.isEncoding(e))throw new TypeError("Unknown encoding: "+e);const r=0|y(t,e);let n=s(r);const i=n.write(t,e);return i!==r&&(n=n.slice(0,i)),n}(t,e);if(ArrayBuffer.isView(t))return function(t){if(X(t,Uint8Array)){const e=new Uint8Array(t);return p(e.buffer,e.byteOffset,e.byteLength)}return h(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(X(t,ArrayBuffer)||t&&X(t.buffer,ArrayBuffer))return p(t,e,r);if("undefined"!=typeof SharedArrayBuffer&&(X(t,SharedArrayBuffer)||t&&X(t.buffer,SharedArrayBuffer)))return p(t,e,r);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');const n=t.valueOf&&t.valueOf();if(null!=n&&n!==t)return u.from(n,e,r);const i=function(t){if(u.isBuffer(t)){const e=0|d(t.length),r=s(e);return 0===r.length||t.copy(r,0,0,e),r}return void 0!==t.length?"number"!=typeof t.length||Y(t.length)?s(0):h(t):"Buffer"===t.type&&Array.isArray(t.data)?h(t.data):void 0}(t);if(i)return i;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return u.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function c(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function l(t){return c(t),s(t<0?0:0|d(t))}function h(t){const e=t.length<0?0:0|d(t.length),r=s(e);for(let n=0;n<e;n+=1)r[n]=255&t[n];return r}function p(t,e,r){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(r||0))throw new RangeError('"length" is outside of buffer bounds');let n;return n=void 0===e&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,e):new Uint8Array(t,e,r),Object.setPrototypeOf(n,u.prototype),n}function d(t){if(t>=a)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+a.toString(16)+" bytes");return 0|t}function y(t,e){if(u.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||X(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);const r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;let i=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return q(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return z(t).length;default:if(i)return n?-1:q(t).length;e=(""+e).toLowerCase(),i=!0}}function b(t,e,r){let n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return x(this,e,r);case"utf8":case"utf-8":return T(this,e,r);case"ascii":return I(this,e,r);case"latin1":case"binary":return P(this,e,r);case"base64":return O(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return B(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function g(t,e,r){const n=t[e];t[e]=t[r],t[r]=n}function v(t,e,r,n,i){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),Y(r=+r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof e&&(e=u.from(e,n)),u.isBuffer(e))return 0===e.length?-1:w(t,e,r,n,i);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):w(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function w(t,e,r,n,i){let o,a=1,s=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;a=2,s/=2,u/=2,r/=2}function f(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(i){let n=-1;for(o=r;o<s;o++)if(f(t,o)===f(e,-1===n?0:o-n)){if(-1===n&&(n=o),o-n+1===u)return n*a}else-1!==n&&(o-=o-n),n=-1}else for(r+u>s&&(r=s-u),o=r;o>=0;o--){let r=!0;for(let n=0;n<u;n++)if(f(t,o+n)!==f(e,n)){r=!1;break}if(r)return o}return-1}function m(t,e,r,n){r=Number(r)||0;const i=t.length-r;n?(n=Number(n))>i&&(n=i):n=i;const o=e.length;let a;for(n>o/2&&(n=o/2),a=0;a<n;++a){const n=parseInt(e.substr(2*a,2),16);if(Y(n))return a;t[r+a]=n}return a}function S(t,e,r,n){return Z(q(e,t.length-r),t,r,n)}function _(t,e,r,n){return Z(function(t){const e=[];for(let r=0;r<t.length;++r)e.push(255&t.charCodeAt(r));return e}(e),t,r,n)}function E(t,e,r,n){return Z(z(e),t,r,n)}function k(t,e,r,n){return Z(function(t,e){let r,n,i;const o=[];for(let a=0;a<t.length&&!((e-=2)<0);++a)r=t.charCodeAt(a),n=r>>8,i=r%256,o.push(i),o.push(n);return o}(e,t.length-r),t,r,n)}function O(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function T(t,e,r){r=Math.min(t.length,r);const n=[];let i=e;for(;i<r;){const e=t[i];let o=null,a=e>239?4:e>223?3:e>191?2:1;if(i+a<=r){let r,n,s,u;switch(a){case 1:e<128&&(o=e);break;case 2:r=t[i+1],128==(192&r)&&(u=(31&e)<<6|63&r,u>127&&(o=u));break;case 3:r=t[i+1],n=t[i+2],128==(192&r)&&128==(192&n)&&(u=(15&e)<<12|(63&r)<<6|63&n,u>2047&&(u<55296||u>57343)&&(o=u));break;case 4:r=t[i+1],n=t[i+2],s=t[i+3],128==(192&r)&&128==(192&n)&&128==(192&s)&&(u=(15&e)<<18|(63&r)<<12|(63&n)<<6|63&s,u>65535&&u<1114112&&(o=u))}}null===o?(o=65533,a=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|1023&o),n.push(o),i+=a}return function(t){const e=t.length;if(e<=A)return String.fromCharCode.apply(String,t);let r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=A));return r}(n)}e.kMaxLength=a,u.TYPED_ARRAY_SUPPORT=function(){try{const t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),42===t.foo()}catch(t){return!1}}(),u.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||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."),Object.defineProperty(u.prototype,"parent",{enumerable:!0,get:function(){if(u.isBuffer(this))return this.buffer}}),Object.defineProperty(u.prototype,"offset",{enumerable:!0,get:function(){if(u.isBuffer(this))return this.byteOffset}}),u.poolSize=8192,u.from=function(t,e,r){return f(t,e,r)},Object.setPrototypeOf(u.prototype,Uint8Array.prototype),Object.setPrototypeOf(u,Uint8Array),u.alloc=function(t,e,r){return function(t,e,r){return c(t),t<=0?s(t):void 0!==e?"string"==typeof r?s(t).fill(e,r):s(t).fill(e):s(t)}(t,e,r)},u.allocUnsafe=function(t){return l(t)},u.allocUnsafeSlow=function(t){return l(t)},u.isBuffer=function(t){return null!=t&&!0===t._isBuffer&&t!==u.prototype},u.compare=function(t,e){if(X(t,Uint8Array)&&(t=u.from(t,t.offset,t.byteLength)),X(e,Uint8Array)&&(e=u.from(e,e.offset,e.byteLength)),!u.isBuffer(t)||!u.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;let r=t.length,n=e.length;for(let i=0,o=Math.min(r,n);i<o;++i)if(t[i]!==e[i]){r=t[i],n=e[i];break}return r<n?-1:n<r?1:0},u.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}},u.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return u.alloc(0);let r;if(void 0===e)for(e=0,r=0;r<t.length;++r)e+=t[r].length;const n=u.allocUnsafe(e);let i=0;for(r=0;r<t.length;++r){let e=t[r];if(X(e,Uint8Array))i+e.length>n.length?(u.isBuffer(e)||(e=u.from(e)),e.copy(n,i)):Uint8Array.prototype.set.call(n,e,i);else{if(!u.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(n,i)}i+=e.length}return n},u.byteLength=y,u.prototype._isBuffer=!0,u.prototype.swap16=function(){const t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;e<t;e+=2)g(this,e,e+1);return this},u.prototype.swap32=function(){const t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let e=0;e<t;e+=4)g(this,e,e+3),g(this,e+1,e+2);return this},u.prototype.swap64=function(){const t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let e=0;e<t;e+=8)g(this,e,e+7),g(this,e+1,e+6),g(this,e+2,e+5),g(this,e+3,e+4);return this},u.prototype.toString=function(){const t=this.length;return 0===t?"":0===arguments.length?T(this,0,t):b.apply(this,arguments)},u.prototype.toLocaleString=u.prototype.toString,u.prototype.equals=function(t){if(!u.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===u.compare(this,t)},u.prototype.inspect=function(){let t="";const r=e.INSPECT_MAX_BYTES;return t=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(t+=" ... "),"<Buffer "+t+">"},o&&(u.prototype[o]=u.prototype.inspect),u.prototype.compare=function(t,e,r,n,i){if(X(t,Uint8Array)&&(t=u.from(t,t.offset,t.byteLength)),!u.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),e<0||r>t.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&e>=r)return 0;if(n>=i)return-1;if(e>=r)return 1;if(this===t)return 0;let o=(i>>>=0)-(n>>>=0),a=(r>>>=0)-(e>>>=0);const s=Math.min(o,a),f=this.slice(n,i),c=t.slice(e,r);for(let t=0;t<s;++t)if(f[t]!==c[t]){o=f[t],a=c[t];break}return o<a?-1:a<o?1:0},u.prototype.includes=function(t,e,r){return-1!==this.indexOf(t,e,r)},u.prototype.indexOf=function(t,e,r){return v(this,t,e,r,!0)},u.prototype.lastIndexOf=function(t,e,r){return v(this,t,e,r,!1)},u.prototype.write=function(t,e,r,n){if(void 0===e)n="utf8",r=this.length,e=0;else if(void 0===r&&"string"==typeof e)n=e,r=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e>>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}const i=this.length-e;if((void 0===r||r>i)&&(r=i),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");let o=!1;for(;;)switch(n){case"hex":return m(this,t,e,r);case"utf8":case"utf-8":return S(this,t,e,r);case"ascii":case"latin1":case"binary":return _(this,t,e,r);case"base64":return E(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,t,e,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const A=4096;function I(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(127&t[i]);return n}function P(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(t[i]);return n}function x(t,e,r){const n=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>n)&&(r=n);let i="";for(let n=e;n<r;++n)i+=$[t[n]];return i}function B(t,e,r){const n=t.slice(e,r);let i="";for(let t=0;t<n.length-1;t+=2)i+=String.fromCharCode(n[t]+256*n[t+1]);return i}function R(t,e,r){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}function U(t,e,r,n,i,o){if(!u.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||e<o)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}function N(t,e,r,n,i){K(e,n,i,t,r,7);let o=Number(e&BigInt(4294967295));t[r++]=o,o>>=8,t[r++]=o,o>>=8,t[r++]=o,o>>=8,t[r++]=o;let a=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=a,a>>=8,t[r++]=a,a>>=8,t[r++]=a,a>>=8,t[r++]=a,r}function j(t,e,r,n,i){K(e,n,i,t,r,7);let o=Number(e&BigInt(4294967295));t[r+7]=o,o>>=8,t[r+6]=o,o>>=8,t[r+5]=o,o>>=8,t[r+4]=o;let a=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=a,a>>=8,t[r+2]=a,a>>=8,t[r+1]=a,a>>=8,t[r]=a,r+8}function L(t,e,r,n,i,o){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function C(t,e,r,n,o){return e=+e,r>>>=0,o||L(t,0,r,4),i.write(t,e,r,n,23,4),r+4}function F(t,e,r,n,o){return e=+e,r>>>=0,o||L(t,0,r,8),i.write(t,e,r,n,52,8),r+8}u.prototype.slice=function(t,e){const r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e<t&&(e=t);const n=this.subarray(t,e);return Object.setPrototypeOf(n,u.prototype),n},u.prototype.readUintLE=u.prototype.readUIntLE=function(t,e,r){t>>>=0,e>>>=0,r||R(t,e,this.length);let n=this[t],i=1,o=0;for(;++o<e&&(i*=256);)n+=this[t+o]*i;return n},u.prototype.readUintBE=u.prototype.readUIntBE=function(t,e,r){t>>>=0,e>>>=0,r||R(t,e,this.length);let n=this[t+--e],i=1;for(;e>0&&(i*=256);)n+=this[t+--e]*i;return n},u.prototype.readUint8=u.prototype.readUInt8=function(t,e){return t>>>=0,e||R(t,1,this.length),this[t]},u.prototype.readUint16LE=u.prototype.readUInt16LE=function(t,e){return t>>>=0,e||R(t,2,this.length),this[t]|this[t+1]<<8},u.prototype.readUint16BE=u.prototype.readUInt16BE=function(t,e){return t>>>=0,e||R(t,2,this.length),this[t]<<8|this[t+1]},u.prototype.readUint32LE=u.prototype.readUInt32LE=function(t,e){return t>>>=0,e||R(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},u.prototype.readUint32BE=u.prototype.readUInt32BE=function(t,e){return t>>>=0,e||R(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},u.prototype.readBigUInt64LE=J(function(t){V(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||W(t,this.length-8);const n=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,i=this[++t]+256*this[++t]+65536*this[++t]+r*2**24;return BigInt(n)+(BigInt(i)<<BigInt(32))}),u.prototype.readBigUInt64BE=J(function(t){V(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||W(t,this.length-8);const n=e*2**24+65536*this[++t]+256*this[++t]+this[++t],i=this[++t]*2**24+65536*this[++t]+256*this[++t]+r;return(BigInt(n)<<BigInt(32))+BigInt(i)}),u.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||R(t,e,this.length);let n=this[t],i=1,o=0;for(;++o<e&&(i*=256);)n+=this[t+o]*i;return i*=128,n>=i&&(n-=Math.pow(2,8*e)),n},u.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||R(t,e,this.length);let n=e,i=1,o=this[t+--n];for(;n>0&&(i*=256);)o+=this[t+--n]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*e)),o},u.prototype.readInt8=function(t,e){return t>>>=0,e||R(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},u.prototype.readInt16LE=function(t,e){t>>>=0,e||R(t,2,this.length);const r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt16BE=function(t,e){t>>>=0,e||R(t,2,this.length);const r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt32LE=function(t,e){return t>>>=0,e||R(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},u.prototype.readInt32BE=function(t,e){return t>>>=0,e||R(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},u.prototype.readBigInt64LE=J(function(t){V(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||W(t,this.length-8);const n=this[t+4]+256*this[t+5]+65536*this[t+6]+(r<<24);return(BigInt(n)<<BigInt(32))+BigInt(e+256*this[++t]+65536*this[++t]+this[++t]*2**24)}),u.prototype.readBigInt64BE=J(function(t){V(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||W(t,this.length-8);const n=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return(BigInt(n)<<BigInt(32))+BigInt(this[++t]*2**24+65536*this[++t]+256*this[++t]+r)}),u.prototype.readFloatLE=function(t,e){return t>>>=0,e||R(t,4,this.length),i.read(this,t,!0,23,4)},u.prototype.readFloatBE=function(t,e){return t>>>=0,e||R(t,4,this.length),i.read(this,t,!1,23,4)},u.prototype.readDoubleLE=function(t,e){return t>>>=0,e||R(t,8,this.length),i.read(this,t,!0,52,8)},u.prototype.readDoubleBE=function(t,e){return t>>>=0,e||R(t,8,this.length),i.read(this,t,!1,52,8)},u.prototype.writeUintLE=u.prototype.writeUIntLE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||U(this,t,e,r,Math.pow(2,8*r)-1,0);let i=1,o=0;for(this[e]=255&t;++o<r&&(i*=256);)this[e+o]=t/i&255;return e+r},u.prototype.writeUintBE=u.prototype.writeUIntBE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||U(this,t,e,r,Math.pow(2,8*r)-1,0);let i=r-1,o=1;for(this[e+i]=255&t;--i>=0&&(o*=256);)this[e+i]=t/o&255;return e+r},u.prototype.writeUint8=u.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,1,255,0),this[e]=255&t,e+1},u.prototype.writeUint16LE=u.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},u.prototype.writeUint16BE=u.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},u.prototype.writeUint32LE=u.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},u.prototype.writeUint32BE=u.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},u.prototype.writeBigUInt64LE=J(function(t,e=0){return N(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))}),u.prototype.writeBigUInt64BE=J(function(t,e=0){return j(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))}),u.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);U(this,t,e,r,n-1,-n)}let i=0,o=1,a=0;for(this[e]=255&t;++i<r&&(o*=256);)t<0&&0===a&&0!==this[e+i-1]&&(a=1),this[e+i]=(t/o|0)-a&255;return e+r},u.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);U(this,t,e,r,n-1,-n)}let i=r-1,o=1,a=0;for(this[e+i]=255&t;--i>=0&&(o*=256);)t<0&&0===a&&0!==this[e+i+1]&&(a=1),this[e+i]=(t/o|0)-a&255;return e+r},u.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},u.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},u.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},u.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},u.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},u.prototype.writeBigInt64LE=J(function(t,e=0){return N(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),u.prototype.writeBigInt64BE=J(function(t,e=0){return j(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),u.prototype.writeFloatLE=function(t,e,r){return C(this,t,e,!0,r)},u.prototype.writeFloatBE=function(t,e,r){return C(this,t,e,!1,r)},u.prototype.writeDoubleLE=function(t,e,r){return F(this,t,e,!0,r)},u.prototype.writeDoubleBE=function(t,e,r){return F(this,t,e,!1,r)},u.prototype.copy=function(t,e,r,n){if(!u.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n<r&&(n=r),n===r)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e<n-r&&(n=t.length-e+r);const i=n-r;return this===t&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(e,r,n):Uint8Array.prototype.set.call(t,this.subarray(r,n),e),i},u.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!u.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===t.length){const e=t.charCodeAt(0);("utf8"===n&&e<128||"latin1"===n)&&(t=e)}}else"number"==typeof t?t&=255:"boolean"==typeof t&&(t=Number(t));if(e<0||this.length<e||this.length<r)throw new RangeError("Out of range index");if(r<=e)return this;let i;if(e>>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(i=e;i<r;++i)this[i]=t;else{const o=u.isBuffer(t)?t:u.from(t,n),a=o.length;if(0===a)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(i=0;i<r-e;++i)this[i+e]=o[i%a]}return this};const D={};function H(t,e,r){D[t]=class extends r{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${t}]`,this.stack,delete this.name}get code(){return t}set code(t){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:t,writable:!0})}toString(){return`${this.name} [${t}]: ${this.message}`}}}function M(t){let e="",r=t.length;const n="-"===t[0]?1:0;for(;r>=n+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}function K(t,e,r,n,i,o){if(t>r||t<e){const n="bigint"==typeof e?"n":"";let i;throw i=o>3?0===e||e===BigInt(0)?`>= 0${n} and < 2${n} ** ${8*(o+1)}${n}`:`>= -(2${n} ** ${8*(o+1)-1}${n}) and < 2 ** ${8*(o+1)-1}${n}`:`>= ${e}${n} and <= ${r}${n}`,new D.ERR_OUT_OF_RANGE("value",i,t)}!function(t,e,r){V(e,"offset"),void 0!==t[e]&&void 0!==t[e+r]||W(e,t.length-(r+1))}(n,i,o)}function V(t,e){if("number"!=typeof t)throw new D.ERR_INVALID_ARG_TYPE(e,"number",t)}function W(t,e,r){if(Math.floor(t)!==t)throw V(t,r),new D.ERR_OUT_OF_RANGE(r||"offset","an integer",t);if(e<0)throw new D.ERR_BUFFER_OUT_OF_BOUNDS;throw new D.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}H("ERR_BUFFER_OUT_OF_BOUNDS",function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),H("ERR_INVALID_ARG_TYPE",function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`},TypeError),H("ERR_OUT_OF_RANGE",function(t,e,r){let n=`The value of "${t}" is out of range.`,i=r;return Number.isInteger(r)&&Math.abs(r)>2**32?i=M(String(r)):"bigint"==typeof r&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=M(i)),i+="n"),n+=` It must be ${e}. Received ${i}`,n},RangeError);const G=/[^+/0-9A-Za-z-_]/g;function q(t,e){let r;e=e||1/0;const n=t.length;let i=null;const o=[];for(let a=0;a<n;++a){if(r=t.charCodeAt(a),r>55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(a+1===n){(e-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;o.push(r)}else if(r<2048){if((e-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function z(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(G,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function Z(t,e,r,n){let i;for(i=0;i<n&&!(i+r>=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function X(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function Y(t){return t!=t}const $=function(){const t="0123456789abcdef",e=new Array(256);for(let r=0;r<16;++r){const n=16*r;for(let i=0;i<16;++i)e[n+i]=t[r]+t[i]}return e}();function J(t){return"undefined"==typeof BigInt?Q:t}function Q(){throw new Error("BigInt not supported")}},8310:(t,e,r)=>{t.exports=i;var n=r(7007).EventEmitter;function i(){n.call(this)}r(6698)(i,n),i.Readable=r(6891),i.Writable=r(1999),i.Duplex=r(8101),i.Transform=r(9083),i.PassThrough=r(3681),i.finished=r(4257),i.pipeline=r(5267),i.Stream=i,i.prototype.pipe=function(t,e){var r=this;function i(e){t.writable&&!1===t.write(e)&&r.pause&&r.pause()}function o(){r.readable&&r.resume&&r.resume()}r.on("data",i),t.on("drain",o),t._isStdio||e&&!1===e.end||(r.on("end",s),r.on("close",u));var a=!1;function s(){a||(a=!0,t.end())}function u(){a||(a=!0,"function"==typeof t.destroy&&t.destroy())}function f(t){if(c(),0===n.listenerCount(this,"error"))throw t}function c(){r.removeListener("data",i),t.removeListener("drain",o),r.removeListener("end",s),r.removeListener("close",u),r.removeListener("error",f),t.removeListener("error",f),r.removeListener("end",c),r.removeListener("close",c),t.removeListener("close",c)}return r.on("error",f),t.on("error",f),r.on("end",c),r.on("close",c),t.on("close",c),t.emit("pipe",r),t}},8377:(t,e,r)=>{var n=r(8287).Buffer,i=r(2577);function o(t,e){if(void 0!==e&&t[0]!==e)throw new Error("Invalid network version");if(33===t.length)return{version:t[0],privateKey:t.slice(1,33),compressed:!1};if(34!==t.length)throw new Error("Invalid WIF length");if(1!==t[33])throw new Error("Invalid compression flag");return{version:t[0],privateKey:t.slice(1,33),compressed:!0}}function a(t,e,r){var i=new n(r?34:33);return i.writeUInt8(t,0),e.copy(i,1),r&&(i[33]=1),i}t.exports={decode:function(t,e){return o(i.decode(t),e)},decodeRaw:o,encode:function(t,e,r){return"number"==typeof t?i.encode(a(t,e,r)):i.encode(a(t.version,t.privateKey,t.compressed))},encodeRaw:a}},8403:(t,e,r)=>{var n=r(1189),i=r(1333)(),o=r(6556),a=r(9612),s=o("Array.prototype.push"),u=o("Object.prototype.propertyIsEnumerable"),f=i?a.getOwnPropertySymbols:null;t.exports=function(t,e){if(null==t)throw new TypeError("target must be an object");var r=a(t);if(1===arguments.length)return r;for(var o=1;o<arguments.length;++o){var c=a(arguments[o]),l=n(c),h=i&&(a.getOwnPropertySymbols||f);if(h)for(var p=h(c),d=0;d<p.length;++d){var y=p[d];u(c,y)&&s(l,y)}for(var b=0;b<l.length;++b){var g=l[b];if(u(c,g)){var v=c[g];r[g]=v}}}return r}},8411:(t,e,r)=>{var n,i=r(9805),o=r(3665),a=r(3269),s=r(4823),u=r(4674),f=-2,c=258,l=262,h=103,p=113,d=666;function y(t,e){return t.msg=u[e],e}function b(t){return(t<<1)-(t>4?9:0)}function g(t){for(var e=t.length;--e>=0;)t[e]=0}function v(t){var e=t.state,r=e.pending;r>t.avail_out&&(r=t.avail_out),0!==r&&(i.arraySet(t.output,e.pending_buf,e.pending_out,r,t.next_out),t.next_out+=r,e.pending_out+=r,t.total_out+=r,t.avail_out-=r,e.pending-=r,0===e.pending&&(e.pending_out=0))}function w(t,e){o._tr_flush_block(t,t.block_start>=0?t.block_start:-1,t.strstart-t.block_start,e),t.block_start=t.strstart,v(t.strm)}function m(t,e){t.pending_buf[t.pending++]=e}function S(t,e){t.pending_buf[t.pending++]=e>>>8&255,t.pending_buf[t.pending++]=255&e}function _(t,e,r,n){var o=t.avail_in;return o>n&&(o=n),0===o?0:(t.avail_in-=o,i.arraySet(e,t.input,t.next_in,o,r),1===t.state.wrap?t.adler=a(t.adler,e,o,r):2===t.state.wrap&&(t.adler=s(t.adler,e,o,r)),t.next_in+=o,t.total_in+=o,o)}function E(t,e){var r,n,i=t.max_chain_length,o=t.strstart,a=t.prev_length,s=t.nice_match,u=t.strstart>t.w_size-l?t.strstart-(t.w_size-l):0,f=t.window,h=t.w_mask,p=t.prev,d=t.strstart+c,y=f[o+a-1],b=f[o+a];t.prev_length>=t.good_match&&(i>>=2),s>t.lookahead&&(s=t.lookahead);do{if(f[(r=e)+a]===b&&f[r+a-1]===y&&f[r]===f[o]&&f[++r]===f[o+1]){o+=2,r++;do{}while(f[++o]===f[++r]&&f[++o]===f[++r]&&f[++o]===f[++r]&&f[++o]===f[++r]&&f[++o]===f[++r]&&f[++o]===f[++r]&&f[++o]===f[++r]&&f[++o]===f[++r]&&o<d);if(n=c-(d-o),o=d-c,n>a){if(t.match_start=e,a=n,n>=s)break;y=f[o+a-1],b=f[o+a]}}}while((e=p[e&h])>u&&0!==--i);return a<=t.lookahead?a:t.lookahead}function k(t){var e,r,n,o,a,s=t.w_size;do{if(o=t.window_size-t.lookahead-t.strstart,t.strstart>=s+(s-l)){i.arraySet(t.window,t.window,s,s,0),t.match_start-=s,t.strstart-=s,t.block_start-=s,e=r=t.hash_size;do{n=t.head[--e],t.head[e]=n>=s?n-s:0}while(--r);e=r=s;do{n=t.prev[--e],t.prev[e]=n>=s?n-s:0}while(--r);o+=s}if(0===t.strm.avail_in)break;if(r=_(t.strm,t.window,t.strstart+t.lookahead,o),t.lookahead+=r,t.lookahead+t.insert>=3)for(a=t.strstart-t.insert,t.ins_h=t.window[a],t.ins_h=(t.ins_h<<t.hash_shift^t.window[a+1])&t.hash_mask;t.insert&&(t.ins_h=(t.ins_h<<t.hash_shift^t.window[a+3-1])&t.hash_mask,t.prev[a&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=a,a++,t.insert--,!(t.lookahead+t.insert<3)););}while(t.lookahead<l&&0!==t.strm.avail_in)}function O(t,e){for(var r,n;;){if(t.lookahead<l){if(k(t),t.lookahead<l&&0===e)return 1;if(0===t.lookahead)break}if(r=0,t.lookahead>=3&&(t.ins_h=(t.ins_h<<t.hash_shift^t.window[t.strstart+3-1])&t.hash_mask,r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),0!==r&&t.strstart-r<=t.w_size-l&&(t.match_length=E(t,r)),t.match_length>=3)if(n=o._tr_tally(t,t.strstart-t.match_start,t.match_length-3),t.lookahead-=t.match_length,t.match_length<=t.max_lazy_match&&t.lookahead>=3){t.match_length--;do{t.strstart++,t.ins_h=(t.ins_h<<t.hash_shift^t.window[t.strstart+3-1])&t.hash_mask,r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart}while(0!==--t.match_length);t.strstart++}else t.strstart+=t.match_length,t.match_length=0,t.ins_h=t.window[t.strstart],t.ins_h=(t.ins_h<<t.hash_shift^t.window[t.strstart+1])&t.hash_mask;else n=o._tr_tally(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++;if(n&&(w(t,!1),0===t.strm.avail_out))return 1}return t.insert=t.strstart<2?t.strstart:2,4===e?(w(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(w(t,!1),0===t.strm.avail_out)?1:2}function T(t,e){for(var r,n,i;;){if(t.lookahead<l){if(k(t),t.lookahead<l&&0===e)return 1;if(0===t.lookahead)break}if(r=0,t.lookahead>=3&&(t.ins_h=(t.ins_h<<t.hash_shift^t.window[t.strstart+3-1])&t.hash_mask,r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),t.prev_length=t.match_length,t.prev_match=t.match_start,t.match_length=2,0!==r&&t.prev_length<t.max_lazy_match&&t.strstart-r<=t.w_size-l&&(t.match_length=E(t,r),t.match_length<=5&&(1===t.strategy||3===t.match_length&&t.strstart-t.match_start>4096)&&(t.match_length=2)),t.prev_length>=3&&t.match_length<=t.prev_length){i=t.strstart+t.lookahead-3,n=o._tr_tally(t,t.strstart-1-t.prev_match,t.prev_length-3),t.lookahead-=t.prev_length-1,t.prev_length-=2;do{++t.strstart<=i&&(t.ins_h=(t.ins_h<<t.hash_shift^t.window[t.strstart+3-1])&t.hash_mask,r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart)}while(0!==--t.prev_length);if(t.match_available=0,t.match_length=2,t.strstart++,n&&(w(t,!1),0===t.strm.avail_out))return 1}else if(t.match_available){if((n=o._tr_tally(t,0,t.window[t.strstart-1]))&&w(t,!1),t.strstart++,t.lookahead--,0===t.strm.avail_out)return 1}else t.match_available=1,t.strstart++,t.lookahead--}return t.match_available&&(n=o._tr_tally(t,0,t.window[t.strstart-1]),t.match_available=0),t.insert=t.strstart<2?t.strstart:2,4===e?(w(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(w(t,!1),0===t.strm.avail_out)?1:2}function A(t,e,r,n,i){this.good_length=t,this.max_lazy=e,this.nice_length=r,this.max_chain=n,this.func=i}function I(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=8,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new i.Buf16(1146),this.dyn_dtree=new i.Buf16(122),this.bl_tree=new i.Buf16(78),g(this.dyn_ltree),g(this.dyn_dtree),g(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new i.Buf16(16),this.heap=new i.Buf16(573),g(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new i.Buf16(573),g(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function P(t){var e;return t&&t.state?(t.total_in=t.total_out=0,t.data_type=2,(e=t.state).pending=0,e.pending_out=0,e.wrap<0&&(e.wrap=-e.wrap),e.status=e.wrap?42:p,t.adler=2===e.wrap?0:1,e.last_flush=0,o._tr_init(e),0):y(t,f)}function x(t){var e=P(t);return 0===e&&function(t){t.window_size=2*t.w_size,g(t.head),t.max_lazy_match=n[t.level].max_lazy,t.good_match=n[t.level].good_length,t.nice_match=n[t.level].nice_length,t.max_chain_length=n[t.level].max_chain,t.strstart=0,t.block_start=0,t.lookahead=0,t.insert=0,t.match_length=t.prev_length=2,t.match_available=0,t.ins_h=0}(t.state),e}function B(t,e,r,n,o,a){if(!t)return f;var s=1;if(-1===e&&(e=6),n<0?(s=0,n=-n):n>15&&(s=2,n-=16),o<1||o>9||8!==r||n<8||n>15||e<0||e>9||a<0||a>4)return y(t,f);8===n&&(n=9);var u=new I;return t.state=u,u.strm=t,u.wrap=s,u.gzhead=null,u.w_bits=n,u.w_size=1<<u.w_bits,u.w_mask=u.w_size-1,u.hash_bits=o+7,u.hash_size=1<<u.hash_bits,u.hash_mask=u.hash_size-1,u.hash_shift=~~((u.hash_bits+3-1)/3),u.window=new i.Buf8(2*u.w_size),u.head=new i.Buf16(u.hash_size),u.prev=new i.Buf16(u.w_size),u.lit_bufsize=1<<o+6,u.pending_buf_size=4*u.lit_bufsize,u.pending_buf=new i.Buf8(u.pending_buf_size),u.d_buf=1*u.lit_bufsize,u.l_buf=3*u.lit_bufsize,u.level=e,u.strategy=a,u.method=r,x(t)}n=[new A(0,0,0,0,function(t,e){var r=65535;for(r>t.pending_buf_size-5&&(r=t.pending_buf_size-5);;){if(t.lookahead<=1){if(k(t),0===t.lookahead&&0===e)return 1;if(0===t.lookahead)break}t.strstart+=t.lookahead,t.lookahead=0;var n=t.block_start+r;if((0===t.strstart||t.strstart>=n)&&(t.lookahead=t.strstart-n,t.strstart=n,w(t,!1),0===t.strm.avail_out))return 1;if(t.strstart-t.block_start>=t.w_size-l&&(w(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,4===e?(w(t,!0),0===t.strm.avail_out?3:4):(t.strstart>t.block_start&&(w(t,!1),t.strm.avail_out),1)}),new A(4,4,8,4,O),new A(4,5,16,8,O),new A(4,6,32,32,O),new A(4,4,16,16,T),new A(8,16,32,32,T),new A(8,16,128,128,T),new A(8,32,128,256,T),new A(32,128,258,1024,T),new A(32,258,258,4096,T)],e.deflateInit=function(t,e){return B(t,e,8,15,8,0)},e.deflateInit2=B,e.deflateReset=x,e.deflateResetKeep=P,e.deflateSetHeader=function(t,e){return t&&t.state?2!==t.state.wrap?f:(t.state.gzhead=e,0):f},e.deflate=function(t,e){var r,i,a,u;if(!t||!t.state||e>5||e<0)return t?y(t,f):f;if(i=t.state,!t.output||!t.input&&0!==t.avail_in||i.status===d&&4!==e)return y(t,0===t.avail_out?-5:f);if(i.strm=t,r=i.last_flush,i.last_flush=e,42===i.status)if(2===i.wrap)t.adler=0,m(i,31),m(i,139),m(i,8),i.gzhead?(m(i,(i.gzhead.text?1:0)+(i.gzhead.hcrc?2:0)+(i.gzhead.extra?4:0)+(i.gzhead.name?8:0)+(i.gzhead.comment?16:0)),m(i,255&i.gzhead.time),m(i,i.gzhead.time>>8&255),m(i,i.gzhead.time>>16&255),m(i,i.gzhead.time>>24&255),m(i,9===i.level?2:i.strategy>=2||i.level<2?4:0),m(i,255&i.gzhead.os),i.gzhead.extra&&i.gzhead.extra.length&&(m(i,255&i.gzhead.extra.length),m(i,i.gzhead.extra.length>>8&255)),i.gzhead.hcrc&&(t.adler=s(t.adler,i.pending_buf,i.pending,0)),i.gzindex=0,i.status=69):(m(i,0),m(i,0),m(i,0),m(i,0),m(i,0),m(i,9===i.level?2:i.strategy>=2||i.level<2?4:0),m(i,3),i.status=p);else{var l=8+(i.w_bits-8<<4)<<8;l|=(i.strategy>=2||i.level<2?0:i.level<6?1:6===i.level?2:3)<<6,0!==i.strstart&&(l|=32),l+=31-l%31,i.status=p,S(i,l),0!==i.strstart&&(S(i,t.adler>>>16),S(i,65535&t.adler)),t.adler=1}if(69===i.status)if(i.gzhead.extra){for(a=i.pending;i.gzindex<(65535&i.gzhead.extra.length)&&(i.pending!==i.pending_buf_size||(i.gzhead.hcrc&&i.pending>a&&(t.adler=s(t.adler,i.pending_buf,i.pending-a,a)),v(t),a=i.pending,i.pending!==i.pending_buf_size));)m(i,255&i.gzhead.extra[i.gzindex]),i.gzindex++;i.gzhead.hcrc&&i.pending>a&&(t.adler=s(t.adler,i.pending_buf,i.pending-a,a)),i.gzindex===i.gzhead.extra.length&&(i.gzindex=0,i.status=73)}else i.status=73;if(73===i.status)if(i.gzhead.name){a=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>a&&(t.adler=s(t.adler,i.pending_buf,i.pending-a,a)),v(t),a=i.pending,i.pending===i.pending_buf_size)){u=1;break}u=i.gzindex<i.gzhead.name.length?255&i.gzhead.name.charCodeAt(i.gzindex++):0,m(i,u)}while(0!==u);i.gzhead.hcrc&&i.pending>a&&(t.adler=s(t.adler,i.pending_buf,i.pending-a,a)),0===u&&(i.gzindex=0,i.status=91)}else i.status=91;if(91===i.status)if(i.gzhead.comment){a=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>a&&(t.adler=s(t.adler,i.pending_buf,i.pending-a,a)),v(t),a=i.pending,i.pending===i.pending_buf_size)){u=1;break}u=i.gzindex<i.gzhead.comment.length?255&i.gzhead.comment.charCodeAt(i.gzindex++):0,m(i,u)}while(0!==u);i.gzhead.hcrc&&i.pending>a&&(t.adler=s(t.adler,i.pending_buf,i.pending-a,a)),0===u&&(i.status=h)}else i.status=h;if(i.status===h&&(i.gzhead.hcrc?(i.pending+2>i.pending_buf_size&&v(t),i.pending+2<=i.pending_buf_size&&(m(i,255&t.adler),m(i,t.adler>>8&255),t.adler=0,i.status=p)):i.status=p),0!==i.pending){if(v(t),0===t.avail_out)return i.last_flush=-1,0}else if(0===t.avail_in&&b(e)<=b(r)&&4!==e)return y(t,-5);if(i.status===d&&0!==t.avail_in)return y(t,-5);if(0!==t.avail_in||0!==i.lookahead||0!==e&&i.status!==d){var _=2===i.strategy?function(t,e){for(var r;;){if(0===t.lookahead&&(k(t),0===t.lookahead)){if(0===e)return 1;break}if(t.match_length=0,r=o._tr_tally(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++,r&&(w(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,4===e?(w(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(w(t,!1),0===t.strm.avail_out)?1:2}(i,e):3===i.strategy?function(t,e){for(var r,n,i,a,s=t.window;;){if(t.lookahead<=c){if(k(t),t.lookahead<=c&&0===e)return 1;if(0===t.lookahead)break}if(t.match_length=0,t.lookahead>=3&&t.strstart>0&&(n=s[i=t.strstart-1])===s[++i]&&n===s[++i]&&n===s[++i]){a=t.strstart+c;do{}while(n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&i<a);t.match_length=c-(a-i),t.match_length>t.lookahead&&(t.match_length=t.lookahead)}if(t.match_length>=3?(r=o._tr_tally(t,1,t.match_length-3),t.lookahead-=t.match_length,t.strstart+=t.match_length,t.match_length=0):(r=o._tr_tally(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++),r&&(w(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,4===e?(w(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(w(t,!1),0===t.strm.avail_out)?1:2}(i,e):n[i.level].func(i,e);if(3!==_&&4!==_||(i.status=d),1===_||3===_)return 0===t.avail_out&&(i.last_flush=-1),0;if(2===_&&(1===e?o._tr_align(i):5!==e&&(o._tr_stored_block(i,0,0,!1),3===e&&(g(i.head),0===i.lookahead&&(i.strstart=0,i.block_start=0,i.insert=0))),v(t),0===t.avail_out))return i.last_flush=-1,0}return 4!==e?0:i.wrap<=0?1:(2===i.wrap?(m(i,255&t.adler),m(i,t.adler>>8&255),m(i,t.adler>>16&255),m(i,t.adler>>24&255),m(i,255&t.total_in),m(i,t.total_in>>8&255),m(i,t.total_in>>16&255),m(i,t.total_in>>24&255)):(S(i,t.adler>>>16),S(i,65535&t.adler)),v(t),i.wrap>0&&(i.wrap=-i.wrap),0!==i.pending?0:1)},e.deflateEnd=function(t){var e;return t&&t.state?42!==(e=t.state.status)&&69!==e&&73!==e&&91!==e&&e!==h&&e!==p&&e!==d?y(t,f):(t.state=null,e===p?y(t,-3):0):f},e.deflateSetDictionary=function(t,e){var r,n,o,s,u,c,l,h,p=e.length;if(!t||!t.state)return f;if(2===(s=(r=t.state).wrap)||1===s&&42!==r.status||r.lookahead)return f;for(1===s&&(t.adler=a(t.adler,e,p,0)),r.wrap=0,p>=r.w_size&&(0===s&&(g(r.head),r.strstart=0,r.block_start=0,r.insert=0),h=new i.Buf8(r.w_size),i.arraySet(h,e,p-r.w_size,r.w_size,0),e=h,p=r.w_size),u=t.avail_in,c=t.next_in,l=t.input,t.avail_in=p,t.next_in=0,t.input=e,k(r);r.lookahead>=3;){n=r.strstart,o=r.lookahead-2;do{r.ins_h=(r.ins_h<<r.hash_shift^r.window[n+3-1])&r.hash_mask,r.prev[n&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=n,n++}while(--o);r.strstart=n,r.lookahead=2,k(r)}return r.strstart+=r.lookahead,r.block_start=r.strstart,r.insert=r.lookahead,r.lookahead=0,r.match_length=r.prev_length=2,r.match_available=0,t.next_in=c,t.input=l,t.avail_in=u,r.wrap=s,0},e.deflateInfo="pako deflate (from Nodeca project)"},8452:(t,e,r)=>{var n=r(1189),i="function"==typeof Symbol&&"symbol"==typeof Symbol("foo"),o=Object.prototype.toString,a=Array.prototype.concat,s=r(41),u=r(592)(),f=function(t,e,r,n){if(e in t)if(!0===n){if(t[e]===r)return}else if(!function(t){return"function"==typeof t&&"[object Function]"===o.call(t)}(n)||!n())return;u?s(t,e,r,!0):s(t,e,r)},c=function(t,e){var r=arguments.length>2?arguments[2]:{},o=n(e);i&&(o=a.call(o,Object.getOwnPropertySymbols(e)));for(var s=0;s<o.length;s+=1)f(t,o[s],e[o[s]],r[o[s]])};c.supportsDescriptors=!!u,t.exports=c},8460:()=>{},8510:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.encodeToCurve=e.hashToCurve=e.secp256k1_hasher=e.schnorr=e.secp256k1=void 0;const n=r(7076),i=r(9175),o=r(3562),a=r(1761),s=r(4967),u=r(1705),f=r(8627),c={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},l={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]},h=BigInt(0),p=BigInt(1),d=BigInt(2),y=(0,s.Field)(c.p,{sqrt:function(t){const e=c.p,r=BigInt(3),n=BigInt(6),i=BigInt(11),o=BigInt(22),a=BigInt(23),u=BigInt(44),f=BigInt(88),l=t*t*t%e,h=l*l*t%e,p=(0,s.pow2)(h,r,e)*h%e,b=(0,s.pow2)(p,r,e)*h%e,g=(0,s.pow2)(b,d,e)*l%e,v=(0,s.pow2)(g,i,e)*g%e,w=(0,s.pow2)(v,o,e)*v%e,m=(0,s.pow2)(w,u,e)*w%e,S=(0,s.pow2)(m,f,e)*m%e,_=(0,s.pow2)(S,u,e)*w%e,E=(0,s.pow2)(_,r,e)*h%e,k=(0,s.pow2)(E,a,e)*v%e,O=(0,s.pow2)(k,n,e)*l%e,T=(0,s.pow2)(O,d,e);if(!y.eql(y.sqr(T),t))throw new Error("Cannot find square root");return T}});e.secp256k1=(0,o.createCurve)({...c,Fp:y,lowS:!0,endo:l},n.sha256);const b={};function g(t,...e){let r=b[t];if(void 0===r){const e=(0,n.sha256)((0,f.utf8ToBytes)(t));r=(0,f.concatBytes)(e,e),b[t]=r}return(0,n.sha256)((0,f.concatBytes)(r,...e))}const v=t=>t.toBytes(!0).slice(1),w=(()=>e.secp256k1.Point)(),m=t=>t%d===h;function S(t){const{Fn:e,BASE:r}=w,n=(0,u._normFnElement)(e,t),i=r.multiply(n);return{scalar:m(i.y)?n:e.neg(n),bytes:v(i)}}function _(t){const e=y;if(!e.isValidNot0(t))throw new Error("invalid x: Fail if x ≥ p");const r=e.create(t*t),n=e.create(r*t+BigInt(7));let i=e.sqrt(n);m(i)||(i=e.neg(i));const o=w.fromAffine({x:t,y:i});return o.assertValidity(),o}const E=f.bytesToNumberBE;function k(...t){return w.Fn.create(E(g("BIP0340/challenge",...t)))}function O(t){return S(t).bytes}function T(t,e,r=(0,i.randomBytes)(32)){const{Fn:n}=w,o=(0,f.ensureBytes)("message",t),{bytes:a,scalar:s}=S(e),u=(0,f.ensureBytes)("auxRand",r,32),c=n.toBytes(s^E(g("BIP0340/aux",u))),l=g("BIP0340/nonce",c,a,o),{bytes:h,scalar:p}=S(l),d=k(h,a,o),y=new Uint8Array(64);if(y.set(h,0),y.set(n.toBytes(n.create(p+d*s)),32),!A(y,o,a))throw new Error("sign: Invalid signature produced");return y}function A(t,e,r){const{Fn:n,BASE:i}=w,o=(0,f.ensureBytes)("signature",t,64),a=(0,f.ensureBytes)("message",e),s=(0,f.ensureBytes)("publicKey",r,32);try{const t=_(E(s)),e=E(o.subarray(0,32));if(!(0,f.inRange)(e,p,c.p))return!1;const r=E(o.subarray(32,64));if(!(0,f.inRange)(r,p,c.n))return!1;const u=k(n.toBytes(e),v(t),a),l=i.multiplyUnsafe(r).add(t.multiplyUnsafe(n.neg(u))),{x:h,y:d}=l.toAffine();return!(l.is0()||!m(d)||h!==e)}catch(t){return!1}}e.schnorr=(()=>{const t=(t=(0,i.randomBytes)(48))=>(0,s.mapHashToField)(t,c.n);return e.secp256k1.utils.randomSecretKey,{keygen:function(e){const r=t(e);return{secretKey:r,publicKey:O(r)}},getPublicKey:O,sign:T,verify:A,Point:w,utils:{randomSecretKey:t,randomPrivateKey:t,taggedHash:g,lift_x:_,pointToBytes:v,numberToBytesBE:f.numberToBytesBE,bytesToNumberBE:f.bytesToNumberBE,mod:s.mod},lengths:{secretKey:32,publicKey:32,publicKeyHasPrefix:!1,signature:64,seed:48}}})();const I=(()=>(0,a.isogenyMap)(y,[["0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa8c7","0x7d3d4c80bc321d5b9f315cea7fd44c5d595d2fc0bf63b92dfff1044f17c6581","0x534c328d23f234e6e2a413deca25caece4506144037c40314ecbd0b53d9dd262","0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa88c"],["0xd35771193d94918a9ca34ccbb7b640dd86cd409542f8487d9fe6b745781eb49b","0xedadc6f64383dc1df7c4b2d51b54225406d36b641f5e41bbc52a56612a8c6d14","0x0000000000000000000000000000000000000000000000000000000000000001"],["0x4bda12f684bda12f684bda12f684bda12f684bda12f684bda12f684b8e38e23c","0xc75e0c32d5cb7c0fa9d0a54b12a0a6d5647ab046d686da6fdffc90fc201d71a3","0x29a6194691f91a73715209ef6512e576722830a201be2018a765e85a9ecee931","0x2f684bda12f684bda12f684bda12f684bda12f684bda12f684bda12f38e38d84"],["0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffff93b","0x7a06534bb8bdb49fd5e9e6632722c2989467c1bfc8e8d978dfb425d2685c2573","0x6484aa716545ca2cf3a70c3fa8fe337e0a3d21162f0d6299a7bf8192bfd2a76f","0x0000000000000000000000000000000000000000000000000000000000000001"]].map(t=>t.map(t=>BigInt(t)))))(),P=(()=>(0,u.mapToCurveSimpleSWU)(y,{A:BigInt("0x3f8731abdd661adca08a5558f0f5d272e953d363cb6f0e5d405447c01a444533"),B:BigInt("1771"),Z:y.create(BigInt("-11"))}))();e.secp256k1_hasher=(0,a.createHasher)(e.secp256k1.Point,t=>{const{x:e,y:r}=P(y.create(t[0]));return I(e,r)},{DST:"secp256k1_XMD:SHA-256_SSWU_RO_",encodeDST:"secp256k1_XMD:SHA-256_SSWU_NU_",p:y.ORDER,m:1,k:128,expand:"xmd",hash:n.sha256}),e.hashToCurve=e.secp256k1_hasher.hashToCurve,e.encodeToCurve=e.secp256k1_hasher.encodeToCurve},8559:(t,e,r)=>{var n=r(5606),i=r(8287).Buffer,o=r(8310).Transform,a=r(5974),s=r(537),u=r(4148).ok,f=r(8287).kMaxLength,c="Cannot create final Buffer. It would be larger than 0x"+f.toString(16)+" bytes";a.Z_MIN_WINDOWBITS=8,a.Z_MAX_WINDOWBITS=15,a.Z_DEFAULT_WINDOWBITS=15,a.Z_MIN_CHUNK=64,a.Z_MAX_CHUNK=1/0,a.Z_DEFAULT_CHUNK=16384,a.Z_MIN_MEMLEVEL=1,a.Z_MAX_MEMLEVEL=9,a.Z_DEFAULT_MEMLEVEL=8,a.Z_MIN_LEVEL=-1,a.Z_MAX_LEVEL=9,a.Z_DEFAULT_LEVEL=a.Z_DEFAULT_COMPRESSION;for(var l=Object.keys(a),h=0;h<l.length;h++){var p=l[h];p.match(/^Z/)&&Object.defineProperty(e,p,{enumerable:!0,value:a[p],writable:!1})}for(var d={Z_OK:a.Z_OK,Z_STREAM_END:a.Z_STREAM_END,Z_NEED_DICT:a.Z_NEED_DICT,Z_ERRNO:a.Z_ERRNO,Z_STREAM_ERROR:a.Z_STREAM_ERROR,Z_DATA_ERROR:a.Z_DATA_ERROR,Z_MEM_ERROR:a.Z_MEM_ERROR,Z_BUF_ERROR:a.Z_BUF_ERROR,Z_VERSION_ERROR:a.Z_VERSION_ERROR},y=Object.keys(d),b=0;b<y.length;b++){var g=y[b];d[d[g]]=g}function v(t,e,r){var n=[],o=0;function a(){for(var e;null!==(e=t.read());)n.push(e),o+=e.length;t.once("readable",a)}function s(){var e,a=null;o>=f?a=new RangeError(c):e=i.concat(n,o),n=[],t.close(),r(a,e)}t.on("error",function(e){t.removeListener("end",s),t.removeListener("readable",a),r(e)}),t.on("end",s),t.end(e),a()}function w(t,e){if("string"==typeof e&&(e=i.from(e)),!i.isBuffer(e))throw new TypeError("Not a string or buffer");var r=t._finishFlushFlag;return t._processChunk(e,r)}function m(t){if(!(this instanceof m))return new m(t);I.call(this,t,a.DEFLATE)}function S(t){if(!(this instanceof S))return new S(t);I.call(this,t,a.INFLATE)}function _(t){if(!(this instanceof _))return new _(t);I.call(this,t,a.GZIP)}function E(t){if(!(this instanceof E))return new E(t);I.call(this,t,a.GUNZIP)}function k(t){if(!(this instanceof k))return new k(t);I.call(this,t,a.DEFLATERAW)}function O(t){if(!(this instanceof O))return new O(t);I.call(this,t,a.INFLATERAW)}function T(t){if(!(this instanceof T))return new T(t);I.call(this,t,a.UNZIP)}function A(t){return t===a.Z_NO_FLUSH||t===a.Z_PARTIAL_FLUSH||t===a.Z_SYNC_FLUSH||t===a.Z_FULL_FLUSH||t===a.Z_FINISH||t===a.Z_BLOCK}function I(t,r){var n=this;if(this._opts=t=t||{},this._chunkSize=t.chunkSize||e.Z_DEFAULT_CHUNK,o.call(this,t),t.flush&&!A(t.flush))throw new Error("Invalid flush flag: "+t.flush);if(t.finishFlush&&!A(t.finishFlush))throw new Error("Invalid flush flag: "+t.finishFlush);if(this._flushFlag=t.flush||a.Z_NO_FLUSH,this._finishFlushFlag=void 0!==t.finishFlush?t.finishFlush:a.Z_FINISH,t.chunkSize&&(t.chunkSize<e.Z_MIN_CHUNK||t.chunkSize>e.Z_MAX_CHUNK))throw new Error("Invalid chunk size: "+t.chunkSize);if(t.windowBits&&(t.windowBits<e.Z_MIN_WINDOWBITS||t.windowBits>e.Z_MAX_WINDOWBITS))throw new Error("Invalid windowBits: "+t.windowBits);if(t.level&&(t.level<e.Z_MIN_LEVEL||t.level>e.Z_MAX_LEVEL))throw new Error("Invalid compression level: "+t.level);if(t.memLevel&&(t.memLevel<e.Z_MIN_MEMLEVEL||t.memLevel>e.Z_MAX_MEMLEVEL))throw new Error("Invalid memLevel: "+t.memLevel);if(t.strategy&&t.strategy!=e.Z_FILTERED&&t.strategy!=e.Z_HUFFMAN_ONLY&&t.strategy!=e.Z_RLE&&t.strategy!=e.Z_FIXED&&t.strategy!=e.Z_DEFAULT_STRATEGY)throw new Error("Invalid strategy: "+t.strategy);if(t.dictionary&&!i.isBuffer(t.dictionary))throw new Error("Invalid dictionary: it should be a Buffer instance");this._handle=new a.Zlib(r);var s=this;this._hadError=!1,this._handle.onerror=function(t,r){P(s),s._hadError=!0;var n=new Error(t);n.errno=r,n.code=e.codes[r],s.emit("error",n)};var u=e.Z_DEFAULT_COMPRESSION;"number"==typeof t.level&&(u=t.level);var f=e.Z_DEFAULT_STRATEGY;"number"==typeof t.strategy&&(f=t.strategy),this._handle.init(t.windowBits||e.Z_DEFAULT_WINDOWBITS,u,t.memLevel||e.Z_DEFAULT_MEMLEVEL,f,t.dictionary),this._buffer=i.allocUnsafe(this._chunkSize),this._offset=0,this._level=u,this._strategy=f,this.once("end",this.close),Object.defineProperty(this,"_closed",{get:function(){return!n._handle},configurable:!0,enumerable:!0})}function P(t,e){e&&n.nextTick(e),t._handle&&(t._handle.close(),t._handle=null)}function x(t){t.emit("close")}Object.defineProperty(e,"codes",{enumerable:!0,value:Object.freeze(d),writable:!1}),e.Deflate=m,e.Inflate=S,e.Gzip=_,e.Gunzip=E,e.DeflateRaw=k,e.InflateRaw=O,e.Unzip=T,e.createDeflate=function(t){return new m(t)},e.createInflate=function(t){return new S(t)},e.createDeflateRaw=function(t){return new k(t)},e.createInflateRaw=function(t){return new O(t)},e.createGzip=function(t){return new _(t)},e.createGunzip=function(t){return new E(t)},e.createUnzip=function(t){return new T(t)},e.deflate=function(t,e,r){return"function"==typeof e&&(r=e,e={}),v(new m(e),t,r)},e.deflateSync=function(t,e){return w(new m(e),t)},e.gzip=function(t,e,r){return"function"==typeof e&&(r=e,e={}),v(new _(e),t,r)},e.gzipSync=function(t,e){return w(new _(e),t)},e.deflateRaw=function(t,e,r){return"function"==typeof e&&(r=e,e={}),v(new k(e),t,r)},e.deflateRawSync=function(t,e){return w(new k(e),t)},e.unzip=function(t,e,r){return"function"==typeof e&&(r=e,e={}),v(new T(e),t,r)},e.unzipSync=function(t,e){return w(new T(e),t)},e.inflate=function(t,e,r){return"function"==typeof e&&(r=e,e={}),v(new S(e),t,r)},e.inflateSync=function(t,e){return w(new S(e),t)},e.gunzip=function(t,e,r){return"function"==typeof e&&(r=e,e={}),v(new E(e),t,r)},e.gunzipSync=function(t,e){return w(new E(e),t)},e.inflateRaw=function(t,e,r){return"function"==typeof e&&(r=e,e={}),v(new O(e),t,r)},e.inflateRawSync=function(t,e){return w(new O(e),t)},s.inherits(I,o),I.prototype.params=function(t,r,i){if(t<e.Z_MIN_LEVEL||t>e.Z_MAX_LEVEL)throw new RangeError("Invalid compression level: "+t);if(r!=e.Z_FILTERED&&r!=e.Z_HUFFMAN_ONLY&&r!=e.Z_RLE&&r!=e.Z_FIXED&&r!=e.Z_DEFAULT_STRATEGY)throw new TypeError("Invalid strategy: "+r);if(this._level!==t||this._strategy!==r){var o=this;this.flush(a.Z_SYNC_FLUSH,function(){u(o._handle,"zlib binding closed"),o._handle.params(t,r),o._hadError||(o._level=t,o._strategy=r,i&&i())})}else n.nextTick(i)},I.prototype.reset=function(){return u(this._handle,"zlib binding closed"),this._handle.reset()},I.prototype._flush=function(t){this._transform(i.alloc(0),"",t)},I.prototype.flush=function(t,e){var r=this,o=this._writableState;("function"==typeof t||void 0===t&&!e)&&(e=t,t=a.Z_FULL_FLUSH),o.ended?e&&n.nextTick(e):o.ending?e&&this.once("end",e):o.needDrain?e&&this.once("drain",function(){return r.flush(t,e)}):(this._flushFlag=t,this.write(i.alloc(0),"",e))},I.prototype.close=function(t){P(this,t),n.nextTick(x,this)},I.prototype._transform=function(t,e,r){var n,o=this._writableState,s=(o.ending||o.ended)&&(!t||o.length===t.length);return null===t||i.isBuffer(t)?this._handle?(s?n=this._finishFlushFlag:(n=this._flushFlag,t.length>=o.length&&(this._flushFlag=this._opts.flush||a.Z_NO_FLUSH)),void this._processChunk(t,n,r)):r(new Error("zlib binding closed")):r(new Error("invalid input"))},I.prototype._processChunk=function(t,e,r){var n=t&&t.length,o=this._chunkSize-this._offset,a=0,s=this,l="function"==typeof r;if(!l){var h,p=[],d=0;this.on("error",function(t){h=t}),u(this._handle,"zlib binding closed");do{var y=this._handle.writeSync(e,t,a,n,this._buffer,this._offset,o)}while(!this._hadError&&v(y[0],y[1]));if(this._hadError)throw h;if(d>=f)throw P(this),new RangeError(c);var b=i.concat(p,d);return P(this),b}u(this._handle,"zlib binding closed");var g=this._handle.write(e,t,a,n,this._buffer,this._offset,o);function v(f,c){if(this&&(this.buffer=null,this.callback=null),!s._hadError){var h=o-c;if(u(h>=0,"have should not go down"),h>0){var y=s._buffer.slice(s._offset,s._offset+h);s._offset+=h,l?s.push(y):(p.push(y),d+=y.length)}if((0===c||s._offset>=s._chunkSize)&&(o=s._chunkSize,s._offset=0,s._buffer=i.allocUnsafe(s._chunkSize)),0===c){if(a+=n-f,n=f,!l)return!0;var b=s._handle.write(e,t,a,n,s._buffer,s._offset,s._chunkSize);return b.callback=v,void(b.buffer=t)}if(!l)return!1;r()}}g.buffer=t,g.callback=v},s.inherits(m,I),s.inherits(S,I),s.inherits(_,I),s.inherits(E,I),s.inherits(k,I),s.inherits(O,I),s.inherits(T,I)},8627:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.notImplemented=e.bitMask=e.utf8ToBytes=e.randomBytes=e.isBytes=e.hexToBytes=e.concatBytes=e.bytesToUtf8=e.bytesToHex=e.anumber=e.abytes=void 0,e.abool=function(t,e){if("boolean"!=typeof e)throw new Error(t+" boolean expected, got "+e)},e._abool2=function(t,e=""){if("boolean"!=typeof t)throw new Error((e&&`"${e}"`)+"expected boolean, got type="+typeof t);return t},e._abytes2=function(t,e,r=""){const i=(0,n.isBytes)(t),o=t?.length,a=void 0!==e;if(!i||a&&o!==e)throw new Error((r&&`"${r}" `)+"expected Uint8Array"+(a?` of length ${e}`:"")+", got "+(i?`length=${o}`:"type="+typeof t));return t},e.numberToHexUnpadded=s,e.hexToNumber=u,e.bytesToNumberBE=function(t){return u((0,n.bytesToHex)(t))},e.bytesToNumberLE=function(t){return(0,n.abytes)(t),u((0,n.bytesToHex)(Uint8Array.from(t).reverse()))},e.numberToBytesBE=f,e.numberToBytesLE=function(t,e){return f(t,e).reverse()},e.numberToVarBytesBE=function(t){return(0,n.hexToBytes)(s(t))},e.ensureBytes=function(t,e,r){let i;if("string"==typeof e)try{i=(0,n.hexToBytes)(e)}catch(e){throw new Error(t+" must be hex string or Uint8Array, cause: "+e)}else{if(!(0,n.isBytes)(e))throw new Error(t+" must be hex string or Uint8Array");i=Uint8Array.from(e)}const o=i.length;if("number"==typeof r&&o!==r)throw new Error(t+" of length "+r+" expected, got "+o);return i},e.equalBytes=function(t,e){if(t.length!==e.length)return!1;let r=0;for(let n=0;n<t.length;n++)r|=t[n]^e[n];return 0===r},e.copyBytes=function(t){return Uint8Array.from(t)},e.asciiToBytes=function(t){return Uint8Array.from(t,(e,r)=>{const n=e.charCodeAt(0);if(1!==e.length||n>127)throw new Error(`string contains non-ASCII character "${t[r]}" with code ${n} at position ${r}`);return n})},e.inRange=l,e.aInRange=function(t,e,r,n){if(!l(e,r,n))throw new Error("expected valid "+t+": "+r+" <= n < "+n+", got "+e)},e.bitLen=function(t){let e;for(e=0;t>o;t>>=a,e+=1);return e},e.bitGet=function(t,e){return t>>BigInt(e)&a},e.bitSet=function(t,e,r){return t|(r?a:o)<<BigInt(e)},e.createHmacDrbg=function(t,e,r){if("number"!=typeof t||t<2)throw new Error("hashLen must be a number");if("number"!=typeof e||e<2)throw new Error("qByteLen must be a number");if("function"!=typeof r)throw new Error("hmacFn must be a function");const i=t=>new Uint8Array(t),o=t=>Uint8Array.of(t);let a=i(t),s=i(t),u=0;const f=()=>{a.fill(1),s.fill(0),u=0},c=(...t)=>r(s,a,...t),l=(t=i(0))=>{s=c(o(0),t),a=c(),0!==t.length&&(s=c(o(1),t),a=c())},h=()=>{if(u++>=1e3)throw new Error("drbg: tried 1000 values");let t=0;const r=[];for(;t<e;){a=c();const e=a.slice();r.push(e),t+=a.length}return(0,n.concatBytes)(...r)};return(t,e)=>{let r;for(f(),l(t);!(r=e(h()));)l();return f(),r}},e.validateObject=function(t,e,r={}){const n=(e,r,n)=>{const i=h[r];if("function"!=typeof i)throw new Error("invalid validator function");const o=t[e];if(!(n&&void 0===o||i(o,t)))throw new Error("param "+String(e)+" is invalid. Expected "+r+", got "+o)};for(const[t,r]of Object.entries(e))n(t,r,!1);for(const[t,e]of Object.entries(r))n(t,e,!0);return t},e.isHash=function(t){return"function"==typeof t&&Number.isSafeInteger(t.outputLen)},e._validateObject=function(t,e,r={}){if(!t||"object"!=typeof t)throw new Error("expected valid options object");function n(e,r,n){const i=t[e];if(n&&void 0===i)return;const o=typeof i;if(o!==r||null===i)throw new Error(`param "${e}" is invalid: expected ${r}, got ${o}`)}Object.entries(e).forEach(([t,e])=>n(t,e,!1)),Object.entries(r).forEach(([t,e])=>n(t,e,!0))},e.memoized=function(t){const e=new WeakMap;return(r,...n)=>{const i=e.get(r);if(void 0!==i)return i;const o=t(r,...n);return e.set(r,o),o}};const n=r(9175);var i=r(9175);Object.defineProperty(e,"abytes",{enumerable:!0,get:function(){return i.abytes}}),Object.defineProperty(e,"anumber",{enumerable:!0,get:function(){return i.anumber}}),Object.defineProperty(e,"bytesToHex",{enumerable:!0,get:function(){return i.bytesToHex}}),Object.defineProperty(e,"bytesToUtf8",{enumerable:!0,get:function(){return i.bytesToUtf8}}),Object.defineProperty(e,"concatBytes",{enumerable:!0,get:function(){return i.concatBytes}}),Object.defineProperty(e,"hexToBytes",{enumerable:!0,get:function(){return i.hexToBytes}}),Object.defineProperty(e,"isBytes",{enumerable:!0,get:function(){return i.isBytes}}),Object.defineProperty(e,"randomBytes",{enumerable:!0,get:function(){return i.randomBytes}}),Object.defineProperty(e,"utf8ToBytes",{enumerable:!0,get:function(){return i.utf8ToBytes}});const o=BigInt(0),a=BigInt(1);function s(t){const e=t.toString(16);return 1&e.length?"0"+e:e}function u(t){if("string"!=typeof t)throw new Error("hex string expected, got "+typeof t);return""===t?o:BigInt("0x"+t)}function f(t,e){return(0,n.hexToBytes)(t.toString(16).padStart(2*e,"0"))}const c=t=>"bigint"==typeof t&&o<=t;function l(t,e,r){return c(t)&&c(e)&&c(r)&&e<=t&&t<r}e.bitMask=t=>(a<<BigInt(t))-a;const h={bigint:t=>"bigint"==typeof t,function:t=>"function"==typeof t,boolean:t=>"boolean"==typeof t,string:t=>"string"==typeof t,stringOrUint8Array:t=>"string"==typeof t||(0,n.isBytes)(t),isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,e)=>e.Fp.isValid(t),hash:t=>"function"==typeof t&&Number.isSafeInteger(t.outputLen)};e.notImplemented=()=>{throw new Error("not implemented")}},8648:t=>{t.exports="undefined"!=typeof Reflect&&Reflect.getPrototypeOf||null},8676:(t,e,r)=>{var n=r(1061),i=r(2113),o=n.tfJSON,a=n.TfTypeError,s=n.TfPropertyTypeError,u=n.tfSubError,f=n.getValueTypeName,c={arrayOf:function(t,e){function r(r,n){return!!i.Array(r)&&!i.Nil(r)&&!(void 0!==e.minLength&&r.length<e.minLength)&&!(void 0!==e.maxLength&&r.length>e.maxLength)&&(void 0===e.length||r.length===e.length)&&r.every(function(e,r){try{return h(t,e,n)}catch(t){throw u(t,r)}})}return t=l(t),e=e||{},r.toJSON=function(){var r="["+o(t)+"]";return void 0!==e.length?r+="{"+e.length+"}":void 0===e.minLength&&void 0===e.maxLength||(r+="{"+(void 0===e.minLength?0:e.minLength)+","+(void 0===e.maxLength?1/0:e.maxLength)+"}"),r},r},maybe:function t(e){function r(r,n){return i.Nil(r)||e(r,n,t)}return e=l(e),r.toJSON=function(){return"?"+o(e)},r},map:function(t,e){function r(r,n){if(!i.Object(r))return!1;if(i.Nil(r))return!1;for(var o in r){try{e&&h(e,o,n)}catch(t){throw u(t,o,"key")}try{var a=r[o];h(t,a,n)}catch(t){throw u(t,o)}}return!0}return t=l(t),e&&(e=l(e)),r.toJSON=e?function(){return"{"+o(e)+": "+o(t)+"}"}:function(){return"{"+o(t)+"}"},r},object:function(t){var e={};for(var r in t)e[r]=l(t[r]);function n(t,r){if(!i.Object(t))return!1;if(i.Nil(t))return!1;var n;try{for(n in e)h(e[n],t[n],r)}catch(t){throw u(t,n)}if(r)for(n in t)if(!e[n])throw new s(void 0,n);return!0}return n.toJSON=function(){return o(e)},n},anyOf:function(){var t=[].slice.call(arguments).map(l);function e(e,r){return t.some(function(t){try{return h(t,e,r)}catch(t){return!1}})}return e.toJSON=function(){return t.map(o).join("|")},e},allOf:function(){var t=[].slice.call(arguments).map(l);function e(e,r){return t.every(function(t){try{return h(t,e,r)}catch(t){return!1}})}return e.toJSON=function(){return t.map(o).join(" & ")},e},quacksLike:function(t){function e(e){return t===f(e)}return e.toJSON=function(){return t},e},tuple:function(){var t=[].slice.call(arguments).map(l);function e(e,r){return!i.Nil(e)&&!i.Nil(e.length)&&(!r||e.length===t.length)&&t.every(function(t,n){try{return h(t,e[n],r)}catch(t){throw u(t,n)}})}return e.toJSON=function(){return"("+t.map(o).join(", ")+")"},e},value:function(t){function e(e){return e===t}return e.toJSON=function(){return t},e}};function l(t){if(i.String(t))return"?"===t[0]?c.maybe(t.slice(1)):i[t]||c.quacksLike(t);if(t&&i.Object(t)){if(i.Array(t)){if(1!==t.length)throw new TypeError("Expected compile() parameter of type Array of length 1");return c.arrayOf(t[0])}return c.object(t)}return i.Function(t)?t:c.value(t)}function h(t,e,r,n){if(i.Function(t)){if(t(e,r))return!0;throw new a(n||t,e)}return h(l(t),e,r)}for(var p in c.oneOf=c.anyOf,i)h[p]=i[p];for(p in c)h[p]=c[p];var d=r(9542);for(p in d)h[p]=d[p];h.compile=l,h.TfTypeError=a,h.TfPropertyTypeError=s,t.exports=h},8700:(t,e,r)=>{e.dg=void 0;var n=r(5170);Object.defineProperty(e,"dg",{enumerable:!0,get:function(){return n.ECPairFactory}})},8775:(t,e,r)=>{var n=r(2260).F.ERR_INVALID_OPT_VALUE;t.exports={getHighWaterMark:function(t,e,r,i){var o=function(t,e,r){return null!=t.highWaterMark?t.highWaterMark:e?t[r]:null}(e,i,r);if(null!=o){if(!isFinite(o)||Math.floor(o)!==o||o<0)throw new n(i?r:"highWaterMark",o);return Math.floor(o)}return t.objectMode?16:16384}}},8875:(t,e,r)=>{var n;if(!Object.keys){var i=Object.prototype.hasOwnProperty,o=Object.prototype.toString,a=r(1093),s=Object.prototype.propertyIsEnumerable,u=!s.call({toString:null},"toString"),f=s.call(function(){},"prototype"),c=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],l=function(t){var e=t.constructor;return e&&e.prototype===t},h={$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},p=function(){if("undefined"==typeof window)return!1;for(var t in window)try{if(!h["$"+t]&&i.call(window,t)&&null!==window[t]&&"object"==typeof window[t])try{l(window[t])}catch(t){return!0}}catch(t){return!0}return!1}();n=function(t){var e=null!==t&&"object"==typeof t,r="[object Function]"===o.call(t),n=a(t),s=e&&"[object String]"===o.call(t),h=[];if(!e&&!r&&!n)throw new TypeError("Object.keys called on a non-object");var d=f&&r;if(s&&t.length>0&&!i.call(t,0))for(var y=0;y<t.length;++y)h.push(String(y));if(n&&t.length>0)for(var b=0;b<t.length;++b)h.push(String(b));else for(var g in t)d&&"prototype"===g||!i.call(t,g)||h.push(String(g));if(u)for(var v=function(t){if("undefined"==typeof window||!p)return l(t);try{return l(t)}catch(t){return!1}}(t),w=0;w<c.length;++w)v&&"constructor"===c[w]||!i.call(t,c[w])||h.push(c[w]);return h}}t.exports=n},8968:t=>{t.exports=Math.floor},9032:(t,e,r)=>{var n=r(7244),i=r(8184),o=r(5767),a=r(5680);function s(t){return t.call.bind(t)}var u="undefined"!=typeof BigInt,f="undefined"!=typeof Symbol,c=s(Object.prototype.toString),l=s(Number.prototype.valueOf),h=s(String.prototype.valueOf),p=s(Boolean.prototype.valueOf);if(u)var d=s(BigInt.prototype.valueOf);if(f)var y=s(Symbol.prototype.valueOf);function b(t,e){if("object"!=typeof t)return!1;try{return e(t),!0}catch(t){return!1}}function g(t){return"[object Map]"===c(t)}function v(t){return"[object Set]"===c(t)}function w(t){return"[object WeakMap]"===c(t)}function m(t){return"[object WeakSet]"===c(t)}function S(t){return"[object ArrayBuffer]"===c(t)}function _(t){return"undefined"!=typeof ArrayBuffer&&(S.working?S(t):t instanceof ArrayBuffer)}function E(t){return"[object DataView]"===c(t)}function k(t){return"undefined"!=typeof DataView&&(E.working?E(t):t instanceof DataView)}e.isArgumentsObject=n,e.isGeneratorFunction=i,e.isTypedArray=a,e.isPromise=function(t){return"undefined"!=typeof Promise&&t instanceof Promise||null!==t&&"object"==typeof t&&"function"==typeof t.then&&"function"==typeof t.catch},e.isArrayBufferView=function(t){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(t):a(t)||k(t)},e.isUint8Array=function(t){return"Uint8Array"===o(t)},e.isUint8ClampedArray=function(t){return"Uint8ClampedArray"===o(t)},e.isUint16Array=function(t){return"Uint16Array"===o(t)},e.isUint32Array=function(t){return"Uint32Array"===o(t)},e.isInt8Array=function(t){return"Int8Array"===o(t)},e.isInt16Array=function(t){return"Int16Array"===o(t)},e.isInt32Array=function(t){return"Int32Array"===o(t)},e.isFloat32Array=function(t){return"Float32Array"===o(t)},e.isFloat64Array=function(t){return"Float64Array"===o(t)},e.isBigInt64Array=function(t){return"BigInt64Array"===o(t)},e.isBigUint64Array=function(t){return"BigUint64Array"===o(t)},g.working="undefined"!=typeof Map&&g(new Map),e.isMap=function(t){return"undefined"!=typeof Map&&(g.working?g(t):t instanceof Map)},v.working="undefined"!=typeof Set&&v(new Set),e.isSet=function(t){return"undefined"!=typeof Set&&(v.working?v(t):t instanceof Set)},w.working="undefined"!=typeof WeakMap&&w(new WeakMap),e.isWeakMap=function(t){return"undefined"!=typeof WeakMap&&(w.working?w(t):t instanceof WeakMap)},m.working="undefined"!=typeof WeakSet&&m(new WeakSet),e.isWeakSet=function(t){return m(t)},S.working="undefined"!=typeof ArrayBuffer&&S(new ArrayBuffer),e.isArrayBuffer=_,E.working="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof DataView&&E(new DataView(new ArrayBuffer(1),0,1)),e.isDataView=k;var O="undefined"!=typeof SharedArrayBuffer?SharedArrayBuffer:void 0;function T(t){return"[object SharedArrayBuffer]"===c(t)}function A(t){return void 0!==O&&(void 0===T.working&&(T.working=T(new O)),T.working?T(t):t instanceof O)}function I(t){return b(t,l)}function P(t){return b(t,h)}function x(t){return b(t,p)}function B(t){return u&&b(t,d)}function R(t){return f&&b(t,y)}e.isSharedArrayBuffer=A,e.isAsyncFunction=function(t){return"[object AsyncFunction]"===c(t)},e.isMapIterator=function(t){return"[object Map Iterator]"===c(t)},e.isSetIterator=function(t){return"[object Set Iterator]"===c(t)},e.isGeneratorObject=function(t){return"[object Generator]"===c(t)},e.isWebAssemblyCompiledModule=function(t){return"[object WebAssembly.Module]"===c(t)},e.isNumberObject=I,e.isStringObject=P,e.isBooleanObject=x,e.isBigIntObject=B,e.isSymbolObject=R,e.isBoxedPrimitive=function(t){return I(t)||P(t)||x(t)||B(t)||R(t)},e.isAnyArrayBuffer=function(t){return"undefined"!=typeof Uint8Array&&(_(t)||A(t))},["isProxy","isExternal","isModuleNamespaceObject"].forEach(function(t){Object.defineProperty(e,t,{enumerable:!1,value:function(){throw new Error(t+" is not supported in userland")}})})},9083:(t,e,r)=>{t.exports=c;var n=r(2463).F,i=n.ERR_METHOD_NOT_IMPLEMENTED,o=n.ERR_MULTIPLE_CALLBACK,a=n.ERR_TRANSFORM_ALREADY_TRANSFORMING,s=n.ERR_TRANSFORM_WITH_LENGTH_0,u=r(8101);function f(t,e){var r=this._transformState;r.transforming=!1;var n=r.writecb;if(null===n)return this.emit("error",new o);r.writechunk=null,r.writecb=null,null!=e&&this.push(e),n(t);var i=this._readableState;i.reading=!1,(i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}function c(t){if(!(this instanceof c))return new c(t);u.call(this,t),this._transformState={afterTransform:f.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,t&&("function"==typeof t.transform&&(this._transform=t.transform),"function"==typeof t.flush&&(this._flush=t.flush)),this.on("prefinish",l)}function l(){var t=this;"function"!=typeof this._flush||this._readableState.destroyed?h(this,null,null):this._flush(function(e,r){h(t,e,r)})}function h(t,e,r){if(e)return t.emit("error",e);if(null!=r&&t.push(r),t._writableState.length)throw new s;if(t._transformState.transforming)throw new a;return t.push(null)}r(6698)(c,u),c.prototype.push=function(t,e){return this._transformState.needTransform=!1,u.prototype.push.call(this,t,e)},c.prototype._transform=function(t,e,r){r(new i("_transform()"))},c.prototype._write=function(t,e,r){var n=this._transformState;if(n.writecb=r,n.writechunk=t,n.writeencoding=e,!n.transforming){var i=this._readableState;(n.needTransform||i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}},c.prototype._read=function(t){var e=this._transformState;null===e.writechunk||e.transforming?e.needTransform=!0:(e.transforming=!0,this._transform(e.writechunk,e.writeencoding,e.afterTransform))},c.prototype._destroy=function(t,e){u.prototype._destroy.call(this,t,function(t){e(t)})}},9092:(t,e,r)=>{var n=r(1333);t.exports=function(){return n()&&!!Symbol.toStringTag}},9133:(t,e,r)=>{var n=r(8403);t.exports=function(){return Object.assign?function(){if(!Object.assign)return!1;for(var t="abcdefghijklmnopqrst",e=t.split(""),r={},n=0;n<e.length;++n)r[e[n]]=e[n];var i=Object.assign({},r),o="";for(var a in i)o+=a;return t!==o}()||function(){if(!Object.assign||!Object.preventExtensions)return!1;var t=Object.preventExtensions({1:2});try{Object.assign(t,"xy")}catch(e){return"y"===t[1]}return!1}()?n:Object.assign:n}},9175:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.wrapXOFConstructorWithOpts=e.wrapConstructorWithOpts=e.wrapConstructor=e.Hash=e.nextTick=e.swap32IfBE=e.byteSwapIfBE=e.swap8IfBE=e.isLE=void 0,e.isBytes=i,e.anumber=o,e.abytes=a,e.ahash=function(t){if("function"!=typeof t||"function"!=typeof t.create)throw new Error("Hash should be wrapped by utils.createHasher");o(t.outputLen),o(t.blockLen)},e.aexists=function(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")},e.aoutput=function(t,e){a(t);const r=e.outputLen;if(t.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)},e.u8=function(t){return new Uint8Array(t.buffer,t.byteOffset,t.byteLength)},e.u32=function(t){return new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4))},e.clean=function(...t){for(let e=0;e<t.length;e++)t[e].fill(0)},e.createView=function(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)},e.rotr=function(t,e){return t<<32-e|t>>>e},e.rotl=function(t,e){return t<<e|t>>>32-e>>>0},e.byteSwap=s,e.byteSwap32=u,e.bytesToHex=function(t){if(a(t),f)return t.toHex();let e="";for(let r=0;r<t.length;r++)e+=c[t[r]];return e},e.hexToBytes=function(t){if("string"!=typeof t)throw new Error("hex string expected, got "+typeof t);if(f)return Uint8Array.fromHex(t);const e=t.length,r=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);const n=new Uint8Array(r);for(let e=0,i=0;e<r;e++,i+=2){const r=h(t.charCodeAt(i)),o=h(t.charCodeAt(i+1));if(void 0===r||void 0===o){const e=t[i]+t[i+1];throw new Error('hex string expected, got non-hex character "'+e+'" at index '+i)}n[e]=16*r+o}return n},e.asyncLoop=async function(t,r,n){let i=Date.now();for(let o=0;o<t;o++){n(o);const t=Date.now()-i;t>=0&&t<r||(await(0,e.nextTick)(),i+=t)}},e.utf8ToBytes=p,e.bytesToUtf8=function(t){return(new TextDecoder).decode(t)},e.toBytes=d,e.kdfInputToBytes=function(t){return"string"==typeof t&&(t=p(t)),a(t),t},e.concatBytes=function(...t){let e=0;for(let r=0;r<t.length;r++){const n=t[r];a(n),e+=n.length}const r=new Uint8Array(e);for(let e=0,n=0;e<t.length;e++){const i=t[e];r.set(i,n),n+=i.length}return r},e.checkOpts=function(t,e){if(void 0!==e&&"[object Object]"!=={}.toString.call(e))throw new Error("options should be object or undefined");return Object.assign(t,e)},e.createHasher=y,e.createOptHasher=b,e.createXOFer=g,e.randomBytes=function(t=32){if(n.crypto&&"function"==typeof n.crypto.getRandomValues)return n.crypto.getRandomValues(new Uint8Array(t));if(n.crypto&&"function"==typeof n.crypto.randomBytes)return Uint8Array.from(n.crypto.randomBytes(t));throw new Error("crypto.getRandomValues must be defined")};const n=r(5145);function i(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&"Uint8Array"===t.constructor.name}function o(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function a(t,...e){if(!i(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function s(t){return t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255}function u(t){for(let e=0;e<t.length;e++)t[e]=s(t[e]);return t}e.isLE=68===new Uint8Array(new Uint32Array([287454020]).buffer)[0],e.swap8IfBE=e.isLE?t=>t:t=>s(t),e.byteSwapIfBE=e.swap8IfBE,e.swap32IfBE=e.isLE?t=>t:u;const f=(()=>"function"==typeof Uint8Array.from([]).toHex&&"function"==typeof Uint8Array.fromHex)(),c=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0")),l={_0:48,_9:57,A:65,F:70,a:97,f:102};function h(t){return t>=l._0&&t<=l._9?t-l._0:t>=l.A&&t<=l.F?t-(l.A-10):t>=l.a&&t<=l.f?t-(l.a-10):void 0}function p(t){if("string"!=typeof t)throw new Error("string expected");return new Uint8Array((new TextEncoder).encode(t))}function d(t){return"string"==typeof t&&(t=p(t)),a(t),t}function y(t){const e=e=>t().update(d(e)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function b(t){const e=(e,r)=>t(r).update(d(e)).digest(),r=t({});return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=e=>t(e),e}function g(t){const e=(e,r)=>t(r).update(d(e)).digest(),r=t({});return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=e=>t(e),e}e.nextTick=async()=>{},e.Hash=class{},e.wrapConstructor=y,e.wrapConstructorWithOpts=b,e.wrapXOFConstructorWithOpts=g},9209:(t,e,r)=>{var n=r(6578),i="undefined"==typeof globalThis?r.g:globalThis;t.exports=function(){for(var t=[],e=0;e<n.length;e++)"function"==typeof i[n[e]]&&(t[t.length]=n[e]);return t}},9211:t=>{var e=function(t){return t!=t};t.exports=function(t,r){return 0===t&&0===r?1/t==1/r:t===r||!(!e(t)||!e(r))}},9284:(t,e,r)=>{var n=r(2861).Buffer;t.exports=function(t){if(t.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),r=0;r<e.length;r++)e[r]=255;for(var i=0;i<t.length;i++){var o=t.charAt(i),a=o.charCodeAt(0);if(255!==e[a])throw new TypeError(o+" is ambiguous");e[a]=i}var s=t.length,u=t.charAt(0),f=Math.log(s)/Math.log(256),c=Math.log(256)/Math.log(s);function l(t){if("string"!=typeof t)throw new TypeError("Expected String");if(0===t.length)return n.alloc(0);for(var r=0,i=0,o=0;t[r]===u;)i++,r++;for(var a=(t.length-r)*f+1>>>0,c=new Uint8Array(a);r<t.length;){var l=t.charCodeAt(r);if(l>255)return;var h=e[l];if(255===h)return;for(var p=0,d=a-1;(0!==h||p<o)&&-1!==d;d--,p++)h+=s*c[d]>>>0,c[d]=h%256>>>0,h=h/256>>>0;if(0!==h)throw new Error("Non-zero carry");o=p,r++}for(var y=a-o;y!==a&&0===c[y];)y++;var b=n.allocUnsafe(i+(a-y));b.fill(0,0,i);for(var g=i;y!==a;)b[g++]=c[y++];return b}return{encode:function(e){if((Array.isArray(e)||e instanceof Uint8Array)&&(e=n.from(e)),!n.isBuffer(e))throw new TypeError("Expected Buffer");if(0===e.length)return"";for(var r=0,i=0,o=0,a=e.length;o!==a&&0===e[o];)o++,r++;for(var f=(a-o)*c+1>>>0,l=new Uint8Array(f);o!==a;){for(var h=e[o],p=0,d=f-1;(0!==h||p<i)&&-1!==d;d--,p++)h+=256*l[d]>>>0,l[d]=h%s>>>0,h=h/s>>>0;if(0!==h)throw new Error("Non-zero carry");i=p,o++}for(var y=f-i;y!==f&&0===l[y];)y++;for(var b=u.repeat(r);y<f;++y)b+=t.charAt(l[y]);return b},decodeUnsafe:l,decode:function(t){var e=l(t);if(e)return e;throw new Error("Non-base"+s+" character")}}}},9290:t=>{t.exports=RangeError},9353:t=>{var e=Object.prototype.toString,r=Math.max,n=function(t,e){for(var r=[],n=0;n<t.length;n+=1)r[n]=t[n];for(var i=0;i<e.length;i+=1)r[i+t.length]=e[i];return r};t.exports=function(t){var i=this;if("function"!=typeof i||"[object Function]"!==e.apply(i))throw new TypeError("Function.prototype.bind called on incompatible "+i);for(var o,a=function(t){for(var e=[],r=1,n=0;r<t.length;r+=1,n+=1)e[n]=t[r];return e}(arguments),s=r(0,i.length-a.length),u=[],f=0;f<s;f++)u[f]="$"+f;if(o=Function("binder","return function ("+function(t){for(var e="",r=0;r<t.length;r+=1)e+=t[r],r+1<t.length&&(e+=",");return e}(u)+"){ return binder.apply(this,arguments); }")(function(){if(this instanceof o){var e=i.apply(this,n(a,arguments));return Object(e)===e?e:this}return i.apply(t,n(a,arguments))}),i.prototype){var c=function(){};c.prototype=i.prototype,o.prototype=new c,c.prototype=null}return o}},9383:t=>{t.exports=Error},9394:(t,e,r)=>{var n=r(9211);t.exports=function(){return"function"==typeof Object.is?Object.is:n}},9434:(t,e,r)=>{var n,i=r(2260).F,o=i.ERR_MISSING_ARGS,a=i.ERR_STREAM_DESTROYED;function s(t){if(t)throw t}function u(t){t()}function f(t,e){return t.pipe(e)}t.exports=function(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];var c,l=function(t){return t.length?"function"!=typeof t[t.length-1]?s:t.pop():s}(e);if(Array.isArray(e[0])&&(e=e[0]),e.length<2)throw new o("streams");var h=e.map(function(t,i){var o=i<e.length-1;return function(t,e,i,o){o=function(t){var e=!1;return function(){e||(e=!0,t.apply(void 0,arguments))}}(o);var s=!1;t.on("close",function(){s=!0}),void 0===n&&(n=r(5826)),n(t,{readable:e,writable:i},function(t){if(t)return o(t);s=!0,o()});var u=!1;return function(e){if(!s&&!u)return u=!0,function(t){return t.setHeader&&"function"==typeof t.abort}(t)?t.abort():"function"==typeof t.destroy?t.destroy():void o(e||new a("pipe"))}}(t,o,i>0,function(t){c||(c=t),t&&h.forEach(u),o||(h.forEach(u),l(c))})});return e.reduce(f)}},9538:t=>{t.exports=ReferenceError},9542:(t,e,r)=>{var n=r(8287).Buffer,i=r(2113),o=r(1061);function a(t){return n.isBuffer(t)}function s(t){return"string"==typeof t&&/^([0-9a-f]{2})+$/i.test(t)}function u(t,e){var r=t.toJSON();function n(n){if(!t(n))return!1;if(n.length===e)return!0;throw o.tfCustomError(r+"(Length: "+e+")",r+"(Length: "+n.length+")")}return n.toJSON=function(){return r},n}var f=u.bind(null,i.Array),c=u.bind(null,a),l=u.bind(null,s),h=u.bind(null,i.String),p=Math.pow(2,53)-1,d={ArrayN:f,Buffer:a,BufferN:c,Finite:function(t){return"number"==typeof t&&isFinite(t)},Hex:s,HexN:l,Int8:function(t){return t<<24>>24===t},Int16:function(t){return t<<16>>16===t},Int32:function(t){return(0|t)===t},Int53:function(t){return"number"==typeof t&&t>=-p&&t<=p&&Math.floor(t)===t},Range:function(t,e,r){function n(n,i){return r(n,i)&&n>t&&n<e}return r=r||i.Number,n.toJSON=function(){return`${r.toJSON()} between [${t}, ${e}]`},n},StringN:h,UInt8:function(t){return(255&t)===t},UInt16:function(t){return(65535&t)===t},UInt32:function(t){return t>>>0===t},UInt53:function(t){return"number"==typeof t&&t>=0&&t<=p&&Math.floor(t)===t}};for(var y in d)d[y].toJSON=function(t){return t}.bind(null,y);t.exports=d},9579:(t,e,r)=>{var n=r(8287).Buffer,i=n.isEncoding||function(t){switch(t&&t.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}},o=e.I=function(t){switch(this.encoding=(t||"utf8").toLowerCase().replace(/[-_]/,""),function(t){if(t&&!i(t))throw new Error("Unknown encoding: "+t)}(t),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=s;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=u;break;default:return void(this.write=a)}this.charBuffer=new n(6),this.charReceived=0,this.charLength=0};function a(t){return t.toString(this.encoding)}function s(t){this.charReceived=t.length%2,this.charLength=this.charReceived?2:0}function u(t){this.charReceived=t.length%3,this.charLength=this.charReceived?3:0}o.prototype.write=function(t){for(var e="";this.charLength;){var r=t.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:t.length;if(t.copy(this.charBuffer,this.charReceived,0,r),this.charReceived+=r,this.charReceived<this.charLength)return"";if(t=t.slice(r,t.length),!((n=(e=this.charBuffer.slice(0,this.charLength).toString(this.encoding)).charCodeAt(e.length-1))>=55296&&n<=56319)){if(this.charReceived=this.charLength=0,0===t.length)return e;break}this.charLength+=this.surrogateSize,e=""}this.detectIncompleteChar(t);var n,i=t.length;if(this.charLength&&(t.copy(this.charBuffer,0,t.length-this.charReceived,i),i-=this.charReceived),i=(e+=t.toString(this.encoding,0,i)).length-1,(n=e.charCodeAt(i))>=55296&&n<=56319){var o=this.surrogateSize;return this.charLength+=o,this.charReceived+=o,this.charBuffer.copy(this.charBuffer,o,0,o),t.copy(this.charBuffer,0,0,o),e.substring(0,i)}return e},o.prototype.detectIncompleteChar=function(t){for(var e=t.length>=3?3:t.length;e>0;e--){var r=t[t.length-e];if(1==e&&r>>5==6){this.charLength=2;break}if(e<=2&&r>>4==14){this.charLength=3;break}if(e<=3&&r>>3==30){this.charLength=4;break}}this.charReceived=e},o.prototype.end=function(t){var e="";if(t&&t.length&&(e=this.write(t)),this.charReceived){var r=this.charReceived,n=this.charBuffer,i=this.encoding;e+=n.slice(0,r).toString(i)}return e}},9597:(t,e,r)=>{function n(t){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n(t)}function i(t,e){return i=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},i(t,e)}function o(t){return o=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},o(t)}var a,s,u={};function f(t,e,r){r||(r=Error);var a=function(r){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&i(t,e)}(c,r);var a,s,u,f=(s=c,u=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(t){return!1}}(),function(){var t,e=o(s);if(u){var r=o(this).constructor;t=Reflect.construct(e,arguments,r)}else t=e.apply(this,arguments);return function(t,e){if(e&&("object"===n(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(this,t)});function c(r,n,i){var o;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,c),o=f.call(this,function(t,r,n){return"string"==typeof e?e:e(t,r,n)}(r,n,i)),o.code=t,o}return a=c,Object.defineProperty(a,"prototype",{writable:!1}),a}(r);u[t]=a}function c(t,e){if(Array.isArray(t)){var r=t.length;return t=t.map(function(t){return String(t)}),r>2?"one of ".concat(e," ").concat(t.slice(0,r-1).join(", "),", or ")+t[r-1]:2===r?"one of ".concat(e," ").concat(t[0]," or ").concat(t[1]):"of ".concat(e," ").concat(t[0])}return"of ".concat(e," ").concat(String(t))}f("ERR_AMBIGUOUS_ARGUMENT",'The "%s" argument is ambiguous. %s',TypeError),f("ERR_INVALID_ARG_TYPE",function(t,e,i){var o,s,u;if(void 0===a&&(a=r(4148)),a("string"==typeof t,"'name' must be a string"),"string"==typeof e&&(u="not ",e.substr(0,4)===u)?(o="must not be",e=e.replace(/^not /,"")):o="must be",function(t,e,r){return(void 0===r||r>t.length)&&(r=t.length),t.substring(r-9,r)===e}(t," argument"))s="The ".concat(t," ").concat(o," ").concat(c(e,"type"));else{var f=function(t,e,r){return"number"!=typeof r&&(r=0),!(r+1>t.length)&&-1!==t.indexOf(".",r)}(t)?"property":"argument";s='The "'.concat(t,'" ').concat(f," ").concat(o," ").concat(c(e,"type"))}return s+". Received type ".concat(n(i))},TypeError),f("ERR_INVALID_ARG_VALUE",function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"is invalid";void 0===s&&(s=r(537));var i=s.inspect(e);return i.length>128&&(i="".concat(i.slice(0,128),"...")),"The argument '".concat(t,"' ").concat(n,". Received ").concat(i)},TypeError,RangeError),f("ERR_INVALID_RETURN_VALUE",function(t,e,r){var i;return i=r&&r.constructor&&r.constructor.name?"instance of ".concat(r.constructor.name):"type ".concat(n(r)),"Expected ".concat(t,' to be returned from the "').concat(e,'"')+" function but got ".concat(i,".")},TypeError),f("ERR_MISSING_ARGS",function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];void 0===a&&(a=r(4148)),a(e.length>0,"At least one arg needs to be specified");var i="The ",o=e.length;switch(e=e.map(function(t){return'"'.concat(t,'"')}),o){case 1:i+="".concat(e[0]," argument");break;case 2:i+="".concat(e[0]," and ").concat(e[1]," arguments");break;default:i+=e.slice(0,o-1).join(", "),i+=", and ".concat(e[o-1]," arguments")}return"".concat(i," must be specified")},TypeError),t.exports.codes=u},9600:t=>{var e,r,n=Function.prototype.toString,i="object"==typeof Reflect&&null!==Reflect&&Reflect.apply;if("function"==typeof i&&"function"==typeof Object.defineProperty)try{e=Object.defineProperty({},"length",{get:function(){throw r}}),r={},i(function(){throw 42},null,e)}catch(t){t!==r&&(i=null)}else i=null;var o=/^\s*class\b/,a=function(t){try{var e=n.call(t);return o.test(e)}catch(t){return!1}},s=function(t){try{return!a(t)&&(n.call(t),!0)}catch(t){return!1}},u=Object.prototype.toString,f="function"==typeof Symbol&&!!Symbol.toStringTag,c=!(0 in[,]),l=function(){return!1};if("object"==typeof document){var h=document.all;u.call(h)===u.call(document.all)&&(l=function(t){if((c||!t)&&(void 0===t||"object"==typeof t))try{var e=u.call(t);return("[object HTMLAllCollection]"===e||"[object HTML document.all class]"===e||"[object HTMLCollection]"===e||"[object Object]"===e)&&null==t("")}catch(t){}return!1})}t.exports=i?function(t){if(l(t))return!0;if(!t)return!1;if("function"!=typeof t&&"object"!=typeof t)return!1;try{i(t,null,e)}catch(t){if(t!==r)return!1}return!a(t)&&s(t)}:function(t){if(l(t))return!0;if(!t)return!1;if("function"!=typeof t&&"object"!=typeof t)return!1;if(f)return s(t);if(a(t))return!1;var e=u.call(t);return!("[object Function]"!==e&&"[object GeneratorFunction]"!==e&&!/^\[object HTML/.test(e))&&s(t)}},9612:t=>{t.exports=Object},9615:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.hmac=e.HMAC=void 0;const n=r(9175);class i extends n.Hash{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,(0,n.ahash)(t);const r=(0,n.toBytes)(e);if(this.iHash=t.create(),"function"!=typeof this.iHash.update)throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const i=this.blockLen,o=new Uint8Array(i);o.set(r.length>i?t.create().update(r).digest():r);for(let t=0;t<o.length;t++)o[t]^=54;this.iHash.update(o),this.oHash=t.create();for(let t=0;t<o.length;t++)o[t]^=106;this.oHash.update(o),(0,n.clean)(o)}update(t){return(0,n.aexists)(this),this.iHash.update(t),this}digestInto(t){(0,n.aexists)(this),(0,n.abytes)(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){const t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));const{oHash:e,iHash:r,finished:n,destroyed:i,blockLen:o,outputLen:a}=this;return t.finished=n,t.destroyed=i,t.blockLen=o,t.outputLen=a,t.oHash=e._cloneInto(t.oHash),t.iHash=r._cloneInto(t.iHash),t}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}e.HMAC=i,e.hmac=(t,e,r)=>new i(t,e).update(r).digest(),e.hmac.create=(t,e)=>new i(t,e)},9675:t=>{t.exports=TypeError},9681:t=>{t.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},9721:(t,e,r)=>{var n=r(6556),i=r(4035),o=n("RegExp.prototype.exec"),a=r(9675);t.exports=function(t){if(!i(t))throw new a("`regex` must be a RegExp");return function(e){return null!==o(t,e)}}},9805:(t,e)=>{var r="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Int32Array;function n(t,e){return Object.prototype.hasOwnProperty.call(t,e)}e.assign=function(t){for(var e=Array.prototype.slice.call(arguments,1);e.length;){var r=e.shift();if(r){if("object"!=typeof r)throw new TypeError(r+"must be non-object");for(var i in r)n(r,i)&&(t[i]=r[i])}}return t},e.shrinkBuf=function(t,e){return t.length===e?t:t.subarray?t.subarray(0,e):(t.length=e,t)};var i={arraySet:function(t,e,r,n,i){if(e.subarray&&t.subarray)t.set(e.subarray(r,r+n),i);else for(var o=0;o<n;o++)t[i+o]=e[r+o]},flattenChunks:function(t){var e,r,n,i,o,a;for(n=0,e=0,r=t.length;e<r;e++)n+=t[e].length;for(a=new Uint8Array(n),i=0,e=0,r=t.length;e<r;e++)o=t[e],a.set(o,i),i+=o.length;return a}},o={arraySet:function(t,e,r,n,i){for(var o=0;o<n;o++)t[i+o]=e[r+o]},flattenChunks:function(t){return[].concat.apply([],t)}};e.setTyped=function(t){t?(e.Buf8=Uint8Array,e.Buf16=Uint16Array,e.Buf32=Int32Array,e.assign(e,i)):(e.Buf8=Array,e.Buf16=Array,e.Buf32=Array,e.assign(e,o))},e.setTyped(r)},9957:(t,e,r)=>{var n=Function.prototype.call,i=Object.prototype.hasOwnProperty,o=r(6743);t.exports=o.call(n,i)}},n={};function i(t){var e=n[t];if(void 0!==e)return e.exports;var o=n[t]={exports:{}};return r[t](o,o.exports,i),o.exports}i.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return i.d(e,{a:e}),e},e=Object.getPrototypeOf?t=>Object.getPrototypeOf(t):t=>t.__proto__,i.t=function(r,n){if(1&n&&(r=this(r)),8&n)return r;if("object"==typeof r&&r){if(4&n&&r.__esModule)return r;if(16&n&&"function"==typeof r.then)return r}var o=Object.create(null);i.r(o);var a={};t=t||[null,e({}),e([]),e(e)];for(var s=2&n&&r;("object"==typeof s||"function"==typeof s)&&!~t.indexOf(s);s=e(s))Object.getOwnPropertyNames(s).forEach(t=>a[t]=()=>r[t]);return a.default=()=>r,i.d(o,a),o},i.d=(t,e)=>{for(var r in e)i.o(e,r)&&!i.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},i.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),i.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),i.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var o={};i.r(o),i.d(o,{ABICoder:()=>rw,ABIDataTypes:()=>Xv,ADDRESS_BYTE_LENGTH:()=>gc,ANCHOR_SCRIPT:()=>Ay,Address:()=>ih,AddressGenerator:()=>xp,AddressMap:()=>Jc,AddressSet:()=>uw,AddressTypes:()=>hl,AddressVerificator:()=>vl,BOOLEAN_BYTE_LENGTH:()=>Bc,BinaryReader:()=>uh,BinaryWriter:()=>ph,BitcoinUtils:()=>sl,BufferHelper:()=>Lc,CSVModes:()=>Kd,CalldataGenerator:()=>Uh,ChainId:()=>Zy,ChallengeSolution:()=>dv,ChallengeSubmission:()=>pv,ChallengeVerification:()=>hv,Compressor:()=>h,Consensus:()=>Yy,ContractAddress:()=>xl,ContractBaseMetadata:()=>$y,CustomGenerator:()=>Hh,CustomKeypair:()=>Ww,CustomScriptTransaction:()=>wb,DeploymentGenerator:()=>Jh,DeploymentTransaction:()=>Xb,DeterministicMap:()=>_w,DeterministicSet:()=>xw,EcKeyPair:()=>bc,EpochValidator:()=>wv,FACTORY_ADDRESS_FRACTAL:()=>Dm,FACTORY_ADDRESS_REGTEST:()=>Pm,FACTORY_ADDRESS_TESTNET:()=>Nm,Features:()=>hh,FundingTransaction:()=>ag,Generator:()=>_h,I128_BYTE_LENGTH:()=>Tc,I16_BYTE_LENGTH:()=>Pc,I256_BYTE_LENGTH:()=>Oc,I32_BYTE_LENGTH:()=>Ic,I64_BYTE_LENGTH:()=>Ac,I8_BYTE_LENGTH:()=>xc,InteractionTransaction:()=>yg,InteractionTransactionP2WDA:()=>Ag,LegacyCalldataGenerator:()=>fp,MINIMUM_AMOUNT_CA:()=>Ty,MINIMUM_AMOUNT_REWARD:()=>Oy,MOTO_ADDRESS_FRACTAL:()=>Km,MOTO_ADDRESS_REGTEST:()=>Rm,MOTO_ADDRESS_TESTNET:()=>Cm,MessageSigner:()=>Dy,MessageType:()=>Kw,MultiSignGenerator:()=>yp,MultiSignTransaction:()=>iv,NetEvent:()=>jw,OPNET_DEPLOYMENT_VERSION:()=>Yh,OPNetConsensusConfig:()=>tb,OPNetLimitedProvider:()=>Nv,OPNetMetadata:()=>Gm,OPNetNetwork:()=>Im,OPNetTokenAddressManager:()=>Wm,P2TR_MS:()=>Yv,P2WDADetector:()=>pl,P2WDAGenerator:()=>Op,POOL_ADDRESS_FRACTAL:()=>Hm,POOL_ADDRESS_REGTEST:()=>xm,POOL_ADDRESS_TESTNET:()=>jm,PSBTTypes:()=>Wv,PsbtTransaction:()=>Gv,ROUTER_ADDRESS_FRACTAL:()=>Vm,ROUTER_ADDRESS_REGTEST:()=>Um,ROUTER_ADDRESS_TESTNET:()=>Fm,RoswellConsensus:()=>Jy,SELECTOR_BYTE_LENGTH:()=>vc,Secp256k1PointDeriver:()=>kl,SharedInteractionTransaction:()=>Nb,SignatureType:()=>Vw,SigningProtocol:()=>Sm,TapscriptVerificator:()=>Uy,TimeLockGenerator:()=>Nl,TransactionBuilder:()=>Iy,TransactionFactory:()=>Mg,TransactionSequence:()=>Md,TransactionType:()=>Xy,TweakedSigner:()=>Vd,TweakedTransaction:()=>uy,U128_BYTE_LENGTH:()=>mc,U16_BYTE_LENGTH:()=>Ec,U256_BYTE_LENGTH:()=>wc,U32_BYTE_LENGTH:()=>_c,U64_BYTE_LENGTH:()=>Sc,U8_BYTE_LENGTH:()=>kc,UnisatChainType:()=>Mw,UnisatNetwork:()=>Hw,UnisatSigner:()=>im,WBTC_ADDRESS_FRACTAL:()=>Mm,WBTC_ADDRESS_REGTEST:()=>Bm,WBTC_ADDRESS_TESTNET:()=>Lm,Wallet:()=>Wy,XverseNetwork:()=>mm,XverseSigner:()=>_m,currentConsensus:()=>eb,currentConsensusConfig:()=>rb,version:()=>a,versionBuffer:()=>$h});var a="1.6.6",s=i(8559),u=i.n(s);function f(t){return f="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},f(t)}function c(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,l(n.key),n)}}function l(t){var e=function(t){if("object"!=f(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=f(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==f(e)?e:e+""}var h=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)}return function(t,e,r){return r&&c(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,0,[{key:"compress",value:function(e){return u().gzipSync(e,t.zlibOptions)}},{key:"decompress",value:function(e){return u().gunzipSync(e,t.zlibOptions)}}])}();!function(t,e,r){(e=l(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r}(h,"zlibOptions",{level:9,maxOutputLength:16777216});var p={34:(t,e,r)=>{var n=r(287).hp;Object.defineProperty(e,"__esModule",{value:!0});const i=r(80);e.decode=function(t){if(t.key[0]!==i.InputTypes.TAP_SCRIPT_SIG)throw new Error("Decode Error: could not decode tapScriptSig with key 0x"+t.key.toString("hex"));if(65!==t.key.length)throw new Error("Decode Error: tapScriptSig has invalid key 0x"+t.key.toString("hex"));if(64!==t.value.length&&65!==t.value.length)throw new Error("Decode Error: tapScriptSig has invalid signature in key 0x"+t.key.toString("hex"));return{pubkey:t.key.slice(1,33),leafHash:t.key.slice(33),signature:t.value}},e.encode=function(t){const e=n.from([i.InputTypes.TAP_SCRIPT_SIG]);return{key:n.concat([e,t.pubkey,t.leafHash]),value:t.signature}},e.expected="{ pubkey: Buffer; leafHash: Buffer; signature: Buffer; }",e.check=function(t){return n.isBuffer(t.pubkey)&&n.isBuffer(t.leafHash)&&n.isBuffer(t.signature)&&32===t.pubkey.length&&32===t.leafHash.length&&(64===t.signature.length||65===t.signature.length)},e.canAddToArray=function(t,e,r){const n=e.pubkey.toString("hex")+e.leafHash.toString("hex");return!r.has(n)&&(r.add(n),0===t.filter(t=>t.pubkey.equals(e.pubkey)&&t.leafHash.equals(e.leafHash)).length)}},61:(t,e,r)=>{var n=r(113);function i(t){return t.name||t.toString().match(/function (.*?)\s*\(/)[1]}function o(t){return n.Nil(t)?"":i(t.constructor)}function a(t,e){Error.captureStackTrace&&Error.captureStackTrace(t,e)}function s(t){return n.Function(t)?t.toJSON?t.toJSON():i(t):n.Array(t)?"Array":t&&n.Object(t)?"Object":void 0!==t?t:""}function u(t,e,r){var i=function(t){return n.Function(t)?"":n.String(t)?JSON.stringify(t):t&&n.Object(t)?"":t}(e);return"Expected "+s(t)+", got"+(""!==r?" "+r:"")+(""!==i?" "+i:"")}function f(t,e,r){r=r||o(e),this.message=u(t,e,r),a(this,f),this.__type=t,this.__value=e,this.__valueTypeName=r}function c(t,e,r,n,i){t?(i=i||o(n),this.message=function(t,e,r,n,i){var o='" of type ';return"key"===e&&(o='" with key type '),u('property "'+s(r)+o+s(t),n,i)}(t,r,e,n,i)):this.message='Unexpected property "'+e+'"',a(this,f),this.__label=r,this.__property=e,this.__type=t,this.__value=n,this.__valueTypeName=i}f.prototype=Object.create(Error.prototype),f.prototype.constructor=f,c.prototype=Object.create(Error.prototype),c.prototype.constructor=f,t.exports={TfTypeError:f,TfPropertyTypeError:c,tfCustomError:function(t,e){return new f(t,{},e)},tfSubError:function(t,e,r){return t instanceof c?(e=e+"."+t.__property,t=new c(t.__type,e,t.__label,t.__value,t.__valueTypeName)):t instanceof f&&(t=new c(t.__type,e,r,t.__value,t.__valueTypeName)),a(t),t},tfJSON:s,getValueTypeName:o}},80:(t,e)=>{var r,n,i;Object.defineProperty(e,"__esModule",{value:!0}),(i=e.GlobalTypes||(e.GlobalTypes={}))[i.UNSIGNED_TX=0]="UNSIGNED_TX",i[i.GLOBAL_XPUB=1]="GLOBAL_XPUB",e.GLOBAL_TYPE_NAMES=["unsignedTx","globalXpub"],(n=e.InputTypes||(e.InputTypes={}))[n.NON_WITNESS_UTXO=0]="NON_WITNESS_UTXO",n[n.WITNESS_UTXO=1]="WITNESS_UTXO",n[n.PARTIAL_SIG=2]="PARTIAL_SIG",n[n.SIGHASH_TYPE=3]="SIGHASH_TYPE",n[n.REDEEM_SCRIPT=4]="REDEEM_SCRIPT",n[n.WITNESS_SCRIPT=5]="WITNESS_SCRIPT",n[n.BIP32_DERIVATION=6]="BIP32_DERIVATION",n[n.FINAL_SCRIPTSIG=7]="FINAL_SCRIPTSIG",n[n.FINAL_SCRIPTWITNESS=8]="FINAL_SCRIPTWITNESS",n[n.POR_COMMITMENT=9]="POR_COMMITMENT",n[n.TAP_KEY_SIG=19]="TAP_KEY_SIG",n[n.TAP_SCRIPT_SIG=20]="TAP_SCRIPT_SIG",n[n.TAP_LEAF_SCRIPT=21]="TAP_LEAF_SCRIPT",n[n.TAP_BIP32_DERIVATION=22]="TAP_BIP32_DERIVATION",n[n.TAP_INTERNAL_KEY=23]="TAP_INTERNAL_KEY",n[n.TAP_MERKLE_ROOT=24]="TAP_MERKLE_ROOT",e.INPUT_TYPE_NAMES=["nonWitnessUtxo","witnessUtxo","partialSig","sighashType","redeemScript","witnessScript","bip32Derivation","finalScriptSig","finalScriptWitness","porCommitment","tapKeySig","tapScriptSig","tapLeafScript","tapBip32Derivation","tapInternalKey","tapMerkleRoot"],(r=e.OutputTypes||(e.OutputTypes={}))[r.REDEEM_SCRIPT=0]="REDEEM_SCRIPT",r[r.WITNESS_SCRIPT=1]="WITNESS_SCRIPT",r[r.BIP32_DERIVATION=2]="BIP32_DERIVATION",r[r.TAP_INTERNAL_KEY=5]="TAP_INTERNAL_KEY",r[r.TAP_TREE=6]="TAP_TREE",r[r.TAP_BIP32_DERIVATION=7]="TAP_BIP32_DERIVATION",e.OUTPUT_TYPE_NAMES=["redeemScript","witnessScript","bip32Derivation","tapInternalKey","tapTree","tapBip32Derivation"]},113:t=>{var e={Array:function(t){return null!=t&&t.constructor===Array},Boolean:function(t){return"boolean"==typeof t},Function:function(t){return"function"==typeof t},Nil:function(t){return null==t},Number:function(t){return"number"==typeof t},Object:function(t){return"object"==typeof t},String:function(t){return"string"==typeof t},"":function(){return!0}};for(var r in e.Null=e.Nil,e)e[r].toJSON=function(t){return t}.bind(null,r);t.exports=e},133:(t,e,r)=>{var n=r(287).hp;Object.defineProperty(e,"__esModule",{value:!0});const i=r(394);function o(t){const e=t.key.length,r=t.value.length,o=i.encodingLength(e),a=i.encodingLength(r),s=n.allocUnsafe(o+e+a+r);return i.encode(e,s,0),t.key.copy(s,o),i.encode(r,s,o+e),t.value.copy(s,o+e+a),s}function a(t,e){if("number"!=typeof t)throw new Error("cannot write a non-number as a number");if(t<0)throw new Error("specified a negative value for writing an unsigned value");if(t>e)throw new Error("RangeError: value out of range");if(Math.floor(t)!==t)throw new Error("value has a fractional component")}e.range=t=>[...Array(t).keys()],e.reverseBuffer=function(t){if(t.length<1)return t;let e=t.length-1,r=0;for(let n=0;n<t.length/2;n++)r=t[n],t[n]=t[e],t[e]=r,e--;return t},e.keyValsToBuffer=function(t){const e=t.map(o);return e.push(n.from([0])),n.concat(e)},e.keyValToBuffer=o,e.readUInt64LE=function(t,e){const r=t.readUInt32LE(e);let n=t.readUInt32LE(e+4);return n*=4294967296,a(n+r,9007199254740991),n+r},e.writeUInt64LE=function(t,e,r){return a(e,9007199254740991),t.writeInt32LE(-1&e,r),t.writeUInt32LE(Math.floor(e/4294967296),r+4),r+8}},213:(t,e,r)=>{var n=r(287).hp;Object.defineProperty(e,"__esModule",{value:!0});const i=r(80);e.encode=function(t){return{key:n.from([i.GlobalTypes.UNSIGNED_TX]),value:t.toBuffer()}}},223:(t,e,r)=>{var n=r(287).hp;Object.defineProperty(e,"__esModule",{value:!0}),e.makeConverter=function(t){return{decode:function(e){if(e.key[0]!==t||1!==e.key.length)throw new Error("Decode Error: could not decode tapInternalKey with key 0x"+e.key.toString("hex"));if(32!==e.value.length)throw new Error("Decode Error: tapInternalKey not a 32-byte x-only pubkey");return e.value},encode:function(e){return{key:n.from([t]),value:e}},check:function(t){return n.isBuffer(t)&&32===t.length},expected:"Buffer",canAdd:function(t,e){return!!t&&!!e&&void 0===t.tapInternalKey}}}},238:(t,e,r)=>{var n=r(287).hp;Object.defineProperty(e,"__esModule",{value:!0});const i=r(706),o=r(133);e.psbtToBuffer=function({globalMap:t,inputs:e,outputs:r}){const{globalKeyVals:i,inputKeyVals:a,outputKeyVals:s}=u({globalMap:t,inputs:e,outputs:r}),f=o.keyValsToBuffer(i),c=t=>0===t.length?[n.from([0])]:t.map(o.keyValsToBuffer),l=c(a),h=c(s),p=n.allocUnsafe(5);return p.writeUIntBE(482972169471,0,5),n.concat([p,f].concat(l,h))};const a=(t,e)=>t.key.compare(e.key);function s(t,e){const r=new Set,n=Object.entries(t).reduce((t,[n,i])=>{if("unknownKeyVals"===n)return t;const o=e[n];if(void 0===o)return t;const a=(Array.isArray(i)?i:[i]).map(o.encode);return a.map(t=>t.key.toString("hex")).forEach(t=>{if(r.has(t))throw new Error("Serialize Error: Duplicate key: "+t);r.add(t)}),t.concat(a)},[]),i=t.unknownKeyVals?t.unknownKeyVals.filter(t=>!r.has(t.key.toString("hex"))):[];return n.concat(i).sort(a)}function u({globalMap:t,inputs:e,outputs:r}){return{globalKeyVals:s(t,i.globals),inputKeyVals:e.map(t=>s(t,i.inputs)),outputKeyVals:r.map(t=>s(t,i.outputs))}}e.psbtToKeyVals=u},251:(t,e)=>{e.read=function(t,e,r,n,i){var o,a,s=8*i-n-1,u=(1<<s)-1,f=u>>1,c=-7,l=r?i-1:0,h=r?-1:1,p=t[e+l];for(l+=h,o=p&(1<<-c)-1,p>>=-c,c+=s;c>0;o=256*o+t[e+l],l+=h,c-=8);for(a=o&(1<<-c)-1,o>>=-c,c+=n;c>0;a=256*a+t[e+l],l+=h,c-=8);if(0===o)o=1-f;else{if(o===u)return a?NaN:1/0*(p?-1:1);a+=Math.pow(2,n),o-=f}return(p?-1:1)*a*Math.pow(2,o-n)},e.write=function(t,e,r,n,i,o){var a,s,u,f=8*o-i-1,c=(1<<f)-1,l=c>>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:o-1,d=n?1:-1,y=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,a=c):(a=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-a))<1&&(a--,u*=2),(e+=a+l>=1?h/u:h*Math.pow(2,1-l))*u>=2&&(a++,u/=2),a+l>=c?(s=0,a=c):a+l>=1?(s=(e*u-1)*Math.pow(2,i),a+=l):(s=e*Math.pow(2,l-1)*Math.pow(2,i),a=0));i>=8;t[r+p]=255&s,p+=d,s/=256,i-=8);for(a=a<<i|s,f+=i;f>0;t[r+p]=255&a,p+=d,a/=256,f-=8);t[r+p-d]|=128*y}},263:(t,e,r)=>{var n=r(287).hp;Object.defineProperty(e,"__esModule",{value:!0});const i=r(706),o=r(133),a=r(394),s=r(80);function u(t,e,r){if(!e.equals(n.from([r])))throw new Error(`Format Error: Invalid ${t} key: ${e.toString("hex")}`)}function f(t,{globalMapKeyVals:e,inputKeyVals:r,outputKeyVals:n}){const a={unsignedTx:t};let f=0;for(const t of e)switch(t.key[0]){case s.GlobalTypes.UNSIGNED_TX:if(u("global",t.key,s.GlobalTypes.UNSIGNED_TX),f>0)throw new Error("Format Error: GlobalMap has multiple UNSIGNED_TX");f++;break;case s.GlobalTypes.GLOBAL_XPUB:void 0===a.globalXpub&&(a.globalXpub=[]),a.globalXpub.push(i.globals.globalXpub.decode(t));break;default:a.unknownKeyVals||(a.unknownKeyVals=[]),a.unknownKeyVals.push(t)}const c=r.length,l=n.length,h=[],p=[];for(const t of o.range(c)){const e={};for(const n of r[t])switch(i.inputs.checkPubkey(n),n.key[0]){case s.InputTypes.NON_WITNESS_UTXO:if(u("input",n.key,s.InputTypes.NON_WITNESS_UTXO),void 0!==e.nonWitnessUtxo)throw new Error("Format Error: Input has multiple NON_WITNESS_UTXO");e.nonWitnessUtxo=i.inputs.nonWitnessUtxo.decode(n);break;case s.InputTypes.WITNESS_UTXO:if(u("input",n.key,s.InputTypes.WITNESS_UTXO),void 0!==e.witnessUtxo)throw new Error("Format Error: Input has multiple WITNESS_UTXO");e.witnessUtxo=i.inputs.witnessUtxo.decode(n);break;case s.InputTypes.PARTIAL_SIG:void 0===e.partialSig&&(e.partialSig=[]),e.partialSig.push(i.inputs.partialSig.decode(n));break;case s.InputTypes.SIGHASH_TYPE:if(u("input",n.key,s.InputTypes.SIGHASH_TYPE),void 0!==e.sighashType)throw new Error("Format Error: Input has multiple SIGHASH_TYPE");e.sighashType=i.inputs.sighashType.decode(n);break;case s.InputTypes.REDEEM_SCRIPT:if(u("input",n.key,s.InputTypes.REDEEM_SCRIPT),void 0!==e.redeemScript)throw new Error("Format Error: Input has multiple REDEEM_SCRIPT");e.redeemScript=i.inputs.redeemScript.decode(n);break;case s.InputTypes.WITNESS_SCRIPT:if(u("input",n.key,s.InputTypes.WITNESS_SCRIPT),void 0!==e.witnessScript)throw new Error("Format Error: Input has multiple WITNESS_SCRIPT");e.witnessScript=i.inputs.witnessScript.decode(n);break;case s.InputTypes.BIP32_DERIVATION:void 0===e.bip32Derivation&&(e.bip32Derivation=[]),e.bip32Derivation.push(i.inputs.bip32Derivation.decode(n));break;case s.InputTypes.FINAL_SCRIPTSIG:u("input",n.key,s.InputTypes.FINAL_SCRIPTSIG),e.finalScriptSig=i.inputs.finalScriptSig.decode(n);break;case s.InputTypes.FINAL_SCRIPTWITNESS:u("input",n.key,s.InputTypes.FINAL_SCRIPTWITNESS),e.finalScriptWitness=i.inputs.finalScriptWitness.decode(n);break;case s.InputTypes.POR_COMMITMENT:u("input",n.key,s.InputTypes.POR_COMMITMENT),e.porCommitment=i.inputs.porCommitment.decode(n);break;case s.InputTypes.TAP_KEY_SIG:u("input",n.key,s.InputTypes.TAP_KEY_SIG),e.tapKeySig=i.inputs.tapKeySig.decode(n);break;case s.InputTypes.TAP_SCRIPT_SIG:void 0===e.tapScriptSig&&(e.tapScriptSig=[]),e.tapScriptSig.push(i.inputs.tapScriptSig.decode(n));break;case s.InputTypes.TAP_LEAF_SCRIPT:void 0===e.tapLeafScript&&(e.tapLeafScript=[]),e.tapLeafScript.push(i.inputs.tapLeafScript.decode(n));break;case s.InputTypes.TAP_BIP32_DERIVATION:void 0===e.tapBip32Derivation&&(e.tapBip32Derivation=[]),e.tapBip32Derivation.push(i.inputs.tapBip32Derivation.decode(n));break;case s.InputTypes.TAP_INTERNAL_KEY:u("input",n.key,s.InputTypes.TAP_INTERNAL_KEY),e.tapInternalKey=i.inputs.tapInternalKey.decode(n);break;case s.InputTypes.TAP_MERKLE_ROOT:u("input",n.key,s.InputTypes.TAP_MERKLE_ROOT),e.tapMerkleRoot=i.inputs.tapMerkleRoot.decode(n);break;default:e.unknownKeyVals||(e.unknownKeyVals=[]),e.unknownKeyVals.push(n)}h.push(e)}for(const t of o.range(l)){const e={};for(const r of n[t])switch(i.outputs.checkPubkey(r),r.key[0]){case s.OutputTypes.REDEEM_SCRIPT:if(u("output",r.key,s.OutputTypes.REDEEM_SCRIPT),void 0!==e.redeemScript)throw new Error("Format Error: Output has multiple REDEEM_SCRIPT");e.redeemScript=i.outputs.redeemScript.decode(r);break;case s.OutputTypes.WITNESS_SCRIPT:if(u("output",r.key,s.OutputTypes.WITNESS_SCRIPT),void 0!==e.witnessScript)throw new Error("Format Error: Output has multiple WITNESS_SCRIPT");e.witnessScript=i.outputs.witnessScript.decode(r);break;case s.OutputTypes.BIP32_DERIVATION:void 0===e.bip32Derivation&&(e.bip32Derivation=[]),e.bip32Derivation.push(i.outputs.bip32Derivation.decode(r));break;case s.OutputTypes.TAP_INTERNAL_KEY:u("output",r.key,s.OutputTypes.TAP_INTERNAL_KEY),e.tapInternalKey=i.outputs.tapInternalKey.decode(r);break;case s.OutputTypes.TAP_TREE:u("output",r.key,s.OutputTypes.TAP_TREE),e.tapTree=i.outputs.tapTree.decode(r);break;case s.OutputTypes.TAP_BIP32_DERIVATION:void 0===e.tapBip32Derivation&&(e.tapBip32Derivation=[]),e.tapBip32Derivation.push(i.outputs.tapBip32Derivation.decode(r));break;default:e.unknownKeyVals||(e.unknownKeyVals=[]),e.unknownKeyVals.push(r)}p.push(e)}return{globalMap:a,inputs:h,outputs:p}}e.psbtFromBuffer=function(t,e){let r=0;function n(){const e=a.decode(t,r);r+=a.encodingLength(e);const n=t.slice(r,r+e);return r+=e,n}function i(){return{key:n(),value:n()}}function u(){if(r>=t.length)throw new Error("Format Error: Unexpected End of PSBT");const e=0===t.readUInt8(r);return e&&r++,e}if(1886610036!==function(){const e=t.readUInt32BE(r);return r+=4,e}())throw new Error("Format Error: Invalid Magic Number");if(255!==function(){const e=t.readUInt8(r);return r+=1,e}())throw new Error("Format Error: Magic Number must be followed by 0xff separator");const c=[],l={};for(;!u();){const t=i(),e=t.key.toString("hex");if(l[e])throw new Error("Format Error: Keys must be unique for global keymap: key "+e);l[e]=1,c.push(t)}const h=c.filter(t=>t.key[0]===s.GlobalTypes.UNSIGNED_TX);if(1!==h.length)throw new Error("Format Error: Only one UNSIGNED_TX allowed");const p=e(h[0].value),{inputCount:d,outputCount:y}=p.getInputOutputCounts(),b=[],g=[];for(const t of o.range(d)){const e={},r=[];for(;!u();){const n=i(),o=n.key.toString("hex");if(e[o])throw new Error("Format Error: Keys must be unique for each input: input index "+t+" key "+o);e[o]=1,r.push(n)}b.push(r)}for(const t of o.range(y)){const e={},r=[];for(;!u();){const n=i(),o=n.key.toString("hex");if(e[o])throw new Error("Format Error: Keys must be unique for each output: output index "+t+" key "+o);e[o]=1,r.push(n)}g.push(r)}return f(p,{globalMapKeyVals:c,inputKeyVals:b,outputKeyVals:g})},e.checkKeyBuffer=u,e.psbtFromKeyVals=f},287:(t,e,r)=>{const n=r(526),i=r(251),o="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;e.hp=u,e.IS=50;const a=2147483647;function s(t){if(t>a)throw new RangeError('The value "'+t+'" is invalid for option "size"');const e=new Uint8Array(t);return Object.setPrototypeOf(e,u.prototype),e}function u(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return l(t)}return f(t,e,r)}function f(t,e,r){if("string"==typeof t)return function(t,e){if("string"==typeof e&&""!==e||(e="utf8"),!u.isEncoding(e))throw new TypeError("Unknown encoding: "+e);const r=0|y(t,e);let n=s(r);const i=n.write(t,e);return i!==r&&(n=n.slice(0,i)),n}(t,e);if(ArrayBuffer.isView(t))return function(t){if(X(t,Uint8Array)){const e=new Uint8Array(t);return p(e.buffer,e.byteOffset,e.byteLength)}return h(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(X(t,ArrayBuffer)||t&&X(t.buffer,ArrayBuffer))return p(t,e,r);if("undefined"!=typeof SharedArrayBuffer&&(X(t,SharedArrayBuffer)||t&&X(t.buffer,SharedArrayBuffer)))return p(t,e,r);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');const n=t.valueOf&&t.valueOf();if(null!=n&&n!==t)return u.from(n,e,r);const i=function(t){if(u.isBuffer(t)){const e=0|d(t.length),r=s(e);return 0===r.length||t.copy(r,0,0,e),r}return void 0!==t.length?"number"!=typeof t.length||Y(t.length)?s(0):h(t):"Buffer"===t.type&&Array.isArray(t.data)?h(t.data):void 0}(t);if(i)return i;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return u.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function c(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function l(t){return c(t),s(t<0?0:0|d(t))}function h(t){const e=t.length<0?0:0|d(t.length),r=s(e);for(let n=0;n<e;n+=1)r[n]=255&t[n];return r}function p(t,e,r){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(r||0))throw new RangeError('"length" is outside of buffer bounds');let n;return n=void 0===e&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,e):new Uint8Array(t,e,r),Object.setPrototypeOf(n,u.prototype),n}function d(t){if(t>=a)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+a.toString(16)+" bytes");return 0|t}function y(t,e){if(u.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||X(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);const r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;let i=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return q(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return z(t).length;default:if(i)return n?-1:q(t).length;e=(""+e).toLowerCase(),i=!0}}function b(t,e,r){let n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return x(this,e,r);case"utf8":case"utf-8":return T(this,e,r);case"ascii":return I(this,e,r);case"latin1":case"binary":return P(this,e,r);case"base64":return O(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return B(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function g(t,e,r){const n=t[e];t[e]=t[r],t[r]=n}function v(t,e,r,n,i){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),Y(r=+r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof e&&(e=u.from(e,n)),u.isBuffer(e))return 0===e.length?-1:w(t,e,r,n,i);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):w(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function w(t,e,r,n,i){let o,a=1,s=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;a=2,s/=2,u/=2,r/=2}function f(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(i){let n=-1;for(o=r;o<s;o++)if(f(t,o)===f(e,-1===n?0:o-n)){if(-1===n&&(n=o),o-n+1===u)return n*a}else-1!==n&&(o-=o-n),n=-1}else for(r+u>s&&(r=s-u),o=r;o>=0;o--){let r=!0;for(let n=0;n<u;n++)if(f(t,o+n)!==f(e,n)){r=!1;break}if(r)return o}return-1}function m(t,e,r,n){r=Number(r)||0;const i=t.length-r;n?(n=Number(n))>i&&(n=i):n=i;const o=e.length;let a;for(n>o/2&&(n=o/2),a=0;a<n;++a){const n=parseInt(e.substr(2*a,2),16);if(Y(n))return a;t[r+a]=n}return a}function S(t,e,r,n){return Z(q(e,t.length-r),t,r,n)}function _(t,e,r,n){return Z(function(t){const e=[];for(let r=0;r<t.length;++r)e.push(255&t.charCodeAt(r));return e}(e),t,r,n)}function E(t,e,r,n){return Z(z(e),t,r,n)}function k(t,e,r,n){return Z(function(t,e){let r,n,i;const o=[];for(let a=0;a<t.length&&!((e-=2)<0);++a)r=t.charCodeAt(a),n=r>>8,i=r%256,o.push(i),o.push(n);return o}(e,t.length-r),t,r,n)}function O(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function T(t,e,r){r=Math.min(t.length,r);const n=[];let i=e;for(;i<r;){const e=t[i];let o=null,a=e>239?4:e>223?3:e>191?2:1;if(i+a<=r){let r,n,s,u;switch(a){case 1:e<128&&(o=e);break;case 2:r=t[i+1],128==(192&r)&&(u=(31&e)<<6|63&r,u>127&&(o=u));break;case 3:r=t[i+1],n=t[i+2],128==(192&r)&&128==(192&n)&&(u=(15&e)<<12|(63&r)<<6|63&n,u>2047&&(u<55296||u>57343)&&(o=u));break;case 4:r=t[i+1],n=t[i+2],s=t[i+3],128==(192&r)&&128==(192&n)&&128==(192&s)&&(u=(15&e)<<18|(63&r)<<12|(63&n)<<6|63&s,u>65535&&u<1114112&&(o=u))}}null===o?(o=65533,a=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|1023&o),n.push(o),i+=a}return function(t){const e=t.length;if(e<=A)return String.fromCharCode.apply(String,t);let r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=A));return r}(n)}u.TYPED_ARRAY_SUPPORT=function(){try{const t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),42===t.foo()}catch(t){return!1}}(),u.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||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."),Object.defineProperty(u.prototype,"parent",{enumerable:!0,get:function(){if(u.isBuffer(this))return this.buffer}}),Object.defineProperty(u.prototype,"offset",{enumerable:!0,get:function(){if(u.isBuffer(this))return this.byteOffset}}),u.poolSize=8192,u.from=function(t,e,r){return f(t,e,r)},Object.setPrototypeOf(u.prototype,Uint8Array.prototype),Object.setPrototypeOf(u,Uint8Array),u.alloc=function(t,e,r){return function(t,e,r){return c(t),t<=0?s(t):void 0!==e?"string"==typeof r?s(t).fill(e,r):s(t).fill(e):s(t)}(t,e,r)},u.allocUnsafe=function(t){return l(t)},u.allocUnsafeSlow=function(t){return l(t)},u.isBuffer=function(t){return null!=t&&!0===t._isBuffer&&t!==u.prototype},u.compare=function(t,e){if(X(t,Uint8Array)&&(t=u.from(t,t.offset,t.byteLength)),X(e,Uint8Array)&&(e=u.from(e,e.offset,e.byteLength)),!u.isBuffer(t)||!u.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;let r=t.length,n=e.length;for(let i=0,o=Math.min(r,n);i<o;++i)if(t[i]!==e[i]){r=t[i],n=e[i];break}return r<n?-1:n<r?1:0},u.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}},u.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return u.alloc(0);let r;if(void 0===e)for(e=0,r=0;r<t.length;++r)e+=t[r].length;const n=u.allocUnsafe(e);let i=0;for(r=0;r<t.length;++r){let e=t[r];if(X(e,Uint8Array))i+e.length>n.length?(u.isBuffer(e)||(e=u.from(e)),e.copy(n,i)):Uint8Array.prototype.set.call(n,e,i);else{if(!u.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(n,i)}i+=e.length}return n},u.byteLength=y,u.prototype._isBuffer=!0,u.prototype.swap16=function(){const t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;e<t;e+=2)g(this,e,e+1);return this},u.prototype.swap32=function(){const t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let e=0;e<t;e+=4)g(this,e,e+3),g(this,e+1,e+2);return this},u.prototype.swap64=function(){const t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let e=0;e<t;e+=8)g(this,e,e+7),g(this,e+1,e+6),g(this,e+2,e+5),g(this,e+3,e+4);return this},u.prototype.toString=function(){const t=this.length;return 0===t?"":0===arguments.length?T(this,0,t):b.apply(this,arguments)},u.prototype.toLocaleString=u.prototype.toString,u.prototype.equals=function(t){if(!u.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===u.compare(this,t)},u.prototype.inspect=function(){let t="";const r=e.IS;return t=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(t+=" ... "),"<Buffer "+t+">"},o&&(u.prototype[o]=u.prototype.inspect),u.prototype.compare=function(t,e,r,n,i){if(X(t,Uint8Array)&&(t=u.from(t,t.offset,t.byteLength)),!u.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),e<0||r>t.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&e>=r)return 0;if(n>=i)return-1;if(e>=r)return 1;if(this===t)return 0;let o=(i>>>=0)-(n>>>=0),a=(r>>>=0)-(e>>>=0);const s=Math.min(o,a),f=this.slice(n,i),c=t.slice(e,r);for(let t=0;t<s;++t)if(f[t]!==c[t]){o=f[t],a=c[t];break}return o<a?-1:a<o?1:0},u.prototype.includes=function(t,e,r){return-1!==this.indexOf(t,e,r)},u.prototype.indexOf=function(t,e,r){return v(this,t,e,r,!0)},u.prototype.lastIndexOf=function(t,e,r){return v(this,t,e,r,!1)},u.prototype.write=function(t,e,r,n){if(void 0===e)n="utf8",r=this.length,e=0;else if(void 0===r&&"string"==typeof e)n=e,r=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e>>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}const i=this.length-e;if((void 0===r||r>i)&&(r=i),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");let o=!1;for(;;)switch(n){case"hex":return m(this,t,e,r);case"utf8":case"utf-8":return S(this,t,e,r);case"ascii":case"latin1":case"binary":return _(this,t,e,r);case"base64":return E(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,t,e,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const A=4096;function I(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(127&t[i]);return n}function P(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(t[i]);return n}function x(t,e,r){const n=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>n)&&(r=n);let i="";for(let n=e;n<r;++n)i+=$[t[n]];return i}function B(t,e,r){const n=t.slice(e,r);let i="";for(let t=0;t<n.length-1;t+=2)i+=String.fromCharCode(n[t]+256*n[t+1]);return i}function R(t,e,r){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}function U(t,e,r,n,i,o){if(!u.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||e<o)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}function N(t,e,r,n,i){K(e,n,i,t,r,7);let o=Number(e&BigInt(4294967295));t[r++]=o,o>>=8,t[r++]=o,o>>=8,t[r++]=o,o>>=8,t[r++]=o;let a=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=a,a>>=8,t[r++]=a,a>>=8,t[r++]=a,a>>=8,t[r++]=a,r}function j(t,e,r,n,i){K(e,n,i,t,r,7);let o=Number(e&BigInt(4294967295));t[r+7]=o,o>>=8,t[r+6]=o,o>>=8,t[r+5]=o,o>>=8,t[r+4]=o;let a=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=a,a>>=8,t[r+2]=a,a>>=8,t[r+1]=a,a>>=8,t[r]=a,r+8}function L(t,e,r,n,i,o){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function C(t,e,r,n,o){return e=+e,r>>>=0,o||L(t,0,r,4),i.write(t,e,r,n,23,4),r+4}function F(t,e,r,n,o){return e=+e,r>>>=0,o||L(t,0,r,8),i.write(t,e,r,n,52,8),r+8}u.prototype.slice=function(t,e){const r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e<t&&(e=t);const n=this.subarray(t,e);return Object.setPrototypeOf(n,u.prototype),n},u.prototype.readUintLE=u.prototype.readUIntLE=function(t,e,r){t>>>=0,e>>>=0,r||R(t,e,this.length);let n=this[t],i=1,o=0;for(;++o<e&&(i*=256);)n+=this[t+o]*i;return n},u.prototype.readUintBE=u.prototype.readUIntBE=function(t,e,r){t>>>=0,e>>>=0,r||R(t,e,this.length);let n=this[t+--e],i=1;for(;e>0&&(i*=256);)n+=this[t+--e]*i;return n},u.prototype.readUint8=u.prototype.readUInt8=function(t,e){return t>>>=0,e||R(t,1,this.length),this[t]},u.prototype.readUint16LE=u.prototype.readUInt16LE=function(t,e){return t>>>=0,e||R(t,2,this.length),this[t]|this[t+1]<<8},u.prototype.readUint16BE=u.prototype.readUInt16BE=function(t,e){return t>>>=0,e||R(t,2,this.length),this[t]<<8|this[t+1]},u.prototype.readUint32LE=u.prototype.readUInt32LE=function(t,e){return t>>>=0,e||R(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},u.prototype.readUint32BE=u.prototype.readUInt32BE=function(t,e){return t>>>=0,e||R(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},u.prototype.readBigUInt64LE=J(function(t){V(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||W(t,this.length-8);const n=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,i=this[++t]+256*this[++t]+65536*this[++t]+r*2**24;return BigInt(n)+(BigInt(i)<<BigInt(32))}),u.prototype.readBigUInt64BE=J(function(t){V(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||W(t,this.length-8);const n=e*2**24+65536*this[++t]+256*this[++t]+this[++t],i=this[++t]*2**24+65536*this[++t]+256*this[++t]+r;return(BigInt(n)<<BigInt(32))+BigInt(i)}),u.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||R(t,e,this.length);let n=this[t],i=1,o=0;for(;++o<e&&(i*=256);)n+=this[t+o]*i;return i*=128,n>=i&&(n-=Math.pow(2,8*e)),n},u.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||R(t,e,this.length);let n=e,i=1,o=this[t+--n];for(;n>0&&(i*=256);)o+=this[t+--n]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*e)),o},u.prototype.readInt8=function(t,e){return t>>>=0,e||R(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},u.prototype.readInt16LE=function(t,e){t>>>=0,e||R(t,2,this.length);const r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt16BE=function(t,e){t>>>=0,e||R(t,2,this.length);const r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt32LE=function(t,e){return t>>>=0,e||R(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},u.prototype.readInt32BE=function(t,e){return t>>>=0,e||R(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},u.prototype.readBigInt64LE=J(function(t){V(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||W(t,this.length-8);const n=this[t+4]+256*this[t+5]+65536*this[t+6]+(r<<24);return(BigInt(n)<<BigInt(32))+BigInt(e+256*this[++t]+65536*this[++t]+this[++t]*2**24)}),u.prototype.readBigInt64BE=J(function(t){V(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||W(t,this.length-8);const n=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return(BigInt(n)<<BigInt(32))+BigInt(this[++t]*2**24+65536*this[++t]+256*this[++t]+r)}),u.prototype.readFloatLE=function(t,e){return t>>>=0,e||R(t,4,this.length),i.read(this,t,!0,23,4)},u.prototype.readFloatBE=function(t,e){return t>>>=0,e||R(t,4,this.length),i.read(this,t,!1,23,4)},u.prototype.readDoubleLE=function(t,e){return t>>>=0,e||R(t,8,this.length),i.read(this,t,!0,52,8)},u.prototype.readDoubleBE=function(t,e){return t>>>=0,e||R(t,8,this.length),i.read(this,t,!1,52,8)},u.prototype.writeUintLE=u.prototype.writeUIntLE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||U(this,t,e,r,Math.pow(2,8*r)-1,0);let i=1,o=0;for(this[e]=255&t;++o<r&&(i*=256);)this[e+o]=t/i&255;return e+r},u.prototype.writeUintBE=u.prototype.writeUIntBE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||U(this,t,e,r,Math.pow(2,8*r)-1,0);let i=r-1,o=1;for(this[e+i]=255&t;--i>=0&&(o*=256);)this[e+i]=t/o&255;return e+r},u.prototype.writeUint8=u.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,1,255,0),this[e]=255&t,e+1},u.prototype.writeUint16LE=u.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},u.prototype.writeUint16BE=u.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},u.prototype.writeUint32LE=u.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},u.prototype.writeUint32BE=u.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},u.prototype.writeBigUInt64LE=J(function(t,e=0){return N(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))}),u.prototype.writeBigUInt64BE=J(function(t,e=0){return j(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))}),u.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);U(this,t,e,r,n-1,-n)}let i=0,o=1,a=0;for(this[e]=255&t;++i<r&&(o*=256);)t<0&&0===a&&0!==this[e+i-1]&&(a=1),this[e+i]=(t/o|0)-a&255;return e+r},u.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);U(this,t,e,r,n-1,-n)}let i=r-1,o=1,a=0;for(this[e+i]=255&t;--i>=0&&(o*=256);)t<0&&0===a&&0!==this[e+i+1]&&(a=1),this[e+i]=(t/o|0)-a&255;return e+r},u.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},u.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},u.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},u.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},u.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},u.prototype.writeBigInt64LE=J(function(t,e=0){return N(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),u.prototype.writeBigInt64BE=J(function(t,e=0){return j(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),u.prototype.writeFloatLE=function(t,e,r){return C(this,t,e,!0,r)},u.prototype.writeFloatBE=function(t,e,r){return C(this,t,e,!1,r)},u.prototype.writeDoubleLE=function(t,e,r){return F(this,t,e,!0,r)},u.prototype.writeDoubleBE=function(t,e,r){return F(this,t,e,!1,r)},u.prototype.copy=function(t,e,r,n){if(!u.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n<r&&(n=r),n===r)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e<n-r&&(n=t.length-e+r);const i=n-r;return this===t&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(e,r,n):Uint8Array.prototype.set.call(t,this.subarray(r,n),e),i},u.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!u.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===t.length){const e=t.charCodeAt(0);("utf8"===n&&e<128||"latin1"===n)&&(t=e)}}else"number"==typeof t?t&=255:"boolean"==typeof t&&(t=Number(t));if(e<0||this.length<e||this.length<r)throw new RangeError("Out of range index");if(r<=e)return this;let i;if(e>>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(i=e;i<r;++i)this[i]=t;else{const o=u.isBuffer(t)?t:u.from(t,n),a=o.length;if(0===a)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(i=0;i<r-e;++i)this[i+e]=o[i%a]}return this};const D={};function H(t,e,r){D[t]=class extends r{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${t}]`,this.stack,delete this.name}get code(){return t}set code(t){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:t,writable:!0})}toString(){return`${this.name} [${t}]: ${this.message}`}}}function M(t){let e="",r=t.length;const n="-"===t[0]?1:0;for(;r>=n+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}function K(t,e,r,n,i,o){if(t>r||t<e){const n="bigint"==typeof e?"n":"";let i;throw i=o>3?0===e||e===BigInt(0)?`>= 0${n} and < 2${n} ** ${8*(o+1)}${n}`:`>= -(2${n} ** ${8*(o+1)-1}${n}) and < 2 ** ${8*(o+1)-1}${n}`:`>= ${e}${n} and <= ${r}${n}`,new D.ERR_OUT_OF_RANGE("value",i,t)}!function(t,e,r){V(e,"offset"),void 0!==t[e]&&void 0!==t[e+r]||W(e,t.length-(r+1))}(n,i,o)}function V(t,e){if("number"!=typeof t)throw new D.ERR_INVALID_ARG_TYPE(e,"number",t)}function W(t,e,r){if(Math.floor(t)!==t)throw V(t,r),new D.ERR_OUT_OF_RANGE(r||"offset","an integer",t);if(e<0)throw new D.ERR_BUFFER_OUT_OF_BOUNDS;throw new D.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}H("ERR_BUFFER_OUT_OF_BOUNDS",function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),H("ERR_INVALID_ARG_TYPE",function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`},TypeError),H("ERR_OUT_OF_RANGE",function(t,e,r){let n=`The value of "${t}" is out of range.`,i=r;return Number.isInteger(r)&&Math.abs(r)>2**32?i=M(String(r)):"bigint"==typeof r&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=M(i)),i+="n"),n+=` It must be ${e}. Received ${i}`,n},RangeError);const G=/[^+/0-9A-Za-z-_]/g;function q(t,e){let r;e=e||1/0;const n=t.length;let i=null;const o=[];for(let a=0;a<n;++a){if(r=t.charCodeAt(a),r>55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(a+1===n){(e-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;o.push(r)}else if(r<2048){if((e-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function z(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(G,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function Z(t,e,r,n){let i;for(i=0;i<n&&!(i+r>=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function X(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function Y(t){return t!=t}const $=function(){const t="0123456789abcdef",e=new Array(256);for(let r=0;r<16;++r){const n=16*r;for(let i=0;i<16;++i)e[n+i]=t[r]+t[i]}return e}();function J(t){return"undefined"==typeof BigInt?Q:t}function Q(){throw new Error("BigInt not supported")}},307:(t,e,r)=>{var n=r(287).hp;Object.defineProperty(e,"__esModule",{value:!0}),e.makeConverter=function(t){return{decode:function(e){if(e.key[0]!==t)throw new Error("Decode Error: could not decode redeemScript with key 0x"+e.key.toString("hex"));return e.value},encode:function(e){return{key:n.from([t]),value:e}},check:function(t){return n.isBuffer(t)},expected:"Buffer",canAdd:function(t,e){return!!t&&!!e&&void 0===t.redeemScript}}}},343:(t,e)=>{e.p2=e.I=void 0;const r="qpzry9x8gf2tvdw0s3jn54khce6mua7l",n={};for(let t=0;t<32;t++){const e=r.charAt(t);n[e]=t}function i(t){const e=t>>25;return(33554431&t)<<5^996825010&-(1&e)^642813549&-(e>>1&1)^513874426&-(e>>2&1)^1027748829&-(e>>3&1)^705979059&-(e>>4&1)}function o(t){let e=1;for(let r=0;r<t.length;++r){const n=t.charCodeAt(r);if(n<33||n>126)return"Invalid prefix ("+t+")";e=i(e)^n>>5}e=i(e);for(let r=0;r<t.length;++r){const n=t.charCodeAt(r);e=i(e)^31&n}return e}function a(t,e,r,n){let i=0,o=0;const a=(1<<r)-1,s=[];for(let n=0;n<t.length;++n)for(i=i<<e|t[n],o+=e;o>=r;)o-=r,s.push(i>>o&a);if(n)o>0&&s.push(i<<r-o&a);else{if(o>=e)return"Excess padding";if(i<<r-o&a)return"Non-zero padding"}return s}function s(t){return a(t,8,5,!0)}function u(t){const e=a(t,5,8,!1);if(Array.isArray(e))return e}function f(t){const e=a(t,5,8,!1);if(Array.isArray(e))return e;throw new Error(e)}function c(t){let e;function a(t,r){if(r=r||90,t.length<8)return t+" too short";if(t.length>r)return"Exceeds length limit";const a=t.toLowerCase(),s=t.toUpperCase();if(t!==a&&t!==s)return"Mixed-case string "+t;const u=(t=a).lastIndexOf("1");if(-1===u)return"No separator character for "+t;if(0===u)return"Missing prefix for "+t;const f=t.slice(0,u),c=t.slice(u+1);if(c.length<6)return"Data too short";let l=o(f);if("string"==typeof l)return l;const h=[];for(let t=0;t<c.length;++t){const e=c.charAt(t),r=n[e];if(void 0===r)return"Unknown character "+e;l=i(l)^r,t+6>=c.length||h.push(r)}return l!==e?"Invalid checksum for "+t:{prefix:f,words:h}}return e="bech32"===t?1:734539939,{decodeUnsafe:function(t,e){const r=a(t,e);if("object"==typeof r)return r},decode:function(t,e){const r=a(t,e);if("object"==typeof r)return r;throw new Error(r)},encode:function(t,n,a){if(a=a||90,t.length+7+n.length>a)throw new TypeError("Exceeds length limit");let s=o(t=t.toLowerCase());if("string"==typeof s)throw new Error(s);let u=t+"1";for(let t=0;t<n.length;++t){const e=n[t];if(e>>5)throw new Error("Non 5-bit word");s=i(s)^e,u+=r.charAt(e)}for(let t=0;t<6;++t)s=i(s);s^=e;for(let t=0;t<6;++t)u+=r.charAt(s>>5*(5-t)&31);return u},toWords:s,fromWordsUnsafe:u,fromWords:f}}e.I=c("bech32"),e.p2=c("bech32m")},344:(t,e,r)=>{var n=r(287).hp;Object.defineProperty(e,"__esModule",{value:!0});const i=r(80);e.decode=function(t){if(t.key[0]!==i.InputTypes.SIGHASH_TYPE)throw new Error("Decode Error: could not decode sighashType with key 0x"+t.key.toString("hex"));return t.value.readUInt32LE(0)},e.encode=function(t){const e=n.from([i.InputTypes.SIGHASH_TYPE]),r=n.allocUnsafe(4);return r.writeUInt32LE(t,0),{key:e,value:r}},e.expected="number",e.check=function(t){return"number"==typeof t},e.canAdd=function(t,e){return!!t&&!!e&&void 0===t.sighashType}},394:(t,e,r)=>{var n=r(287).hp;function i(t){if(t<0||t>9007199254740991||t%1!=0)throw new RangeError("value out of range")}function o(t){return i(t),t<253?1:t<=65535?3:t<=4294967295?5:9}Object.defineProperty(e,"__esModule",{value:!0}),e.encode=function t(e,r,a){if(i(e),r||(r=n.allocUnsafe(o(e))),!n.isBuffer(r))throw new TypeError("buffer must be a Buffer instance");return a||(a=0),e<253?(r.writeUInt8(e,a),Object.assign(t,{bytes:1})):e<=65535?(r.writeUInt8(253,a),r.writeUInt16LE(e,a+1),Object.assign(t,{bytes:3})):e<=4294967295?(r.writeUInt8(254,a),r.writeUInt32LE(e,a+1),Object.assign(t,{bytes:5})):(r.writeUInt8(255,a),r.writeUInt32LE(e>>>0,a+1),r.writeUInt32LE(e/4294967296|0,a+5),Object.assign(t,{bytes:9})),r},e.decode=function t(e,r){if(!n.isBuffer(e))throw new TypeError("buffer must be a Buffer instance");r||(r=0);const o=e.readUInt8(r);if(o<253)return Object.assign(t,{bytes:1}),o;if(253===o)return Object.assign(t,{bytes:3}),e.readUInt16LE(r+1);if(254===o)return Object.assign(t,{bytes:5}),e.readUInt32LE(r+1);{Object.assign(t,{bytes:9});const n=e.readUInt32LE(r+1),o=4294967296*e.readUInt32LE(r+5)+n;return i(o),o}},e.encodingLength=o},412:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.makeChecker=function(t){return function(e){let r;if(t.includes(e.key[0])&&(r=e.key.slice(1),33!==r.length&&65!==r.length||![2,3,4].includes(r[0])))throw new Error("Format Error: invalid pubkey in key 0x"+e.key.toString("hex"));return r}}},431:(t,e,r)=>{var n=r(287).hp;Object.defineProperty(e,"__esModule",{value:!0});const i=r(80);e.decode=function(t){if(t.key[0]!==i.InputTypes.NON_WITNESS_UTXO)throw new Error("Decode Error: could not decode nonWitnessUtxo with key 0x"+t.key.toString("hex"));return t.value},e.encode=function(t){return{key:n.from([i.InputTypes.NON_WITNESS_UTXO]),value:t}},e.expected="Buffer",e.check=function(t){return n.isBuffer(t)},e.canAdd=function(t,e){return!!t&&!!e&&void 0===t.nonWitnessUtxo}},454:(t,e,r)=>{var n=r(287).hp;Object.defineProperty(e,"__esModule",{value:!0});const i=r(80);function o(t){return n.isBuffer(t)&&32===t.length}e.decode=function(t){if(t.key[0]!==i.InputTypes.TAP_MERKLE_ROOT||1!==t.key.length)throw new Error("Decode Error: could not decode tapMerkleRoot with key 0x"+t.key.toString("hex"));if(!o(t.value))throw new Error("Decode Error: tapMerkleRoot not a 32-byte hash");return t.value},e.encode=function(t){return{key:n.from([i.InputTypes.TAP_MERKLE_ROOT]),value:t}},e.expected="Buffer",e.check=o,e.canAdd=function(t,e){return!!t&&!!e&&void 0===t.tapMerkleRoot}},457:(t,e,r)=>{function n(t){for(var r in t)e.hasOwnProperty(r)||(e[r]=t[r])}Object.defineProperty(e,"__esModule",{value:!0}),n(r(263)),n(r(238))},526:(t,e)=>{e.byteLength=function(t){var e=s(t),r=e[0],n=e[1];return 3*(r+n)/4-n},e.toByteArray=function(t){var e,r,o=s(t),a=o[0],u=o[1],f=new i(function(t,e,r){return 3*(e+r)/4-r}(0,a,u)),c=0,l=u>0?a-4:a;for(r=0;r<l;r+=4)e=n[t.charCodeAt(r)]<<18|n[t.charCodeAt(r+1)]<<12|n[t.charCodeAt(r+2)]<<6|n[t.charCodeAt(r+3)],f[c++]=e>>16&255,f[c++]=e>>8&255,f[c++]=255&e;return 2===u&&(e=n[t.charCodeAt(r)]<<2|n[t.charCodeAt(r+1)]>>4,f[c++]=255&e),1===u&&(e=n[t.charCodeAt(r)]<<10|n[t.charCodeAt(r+1)]<<4|n[t.charCodeAt(r+2)]>>2,f[c++]=e>>8&255,f[c++]=255&e),f},e.fromByteArray=function(t){for(var e,n=t.length,i=n%3,o=[],a=16383,s=0,f=n-i;s<f;s+=a)o.push(u(t,s,s+a>f?f:s+a));return 1===i?(e=t[n-1],o.push(r[e>>2]+r[e<<4&63]+"==")):2===i&&(e=(t[n-2]<<8)+t[n-1],o.push(r[e>>10]+r[e>>4&63]+r[e<<2&63]+"=")),o.join("")};for(var r=[],n=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0;a<64;++a)r[a]=o[a],n[o.charCodeAt(a)]=a;function s(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function u(t,e,n){for(var i,o,a=[],s=e;s<n;s+=3)i=(t[s]<<16&16711680)+(t[s+1]<<8&65280)+(255&t[s+2]),a.push(r[(o=i)>>18&63]+r[o>>12&63]+r[o>>6&63]+r[63&o]);return a.join("")}n["-".charCodeAt(0)]=62,n["_".charCodeAt(0)]=63},542:(t,e,r)=>{var n=r(287).hp,i=r(113),o=r(61);function a(t){return n.isBuffer(t)}function s(t){return"string"==typeof t&&/^([0-9a-f]{2})+$/i.test(t)}function u(t,e){var r=t.toJSON();function n(n){if(!t(n))return!1;if(n.length===e)return!0;throw o.tfCustomError(r+"(Length: "+e+")",r+"(Length: "+n.length+")")}return n.toJSON=function(){return r},n}var f=u.bind(null,i.Array),c=u.bind(null,a),l=u.bind(null,s),h=u.bind(null,i.String),p=Math.pow(2,53)-1,d={ArrayN:f,Buffer:a,BufferN:c,Finite:function(t){return"number"==typeof t&&isFinite(t)},Hex:s,HexN:l,Int8:function(t){return t<<24>>24===t},Int16:function(t){return t<<16>>16===t},Int32:function(t){return(0|t)===t},Int53:function(t){return"number"==typeof t&&t>=-p&&t<=p&&Math.floor(t)===t},Range:function(t,e,r){function n(n,i){return r(n,i)&&n>t&&n<e}return r=r||i.Number,n.toJSON=function(){return`${r.toJSON()} between [${t}, ${e}]`},n},StringN:h,UInt8:function(t){return(255&t)===t},UInt16:function(t){return(65535&t)===t},UInt32:function(t){return t>>>0===t},UInt53:function(t){return"number"==typeof t&&t>=0&&t<=p&&Math.floor(t)===t}};for(var y in d)d[y].toJSON=function(t){return t}.bind(null,y);t.exports=d},545:(t,e,r)=>{var n=r(287).hp;Object.defineProperty(e,"__esModule",{value:!0});const i=t=>33===t.length&&[2,3].includes(t[0])||65===t.length&&4===t[0];e.makeConverter=function(t,e=i){return{decode:function(r){if(r.key[0]!==t)throw new Error("Decode Error: could not decode bip32Derivation with key 0x"+r.key.toString("hex"));const n=r.key.slice(1);if(!e(n))throw new Error("Decode Error: bip32Derivation has invalid pubkey in key 0x"+r.key.toString("hex"));if(r.value.length/4%1!=0)throw new Error("Decode Error: Input BIP32_DERIVATION value length should be multiple of 4");const i={masterFingerprint:r.value.slice(0,4),pubkey:n,path:"m"};for(const t of(o=r.value.length/4-1,[...Array(o).keys()])){const e=r.value.readUInt32LE(4*t+4),n=!!(2147483648&e),o=2147483647&e;i.path+="/"+o.toString(10)+(n?"'":"")}var o;return i},encode:function(e){const r=n.from([t]),i=n.concat([r,e.pubkey]),o=e.path.split("/"),a=n.allocUnsafe(4*o.length);e.masterFingerprint.copy(a,0);let s=4;return o.slice(1).forEach(t=>{const e="'"===t.slice(-1);let r=2147483647&parseInt(e?t.slice(0,-1):t,10);e&&(r+=2147483648),a.writeUInt32LE(r,s),s+=4}),{key:i,value:a}},check:function(t){return n.isBuffer(t.pubkey)&&n.isBuffer(t.masterFingerprint)&&"string"==typeof t.path&&e(t.pubkey)&&4===t.masterFingerprint.length},expected:"{ masterFingerprint: Buffer; pubkey: Buffer; path: string; }",canAddToArray:function(t,e,r){const n=e.pubkey.toString("hex");return!r.has(n)&&(r.add(n),0===t.filter(t=>t.pubkey.equals(e.pubkey)).length)}}}},578:(t,e,r)=>{var n=r(287).hp;Object.defineProperty(e,"__esModule",{value:!0}),e.makeConverter=function(t){return{decode:function(e){if(e.key[0]!==t)throw new Error("Decode Error: could not decode witnessScript with key 0x"+e.key.toString("hex"));return e.value},encode:function(e){return{key:n.from([t]),value:e}},check:function(t){return n.isBuffer(t)},expected:"Buffer",canAdd:function(t,e){return!!t&&!!e&&void 0===t.witnessScript}}}},605:(t,e,r)=>{var n=r(287).hp;Object.defineProperty(e,"__esModule",{value:!0});const i=r(80);e.decode=function(t){if(t.key[0]!==i.InputTypes.FINAL_SCRIPTSIG)throw new Error("Decode Error: could not decode finalScriptSig with key 0x"+t.key.toString("hex"));return t.value},e.encode=function(t){return{key:n.from([i.InputTypes.FINAL_SCRIPTSIG]),value:t}},e.expected="Buffer",e.check=function(t){return n.isBuffer(t)},e.canAdd=function(t,e){return!!t&&!!e&&void 0===t.finalScriptSig}},614:(t,e,r)=>{var n=r(287).hp;const i=r(863),o=r(457),a=r(80),s=r(699);e.i=class{constructor(t){this.inputs=[],this.outputs=[],this.globalMap={unsignedTx:t}}static fromBase64(t,e){const r=n.from(t,"base64");return this.fromBuffer(r,e)}static fromHex(t,e){const r=n.from(t,"hex");return this.fromBuffer(r,e)}static fromBuffer(t,e){const r=o.psbtFromBuffer(t,e),n=new this(r.globalMap.unsignedTx);return Object.assign(n,r),n}toBase64(){return this.toBuffer().toString("base64")}toHex(){return this.toBuffer().toString("hex")}toBuffer(){return o.psbtToBuffer(this)}updateGlobal(t){return s.updateGlobal(t,this.globalMap),this}updateInput(t,e){const r=s.checkForInput(this.inputs,t);return s.updateInput(e,r),this}updateOutput(t,e){const r=s.checkForOutput(this.outputs,t);return s.updateOutput(e,r),this}addUnknownKeyValToGlobal(t){return s.checkHasKey(t,this.globalMap.unknownKeyVals,s.getEnumLength(a.GlobalTypes)),this.globalMap.unknownKeyVals||(this.globalMap.unknownKeyVals=[]),this.globalMap.unknownKeyVals.push(t),this}addUnknownKeyValToInput(t,e){const r=s.checkForInput(this.inputs,t);return s.checkHasKey(e,r.unknownKeyVals,s.getEnumLength(a.InputTypes)),r.unknownKeyVals||(r.unknownKeyVals=[]),r.unknownKeyVals.push(e),this}addUnknownKeyValToOutput(t,e){const r=s.checkForOutput(this.outputs,t);return s.checkHasKey(e,r.unknownKeyVals,s.getEnumLength(a.OutputTypes)),r.unknownKeyVals||(r.unknownKeyVals=[]),r.unknownKeyVals.push(e),this}addInput(t){this.globalMap.unsignedTx.addInput(t),this.inputs.push({unknownKeyVals:[]});const e=t.unknownKeyVals||[],r=this.inputs.length-1;if(!Array.isArray(e))throw new Error("unknownKeyVals must be an Array");return e.forEach(t=>this.addUnknownKeyValToInput(r,t)),s.addInputAttributes(this.inputs,t),this}addOutput(t){this.globalMap.unsignedTx.addOutput(t),this.outputs.push({unknownKeyVals:[]});const e=t.unknownKeyVals||[],r=this.outputs.length-1;if(!Array.isArray(e))throw new Error("unknownKeyVals must be an Array");return e.forEach(t=>this.addUnknownKeyValToOutput(r,t)),s.addOutputAttributes(this.outputs,t),this}clearFinalizedInput(t){const e=s.checkForInput(this.inputs,t);s.inputCheckUncleanFinalized(t,e);for(const t of Object.keys(e))["witnessUtxo","nonWitnessUtxo","finalScriptSig","finalScriptWitness","unknownKeyVals"].includes(t)||delete e[t];return this}combine(...t){const e=i.combine([this].concat(t));return Object.assign(this,e),this}getTransaction(){return this.globalMap.unsignedTx.toBuffer()}}},636:(t,e,r)=>{var n=r(287).hp;Object.defineProperty(e,"__esModule",{value:!0});const i=r(394),o=r(545),a=t=>32===t.length;e.makeConverter=function(t){const e=o.makeConverter(t,a);return{decode:function(t){const r=i.decode(t.value),n=i.encodingLength(r),o=e.decode({key:t.key,value:t.value.slice(n+32*r)}),a=new Array(r);for(let e=0,i=n;e<r;e++,i+=32)a[e]=t.value.slice(i,i+32);return Object.assign({},o,{leafHashes:a})},encode:function(t){const r=e.encode(t),o=i.encodingLength(t.leafHashes.length),a=n.allocUnsafe(o);i.encode(t.leafHashes.length,a);const s=n.concat([a,...t.leafHashes,r.value]);return Object.assign({},r,{value:s})},check:function(t){return Array.isArray(t.leafHashes)&&t.leafHashes.every(t=>n.isBuffer(t)&&32===t.length)&&e.check(t)},expected:"{ masterFingerprint: Buffer; pubkey: Buffer; path: string; leafHashes: Buffer[]; }",canAddToArray:e.canAddToArray}}},676:(t,e,r)=>{var n=r(61),i=r(113),o=n.tfJSON,a=n.TfTypeError,s=n.TfPropertyTypeError,u=n.tfSubError,f=n.getValueTypeName,c={arrayOf:function(t,e){function r(r,n){return!!i.Array(r)&&!i.Nil(r)&&!(void 0!==e.minLength&&r.length<e.minLength)&&!(void 0!==e.maxLength&&r.length>e.maxLength)&&(void 0===e.length||r.length===e.length)&&r.every(function(e,r){try{return h(t,e,n)}catch(t){throw u(t,r)}})}return t=l(t),e=e||{},r.toJSON=function(){var r="["+o(t)+"]";return void 0!==e.length?r+="{"+e.length+"}":void 0===e.minLength&&void 0===e.maxLength||(r+="{"+(void 0===e.minLength?0:e.minLength)+","+(void 0===e.maxLength?1/0:e.maxLength)+"}"),r},r},maybe:function t(e){function r(r,n){return i.Nil(r)||e(r,n,t)}return e=l(e),r.toJSON=function(){return"?"+o(e)},r},map:function(t,e){function r(r,n){if(!i.Object(r))return!1;if(i.Nil(r))return!1;for(var o in r){try{e&&h(e,o,n)}catch(t){throw u(t,o,"key")}try{var a=r[o];h(t,a,n)}catch(t){throw u(t,o)}}return!0}return t=l(t),e&&(e=l(e)),r.toJSON=e?function(){return"{"+o(e)+": "+o(t)+"}"}:function(){return"{"+o(t)+"}"},r},object:function(t){var e={};for(var r in t)e[r]=l(t[r]);function n(t,r){if(!i.Object(t))return!1;if(i.Nil(t))return!1;var n;try{for(n in e)h(e[n],t[n],r)}catch(t){throw u(t,n)}if(r)for(n in t)if(!e[n])throw new s(void 0,n);return!0}return n.toJSON=function(){return o(e)},n},anyOf:function(){var t=[].slice.call(arguments).map(l);function e(e,r){return t.some(function(t){try{return h(t,e,r)}catch(t){return!1}})}return e.toJSON=function(){return t.map(o).join("|")},e},allOf:function(){var t=[].slice.call(arguments).map(l);function e(e,r){return t.every(function(t){try{return h(t,e,r)}catch(t){return!1}})}return e.toJSON=function(){return t.map(o).join(" & ")},e},quacksLike:function(t){function e(e){return t===f(e)}return e.toJSON=function(){return t},e},tuple:function(){var t=[].slice.call(arguments).map(l);function e(e,r){return!i.Nil(e)&&!i.Nil(e.length)&&(!r||e.length===t.length)&&t.every(function(t,n){try{return h(t,e[n],r)}catch(t){throw u(t,n)}})}return e.toJSON=function(){return"("+t.map(o).join(", ")+")"},e},value:function(t){function e(e){return e===t}return e.toJSON=function(){return t},e}};function l(t){if(i.String(t))return"?"===t[0]?c.maybe(t.slice(1)):i[t]||c.quacksLike(t);if(t&&i.Object(t)){if(i.Array(t)){if(1!==t.length)throw new TypeError("Expected compile() parameter of type Array of length 1");return c.arrayOf(t[0])}return c.object(t)}return i.Function(t)?t:c.value(t)}function h(t,e,r,n){if(i.Function(t)){if(t(e,r))return!0;throw new a(n||t,e)}return h(l(t),e,r)}for(var p in c.oneOf=c.anyOf,i)h[p]=i[p];for(p in c)h[p]=c[p];var d=r(542);for(p in d)h[p]=d[p];h.compile=l,h.TfTypeError=a,h.TfPropertyTypeError=s,t.exports=h},695:(t,e,r)=>{var n=r(287).hp;Object.defineProperty(e,"__esModule",{value:!0});const i=r(80);e.decode=function(t){if(t.key[0]!==i.InputTypes.TAP_LEAF_SCRIPT)throw new Error("Decode Error: could not decode tapLeafScript with key 0x"+t.key.toString("hex"));if((t.key.length-2)%32!=0)throw new Error("Decode Error: tapLeafScript has invalid control block in key 0x"+t.key.toString("hex"));const e=t.value[t.value.length-1];if((254&t.key[1])!==e)throw new Error("Decode Error: tapLeafScript bad leaf version in key 0x"+t.key.toString("hex"));const r=t.value.slice(0,-1);return{controlBlock:t.key.slice(1),script:r,leafVersion:e}},e.encode=function(t){const e=n.from([i.InputTypes.TAP_LEAF_SCRIPT]),r=n.from([t.leafVersion]);return{key:n.concat([e,t.controlBlock]),value:n.concat([t.script,r])}},e.expected="{ controlBlock: Buffer; leafVersion: number, script: Buffer; }",e.check=function(t){return n.isBuffer(t.controlBlock)&&(t.controlBlock.length-1)%32==0&&(254&t.controlBlock[0])===t.leafVersion&&n.isBuffer(t.script)},e.canAddToArray=function(t,e,r){const n=e.controlBlock.toString("hex");return!r.has(n)&&(r.add(n),0===t.filter(t=>t.controlBlock.equals(e.controlBlock)).length)}},699:(t,e,r)=>{var n=r(287).hp;Object.defineProperty(e,"__esModule",{value:!0});const i=r(706);function o(t,e){const r=t[e];if(void 0===r)throw new Error(`No input #${e}`);return r}function a(t,e){const r=t[e];if(void 0===r)throw new Error(`No output #${e}`);return r}function s(t,e,r,n){throw new Error(`Data for ${t} key ${e} is incorrect: Expected ${r} and got ${JSON.stringify(n)}`)}function u(t){return(e,r)=>{for(const n of Object.keys(e)){const o=e[n],{canAdd:a,canAddToArray:u,check:f,expected:c}=i[t+"s"][n]||{};if(f)if(u){if(!Array.isArray(o)||r[n]&&!Array.isArray(r[n]))throw new Error(`Key type ${n} must be an array`);o.every(f)||s(t,n,c,o);const e=r[n]||[],i=new Set;if(!o.every(t=>u(e,t,i)))throw new Error("Can not add duplicate data to array");r[n]=e.concat(o)}else{if(f(o)||s(t,n,c,o),!a(r,o))throw new Error(`Can not add duplicate data to ${t}`);r[n]=o}}}}e.checkForInput=o,e.checkForOutput=a,e.checkHasKey=function(t,e,r){if(t.key[0]<r)throw new Error("Use the method for your specific key instead of addUnknownKeyVal*");if(e&&0!==e.filter(e=>e.key.equals(t.key)).length)throw new Error(`Duplicate Key: ${t.key.toString("hex")}`)},e.getEnumLength=function(t){let e=0;return Object.keys(t).forEach(t=>{Number(isNaN(Number(t)))&&e++}),e},e.inputCheckUncleanFinalized=function(t,e){let r=!1;if(e.nonWitnessUtxo||e.witnessUtxo){const t=!!e.redeemScript,n=!!e.witnessScript,i=!t||!!e.finalScriptSig,o=!n||!!e.finalScriptWitness,a=!!e.finalScriptSig||!!e.finalScriptWitness;r=i&&o&&a}if(!1===r)throw new Error(`Input #${t} has too much or too little data to clean`)},e.updateGlobal=u("global"),e.updateInput=u("input"),e.updateOutput=u("output"),e.addInputAttributes=function(t,r){const n=o(t,t.length-1);e.updateInput(r,n)},e.addOutputAttributes=function(t,r){const n=a(t,t.length-1);e.updateOutput(r,n)},e.defaultVersionSetter=function(t,e){if(!n.isBuffer(e)||e.length<4)throw new Error("Set Version: Invalid Transaction");return e.writeUInt32LE(t,0),e},e.defaultLocktimeSetter=function(t,e){if(!n.isBuffer(e)||e.length<4)throw new Error("Set Locktime: Invalid Transaction");return e.writeUInt32LE(t,e.length-4),e}},706:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0});const n=r(80),i=r(834),o=r(213),a=r(605),s=r(795),u=r(431),f=r(907),c=r(949),l=r(344),h=r(760),p=r(695),d=r(454),y=r(34),b=r(926),g=r(851),v=r(545),w=r(412),m=r(307),S=r(636),_=r(223),E=r(578),k={unsignedTx:o,globalXpub:i,checkPubkey:w.makeChecker([])};e.globals=k;const O={nonWitnessUtxo:u,partialSig:f,sighashType:l,finalScriptSig:a,finalScriptWitness:s,porCommitment:c,witnessUtxo:b,bip32Derivation:v.makeConverter(n.InputTypes.BIP32_DERIVATION),redeemScript:m.makeConverter(n.InputTypes.REDEEM_SCRIPT),witnessScript:E.makeConverter(n.InputTypes.WITNESS_SCRIPT),checkPubkey:w.makeChecker([n.InputTypes.PARTIAL_SIG,n.InputTypes.BIP32_DERIVATION]),tapKeySig:h,tapScriptSig:y,tapLeafScript:p,tapBip32Derivation:S.makeConverter(n.InputTypes.TAP_BIP32_DERIVATION),tapInternalKey:_.makeConverter(n.InputTypes.TAP_INTERNAL_KEY),tapMerkleRoot:d};e.inputs=O;const T={bip32Derivation:v.makeConverter(n.OutputTypes.BIP32_DERIVATION),redeemScript:m.makeConverter(n.OutputTypes.REDEEM_SCRIPT),witnessScript:E.makeConverter(n.OutputTypes.WITNESS_SCRIPT),checkPubkey:w.makeChecker([n.OutputTypes.BIP32_DERIVATION]),tapBip32Derivation:S.makeConverter(n.OutputTypes.TAP_BIP32_DERIVATION),tapTree:g,tapInternalKey:_.makeConverter(n.OutputTypes.TAP_INTERNAL_KEY)};e.outputs=T},760:(t,e,r)=>{var n=r(287).hp;Object.defineProperty(e,"__esModule",{value:!0});const i=r(80);function o(t){return n.isBuffer(t)&&(64===t.length||65===t.length)}e.decode=function(t){if(t.key[0]!==i.InputTypes.TAP_KEY_SIG||1!==t.key.length)throw new Error("Decode Error: could not decode tapKeySig with key 0x"+t.key.toString("hex"));if(!o(t.value))throw new Error("Decode Error: tapKeySig not a valid 64-65-byte BIP340 signature");return t.value},e.encode=function(t){return{key:n.from([i.InputTypes.TAP_KEY_SIG]),value:t}},e.expected="Buffer",e.check=o,e.canAdd=function(t,e){return!!t&&!!e&&void 0===t.tapKeySig}},795:(t,e,r)=>{var n=r(287).hp;Object.defineProperty(e,"__esModule",{value:!0});const i=r(80);e.decode=function(t){if(t.key[0]!==i.InputTypes.FINAL_SCRIPTWITNESS)throw new Error("Decode Error: could not decode finalScriptWitness with key 0x"+t.key.toString("hex"));return t.value},e.encode=function(t){return{key:n.from([i.InputTypes.FINAL_SCRIPTWITNESS]),value:t}},e.expected="Buffer",e.check=function(t){return n.isBuffer(t)},e.canAdd=function(t,e){return!!t&&!!e&&void 0===t.finalScriptWitness}},834:(t,e,r)=>{var n=r(287).hp;Object.defineProperty(e,"__esModule",{value:!0});const i=r(80);e.decode=function(t){if(t.key[0]!==i.GlobalTypes.GLOBAL_XPUB)throw new Error("Decode Error: could not decode globalXpub with key 0x"+t.key.toString("hex"));if(79!==t.key.length||![2,3].includes(t.key[46]))throw new Error("Decode Error: globalXpub has invalid extended pubkey in key 0x"+t.key.toString("hex"));if(t.value.length/4%1!=0)throw new Error("Decode Error: Global GLOBAL_XPUB value length should be multiple of 4");const e=t.key.slice(1),r={masterFingerprint:t.value.slice(0,4),extendedPubkey:e,path:"m"};for(const e of(n=t.value.length/4-1,[...Array(n).keys()])){const n=t.value.readUInt32LE(4*e+4),i=!!(2147483648&n),o=2147483647&n;r.path+="/"+o.toString(10)+(i?"'":"")}var n;return r},e.encode=function(t){const e=n.from([i.GlobalTypes.GLOBAL_XPUB]),r=n.concat([e,t.extendedPubkey]),o=t.path.split("/"),a=n.allocUnsafe(4*o.length);t.masterFingerprint.copy(a,0);let s=4;return o.slice(1).forEach(t=>{const e="'"===t.slice(-1);let r=2147483647&parseInt(e?t.slice(0,-1):t,10);e&&(r+=2147483648),a.writeUInt32LE(r,s),s+=4}),{key:r,value:a}},e.expected="{ masterFingerprint: Buffer; extendedPubkey: Buffer; path: string; }",e.check=function(t){const e=t.extendedPubkey,r=t.masterFingerprint,i=t.path;return n.isBuffer(e)&&78===e.length&&[2,3].indexOf(e[45])>-1&&n.isBuffer(r)&&4===r.length&&"string"==typeof i&&!!i.match(/^m(\/\d+'?)*$/)},e.canAddToArray=function(t,e,r){const n=e.extendedPubkey.toString("hex");return!r.has(n)&&(r.add(n),0===t.filter(t=>t.extendedPubkey.equals(e.extendedPubkey)).length)}},851:(t,e,r)=>{var n=r(287).hp;Object.defineProperty(e,"__esModule",{value:!0});const i=r(80),o=r(394);e.decode=function(t){if(t.key[0]!==i.OutputTypes.TAP_TREE||1!==t.key.length)throw new Error("Decode Error: could not decode tapTree with key 0x"+t.key.toString("hex"));let e=0;const r=[];for(;e<t.value.length;){const n=t.value[e++],i=t.value[e++],a=o.decode(t.value,e);e+=o.encodingLength(a),r.push({depth:n,leafVersion:i,script:t.value.slice(e,e+a)}),e+=a}return{leaves:r}},e.encode=function(t){const e=n.from([i.OutputTypes.TAP_TREE]),r=[].concat(...t.leaves.map(t=>[n.of(t.depth,t.leafVersion),o.encode(t.script.length),t.script]));return{key:e,value:n.concat(r)}},e.expected="{ leaves: [{ depth: number; leafVersion: number, script: Buffer; }] }",e.check=function(t){return Array.isArray(t.leaves)&&t.leaves.every(t=>t.depth>=0&&t.depth<=128&&(254&t.leafVersion)===t.leafVersion&&n.isBuffer(t.script))},e.canAdd=function(t,e){return!!t&&!!e&&void 0===t.tapTree}},863:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0});const n=r(457);function i(t,e,r){return n=>{if(t.has(n))return;const i=r.filter(t=>t.key.toString("hex")===n)[0];e.push(i),t.add(n)}}function o(t){return t.globalMap.unsignedTx}function a(t){const e=new Set;return t.forEach(t=>{const r=t.key.toString("hex");if(e.has(r))throw new Error("Combine: KeyValue Map keys should be unique");e.add(r)}),e}e.combine=function(t){const e=t[0],r=n.psbtToKeyVals(e),s=t.slice(1);if(0===s.length)throw new Error("Combine: Nothing to combine");const u=o(e);if(void 0===u)throw new Error("Combine: Self missing transaction");const f=a(r.globalKeyVals),c=r.inputKeyVals.map(a),l=r.outputKeyVals.map(a);for(const t of s){const e=o(t);if(void 0===e||!e.toBuffer().equals(u.toBuffer()))throw new Error("Combine: One of the Psbts does not have the same transaction.");const s=n.psbtToKeyVals(t);a(s.globalKeyVals).forEach(i(f,r.globalKeyVals,s.globalKeyVals)),s.inputKeyVals.map(a).forEach((t,e)=>t.forEach(i(c[e],r.inputKeyVals[e],s.inputKeyVals[e]))),s.outputKeyVals.map(a).forEach((t,e)=>t.forEach(i(l[e],r.outputKeyVals[e],s.outputKeyVals[e])))}return n.psbtFromKeyVals(u,{globalMapKeyVals:r.globalKeyVals,inputKeyVals:r.inputKeyVals,outputKeyVals:r.outputKeyVals})}},907:(t,e,r)=>{var n=r(287).hp;Object.defineProperty(e,"__esModule",{value:!0});const i=r(80);e.decode=function(t){if(t.key[0]!==i.InputTypes.PARTIAL_SIG)throw new Error("Decode Error: could not decode partialSig with key 0x"+t.key.toString("hex"));if(34!==t.key.length&&66!==t.key.length||![2,3,4].includes(t.key[1]))throw new Error("Decode Error: partialSig has invalid pubkey in key 0x"+t.key.toString("hex"));return{pubkey:t.key.slice(1),signature:t.value}},e.encode=function(t){const e=n.from([i.InputTypes.PARTIAL_SIG]);return{key:n.concat([e,t.pubkey]),value:t.signature}},e.expected="{ pubkey: Buffer; signature: Buffer; }",e.check=function(t){return n.isBuffer(t.pubkey)&&n.isBuffer(t.signature)&&[33,65].includes(t.pubkey.length)&&[2,3,4].includes(t.pubkey[0])&&function(t){if(!n.isBuffer(t)||t.length<9)return!1;if(48!==t[0])return!1;if(t.length!==t[1]+3)return!1;if(2!==t[2])return!1;const e=t[3];if(e>33||e<1)return!1;if(2!==t[3+e+1])return!1;const r=t[3+e+2];return!(r>33||r<1)&&t.length===3+e+2+r+2}(t.signature)},e.canAddToArray=function(t,e,r){const n=e.pubkey.toString("hex");return!r.has(n)&&(r.add(n),0===t.filter(t=>t.pubkey.equals(e.pubkey)).length)}},926:(t,e,r)=>{var n=r(287).hp;Object.defineProperty(e,"__esModule",{value:!0});const i=r(80),o=r(133),a=r(394);e.decode=function(t){if(t.key[0]!==i.InputTypes.WITNESS_UTXO)throw new Error("Decode Error: could not decode witnessUtxo with key 0x"+t.key.toString("hex"));const e=o.readUInt64LE(t.value,0);let r=8;const n=a.decode(t.value,r);r+=a.encodingLength(n);const s=t.value.slice(r);if(s.length!==n)throw new Error("Decode Error: WITNESS_UTXO script is not proper length");return{script:s,value:e}},e.encode=function(t){const{script:e,value:r}=t,s=a.encodingLength(e.length),u=n.allocUnsafe(8+s+e.length);return o.writeUInt64LE(u,r,0),a.encode(e.length,u,8),e.copy(u,8+s),{key:n.from([i.InputTypes.WITNESS_UTXO]),value:u}},e.expected="{ script: Buffer; value: number; }",e.check=function(t){return n.isBuffer(t.script)&&"number"==typeof t.value},e.canAdd=function(t,e){return!!t&&!!e&&void 0===t.witnessUtxo}},949:(t,e,r)=>{var n=r(287).hp;Object.defineProperty(e,"__esModule",{value:!0});const i=r(80);e.decode=function(t){if(t.key[0]!==i.InputTypes.POR_COMMITMENT)throw new Error("Decode Error: could not decode porCommitment with key 0x"+t.key.toString("hex"));return t.value.toString("utf8")},e.encode=function(t){return{key:n.from([i.InputTypes.POR_COMMITMENT]),value:n.from(t,"utf8")}},e.expected="string",e.check=function(t){return"string"==typeof t},e.canAdd=function(t,e){return!!t&&!!e&&void 0===t.porCommitment}}},d={};function y(t){var e=d[t];if(void 0!==e)return e.exports;var r=d[t]={exports:{}};return p[t](r,r.exports,y),r.exports}y.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return y.d(e,{a:e}),e},y.d=(t,e)=>{for(var r in e)y.o(e,r)&&!y.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},y.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),y.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var b={};y.r(b),y.d(b,{bitcoin:()=>O,bitcoinCash:()=>R,bitcoinCashTestnet:()=>U,dash:()=>N,dashTestnet:()=>j,dogecoin:()=>I,dogecoinTestnet:()=>P,litecoin:()=>x,litecoinTestnet:()=>B,regtest:()=>T,testnet:()=>A});var g={};y.r(g),y.d(g,{decode:()=>pt,encode:()=>dt});var v={};y.r(v),y.d(v,{decode:()=>Gt,encode:()=>qt});var w={};y.r(w),y.d(w,{OPS:()=>it,compile:()=>re,countNonPushOnlyOPs:()=>Jt,decompile:()=>ne,fromASM:()=>oe,isCanonicalPubKey:()=>se,isCanonicalScriptSignature:()=>fe,isDefinedHashType:()=>ue,isPushOnly:()=>$t,number:()=>ce,signature:()=>le,toASM:()=>ie,toStack:()=>ae});var m={};y.r(m),y.d(m,{FUTURE_MAX_VERSION:()=>ge,FUTURE_OPNET_VERSION:()=>ve,FUTURE_SEGWIT_MAX_SIZE:()=>de,FUTURE_SEGWIT_MAX_VERSION:()=>be,FUTURE_SEGWIT_MIN_SIZE:()=>ye,FUTURE_SEGWIT_MIN_VERSION:()=>we,FUTURE_SEGWIT_VERSION_DIFF:()=>me,_toFutureSegwitAddress:()=>ke,fromBase58Check:()=>Oe,fromBech32:()=>Te,fromOutputScript:()=>Pe,isUnknownSegwitVersion:()=>_e,toBase58Check:()=>Ae,toBech32:()=>Ie,toFutureOPNetAddress:()=>Ee,toOutputScript:()=>xe});var S={};y.r(S),y.d(S,{TAGGED_HASH_PREFIXES:()=>ir,TAGS:()=>nr,hash160:()=>er,hash256:()=>rr,ripemd160:()=>Je,sha1:()=>Qe,sha256:()=>tr,taggedHash:()=>or});var _={};y.r(_),y.d(_,{decode:()=>gr,encode:()=>br,encodingLength:()=>vr});var E={};y.r(E),y.d(E,{Transaction:()=>hi});var k={};y.r(k),y.d(k,{LEAF_VERSION_TAPSCRIPT:()=>Ur,MAX_TAPTREE_DEPTH:()=>Nr,PaymentType:()=>Yi,findScriptPath:()=>Fr,p2data:()=>qr,p2ms:()=>Xr,p2op:()=>Ui,p2pk:()=>$r,p2pkh:()=>Qi,p2sh:()=>Dn,p2tr:()=>Vn,p2wpkh:()=>zn,p2wsh:()=>Jn,prop:()=>Vr,rootHashFromPath:()=>Lr,tapTweakHash:()=>Hr,tapleafHash:()=>Dr,toHashTree:()=>Cr,tweakKey:()=>Mr,value:()=>Wr});var O={messagePrefix:"Bitcoin Signed Message:\n",bech32:"bc",bech32Opnet:"op",bip32:{public:76067358,private:76066276},pubKeyHash:0,scriptHash:5,wif:128},T={messagePrefix:"Bitcoin Signed Message:\n",bech32:"bcrt",bech32Opnet:"opr",bip32:{public:70617039,private:70615956},pubKeyHash:111,scriptHash:196,wif:239},A={messagePrefix:"Bitcoin Signed Message:\n",bech32:"tb",bech32Opnet:"opt",bip32:{public:70617039,private:70615956},pubKeyHash:111,scriptHash:196,wif:239},I={messagePrefix:"Dogecoin Signed Message:\n",bech32:"",bech32Opnet:"",bip32:{public:49990397,private:49988504},pubKeyHash:30,scriptHash:22,wif:158},P={messagePrefix:"Dogecoin Signed Message:\n",bech32:"",bech32Opnet:"",bip32:{public:70429096,private:70427203},pubKeyHash:113,scriptHash:196,wif:241},x={messagePrefix:"Litecoin Signed Message:\n",bech32:"ltc",bech32Opnet:"opl",bip32:{public:27108450,private:27106558},pubKeyHash:48,scriptHash:50,wif:176},B={messagePrefix:"Litecoin Signed Message:\n",bech32:"tltc",bech32Opnet:"oplt",bip32:{public:70709117,private:70711009},pubKeyHash:111,scriptHash:58,wif:239},R={messagePrefix:"Bitcoin Signed Message:\n",bech32:"bitcoincash",bech32Opnet:"opbch",bip32:{public:76067358,private:76066276},pubKeyHash:0,scriptHash:5,wif:128},U={messagePrefix:"Bitcoin Signed Message:\n",bech32:"bchtest",bech32Opnet:"opbcht",bip32:{public:70617039,private:70615956},pubKeyHash:111,scriptHash:196,wif:239},N={messagePrefix:"DarkCoin Signed Message:\n",bech32:"",bech32Opnet:"",bip32:{public:50221772,private:50221816},pubKeyHash:76,scriptHash:16,wif:204},j={messagePrefix:"DarkCoin Signed Message:\n",bech32:"",bech32Opnet:"",bip32:{public:981492128,private:981489719},pubKeyHash:140,scriptHash:19,wif:239},L=y(343);function C(t,...e){if(!((r=t)instanceof Uint8Array||ArrayBuffer.isView(r)&&"Uint8Array"===r.constructor.name))throw new Error("Uint8Array expected");var r;if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function F(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function D(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}function H(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function M(t,e){return t<<32-e|t>>>e}function K(t,e){return t<<e|t>>>32-e>>>0}function V(t){return"string"==typeof t&&(t=function(t){if("string"!=typeof t)throw new Error("string expected");return new Uint8Array((new TextEncoder).encode(t))}(t)),C(t),t}class W{}function G(t){const e=e=>t().update(V(e)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function q(t,e,r){return t&e^~t&r}function z(t,e,r){return t&e^t&r^e&r}class Z extends W{constructor(t,e,r,n){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=t,this.outputLen=e,this.padOffset=r,this.isLE=n,this.buffer=new Uint8Array(t),this.view=H(this.buffer)}update(t){F(this),C(t=V(t));const{view:e,buffer:r,blockLen:n}=this,i=t.length;for(let o=0;o<i;){const a=Math.min(n-this.pos,i-o);if(a!==n)r.set(t.subarray(o,o+a),this.pos),this.pos+=a,o+=a,this.pos===n&&(this.process(e,0),this.pos=0);else{const e=H(t);for(;n<=i-o;o+=n)this.process(e,o)}}return this.length+=t.length,this.roundClean(),this}digestInto(t){F(this),function(t,e){C(t);const r=e.outputLen;if(t.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}(t,this),this.finished=!0;const{buffer:e,view:r,blockLen:n,isLE:i}=this;let{pos:o}=this;e[o++]=128,D(this.buffer.subarray(o)),this.padOffset>n-o&&(this.process(r,0),o=0);for(let t=o;t<n;t++)e[t]=0;!function(t,e,r,n){if("function"==typeof t.setBigUint64)return t.setBigUint64(e,r,n);const i=BigInt(32),o=BigInt(4294967295),a=Number(r>>i&o),s=Number(r&o),u=n?4:0,f=n?0:4;t.setUint32(e+u,a,n),t.setUint32(e+f,s,n)}(r,n-8,BigInt(8*this.length),i),this.process(r,0);const a=H(t),s=this.outputLen;if(s%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const u=s/4,f=this.get();if(u>f.length)throw new Error("_sha2: outputLen bigger than state");for(let t=0;t<u;t++)a.setUint32(4*t,f[t],i)}digest(){const{buffer:t,outputLen:e}=this;this.digestInto(t);const r=t.slice(0,e);return this.destroy(),r}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:e,buffer:r,length:n,finished:i,destroyed:o,pos:a}=this;return t.destroyed=o,t.finished=i,t.length=n,t.pos=a,n%e&&t.buffer.set(r),t}clone(){return this._cloneInto()}}const X=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Y=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]),$=new Uint32Array(64);class J extends Z{constructor(t=32){super(64,t,8,!1),this.A=0|X[0],this.B=0|X[1],this.C=0|X[2],this.D=0|X[3],this.E=0|X[4],this.F=0|X[5],this.G=0|X[6],this.H=0|X[7]}get(){const{A:t,B:e,C:r,D:n,E:i,F:o,G:a,H:s}=this;return[t,e,r,n,i,o,a,s]}set(t,e,r,n,i,o,a,s){this.A=0|t,this.B=0|e,this.C=0|r,this.D=0|n,this.E=0|i,this.F=0|o,this.G=0|a,this.H=0|s}process(t,e){for(let r=0;r<16;r++,e+=4)$[r]=t.getUint32(e,!1);for(let t=16;t<64;t++){const e=$[t-15],r=$[t-2],n=M(e,7)^M(e,18)^e>>>3,i=M(r,17)^M(r,19)^r>>>10;$[t]=i+$[t-7]+n+$[t-16]|0}let{A:r,B:n,C:i,D:o,E:a,F:s,G:u,H:f}=this;for(let t=0;t<64;t++){const e=f+(M(a,6)^M(a,11)^M(a,25))+q(a,s,u)+Y[t]+$[t]|0,c=(M(r,2)^M(r,13)^M(r,22))+z(r,n,i)|0;f=u,u=s,s=a,a=o+e|0,o=i,i=n,n=r,r=e+c|0}r=r+this.A|0,n=n+this.B|0,i=i+this.C|0,o=o+this.D|0,a=a+this.E|0,s=s+this.F|0,u=u+this.G|0,f=f+this.H|0,this.set(r,n,i,o,a,s,u,f)}roundClean(){D($)}destroy(){this.set(0,0,0,0,0,0,0,0),D(this.buffer)}}const Q=G(()=>new J),tt=function(t){const e=new Uint8Array(256);for(let t=0;t<e.length;t++)e[t]=255;for(let r=0;r<58;r++){const n=t.charAt(r),i=n.charCodeAt(0);if(255!==e[i])throw new TypeError(n+" is ambiguous");e[i]=r}const r=t.charAt(0),n=Math.log(58)/Math.log(256),i=Math.log(256)/Math.log(58);function o(t){if("string"!=typeof t)throw new TypeError("Expected String");if(0===t.length)return new Uint8Array;let i=0,o=0,a=0;for(;t[i]===r;)o++,i++;const s=(t.length-i)*n+1>>>0,u=new Uint8Array(s);for(;t[i];){let r=e[t.charCodeAt(i)];if(255===r)return;let n=0;for(let t=s-1;(0!==r||n<a)&&-1!==t;t--,n++)r+=58*u[t]>>>0,u[t]=r%256>>>0,r=r/256>>>0;if(0!==r)throw new Error("Non-zero carry");a=n,i++}let f=s-a;for(;f!==s&&0===u[f];)f++;const c=new Uint8Array(o+(s-f));let l=o;for(;f!==s;)c[l++]=u[f++];return c}return{encode:function(e){if(e instanceof Uint8Array||(ArrayBuffer.isView(e)?e=new Uint8Array(e.buffer,e.byteOffset,e.byteLength):Array.isArray(e)&&(e=Uint8Array.from(e))),!(e instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===e.length)return"";let n=0,o=0,a=0;const s=e.length;for(;a!==s&&0===e[a];)a++,n++;const u=(s-a)*i+1>>>0,f=new Uint8Array(u);for(;a!==s;){let t=e[a],r=0;for(let e=u-1;(0!==t||r<o)&&-1!==e;e--,r++)t+=256*f[e]>>>0,f[e]=t%58>>>0,t=t/58>>>0;if(0!==t)throw new Error("Non-zero carry");o=r,a++}let c=u-o;for(;c!==u&&0===f[c];)c++;let l=r.repeat(n);for(;c<u;++c)l+=t.charAt(f[c]);return l},decodeUnsafe:o,decode:function(t){const e=o(t);if(e)return e;throw new Error("Non-base58 character")}}}("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),et=function(t){function e(e){var r=e.slice(0,-4),n=e.slice(-4),i=t(r);if(!(n[0]^i[0]|n[1]^i[1]|n[2]^i[2]|n[3]^i[3]))return r}return{encode:function(e){var r=Uint8Array.from(e),n=t(r),i=r.length+4,o=new Uint8Array(i);return o.set(r,0),o.set(n.subarray(0,4),r.length),tt.encode(o)},decode:function(t){var r=e(tt.decode(t));if(null==r)throw new Error("Invalid checksum");return r},decodeUnsafe:function(t){var r=tt.decodeUnsafe(t);if(null!=r)return e(r)}}}(function(t){return Q(Q(t))});var rt=y(287).hp;function nt(t,e){var r=t.length,n=e.length;if(0===r)throw new Error("R length is zero");if(0===n)throw new Error("S length is zero");if(r>33)throw new Error("R length is too long");if(n>33)throw new Error("S length is too long");if(128&t[0])throw new Error("R value is negative");if(128&e[0])throw new Error("S value is negative");if(r>1&&0===t[0]&&!(128&t[1]))throw new Error("R value excessively padded");if(n>1&&0===e[0]&&!(128&e[1]))throw new Error("S value excessively padded");var i=rt.allocUnsafe(6+r+n);return i[0]=48,i[1]=i.length-2,i[2]=2,i[3]=t.length,t.copy(i,4),i[4+r]=2,i[5+r]=e.length,e.copy(i,6+r),i}for(var it={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_SUBSTR:127,OP_LEFT:128,OP_RIGHT: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_NOP1:176,OP_NOP2:177,OP_CHECKLOCKTIMEVERIFY:177,OP_NOP3:178,OP_CHECKSEQUENCEVERIFY:178,OP_NOP4:179,OP_NOP5:180,OP_NOP6:181,OP_NOP7:182,OP_NOP8:183,OP_NOP9:184,OP_NOP10:185,OP_CHECKSIGADD:186,OP_PUBKEYHASH:253,OP_PUBKEY:254,OP_INVALIDOPCODE:255},ot={},at=0,st=Object.keys(it);at<st.length;at++){var ut=st[at],ft=it[ut];ot[ft]=ut}function ct(t){return t<it.OP_PUSHDATA1?1:t<=255?2:t<=65535?3:5}function lt(t,e){var r,n,i=t.readUInt8(e);if(i<it.OP_PUSHDATA1)r=i,n=1;else if(i===it.OP_PUSHDATA1){if(e+2>t.length)return null;r=t.readUInt8(e+1),n=2}else if(i===it.OP_PUSHDATA2){if(e+3>t.length)return null;r=t.readUInt16LE(e+1),n=3}else{if(e+5>t.length)return null;if(i!==it.OP_PUSHDATA4)throw new Error("Unexpected opcode");r=t.readUInt32LE(e+1),n=5}return{opcode:i,number:r,size:n}}var ht=y(287).hp;function pt(t,e,r){e=e||4,r=void 0===r||r;var n=t.length;if(0===n)return 0;if(n>e)throw new TypeError("Script number overflow");if(r&&!(127&t[n-1]||!(n<=1)&&128&t[n-2]))throw new Error("Non-minimally encoded script number");if(5===n){var i=t.readUInt32LE(0),o=t.readUInt8(4);return 128&o?-(4294967296*(-129&o)+i):4294967296*o+i}for(var a=0,s=0;s<n;++s)a|=t[s]<<8*s;return 128&t[n-1]?-(a&~(128<<8*(n-1))):a}function dt(t){for(var e=Math.abs(t),r=function(t){return t>2147483647?5:t>8388607?4:t>32767?3:t>127?2:t>0?1:0}(e),n=ht.allocUnsafe(r),i=t<0,o=0;o<r;++o)n.writeUInt8(255&e,o),e>>=8;return 128&n[r-1]?n.writeUInt8(i?128:0,r-1):i&&(n[r-1]|=128),n}var yt=y(287),bt=y(676),gt=y.n(bt)(),vt=yt.hp.alloc(32,0),wt=yt.hp.from("fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f","hex");function mt(t,e){return t.length===e.length&&t.every(function(t,r){return t.equals(e[r])})}function St(t){if(!yt.hp.isBuffer(t))return!1;if(t.length<33)return!1;var e=t[0],r=t.slice(1,33);if(0===r.compare(vt))return!1;if(r.compare(wt)>=0)return!1;if((2===e||3===e)&&33===t.length)return!0;if(65!==t.length)return!1;var n=t.slice(33);return!(0===n.compare(vt)||n.compare(wt)>=0||4!==e&&6!==e&&7!==e)}function _t(t){return gt.UInt53(t)&&t<=21e14}var Et=254;function kt(t){return!(!t||!("output"in t)||!yt.hp.isBuffer(t.output)||void 0!==t.version&&(t.version&Et)!==t.version)}function Ot(t){return Pt(t)?2===t.length&&t.every(function(t){return Ot(t)}):kt(t)}gt.BufferN(32);var Tt=gt.BufferN(20),At=gt.BufferN(32),It=gt.Number,Pt=gt.Array,xt=(gt.Boolean,gt.String),Bt=gt.Buffer,Rt=gt.Hex,Ut=gt.maybe,Nt=gt.tuple,jt=gt.UInt8,Lt=gt.UInt32,Ct=gt.Function,Ft=gt.BufferN,Dt=gt.Null,Ht=(gt.oneOf,y(287).hp),Mt=gt,Kt=Ht.alloc(1,0);function Vt(t){for(var e=0;0===t[e];)++e;return e===t.length?Kt:128&(t=t.slice(e))[0]?Ht.concat([Kt,t],1+t.length):t}function Wt(t){0===t[0]&&(t=t.slice(1));var e=Ht.alloc(32,0),r=Math.max(0,32-t.length);return t.copy(e,r),e}function Gt(t){var e=t.readUInt8(t.length-1);if(!ue(e))throw new Error("Invalid hashType "+e);var r=function(t){if(t.length<8)throw new Error("DER sequence length is too short");if(t.length>72)throw new Error("DER sequence length is too long");if(48!==t[0])throw new Error("Expected DER sequence");if(t[1]!==t.length-2)throw new Error("DER sequence length is invalid");if(2!==t[2])throw new Error("Expected DER integer");var e=t[3];if(0===e)throw new Error("R length is zero");if(5+e>=t.length)throw new Error("R length is too long");if(2!==t[4+e])throw new Error("Expected DER integer (2)");var r=t[5+e];if(0===r)throw new Error("S length is zero");if(6+e+r!==t.length)throw new Error("S length is invalid");if(128&t[4])throw new Error("R value is negative");if(e>1&&0===t[4]&&!(128&t[5]))throw new Error("R value excessively padded");if(128&t[e+6])throw new Error("S value is negative");if(r>1&&0===t[e+6]&&!(128&t[e+7]))throw new Error("S value excessively padded");return{r:t.slice(4,4+e),s:t.slice(6+e)}}(t.slice(0,-1)),n=Wt(r.r),i=Wt(r.s);return{signature:Ht.concat([n,i],64),hashType:e}}function qt(t,e){if(Mt({signature:Ft(64),hashType:jt},{signature:t,hashType:e}),!ue(e))throw new Error("Invalid hashType "+e);var r=Ht.allocUnsafe(1);r.writeUInt8(e,0);var n=Vt(t.slice(0,32)),i=Vt(t.slice(32,64));return Ht.concat([nt(n,i),r])}var zt=y(287).hp,Zt=gt,Xt=it.OP_RESERVED;function Yt(t){return Bt(t)||function(t){return It(t)&&(t===it.OP_0||t>=it.OP_1&&t<=it.OP_16||t===it.OP_1NEGATE)}(t)}function $t(t){return Pt(t)&&t.every(Yt)}function Jt(t){return t.length-t.filter(Yt).length}function Qt(t){return 0===t.length?it.OP_0:1===t.length?t[0]>=1&&t[0]<=16?Xt+t[0]:129===t[0]?it.OP_1NEGATE:void 0:void 0}function te(t){return zt.isBuffer(t)}function ee(t){return zt.isBuffer(t)}function re(t){if(te(t))return t;Zt(Pt,t);var e=t.reduce(function(t,e){return ee(e)?1===e.length&&void 0!==Qt(e)?t+1:t+ct(e.length)+e.length:t+1},0),r=zt.allocUnsafe(e),n=0;if(t.forEach(function(t){if(ee(t)){var e=Qt(t);if(void 0!==e)return r.writeUInt8(e,n),void(n+=1);n+=function(t,e,r){var n=ct(e);return 1===n?t.writeUInt8(e,r):2===n?(t.writeUInt8(it.OP_PUSHDATA1,r),t.writeUInt8(e,r+1)):3===n?(t.writeUInt8(it.OP_PUSHDATA2,r),t.writeUInt16LE(e,r+1)):(t.writeUInt8(it.OP_PUSHDATA4,r),t.writeUInt32LE(e,r+1)),n}(r,t.length,n),t.copy(r,n),n+=t.length}else r.writeUInt8(t,n),n+=1}),n!==r.length)throw new Error("Could not decode chunks");return r}function ne(t){if(Pt(t))return t;Zt(Bt,t);for(var e=[],r=0;r<t.length;){var n=t[r];if(n>it.OP_0&&n<=it.OP_PUSHDATA4){var i=lt(t,r);if(null===i)return null;if((r+=i.size)+i.number>t.length)return null;var o=t.slice(r,r+i.number);r+=i.number;var a=Qt(o);void 0!==a?e.push(a):e.push(o)}else e.push(n),r+=1}return e}function ie(t){if(te(t)&&(t=ne(t)),!t)throw new Error("Could not convert invalid chunks to ASM");return t.map(function(t){if(ee(t)){var e=Qt(t);if(void 0===e)return t.toString("hex");t=e}return ot[t]}).join(" ")}function oe(t){return Zt(xt,t),re(t.split(" ").map(function(t){return void 0!==it[t]?it[t]:(Zt(Rt,t),zt.from(t,"hex"))}))}function ae(t){return t=ne(t),Zt($t,t),t.map(function(t){return ee(t)?t:t===it.OP_0?zt.allocUnsafe(0):dt(t-Xt)})}function se(t){return St(t)}function ue(t){var e=-129&t;return e>0&&e<4}function fe(t){return!!zt.isBuffer(t)&&!!ue(t[t.length-1])&&function(t){if(t.length<8)return!1;if(t.length>72)return!1;if(48!==t[0])return!1;if(t[1]!==t.length-2)return!1;if(2!==t[2])return!1;var e=t[3];if(0===e)return!1;if(5+e>=t.length)return!1;if(2!==t[4+e])return!1;var r=t[5+e];return!(0===r||6+e+r!==t.length||128&t[4]||e>1&&0===t[4]&&!(128&t[5])||128&t[e+6]||r>1&&0===t[e+6]&&!(128&t[e+7]))}(t.slice(0,-1))}var ce=g,le=v,he=y(287).hp;function pe(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}var de=40,ye=2,be=15,ge=16,ve=16,we=2,me=80,Se="WARNING: Sending to a future segwit version address can lead to loss of funds. End users MUST be warned carefully in the GUI and asked if they wish to proceed with caution. Wallets should verify the segwit version from the output of fromBech32, then decide when it is safe to use which version of segwit.",_e=function(t){try{var e=t.subarray(2);if(e.length<ye||e.length>de)throw new TypeError("Invalid program length for segwit address");var r=t[0]-me;if(r<we||r>be+1)throw new TypeError("Invalid version for segwit address");if(1===r)throw new TypeError("taproot");return!0}catch(t){}return!1};function Ee(t,e){if(!he.isBuffer(t))throw new TypeError("output must be a Buffer");if(!e.bech32Opnet)throw new Error("Network does not support opnet");var r,n=t[0],i=1;if(t[1]<76)r=t[1],i=2;else{if(76!==t[1])throw new TypeError("Unsupported push opcode in script");r=t[2],i=3}var o=t.subarray(i,i+r);if(o.length<ye||o.length>de)throw new TypeError("Invalid program length for segwit address");var a=n===it.OP_0?0:n>=it.OP_1&&n<=it.OP_16?n-(it.OP_1-1):-1;if(a<be||a>ge)throw new TypeError("Invalid segwit version ".concat(a));var s,u=[a].concat(function(t){if(Array.isArray(t))return pe(t)}(s=L.p2.toWords(o))||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(s)||function(t,e){if(t){if("string"==typeof t)return pe(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?pe(t,e):void 0}}(s)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}());return L.p2.encode(e.bech32Opnet,u)}function ke(t,e){var r=t.subarray(2);if(r.length<ye||r.length>de)throw new TypeError("Invalid program length for segwit address");var n=t[0]-me;if(n<we||n>be)throw new TypeError("Invalid version for segwit address");if(t[1]!==r.length)throw new TypeError("Invalid script for segwit address ".concat(t[1]," !== ").concat(r.length));return Ie(r,n,e.bech32,e.bech32Opnet)}function Oe(t){var e=he.from(et.decode(t));if(e.length<21)throw new TypeError(t+" is too short");if(e.length>21)throw new TypeError(t+" is too long");return{version:e.readUInt8(0),hash:e.subarray(1)}}function Te(t){var e,r;try{e=L.I.decode(t)}catch(t){}if(e){if(0!==(r=e.words[0]))throw new TypeError(t+" uses wrong encoding")}else if(0===(r=(e=L.p2.decode(t)).words[0]))throw new TypeError(t+" uses wrong encoding");var n=L.I.fromWords(e.words.slice(1));return{version:r,prefix:e.prefix,data:he.from(n)}}function Ae(t,e){gt(Nt(Tt,jt),arguments);var r=he.allocUnsafe(21);return r.writeUInt8(e,0),t.copy(r,1),et.encode(r)}function Ie(t,e,r,n){var i=L.I.toWords(t);return i.unshift(e),e===ve&&n?L.p2.encode(n,i):0===e?L.I.encode(r,i):L.p2.encode(r,i)}function Pe(t,e){e=e||O;try{return Qi({output:t,network:e}).address}catch(t){}try{return Dn({output:t,network:e}).address}catch(t){}try{return zn({output:t,network:e}).address}catch(t){}try{return Jn({output:t,network:e}).address}catch(t){}try{return Vn({output:t,network:e}).address}catch(t){}try{return Ee(t,e)}catch(t){}try{return ke(t,e)}catch(t){}throw new Error(ie(t)+" has no matching Address")}function xe(t,e){var r,n;e=e||O;try{r=Oe(t)}catch(t){}if(r){if(r.version===e.pubKeyHash)return Qi({hash:r.hash}).output;if(r.version===e.scriptHash)return Dn({hash:r.hash}).output}else{try{n=Te(t)}catch(t){}if(n){if(n.prefix!==e.bech32&&e.bech32Opnet&&n.prefix!==e.bech32Opnet)throw new Error(t+" has an invalid prefix");if(0===n.version){if(20===n.data.length)return zn({hash:n.data}).output;if(32===n.data.length)return Jn({hash:n.data}).output}else if(1===n.version){if(32===n.data.length)return Vn({pubkey:n.data}).output}else{if(n.version===ve){if(!e.bech32Opnet)throw new Error(t+" has an invalid prefix");return Ui({program:n.data,network:e}).output}if(n.version>=we&&n.version<=be&&n.data.length>=ye&&n.data.length<=de)return n.version!==ve&&console.warn(Se),re([n.version+me,n.data])}}}return he.from(t,"hex")}const Be=Uint32Array.from([1732584193,4023233417,2562383102,271733878,3285377520]),Re=new Uint32Array(80);class Ue extends Z{constructor(){super(64,20,8,!1),this.A=0|Be[0],this.B=0|Be[1],this.C=0|Be[2],this.D=0|Be[3],this.E=0|Be[4]}get(){const{A:t,B:e,C:r,D:n,E:i}=this;return[t,e,r,n,i]}set(t,e,r,n,i){this.A=0|t,this.B=0|e,this.C=0|r,this.D=0|n,this.E=0|i}process(t,e){for(let r=0;r<16;r++,e+=4)Re[r]=t.getUint32(e,!1);for(let t=16;t<80;t++)Re[t]=K(Re[t-3]^Re[t-8]^Re[t-14]^Re[t-16],1);let{A:r,B:n,C:i,D:o,E:a}=this;for(let t=0;t<80;t++){let e,s;t<20?(e=q(n,i,o),s=1518500249):t<40?(e=n^i^o,s=1859775393):t<60?(e=z(n,i,o),s=2400959708):(e=n^i^o,s=3395469782);const u=K(r,5)+e+a+s+Re[t]|0;a=o,o=i,i=K(n,30),n=r,r=u}r=r+this.A|0,n=n+this.B|0,i=i+this.C|0,o=o+this.D|0,a=a+this.E|0,this.set(r,n,i,o,a)}roundClean(){D(Re)}destroy(){this.set(0,0,0,0,0),D(this.buffer)}}const Ne=G(()=>new Ue),je=Uint8Array.from([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),Le=Uint8Array.from(new Array(16).fill(0).map((t,e)=>e)),Ce=Le.map(t=>(9*t+5)%16),Fe=(()=>{const t=[[Le],[Ce]];for(let e=0;e<4;e++)for(let r of t)r.push(r[e].map(t=>je[t]));return t})(),De=Fe[0],He=Fe[1],Me=[[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8],[12,13,11,15,6,9,9,7,12,15,11,13,7,8,7,7],[13,15,14,11,7,7,6,8,13,14,13,12,5,5,6,9],[14,11,12,14,8,6,5,5,15,12,15,14,9,9,8,6],[15,12,13,13,9,5,8,6,14,11,12,11,8,6,5,5]].map(t=>Uint8Array.from(t)),Ke=De.map((t,e)=>t.map(t=>Me[e][t])),Ve=He.map((t,e)=>t.map(t=>Me[e][t])),We=Uint32Array.from([0,1518500249,1859775393,2400959708,2840853838]),Ge=Uint32Array.from([1352829926,1548603684,1836072691,2053994217,0]);function qe(t,e,r,n){return 0===t?e^r^n:1===t?e&r|~e&n:2===t?(e|~r)^n:3===t?e&n|r&~n:e^(r|~n)}const ze=new Uint32Array(16);class Ze extends Z{constructor(){super(64,20,8,!0),this.h0=1732584193,this.h1=-271733879,this.h2=-1732584194,this.h3=271733878,this.h4=-1009589776}get(){const{h0:t,h1:e,h2:r,h3:n,h4:i}=this;return[t,e,r,n,i]}set(t,e,r,n,i){this.h0=0|t,this.h1=0|e,this.h2=0|r,this.h3=0|n,this.h4=0|i}process(t,e){for(let r=0;r<16;r++,e+=4)ze[r]=t.getUint32(e,!0);let r=0|this.h0,n=r,i=0|this.h1,o=i,a=0|this.h2,s=a,u=0|this.h3,f=u,c=0|this.h4,l=c;for(let t=0;t<5;t++){const e=4-t,h=We[t],p=Ge[t],d=De[t],y=He[t],b=Ke[t],g=Ve[t];for(let e=0;e<16;e++){const n=K(r+qe(t,i,a,u)+ze[d[e]]+h,b[e])+c|0;r=c,c=u,u=0|K(a,10),a=i,i=n}for(let t=0;t<16;t++){const r=K(n+qe(e,o,s,f)+ze[y[t]]+p,g[t])+l|0;n=l,l=f,f=0|K(s,10),s=o,o=r}}this.set(this.h1+a+f|0,this.h2+u+l|0,this.h3+c+n|0,this.h4+r+o|0,this.h0+i+s|0)}roundClean(){D(ze)}destroy(){this.destroyed=!0,D(this.buffer),this.set(0,0,0,0,0)}}const Xe=G(()=>new Ze),Ye=Ne;var $e=y(287).hp;function Je(t){return $e.from(Xe(Uint8Array.from(t)))}function Qe(t){return $e.from(Ye(Uint8Array.from(t)))}function tr(t){return $e.from(Q(Uint8Array.from(t)))}function er(t){return $e.from(Xe(Q(Uint8Array.from(t))))}function rr(t){return $e.from(Q(Q(Uint8Array.from(t))))}var nr=["BIP0340/challenge","BIP0340/aux","BIP0340/nonce","TapLeaf","TapBranch","TapSighash","TapTweak","KeyAgg list","KeyAgg coefficient"],ir={"BIP0340/challenge":$e.from([123,181,45,122,159,239,88,50,62,177,191,122,64,125,179,130,210,243,242,216,27,177,34,79,73,254,81,143,109,72,211,124,123,181,45,122,159,239,88,50,62,177,191,122,64,125,179,130,210,243,242,216,27,177,34,79,73,254,81,143,109,72,211,124]),"BIP0340/aux":$e.from([241,239,78,94,192,99,202,218,109,148,202,250,157,152,126,160,105,38,88,57,236,193,31,151,45,119,165,46,216,193,204,144,241,239,78,94,192,99,202,218,109,148,202,250,157,152,126,160,105,38,88,57,236,193,31,151,45,119,165,46,216,193,204,144]),"BIP0340/nonce":$e.from([7,73,119,52,167,155,203,53,91,155,140,125,3,79,18,28,244,52,215,62,247,45,218,25,135,0,97,251,82,191,235,47,7,73,119,52,167,155,203,53,91,155,140,125,3,79,18,28,244,52,215,62,247,45,218,25,135,0,97,251,82,191,235,47]),TapLeaf:$e.from([174,234,143,220,66,8,152,49,5,115,75,88,8,29,30,38,56,211,95,28,181,64,8,212,211,87,202,3,190,120,233,238,174,234,143,220,66,8,152,49,5,115,75,88,8,29,30,38,56,211,95,28,181,64,8,212,211,87,202,3,190,120,233,238]),TapBranch:$e.from([25,65,161,242,229,110,185,95,162,169,241,148,190,92,1,247,33,111,51,237,130,176,145,70,52,144,208,91,245,22,160,21,25,65,161,242,229,110,185,95,162,169,241,148,190,92,1,247,33,111,51,237,130,176,145,70,52,144,208,91,245,22,160,21]),TapSighash:$e.from([244,10,72,223,75,42,112,200,180,146,75,242,101,70,97,237,61,149,253,102,163,19,235,135,35,117,151,198,40,228,160,49,244,10,72,223,75,42,112,200,180,146,75,242,101,70,97,237,61,149,253,102,163,19,235,135,35,117,151,198,40,228,160,49]),TapTweak:$e.from([232,15,225,99,156,156,160,80,227,175,27,57,193,67,198,62,66,156,188,235,21,217,64,251,181,197,161,244,175,87,197,233,232,15,225,99,156,156,160,80,227,175,27,57,193,67,198,62,66,156,188,235,21,217,64,251,181,197,161,244,175,87,197,233]),"KeyAgg list":$e.from([72,28,151,28,60,11,70,215,240,178,117,174,89,141,78,44,126,215,49,156,89,74,92,110,199,158,160,212,153,2,148,240,72,28,151,28,60,11,70,215,240,178,117,174,89,141,78,44,126,215,49,156,89,74,92,110,199,158,160,212,153,2,148,240]),"KeyAgg coefficient":$e.from([191,201,4,3,77,28,136,232,200,14,34,229,61,36,86,109,100,130,78,214,66,114,129,192,145,0,249,77,205,82,201,129,191,201,4,3,77,28,136,232,200,14,34,229,61,36,86,109,100,130,78,214,66,114,129,192,145,0,249,77,205,82,201,129])};function or(t,e){return tr($e.concat([ir[t],e]))}var ar=y(287).hp,sr={};function ur(t){var e;t?t!==sr.eccLib&&(lr("function"==typeof(e=t).isXOnlyPoint),lr(e.isXOnlyPoint(cr("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),lr(e.isXOnlyPoint(cr("fffffffffffffffffffffffffffffffffffffffffffffffffffffffeeffffc2e"))),lr(e.isXOnlyPoint(cr("f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9"))),lr(e.isXOnlyPoint(cr("0000000000000000000000000000000000000000000000000000000000000001"))),lr(!e.isXOnlyPoint(cr("0000000000000000000000000000000000000000000000000000000000000000"))),lr(!e.isXOnlyPoint(cr("fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"))),lr("function"==typeof e.xOnlyPointAddTweak),hr.forEach(function(t){var r=e.xOnlyPointAddTweak(cr(t.pubkey),cr(t.tweak));null===t.result?lr(null===r):(lr(null!==r),lr(r.parity===t.parity),lr(ar.from(r.xOnlyPubkey).equals(cr(t.result))))}),sr.eccLib=t):sr.eccLib=t}function fr(){if(!sr.eccLib)throw new Error("No ECC Library provided. You must call initEccLib() with a valid TinySecp256k1Interface instance");return sr.eccLib}var cr=function(t){return ar.from(t,"hex")};function lr(t){if(!t)throw new Error("ecc library invalid")}var hr=[{pubkey:"79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798",tweak:"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140",parity:-1,result:null},{pubkey:"1617d38ed8d8657da4d4761e8057bc396ea9e4b9d29776d4be096016dbd2509b",tweak:"a8397a935f0dfceba6ba9618f6451ef4d80637abf4e6af2669fbc9de6a8fd2ac",parity:1,result:"e478f99dab91052ab39a33ea35fd5e6e4933f4d28023cd597c9a1f6760346adf"},{pubkey:"2c0b7cf95324a07d05398b240174dc0c2be444d96b159aa6c7f7b1e668680991",tweak:"823c3cd2142744b075a87eade7e1b8678ba308d566226a0056ca2b7a76f86b47",parity:0,result:"9534f8dc8c6deda2dc007655981c78b49c5d96c778fbf363462a11ec9dfd948c"}];const pr="0123456789abcdefABCDEF";pr.split("").map(t=>t.codePointAt(0)),Array(256).fill(!0).map((t,e)=>{const r=String.fromCodePoint(e),n=pr.indexOf(r);return n<0?void 0:n<16?n:n-6}),new TextEncoder,new TextDecoder;const dr=t=>{if(t<0||t>0xffffffffffffffffn)throw new RangeError("value out of range")};function yr(t){"number"==typeof t?function(t){if(t<0||t>Number.MAX_SAFE_INTEGER||t%1!=0)throw new RangeError("value out of range")}(t):dr(t)}function br(t,e,r){yr(t),void 0===r&&(r=0),void 0===e&&(e=new Uint8Array(vr(t)));let n=0;return t<253?(e.set([Number(t)],r),n=1):t<=65535?(e.set([253],r),function(t,e,r,n){if(e+2>t.length)throw new Error("Offset is outside the bounds of Uint8Array");if(n=n.toUpperCase(),r>65535)throw new Error(`The value of "value" is out of range. It must be >= 0 and <= 65535. Received ${r}`);"LE"===n?(t[e]=255&r,t[e+1]=r>>8&255):(t[e]=r>>8&255,t[e+1]=255&r)}(e,r+1,Number(t),"LE"),n=3):t<=4294967295?(e.set([254],r),function(t,e,r,n){if(e+4>t.length)throw new Error("Offset is outside the bounds of Uint8Array");if(n=n.toUpperCase(),r>4294967295)throw new Error(`The value of "value" is out of range. It must be >= 0 and <= 4294967295. Received ${r}`);"LE"===n?(t[e]=255&r,t[e+1]=r>>8&255,t[e+2]=r>>16&255,t[e+3]=r>>24&255):(t[e]=r>>24&255,t[e+1]=r>>16&255,t[e+2]=r>>8&255,t[e+3]=255&r)}(e,r+1,Number(t),"LE"),n=5):(e.set([255],r),function(t,e,r,n){if(e+8>t.length)throw new Error("Offset is outside the bounds of Uint8Array");if(n=n.toUpperCase(),r>0xffffffffffffffffn)throw new Error(`The value of "value" is out of range. It must be >= 0 and <= 18446744073709551615. Received ${r}`);"LE"===n?(t[e]=Number(0xffn&r),t[e+1]=Number(r>>8n&0xffn),t[e+2]=Number(r>>16n&0xffn),t[e+3]=Number(r>>24n&0xffn),t[e+4]=Number(r>>32n&0xffn),t[e+5]=Number(r>>40n&0xffn),t[e+6]=Number(r>>48n&0xffn),t[e+7]=Number(r>>56n&0xffn)):(t[e]=Number(r>>56n&0xffn),t[e+1]=Number(r>>48n&0xffn),t[e+2]=Number(r>>40n&0xffn),t[e+3]=Number(r>>32n&0xffn),t[e+4]=Number(r>>24n&0xffn),t[e+5]=Number(r>>16n&0xffn),t[e+6]=Number(r>>8n&0xffn),t[e+7]=Number(0xffn&r))}(e,r+1,BigInt(t),"LE"),n=9),{buffer:e,bytes:n}}function gr(t,e){void 0===e&&(e=0);const r=t.at(e);if(void 0===r)throw new Error("buffer too small");if(r<253)return{numberValue:r,bigintValue:BigInt(r),bytes:1};if(253===r){const r=function(t,e,r){if(e+2>t.length)throw new Error("Offset is outside the bounds of Uint8Array");if("LE"===(r=r.toUpperCase())){let r=0;return r=(r<<8)+t[e+1],r=(r<<8)+t[e],r}{let r=0;return r=(r<<8)+t[e],r=(r<<8)+t[e+1],r}}(t,e+1,"LE");return{numberValue:r,bigintValue:BigInt(r),bytes:3}}if(254===r){const r=function(t,e,r){if(e+4>t.length)throw new Error("Offset is outside the bounds of Uint8Array");if("LE"===(r=r.toUpperCase())){let r=0;return r=(r<<8)+t[e+3]>>>0,r=(r<<8)+t[e+2]>>>0,r=(r<<8)+t[e+1]>>>0,r=(r<<8)+t[e]>>>0,r}{let r=0;return r=(r<<8)+t[e]>>>0,r=(r<<8)+t[e+1]>>>0,r=(r<<8)+t[e+2]>>>0,r=(r<<8)+t[e+3]>>>0,r}}(t,e+1,"LE");return{numberValue:r,bigintValue:BigInt(r),bytes:5}}{const r=function(t,e,r){if(e+8>t.length)throw new Error("Offset is outside the bounds of Uint8Array");if("LE"===(r=r.toUpperCase())){let r=0n;return r=(r<<8n)+BigInt(t[e+7]),r=(r<<8n)+BigInt(t[e+6]),r=(r<<8n)+BigInt(t[e+5]),r=(r<<8n)+BigInt(t[e+4]),r=(r<<8n)+BigInt(t[e+3]),r=(r<<8n)+BigInt(t[e+2]),r=(r<<8n)+BigInt(t[e+1]),r=(r<<8n)+BigInt(t[e]),r}{let r=0n;return r=(r<<8n)+BigInt(t[e]),r=(r<<8n)+BigInt(t[e+1]),r=(r<<8n)+BigInt(t[e+2]),r=(r<<8n)+BigInt(t[e+3]),r=(r<<8n)+BigInt(t[e+4]),r=(r<<8n)+BigInt(t[e+5]),r=(r<<8n)+BigInt(t[e+6]),r=(r<<8n)+BigInt(t[e+7]),r}}(t,e+1,"LE");return{numberValue:r<=Number.MAX_SAFE_INTEGER?Number(r):null,bigintValue:r,bytes:9}}}function vr(t){return yr(t),t<253?1:t<=65535?3:t<=4294967295?5:9}var wr=y(287).hp;function mr(t){return mr="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},mr(t)}function Sr(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function _r(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,kr(n.key),n)}}function Er(t,e,r){return e&&_r(t.prototype,e),r&&_r(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function kr(t){var e=function(t){if("object"!=mr(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=mr(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==mr(e)?e:e+""}var Or=gt;function Tr(t,e){if("number"!=typeof t)throw new Error("cannot write a non-number as a number");if(t<0)throw new Error("specified a negative value for writing an unsigned value");if(t>e)throw new Error("RangeError: value out of range");if(Math.floor(t)!==t)throw new Error("value has a fractional component")}function Ar(t){if(t.length<1)return t;for(var e=t.length-1,r=0,n=0;n<t.length/2;n++)r=t[n],t[n]=t[e],t[e]=r,e--;return t}function Ir(t){var e=wr.allocUnsafe(t.length);return t.copy(e),e}var Pr=function(){function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;Sr(this,t),this.buffer=e,this.offset=r,Or(Nt(Bt,Lt),[e,r])}return Er(t,[{key:"writeUInt8",value:function(t){this.offset=this.buffer.writeUInt8(t,this.offset)}},{key:"writeInt32",value:function(t){this.offset=this.buffer.writeInt32LE(t,this.offset)}},{key:"writeUInt32",value:function(t){this.offset=this.buffer.writeUInt32LE(t,this.offset)}},{key:"writeUInt64",value:function(t){this.offset=function(t,e,r){return Tr(e,9007199254740991),t.writeInt32LE(-1&e,r),t.writeUInt32LE(Math.floor(e/4294967296),r+4),r+8}(this.buffer,t,this.offset)}},{key:"writeVarInt",value:function(t){var e=br(t,this.buffer,this.offset);this.offset+=e.bytes}},{key:"writeSlice",value:function(t){if(this.buffer.length<this.offset+t.length)throw new Error("Cannot write slice out of bounds");this.offset+=t.copy(this.buffer,this.offset)}},{key:"writeVarSlice",value:function(t){this.writeVarInt(t.length),this.writeSlice(t)}},{key:"writeVector",value:function(t){var e=this;this.writeVarInt(t.length),t.forEach(function(t){return e.writeVarSlice(t)})}},{key:"end",value:function(){if(this.buffer.length===this.offset)return this.buffer;throw new Error("buffer size ".concat(this.buffer.length,", offset ").concat(this.offset))}}],[{key:"withCapacity",value:function(e){return new t(wr.alloc(e))}}])}(),xr=Er(function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;Sr(this,t),this.buffer=e,this.offset=r,Or(Nt(Bt,Lt),[e,r])},[{key:"readUInt8",value:function(){var t=this.buffer.readUInt8(this.offset);return this.offset++,t}},{key:"readInt32",value:function(){var t=this.buffer.readInt32LE(this.offset);return this.offset+=4,t}},{key:"readUInt32",value:function(){var t=this.buffer.readUInt32LE(this.offset);return this.offset+=4,t}},{key:"readUInt64",value:function(){var t=function(t,e){var r=t.readUInt32LE(e),n=t.readUInt32LE(e+4);return Tr((n*=4294967296)+r,9007199254740991),n+r}(this.buffer,this.offset);return this.offset+=8,t}},{key:"readVarInt",value:function(){var t=gr(this.buffer,this.offset);return this.offset+=t.bytes,t.numberValue||0}},{key:"readSlice",value:function(t){if(this.buffer.length<this.offset+t)throw new Error("Cannot read slice out of bounds");var e=this.buffer.subarray(this.offset,this.offset+t);return this.offset+=t,e}},{key:"readVarSlice",value:function(){return this.readSlice(this.readVarInt())}},{key:"readVector",value:function(){for(var t=this.readVarInt(),e=[],r=0;r<t;r++)e.push(this.readVarSlice());return e}}]);function Br(t){return function(t){if(Array.isArray(t))return Rr(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return Rr(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Rr(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Rr(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}var Ur=192,Nr=128,jr=function(t){return"left"in t&&"right"in t};function Lr(t,e){if(t.length<33)throw new TypeError("The control-block length is too small. Got ".concat(t.length,", expected min 33."));for(var r=(t.length-33)/32,n=e,i=0;i<r;i++){var o=t.slice(33+32*i,65+32*i);n=n.compare(o)<0?Kr(n,o):Kr(o,n)}return n}function Cr(t){if(kt(t))return{hash:Dr(t)};var e=[Cr(t[0]),Cr(t[1])];e.sort(function(t,e){return t.hash.compare(e.hash)});var r=e[0],n=e[1];return{hash:Kr(r.hash,n.hash),left:r,right:n}}function Fr(t,e){if(jr(t)){var r=Fr(t.left,e);if(void 0!==r)return[].concat(Br(r),[t.right.hash]);var n=Fr(t.right,e);if(void 0!==n)return[].concat(Br(n),[t.left.hash])}else if(t.hash.equals(e))return[]}function Dr(t){var e,r,n,i=t.version||Ur;return or("TapLeaf",yt.hp.concat([yt.hp.from([i]),(e=t.output,r=vr(e.length),n=yt.hp.allocUnsafe(r),br(e.length,n),yt.hp.concat([n,e]))]))}function Hr(t,e){return or("TapTweak",yt.hp.concat(e?[t,e]:[t]))}function Mr(t,e){if(!yt.hp.isBuffer(t))return null;if(32!==t.length)return null;if(e&&32!==e.length)return null;var r=Hr(t,e),n=fr().xOnlyPointAddTweak(t,r);return n&&null!==n.xOnlyPubkey?{parity:n.parity,x:yt.hp.from(n.xOnlyPubkey)}:null}function Kr(t,e){return or("TapBranch",yt.hp.concat([t,e]))}function Vr(t,e,r){Object.defineProperty(t,e,{configurable:!0,enumerable:!0,get:function(){var t=r.call(this);return this[e]=t,t},set:function(t){Object.defineProperty(this,e,{configurable:!0,enumerable:!0,value:t,writable:!0})}})}function Wr(t){var e;return function(){return void 0!==e?e:e=t()}}var Gr=it;function qr(t,e){if(!t.data&&!t.output)throw new TypeError("Not enough data");e=Object.assign({validate:!0},e||{}),gt({network:gt.maybe(gt.Object),output:gt.maybe(gt.Buffer),data:gt.maybe(gt.arrayOf(gt.Buffer))},t);var r=t.network||O,n={name:Yi.Embed,network:r,data:[]};if(Vr(n,"output",function(){if(t.data)return re([Gr.OP_RETURN].concat(t.data))}),Vr(n,"data",function(){if(t.output){var e=ne(t.output);if(null!=e)return e.slice(1)}}),e.validate&&t.output){var i=ne(t.output);if(i[0]!==Gr.OP_RETURN)throw new TypeError("Output is invalid");if(!i.slice(1).every(gt.Buffer))throw new TypeError("Output is invalid");if(t.data&&!mt(t.data,n.data))throw new TypeError("Data mismatch")}return Object.assign(n,t)}var zr=it,Zr=zr.OP_RESERVED;function Xr(t,e){if(!(t.input||t.output||t.pubkeys&&void 0!==t.m||t.signatures))throw new TypeError("Not enough data");function r(t){return fe(t)||void 0!==(e.allowIncomplete&&t===zr.OP_0)}e=Object.assign({validate:!0},e||{}),gt({network:gt.maybe(gt.Object),m:gt.maybe(gt.Number),n:gt.maybe(gt.Number),output:gt.maybe(gt.Buffer),pubkeys:gt.maybe(gt.arrayOf(St)),signatures:gt.maybe(gt.arrayOf(r)),input:gt.maybe(gt.Buffer)},t);var n={network:t.network||O,name:Yi.P2MS},i=[],o=!1;function a(t){o||(o=!0,i=ne(t),n.m=i[0]-Zr,n.n=i[i.length-2]-Zr,n.pubkeys=i.slice(1,-2))}if(Vr(n,"output",function(){if(t.m&&n.n&&t.pubkeys)return re([].concat(Zr+t.m,t.pubkeys,Zr+n.n,zr.OP_CHECKMULTISIG))}),Vr(n,"m",function(){if(n.output)return a(n.output),n.m}),Vr(n,"n",function(){if(n.pubkeys)return n.pubkeys.length}),Vr(n,"pubkeys",function(){if(t.output)return a(t.output),n.pubkeys}),Vr(n,"signatures",function(){if(t.input){var e=ne(t.input);if(null!=e)return e.slice(1)}}),Vr(n,"input",function(){if(t.signatures)return re([zr.OP_0].concat(t.signatures))}),Vr(n,"witness",function(){if(n.input)return[]}),Vr(n,"name",function(){if(n.m&&n.n)return"p2ms(".concat(n.m," of ").concat(n.n,")")}),e.validate){if(t.output){if(a(t.output),!gt.Number(i[0]))throw new TypeError("Output is invalid");if(!gt.Number(i[i.length-2]))throw new TypeError("Output is invalid");if(i[i.length-1]!==zr.OP_CHECKMULTISIG)throw new TypeError("Output is invalid");if(n.m<=0||n.n>16||n.m>n.n||n.n!==i.length-3)throw new TypeError("Output is invalid");if(!n.pubkeys.every(function(t){return St(t)}))throw new TypeError("Output is invalid");if(void 0!==t.m&&t.m!==n.m)throw new TypeError("m mismatch");if(void 0!==t.n&&t.n!==n.n)throw new TypeError("n mismatch");if(t.pubkeys&&!mt(t.pubkeys,n.pubkeys))throw new TypeError("Pubkeys mismatch")}if(t.pubkeys){if(void 0!==t.n&&t.n!==t.pubkeys.length)throw new TypeError("Pubkey count mismatch");if(n.n=t.pubkeys.length,n.n<n.m)throw new TypeError("Pubkey count cannot be less than m")}if(t.signatures){if(t.signatures.length<n.m)throw new TypeError("Not enough signatures provided");if(t.signatures.length>n.m)throw new TypeError("Too many signatures provided")}if(t.input){if(t.input[0]!==zr.OP_0)throw new TypeError("Input is invalid");if(0===n.signatures.length||!n.signatures.every(r))throw new TypeError("Input has invalid signature(s)");if(t.signatures&&!mt(t.signatures,n.signatures))throw new TypeError("Signature mismatch");if(void 0!==t.m&&t.m!==t.signatures.length)throw new TypeError("Signature count mismatch")}}return Object.assign(n,t)}var Yr=it;function $r(t,e){if(!(t.input||t.output||t.pubkey||t.input||t.signature))throw new TypeError("Not enough data");e=Object.assign({validate:!0},e||{}),gt({network:gt.maybe(gt.Object),output:gt.maybe(gt.Buffer),pubkey:gt.maybe(St),signature:gt.maybe(fe),input:gt.maybe(gt.Buffer)},t);var r=Wr(function(){return ne(t.input)}),n=t.network||O,i={name:Yi.P2PK,network:n,pubkey:void 0};if(Vr(i,"output",function(){if(t.pubkey)return re([t.pubkey,Yr.OP_CHECKSIG])}),Vr(i,"pubkey",function(){if(t.output)return t.output.slice(1,-1)}),Vr(i,"signature",function(){if(t.input)return r()[0]}),Vr(i,"input",function(){if(t.signature)return re([t.signature])}),Vr(i,"witness",function(){if(i.input)return[]}),e.validate){if(t.output){if(t.output[t.output.length-1]!==Yr.OP_CHECKSIG)throw new TypeError("Output is invalid");if(!St(i.pubkey))throw new TypeError("Output pubkey is invalid");if(t.pubkey&&!t.pubkey.equals(i.pubkey))throw new TypeError("Pubkey mismatch")}if(t.signature&&t.input&&!t.input.equals(i.input))throw new TypeError("Signature mismatch");if(t.input){if(1!==r().length)throw new TypeError("Input is invalid");if(!fe(i.signature))throw new TypeError("Input has invalid signature")}}return Object.assign(i,t)}const Jr=2n**256n,Qr=Jr-0x1000003d1n,tn=Jr-0x14551231950b75fc4402da1732fc9bebfn,en=0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798n,rn=0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8n,nn={p:Qr,n:tn,a:0n,b:7n,Gx:en,Gy:rn},on=t=>dn(dn(t*t)*t+nn.b),an=(t="")=>{throw new Error(t)},sn=t=>"bigint"==typeof t,un=t=>"string"==typeof t,fn=t=>sn(t)&&0n<t&&t<Qr,cn=t=>sn(t)&&0n<t&&t<tn,ln=(t,e)=>!(t=>t instanceof Uint8Array||ArrayBuffer.isView(t)&&"Uint8Array"===t.constructor.name)(t)||"number"==typeof e&&e>0&&t.length!==e?an("Uint8Array expected"):t,hn=t=>new Uint8Array(t),pn=(t,e)=>ln(un(t)?_n(t):hn(ln(t)),e),dn=(t,e=Qr)=>{const r=t%e;return r>=0n?r:e+r},yn=t=>t instanceof bn?t:an("Point expected");class bn{constructor(t,e,r){this.px=t,this.py=e,this.pz=r,Object.freeze(this)}static fromAffine(t){return 0n===t.x&&0n===t.y?vn:new bn(t.x,t.y,1n)}static fromHex(t){let e;const r=(t=pn(t))[0],n=t.subarray(1),i=kn(n,0,32),o=t.length;if(33===o&&[2,3].includes(r)){fn(i)||an("Point hex invalid: x not FE");let t=Pn(on(i));!(1&~r)!=(1n==(1n&t))&&(t=dn(-t)),e=new bn(i,t,1n)}return 65===o&&4===r&&(e=new bn(i,kn(n,32,64),1n)),e?e.ok():an("Point invalid: not on curve")}static fromPrivateKey(t){return gn.mul(xn(t))}get x(){return this.aff().x}get y(){return this.aff().y}equals(t){const{px:e,py:r,pz:n}=this,{px:i,py:o,pz:a}=yn(t),s=dn(e*a),u=dn(i*n),f=dn(r*a),c=dn(o*n);return s===u&&f===c}negate(){return new bn(this.px,dn(-this.py),this.pz)}double(){return this.add(this)}add(t){const{px:e,py:r,pz:n}=this,{px:i,py:o,pz:a}=yn(t),{a:s,b:u}=nn;let f=0n,c=0n,l=0n;const h=dn(3n*u);let p=dn(e*i),d=dn(r*o),y=dn(n*a),b=dn(e+r),g=dn(i+o);b=dn(b*g),g=dn(p+d),b=dn(b-g),g=dn(e+n);let v=dn(i+a);return g=dn(g*v),v=dn(p+y),g=dn(g-v),v=dn(r+n),f=dn(o+a),v=dn(v*f),f=dn(d+y),v=dn(v-f),l=dn(s*g),f=dn(h*y),l=dn(f+l),f=dn(d-l),l=dn(d+l),c=dn(f*l),d=dn(p+p),d=dn(d+p),y=dn(s*y),g=dn(h*g),d=dn(d+y),y=dn(p-y),y=dn(s*y),g=dn(g+y),p=dn(d*g),c=dn(c+p),p=dn(v*g),f=dn(b*f),f=dn(f-p),p=dn(b*d),l=dn(v*l),l=dn(l+p),new bn(f,c,l)}mul(t,e=!0){if(!e&&0n===t)return vn;if(cn(t)||an("scalar invalid"),this.equals(gn))return jn(t).p;let r=vn,n=gn;for(let i=this;t>0n;i=i.double(),t>>=1n)1n&t?r=r.add(i):e&&(n=n.add(i));return r}mulAddQUns(t,e,r){return this.mul(e,!1).add(t.mul(r,!1)).ok()}toAffine(){const{px:t,py:e,pz:r}=this;if(this.equals(vn))return{x:0n,y:0n};if(1n===r)return{x:t,y:e};const n=In(r,Qr);return 1n!==dn(r*n)&&an("inverse invalid"),{x:dn(t*n),y:dn(e*n)}}assertValidity(){const{x:t,y:e}=this.aff();return fn(t)&&fn(e)||an("Point invalid: x or y"),dn(e*e)===on(t)?this:an("Point invalid: not on curve")}multiply(t){return this.mul(t)}aff(){return this.toAffine()}ok(){return this.assertValidity()}toHex(t=!0){const{x:e,y:r}=this.aff();return(t?0n==(1n&r)?"02":"03":"04")+Tn(e)+(t?"":Tn(r))}toRawBytes(t=!0){return _n(this.toHex(t))}}bn.BASE=new bn(en,rn,1n),bn.ZERO=new bn(0n,1n,0n);const{BASE:gn,ZERO:vn}=bn,wn=(t,e)=>t.toString(16).padStart(e,"0"),mn=t=>Array.from(ln(t)).map(t=>wn(t,2)).join(""),Sn=t=>t>=48&&t<=57?t-48:t>=65&&t<=70?t-55:t>=97&&t<=102?t-87:void 0,_n=t=>{const e="hex invalid";if(!un(t))return an(e);const r=t.length,n=r/2;if(r%2)return an(e);const i=hn(n);for(let r=0,o=0;r<n;r++,o+=2){const n=Sn(t.charCodeAt(o)),a=Sn(t.charCodeAt(o+1));if(void 0===n||void 0===a)return an(e);i[r]=16*n+a}return i},En=t=>BigInt("0x"+(mn(t)||"0")),kn=(t,e,r)=>En(t.slice(e,r)),On=t=>sn(t)&&t>=0n&&t<Jr?_n(wn(t,64)):an("bigint expected"),Tn=t=>mn(On(t)),An=(...t)=>{const e=hn(t.reduce((t,e)=>t+ln(e).length,0));let r=0;return t.forEach(t=>{e.set(t,r),r+=t.length}),e},In=(t,e)=>{(0n===t||e<=0n)&&an("no inverse n="+t+" mod="+e);let r=dn(t,e),n=e,i=0n,o=1n,a=1n,s=0n;for(;0n!==r;){const t=n/r,e=n%r,u=i-a*t,f=o-s*t;n=r,r=e,i=a,o=s,a=u,s=f}return 1n===n?dn(i,e):an("no inverse")},Pn=t=>{let e=1n;for(let r=t,n=(Qr+1n)/4n;n>0n;n>>=1n)1n&n&&(e=e*r%Qr),r=r*r%Qr;return dn(e*e)===t?e:an("sqrt invalid")},xn=t=>(sn(t)||(t=En(pn(t,32))),cn(t)?t:an("private key invalid 3")),Bn=()=>"object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0;let Rn;const Un={hexToBytes:_n,bytesToHex:mn,concatBytes:An,bytesToNumberBE:En,numberToBytesBE:On,mod:dn,invert:In,hmacSha256Async:async(t,...e)=>{const r=Bn(),n=r&&r.subtle;if(!n)return an("etc.hmacSha256Async or crypto.subtle must be defined");const i=await n.importKey("raw",t,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]);return hn(await n.sign("HMAC",i,An(...e)))},hmacSha256Sync:Rn,hashToPrivateKey:t=>{((t=pn(t)).length<40||t.length>1024)&&an("expected 40-1024b");const e=dn(En(t),tn-1n);return On(e+1n)},randomBytes:(t=32)=>{const e=Bn();return e&&e.getRandomValues||an("crypto.getRandomValues must be defined"),e.getRandomValues(hn(t))}};let Nn;Object.defineProperties(Un,{hmacSha256Sync:{configurable:!1,get:()=>Rn,set(t){Rn||(Rn=t)}}});const jn=t=>{const e=Nn||(Nn=(()=>{const t=[];let e=gn,r=e;for(let n=0;n<33;n++){r=e,t.push(r);for(let n=1;n<128;n++)r=r.add(e),t.push(r);e=r.double()}return t})()),r=(t,e)=>{let r=e.negate();return t?r:e};let n=vn,i=gn;const o=BigInt(255),a=BigInt(8);for(let s=0;s<33;s++){const u=128*s;let f=Number(t&o);t>>=a,f>128&&(f-=256,t+=1n);const c=u,l=u+Math.abs(f)-1,h=s%2!=0,p=f<0;0===f?i=i.add(r(h,e[c])):n=n.add(r(p,e[l]))}return{p:n,f:i}};var Ln=y(394),Cn=y(287).hp,Fn=it;function Dn(t,e){if(!(t.address||t.hash||t.output||t.redeem||t.input))throw new TypeError("Not enough data");e=Object.assign({validate:!0},e||{}),gt({network:gt.maybe(gt.Object),address:gt.maybe(gt.String),hash:gt.maybe(gt.BufferN(20)),output:gt.maybe(gt.BufferN(23)),redeem:gt.maybe({network:gt.maybe(gt.Object),output:gt.maybe(gt.Buffer),input:gt.maybe(gt.Buffer),witness:gt.maybe(gt.arrayOf(gt.Buffer))}),input:gt.maybe(gt.Buffer),witness:gt.maybe(gt.arrayOf(gt.Buffer))},t);var r=t.network;r||(r=t.redeem&&t.redeem.network||O);var n={network:r,name:Yi.P2SH},i=Wr(function(){var e=Cn.from(et.decode(t.address));return{version:e.readUInt8(0),hash:e.slice(1)}}),o=Wr(function(){return ne(t.input)}),a=Wr(function(){var e=o(),n=e[e.length-1];return{network:r,output:n===Fn.OP_FALSE?Cn.from([]):n,input:re(e.slice(0,-1)),witness:t.witness||[]}});if(Vr(n,"address",function(){if(n.hash){var t=Cn.allocUnsafe(21);return t.writeUInt8(n.network.scriptHash,0),n.hash.copy(t,1),et.encode(t)}}),Vr(n,"hash",function(){return t.output?t.output.slice(2,22):t.address?i().hash:n.redeem&&n.redeem.output?er(n.redeem.output):void 0}),Vr(n,"output",function(){if(n.hash)return re([Fn.OP_HASH160,n.hash,Fn.OP_EQUAL])}),Vr(n,"redeem",function(){if(t.input)return a()}),Vr(n,"input",function(){if(t.redeem&&t.redeem.input&&t.redeem.output)return re([].concat(ne(t.redeem.input),t.redeem.output))}),Vr(n,"witness",function(){return n.redeem&&n.redeem.witness?n.redeem.witness:n.input?[]:void 0}),Vr(n,"name",function(){var t=["p2sh"];return void 0!==n.redeem&&void 0!==n.redeem.name&&t.push(n.redeem.name),t.join("-")}),e.validate){var s=Cn.from([]);if(t.address){if(i().version!==r.scriptHash)throw new TypeError("Invalid version or Network mismatch");if(20!==i().hash.length)throw new TypeError("Invalid address");s=i().hash}if(t.hash){if(s.length>0&&!s.equals(t.hash))throw new TypeError("Hash mismatch");s=t.hash}if(t.output){if(23!==t.output.length||t.output[0]!==Fn.OP_HASH160||20!==t.output[1]||t.output[22]!==Fn.OP_EQUAL)throw new TypeError("Output is invalid");var u=t.output.slice(2,22);if(s.length>0&&!s.equals(u))throw new TypeError("Hash mismatch");s=u}var f=function(t){if(t.output){var e=ne(t.output);if(!e||e.length<1)throw new TypeError("Redeem.output too short");if(t.output.byteLength>520)throw new TypeError("Redeem.output unspendable if larger than 520 bytes");if(Jt(e)>201)throw new TypeError("Redeem.output unspendable with more than 201 non-push ops");var r=er(t.output);if(s.length>0&&!s.equals(r))throw new TypeError("Hash mismatch");s=r}if(t.input){var n=t.input.length>0,i=t.witness&&t.witness.length>0;if(!n&&!i)throw new TypeError("Empty input");if(n&&i)throw new TypeError("Input and witness provided");if(n&&!$t(ne(t.input)))throw new TypeError("Non push-only scriptSig")}};if(t.input){var c=o();if(!c||c.length<1)throw new TypeError("Input too short");if(!Cn.isBuffer(a().output))throw new TypeError("Input is invalid");f(a())}if(t.redeem){if(t.redeem.network&&t.redeem.network!==r)throw new TypeError("Network mismatch");if(t.input){var l=a();if(t.redeem.output&&!t.redeem.output.equals(l.output))throw new TypeError("Redeem.output mismatch");if(t.redeem.input&&!t.redeem.input.equals(l.input))throw new TypeError("Redeem.input mismatch")}f(t.redeem)}if(t.witness&&t.redeem&&t.redeem.witness&&!mt(t.redeem.witness,t.witness))throw new TypeError("Witness and redeem.witness mismatch")}return Object.assign(n,t)}var Hn=it,Mn=1,Kn=80;function Vn(t,e){if(!(t.address||t.output||t.pubkey||t.internalPubkey||t.witness&&t.witness.length>1))throw new TypeError("Not enough data");e=Object.assign({validate:!0},e||{}),gt({address:gt.maybe(gt.String),input:gt.maybe(gt.BufferN(0)),network:gt.maybe(gt.Object),output:gt.maybe(gt.BufferN(34)),internalPubkey:gt.maybe(gt.BufferN(32)),hash:gt.maybe(gt.BufferN(32)),pubkey:gt.maybe(gt.BufferN(32)),signature:gt.maybe(gt.anyOf(gt.BufferN(64),gt.BufferN(65))),witness:gt.maybe(gt.arrayOf(gt.Buffer)),scriptTree:gt.maybe(Ot),redeem:gt.maybe({output:gt.maybe(gt.Buffer),redeemVersion:gt.maybe(gt.Number),witness:gt.maybe(gt.arrayOf(gt.Buffer))}),redeemVersion:gt.maybe(gt.Number)},t);var r=Wr(function(){return Te(t.address)}),n=Wr(function(){if(t.witness&&t.witness.length)return t.witness.length>=2&&t.witness[t.witness.length-1][0]===Kn?t.witness.slice(0,-1):t.witness.slice()}),i=Wr(function(){return t.scriptTree?Cr(t.scriptTree):t.hash?{hash:t.hash}:void 0}),o=t.network||O,a={name:Yi.P2TR,network:o};if(Vr(a,"address",function(){if(a.pubkey){var t=L.p2.toWords(a.pubkey);return t.unshift(Mn),L.p2.encode(o.bech32,t)}}),Vr(a,"hash",function(){var t=i();if(t)return t.hash;var e=n();if(e&&e.length>1){var r=e[e.length-1],o=r[0]&Et;return Lr(r,Dr({output:e[e.length-2],version:o}))}}),Vr(a,"output",function(){if(a.pubkey)return re([Hn.OP_1,a.pubkey])}),Vr(a,"redeemVersion",function(){return t.redeemVersion?t.redeemVersion:t.redeem&&void 0!==t.redeem.redeemVersion&&null!==t.redeem.redeemVersion?t.redeem.redeemVersion:Ur}),Vr(a,"redeem",function(){var t=n();if(t&&!(t.length<2))return{output:t[t.length-2],witness:t.slice(0,-2),redeemVersion:t[t.length-1][0]&Et}}),Vr(a,"pubkey",function(){if(t.pubkey)return t.pubkey;if(t.output)return t.output.slice(2);if(t.address)return r().data;if(a.internalPubkey){var e=Mr(a.internalPubkey,a.hash);if(e)return e.x}}),Vr(a,"internalPubkey",function(){if(t.internalPubkey)return t.internalPubkey;var e=n();return e&&e.length>1?e[e.length-1].slice(1,33):void 0}),Vr(a,"signature",function(){if(t.signature)return t.signature;var e=n();return e&&1===e.length?e[0]:void 0}),Vr(a,"witness",function(){if(t.witness)return t.witness;var e=i();if(e&&t.redeem&&t.redeem.output&&t.internalPubkey){var r=Fr(e,Dr({output:t.redeem.output,version:a.redeemVersion}));if(!r)return;var n=Mr(t.internalPubkey,e.hash);if(!n)return;var o=yt.hp.concat([yt.hp.from([a.redeemVersion|n.parity]),t.internalPubkey].concat(r));return[t.redeem.output,o]}return t.signature?[t.signature]:void 0}),e.validate){var s=yt.hp.from([]);if(t.address){if(o&&o.bech32!==r().prefix)throw new TypeError("Invalid prefix or Network mismatch");if(r().version!==Mn)throw new TypeError("Invalid address version");if(32!==r().data.length)throw new TypeError("Invalid address data");s=r().data}if(t.pubkey){if(s.length>0&&!s.equals(t.pubkey))throw new TypeError("Pubkey mismatch");s=t.pubkey}if(t.output){if(34!==t.output.length||t.output[0]!==Hn.OP_1||32!==t.output[1])throw new TypeError("Output is invalid");if(s.length>0&&!s.equals(t.output.slice(2)))throw new TypeError("Pubkey mismatch");s=t.output.slice(2)}if(t.internalPubkey){var u=Mr(t.internalPubkey,a.hash);if(s.length>0&&!s.equals(u.x))throw new TypeError("Pubkey mismatch");s=u.x}var f=i();if(t.hash&&f&&!t.hash.equals(f.hash))throw new TypeError("Hash mismatch");if(t.redeem&&t.redeem.output&&f&&!Fr(f,Dr({output:t.redeem.output,version:a.redeemVersion})))throw new TypeError("Redeem script not in tree");var c=n();if(t.redeem&&a.redeem){if(t.redeem.redeemVersion&&t.redeem.redeemVersion!==a.redeem.redeemVersion)throw new TypeError("Redeem.redeemVersion and witness mismatch");if(t.redeem.output){if(0===ne(t.redeem.output).length)throw new TypeError("Redeem.output is invalid");if(a.redeem.output&&!t.redeem.output.equals(a.redeem.output))throw new TypeError("Redeem.output and witness mismatch")}if(t.redeem.witness&&a.redeem.witness&&!mt(t.redeem.witness,a.redeem.witness))throw new TypeError("Redeem.witness and witness mismatch")}if(c&&c.length)if(1===c.length){if(t.signature&&!t.signature.equals(c[0]))throw new TypeError("Signature mismatch")}else{var l=c[c.length-1];if(l.length<33)throw new TypeError("The control-block length is too small. Got ".concat(l.length,", expected min 33."));if((l.length-33)%32!=0)throw new TypeError("The control-block length of ".concat(l.length," is incorrect!"));var h=(l.length-33)/32;if(h>128)throw new TypeError("The script path is too long. Got ".concat(h,", expected max 128."));var p=l.slice(1,33);if(t.internalPubkey&&!t.internalPubkey.equals(p))throw new TypeError("Internal pubkey mismatch");if(!fr().isXOnlyPoint(p))throw new TypeError("Invalid internalPubkey for p2tr witness");var d=l[0]&Et,y=Mr(p,Lr(l,Dr({output:c[c.length-2],version:d})));if(!y)throw new TypeError("Invalid outputKey for p2tr witness");if(s.length&&!s.equals(y.x))throw new TypeError("Pubkey mismatch for p2tr witness");if(y.parity!==(1&l[0]))throw new Error("Incorrect parity")}}return Object.assign(a,t)}var Wn=y(287).hp,Gn=it,qn=Wn.alloc(0);function zn(t,e){if(!(t.address||t.hash||t.output||t.pubkey||t.witness))throw new TypeError("Not enough data");e=Object.assign({validate:!0},e||{}),gt({address:gt.maybe(gt.String),hash:gt.maybe(gt.BufferN(20)),input:gt.maybe(gt.BufferN(0)),network:gt.maybe(gt.Object),output:gt.maybe(gt.BufferN(22)),pubkey:gt.maybe(St),signature:gt.maybe(fe),witness:gt.maybe(gt.arrayOf(gt.Buffer))},t);var r=Wr(function(){var e=L.I.decode(t.address),r=e.words.shift(),n=L.I.fromWords(e.words);return{version:r,prefix:e.prefix,data:Wn.from(n)}}),n=t.network||O,i={name:Yi.P2WPKH,network:n};if(Vr(i,"address",function(){if(i.hash){var t=L.I.toWords(i.hash);return t.unshift(0),L.I.encode(n.bech32,t)}}),Vr(i,"hash",function(){return t.output?t.output.slice(2,22):t.address?r().data:t.pubkey||i.pubkey?er(t.pubkey||i.pubkey):void 0}),Vr(i,"output",function(){if(i.hash)return re([Gn.OP_0,i.hash])}),Vr(i,"pubkey",function(){return t.pubkey?t.pubkey:t.witness?t.witness[1]:void 0}),Vr(i,"signature",function(){if(t.witness)return t.witness[0]}),Vr(i,"input",function(){if(i.witness)return qn}),Vr(i,"witness",function(){if(t.pubkey&&t.signature)return[t.signature,t.pubkey]}),e.validate){var o=Wn.from([]);if(t.address){if(n&&n.bech32!==r().prefix)throw new TypeError("Invalid prefix or Network mismatch");if(0!==r().version)throw new TypeError("Invalid address version");if(20!==r().data.length)throw new TypeError("Invalid address data");o=r().data}if(t.hash){if(o.length>0&&!o.equals(t.hash))throw new TypeError("Hash mismatch");o=t.hash}if(t.output){if(22!==t.output.length||t.output[0]!==Gn.OP_0||20!==t.output[1])throw new TypeError("Output is invalid");if(o.length>0&&!o.equals(t.output.slice(2)))throw new TypeError("Hash mismatch");o=t.output.slice(2)}if(t.pubkey){var a=er(t.pubkey);if(o.length>0&&!o.equals(a))throw new TypeError("Hash mismatch");if(o=a,!St(t.pubkey)||33!==t.pubkey.length)throw new TypeError("Invalid pubkey for p2wpkh")}if(t.witness){if(2!==t.witness.length)throw new TypeError("Witness is invalid");if(!fe(t.witness[0]))throw new TypeError("Witness has invalid signature");if(!St(t.witness[1])||33!==t.witness[1].length)throw new TypeError("Witness has invalid pubkey");if(t.signature&&!t.signature.equals(t.witness[0]))throw new TypeError("Signature mismatch");if(t.pubkey&&!t.pubkey.equals(t.witness[1]))throw new TypeError("Pubkey mismatch");var s=er(t.witness[1]);if(o.length>0&&!o.equals(s))throw new TypeError("Hash mismatch")}}return Object.assign(i,t)}var Zn=y(287).hp,Xn=it,Yn=Zn.alloc(0);function $n(t){return!(!Zn.isBuffer(t)||65!==t.length||4!==t[0]||!St(t))}function Jn(t,e){if(!(t.address||t.hash||t.output||t.redeem||t.witness))throw new TypeError("Not enough data");e=Object.assign({validate:!0},e||{}),gt({network:gt.maybe(gt.Object),address:gt.maybe(gt.String),hash:gt.maybe(gt.BufferN(32)),output:gt.maybe(gt.BufferN(34)),redeem:gt.maybe({input:gt.maybe(gt.Buffer),network:gt.maybe(gt.Object),output:gt.maybe(gt.Buffer),witness:gt.maybe(gt.arrayOf(gt.Buffer))}),input:gt.maybe(gt.BufferN(0)),witness:gt.maybe(gt.arrayOf(gt.Buffer))},t);var r=Wr(function(){var e=L.I.decode(t.address),r=e.words.shift(),n=L.I.fromWords(e.words);return{version:r,prefix:e.prefix,data:Zn.from(n)}}),n=Wr(function(){return ne(t.redeem.input)}),i=t.network;i||(i=t.redeem&&t.redeem.network||O);var o={network:i,name:Yi.P2WSH};if(Vr(o,"address",function(){if(o.hash){var t=L.I.toWords(o.hash);return t.unshift(0),L.I.encode(i.bech32,t)}}),Vr(o,"hash",function(){return t.output?t.output.slice(2):t.address?r().data:o.redeem&&o.redeem.output?tr(o.redeem.output):void 0}),Vr(o,"output",function(){if(o.hash)return re([Xn.OP_0,o.hash])}),Vr(o,"redeem",function(){if(t.witness)return{output:t.witness[t.witness.length-1],input:Yn,witness:t.witness.slice(0,-1)}}),Vr(o,"input",function(){if(o.witness)return Yn}),Vr(o,"witness",function(){if(t.redeem&&t.redeem.input&&t.redeem.input.length>0&&t.redeem.output&&t.redeem.output.length>0){var e=ae(n());return o.redeem=Object.assign({witness:e},t.redeem),o.redeem.input=Yn,[].concat(e,t.redeem.output)}if(t.redeem&&t.redeem.output&&t.redeem.witness)return[].concat(t.redeem.witness,t.redeem.output)}),Vr(o,"name",function(){var t=["p2wsh"];return void 0!==o.redeem&&void 0!==o.redeem.name&&t.push(o.redeem.name),t.join("-")}),e.validate){var a=Zn.from([]);if(t.address){if(r().prefix!==i.bech32)throw new TypeError("Invalid prefix or Network mismatch");if(0!==r().version)throw new TypeError("Invalid address version");if(32!==r().data.length)throw new TypeError("Invalid address data");a=r().data}if(t.hash){if(a.length>0&&!a.equals(t.hash))throw new TypeError("Hash mismatch");a=t.hash}if(t.output){if(34!==t.output.length||t.output[0]!==Xn.OP_0||32!==t.output[1])throw new TypeError("Output is invalid");var s=t.output.slice(2);if(a.length>0&&!a.equals(s))throw new TypeError("Hash mismatch");a=s}if(t.redeem){if(t.redeem.network&&t.redeem.network!==i)throw new TypeError("Network mismatch");if(t.redeem.input&&t.redeem.input.length>0&&t.redeem.witness&&t.redeem.witness.length>0)throw new TypeError("Ambiguous witness source");if(t.redeem.output){var u=ne(t.redeem.output);if(!u||u.length<1)throw new TypeError("Redeem.output is invalid");if(t.redeem.output.byteLength>3600)throw new TypeError("Redeem.output unspendable if larger than 3600 bytes");if(Jt(u)>201)throw new TypeError("Redeem.output unspendable with more than 201 non-push ops");var f=tr(t.redeem.output);if(a.length>0&&!a.equals(f))throw new TypeError("Hash mismatch");a=f}if(t.redeem.input&&!$t(n()))throw new TypeError("Non push-only scriptSig");if(t.witness&&t.redeem.witness&&!mt(t.witness,t.redeem.witness))throw new TypeError("Witness and redeem.witness mismatch");if(t.redeem.input&&n().some($n)||t.redeem.output&&(ne(t.redeem.output)||[]).some($n))throw new TypeError("redeem.input or redeem.output contains uncompressed pubkey")}if(t.witness&&t.witness.length>0){var c=t.witness[t.witness.length-1];if(t.redeem&&t.redeem.output&&!t.redeem.output.equals(c))throw new TypeError("Witness and redeem.output mismatch");if(t.witness.some($n)||(ne(c)||[]).some($n))throw new TypeError("Witness contains uncompressed pubkey")}}return Object.assign(o,t)}var Qn=y(287).hp;function ti(t){return ti="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ti(t)}function ei(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,ni(n.key),n)}}function ri(t,e,r){return(e=ni(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function ni(t){var e=function(t){if("object"!=ti(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=ti(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==ti(e)?e:e+""}var ii=gt;function oi(t){var e=t.length;return vr(e)+e}var ai=Qn.allocUnsafe(0),si=[],ui=Qn.from("0000000000000000000000000000000000000000000000000000000000000000","hex"),fi=Qn.from("0000000000000000000000000000000000000000000000000000000000000001","hex"),ci=Qn.from("ffffffffffffffff","hex"),li={script:ai,valueBuffer:ci},hi=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),ri(this,"version",1),ri(this,"locktime",0),ri(this,"ins",[]),ri(this,"outs",[])}return e=t,r=[{key:"isCoinbase",value:function(){return 1===this.ins.length&&t.isCoinbaseHash(this.ins[0].hash)}},{key:"addInput",value:function(e,r,n,i){return ii(Nt(At,Lt,Ut(Lt),Ut(Bt)),arguments),Dt(n)&&(n=t.DEFAULT_SEQUENCE),this.ins.push({hash:e,index:r,script:i||ai,sequence:n,witness:si})-1}},{key:"addOutput",value:function(t,e){return ii(Nt(Bt,_t),arguments),this.outs.push({script:t,value:e})-1}},{key:"hasWitnesses",value:function(){return this.ins.some(function(t){return 0!==t.witness.length})}},{key:"weight",value:function(){return 3*this.byteLength(!1)+this.byteLength(!0)}},{key:"virtualSize",value:function(){return Math.ceil(this.weight()/4)}},{key:"byteLength",value:function(){var t=(!(arguments.length>0&&void 0!==arguments[0])||arguments[0])&&this.hasWitnesses();return(t?10:8)+vr(this.ins.length)+vr(this.outs.length)+this.ins.reduce(function(t,e){return t+40+oi(e.script)},0)+this.outs.reduce(function(t,e){return t+8+oi(e.script)},0)+(t?this.ins.reduce(function(t,e){return t+(vr((r=e.witness).length)+r.reduce(function(t,e){return t+oi(e)},0));var r},0):0)}},{key:"clone",value:function(){var e=new t;return e.version=this.version,e.locktime=this.locktime,e.ins=this.ins.map(function(t){return{hash:t.hash,index:t.index,script:t.script,sequence:t.sequence,witness:t.witness}}),e.outs=this.outs.map(function(t){return{script:t.script,value:t.value}}),e}},{key:"hashForSignature",value:function(e,r,n){if(ii(Nt(Lt,Bt,It),arguments),e>=this.ins.length)return fi;var i=re(ne(r).filter(function(t){return t!==it.OP_CODESEPARATOR})),o=this.clone();if((31&n)===t.SIGHASH_NONE)o.outs=[],o.ins.forEach(function(t,r){r!==e&&(t.sequence=0)});else if((31&n)===t.SIGHASH_SINGLE){if(e>=this.outs.length)return fi;o.outs.length=e+1;for(var a=0;a<e;a++)o.outs[a]=li;o.ins.forEach(function(t,r){r!==e&&(t.sequence=0)})}n&t.SIGHASH_ANYONECANPAY?(o.ins=[o.ins[e]],o.ins[0].script=i):(o.ins.forEach(function(t){t.script=ai}),o.ins[e].script=i);var s=Qn.allocUnsafe(o.byteLength(!1)+4);return s.writeInt32LE(n,s.length-4),o.__toBuffer(s,0,!1),rr(s)}},{key:"hashForWitnessV1",value:function(e,r,n,i,o,a){if(ii(Nt(Lt,ii.arrayOf(Bt),ii.arrayOf(_t),Lt),arguments),n.length!==this.ins.length||r.length!==this.ins.length)throw new Error("Must supply prevout script and value for all inputs");var s=i===t.SIGHASH_DEFAULT?t.SIGHASH_ALL:i&t.SIGHASH_OUTPUT_MASK,u=(i&t.SIGHASH_INPUT_MASK)===t.SIGHASH_ANYONECANPAY,f=s===t.SIGHASH_NONE,c=s===t.SIGHASH_SINGLE,l=ai,h=ai,p=ai,d=ai,y=ai;if(!u){var b=Pr.withCapacity(36*this.ins.length);this.ins.forEach(function(t){b.writeSlice(t.hash),b.writeUInt32(t.index)}),l=tr(b.end()),b=Pr.withCapacity(8*this.ins.length),n.forEach(function(t){return b.writeUInt64(t)}),h=tr(b.end()),b=Pr.withCapacity(r.map(oi).reduce(function(t,e){return t+e})),r.forEach(function(t){return b.writeVarSlice(t)}),p=tr(b.end()),b=Pr.withCapacity(4*this.ins.length),this.ins.forEach(function(t){return b.writeUInt32(t.sequence)}),d=tr(b.end())}if(f||c){if(c&&e<this.outs.length){var g=this.outs[e],v=Pr.withCapacity(8+oi(g.script));v.writeUInt64(g.value),v.writeVarSlice(g.script),y=tr(v.end())}}else{if(!this.outs.length)throw new Error("Add outputs to the transaction before signing.");var w=this.outs.map(function(t){return 8+oi(t.script)}).reduce(function(t,e){return t+e}),m=Pr.withCapacity(w);this.outs.forEach(function(t){m.writeUInt64(t.value),m.writeVarSlice(t.script)}),y=tr(m.end())}var S=(o?2:0)+(a?1:0),_=174-(u?49:0)-(f?32:0)+(a?32:0)+(o?37:0),E=Pr.withCapacity(_);if(E.writeUInt8(i),E.writeInt32(this.version),E.writeUInt32(this.locktime),E.writeSlice(l),E.writeSlice(h),E.writeSlice(p),E.writeSlice(d),f||c||E.writeSlice(y),E.writeUInt8(S),u){var k=this.ins[e];E.writeSlice(k.hash),E.writeUInt32(k.index),E.writeUInt64(n[e]),E.writeVarSlice(r[e]),E.writeUInt32(k.sequence)}else E.writeUInt32(e);if(a){var O=Pr.withCapacity(oi(a));O.writeVarSlice(a),E.writeSlice(tr(O.end()))}return c&&E.writeSlice(y),o&&(E.writeSlice(o),E.writeUInt8(0),E.writeUInt32(4294967295)),or("TapSighash",Qn.concat([Qn.from([0]),E.end()]))}},{key:"hashForWitnessV0",value:function(e,r,n,i){ii(Nt(Lt,Bt,_t,Lt),arguments);var o,a=Qn.from([]),s=ui,u=ui,f=ui;if(i&t.SIGHASH_ANYONECANPAY||(a=Qn.allocUnsafe(36*this.ins.length),o=new Pr(a,0),this.ins.forEach(function(t){o.writeSlice(t.hash),o.writeUInt32(t.index)}),u=rr(a)),i&t.SIGHASH_ANYONECANPAY||(31&i)===t.SIGHASH_SINGLE||(31&i)===t.SIGHASH_NONE||(a=Qn.allocUnsafe(4*this.ins.length),o=new Pr(a,0),this.ins.forEach(function(t){o.writeUInt32(t.sequence)}),f=rr(a)),(31&i)!==t.SIGHASH_SINGLE&&(31&i)!==t.SIGHASH_NONE){var c=this.outs.reduce(function(t,e){return t+8+oi(e.script)},0);a=Qn.allocUnsafe(c),o=new Pr(a,0),this.outs.forEach(function(t){o.writeUInt64(t.value),o.writeVarSlice(t.script)}),s=rr(a)}else if((31&i)===t.SIGHASH_SINGLE&&e<this.outs.length){var l=this.outs[e];a=Qn.allocUnsafe(8+oi(l.script)),(o=new Pr(a,0)).writeUInt64(l.value),o.writeVarSlice(l.script),s=rr(a)}a=Qn.allocUnsafe(156+oi(r)),o=new Pr(a,0);var h=this.ins[e];return o.writeInt32(this.version),o.writeSlice(u),o.writeSlice(f),o.writeSlice(h.hash),o.writeUInt32(h.index),o.writeVarSlice(r),o.writeUInt64(n),o.writeUInt32(h.sequence),o.writeSlice(s),o.writeUInt32(this.locktime),o.writeUInt32(i),rr(a)}},{key:"getHash",value:function(t){return t&&this.isCoinbase()?Qn.alloc(32,0):rr(this.__toBuffer(void 0,void 0,t))}},{key:"getId",value:function(){return Ar(this.getHash(!1)).toString("hex")}},{key:"toBuffer",value:function(t,e){return this.__toBuffer(t,e,!0)}},{key:"toHex",value:function(){return this.toBuffer(void 0,void 0).toString("hex")}},{key:"setInputScript",value:function(t,e){ii(Nt(It,Bt),arguments),this.ins[t].script=e}},{key:"setWitness",value:function(t,e){ii(Nt(It,[Bt]),arguments),this.ins[t].witness=e}},{key:"__toBuffer",value:function(e,r){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];e||(e=Qn.allocUnsafe(this.byteLength(n)));var i=new Pr(e,r||0);i.writeInt32(this.version);var o=n&&this.hasWitnesses();return o&&(i.writeUInt8(t.ADVANCED_TRANSACTION_MARKER),i.writeUInt8(t.ADVANCED_TRANSACTION_FLAG)),i.writeVarInt(this.ins.length),this.ins.forEach(function(t){i.writeSlice(t.hash),i.writeUInt32(t.index),i.writeVarSlice(t.script),i.writeUInt32(t.sequence)}),i.writeVarInt(this.outs.length),this.outs.forEach(function(t){void 0!==t.value?i.writeUInt64(t.value):i.writeSlice(t.valueBuffer),i.writeVarSlice(t.script)}),o&&this.ins.forEach(function(t){i.writeVector(t.witness)}),i.writeUInt32(this.locktime),void 0!==r?e.slice(r,i.offset):e}}],n=[{key:"fromBuffer",value:function(e,r){var n=new xr(e),i=new t;i.version=n.readInt32();var o=n.readUInt8(),a=n.readUInt8(),s=!1;o===t.ADVANCED_TRANSACTION_MARKER&&a===t.ADVANCED_TRANSACTION_FLAG?s=!0:n.offset-=2;for(var u=n.readVarInt(),f=0;f<u;++f){var c=n.readSlice(32),l=n.readUInt32(),h=n.readVarSlice(),p=n.readUInt32();i.ins.push({hash:c,index:l,script:h,sequence:p,witness:si})}for(var d=n.readVarInt(),y=0;y<d;++y)i.outs.push({value:n.readUInt64(),script:n.readVarSlice()});if(s){for(var b=0;b<u;++b)i.ins[b].witness=n.readVector();if(!i.hasWitnesses())throw new Error("Transaction has superfluous witness data")}if(i.locktime=n.readUInt32(),r)return i;if(n.offset!==e.length)throw new Error("Transaction has unexpected data");return i}},{key:"fromHex",value:function(e){return t.fromBuffer(Qn.from(e,"hex"),!1)}},{key:"isCoinbaseHash",value:function(t){ii(At,t);for(var e=0;e<32;++e)if(0!==t[e])return!1;return!0}}],r&&ei(e.prototype,r),n&&ei(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,r,n}();ri(hi,"DEFAULT_SEQUENCE",4294967295),ri(hi,"SIGHASH_DEFAULT",0),ri(hi,"SIGHASH_ALL",1),ri(hi,"SIGHASH_NONE",2),ri(hi,"SIGHASH_SINGLE",3),ri(hi,"SIGHASH_ANYONECANPAY",128),ri(hi,"SIGHASH_OUTPUT_MASK",3),ri(hi,"SIGHASH_INPUT_MASK",128),ri(hi,"ADVANCED_TRANSACTION_MARKER",0),ri(hi,"ADVANCED_TRANSACTION_FLAG",1),ri(hi,"TRUC_VERSION",3),ri(hi,"TRUC_MAX_VSIZE",1e4),ri(hi,"TRUC_CHILD_MAX_VSIZE",1e3);var pi=y(287).hp;function di(t,e){if(t){if("string"==typeof t)return yi(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?yi(t,e):void 0}}function yi(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}var bi=function(t){var e=32===t.length?t:t.slice(1,33);return pi.isBuffer(e)?e:pi.from(e)};function gi(t,e,r){var n=function(t,e,r){if(!t.tapScriptSig||!t.tapScriptSig.length)throw new Error("Can not finalize taproot input #".concat(e,". No tapleaf script signature provided."));var n=(t.tapLeafScript||[]).sort(function(t,e){return t.controlBlock.length-e.controlBlock.length}).find(function(e){return function(t,e,r){var n=Dr({output:t.script,version:t.leafVersion});return(!r||r.equals(n))&&void 0!==e.find(function(t){return t.leafHash.equals(n)})}(e,t.tapScriptSig,r)});if(!n)throw new Error("Can not finalize taproot input #".concat(e,". Signature for tapleaf script not found."));return n}(e,t,r);try{var i=function(t,e){var r=Dr({output:e.script,version:e.leafVersion});return(t.tapScriptSig||[]).filter(function(t){return t.leafHash.equals(r)}).map(function(t){return function(t,e){return Object.assign({positionInScript:zi(e.pubkey,t)},e)}(e.script,t)}).sort(function(t,e){return e.positionInScript-t.positionInScript}).map(function(t){return t.signature})}(e,n);return{finalScriptWitness:Vi(i.concat(n.script).concat(n.controlBlock))}}catch(e){throw new Error("Can not finalize taproot input #".concat(t,": ").concat(e))}}function vi(t,e){var r=e?pi.from([e]):pi.from([]);return pi.concat([t,r])}function wi(t){return t&&!!(t.tapInternalKey||t.tapMerkleRoot||t.tapLeafScript&&t.tapLeafScript.length||t.tapBip32Derivation&&t.tapBip32Derivation.length||t.witnessUtxo&&Ki(t.witnessUtxo.script))}function mi(t,e){return t&&!!(t.tapInternalKey||t.tapTree||t.tapBip32Derivation&&t.tapBip32Derivation.length||e&&Ki(e))}function Si(t,e,r){!function(t,e,r){var n=wi(t)&&Ai(e),i=Ai(t)&&wi(e),o=t===e&&wi(e)&&Ai(e);if(n||i||o)throw new Error("Invalid arguments for Psbt.".concat(r,". ")+"Cannot use both taproot and non-taproot fields.")}(t,e,r),function(t,e,r){if(e.tapMerkleRoot){var n=(e.tapLeafScript||[]).every(function(t){return Ti(t,e.tapMerkleRoot)}),i=(t.tapLeafScript||[]).every(function(t){return Ti(t,e.tapMerkleRoot)});if(!n||!i)throw new Error("Invalid arguments for Psbt.".concat(r,". Tapleaf not part of taptree."))}else if(t.tapMerkleRoot&&!(e.tapLeafScript||[]).every(function(e){return Ti(e,t.tapMerkleRoot)}))throw new Error("Invalid arguments for Psbt.".concat(r,". Tapleaf not part of taptree."))}(t,e,r)}function _i(t,e,r){!function(t,e,r){var n=mi(t)&&Ai(e),i=Ai(t)&&mi(e),o=t===e&&mi(e)&&Ai(e);if(n||i||o)throw new Error("Invalid arguments for Psbt.".concat(r,". ")+"Cannot use both taproot and non-taproot fields.")}(t,e,r),function(t,e){if(e.tapTree||e.tapInternalKey){var r=e.tapInternalKey||t.tapInternalKey,n=e.tapTree||t.tapTree;if(r){var i=t.script,o=function(t,e){return Vn({internalPubkey:t,scriptTree:e&&Ei(e.leaves)}).output}(r,n);if(i&&!i.equals(o))throw new Error("Error adding output. Script or address missmatch.")}}}(t,e)}function Ei(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return 1===t.length&&0===t[0].depth?{output:t[0].script,version:t[0].leafVersion}:function(t){var e,r,n=function(t){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=di(t))){e&&(t=e);var r=0,n=function(){};return{s:n,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:n}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,o=!0,a=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return o=t.done,t},e:function(t){a=!0,i=t},f:function(){try{o||null==e.return||e.return()}finally{if(a)throw i}}}}(t);try{for(n.s();!(r=n.n()).done;)if(!(e=Oi(r.value,e)))throw new Error("No room left to insert tapleaf in tree")}catch(t){n.e(t)}finally{n.f()}return e}(t)}function ki(t){return{signature:t.slice(0,64),hashType:t.slice(64)[0]||hi.SIGHASH_DEFAULT}}function Oi(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;if(r>Nr)throw new Error("Max taptree depth exceeded.");if(t.depth===r)return e?void 0:{output:t.script,version:t.leafVersion};if(!kt(e)){var n=Oi(t,e&&e[0],r+1);if(n)return[n,e&&e[1]];var i=Oi(t,e&&e[1],r+1);return i?[e&&e[0],i]:void 0}}function Ti(t,e){if(!e)return!0;var r=Dr({output:t.script,version:t.leafVersion});return Lr(t.controlBlock,r).equals(e)}function Ai(t){return t&&!!(t.redeemScript||t.witnessScript||t.bip32Derivation&&t.bip32Derivation.length)}var Ii=y(287).hp,Pi=it,xi=16,Bi=2,Ri=40;function Ui(t,e){if(!(t.address||t.output||t.program||void 0!==t.deploymentVersion&&t.hash160))throw new TypeError("At least one of address, output or program must be provided");e=Object.assign({validate:!0},e||{}),gt({address:gt.maybe(gt.String),output:gt.maybe(gt.Buffer),program:gt.maybe(gt.Buffer),network:gt.maybe(gt.Object),deploymentVersion:gt.maybe(gt.Number),hash160:gt.maybe(gt.BufferN(20))},t);var r=function(){if(void 0!==t.deploymentVersion&&void 0!==t.hash160){if(20!==t.hash160.length)throw new TypeError("hash160 must be exactly 20 bytes");if(t.deploymentVersion<0||t.deploymentVersion>255)throw new TypeError("deploymentVersion must fit in one byte");return Ii.concat([Ii.of(t.deploymentVersion),t.hash160])}},n=Wr(function(){return Te(t.address)}),i=t.network||O,o={name:Yi.P2OP,network:i,deploymentVersion:0};if(Vr(o,"program",function(){if(t.program)return t.program;var e=r();if(e)return e;if(t.output){if(t.output[0]!==Pi.OP_16)throw new TypeError("Invalid P2OP script");var i,o=1;if(t.output[1]<76)i=t.output[1],o=2;else{if(76!==t.output[1])throw new TypeError("Unsupported push opcode in P2OP script");i=t.output[2],o=3}return t.output.slice(o,o+i)}return t.address?n().data:void 0}),Vr(o,"deploymentVersion",function(){if(o.program)return o.program[0]}),Vr(o,"hash160",function(){if(o.program)return o.program.slice(1)}),Vr(o,"output",function(){if(o.program)return re([Pi.OP_16,o.program])}),Vr(o,"address",function(){if(o.program){if(!i.bech32Opnet)throw new TypeError("Network does not support opnet");var t=L.p2.toWords(o.program);return t.unshift(xi),L.p2.encode(i.bech32Opnet,t)}}),e.validate){var a=yt.hp.alloc(0);if(t.address){var s=n();if(i.bech32Opnet!==s.prefix)throw new TypeError("Invalid prefix or network mismatch");if(s.version!==xi)throw new TypeError("Invalid witness version for p2op");if(s.data.length<Bi||s.data.length>Ri)throw new TypeError("Invalid witness program length");a=s.data}if(t.program){if(a.length&&!a.equals(t.program))throw new TypeError("Program mismatch");a=t.program}if(!a.length&&void 0!==t.deploymentVersion&&t.hash160&&(a=r()),t.output){var u=o.program;if(a.length&&!a.equals(u))throw new TypeError("Program mismatch (output vs other source)");a=u}if(a.length<Bi||a.length>Ri)throw new TypeError("Witness program must be 2–40 bytes. Was ".concat(a.length," bytes"));if(void 0!==t.deploymentVersion&&t.deploymentVersion!==a[0])throw new TypeError("deploymentVersion mismatch");if(t.hash160&&!t.hash160.equals(a.slice(1)))throw new TypeError("hash160 mismatch")}return Object.assign(o,t)}var Ni=y(287).hp;function ji(t){return function(e){try{return t({output:e}),!0}catch(t){return!1}}}var Li=ji(Xr),Ci=ji($r),Fi=ji(Qi),Di=ji(zn),Hi=ji(Jn),Mi=ji(Dn),Ki=ji(Vn);function Vi(t){var e,r=Ni.allocUnsafe(0);function n(t){var e=r.length,n=Ln.encodingLength(t);r=Ni.concat([r,Ni.allocUnsafe(n)]),Ln.encode(t,r,e)}return n((e=t).length),e.forEach(function(t){n(t.length),function(t){r=Ni.concat([r,Ni.from(t)])}(t)}),r}function Wi(t){if(32!==t.length){if([33,65].includes(t.length)){var e;try{e=bn.fromHex(t)}catch(t){throw new Error("Invalid secp256k1 public key bytes. Cannot parse.")}var r=Gi(e.x),n=Gi(e.y),i=e.y%2n==0n?6:7,o=Ni.alloc(65);return o[0]=i,r.copy(o,1),n.copy(o,33),{hybrid:o,uncompressed:Ni.concat([Ni.from([4]),r,n])}}console.warn("Unsupported key length=".concat(t.length,". Must be 33 (compressed) or 65 (uncompressed)."))}}function Gi(t){var e=t.toString(16);return(e=e.padStart(64,"0")).length>64&&(e=e.slice(-64)),Ni.from(e,"hex")}function qi(t,e){if(t.equals(e))return!0;if(65===t.length&&65===e.length){var r=Ni.from(t),n=Ni.from(e);return 6!==r[0]&&7!==r[0]||(r[0]=4),6!==n[0]&&7!==n[0]||(n[0]=4),r.equals(n)}return!1}function zi(t,e){var r=ne(e);if(null===r)throw new Error("Unknown script error");var n=er(t),i=bi(t),o=Wi(t),a=null!=o&&o.hybrid?er(o.hybrid):void 0,s=null!=o&&o.uncompressed?er(o.uncompressed):void 0;return r.findIndex(function(e){if("number"==typeof e)return!1;if(qi(e,t))return!0;if(qi(e,i))return!0;if(e.equals(n))return!0;if(o){if(qi(e,o.uncompressed))return!0;if(qi(e,o.hybrid))return!0;if(a&&e.equals(a)||s&&e.equals(s))return!0}})}function Zi(t,e){return-1!==zi(t,e)}function Xi(t,e,r){var n=e(t).hashType,i=[];switch(n&hi.SIGHASH_ANYONECANPAY&&i.push("addInput"),31&n){case hi.SIGHASH_ALL:break;case hi.SIGHASH_SINGLE:case hi.SIGHASH_NONE:i.push("addOutput"),i.push("setInputSequence")}return-1===i.indexOf(r)}ji(Ui);var Yi,$i=y(287).hp,Ji=it;function Qi(t,e){if(!(t.address||t.hash||t.output||t.pubkey||t.input))throw new TypeError("Not enough data");e=Object.assign({validate:!0},e||{}),gt({network:gt.maybe(gt.Object),address:gt.maybe(gt.String),hash:gt.maybe(gt.BufferN(20)),output:gt.maybe(gt.BufferN(25)),pubkey:gt.maybe(St),signature:gt.maybe(fe),input:gt.maybe(gt.Buffer)},t);var r=Wr(function(){var e=$i.from(et.decode(t.address));return{version:e.readUInt8(0),hash:e.slice(1)}}),n=Wr(function(){return ne(t.input)}),i=t.network||O,o={name:Yi.P2PKH,network:i,hash:void 0};if(Vr(o,"address",function(){if(o.hash){var t=$i.allocUnsafe(21);return t.writeUInt8(i.pubKeyHash,0),o.hash.copy(t,1),et.encode(t)}}),Vr(o,"hash",function(){return t.output?t.output.slice(3,23):t.address?r().hash:t.pubkey||o.pubkey?er(t.pubkey||o.pubkey):void 0}),Vr(o,"output",function(){if(o.hash)return re([Ji.OP_DUP,Ji.OP_HASH160,o.hash,Ji.OP_EQUALVERIFY,Ji.OP_CHECKSIG])}),Vr(o,"pubkey",function(){if(t.input)return n()[1]}),Vr(o,"signature",function(){if(t.input)return n()[0]}),Vr(o,"input",function(){if(t.pubkey&&t.signature){var e=t.pubkey;if(t.useHybrid||t.useUncompressed){var r=Wi(t.pubkey);r&&(e=t.useUncompressed?r.uncompressed:r.hybrid)}return re([t.signature,e])}}),Vr(o,"witness",function(){if(o.input)return[]}),e.validate){var a=$i.from([]);if(t.address){if(r().version!==i.pubKeyHash)throw new TypeError("Invalid version or Network mismatch");if(20!==r().hash.length)throw new TypeError("Invalid address");a=r().hash}if(t.hash){if(a.length>0&&!a.equals(t.hash))throw new TypeError("Hash mismatch");a=t.hash}if(t.output){if(25!==t.output.length||t.output[0]!==Ji.OP_DUP||t.output[1]!==Ji.OP_HASH160||20!==t.output[2]||t.output[23]!==Ji.OP_EQUALVERIFY||t.output[24]!==Ji.OP_CHECKSIG)throw new TypeError("Output is invalid");var s=t.output.slice(3,23);if(a.length>0&&!a.equals(s))throw new TypeError("Hash mismatch");a=s}if(t.pubkey){var u=er(t.pubkey),f=a.length>0&&!a.equals(u);if(f&&(33===t.pubkey.length&&(2===t.pubkey[0]||3===t.pubkey[0])||65===t.pubkey.length&&4===t.pubkey[0])){var c=Wi(t.pubkey);if(c){var l=er(c.uncompressed);if(a.equals(l))f=!1,t.useUncompressed=!0;else{var h=er(c.hybrid);(f=!a.equals(h))||(t.useHybrid=!0)}}}if(f)throw new TypeError("Hash mismatch");a=u}if(t.input){var p=n();if(2!==p.length)throw new TypeError("Input is invalid");if(!fe(p[0]))throw new TypeError("Input has invalid signature");if(!St(p[1]))throw new TypeError("Input has invalid pubkey");if(t.signature&&!t.signature.equals(p[0]))throw new TypeError("Signature mismatch");if(t.pubkey&&!t.pubkey.equals(p[1]))throw new TypeError("Pubkey mismatch");var d=er(p[1]);if(a.length>0&&!a.equals(d))throw new TypeError("Hash mismatch (input)")}}return Object.assign(o,t)}!function(t){t.P2PK="p2pk",t.P2PKH="p2pkh",t.P2SH="p2sh",t.P2MS="p2ms",t.P2WPKH="p2wpkh",t.P2WSH="p2wsh",t.P2TR="p2tr",t.P2OP="p2op",t.Embed="embed",t.ScriptRedeem="scriptRedeem"}(Yi||(Yi={}));var to=y(287).hp,eo=y(287).hp;function ro(t){return ro="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ro(t)}function no(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,oo(n.key),n)}}function io(t,e,r){return(e=oo(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function oo(t){var e=function(t){if("object"!=ro(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=ro(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==ro(e)?e:e+""}var ao=gt,so=new TypeError("Cannot compute merkle root for zero transactions"),uo=new TypeError("Cannot compute witness commit for non-segwit block");function fo(t){return t instanceof Array&&t[0]&&t[0].ins&&t[0].ins instanceof Array&&t[0].ins[0]&&t[0].ins[0].witness&&t[0].ins[0].witness instanceof Array&&t[0].ins[0].witness.length>0}!function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),io(this,"version",1),io(this,"prevHash",void 0),io(this,"merkleRoot",void 0),io(this,"timestamp",0),io(this,"witnessCommit",void 0),io(this,"bits",0),io(this,"nonce",0),io(this,"transactions",void 0)}return e=t,r=[{key:"getWitnessCommit",value:function(){if(!fo(this.transactions))return null;var t=this.transactions[0].outs.filter(function(t){return t.script.slice(0,6).equals(eo.from("6a24aa21a9ed","hex"))}).map(function(t){return t.script.slice(6,38)});if(0===t.length)return null;var e=t[t.length-1];return e instanceof eo&&32===e.length?e:null}},{key:"hasWitnessCommit",value:function(){return this.witnessCommit instanceof eo&&32===this.witnessCommit.length||null!==this.getWitnessCommit()}},{key:"hasWitness",value:function(){return(t=this.transactions)instanceof Array&&t.some(function(t){return"object"===ro(t)&&t.ins instanceof Array&&t.ins.some(function(t){return"object"===ro(t)&&t.witness instanceof Array&&t.witness.length>0})});var t}},{key:"weight",value:function(){return 3*this.byteLength(!1,!1)+this.byteLength(!1,!0)}},{key:"byteLength",value:function(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return t||!this.transactions?80:80+vr(this.transactions.length)+this.transactions.reduce(function(t,r){return t+r.byteLength(e)},0)}},{key:"getHash",value:function(){return rr(this.toBuffer(!0))}},{key:"getId",value:function(){return Ar(this.getHash()).toString("hex")}},{key:"getUTCDate",value:function(){var t=new Date(0);return t.setUTCSeconds(this.timestamp),t}},{key:"toBuffer",value:function(t){var e=eo.allocUnsafe(this.byteLength(t)),r=new Pr(e);if(r.writeInt32(this.version),r.writeSlice(this.prevHash),r.writeSlice(this.merkleRoot),r.writeUInt32(this.timestamp),r.writeUInt32(this.bits),r.writeUInt32(this.nonce),t||!this.transactions)return e;var n=br(this.transactions.length,e,r.offset);return r.offset+=n.bytes,this.transactions.forEach(function(t){var n=t.byteLength();t.toBuffer(e,r.offset),r.offset+=n}),e}},{key:"toHex",value:function(t){return this.toBuffer(t).toString("hex")}},{key:"checkTxRoots",value:function(){var t=this.hasWitnessCommit();return!(!t&&this.hasWitness())&&this.__checkMerkleRoot()&&(!t||this.__checkWitnessCommit())}},{key:"checkProofOfWork",value:function(){var e=Ar(this.getHash()),r=t.calculateTarget(this.bits);return e.compare(r)<=0}},{key:"__checkMerkleRoot",value:function(){if(!this.transactions)throw so;var e=t.calculateMerkleRoot(this.transactions);return 0===this.merkleRoot.compare(e)}},{key:"__checkWitnessCommit",value:function(){if(!this.transactions)throw so;if(!this.hasWitnessCommit())throw uo;var e=t.calculateMerkleRoot(this.transactions,!0);return 0===this.witnessCommit.compare(e)}}],n=[{key:"fromBuffer",value:function(e){if(e.length<80)throw new Error("Buffer too small (< 80 bytes)");var r=new xr(e),n=new t;if(n.version=r.readInt32(),n.prevHash=r.readSlice(32),n.merkleRoot=r.readSlice(32),n.timestamp=r.readUInt32(),n.bits=r.readUInt32(),n.nonce=r.readUInt32(),80===e.length)return n;var i=function(){var t=hi.fromBuffer(r.buffer.slice(r.offset),!0);return r.offset+=t.byteLength(),t},o=r.readVarInt();n.transactions=[];for(var a=0;a<o;++a){var s=i();n.transactions.push(s)}var u=n.getWitnessCommit();return u&&(n.witnessCommit=u),n}},{key:"fromHex",value:function(e){return t.fromBuffer(eo.from(e,"hex"))}},{key:"calculateTarget",value:function(t){var e=((4278190080&t)>>24)-3,r=8388607&t,n=eo.alloc(32,0);return n.writeUIntBE(r,29-e,3),n}},{key:"calculateMerkleRoot",value:function(t,e){if(ao([{getHash:Ct}],t),0===t.length)throw so;if(e&&!fo(t))throw uo;var r=function(t,e){if(!Array.isArray(t))throw TypeError("Expected values Array");if("function"!=typeof e)throw TypeError("Expected digest Function");for(var r=t.length,n=t.concat();r>1;){for(var i=0,o=0;o<r;o+=2,++i){var a=n[o],s=o+1===r?a:n[o+1],u=to.concat([a,s]);n[i]=e(u)}r=i}return n[0]}(t.map(function(t){return t.getHash(e)}),rr);return e?rr(eo.concat([r,t[0].ins[0].witness[0]])):r}}],r&&no(e.prototype,r),n&&no(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,r,n}();var co=y(614),lo=y(699),ho=y(287).hp;function po(t){return po="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},po(t)}function yo(){yo=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,i="function"==typeof Symbol?Symbol:{},o=i.iterator||"@@iterator",a=i.asyncIterator||"@@asyncIterator",s=i.toStringTag||"@@toStringTag";function u(t,e,r,n){return Object.defineProperty(t,e,{value:r,enumerable:!n,configurable:!n,writable:!n})}try{u({},"")}catch(t){u=function(t,e,r){return t[e]=r}}function f(e,r,n,i){var o=r&&r.prototype instanceof h?r:h,a=Object.create(o.prototype);return u(a,"_invoke",function(e,r,n){var i=1;return function(o,a){if(3===i)throw Error("Generator is already running");if(4===i){if("throw"===o)throw a;return{value:t,done:!0}}for(n.method=o,n.arg=a;;){var s=n.delegate;if(s){var u=S(s,n);if(u){if(u===l)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(1===i)throw i=4,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=3;var f=c(e,r,n);if("normal"===f.type){if(i=n.done?4:2,f.arg===l)continue;return{value:f.arg,done:n.done}}"throw"===f.type&&(i=4,n.method="throw",n.arg=f.arg)}}}(e,n,new k(i||[])),!0),a}function c(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var l={};function h(){}function p(){}function d(){}var y={};u(y,o,function(){return this});var b=Object.getPrototypeOf,g=b&&b(b(O([])));g&&g!==r&&n.call(g,o)&&(y=g);var v=d.prototype=h.prototype=Object.create(y);function w(t){["next","throw","return"].forEach(function(e){u(t,e,function(t){return this._invoke(e,t)})})}function m(t,e){function r(i,o,a,s){var u=c(t[i],t,o);if("throw"!==u.type){var f=u.arg,l=f.value;return l&&"object"==po(l)&&n.call(l,"__await")?e.resolve(l.__await).then(function(t){r("next",t,a,s)},function(t){r("throw",t,a,s)}):e.resolve(l).then(function(t){f.value=t,a(f)},function(t){return r("throw",t,a,s)})}s(u.arg)}var i;u(this,"_invoke",function(t,n){function o(){return new e(function(e,i){r(t,n,e,i)})}return i=i?i.then(o,o):o()},!0)}function S(e,r){var n=r.method,i=e.i[n];if(i===t)return r.delegate=null,"throw"===n&&e.i.return&&(r.method="return",r.arg=t,S(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),l;var o=c(i,e.i,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,l;var a=o.arg;return a?a.done?(r[e.r]=a.value,r.next=e.n,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,l):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,l)}function _(t){this.tryEntries.push(t)}function E(e){var r=e[4]||{};r.type="normal",r.arg=t,e[4]=r}function k(t){this.tryEntries=[[-1]],t.forEach(_,this),this.reset(!0)}function O(e){if(null!=e){var r=e[o];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,a=function r(){for(;++i<e.length;)if(n.call(e,i))return r.value=e[i],r.done=!1,r;return r.value=t,r.done=!0,r};return a.next=a}}throw new TypeError(po(e)+" is not iterable")}return p.prototype=d,u(v,"constructor",d),u(d,"constructor",p),p.displayName=u(d,s,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===p||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,d):(t.__proto__=d,u(t,s,"GeneratorFunction")),t.prototype=Object.create(v),t},e.awrap=function(t){return{__await:t}},w(m.prototype),u(m.prototype,a,function(){return this}),e.AsyncIterator=m,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new m(f(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then(function(t){return t.done?t.value:a.next()})},w(v),u(v,s,"Generator"),u(v,o,function(){return this}),u(v,"toString",function(){return"[object Generator]"}),e.keys=function(t){var e=Object(t),r=[];for(var n in e)r.unshift(n);return function t(){for(;r.length;)if((n=r.pop())in e)return t.value=n,t.done=!1,t;return t.done=!0,t}},e.values=O,k.prototype={constructor:k,reset:function(e){if(this.prev=this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(E),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0][4];if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function n(t){a.type="throw",a.arg=e,r.next=t}for(var i=r.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],a=o[4],s=this.prev,u=o[1],f=o[2];if(-1===o[0])return n("end"),!1;if(!u&&!f)throw Error("try statement without catch or finally");if(null!=o[0]&&o[0]<=s){if(s<u)return this.method="next",this.arg=t,n(u),!0;if(s<f)return n(f),!1}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n[0]>-1&&n[0]<=this.prev&&this.prev<n[2]){var i=n;break}}i&&("break"===t||"continue"===t)&&i[0]<=e&&e<=i[2]&&(i=null);var o=i?i[4]:{};return o.type=t,o.arg=e,i?(this.method="next",this.next=i[2],l):this.complete(o)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),l},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r[2]===t)return this.complete(r[4],r[3]),E(r),l}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r[0]===t){var n=r[4];if("throw"===n.type){var i=n.arg;E(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={i:O(e),r,n},"next"===this.method&&(this.arg=t),l}},e}function bo(t,e,r,n,i,o,a){try{var s=t[o](a),u=s.value}catch(t){return void r(t)}s.done?e(u):Promise.resolve(u).then(n,i)}function go(t){return function(){var e=this,r=arguments;return new Promise(function(n,i){var o=t.apply(e,r);function a(t){bo(o,n,i,a,s,"next",t)}function s(t){bo(o,n,i,a,s,"throw",t)}a(void 0)})}}function vo(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=mo(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}function wo(t){return function(t){if(Array.isArray(t))return So(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||mo(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function mo(t,e){if(t){if("string"==typeof t)return So(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?So(t,e):void 0}}function So(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function _o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function Eo(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Oo(n.key),n)}}function ko(t,e,r){return e&&Eo(t.prototype,e),r&&Eo(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function Oo(t){var e=function(t){if("object"!=po(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=po(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==po(e)?e:e+""}var To={network:O,maximumFeeRate:5e3},Ao=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new co.i(new Po);_o(this,t),this.data=r,this.opts=Object.assign({},To,e),this.__CACHE={__NON_WITNESS_UTXO_TX_CACHE:[],__NON_WITNESS_UTXO_BUF_CACHE:[],__TX_IN_CACHE:{},__TX:this.data.globalMap.unsignedTx.tx,__UNSAFE_SIGN_NONSEGWIT:!1},3===e.version?this.setVersionTRUC():0===this.data.inputs.length&&this.setVersion(2);var n=function(t,e,r,n){Object.defineProperty(t,e,{enumerable:r,writable:n})};n(this,"__CACHE",!1,!0),n(this,"opts",!1,!0)}return ko(t,[{key:"inputCount",get:function(){return this.data.inputs.length}},{key:"version",get:function(){return this.__CACHE.__TX.version},set:function(t){this.setVersion(t)}},{key:"locktime",get:function(){return this.__CACHE.__TX.locktime},set:function(t){this.setLocktime(t)}},{key:"txInputs",get:function(){return this.__CACHE.__TX.ins.map(function(t){return{hash:Ir(t.hash),index:t.index,sequence:t.sequence}})}},{key:"txOutputs",get:function(){var t=this;return this.__CACHE.__TX.outs.map(function(e){var r;try{r=Pe(e.script,t.opts.network)}catch(t){}return{script:Ir(e.script),value:e.value,address:r}})}},{key:"combine",value:function(){for(var t,e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];return(t=this.data).combine.apply(t,wo(r.map(function(t){return t.data}))),this}},{key:"clone",value:function(){return t.fromBuffer(this.data.toBuffer(),JSON.parse(JSON.stringify(this.opts)))}},{key:"setMaximumFeeRate",value:function(t){No(t),this.opts.maximumFeeRate=t}},{key:"setVersion",value:function(t){No(t),jo(this.data.inputs,"setVersion");var e=this.__CACHE;return e.__TX.version=t,e.__EXTRACTED_TX=void 0,this}},{key:"setVersionTRUC",value:function(){return this.setVersion(hi.TRUC_VERSION)}},{key:"setLocktime",value:function(t){No(t),jo(this.data.inputs,"setLocktime");var e=this.__CACHE;return e.__TX.locktime=t,e.__EXTRACTED_TX=void 0,this}},{key:"setInputSequence",value:function(t,e){No(e),jo(this.data.inputs,"setInputSequence");var r=this.__CACHE;if(r.__TX.ins.length<=t)throw new Error("Input index too high");return r.__TX.ins[t].sequence=e,r.__EXTRACTED_TX=void 0,this}},{key:"addInputs",value:function(t){var e=this,r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return t.forEach(function(t){return e.addInput(t,r)}),this}},{key:"addInput",value:function(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(!t||void 0===t.hash||void 0===t.index)throw new Error("Invalid arguments for Psbt.addInput. Requires single object with at least [hash] and [index]");Si(t,t,"addInput"),e&&jo(this.data.inputs,"addInput"),t.witnessScript&&ia(t.witnessScript);var r=this.__CACHE;this.data.addInput(t),Co(r,r.__TX.ins[r.__TX.ins.length-1]);var n=this.data.inputs.length-1,i=this.data.inputs[n];return i.nonWitnessUtxo&&$o(this.__CACHE,i,n),r.__FEE=void 0,r.__FEE_RATE=void 0,r.__EXTRACTED_TX=void 0,this}},{key:"addOutputs",value:function(t){var e=this;return t.forEach(function(t){return e.addOutput(t)}),this}},{key:"addOutput",value:function(t){if(arguments.length>1||!t||void 0===t.value||void 0===t.address&&void 0===t.script)throw new Error("Invalid arguments for Psbt.addOutput. Requires single object with at least [script or address] and [value]");jo(this.data.inputs,"addOutput");var e=t.address;if("string"==typeof e){var r=xe(e,this.opts.network);t=Object.assign({},t,{script:r})}_i(t,t,"addOutput");var n=this.__CACHE;return this.data.addOutput(t),n.__FEE=void 0,n.__FEE_RATE=void 0,n.__EXTRACTED_TX=void 0,this}},{key:"extractTransaction",value:function(t,e){if(e&&(this.data.inputs=this.data.inputs.filter(function(t){return!t.partialSig})),!this.data.inputs.every(Ro))throw new Error("Not finalized");var r=this.__CACHE;if(t||function(t,e,r){var n=e.__FEE_RATE||t.getFeeRate(),i=e.__EXTRACTED_TX.virtualSize(),o=n*i;if(n>=r.maximumFeeRate)throw new Error("Warning: You are paying around ".concat((o/1e8).toFixed(8)," in ")+"fees, which is ".concat(n," satoshi per byte for a transaction ")+"with a VSize of ".concat(i," bytes (segwit counted as 0.25 byte per ")+"byte). Use setMaximumFeeRate method to raise your threshold, or pass true to the first arg of extractTransaction.")}(this,r,this.opts),r.__EXTRACTED_TX)return r.__EXTRACTED_TX;var n=r.__TX.clone();return Jo(this.data.inputs,n,r,!0,e),n}},{key:"getFeeRate",value:function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return Mo("__FEE_RATE","fee rate",this.data.inputs,this.__CACHE,t)}},{key:"getFee",value:function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return Mo("__FEE","fee",this.data.inputs,this.__CACHE,t)}},{key:"finalizeAllInputs",value:function(){var t=this;return(0,lo.checkForInput)(this.data.inputs,0),aa(this.data.inputs.length).forEach(function(e){return t.finalizeInput(e)}),this}},{key:"finalizeInput",value:function(t,e,r){var n=(0,lo.checkForInput)(this.data.inputs,t);return wi(n)?this._finalizeTaprootInput(t,n,void 0,e):this._finalizeInput(t,n,e,null==r||r)}},{key:"finalizeTaprootInput",value:function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:gi,n=(0,lo.checkForInput)(this.data.inputs,t);if(wi(n))return this._finalizeTaprootInput(t,n,e,r);throw new Error("Cannot finalize input #".concat(t,". Not Taproot."))}},{key:"getInputType",value:function(t){var e=(0,lo.checkForInput)(this.data.inputs,t),r=na(ta(t,e,this.__CACHE),t,"input",e.redeemScript||function(t){if(t){var e=ne(t);if(e){var r=e[e.length-1];if(ho.isBuffer(r)&&!ra(r)&&!fe(r)&&ne(r))return r}}}(e.finalScriptSig),e.witnessScript||function(t){if(t){var e=Yo(t),r=e[e.length-1];if(!ra(r)&&ne(r))return r}}(e.finalScriptWitness));return("raw"===r.type?"":r.type+"-")+oa(r.meaningfulScript)}},{key:"inputHasPubkey",value:function(t,e){return function(t,e,r,n){return Zi(t,na(ta(r,e,n),r,"input",e.redeemScript,e.witnessScript).meaningfulScript)}(e,(0,lo.checkForInput)(this.data.inputs,t),t,this.__CACHE)}},{key:"inputHasHDKey",value:function(t,e){var r=(0,lo.checkForInput)(this.data.inputs,t),n=Uo(e);return!!r.bip32Derivation&&r.bip32Derivation.some(n)}},{key:"outputHasPubkey",value:function(t,e){return function(t,e,r,n){return Zi(t,na(n.__TX.outs[r].script,r,"output",e.redeemScript,e.witnessScript).meaningfulScript)}(e,(0,lo.checkForOutput)(this.data.outputs,t),t,this.__CACHE)}},{key:"outputHasHDKey",value:function(t,e){var r=(0,lo.checkForOutput)(this.data.outputs,t),n=Uo(e);return!!r.bip32Derivation&&r.bip32Derivation.some(n)}},{key:"validateSignaturesOfAllInputs",value:function(t){var e=this;return(0,lo.checkForInput)(this.data.inputs,0),aa(this.data.inputs.length).map(function(r){return e.validateSignaturesOfInput(r,t)}).reduce(function(t,e){return!0===e&&t},!0)}},{key:"validateSignaturesOfInput",value:function(t,e,r){return wi(this.data.inputs[t])?this.validateSignaturesOfTaprootInput(t,e,r):this._validateSignaturesOfInput(t,e,r)}},{key:"signAllInputsHD",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[hi.SIGHASH_ALL];if(!t||!t.publicKey||!t.fingerprint)throw new Error("Need HDSigner to sign input");var r,n=[],i=vo(aa(this.data.inputs.length));try{for(i.s();!(r=i.n()).done;){var o=r.value;try{this.signInputHD(o,t,e),n.push(!0)}catch(t){n.push(!1)}}}catch(t){i.e(t)}finally{i.f()}if(n.every(function(t){return!1===t}))throw new Error("No inputs were signed");return this}},{key:"signAllInputsHDAsync",value:function(t){var e=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[hi.SIGHASH_ALL];return new Promise(function(n,i){if(!t||!t.publicKey||!t.fingerprint)return i(new Error("Need HDSigner to sign input"));var o,a=[],s=[],u=vo(aa(e.data.inputs.length));try{for(u.s();!(o=u.n()).done;){var f=o.value;s.push(e.signInputHDAsync(f,t,r).then(function(){a.push(!0)},function(){a.push(!1)}))}}catch(t){u.e(t)}finally{u.f()}return Promise.all(s).then(function(){if(a.every(function(t){return!1===t}))return i(new Error("No inputs were signed"));n()})})}},{key:"signInputHD",value:function(t,e){var r=this,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[hi.SIGHASH_ALL];if(!e||!e.publicKey||!e.fingerprint)throw new Error("Need HDSigner to sign input");return Xo(t,this.data.inputs,e).forEach(function(e){return r.signInput(t,e,n)}),this}},{key:"signInputHDAsync",value:function(t,e){var r=this,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[hi.SIGHASH_ALL];return new Promise(function(i,o){if(!e||!e.publicKey||!e.fingerprint)return o(new Error("Need HDSigner to sign input"));var a=Xo(t,r.data.inputs,e).map(function(e){return r.signInputAsync(t,e,n)});return Promise.all(a).then(function(){i()}).catch(o)})}},{key:"signAllInputs",value:function(t,e){if(!t||!t.publicKey)throw new Error("Need Signer to sign input");var r,n=[],i=vo(aa(this.data.inputs.length));try{for(i.s();!(r=i.n()).done;){var o=r.value;try{this.signInput(o,t,e),n.push(!0)}catch(t){n.push(!1)}}}catch(t){i.e(t)}finally{i.f()}if(n.every(function(t){return!1===t}))throw new Error("No inputs were signed");return this}},{key:"signAllInputsAsync",value:function(t,e){var r=this;return new Promise(function(n,i){if(!t||!t.publicKey)return i(new Error("Need Signer to sign input"));var o,a,s=[],u=[],f=vo(r.data.inputs.entries());try{for(f.s();!(o=f.n()).done;){var c=(a=o.value,function(t){if(Array.isArray(t))return t}(a)||function(t){var e=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=e){var r,n,i,o,a=[],s=!0,u=!1;try{for(i=(e=e.call(t)).next;!(s=(r=i.call(e)).done)&&(a.push(r.value),1!==a.length);s=!0);}catch(t){u=!0,n=t}finally{try{if(!s&&null!=e.return&&(o=e.return(),Object(o)!==o))return}finally{if(u)throw n}}return a}}(a)||mo(a,1)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())[0];u.push(r.signInputAsync(c,t,e).then(function(){s.push(!0)},function(){s.push(!1)}))}}catch(t){f.e(t)}finally{f.f()}return Promise.all(u).then(function(){if(s.every(function(t){return!1===t}))return i(new Error("No inputs were signed"));n()})})}},{key:"signInput",value:function(t,e,r){if(!e||!e.publicKey)throw new Error("Need Signer to sign input");var n=(0,lo.checkForInput)(this.data.inputs,t);return wi(n)?this._signTaprootInput(t,n,e,void 0,r):this._signInput(t,e,r)}},{key:"signTaprootInput",value:function(t,e,r,n){if(!e||!e.publicKey)throw new Error("Need Signer to sign input");var i=(0,lo.checkForInput)(this.data.inputs,t);if(wi(i))return this._signTaprootInput(t,i,e,r,n);throw new Error("Input #".concat(t," is not of type Taproot."))}},{key:"signInputAsync",value:function(t,e,r){var n=this;return Promise.resolve().then(function(){if(!e||!e.publicKey)throw new Error("Need Signer to sign input");var i=(0,lo.checkForInput)(n.data.inputs,t);return wi(i)?n._signTaprootInputAsync(t,i,e,void 0,r):n._signInputAsync(t,e,r)})}},{key:"signTaprootInputAsync",value:function(t,e,r,n){var i=this;return Promise.resolve().then(function(){if(!e||!e.publicKey)throw new Error("Need Signer to sign input");var o=(0,lo.checkForInput)(i.data.inputs,t);if(wi(o))return i._signTaprootInputAsync(t,o,e,r,n);throw new Error("Input #".concat(t," is not of type Taproot."))})}},{key:"toBuffer",value:function(){return xo(this.__CACHE),this.data.toBuffer()}},{key:"toHex",value:function(){return xo(this.__CACHE),this.data.toHex()}},{key:"toBase64",value:function(){return xo(this.__CACHE),this.data.toBase64()}},{key:"updateGlobal",value:function(t){return this.data.updateGlobal(t),this}},{key:"updateInput",value:function(t,e){return e.witnessScript&&ia(e.witnessScript),Si(this.data.inputs[t],e,"updateInput"),this.data.updateInput(t,e),e.nonWitnessUtxo&&$o(this.__CACHE,this.data.inputs[t],t),this}},{key:"updateOutput",value:function(t,e){return _i(this.data.outputs[t],e,"updateOutput"),this.data.updateOutput(t,e),this}},{key:"addUnknownKeyValToGlobal",value:function(t){return this.data.addUnknownKeyValToGlobal(t),this}},{key:"addUnknownKeyValToInput",value:function(t,e){return this.data.addUnknownKeyValToInput(t,e),this}},{key:"addUnknownKeyValToOutput",value:function(t,e){return this.data.addUnknownKeyValToOutput(t,e),this}},{key:"clearFinalizedInput",value:function(t){return this.data.clearFinalizedInput(t),this}},{key:"checkTaprootHashesForSig",value:function(t,e,r,n,i){if("function"!=typeof r.signSchnorr)throw new Error("Need Schnorr Signer to sign taproot input #".concat(t,"."));var o=zo(t,e,this.data.inputs,r.publicKey,this.__CACHE,n,i);if(!o||!o.length)throw new Error("Can not sign for input #".concat(t," with the key ").concat(r.publicKey.toString("hex")));return o}},{key:"_finalizeInput",value:function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Ko,n=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],i=function(t,e,r){var n=r.__TX,i={script:null,isSegwit:!1,isP2SH:!1,isP2WSH:!1};if(i.isP2SH=!!e.redeemScript,i.isP2WSH=!!e.witnessScript,e.witnessScript)i.script=e.witnessScript;else if(e.redeemScript)i.script=e.redeemScript;else if(e.nonWitnessUtxo){var o=Qo(r,e,t),a=n.ins[t].index;i.script=o.outs[a].script}else e.witnessUtxo&&(i.script=e.witnessUtxo.script);if(e.witnessScript||Di(i.script))i.isSegwit=!0;else try{var s=i.script;if(!s)throw new TypeError("Invalid script for segwit address");i.isSegwit=_e(s)}catch(t){}return i}(t,e,this.__CACHE),o=i.script,a=i.isP2SH,s=i.isP2WSH,u=i.isSegwit;if(!o)throw new Error("No script found for input #".concat(t));!function(t){if(t.sighashType&&t.partialSig){var e=t.partialSig,r=t.sighashType;e.forEach(function(t){var e=le.decode(t.signature).hashType;if(r!==e)throw new Error("Signature sighash does not match input sighash type")})}}(e);var f=r(t,e,o,u,a,s,n),c=f.finalScriptSig,l=f.finalScriptWitness;if(c&&this.data.updateInput(t,{finalScriptSig:c}),l&&this.data.updateInput(t,{finalScriptWitness:l}),!c&&!l)throw new Error("Unknown error finalizing input #".concat(t));return this.data.clearFinalizedInput(t),this}},{key:"_finalizeTaprootInput",value:function(t,e,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:gi;if(!e.witnessUtxo)throw new Error("Cannot finalize input #".concat(t,". Missing witness utxo."));if(e.tapKeySig){var i=Vi(Vn({output:e.witnessUtxo.script,signature:e.tapKeySig}).witness);this.data.updateInput(t,{finalScriptWitness:i})}else{var o=n(t,e,r).finalScriptWitness;this.data.updateInput(t,{finalScriptWitness:o})}return this.data.clearFinalizedInput(t),this}},{key:"_validateSignaturesOfInput",value:function(t,e,r){var n=this.data.inputs[t],i=(n||{}).partialSig;if(!n||!i||i.length<1)throw new Error("No signatures to validate");if("function"!=typeof e)throw new Error("Need validator function to validate signatures");var o=r?i.filter(function(t){return t.pubkey.equals(r)}):i;if(o.length<1)throw new Error("No signatures for this pubkey");var a,s,u,f,c=[],l=vo(o);try{for(l.s();!(f=l.n()).done;){var h=f.value,p=le.decode(h.signature),d=u!==p.hashType?Wo(t,Object.assign({},n,{sighashType:p.hashType}),this.__CACHE,!0):{hash:a,script:s},y=d.hash,b=d.script;u=p.hashType,a=y,s=b,Lo(h.pubkey,b,"verify"),c.push(e(h.pubkey,y,p.signature))}}catch(t){l.e(t)}finally{l.f()}return c.every(function(t){return!0===t})}},{key:"validateSignaturesOfTaprootInput",value:function(t,e,r){var n=this.data.inputs[t],i=(n||{}).tapKeySig,o=(n||{}).tapScriptSig;if(!n&&!i&&(!o||o.length))throw new Error("No signatures to validate");if("function"!=typeof e)throw new Error("Need validator function to validate signatures");var a=(r=r&&bi(r))?zo(t,n,this.data.inputs,r,this.__CACHE):function(t,e,r,n){var i=[];if(e.tapInternalKey){var o=Go(t,e,n);o&&i.push(o)}if(e.tapScriptSig){var a=e.tapScriptSig.map(function(t){return t.pubkey});i.push.apply(i,wo(a))}return i.map(function(i){return zo(t,e,r,i,n)}).flat()}(t,n,this.data.inputs,this.__CACHE);if(!a.length)throw new Error("No signatures for this pubkey");var s=a.find(function(t){return!t.leafHash}),u=0;if(i&&s){if(!e(s.pubkey,s.hash,qo(i)))return!1;u++}if(o){var f,c=vo(o);try{var l,h=function(){var t=f.value,r=a.find(function(e){return t.pubkey.equals(e.pubkey)});if(r){if(!e(t.pubkey,r.hash,qo(t.signature)))return{v:!1};u++}};for(c.s();!(f=c.n()).done;)if(l=h())return l.v}catch(t){c.e(t)}finally{c.f()}}return u>0}},{key:"_signInput",value:function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[hi.SIGHASH_ALL],n=Vo(this.data.inputs,t,e.publicKey,this.__CACHE,r),i=n.hash,o=n.sighashType,a=[{pubkey:e.publicKey,signature:le.encode(e.sign(i),o)}];return this.data.updateInput(t,{partialSig:a}),this}},{key:"_signTaprootInput",value:function(t,e,r,n){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:[hi.SIGHASH_DEFAULT],o=this.checkTaprootHashesForSig(t,e,r,n,i),a=o.filter(function(t){return!t.leafHash}).map(function(t){return vi(r.signSchnorr(t.hash),e.sighashType)})[0],s=o.filter(function(t){return!!t.leafHash}).map(function(t){return{pubkey:bi(r.publicKey),signature:vi(r.signSchnorr(t.hash),e.sighashType),leafHash:t.leafHash}});return a&&this.data.updateInput(t,{tapKeySig:a}),s.length&&this.data.updateInput(t,{tapScriptSig:s}),this}},{key:"_signInputAsync",value:function(t,e){var r=this,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[hi.SIGHASH_ALL],i=Vo(this.data.inputs,t,e.publicKey,this.__CACHE,n),o=i.hash,a=i.sighashType;return Promise.resolve(e.sign(o)).then(function(n){var i=[{pubkey:e.publicKey,signature:le.encode(n,a)}];r.data.updateInput(t,{partialSig:i})})}},{key:"_signTaprootInputAsync",value:(e=go(yo().mark(function t(e,r,n,i){var o,a,s,u,f,c,l,h,p,d,y,b=arguments;return yo().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return o=b.length>4&&void 0!==b[4]?b[4]:[hi.SIGHASH_DEFAULT],a=this.checkTaprootHashesForSig(e,r,n,i,o),s=[],u=a.filter(function(t){return!t.leafHash})[0],u&&(f=Promise.resolve(n.signSchnorr(u.hash)).then(function(t){return{tapKeySig:vi(t,r.sighashType)}}),s.push(f)),c=a.filter(function(t){return!!t.leafHash}),c.length&&(l=c.map(function(){var t=go(yo().mark(function t(e){var i,o;return yo().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,n.signSchnorr(e.hash);case 2:return i=t.sent,o=[{pubkey:bi(n.publicKey),signature:vi(i,r.sighashType),leafHash:e.leafHash}],t.abrupt("return",{tapScriptSig:o});case 5:case"end":return t.stop()}},t)}));return function(e){return t.apply(this,arguments)}}()),s.push.apply(s,wo(l))),t.next=9,Promise.all(s);case 9:h=t.sent,p=vo(h);try{for(p.s();!(d=p.n()).done;)y=d.value,this.data.updateInput(e,y)}catch(t){p.e(t)}finally{p.f()}case 12:case"end":return t.stop()}},t,this)})),function(t,r,n,i){return e.apply(this,arguments)})}],[{key:"fromBase64",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=ho.from(t,"base64");return this.fromBuffer(r,e)}},{key:"fromHex",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=ho.from(t,"hex");return this.fromBuffer(r,e)}},{key:"fromBuffer",value:function(e){var r,n,i=new t(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},co.i.fromBuffer(e,Io));return r=i.__CACHE.__TX,n=i.__CACHE,r.ins.forEach(function(t){Co(n,t)}),i}}]);var e}(),Io=function(t){return new Po(t)},Po=ko(function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:ho.from([2,0,0,0,0,0,0,0,0,0]);_o(this,t),this.tx=hi.fromBuffer(e),function(t){if(!t.ins.every(function(t){return t.script&&0===t.script.length&&t.witness&&0===t.witness.length}))throw new Error("Format Error: Transaction ScriptSigs are not empty")}(this.tx),Object.defineProperty(this,"tx",{enumerable:!1,writable:!0})},[{key:"getInputOutputCounts",value:function(){return{inputCount:this.tx.ins.length,outputCount:this.tx.outs.length}}},{key:"addInput",value:function(t){if(void 0===t.hash||void 0===t.index||!ho.isBuffer(t.hash)&&"string"!=typeof t.hash||"number"!=typeof t.index)throw new Error("Error adding input.");var e="string"==typeof t.hash?Ar(ho.from(t.hash,"hex")):t.hash;this.tx.addInput(e,t.index,t.sequence)}},{key:"addOutput",value:function(t){if(void 0===t.script||void 0===t.value||!ho.isBuffer(t.script)||"number"!=typeof t.value)throw new Error("Error adding output.");this.tx.addOutput(t.script,t.value)}},{key:"toBuffer",value:function(){return this.tx.toBuffer()}}]);function xo(t){if(!1!==t.__UNSAFE_SIGN_NONSEGWIT)throw new Error("Not BIP174 compliant, can not export")}function Bo(t,e,r){if(!e)return!1;var n;if((n=r?r.map(function(t){var r=function(t){if(65===t.length){var e=1&t[64],r=t.slice(0,33);return r[0]=2|e,r}return t.slice()}(t);return e.find(function(t){return t.pubkey.equals(r)})}).filter(function(t){return!!t}):e).length>t)throw new Error("Too many signatures");return n.length===t}function Ro(t){return!!t.finalScriptSig||!!t.finalScriptWitness}function Uo(t){return function(e){return!!e.masterFingerprint.equals(t.fingerprint)&&!!t.derivePath(e.path).publicKey.equals(e.pubkey)}}function No(t){if("number"!=typeof t||t!==Math.floor(t)||t>4294967295||t<0)throw new Error("Invalid 32 bit integer")}function jo(t,e){t.forEach(function(t){if(wi(t)?function(t,e){var r=function(t){var e,r=[];if(t.tapKeySig&&r.push(t.tapKeySig),t.tapScriptSig&&r.push.apply(r,function(t){if(Array.isArray(t))return yi(t)}(e=t.tapScriptSig.map(function(t){return t.signature}))||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(e)||di(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),!r.length){var n=function(t){if(t){var e=t.slice(2);return 64===e.length||65===e.length?e:void 0}}(t.finalScriptWitness);n&&r.push(n)}return r}(t);return r.some(function(t){return Xi(t,ki,e)})}(t,e):function(t,e){var r=function(t){var e=[];if(0===(t.partialSig||[]).length){if(!t.finalScriptSig&&!t.finalScriptWitness)return[];e=function(t){var e=t.finalScriptSig&&ne(t.finalScriptSig)||[],r=t.finalScriptWitness&&ne(t.finalScriptWitness)||[];return e.concat(r).filter(function(t){return Ni.isBuffer(t)&&fe(t)}).map(function(t){return{signature:t}})}(t)}else e=t.partialSig;return e.map(function(t){return t.signature})}(t);return r.some(function(t){return Xi(t,le.decode,e)})}(t,e))throw new Error("Can not modify transaction, signatures exist.")})}function Lo(t,e,r){if(!Zi(t,e))throw new Error("Can not ".concat(r," for this input with the key ").concat(t.toString("hex")))}function Co(t,e){var r=Ar(ho.from(e.hash)).toString("hex")+":"+e.index;if(t.__TX_IN_CACHE[r])throw new Error("Duplicate input detected.");t.__TX_IN_CACHE[r]=1}function Fo(t,e){return function(r,n,i,o){var a=t({redeem:{output:i}}).output;if(!n.equals(a))throw new Error("".concat(e," for ").concat(o," #").concat(r," doesn't match the scriptPubKey in the prevout"))}}var Do=Fo(Dn,"Redeem script"),Ho=Fo(Jn,"Witness script");function Mo(t,e,r,n){var i,o=arguments.length>4&&void 0!==arguments[4]&&arguments[4];if(!r.every(Ro))throw new Error("PSBT must be finalized to calculate ".concat(e));if("__FEE_RATE"===t&&n.__FEE_RATE)return n.__FEE_RATE;if("__FEE"===t&&n.__FEE)return n.__FEE;var a=!0;return n.__EXTRACTED_TX?(i=n.__EXTRACTED_TX,a=!1):i=n.__TX.clone(),Jo(r,i,n,a,o),"__FEE_RATE"===t?n.__FEE_RATE:"__FEE"===t?n.__FEE:void 0}function Ko(t,e,r,n,i,o){var a=!(arguments.length>6&&void 0!==arguments[6])||arguments[6],s=arguments.length>7?arguments[7]:void 0,u=oa(r);if(!function(t,e,r){switch(r){case"pubkey":case"pubkeyhash":case"witnesspubkeyhash":return Bo(1,t.partialSig);case"multisig":var n=Xr({output:e});return Bo(n.m,t.partialSig,n.pubkeys);case"nonstandard":return!0;default:return!1}}(e,r,u)&&a)throw new Error("Can not finalize input #".concat(t));return function(t,e,r,n,i,o,a){var s,u,f=function(t,e,r){var n;switch(e){case"multisig":var i=function(t,e){return Xr({output:t}).pubkeys.map(function(t){return(e.filter(function(e){return e.pubkey.equals(t)})[0]||{}).signature}).filter(function(t){return!!t})}(t,r);n=Xr({output:t,signatures:i});break;case"pubkey":n=$r({output:t,signature:r[0].signature});break;case"pubkeyhash":n=Qi({output:t,pubkey:r[0].pubkey,signature:r[0].signature});break;case"witnesspubkeyhash":n=zn({output:t,pubkey:r[0].pubkey,signature:r[0].signature})}return n}(t,e,r),c=o?Jn({redeem:f}):null,l=i?Dn({redeem:c||f}):null;return n?(u=Vi(c?c.witness:f?f.witness:null!=a?a:[ho.from([0])]),l&&(s=null==l?void 0:l.input)):s=l?null==l?void 0:l.input:f?f.input:Array.isArray(a)&&a[0]?a[0]:ho.from([1]),{finalScriptSig:s,finalScriptWitness:u}}(r,u,e.partialSig,n,i,o,s)}function Vo(t,e,r,n,i){var o=Wo(e,(0,lo.checkForInput)(t,e),n,!1,i),a=o.hash,s=o.sighashType;return Lo(r,o.script,"sign"),{hash:a,sighashType:s}}function Wo(t,e,r,n,i){var o,a,s=r.__TX,u=e.sighashType||hi.SIGHASH_ALL;if(Zo(u,i),e.nonWitnessUtxo){var f=Qo(r,e,t),c=s.ins[t].hash,l=f.getHash();if(!c.equals(l))throw new Error("Non-witness UTXO hash for input #".concat(t," doesn't match the hash specified in the prevout"));var h=s.ins[t].index;a=f.outs[h]}else{if(!e.witnessUtxo)throw new Error("Need a Utxo input item for signing");a=e.witnessUtxo}var p=na(a.script,t,"input",e.redeemScript,e.witnessScript),d=p.meaningfulScript,y=p.type;if(["p2sh-p2wsh","p2wsh"].indexOf(y)>=0)o=s.hashForWitnessV0(t,d,a.value,u);else if(Di(d)){var b=Qi({hash:d.slice(2)}).output;o=s.hashForWitnessV0(t,b,a.value,u)}else{if(void 0===e.nonWitnessUtxo&&!1===r.__UNSAFE_SIGN_NONSEGWIT)throw new Error("Input #".concat(t," has witnessUtxo but non-segwit script: ")+"".concat(d.toString("hex")));n||!1===r.__UNSAFE_SIGN_NONSEGWIT||console.warn("Warning: Signing non-segwit inputs without the full parent transaction means there is a chance that a miner could feed you incorrect information to trick you into paying large fees. This behavior is the same as Psbt's predecessor (TransactionBuilder - now removed) when signing non-segwit scripts. You are not able to export this Psbt with toBuffer|toBase64|toHex since it is not BIP174 compliant.\n*********************\nPROCEED WITH CAUTION!\n*********************"),o=s.hashForSignature(t,d,u)}return{script:d,sighashType:u,hash:o}}function Go(t,e,r){var n=ea(t,e,r).script;return Ki(n)?n.subarray(2,34):null}function qo(t){return 64===t.length?t:t.subarray(0,64)}function zo(t,e,r,n,i,o,a){var s=i.__TX,u=e.sighashType||hi.SIGHASH_DEFAULT;Zo(u,a);var f=r.map(function(t,e){return ea(e,t,i)}),c=f.map(function(t){return t.script}),l=f.map(function(t){return t.value}),h=[];if(e.tapInternalKey&&!o){var p=Go(t,e,i)||ho.from([]);if(bi(n).equals(p)){var d=s.hashForWitnessV1(t,c,l,u);h.push({pubkey:n,hash:d})}}var y=(e.tapLeafScript||[]).filter(function(t){return Zi(n,t.script)}).map(function(t){var e=Dr({output:t.script,version:t.leafVersion});return Object.assign({hash:e},t)}).filter(function(t){return!o||o.equals(t.hash)}).map(function(e){var r=s.hashForWitnessV1(t,c,l,u,e.hash);return{pubkey:n,hash:r,leafHash:e.hash}});return h.concat(y)}function Zo(t,e){if(e&&e.indexOf(t)<0){var r=function(t){var e=t&hi.SIGHASH_ANYONECANPAY?"SIGHASH_ANYONECANPAY | ":"";switch(31&t){case hi.SIGHASH_ALL:e+="SIGHASH_ALL";break;case hi.SIGHASH_SINGLE:e+="SIGHASH_SINGLE";break;case hi.SIGHASH_NONE:e+="SIGHASH_NONE"}return e}(t);throw new Error("Sighash type is not allowed. Retry the sign method passing the "+"sighashTypes array of whitelisted types. Sighash type: ".concat(r))}}function Xo(t,e,r){var n=(0,lo.checkForInput)(e,t);if(!n.bip32Derivation||0===n.bip32Derivation.length)throw new Error("Need bip32Derivation to sign with HD");var i=n.bip32Derivation.map(function(t){return t.masterFingerprint.equals(r.fingerprint)?t:void 0}).filter(function(t){return!!t});if(0===i.length)throw new Error("Need one bip32Derivation masterFingerprint to match the HDSigner fingerprint");return i.map(function(t){var e=r.derivePath(t.path);if(!t.pubkey.equals(e.publicKey))throw new Error("pubkey did not match bip32Derivation");return e})}function Yo(t){var e=0;function r(){var r=Ln.decode(t,e);return e+=Ln.decode.bytes,r}return function(){for(var n=r(),i=[],o=0;o<n;o++)i.push((a=r(),e+=a,t.slice(e-a,e)));var a;return i}()}function $o(t,e,r){t.__NON_WITNESS_UTXO_BUF_CACHE[r]=e.nonWitnessUtxo,t.__NON_WITNESS_UTXO_TX_CACHE[r]=hi.fromBuffer(e.nonWitnessUtxo);var n=t,i=r;delete e.nonWitnessUtxo,Object.defineProperty(e,"nonWitnessUtxo",{enumerable:!0,get:function(){var t=n.__NON_WITNESS_UTXO_BUF_CACHE[i],e=n.__NON_WITNESS_UTXO_TX_CACHE[i];if(void 0!==t)return t;var r=e.toBuffer();return n.__NON_WITNESS_UTXO_BUF_CACHE[i]=r,r},set:function(t){n.__NON_WITNESS_UTXO_BUF_CACHE[i]=t}})}function Jo(t,e,r,n,i){var o=0;t.forEach(function(t,i){if(n&&t.finalScriptSig&&(e.ins[i].script=t.finalScriptSig),n&&t.finalScriptWitness&&(e.ins[i].witness=Yo(t.finalScriptWitness)),t.witnessUtxo)o+=t.witnessUtxo.value;else if(t.nonWitnessUtxo){var a=Qo(r,t,i),s=e.ins[i].index,u=a.outs[s];o+=u.value}});var a=e.outs.reduce(function(t,e){return t+e.value},0),s=o-a;if(!i&&s<0)throw new Error("Outputs are spending more than Inputs ".concat(o," < ").concat(a));var u=e.virtualSize();r.__FEE=s,r.__EXTRACTED_TX=e,r.__FEE_RATE=Math.floor(s/u)}function Qo(t,e,r){var n=t.__NON_WITNESS_UTXO_TX_CACHE;return n[r]||$o(t,e,r),n[r]}function ta(t,e,r){return ea(t,e,r).script}function ea(t,e,r){if(void 0!==e.witnessUtxo)return{script:e.witnessUtxo.script,value:e.witnessUtxo.value};if(void 0!==e.nonWitnessUtxo){var n=Qo(r,e,t).outs[r.__TX.ins[t].index];return{script:n.script,value:n.value}}throw new Error("Can't find pubkey in input without Utxo data")}function ra(t){return 33===t.length&&se(t)}function na(t,e,r,n,i){var o,a=Mi(t),s=a&&n&&Hi(n),u=Hi(t);if(a&&void 0===n)throw new Error("scriptPubkey is P2SH but redeemScript missing");if((u||s)&&void 0===i)throw new Error("scriptPubkey or redeemScript is P2WSH but witnessScript missing");return s?(o=i,Do(e,t,n,r),Ho(e,n,i,r),ia(o)):u?(o=i,Ho(e,t,i,r),ia(o)):a?(o=n,Do(e,t,n,r)):o=t,{meaningfulScript:o,type:s?"p2sh-p2wsh":a?"p2sh":u?"p2wsh":"raw"}}function ia(t){if(Di(t)||Mi(t))throw new Error("P2WPKH or P2SH can not be contained within P2WSH")}function oa(t){return Di(t)?"witnesspubkeyhash":Fi(t)?"pubkeyhash":Li(t)?"multisig":Ci(t)?"pubkey":"nonstandard"}function aa(t){return wo(Array(t).keys())}const sa={networks:b,address:m,payments:k,script:w,crypto:S,Transaction:E};var ua=i(3513),fa=i.t(ua,2);const ca="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0;function la(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&"Uint8Array"===t.constructor.name}function ha(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function pa(t,...e){if(!la(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function da(t){if("function"!=typeof t||"function"!=typeof t.create)throw new Error("Hash should be wrapped by utils.createHasher");ha(t.outputLen),ha(t.blockLen)}function ya(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function ba(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}function ga(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function va(t,e){return t<<32-e|t>>>e}function wa(t,e){return t<<e|t>>>32-e>>>0}const ma=(()=>"function"==typeof Uint8Array.from([]).toHex&&"function"==typeof Uint8Array.fromHex)(),Sa=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function _a(t){if(pa(t),ma)return t.toHex();let e="";for(let r=0;r<t.length;r++)e+=Sa[t[r]];return e}function Ea(t){return t>=48&&t<=57?t-48:t>=65&&t<=70?t-55:t>=97&&t<=102?t-87:void 0}function ka(t){if("string"!=typeof t)throw new Error("hex string expected, got "+typeof t);if(ma)return Uint8Array.fromHex(t);const e=t.length,r=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);const n=new Uint8Array(r);for(let e=0,i=0;e<r;e++,i+=2){const r=Ea(t.charCodeAt(i)),o=Ea(t.charCodeAt(i+1));if(void 0===r||void 0===o){const e=t[i]+t[i+1];throw new Error('hex string expected, got non-hex character "'+e+'" at index '+i)}n[e]=16*r+o}return n}function Oa(t){if("string"!=typeof t)throw new Error("string expected");return new Uint8Array((new TextEncoder).encode(t))}function Ta(t){return"string"==typeof t&&(t=Oa(t)),pa(t),t}function Aa(...t){let e=0;for(let r=0;r<t.length;r++){const n=t[r];pa(n),e+=n.length}const r=new Uint8Array(e);for(let e=0,n=0;e<t.length;e++){const i=t[e];r.set(i,n),n+=i.length}return r}class Ia{}function Pa(t){const e=e=>t().update(Ta(e)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function xa(t=32){if(ca&&"function"==typeof ca.getRandomValues)return ca.getRandomValues(new Uint8Array(t));if(ca&&"function"==typeof ca.randomBytes)return Uint8Array.from(ca.randomBytes(t));throw new Error("crypto.getRandomValues must be defined")}class Ba extends Ia{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,da(t);const r=Ta(e);if(this.iHash=t.create(),"function"!=typeof this.iHash.update)throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const n=this.blockLen,i=new Uint8Array(n);i.set(r.length>n?t.create().update(r).digest():r);for(let t=0;t<i.length;t++)i[t]^=54;this.iHash.update(i),this.oHash=t.create();for(let t=0;t<i.length;t++)i[t]^=106;this.oHash.update(i),ba(i)}update(t){return ya(this),this.iHash.update(t),this}digestInto(t){ya(this),pa(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){const t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));const{oHash:e,iHash:r,finished:n,destroyed:i,blockLen:o,outputLen:a}=this;return t.finished=n,t.destroyed=i,t.blockLen=o,t.outputLen=a,t.oHash=e._cloneInto(t.oHash),t.iHash=r._cloneInto(t.iHash),t}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const Ra=(t,e,r)=>new Ba(t,e).update(r).digest();function Ua(t,e,r){return t&e^~t&r}function Na(t,e,r){return t&e^t&r^e&r}Ra.create=(t,e)=>new Ba(t,e);class ja extends Ia{constructor(t,e,r,n){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=t,this.outputLen=e,this.padOffset=r,this.isLE=n,this.buffer=new Uint8Array(t),this.view=ga(this.buffer)}update(t){ya(this),pa(t=Ta(t));const{view:e,buffer:r,blockLen:n}=this,i=t.length;for(let o=0;o<i;){const a=Math.min(n-this.pos,i-o);if(a===n){const e=ga(t);for(;n<=i-o;o+=n)this.process(e,o);continue}r.set(t.subarray(o,o+a),this.pos),this.pos+=a,o+=a,this.pos===n&&(this.process(e,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){ya(this),function(t,e){pa(t);const r=e.outputLen;if(t.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}(t,this),this.finished=!0;const{buffer:e,view:r,blockLen:n,isLE:i}=this;let{pos:o}=this;e[o++]=128,ba(this.buffer.subarray(o)),this.padOffset>n-o&&(this.process(r,0),o=0);for(let t=o;t<n;t++)e[t]=0;!function(t,e,r,n){if("function"==typeof t.setBigUint64)return t.setBigUint64(e,r,n);const i=BigInt(32),o=BigInt(4294967295),a=Number(r>>i&o),s=Number(r&o),u=n?4:0,f=n?0:4;t.setUint32(e+u,a,n),t.setUint32(e+f,s,n)}(r,n-8,BigInt(8*this.length),i),this.process(r,0);const a=ga(t),s=this.outputLen;if(s%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const u=s/4,f=this.get();if(u>f.length)throw new Error("_sha2: outputLen bigger than state");for(let t=0;t<u;t++)a.setUint32(4*t,f[t],i)}digest(){const{buffer:t,outputLen:e}=this;this.digestInto(t);const r=t.slice(0,e);return this.destroy(),r}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:e,buffer:r,length:n,finished:i,destroyed:o,pos:a}=this;return t.destroyed=o,t.finished=i,t.length=n,t.pos=a,n%e&&t.buffer.set(r),t}clone(){return this._cloneInto()}}const La=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Ca=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]),Fa=Uint8Array.from([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),Da=(()=>Uint8Array.from(new Array(16).fill(0).map((t,e)=>e)))(),Ha=(()=>Da.map(t=>(9*t+5)%16))(),Ma=(()=>{const t=[[Da],[Ha]];for(let e=0;e<4;e++)for(let r of t)r.push(r[e].map(t=>Fa[t]));return t})(),Ka=(()=>Ma[0])(),Va=(()=>Ma[1])(),Wa=[[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8],[12,13,11,15,6,9,9,7,12,15,11,13,7,8,7,7],[13,15,14,11,7,7,6,8,13,14,13,12,5,5,6,9],[14,11,12,14,8,6,5,5,15,12,15,14,9,9,8,6],[15,12,13,13,9,5,8,6,14,11,12,11,8,6,5,5]].map(t=>Uint8Array.from(t)),Ga=Ka.map((t,e)=>t.map(t=>Wa[e][t])),qa=Va.map((t,e)=>t.map(t=>Wa[e][t])),za=Uint32Array.from([0,1518500249,1859775393,2400959708,2840853838]),Za=Uint32Array.from([1352829926,1548603684,1836072691,2053994217,0]);function Xa(t,e,r,n){return 0===t?e^r^n:1===t?e&r|~e&n:2===t?(e|~r)^n:3===t?e&n|r&~n:e^(r|~n)}const Ya=new Uint32Array(16);class $a extends ja{constructor(){super(64,20,8,!0),this.h0=1732584193,this.h1=-271733879,this.h2=-1732584194,this.h3=271733878,this.h4=-1009589776}get(){const{h0:t,h1:e,h2:r,h3:n,h4:i}=this;return[t,e,r,n,i]}set(t,e,r,n,i){this.h0=0|t,this.h1=0|e,this.h2=0|r,this.h3=0|n,this.h4=0|i}process(t,e){for(let r=0;r<16;r++,e+=4)Ya[r]=t.getUint32(e,!0);let r=0|this.h0,n=r,i=0|this.h1,o=i,a=0|this.h2,s=a,u=0|this.h3,f=u,c=0|this.h4,l=c;for(let t=0;t<5;t++){const e=4-t,h=za[t],p=Za[t],d=Ka[t],y=Va[t],b=Ga[t],g=qa[t];for(let e=0;e<16;e++){const n=wa(r+Xa(t,i,a,u)+Ya[d[e]]+h,b[e])+c|0;r=c,c=u,u=0|wa(a,10),a=i,i=n}for(let t=0;t<16;t++){const r=wa(n+Xa(e,o,s,f)+Ya[y[t]]+p,g[t])+l|0;n=l,l=f,f=0|wa(s,10),s=o,o=r}}this.set(this.h1+a+f|0,this.h2+u+l|0,this.h3+c+n|0,this.h4+r+o|0,this.h0+i+s|0)}roundClean(){ba(Ya)}destroy(){this.destroyed=!0,ba(this.buffer),this.set(0,0,0,0,0)}}const Ja=Pa(()=>new $a),Qa=BigInt(2**32-1),ts=BigInt(32);function es(t,e=!1){return e?{h:Number(t&Qa),l:Number(t>>ts&Qa)}:{h:0|Number(t>>ts&Qa),l:0|Number(t&Qa)}}const rs=(t,e,r)=>t>>>r,ns=(t,e,r)=>t<<32-r|e>>>r,is=(t,e,r)=>t>>>r|e<<32-r,os=(t,e,r)=>t<<32-r|e>>>r,as=(t,e,r)=>t<<64-r|e>>>r-32,ss=(t,e,r)=>t>>>r-32|e<<64-r;function us(t,e,r,n){const i=(e>>>0)+(n>>>0);return{h:t+r+(i/2**32|0)|0,l:0|i}}const fs=(t,e,r)=>(t>>>0)+(e>>>0)+(r>>>0),cs=(t,e,r,n)=>e+r+n+(t/2**32|0)|0,ls=(t,e,r,n)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0),hs=(t,e,r,n,i)=>e+r+n+i+(t/2**32|0)|0,ps=(t,e,r,n,i)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0)+(i>>>0),ds=(t,e,r,n,i,o)=>e+r+n+i+o+(t/2**32|0)|0,ys=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]),bs=new Uint32Array(64);class gs extends ja{constructor(t=32){super(64,t,8,!1),this.A=0|La[0],this.B=0|La[1],this.C=0|La[2],this.D=0|La[3],this.E=0|La[4],this.F=0|La[5],this.G=0|La[6],this.H=0|La[7]}get(){const{A:t,B:e,C:r,D:n,E:i,F:o,G:a,H:s}=this;return[t,e,r,n,i,o,a,s]}set(t,e,r,n,i,o,a,s){this.A=0|t,this.B=0|e,this.C=0|r,this.D=0|n,this.E=0|i,this.F=0|o,this.G=0|a,this.H=0|s}process(t,e){for(let r=0;r<16;r++,e+=4)bs[r]=t.getUint32(e,!1);for(let t=16;t<64;t++){const e=bs[t-15],r=bs[t-2],n=va(e,7)^va(e,18)^e>>>3,i=va(r,17)^va(r,19)^r>>>10;bs[t]=i+bs[t-7]+n+bs[t-16]|0}let{A:r,B:n,C:i,D:o,E:a,F:s,G:u,H:f}=this;for(let t=0;t<64;t++){const e=f+(va(a,6)^va(a,11)^va(a,25))+Ua(a,s,u)+ys[t]+bs[t]|0,c=(va(r,2)^va(r,13)^va(r,22))+Na(r,n,i)|0;f=u,u=s,s=a,a=o+e|0,o=i,i=n,n=r,r=e+c|0}r=r+this.A|0,n=n+this.B|0,i=i+this.C|0,o=o+this.D|0,a=a+this.E|0,s=s+this.F|0,u=u+this.G|0,f=f+this.H|0,this.set(r,n,i,o,a,s,u,f)}roundClean(){ba(bs)}destroy(){this.set(0,0,0,0,0,0,0,0),ba(this.buffer)}}const vs=(()=>function(t,e=!1){const r=t.length;let n=new Uint32Array(r),i=new Uint32Array(r);for(let o=0;o<r;o++){const{h:r,l:a}=es(t[o],e);[n[o],i[o]]=[r,a]}return[n,i]}(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(t=>BigInt(t))))(),ws=(()=>vs[0])(),ms=(()=>vs[1])(),Ss=new Uint32Array(80),_s=new Uint32Array(80);class Es extends ja{constructor(t=64){super(128,t,16,!1),this.Ah=0|Ca[0],this.Al=0|Ca[1],this.Bh=0|Ca[2],this.Bl=0|Ca[3],this.Ch=0|Ca[4],this.Cl=0|Ca[5],this.Dh=0|Ca[6],this.Dl=0|Ca[7],this.Eh=0|Ca[8],this.El=0|Ca[9],this.Fh=0|Ca[10],this.Fl=0|Ca[11],this.Gh=0|Ca[12],this.Gl=0|Ca[13],this.Hh=0|Ca[14],this.Hl=0|Ca[15]}get(){const{Ah:t,Al:e,Bh:r,Bl:n,Ch:i,Cl:o,Dh:a,Dl:s,Eh:u,El:f,Fh:c,Fl:l,Gh:h,Gl:p,Hh:d,Hl:y}=this;return[t,e,r,n,i,o,a,s,u,f,c,l,h,p,d,y]}set(t,e,r,n,i,o,a,s,u,f,c,l,h,p,d,y){this.Ah=0|t,this.Al=0|e,this.Bh=0|r,this.Bl=0|n,this.Ch=0|i,this.Cl=0|o,this.Dh=0|a,this.Dl=0|s,this.Eh=0|u,this.El=0|f,this.Fh=0|c,this.Fl=0|l,this.Gh=0|h,this.Gl=0|p,this.Hh=0|d,this.Hl=0|y}process(t,e){for(let r=0;r<16;r++,e+=4)Ss[r]=t.getUint32(e),_s[r]=t.getUint32(e+=4);for(let t=16;t<80;t++){const e=0|Ss[t-15],r=0|_s[t-15],n=is(e,r,1)^is(e,r,8)^rs(e,0,7),i=os(e,r,1)^os(e,r,8)^ns(e,r,7),o=0|Ss[t-2],a=0|_s[t-2],s=is(o,a,19)^as(o,a,61)^rs(o,0,6),u=os(o,a,19)^ss(o,a,61)^ns(o,a,6),f=ls(i,u,_s[t-7],_s[t-16]),c=hs(f,n,s,Ss[t-7],Ss[t-16]);Ss[t]=0|c,_s[t]=0|f}let{Ah:r,Al:n,Bh:i,Bl:o,Ch:a,Cl:s,Dh:u,Dl:f,Eh:c,El:l,Fh:h,Fl:p,Gh:d,Gl:y,Hh:b,Hl:g}=this;for(let t=0;t<80;t++){const e=is(c,l,14)^is(c,l,18)^as(c,l,41),v=os(c,l,14)^os(c,l,18)^ss(c,l,41),w=c&h^~c&d,m=ps(g,v,l&p^~l&y,ms[t],_s[t]),S=ds(m,b,e,w,ws[t],Ss[t]),_=0|m,E=is(r,n,28)^as(r,n,34)^as(r,n,39),k=os(r,n,28)^ss(r,n,34)^ss(r,n,39),O=r&i^r&a^i&a,T=n&o^n&s^o&s;b=0|d,g=0|y,d=0|h,y=0|p,h=0|c,p=0|l,({h:c,l}=us(0|u,0|f,0|S,0|_)),u=0|a,f=0|s,a=0|i,s=0|o,i=0|r,o=0|n;const A=fs(_,k,T);r=cs(A,S,E,O),n=0|A}({h:r,l:n}=us(0|this.Ah,0|this.Al,0|r,0|n)),({h:i,l:o}=us(0|this.Bh,0|this.Bl,0|i,0|o)),({h:a,l:s}=us(0|this.Ch,0|this.Cl,0|a,0|s)),({h:u,l:f}=us(0|this.Dh,0|this.Dl,0|u,0|f)),({h:c,l}=us(0|this.Eh,0|this.El,0|c,0|l)),({h,l:p}=us(0|this.Fh,0|this.Fl,0|h,0|p)),({h:d,l:y}=us(0|this.Gh,0|this.Gl,0|d,0|y)),({h:b,l:g}=us(0|this.Hh,0|this.Hl,0|b,0|g)),this.set(r,n,i,o,a,s,u,f,c,l,h,p,d,y,b,g)}roundClean(){ba(Ss,_s)}destroy(){ba(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const ks=Pa(()=>new gs),Os=ks,Ts=Pa(()=>new Es);function As(t,e){return Ra(Ts,t,e)}const Is="0123456789abcdefABCDEF",Ps=(Is.split("").map(t=>t.codePointAt(0)),Array(256).fill(!0).map((t,e)=>{const r=String.fromCodePoint(e),n=Is.indexOf(r);return n<0?void 0:n<16?n:n-6})),xs=new TextEncoder;function Bs(t,e){const r=Math.min(t.length,e.length);for(let n=0;n<r;++n)if(t[n]!==e[n])return t[n]<e[n]?-1:1;return t.length===e.length?0:t.length>e.length?1:-1}function Rs(t,e,r){if(e+1>t.length)throw new Error("Offset is outside the bounds of Uint8Array");if(r>255)throw new Error(`The value of "value" is out of range. It must be >= 0 and <= 255. Received ${r}`);t[e]=r}function Us(t,e,r,n){if(e+4>t.length)throw new Error("Offset is outside the bounds of Uint8Array");if(n=n.toUpperCase(),r>4294967295)throw new Error(`The value of "value" is out of range. It must be >= 0 and <= 4294967295. Received ${r}`);"LE"===n?(t[e]=255&r,t[e+1]=r>>8&255,t[e+2]=r>>16&255,t[e+3]=r>>24&255):(t[e]=r>>24&255,t[e+1]=r>>16&255,t[e+2]=r>>8&255,t[e+3]=255&r)}function Ns(t,e,r){if(e+4>t.length)throw new Error("Offset is outside the bounds of Uint8Array");if("LE"===(r=r.toUpperCase())){let r=0;return r=(r<<8)+t[e+3]>>>0,r=(r<<8)+t[e+2]>>>0,r=(r<<8)+t[e+1]>>>0,r=(r<<8)+t[e]>>>0,r}{let r=0;return r=(r<<8)+t[e]>>>0,r=(r<<8)+t[e+1]>>>0,r=(r<<8)+t[e+2]>>>0,r=(r<<8)+t[e+3]>>>0,r}}new TextDecoder;const js=t=>function(t){const e=xs.encode(t||""),r=new Uint8Array(Math.floor(e.length/2));let n;for(n=0;n<r.length;n++){const t=Ps[e[2*n]],i=Ps[e[2*n+1]];if(void 0===t||void 0===i)break;r[n]=t<<4|i}return n===r.length?r:r.slice(0,n)}(t);function Ls(t){if(!t)throw new Error("ecc library invalid")}function Cs(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&"Uint8Array"===t.constructor.name}function Fs(t,e){return!!Array.isArray(e)&&(0===e.length||(t?e.every(t=>"string"==typeof t):e.every(t=>Number.isSafeInteger(t))))}function Ds(t){if("function"!=typeof t)throw new Error("function expected");return!0}function Hs(t,e){if("string"!=typeof e)throw new Error(`${t}: string expected`);return!0}function Ms(t){if(!Number.isSafeInteger(t))throw new Error(`invalid integer: ${t}`)}function Ks(t){if(!Array.isArray(t))throw new Error("array expected")}function Vs(t,e){if(!Fs(!0,e))throw new Error(`${t}: array of strings expected`)}function Ws(t,e){if(!Fs(!1,e))throw new Error(`${t}: array of numbers expected`)}function Gs(...t){const e=t=>t,r=(t,e)=>r=>t(e(r)),n=t.map(t=>t.encode).reduceRight(r,e),i=t.map(t=>t.decode).reduce(r,e);return{encode:n,decode:i}}function qs(t){const e="string"==typeof t?t.split(""):t,r=e.length;Vs("alphabet",e);const n=new Map(e.map((t,e)=>[t,e]));return{encode:n=>(Ks(n),n.map(n=>{if(!Number.isSafeInteger(n)||n<0||n>=r)throw new Error(`alphabet.encode: digit index outside alphabet "${n}". Allowed: ${t}`);return e[n]})),decode:e=>(Ks(e),e.map(e=>{Hs("alphabet.decode",e);const r=n.get(e);if(void 0===r)throw new Error(`Unknown letter: "${e}". Allowed: ${t}`);return r}))}}function zs(t=""){return Hs("join",t),{encode:e=>(Vs("join.decode",e),e.join(t)),decode:e=>(Hs("join.decode",e),e.split(t))}}function Zs(t,e="="){return Ms(t),Hs("padding",e),{encode(r){for(Vs("padding.encode",r);r.length*t%8;)r.push(e);return r},decode(r){Vs("padding.decode",r);let n=r.length;if(n*t%8)throw new Error("padding: invalid, string should have whole number of bytes");for(;n>0&&r[n-1]===e;n--)if((n-1)*t%8==0)throw new Error("padding: invalid, string has too much padding");return r.slice(0,n)}}}function Xs(t){return Ds(t),{encode:t=>t,decode:e=>t(e)}}function Ys(t,e,r){if(e<2)throw new Error(`convertRadix: invalid from=${e}, base cannot be less than 2`);if(r<2)throw new Error(`convertRadix: invalid to=${r}, base cannot be less than 2`);if(Ks(t),!t.length)return[];let n=0;const i=[],o=Array.from(t,t=>{if(Ms(t),t<0||t>=e)throw new Error(`invalid integer: ${t}`);return t}),a=o.length;for(;;){let t=0,s=!0;for(let i=n;i<a;i++){const a=o[i],u=e*t,f=u+a;if(!Number.isSafeInteger(f)||u/e!==t||f-a!==u)throw new Error("convertRadix: carry overflow");const c=f/r;t=f%r;const l=Math.floor(c);if(o[i]=l,!Number.isSafeInteger(l)||l*r+t!==f)throw new Error("convertRadix: carry overflow");s&&(l?s=!1:n=i)}if(i.push(t),s)break}for(let e=0;e<t.length-1&&0===t[e];e++)i.push(0);return i.reverse()}const $s=(t,e)=>0===e?t:$s(e,t%e),Js=(t,e)=>t+(e-$s(t,e)),Qs=(()=>{let t=[];for(let e=0;e<40;e++)t.push(2**e);return t})();function tu(t,e,r,n){if(Ks(t),e<=0||e>32)throw new Error(`convertRadix2: wrong from=${e}`);if(r<=0||r>32)throw new Error(`convertRadix2: wrong to=${r}`);if(Js(e,r)>32)throw new Error(`convertRadix2: carry overflow from=${e} to=${r} carryBits=${Js(e,r)}`);let i=0,o=0;const a=Qs[e],s=Qs[r]-1,u=[];for(const n of t){if(Ms(n),n>=a)throw new Error(`convertRadix2: invalid data word=${n} from=${e}`);if(i=i<<e|n,o+e>32)throw new Error(`convertRadix2: carry overflow pos=${o} from=${e}`);for(o+=e;o>=r;o-=r)u.push((i>>o-r&s)>>>0);const t=Qs[o];if(void 0===t)throw new Error("invalid carry");i&=t-1}if(i=i<<r-o&s,!n&&o>=e)throw new Error("Excess padding");if(!n&&i>0)throw new Error(`Non-zero padding: ${i}`);return n&&o>0&&u.push(i>>>0),u}function eu(t,e=!1){if(Ms(t),t<=0||t>32)throw new Error("radix2: bits should be in (0..32]");if(Js(8,t)>32||Js(t,8)>32)throw new Error("radix2: carry overflow");return{encode:r=>{if(!Cs(r))throw new Error("radix2.encode input should be Uint8Array");return tu(Array.from(r),8,t,!e)},decode:r=>(Ws("radix2.decode",r),Uint8Array.from(tu(r,t,8,e)))}}function ru(t){return Ds(t),function(...e){try{return t.apply(null,e)}catch(t){}}}Gs(eu(4),qs("0123456789ABCDEF"),zs("")),Gs(eu(5),qs("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),Zs(5),zs("")),Gs(eu(5),qs("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),zs("")),Gs(eu(5),qs("0123456789ABCDEFGHIJKLMNOPQRSTUV"),Zs(5),zs("")),Gs(eu(5),qs("0123456789ABCDEFGHIJKLMNOPQRSTUV"),zs("")),Gs(eu(5),qs("0123456789ABCDEFGHJKMNPQRSTVWXYZ"),zs(""),Xs(t=>t.toUpperCase().replace(/O/g,"0").replace(/[IL]/g,"1")));const nu=(()=>"function"==typeof Uint8Array.from([]).toBase64&&"function"==typeof Uint8Array.fromBase64)(),iu=(nu||Gs(eu(6),qs("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),Zs(6),zs("")),Gs(eu(6),qs("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),zs("")),nu||Gs(eu(6),qs("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),Zs(6),zs("")),Gs(eu(6),qs("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),zs("")),t=>{return Gs((Ms(e=58),{encode:t=>{if(!Cs(t))throw new Error("radix.encode input should be Uint8Array");return Ys(Array.from(t),256,e)},decode:t=>(Ws("radix.decode",t),Uint8Array.from(Ys(t,e,256)))}),qs(t),zs(""));var e}),ou=iu("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),au=(iu("123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"),iu("rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz"),t=>Gs(function(t,e){return Ms(t),Ds(e),{encode(r){if(!Cs(r))throw new Error("checksum.encode: input should be Uint8Array");const n=e(r).slice(0,t),i=new Uint8Array(r.length+t);return i.set(r),i.set(n,r.length),i},decode(r){if(!Cs(r))throw new Error("checksum.decode: input should be Uint8Array");const n=r.slice(0,-t),i=r.slice(-t),o=e(n).slice(0,t);for(let e=0;e<t;e++)if(o[e]!==i[e])throw new Error("Invalid checksum");return n}}}(4,e=>t(t(e))),ou)),su=Gs(qs("qpzry9x8gf2tvdw0s3jn54khce6mua7l"),zs("")),uu=[996825010,642813549,513874426,1027748829,705979059];function fu(t){const e=t>>25;let r=(33554431&t)<<5;for(let t=0;t<uu.length;t++)1==(e>>t&1)&&(r^=uu[t]);return r}function cu(t,e,r=1){const n=t.length;let i=1;for(let e=0;e<n;e++){const r=t.charCodeAt(e);if(r<33||r>126)throw new Error(`Invalid prefix (${t})`);i=fu(i)^r>>5}i=fu(i);for(let e=0;e<n;e++)i=fu(i)^31&t.charCodeAt(e);for(let t of e)i=fu(i)^t;for(let t=0;t<6;t++)i=fu(i);return i^=r,su.encode(tu([i%Qs[30]],30,5,!1))}function lu(t){const e="bech32"===t?1:734539939,r=eu(5),n=r.decode,i=r.encode,o=ru(n);function a(t,r,n=90){Hs("bech32.encode prefix",t),Cs(r)&&(r=Array.from(r)),Ws("bech32.encode",r);const i=t.length;if(0===i)throw new TypeError(`Invalid prefix length ${i}`);const o=i+7+r.length;if(!1!==n&&o>n)throw new TypeError(`Length ${o} exceeds limit ${n}`);const a=t.toLowerCase(),s=cu(a,r,e);return`${a}1${su.encode(r)}${s}`}function s(t,r=90){Hs("bech32.decode input",t);const n=t.length;if(n<8||!1!==r&&n>r)throw new TypeError(`invalid string length: ${n} (${t}). Expected (8..${r})`);const i=t.toLowerCase();if(t!==i&&t!==t.toUpperCase())throw new Error("String must be lowercase or uppercase");const o=i.lastIndexOf("1");if(0===o||-1===o)throw new Error('Letter "1" must be present between prefix and data only');const a=i.slice(0,o),s=i.slice(o+1);if(s.length<6)throw new Error("Data must be at least 6 characters long");const u=su.decode(s).slice(0,-6),f=cu(a,u,e);if(!s.endsWith(f))throw new Error(`Invalid checksum in ${t}: expected "${f}"`);return{prefix:a,words:u}}return{encode:a,decode:s,encodeFromBytes:function(t,e){return a(t,i(e))},decodeToBytes:function(t){const{prefix:e,words:r}=s(t,!1);return{prefix:e,words:r,bytes:n(r)}},decodeUnsafe:ru(s),fromWords:n,fromWordsUnsafe:o,toWords:i}}lu("bech32"),lu("bech32m");function hu(t){const e=typeof t;return"string"===e?`"${t}"`:"number"===e||"bigint"===e||"boolean"===e?`${t}`:"object"===e||"function"===e?(t&&Object.getPrototypeOf(t)?.constructor?.name)??"null":e}function pu(t,e,r,n,i){const o=i&&"input"in i?i.input:r.value,a=i?.expected??t.expects??null,s=i?.received??hu(o),u={kind:t.kind,type:t.type,input:o,expected:a,received:s,message:`Invalid ${e}: ${a?`Expected ${a} but r`:"R"}eceived ${s}`,requirement:t.requirement,path:i?.path,issues:i?.issues,lang:n.lang,abortEarly:n.abortEarly,abortPipeEarly:n.abortPipeEarly},f="schema"===t.kind,c=i?.message??t.message??(t.reference,void u.lang)??(f?void u.lang:null)??n.message??void u.lang;c&&(u.message="function"==typeof c?c(u):c),f&&(r.typed=!1),r.issues?r.issues.push(u):r.issues=[u]}(()=>"function"==typeof Uint8Array.from([]).toHex&&"function"==typeof Uint8Array.fromHex)()||Gs(eu(4),qs("0123456789abcdef"),zs(""),Xs(t=>{if("string"!=typeof t||t.length%2!=0)throw new TypeError(`hex.decode: expected string, got ${typeof t} with length ${t.length}`);return t.toLowerCase()}));var du=class extends Error{issues;constructor(t){super(t[0].message),this.name="ValiError",this.issues=t}};function yu(t){return{kind:"validation",type:"integer",reference:yu,async:!1,expects:null,requirement:Number.isInteger,message:t,_run(t,e){return t.typed&&!this.requirement(t.value)&&pu(this,"integer",t,e),t}}}function bu(t,e){return{kind:"validation",type:"length",reference:bu,async:!1,expects:`${t}`,requirement:t,message:e,_run(t,e){return t.typed&&t.value.length!==this.requirement&&pu(this,"length",t,e,{received:`${t.value.length}`}),t}}}function gu(t,e){return{kind:"validation",type:"max_value",reference:gu,async:!1,expects:`<=${t instanceof Date?t.toJSON():hu(t)}`,requirement:t,message:e,_run(t,e){return t.typed&&t.value>this.requirement&&pu(this,"value",t,e,{received:t.value instanceof Date?t.value.toJSON():hu(t.value)}),t}}}function vu(t,e){return{kind:"validation",type:"min_value",reference:vu,async:!1,expects:`>=${t instanceof Date?t.toJSON():hu(t)}`,requirement:t,message:e,_run(t,e){return t.typed&&t.value<this.requirement&&pu(this,"value",t,e,{received:t.value instanceof Date?t.value.toJSON():hu(t.value)}),t}}}function wu(t,e){return{kind:"schema",type:"instance",reference:wu,expects:t.name,async:!1,class:t,message:e,_run(t,e){return t.value instanceof this.class?t.typed=!0:pu(this,"type",t,e),t}}}function mu(t){return{kind:"schema",type:"number",reference:mu,expects:"number",async:!1,message:t,_run(t,e){return"number"!=typeof t.value||isNaN(t.value)?pu(this,"type",t,e):t.typed=!0,t}}}function Su(t,e){return{kind:"schema",type:"object",reference:Su,expects:"Object",async:!1,entries:t,message:e,_run(t,e){const r=t.value;if(r&&"object"==typeof r){t.typed=!0,t.value={};for(const n in this.entries){const i=r[n],o=this.entries[n]._run({typed:!1,value:i},e);if(o.issues){const a={type:"object",origin:"value",input:r,key:n,value:i};for(const e of o.issues)e.path?e.path.unshift(a):e.path=[a],t.issues?.push(e);if(t.issues||(t.issues=o.issues),e.abortEarly){t.typed=!1;break}}o.typed||(t.typed=!1),(void 0!==o.value||n in r)&&(t.value[n]=o.value)}}else pu(this,"type",t,e);return t}}}function _u(t,e,r){const n=t._run({typed:!1,value:e},function(t){return{lang:t?.lang??void 0,message:t?.message,abortEarly:t?.abortEarly??void 0,abortPipeEarly:t?.abortPipeEarly??void 0}}(r));if(n.issues)throw new du(n.issues);return n.value}function Eu(...t){return{...t[0],pipe:t,_run(e,r){for(const n of t)if("metadata"!==n.kind){if(e.issues&&("schema"===n.kind||"transformation"===n.kind)){e.typed=!1;break}e.issues&&(r.abortEarly||r.abortPipeEarly)||(e=n._run(e,r))}return e}}}const ku=Eu(mu(),yu(),vu(0),gu(4294967295)),Ou=Eu(mu(),yu(),vu(0),gu(2147483647)),Tu=Eu(mu(),yu(),vu(0),gu(255)),Au=Eu(wu(Uint8Array),bu(32)),Iu=Eu(wu(Uint8Array),bu(33)),Pu=Su({wif:Tu,bip32:Su({public:ku,private:ku})}),xu=Eu(function t(e){return{kind:"schema",type:"string",reference:t,expects:"string",async:!1,message:e,_run(t,e){return"string"==typeof t.value?t.typed=!0:pu(this,"type",t,e),t}}}(),function t(e,r){return{kind:"validation",type:"regex",reference:t,async:!1,expects:`${e}`,requirement:e,message:r,_run(t,e){return t.typed&&!this.requirement.test(t.value)&&pu(this,"format",t,e),t}}}(/^(m\/)?(\d+'?\/)*\d+'?$/)),Bu=function(t){if(t.length>=255)throw new TypeError("Alphabet too long");const e=new Uint8Array(256);for(let t=0;t<e.length;t++)e[t]=255;for(let r=0;r<t.length;r++){const n=t.charAt(r),i=n.charCodeAt(0);if(255!==e[i])throw new TypeError(n+" is ambiguous");e[i]=r}const r=t.length,n=t.charAt(0),i=Math.log(r)/Math.log(256),o=Math.log(256)/Math.log(r);function a(t){if("string"!=typeof t)throw new TypeError("Expected String");if(0===t.length)return new Uint8Array;let o=0,a=0,s=0;for(;t[o]===n;)a++,o++;const u=(t.length-o)*i+1>>>0,f=new Uint8Array(u);for(;o<t.length;){const n=t.charCodeAt(o);if(n>255)return;let i=e[n];if(255===i)return;let a=0;for(let t=u-1;(0!==i||a<s)&&-1!==t;t--,a++)i+=r*f[t]>>>0,f[t]=i%256>>>0,i=i/256>>>0;if(0!==i)throw new Error("Non-zero carry");s=a,o++}let c=u-s;for(;c!==u&&0===f[c];)c++;const l=new Uint8Array(a+(u-c));let h=a;for(;c!==u;)l[h++]=f[c++];return l}return{encode:function(e){if(e instanceof Uint8Array||(ArrayBuffer.isView(e)?e=new Uint8Array(e.buffer,e.byteOffset,e.byteLength):Array.isArray(e)&&(e=Uint8Array.from(e))),!(e instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===e.length)return"";let i=0,a=0,s=0;const u=e.length;for(;s!==u&&0===e[s];)s++,i++;const f=(u-s)*o+1>>>0,c=new Uint8Array(f);for(;s!==u;){let t=e[s],n=0;for(let e=f-1;(0!==t||n<a)&&-1!==e;e--,n++)t+=256*c[e]>>>0,c[e]=t%r>>>0,t=t/r>>>0;if(0!==t)throw new Error("Non-zero carry");a=n,s++}let l=f-a;for(;l!==f&&0===c[l];)l++;let h=n.repeat(i);for(;l<f;++l)h+=t.charAt(c[l]);return h},decodeUnsafe:a,decode:function(t){const e=a(t);if(e)return e;throw new Error("Non-base"+r+" character")}}}("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),Ru=function(t){function e(e){var r=e.slice(0,-4),n=e.slice(-4),i=t(r);if(!(n[0]^i[0]|n[1]^i[1]|n[2]^i[2]|n[3]^i[3]))return r}return{encode:function(e){var r=Uint8Array.from(e),n=t(r),i=r.length+4,o=new Uint8Array(i);return o.set(r,0),o.set(n.subarray(0,4),r.length),Bu.encode(o)},decode:function(t){var r=e(Bu.decode(t));if(null==r)throw new Error("Invalid checksum");return r},decodeUnsafe:function(t){var r=Bu.decodeUnsafe(t);if(null!=r)return e(r)}}}(function(t){return Os(Os(t))});const Uu=au(Os);var Nu=i(8700);const ju=BigInt(0),Lu=BigInt(1);function Cu(t,e=""){if("boolean"!=typeof t)throw new Error((e&&`"${e}"`)+"expected boolean, got type="+typeof t);return t}function Fu(t,e,r=""){const n=la(t),i=t?.length,o=void 0!==e;if(!n||o&&i!==e)throw new Error((r&&`"${r}" `)+"expected Uint8Array"+(o?` of length ${e}`:"")+", got "+(n?`length=${i}`:"type="+typeof t));return t}function Du(t){const e=t.toString(16);return 1&e.length?"0"+e:e}function Hu(t){if("string"!=typeof t)throw new Error("hex string expected, got "+typeof t);return""===t?ju:BigInt("0x"+t)}function Mu(t){return Hu(_a(t))}function Ku(t){return pa(t),Hu(_a(Uint8Array.from(t).reverse()))}function Vu(t,e){return ka(t.toString(16).padStart(2*e,"0"))}function Wu(t,e){return Vu(t,e).reverse()}function Gu(t,e,r){let n;if("string"==typeof e)try{n=ka(e)}catch(e){throw new Error(t+" must be hex string or Uint8Array, cause: "+e)}else{if(!la(e))throw new Error(t+" must be hex string or Uint8Array");n=Uint8Array.from(e)}const i=n.length;if("number"==typeof r&&i!==r)throw new Error(t+" of length "+r+" expected, got "+i);return n}const qu=t=>"bigint"==typeof t&&ju<=t;function zu(t,e,r,n){if(!function(t,e,r){return qu(t)&&qu(e)&&qu(r)&&e<=t&&t<r}(e,r,n))throw new Error("expected valid "+t+": "+r+" <= n < "+n+", got "+e)}function Zu(t){let e;for(e=0;t>ju;t>>=Lu,e+=1);return e}const Xu=t=>(Lu<<BigInt(t))-Lu;function Yu(t,e,r={}){if(!t||"object"!=typeof t)throw new Error("expected valid options object");function n(e,r,n){const i=t[e];if(n&&void 0===i)return;const o=typeof i;if(o!==r||null===i)throw new Error(`param "${e}" is invalid: expected ${r}, got ${o}`)}Object.entries(e).forEach(([t,e])=>n(t,e,!1)),Object.entries(r).forEach(([t,e])=>n(t,e,!0))}function $u(t){const e=new WeakMap;return(r,...n)=>{const i=e.get(r);if(void 0!==i)return i;const o=t(r,...n);return e.set(r,o),o}}const Ju=BigInt(0),Qu=BigInt(1),tf=BigInt(2),ef=BigInt(3),rf=BigInt(4),nf=BigInt(5),of=BigInt(7),af=BigInt(8),sf=BigInt(9),uf=BigInt(16);function ff(t,e){const r=t%e;return r>=Ju?r:e+r}function cf(t,e,r){let n=t;for(;e-- >Ju;)n*=n,n%=r;return n}function lf(t,e){if(t===Ju)throw new Error("invert: expected non-zero number");if(e<=Ju)throw new Error("invert: expected positive modulus, got "+e);let r=ff(t,e),n=e,i=Ju,o=Qu,a=Qu,s=Ju;for(;r!==Ju;){const t=n/r,e=n%r,u=i-a*t,f=o-s*t;n=r,r=e,i=a,o=s,a=u,s=f}if(n!==Qu)throw new Error("invert: does not exist");return ff(i,e)}function hf(t,e,r){if(!t.eql(t.sqr(e),r))throw new Error("Cannot find square root")}function pf(t,e){const r=(t.ORDER+Qu)/rf,n=t.pow(e,r);return hf(t,n,e),n}function df(t,e){const r=(t.ORDER-nf)/af,n=t.mul(e,tf),i=t.pow(n,r),o=t.mul(e,i),a=t.mul(t.mul(o,tf),i),s=t.mul(o,t.sub(a,t.ONE));return hf(t,s,e),s}function yf(t){if(t<ef)throw new Error("sqrt is not defined for small field");let e=t-Qu,r=0;for(;e%tf===Ju;)e/=tf,r++;let n=tf;const i=mf(t);for(;1===vf(i,n);)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(1===r)return pf;let o=i.pow(n,e);const a=(e+Qu)/tf;return function(t,n){if(t.is0(n))return n;if(1!==vf(t,n))throw new Error("Cannot find square root");let i=r,s=t.mul(t.ONE,o),u=t.pow(n,e),f=t.pow(n,a);for(;!t.eql(u,t.ONE);){if(t.is0(u))return t.ZERO;let e=1,r=t.sqr(u);for(;!t.eql(r,t.ONE);)if(e++,r=t.sqr(r),e===i)throw new Error("Cannot find square root");const n=Qu<<BigInt(i-e-1),o=t.pow(s,n);i=e,s=t.sqr(o),u=t.mul(u,s),f=t.mul(f,o)}return f}}const bf=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function gf(t,e,r=!1){const n=new Array(e.length).fill(r?t.ZERO:void 0),i=e.reduce((e,r,i)=>t.is0(r)?e:(n[i]=e,t.mul(e,r)),t.ONE),o=t.inv(i);return e.reduceRight((e,r,i)=>t.is0(r)?e:(n[i]=t.mul(e,n[i]),t.mul(e,r)),o),n}function vf(t,e){const r=(t.ORDER-Qu)/tf,n=t.pow(e,r),i=t.eql(n,t.ONE),o=t.eql(n,t.ZERO),a=t.eql(n,t.neg(t.ONE));if(!i&&!o&&!a)throw new Error("invalid Legendre symbol result");return i?1:o?0:-1}function wf(t,e){void 0!==e&&ha(e);const r=void 0!==e?e:t.toString(2).length;return{nBitLength:r,nByteLength:Math.ceil(r/8)}}function mf(t,e,r=!1,n={}){if(t<=Ju)throw new Error("invalid field: expected ORDER > 0, got "+t);let i,o,a,s=!1;if("object"==typeof e&&null!=e){if(n.sqrt||r)throw new Error("cannot specify opts in two arguments");const t=e;t.BITS&&(i=t.BITS),t.sqrt&&(o=t.sqrt),"boolean"==typeof t.isLE&&(r=t.isLE),"boolean"==typeof t.modFromBytes&&(s=t.modFromBytes),a=t.allowedLengths}else"number"==typeof e&&(i=e),n.sqrt&&(o=n.sqrt);const{nBitLength:u,nByteLength:f}=wf(t,i);if(f>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let c;const l=Object.freeze({ORDER:t,isLE:r,BITS:u,BYTES:f,MASK:Xu(u),ZERO:Ju,ONE:Qu,allowedLengths:a,create:e=>ff(e,t),isValid:e=>{if("bigint"!=typeof e)throw new Error("invalid field element: expected bigint, got "+typeof e);return Ju<=e&&e<t},is0:t=>t===Ju,isValidNot0:t=>!l.is0(t)&&l.isValid(t),isOdd:t=>(t&Qu)===Qu,neg:e=>ff(-e,t),eql:(t,e)=>t===e,sqr:e=>ff(e*e,t),add:(e,r)=>ff(e+r,t),sub:(e,r)=>ff(e-r,t),mul:(e,r)=>ff(e*r,t),pow:(t,e)=>function(t,e,r){if(r<Ju)throw new Error("invalid exponent, negatives unsupported");if(r===Ju)return t.ONE;if(r===Qu)return e;let n=t.ONE,i=e;for(;r>Ju;)r&Qu&&(n=t.mul(n,i)),i=t.sqr(i),r>>=Qu;return n}(l,t,e),div:(e,r)=>ff(e*lf(r,t),t),sqrN:t=>t*t,addN:(t,e)=>t+e,subN:(t,e)=>t-e,mulN:(t,e)=>t*e,inv:e=>lf(e,t),sqrt:o||(e=>(c||(c=function(t){return t%rf===ef?pf:t%af===nf?df:t%uf===sf?function(t){const e=mf(t),r=yf(t),n=r(e,e.neg(e.ONE)),i=r(e,n),o=r(e,e.neg(n)),a=(t+of)/uf;return(t,e)=>{let r=t.pow(e,a),s=t.mul(r,n);const u=t.mul(r,i),f=t.mul(r,o),c=t.eql(t.sqr(s),e),l=t.eql(t.sqr(u),e);r=t.cmov(r,s,c),s=t.cmov(f,u,l);const h=t.eql(t.sqr(s),e),p=t.cmov(r,s,h);return hf(t,p,e),p}}(t):yf(t)}(t)),c(l,e))),toBytes:t=>r?Wu(t,f):Vu(t,f),fromBytes:(e,n=!0)=>{if(a){if(!a.includes(e.length)||e.length>f)throw new Error("Field.fromBytes: expected "+a+" bytes, got "+e.length);const t=new Uint8Array(f);t.set(e,r?0:t.length-e.length),e=t}if(e.length!==f)throw new Error("Field.fromBytes: expected "+f+" bytes, got "+e.length);let i=r?Ku(e):Mu(e);if(s&&(i=ff(i,t)),!n&&!l.isValid(i))throw new Error("invalid field element: outside of range 0..ORDER");return i},invertBatch:t=>gf(l,t),cmov:(t,e,r)=>r?e:t});return Object.freeze(l)}function Sf(t){if("bigint"!=typeof t)throw new Error("field order must be bigint");const e=t.toString(2).length;return Math.ceil(e/8)}function _f(t){const e=Sf(t);return e+Math.ceil(e/2)}const Ef=BigInt(0),kf=BigInt(1);function Of(t,e){const r=e.negate();return t?r:e}function Tf(t,e){const r=gf(t.Fp,e.map(t=>t.Z));return e.map((e,n)=>t.fromAffine(e.toAffine(r[n])))}function Af(t,e){if(!Number.isSafeInteger(t)||t<=0||t>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+t)}function If(t,e){Af(t,e);const r=2**t;return{windows:Math.ceil(e/t)+1,windowSize:2**(t-1),mask:Xu(t),maxNumber:r,shiftBy:BigInt(t)}}function Pf(t,e,r){const{windowSize:n,mask:i,maxNumber:o,shiftBy:a}=r;let s=Number(t&i),u=t>>a;s>n&&(s-=o,u+=kf);const f=e*n;return{nextN:u,offset:f+Math.abs(s)-1,isZero:0===s,isNeg:s<0,isNegF:e%2!=0,offsetF:f}}const xf=new WeakMap,Bf=new WeakMap;function Rf(t){return Bf.get(t)||1}function Uf(t){if(t!==Ef)throw new Error("invalid wNAF")}class Nf{constructor(t,e){this.BASE=t.BASE,this.ZERO=t.ZERO,this.Fn=t.Fn,this.bits=e}_unsafeLadder(t,e,r=this.ZERO){let n=t;for(;e>Ef;)e&kf&&(r=r.add(n)),n=n.double(),e>>=kf;return r}precomputeWindow(t,e){const{windows:r,windowSize:n}=If(e,this.bits),i=[];let o=t,a=o;for(let t=0;t<r;t++){a=o,i.push(a);for(let t=1;t<n;t++)a=a.add(o),i.push(a);o=a.double()}return i}wNAF(t,e,r){if(!this.Fn.isValid(r))throw new Error("invalid scalar");let n=this.ZERO,i=this.BASE;const o=If(t,this.bits);for(let t=0;t<o.windows;t++){const{nextN:a,offset:s,isZero:u,isNeg:f,isNegF:c,offsetF:l}=Pf(r,t,o);r=a,u?i=i.add(Of(c,e[l])):n=n.add(Of(f,e[s]))}return Uf(r),{p:n,f:i}}wNAFUnsafe(t,e,r,n=this.ZERO){const i=If(t,this.bits);for(let t=0;t<i.windows&&r!==Ef;t++){const{nextN:o,offset:a,isZero:s,isNeg:u}=Pf(r,t,i);if(r=o,!s){const t=e[a];n=n.add(u?t.negate():t)}}return Uf(r),n}getPrecomputes(t,e,r){let n=xf.get(e);return n||(n=this.precomputeWindow(e,t),1!==t&&("function"==typeof r&&(n=r(n)),xf.set(e,n))),n}cached(t,e,r){const n=Rf(t);return this.wNAF(n,this.getPrecomputes(n,t,r),e)}unsafe(t,e,r,n){const i=Rf(t);return 1===i?this._unsafeLadder(t,e,n):this.wNAFUnsafe(i,this.getPrecomputes(i,t,r),e,n)}createCache(t,e){Af(e,this.bits),Bf.set(t,e),xf.delete(t)}hasCache(t){return 1!==Rf(t)}}function jf(t,e,r){if(e){if(e.ORDER!==t)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return function(t){Yu(t,bf.reduce((t,e)=>(t[e]="function",t),{ORDER:"bigint",MASK:"bigint",BYTES:"number",BITS:"number"}))}(e),e}return mf(t,{isLE:r})}const Lf=(t,e)=>(t+(t>=0?e:-e)/Vf)/e;function Cf(t){if(!["compact","recovered","der"].includes(t))throw new Error('Signature format must be "compact", "recovered", or "der"');return t}function Ff(t,e){const r={};for(let n of Object.keys(e))r[n]=void 0===t[n]?e[n]:t[n];return Cu(r.lowS,"lowS"),Cu(r.prehash,"prehash"),void 0!==r.format&&Cf(r.format),r}class Df extends Error{constructor(t=""){super(t)}}const Hf={Err:Df,_tlv:{encode:(t,e)=>{const{Err:r}=Hf;if(t<0||t>256)throw new r("tlv.encode: wrong tag");if(1&e.length)throw new r("tlv.encode: unpadded data");const n=e.length/2,i=Du(n);if(i.length/2&128)throw new r("tlv.encode: long form length too big");const o=n>127?Du(i.length/2|128):"";return Du(t)+o+i+e},decode(t,e){const{Err:r}=Hf;let n=0;if(t<0||t>256)throw new r("tlv.encode: wrong tag");if(e.length<2||e[n++]!==t)throw new r("tlv.decode: wrong tlv");const i=e[n++];let o=0;if(128&i){const t=127&i;if(!t)throw new r("tlv.decode(long): indefinite length not supported");if(t>4)throw new r("tlv.decode(long): byte length is too big");const a=e.subarray(n,n+t);if(a.length!==t)throw new r("tlv.decode: length bytes not complete");if(0===a[0])throw new r("tlv.decode(long): zero leftmost byte");for(const t of a)o=o<<8|t;if(n+=t,o<128)throw new r("tlv.decode(long): not minimal encoding")}else o=i;const a=e.subarray(n,n+o);if(a.length!==o)throw new r("tlv.decode: wrong value length");return{v:a,l:e.subarray(n+o)}}},_int:{encode(t){const{Err:e}=Hf;if(t<Mf)throw new e("integer: negative integers are not allowed");let r=Du(t);if(8&Number.parseInt(r[0],16)&&(r="00"+r),1&r.length)throw new e("unexpected DER parsing assertion: unpadded hex");return r},decode(t){const{Err:e}=Hf;if(128&t[0])throw new e("invalid signature integer: negative");if(0===t[0]&&!(128&t[1]))throw new e("invalid signature integer: unnecessary leading zero");return Mu(t)}},toSig(t){const{Err:e,_int:r,_tlv:n}=Hf,i=Gu("signature",t),{v:o,l:a}=n.decode(48,i);if(a.length)throw new e("invalid signature: left bytes after parsing");const{v:s,l:u}=n.decode(2,o),{v:f,l:c}=n.decode(2,u);if(c.length)throw new e("invalid signature: left bytes after parsing");return{r:r.decode(s),s:r.decode(f)}},hexFromSig(t){const{_tlv:e,_int:r}=Hf,n=e.encode(2,r.encode(t.r))+e.encode(2,r.encode(t.s));return e.encode(48,n)}},Mf=BigInt(0),Kf=BigInt(1),Vf=BigInt(2),Wf=BigInt(3),Gf=BigInt(4);function qf(t,e){const{BYTES:r}=t;let n;if("bigint"==typeof e)n=e;else{let i=Gu("private key",e);try{n=t.fromBytes(i)}catch(t){throw new Error(`invalid private key: expected ui8a of size ${r}, got ${typeof e}`)}}if(!t.isValidNot0(n))throw new Error("invalid private key: out of range [1..N-1]");return n}function zf(t,e={}){const r=function(t,e,r={},n){if(void 0===n&&(n="edwards"===t),!e||"object"!=typeof e)throw new Error(`expected valid ${t} CURVE object`);for(const t of["p","n","h"]){const r=e[t];if(!("bigint"==typeof r&&r>Ef))throw new Error(`CURVE.${t} must be positive bigint`)}const i=jf(e.p,r.Fp,n),o=jf(e.n,r.Fn,n),a=["Gx","Gy","a","weierstrass"===t?"b":"d"];for(const t of a)if(!i.isValid(e[t]))throw new Error(`CURVE.${t} must be valid field element of CURVE.Fp`);return{CURVE:e=Object.freeze(Object.assign({},e)),Fp:i,Fn:o}}("weierstrass",t,e),{Fp:n,Fn:i}=r;let o=r.CURVE;const{h:a,n:s}=o;Yu(e,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object",wrapPrivateKey:"boolean"});const{endo:u}=e;if(u&&(!n.is0(o.a)||"bigint"!=typeof u.beta||!Array.isArray(u.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');const f=Xf(n,i);function c(){if(!n.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}const l=e.toBytes||function(t,e,r){const{x:i,y:o}=e.toAffine(),a=n.toBytes(i);return Cu(r,"isCompressed"),r?(c(),Aa(Zf(!n.isOdd(o)),a)):Aa(Uint8Array.of(4),a,n.toBytes(o))},h=e.fromBytes||function(t){Fu(t,void 0,"Point");const{publicKey:e,publicKeyUncompressed:r}=f,i=t.length,o=t[0],a=t.subarray(1);if(i!==e||2!==o&&3!==o){if(i===r&&4===o){const t=n.BYTES,e=n.fromBytes(a.subarray(0,t)),r=n.fromBytes(a.subarray(t,2*t));if(!d(e,r))throw new Error("bad point: is not on curve");return{x:e,y:r}}throw new Error(`bad point: got length ${i}, expected compressed=${e} or uncompressed=${r}`)}{const t=n.fromBytes(a);if(!n.isValid(t))throw new Error("bad point: is not on curve, wrong x");const e=p(t);let r;try{r=n.sqrt(e)}catch(t){const e=t instanceof Error?": "+t.message:"";throw new Error("bad point: is not on curve, sqrt error"+e)}return c(),!(1&~o)!==n.isOdd(r)&&(r=n.neg(r)),{x:t,y:r}}};function p(t){const e=n.sqr(t),r=n.mul(e,t);return n.add(n.add(r,n.mul(t,o.a)),o.b)}function d(t,e){const r=n.sqr(e),i=p(t);return n.eql(r,i)}if(!d(o.Gx,o.Gy))throw new Error("bad curve params: generator point");const y=n.mul(n.pow(o.a,Wf),Gf),b=n.mul(n.sqr(o.b),BigInt(27));if(n.is0(n.add(y,b)))throw new Error("bad curve params: a or b");function g(t,e,r=!1){if(!n.isValid(e)||r&&n.is0(e))throw new Error(`bad point coordinate ${t}`);return e}function v(t){if(!(t instanceof E))throw new Error("ProjectivePoint expected")}function w(t){if(!u||!u.basises)throw new Error("no endo");return function(t,e,r){const[[n,i],[o,a]]=e,s=Lf(a*t,r),u=Lf(-i*t,r);let f=t-s*n-u*o,c=-s*i-u*a;const l=f<Mf,h=c<Mf;l&&(f=-f),h&&(c=-c);const p=Xu(Math.ceil(Zu(r)/2))+Kf;if(f<Mf||f>=p||c<Mf||c>=p)throw new Error("splitScalar (endomorphism): failed, k="+t);return{k1neg:l,k1:f,k2neg:h,k2:c}}(t,u.basises,i.ORDER)}const m=$u((t,e)=>{const{X:r,Y:i,Z:o}=t;if(n.eql(o,n.ONE))return{x:r,y:i};const a=t.is0();null==e&&(e=a?n.ONE:n.inv(o));const s=n.mul(r,e),u=n.mul(i,e),f=n.mul(o,e);if(a)return{x:n.ZERO,y:n.ZERO};if(!n.eql(f,n.ONE))throw new Error("invZ was invalid");return{x:s,y:u}}),S=$u(t=>{if(t.is0()){if(e.allowInfinityPoint&&!n.is0(t.Y))return;throw new Error("bad point: ZERO")}const{x:r,y:i}=t.toAffine();if(!n.isValid(r)||!n.isValid(i))throw new Error("bad point: x or y not field elements");if(!d(r,i))throw new Error("bad point: equation left != right");if(!t.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});function _(t,e,r,i,o){return r=new E(n.mul(r.X,t),r.Y,r.Z),e=Of(i,e),r=Of(o,r),e.add(r)}class E{constructor(t,e,r){this.X=g("x",t),this.Y=g("y",e,!0),this.Z=g("z",r),Object.freeze(this)}static CURVE(){return o}static fromAffine(t){const{x:e,y:r}=t||{};if(!t||!n.isValid(e)||!n.isValid(r))throw new Error("invalid affine point");if(t instanceof E)throw new Error("projective point not allowed");return n.is0(e)&&n.is0(r)?E.ZERO:new E(e,r,n.ONE)}static fromBytes(t){const e=E.fromAffine(h(Fu(t,void 0,"point")));return e.assertValidity(),e}static fromHex(t){return E.fromBytes(Gu("pointHex",t))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(t=8,e=!0){return O.createCache(this,t),e||this.multiply(Wf),this}assertValidity(){S(this)}hasEvenY(){const{y:t}=this.toAffine();if(!n.isOdd)throw new Error("Field doesn't support isOdd");return!n.isOdd(t)}equals(t){v(t);const{X:e,Y:r,Z:i}=this,{X:o,Y:a,Z:s}=t,u=n.eql(n.mul(e,s),n.mul(o,i)),f=n.eql(n.mul(r,s),n.mul(a,i));return u&&f}negate(){return new E(this.X,n.neg(this.Y),this.Z)}double(){const{a:t,b:e}=o,r=n.mul(e,Wf),{X:i,Y:a,Z:s}=this;let u=n.ZERO,f=n.ZERO,c=n.ZERO,l=n.mul(i,i),h=n.mul(a,a),p=n.mul(s,s),d=n.mul(i,a);return d=n.add(d,d),c=n.mul(i,s),c=n.add(c,c),u=n.mul(t,c),f=n.mul(r,p),f=n.add(u,f),u=n.sub(h,f),f=n.add(h,f),f=n.mul(u,f),u=n.mul(d,u),c=n.mul(r,c),p=n.mul(t,p),d=n.sub(l,p),d=n.mul(t,d),d=n.add(d,c),c=n.add(l,l),l=n.add(c,l),l=n.add(l,p),l=n.mul(l,d),f=n.add(f,l),p=n.mul(a,s),p=n.add(p,p),l=n.mul(p,d),u=n.sub(u,l),c=n.mul(p,h),c=n.add(c,c),c=n.add(c,c),new E(u,f,c)}add(t){v(t);const{X:e,Y:r,Z:i}=this,{X:a,Y:s,Z:u}=t;let f=n.ZERO,c=n.ZERO,l=n.ZERO;const h=o.a,p=n.mul(o.b,Wf);let d=n.mul(e,a),y=n.mul(r,s),b=n.mul(i,u),g=n.add(e,r),w=n.add(a,s);g=n.mul(g,w),w=n.add(d,y),g=n.sub(g,w),w=n.add(e,i);let m=n.add(a,u);return w=n.mul(w,m),m=n.add(d,b),w=n.sub(w,m),m=n.add(r,i),f=n.add(s,u),m=n.mul(m,f),f=n.add(y,b),m=n.sub(m,f),l=n.mul(h,w),f=n.mul(p,b),l=n.add(f,l),f=n.sub(y,l),l=n.add(y,l),c=n.mul(f,l),y=n.add(d,d),y=n.add(y,d),b=n.mul(h,b),w=n.mul(p,w),y=n.add(y,b),b=n.sub(d,b),b=n.mul(h,b),w=n.add(w,b),d=n.mul(y,w),c=n.add(c,d),d=n.mul(m,w),f=n.mul(g,f),f=n.sub(f,d),d=n.mul(g,y),l=n.mul(m,l),l=n.add(l,d),new E(f,c,l)}subtract(t){return this.add(t.negate())}is0(){return this.equals(E.ZERO)}multiply(t){const{endo:r}=e;if(!i.isValidNot0(t))throw new Error("invalid scalar: out of range");let n,o;const a=t=>O.cached(this,t,t=>Tf(E,t));if(r){const{k1neg:e,k1:i,k2neg:s,k2:u}=w(t),{p:f,f:c}=a(i),{p:l,f:h}=a(u);o=c.add(h),n=_(r.beta,f,l,e,s)}else{const{p:e,f:r}=a(t);n=e,o=r}return Tf(E,[n,o])[0]}multiplyUnsafe(t){const{endo:r}=e,n=this;if(!i.isValid(t))throw new Error("invalid scalar: out of range");if(t===Mf||n.is0())return E.ZERO;if(t===Kf)return n;if(O.hasCache(this))return this.multiply(t);if(r){const{k1neg:e,k1:i,k2neg:o,k2:a}=w(t),{p1:s,p2:u}=function(t,e,r,n){let i=e,o=t.ZERO,a=t.ZERO;for(;r>Ef||n>Ef;)r&kf&&(o=o.add(i)),n&kf&&(a=a.add(i)),i=i.double(),r>>=kf,n>>=kf;return{p1:o,p2:a}}(E,n,i,a);return _(r.beta,s,u,e,o)}return O.unsafe(n,t)}multiplyAndAddUnsafe(t,e,r){const n=this.multiplyUnsafe(e).add(t.multiplyUnsafe(r));return n.is0()?void 0:n}toAffine(t){return m(this,t)}isTorsionFree(){const{isTorsionFree:t}=e;return a===Kf||(t?t(E,this):O.unsafe(this,s).is0())}clearCofactor(){const{clearCofactor:t}=e;return a===Kf?this:t?t(E,this):this.multiplyUnsafe(a)}isSmallOrder(){return this.multiplyUnsafe(a).is0()}toBytes(t=!0){return Cu(t,"isCompressed"),this.assertValidity(),l(E,this,t)}toHex(t=!0){return _a(this.toBytes(t))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}get px(){return this.X}get py(){return this.X}get pz(){return this.Z}toRawBytes(t=!0){return this.toBytes(t)}_setWindowSize(t){this.precompute(t)}static normalizeZ(t){return Tf(E,t)}static msm(t,e){return function(t,e,r,n){(function(t,e){if(!Array.isArray(t))throw new Error("array expected");t.forEach((t,r)=>{if(!(t instanceof e))throw new Error("invalid point at index "+r)})})(r,t),function(t,e){if(!Array.isArray(t))throw new Error("array of scalars expected");t.forEach((t,r)=>{if(!e.isValid(t))throw new Error("invalid scalar at index "+r)})}(n,e);const i=r.length,o=n.length;if(i!==o)throw new Error("arrays of points and scalars must have equal length");const a=t.ZERO,s=Zu(BigInt(i));let u=1;s>12?u=s-3:s>4?u=s-2:s>0&&(u=2);const f=Xu(u),c=new Array(Number(f)+1).fill(a);let l=a;for(let t=Math.floor((e.BITS-1)/u)*u;t>=0;t-=u){c.fill(a);for(let e=0;e<o;e++){const i=n[e],o=Number(i>>BigInt(t)&f);c[o]=c[o].add(r[e])}let e=a;for(let t=c.length-1,r=a;t>0;t--)r=r.add(c[t]),e=e.add(r);if(l=l.add(e),0!==t)for(let t=0;t<u;t++)l=l.double()}return l}(E,i,t,e)}static fromPrivateKey(t){return E.BASE.multiply(qf(i,t))}}E.BASE=new E(o.Gx,o.Gy,n.ONE),E.ZERO=new E(n.ZERO,n.ONE,n.ZERO),E.Fp=n,E.Fn=i;const k=i.BITS,O=new Nf(E,e.endo?Math.ceil(k/2):k);return E.BASE.precompute(8),E}function Zf(t){return Uint8Array.of(t?2:3)}function Xf(t,e){return{secretKey:e.BYTES,publicKey:1+t.BYTES,publicKeyUncompressed:1+2*t.BYTES,publicKeyHasPrefix:!0,signature:2*e.BYTES}}function Yf(t,e,r={}){da(e),Yu(r,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});const n=r.randomBytes||xa,i=r.hmac||((t,...r)=>Ra(e,t,Aa(...r))),{Fp:o,Fn:a}=t,{ORDER:s,BITS:u}=a,{keygen:f,getPublicKey:c,getSharedSecret:l,utils:h,lengths:p}=function(t,e={}){const{Fn:r}=t,n=e.randomBytes||xa,i=Object.assign(Xf(t.Fp,r),{seed:_f(r.ORDER)});function o(t){try{return!!qf(r,t)}catch(t){return!1}}function a(t=n(i.seed)){return function(t,e,r=!1){const n=t.length,i=Sf(e),o=_f(e);if(n<16||n<o||n>1024)throw new Error("expected "+o+"-1024 bytes of input, got "+n);const a=ff(r?Ku(t):Mu(t),e-Qu)+Qu;return r?Wu(a,i):Vu(a,i)}(Fu(t,i.seed,"seed"),r.ORDER)}function s(e,n=!0){return t.BASE.multiply(qf(r,e)).toBytes(n)}function u(e){if("bigint"==typeof e)return!1;if(e instanceof t)return!0;const{secretKey:n,publicKey:o,publicKeyUncompressed:a}=i;if(r.allowedLengths||n===o)return;const s=Gu("key",e).length;return s===o||s===a}const f={isValidSecretKey:o,isValidPublicKey:function(e,r){const{publicKey:n,publicKeyUncompressed:o}=i;try{const i=e.length;return!(!0===r&&i!==n||!1===r&&i!==o||!t.fromBytes(e))}catch(t){return!1}},randomSecretKey:a,isValidPrivateKey:o,randomPrivateKey:a,normPrivateKeyToScalar:t=>qf(r,t),precompute:(e=8,r=t.BASE)=>r.precompute(e,!1)};return Object.freeze({getPublicKey:s,getSharedSecret:function(e,n,i=!0){if(!0===u(e))throw new Error("first arg must be private key");if(!1===u(n))throw new Error("second arg must be public key");const o=qf(r,e);return t.fromHex(n).multiply(o).toBytes(i)},keygen:function(t){const e=a(t);return{secretKey:e,publicKey:s(e)}},Point:t,utils:f,lengths:i})}(t,r),d={prehash:!1,lowS:"boolean"==typeof r.lowS&&r.lowS,format:void 0,extraEntropy:!1},y="compact";function b(t){return t>s>>Kf}function g(t,e){if(!a.isValidNot0(e))throw new Error(`invalid signature ${t}: out of range 1..Point.Fn.ORDER`);return e}class v{constructor(t,e,r){this.r=g("r",t),this.s=g("s",e),null!=r&&(this.recovery=r),Object.freeze(this)}static fromBytes(t,e=y){let r;if(function(t,e){Cf(e);const r=p.signature;Fu(t,"compact"===e?r:"recovered"===e?r+1:void 0,`${e} signature`)}(t,e),"der"===e){const{r:e,s:r}=Hf.toSig(Fu(t));return new v(e,r)}"recovered"===e&&(r=t[0],e="compact",t=t.subarray(1));const n=a.BYTES,i=t.subarray(0,n),o=t.subarray(n,2*n);return new v(a.fromBytes(i),a.fromBytes(o),r)}static fromHex(t,e){return this.fromBytes(ka(t),e)}addRecoveryBit(t){return new v(this.r,this.s,t)}recoverPublicKey(e){const r=o.ORDER,{r:n,s:i,recovery:u}=this;if(null==u||![0,1,2,3].includes(u))throw new Error("recovery id invalid");if(s*Vf<r&&u>1)throw new Error("recovery id is ambiguous for h>1 curve");const f=2===u||3===u?n+s:n;if(!o.isValid(f))throw new Error("recovery id 2 or 3 invalid");const c=o.toBytes(f),l=t.fromBytes(Aa(Zf(!(1&u)),c)),h=a.inv(f),p=m(Gu("msgHash",e)),d=a.create(-p*h),y=a.create(i*h),b=t.BASE.multiplyUnsafe(d).add(l.multiplyUnsafe(y));if(b.is0())throw new Error("point at infinify");return b.assertValidity(),b}hasHighS(){return b(this.s)}toBytes(t=y){if(Cf(t),"der"===t)return ka(Hf.hexFromSig(this));const e=a.toBytes(this.r),r=a.toBytes(this.s);if("recovered"===t){if(null==this.recovery)throw new Error("recovery bit must be present");return Aa(Uint8Array.of(this.recovery),e,r)}return Aa(e,r)}toHex(t){return _a(this.toBytes(t))}assertValidity(){}static fromCompact(t){return v.fromBytes(Gu("sig",t),"compact")}static fromDER(t){return v.fromBytes(Gu("sig",t),"der")}normalizeS(){return this.hasHighS()?new v(this.r,a.neg(this.s),this.recovery):this}toDERRawBytes(){return this.toBytes("der")}toDERHex(){return _a(this.toBytes("der"))}toCompactRawBytes(){return this.toBytes("compact")}toCompactHex(){return _a(this.toBytes("compact"))}}const w=r.bits2int||function(t){if(t.length>8192)throw new Error("input is too large");const e=Mu(t),r=8*t.length-u;return r>0?e>>BigInt(r):e},m=r.bits2int_modN||function(t){return a.create(w(t))},S=Xu(u);function _(t){return zu("num < 2^"+u,t,Mf,S),a.toBytes(t)}function E(t,r){return Fu(t,void 0,"message"),r?Fu(e(t),void 0,"prehashed message"):t}return Object.freeze({keygen:f,getPublicKey:c,getSharedSecret:l,utils:h,lengths:p,Point:t,sign:function(r,o,s={}){r=Gu("message",r);const{seed:u,k2sig:f}=function(e,r,i){if(["recovered","canonical"].some(t=>t in i))throw new Error("sign() legacy options not supported");const{lowS:o,prehash:s,extraEntropy:u}=Ff(i,d);e=E(e,s);const f=m(e),c=qf(a,r),l=[_(c),_(f)];if(null!=u&&!1!==u){const t=!0===u?n(p.secretKey):u;l.push(Gu("extraEntropy",t))}const h=Aa(...l),y=f;return{seed:h,k2sig:function(e){const r=w(e);if(!a.isValidNot0(r))return;const n=a.inv(r),i=t.BASE.multiply(r).toAffine(),s=a.create(i.x);if(s===Mf)return;const u=a.create(n*a.create(y+s*c));if(u===Mf)return;let f=(i.x===s?0:2)|Number(i.y&Kf),l=u;return o&&b(u)&&(l=a.neg(u),f^=1),new v(s,l,f)}}}(r,o,s);return function(t,e,r){if("number"!=typeof t||t<2)throw new Error("hashLen must be a number");if("number"!=typeof e||e<2)throw new Error("qByteLen must be a number");if("function"!=typeof r)throw new Error("hmacFn must be a function");const n=t=>new Uint8Array(t),i=t=>Uint8Array.of(t);let o=n(t),a=n(t),s=0;const u=()=>{o.fill(1),a.fill(0),s=0},f=(...t)=>r(a,o,...t),c=(t=n(0))=>{a=f(i(0),t),o=f(),0!==t.length&&(a=f(i(1),t),o=f())},l=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let t=0;const r=[];for(;t<e;){o=f();const e=o.slice();r.push(e),t+=o.length}return Aa(...r)};return(t,e)=>{let r;for(u(),c(t);!(r=e(l()));)c();return u(),r}}(e.outputLen,a.BYTES,i)(u,f)},verify:function(e,r,n,i={}){const{lowS:o,prehash:s,format:u}=Ff(i,d);if(n=Gu("publicKey",n),r=E(Gu("message",r),s),"strict"in i)throw new Error("options.strict was renamed to lowS");const f=void 0===u?function(t){let e;const r="string"==typeof t||la(t),n=!r&&null!==t&&"object"==typeof t&&"bigint"==typeof t.r&&"bigint"==typeof t.s;if(!r&&!n)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");if(n)e=new v(t.r,t.s);else if(r){try{e=v.fromBytes(Gu("sig",t),"der")}catch(t){if(!(t instanceof Hf.Err))throw t}if(!e)try{e=v.fromBytes(Gu("sig",t),"compact")}catch(t){return!1}}return e||!1}(e):v.fromBytes(Gu("sig",e),u);if(!1===f)return!1;try{const e=t.fromBytes(n);if(o&&f.hasHighS())return!1;const{r:i,s}=f,u=m(r),c=a.inv(s),l=a.create(u*c),h=a.create(i*c),p=t.BASE.multiplyUnsafe(l).add(e.multiplyUnsafe(h));return!p.is0()&&a.create(p.x)===i}catch(t){return!1}},recoverPublicKey:function(t,e,r={}){const{prehash:n}=Ff(r,d);return e=E(e,n),v.fromBytes(t,"recovered").recoverPublicKey(e).toBytes()},Signature:v,hash:e})}function $f(t){const{CURVE:e,curveOpts:r,hash:n,ecdsaOpts:i}=function(t){const{CURVE:e,curveOpts:r}=function(t){const e={a:t.a,b:t.b,p:t.Fp.ORDER,n:t.n,h:t.h,Gx:t.Gx,Gy:t.Gy},r=t.Fp;let n=t.allowedPrivateKeyLengths?Array.from(new Set(t.allowedPrivateKeyLengths.map(t=>Math.ceil(t/2)))):void 0;return{CURVE:e,curveOpts:{Fp:r,Fn:mf(e.n,{BITS:t.nBitLength,allowedLengths:n,modFromBytes:t.wrapPrivateKey}),allowInfinityPoint:t.allowInfinityPoint,endo:t.endo,isTorsionFree:t.isTorsionFree,clearCofactor:t.clearCofactor,fromBytes:t.fromBytes,toBytes:t.toBytes}}}(t),n={hmac:t.hmac,randomBytes:t.randomBytes,lowS:t.lowS,bits2int:t.bits2int,bits2int_modN:t.bits2int_modN};return{CURVE:e,curveOpts:r,hash:t.hash,ecdsaOpts:n}}(t);return function(t,e){const r=e.Point;return Object.assign({},e,{ProjectivePoint:r,CURVE:Object.assign({},t,wf(r.Fn.ORDER,r.Fn.BITS))})}(t,Yf(zf(e,r),n,i))}const Jf={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},Qf={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]},tc=BigInt(2),ec=mf(Jf.p,{sqrt:function(t){const e=Jf.p,r=BigInt(3),n=BigInt(6),i=BigInt(11),o=BigInt(22),a=BigInt(23),s=BigInt(44),u=BigInt(88),f=t*t*t%e,c=f*f*t%e,l=cf(c,r,e)*c%e,h=cf(l,r,e)*c%e,p=cf(h,tc,e)*f%e,d=cf(p,i,e)*p%e,y=cf(d,o,e)*d%e,b=cf(y,s,e)*y%e,g=cf(b,u,e)*b%e,v=cf(g,s,e)*y%e,w=cf(v,r,e)*c%e,m=cf(w,a,e)*d%e,S=cf(m,n,e)*f%e,_=cf(S,tc,e);if(!ec.eql(ec.sqr(_),t))throw new Error("Cannot find square root");return _}}),rc=function(t){const e=e=>$f({...t,hash:e});return{...e(ks),create:e}}({...Jf,Fp:ec,lowS:!0,endo:Qf}),nc=Aa,ic=Oa,oc=Mu;var ac=i(8287).Buffer;function sc(t){return sc="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},sc(t)}function uc(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,cc(n.key),n)}}function fc(t,e,r){return(e=cc(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function cc(t){var e=function(t){if("object"!=sc(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=sc(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==sc(e)?e:e+""}ur(fa);var lc=function(t){!function(t){if(Ls(t.isPoint(js("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),Ls(!t.isPoint(js("030000000000000000000000000000000000000000000000000000000000000005"))),Ls(t.isPrivate(js("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),Ls(t.isPrivate(js("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"))),Ls(!t.isPrivate(js("0000000000000000000000000000000000000000000000000000000000000000"))),Ls(!t.isPrivate(js("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"))),Ls(!t.isPrivate(js("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364142"))),Ls(0===Bs(t.pointFromScalar(js("b1121e4088a66a28f5b6b0f5844943ecd9f610196d7bb83b25214b60452c09af")),js("02b07ba9dca9523b7ef4bd97703d43d20399eb698e194704791a25ce77a400df99"))),t.xOnlyPointAddTweak){Ls(null===t.xOnlyPointAddTweak(js("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),js("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140")));let e=t.xOnlyPointAddTweak(js("1617d38ed8d8657da4d4761e8057bc396ea9e4b9d29776d4be096016dbd2509b"),js("a8397a935f0dfceba6ba9618f6451ef4d80637abf4e6af2669fbc9de6a8fd2ac"));Ls(0===Bs(e.xOnlyPubkey,js("e478f99dab91052ab39a33ea35fd5e6e4933f4d28023cd597c9a1f6760346adf"))&&1===e.parity),e=t.xOnlyPointAddTweak(js("2c0b7cf95324a07d05398b240174dc0c2be444d96b159aa6c7f7b1e668680991"),js("823c3cd2142744b075a87eade7e1b8678ba308d566226a0056ca2b7a76f86b47"))}Ls(0===Bs(t.pointAddScalar(js("0379be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),js("0000000000000000000000000000000000000000000000000000000000000003")),js("02c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee5"))),Ls(0===Bs(t.privateAdd(js("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd036413e"),js("0000000000000000000000000000000000000000000000000000000000000002")),js("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"))),t.privateNegate&&(Ls(0===Bs(t.privateNegate(js("0000000000000000000000000000000000000000000000000000000000000001")),js("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"))),Ls(0===Bs(t.privateNegate(js("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd036413e")),js("0000000000000000000000000000000000000000000000000000000000000003"))),Ls(0===Bs(t.privateNegate(js("b1121e4088a66a28f5b6b0f5844943ecd9f610196d7bb83b25214b60452c09af")),js("4eede1bf775995d70a494f0a7bb6bc11e0b8cccd41cce8009ab1132c8b0a3792")))),Ls(0===Bs(t.sign(js("5e9f0a0d593efdcf78ac923bc3313e4e7d408d574354ee2b3288c0da9fbba6ed"),js("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140")),js("54c4a33c6423d689378f160a7ff8b61330444abb58fb470f96ea16d99d4a2fed07082304410efa6b2943111b6a4e0aaa7b7db55a07e9861d1fb3cb1f421044a5"))),Ls(t.verify(js("5e9f0a0d593efdcf78ac923bc3313e4e7d408d574354ee2b3288c0da9fbba6ed"),js("0379be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),js("54c4a33c6423d689378f160a7ff8b61330444abb58fb470f96ea16d99d4a2fed07082304410efa6b2943111b6a4e0aaa7b7db55a07e9861d1fb3cb1f421044a5"))),t.signSchnorr&&Ls(0===Bs(t.signSchnorr(js("7e2d58d8b3bcdf1abadec7829054f90dda9805aab56c77333024b9d0a508b75c"),js("c90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b14e5c9"),js("c87aa53824b4d7ae2eb035a2b5bbbccc080e76cdc6d1692c4b0b62d798e6d906")),js("5831aaeed7b44bb74e5eab94ba9d4294c49bcf2a60728d8b4c200f50dd313c1bab745879a5ad954a72c45a91c3a51d3c7adea98d82f8481e0e1e03674a6f3fb7"))),t.verifySchnorr&&Ls(t.verifySchnorr(js("7e2d58d8b3bcdf1abadec7829054f90dda9805aab56c77333024b9d0a508b75c"),js("dd308afec5777e13121fa72b9cc1b7cc0139715309b086c960e18fd969774eb8"),js("5831aaeed7b44bb74e5eab94ba9d4294c49bcf2a60728d8b4c200f50dd313c1bab745879a5ad954a72c45a91c3a51d3c7adea98d82f8481e0e1e03674a6f3fb7")))}(t);const e={messagePrefix:"Bitcoin Signed Message:\n",bech32:"bc",bip32:{public:76067358,private:76066276},pubKeyHash:0,scriptHash:5,wif:128},r=2147483648;class n{__D;__Q;lowR=!1;constructor(t,e){this.__D=t,this.__Q=e}get publicKey(){return void 0===this.__Q&&(this.__Q=t.pointFromScalar(this.__D,!0)),this.__Q}get privateKey(){return this.__D}sign(e,r){if(!this.privateKey)throw new Error("Missing private key");if(void 0===r&&(r=this.lowR),!1===r)return t.sign(e,this.privateKey);{let r=t.sign(e,this.privateKey);const n=new Uint8Array(32);let i=0;for(;r[0]>127;)i++,Us(n,0,i,"LE"),r=t.sign(e,this.privateKey,n);return r}}signSchnorr(e){if(!this.privateKey)throw new Error("Missing private key");if(!t.signSchnorr)throw new Error("signSchnorr not supported by ecc library");return t.signSchnorr(e,this.privateKey)}verify(e,r){return t.verify(e,this.publicKey,r)}verifySchnorr(e,r){if(!t.verifySchnorr)throw new Error("verifySchnorr not supported by ecc library");return t.verifySchnorr(e,this.publicKey.subarray(1,33),r)}}class i extends n{chainCode;network;__DEPTH;__INDEX;__PARENT_FINGERPRINT;constructor(t,e,r,n,i=0,o=0,a=0){super(t,e),this.chainCode=r,this.network=n,this.__DEPTH=i,this.__INDEX=o,this.__PARENT_FINGERPRINT=a,_u(Pu,n)}get depth(){return this.__DEPTH}get index(){return this.__INDEX}get parentFingerprint(){return this.__PARENT_FINGERPRINT}get identifier(){return function(t){return Ja(Os(t))}(this.publicKey)}get fingerprint(){return this.identifier.slice(0,4)}get compressed(){return!0}isNeutered(){return void 0===this.__D}neutered(){return s(this.publicKey,this.chainCode,this.network,this.depth,this.index,this.parentFingerprint)}toBase58(){const t=this.network,e=this.isNeutered()?t.bip32.public:t.bip32.private,r=new Uint8Array(78);return Us(r,0,e,"BE"),Rs(r,4,this.depth),Us(r,5,this.parentFingerprint,"BE"),Us(r,9,this.index,"BE"),r.set(this.chainCode,13),this.isNeutered()?r.set(this.publicKey,45):(Rs(r,45,0),r.set(this.privateKey,46)),n=r,Uu.encode(n);var n}toWIF(){if(!this.privateKey)throw new TypeError("Missing private key");return t={version:this.network.wif,privateKey:this.privateKey,compressed:!0},Ru.encode(function(t,e,r){if(32!==e.length)throw new TypeError("Invalid privateKey length");var n=new Uint8Array(r?34:33);return new DataView(n.buffer).setUint8(0,t),n.set(e,1),r&&(n[33]=1),n}(t.version,t.privateKey,t.compressed));var t}derive(e){_u(ku,e);const n=e>=r,i=new Uint8Array(37);if(n){if(this.isNeutered())throw new TypeError("Missing private key for hardened child key");i[0]=0,i.set(this.privateKey,1),Us(i,33,e,"BE")}else i.set(this.publicKey,0),Us(i,33,e,"BE");const o=As(this.chainCode,i),u=o.slice(0,32),f=o.slice(32);if(!t.isPrivate(u))return this.derive(e+1);let c;if(this.isNeutered()){const r=t.pointAddScalar(this.publicKey,u,!0);if(null===r)return this.derive(e+1);c=s(r,f,this.network,this.depth+1,e,Ns(this.fingerprint,0,"BE"))}else{const r=t.privateAdd(this.privateKey,u);if(null==r)return this.derive(e+1);c=a(r,f,this.network,this.depth+1,e,Ns(this.fingerprint,0,"BE"))}return c}deriveHardened(t){if("number"==typeof _u(Ou,t))return this.derive(t+r);throw new TypeError("Expected UInt31, got "+t)}derivePath(t){_u(xu,t);let e=t.split("/");if("m"===e[0]){if(this.parentFingerprint)throw new TypeError("Expected master, got child");e=e.slice(1)}return e.reduce((t,e)=>{let r;return"'"===e.slice(-1)?(r=parseInt(e.slice(0,-1),10),t.deriveHardened(r)):(r=parseInt(e,10),t.derive(r))},this)}tweak(t){return this.privateKey?this.tweakFromPrivateKey(t):this.tweakFromPublicKey(t)}tweakFromPublicKey(e){const r=32===(i=this.publicKey).length?i:i.slice(1,33);var i;if(!t.xOnlyPointAddTweak)throw new Error("xOnlyPointAddTweak not supported by ecc library");const o=t.xOnlyPointAddTweak(r,e);if(!o||null===o.xOnlyPubkey)throw new Error("Cannot tweak public key!");const a=function(t){const e=t.reduce((t,e)=>t+e.length,0),r=new Uint8Array(e);let n=0;for(const e of t)r.set(e,n),n+=e.length;return r}([Uint8Array.from([0===o.parity?2:3]),o.xOnlyPubkey]);return new n(void 0,a)}tweakFromPrivateKey(e){const r=3===this.publicKey[0]||4===this.publicKey[0]&&!(1&~this.publicKey[64]),i=(()=>{if(r){if(t.privateNegate)return t.privateNegate(this.privateKey);throw new Error("privateNegate not supported by ecc library")}return this.privateKey})(),o=t.privateAdd(i,e);if(!o)throw new Error("Invalid tweaked private key!");return new n(o,void 0)}}function o(t,e,r){return a(t,e,r)}function a(r,n,o,a,s,u){if(_u(Au,r),_u(Au,n),o=o||e,!t.isPrivate(r))throw new TypeError("Private key not in range [1, n)");return new i(r,void 0,n,o,a,s,u)}function s(r,n,o,a,s,u){if(_u(Iu,r),_u(Au,n),o=o||e,!t.isPoint(r))throw new TypeError("Point is not on the curve");return new i(void 0,r,n,o,a,s,u)}return{fromSeed:function(t,r){if(_u(wu(Uint8Array),t),t.length<16)throw new TypeError("Seed should be at least 128 bits");if(t.length>64)throw new TypeError("Seed should be at most 512 bits");r=r||e;const n=As(xs.encode("Bitcoin seed"),t);return o(n.slice(0,32),n.slice(32),r)},fromBase58:function(t,r){const n=(i=t,Uu.decode(i));var i;if(78!==n.length)throw new TypeError("Invalid buffer length");r=r||e;const o=Ns(n,0,"BE");if(o!==r.bip32.private&&o!==r.bip32.public)throw new TypeError("Invalid network version");const u=n[4],f=Ns(n,5,"BE");if(0===u&&0!==f)throw new TypeError("Invalid parent fingerprint");const c=Ns(n,9,"BE");if(0===u&&0!==c)throw new TypeError("Invalid index");const l=n.slice(13,45);let h;if(o===r.bip32.private){if(0!==n[45])throw new TypeError("Invalid private key");h=a(n.slice(46,78),l,r,u,c,f)}else h=s(n.slice(45,78),l,r,u,c,f);return h},fromPublicKey:function(t,e,r){return s(t,e,r)},fromPrivateKey:o}};if(!lc)throw new Error("Failed to load BIP32 library");var hc=rc.Point,pc=hc.Fn.ORDER,dc=ic("TapTweak"),yc=ks(dc),bc=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)}return function(t,e,r){return r&&uc(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,0,[{key:"fromWIF",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:b.bitcoin;return this.ECPair.fromWIF(t,e)}},{key:"fromPrivateKey",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:b.bitcoin;return this.ECPair.fromPrivateKey(ac.isBuffer(t)?t:ac.from(t),{network:e})}},{key:"fromPublicKey",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:b.bitcoin,r=ac.isBuffer(t)?t:ac.from(t);return this.ECPair.fromPublicKey(r,{network:e})}},{key:"generateMultiSigAddress",value:function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:b.bitcoin,n=this.verifyPubKeys(t,r);if(n.length!==t.length)throw new Error("Contains invalid public keys");var i=k.p2ms({m:e,pubkeys:n,network:r}),o=k.p2wsh({redeem:i,network:r}).address;if(!o)throw new Error("Failed to generate address");return o}},{key:"verifyPubKeys",value:function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:b.bitcoin;return e.map(function(e){var n=t.fromPublicKey(e,r);if(!n)throw new Error("Failed to regenerate key");return ac.from(n.publicKey)})}},{key:"getP2WPKHAddress",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:b.bitcoin,r=k.p2wpkh({pubkey:ac.from(t.publicKey),network:e});if(!r.address)throw new Error("Failed to generate wallet");return r.address}},{key:"tweakedPubKeyToAddress",value:function(e,r){e.startsWith("0x")&&(e=e.slice(2));var n=ac.from(e,"hex");return 32!==n.length&&(n=bi(n)),t.tweakedPubKeyBufferToAddress(n,r)}},{key:"tweakedPubKeyBufferToAddress",value:function(t,e){var r=k.p2tr({pubkey:ac.isBuffer(t)?t:ac.from(t),network:e}).address;if(!r)throw new Error("Failed to generate Taproot address");return r}},{key:"p2op",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:b.bitcoin,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=ac.concat([ac.from([r]),sa.crypto.hash160(ac.from(t))]);if(n.length<2||n.length>40)throw new Error("Witness program must be 2-40 bytes.");return Pe(w.compile([it.OP_16,n]),e)}},{key:"xOnlyTweakedPubKeyToAddress",value:function(t,e){t.startsWith("0x")&&(t=t.slice(2));var r=ac.from(t,"hex"),n=k.p2tr({pubkey:r,network:e}).address;if(!n)throw new Error("Failed to generate Taproot address");return n}},{key:"tweakPublicKey",value:function(t){"string"==typeof t&&t.startsWith("0x")&&(t=t.slice(2));var e=hc.fromHex(t),r=0n==(1n&e.y)?e:e.negate(),n=function(t){return ks(nc(yc,yc,t))}(r.toBytes(!0).subarray(1)),i=ff(oc(n),pc),o=r.add(hc.BASE.multiply(i));return ac.from(o.toBytes(!0))}},{key:"tweakBatchSharedT",value:function(t,e){var r=hc.BASE.multiply(e);return t.map(function(t){var e=hc.fromHex(t);return(e.y%2n==0n?e:e.negate()).add(r).toBytes(!0)})}},{key:"generateWallet",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:b.bitcoin,e=this.ECPair.makeRandom({network:t}),r=this.getP2WPKHAddress(e,t);if(!r)throw new Error("Failed to generate wallet");return{address:r,privateKey:e.toWIF(),publicKey:ac.from(e.publicKey).toString("hex")}}},{key:"verifyContractAddress",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:b.bitcoin;return!!m.toOutputScript(t,e)}},{key:"getLegacySegwitAddress",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:b.bitcoin,r=k.p2sh({redeem:k.p2wpkh({pubkey:ac.from(t.publicKey),network:e}),network:e});if(!r.address)throw new Error("Failed to generate wallet");return r.address}},{key:"getLegacyAddress",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:b.bitcoin,r=k.p2pkh({pubkey:ac.from(t.publicKey),network:e});if(!r.address)throw new Error("Failed to generate wallet");return r.address}},{key:"getP2PKH",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:b.bitcoin,r=k.p2pkh({pubkey:ac.from(t),network:e});if(!r.address)throw new Error("Failed to generate wallet");return r.address}},{key:"getP2PKAddress",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:b.bitcoin,r=k.p2pk({pubkey:ac.from(t.publicKey),network:e});if(!r.output)throw new Error("Failed to generate wallet");return"0x"+r.output.toString("hex")}},{key:"generateRandomKeyPair",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:b.bitcoin;return this.ECPair.makeRandom({network:t})}},{key:"fromSeed",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:b.bitcoin;return this.BIP32.fromSeed(t,e)}},{key:"getTaprootAddress",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:b.bitcoin,r=k.p2tr({internalPubkey:bi(ac.from(t.publicKey)),network:e}).address;if(!r)throw new Error("Failed to generate sender address for transaction");return r}},{key:"getTaprootAddressFromAddress",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:b.bitcoin,r=k.p2tr({address:t,network:e}).address;if(!r)throw new Error("Failed to generate sender address for transaction");return r}},{key:"fromSeedKeyPair",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:b.bitcoin,r=this.BIP32.fromSeed(t,e).privateKey;if(!r)throw new Error("Failed to generate key pair");return this.ECPair.fromPrivateKey(ac.from(r),{network:e})}}])}();fc(bc,"BIP32",lc(fa)),fc(bc,"ECPair",(0,Nu.dg)(fa)),hc.BASE.precompute(8);var gc=32,vc=4,wc=32,mc=16,Sc=8,_c=4,Ec=2,kc=1,Oc=32,Tc=16,Ac=8,Ic=4,Pc=2,xc=1,Bc=1,Rc=i(8287).Buffer;function Uc(t){return Uc="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Uc(t)}function Nc(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,jc(n.key),n)}}function jc(t){var e=function(t){if("object"!=Uc(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Uc(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Uc(e)?e:e+""}var Lc=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)}return function(t,e,r){return r&&Nc(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,0,[{key:"bufferToUint8Array",value:function(t){if(Rc.isBuffer(t)){for(var e=t.byteLength,r=new ArrayBuffer(e),n=new Uint8Array(r),i=0;i<e;++i)n[i]=t[i];return n}return t}},{key:"uint8ArrayToHex",value:function(t){return Rc.from(t.buffer,0,t.byteLength).toString("hex")}},{key:"hexToUint8Array",value:function(t){t.startsWith("0x")&&(t=t.substring(2)),t.length%2!=0&&(t="0"+t);for(var e=t.length/2,r=new Uint8Array(e),n=0;n<e;n++)r[n]=parseInt(t.substring(2*n,2*n+2),16);return r}},{key:"pointerToUint8Array",value:function(e){var r=e.toString(16).padStart(64,"0");return t.hexToUint8Array(r)}},{key:"uint8ArrayToPointer",value:function(e){var r=t.uint8ArrayToHex(e);return BigInt("0x"+r)}},{key:"valueToUint8Array",value:function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:wc,n=e.toString(16).padStart(2*r,"0");return t.hexToUint8Array(n)}},{key:"uint8ArrayToValue",value:function(e){var r=t.uint8ArrayToHex(e);return r?BigInt("0x"+r):BigInt(0)}}])}();function Cc(t){return Cc="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Cc(t)}function Fc(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Hc(n.key),n)}}function Dc(t,e,r){return(e=Hc(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Hc(t){var e=function(t){if("object"!=Cc(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Cc(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Cc(e)?e:e+""}!function(t,e){(e=jc(e))in t?Object.defineProperty(t,e,{value:32,enumerable:!0,configurable:!0,writable:!0}):t[e]=32}(Lc,"EXPECTED_BUFFER_LENGTH");var Mc=function(){return function(t,e){return e&&Fc(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}(function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),Dc(this,"_keys",[]),Dc(this,"_values",[])},[{key:"size",get:function(){return this._keys.length}},{key:"keys",value:function(){return this._keys}},{key:"values",value:function(){return this._values}},{key:"entries",value:function(){for(var t=[],e=0;e<this._keys.length;e++)t.push([this._keys[e],this._values[e]]);return t}},{key:"set",value:function(t,e){var r=this.indexOf(t);-1==r?(this._keys.push(t),this._values.push(e)):this._values[r]=e}},{key:"indexOf",value:function(t){for(var e=0;e<this._keys.length;e++)if(this._keys[e]==t)return e;return-1}},{key:"get",value:function(t){var e=this.indexOf(t);if(-1!=e)return this._values[e]}},{key:"has",value:function(t){return-1!=this.indexOf(t)}},{key:"delete",value:function(t){var e=this.indexOf(t);return-1!=e&&(this._keys.splice(e,1),this._values.splice(e,1),!0)}},{key:"clear",value:function(){this._keys=[],this._values=[]}}])}();function Kc(t){return Kc="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Kc(t)}function Vc(){var t,e,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",i=r.toStringTag||"@@toStringTag";function o(r,n,i,o){var u=n&&n.prototype instanceof s?n:s,f=Object.create(u.prototype);return Wc(f,"_invoke",function(r,n,i){var o,s,u,f=0,c=i||[],l=!1,h={p:0,n:0,v:t,a:p,f:p.bind(t,4),d:function(e,r){return o=e,s=0,u=t,h.n=r,a}};function p(r,n){for(s=r,u=n,e=0;!l&&f&&!i&&e<c.length;e++){var i,o=c[e],p=h.p,d=o[2];r>3?(i=d===n)&&(u=o[(s=o[4])?5:(s=3,3)],o[4]=o[5]=t):o[0]<=p&&((i=r<2&&p<o[1])?(s=0,h.v=n,h.n=o[1]):p<d&&(i=r<3||o[0]>n||n>d)&&(o[4]=r,o[5]=n,h.n=d,s=0))}if(i||r>1)return a;throw l=!0,n}return function(i,c,d){if(f>1)throw TypeError("Generator is already running");for(l&&1===c&&p(c,d),s=c,u=d;(e=s<2?t:u)||!l;){o||(s?s<3?(s>1&&(h.n=-1),p(s,u)):h.n=u:h.v=u);try{if(f=2,o){if(s||(i="next"),e=o[i]){if(!(e=e.call(o,u)))throw TypeError("iterator result is not an object");if(!e.done)return e;u=e.value,s<2&&(s=0)}else 1===s&&(e=o.return)&&e.call(o),s<2&&(u=TypeError("The iterator does not provide a '"+i+"' method"),s=1);o=t}else if((e=(l=h.n<0)?u:r.call(n,h))!==a)break}catch(e){o=t,s=1,u=e}finally{f=1}}return{value:e,done:l}}}(r,i,o),!0),f}var a={};function s(){}function u(){}function f(){}e=Object.getPrototypeOf;var c=[][n]?e(e([][n]())):(Wc(e={},n,function(){return this}),e),l=f.prototype=s.prototype=Object.create(c);function h(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,f):(t.__proto__=f,Wc(t,i,"GeneratorFunction")),t.prototype=Object.create(l),t}return u.prototype=f,Wc(l,"constructor",f),Wc(f,"constructor",u),u.displayName="GeneratorFunction",Wc(f,i,"GeneratorFunction"),Wc(l),Wc(l,i,"Generator"),Wc(l,n,function(){return this}),Wc(l,"toString",function(){return"[object Generator]"}),(Vc=function(){return{w:o,m:h}})()}function Wc(t,e,r,n){var i=Object.defineProperty;try{i({},"",{})}catch(t){i=0}Wc=function(t,e,r,n){function o(e,r){Wc(t,e,function(t){return this._invoke(e,r,t)})}e?i?i(t,e,{value:r,enumerable:!n,configurable:!n,writable:!n}):t[e]=r:(o("next",0),o("throw",1),o("return",2))},Wc(t,e,r,n)}function Gc(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return qc(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?qc(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}function qc(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function zc(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Zc(n.key),n)}}function Zc(t){var e=function(t){if("object"!=Kc(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Kc(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Kc(e)?e:e+""}function Xc(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(Xc=function(){return!!t})()}function Yc(t){return Yc=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Yc(t)}function $c(t,e){return $c=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},$c(t,e)}var Jc=function(){function t(){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),function(t,e,r){return e=Yc(e),function(t,e){if(e&&("object"==Kc(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,Xc()?Reflect.construct(e,r||[],Yc(t).constructor):e.apply(t,r))}(this,t,arguments)}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&$c(t,e)}(t,Mc),function(t,e){return e&&zc(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"set",value:function(t,e){var r=this.indexOf(t);-1==r?(this._keys.push(t),this._values.push(e)):this._values[r]=e}},{key:"indexOf",value:function(t){for(var e=0;e<this._keys.length;e++){var r=this._keys[e];if(t.equals(r))return e}return-1}},{key:"has",value:function(t){for(var e=0;e<this._keys.length;e++)if(t.equals(this._keys[e]))return!0;return!1}},{key:"get",value:function(t){var e=this.indexOf(t);if(-1!=e)return this._values[e]}},{key:"delete",value:function(t){var e=this.indexOf(t);return-1!=e&&(this._keys.splice(e,1),this._values.splice(e,1),!0)}},{key:Symbol.iterator,value:Vc().m(function t(){var e,r,n,i;return Vc().w(function(t){for(;;)switch(t.p=t.n){case 0:e=Gc(this._keys),t.p=1,e.s();case 2:if((r=e.n()).done){t.n=4;break}return n=r.value,t.n=3,[n,this.get(n)];case 3:t.n=2;break;case 4:t.n=6;break;case 5:t.p=5,i=t.v,e.e(i);case 6:return t.p=6,e.f(),t.f(6);case 7:return t.a(2)}},t,this,[[1,5,6,7]])})}])}(),Qc=i(4148);var tl=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if("undefined"!=typeof global)return global;throw new Error("unable to locate global object")}();function el(t){switch(t){case"sha256":return Os.create();case"sha512":return Ts.create()}Qc(!1,"invalid hashing algorithm name","INVALID_ARGUMENT",{argument:"algorithm",value:t})}tl.crypto||tl.msCrypto;var rl=i(8287).Buffer;function nl(t){return nl="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},nl(t)}function il(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,ol(n.key),n)}}function ol(t){var e=function(t){if("object"!=nl(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=nl(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==nl(e)?e:e+""}var al=/^[0-9a-fA-F]+$/,sl=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)}return function(t,e,r){return r&&il(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,0,[{key:"btcToSatoshi",value:function(t){return BigInt(1e8*t)}},{key:"rndBytes",value:function(){var e=t.getSafeRandomValues(64);return rl.from(e)}},{key:"getSafeRandomValues",value:function(t){if(void 0!==globalThis.window&&globalThis.window.crypto&&"function"==typeof globalThis.window.crypto.getRandomValues){var e=new Uint8Array(t);return window.crypto.getRandomValues(e),rl.from(e)}if(globalThis.crypto&&"function"==typeof globalThis.crypto.getRandomValues){var r=new Uint8Array(t);return globalThis.crypto.getRandomValues(r),rl.from(r)}throw console.log("No secure random number generator available. Please upgrade your environment.",globalThis.window.crypto,globalThis.crypto),new Error("No secure random number generator available. Please upgrade your environment.")}},{key:"isValidHex",value:function(t){return al.test(t)}},{key:"opnetHash",value:function(t){var e=el("sha512");e.update(t);var r=e.digest();return"0x".concat(rl.from(r).toString("hex"))}}])}(),ul=i(8287);function fl(t){return fl="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},fl(t)}function cl(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,ll(n.key),n)}}function ll(t){var e=function(t){if("object"!=fl(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=fl(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==fl(e)?e:e+""}var hl,pl=function(){return function(t,e,r){return r&&cl(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)},0,[{key:"isP2WDAUTXO",value:function(t){if(!t.witnessScript)return!1;var e=ul.Buffer.isBuffer(t.witnessScript)?t.witnessScript:ul.Buffer.from(t.witnessScript,"hex");return this.isP2WDAWitnessScript(e)}},{key:"isP2WDAWitnessScript",value:function(t){try{var e=w.decompile(t);if(!e||7!==e.length)return!1;for(var r=0;r<5;r++)if(e[r]!==it.OP_2DROP)return!1;return ul.Buffer.isBuffer(e[5])&&33===e[5].length&&e[6]===it.OP_CHECKSIG}catch(t){return!1}}},{key:"generateP2WDAAddress",value:function(t,e){if(33!==t.length)throw new Error("Public key must be 33 bytes (compressed)");var r=w.compile([it.OP_2DROP,it.OP_2DROP,it.OP_2DROP,it.OP_2DROP,it.OP_2DROP,t,it.OP_CHECKSIG]),n=k.p2wsh({redeem:{output:r},network:e});if(!n.address||!n.output)throw new Error("Failed to generate P2WDA address");return{address:n.address,witnessScript:r,scriptPubKey:n.output}}},{key:"extractPublicKeyFromP2WDA",value:function(t){try{var e=w.decompile(t);if(!e||7!==e.length)return null;for(var r=0;r<5;r++)if(e[r]!==it.OP_2DROP)return null;return ul.Buffer.isBuffer(e[5])&&33===e[5].length&&e[6]===it.OP_CHECKSIG?e[5]:null}catch(t){return null}}},{key:"createSimpleP2WDAWitness",value:function(t,e){for(var r=[t],n=0;n<10;n++)r.push(ul.Buffer.alloc(0));return r.push(e),r}},{key:"validateP2WDASignature",value:function(t,e,r){return 64===e.length}},{key:"estimateP2WDAWitnessSize",value:function(){return 72+(arguments.length>0&&void 0!==arguments[0]?arguments[0]:0)+39+12}},{key:"couldBeP2WDA",value:function(t){return 34===t.length&&0===t[0]&&32===t[1]}}])}(),dl=i(8287).Buffer;function yl(t){return yl="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},yl(t)}function bl(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,gl(n.key),n)}}function gl(t){var e=function(t){if("object"!=yl(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=yl(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==yl(e)?e:e+""}ur(fa),function(t){t.P2PKH="P2PKH",t.P2OP="P2OP",t.P2SH_OR_P2SH_P2WPKH="P2SH_OR_P2SH-P2WPKH",t.P2PK="P2PK",t.P2TR="P2TR",t.P2WPKH="P2WPKH",t.P2WSH="P2WSH",t.P2WDA="P2WDA"}(hl||(hl={}));var vl=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)}return function(t,e,r){return r&&bl(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,0,[{key:"isValidP2TRAddress",value:function(t,e){if(!t||t.length<50)return!1;var r=!1;try{m.toOutputScript(t,e),r=1===m.fromBech32(t).version}catch(t){}return r}},{key:"isP2WPKHAddress",value:function(t,e){if(!t||t.length<20||t.length>50)return!1;var r=!1;try{var n=m.fromBech32(t);m.toOutputScript(t,e),r=0===n.version&&20===n.data.length}catch(t){}return r}},{key:"isP2WDAWitnessScript",value:function(t){return pl.isP2WDAWitnessScript(t)}},{key:"isP2PKHOrP2SH",value:function(t,e){try{var r=m.fromBase58Check(t);return r.version===e.pubKeyHash||r.version===e.scriptHash}catch(t){return!1}}},{key:"isValidPublicKey",value:function(t,e){try{if(t.startsWith("0x")&&(t=t.slice(2)),!sl.isValidHex(t))return!1;if(64===t.length)return!0;var r=dl.from(t,"hex");if(130===t.length&&6===r[0]||7===r[0])return!0;if(66===t.length||130===t.length)return bc.fromPublicKey(r,e),!0}catch(t){return!1}return!1}},{key:"requireRedeemScript",value:function(t,e){try{var r=m.fromBase58Check(t);return r.version!==e.pubKeyHash&&r.version===e.scriptHash}catch(t){return!1}}},{key:"detectAddressType",value:function(e,r){if(t.isValidPublicKey(e,r))return hl.P2PK;try{var n=m.fromBase58Check(e);if(n.version===r.pubKeyHash)return hl.P2PKH;if(n.version===r.scriptHash)return hl.P2SH_OR_P2SH_P2WPKH}catch(t){}try{var i=m.fromBech32(e);if((i.prefix===r.bech32Opnet||i.prefix===r.bech32)&&16===i.version)return hl.P2OP;if(i.prefix===r.bech32){if(0===i.version&&20===i.data.length)return hl.P2WPKH;if(0===i.version&&32===i.data.length)return hl.P2WSH;if(1===i.version&&32===i.data.length)return hl.P2TR}}catch(t){}return null}},{key:"detectAddressTypeWithWitnessScript",value:function(e,r,n){var i=t.detectAddressType(e,r);return i===hl.P2WSH&&n&&t.isP2WDAWitnessScript(n)?hl.P2WDA:i}},{key:"validateP2WDAAddress",value:function(e,r,n){try{if(t.detectAddressType(e,r)!==hl.P2WSH)return{isValid:!1,isPotentiallyP2WDA:!1,isDefinitelyP2WDA:!1,error:"Not a P2WSH address"};if(!n)return{isValid:!0,isPotentiallyP2WDA:!0,isDefinitelyP2WDA:!1};if(!t.isP2WDAWitnessScript(n))return{isValid:!0,isPotentiallyP2WDA:!0,isDefinitelyP2WDA:!1,error:"Witness script does not match P2WDA pattern"};if(k.p2wsh({redeem:{output:n},network:r}).address!==e)return{isValid:!1,isPotentiallyP2WDA:!1,isDefinitelyP2WDA:!1,error:"Witness script does not match address"};var i=pl.extractPublicKeyFromP2WDA(n);return i?{isValid:!0,isPotentiallyP2WDA:!0,isDefinitelyP2WDA:!0,publicKey:i}:{isValid:!1,isPotentiallyP2WDA:!1,isDefinitelyP2WDA:!1,error:"Failed to extract public key from witness script"}}catch(t){return{isValid:!1,isPotentiallyP2WDA:!1,isDefinitelyP2WDA:!1,error:t.message}}}}])}();function wl(t){return wl="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},wl(t)}function ml(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function Sl(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,_l(n.key),n)}}function _l(t){var e=function(t){if("object"!=wl(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=wl(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==wl(e)?e:e+""}var El=0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2fn,kl=function(){return function(t,e){return e&&Sl(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}(function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1e4;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.maxTries=e},[{key:"findOrDeriveValidPoint",value:function(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.maxTries;if(32!==t.length)throw new Error("xBytes must be exactly 32 bytes.");var n=this.bytesToBigInt(t)%El,i=this.isValidX(n);if(e&&null===i)throw new Error("The given x is not a valid curve point.");for(var o=0;null===i;)if(n=(n+1n)%El,i=this.isValidX(n),++o>r)throw new Error("Could not find a valid X point within ".concat(r," increments."));return{x:n,y1:i,y2:(El-i)%El}}},{key:"getCanonicalY",value:function(t,e){return t<e?t:e}},{key:"getHybridPublicKey",value:function(t,e){var r=e%2n==0n?6:7,n=this.bigIntTo32Bytes(t),i=this.bigIntTo32Bytes(e),o=new Uint8Array(65);return o[0]=r,o.set(n,1),o.set(i,33),o}},{key:"isValidX",value:function(t){var e=(this.modPow(t,3n,El)+7n)%El;return this.sqrtModP(e,El)}},{key:"modPow",value:function(t,e,r){for(var n=1n,i=t%r,o=e;o>0;)1n==(1n&o)&&(n=n*i%r),i=i*i%r,o>>=1n;return n}},{key:"sqrtModP",value:function(t,e){var r=this.modPow(t,e+1n>>2n,e);return r*r%e!==t%e?null:r}},{key:"bytesToBigInt",value:function(t){var e,r=0n,n=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return ml(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?ml(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}(t);try{for(n.s();!(e=n.n()).done;){var i=e.value;r=r<<8n|BigInt(i)}}catch(t){n.e(t)}finally{n.f()}return r}},{key:"bigIntTo32Bytes",value:function(t){for(var e=new Uint8Array(32),r=31;r>=0;r--)e[r]=Number(0xffn&t),t>>=8n;return e}}])}(),Ol=i(8287).Buffer;function Tl(t){return Tl="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Tl(t)}function Al(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Il(n.key),n)}}function Il(t){var e=function(t){if("object"!=Tl(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Tl(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Tl(e)?e:e+""}var Pl=function(){return function(t,e){return e&&Al(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}(function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),function(t,e,r){(e=Il(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r}(this,"deriver",new kl)},[{key:"generateHybridKeyFromHash",value:function(t){var e=this.deriver.findOrDeriveValidPoint(this.cloneBuffer(t),!1),r=this.deriver.getCanonicalY(e.y1,e.y2);return Ol.from(this.deriver.getHybridPublicKey(e.x,r))}},{key:"cloneBuffer",value:function(t){return Ol.from(t)}}])}(),xl=new Pl;function Bl(t){return Bl="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Bl(t)}function Rl(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Ul(n.key),n)}}function Ul(t){var e=function(t){if("object"!=Bl(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Bl(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Bl(e)?e:e+""}var Nl=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)}return function(t,e,r){return r&&Rl(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,0,[{key:"generateTimeLockAddress",value:function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:b.bitcoin,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t.CSV_BLOCKS,i=w.compile([w.number.encode(n),it.OP_CHECKSEQUENCEVERIFY,it.OP_DROP,e,it.OP_CHECKSIG]),o=sa.payments.p2wsh({redeem:{output:i},network:r});if(!o.address)throw new Error("Failed to generate P2WSH address");return{address:o.address,witnessScript:i}}}])}();!function(t,e){(e=Ul(e))in t?Object.defineProperty(t,e,{value:75,enumerable:!0,configurable:!0,writable:!0}):t[e]=75}(Nl,"CSV_BLOCKS");var jl=i(8287).Buffer;function Ll(t){return Ll="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Ll(t)}function Cl(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Fl(n.key),n)}}function Fl(t){var e=function(t){if("object"!=Ll(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Ll(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Ll(e)?e:e+""}function Dl(t,e){if(e&&("object"==Ll(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function Hl(t,e,r,n){var i=Ml(Gl(1&n?t.prototype:t),e,r);return 2&n&&"function"==typeof i?function(t){return i.apply(r,t)}:i}function Ml(){return Ml="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,r){var n=function(t,e){for(;!{}.hasOwnProperty.call(t,e)&&null!==(t=Gl(t)););return t}(t,e);if(n){var i=Object.getOwnPropertyDescriptor(n,e);return i.get?i.get.call(arguments.length<3?t:r):i.value}},Ml.apply(null,arguments)}function Kl(t){var e="function"==typeof Map?new Map:void 0;return Kl=function(t){if(null===t||!function(t){try{return-1!==Function.toString.call(t).indexOf("[native code]")}catch(e){return"function"==typeof t}}(t))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,r)}function r(){return function(t,e,r){if(Vl())return Reflect.construct.apply(null,arguments);var n=[null];n.push.apply(n,e);var i=new(t.bind.apply(t,n));return r&&Wl(i,r.prototype),i}(t,arguments,Gl(this).constructor)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),Wl(r,t)},Kl(t)}function Vl(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(Vl=function(){return!!t})()}function Wl(t,e){return Wl=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Wl(t,e)}function Gl(t){return Gl=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Gl(t)}function ql(t,e,r){(function(t,e){if(e.has(t))throw new TypeError("Cannot initialize the same private elements twice on an object")})(t,e),e.set(t,r)}function zl(t,e,r){return t.set(Xl(t,e),r),r}function Zl(t,e){return t.get(Xl(t,e))}function Xl(t,e,r){if("function"==typeof t?t===e:t.has(e))return arguments.length<3?e:r;throw new TypeError("Private element is not present on this object")}var Yl=new WeakMap,$l=new WeakMap,Jl=new WeakMap,Ql=new WeakMap,th=new WeakMap,eh=new WeakMap,rh=new WeakMap,nh=new WeakMap,ih=function(){function t(e){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),r=function(t,e,r){return e=Gl(e),Dl(t,Vl()?Reflect.construct(e,r||[],Gl(t).constructor):e.apply(t,r))}(this,t,[gc]),ql(r,Yl,void 0),ql(r,$l,void 0),ql(r,Jl,void 0),ql(r,Ql,void 0),ql(r,th,void 0),ql(r,eh,void 0),ql(r,rh,void 0),ql(r,nh,void 0),e?(r.set(e),r):Dl(r)}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Wl(t,e)}(t,Kl(Uint8Array)),function(t,e,r){return e&&Cl(t.prototype,e),r&&Cl(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"originalPublicKey",get:function(){return Zl(Ql,this)}},{key:"keyPair",get:function(){if(!Zl(th,this))throw new Error("Public key not set for address");return Zl(th,this)}},{key:"toHex",value:function(){return"0x"+jl.from(this).toString("hex")}},{key:"toBuffer",value:function(){return jl.from(this)}},{key:"toUncompressedHex",value:function(){if(!Zl(eh,this))throw new Error("Public key not set");return"0x"+Zl(eh,this).uncompressed.toString("hex")}},{key:"toUncompressedBuffer",value:function(){if(!Zl(eh,this))throw new Error("Public key not set");return Zl(eh,this).uncompressed}},{key:"toHybridPublicKeyHex",value:function(){if(!Zl(eh,this))throw new Error("Public key not set");return"0x"+Zl(eh,this).hybrid.toString("hex")}},{key:"toHybridPublicKeyBuffer",value:function(){if(!Zl(eh,this))throw new Error("Public key not set");return Zl(eh,this).hybrid}},{key:"originalPublicKeyBuffer",value:function(){if(!Zl(Ql,this))throw new Error("Public key not set");return jl.from(Zl(Ql,this))}},{key:"equals",value:function(t){var e=this;if(t.length!==e.length)return!1;for(var r=0;r<e.length;r++)if(e[r]!==t[r])return!1;return!0}},{key:"lessThan",value:function(t){for(var e=0;e<gc;e++){var r=this[e],n=t[e];if(r<n)return!0;if(r>n)return!1}return!1}},{key:"greaterThan",value:function(t){for(var e=0;e<gc;e++){var r=this[e],n=t[e];if(r>n)return!0;if(r<n)return!1}return!1}},{key:"set",value:function(e){if(![gc,33,65].includes(e.length))throw new Error("Invalid public key length ".concat(e.length));if(e.length===gc){var r=jl.alloc(gc);r.set(e),zl(rh,this,xl.generateHybridKeyFromHash(r)),Hl(t,"set",this,3)([e])}else this.autoFormat(e)}},{key:"isValid",value:function(t){return vl.isValidPublicKey(jl.from(this).toString("hex"),t)}},{key:"p2pk",value:function(){return this.toHex()}},{key:"p2wpkh",value:function(t){return bc.getP2WPKHAddress(this.keyPair,t)}},{key:"p2pkh",value:function(t){return bc.getLegacyAddress(this.keyPair,t)}},{key:"p2shp2wpkh",value:function(t){return bc.getLegacySegwitAddress(this.keyPair,t)}},{key:"toString",value:function(){return this.toHex()}},{key:"toJSON",value:function(){return this.toHex()}},{key:"p2tr",value:function(t){if(Zl(Yl,this)&&Zl(Jl,this)===t)return Zl(Yl,this);var e=bc.tweakedPubKeyBufferToAddress(this,t);if(e)return zl(Jl,this,t),zl(Yl,this,e),e;throw new Error("Public key not set")}},{key:"p2wda",value:function(t){if(Zl(nh,this)&&Zl(Jl,this)===t)return Zl(nh,this);if(!Zl(Ql,this))throw new Error("Cannot create P2WDA address: public key not set");var e=jl.from(Zl(Ql,this));if(33!==e.length)throw new Error("P2WDA requires a compressed public key (33 bytes)");try{var r=pl.generateP2WDAAddress(e,t);return zl(Jl,this,t),zl(nh,this,r),{address:r.address,witnessScript:r.witnessScript}}catch(t){throw new Error("Failed to generate P2WDA address: ".concat(t.message))}}},{key:"toCSV",value:function(t,e){var r=Number(t);if(r<1||r>65535)throw new Error("CSV block number must be between 1 and 65535");if(!Zl(Ql,this))throw new Error("Cannot create CSV address: public key not set");var n=jl.from(Zl(Ql,this));return Nl.generateTimeLockAddress(n,e,r)}},{key:"p2op",value:function(t){if(Zl($l,this)&&Zl(Jl,this)===t)return Zl($l,this);var e=bc.p2op(this,t);if(e)return zl(Jl,this,t),zl($l,this,e),e;throw new Error("Public key not set")}},{key:"toTweakedHybridPublicKeyHex",value:function(){if(!Zl(rh,this))throw new Error("Public key not set");return"0x"+Zl(rh,this).toString("hex")}},{key:"toTweakedHybridPublicKeyBuffer",value:function(){if(!Zl(rh,this))throw new Error("Public key not set");return Zl(rh,this)}},{key:"autoFormat",value:function(e){var r=e[0];3===r||2===r||4!==r&&6!==r&&7!==r||(e=t.uncompressedToCompressed(e)),zl(Ql,this,Uint8Array.from(e)),zl(th,this,bc.fromPublicKey(Zl(Ql,this))),zl(eh,this,Wi(Zl(Ql,this)));var n=bi(bc.tweakPublicKey(jl.from(Zl(Ql,this))));zl(rh,this,xl.generateHybridKeyFromHash(n)),Hl(t,"set",this,3)([n])}}],[{key:"dead",value:function(){return t.fromString("0x04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f")}},{key:"zero",value:function(){return new t}},{key:"fromString",value:function(e){if(!e)throw new Error("Invalid public key");if(e.startsWith("0x")&&(e=e.slice(2)),!sl.isValidHex(e))throw new Error('You must only pass public keys in hexadecimal format. If you have an address such as bc1q... you must convert it to a public key first. Please refer to await provider.getPublicKeyInfo("bc1q..."). If the public key associated with the address is not found, you must force the user to enter the destination public key. It looks like: 0x020373626d317ae8788ce3280b491068610d840c23ecb64c14075bbb9f670af52c.');return new t(jl.from(e,"hex"))}},{key:"wrap",value:function(e){return new t(e)}},{key:"uncompressedToCompressed",value:function(t){var e=Uint8Array.from(t),r=e.slice(1,33),n=e.slice(33),i=jl.alloc(33);return i[0]=2+(1&n[n.length-1]),i.set(r,1),i}}])}();function oh(t){return oh="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},oh(t)}function ah(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,sh(n.key),n)}}function sh(t){var e=function(t){if("object"!=oh(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=oh(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==oh(e)?e:e+""}var uh=function(){return function(t,e,r){return e&&ah(t.prototype,e),r&&ah(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),function(t,e){(e=sh(e))in t?Object.defineProperty(t,e,{value:0,enumerable:!0,configurable:!0,writable:!0}):t[e]=0}(this,"currentOffset"),this.buffer=new DataView(e.buffer,e.byteOffset,e.byteLength)},[{key:"setBuffer",value:function(t){this.buffer=new DataView(t.buffer,t.byteOffset,t.byteLength),this.currentOffset=0}},{key:"length",value:function(){return this.buffer.byteLength}},{key:"bytesLeft",value:function(){return this.buffer.byteLength-this.currentOffset}},{key:"readU8",value:function(){this.verifyEnd(this.currentOffset+kc);var t=this.buffer.getUint8(this.currentOffset);return this.currentOffset+=kc,t}},{key:"readU16",value:function(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];this.verifyEnd(this.currentOffset+Ec);var e=this.buffer.getUint16(this.currentOffset,!t);return this.currentOffset+=Ec,e}},{key:"readU32",value:function(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];this.verifyEnd(this.currentOffset+_c);var e=this.buffer.getUint32(this.currentOffset,!t);return this.currentOffset+=_c,e}},{key:"readU64",value:function(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];this.verifyEnd(this.currentOffset+Sc);var e=this.buffer.getBigUint64(this.currentOffset,!t);return this.currentOffset+=Sc,e}},{key:"readU128",value:function(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],e=this.readBytes(mc),r=e;return t||(r=this.reverseBytes(e)),BigInt("0x"+this.toHexString(r))}},{key:"readU256",value:function(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],e=this.readBytes(wc),r=e;return t||(r=this.reverseBytes(e)),BigInt("0x"+this.toHexString(r))}},{key:"readI128",value:function(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],e=this.readBytes(Tc),r=e;t||(r=this.reverseBytes(e));var n=BigInt("0x"+this.toHexString(r));return 128&r[0]&&(n-=BigInt(1)<<BigInt(128)),n}},{key:"readBoolean",value:function(){return 0!==this.readU8()}},{key:"readSelector",value:function(){return this.readU32(!0)}},{key:"readBytes",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.verifyEnd(this.currentOffset+t);for(var r=new Uint8Array(t),n=0;n<t;n++){var i=this.buffer.getUint8(this.currentOffset++);if(e&&0===i){r=r.subarray(0,n);break}r[n]=i}return r}},{key:"readString",value:function(t){var e=new TextDecoder,r=this.readBytes(t,!1);return e.decode(r)}},{key:"readStringWithLength",value:function(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],e=this.readU32(t);return this.readString(e)}},{key:"readAddress",value:function(){var t=Array.from(this.readBytes(gc));return new ih(t)}},{key:"readBytesWithLength",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],r=this.readU32(e);if(t>0&&r>t)throw new Error("Data length exceeds maximum length.");return this.readBytes(r)}},{key:"readAddressArray",value:function(){for(var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],e=this.readU16(t),r=new Array(e),n=0;n<e;n++)r[n]=this.readAddress();return r}},{key:"readU256Array",value:function(){for(var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],e=this.readU16(t),r=new Array(e),n=0;n<e;n++)r[n]=this.readU256(t);return r}},{key:"readU128Array",value:function(){for(var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],e=this.readU16(t),r=new Array(e),n=0;n<e;n++)r[n]=this.readU128(t);return r}},{key:"readU64Array",value:function(){for(var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],e=this.readU16(t),r=new Array(e),n=0;n<e;n++)r[n]=this.readU64(t);return r}},{key:"readU32Array",value:function(){for(var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],e=this.readU16(t),r=new Array(e),n=0;n<e;n++)r[n]=this.readU32(t);return r}},{key:"readU16Array",value:function(){for(var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],e=this.readU16(t),r=new Array(e),n=0;n<e;n++)r[n]=this.readU16(t);return r}},{key:"readU8Array",value:function(){for(var t=this.readU16(!0),e=new Array(t),r=0;r<t;r++)e[r]=this.readU8();return e}},{key:"readStringArray",value:function(){for(var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],e=this.readU16(t),r=new Array(e),n=0;n<e;n++)r[n]=this.readStringWithLength(t);return r}},{key:"readBytesArray",value:function(){for(var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],e=this.readU16(t),r=new Array(e),n=0;n<e;n++)r[n]=this.readBytesWithLength(0,t);return r}},{key:"readAddressValueTuple",value:function(){for(var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],e=this.readU16(t),r=new Jc,n=0;n<e;n++){var i=this.readAddress(),o=this.readU256(t);if(r.has(i))throw new Error("Duplicate address found in map");r.set(i,o)}return r}},{key:"getOffset",value:function(){return this.currentOffset}},{key:"setOffset",value:function(t){this.currentOffset=t}},{key:"verifyEnd",value:function(t){if(t>this.buffer.byteLength)throw new Error("Attempt to read beyond buffer length: requested up to byte offset ".concat(t,", but buffer is only ").concat(this.buffer.byteLength," bytes."))}},{key:"reverseBytes",value:function(t){for(var e=new Uint8Array(t.length),r=0;r<t.length;r++)e[r]=t[t.length-1-r];return e}},{key:"toHexString",value:function(t){return Array.from(t,function(t){return t.toString(16).padStart(2,"0")}).join("")}}],[{key:"stringCompare",value:function(t,e){return t.localeCompare(e)}},{key:"bigintCompare",value:function(t,e){return t<e?-1:t>e?1:0}},{key:"numberCompare",value:function(t,e){return t<e?-1:t>e?1:0}}])}();function fh(t){return fh="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},fh(t)}function ch(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,lh(n.key),n)}}function lh(t){var e=function(t){if("object"!=fh(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=fh(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==fh(e)?e:e+""}var hh,ph=function(){return function(t,e){return e&&ch(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}(function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),function(t,e){(e=lh(e))in t?Object.defineProperty(t,e,{value:0,enumerable:!0,configurable:!0,writable:!0}):t[e]=0}(this,"currentOffset"),this.buffer=this.getDefaultBuffer(e)},[{key:"writeU8",value:function(t){if(t>255)throw new Error("u8 value is too large.");this.allocSafe(kc),this.buffer.setUint8(this.currentOffset++,t)}},{key:"writeU16",value:function(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(t>65535)throw new Error("u16 value is too large.");this.allocSafe(Ec),this.buffer.setUint16(this.currentOffset,t,!e),this.currentOffset+=2}},{key:"writeU32",value:function(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(t>4294967295)throw new Error("u32 value is too large.");this.allocSafe(_c),this.buffer.setUint32(this.currentOffset,t,!e),this.currentOffset+=4}},{key:"writeU64",value:function(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(t>18446744073709551615n)throw new Error("u64 value is too large.");this.allocSafe(Sc),this.buffer.setBigUint64(this.currentOffset,t,!e),this.currentOffset+=8}},{key:"writeSelector",value:function(t){this.writeU32(t,!0)}},{key:"writeBoolean",value:function(t){this.writeU8(t?1:0)}},{key:"writeI128",value:function(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(t>170141183460469231731687303715884105727n||t<-170141183460469231731687303715884105728n)throw new Error("i128 value is too large.");this.allocSafe(Tc);var r=Lc.valueToUint8Array(t,Tc);if(r.byteLength!==Tc)throw new Error("Invalid i128 value: ".concat(t));if(e)for(var n=0;n<r.byteLength;n++)this.writeU8(r[n]);else for(var i=r.byteLength-1;i>=0;i--)this.writeU8(r[i])}},{key:"writeU256",value:function(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(t>115792089237316195423570985008687907853269984665640564039457584007913129639935n&&t<0n)throw new Error("u256 value is too large or negative.");this.allocSafe(wc);var r=Lc.valueToUint8Array(t);if(r.byteLength!==wc)throw new Error("Invalid u256 value: ".concat(t));if(e)for(var n=0;n<r.byteLength;n++)this.writeU8(r[n]);else for(var i=r.byteLength-1;i>=0;i--)this.writeU8(r[i])}},{key:"writeU128",value:function(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(t>340282366920938463463374607431768211455n&&t<0n)throw new Error("u128 value is too large or negative.");this.allocSafe(mc);var r=Lc.valueToUint8Array(t,mc);if(r.byteLength!==mc)throw new Error("Invalid u128 value: ".concat(t));if(e)for(var n=0;n<r.byteLength;n++)this.writeU8(r[n]);else for(var i=r.byteLength-1;i>=0;i--)this.writeU8(r[i])}},{key:"writeBytes",value:function(t){this.allocSafe(t.byteLength);for(var e=0;e<t.byteLength;e++)this.writeU8(t[e])}},{key:"writeString",value:function(t){var e=(new TextEncoder).encode(t);this.allocSafe(e.length),this.writeBytes(e)}},{key:"writeStringWithLength",value:function(t){var e=(new TextEncoder).encode(t);this.allocSafe(_c+e.length),this.writeU32(e.length),this.writeBytes(e)}},{key:"writeAddress",value:function(t){this.verifyAddress(t),this.writeBytes(t)}},{key:"getBuffer",value:function(){for(var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],e=new Uint8Array(this.buffer.byteLength),r=0;r<this.buffer.byteLength;r++)e[r]=this.buffer.getUint8(r);return t&&this.clear(),e}},{key:"reset",value:function(){this.currentOffset=0,this.buffer=this.getDefaultBuffer(4)}},{key:"toBytesReader",value:function(){return new uh(this.getBuffer())}},{key:"getOffset",value:function(){return this.currentOffset}},{key:"setOffset",value:function(t){this.currentOffset=t}},{key:"clear",value:function(){this.currentOffset=0,this.buffer=this.getDefaultBuffer()}},{key:"allocSafe",value:function(t){this.currentOffset+t>this.buffer.byteLength&&this.resize(t)}},{key:"writeAddressValueTuple",value:function(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(t.size>65535)throw new Error("Map size is too large");this.writeU16(t.size,e);for(var r=Array.from(t.keys()),n=0;n<r.length;n++){var i=r[n],o=t.get(i);if(null==o)throw new Error("Value not found");this.writeAddress(i),this.writeU256(o,e)}}},{key:"writeBytesWithLength",value:function(t){this.writeU32(t.length),this.writeBytes(t)}},{key:"writeAddressArray",value:function(t){if(t.length>65535)throw new Error("Array size is too large");this.writeU16(t.length);for(var e=0;e<t.length;e++)this.writeAddress(t[e])}},{key:"writeU32Array",value:function(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(t.length>65535)throw new Error("Array size is too large");this.writeU16(t.length,e);for(var r=0;r<t.length;r++)this.writeU32(t[r],e)}},{key:"writeU256Array",value:function(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(t.length>65535)throw new Error("Array size is too large");this.writeU16(t.length,e);for(var r=0;r<t.length;r++)this.writeU256(t[r],e)}},{key:"writeU128Array",value:function(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(t.length>65535)throw new Error("Array size is too large");this.writeU16(t.length,e);for(var r=0;r<t.length;r++)this.writeU128(t[r],e)}},{key:"writeStringArray",value:function(t){if(t.length>65535)throw new Error("Array size is too large");this.writeU16(t.length);for(var e=0;e<t.length;e++)this.writeStringWithLength(t[e])}},{key:"writeU16Array",value:function(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(t.length>65535)throw new Error("Array size is too large");this.writeU16(t.length,e);for(var r=0;r<t.length;r++)this.writeU16(t[r],e)}},{key:"writeU8Array",value:function(t){if(t.length>65535)throw new Error("Array size is too large");this.writeU16(t.length);for(var e=0;e<t.length;e++)this.writeU8(t[e])}},{key:"writeU64Array",value:function(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(t.length>65535)throw new Error("Array size is too large");this.writeU16(t.length,e);for(var r=0;r<t.length;r++)this.writeU64(t[r],e)}},{key:"writeBytesArray",value:function(t){if(t.length>65535)throw new Error("Array size is too large");this.writeU16(t.length);for(var e=0;e<t.length;e++)this.writeBytesWithLength(t[e])}},{key:"verifyAddress",value:function(t){if(t.byteLength>gc)throw new Error("Address is too long ".concat(t.byteLength," > ").concat(gc," bytes"))}},{key:"resize",value:function(t){for(var e=new Uint8Array(this.buffer.byteLength+t),r=0;r<this.buffer.byteLength;r++)e[r]=this.buffer.getUint8(r);this.buffer=new DataView(e.buffer,e.byteOffset,e.byteLength)}},{key:"getDefaultBuffer",value:function(){return new DataView(new ArrayBuffer(arguments.length>0&&void 0!==arguments[0]?arguments[0]:0))}}])}();!function(t){t[t.ACCESS_LIST=1]="ACCESS_LIST",t[t.EPOCH_SUBMISSION=2]="EPOCH_SUBMISSION"}(hh||(hh={}));var dh=i(8287).Buffer;function yh(t){return yh="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},yh(t)}function bh(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=gh(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}function gh(t,e){if(t){if("string"==typeof t)return vh(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?vh(t,e):void 0}}function vh(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function wh(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Sh(n.key),n)}}function mh(t,e,r){return(e=Sh(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Sh(t){var e=function(t){if("object"!=yh(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=yh(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==yh(e)?e:e+""}var _h=function(){function t(e,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:b.bitcoin;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),mh(this,"network",b.bitcoin),this.senderPubKey=e,this.contractSaltPubKey=r,this.network=n,this.xSenderPubKey=bi(e)}return function(t,e){return e&&wh(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"buildHeader",value:function(t){var e,r=0,n=bh(t);try{for(n.s();!(e=n.n()).done;)r|=e.value}catch(t){n.e(t)}finally{n.f()}var i=dh.alloc(3);return i.writeUIntBE(r,0,3),dh.from([this.senderPubKey[0]].concat(function(t){return function(t){if(Array.isArray(t))return vh(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||gh(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}(i)))}},{key:"getHeader",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],r=new ph(12);return r.writeBytes(this.buildHeader(e)),r.writeU64(t),dh.from(r.getBuffer())}},{key:"splitBufferIntoChunks",value:function(e){for(var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t.DATA_CHUNK_SIZE,n=[],i=0;i<e.length;i+=r){for(var o=Math.min(r,e.length-i),a=dh.alloc(o),s=0;s<o;s++)a.writeUInt8(e[i+s],s);n.push([a])}return n}},{key:"encodeFeature",value:function(t){switch(t.opcode){case hh.ACCESS_LIST:return this.splitBufferIntoChunks(this.encodeAccessListFeature(t));case hh.EPOCH_SUBMISSION:return this.splitBufferIntoChunks(this.encodeChallengeSubmission(t));default:throw new Error("Unknown feature type: ".concat(t.opcode))}}},{key:"encodeAccessListFeature",value:function(t){var e=new ph;for(var r in e.writeU16(Object.keys(t.data).length),t.data){var n=ih.fromString(r),i=t.data[r];e.writeAddress(n),e.writeU32(i.length);var o,a=bh(i);try{for(a.s();!(o=a.n()).done;){var s=o.value,u=dh.from(s,"base64");if(32!==u.length)throw new Error("Invalid pointer length: ".concat(u.length));e.writeBytes(u)}}catch(t){a.e(t)}finally{a.f()}}return h.compress(dh.from(e.getBuffer()))}},{key:"encodeChallengeSubmission",value:function(t){if("verifySignature"in t.data&&!t.data.verifySignature())throw new Error("Invalid signature in challenge submission feature");var e=new ph;return e.writeBytes(t.data.publicKey.originalPublicKeyBuffer()),e.writeBytes(t.data.solution),t.data.graffiti&&e.writeBytesWithLength(t.data.graffiti),dh.from(e.getBuffer())}}])}();mh(_h,"DATA_CHUNK_SIZE",512),mh(_h,"MAGIC",dh.from("op","utf-8"));var Eh=i(8287).Buffer;function kh(t){return kh="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},kh(t)}function Oh(t){return function(t){if(Array.isArray(t))return Ah(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||Th(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Th(t,e){if(t){if("string"==typeof t)return Ah(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Ah(t,e):void 0}}function Ah(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function Ih(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Ph(n.key),n)}}function Ph(t){var e=function(t){if("object"!=kh(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=kh(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==kh(e)?e:e+""}function xh(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(xh=function(){return!!t})()}function Bh(t){return Bh=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Bh(t)}function Rh(t,e){return Rh=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Rh(t,e)}var Uh=function(){function t(e,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:b.bitcoin;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),function(t,e,r){return e=Bh(e),function(t,e){if(e&&("object"==kh(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,xh()?Reflect.construct(e,r||[],Bh(t).constructor):e.apply(t,r))}(this,t,[e,r,n])}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Rh(t,e)}(t,_h),function(t,e,r){return e&&Ih(t.prototype,e),r&&Ih(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"compile",value:function(t,e,r,n){var i,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:[];if(!this.contractSaltPubKey)throw new Error("Contract salt public key not set");var a=this.splitBufferIntoChunks(t);if(!a.length)throw new Error("No data chunks found");for(var s=[],u=[],f=0;f<o.length;f++){var c=o[f];s.push(c.opcode);var l=this.encodeFeature(c);u.push.apply(u,Oh(l))}var h=[this.getHeader(n,s),it.OP_TOALTSTACK,r.publicKey.originalPublicKeyBuffer(),it.OP_TOALTSTACK,r.solution,it.OP_TOALTSTACK,this.xSenderPubKey,it.OP_DUP,it.OP_HASH256,S.hash256(this.xSenderPubKey),it.OP_EQUALVERIFY,it.OP_CHECKSIGVERIFY,this.contractSaltPubKey,it.OP_CHECKSIGVERIFY,it.OP_HASH160,S.hash160(e),it.OP_EQUALVERIFY,it.OP_DEPTH,it.OP_1,it.OP_NUMEQUAL,it.OP_IF,_h.MAGIC],p=(h=(i=h).concat.apply(i,u.concat([it.OP_1NEGATE].concat(Oh(a),[it.OP_ELSE,it.OP_1,it.OP_ENDIF])))).flat(),d=w.compile(p);if(!w.decompile(d))throw new Error("Failed to decompile script??");return d}}],[{key:"getPubKeyAsBuffer",value:function(t,e){var r,n=Eh.alloc(0),i=function(t){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=Th(t))){e&&(t=e);var r=0,n=function(){};return{s:n,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:n}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,o=!0,a=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return o=t.done,t},e:function(t){a=!0,i=t},f:function(){try{o||null==e.return||e.return()}finally{if(a)throw i}}}}(t);try{for(i.s();!(r=i.n()).done;){var o=r.value;if(!bc.fromPublicKey(o,e).compressed)throw new Error("Public key must be compressed");if(33!==o.byteLength)throw new Error("Public key must be 33 bytes, got ".concat(o.byteLength," bytes."));n=Eh.concat([n,o])}}catch(t){i.e(t)}finally{i.f()}var a=h.compress(n);return a.byteLength>=n.byteLength?n:a}}])}();function Nh(t){return Nh="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Nh(t)}function jh(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Lh(n.key),n)}}function Lh(t){var e=function(t){if("object"!=Nh(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Nh(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Nh(e)?e:e+""}function Ch(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(Ch=function(){return!!t})()}function Fh(t){return Fh=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Fh(t)}function Dh(t,e){return Dh=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Dh(t,e)}var Hh=function(){function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:b.bitcoin;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),function(t,e,r){return e=Fh(e),function(t,e){if(e&&("object"==Nh(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,Ch()?Reflect.construct(e,r||[],Fh(t).constructor):e.apply(t,r))}(this,t,[e,void 0,r])}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Dh(t,e)}(t,_h),function(t,e){return e&&jh(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"compile",value:function(t){var e=t.flat(),r=w.compile(e);if(!w.decompile(r))throw new Error("Failed to decompile script??");return r}}])}(),Mh=i(8287).Buffer;function Kh(t){return Kh="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Kh(t)}function Vh(t){return function(t){if(Array.isArray(t))return Wh(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return Wh(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Wh(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Wh(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function Gh(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,qh(n.key),n)}}function qh(t){var e=function(t){if("object"!=Kh(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Kh(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Kh(e)?e:e+""}function zh(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(zh=function(){return!!t})()}function Zh(t){return Zh=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Zh(t)}function Xh(t,e){return Xh=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Xh(t,e)}var Yh=0,$h=Mh.from([Yh]),Jh=function(){function t(e,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:b.bitcoin;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),function(t,e,r){return e=Zh(e),function(t,e){if(e&&("object"==Kh(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,zh()?Reflect.construct(e,r||[],Zh(t).constructor):e.apply(t,r))}(this,t,[e,r,n])}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Xh(t,e)}(t,_h),function(t,e){return e&&Gh(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"compile",value:function(t,e,r,n,i,o){var a=this.getAsm(t,e,r,n,i,o),s=w.compile(a);if(!w.decompile(s))throw new Error("Failed to decompile script??");return s}},{key:"getAsm",value:function(t,e,r,n,i,o){if(!this.contractSaltPubKey)throw new Error("Contract salt public key not set");var a=this.splitBufferIntoChunks(t),s=i?this.splitBufferIntoChunks(i):[],u=[],f=[];if(o)for(var c=0;c<o.length;c++){var l=o[c];u.push(l.opcode);var h=this.encodeFeature(l);f.push.apply(f,Vh(h))}return[this.getHeader(n,u),it.OP_TOALTSTACK,r.publicKey.originalPublicKeyBuffer(),it.OP_TOALTSTACK,r.solution,it.OP_TOALTSTACK,this.xSenderPubKey,it.OP_DUP,it.OP_HASH256,S.hash256(this.xSenderPubKey),it.OP_EQUALVERIFY,it.OP_CHECKSIGVERIFY,this.contractSaltPubKey,it.OP_CHECKSIGVERIFY,it.OP_HASH256,S.hash256(e),it.OP_EQUALVERIFY,it.OP_DEPTH,it.OP_1,it.OP_NUMEQUAL,it.OP_IF,_h.MAGIC].concat(f,[it.OP_0],Vh(s),[it.OP_1NEGATE],Vh(a),[it.OP_ELSE,it.OP_1,it.OP_ENDIF]).flat()}}])}(),Qh=i(8287).Buffer;function tp(t){return tp="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},tp(t)}function ep(t){return function(t){if(Array.isArray(t))return np(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||rp(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function rp(t,e){if(t){if("string"==typeof t)return np(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?np(t,e):void 0}}function np(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function ip(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,op(n.key),n)}}function op(t){var e=function(t){if("object"!=tp(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=tp(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==tp(e)?e:e+""}function ap(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(ap=function(){return!!t})()}function sp(t){return sp=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},sp(t)}function up(t,e){return up=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},up(t,e)}var fp=function(){function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:b.bitcoin;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),function(t,e,r){return e=sp(e),function(t,e){if(e&&("object"==tp(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,ap()?Reflect.construct(e,r||[],sp(t).constructor):e.apply(t,r))}(this,t,[e,Qh.alloc(0),r])}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&up(t,e)}(t,_h),function(t,e,r){return e&&ip(t.prototype,e),r&&ip(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"compile",value:function(t,e,r,n){var i,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:[],a=this.splitBufferIntoChunks(t);if(!a.length)throw new Error("No data chunks found");for(var s=[],u=[],f=0;f<o.length;f++){var c=o[f];s.push(c.opcode);var l=this.encodeFeature(c);u.push.apply(u,ep(l))}var h=[this.getHeader(n,s),it.OP_TOALTSTACK,r,it.OP_TOALTSTACK,this.senderPubKey,it.OP_DUP,it.OP_HASH256,S.hash256(this.senderPubKey),it.OP_EQUALVERIFY,it.OP_CHECKSIGVERIFY,e,it.OP_TOALTSTACK,it.OP_DEPTH,it.OP_1,it.OP_NUMEQUAL,it.OP_IF,_h.MAGIC],p=(h=(i=h).concat.apply(i,u.concat([it.OP_1NEGATE].concat(ep(a),[it.OP_ELSE,it.OP_1,it.OP_ENDIF])))).flat(),d=w.compile(p);if(!w.decompile(d))throw new Error("Failed to decompile script??");return d}}],[{key:"getPubKeyAsBuffer",value:function(t,e){var r,n=Qh.alloc(0),i=function(t){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=rp(t))){e&&(t=e);var r=0,n=function(){};return{s:n,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:n}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,o=!0,a=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return o=t.done,t},e:function(t){a=!0,i=t},f:function(){try{o||null==e.return||e.return()}finally{if(a)throw i}}}}(t);try{for(i.s();!(r=i.n()).done;){var o=r.value;if(!bc.fromPublicKey(o,e).compressed)throw new Error("Public key must be compressed");if(33!==o.byteLength)throw new Error("Public key must be 33 bytes, got ".concat(o.byteLength," bytes."));n=Qh.concat([n,o])}}catch(t){i.e(t)}finally{i.f()}var a=h.compress(n);return a.byteLength>=n.byteLength?n:a}}])}(),cp=i(8287).Buffer;function lp(t){return lp="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},lp(t)}function hp(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function pp(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,dp(n.key),n)}}function dp(t){var e=function(t){if("object"!=lp(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=lp(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==lp(e)?e:e+""}var yp=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)}return function(t,e,r){return r&&pp(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,0,[{key:"compile",value:function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2?arguments[2]:void 0;if(r<2)throw new Error("Minimum signatures must be greater than 1");if(e.length<r)throw new Error("The amount of public keys is lower than the minimum required");if(r>t.MAXIMUM_SUPPORTED_SIGNATURE)throw new Error("The maximum amount of signatures is ".concat(t.MAXIMUM_SUPPORTED_SIGNATURE));var i=cp.alloc(1);i.writeUInt8(r),e=(e=e.filter(function(t,e,r){return e===r.findIndex(function(e){return t.equals(e)})})).sort(function(t,e){return t.compare(e)});var o=!1,a=e.map(function(t){var e=bi(t);return n&&!o&&(o=n.equals(e)),e});n&&!o&&a.push(n);var s=[it.OP_0].concat(function(t){return function(t){if(Array.isArray(t))return hp(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return hp(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?hp(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}(a.flatMap(function(t){return[t,it.OP_CHECKSIGADD]})),[i,it.OP_NUMEQUAL]).flat(),u=w.compile(s);if(!w.decompile(u))throw new Error("Failed to decompile script.");return u}}])}();!function(t,e){(e=dp(e))in t?Object.defineProperty(t,e,{value:255,enumerable:!0,configurable:!0,writable:!0}):t[e]=255}(yp,"MAXIMUM_SUPPORTED_SIGNATURE");var bp=i(8287).Buffer;function gp(t){return gp="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},gp(t)}function vp(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function wp(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,kp(n.key),n)}}function mp(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(mp=function(){return!!t})()}function Sp(){return Sp="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,r){var n=function(t,e){for(;!{}.hasOwnProperty.call(t,e)&&null!==(t=_p(t)););return t}(t,e);if(n){var i=Object.getOwnPropertyDescriptor(n,e);return i.get?i.get.call(arguments.length<3?t:r):i.value}},Sp.apply(null,arguments)}function _p(t){return _p=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},_p(t)}function Ep(t,e){return Ep=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Ep(t,e)}function kp(t){var e=function(t){if("object"!=gp(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=gp(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==gp(e)?e:e+""}var Op=function(){function t(e,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:b.bitcoin;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),function(t,e,r){return e=_p(e),function(t,e){if(e&&("object"==gp(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,mp()?Reflect.construct(e,r||[],_p(t).constructor):e.apply(t,r))}(this,t,[e,r,n])}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Ep(t,e)}(t,_h),function(t,e,r){return e&&wp(t.prototype,e),r&&wp(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"compile",value:function(e,r,n,i){var o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:[];if(!this.contractSaltPubKey)throw new Error("Contract salt public key not set");if(32!==r.length)throw new Error("Contract secret must be exactly 32 bytes");var a=new ph;return a.writeU8(t.P2WDA_VERSION),a.writeBytes(this.getHeader(i,o.map(function(t){return t.opcode}))),a.writeBytes(r),a.writeBytes(n.publicKey.originalPublicKeyBuffer()),a.writeBytes(n.solution),a.writeU32(e.length),a.writeBytes(e),this.writeFeatures(a,o),bp.from(a.getBuffer())}},{key:"getHeader",value:function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];return function(t,e,r){var n=Sp(_p(t.prototype),"getHeader",r);return"function"==typeof n?function(t){return n.apply(r,t)}:n}(t,0,this)([e,r])}},{key:"writeFeatures",value:function(t,e){t.writeU16(e.length);var r,n=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return vp(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?vp(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}(e);try{for(n.s();!(r=n.n()).done;){var i=r.value;t.writeU8(i.opcode);var o=this.encodeFeatureData(i);t.writeU32(o.length),t.writeBytes(o)}}catch(t){n.e(t)}finally{n.f()}}},{key:"encodeFeatureData",value:function(t){switch(t.opcode){case hh.ACCESS_LIST:var e=this.encodeFeature(t);return bp.concat(e.flat());case hh.EPOCH_SUBMISSION:var r=this.encodeFeature(t);return bp.concat(r.flat());default:throw new Error("Unknown feature type: ".concat(t.opcode))}}}],[{key:"validateWitnessSize",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:10,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:80,n=t+64,i=Math.ceil(.7*n);return Math.ceil(i/r)<=e}}])}();!function(t,e){(e=kp(e))in t?Object.defineProperty(t,e,{value:1,enumerable:!0,configurable:!0,writable:!0}):t[e]=1}(Op,"P2WDA_VERSION");var Tp=i(2343);function Ap(t){return Ap="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Ap(t)}function Ip(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Pp(n.key),n)}}function Pp(t){var e=function(t){if("object"!=Ap(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Ap(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Ap(e)?e:e+""}ur(fa);var xp=function(){return function(t,e,r){return r&&Ip(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)},0,[{key:"generatePKSH",value:function(t,e){if(32!==t.length)throw new Error("Invalid hash length");var r=Je(t);return this.toSegwitAddress(r,e)}},{key:"generateTaprootAddress",value:function(t,e){if(32!==t.length)throw new Error("Invalid public key length");var r=Tp.p2.toWords(t);return r.unshift(1),Tp.p2.encode(e.bech32,r)}},{key:"toSegwitAddress",value:function(t,e){var r=Tp.I.toWords(t);return r.unshift(0),Tp.I.encode(e.bech32,r)}}])}(),Bp={d:(t,e)=>{for(var r in e)Bp.o(e,r)&&!Bp.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},Rp={};Bp.d(Rp,{q$:()=>Nd,Vy:()=>jd,$7:()=>Up,rE:()=>Np});var Up={};Bp.r(Up),Bp.d(Up,{DebugLevel:()=>Nd,Logger:()=>jd,version:()=>Np});var Np="1.0.2";function jp(t,e){t=t.replace("#","");var r=parseInt(t,16),n=Math.round(2.55*e),i=(r>>16)+n,o=(r>>8&255)+n,a=(255&r)+n;return(16777216+65536*(i<255?i<1?0:i:255)+256*(o<255?o<1?0:o:255)+(a<255?a<1?0:a:255)).toString(16).slice(1)}const Lp=(t=0)=>e=>`[${e+t}m`,Cp=(t=0)=>e=>`[${38+t};5;${e}m`,Fp=(t=0)=>(e,r,n)=>`[${38+t};2;${e};${r};${n}m`,Dp={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};Object.keys(Dp.modifier),Object.keys(Dp.color),Object.keys(Dp.bgColor);const Hp=function(){const t=new Map;for(const[e,r]of Object.entries(Dp)){for(const[e,n]of Object.entries(r))Dp[e]={open:`[${n[0]}m`,close:`[${n[1]}m`},r[e]=Dp[e],t.set(n[0],n[1]);Object.defineProperty(Dp,e,{value:r,enumerable:!1})}return Object.defineProperty(Dp,"codes",{value:t,enumerable:!1}),Dp.color.close="",Dp.bgColor.close="",Dp.color.ansi=Lp(),Dp.color.ansi256=Cp(),Dp.color.ansi16m=Fp(),Dp.bgColor.ansi=Lp(10),Dp.bgColor.ansi256=Cp(10),Dp.bgColor.ansi16m=Fp(10),Object.defineProperties(Dp,{rgbToAnsi256:{value:(t,e,r)=>t===e&&e===r?t<8?16:t>248?231:Math.round((t-8)/247*24)+232:16+36*Math.round(t/255*5)+6*Math.round(e/255*5)+Math.round(r/255*5),enumerable:!1},hexToRgb:{value(t){const e=/[a-f\d]{6}|[a-f\d]{3}/i.exec(t.toString(16));if(!e)return[0,0,0];let[r]=e;3===r.length&&(r=[...r].map(t=>t+t).join(""));const n=Number.parseInt(r,16);return[n>>16&255,n>>8&255,255&n]},enumerable:!1},hexToAnsi256:{value:t=>Dp.rgbToAnsi256(...Dp.hexToRgb(t)),enumerable:!1},ansi256ToAnsi:{value(t){if(t<8)return 30+t;if(t<16)return t-8+90;let e,r,n;if(t>=232)e=(10*(t-232)+8)/255,r=e,n=e;else{const i=(t-=16)%36;e=Math.floor(t/36)/5,r=Math.floor(i/6)/5,n=i%6/5}const i=2*Math.max(e,r,n);if(0===i)return 30;let o=30+(Math.round(n)<<2|Math.round(r)<<1|Math.round(e));return 2===i&&(o+=60),o},enumerable:!1},rgbToAnsi:{value:(t,e,r)=>Dp.ansi256ToAnsi(Dp.rgbToAnsi256(t,e,r)),enumerable:!1},hexToAnsi:{value:t=>Dp.ansi256ToAnsi(Dp.hexToAnsi256(t)),enumerable:!1}}),Dp}(),Mp=(()=>{if(navigator.userAgentData){const t=navigator.userAgentData.brands.find(({brand:t})=>"Chromium"===t);if(t&&t.version>93)return 3}return/\b(Chrome|Chromium)\//.test(navigator.userAgent)?1:0})(),Kp=0!==Mp&&{level:Mp,hasBasic:!0,has256:Mp>=2,has16m:Mp>=3},Vp={stdout:Kp,stderr:Kp};function Wp(t,e,r){let n=t.indexOf(e);if(-1===n)return t;const i=e.length;let o=0,a="";do{a+=t.slice(o,n)+e+r,o=n+i,n=t.indexOf(e,o)}while(-1!==n);return a+=t.slice(o),a}const{stdout:Gp,stderr:qp}=Vp,zp=Symbol("GENERATOR"),Zp=Symbol("STYLER"),Xp=Symbol("IS_EMPTY"),Yp=["ansi","ansi","ansi256","ansi16m"],$p=Object.create(null);class Jp{constructor(t){return Qp(t)}}const Qp=t=>{const e=(...t)=>t.join(" ");return((t,e={})=>{if(e.level&&!(Number.isInteger(e.level)&&e.level>=0&&e.level<=3))throw new Error("The `level` option should be an integer from 0 to 3");const r=Gp?Gp.level:0;t.level=void 0===e.level?r:e.level})(e,t),Object.setPrototypeOf(e,td.prototype),e};function td(t){return Qp(t)}Object.setPrototypeOf(td.prototype,Function.prototype);for(const[t,e]of Object.entries(Hp))$p[t]={get(){const r=od(this,id(e.open,e.close,this[Zp]),this[Xp]);return Object.defineProperty(this,t,{value:r}),r}};$p.visible={get(){const t=od(this,this[Zp],!0);return Object.defineProperty(this,"visible",{value:t}),t}};const ed=(t,e,r,...n)=>"rgb"===t?"ansi16m"===e?Hp[r].ansi16m(...n):"ansi256"===e?Hp[r].ansi256(Hp.rgbToAnsi256(...n)):Hp[r].ansi(Hp.rgbToAnsi(...n)):"hex"===t?ed("rgb",e,r,...Hp.hexToRgb(...n)):Hp[r][t](...n),rd=["rgb","hex","ansi256"];for(const t of rd)$p[t]={get(){const{level:e}=this;return function(...r){const n=id(ed(t,Yp[e],"color",...r),Hp.color.close,this[Zp]);return od(this,n,this[Xp])}}},$p["bg"+t[0].toUpperCase()+t.slice(1)]={get(){const{level:e}=this;return function(...r){const n=id(ed(t,Yp[e],"bgColor",...r),Hp.bgColor.close,this[Zp]);return od(this,n,this[Xp])}}};const nd=Object.defineProperties(()=>{},{...$p,level:{enumerable:!0,get(){return this[zp].level},set(t){this[zp].level=t}}}),id=(t,e,r)=>{let n,i;return void 0===r?(n=t,i=e):(n=r.openAll+t,i=e+r.closeAll),{open:t,close:e,openAll:n,closeAll:i,parent:r}},od=(t,e,r)=>{const n=(...t)=>ad(n,1===t.length?""+t[0]:t.join(" "));return Object.setPrototypeOf(n,nd),n[zp]=t,n[Zp]=e,n[Xp]=r,n},ad=(t,e)=>{if(t.level<=0||!e)return t[Xp]?"":e;let r=t[Zp];if(void 0===r)return e;const{openAll:n,closeAll:i}=r;if(e.includes(""))for(;void 0!==r;)e=Wp(e,r.close,r.open),r=r.parent;const o=e.indexOf("\n");return-1!==o&&(e=function(t,e,r,n){let i=0,o="";do{const a="\r"===t[n-1];o+=t.slice(i,a?n-1:n)+e+(a?"\r\n":"\n")+r,i=n+1,n=t.indexOf("\n",i)}while(-1!==n);return o+=t.slice(i),o}(e,i,n,o)),n+e+i};function sd(t){return sd="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},sd(t)}function ud(t,e,r){(function(t,e){if(e.has(t))throw new TypeError("Cannot initialize the same private elements twice on an object")})(t,e),e.set(t,r)}function fd(t,e,r){return(e=cd(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function cd(t){var e=function(t){if("object"!=sd(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=sd(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==sd(e)?e:e+""}function ld(t,e){return t.get(function(t,e,r){if("function"==typeof t?t===e:t.has(e))return arguments.length<3?e:r;throw new TypeError("Private element is not present on this object")}(t,e))}Object.defineProperties(td.prototype,$p),td(),td({level:qp?qp.level:0});var hd=new WeakMap,pd=new WeakMap,dd=new WeakMap,yd=new WeakMap,bd=new WeakMap,gd=new WeakMap,vd=new WeakMap,wd=new WeakMap,md=new WeakMap,Sd=new WeakMap,_d=new WeakMap,Ed=new WeakMap,kd=new WeakMap,Od=new WeakMap,Td=new WeakMap,Ad=new WeakMap,Id=new WeakMap,Pd=function(){return t=function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new Jp;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),fd(this,"moduleName",""),fd(this,"logColor","#00bfff"),fd(this,"enableLogs",!0),fd(this,"hideLogs",!1),ud(this,hd,"#ff00ff"),ud(this,pd,jp(ld(hd,this),75)),ud(this,dd,"#9400d3"),ud(this,yd,jp(ld(dd,this),15)),ud(this,bd,jp(ld(yd,this),15)),ud(this,gd,"#7cfc00"),ud(this,vd,jp(ld(gd,this),15)),ud(this,wd,"#ffdead"),ud(this,md,jp(ld(wd,this),15)),ud(this,Sd,"#ff8c00"),ud(this,_d,jp(ld(Sd,this),15)),ud(this,Ed,"#ff4500"),ud(this,kd,jp(ld(Ed,this),15)),ud(this,Od,"#ffffff"),ud(this,Td,jp(ld(Od,this),15)),ud(this,Ad,"#8b0000"),ud(this,Id,jp(ld(Ad,this),15)),fd(this,"prefix",""),this.chalk=e,this.moduleName=this.constructor.name},e=[{key:"setLogPrefix",value:function(t){this.prefix=t}},{key:"getStartPrefix",value:function(){return this.prefix}},{key:"disable",value:function(){this.enableLogs=!1}},{key:"enable",value:function(){this.enableLogs=!0}},{key:"fancyLog",value:function(t,e,r,n,i){this.enableLogs&&console.log(this.chalk.hex(ld(hd,this))("".concat(this.getStartPrefix(),"[").concat(this.moduleName," INFO]: "))+this.chalk.hex(ld(Od,this))(t)+" "+this.chalk.hex(ld(_d,this))(e)+" "+this.chalk.hex(ld(Od,this))(r)+" "+this.chalk.hex(ld(bd,this))(n)+" "+this.chalk.hex(ld(Od,this))(i))}},{key:"log",value:function(){if(this.enableLogs&&!this.hideLogs){var t=jp(this.logColor,15);console.log(this.chalk.hex(this.logColor)("".concat(this.getStartPrefix(),"[").concat(this.moduleName," LOG]: "))+this.chalk.hex(t).apply(void 0,arguments))}}},{key:"lightOrangeLog",value:function(){this.enableLogs&&(this.hideLogs||console.log(this.chalk.hex(ld(_d,this))("".concat(this.getStartPrefix(),"[").concat(this.moduleName," LOG]: "))+this.chalk.hex(ld(Od,this)).apply(void 0,arguments)))}},{key:"error",value:function(){this.enableLogs&&console.log(this.chalk.hex(ld(Ed,this))("".concat(this.getStartPrefix(),"[").concat(this.moduleName," ERROR]: "))+this.chalk.hex(ld(kd,this)).apply(void 0,arguments))}},{key:"warn",value:function(){this.enableLogs&&console.log(this.chalk.hex(ld(Sd,this))("".concat(this.getStartPrefix(),"[").concat(this.moduleName," WARN]: "))+this.chalk.hex(ld(_d,this)).apply(void 0,arguments))}},{key:"debug",value:function(){this.enableLogs&&(this.hideLogs||console.log(this.chalk.hex(ld(wd,this))("".concat(this.getStartPrefix(),"[").concat(this.moduleName," DEBUG]: "))+this.chalk.hex(ld(md,this)).apply(void 0,arguments)))}},{key:"success",value:function(){this.enableLogs&&(this.hideLogs||console.log(this.chalk.hex(ld(gd,this))("".concat(this.getStartPrefix(),"[").concat(this.moduleName," SUCCESS]: "))+this.chalk.hex(ld(vd,this)).apply(void 0,arguments)))}},{key:"fail",value:function(){this.enableLogs&&(this.hideLogs||console.log(this.chalk.hex(ld(Ed,this))("".concat(this.getStartPrefix(),"[").concat(this.moduleName," FAIL]: "))+this.chalk.hex(ld(kd,this)).apply(void 0,arguments)))}},{key:"debugBright",value:function(){this.enableLogs&&(this.hideLogs||console.log(this.chalk.hex(ld(dd,this))("".concat(this.getStartPrefix(),"[").concat(this.moduleName," DEBUG]: "))+this.chalk.hex(ld(yd,this)).apply(void 0,arguments)))}},{key:"important",value:function(){this.enableLogs&&console.log(this.chalk.hex(ld(hd,this))("".concat(this.getStartPrefix(),"[").concat(this.moduleName," IMPORTANT]: "))+this.chalk.hex(ld(pd,this)).apply(void 0,arguments))}},{key:"panic",value:function(){this.enableLogs&&console.log(this.chalk.hex(ld(Ad,this))("".concat(this.getStartPrefix(),"[").concat(this.moduleName," HELP PANIC]: "))+this.chalk.hex(ld(Id,this)).apply(void 0,arguments))}},{key:"info",value:function(){this.enableLogs&&console.log(this.chalk.hex(ld(hd,this))("".concat(this.getStartPrefix(),"[").concat(this.moduleName," INFO]: "))+this.chalk.hex(ld(Od,this)).apply(void 0,arguments))}},{key:"securityNotice",value:function(){this.enableLogs&&console.log(this.chalk.hex("#22d8e6")("".concat(this.getStartPrefix(),"[").concat(this.moduleName," SECURITY NOTICE]: "))+this.chalk.hex("#22e3e6").apply(void 0,arguments))}},{key:"traceLog",value:function(){this.enableLogs&&console.log(this.chalk.hex("#ffffff")("".concat(this.getStartPrefix(),"[").concat(this.moduleName," TRACE LOG]: "))+this.chalk.hex(ld(Td,this)).apply(void 0,arguments))}}],e&&function(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,cd(n.key),n)}}(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}();function xd(t){return xd="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},xd(t)}function Bd(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(Bd=function(){return!!t})()}function Rd(t){return Rd=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Rd(t)}function Ud(t,e){return Ud=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Ud(t,e)}var Nd,jd=function(){function t(){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),function(t,e){return e=Rd(e),function(t,e){if(e&&("object"==xd(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,Bd()?Reflect.construct(e,[],Rd(t).constructor):e.apply(t,void 0))}(this,t)}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Ud(t,e)}(t,Pd),e=t,Object.defineProperty(e,"prototype",{writable:!1}),e;var e}();!function(t){t[t.NONE=0]="NONE",t[t.ERROR=1]="ERROR",t[t.WARN=2]="WARN",t[t.INFO=3]="INFO",t[t.DEBUG=4]="DEBUG",t[t.TRACE=5]="TRACE",t[t.ALL=6]="ALL"}(Nd||(Nd={}));var Ld=Rp.Vy,Cd=i(8287).Buffer;function Fd(t){return Fd="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Fd(t)}function Dd(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Hd(n.key),n)}}function Hd(t){var e=function(t){if("object"!=Fd(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Fd(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Fd(e)?e:e+""}ur(fa);var Md,Kd,Vd=function(){return function(t,e,r){return r&&Dd(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)},0,[{key:"tweakSigner",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.privateKey;if(!r)throw new Error("Private key is required for tweaking signer!");3===t.publicKey[0]&&(r=ua.privateNegate(r));var n=ua.privateAdd(r,Hr(bi(Cd.from(t.publicKey)),e.tweakHash));if(!n)throw new Error("Invalid tweaked private key!");return bc.fromPrivateKey(Cd.from(n),e.network)}}])}();function Wd(t){return t&&!!(t.tapInternalKey||t.tapMerkleRoot||t.tapLeafScript&&t.tapLeafScript.length||t.tapBip32Derivation&&t.tapBip32Derivation.length||t.witnessUtxo&&Ki(t.witnessUtxo.script))}function Gd(t,e){if(t.nonWitnessUtxo&&!t.redeemScript&&!t.witnessScript&&!t.witnessUtxo||t.redeemScript)return!0;var r=function(t){return t.redeemScript?t.redeemScript:t.witnessScript?t.witnessScript:t.witnessUtxo?t.witnessUtxo.script:(t.nonWitnessUtxo,null)}(t);return!!r&&qd(e,r)}function qd(t,e){return-1!==zi(t,e)}function zd(t){return zd="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},zd(t)}function Zd(){var t,e,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",i=r.toStringTag||"@@toStringTag";function o(r,n,i,o){var u=n&&n.prototype instanceof s?n:s,f=Object.create(u.prototype);return Xd(f,"_invoke",function(r,n,i){var o,s,u,f=0,c=i||[],l=!1,h={p:0,n:0,v:t,a:p,f:p.bind(t,4),d:function(e,r){return o=e,s=0,u=t,h.n=r,a}};function p(r,n){for(s=r,u=n,e=0;!l&&f&&!i&&e<c.length;e++){var i,o=c[e],p=h.p,d=o[2];r>3?(i=d===n)&&(u=o[(s=o[4])?5:(s=3,3)],o[4]=o[5]=t):o[0]<=p&&((i=r<2&&p<o[1])?(s=0,h.v=n,h.n=o[1]):p<d&&(i=r<3||o[0]>n||n>d)&&(o[4]=r,o[5]=n,h.n=d,s=0))}if(i||r>1)return a;throw l=!0,n}return function(i,c,d){if(f>1)throw TypeError("Generator is already running");for(l&&1===c&&p(c,d),s=c,u=d;(e=s<2?t:u)||!l;){o||(s?s<3?(s>1&&(h.n=-1),p(s,u)):h.n=u:h.v=u);try{if(f=2,o){if(s||(i="next"),e=o[i]){if(!(e=e.call(o,u)))throw TypeError("iterator result is not an object");if(!e.done)return e;u=e.value,s<2&&(s=0)}else 1===s&&(e=o.return)&&e.call(o),s<2&&(u=TypeError("The iterator does not provide a '"+i+"' method"),s=1);o=t}else if((e=(l=h.n<0)?u:r.call(n,h))!==a)break}catch(e){o=t,s=1,u=e}finally{f=1}}return{value:e,done:l}}}(r,i,o),!0),f}var a={};function s(){}function u(){}function f(){}e=Object.getPrototypeOf;var c=[][n]?e(e([][n]())):(Xd(e={},n,function(){return this}),e),l=f.prototype=s.prototype=Object.create(c);function h(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,f):(t.__proto__=f,Xd(t,i,"GeneratorFunction")),t.prototype=Object.create(l),t}return u.prototype=f,Xd(l,"constructor",f),Xd(f,"constructor",u),u.displayName="GeneratorFunction",Xd(f,i,"GeneratorFunction"),Xd(l),Xd(l,i,"Generator"),Xd(l,n,function(){return this}),Xd(l,"toString",function(){return"[object Generator]"}),(Zd=function(){return{w:o,m:h}})()}function Xd(t,e,r,n){var i=Object.defineProperty;try{i({},"",{})}catch(t){i=0}Xd=function(t,e,r,n){function o(e,r){Xd(t,e,function(t){return this._invoke(e,r,t)})}e?i?i(t,e,{value:r,enumerable:!n,configurable:!n,writable:!n}):t[e]=r:(o("next",0),o("throw",1),o("return",2))},Xd(t,e,r,n)}function Yd(t,e,r,n,i,o,a){try{var s=t[o](a),u=s.value}catch(t){return void r(t)}s.done?e(u):Promise.resolve(u).then(n,i)}function $d(t){return function(){var e=this,r=arguments;return new Promise(function(n,i){var o=t.apply(e,r);function a(t){Yd(o,n,i,a,s,"next",t)}function s(t){Yd(o,n,i,a,s,"throw",t)}a(void 0)})}}function Jd(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=ty(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}function Qd(t){return function(t){if(Array.isArray(t))return ey(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||ty(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function ty(t,e){if(t){if("string"==typeof t)return ey(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?ey(t,e):void 0}}function ey(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function ry(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,sy(n.key),n)}}function ny(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(ny=function(){return!!t})()}function iy(t){return iy=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},iy(t)}function oy(t,e){return oy=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},oy(t,e)}function ay(t,e,r){return(e=sy(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function sy(t){var e=function(t){if("object"!=zd(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=zd(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==zd(e)?e:e+""}!function(t){t[t.REPLACE_BY_FEE=4294967293]="REPLACE_BY_FEE",t[t.FINAL=4294967295]="FINAL"}(Md||(Md={})),function(t){t[t.BLOCKS=0]="BLOCKS",t[t.TIMESTAMPS=1]="TIMESTAMPS"}(Kd||(Kd={}));var uy=function(){function t(e){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),ay(r=function(t,e,r){return e=iy(e),function(t,e){if(e&&("object"==zd(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,ny()?Reflect.construct(e,r||[],iy(t).constructor):e.apply(t,r))}(this,t),"logColor","#00ffe1"),ay(r,"finalized",!1),ay(r,"signed",!1),ay(r,"scriptData",null),ay(r,"tapData",null),ay(r,"inputs",[]),ay(r,"sequence",Md.REPLACE_BY_FEE),ay(r,"tapLeafScript",null),ay(r,"isBrowser",!1),ay(r,"csvInputIndices",new Set),ay(r,"anchorInputIndices",new Set),ay(r,"regenerated",!1),ay(r,"ignoreSignatureErrors",!1),ay(r,"noSignatures",!1),ay(r,"txVersion",2),ay(r,"customFinalizerP2SH",function(t,e,n,i,o,a){var s=r.inputs[t];if(o&&e.partialSig&&s&&s.redeemScript){var u=e.partialSig.map(function(t){return t.signature})||[];return{finalScriptSig:w.compile([].concat(Qd(u),[s.redeemScript])),finalScriptWitness:void 0}}if(r.anchorInputIndices.has(t))return{finalScriptSig:void 0,finalScriptWitness:ul.Buffer.from([0])};if(a&&i&&e.witnessScript){if(!e.partialSig||0===e.partialSig.length)throw new Error("No signatures for P2WSH input #".concat(t));if(pl.isP2WDAWitnessScript(e.witnessScript))return r.finalizeSecondaryP2WDA(t,e);if(r.csvInputIndices.has(t)){var f=[e.partialSig[0].signature,e.witnessScript];return{finalScriptSig:void 0,finalScriptWitness:Iy.witnessStackToScriptWitness(f)}}}return Ko(t,e,n,i,o,a,!0,r.unlockScript)}),r.signer=e.signer,r.network=e.network,r.noSignatures=e.noSignatures||!1,r.nonWitnessUtxo=e.nonWitnessUtxo,r.unlockScript=e.unlockScript,r.isBrowser="undefined"!=typeof window,e.txVersion&&(r.txVersion=e.txVersion),r}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&oy(t,e)}(t,Ld),function(t,e,r){return e&&ry(t.prototype,e),r&&ry(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"ignoreSignatureError",value:function(){this.ignoreSignatureErrors=!0}},{key:"getScriptAddress",value:function(){if(!this.scriptData||!this.scriptData.address)throw new Error("Tap data is required");return this.scriptData.address}},{key:"getTransaction",value:function(){return this.transaction.extractTransaction(!1)}},{key:"getTapAddress",value:function(){if(!this.tapData||!this.tapData.address)throw new Error("Tap data is required");return this.tapData.address}},{key:"disableRBF",value:function(){if(this.signed)throw new Error("Transaction is already signed");this.sequence=Md.FINAL;var t,e=Jd(this.inputs);try{for(e.s();!(t=e.n()).done;){var r=t.value;this.csvInputIndices.has(this.inputs.indexOf(r))||(r.sequence=Md.FINAL)}}catch(t){e.e(t)}finally{e.f()}}},{key:"getTweakerHash",value:function(){var t;return null===(t=this.tapData)||void 0===t?void 0:t.hash}},{key:"preEstimateTransactionFees",value:function(t,e,r,n,i){var o=10n+41n*e+68n*r;return(3n*o+(o+(144n*n+34n*i+(1n+35n*i+1n+n))))/4n*t}},{key:"generateTapData",value:function(){return{internalPubkey:this.internalPubKeyToXOnly(),network:this.network,name:Yi.P2TR}}},{key:"generateScriptAddress",value:function(){return{internalPubkey:this.internalPubKeyToXOnly(),network:this.network,name:Yi.P2TR}}},{key:"getSignerKey",value:function(){return this.signer}},{key:"signInput",value:(s=$d(Zd().m(function t(e,r,n,i){var o,a,s,u,f,c,l,h,p=arguments;return Zd().w(function(t){for(;;)switch(t.p=t.n){case 0:if(o=p.length>4&&void 0!==p[4]&&p[4],a=p.length>5&&void 0!==p[5]&&p[5],!this.anchorInputIndices.has(n)){t.n=1;break}return t.a(2);case 1:if(s=i.publicKey,u=Wd(r),o&&(u=!u),f=!1,c=!1,!u){t.n=6;break}return t.p=2,t.n=3,this.attemptSignTaproot(e,r,n,i,s);case 3:f=!0,t.n=5;break;case 4:t.p=4,l=t.v,this.error("Failed to sign Taproot script path input ".concat(n," (reverse: ").concat(o,"): ").concat(l.message)),c=!0;case 5:t.n=10;break;case 6:if(!o&&!Gd(r,s)){t.n=10;break}return t.p=7,t.n=8,this.signNonTaprootInput(i,e,n);case 8:f=!0,t.n=10;break;case 9:t.p=9,h=t.v,this.error("Failed to sign non-Taproot input ".concat(n,": ").concat(h.stack)),c=!0;case 10:if(f){t.n=14;break}if(!c||!a){t.n=11;break}throw new Error("Failed to sign input ".concat(n," with the provided signer."));case 11:return t.p=11,t.n=12,this.signInput(e,r,n,i,!0,c);case 12:t.n=14;break;case 13:throw t.p=13,t.v,new Error("Cannot sign input ".concat(n," with the provided signer."));case 14:return t.a(2)}},t,this,[[11,13],[7,9],[2,4]])})),function(t,e,r,n){return s.apply(this,arguments)})},{key:"splitArray",value:function(t,e){if(e<=0)throw new Error("Chunk size must be greater than 0.");for(var r=[],n=0;n<t.length;n+=e)r.push(t.slice(n,n+e));return r}},{key:"signInputs",value:(a=$d(Zd().m(function t(e){return Zd().w(function(t){for(;;)switch(t.n){case 0:if(!("multiSignPsbt"in this.signer)){t.n=2;break}return t.n=1,this.signInputsWalletBased(e);case 1:case 3:return t.a(2);case 2:return t.n=3,this.signInputsNonWalletBased(e)}},t,this)})),function(t){return a.apply(this,arguments)})},{key:"signInputsNonWalletBased",value:(o=$d(Zd().m(function t(e){var r,n,i,o,a,s,u,f,c,l,h;return Zd().w(function(t){for(;;)switch(t.n){case 0:if(r=e.data.inputs,n=20,i=this.splitArray(r,n),this.noSignatures){t.n=3;break}o=0;case 1:if(!(o<i.length)){t.n=3;break}for(a=i[o],s=[],u=o*n,f=0;f<a.length;f++){c=u+f,l=a[f];try{s.push(this.signInput(e,l,c,this.signer))}catch(t){this.log("Failed to sign input ".concat(c,": ").concat(t.stack))}}return t.n=2,Promise.all(s);case 2:o++,t.n=1;break;case 3:for(h=0;h<e.data.inputs.length;h++)e.finalizeInput(h,this.customFinalizerP2SH.bind(this));this.finalized=!0;case 4:return t.a(2)}},t,this)})),function(t){return o.apply(this,arguments)})},{key:"internalPubKeyToXOnly",value:function(){return bi(ul.Buffer.from(this.signer.publicKey))}},{key:"internalInit",value:function(){this.scriptData=k.p2tr(this.generateScriptAddress()),this.tapData=k.p2tr(this.generateTapData())}},{key:"tweakSigner",value:function(){this.tweakedSigner||(this.tweakedSigner=this.getTweakedSigner(!0))}},{key:"getTweakedSigner",value:function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0],e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.signer,r={network:this.network};if(t&&(r.tweakHash=this.getTweakerHash()),"privateKey"in e)return Vd.tweakSigner(e,r)}},{key:"generateP2SHRedeemScript",value:function(t){var e=k.p2wsh({redeem:{output:t},network:this.network});return k.p2sh({redeem:e,network:this.network}).output}},{key:"generateP2SHRedeemScriptLegacy",value:function(t){var e=S.hash160(this.signer.publicKey),r=w.compile([it.OP_DUP,it.OP_HASH160,e,it.OP_EQUALVERIFY,it.OP_CHECKSIG]),n=S.hash160(r),i=w.compile([it.OP_HASH160,n,it.OP_EQUAL]),o=k.p2wsh({redeem:{output:r},network:this.network}),a=k.p2sh({redeem:o,network:this.network});if(m.fromOutputScript(i,this.network)===t&&a.redeem&&a.redeem.output)return{redeemScript:r,outputScript:a.redeem.output}}},{key:"generateP2SHP2PKHRedeemScript",value:function(t){var e,r=ul.Buffer.isBuffer(this.signer.publicKey)?this.signer.publicKey:ul.Buffer.from(this.signer.publicKey,"hex"),n=k.p2wpkh({pubkey:r,network:this.network}),i=k.p2sh({redeem:n,network:this.network}),o=i.address;if(!(null===(e=i.redeem)||void 0===e?void 0:e.output))throw new Error("Failed to generate P2SH-P2WPKH redeem script");if(o===t&&i.redeem&&i.redeem.output&&i.output)return{redeemScript:i.redeem.output,outputScript:i.output}}},{key:"generatePsbtInputExtended",value:function(e,r){var n=ul.Buffer.from(e.scriptPubKey.hex,"hex"),i={hash:e.transactionId,index:e.outputIndex,sequence:this.sequence,witnessUtxo:{value:Number(e.value),script:n}};if(Fi(n)){if(!e.nonWitnessUtxo)throw new Error("Missing nonWitnessUtxo for P2PKH UTXO");i.nonWitnessUtxo=ul.Buffer.isBuffer(e.nonWitnessUtxo)?e.nonWitnessUtxo:ul.Buffer.from(e.nonWitnessUtxo,"hex")}else if(Di(n)||_e(n));else if(Hi(n))this.processP2WSHInput(e,i,r);else if(Mi(n)){var o;if(e.redeemScript)o=ul.Buffer.isBuffer(e.redeemScript)?e.redeemScript:ul.Buffer.from(e.redeemScript,"hex");else{if(!e.scriptPubKey.address)throw new Error("Missing redeemScript and no address to regenerate it for P2SH UTXO");var a=this.generateP2SHP2PKHRedeemScript(e.scriptPubKey.address);if(!a)throw new Error("Missing redeemScript for P2SH UTXO and unable to regenerate");o=a.redeemScript}i.redeemScript=o;var s=k.p2sh({redeem:{output:i.redeemScript}});if(!s.redeem)throw new Error("Failed to extract redeem script from P2SH UTXO");var u=s.redeem.output;if(!u)throw new Error("Failed to extract redeem output from P2SH UTXO");e.nonWitnessUtxo&&(i.nonWitnessUtxo=ul.Buffer.isBuffer(e.nonWitnessUtxo)?e.nonWitnessUtxo:ul.Buffer.from(e.nonWitnessUtxo,"hex")),Di(u)?delete i.nonWitnessUtxo:Hi(u)?(delete i.nonWitnessUtxo,this.processP2WSHInput(e,i,r)):delete i.witnessUtxo}else if(Ki(n)){if(this.sighashTypes){var f=t.calculateSignHash(this.sighashTypes);f&&(i.sighashType=f)}this.tweakSigner(),i.tapInternalKey=this.internalPubKeyToXOnly()}else if(function(t){return 4===t.length&&81===t[0]&&2===t[1]&&78===t[2]&&115===t[3]}(n))this.anchorInputIndices.add(r),i.isPayToAnchor=!0;else if(Ci(n)||Li(n)){if(!e.nonWitnessUtxo)throw new Error("Missing nonWitnessUtxo for P2PK or P2MS UTXO");i.nonWitnessUtxo=ul.Buffer.isBuffer(e.nonWitnessUtxo)?e.nonWitnessUtxo:ul.Buffer.from(e.nonWitnessUtxo,"hex")}else this.error("Unknown or unsupported script type for output: ".concat(e.scriptPubKey.hex));return 0===r&&(this.tapLeafScript&&(i.tapLeafScript=[this.tapLeafScript]),this.nonWitnessUtxo&&(i.nonWitnessUtxo=this.nonWitnessUtxo)),i}},{key:"processP2WSHInput",value:function(t,e,r){if(!t.witnessScript)throw new Error("Missing witnessScript for P2WSH UTXO");e.witnessScript=ul.Buffer.isBuffer(t.witnessScript)?t.witnessScript:ul.Buffer.from(t.witnessScript,"hex");var n=w.decompile(e.witnessScript);if(n&&this.isCSVScript(n)){var i=w.decompile(e.witnessScript);if(i&&this.isCSVScript(i)){this.csvInputIndices.add(r);var o=this.extractCSVBlocks(i);console.log("csvBlocks",o),e.sequence=this.setCSVSequence(o,this.sequence)}}}},{key:"secondsToCSVTimeUnits",value:function(t){return Math.floor(t/512)}},{key:"createTimeBasedCSV",value:function(t){var e=this.secondsToCSVTimeUnits(t);if(e>65535)throw new Error("Time units ".concat(e," exceeds maximum of 65,535"));return e|1<<22}},{key:"isCSVEnabled",value:function(t){return!(t&1<<31)}},{key:"extractCSVValue",value:function(t){return 65535&t}},{key:"finalizeSecondaryP2WDA",value:function(t,e){if(!e.partialSig||0===e.partialSig.length)throw new Error("No signature for P2WDA input #".concat(t));if(!e.witnessScript)throw new Error("No witness script for P2WDA input #".concat(t));var r=pl.createSimpleP2WDAWitness(e.partialSig[0].signature,e.witnessScript);return{finalScriptSig:void 0,finalScriptWitness:Iy.witnessStackToScriptWitness(r)}}},{key:"signInputsWalletBased",value:(i=$d(Zd().m(function t(e){var r,n;return Zd().w(function(t){for(;;)switch(t.n){case 0:return r=this.signer,t.n=1,r.multiSignPsbt([e]);case 1:for(n=0;n<e.data.inputs.length;n++)e.finalizeInput(n,this.customFinalizerP2SH.bind(this));this.finalized=!0;case 2:return t.a(2)}},t,this)})),function(t){return i.apply(this,arguments)})},{key:"isCSVScript",value:function(t){return t.some(function(t){return t===it.OP_CHECKSEQUENCEVERIFY})}},{key:"setCSVSequence",value:function(t,e){if(this.txVersion<2)throw new Error("CSV requires transaction version 2 or higher");if(t>65535)throw new Error("CSV blocks ".concat(t," exceeds maximum of 65,535"));var r=65535&t;return!!(t&1<<22)&&(r|=1<<22),e===Md.REPLACE_BY_FEE&&(r|=1<<25),2147483647&r}},{key:"getCSVType",value:function(t){return t&1<<22?Kd.TIMESTAMPS:Kd.BLOCKS}},{key:"extractCSVBlocks",value:function(t){for(var e=0;e<t.length;e++)if(t[e]===it.OP_CHECKSEQUENCEVERIFY&&e>0){var r=t[e-1];if(ul.Buffer.isBuffer(r))return w.number.decode(r);if("number"==typeof r){if(r===it.OP_0||r===it.OP_FALSE)return 0;if(r===it.OP_1NEGATE)return-1;if(r>=it.OP_1&&r<=it.OP_16)return r-it.OP_1+1;throw new Error("Unexpected raw number in script: ".concat(r))}}return 0}},{key:"attemptSignTaproot",value:(n=$d(Zd().m(function t(e,r,n,i,o){var a;return Zd().w(function(t){for(;;)switch(t.p=t.n){case 0:if(!this.isTaprootScriptSpend(r,o)){t.n=2;break}return t.n=1,this.signTaprootInput(i,e,n);case 1:t.n=9;break;case 2:if(i!==this.signer?a=this.getTweakedSigner(!0,i):(this.tweakedSigner||this.tweakSigner(),a=this.tweakedSigner),!a){t.n=8;break}return t.p=3,t.n=4,this.signTaprootInput(a,e,n);case 4:t.n=7;break;case 5:if(t.p=5,t.v,a=this.getTweakedSigner(!1,this.signer)){t.n=6;break}throw new Error("Failed to obtain tweaked signer for input ".concat(n,"."));case 6:return t.n=7,this.signTaprootInput(a,e,n);case 7:t.n=9;break;case 8:this.error("Failed to obtain tweaked signer for input ".concat(n,"."));case 9:return t.a(2)}},t,this,[[3,5]])})),function(t,e,r,i,o){return n.apply(this,arguments)})},{key:"isTaprootScriptSpend",value:function(t,e){if(t.tapLeafScript&&t.tapLeafScript.length>0){var r,n=Jd(t.tapLeafScript);try{for(n.s();!(r=n.n()).done;)if(qd(e,r.value.script))return!0}catch(t){n.e(t)}finally{n.f()}}return!1}},{key:"signTaprootInput",value:(r=$d(Zd().m(function t(e,r,n,i){return Zd().w(function(t){for(;;)switch(t.p=t.n){case 0:if(!("signTaprootInput"in e)){t.n=5;break}return t.p=1,t.n=2,e.signTaprootInput(r,n,i);case 2:t.n=4;break;case 3:throw t.p=3,t.v,new Error("Failed to sign Taproot input with provided signer.");case 4:t.n=6;break;case 5:r.signTaprootInput(n,e);case 6:return t.a(2)}},t,null,[[1,3]])})),function(t,e,n,i){return r.apply(this,arguments)})},{key:"signNonTaprootInput",value:(e=$d(Zd().m(function t(e,r,n){return Zd().w(function(t){for(;;)switch(t.n){case 0:if(!("signInput"in e)){t.n=2;break}return t.n=1,e.signInput(r,n);case 1:t.n=3;break;case 2:r.signInput(n,e);case 3:return t.a(2)}},t)})),function(t,r,n){return e.apply(this,arguments)})}],[{key:"readScriptWitnessToWitnessStack",value:function(t){var e=0;function r(){var r=_.decode(t,e);return e+=r.bytes,r.numberValue||0}function n(){return function(r){var n=t.subarray(e,e+r);return e+=r,n}(r())}return function(){for(var t=r(),e=[],i=0;i<t;i++)e.push(n());return e}()}},{key:"preEstimateTaprootTransactionFees",value:function(t,e,r,n,i,o){var a=10n+41n*e+68n*r;return(3n*a+(a+(1n*e+n*i+(arguments.length>6&&void 0!==arguments[6]?arguments[6]:32n)*e+(arguments.length>7&&void 0!==arguments[7]?arguments[7]:139n)*e+o)))/4n*t}},{key:"signInput",value:function(t,e,r,n,i){i&&i[0]&&(e.sighashType=i[0]),t.signInput(r,n,i.length?i:void 0)}},{key:"calculateSignHash",value:function(t){if(!t)throw new Error("Sighash types are required");var e,r=0,n=Jd(t);try{for(n.s();!(e=n.n()).done;)r|=e.value}catch(t){n.e(t)}finally{n.f()}return r||0}}]);var e,r,n,i,o,a,s}(),fy=i(8287).Buffer;function cy(t){return cy="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},cy(t)}function ly(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=hy(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}function hy(t,e){if(t){if("string"==typeof t)return py(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?py(t,e):void 0}}function py(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function dy(){var t,e,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",i=r.toStringTag||"@@toStringTag";function o(r,n,i,o){var u=n&&n.prototype instanceof s?n:s,f=Object.create(u.prototype);return yy(f,"_invoke",function(r,n,i){var o,s,u,f=0,c=i||[],l=!1,h={p:0,n:0,v:t,a:p,f:p.bind(t,4),d:function(e,r){return o=e,s=0,u=t,h.n=r,a}};function p(r,n){for(s=r,u=n,e=0;!l&&f&&!i&&e<c.length;e++){var i,o=c[e],p=h.p,d=o[2];r>3?(i=d===n)&&(u=o[(s=o[4])?5:(s=3,3)],o[4]=o[5]=t):o[0]<=p&&((i=r<2&&p<o[1])?(s=0,h.v=n,h.n=o[1]):p<d&&(i=r<3||o[0]>n||n>d)&&(o[4]=r,o[5]=n,h.n=d,s=0))}if(i||r>1)return a;throw l=!0,n}return function(i,c,d){if(f>1)throw TypeError("Generator is already running");for(l&&1===c&&p(c,d),s=c,u=d;(e=s<2?t:u)||!l;){o||(s?s<3?(s>1&&(h.n=-1),p(s,u)):h.n=u:h.v=u);try{if(f=2,o){if(s||(i="next"),e=o[i]){if(!(e=e.call(o,u)))throw TypeError("iterator result is not an object");if(!e.done)return e;u=e.value,s<2&&(s=0)}else 1===s&&(e=o.return)&&e.call(o),s<2&&(u=TypeError("The iterator does not provide a '"+i+"' method"),s=1);o=t}else if((e=(l=h.n<0)?u:r.call(n,h))!==a)break}catch(e){o=t,s=1,u=e}finally{f=1}}return{value:e,done:l}}}(r,i,o),!0),f}var a={};function s(){}function u(){}function f(){}e=Object.getPrototypeOf;var c=[][n]?e(e([][n]())):(yy(e={},n,function(){return this}),e),l=f.prototype=s.prototype=Object.create(c);function h(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,f):(t.__proto__=f,yy(t,i,"GeneratorFunction")),t.prototype=Object.create(l),t}return u.prototype=f,yy(l,"constructor",f),yy(f,"constructor",u),u.displayName="GeneratorFunction",yy(f,i,"GeneratorFunction"),yy(l),yy(l,i,"Generator"),yy(l,n,function(){return this}),yy(l,"toString",function(){return"[object Generator]"}),(dy=function(){return{w:o,m:h}})()}function yy(t,e,r,n){var i=Object.defineProperty;try{i({},"",{})}catch(t){i=0}yy=function(t,e,r,n){function o(e,r){yy(t,e,function(t){return this._invoke(e,r,t)})}e?i?i(t,e,{value:r,enumerable:!n,configurable:!n,writable:!n}):t[e]=r:(o("next",0),o("throw",1),o("return",2))},yy(t,e,r,n)}function by(t,e,r,n,i,o,a){try{var s=t[o](a),u=s.value}catch(t){return void r(t)}s.done?e(u):Promise.resolve(u).then(n,i)}function gy(t){return function(){var e=this,r=arguments;return new Promise(function(n,i){var o=t.apply(e,r);function a(t){by(o,n,i,a,s,"next",t)}function s(t){by(o,n,i,a,s,"throw",t)}a(void 0)})}}function vy(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,ky(n.key),n)}}function wy(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(wy=function(){return!!t})()}function my(){return my="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,r){var n=function(t,e){for(;!{}.hasOwnProperty.call(t,e)&&null!==(t=Sy(t)););return t}(t,e);if(n){var i=Object.getOwnPropertyDescriptor(n,e);return i.get?i.get.call(arguments.length<3?t:r):i.value}},my.apply(null,arguments)}function Sy(t){return Sy=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Sy(t)}function _y(t,e){return _y=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},_y(t,e)}function Ey(t,e,r){return(e=ky(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function ky(t){var e=function(t){if("object"!=cy(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=cy(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==cy(e)?e:e+""}ur(fa);var Oy=540n,Ty=297n,Ay=fy.from("51024e73","hex"),Iy=function(){function t(e){var r,n,i,o;if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),Ey(o=function(t,e,r){return e=Sy(e),function(t,e){if(e&&("object"==cy(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,wy()?Reflect.construct(e,r||[],Sy(t).constructor):e.apply(t,r))}(this,t,[e]),"logColor","#785def"),Ey(o,"overflowFees",0n),Ey(o,"transactionFee",0n),Ey(o,"estimatedFees",0n),Ey(o,"updateInputs",[]),Ey(o,"outputs",[]),Ey(o,"feeOutput",null),Ey(o,"_maximumFeeRate",1e8),e.estimatedFees&&(o.estimatedFees=e.estimatedFees),o.signer=e.signer,o.network=e.network,o.feeRate=e.feeRate,o.priorityFee=null!==(r=e.priorityFee)&&void 0!==r?r:0n,o.gasSatFee=null!==(n=e.gasSatFee)&&void 0!==n?n:0n,o.utxos=e.utxos,o.optionalInputs=e.optionalInputs||[],o.to=e.to||void 0,e.note&&("string"==typeof e.note?o.note=fy.from(e.note,"utf8"):o.note=e.note),o.anchor=null!==(i=e.anchor)&&void 0!==i&&i,o.isPubKeyDestination=!!o.to&&vl.isValidPublicKey(o.to,o.network),o.optionalOutputs=e.optionalOutputs,o.from=t.getFrom(e.from,o.signer,o.network),o.totalInputAmount=o.calculateTotalUTXOAmount(),o.calculateTotalVOutAmount()<o.totalInputAmount)throw new Error("Vout value is less than the value to send");return o.transaction=new Ao({network:o.network,version:o.txVersion}),o}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&_y(t,e)}(t,uy),function(t,e,r){return e&&vy(t.prototype,e),r&&vy(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"addOPReturn",value:function(t){var e=w.compile([it.OP_RETURN,t]);this.addOutput({value:0,script:e})}},{key:"addAnchor",value:function(){this.addOutput({value:0,script:Ay})}},{key:"getFundingTransactionParameters",value:(f=gy(dy().m(function t(){var e,r;return dy().w(function(t){for(;;)switch(t.n){case 0:if(this.estimatedFees){t.n=2;break}return t.n=1,this.estimateTransactionFees();case 1:this.estimatedFees=t.v;case 2:return t.a(2,{utxos:this.utxos,to:this.getScriptAddress(),signer:this.signer,network:this.network,feeRate:this.feeRate,priorityFee:null!==(e=this.priorityFee)&&void 0!==e?e:0n,gasSatFee:null!==(r=this.gasSatFee)&&void 0!==r?r:0n,from:this.from,amount:this.estimatedFees,optionalOutputs:this.optionalOutputs,optionalInputs:this.optionalInputs})}},t,this)})),function(){return f.apply(this,arguments)})},{key:"setDestinationAddress",value:function(t){this.to=t}},{key:"setMaximumFeeRate",value:function(t){this._maximumFeeRate=t}},{key:"signTransaction",value:(u=gy(dy().m(function t(){return dy().w(function(t){for(;;)switch(t.n){case 0:if(this.utxos.length){t.n=1;break}throw new Error("No UTXOs specified");case 1:if(!this.to||this.isPubKeyDestination||bc.verifyContractAddress(this.to,this.network)){t.n=2;break}throw new Error("Invalid contract address. The contract address must be a taproot address.");case 2:if(!this.signed){t.n=3;break}throw new Error("Transaction is already signed");case 3:return this.signed=!0,t.n=4,this.buildTransaction();case 4:return t.n=5,this.internalBuildTransaction(this.transaction);case 5:if(!t.v){t.n=7;break}if(!this.regenerated){t.n=6;break}throw new Error("Transaction was regenerated");case 6:return t.a(2,this.transaction.extractTransaction(!0,!0));case 7:throw new Error("Could not sign transaction");case 8:return t.a(2)}},t,this)})),function(){return u.apply(this,arguments)})},{key:"generateTransactionMinimalSignatures",value:(s=gy(dy().m(function t(){var e,r,n,i,o=arguments;return dy().w(function(t){for(;;)switch(t.n){case 0:if(e=o.length>0&&void 0!==o[0]&&o[0],!this.to||this.isPubKeyDestination||bc.verifyContractAddress(this.to,this.network)){t.n=1;break}throw new Error("Invalid contract address. The contract address must be a taproot address.");case 1:return t.n=2,this.buildTransaction();case 2:if(0===this.transaction.data.inputs.length){for(r=this.getInputs(),n=this.getOutputs(),this.transaction.setMaximumFeeRate(this._maximumFeeRate),this.transaction.addInputs(r,e),i=0;i<this.updateInputs.length;i++)this.transaction.updateInput(i,this.updateInputs[i]);this.transaction.addOutputs(n)}case 3:return t.a(2)}},t,this)})),function(){return s.apply(this,arguments)})},{key:"signPSBT",value:(a=gy(dy().m(function t(){return dy().w(function(t){for(;;)switch(t.n){case 0:return t.n=1,this.signTransaction();case 1:if(!t.v){t.n=2;break}return t.a(2,this.transaction);case 2:throw new Error("Could not sign transaction");case 3:return t.a(2)}},t,this)})),function(){return a.apply(this,arguments)})},{key:"addInput",value:function(t){this.inputs.push(t)}},{key:"addOutput",value:function(e){if(0===e.value){var r=e;if(!r.script||0===r.script.length)throw new Error("Output value is 0 and no script provided");if(r.script.length<2)throw new Error("Output script is too short");if(r.script[0]!==it.OP_RETURN&&!r.script.equals(Ay))throw new Error("Output script must start with OP_RETURN or be an ANCHOR when value is 0")}else if(e.value<t.MINIMUM_DUST)throw new Error("Output value is less than the minimum dust ".concat(e.value," < ").concat(t.MINIMUM_DUST));this.outputs.push(e)}},{key:"toAddress",value:function(){return this.to}},{key:"address",value:function(){var t;return null===(t=this.tapData)||void 0===t?void 0:t.address}},{key:"estimateTransactionFees",value:(o=gy(dy().m(function t(){var e,r,n,i;return dy().w(function(t){for(;;)switch(t.n){case 0:if(this.utxos.length){t.n=1;break}throw new Error("No UTXOs specified");case 1:if(!this.estimatedFees){t.n=2;break}return t.a(2,this.estimatedFees);case 2:return e=new Ao({network:this.network}),t.n=3,this.internalBuildTransaction(e);case 3:if(!t.v){t.n=4;break}return r=e.extractTransaction(!0,!0),n=r.virtualSize(),i=this.feeRate*n,this.estimatedFees=BigInt(Math.ceil(i)+1),t.a(2,this.estimatedFees);case 4:throw new Error("Could not build transaction to estimate fee. Something went wrong while building the transaction.");case 5:return t.a(2)}},t,this)})),function(){return o.apply(this,arguments)})},{key:"rebuildFromBase64",value:(i=gy(dy().m(function t(e){return dy().w(function(t){for(;;)switch(t.n){case 0:return this.transaction=Ao.fromBase64(e,{network:this.network,version:this.txVersion}),this.signed=!1,this.sighashTypes=[hi.SIGHASH_ANYONECANPAY,hi.SIGHASH_ALL],t.n=1,this.signPSBT();case 1:return t.a(2,t.v)}},t,this)})),function(t){return i.apply(this,arguments)})},{key:"setPSBT",value:function(t){this.transaction=t}},{key:"getInputs",value:function(){return this.inputs}},{key:"getOutputs",value:function(){var t=function(t){return function(t){if(Array.isArray(t))return py(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||hy(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}(this.outputs);return this.feeOutput&&t.push(this.feeOutput),t}},{key:"getOptionalOutputValue",value:function(){if(!this.optionalOutputs)return 0n;for(var t=0n,e=0;e<this.optionalOutputs.length;e++)t+=BigInt(this.optionalOutputs[e].value);return t}},{key:"addRefundOutput",value:(n=gy(dy().m(function e(r){var n,i;return dy().w(function(e){for(;;)switch(e.n){case 0:if(this.note&&this.addOPReturn(this.note),this.anchor&&this.addAnchor(),!((n=this.totalInputAmount-r)>=t.MINIMUM_DUST)){e.n=6;break}if(!vl.isValidP2TRAddress(this.from,this.network)){e.n=2;break}return e.n=1,this.setFeeOutput({value:Number(n),address:this.from,tapInternalKey:this.internalPubKeyToXOnly()});case 1:e.n=5;break;case 2:if(!vl.isValidPublicKey(this.from,this.network)){e.n=4;break}return i=w.compile([fy.from(this.from.replace("0x",""),"hex"),it.OP_CHECKSIG]),e.n=3,this.setFeeOutput({value:Number(n),script:i});case 3:e.n=5;break;case 4:return e.n=5,this.setFeeOutput({value:Number(n),address:this.from});case 5:return e.a(2);case 6:this.warn("Amount to send back (".concat(n," sat) is less than the minimum dust (").concat(t.MINIMUM_DUST," sat), it will be consumed in fees instead."));case 7:return e.a(2)}},e,this)})),function(t){return n.apply(this,arguments)})},{key:"addValueToToOutput",value:function(e){if(e<t.MINIMUM_DUST)throw new Error("Value to send is less than the minimum dust ".concat(e," < ").concat(t.MINIMUM_DUST));var r,n=ly(this.outputs);try{for(n.s();!(r=n.n()).done;){var i=r.value;if("address"in i&&i.address===this.to)return void(i.value+=Number(e))}}catch(t){n.e(t)}finally{n.f()}throw new Error("Output not found")}},{key:"getTransactionOPNetFee",value:function(){var e=this.priorityFee+this.gasSatFee;return e>t.MINIMUM_DUST?e:t.MINIMUM_DUST}},{key:"calculateTotalUTXOAmount",value:function(){var t,e=0n,r=ly(this.utxos);try{for(r.s();!(t=r.n()).done;)e+=t.value.value}catch(t){r.e(t)}finally{r.f()}var n,i=ly(this.optionalInputs);try{for(i.s();!(n=i.n()).done;)e+=n.value.value}catch(t){i.e(t)}finally{i.f()}return e}},{key:"calculateTotalVOutAmount",value:function(){var t,e=0n,r=ly(this.utxos);try{for(r.s();!(t=r.n()).done;)e+=t.value.value}catch(t){r.e(t)}finally{r.f()}var n,i=ly(this.optionalInputs);try{for(i.s();!(n=i.n()).done;)e+=n.value.value}catch(t){i.e(t)}finally{i.f()}return e}},{key:"addOptionalOutputsAndGetAmount",value:function(){if(!this.optionalOutputs)return 0n;for(var t=0n,e=0;e<this.optionalOutputs.length;e++)this.addOutput(this.optionalOutputs[e]),t+=BigInt(this.optionalOutputs[e].value);return t}},{key:"addInputsFromUTXO",value:function(){if(this.utxos.length){if(this.totalInputAmount<t.MINIMUM_DUST)throw new Error("Total input amount is ".concat(this.totalInputAmount," sat which is less than the minimum dust ").concat(t.MINIMUM_DUST," sat."));for(var e=0;e<this.utxos.length;e++){var r=this.utxos[e],n=this.generatePsbtInputExtended(r,e);this.addInput(n)}}if(this.optionalInputs)for(var i=this.utxos.length;i<this.optionalInputs.length+this.utxos.length;i++){var o=this.optionalInputs[i-this.utxos.length],a=this.generatePsbtInputExtended(o,i,!0);this.addInput(a)}}},{key:"internalInit",value:function(){this.verifyUTXOValidity(),function(t,e,r){var n=my(Sy(t.prototype),"internalInit",r);return"function"==typeof n?function(t){return n.apply(r,t)}:n}(t,0,this)([])}},{key:"updateInput",value:function(t){this.updateInputs.push(t)}},{key:"getWitness",value:function(){if(!this.tapData||!this.tapData.witness)throw new Error("Witness is required");if(0===this.tapData.witness.length)throw new Error("Witness is empty");return this.tapData.witness[this.tapData.witness.length-1]}},{key:"getTapOutput",value:function(){if(!this.tapData||!this.tapData.output)throw new Error("Tap data is required");return this.tapData.output}},{key:"verifyUTXOValidity",value:function(){var t,e=ly(this.utxos);try{for(e.s();!(t=e.n()).done;)if(!t.value.scriptPubKey)throw new Error("Address is required")}catch(t){e.e(t)}finally{e.f()}var r,n=ly(this.optionalInputs);try{for(n.s();!(r=n.n()).done;)if(!r.value.scriptPubKey)throw new Error("Address is required")}catch(t){n.e(t)}finally{n.f()}}},{key:"setFeeOutput",value:(r=gy(dy().m(function e(r){var n,i,o,a;return dy().w(function(e){for(;;)switch(e.n){case 0:return n=r.value,e.n=1,this.estimateTransactionFees();case 1:if(i=e.v,r.value=n-Number(i),!(r.value<t.MINIMUM_DUST)){e.n=3;break}if(this.feeOutput=null,!(r.value<0)){e.n=2;break}throw new Error("setFeeOutput: Insufficient funds to pay the fees. Fee: ".concat(i," < Value: ").concat(n,". Total input: ").concat(this.totalInputAmount," sat"));case 2:e.n=6;break;case 3:return this.feeOutput=r,e.n=4,this.estimateTransactionFees();case 4:if(!((o=e.v)>BigInt(n))){e.n=5;break}throw new Error("estimateTransactionFees: Insufficient funds to pay the fees. Fee: ".concat(o," > Value: ").concat(n,". Total input: ").concat(this.totalInputAmount," sat"));case 5:(a=n-Number(o))<t.MINIMUM_DUST?this.feeOutput=null:this.feeOutput.value=a,this.overflowFees=BigInt(a);case 6:return e.a(2)}},e,this)})),function(t){return r.apply(this,arguments)})},{key:"internalBuildTransaction",value:(e=gy(dy().m(function t(e){var r,n,i,o,a,s,u=arguments;return dy().w(function(t){for(;;)switch(t.p=t.n){case 0:if(r=u.length>1&&void 0!==u[1]&&u[1],0===e.data.inputs.length){for(n=this.getInputs(),i=this.getOutputs(),e.setMaximumFeeRate(this._maximumFeeRate),e.addInputs(n,r),o=0;o<this.updateInputs.length;o++)e.updateInput(o,this.updateInputs[o]);e.addOutputs(i)}return t.p=1,t.n=2,this.signInputs(e);case 2:return this.finalized&&(this.transactionFee=BigInt(e.getFee())),t.a(2,!0);case 3:return t.p=3,s=t.v,a=s,this.error("[internalBuildTransaction] Something went wrong while getting building the transaction: ".concat(a.stack)),t.a(2,!1)}},t,this,[[1,3]])})),function(t){return e.apply(this,arguments)})}],[{key:"getFrom",value:function(t,e,r){return t||bc.getTaprootAddress(e,r)}},{key:"witnessStackToScriptWitness",value:function(t){var e,r=fy.allocUnsafe(0);function n(t){var e=r.length,n=_.encodingLength(t);r=fy.concat([r,fy.allocUnsafe(n)]),_.encode(t,r,e)}return n((e=t).length),e.forEach(function(t){n(t.length),function(t){r=fy.concat([r,fy.from(t)])}(t)}),r}}]);var e,r,n,i,o,a,s,u,f}();Ey(Iy,"LOCK_LEAF_SCRIPT",w.compile([it.OP_FALSE,it.OP_VERIFY])),Ey(Iy,"MINIMUM_DUST",50n);var Py=i(8287).Buffer;function xy(t){return xy="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},xy(t)}function By(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Ry(n.key),n)}}function Ry(t){var e=function(t){if("object"!=xy(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=xy(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==xy(e)?e:e+""}var Uy=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)}return function(t,e,r){return r&&By(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,0,[{key:"getContractAddress",value:function(e){var r=e.network||b.bitcoin,n=[{output:new Jh(e.deployerPubKey,bi(e.contractSaltPubKey),r).compile(e.bytecode,e.originalSalt,e.challenge,e.priorityFee,e.calldata,e.features),version:t.TAP_SCRIPT_VERSION},{output:Iy.LOCK_LEAF_SCRIPT,version:t.TAP_SCRIPT_VERSION}];return t.generateAddressFromScript(e,n)}},{key:"verifyControlBlock",value:function(e,r){var n=e.network||b.bitcoin,i=new Jh(e.deployerPubKey,bi(e.contractSaltPubKey),n).compile(e.bytecode,e.originalSalt,e.challenge,e.priorityFee,e.calldata,e.features),o=[{output:i,version:t.TAP_SCRIPT_VERSION},{output:Iy.LOCK_LEAF_SCRIPT,version:t.TAP_SCRIPT_VERSION}],a=k.p2tr({internalPubkey:bi(e.deployerPubKey),network:n,scriptTree:o,redeem:{output:i,redeemVersion:t.TAP_SCRIPT_VERSION}}).witness;return!(!a||0===a.length)&&a[a.length-1].equals(r)}},{key:"getContractSeed",value:function(t,e,r){var n=S.hash256(e),i=Py.concat([t,r,n]);return S.hash256(i)}},{key:"generateAddressFromScript",value:function(t,e){var r=t.network||b.bitcoin,n={internalPubkey:bi(t.deployerPubKey),network:r,scriptTree:e};return k.p2tr(n).address}}])}();!function(t,e){(e=Ry(e))in t?Object.defineProperty(t,e,{value:192,enumerable:!0,configurable:!0,writable:!0}):t[e]=192}(Uy,"TAP_SCRIPT_VERSION");var Ny=i(8287).Buffer;function jy(t){return jy="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},jy(t)}function Ly(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Cy(n.key),n)}}function Cy(t){var e=function(t){if("object"!=jy(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=jy(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==jy(e)?e:e+""}var Fy=function(){return function(t,e){return e&&Ly(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}(function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)},[{key:"sha256",value:function(t){return S.sha256(Ny.from(t))}},{key:"tweakAndSignMessage",value:function(t,e,r){var n=Vd.tweakSigner(t,{network:r});return this.signMessage(n,e)}},{key:"signMessage",value:function(t,e){if("string"==typeof e&&(e=Ny.from(e,"utf-8")),!t.privateKey)throw new Error("Private key not found in keypair.");var r=this.sha256(e);return{signature:ua.signSchnorr(r,t.privateKey),message:r}}},{key:"verifySignature",value:function(t,e,r){if("string"==typeof e&&(e=Ny.from(e,"utf-8")),64!==r.length)throw new Error("Invalid signature length.");var n=this.sha256(e);return ua.verifySchnorr(n,bi(Ny.from(t)),r)}},{key:"tweakAndVerifySignature",value:function(t,e,r){var n=bc.tweakPublicKey(Ny.from(t));return this.verifySignature(n,e,r)}}])}(),Dy=new Fy,Hy=i(8287).Buffer;function My(t){return My="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},My(t)}function Ky(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Vy(n.key),n)}}function Vy(t){var e=function(t){if("object"!=My(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=My(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==My(e)?e:e+""}var Wy=function(){function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:b.bitcoin;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.network=r;var n=e.startsWith("0x")?e.replace("0x",""):e;sl.isValidHex(n)?this._keypair=bc.fromPrivateKey(Hy.from(n,"hex"),this.network):this._keypair=bc.fromWIF(n,this.network),this._bufferPubKey=this._keypair.publicKey,this._address=new ih(this._keypair.publicKey),this._p2tr=this._address.p2tr(this.network),this._p2wpkh=this._address.p2wpkh(this.network),this._legacy=this._address.p2pkh(this.network),this._segwitLegacy=this._address.p2wpkh(this.network),this._p2wda=this._address.p2wda(this.network),this._tweakedKey=this._address.toBuffer()}return function(t,e,r){return e&&Ky(t.prototype,e),r&&Ky(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"address",get:function(){return this._address}},{key:"tweakedPubKeyKey",get:function(){return this._tweakedKey}},{key:"keypair",get:function(){if(!this._keypair)throw new Error("Keypair not set");return this._keypair}},{key:"p2wpkh",get:function(){return this._p2wpkh}},{key:"p2tr",get:function(){return this._p2tr}},{key:"p2wda",get:function(){return this._p2wda}},{key:"legacy",get:function(){return this._legacy}},{key:"addresses",get:function(){return[this.p2wpkh,this.p2tr,this.legacy,this.segwitLegacy]}},{key:"segwitLegacy",get:function(){return this._segwitLegacy}},{key:"publicKey",get:function(){if(!this._bufferPubKey)throw new Error("Public key not set");return this._bufferPubKey}},{key:"xOnly",get:function(){if(!this.keypair)throw new Error("Keypair not set");return bi(this._bufferPubKey)}}],[{key:"fromWif",value:function(e){return new t(e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:b.bitcoin)}},{key:"new",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:b.bitcoin;return new t(bc.generateWallet(e).privateKey,e)}}])}();function Gy(t){return Gy="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Gy(t)}function qy(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,zy(n.key),n)}}function zy(t){var e=function(t){if("object"!=Gy(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Gy(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Gy(e)?e:e+""}var Zy,Xy,Yy,$y=function(){return function(t,e,r){return e&&qy(t.prototype,e),r&&qy(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:b.bitcoin;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.network=e},[{key:"getAddress",value:function(){return this.address}}],[{key:"getAddress",value:function(){throw new Error("Method not implemented.")}}])}();!function(t){t[t.Bitcoin=0]="Bitcoin",t[t.Fractal=1]="Fractal"}(Zy||(Zy={})),function(t){t[t.GENERIC=0]="GENERIC",t[t.FUNDING=1]="FUNDING",t[t.DEPLOYMENT=2]="DEPLOYMENT",t[t.INTERACTION=3]="INTERACTION",t[t.MULTI_SIG=4]="MULTI_SIG",t[t.CUSTOM_CODE=5]="CUSTOM_CODE",t[t.CHALLENGE_SOLUTION=6]="CHALLENGE_SOLUTION"}(Xy||(Xy={})),function(t){t[t.Roswell=0]="Roswell",t[t.Rachel=1]="Rachel",t[t.Kecksburg=2]="Kecksburg",t[t.Phoenix=3]="Phoenix",t[t.Aurora=4]="Aurora",t[t.Rendlesham=5]="Rendlesham",t[t.Lazar=6]="Lazar",t[t.ShagHarbor=7]="ShagHarbor",t[t.Exeter=8]="Exeter",t[t.Stephenville=9]="Stephenville",t[t.Valensole=10]="Valensole",t[t.Socorro=11]="Socorro",t[t.Pascagoula=12]="Pascagoula",t[t.Tehran=13]="Tehran",t[t.Westall=14]="Westall",t[t.Hopkinsville=15]="Hopkinsville",t[t.Belgium=16]="Belgium",t[t.Breeze=17]="Breeze",t[t.Flatwoods=18]="Flatwoods",t[t.Maury=20]="Maury",t[t.Varginha=21]="Varginha",t[t.Trindade=22]="Trindade",t[t.Levelland=23]="Levelland",t[t.Wanaque=24]="Wanaque",t[t.Coyame=25]="Coyame",t[t.Delphos=26]="Delphos"}(Yy||(Yy={}));var Jy={CONSENSUS:Yy.Roswell,CONSENSUS_NAME:"Roswell",ENABLED_AT_BLOCK:0n};function Qy(t){return Qy="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Qy(t)}var tb=function(t,e,r){return(e=function(t){var e=function(t){if("object"!=Qy(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Qy(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Qy(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}({},Yy.Roswell,Jy),eb=Yy.Roswell,rb=tb[eb],nb=i(8287).Buffer;function ib(t){return ib="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ib(t)}function ob(t,e){if(t){if("string"==typeof t)return ab(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?ab(t,e):void 0}}function ab(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function sb(){var t,e,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",i=r.toStringTag||"@@toStringTag";function o(r,n,i,o){var u=n&&n.prototype instanceof s?n:s,f=Object.create(u.prototype);return ub(f,"_invoke",function(r,n,i){var o,s,u,f=0,c=i||[],l=!1,h={p:0,n:0,v:t,a:p,f:p.bind(t,4),d:function(e,r){return o=e,s=0,u=t,h.n=r,a}};function p(r,n){for(s=r,u=n,e=0;!l&&f&&!i&&e<c.length;e++){var i,o=c[e],p=h.p,d=o[2];r>3?(i=d===n)&&(u=o[(s=o[4])?5:(s=3,3)],o[4]=o[5]=t):o[0]<=p&&((i=r<2&&p<o[1])?(s=0,h.v=n,h.n=o[1]):p<d&&(i=r<3||o[0]>n||n>d)&&(o[4]=r,o[5]=n,h.n=d,s=0))}if(i||r>1)return a;throw l=!0,n}return function(i,c,d){if(f>1)throw TypeError("Generator is already running");for(l&&1===c&&p(c,d),s=c,u=d;(e=s<2?t:u)||!l;){o||(s?s<3?(s>1&&(h.n=-1),p(s,u)):h.n=u:h.v=u);try{if(f=2,o){if(s||(i="next"),e=o[i]){if(!(e=e.call(o,u)))throw TypeError("iterator result is not an object");if(!e.done)return e;u=e.value,s<2&&(s=0)}else 1===s&&(e=o.return)&&e.call(o),s<2&&(u=TypeError("The iterator does not provide a '"+i+"' method"),s=1);o=t}else if((e=(l=h.n<0)?u:r.call(n,h))!==a)break}catch(e){o=t,s=1,u=e}finally{f=1}}return{value:e,done:l}}}(r,i,o),!0),f}var a={};function s(){}function u(){}function f(){}e=Object.getPrototypeOf;var c=[][n]?e(e([][n]())):(ub(e={},n,function(){return this}),e),l=f.prototype=s.prototype=Object.create(c);function h(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,f):(t.__proto__=f,ub(t,i,"GeneratorFunction")),t.prototype=Object.create(l),t}return u.prototype=f,ub(l,"constructor",f),ub(f,"constructor",u),u.displayName="GeneratorFunction",ub(f,i,"GeneratorFunction"),ub(l),ub(l,i,"Generator"),ub(l,n,function(){return this}),ub(l,"toString",function(){return"[object Generator]"}),(sb=function(){return{w:o,m:h}})()}function ub(t,e,r,n){var i=Object.defineProperty;try{i({},"",{})}catch(t){i=0}ub=function(t,e,r,n){function o(e,r){ub(t,e,function(t){return this._invoke(e,r,t)})}e?i?i(t,e,{value:r,enumerable:!n,configurable:!n,writable:!n}):t[e]=r:(o("next",0),o("throw",1),o("return",2))},ub(t,e,r,n)}function fb(t,e,r,n,i,o,a){try{var s=t[o](a),u=s.value}catch(t){return void r(t)}s.done?e(u):Promise.resolve(u).then(n,i)}function cb(t){return function(){var e=this,r=arguments;return new Promise(function(n,i){var o=t.apply(e,r);function a(t){fb(o,n,i,a,s,"next",t)}function s(t){fb(o,n,i,a,s,"throw",t)}a(void 0)})}}function lb(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,vb(n.key),n)}}function hb(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(hb=function(){return!!t})()}function pb(t,e,r,n){var i=db(yb(1&n?t.prototype:t),e,r);return 2&n&&"function"==typeof i?function(t){return i.apply(r,t)}:i}function db(){return db="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,r){var n=function(t,e){for(;!{}.hasOwnProperty.call(t,e)&&null!==(t=yb(t)););return t}(t,e);if(n){var i=Object.getOwnPropertyDescriptor(n,e);return i.get?i.get.call(arguments.length<3?t:r):i.value}},db.apply(null,arguments)}function yb(t){return yb=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},yb(t)}function bb(t,e){return bb=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},bb(t,e)}function gb(t,e,r){return(e=vb(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function vb(t){var e=function(t){if("object"!=ib(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=ib(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==ib(e)?e:e+""}var wb=function(){function t(e){var r;if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),gb(r=function(t,e,r){return e=yb(e),function(t,e){if(e&&("object"==ib(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,hb()?Reflect.construct(e,r||[],yb(t).constructor):e.apply(t,r))}(this,t,[e]),"type",Xy.CUSTOM_CODE),gb(r,"tapLeafScript",null),gb(r,"targetScriptRedeem",null),gb(r,"leftOverFundsScriptRedeem",null),gb(r,"customFinalizer",function(t,e){if(!r.tapLeafScript)throw new Error("Tap leaf script is required");var n=r.getScriptSolution(e).concat(r.tapLeafScript.script).concat(r.tapLeafScript.controlBlock);if(r.annexData&&r.annexData.length>0){var i=80===r.annexData[0]?r.annexData:nb.concat([nb.from([80]),r.annexData]);n.push(i)}return{finalScriptWitness:Iy.witnessStackToScriptWitness(n)}}),!e.script)throw new Error("Bitcoin script is required");if(!e.witnesses)throw new Error("Witness(es) are required");return r.witnesses=e.witnesses,r.randomBytes=e.randomBytes||sl.rndBytes(),r.scriptSeed=r.getContractSeed(),r.contractSigner=bc.fromSeedKeyPair(r.scriptSeed,r.network),r.generator=new Hh(r.internalPubKeyToXOnly(),r.network),r.compiledTargetScript=r.generator.compile(e.script),r.scriptTree=r.getScriptTree(),r.internalInit(),r._scriptAddress=xp.generatePKSH(r.scriptSeed,r.network),r}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&bb(t,e)}(t,Iy),function(t,e){return e&&lb(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"scriptAddress",get:function(){return this._scriptAddress}},{key:"p2trAddress",get:function(){return this.to||this.getScriptAddress()}},{key:"getRndBytes",value:function(){return this.randomBytes}},{key:"contractSignerXOnlyPubKey",value:function(){return bi(nb.from(this.contractSigner.publicKey))}},{key:"buildTransaction",value:(r=cb(sb().m(function t(){var e,r;return sb().w(function(t){for(;;)switch(t.n){case 0:if(this.to||(this.to=this.getScriptAddress()),e=this.contractSigner?this.targetScriptRedeem:this.leftOverFundsScriptRedeem){t.n=1;break}throw new Error("Left over funds script redeem is required");case 1:if(e.redeemVersion){t.n=2;break}throw new Error("Left over funds script redeem version is required");case 2:if(e.output){t.n=3;break}throw new Error("Left over funds script redeem output is required");case 3:return this.tapLeafScript={leafVersion:e.redeemVersion,script:e.output,controlBlock:this.getWitness()},this.addInputsFromUTXO(),r=this.getTransactionOPNetFee(),this.addOutput({value:Number(r),address:this.to}),t.n=4,this.addRefundOutput(r+this.addOptionalOutputsAndGetAmount());case 4:return t.a(2)}},t,this)})),function(){return r.apply(this,arguments)})},{key:"signInputs",value:(e=cb(sb().m(function e(r){var n;return sb().w(function(e){for(;;)switch(e.n){case 0:if(this.contractSigner){e.n=2;break}return e.n=1,pb(t,"signInputs",this,3)([r]);case 1:return e.a(2);case 2:for(n=0;n<r.data.inputs.length;n++)if(0===n){try{r.signInput(0,this.contractSigner)}catch(t){}r.signInput(0,this.getSignerKey()),r.finalizeInput(0,this.customFinalizer)}else r.signInput(n,this.getSignerKey()),r.finalizeInput(n);case 3:return e.a(2)}},e,this)})),function(t){return e.apply(this,arguments)})},{key:"generateScriptAddress",value:function(){return{internalPubkey:this.internalPubKeyToXOnly(),network:this.network,scriptTree:this.scriptTree,name:Yi.P2TR}}},{key:"generateTapData",value:function(){var t=this.contractSigner?this.targetScriptRedeem:this.leftOverFundsScriptRedeem;if(!t)throw new Error("Left over funds script redeem is required");if(!this.scriptTree)throw new Error("Script tree is required");return{internalPubkey:this.internalPubKeyToXOnly(),network:this.network,scriptTree:this.scriptTree,redeem:t,name:Yi.P2TR}}},{key:"getScriptSolution",value:function(t){if(!t.tapScriptSig)throw new Error("Tap script signature is required");var e=function(t){return function(t){if(Array.isArray(t))return ab(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||ob(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}(this.witnesses);if(t.tapScriptSig){var r,n=function(t){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=ob(t))){e&&(t=e);var r=0,n=function(){};return{s:n,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:n}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,o=!0,a=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return o=t.done,t},e:function(t){a=!0,i=t},f:function(){try{o||null==e.return||e.return()}finally{if(a)throw i}}}}(t.tapScriptSig);try{for(n.s();!(r=n.n()).done;){var i=r.value;e.push(i.signature)}}catch(t){n.e(t)}finally{n.f()}}return e}},{key:"getContractSeed",value:function(){return S.hash256(this.randomBytes)}},{key:"getPubKeys",value:function(){var t=[nb.from(this.signer.publicKey)];return this.contractSigner&&t.push(nb.from(this.contractSigner.publicKey)),t}},{key:"generateRedeemScripts",value:function(){this.targetScriptRedeem={name:Yi.P2TR,output:this.compiledTargetScript,redeemVersion:192},this.leftOverFundsScriptRedeem={name:Yi.P2TR,output:this.getLeafScript(),redeemVersion:192}}},{key:"getLeafScript",value:function(){return Iy.LOCK_LEAF_SCRIPT}},{key:"getScriptTree",value:function(){return this.generateRedeemScripts(),[{output:this.compiledTargetScript,version:192},{output:this.getLeafScript(),version:192}]}}]);var e,r}(),mb=i(8287).Buffer;function Sb(t){return Sb="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Sb(t)}function _b(){var t,e,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",i=r.toStringTag||"@@toStringTag";function o(r,n,i,o){var u=n&&n.prototype instanceof s?n:s,f=Object.create(u.prototype);return Eb(f,"_invoke",function(r,n,i){var o,s,u,f=0,c=i||[],l=!1,h={p:0,n:0,v:t,a:p,f:p.bind(t,4),d:function(e,r){return o=e,s=0,u=t,h.n=r,a}};function p(r,n){for(s=r,u=n,e=0;!l&&f&&!i&&e<c.length;e++){var i,o=c[e],p=h.p,d=o[2];r>3?(i=d===n)&&(u=o[(s=o[4])?5:(s=3,3)],o[4]=o[5]=t):o[0]<=p&&((i=r<2&&p<o[1])?(s=0,h.v=n,h.n=o[1]):p<d&&(i=r<3||o[0]>n||n>d)&&(o[4]=r,o[5]=n,h.n=d,s=0))}if(i||r>1)return a;throw l=!0,n}return function(i,c,d){if(f>1)throw TypeError("Generator is already running");for(l&&1===c&&p(c,d),s=c,u=d;(e=s<2?t:u)||!l;){o||(s?s<3?(s>1&&(h.n=-1),p(s,u)):h.n=u:h.v=u);try{if(f=2,o){if(s||(i="next"),e=o[i]){if(!(e=e.call(o,u)))throw TypeError("iterator result is not an object");if(!e.done)return e;u=e.value,s<2&&(s=0)}else 1===s&&(e=o.return)&&e.call(o),s<2&&(u=TypeError("The iterator does not provide a '"+i+"' method"),s=1);o=t}else if((e=(l=h.n<0)?u:r.call(n,h))!==a)break}catch(e){o=t,s=1,u=e}finally{f=1}}return{value:e,done:l}}}(r,i,o),!0),f}var a={};function s(){}function u(){}function f(){}e=Object.getPrototypeOf;var c=[][n]?e(e([][n]())):(Eb(e={},n,function(){return this}),e),l=f.prototype=s.prototype=Object.create(c);function h(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,f):(t.__proto__=f,Eb(t,i,"GeneratorFunction")),t.prototype=Object.create(l),t}return u.prototype=f,Eb(l,"constructor",f),Eb(f,"constructor",u),u.displayName="GeneratorFunction",Eb(f,i,"GeneratorFunction"),Eb(l),Eb(l,i,"Generator"),Eb(l,n,function(){return this}),Eb(l,"toString",function(){return"[object Generator]"}),(_b=function(){return{w:o,m:h}})()}function Eb(t,e,r,n){var i=Object.defineProperty;try{i({},"",{})}catch(t){i=0}Eb=function(t,e,r,n){function o(e,r){Eb(t,e,function(t){return this._invoke(e,r,t)})}e?i?i(t,e,{value:r,enumerable:!n,configurable:!n,writable:!n}):t[e]=r:(o("next",0),o("throw",1),o("return",2))},Eb(t,e,r,n)}function kb(t,e,r,n,i,o,a){try{var s=t[o](a),u=s.value}catch(t){return void r(t)}s.done?e(u):Promise.resolve(u).then(n,i)}function Ob(t){return function(){var e=this,r=arguments;return new Promise(function(n,i){var o=t.apply(e,r);function a(t){kb(o,n,i,a,s,"next",t)}function s(t){kb(o,n,i,a,s,"throw",t)}a(void 0)})}}function Tb(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Ub(n.key),n)}}function Ab(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(Ab=function(){return!!t})()}function Ib(t,e,r,n){var i=Pb(xb(1&n?t.prototype:t),e,r);return 2&n&&"function"==typeof i?function(t){return i.apply(r,t)}:i}function Pb(){return Pb="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,r){var n=function(t,e){for(;!{}.hasOwnProperty.call(t,e)&&null!==(t=xb(t)););return t}(t,e);if(n){var i=Object.getOwnPropertyDescriptor(n,e);return i.get?i.get.call(arguments.length<3?t:r):i.value}},Pb.apply(null,arguments)}function xb(t){return xb=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},xb(t)}function Bb(t,e){return Bb=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Bb(t,e)}function Rb(t,e,r){return(e=Ub(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Ub(t){var e=function(t){if("object"!=Sb(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Sb(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Sb(e)?e:e+""}var Nb=function(){function t(e){var r;if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),Rb(r=function(t,e,r){return e=xb(e),function(t,e){if(e&&("object"==Sb(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,Ab()?Reflect.construct(e,r||[],xb(t).constructor):e.apply(t,r))}(this,t,[e]),"targetScriptRedeem",null),Rb(r,"leftOverFundsScriptRedeem",null),Rb(r,"customFinalizer",function(t,e){if(!r.tapLeafScript)throw new Error("Tap leaf script is required");if(!r.contractSecret)throw new Error("Contract secret is required");var n=r.getScriptSolution(e).concat(r.tapLeafScript.script).concat(r.tapLeafScript.controlBlock);return{finalScriptWitness:Iy.witnessStackToScriptWitness(n)}}),!e.calldata)throw new Error("Calldata is required");if(!e.challenge)throw new Error("Challenge solution is required");return r.challenge=e.challenge,r.disableAutoRefund=e.disableAutoRefund||!1,r.epochChallenge=Nl.generateTimeLockAddress(r.challenge.publicKey.originalPublicKeyBuffer(),r.network),r.calldata=h.compress(e.calldata),r.randomBytes=e.randomBytes||sl.rndBytes(),r.scriptSigner=r.generateKeyPairFromSeed(),r.calldataGenerator=new Uh(mb.from(r.signer.publicKey),r.scriptSignerXOnlyPubKey(),r.network),r}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Bb(t,e)}(t,Iy),function(t,e){return e&&Tb(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"getContractSecret",value:function(){return this.contractSecret}},{key:"getRndBytes",value:function(){return this.randomBytes}},{key:"getChallenge",value:function(){return this.challenge}},{key:"scriptSignerXOnlyPubKey",value:function(){return bi(mb.from(this.scriptSigner.publicKey))}},{key:"generateKeyPairFromSeed",value:function(){return bc.fromSeedKeyPair(this.randomBytes,this.network)}},{key:"buildTransaction",value:(o=Ob(_b().m(function t(){var e;return _b().w(function(t){for(;;)switch(t.n){case 0:if(e=this.scriptSigner?this.targetScriptRedeem:this.leftOverFundsScriptRedeem){t.n=1;break}throw new Error("Left over funds script redeem is required");case 1:if(e.redeemVersion){t.n=2;break}throw new Error("Left over funds script redeem version is required");case 2:if(e.output){t.n=3;break}throw new Error("Left over funds script redeem output is required");case 3:return this.tapLeafScript={leafVersion:e.redeemVersion,script:e.output,controlBlock:this.getWitness()},this.regenerated||this.addInputsFromUTXO(),t.n=4,this.createMineableRewardOutputs();case 4:return t.a(2)}},t,this)})),function(){return o.apply(this,arguments)})},{key:"signInputs",value:(i=Ob(_b().m(function e(r){return _b().w(function(e){for(;;)switch(e.n){case 0:if(this.scriptSigner){e.n=2;break}return e.n=1,Ib(t,"signInputs",this,3)([r]);case 1:case 5:return e.a(2);case 2:if(!("multiSignPsbt"in this.signer)){e.n=4;break}return e.n=3,this.signInputsWalletBased(r);case 3:e.n=5;break;case 4:return e.n=5,this.signInputsNonWalletBased(r)}},e,this)})),function(t){return i.apply(this,arguments)})},{key:"generateScriptAddress",value:function(){return{internalPubkey:this.internalPubKeyToXOnly(),network:this.network,scriptTree:this.scriptTree,name:Yi.P2TR}}},{key:"generateTapData",value:function(){var t=this.scriptSigner?this.targetScriptRedeem:this.leftOverFundsScriptRedeem;if(!t)throw new Error("Left over funds script redeem is required");if(!this.scriptTree)throw new Error("Script tree is required");return{internalPubkey:this.internalPubKeyToXOnly(),network:this.network,scriptTree:this.scriptTree,redeem:t,name:Yi.P2TR}}},{key:"getScriptSolution",value:function(t){if(!t.tapScriptSig)throw new Error("Tap script signature is required");return[this.contractSecret,t.tapScriptSig[0].signature,t.tapScriptSig[1].signature]}},{key:"getScriptTree",value:function(){if(!this.calldata)throw new Error("Calldata is required");return this.generateRedeemScripts(),[{output:this.compiledTargetScript,version:192},{output:t.LOCK_LEAF_SCRIPT,version:192}]}},{key:"signInputsWalletBased",value:(n=Ob(_b().m(function t(e){var r,n;return _b().w(function(t){for(;;)switch(t.n){case 0:return r=this.signer,t.n=1,this.signInput(e,e.data.inputs[0],0,this.scriptSigner);case 1:return t.n=2,r.multiSignPsbt([e]);case 2:for(n=0;n<e.data.inputs.length;n++)if(0===n)e.finalizeInput(n,this.customFinalizer.bind(this));else try{e.finalizeInput(n,this.customFinalizerP2SH.bind(this))}catch(t){e.finalizeInput(n)}case 3:return t.a(2)}},t,this)})),function(t){return n.apply(this,arguments)})},{key:"signInputsNonWalletBased",value:(r=Ob(_b().m(function t(e){var r;return _b().w(function(t){for(;;)switch(t.n){case 0:r=0;case 1:if(!(r<e.data.inputs.length)){t.n=7;break}if(0!==r){t.n=4;break}return t.n=2,this.signInput(e,e.data.inputs[r],r,this.scriptSigner);case 2:return t.n=3,this.signInput(e,e.data.inputs[r],r,this.getSignerKey());case 3:e.finalizeInput(0,this.customFinalizer.bind(this)),t.n=6;break;case 4:return t.n=5,this.signInput(e,e.data.inputs[r],r,this.signer);case 5:try{e.finalizeInput(r,this.customFinalizerP2SH.bind(this))}catch(t){e.finalizeInput(r)}case 6:r++,t.n=1;break;case 7:return t.a(2)}},t,this)})),function(t){return r.apply(this,arguments)})},{key:"createMineableRewardOutputs",value:(e=Ob(_b().m(function t(){var e,r,n;return _b().w(function(t){for(;;)switch(t.n){case 0:if(this.to){t.n=1;break}throw new Error("To address is required");case 1:if(e=this.getTransactionOPNetFee(),r=e>Oy+Ty?Ty:e,this.addOutput({value:Number(r),address:this.to}),r===Ty&&e-Ty>Oy&&this.addOutput({value:Number(e-r),address:this.epochChallenge.address}),n=this.addOptionalOutputsAndGetAmount(),this.disableAutoRefund){t.n=2;break}return t.n=2,this.addRefundOutput(e+n);case 2:return t.a(2)}},t,this)})),function(){return e.apply(this,arguments)})},{key:"getPubKeys",value:function(){var t=[mb.from(this.signer.publicKey)];return this.scriptSigner&&t.push(mb.from(this.scriptSigner.publicKey)),t}},{key:"generateRedeemScripts",value:function(){this.targetScriptRedeem={name:Yi.P2TR,output:this.compiledTargetScript,redeemVersion:192},this.leftOverFundsScriptRedeem={name:Yi.P2TR,output:t.LOCK_LEAF_SCRIPT,redeemVersion:192}}}]);var e,r,n,i,o}();Rb(Nb,"MAXIMUM_CALLDATA_SIZE",1048576);var jb=i(8287).Buffer;function Lb(t){return Lb="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Lb(t)}function Cb(){var t,e,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",i=r.toStringTag||"@@toStringTag";function o(r,n,i,o){var u=n&&n.prototype instanceof s?n:s,f=Object.create(u.prototype);return Fb(f,"_invoke",function(r,n,i){var o,s,u,f=0,c=i||[],l=!1,h={p:0,n:0,v:t,a:p,f:p.bind(t,4),d:function(e,r){return o=e,s=0,u=t,h.n=r,a}};function p(r,n){for(s=r,u=n,e=0;!l&&f&&!i&&e<c.length;e++){var i,o=c[e],p=h.p,d=o[2];r>3?(i=d===n)&&(u=o[(s=o[4])?5:(s=3,3)],o[4]=o[5]=t):o[0]<=p&&((i=r<2&&p<o[1])?(s=0,h.v=n,h.n=o[1]):p<d&&(i=r<3||o[0]>n||n>d)&&(o[4]=r,o[5]=n,h.n=d,s=0))}if(i||r>1)return a;throw l=!0,n}return function(i,c,d){if(f>1)throw TypeError("Generator is already running");for(l&&1===c&&p(c,d),s=c,u=d;(e=s<2?t:u)||!l;){o||(s?s<3?(s>1&&(h.n=-1),p(s,u)):h.n=u:h.v=u);try{if(f=2,o){if(s||(i="next"),e=o[i]){if(!(e=e.call(o,u)))throw TypeError("iterator result is not an object");if(!e.done)return e;u=e.value,s<2&&(s=0)}else 1===s&&(e=o.return)&&e.call(o),s<2&&(u=TypeError("The iterator does not provide a '"+i+"' method"),s=1);o=t}else if((e=(l=h.n<0)?u:r.call(n,h))!==a)break}catch(e){o=t,s=1,u=e}finally{f=1}}return{value:e,done:l}}}(r,i,o),!0),f}var a={};function s(){}function u(){}function f(){}e=Object.getPrototypeOf;var c=[][n]?e(e([][n]())):(Fb(e={},n,function(){return this}),e),l=f.prototype=s.prototype=Object.create(c);function h(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,f):(t.__proto__=f,Fb(t,i,"GeneratorFunction")),t.prototype=Object.create(l),t}return u.prototype=f,Fb(l,"constructor",f),Fb(f,"constructor",u),u.displayName="GeneratorFunction",Fb(f,i,"GeneratorFunction"),Fb(l),Fb(l,i,"Generator"),Fb(l,n,function(){return this}),Fb(l,"toString",function(){return"[object Generator]"}),(Cb=function(){return{w:o,m:h}})()}function Fb(t,e,r,n){var i=Object.defineProperty;try{i({},"",{})}catch(t){i=0}Fb=function(t,e,r,n){function o(e,r){Fb(t,e,function(t){return this._invoke(e,r,t)})}e?i?i(t,e,{value:r,enumerable:!n,configurable:!n,writable:!n}):t[e]=r:(o("next",0),o("throw",1),o("return",2))},Fb(t,e,r,n)}function Db(t,e,r,n,i,o,a){try{var s=t[o](a),u=s.value}catch(t){return void r(t)}s.done?e(u):Promise.resolve(u).then(n,i)}function Hb(t){return function(){var e=this,r=arguments;return new Promise(function(n,i){var o=t.apply(e,r);function a(t){Db(o,n,i,a,s,"next",t)}function s(t){Db(o,n,i,a,s,"throw",t)}a(void 0)})}}function Mb(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Zb(n.key),n)}}function Kb(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(Kb=function(){return!!t})()}function Vb(t,e,r,n){var i=Wb(Gb(1&n?t.prototype:t),e,r);return 2&n&&"function"==typeof i?function(t){return i.apply(r,t)}:i}function Wb(){return Wb="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,r){var n=function(t,e){for(;!{}.hasOwnProperty.call(t,e)&&null!==(t=Gb(t)););return t}(t,e);if(n){var i=Object.getOwnPropertyDescriptor(n,e);return i.get?i.get.call(arguments.length<3?t:r):i.value}},Wb.apply(null,arguments)}function Gb(t){return Gb=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Gb(t)}function qb(t,e){return qb=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},qb(t,e)}function zb(t,e,r){return(e=Zb(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Zb(t){var e=function(t){if("object"!=Lb(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Lb(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Lb(e)?e:e+""}var Xb=function(){function t(e){var r;if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),zb(r=function(t,e,r){return e=Gb(e),function(t,e){if(e&&("object"==Lb(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,Kb()?Reflect.construct(e,r||[],Gb(t).constructor):e.apply(t,r))}(this,t,[e]),"type",Xy.DEPLOYMENT),zb(r,"tapLeafScript",null),zb(r,"deploymentVersion",0),zb(r,"targetScriptRedeem",null),zb(r,"leftOverFundsScriptRedeem",null),zb(r,"customFinalizer",function(t,e){if(!r.tapLeafScript)throw new Error("Tap leaf script is required");if(!e.tapScriptSig)throw new Error("Tap script signature is required");var n=[r.randomBytes,e.tapScriptSig[0].signature,e.tapScriptSig[1].signature].concat(r.tapLeafScript.script).concat(r.tapLeafScript.controlBlock);return{finalScriptWitness:Iy.witnessStackToScriptWitness(n)}}),r.bytecode=h.compress(jb.concat([$h,e.bytecode])),r.verifyBytecode(),e.calldata&&(r.calldata=e.calldata,r.verifyCalldata()),!e.challenge)throw new Error("Challenge solution is required");return r.randomBytes=e.randomBytes||sl.rndBytes(),r.challenge=e.challenge,r.epochChallenge=Nl.generateTimeLockAddress(r.challenge.publicKey.originalPublicKeyBuffer(),r.network),r.contractSeed=r.getContractSeed(),r.contractSigner=bc.fromSeedKeyPair(r.contractSeed,r.network),r.deploymentGenerator=new Jh(jb.from(r.signer.publicKey),r.contractSignerXOnlyPubKey(),r.network),r.compiledTargetScript=r.deploymentGenerator.compile(r.bytecode,r.randomBytes,r.challenge,r.priorityFee,r.calldata,r.generateFeatures(e)),r.scriptTree=r.getScriptTree(),r.internalInit(),r._contractPubKey="0x"+r.contractSeed.toString("hex"),r._contractAddress=new ih(r.contractSeed),r}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&qb(t,e)}(t,Iy),function(t,e){return e&&Mb(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"contractPubKey",get:function(){return this._contractPubKey}},{key:"contractAddress",get:function(){return this._contractAddress}},{key:"p2trAddress",get:function(){return this.to||this.getScriptAddress()}},{key:"getRndBytes",value:function(){return this.randomBytes}},{key:"getChallenge",value:function(){return this.challenge}},{key:"getContractAddress",value:function(){return this._computedAddress||(this._computedAddress=bc.p2op(this.contractSeed,this.network,this.deploymentVersion)),this._computedAddress}},{key:"contractSignerXOnlyPubKey",value:function(){return bi(jb.from(this.contractSigner.publicKey))}},{key:"buildTransaction",value:(n=Hb(Cb().m(function t(){var e,r,n;return Cb().w(function(t){for(;;)switch(t.n){case 0:if(this.to||(this.to=this.getScriptAddress()),e=this.contractSigner?this.targetScriptRedeem:this.leftOverFundsScriptRedeem){t.n=1;break}throw new Error("Left over funds script redeem is required");case 1:if(e.redeemVersion){t.n=2;break}throw new Error("Left over funds script redeem version is required");case 2:if(e.output){t.n=3;break}throw new Error("Left over funds script redeem output is required");case 3:return this.tapLeafScript={leafVersion:e.redeemVersion,script:e.output,controlBlock:this.getWitness()},this.addInputsFromUTXO(),r=this.getTransactionOPNetFee(),n=r>Oy+Ty?Ty:r,this.addOutput({value:Number(n),address:this.getContractAddress()}),n===Ty&&r-Ty>Oy&&this.addOutput({value:Number(r-n),address:this.epochChallenge.address}),t.n=4,this.addRefundOutput(r+this.addOptionalOutputsAndGetAmount());case 4:return t.a(2)}},t,this)})),function(){return n.apply(this,arguments)})},{key:"signInputsWalletBased",value:(r=Hb(Cb().m(function t(e){var r,n;return Cb().w(function(t){for(;;)switch(t.n){case 0:return r=this.signer,t.n=1,this.signInput(e,e.data.inputs[0],0,this.contractSigner);case 1:return t.n=2,r.multiSignPsbt([e]);case 2:for(n=0;n<e.data.inputs.length;n++)if(0===n)e.finalizeInput(n,this.customFinalizer.bind(this));else try{e.finalizeInput(n,this.customFinalizerP2SH.bind(this))}catch(t){e.finalizeInput(n)}case 3:return t.a(2)}},t,this)})),function(t){return r.apply(this,arguments)})},{key:"signInputs",value:(e=Hb(Cb().m(function e(r){var n;return Cb().w(function(e){for(;;)switch(e.n){case 0:if(this.contractSigner){e.n=2;break}return e.n=1,Vb(t,"signInputs",this,3)([r]);case 1:return e.a(2);case 2:if(!("multiSignPsbt"in this.signer)){e.n=4;break}return e.n=3,this.signInputsWalletBased(r);case 3:return e.a(2);case 4:for(n=0;n<r.data.inputs.length;n++)if(0===n)r.signInput(0,this.contractSigner),r.signInput(0,this.getSignerKey()),r.finalizeInput(0,this.customFinalizer.bind(this));else{r.signInput(n,this.getSignerKey());try{r.finalizeInput(n,this.customFinalizerP2SH.bind(this))}catch(t){r.finalizeInput(n)}}case 5:return e.a(2)}},e,this)})),function(t){return e.apply(this,arguments)})},{key:"generateScriptAddress",value:function(){return{name:Yi.P2TR,internalPubkey:this.internalPubKeyToXOnly(),network:this.network,scriptTree:this.scriptTree}}},{key:"generateTapData",value:function(){var t=this.contractSigner?this.targetScriptRedeem:this.leftOverFundsScriptRedeem;if(!t)throw new Error("Left over funds script redeem is required");if(!this.scriptTree)throw new Error("Script tree is required");return{name:Yi.P2TR,internalPubkey:this.internalPubKeyToXOnly(),network:this.network,scriptTree:this.scriptTree,redeem:t}}},{key:"generateFeatures",value:function(t){var e=[],r=t.challenge.getSubmission();return r&&e.push({opcode:hh.EPOCH_SUBMISSION,data:r}),e}},{key:"verifyCalldata",value:function(){if(this.calldata&&this.calldata.length>Nb.MAXIMUM_CALLDATA_SIZE)throw new Error("Calldata size overflow.")}},{key:"verifyBytecode",value:function(){if(!this.bytecode)throw new Error("Bytecode is required");if(this.bytecode.length>t.MAXIMUM_CONTRACT_SIZE)throw new Error("Contract size overflow.")}},{key:"getContractSeed",value:function(){if(!this.bytecode)throw new Error("Bytecode is required");var t=this.internalPubKeyToXOnly(),e=S.hash256(this.randomBytes),r=S.hash256(this.bytecode),n=jb.concat([t,e,r]);return S.hash256(n)}},{key:"getPubKeys",value:function(){var t=[jb.from(this.signer.publicKey)];return this.contractSigner&&t.push(jb.from(this.contractSigner.publicKey)),t}},{key:"generateRedeemScripts",value:function(){this.targetScriptRedeem={name:Yi.P2TR,output:this.compiledTargetScript,redeemVersion:192},this.leftOverFundsScriptRedeem={name:Yi.P2TR,output:this.getLeafScript(),redeemVersion:192}}},{key:"getLeafScript",value:function(){return Iy.LOCK_LEAF_SCRIPT}},{key:"getScriptTree",value:function(){if(!this.bytecode)throw new Error("Contract bytecode is required");return this.generateRedeemScripts(),[{output:this.compiledTargetScript,version:192},{output:this.getLeafScript(),version:192}]}}]);var e,r,n}();zb(Xb,"MAXIMUM_CONTRACT_SIZE",131072);var Yb=i(8287).Buffer;function $b(t){return $b="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},$b(t)}function Jb(){var t,e,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",i=r.toStringTag||"@@toStringTag";function o(r,n,i,o){var u=n&&n.prototype instanceof s?n:s,f=Object.create(u.prototype);return Qb(f,"_invoke",function(r,n,i){var o,s,u,f=0,c=i||[],l=!1,h={p:0,n:0,v:t,a:p,f:p.bind(t,4),d:function(e,r){return o=e,s=0,u=t,h.n=r,a}};function p(r,n){for(s=r,u=n,e=0;!l&&f&&!i&&e<c.length;e++){var i,o=c[e],p=h.p,d=o[2];r>3?(i=d===n)&&(u=o[(s=o[4])?5:(s=3,3)],o[4]=o[5]=t):o[0]<=p&&((i=r<2&&p<o[1])?(s=0,h.v=n,h.n=o[1]):p<d&&(i=r<3||o[0]>n||n>d)&&(o[4]=r,o[5]=n,h.n=d,s=0))}if(i||r>1)return a;throw l=!0,n}return function(i,c,d){if(f>1)throw TypeError("Generator is already running");for(l&&1===c&&p(c,d),s=c,u=d;(e=s<2?t:u)||!l;){o||(s?s<3?(s>1&&(h.n=-1),p(s,u)):h.n=u:h.v=u);try{if(f=2,o){if(s||(i="next"),e=o[i]){if(!(e=e.call(o,u)))throw TypeError("iterator result is not an object");if(!e.done)return e;u=e.value,s<2&&(s=0)}else 1===s&&(e=o.return)&&e.call(o),s<2&&(u=TypeError("The iterator does not provide a '"+i+"' method"),s=1);o=t}else if((e=(l=h.n<0)?u:r.call(n,h))!==a)break}catch(e){o=t,s=1,u=e}finally{f=1}}return{value:e,done:l}}}(r,i,o),!0),f}var a={};function s(){}function u(){}function f(){}e=Object.getPrototypeOf;var c=[][n]?e(e([][n]())):(Qb(e={},n,function(){return this}),e),l=f.prototype=s.prototype=Object.create(c);function h(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,f):(t.__proto__=f,Qb(t,i,"GeneratorFunction")),t.prototype=Object.create(l),t}return u.prototype=f,Qb(l,"constructor",f),Qb(f,"constructor",u),u.displayName="GeneratorFunction",Qb(f,i,"GeneratorFunction"),Qb(l),Qb(l,i,"Generator"),Qb(l,n,function(){return this}),Qb(l,"toString",function(){return"[object Generator]"}),(Jb=function(){return{w:o,m:h}})()}function Qb(t,e,r,n){var i=Object.defineProperty;try{i({},"",{})}catch(t){i=0}Qb=function(t,e,r,n){function o(e,r){Qb(t,e,function(t){return this._invoke(e,r,t)})}e?i?i(t,e,{value:r,enumerable:!n,configurable:!n,writable:!n}):t[e]=r:(o("next",0),o("throw",1),o("return",2))},Qb(t,e,r,n)}function tg(t,e,r,n,i,o,a){try{var s=t[o](a),u=s.value}catch(t){return void r(t)}s.done?e(u):Promise.resolve(u).then(n,i)}function eg(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,og(n.key),n)}}function rg(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(rg=function(){return!!t})()}function ng(t){return ng=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},ng(t)}function ig(t,e){return ig=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},ig(t,e)}function og(t){var e=function(t){if("object"!=$b(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=$b(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==$b(e)?e:e+""}var ag=function(){function t(e){var r,n;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),function(t,e,r){(e=og(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r}(n=function(t,e,r){return e=ng(e),function(t,e){if(e&&("object"==$b(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,rg()?Reflect.construct(e,r||[],ng(t).constructor):e.apply(t,r))}(this,t,[e]),"type",Xy.FUNDING),n.amount=e.amount,n.splitInputsInto=null!==(r=e.splitInputsInto)&&void 0!==r?r:1,n.internalInit(),n}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&ig(t,e)}(t,Iy),function(t,e){return e&&eg(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"buildTransaction",value:(e=function(t){return function(){var e=this,r=arguments;return new Promise(function(n,i){var o=t.apply(e,r);function a(t){tg(o,n,i,a,s,"next",t)}function s(t){tg(o,n,i,a,s,"throw",t)}a(void 0)})}}(Jb().m(function t(){var e;return Jb().w(function(t){for(;;)switch(t.n){case 0:if(this.to){t.n=1;break}throw new Error("Recipient address is required");case 1:return this.addInputsFromUTXO(),this.splitInputsInto>1?this.splitInputs(this.amount):this.isPubKeyDestination?(e=w.compile([Yb.from(this.to.replace("0x",""),"hex"),it.OP_CHECKSIG]),this.addOutput({value:Number(this.amount),script:e})):this.addOutput({value:Number(this.amount),address:this.to}),t.n=2,this.addRefundOutput(this.amount+this.addOptionalOutputsAndGetAmount());case 2:return t.a(2)}},t,this)})),function(){return e.apply(this,arguments)})},{key:"splitInputs",value:function(t){if(!this.to)throw new Error("Recipient address is required");for(var e=t/BigInt(this.splitInputsInto),r=0;r<this.splitInputsInto;r++)this.isPubKeyDestination?this.addOutput({value:Number(e),script:Yb.from(this.to.slice(2),"hex")}):this.addOutput({value:Number(e),address:this.to})}},{key:"getSignerKey",value:function(){return this.signer}}]);var e}(),sg=i(8287).Buffer;function ug(t){return ug="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ug(t)}function fg(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,dg(n.key),n)}}function cg(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(cg=function(){return!!t})()}function lg(t){return lg=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},lg(t)}function hg(t,e){return hg=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},hg(t,e)}function pg(t,e,r){return(e=dg(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function dg(t){var e=function(t){if("object"!=ug(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=ug(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==ug(e)?e:e+""}var yg=function(){function t(e){var r;if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),pg(r=function(t,e,r){return e=lg(e),function(t,e){if(e&&("object"==ug(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,cg()?Reflect.construct(e,r||[],lg(t).constructor):e.apply(t,r))}(this,t,[e]),"type",Xy.INTERACTION),pg(r,"tapLeafScript",null),!e.contract)throw new Error("parameters.contract is required for interaction transaction.");if(r.contractSecret=sg.from(e.contract.replace("0x",""),"hex"),32!==r.contractSecret.length)throw new Error("Invalid contract secret length. Expected 32 bytes.");return r.compiledTargetScript=r.calldataGenerator.compile(r.calldata,r.contractSecret,r.challenge,r.priorityFee,r.generateFeatures(e)),r.scriptTree=r.getScriptTree(),r.internalInit(),r}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&hg(t,e)}(t,Nb),function(t,e){return e&&fg(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"generateFeatures",value:function(t){var e=[];t.loadedStorage&&e.push({opcode:hh.ACCESS_LIST,data:t.loadedStorage});var r=t.challenge.getSubmission();return r&&e.push({opcode:hh.EPOCH_SUBMISSION,data:r}),e}}])}();function bg(t){return bg="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},bg(t)}function gg(){var t,e,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",i=r.toStringTag||"@@toStringTag";function o(r,n,i,o){var u=n&&n.prototype instanceof s?n:s,f=Object.create(u.prototype);return vg(f,"_invoke",function(r,n,i){var o,s,u,f=0,c=i||[],l=!1,h={p:0,n:0,v:t,a:p,f:p.bind(t,4),d:function(e,r){return o=e,s=0,u=t,h.n=r,a}};function p(r,n){for(s=r,u=n,e=0;!l&&f&&!i&&e<c.length;e++){var i,o=c[e],p=h.p,d=o[2];r>3?(i=d===n)&&(u=o[(s=o[4])?5:(s=3,3)],o[4]=o[5]=t):o[0]<=p&&((i=r<2&&p<o[1])?(s=0,h.v=n,h.n=o[1]):p<d&&(i=r<3||o[0]>n||n>d)&&(o[4]=r,o[5]=n,h.n=d,s=0))}if(i||r>1)return a;throw l=!0,n}return function(i,c,d){if(f>1)throw TypeError("Generator is already running");for(l&&1===c&&p(c,d),s=c,u=d;(e=s<2?t:u)||!l;){o||(s?s<3?(s>1&&(h.n=-1),p(s,u)):h.n=u:h.v=u);try{if(f=2,o){if(s||(i="next"),e=o[i]){if(!(e=e.call(o,u)))throw TypeError("iterator result is not an object");if(!e.done)return e;u=e.value,s<2&&(s=0)}else 1===s&&(e=o.return)&&e.call(o),s<2&&(u=TypeError("The iterator does not provide a '"+i+"' method"),s=1);o=t}else if((e=(l=h.n<0)?u:r.call(n,h))!==a)break}catch(e){o=t,s=1,u=e}finally{f=1}}return{value:e,done:l}}}(r,i,o),!0),f}var a={};function s(){}function u(){}function f(){}e=Object.getPrototypeOf;var c=[][n]?e(e([][n]())):(vg(e={},n,function(){return this}),e),l=f.prototype=s.prototype=Object.create(c);function h(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,f):(t.__proto__=f,vg(t,i,"GeneratorFunction")),t.prototype=Object.create(l),t}return u.prototype=f,vg(l,"constructor",f),vg(f,"constructor",u),u.displayName="GeneratorFunction",vg(f,i,"GeneratorFunction"),vg(l),vg(l,i,"Generator"),vg(l,n,function(){return this}),vg(l,"toString",function(){return"[object Generator]"}),(gg=function(){return{w:o,m:h}})()}function vg(t,e,r,n){var i=Object.defineProperty;try{i({},"",{})}catch(t){i=0}vg=function(t,e,r,n){function o(e,r){vg(t,e,function(t){return this._invoke(e,r,t)})}e?i?i(t,e,{value:r,enumerable:!n,configurable:!n,writable:!n}):t[e]=r:(o("next",0),o("throw",1),o("return",2))},vg(t,e,r,n)}function wg(t,e,r,n,i,o,a){try{var s=t[o](a),u=s.value}catch(t){return void r(t)}s.done?e(u):Promise.resolve(u).then(n,i)}function mg(t){return function(){var e=this,r=arguments;return new Promise(function(n,i){var o=t.apply(e,r);function a(t){wg(o,n,i,a,s,"next",t)}function s(t){wg(o,n,i,a,s,"throw",t)}a(void 0)})}}function Sg(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Tg(n.key),n)}}function _g(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(_g=function(){return!!t})()}function Eg(t){return Eg=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Eg(t)}function kg(t,e){return kg=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},kg(t,e)}function Og(t,e,r){return(e=Tg(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Tg(t){var e=function(t){if("object"!=bg(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=bg(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==bg(e)?e:e+""}var Ag=function(){function t(e){var r;if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),Og(r=function(t,e,r){return e=Eg(e),function(t,e){if(e&&("object"==bg(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,_g()?Reflect.construct(e,r||[],Eg(t).constructor):e.apply(t,r))}(this,t,[e]),"type",Xy.INTERACTION),Og(r,"p2wdaInputIndices",new Set),Og(r,"compiledOperationData",null),!e.to)throw new Error("Contract address (to) is required");if(!e.contract)throw new Error("Contract secret is required");if(!e.calldata)throw new Error("Calldata is required");if(!e.challenge)throw new Error("Challenge solution is required");if(r.disableAutoRefund=e.disableAutoRefund||!1,r.contractAddress=e.to,r.contractSecret=ul.Buffer.from(e.contract.replace("0x",""),"hex"),r.calldata=h.compress(e.calldata),r.challenge=e.challenge,r.randomBytes=e.randomBytes||sl.rndBytes(),r.scriptSigner=r.generateKeyPairFromSeed(),r.p2wdaGenerator=new Op(ul.Buffer.from(r.signer.publicKey),r.scriptSignerXOnlyPubKey(),r.network),32!==r.contractSecret.length)throw new Error("Invalid contract secret length. Expected 32 bytes.");return r.epochChallenge=Nl.generateTimeLockAddress(r.challenge.publicKey.originalPublicKeyBuffer(),r.network),r.validateP2WDAInputs(),r.compiledOperationData=r.p2wdaGenerator.compile(r.calldata,r.contractSecret,r.challenge,r.priorityFee,r.generateFeatures(e)),r.validateOperationDataSize(),r.internalInit(),r}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&kg(t,e)}(t,Iy),function(t,e){return e&&Sg(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"getRndBytes",value:function(){return this.randomBytes}},{key:"getChallenge",value:function(){return this.challenge}},{key:"getContractSecret",value:function(){return this.contractSecret}},{key:"buildTransaction",value:(n=mg(gg().m(function t(){return gg().w(function(t){for(;;)switch(t.n){case 0:return this.regenerated||this.addInputsFromUTXO(),t.n=1,this.createMineableRewardOutputs();case 1:return t.a(2)}},t,this)})),function(){return n.apply(this,arguments)})},{key:"createMineableRewardOutputs",value:(r=mg(gg().m(function t(){var e,r,n;return gg().w(function(t){for(;;)switch(t.n){case 0:if(this.to){t.n=1;break}throw new Error("To address is required");case 1:if(e=this.getTransactionOPNetFee(),r=e>Oy+Ty?Ty:e,this.addOutput({value:Number(r),address:this.to}),r===Ty&&e-Ty>Oy&&this.addOutput({value:Number(e-r),address:this.epochChallenge.address}),n=this.addOptionalOutputsAndGetAmount(),this.disableAutoRefund){t.n=2;break}return t.n=2,this.addRefundOutput(e+n);case 2:return t.a(2)}},t,this)})),function(){return r.apply(this,arguments)})},{key:"signInputs",value:(e=mg(gg().m(function t(e){var r,n;return gg().w(function(t){for(;;)switch(t.n){case 0:r=0;case 1:if(!(r<e.data.inputs.length)){t.n=3;break}return t.n=2,this.signInput(e,e.data.inputs[r],r,this.signer);case 2:r++,t.n=1;break;case 3:for(n=0;n<e.data.inputs.length;n++)this.p2wdaInputIndices.has(n)?0===n?e.finalizeInput(n,this.finalizePrimaryP2WDA.bind(this)):e.finalizeInput(n,this.finalizeSecondaryP2WDA.bind(this)):e.finalizeInput(n,this.customFinalizerP2SH.bind(this));this.finalized=!0;case 4:return t.a(2)}},t,this)})),function(t){return e.apply(this,arguments)})},{key:"generateFeatures",value:function(t){var e=[];t.loadedStorage&&e.push({opcode:hh.ACCESS_LIST,data:t.loadedStorage});var r=t.challenge.getSubmission();return r&&e.push({opcode:hh.EPOCH_SUBMISSION,data:r}),e}},{key:"generateKeyPairFromSeed",value:function(){return bc.fromSeedKeyPair(this.randomBytes,this.network)}},{key:"scriptSignerXOnlyPubKey",value:function(){return bi(ul.Buffer.from(this.scriptSigner.publicKey))}},{key:"validateP2WDAInputs",value:function(){if(0===this.utxos.length||!pl.isP2WDAUTXO(this.utxos[0]))throw new Error("Input 0 must be a P2WDA UTXO");for(var t=0;t<this.utxos.length;t++)pl.isP2WDAUTXO(this.utxos[t])&&this.p2wdaInputIndices.add(t);for(var e=0;e<this.optionalInputs.length;e++){var r=this.utxos.length+e;pl.isP2WDAUTXO(this.optionalInputs[e])&&this.p2wdaInputIndices.add(r)}}},{key:"validateOperationDataSize",value:function(){if(!this.compiledOperationData)throw new Error("Operation data not compiled");var e=this.compiledOperationData.length;if(!Op.validateWitnessSize(e)){var r=e+64,n=Math.ceil(.7*r),i=Math.ceil(n/t.MAX_BYTES_PER_WITNESS);throw new Error("Please dont use P2WDA for this operation. Data too large. Raw size: ".concat(e," bytes, ")+"estimated compressed: ".concat(n," bytes, ")+"needs ".concat(i," witness fields, max is ").concat(t.MAX_WITNESS_FIELDS))}}},{key:"finalizePrimaryP2WDA",value:function(e,r){if(!r.partialSig||0===r.partialSig.length)throw new Error("No signature for P2WDA input #".concat(e));if(!r.witnessScript)throw new Error("No witness script for P2WDA input #".concat(e));if(!this.compiledOperationData)throw new Error("Operation data not compiled");var n=r.partialSig[0].signature,i=ul.Buffer.concat([n,this.compiledOperationData]),o=Dy.signMessage(this.signer,i),a=ul.Buffer.from(o.signature),s=ul.Buffer.concat([a,this.compiledOperationData]),u=h.compress(s),f=this.splitIntoWitnessChunks(u);if(f.length>t.MAX_WITNESS_FIELDS)throw new Error("Compressed data needs ".concat(f.length," witness fields, max is ").concat(t.MAX_WITNESS_FIELDS));for(var c=[n],l=0;l<t.MAX_WITNESS_FIELDS;l++)c.push(l<f.length?f[l]:ul.Buffer.alloc(0));return c.push(r.witnessScript),{finalScriptSig:void 0,finalScriptWitness:Iy.witnessStackToScriptWitness(c)}}},{key:"splitIntoWitnessChunks",value:function(e){for(var r=[],n=0;n<e.length;){var i=Math.min(t.MAX_BYTES_PER_WITNESS,e.length-n);r.push(e.subarray(n,n+i)),n+=i}return r}}]);var e,r,n}();Og(Ag,"MAX_WITNESS_FIELDS",10),Og(Ag,"MAX_BYTES_PER_WITNESS",80);var Ig=i(8287).Buffer;function Pg(t){return Pg="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Pg(t)}function xg(){var t,e,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",i=r.toStringTag||"@@toStringTag";function o(r,n,i,o){var u=n&&n.prototype instanceof s?n:s,f=Object.create(u.prototype);return Bg(f,"_invoke",function(r,n,i){var o,s,u,f=0,c=i||[],l=!1,h={p:0,n:0,v:t,a:p,f:p.bind(t,4),d:function(e,r){return o=e,s=0,u=t,h.n=r,a}};function p(r,n){for(s=r,u=n,e=0;!l&&f&&!i&&e<c.length;e++){var i,o=c[e],p=h.p,d=o[2];r>3?(i=d===n)&&(u=o[(s=o[4])?5:(s=3,3)],o[4]=o[5]=t):o[0]<=p&&((i=r<2&&p<o[1])?(s=0,h.v=n,h.n=o[1]):p<d&&(i=r<3||o[0]>n||n>d)&&(o[4]=r,o[5]=n,h.n=d,s=0))}if(i||r>1)return a;throw l=!0,n}return function(i,c,d){if(f>1)throw TypeError("Generator is already running");for(l&&1===c&&p(c,d),s=c,u=d;(e=s<2?t:u)||!l;){o||(s?s<3?(s>1&&(h.n=-1),p(s,u)):h.n=u:h.v=u);try{if(f=2,o){if(s||(i="next"),e=o[i]){if(!(e=e.call(o,u)))throw TypeError("iterator result is not an object");if(!e.done)return e;u=e.value,s<2&&(s=0)}else 1===s&&(e=o.return)&&e.call(o),s<2&&(u=TypeError("The iterator does not provide a '"+i+"' method"),s=1);o=t}else if((e=(l=h.n<0)?u:r.call(n,h))!==a)break}catch(e){o=t,s=1,u=e}finally{f=1}}return{value:e,done:l}}}(r,i,o),!0),f}var a={};function s(){}function u(){}function f(){}e=Object.getPrototypeOf;var c=[][n]?e(e([][n]())):(Bg(e={},n,function(){return this}),e),l=f.prototype=s.prototype=Object.create(c);function h(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,f):(t.__proto__=f,Bg(t,i,"GeneratorFunction")),t.prototype=Object.create(l),t}return u.prototype=f,Bg(l,"constructor",f),Bg(f,"constructor",u),u.displayName="GeneratorFunction",Bg(f,i,"GeneratorFunction"),Bg(l),Bg(l,i,"Generator"),Bg(l,n,function(){return this}),Bg(l,"toString",function(){return"[object Generator]"}),(xg=function(){return{w:o,m:h}})()}function Bg(t,e,r,n){var i=Object.defineProperty;try{i({},"",{})}catch(t){i=0}Bg=function(t,e,r,n){function o(e,r){Bg(t,e,function(t){return this._invoke(e,r,t)})}e?i?i(t,e,{value:r,enumerable:!n,configurable:!n,writable:!n}):t[e]=r:(o("next",0),o("throw",1),o("return",2))},Bg(t,e,r,n)}function Rg(t){return function(t){if(Array.isArray(t))return Ug(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return Ug(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Ug(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Ug(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function Ng(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function jg(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?Ng(Object(r),!0).forEach(function(e){Lg(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Ng(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function Lg(t,e,r){return(e=Hg(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Cg(t,e,r,n,i,o,a){try{var s=t[o](a),u=s.value}catch(t){return void r(t)}s.done?e(u):Promise.resolve(u).then(n,i)}function Fg(t){return function(){var e=this,r=arguments;return new Promise(function(n,i){var o=t.apply(e,r);function a(t){Cg(o,n,i,a,s,"next",t)}function s(t){Cg(o,n,i,a,s,"throw",t)}a(void 0)})}}function Dg(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Hg(n.key),n)}}function Hg(t){var e=function(t){if("object"!=Pg(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Pg(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Pg(e)?e:e+""}var Mg=function(){return function(t,e){return e&&Dg(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}(function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)},[{key:"createCustomScriptTransaction",value:(s=Fg(xg().m(function t(e){var r,n,i,o,a,s,u,f,c,l,h,p;return xg().w(function(t){for(;;)switch(t.n){case 0:if(e.to){t.n=1;break}throw new Error('Field "to" not provided.');case 1:if(e.from){t.n=2;break}throw new Error('Field "from" not provided.');case 2:if(e.utxos[0]){t.n=3;break}throw new Error("Missing at least one UTXO.");case 3:if("signer"in e){t.n=4;break}throw new Error('Field "signer" not provided, OP_WALLET not detected.');case 4:return r=this.parseOptionalInputs(e.optionalInputs),n=new wb(jg(jg({},e),{},{utxos:[e.utxos[0]],optionalInputs:r})),t.n=5,n.generateTransactionMinimalSignatures();case 5:return t.n=6,n.getFundingTransactionParameters();case 6:return(i=t.v).utxos=e.utxos,t.n=7,n.estimateTransactionFees();case 7:return c=t.v,l=this.getPriorityFee(e),h=c+l,p=n.getOptionalOutputValue(),i.amount=h+p,t.n=8,this.createFundTransaction(jg(jg({},i),{},{optionalOutputs:[],optionalInputs:[]}));case 8:if(o=t.v){t.n=9;break}throw new Error("Could not sign funding transaction.");case 9:return i.estimatedFees=o.estimatedFees,t.n=10,this.createFundTransaction(jg(jg({},i),{},{optionalOutputs:[],optionalInputs:[]}));case 10:if(a=t.v){t.n=11;break}throw new Error("Could not sign funding transaction.");case 11:return e.utxos=this.getUTXOAsTransaction(a.tx,e.to,0),s=jg(jg({},e),{},{utxos:Rg(this.getUTXOAsTransaction(a.tx,e.to,0)),randomBytes:n.getRndBytes(),nonWitnessUtxo:a.tx.toBuffer(),estimatedFees:n.estimatedFees,optionalInputs:r}),u=new wb(s),t.n=12,u.signTransaction();case 12:return f=t.v,t.a(2,[a.tx.toHex(),f.toHex(),this.getUTXOAsTransaction(a.tx,e.from,1)])}},t,this)})),function(t){return s.apply(this,arguments)})},{key:"signInteraction",value:(a=Fg(xg().m(function t(e){var r,n,i,o,a,s,u,f,c,l,h,p,d;return xg().w(function(t){for(;;)switch(t.n){case 0:if(e.to){t.n=1;break}throw new Error('Field "to" not provided.');case 1:if(e.from){t.n=2;break}throw new Error('Field "from" not provided.');case 2:if(e.utxos[0]){t.n=3;break}throw new Error("Missing at least one UTXO.");case 3:return t.n=4,this.detectInteractionOPWallet(e);case 4:if(!(r=t.v)){t.n=5;break}return t.a(2,r);case 5:if("signer"in e){t.n=6;break}throw new Error('Field "signer" not provided, OP_WALLET not detected.');case 6:if(!this.hasP2WDAInputs(e.utxos)){t.n=7;break}return t.a(2,this.signP2WDAInteraction(e));case 7:return n=this.parseOptionalInputs(e.optionalInputs),i=new yg(jg(jg({},e),{},{utxos:[e.utxos[0]],optionalInputs:n})),t.n=8,i.generateTransactionMinimalSignatures();case 8:return t.n=9,i.getFundingTransactionParameters();case 9:return(o=t.v).utxos=e.utxos,t.n=10,i.estimateTransactionFees();case 10:return l=t.v,h=this.getPriorityFee(e),p=l+h,d=i.getOptionalOutputValue(),o.amount=p+d,t.n=11,this.createFundTransaction(jg(jg({},o),{},{optionalOutputs:[],optionalInputs:[]}));case 11:if(a=t.v){t.n=12;break}throw new Error("Could not sign funding transaction.");case 12:return o.estimatedFees=a.estimatedFees,t.n=13,this.createFundTransaction(jg(jg({},o),{},{optionalOutputs:[],optionalInputs:[]}));case 13:if(s=t.v){t.n=14;break}throw new Error("Could not sign funding transaction.");case 14:return e.utxos=this.getUTXOAsTransaction(s.tx,e.to,0),u=jg(jg({},e),{},{utxos:Rg(this.getUTXOAsTransaction(s.tx,e.to,0)),randomBytes:i.getRndBytes(),challenge:i.getChallenge(),nonWitnessUtxo:s.tx.toBuffer(),estimatedFees:i.estimatedFees,optionalInputs:n}),f=new yg(u),t.n=15,f.signTransaction();case 15:return c=t.v,t.a(2,{fundingTransaction:s.tx.toHex(),interactionTransaction:c.toHex(),estimatedFees:i.estimatedFees,nextUTXOs:this.getUTXOAsTransaction(s.tx,e.from,1),challenge:i.getChallenge().toRaw()})}},t,this)})),function(t){return a.apply(this,arguments)})},{key:"signDeployment",value:(o=Fg(xg().m(function t(e){var r,n,i,o,a,s,u,f,c,l,h,p,d,y,b,g,v,w;return xg().w(function(t){for(;;)switch(t.n){case 0:return t.n=1,this.detectDeploymentOPWallet(e);case 1:if(!(r=t.v)){t.n=2;break}return t.a(2,r);case 2:if("signer"in e){t.n=3;break}throw new Error('Field "signer" not provided, OP_WALLET not detected.');case 3:return n=this.parseOptionalInputs(e.optionalInputs),i=new Xb(jg(jg({},e),{},{utxos:[e.utxos[0]],optionalInputs:n})),t.n=4,i.generateTransactionMinimalSignatures();case 4:return t.n=5,i.getFundingTransactionParameters();case 5:return(o=t.v).utxos=e.utxos,t.n=6,i.estimateTransactionFees();case 6:return b=t.v,g=this.getPriorityFee(e),v=b+g,w=i.getOptionalOutputValue(),o.amount=v+w,t.n=7,this.createFundTransaction(jg(jg({},o),{},{optionalOutputs:[],optionalInputs:[]}));case 7:if(a=t.v){t.n=8;break}throw new Error("Could not sign funding transaction.");case 8:return o.estimatedFees=a.estimatedFees,s=new ag(jg(jg({},o),{},{optionalInputs:[],optionalOutputs:[]})),t.n=9,s.signTransaction();case 9:if(u=t.v){t.n=10;break}throw new Error("Could not sign funding transaction.");case 10:return f=u.outs[0],c={transactionId:u.getId(),outputIndex:0,scriptPubKey:{hex:f.script.toString("hex"),address:i.getScriptAddress()},value:BigInt(f.value)},l=jg(jg({},e),{},{utxos:[c],randomBytes:i.getRndBytes(),challenge:i.getChallenge(),nonWitnessUtxo:u.toBuffer(),estimatedFees:i.estimatedFees,optionalInputs:n}),h=new Xb(l),t.n=11,h.signTransaction();case 11:return p=t.v,d=u.outs[1],y={transactionId:u.getId(),outputIndex:1,scriptPubKey:{hex:d.script.toString("hex"),address:e.from},value:BigInt(d.value)},t.a(2,{transaction:[u.toHex(),p.toHex()],contractAddress:h.getContractAddress(),contractPubKey:h.contractPubKey,utxos:[y],challenge:i.getChallenge().toRaw()})}},t,this)})),function(t){return o.apply(this,arguments)})},{key:"createBTCTransfer",value:(i=Fg(xg().m(function t(e){var r;return xg().w(function(t){for(;;)switch(t.n){case 0:if(e.from){t.n=1;break}throw new Error('Field "from" not provided.');case 1:return t.n=2,this.createFundTransaction(e);case 2:return r=t.v,t.a(2,{estimatedFees:r.estimatedFees,original:r.original,tx:r.tx.toHex(),nextUTXOs:this.getAllNewUTXOs(r.original,r.tx,e.from)})}},t,this)})),function(t){return i.apply(this,arguments)})},{key:"getAllNewUTXOs",value:function(t,e,r){for(var n=t.getOutputs(),i=[],o=0;o<e.outs.length;o++){var a=n[o];"address"in a&&a.address===r&&i.push.apply(i,Rg(this.getUTXOAsTransaction(e,r,o)))}return i}},{key:"parseOptionalInputs",value:function(t){return(t||[]).map(function(t){var e=t.nonWitnessUtxo;return!e||e instanceof Uint8Array||"object"!==Pg(e)||(e=Ig.from(Uint8Array.from(Object.values(t.nonWitnessUtxo)))),jg(jg({},t),{},{nonWitnessUtxo:e})})}},{key:"detectInteractionOPWallet",value:(n=Fg(xg().m(function t(e){var r,n,i;return xg().w(function(t){for(;;)switch(t.n){case 0:if("undefined"!=typeof window){t.n=1;break}return t.a(2,null);case 1:if((r=window)&&r.opnet&&r.opnet.web3){t.n=2;break}return t.a(2,null);case 2:return n=r.opnet.web3,t.n=3,n.signInteraction(jg(jg({},e),{},{signer:void 0}));case 3:if(i=t.v){t.n=4;break}throw new Error("Could not sign interaction transaction.");case 4:return t.a(2,i)}},t)})),function(t){return n.apply(this,arguments)})},{key:"detectDeploymentOPWallet",value:(r=Fg(xg().m(function t(e){var r,n,i;return xg().w(function(t){for(;;)switch(t.n){case 0:if("undefined"!=typeof window){t.n=1;break}return t.a(2,null);case 1:if((r=window)&&r.opnet&&r.opnet.web3){t.n=2;break}return t.a(2,null);case 2:return n=r.opnet.web3,t.n=3,n.deployContract(jg(jg({},e),{},{signer:void 0}));case 3:if(i=t.v){t.n=4;break}throw new Error("Could not sign interaction transaction.");case 4:return t.a(2,i)}},t)})),function(t){return r.apply(this,arguments)})},{key:"createFundTransaction",value:(e=Fg(xg().m(function t(e){var r,n;return xg().w(function(t){for(;;)switch(t.n){case 0:if(e.to){t.n=1;break}throw new Error('Field "to" not provided.');case 1:return r=new ag(e),t.n=2,r.signTransaction();case 2:if(n=t.v){t.n=3;break}throw new Error("Could not sign funding transaction.");case 3:return t.a(2,{tx:n,original:r,estimatedFees:r.estimatedFees,nextUTXOs:this.getUTXOAsTransaction(n,e.to,0)})}},t,this)})),function(t){return e.apply(this,arguments)})},{key:"hasP2WDAInputs",value:function(t){return t.some(function(t){return pl.isP2WDAUTXO(t)})}},{key:"writePSBTHeader",value:function(t,e){var r=Ig.from(e,"base64"),n=Ig.alloc(2);return n.writeUInt8(t,0),n.writeUInt8(eb,1),Ig.concat([n,r]).toString("hex")}},{key:"signP2WDAInteraction",value:(t=Fg(xg().m(function t(e){var r,n,i,o;return xg().w(function(t){for(;;)switch(t.n){case 0:if(e.from){t.n=1;break}throw new Error('Field "from" not provided.');case 1:if("signer"in e){t.n=2;break}throw new Error("P2WDA interactions require a signer. OP_WALLET is not supported for P2WDA.");case 2:return r=this.parseOptionalInputs(e.optionalInputs),n=new Ag(jg(jg({},e),{},{optionalInputs:r})),t.n=3,n.signTransaction();case 3:return i=t.v,o=i.toHex(),t.a(2,{fundingTransaction:null,interactionTransaction:o,estimatedFees:n.estimatedFees,nextUTXOs:this.getUTXOAsTransaction(i,e.from,i.outs.length-1),challenge:e.challenge.toRaw()})}},t,this)})),function(e){return t.apply(this,arguments)})},{key:"getPriorityFee",value:function(t){var e=t.priorityFee+t.gasSatFee;return e<Iy.MINIMUM_DUST?Iy.MINIMUM_DUST:e}},{key:"getUTXOAsTransaction",value:function(t,e,r){if(!t.outs[r])return[];var n=t.outs[r];return[{transactionId:t.getId(),outputIndex:r,scriptPubKey:{hex:n.script.toString("hex"),address:e},value:BigInt(n.value)}]}}]);var t,e,r,n,i,o,a,s}(),Kg=i(8287).Buffer;function Vg(t){return Vg="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Vg(t)}function Wg(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return Gg(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Gg(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}function Gg(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function qg(){var t,e,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",i=r.toStringTag||"@@toStringTag";function o(r,n,i,o){var u=n&&n.prototype instanceof s?n:s,f=Object.create(u.prototype);return zg(f,"_invoke",function(r,n,i){var o,s,u,f=0,c=i||[],l=!1,h={p:0,n:0,v:t,a:p,f:p.bind(t,4),d:function(e,r){return o=e,s=0,u=t,h.n=r,a}};function p(r,n){for(s=r,u=n,e=0;!l&&f&&!i&&e<c.length;e++){var i,o=c[e],p=h.p,d=o[2];r>3?(i=d===n)&&(u=o[(s=o[4])?5:(s=3,3)],o[4]=o[5]=t):o[0]<=p&&((i=r<2&&p<o[1])?(s=0,h.v=n,h.n=o[1]):p<d&&(i=r<3||o[0]>n||n>d)&&(o[4]=r,o[5]=n,h.n=d,s=0))}if(i||r>1)return a;throw l=!0,n}return function(i,c,d){if(f>1)throw TypeError("Generator is already running");for(l&&1===c&&p(c,d),s=c,u=d;(e=s<2?t:u)||!l;){o||(s?s<3?(s>1&&(h.n=-1),p(s,u)):h.n=u:h.v=u);try{if(f=2,o){if(s||(i="next"),e=o[i]){if(!(e=e.call(o,u)))throw TypeError("iterator result is not an object");if(!e.done)return e;u=e.value,s<2&&(s=0)}else 1===s&&(e=o.return)&&e.call(o),s<2&&(u=TypeError("The iterator does not provide a '"+i+"' method"),s=1);o=t}else if((e=(l=h.n<0)?u:r.call(n,h))!==a)break}catch(e){o=t,s=1,u=e}finally{f=1}}return{value:e,done:l}}}(r,i,o),!0),f}var a={};function s(){}function u(){}function f(){}e=Object.getPrototypeOf;var c=[][n]?e(e([][n]())):(zg(e={},n,function(){return this}),e),l=f.prototype=s.prototype=Object.create(c);function h(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,f):(t.__proto__=f,zg(t,i,"GeneratorFunction")),t.prototype=Object.create(l),t}return u.prototype=f,zg(l,"constructor",f),zg(f,"constructor",u),u.displayName="GeneratorFunction",zg(f,i,"GeneratorFunction"),zg(l),zg(l,i,"Generator"),zg(l,n,function(){return this}),zg(l,"toString",function(){return"[object Generator]"}),(qg=function(){return{w:o,m:h}})()}function zg(t,e,r,n){var i=Object.defineProperty;try{i({},"",{})}catch(t){i=0}zg=function(t,e,r,n){function o(e,r){zg(t,e,function(t){return this._invoke(e,r,t)})}e?i?i(t,e,{value:r,enumerable:!n,configurable:!n,writable:!n}):t[e]=r:(o("next",0),o("throw",1),o("return",2))},zg(t,e,r,n)}function Zg(t,e,r,n,i,o,a){try{var s=t[o](a),u=s.value}catch(t){return void r(t)}s.done?e(u):Promise.resolve(u).then(n,i)}function Xg(t){return function(){var e=this,r=arguments;return new Promise(function(n,i){var o=t.apply(e,r);function a(t){Zg(o,n,i,a,s,"next",t)}function s(t){Zg(o,n,i,a,s,"throw",t)}a(void 0)})}}function Yg(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function $g(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?Yg(Object(r),!0).forEach(function(e){rv(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Yg(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function Jg(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,nv(n.key),n)}}function Qg(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(Qg=function(){return!!t})()}function tv(t){return tv=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},tv(t)}function ev(t,e){return ev=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},ev(t,e)}function rv(t,e,r){return(e=nv(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function nv(t){var e=function(t){if("object"!=Vg(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Vg(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Vg(e)?e:e+""}var iv=function(){function t(e){var r;if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),!e.refundVault)throw new Error("Refund vault is required");if(!e.requestedAmount)throw new Error("Requested amount is required");if(!e.receiver)throw new Error("Receiver is required");if(rv(r=function(t,e,r){return e=tv(e),function(t,e){if(e&&("object"==Vg(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,Qg()?Reflect.construct(e,r||[],tv(t).constructor):e.apply(t,r))}(this,t,[$g($g({},e),{},{signer:bc.fromPrivateKey(S.sha256(Kg.from("aaaaaaaa","utf-8"))),priorityFee:0n,gasSatFee:0n})]),"type",Xy.MULTI_SIG),rv(r,"targetScriptRedeem",null),rv(r,"leftOverFundsScriptRedeem",null),rv(r,"originalInputCount",0),rv(r,"sighashTypes",t.signHashTypesArray),rv(r,"customFinalizer",function(t,e){if(!r.tapLeafScript)throw new Error("Tap leaf script is required");var n=r.getScriptSolution(e).concat(r.tapLeafScript.script).concat(r.tapLeafScript.controlBlock);return{finalScriptWitness:Iy.witnessStackToScriptWitness(n)}}),!e.pubkeys)throw new Error("Pubkeys are required");return e.psbt&&(r.log("Using provided PSBT."),r.transaction=e.psbt,r.originalInputCount=r.transaction.data.inputs.length),r.refundVault=e.refundVault,r.requestedAmount=e.requestedAmount,r.receiver=e.receiver,r.publicKeys=e.pubkeys,r.minimumSignatures=e.minimumSignatures,r.compiledTargetScript=yp.compile(e.pubkeys,r.minimumSignatures),r.scriptTree=r.getScriptTree(),r.internalInit(),r}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&ev(t,e)}(t,Iy),function(t,e,r){return e&&Jg(t.prototype,e),r&&Jg(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"finalizeTransactionInputs",value:function(){var t=!1;try{for(var e=this.originalInputCount;e<this.transaction.data.inputs.length;e++)this.transaction.finalizeInput(e,this.customFinalizer.bind(this));t=!0}catch(t){this.error("Error finalizing transaction inputs: ".concat(t.stack))}return t}},{key:"signPSBT",value:(i=Xg(qg().m(function t(){return qg().w(function(t){for(;;)switch(t.n){case 0:return t.n=1,this.signTransaction();case 1:if(!t.v){t.n=2;break}return t.a(2,this.transaction);case 2:throw new Error("Could not sign transaction");case 3:return t.a(2)}},t,this)})),function(){return i.apply(this,arguments)})},{key:"buildTransaction",value:(n=Xg(qg().m(function t(){var e,r;return qg().w(function(t){for(;;)switch(t.n){case 0:if(e=this.targetScriptRedeem){t.n=1;break}throw new Error("Left over funds script redeem is required");case 1:if(e.redeemVersion){t.n=2;break}throw new Error("Left over funds script redeem version is required");case 2:if(e.output){t.n=3;break}throw new Error("Left over funds script redeem output is required");case 3:if(this.tapLeafScript={leafVersion:e.redeemVersion,script:e.output,controlBlock:this.getWitness()},this.addInputsFromUTXO(),!((r=this.calculateOutputLeftAmountFromVaults(this.utxos))<0)){t.n=4;break}throw new Error("Output value left is negative ".concat(r,"."));case 4:this.addOutput({address:this.refundVault,value:Number(r)}),this.addOutput({address:this.receiver,value:Number(this.requestedAmount)});case 5:return t.a(2)}},t,this)})),function(){return n.apply(this,arguments)})},{key:"internalBuildTransaction",value:(r=Xg(qg().m(function t(e){var r,n,i,o,a,s,u=arguments;return qg().w(function(t){for(;;)switch(t.p=t.n){case 0:for(r=u.length>1&&void 0!==u[1]&&u[1],n=this.getInputs(),i=this.getOutputs(),e.setMaximumFeeRate(this._maximumFeeRate),e.addInputs(n,r),o=0;o<this.updateInputs.length;o++)e.updateInput(o,this.updateInputs[o]);return e.addOutputs(i),t.p=1,t.n=2,this.signInputs(e);case 2:return t.a(2,this.finalizeTransactionInputs());case 3:return t.p=3,s=t.v,a=s,this.error("[internalBuildTransaction] Something went wrong while getting building the transaction: ".concat(a.stack)),t.a(2,!1)}},t,this,[[1,3]])})),function(t){return r.apply(this,arguments)})},{key:"signInputs",value:(e=Xg(qg().m(function t(e){return qg().w(function(t){for(;;)if(0===t.n)return t.a(2)},t)})),function(t){return e.apply(this,arguments)})},{key:"generateScriptAddress",value:function(){return{internalPubkey:bi(t.numsPoint),network:this.network,scriptTree:this.scriptTree,name:Yi.P2TR}}},{key:"generateTapData",value:function(){var e=this.targetScriptRedeem;if(!e)throw new Error("Left over funds script redeem is required");if(!this.scriptTree)throw new Error("Script tree is required");return{internalPubkey:bi(t.numsPoint),network:this.network,scriptTree:this.scriptTree,redeem:e,name:Yi.P2TR}}},{key:"getScriptSolution",value:function(t){return t.tapScriptSig?t.tapScriptSig.map(function(t){return t.signature}):[]}},{key:"getScriptTree",value:function(){return this.generateRedeemScripts(),[{output:this.compiledTargetScript,version:192},{output:t.LOCK_LEAF_SCRIPT,version:192}]}},{key:"getTotalOutputAmount",value:function(t){var e,r=0n,n=Wg(t);try{for(n.s();!(e=n.n()).done;)r+=e.value.value}catch(t){n.e(t)}finally{n.f()}return r}},{key:"calculateOutputLeftAmountFromVaults",value:function(t){return this.getTotalOutputAmount(t)-this.requestedAmount}},{key:"generateRedeemScripts",value:function(){this.targetScriptRedeem={name:Yi.P2TR,output:this.compiledTargetScript,redeemVersion:192},this.leftOverFundsScriptRedeem={name:Yi.P2TR,output:t.LOCK_LEAF_SCRIPT,redeemVersion:192}}}],[{key:"fromBase64",value:function(e){var r=Ao.fromBase64(e.psbt,{network:e.network});return new t($g($g({},e),{},{psbt:r}))}},{key:"verifyIfSigned",value:function(t,e){for(var r=!1,n=1;n<t.data.inputs.length;n++){var i=t.data.inputs[n];if(i.finalScriptWitness){var o=Iy.readScriptWitnessToWitnessStack(i.finalScriptWitness);if(!(o.length<3))for(var a=0;a<o.length-2;a+=3)if(o[a+2].equals(e)){r=!0;break}}}return r}},{key:"signPartial",value:function(e,r,n,i){for(var o=!1,a=!0,s=n;s<e.data.inputs.length;s++){var u=e.data.inputs[s];u.tapInternalKey||(u.tapInternalKey=bi(t.numsPoint));var f=[];if(u.finalScriptWitness){var c=Iy.readScriptWitnessToWitnessStack(u.finalScriptWitness);u.tapLeafScript=[{leafVersion:192,script:c[c.length-2],controlBlock:c[c.length-1]}];for(var l=0;l<c.length-2;l+=3)f.push({signature:c[l],leafHash:c[l+1],pubkey:c[l+2]});u.tapScriptSig=(u.tapScriptSig||[]).concat(f)}delete u.finalScriptWitness;var h=t.signHashTypesArray?[t.calculateSignHash(t.signHashTypesArray)]:[];try{t.signInput(e,u,s,r,h),o=!0}catch(t){console.log(t)}if(o){if(!u.tapScriptSig)throw new Error("No new signatures for input");u.tapScriptSig.length!==i[s-n]&&(a=!1)}}return{signed:o,final:!!o&&a}}},{key:"dedupeSignatures",value:function(t,e){var r,n=new Map,i=Wg(t);try{for(i.s();!(r=i.n()).done;){var o=r.value;n.set(o.pubkey.toString("hex"),o)}}catch(t){i.e(t)}finally{i.f()}var a,s=Wg(e);try{for(s.s();!(a=s.n()).done;){var u=a.value;n.has(u.pubkey.toString("hex"))||n.set(u.pubkey.toString("hex"),u)}}catch(t){s.e(t)}finally{s.f()}return Array.from(n.values())}},{key:"attemptFinalizeInputs",value:function(e,r,n,i){for(var o=0,a=function(a){try{var s=e.data.inputs[a];s.tapInternalKey||(s.tapInternalKey=bi(t.numsPoint));var u=[];if(s.finalScriptWitness){for(var f=Iy.readScriptWitnessToWitnessStack(s.finalScriptWitness),c=0;c<f.length-2;c+=3)u.push({signature:f[c],leafHash:f[c+1],pubkey:f[c+2]});s.tapLeafScript=[{leafVersion:192,script:f[f.length-2],controlBlock:f[f.length-1]}],s.tapScriptSig=t.dedupeSignatures(s.tapScriptSig||[],u)}delete s.finalScriptWitness,e.finalizeInput(a,function(e,o){return t.partialFinalizer(e,o,[],n[a-r],i)}),o++}catch(t){}},s=r;s<e.data.inputs.length;s++)a(s);return o===e.data.inputs.length-r}}]);var e,r,n,i}();rv(iv,"LOCK_LEAF_SCRIPT",w.compile([it.OP_XOR,it.OP_NOP,it.OP_CODESEPARATOR])),rv(iv,"signHashTypesArray",[]),rv(iv,"numsPoint",Kg.from("50929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac0","hex")),rv(iv,"partialFinalizer",function(t,e,r,n,i){if(!e.tapLeafScript||!e.tapLeafScript[0].script||!e.tapLeafScript[0].controlBlock)throw new Error("Tap leaf script is required");if(!e.tapScriptSig)throw new Error("No new signatures for input ".concat(t,"."));var o=[];if(i){var a,s=Wg(n);try{for(s.s();!(a=s.n()).done;){var u,f=a.value,c=!1,l=Wg(e.tapScriptSig);try{for(l.s();!(u=l.n()).done;){var h=u.value;h.pubkey.equals(bi(f))&&(o.push(h.signature),c=!0)}}catch(t){l.e(t)}finally{l.f()}c||o.push(Kg.alloc(0))}}catch(t){s.e(t)}finally{s.f()}o=o.reverse()}else o=e.tapScriptSig.map(function(t){return[t.signature,t.leafHash,t.pubkey]}).flat();r.length>0&&(o=o.concat(r));var p=o.concat(e.tapLeafScript[0].script).concat(e.tapLeafScript[0].controlBlock);return{finalScriptWitness:Iy.witnessStackToScriptWitness(p)}});var ov=i(8287).Buffer;function av(t){return ov.from(t.replace("0x",""),"hex")}function sv(t){return sv="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},sv(t)}function uv(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,cv(n.key),n)}}function fv(t,e,r){return e&&uv(t.prototype,e),r&&uv(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function cv(t){var e=function(t){if("object"!=sv(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=sv(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==sv(e)?e:e+""}function lv(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}var hv=fv(function t(e){lv(this,t),this.epochHash=av(e.epochHash),this.epochRoot=av(e.epochRoot),this.targetHash=av(e.targetHash),this.targetChecksum=av(e.targetChecksum),this.startBlock=BigInt(e.startBlock),this.endBlock=BigInt(e.endBlock),this.proofs=Object.freeze(e.proofs.map(function(t){return av(t)}))}),pv=function(){return fv(function t(e,r){lv(this,t),this.epochNumber=r,this.publicKey=ih.fromString(e.publicKey),this.solution=av(e.solution),this.graffiti=e.graffiti?av(e.graffiti):void 0,this.signature=av(e.signature)},[{key:"verifySignature",value:function(){var t=new ph;t.writeAddress(this.publicKey),t.writeU64(this.epochNumber),t.writeBytes(this.solution),this.graffiti&&t.writeBytes(this.graffiti);var e=t.getBuffer();return Dy.verifySignature(this.publicKey,e,this.signature)}}])}(),dv=function(){return fv(function t(e){lv(this,t),this.epochNumber=BigInt(e.epochNumber),this.publicKey=ih.fromString(e.publicKey),this.solution=av(e.solution),this.salt=av(e.salt),this.graffiti=av(e.graffiti),this.difficulty=e.difficulty,this.verification=new hv(e.verification),this.submission=e.submission?new pv(e.submission,this.epochNumber+2n):e.submission},[{key:"verifySubmissionSignature",value:function(){if(!this.submission)throw new Error("No submission provided in request.");return this.submission.verifySignature()}},{key:"getSubmission",value:function(){if(this.submission){if(!this.verifySubmissionSignature())throw new Error("Invalid submission signature.");return this.submission}}},{key:"verify",value:function(){return wv.validateChallengeSolution(this)}},{key:"toBuffer",value:function(){return this.solution}},{key:"toHex",value:function(){return"0x"+this.solution.toString("hex")}},{key:"toRaw",value:function(){return{epochNumber:this.epochNumber.toString(),publicKey:this.publicKey.toHex(),solution:this.toHex(),salt:"0x"+this.salt.toString("hex"),graffiti:"0x"+this.graffiti.toString("hex"),difficulty:this.difficulty,verification:{epochHash:"0x"+this.verification.epochHash.toString("hex"),epochRoot:"0x"+this.verification.epochRoot.toString("hex"),targetHash:"0x"+this.verification.targetHash.toString("hex"),targetChecksum:"0x"+this.verification.targetChecksum.toString("hex"),startBlock:this.verification.startBlock.toString(),endBlock:this.verification.endBlock.toString(),proofs:this.verification.proofs.map(function(t){return"0x"+t.toString("hex")})}}}},{key:"calculateSolution",value:function(){return wv.calculateSolution(this.verification.targetChecksum,this.publicKey.toBuffer(),this.salt)}},{key:"checkDifficulty",value:function(t){return wv.checkDifficulty(this.solution,this.verification.targetHash,t)}},{key:"getMiningTargetBlock",value:function(){return wv.getMiningTargetBlock(this.epochNumber)}}],[{key:"validateRaw",value:function(t){return wv.validateEpochWinner(t)}}])}(),yv=i(8287).Buffer;function bv(t){return bv="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},bv(t)}function gv(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,vv(n.key),n)}}function vv(t){var e=function(t){if("object"!=bv(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=bv(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==bv(e)?e:e+""}var wv=function(){return function(t,e,r){return r&&gv(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)},0,[{key:"bufferToUint8Array",value:function(t){return new Uint8Array(t)}},{key:"uint8ArrayToBuffer",value:function(t){return yv.from(t)}},{key:"sha1",value:function(t){return S.sha1(yv.isBuffer(t)?t:yv.from(t))}},{key:"calculatePreimage",value:function(t,e,r){if(32!==t.length||32!==e.length||32!==r.length)throw new Error("All inputs must be 32 bytes");for(var n=yv.alloc(32),i=0;i<32;i++)n[i]=t[i]^e[i]^r[i];return n}},{key:"countMatchingBits",value:function(t,e){var r=0;if(t.length!==e.length)throw new Error("Hashes must be of the same length");for(var n=Math.min(t.length,e.length),i=0;i<n;i++){var o=t[i],a=e[i];if(o===a)r+=8;else for(var s=7;s>=0;s--){if((o>>s&1)!=(a>>s&1))return r;r++}}return r}},{key:"verifySolution",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];try{var r=t.verification,n=this.calculatePreimage(r.targetChecksum,t.publicKey.toBuffer(),t.salt),i=this.sha1(n),o=this.uint8ArrayToBuffer(i);if(!o.equals(t.solution))return!1;if(this.countMatchingBits(o,r.targetHash)!==t.difficulty)return!1;var a=t.epochNumber*this.BLOCKS_PER_EPOCH,s=a+this.BLOCKS_PER_EPOCH-1n;return!(r.startBlock!==a||r.endBlock!==s)}catch(t){return e&&console.error("Verification error:",t),!1}}},{key:"getMiningTargetBlock",value:function(t){return 0n===t?null:t*this.BLOCKS_PER_EPOCH-1n}},{key:"validateEpochWinner",value:function(t){var e=new dv(t);return this.verifySolution(e)}},{key:"validateChallengeSolution",value:function(t){return this.verifySolution(t)}},{key:"calculateSolution",value:function(t,e,r){var n=this.calculatePreimage(t,e,r),i=this.sha1(this.bufferToUint8Array(n));return this.uint8ArrayToBuffer(i)}},{key:"checkDifficulty",value:function(t,e,r){var n=this.countMatchingBits(t,e);return{valid:n>=r,difficulty:n}}}])}();!function(t,e){(e=vv(e))in t?Object.defineProperty(t,e,{value:5n,enumerable:!0,configurable:!0,writable:!0}):t[e]=5n}(wv,"BLOCKS_PER_EPOCH");var mv=i(8287).Buffer;function Sv(t){return Sv="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Sv(t)}function _v(t){if(null!=t){var e=t["function"==typeof Symbol&&Symbol.iterator||"@@iterator"],r=0;if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length))return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}}}throw new TypeError(Sv(t)+" is not iterable")}function Ev(){var t,e,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",i=r.toStringTag||"@@toStringTag";function o(r,n,i,o){var u=n&&n.prototype instanceof s?n:s,f=Object.create(u.prototype);return kv(f,"_invoke",function(r,n,i){var o,s,u,f=0,c=i||[],l=!1,h={p:0,n:0,v:t,a:p,f:p.bind(t,4),d:function(e,r){return o=e,s=0,u=t,h.n=r,a}};function p(r,n){for(s=r,u=n,e=0;!l&&f&&!i&&e<c.length;e++){var i,o=c[e],p=h.p,d=o[2];r>3?(i=d===n)&&(u=o[(s=o[4])?5:(s=3,3)],o[4]=o[5]=t):o[0]<=p&&((i=r<2&&p<o[1])?(s=0,h.v=n,h.n=o[1]):p<d&&(i=r<3||o[0]>n||n>d)&&(o[4]=r,o[5]=n,h.n=d,s=0))}if(i||r>1)return a;throw l=!0,n}return function(i,c,d){if(f>1)throw TypeError("Generator is already running");for(l&&1===c&&p(c,d),s=c,u=d;(e=s<2?t:u)||!l;){o||(s?s<3?(s>1&&(h.n=-1),p(s,u)):h.n=u:h.v=u);try{if(f=2,o){if(s||(i="next"),e=o[i]){if(!(e=e.call(o,u)))throw TypeError("iterator result is not an object");if(!e.done)return e;u=e.value,s<2&&(s=0)}else 1===s&&(e=o.return)&&e.call(o),s<2&&(u=TypeError("The iterator does not provide a '"+i+"' method"),s=1);o=t}else if((e=(l=h.n<0)?u:r.call(n,h))!==a)break}catch(e){o=t,s=1,u=e}finally{f=1}}return{value:e,done:l}}}(r,i,o),!0),f}var a={};function s(){}function u(){}function f(){}e=Object.getPrototypeOf;var c=[][n]?e(e([][n]())):(kv(e={},n,function(){return this}),e),l=f.prototype=s.prototype=Object.create(c);function h(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,f):(t.__proto__=f,kv(t,i,"GeneratorFunction")),t.prototype=Object.create(l),t}return u.prototype=f,kv(l,"constructor",f),kv(f,"constructor",u),u.displayName="GeneratorFunction",kv(f,i,"GeneratorFunction"),kv(l),kv(l,i,"Generator"),kv(l,n,function(){return this}),kv(l,"toString",function(){return"[object Generator]"}),(Ev=function(){return{w:o,m:h}})()}function kv(t,e,r,n){var i=Object.defineProperty;try{i({},"",{})}catch(t){i=0}kv=function(t,e,r,n){function o(e,r){kv(t,e,function(t){return this._invoke(e,r,t)})}e?i?i(t,e,{value:r,enumerable:!n,configurable:!n,writable:!n}):t[e]=r:(o("next",0),o("throw",1),o("return",2))},kv(t,e,r,n)}function Ov(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=Av(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}function Tv(t){return function(t){if(Array.isArray(t))return Iv(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||Av(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Av(t,e){if(t){if("string"==typeof t)return Iv(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Iv(t,e):void 0}}function Iv(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function Pv(t,e,r,n,i,o,a){try{var s=t[o](a),u=s.value}catch(t){return void r(t)}s.done?e(u):Promise.resolve(u).then(n,i)}function xv(t){return function(){var e=this,r=arguments;return new Promise(function(n,i){var o=t.apply(e,r);function a(t){Pv(o,n,i,a,s,"next",t)}function s(t){Pv(o,n,i,a,s,"throw",t)}a(void 0)})}}function Bv(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Uv(n.key),n)}}function Rv(t,e,r){return(e=Uv(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Uv(t){var e=function(t){if("object"!=Sv(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Sv(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Sv(e)?e:e+""}var Nv=function(){return function(t,e){return e&&Bv(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}(function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),Rv(this,"utxoPath","address/utxos"),Rv(this,"rpc","json-rpc"),this.opnetAPIUrl=e},[{key:"fetchUTXO",value:(i=xv(Ev().m(function t(e){var r,n,i,o,a,s,u,f,c,l,h,p,d,y,b,g,v,w,m,S;return Ev().w(function(t){for(;;)switch(t.p=t.n){case 0:return void 0===e.usePendingUTXO&&(e.usePendingUTXO=!0),void 0===e.optimized&&(e.optimized=!0),n={method:"GET",headers:{"Content-Type":"application/json"}},i="".concat(this.opnetAPIUrl,"/api/v1/").concat(this.utxoPath,"?address=").concat(e.address,"&optimize=").concat(null!==(r=e.optimized)&&void 0!==r&&r),t.n=1,fetch(i,n);case 1:if((o=t.v).ok){t.n=2;break}throw new Error("Failed to fetch UTXO data: ".concat(o.statusText));case 2:return t.n=3,o.json();case 3:a=t.v,s=e.usePendingUTXO?[].concat(Tv(a.confirmed),Tv(a.pending)):a.confirmed,u=[],f=Ov(s),t.p=4,l=Ev().m(function t(){var e;return Ev().w(function(t){for(;;)switch(t.n){case 0:if(e=c.value,!a.spentTransactions.some(function(t){return t.transactionId===e.transactionId&&t.outputIndex===e.outputIndex})){t.n=1;break}return t.a(2,1);case 1:u.push(e);case 2:return t.a(2)}},t)}),f.s();case 5:if((c=f.n()).done){t.n=8;break}return t.d(_v(l()),6);case 6:if(!t.v){t.n=7;break}return t.a(3,7);case 7:t.n=5;break;case 8:t.n=10;break;case 9:t.p=9,m=t.v,f.e(m);case 10:return t.p=10,f.f(),t.f(10);case 11:if(0!==u.length){t.n=12;break}throw new Error("No UTXO found");case 12:if(h=u.filter(function(t){return BigInt(t.value)>=e.minAmount}),0!==h.length){t.n=13;break}throw new Error("No UTXO found (minAmount)");case 13:p=[],d=0n,y=e.requestedAmount,b=Ov(h),t.p=14,b.s();case 15:if((g=b.n()).done){t.n=18;break}if(v=g.value,!((w=BigInt(v.value))<=0n)){t.n=16;break}return t.a(3,17);case 16:if(d+=w,p.push({transactionId:v.transactionId,outputIndex:v.outputIndex,value:w,scriptPubKey:v.scriptPubKey,nonWitnessUtxo:mv.from(v.raw,"base64")}),!(d>y)){t.n=17;break}return t.a(3,18);case 17:t.n=15;break;case 18:t.n=20;break;case 19:t.p=19,S=t.v,b.e(S);case 20:return t.p=20,b.f(),t.f(20);case 21:return t.a(2,p)}},t,this,[[14,19,20,21],[4,9,10,11]])})),function(t){return i.apply(this,arguments)})},{key:"fetchUTXOMultiAddr",value:(n=xv(Ev().m(function t(e){var r,n,i,o,a,s,u,f,c,l,h,p;return Ev().w(function(t){for(;;)switch(t.n){case 0:r=[],n=Ov(e.addresses);try{for(n.s();!(i=n.n()).done;)o=i.value,a={address:o,minAmount:e.minAmount,requestedAmount:e.requestedAmount,optimized:e.optimized,usePendingUTXO:e.usePendingUTXO},s=this.fetchUTXO(a).catch(function(){return[]}),r.push(s)}catch(t){n.e(t)}finally{n.f()}return t.n=1,Promise.all(r);case 1:u=t.v,f=u.flat(),c=[],l=0n,h=0;case 2:if(!(h<f.length)){t.n=5;break}if(p=f[h],!(l>=e.requestedAmount)){t.n=3;break}return t.a(3,5);case 3:l+=p.value,c.push(p);case 4:h++,t.n=2;break;case 5:return t.a(2,c)}},t,this)})),function(t){return n.apply(this,arguments)})},{key:"broadcastTransaction",value:(r=xv(Ev().m(function t(e,r){var n,i;return Ev().w(function(t){for(;;)switch(t.n){case 0:return n=[e,r],t.n=1,this.rpcMethod("btc_sendRawTransaction",n);case 1:if(i=t.v){t.n=2;break}return t.a(2);case 2:return t.a(2,i)}},t,this)})),function(t,e){return r.apply(this,arguments)})},{key:"splitUTXOs",value:(e=xv(Ev().m(function t(e,r,n,i){var o,a,s,u,f,c,l;return Ev().w(function(t){for(;;)switch(t.n){case 0:return o={addresses:[e.p2wpkh,e.p2tr],minAmount:330n,requestedAmount:1000000000000000n},t.n=1,this.fetchUTXOMultiAddr(o);case 1:if((a=t.v)&&a.length){t.n=2;break}return t.a(2,{error:"No UTXOs found"});case 2:return s=BigInt(n)*i,u={amount:s,feeRate:500,from:e.p2tr,utxos:a,signer:e.keypair,network:r,to:e.p2tr,splitInputsInto:n,priorityFee:0n,gasSatFee:330n},f=new Mg,t.n=3,f.createBTCTransfer(u);case 3:return c=t.v,t.n=4,this.broadcastTransaction(c.tx,!1);case 4:if(l=t.v){t.n=5;break}return t.a(2,{error:"Could not broadcast transaction"});case 5:return t.a(2,l)}},t,this)})),function(t,r,n,i){return e.apply(this,arguments)})},{key:"rpcMethod",value:(t=xv(Ev().m(function t(e,r){var n,i,o,a,s;return Ev().w(function(t){for(;;)switch(t.n){case 0:return n={method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({jsonrpc:"2.0",method:e,params:r,id:1})},i="".concat(this.opnetAPIUrl,"/api/v1/").concat(this.rpc),t.n=1,fetch(i,n);case 1:if((o=t.v).ok){t.n=2;break}throw new Error("Failed to fetch to rpc: ".concat(o.statusText));case 2:return t.n=3,o.json();case 3:if(a=t.v){t.n=4;break}throw new Error("No data fetched");case 4:if(s=a.result){t.n=5;break}throw new Error("No rpc parameters found");case 5:if(!("error"in s)){t.n=6;break}throw new Error("Error in fetching to rpc ".concat(s.error));case 6:return t.a(2,s)}},t,this)})),function(e,r){return t.apply(this,arguments)})}]);var t,e,r,n,i}();function jv(t){return jv="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},jv(t)}function Lv(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function Cv(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?Lv(Object(r),!0).forEach(function(e){Kv(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Lv(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function Fv(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Vv(n.key),n)}}function Dv(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(Dv=function(){return!!t})()}function Hv(t){return Hv=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Hv(t)}function Mv(t,e){return Mv=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Mv(t,e)}function Kv(t,e,r){return(e=Vv(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Vv(t){var e=function(t){if("object"!=jv(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=jv(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==jv(e)?e:e+""}var Wv,Gv=function(){function t(e){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),Kv(r=function(t,e,r){return e=Hv(e),function(t,e){if(e&&("object"==jv(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,Dv()?Reflect.construct(e,r||[],Hv(t).constructor):e.apply(t,r))}(this,t,[e]),"logColor","#00ffe1"),Kv(r,"feesAddition",10000n),Kv(r,"sighashTypes",[]),r.signer=e.signer,r.network=e.network,r.transaction=e.psbt,r.ignoreSignatureError(),r.tweakSigner(),r.internalInit(),r}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Mv(t,e)}(t,uy),function(t,e,r){return e&&Fv(t.prototype,e),r&&Fv(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"extractTransaction",value:function(){return this.transaction.extractTransaction()}},{key:"final",value:function(){return this.extractTransaction().toHex()}},{key:"toHex",value:function(){return this.transaction.toHex()}},{key:"addInput",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.transaction.addInput(t,e)}},{key:"addOutput",value:function(t){t.value&&this.transaction.addOutput(t)}},{key:"attemptFinalizeInputs",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;try{for(var e=this.transaction.data.inputs,r=t;r<e.length;r++){var n=e[r];n.finalScriptWitness?this.transaction.finalizeTaprootInput(r,n.finalScriptWitness):this.transaction.finalizeInput(r)}return!0}catch(t){return this.warn(t.stack||"Couldn't finalize inputs"),!1}}},{key:"getPSBT",value:function(){return this.transaction}}],[{key:"fromBase64",value:function(e,r){var n=Ao.fromBase64(e,{network:r.network});return new t(Cv(Cv({},r),{},{psbt:n}))}},{key:"fromHex",value:function(e,r){var n=Ao.fromHex(e,{network:r.network});return new t(Cv(Cv({},r),{},{psbt:n}))}},{key:"from",value:function(e){var r=new Ao({network:e.network});return new t(Cv(Cv({},e),{},{psbt:r}))}}])}();function qv(t){return qv="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},qv(t)}function zv(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Zv(n.key),n)}}function Zv(t){var e=function(t){if("object"!=qv(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=qv(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==qv(e)?e:e+""}!function(t){t[t.UNWRAP=0]="UNWRAP"}(Wv||(Wv={}));var Xv,Yv=function(){return function(t,e,r){return r&&zv(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)},0,[{key:"generateMultiSigAddress",value:function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:b.bitcoin;if(bc.verifyPubKeys(t,r).length!==t.length)throw new Error("Contains invalid public keys");var n=new iv({network:r,utxos:[],pubkeys:t,minimumSignatures:e,feeRate:100,receiver:"a",requestedAmount:1n,refundVault:"a"}).getScriptAddress();if(!n)throw new Error("Failed to generate address");return n}}])}(),$v=i(2802),Jv=i.n($v);function Qv(t){return Qv="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Qv(t)}function tw(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,ew(n.key),n)}}function ew(t){var e=function(t){if("object"!=Qv(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Qv(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Qv(e)?e:e+""}!function(t){t.UINT8="UINT8",t.UINT16="UINT16",t.UINT32="UINT32",t.UINT64="UINT64",t.UINT128="UINT128",t.UINT256="UINT256",t.INT128="INT128",t.BOOL="BOOL",t.ADDRESS="ADDRESS",t.STRING="STRING",t.BYTES4="BYTES4",t.BYTES32="BYTES32",t.BYTES="BYTES",t.ADDRESS_UINT256_TUPLE="ADDRESS_UINT256_TUPLE",t.ARRAY_OF_ADDRESSES="ARRAY_OF_ADDRESSES",t.ARRAY_OF_UINT256="ARRAY_OF_UINT256",t.ARRAY_OF_UINT128="ARRAY_OF_UINT128",t.ARRAY_OF_UINT64="ARRAY_OF_UINT64",t.ARRAY_OF_UINT32="ARRAY_OF_UINT32",t.ARRAY_OF_UINT16="ARRAY_OF_UINT16",t.ARRAY_OF_UINT8="ARRAY_OF_UINT8",t.ARRAY_OF_STRING="ARRAY_OF_STRING",t.ARRAY_OF_BYTES="ARRAY_OF_BYTES"}(Xv||(Xv={}));var rw=function(){return function(t,e){return e&&tw(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}(function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)},[{key:"decodeData",value:function(t,e){for(var r=new uh(t),n=[],i=0;i<e.length;i++)switch(e[i]){case Xv.UINT8:n.push(r.readU8());break;case Xv.UINT16:n.push(r.readU16());break;case Xv.UINT32:n.push(r.readU32());break;case Xv.BYTES4:n.push(r.readBytes(4));break;case Xv.BYTES32:n.push(r.readBytes(32));break;case Xv.BOOL:n.push(r.readBoolean());break;case Xv.ADDRESS:n.push(r.readAddress());break;case Xv.STRING:n.push(r.readStringWithLength());break;case Xv.UINT128:n.push(r.readU128());break;case Xv.UINT256:n.push(r.readU256());break;case Xv.INT128:n.push(r.readI128());break;case Xv.ADDRESS_UINT256_TUPLE:n.push(r.readAddressValueTuple());break;case Xv.BYTES:n.push(r.readBytesWithLength());break;case Xv.UINT64:n.push(r.readU64());break;case Xv.ARRAY_OF_ADDRESSES:n.push(r.readAddressArray());break;case Xv.ARRAY_OF_UINT256:n.push(r.readU256Array());break;case Xv.ARRAY_OF_UINT128:n.push(r.readU128Array());break;case Xv.ARRAY_OF_UINT64:n.push(r.readU64Array());break;case Xv.ARRAY_OF_UINT32:n.push(r.readU32Array());break;case Xv.ARRAY_OF_UINT16:n.push(r.readU16Array());break;case Xv.ARRAY_OF_UINT8:n.push(r.readU8Array());break;case Xv.ARRAY_OF_STRING:n.push(r.readStringArray());break;case Xv.ARRAY_OF_BYTES:n.push(r.readBytesArray())}return n}},{key:"encodeSelector",value:function(t){return this.sha256(t).subarray(0,4).toString("hex")}},{key:"numericSelectorToHex",value:function(t){return t.toString(16)}},{key:"bigIntToUint8Array",value:function(t,e){for(var r=new Uint8Array(e),n=Lc.valueToUint8Array(t),i=0;i<e;i++)r[i]=n[i]||0;return r}},{key:"sha256",value:function(t){return(new(Jv().sha256)).update(t).digest()}}])}();function nw(t){return nw="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},nw(t)}function iw(){var t,e,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",i=r.toStringTag||"@@toStringTag";function o(r,n,i,o){var u=n&&n.prototype instanceof s?n:s,f=Object.create(u.prototype);return ow(f,"_invoke",function(r,n,i){var o,s,u,f=0,c=i||[],l=!1,h={p:0,n:0,v:t,a:p,f:p.bind(t,4),d:function(e,r){return o=e,s=0,u=t,h.n=r,a}};function p(r,n){for(s=r,u=n,e=0;!l&&f&&!i&&e<c.length;e++){var i,o=c[e],p=h.p,d=o[2];r>3?(i=d===n)&&(u=o[(s=o[4])?5:(s=3,3)],o[4]=o[5]=t):o[0]<=p&&((i=r<2&&p<o[1])?(s=0,h.v=n,h.n=o[1]):p<d&&(i=r<3||o[0]>n||n>d)&&(o[4]=r,o[5]=n,h.n=d,s=0))}if(i||r>1)return a;throw l=!0,n}return function(i,c,d){if(f>1)throw TypeError("Generator is already running");for(l&&1===c&&p(c,d),s=c,u=d;(e=s<2?t:u)||!l;){o||(s?s<3?(s>1&&(h.n=-1),p(s,u)):h.n=u:h.v=u);try{if(f=2,o){if(s||(i="next"),e=o[i]){if(!(e=e.call(o,u)))throw TypeError("iterator result is not an object");if(!e.done)return e;u=e.value,s<2&&(s=0)}else 1===s&&(e=o.return)&&e.call(o),s<2&&(u=TypeError("The iterator does not provide a '"+i+"' method"),s=1);o=t}else if((e=(l=h.n<0)?u:r.call(n,h))!==a)break}catch(e){o=t,s=1,u=e}finally{f=1}}return{value:e,done:l}}}(r,i,o),!0),f}var a={};function s(){}function u(){}function f(){}e=Object.getPrototypeOf;var c=[][n]?e(e([][n]())):(ow(e={},n,function(){return this}),e),l=f.prototype=s.prototype=Object.create(c);function h(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,f):(t.__proto__=f,ow(t,i,"GeneratorFunction")),t.prototype=Object.create(l),t}return u.prototype=f,ow(l,"constructor",f),ow(f,"constructor",u),u.displayName="GeneratorFunction",ow(f,i,"GeneratorFunction"),ow(l),ow(l,i,"Generator"),ow(l,n,function(){return this}),ow(l,"toString",function(){return"[object Generator]"}),(iw=function(){return{w:o,m:h}})()}function ow(t,e,r,n){var i=Object.defineProperty;try{i({},"",{})}catch(t){i=0}ow=function(t,e,r,n){function o(e,r){ow(t,e,function(t){return this._invoke(e,r,t)})}e?i?i(t,e,{value:r,enumerable:!n,configurable:!n,writable:!n}):t[e]=r:(o("next",0),o("throw",1),o("return",2))},ow(t,e,r,n)}function aw(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,sw(n.key),n)}}function sw(t){var e=function(t){if("object"!=nw(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=nw(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==nw(e)?e:e+""}var uw=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.keys=e}return function(t,e){return e&&aw(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"size",get:function(){return this.keys.length}},{key:"add",value:function(t){this.has(t)||this.keys.push(t)}},{key:"has",value:function(t){for(var e=0;e<this.keys.length;e++)if(this.keys[e].equals(t))return!0;return!1}},{key:"remove",value:function(t){var e=this.keys.findIndex(function(e){return e.equals(t)});-1!==e&&this.keys.splice(e,1)}},{key:"clone",value:function(){for(var e=new t,r=0;r<this.keys.length;r++)e.add(this.keys[r]);return e}},{key:"clear",value:function(){this.keys=[]}},{key:"combine",value:function(t){for(var e=this.clone(),r=0;r<t.keys.length;r++)e.add(t.keys[r]);return e}},{key:Symbol.iterator,value:iw().m(function t(){var e;return iw().w(function(t){for(;;)switch(t.n){case 0:e=0;case 1:if(!(e<this.keys.length)){t.n=3;break}return t.n=2,this.keys[e];case 2:e++,t.n=1;break;case 3:return t.a(2)}},t,this)})}])}();function fw(t){return fw="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},fw(t)}function cw(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,i,o,a,s=[],u=!0,f=!1;try{if(o=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=o.call(r)).done)&&(s.push(n.value),s.length!==e);u=!0);}catch(t){f=!0,i=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(f)throw i}}return s}}(t,e)||dw(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function lw(){var t,e,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",i=r.toStringTag||"@@toStringTag";function o(r,n,i,o){var u=n&&n.prototype instanceof s?n:s,f=Object.create(u.prototype);return hw(f,"_invoke",function(r,n,i){var o,s,u,f=0,c=i||[],l=!1,h={p:0,n:0,v:t,a:p,f:p.bind(t,4),d:function(e,r){return o=e,s=0,u=t,h.n=r,a}};function p(r,n){for(s=r,u=n,e=0;!l&&f&&!i&&e<c.length;e++){var i,o=c[e],p=h.p,d=o[2];r>3?(i=d===n)&&(u=o[(s=o[4])?5:(s=3,3)],o[4]=o[5]=t):o[0]<=p&&((i=r<2&&p<o[1])?(s=0,h.v=n,h.n=o[1]):p<d&&(i=r<3||o[0]>n||n>d)&&(o[4]=r,o[5]=n,h.n=d,s=0))}if(i||r>1)return a;throw l=!0,n}return function(i,c,d){if(f>1)throw TypeError("Generator is already running");for(l&&1===c&&p(c,d),s=c,u=d;(e=s<2?t:u)||!l;){o||(s?s<3?(s>1&&(h.n=-1),p(s,u)):h.n=u:h.v=u);try{if(f=2,o){if(s||(i="next"),e=o[i]){if(!(e=e.call(o,u)))throw TypeError("iterator result is not an object");if(!e.done)return e;u=e.value,s<2&&(s=0)}else 1===s&&(e=o.return)&&e.call(o),s<2&&(u=TypeError("The iterator does not provide a '"+i+"' method"),s=1);o=t}else if((e=(l=h.n<0)?u:r.call(n,h))!==a)break}catch(e){o=t,s=1,u=e}finally{f=1}}return{value:e,done:l}}}(r,i,o),!0),f}var a={};function s(){}function u(){}function f(){}e=Object.getPrototypeOf;var c=[][n]?e(e([][n]())):(hw(e={},n,function(){return this}),e),l=f.prototype=s.prototype=Object.create(c);function h(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,f):(t.__proto__=f,hw(t,i,"GeneratorFunction")),t.prototype=Object.create(l),t}return u.prototype=f,hw(l,"constructor",f),hw(f,"constructor",u),u.displayName="GeneratorFunction",hw(f,i,"GeneratorFunction"),hw(l),hw(l,i,"Generator"),hw(l,n,function(){return this}),hw(l,"toString",function(){return"[object Generator]"}),(lw=function(){return{w:o,m:h}})()}function hw(t,e,r,n){var i=Object.defineProperty;try{i({},"",{})}catch(t){i=0}hw=function(t,e,r,n){function o(e,r){hw(t,e,function(t){return this._invoke(e,r,t)})}e?i?i(t,e,{value:r,enumerable:!n,configurable:!n,writable:!n}):t[e]=r:(o("next",0),o("throw",1),o("return",2))},hw(t,e,r,n)}function pw(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=dw(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}function dw(t,e){if(t){if("string"==typeof t)return yw(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?yw(t,e):void 0}}function yw(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function bw(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,gw(n.key),n)}}function gw(t){var e=function(t){if("object"!=fw(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=fw(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==fw(e)?e:e+""}function vw(t,e){return t.get(mw(t,e))}function ww(t,e,r){return t.set(mw(t,e),r),r}function mw(t,e,r){if("function"==typeof t?t===e:t.has(e))return arguments.length<3?e:r;throw new TypeError("Private element is not present on this object")}var Sw=new WeakMap,_w=function(){function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),function(t,e,r){(function(t,e){if(e.has(t))throw new TypeError("Cannot initialize the same private elements twice on an object")})(t,e),e.set(t,r)}(this,Sw,void 0),this.compareFn=e,this.map=new Map,ww(Sw,this,[])}return function(t,e,r){return e&&bw(t.prototype,e),r&&bw(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"size",get:function(){return this.map.size}},{key:"set",value:function(t,e){this.map.has(t)||(vw(Sw,this).push(t),vw(Sw,this).sort(this.compareFn)),this.map.set(t,e)}},{key:"get",value:function(t){return this.map.get(t)}},{key:"keys",value:function(){return vw(Sw,this).values()}},{key:"values",value:function(){for(var t=[],e=0;e<vw(Sw,this).length;e++){var r=vw(Sw,this)[e],n=this.map.get(r);if(!n)throw new Error("Value not found");t.push(n)}return t.values()}},{key:"has",value:function(t){return this.map.has(t)}},{key:"delete",value:function(t){return!!this.map.has(t)&&(this.map.delete(t),ww(Sw,this,vw(Sw,this).filter(function(e){return e!==t})),!0)}},{key:"clear",value:function(){this.map.clear(),ww(Sw,this,[])}},{key:"forEach",value:function(t){var e,r=pw(vw(Sw,this));try{for(r.s();!(e=r.n()).done;){var n=e.value;t(this.map.get(n),n,this)}}catch(t){r.e(t)}finally{r.f()}}},{key:Symbol.iterator,value:lw().m(function t(){var e,r,n,i;return lw().w(function(t){for(;;)switch(t.p=t.n){case 0:e=pw(vw(Sw,this)),t.p=1,e.s();case 2:if((r=e.n()).done){t.n=4;break}return n=r.value,t.n=3,[n,this.map.get(n)];case 3:t.n=2;break;case 4:t.n=6;break;case 5:t.p=5,i=t.v,e.e(i);case 6:return t.p=6,e.f(),t.f(6);case 7:return t.a(2)}},t,this,[[1,5,6,7]])})}],[{key:"fromMap",value:function(e,r){var n,i=new t(r),o=pw(e);try{for(o.s();!(n=o.n()).done;){var a=cw(n.value,2),s=a[0],u=a[1];i.set(s,u)}}catch(t){o.e(t)}finally{o.f()}return i}}])}();function Ew(t){return Ew="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Ew(t)}function kw(){var t,e,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",i=r.toStringTag||"@@toStringTag";function o(r,n,i,o){var u=n&&n.prototype instanceof s?n:s,f=Object.create(u.prototype);return Ow(f,"_invoke",function(r,n,i){var o,s,u,f=0,c=i||[],l=!1,h={p:0,n:0,v:t,a:p,f:p.bind(t,4),d:function(e,r){return o=e,s=0,u=t,h.n=r,a}};function p(r,n){for(s=r,u=n,e=0;!l&&f&&!i&&e<c.length;e++){var i,o=c[e],p=h.p,d=o[2];r>3?(i=d===n)&&(u=o[(s=o[4])?5:(s=3,3)],o[4]=o[5]=t):o[0]<=p&&((i=r<2&&p<o[1])?(s=0,h.v=n,h.n=o[1]):p<d&&(i=r<3||o[0]>n||n>d)&&(o[4]=r,o[5]=n,h.n=d,s=0))}if(i||r>1)return a;throw l=!0,n}return function(i,c,d){if(f>1)throw TypeError("Generator is already running");for(l&&1===c&&p(c,d),s=c,u=d;(e=s<2?t:u)||!l;){o||(s?s<3?(s>1&&(h.n=-1),p(s,u)):h.n=u:h.v=u);try{if(f=2,o){if(s||(i="next"),e=o[i]){if(!(e=e.call(o,u)))throw TypeError("iterator result is not an object");if(!e.done)return e;u=e.value,s<2&&(s=0)}else 1===s&&(e=o.return)&&e.call(o),s<2&&(u=TypeError("The iterator does not provide a '"+i+"' method"),s=1);o=t}else if((e=(l=h.n<0)?u:r.call(n,h))!==a)break}catch(e){o=t,s=1,u=e}finally{f=1}}return{value:e,done:l}}}(r,i,o),!0),f}var a={};function s(){}function u(){}function f(){}e=Object.getPrototypeOf;var c=[][n]?e(e([][n]())):(Ow(e={},n,function(){return this}),e),l=f.prototype=s.prototype=Object.create(c);function h(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,f):(t.__proto__=f,Ow(t,i,"GeneratorFunction")),t.prototype=Object.create(l),t}return u.prototype=f,Ow(l,"constructor",f),Ow(f,"constructor",u),u.displayName="GeneratorFunction",Ow(f,i,"GeneratorFunction"),Ow(l),Ow(l,i,"Generator"),Ow(l,n,function(){return this}),Ow(l,"toString",function(){return"[object Generator]"}),(kw=function(){return{w:o,m:h}})()}function Ow(t,e,r,n){var i=Object.defineProperty;try{i({},"",{})}catch(t){i=0}Ow=function(t,e,r,n){function o(e,r){Ow(t,e,function(t){return this._invoke(e,r,t)})}e?i?i(t,e,{value:r,enumerable:!n,configurable:!n,writable:!n}):t[e]=r:(o("next",0),o("throw",1),o("return",2))},Ow(t,e,r,n)}function Tw(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return Aw(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Aw(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}function Aw(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function Iw(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Pw(n.key),n)}}function Pw(t){var e=function(t){if("object"!=Ew(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Ew(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Ew(e)?e:e+""}var xw=function(){function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.compareFn=e,this.elements=[]}return function(t,e,r){return e&&Iw(t.prototype,e),r&&Iw(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"add",value:function(t){this.elements.includes(t)||(this.elements.push(t),this.elements.sort(this.compareFn))}},{key:"delete",value:function(t){var e=this.elements.indexOf(t);return-1!==e&&(this.elements.splice(e,1),!0)}},{key:"has",value:function(t){return this.elements.includes(t)}},{key:"clear",value:function(){this.elements=[]}},{key:"forEach",value:function(t){var e,r=Tw(this.elements);try{for(r.s();!(e=r.n()).done;)t(e.value,this)}catch(t){r.e(t)}finally{r.f()}}},{key:"size",get:function(){return this.elements.length}},{key:Symbol.iterator,value:kw().m(function(){var t,e,r,n;return kw().w(function(i){for(;;)switch(i.p=i.n){case 0:t=Tw(this.elements),i.p=1,t.s();case 2:if((e=t.n()).done){i.n=4;break}return r=e.value,i.n=3,r;case 3:i.n=2;break;case 4:i.n=6;break;case 5:i.p=5,n=i.v,t.e(n);case 6:return i.p=6,t.f(),i.f(6);case 7:return i.a(2)}},r,this,[[1,5,6,7]])})}],[{key:"fromSet",value:function(e,r){var n,i=new t(r),o=Tw(e);try{for(o.s();!(n=o.n()).done;){var a=n.value;i.add(a)}}catch(t){o.e(t)}finally{o.f()}return i}}])}();function Bw(t){return Bw="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Bw(t)}function Rw(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Nw(n.key),n)}}function Uw(t,e,r){return e&&Rw(t.prototype,e),r&&Rw(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function Nw(t){var e=function(t){if("object"!=Bw(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Bw(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Bw(e)?e:e+""}var jw=Uw(function t(e,r){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.type=e,this.data=r});function Lw(t){return Lw="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Lw(t)}function Cw(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Dw(n.key),n)}}function Fw(t,e,r){return e&&Cw(t.prototype,e),r&&Cw(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function Dw(t){var e=function(t){if("object"!=Lw(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Lw(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Lw(e)?e:e+""}var Hw,Mw,Kw,Vw,Ww=Fw(function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)});!function(t){t.testnet="testnet",t.mainnet="livenet",t.regtest="regtest"}(Hw||(Hw={})),function(t){t.BITCOIN_MAINNET="BITCOIN_MAINNET",t.BITCOIN_TESTNET="BITCOIN_TESTNET",t.BITCOIN_TESTNET4="BITCOIN_TESTNET4",t.BITCOIN_REGTEST="BITCOIN_REGTEST",t.BITCOIN_SIGNET="BITCOIN_SIGNET",t.FRACTAL_BITCOIN_MAINNET="FRACTAL_BITCOIN_MAINNET",t.FRACTAL_BITCOIN_TESTNET="FRACTAL_BITCOIN_TESTNET"}(Mw||(Mw={})),function(t){t.ecdsa="ecdsa",t.bip322="bip322-simple"}(Kw||(Kw={})),function(t){t.ecdsa="ecdsa",t.schnorr="schnorr"}(Vw||(Vw={}));var Gw=i(8287).Buffer;function qw(t){return qw="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},qw(t)}function zw(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return Zw(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Zw(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}function Zw(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function Xw(){var t,e,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",i=r.toStringTag||"@@toStringTag";function o(r,n,i,o){var u=n&&n.prototype instanceof s?n:s,f=Object.create(u.prototype);return Yw(f,"_invoke",function(r,n,i){var o,s,u,f=0,c=i||[],l=!1,h={p:0,n:0,v:t,a:p,f:p.bind(t,4),d:function(e,r){return o=e,s=0,u=t,h.n=r,a}};function p(r,n){for(s=r,u=n,e=0;!l&&f&&!i&&e<c.length;e++){var i,o=c[e],p=h.p,d=o[2];r>3?(i=d===n)&&(u=o[(s=o[4])?5:(s=3,3)],o[4]=o[5]=t):o[0]<=p&&((i=r<2&&p<o[1])?(s=0,h.v=n,h.n=o[1]):p<d&&(i=r<3||o[0]>n||n>d)&&(o[4]=r,o[5]=n,h.n=d,s=0))}if(i||r>1)return a;throw l=!0,n}return function(i,c,d){if(f>1)throw TypeError("Generator is already running");for(l&&1===c&&p(c,d),s=c,u=d;(e=s<2?t:u)||!l;){o||(s?s<3?(s>1&&(h.n=-1),p(s,u)):h.n=u:h.v=u);try{if(f=2,o){if(s||(i="next"),e=o[i]){if(!(e=e.call(o,u)))throw TypeError("iterator result is not an object");if(!e.done)return e;u=e.value,s<2&&(s=0)}else 1===s&&(e=o.return)&&e.call(o),s<2&&(u=TypeError("The iterator does not provide a '"+i+"' method"),s=1);o=t}else if((e=(l=h.n<0)?u:r.call(n,h))!==a)break}catch(e){o=t,s=1,u=e}finally{f=1}}return{value:e,done:l}}}(r,i,o),!0),f}var a={};function s(){}function u(){}function f(){}e=Object.getPrototypeOf;var c=[][n]?e(e([][n]())):(Yw(e={},n,function(){return this}),e),l=f.prototype=s.prototype=Object.create(c);function h(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,f):(t.__proto__=f,Yw(t,i,"GeneratorFunction")),t.prototype=Object.create(l),t}return u.prototype=f,Yw(l,"constructor",f),Yw(f,"constructor",u),u.displayName="GeneratorFunction",Yw(f,i,"GeneratorFunction"),Yw(l),Yw(l,i,"Generator"),Yw(l,n,function(){return this}),Yw(l,"toString",function(){return"[object Generator]"}),(Xw=function(){return{w:o,m:h}})()}function Yw(t,e,r,n){var i=Object.defineProperty;try{i({},"",{})}catch(t){i=0}Yw=function(t,e,r,n){function o(e,r){Yw(t,e,function(t){return this._invoke(e,r,t)})}e?i?i(t,e,{value:r,enumerable:!n,configurable:!n,writable:!n}):t[e]=r:(o("next",0),o("throw",1),o("return",2))},Yw(t,e,r,n)}function $w(t,e,r,n,i,o,a){try{var s=t[o](a),u=s.value}catch(t){return void r(t)}s.done?e(u):Promise.resolve(u).then(n,i)}function Jw(t){return function(){var e=this,r=arguments;return new Promise(function(n,i){var o=t.apply(e,r);function a(t){$w(o,n,i,a,s,"next",t)}function s(t){$w(o,n,i,a,s,"throw",t)}a(void 0)})}}function Qw(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,nm(n.key),n)}}function tm(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(tm=function(){return!!t})()}function em(t){return em=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},em(t)}function rm(t,e){return rm=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},rm(t,e)}function nm(t){var e=function(t){if("object"!=qw(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=qw(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==qw(e)?e:e+""}var im=function(){function t(){var e;if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),function(t,e,r){(e=nm(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r}(e=function(t,e,r){return e=em(e),function(t,e){if(e&&("object"==qw(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,tm()?Reflect.construct(e,r||[],em(t).constructor):e.apply(t,r))}(this,t),"isInitialized",!1),!window)throw new Error("UnisatSigner can only be used in a browser environment");return e}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&rm(t,e)}(t,Ww),function(t,e){return e&&Qw(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"p2tr",get:function(){if(!this._p2tr)throw new Error("P2TR address not set");return this._p2tr}},{key:"p2wpkh",get:function(){if(!this._p2wpkh)throw new Error("P2PKH address not set");return this._p2wpkh}},{key:"addresses",get:function(){if(!this._addresses)throw new Error("Addresses not set");return this._addresses}},{key:"publicKey",get:function(){if(!this._publicKey)throw new Error("Public key not set");return this._publicKey}},{key:"network",get:function(){if(!this._network)throw new Error("Network not set");return this._network}},{key:"unisat",get:function(){if(!window)throw new Error("Window not found");var t=window.unisat;if(!t)throw new Error("Unisat extension not found");return t}},{key:"signData",value:(a=Jw(Xw().m(function t(e,r){var n,i;return Xw().w(function(t){for(;;)switch(t.n){case 0:return n=e.toString("hex"),t.n=1,this.unisat.signData(n,r);case 1:return i=t.v,t.a(2,Gw.from(i,"hex"))}},t,this)})),function(t,e){return a.apply(this,arguments)})},{key:"init",value:(o=Jw(Xw().m(function t(){var e,r,n;return Xw().w(function(t){for(;;)switch(t.n){case 0:if(!this.isInitialized){t.n=1;break}return t.a(2);case 1:return t.n=2,this.unisat.getNetwork();case 2:e=t.v,n=e,t.n=n===Hw.mainnet?3:n===Hw.testnet?4:n===Hw.regtest?5:6;break;case 3:return this._network=b.bitcoin,t.a(3,7);case 4:return this._network=b.testnet,t.a(3,7);case 5:return this._network=b.regtest,t.a(3,7);case 6:throw new Error("Invalid network: ".concat(e));case 7:return t.n=8,this.unisat.getPublicKey();case 8:if(""!==(r=t.v)){t.n=9;break}throw new Error("Unlock your wallet first");case 9:this._publicKey=Gw.from(r,"hex"),this._p2wpkh=bc.getP2WPKHAddress(this,this.network),this._p2tr=bc.getTaprootAddress(this,this.network),this._addresses=[this._p2wpkh,this._p2tr],this.isInitialized=!0;case 10:return t.a(2)}},t,this)})),function(){return o.apply(this,arguments)})},{key:"getPublicKey",value:function(){if(!this.isInitialized)throw new Error("UnisatSigner not initialized");return this.publicKey}},{key:"sign",value:function(t,e){throw new Error("Not implemented: sign")}},{key:"signSchnorr",value:function(t){throw new Error("Not implemented: signSchnorr")}},{key:"verify",value:function(t,e){throw new Error("Not implemented: verify")}},{key:"signTaprootInput",value:(i=Jw(Xw().m(function t(e,r,n){var i,o;return Xw().w(function(t){for(;;)switch(t.n){case 0:if(!((i=e.data.inputs[r]).tapKeySig||i.finalScriptSig||Array.isArray(i.partialSig)&&i.partialSig.length&&this.hasAlreadyPartialSig(i.partialSig)||Array.isArray(i.tapScriptSig)&&i.tapScriptSig.length&&this.hasAlreadySignedTapScriptSig(i.tapScriptSig))){t.n=1;break}return t.a(2);case 1:return t.n=2,this.signAllTweaked(e,n,!1);case 2:o=t.v,this.combine(e,o,r);case 3:return t.a(2)}},t,this)})),function(t,e,r){return i.apply(this,arguments)})},{key:"signInput",value:(n=Jw(Xw().m(function t(e,r,n){var i,o;return Xw().w(function(t){for(;;)switch(t.n){case 0:if(!((i=e.data.inputs[r]).tapKeySig||i.finalScriptSig||Array.isArray(i.partialSig)&&i.partialSig.length&&this.hasAlreadyPartialSig(i.partialSig)||Array.isArray(i.tapScriptSig)&&i.tapScriptSig.length&&this.hasAlreadySignedTapScriptSig(i.tapScriptSig))){t.n=1;break}return t.a(2);case 1:return t.n=2,this.signAllTweaked(e,n,!0);case 2:o=t.v,this.combine(e,o,r);case 3:return t.a(2)}},t,this)})),function(t,e,r){return n.apply(this,arguments)})},{key:"multiSignPsbt",value:(r=Jw(Xw().m(function t(e){var r,n,i,o,a,s,u,f,c,l=this;return Xw().w(function(t){for(;;)switch(t.n){case 0:r=[],n=[],i=zw(e);try{for(i.s();!(o=i.n()).done;)a=o.value,s=a.toHex(),r.push(s),u=a.data.inputs.map(function(t,e){var r=!1,n=!1;if(Wd(t)){if(t.tapLeafScript&&t.tapLeafScript.length>0){var i,o=zw(t.tapLeafScript);try{for(o.s();!(i=o.n()).done;){var a=i.value;if(om(l.publicKey,a.script)){r=!0,n=!1;break}}}catch(t){o.e(t)}finally{o.f()}}if(!r&&t.tapInternalKey){var s=t.tapInternalKey,u=bi(l.publicKey);s.equals(u)&&(r=!0,n=!0)}}else Gd(t,l.publicKey)&&(r=!0,n=!1);return r?{index:e,publicKey:l.publicKey.toString("hex"),disableTweakSigner:!n}:null}).filter(function(t){return null!==t}),n.push({autoFinalized:!1,toSignInputs:u})}catch(t){i.e(t)}finally{i.f()}return t.n=1,this.unisat.signPsbt(r[0],n[0]);case 1:f=t.v,c=Ao.fromHex(f),e[0].combine(c);case 2:return t.a(2)}},t,this)})),function(t){return r.apply(this,arguments)})},{key:"hasAlreadySignedTapScriptSig",value:function(t){for(var e=0;e<t.length;e++){var r=t[e];if(Gw.from(r.pubkey).equals(this.publicKey)&&r.signature)return!0}return!1}},{key:"hasAlreadyPartialSig",value:function(t){for(var e=0;e<t.length;e++){var r=t[e];if(Gw.from(r.pubkey).equals(this.publicKey)&&r.signature)return!0}return!1}},{key:"combine",value:function(t,e,r){var n,i=e.data.inputs[r],o=t.data.inputs[r];if(i.partialSig&&t.updateInput(r,{partialSig:i.partialSig}),i.tapKeySig&&!o.tapKeySig&&t.updateInput(r,{tapKeySig:i.tapKeySig}),null!==(n=i.tapScriptSig)&&void 0!==n&&n.length){var a=o.tapScriptSig;if(a){var s=this.getNonDuplicateScriptSig(a,i.tapScriptSig);s.length&&t.updateInput(r,{tapScriptSig:s})}else t.updateInput(r,{tapScriptSig:i.tapScriptSig})}}},{key:"signAllTweaked",value:(e=Jw(Xw().m(function t(e,r){var n,i,o,a,s,u,f=arguments;return Xw().w(function(t){for(;;)switch(t.n){case 0:return n=f.length>2&&void 0!==f[2]&&f[2],i=this.publicKey.toString("hex"),o=e.data.inputs.map(function(t,e){return[{index:e,publicKey:i,sighashTypes:r,disableTweakSigner:n}]}),a={autoFinalized:!1,toSignInputs:o.flat()},s=e.toHex(),t.n=1,this.unisat.signPsbt(s,a);case 1:return u=t.v,t.a(2,Ao.fromHex(u))}},t,this)})),function(t,r){return e.apply(this,arguments)})},{key:"getNonDuplicateScriptSig",value:function(t,e){for(var r=[],n=function(n){t.find(function(t){return t.pubkey.equals(e[n].pubkey)})||r.push(e[n])},i=0;i<e.length;i++)n(i);return r}}]);var e,r,n,i,o,a}();function om(t,e){return-1!==function(t,e){var r=S.hash160(t),n=bi(t),i=w.decompile(e);if(null===i)throw new Error("Unknown script error");return i.findIndex(function(e){return"number"!=typeof e&&Gw.isBuffer(e)&&(e.equals(t)||e.equals(r)||e.equals(n))})}(t,e)}var am=i(8287).Buffer;function sm(t){return sm="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},sm(t)}function um(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return fm(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?fm(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}function fm(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function cm(){var t,e,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",i=r.toStringTag||"@@toStringTag";function o(r,n,i,o){var u=n&&n.prototype instanceof s?n:s,f=Object.create(u.prototype);return lm(f,"_invoke",function(r,n,i){var o,s,u,f=0,c=i||[],l=!1,h={p:0,n:0,v:t,a:p,f:p.bind(t,4),d:function(e,r){return o=e,s=0,u=t,h.n=r,a}};function p(r,n){for(s=r,u=n,e=0;!l&&f&&!i&&e<c.length;e++){var i,o=c[e],p=h.p,d=o[2];r>3?(i=d===n)&&(u=o[(s=o[4])?5:(s=3,3)],o[4]=o[5]=t):o[0]<=p&&((i=r<2&&p<o[1])?(s=0,h.v=n,h.n=o[1]):p<d&&(i=r<3||o[0]>n||n>d)&&(o[4]=r,o[5]=n,h.n=d,s=0))}if(i||r>1)return a;throw l=!0,n}return function(i,c,d){if(f>1)throw TypeError("Generator is already running");for(l&&1===c&&p(c,d),s=c,u=d;(e=s<2?t:u)||!l;){o||(s?s<3?(s>1&&(h.n=-1),p(s,u)):h.n=u:h.v=u);try{if(f=2,o){if(s||(i="next"),e=o[i]){if(!(e=e.call(o,u)))throw TypeError("iterator result is not an object");if(!e.done)return e;u=e.value,s<2&&(s=0)}else 1===s&&(e=o.return)&&e.call(o),s<2&&(u=TypeError("The iterator does not provide a '"+i+"' method"),s=1);o=t}else if((e=(l=h.n<0)?u:r.call(n,h))!==a)break}catch(e){o=t,s=1,u=e}finally{f=1}}return{value:e,done:l}}}(r,i,o),!0),f}var a={};function s(){}function u(){}function f(){}e=Object.getPrototypeOf;var c=[][n]?e(e([][n]())):(lm(e={},n,function(){return this}),e),l=f.prototype=s.prototype=Object.create(c);function h(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,f):(t.__proto__=f,lm(t,i,"GeneratorFunction")),t.prototype=Object.create(l),t}return u.prototype=f,lm(l,"constructor",f),lm(f,"constructor",u),u.displayName="GeneratorFunction",lm(f,i,"GeneratorFunction"),lm(l),lm(l,i,"Generator"),lm(l,n,function(){return this}),lm(l,"toString",function(){return"[object Generator]"}),(cm=function(){return{w:o,m:h}})()}function lm(t,e,r,n){var i=Object.defineProperty;try{i({},"",{})}catch(t){i=0}lm=function(t,e,r,n){function o(e,r){lm(t,e,function(t){return this._invoke(e,r,t)})}e?i?i(t,e,{value:r,enumerable:!n,configurable:!n,writable:!n}):t[e]=r:(o("next",0),o("throw",1),o("return",2))},lm(t,e,r,n)}function hm(t,e,r,n,i,o,a){try{var s=t[o](a),u=s.value}catch(t){return void r(t)}s.done?e(u):Promise.resolve(u).then(n,i)}function pm(t){return function(){var e=this,r=arguments;return new Promise(function(n,i){var o=t.apply(e,r);function a(t){hm(o,n,i,a,s,"next",t)}function s(t){hm(o,n,i,a,s,"throw",t)}a(void 0)})}}function dm(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,wm(n.key),n)}}function ym(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(ym=function(){return!!t})()}function bm(t){return bm=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},bm(t)}function gm(t,e){return gm=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},gm(t,e)}function vm(t,e,r){return(e=wm(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function wm(t){var e=function(t){if("object"!=sm(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=sm(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==sm(e)?e:e+""}var mm,Sm,_m=function(){function t(){var e;if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),vm(e=function(t,e,r){return e=bm(e),function(t,e){if(e&&("object"==sm(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,ym()?Reflect.construct(e,r||[],bm(t).constructor):e.apply(t,r))}(this,t),"isInitialized",!1),!window)throw new Error("XverseSigner can only be used in a browser environment");return e}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&gm(t,e)}(t,Ww),function(t,e){return e&&dm(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"p2tr",get:function(){if(!this._p2tr)throw new Error("P2TR address not set");return this._p2tr}},{key:"p2wpkh",get:function(){if(!this._p2wpkh)throw new Error("P2PKH address not set");return this._p2wpkh}},{key:"addresses",get:function(){if(!this._addresses)throw new Error("Addresses not set");return this._addresses}},{key:"publicKey",get:function(){if(!this._publicKey)throw new Error("Public key not set");return this._publicKey}},{key:"network",get:function(){if(!this._network)throw new Error("Network not set");return this._network}},{key:"BitcoinProvider",get:function(){var t=window.BitcoinProvider;if(!t)throw new Error("Xverse Wallet extension not found");return t}},{key:"init",value:(a=pm(cm().m(function t(){var e,r,n;return cm().w(function(t){for(;;)switch(t.n){case 0:if(!this.isInitialized){t.n=1;break}return t.a(2);case 1:return t.n=2,this.BitcoinProvider.request("wallet_connect",null);case 2:if(!("error"in(e=t.v))){t.n=3;break}throw new Error(e.error.message);case 3:if(r=e.result.addresses.find(function(t){return"payment"===t.purpose})){t.n=4;break}throw new Error("Payment address not found");case 4:if(n=r.address.startsWith("tb")?b.testnet:r.address.startsWith("bc")?b.bitcoin:null){t.n=5;break}throw new Error("Network not supported");case 5:this._network=n,this._publicKey=am.from(r.publicKey,"hex"),this._p2wpkh=bc.getP2WPKHAddress(this,this.network),this._p2tr=bc.getTaprootAddress(this,this.network),this._addresses=[this._p2wpkh,this._p2tr],this.isInitialized=!0;case 6:return t.a(2)}},t,this)})),function(){return a.apply(this,arguments)})},{key:"signData",value:(o=pm(cm().m(function t(e,r,n){var i,o;return cm().w(function(t){for(;;)switch(t.n){case 0:if(this.isInitialized){t.n=1;break}throw new Error("UnisatSigner not initialized");case 1:return t.n=2,this.BitcoinProvider.request("signMessage",{address:r,message:e.toString(),protocol:n});case 2:if(!("error"in(i=t.v))){t.n=3;break}throw new Error(i.error.message);case 3:if((o=i.result).signature){t.n=4;break}throw new Error("Signature not found");case 4:return t.a(2,am.from(o.signature,"hex"))}},t,this)})),function(t,e,r){return o.apply(this,arguments)})},{key:"getPublicKey",value:function(){if(!this.isInitialized)throw new Error("UnisatSigner not initialized");return this.publicKey}},{key:"sign",value:function(t,e){throw new Error("Not implemented: sign")}},{key:"signSchnorr",value:function(t){throw new Error("Not implemented: signSchnorr")}},{key:"verify",value:function(t,e){throw new Error("Not implemented: verify")}},{key:"signTaprootInput",value:(i=pm(cm().m(function t(e,r,n){var i,o;return cm().w(function(t){for(;;)switch(t.n){case 0:if(!((i=e.data.inputs[r]).tapKeySig||i.finalScriptSig||Array.isArray(i.partialSig)&&i.partialSig.length&&this.hasAlreadyPartialSig(i.partialSig)||Array.isArray(i.tapScriptSig)&&i.tapScriptSig.length&&this.hasAlreadySignedTapScriptSig(i.tapScriptSig))){t.n=1;break}return t.a(2);case 1:return t.n=2,this.signAllTweaked(e,n,!1);case 2:o=t.v,this.combine(e,o,r);case 3:return t.a(2)}},t,this)})),function(t,e,r){return i.apply(this,arguments)})},{key:"signInput",value:(n=pm(cm().m(function t(e,r,n){var i,o;return cm().w(function(t){for(;;)switch(t.n){case 0:if(!((i=e.data.inputs[r]).tapKeySig||i.finalScriptSig||Array.isArray(i.partialSig)&&i.partialSig.length&&this.hasAlreadyPartialSig(i.partialSig)||Array.isArray(i.tapScriptSig)&&i.tapScriptSig.length&&this.hasAlreadySignedTapScriptSig(i.tapScriptSig))){t.n=1;break}return t.a(2);case 1:return t.n=2,this.signAllTweaked(e,n,!0);case 2:o=t.v,this.combine(e,o,r);case 3:return t.a(2)}},t,this)})),function(t,e,r){return n.apply(this,arguments)})},{key:"multiSignPsbt",value:(r=pm(cm().m(function t(e){var r,n,i,o,a,s,u,f,c,l,h,p=this;return cm().w(function(t){for(;;)switch(t.n){case 0:n=[],i=[],o=um(e);try{for(o.s();!(a=o.n()).done;)s=a.value,u=s.toBase64(),n.push(u),f=s.data.inputs.map(function(t,e){var r=!1,n=!1;if(Wd(t)){if(t.tapLeafScript&&t.tapLeafScript.length>0){var i,o=um(t.tapLeafScript);try{for(o.s();!(i=o.n()).done;){var a=i.value;if(qd(p.publicKey,a.script)){r=!0,n=!1;break}}}catch(t){o.e(t)}finally{o.f()}}if(!r&&t.tapInternalKey){var s=t.tapInternalKey,u=bi(p.publicKey);s.equals(u)&&(r=!0,n=!0)}}else Gd(t,p.publicKey)&&(r=!0,n=!1);return r?{index:e,publicKey:p.publicKey.toString("hex"),disableTweakSigner:!n}:null}).filter(function(t){return null!==t}),i.push({autoFinalized:!1,toSignInputs:f})}catch(t){o.e(t)}finally{o.f()}return c=vm({},this.p2wpkh,(null===(r=i[0].toSignInputs)||void 0===r?void 0:r.map(function(t){return t.index}))||[]),t.n=1,this.BitcoinProvider.request("signPsbt",{psbt:n[0],signInputs:c});case 1:if(!("error"in(l=t.v))){t.n=2;break}throw new Error(l.error.message);case 2:h=Ao.fromBase64(l.result.psbt),e[0].combine(h);case 3:return t.a(2)}},t,this)})),function(t){return r.apply(this,arguments)})},{key:"hasAlreadySignedTapScriptSig",value:function(t){for(var e=0;e<t.length;e++){var r=t[e];if(am.from(r.pubkey).equals(this.publicKey)&&r.signature)return!0}return!1}},{key:"hasAlreadyPartialSig",value:function(t){for(var e=0;e<t.length;e++){var r=t[e];if(am.from(r.pubkey).equals(this.publicKey)&&r.signature)return!0}return!1}},{key:"combine",value:function(t,e,r){var n,i=e.data.inputs[r],o=t.data.inputs[r];if(i.partialSig&&t.updateInput(r,{partialSig:i.partialSig}),i.tapKeySig&&!o.tapKeySig&&t.updateInput(r,{tapKeySig:i.tapKeySig}),null!==(n=i.tapScriptSig)&&void 0!==n&&n.length){var a=o.tapScriptSig;if(a){var s=this.getNonDuplicateScriptSig(a,i.tapScriptSig);s.length&&t.updateInput(r,{tapScriptSig:s})}else t.updateInput(r,{tapScriptSig:i.tapScriptSig})}}},{key:"signAllTweaked",value:(e=pm(cm().m(function t(e,r){var n,i,o,a,s,u,f,c,l=arguments;return cm().w(function(t){for(;;)switch(t.n){case 0:return i=l.length>2&&void 0!==l[2]&&l[2],o=this.publicKey.toString("hex"),a=e.data.inputs.map(function(t,e){return[{index:e,publicKey:o,sighashTypes:r,disableTweakSigner:i}]}),s={autoFinalized:!1,toSignInputs:a.flat()},u=e.toBase64(),f=vm({},this.p2wpkh,(null===(n=s.toSignInputs)||void 0===n?void 0:n.map(function(t){return t.index}))||[]),t.n=1,this.BitcoinProvider.request("signPsbt",{psbt:u,signInputs:f});case 1:if(!("error"in(c=t.v))){t.n=2;break}throw new Error(c.error.message);case 2:return t.a(2,Ao.fromBase64(c.result.psbt))}},t,this)})),function(t,r){return e.apply(this,arguments)})},{key:"getNonDuplicateScriptSig",value:function(t,e){for(var r=[],n=function(n){t.find(function(t){return t.pubkey.equals(e[n].pubkey)})||r.push(e[n])},i=0;i<e.length;i++)n(i);return r}}]);var e,r,n,i,o,a}();function Em(t){return Em="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Em(t)}function km(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Tm(n.key),n)}}function Om(t,e,r){return(e=Tm(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Tm(t){var e=function(t){if("object"!=Em(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Em(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Em(e)?e:e+""}function Am(){return ih.dead()}!function(t){t.mainnet="mainnet",t.testnet="testnet",t.signet="Signet"}(mm||(mm={})),function(t){t.ECDSA="ECDSA",t.BIP322="BIP322"}(Sm||(Sm={}));var Im,Pm=Am(),xm=Am(),Bm=Am(),Rm=Am(),Um=Am(),Nm=Am(),jm=Am(),Lm=Am(),Cm=Am(),Fm=Am(),Dm=Am(),Hm=Am(),Mm=Am(),Km=Am(),Vm=Am();!function(t){t.Mainnet="mainnet",t.Testnet="testnet",t.Regtest="regtest"}(Im||(Im={}));var Wm=function(){return function(t,e){return e&&km(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}(function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),Om(this,"metadata",Om(Om({},Zy.Bitcoin,Om(Om({},Im.Testnet,{factory:Nm,pool:jm,wbtc:Lm,moto:Cm,router:Fm}),Im.Regtest,{factory:Pm,pool:xm,wbtc:Bm,moto:Rm,router:Um})),Zy.Fractal,Om({},Im.Mainnet,{factory:Dm,pool:Hm,wbtc:Mm,moto:Km,router:Vm})))},[{key:"getFactoryAddress",value:function(t,e){var r,n=null===(r=this.metadata[e][t])||void 0===r?void 0:r.factory;if(!n)throw new Error("Factory address not found for network ".concat(t," and chainId ").concat(e));return n}},{key:"getPoolAddress",value:function(t,e){var r,n=null===(r=this.metadata[e][t])||void 0===r?void 0:r.pool;if(!n)throw new Error("Pool address not found for network ".concat(t," and chainId ").concat(e));return n}},{key:"getWBTCAddress",value:function(t,e){var r,n=null===(r=this.metadata[e][t])||void 0===r?void 0:r.wbtc;if(!n)throw new Error("WBTC address not found for network ".concat(t," and chainId ").concat(e));return n}},{key:"getMOTOAddress",value:function(t,e){var r,n=null===(r=this.metadata[e][t])||void 0===r?void 0:r.moto;if(!n)throw new Error("MOTO address not found for network ".concat(t," and chainId ").concat(e));return n}},{key:"getRouterAddress",value:function(t,e){var r,n=null===(r=this.metadata[e][t])||void 0===r?void 0:r.router;if(!n)throw new Error("Router address not found for network ".concat(t," and chainId ").concat(e));return n}},{key:"getAddresses",value:function(t,e){var r=this.metadata[e][t];if(!r)throw new Error("Metadata not found for network ".concat(t," and chainId ").concat(e));return r}}])}(),Gm=new Wm;export{rw as ABICoder,Xv as ABIDataTypes,gc as ADDRESS_BYTE_LENGTH,Ay as ANCHOR_SCRIPT,ih as Address,xp as AddressGenerator,Jc as AddressMap,uw as AddressSet,hl as AddressTypes,vl as AddressVerificator,Bc as BOOLEAN_BYTE_LENGTH,uh as BinaryReader,ph as BinaryWriter,sl as BitcoinUtils,Lc as BufferHelper,Kd as CSVModes,Uh as CalldataGenerator,Zy as ChainId,dv as ChallengeSolution,pv as ChallengeSubmission,hv as ChallengeVerification,h as Compressor,Yy as Consensus,xl as ContractAddress,$y as ContractBaseMetadata,Hh as CustomGenerator,Ww as CustomKeypair,wb as CustomScriptTransaction,Jh as DeploymentGenerator,Xb as DeploymentTransaction,_w as DeterministicMap,xw as DeterministicSet,bc as EcKeyPair,wv as EpochValidator,Dm as FACTORY_ADDRESS_FRACTAL,Pm as FACTORY_ADDRESS_REGTEST,Nm as FACTORY_ADDRESS_TESTNET,hh as Features,ag as FundingTransaction,_h as Generator,Tc as I128_BYTE_LENGTH,Pc as I16_BYTE_LENGTH,Oc as I256_BYTE_LENGTH,Ic as I32_BYTE_LENGTH,Ac as I64_BYTE_LENGTH,xc as I8_BYTE_LENGTH,yg as InteractionTransaction,Ag as InteractionTransactionP2WDA,fp as LegacyCalldataGenerator,Ty as MINIMUM_AMOUNT_CA,Oy as MINIMUM_AMOUNT_REWARD,Km as MOTO_ADDRESS_FRACTAL,Rm as MOTO_ADDRESS_REGTEST,Cm as MOTO_ADDRESS_TESTNET,Dy as MessageSigner,Kw as MessageType,yp as MultiSignGenerator,iv as MultiSignTransaction,jw as NetEvent,Yh as OPNET_DEPLOYMENT_VERSION,tb as OPNetConsensusConfig,Nv as OPNetLimitedProvider,Gm as OPNetMetadata,Im as OPNetNetwork,Wm as OPNetTokenAddressManager,Yv as P2TR_MS,pl as P2WDADetector,Op as P2WDAGenerator,Hm as POOL_ADDRESS_FRACTAL,xm as POOL_ADDRESS_REGTEST,jm as POOL_ADDRESS_TESTNET,Wv as PSBTTypes,Gv as PsbtTransaction,Vm as ROUTER_ADDRESS_FRACTAL,Um as ROUTER_ADDRESS_REGTEST,Fm as ROUTER_ADDRESS_TESTNET,Jy as RoswellConsensus,vc as SELECTOR_BYTE_LENGTH,kl as Secp256k1PointDeriver,Nb as SharedInteractionTransaction,Vw as SignatureType,Sm as SigningProtocol,Uy as TapscriptVerificator,Nl as TimeLockGenerator,Iy as TransactionBuilder,Mg as TransactionFactory,Md as TransactionSequence,Xy as TransactionType,Vd as TweakedSigner,uy as TweakedTransaction,mc as U128_BYTE_LENGTH,Ec as U16_BYTE_LENGTH,wc as U256_BYTE_LENGTH,_c as U32_BYTE_LENGTH,Sc as U64_BYTE_LENGTH,kc as U8_BYTE_LENGTH,Mw as UnisatChainType,Hw as UnisatNetwork,im as UnisatSigner,Mm as WBTC_ADDRESS_FRACTAL,Bm as WBTC_ADDRESS_REGTEST,Lm as WBTC_ADDRESS_TESTNET,Wy as Wallet,mm as XverseNetwork,_m as XverseSigner,eb as currentConsensus,rb as currentConsensusConfig,o as opnet,a as version,$h as versionBuffer};
2
+ var t,e,r={41:(t,e,r)=>{var n=r(655),i=r(8068),o=r(9675),a=r(5795);t.exports=function(t,e,r){if(!t||"object"!=typeof t&&"function"!=typeof t)throw new o("`obj` must be an object or a function`");if("string"!=typeof e&&"symbol"!=typeof e)throw new o("`property` must be a string or a symbol`");if(arguments.length>3&&"boolean"!=typeof arguments[3]&&null!==arguments[3])throw new o("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&"boolean"!=typeof arguments[4]&&null!==arguments[4])throw new o("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&"boolean"!=typeof arguments[5]&&null!==arguments[5])throw new o("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&"boolean"!=typeof arguments[6])throw new o("`loose`, if provided, must be a boolean");var s=arguments.length>3?arguments[3]:null,u=arguments.length>4?arguments[4]:null,c=arguments.length>5?arguments[5]:null,f=arguments.length>6&&arguments[6],l=!!a&&a(t,e);if(n)n(t,e,{configurable:null===c&&l?l.configurable:!c,enumerable:null===s&&l?l.enumerable:!s,value:r,writable:null===u&&l?l.writable:!u});else{if(!f&&(s||u||c))throw new i("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.");t[e]=r}}},76:t=>{t.exports=Function.prototype.call},251:(t,e)=>{e.read=function(t,e,r,n,i){var o,a,s=8*i-n-1,u=(1<<s)-1,c=u>>1,f=-7,l=r?i-1:0,h=r?-1:1,p=t[e+l];for(l+=h,o=p&(1<<-f)-1,p>>=-f,f+=s;f>0;o=256*o+t[e+l],l+=h,f-=8);for(a=o&(1<<-f)-1,o>>=-f,f+=n;f>0;a=256*a+t[e+l],l+=h,f-=8);if(0===o)o=1-c;else{if(o===u)return a?NaN:1/0*(p?-1:1);a+=Math.pow(2,n),o-=c}return(p?-1:1)*a*Math.pow(2,o-n)},e.write=function(t,e,r,n,i,o){var a,s,u,c=8*o-i-1,f=(1<<c)-1,l=f>>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:o-1,d=n?1:-1,y=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,a=f):(a=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-a))<1&&(a--,u*=2),(e+=a+l>=1?h/u:h*Math.pow(2,1-l))*u>=2&&(a++,u/=2),a+l>=f?(s=0,a=f):a+l>=1?(s=(e*u-1)*Math.pow(2,i),a+=l):(s=e*Math.pow(2,l-1)*Math.pow(2,i),a=0));i>=8;t[r+p]=255&s,p+=d,s/=256,i-=8);for(a=a<<i|s,c+=i;c>0;t[r+p]=255&a,p+=d,a/=256,c-=8);t[r+p-d]|=128*y}},320:(t,e,r)=>{var n=r(320);t.exports=function(t){return(new n).update(t).digest()}},392:(t,e,r)=>{var n=r(2861).Buffer,i=r(5377);function o(t,e){this._block=n.alloc(t),this._finalSize=e,this._blockSize=t,this._len=0}o.prototype.update=function(t,e){t=i(t,e||"utf8");for(var r=this._block,n=this._blockSize,o=t.length,a=this._len,s=0;s<o;){for(var u=a%n,c=Math.min(o-s,n-u),f=0;f<c;f++)r[u+f]=t[s+f];s+=c,(a+=c)%n===0&&this._update(r)}return this._len+=o,this},o.prototype.digest=function(t){var e=this._len%this._blockSize;this._block[e]=128,this._block.fill(0,e+1),e>=this._finalSize&&(this._update(this._block),this._block.fill(0));var r=8*this._len;if(r<=4294967295)this._block.writeUInt32BE(r,this._blockSize-4);else{var n=(4294967295&r)>>>0,i=(r-n)/4294967296;this._block.writeUInt32BE(i,this._blockSize-8),this._block.writeUInt32BE(n,this._blockSize-4)}this._update(this._block);var o=this._hash();return t?o.toString(t):o},o.prototype._update=function(){throw new Error("_update must be implemented by subclass")},t.exports=o},414:t=>{t.exports=Math.round},453:(t,e,r)=>{var n,i=r(9612),o=r(9383),a=r(1237),s=r(9290),u=r(9538),c=r(8068),f=r(9675),l=r(5345),h=r(1514),p=r(8968),d=r(6188),y=r(8002),b=r(5880),g=r(414),v=r(3093),w=Function,m=function(t){try{return w('"use strict"; return ('+t+").constructor;")()}catch(t){}},S=r(5795),_=r(655),E=function(){throw new f},k=S?function(){try{return E}catch(t){try{return S(arguments,"callee").get}catch(t){return E}}}():E,O=r(4039)(),T=r(3628),A=r(1064),I=r(8648),P=r(1002),x=r(76),B={},R="undefined"!=typeof Uint8Array&&T?T(Uint8Array):n,U={__proto__:null,"%AggregateError%":"undefined"==typeof AggregateError?n:AggregateError,"%Array%":Array,"%ArrayBuffer%":"undefined"==typeof ArrayBuffer?n:ArrayBuffer,"%ArrayIteratorPrototype%":O&&T?T([][Symbol.iterator]()):n,"%AsyncFromSyncIteratorPrototype%":n,"%AsyncFunction%":B,"%AsyncGenerator%":B,"%AsyncGeneratorFunction%":B,"%AsyncIteratorPrototype%":B,"%Atomics%":"undefined"==typeof Atomics?n:Atomics,"%BigInt%":"undefined"==typeof BigInt?n:BigInt,"%BigInt64Array%":"undefined"==typeof BigInt64Array?n:BigInt64Array,"%BigUint64Array%":"undefined"==typeof BigUint64Array?n:BigUint64Array,"%Boolean%":Boolean,"%DataView%":"undefined"==typeof DataView?n:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":o,"%eval%":eval,"%EvalError%":a,"%Float16Array%":"undefined"==typeof Float16Array?n:Float16Array,"%Float32Array%":"undefined"==typeof Float32Array?n:Float32Array,"%Float64Array%":"undefined"==typeof Float64Array?n:Float64Array,"%FinalizationRegistry%":"undefined"==typeof FinalizationRegistry?n:FinalizationRegistry,"%Function%":w,"%GeneratorFunction%":B,"%Int8Array%":"undefined"==typeof Int8Array?n:Int8Array,"%Int16Array%":"undefined"==typeof Int16Array?n:Int16Array,"%Int32Array%":"undefined"==typeof Int32Array?n:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":O&&T?T(T([][Symbol.iterator]())):n,"%JSON%":"object"==typeof JSON?JSON:n,"%Map%":"undefined"==typeof Map?n:Map,"%MapIteratorPrototype%":"undefined"!=typeof Map&&O&&T?T((new Map)[Symbol.iterator]()):n,"%Math%":Math,"%Number%":Number,"%Object%":i,"%Object.getOwnPropertyDescriptor%":S,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":"undefined"==typeof Promise?n:Promise,"%Proxy%":"undefined"==typeof Proxy?n:Proxy,"%RangeError%":s,"%ReferenceError%":u,"%Reflect%":"undefined"==typeof Reflect?n:Reflect,"%RegExp%":RegExp,"%Set%":"undefined"==typeof Set?n:Set,"%SetIteratorPrototype%":"undefined"!=typeof Set&&O&&T?T((new Set)[Symbol.iterator]()):n,"%SharedArrayBuffer%":"undefined"==typeof SharedArrayBuffer?n:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":O&&T?T(""[Symbol.iterator]()):n,"%Symbol%":O?Symbol:n,"%SyntaxError%":c,"%ThrowTypeError%":k,"%TypedArray%":R,"%TypeError%":f,"%Uint8Array%":"undefined"==typeof Uint8Array?n:Uint8Array,"%Uint8ClampedArray%":"undefined"==typeof Uint8ClampedArray?n:Uint8ClampedArray,"%Uint16Array%":"undefined"==typeof Uint16Array?n:Uint16Array,"%Uint32Array%":"undefined"==typeof Uint32Array?n:Uint32Array,"%URIError%":l,"%WeakMap%":"undefined"==typeof WeakMap?n:WeakMap,"%WeakRef%":"undefined"==typeof WeakRef?n:WeakRef,"%WeakSet%":"undefined"==typeof WeakSet?n:WeakSet,"%Function.prototype.call%":x,"%Function.prototype.apply%":P,"%Object.defineProperty%":_,"%Object.getPrototypeOf%":A,"%Math.abs%":h,"%Math.floor%":p,"%Math.max%":d,"%Math.min%":y,"%Math.pow%":b,"%Math.round%":g,"%Math.sign%":v,"%Reflect.getPrototypeOf%":I};if(T)try{null.error}catch(t){var j=T(T(t));U["%Error.prototype%"]=j}var N=function t(e){var r;if("%AsyncFunction%"===e)r=m("async function () {}");else if("%GeneratorFunction%"===e)r=m("function* () {}");else if("%AsyncGeneratorFunction%"===e)r=m("async function* () {}");else if("%AsyncGenerator%"===e){var n=t("%AsyncGeneratorFunction%");n&&(r=n.prototype)}else if("%AsyncIteratorPrototype%"===e){var i=t("%AsyncGenerator%");i&&T&&(r=T(i.prototype))}return U[e]=r,r},L={__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"]},C=r(6743),F=r(9957),D=C.call(x,Array.prototype.concat),H=C.call(P,Array.prototype.splice),M=C.call(x,String.prototype.replace),K=C.call(x,String.prototype.slice),V=C.call(x,RegExp.prototype.exec),W=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,G=/\\(\\)?/g,q=function(t,e){var r,n=t;if(F(L,n)&&(n="%"+(r=L[n])[0]+"%"),F(U,n)){var i=U[n];if(i===B&&(i=N(n)),void 0===i&&!e)throw new f("intrinsic "+t+" exists, but is not available. Please file an issue!");return{alias:r,name:n,value:i}}throw new c("intrinsic "+t+" does not exist!")};t.exports=function(t,e){if("string"!=typeof t||0===t.length)throw new f("intrinsic name must be a non-empty string");if(arguments.length>1&&"boolean"!=typeof e)throw new f('"allowMissing" argument must be a boolean');if(null===V(/^%?[^%]*%?$/,t))throw new c("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var r=function(t){var e=K(t,0,1),r=K(t,-1);if("%"===e&&"%"!==r)throw new c("invalid intrinsic syntax, expected closing `%`");if("%"===r&&"%"!==e)throw new c("invalid intrinsic syntax, expected opening `%`");var n=[];return M(t,W,function(t,e,r,i){n[n.length]=r?M(i,G,"$1"):e||t}),n}(t),n=r.length>0?r[0]:"",i=q("%"+n+"%",e),o=i.name,a=i.value,s=!1,u=i.alias;u&&(n=u[0],H(r,D([0,1],u)));for(var l=1,h=!0;l<r.length;l+=1){var p=r[l],d=K(p,0,1),y=K(p,-1);if(('"'===d||"'"===d||"`"===d||'"'===y||"'"===y||"`"===y)&&d!==y)throw new c("property names with quotes must have matching quotes");if("constructor"!==p&&h||(s=!0),F(U,o="%"+(n+="."+p)+"%"))a=U[o];else if(null!=a){if(!(p in a)){if(!e)throw new f("base intrinsic for "+t+" exists, but the property is not available.");return}if(S&&l+1>=r.length){var b=S(a,p);a=(h=!!b)&&"get"in b&&!("originalValue"in b.get)?b.get:a[p]}else h=F(a,p),a=a[p];h&&!s&&(U[o]=a)}}return a}},487:(t,e,r)=>{var n=r(6897),i=r(655),o=r(3126),a=r(2205);t.exports=function(t){var e=o(arguments),r=t.length-(arguments.length-1);return n(e,1+(r>0?r:0),!0)},i?i(t.exports,"apply",{value:a}):t.exports.apply=a},537:(t,e,r)=>{var n=r(5606),i=Object.getOwnPropertyDescriptors||function(t){for(var e=Object.keys(t),r={},n=0;n<e.length;n++)r[e[n]]=Object.getOwnPropertyDescriptor(t,e[n]);return r},o=/%[sdj%]/g;e.format=function(t){if(!w(t)){for(var e=[],r=0;r<arguments.length;r++)e.push(c(arguments[r]));return e.join(" ")}r=1;for(var n=arguments,i=n.length,a=String(t).replace(o,function(t){if("%%"===t)return"%";if(r>=i)return t;switch(t){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(t){return"[Circular]"}default:return t}}),s=n[r];r<i;s=n[++r])g(s)||!_(s)?a+=" "+s:a+=" "+c(s);return a},e.deprecate=function(t,r){if(void 0!==n&&!0===n.noDeprecation)return t;if(void 0===n)return function(){return e.deprecate(t,r).apply(this,arguments)};var i=!1;return function(){if(!i){if(n.throwDeprecation)throw new Error(r);n.traceDeprecation?console.trace(r):console.error(r),i=!0}return t.apply(this,arguments)}};var a={},s=/^$/;if(n.env.NODE_DEBUG){var u=n.env.NODE_DEBUG;u=u.replace(/[|\\{}()[\]^$+?.]/g,"\\$&").replace(/\*/g,".*").replace(/,/g,"$|^").toUpperCase(),s=new RegExp("^"+u+"$","i")}function c(t,r){var n={seen:[],stylize:l};return arguments.length>=3&&(n.depth=arguments[2]),arguments.length>=4&&(n.colors=arguments[3]),b(r)?n.showHidden=r:r&&e._extend(n,r),m(n.showHidden)&&(n.showHidden=!1),m(n.depth)&&(n.depth=2),m(n.colors)&&(n.colors=!1),m(n.customInspect)&&(n.customInspect=!0),n.colors&&(n.stylize=f),h(n,t,n.depth)}function f(t,e){var r=c.styles[e];return r?"["+c.colors[r][0]+"m"+t+"["+c.colors[r][1]+"m":t}function l(t,e){return t}function h(t,r,n){if(t.customInspect&&r&&O(r.inspect)&&r.inspect!==e.inspect&&(!r.constructor||r.constructor.prototype!==r)){var i=r.inspect(n,t);return w(i)||(i=h(t,i,n)),i}var o=function(t,e){if(m(e))return t.stylize("undefined","undefined");if(w(e)){var r="'"+JSON.stringify(e).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return t.stylize(r,"string")}return v(e)?t.stylize(""+e,"number"):b(e)?t.stylize(""+e,"boolean"):g(e)?t.stylize("null","null"):void 0}(t,r);if(o)return o;var a=Object.keys(r),s=function(t){var e={};return t.forEach(function(t,r){e[t]=!0}),e}(a);if(t.showHidden&&(a=Object.getOwnPropertyNames(r)),k(r)&&(a.indexOf("message")>=0||a.indexOf("description")>=0))return p(r);if(0===a.length){if(O(r)){var u=r.name?": "+r.name:"";return t.stylize("[Function"+u+"]","special")}if(S(r))return t.stylize(RegExp.prototype.toString.call(r),"regexp");if(E(r))return t.stylize(Date.prototype.toString.call(r),"date");if(k(r))return p(r)}var c,f="",l=!1,_=["{","}"];return y(r)&&(l=!0,_=["[","]"]),O(r)&&(f=" [Function"+(r.name?": "+r.name:"")+"]"),S(r)&&(f=" "+RegExp.prototype.toString.call(r)),E(r)&&(f=" "+Date.prototype.toUTCString.call(r)),k(r)&&(f=" "+p(r)),0!==a.length||l&&0!=r.length?n<0?S(r)?t.stylize(RegExp.prototype.toString.call(r),"regexp"):t.stylize("[Object]","special"):(t.seen.push(r),c=l?function(t,e,r,n,i){for(var o=[],a=0,s=e.length;a<s;++a)P(e,String(a))?o.push(d(t,e,r,n,String(a),!0)):o.push("");return i.forEach(function(i){i.match(/^\d+$/)||o.push(d(t,e,r,n,i,!0))}),o}(t,r,n,s,a):a.map(function(e){return d(t,r,n,s,e,l)}),t.seen.pop(),function(t,e,r){return t.reduce(function(t,e){return e.indexOf("\n"),t+e.replace(/\u001b\[\d\d?m/g,"").length+1},0)>60?r[0]+(""===e?"":e+"\n ")+" "+t.join(",\n ")+" "+r[1]:r[0]+e+" "+t.join(", ")+" "+r[1]}(c,f,_)):_[0]+f+_[1]}function p(t){return"["+Error.prototype.toString.call(t)+"]"}function d(t,e,r,n,i,o){var a,s,u;if((u=Object.getOwnPropertyDescriptor(e,i)||{value:e[i]}).get?s=u.set?t.stylize("[Getter/Setter]","special"):t.stylize("[Getter]","special"):u.set&&(s=t.stylize("[Setter]","special")),P(n,i)||(a="["+i+"]"),s||(t.seen.indexOf(u.value)<0?(s=g(r)?h(t,u.value,null):h(t,u.value,r-1)).indexOf("\n")>-1&&(s=o?s.split("\n").map(function(t){return" "+t}).join("\n").slice(2):"\n"+s.split("\n").map(function(t){return" "+t}).join("\n")):s=t.stylize("[Circular]","special")),m(a)){if(o&&i.match(/^\d+$/))return s;(a=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(a=a.slice(1,-1),a=t.stylize(a,"name")):(a=a.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),a=t.stylize(a,"string"))}return a+": "+s}function y(t){return Array.isArray(t)}function b(t){return"boolean"==typeof t}function g(t){return null===t}function v(t){return"number"==typeof t}function w(t){return"string"==typeof t}function m(t){return void 0===t}function S(t){return _(t)&&"[object RegExp]"===T(t)}function _(t){return"object"==typeof t&&null!==t}function E(t){return _(t)&&"[object Date]"===T(t)}function k(t){return _(t)&&("[object Error]"===T(t)||t instanceof Error)}function O(t){return"function"==typeof t}function T(t){return Object.prototype.toString.call(t)}function A(t){return t<10?"0"+t.toString(10):t.toString(10)}e.debuglog=function(t){if(t=t.toUpperCase(),!a[t])if(s.test(t)){var r=n.pid;a[t]=function(){var n=e.format.apply(e,arguments);console.error("%s %d: %s",t,r,n)}}else a[t]=function(){};return a[t]},e.inspect=c,c.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]},c.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},e.types=r(9032),e.isArray=y,e.isBoolean=b,e.isNull=g,e.isNullOrUndefined=function(t){return null==t},e.isNumber=v,e.isString=w,e.isSymbol=function(t){return"symbol"==typeof t},e.isUndefined=m,e.isRegExp=S,e.types.isRegExp=S,e.isObject=_,e.isDate=E,e.types.isDate=E,e.isError=k,e.types.isNativeError=k,e.isFunction=O,e.isPrimitive=function(t){return null===t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||"symbol"==typeof t||void 0===t},e.isBuffer=r(1135);var I=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function P(t,e){return Object.prototype.hasOwnProperty.call(t,e)}e.log=function(){console.log("%s - %s",function(){var t=new Date,e=[A(t.getHours()),A(t.getMinutes()),A(t.getSeconds())].join(":");return[t.getDate(),I[t.getMonth()],e].join(" ")}(),e.format.apply(e,arguments))},e.inherits=r(6698),e._extend=function(t,e){if(!e||!_(e))return t;for(var r=Object.keys(e),n=r.length;n--;)t[r[n]]=e[r[n]];return t};var x="undefined"!=typeof Symbol?Symbol("util.promisify.custom"):void 0;function B(t,e){if(!t){var r=new Error("Promise was rejected with a falsy value");r.reason=t,t=r}return e(t)}e.promisify=function(t){if("function"!=typeof t)throw new TypeError('The "original" argument must be of type Function');if(x&&t[x]){var e;if("function"!=typeof(e=t[x]))throw new TypeError('The "util.promisify.custom" argument must be of type Function');return Object.defineProperty(e,x,{value:e,enumerable:!1,writable:!1,configurable:!0}),e}function e(){for(var e,r,n=new Promise(function(t,n){e=t,r=n}),i=[],o=0;o<arguments.length;o++)i.push(arguments[o]);i.push(function(t,n){t?r(t):e(n)});try{t.apply(this,i)}catch(t){r(t)}return n}return Object.setPrototypeOf(e,Object.getPrototypeOf(t)),x&&Object.defineProperty(e,x,{value:e,enumerable:!1,writable:!1,configurable:!0}),Object.defineProperties(e,i(t))},e.promisify.custom=x,e.callbackify=function(t){if("function"!=typeof t)throw new TypeError('The "original" argument must be of type Function');function e(){for(var e=[],r=0;r<arguments.length;r++)e.push(arguments[r]);var i=e.pop();if("function"!=typeof i)throw new TypeError("The last argument must be of type Function");var o=this,a=function(){return i.apply(o,arguments)};t.apply(this,e).then(function(t){n.nextTick(a.bind(null,null,t))},function(t){n.nextTick(B.bind(null,t,a))})}return Object.setPrototypeOf(e,Object.getPrototypeOf(t)),Object.defineProperties(e,i(t)),e}},592:(t,e,r)=>{var n=r(655),i=function(){return!!n};i.hasArrayLengthDefineBug=function(){if(!n)return null;try{return 1!==n([],"length",{value:1}).length}catch(t){return!0}},t.exports=i},655:t=>{var e=Object.defineProperty||!1;if(e)try{e({},"a",{value:1})}catch(t){e=!1}t.exports=e},709:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),e.testEcc=void 0;const i=t=>n.from(t,"hex");function o(t){if(!t)throw new Error("ecc library invalid")}e.testEcc=function(t){o(t.isPoint(i("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),o(!t.isPoint(i("030000000000000000000000000000000000000000000000000000000000000005"))),o(t.isPrivate(i("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),o(t.isPrivate(i("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"))),o(!t.isPrivate(i("0000000000000000000000000000000000000000000000000000000000000000"))),o(!t.isPrivate(i("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"))),o(!t.isPrivate(i("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364142"))),o(n.from(t.privateAdd(i("0000000000000000000000000000000000000000000000000000000000000001"),i("0000000000000000000000000000000000000000000000000000000000000000"))).equals(i("0000000000000000000000000000000000000000000000000000000000000001"))),o(null===t.privateAdd(i("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd036413e"),i("0000000000000000000000000000000000000000000000000000000000000003"))),o(n.from(t.privateAdd(i("e211078564db65c3ce7704f08262b1f38f1ef412ad15b5ac2d76657a63b2c500"),i("b51fbb69051255d1becbd683de5848242a89c229348dd72896a87ada94ae8665"))).equals(i("9730c2ee69edbb958d42db7460bafa18fef9d955325aec99044c81c8282b0a24"))),o(n.from(t.privateNegate(i("0000000000000000000000000000000000000000000000000000000000000001"))).equals(i("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"))),o(n.from(t.privateNegate(i("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd036413e"))).equals(i("0000000000000000000000000000000000000000000000000000000000000003"))),o(n.from(t.privateNegate(i("b1121e4088a66a28f5b6b0f5844943ecd9f610196d7bb83b25214b60452c09af"))).equals(i("4eede1bf775995d70a494f0a7bb6bc11e0b8cccd41cce8009ab1132c8b0a3792"))),o(n.from(t.pointCompress(i("0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"),!0)).equals(i("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),o(n.from(t.pointCompress(i("0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"),!1)).equals(i("0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"))),o(n.from(t.pointCompress(i("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),!0)).equals(i("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),o(n.from(t.pointCompress(i("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),!1)).equals(i("0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"))),o(n.from(t.pointFromScalar(i("b1121e4088a66a28f5b6b0f5844943ecd9f610196d7bb83b25214b60452c09af"))).equals(i("02b07ba9dca9523b7ef4bd97703d43d20399eb698e194704791a25ce77a400df99"))),o(null===t.xOnlyPointAddTweak(i("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),i("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140")));let e=t.xOnlyPointAddTweak(i("1617d38ed8d8657da4d4761e8057bc396ea9e4b9d29776d4be096016dbd2509b"),i("a8397a935f0dfceba6ba9618f6451ef4d80637abf4e6af2669fbc9de6a8fd2ac"));o(n.from(e.xOnlyPubkey).equals(i("e478f99dab91052ab39a33ea35fd5e6e4933f4d28023cd597c9a1f6760346adf"))&&1===e.parity),e=t.xOnlyPointAddTweak(i("2c0b7cf95324a07d05398b240174dc0c2be444d96b159aa6c7f7b1e668680991"),i("823c3cd2142744b075a87eade7e1b8678ba308d566226a0056ca2b7a76f86b47")),o(n.from(e.xOnlyPubkey).equals(i("9534f8dc8c6deda2dc007655981c78b49c5d96c778fbf363462a11ec9dfd948c"))&&0===e.parity),o(n.from(t.sign(i("5e9f0a0d593efdcf78ac923bc3313e4e7d408d574354ee2b3288c0da9fbba6ed"),i("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"))).equals(i("54c4a33c6423d689378f160a7ff8b61330444abb58fb470f96ea16d99d4a2fed07082304410efa6b2943111b6a4e0aaa7b7db55a07e9861d1fb3cb1f421044a5"))),o(t.verify(i("5e9f0a0d593efdcf78ac923bc3313e4e7d408d574354ee2b3288c0da9fbba6ed"),i("0379be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),i("54c4a33c6423d689378f160a7ff8b61330444abb58fb470f96ea16d99d4a2fed07082304410efa6b2943111b6a4e0aaa7b7db55a07e9861d1fb3cb1f421044a5"))),t.signSchnorr&&o(n.from(t.signSchnorr(i("7e2d58d8b3bcdf1abadec7829054f90dda9805aab56c77333024b9d0a508b75c"),i("c90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b14e5c9"),i("c87aa53824b4d7ae2eb035a2b5bbbccc080e76cdc6d1692c4b0b62d798e6d906"))).equals(i("5831aaeed7b44bb74e5eab94ba9d4294c49bcf2a60728d8b4c200f50dd313c1bab745879a5ad954a72c45a91c3a51d3c7adea98d82f8481e0e1e03674a6f3fb7"))),t.verifySchnorr&&o(t.verifySchnorr(i("7e2d58d8b3bcdf1abadec7829054f90dda9805aab56c77333024b9d0a508b75c"),i("dd308afec5777e13121fa72b9cc1b7cc0139715309b086c960e18fd969774eb8"),i("5831aaeed7b44bb74e5eab94ba9d4294c49bcf2a60728d8b4c200f50dd313c1bab745879a5ad954a72c45a91c3a51d3c7adea98d82f8481e0e1e03674a6f3fb7")))}},953:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.maybe=e.Boolean=e.Array=e.Buffer256bit=e.Network=e.typeforce=void 0,e.typeforce=r(8676),e.Network=e.typeforce.compile({messagePrefix:e.typeforce.oneOf(e.typeforce.Buffer,e.typeforce.String),bip32:{public:e.typeforce.UInt32,private:e.typeforce.UInt32},pubKeyHash:e.typeforce.UInt8,scriptHash:e.typeforce.UInt8,wif:e.typeforce.UInt8}),e.Buffer256bit=e.typeforce.BufferN(32),e.Array=e.typeforce.Array,e.Boolean=e.typeforce.Boolean,e.maybe=e.typeforce.maybe},968:t=>{t.exports=function(){throw new Error("Readable.from is not available in the browser")}},1002:t=>{t.exports=Function.prototype.apply},1061:(t,e,r)=>{var n=r(2113);function i(t){return t.name||t.toString().match(/function (.*?)\s*\(/)[1]}function o(t){return n.Nil(t)?"":i(t.constructor)}function a(t,e){Error.captureStackTrace&&Error.captureStackTrace(t,e)}function s(t){return n.Function(t)?t.toJSON?t.toJSON():i(t):n.Array(t)?"Array":t&&n.Object(t)?"Object":void 0!==t?t:""}function u(t,e,r){var i=function(t){return n.Function(t)?"":n.String(t)?JSON.stringify(t):t&&n.Object(t)?"":t}(e);return"Expected "+s(t)+", got"+(""!==r?" "+r:"")+(""!==i?" "+i:"")}function c(t,e,r){r=r||o(e),this.message=u(t,e,r),a(this,c),this.__type=t,this.__value=e,this.__valueTypeName=r}function f(t,e,r,n,i){t?(i=i||o(n),this.message=function(t,e,r,n,i){var o='" of type ';return"key"===e&&(o='" with key type '),u('property "'+s(r)+o+s(t),n,i)}(t,r,e,n,i)):this.message='Unexpected property "'+e+'"',a(this,c),this.__label=r,this.__property=e,this.__type=t,this.__value=n,this.__valueTypeName=i}c.prototype=Object.create(Error.prototype),c.prototype.constructor=c,f.prototype=Object.create(Error.prototype),f.prototype.constructor=c,t.exports={TfTypeError:c,TfPropertyTypeError:f,tfCustomError:function(t,e){return new c(t,{},e)},tfSubError:function(t,e,r){return t instanceof f?(e=e+"."+t.__property,t=new f(t.__type,e,t.__label,t.__value,t.__valueTypeName)):t instanceof c&&(t=new f(t.__type,e,r,t.__value,t.__valueTypeName)),a(t),t},tfJSON:s,getValueTypeName:o}},1064:(t,e,r)=>{var n=r(9612);t.exports=n.getPrototypeOf||null},1093:t=>{var e=Object.prototype.toString;t.exports=function(t){var r=e.call(t),n="[object Arguments]"===r;return n||(n="[object Array]"!==r&&null!==t&&"object"==typeof t&&"number"==typeof t.length&&t.length>=0&&"[object Function]"===e.call(t.callee)),n}},1135:t=>{t.exports=function(t){return t&&"object"==typeof t&&"function"==typeof t.copy&&"function"==typeof t.fill&&"function"==typeof t.readUInt8}},1181:(t,e,r)=>{t.exports=r(7007).EventEmitter},1189:(t,e,r)=>{var n=Array.prototype.slice,i=r(1093),o=Object.keys,a=o?function(t){return o(t)}:r(8875),s=Object.keys;a.shim=function(){if(Object.keys){var t=function(){var t=Object.keys(arguments);return t&&t.length===arguments.length}(1,2);t||(Object.keys=function(t){return i(t)?s(n.call(t)):s(t)})}else Object.keys=a;return Object.keys||a},t.exports=a},1237:t=>{t.exports=EvalError},1333:t=>{t.exports=function(){if("function"!=typeof Symbol||"function"!=typeof Object.getOwnPropertySymbols)return!1;if("symbol"==typeof Symbol.iterator)return!0;var t={},e=Symbol("test"),r=Object(e);if("string"==typeof e)return!1;if("[object Symbol]"!==Object.prototype.toString.call(e))return!1;if("[object Symbol]"!==Object.prototype.toString.call(r))return!1;for(var n in t[e]=42,t)return!1;if("function"==typeof Object.keys&&0!==Object.keys(t).length)return!1;if("function"==typeof Object.getOwnPropertyNames&&0!==Object.getOwnPropertyNames(t).length)return!1;var i=Object.getOwnPropertySymbols(t);if(1!==i.length||i[0]!==e)return!1;if(!Object.prototype.propertyIsEnumerable.call(t,e))return!1;if("function"==typeof Object.getOwnPropertyDescriptor){var o=Object.getOwnPropertyDescriptor(t,e);if(42!==o.value||!0!==o.enumerable)return!1}return!0}},1396:(t,e,r)=>{t.exports=r(7007).EventEmitter},1447:(t,e,r)=>{var n=r(9805),i=r(3269),o=r(4823),a=r(7293),s=r(1998),u=-2,c=12,f=30;function l(t){return(t>>>24&255)+(t>>>8&65280)+((65280&t)<<8)+((255&t)<<24)}function h(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new n.Buf16(320),this.work=new n.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function p(t){var e;return t&&t.state?(e=t.state,t.total_in=t.total_out=e.total=0,t.msg="",e.wrap&&(t.adler=1&e.wrap),e.mode=1,e.last=0,e.havedict=0,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new n.Buf32(852),e.distcode=e.distdyn=new n.Buf32(592),e.sane=1,e.back=-1,0):u}function d(t){var e;return t&&t.state?((e=t.state).wsize=0,e.whave=0,e.wnext=0,p(t)):u}function y(t,e){var r,n;return t&&t.state?(n=t.state,e<0?(r=0,e=-e):(r=1+(e>>4),e<48&&(e&=15)),e&&(e<8||e>15)?u:(null!==n.window&&n.wbits!==e&&(n.window=null),n.wrap=r,n.wbits=e,d(t))):u}function b(t,e){var r,n;return t?(n=new h,t.state=n,n.window=null,0!==(r=y(t,e))&&(t.state=null),r):u}var g,v,w=!0;function m(t){if(w){var e;for(g=new n.Buf32(512),v=new n.Buf32(32),e=0;e<144;)t.lens[e++]=8;for(;e<256;)t.lens[e++]=9;for(;e<280;)t.lens[e++]=7;for(;e<288;)t.lens[e++]=8;for(s(1,t.lens,0,288,g,0,t.work,{bits:9}),e=0;e<32;)t.lens[e++]=5;s(2,t.lens,0,32,v,0,t.work,{bits:5}),w=!1}t.lencode=g,t.lenbits=9,t.distcode=v,t.distbits=5}function S(t,e,r,i){var o,a=t.state;return null===a.window&&(a.wsize=1<<a.wbits,a.wnext=0,a.whave=0,a.window=new n.Buf8(a.wsize)),i>=a.wsize?(n.arraySet(a.window,e,r-a.wsize,a.wsize,0),a.wnext=0,a.whave=a.wsize):((o=a.wsize-a.wnext)>i&&(o=i),n.arraySet(a.window,e,r-i,o,a.wnext),(i-=o)?(n.arraySet(a.window,e,r-i,i,0),a.wnext=i,a.whave=a.wsize):(a.wnext+=o,a.wnext===a.wsize&&(a.wnext=0),a.whave<a.wsize&&(a.whave+=o))),0}e.inflateReset=d,e.inflateReset2=y,e.inflateResetKeep=p,e.inflateInit=function(t){return b(t,15)},e.inflateInit2=b,e.inflate=function(t,e){var r,h,p,d,y,b,g,v,w,_,E,k,O,T,A,I,P,x,B,R,U,j,N,L,C=0,F=new n.Buf8(4),D=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!t||!t.state||!t.output||!t.input&&0!==t.avail_in)return u;(r=t.state).mode===c&&(r.mode=13),y=t.next_out,p=t.output,g=t.avail_out,d=t.next_in,h=t.input,b=t.avail_in,v=r.hold,w=r.bits,_=b,E=g,j=0;t:for(;;)switch(r.mode){case 1:if(0===r.wrap){r.mode=13;break}for(;w<16;){if(0===b)break t;b--,v+=h[d++]<<w,w+=8}if(2&r.wrap&&35615===v){r.check=0,F[0]=255&v,F[1]=v>>>8&255,r.check=o(r.check,F,2,0),v=0,w=0,r.mode=2;break}if(r.flags=0,r.head&&(r.head.done=!1),!(1&r.wrap)||(((255&v)<<8)+(v>>8))%31){t.msg="incorrect header check",r.mode=f;break}if(8!=(15&v)){t.msg="unknown compression method",r.mode=f;break}if(w-=4,U=8+(15&(v>>>=4)),0===r.wbits)r.wbits=U;else if(U>r.wbits){t.msg="invalid window size",r.mode=f;break}r.dmax=1<<U,t.adler=r.check=1,r.mode=512&v?10:c,v=0,w=0;break;case 2:for(;w<16;){if(0===b)break t;b--,v+=h[d++]<<w,w+=8}if(r.flags=v,8!=(255&r.flags)){t.msg="unknown compression method",r.mode=f;break}if(57344&r.flags){t.msg="unknown header flags set",r.mode=f;break}r.head&&(r.head.text=v>>8&1),512&r.flags&&(F[0]=255&v,F[1]=v>>>8&255,r.check=o(r.check,F,2,0)),v=0,w=0,r.mode=3;case 3:for(;w<32;){if(0===b)break t;b--,v+=h[d++]<<w,w+=8}r.head&&(r.head.time=v),512&r.flags&&(F[0]=255&v,F[1]=v>>>8&255,F[2]=v>>>16&255,F[3]=v>>>24&255,r.check=o(r.check,F,4,0)),v=0,w=0,r.mode=4;case 4:for(;w<16;){if(0===b)break t;b--,v+=h[d++]<<w,w+=8}r.head&&(r.head.xflags=255&v,r.head.os=v>>8),512&r.flags&&(F[0]=255&v,F[1]=v>>>8&255,r.check=o(r.check,F,2,0)),v=0,w=0,r.mode=5;case 5:if(1024&r.flags){for(;w<16;){if(0===b)break t;b--,v+=h[d++]<<w,w+=8}r.length=v,r.head&&(r.head.extra_len=v),512&r.flags&&(F[0]=255&v,F[1]=v>>>8&255,r.check=o(r.check,F,2,0)),v=0,w=0}else r.head&&(r.head.extra=null);r.mode=6;case 6:if(1024&r.flags&&((k=r.length)>b&&(k=b),k&&(r.head&&(U=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Array(r.head.extra_len)),n.arraySet(r.head.extra,h,d,k,U)),512&r.flags&&(r.check=o(r.check,h,k,d)),b-=k,d+=k,r.length-=k),r.length))break t;r.length=0,r.mode=7;case 7:if(2048&r.flags){if(0===b)break t;k=0;do{U=h[d+k++],r.head&&U&&r.length<65536&&(r.head.name+=String.fromCharCode(U))}while(U&&k<b);if(512&r.flags&&(r.check=o(r.check,h,k,d)),b-=k,d+=k,U)break t}else r.head&&(r.head.name=null);r.length=0,r.mode=8;case 8:if(4096&r.flags){if(0===b)break t;k=0;do{U=h[d+k++],r.head&&U&&r.length<65536&&(r.head.comment+=String.fromCharCode(U))}while(U&&k<b);if(512&r.flags&&(r.check=o(r.check,h,k,d)),b-=k,d+=k,U)break t}else r.head&&(r.head.comment=null);r.mode=9;case 9:if(512&r.flags){for(;w<16;){if(0===b)break t;b--,v+=h[d++]<<w,w+=8}if(v!==(65535&r.check)){t.msg="header crc mismatch",r.mode=f;break}v=0,w=0}r.head&&(r.head.hcrc=r.flags>>9&1,r.head.done=!0),t.adler=r.check=0,r.mode=c;break;case 10:for(;w<32;){if(0===b)break t;b--,v+=h[d++]<<w,w+=8}t.adler=r.check=l(v),v=0,w=0,r.mode=11;case 11:if(0===r.havedict)return t.next_out=y,t.avail_out=g,t.next_in=d,t.avail_in=b,r.hold=v,r.bits=w,2;t.adler=r.check=1,r.mode=c;case c:if(5===e||6===e)break t;case 13:if(r.last){v>>>=7&w,w-=7&w,r.mode=27;break}for(;w<3;){if(0===b)break t;b--,v+=h[d++]<<w,w+=8}switch(r.last=1&v,w-=1,3&(v>>>=1)){case 0:r.mode=14;break;case 1:if(m(r),r.mode=20,6===e){v>>>=2,w-=2;break t}break;case 2:r.mode=17;break;case 3:t.msg="invalid block type",r.mode=f}v>>>=2,w-=2;break;case 14:for(v>>>=7&w,w-=7&w;w<32;){if(0===b)break t;b--,v+=h[d++]<<w,w+=8}if((65535&v)!=(v>>>16^65535)){t.msg="invalid stored block lengths",r.mode=f;break}if(r.length=65535&v,v=0,w=0,r.mode=15,6===e)break t;case 15:r.mode=16;case 16:if(k=r.length){if(k>b&&(k=b),k>g&&(k=g),0===k)break t;n.arraySet(p,h,d,k,y),b-=k,d+=k,g-=k,y+=k,r.length-=k;break}r.mode=c;break;case 17:for(;w<14;){if(0===b)break t;b--,v+=h[d++]<<w,w+=8}if(r.nlen=257+(31&v),v>>>=5,w-=5,r.ndist=1+(31&v),v>>>=5,w-=5,r.ncode=4+(15&v),v>>>=4,w-=4,r.nlen>286||r.ndist>30){t.msg="too many length or distance symbols",r.mode=f;break}r.have=0,r.mode=18;case 18:for(;r.have<r.ncode;){for(;w<3;){if(0===b)break t;b--,v+=h[d++]<<w,w+=8}r.lens[D[r.have++]]=7&v,v>>>=3,w-=3}for(;r.have<19;)r.lens[D[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,N={bits:r.lenbits},j=s(0,r.lens,0,19,r.lencode,0,r.work,N),r.lenbits=N.bits,j){t.msg="invalid code lengths set",r.mode=f;break}r.have=0,r.mode=19;case 19:for(;r.have<r.nlen+r.ndist;){for(;I=(C=r.lencode[v&(1<<r.lenbits)-1])>>>16&255,P=65535&C,!((A=C>>>24)<=w);){if(0===b)break t;b--,v+=h[d++]<<w,w+=8}if(P<16)v>>>=A,w-=A,r.lens[r.have++]=P;else{if(16===P){for(L=A+2;w<L;){if(0===b)break t;b--,v+=h[d++]<<w,w+=8}if(v>>>=A,w-=A,0===r.have){t.msg="invalid bit length repeat",r.mode=f;break}U=r.lens[r.have-1],k=3+(3&v),v>>>=2,w-=2}else if(17===P){for(L=A+3;w<L;){if(0===b)break t;b--,v+=h[d++]<<w,w+=8}w-=A,U=0,k=3+(7&(v>>>=A)),v>>>=3,w-=3}else{for(L=A+7;w<L;){if(0===b)break t;b--,v+=h[d++]<<w,w+=8}w-=A,U=0,k=11+(127&(v>>>=A)),v>>>=7,w-=7}if(r.have+k>r.nlen+r.ndist){t.msg="invalid bit length repeat",r.mode=f;break}for(;k--;)r.lens[r.have++]=U}}if(r.mode===f)break;if(0===r.lens[256]){t.msg="invalid code -- missing end-of-block",r.mode=f;break}if(r.lenbits=9,N={bits:r.lenbits},j=s(1,r.lens,0,r.nlen,r.lencode,0,r.work,N),r.lenbits=N.bits,j){t.msg="invalid literal/lengths set",r.mode=f;break}if(r.distbits=6,r.distcode=r.distdyn,N={bits:r.distbits},j=s(2,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,N),r.distbits=N.bits,j){t.msg="invalid distances set",r.mode=f;break}if(r.mode=20,6===e)break t;case 20:r.mode=21;case 21:if(b>=6&&g>=258){t.next_out=y,t.avail_out=g,t.next_in=d,t.avail_in=b,r.hold=v,r.bits=w,a(t,E),y=t.next_out,p=t.output,g=t.avail_out,d=t.next_in,h=t.input,b=t.avail_in,v=r.hold,w=r.bits,r.mode===c&&(r.back=-1);break}for(r.back=0;I=(C=r.lencode[v&(1<<r.lenbits)-1])>>>16&255,P=65535&C,!((A=C>>>24)<=w);){if(0===b)break t;b--,v+=h[d++]<<w,w+=8}if(I&&!(240&I)){for(x=A,B=I,R=P;I=(C=r.lencode[R+((v&(1<<x+B)-1)>>x)])>>>16&255,P=65535&C,!(x+(A=C>>>24)<=w);){if(0===b)break t;b--,v+=h[d++]<<w,w+=8}v>>>=x,w-=x,r.back+=x}if(v>>>=A,w-=A,r.back+=A,r.length=P,0===I){r.mode=26;break}if(32&I){r.back=-1,r.mode=c;break}if(64&I){t.msg="invalid literal/length code",r.mode=f;break}r.extra=15&I,r.mode=22;case 22:if(r.extra){for(L=r.extra;w<L;){if(0===b)break t;b--,v+=h[d++]<<w,w+=8}r.length+=v&(1<<r.extra)-1,v>>>=r.extra,w-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=23;case 23:for(;I=(C=r.distcode[v&(1<<r.distbits)-1])>>>16&255,P=65535&C,!((A=C>>>24)<=w);){if(0===b)break t;b--,v+=h[d++]<<w,w+=8}if(!(240&I)){for(x=A,B=I,R=P;I=(C=r.distcode[R+((v&(1<<x+B)-1)>>x)])>>>16&255,P=65535&C,!(x+(A=C>>>24)<=w);){if(0===b)break t;b--,v+=h[d++]<<w,w+=8}v>>>=x,w-=x,r.back+=x}if(v>>>=A,w-=A,r.back+=A,64&I){t.msg="invalid distance code",r.mode=f;break}r.offset=P,r.extra=15&I,r.mode=24;case 24:if(r.extra){for(L=r.extra;w<L;){if(0===b)break t;b--,v+=h[d++]<<w,w+=8}r.offset+=v&(1<<r.extra)-1,v>>>=r.extra,w-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){t.msg="invalid distance too far back",r.mode=f;break}r.mode=25;case 25:if(0===g)break t;if(k=E-g,r.offset>k){if((k=r.offset-k)>r.whave&&r.sane){t.msg="invalid distance too far back",r.mode=f;break}k>r.wnext?(k-=r.wnext,O=r.wsize-k):O=r.wnext-k,k>r.length&&(k=r.length),T=r.window}else T=p,O=y-r.offset,k=r.length;k>g&&(k=g),g-=k,r.length-=k;do{p[y++]=T[O++]}while(--k);0===r.length&&(r.mode=21);break;case 26:if(0===g)break t;p[y++]=r.length,g--,r.mode=21;break;case 27:if(r.wrap){for(;w<32;){if(0===b)break t;b--,v|=h[d++]<<w,w+=8}if(E-=g,t.total_out+=E,r.total+=E,E&&(t.adler=r.check=r.flags?o(r.check,p,E,y-E):i(r.check,p,E,y-E)),E=g,(r.flags?v:l(v))!==r.check){t.msg="incorrect data check",r.mode=f;break}v=0,w=0}r.mode=28;case 28:if(r.wrap&&r.flags){for(;w<32;){if(0===b)break t;b--,v+=h[d++]<<w,w+=8}if(v!==(4294967295&r.total)){t.msg="incorrect length check",r.mode=f;break}v=0,w=0}r.mode=29;case 29:j=1;break t;case f:j=-3;break t;case 31:return-4;default:return u}return t.next_out=y,t.avail_out=g,t.next_in=d,t.avail_in=b,r.hold=v,r.bits=w,(r.wsize||E!==t.avail_out&&r.mode<f&&(r.mode<27||4!==e))&&S(t,t.output,t.next_out,E-t.avail_out)?(r.mode=31,-4):(_-=t.avail_in,E-=t.avail_out,t.total_in+=_,t.total_out+=E,r.total+=E,r.wrap&&E&&(t.adler=r.check=r.flags?o(r.check,p,E,t.next_out-E):i(r.check,p,E,t.next_out-E)),t.data_type=r.bits+(r.last?64:0)+(r.mode===c?128:0)+(20===r.mode||15===r.mode?256:0),(0===_&&0===E||4===e)&&0===j&&(j=-5),j)},e.inflateEnd=function(t){if(!t||!t.state)return u;var e=t.state;return e.window&&(e.window=null),t.state=null,0},e.inflateGetHeader=function(t,e){var r;return t&&t.state&&2&(r=t.state).wrap?(r.head=e,e.done=!1,0):u},e.inflateSetDictionary=function(t,e){var r,n=e.length;return t&&t.state?0!==(r=t.state).wrap&&11!==r.mode?u:11===r.mode&&i(1,e,n,0)!==r.check?-3:S(t,e,n,n)?(r.mode=31,-4):(r.havedict=1,0):u},e.inflateInfo="pako inflate (from Nodeca project)"},1468:(t,e,r)=>{var n=r(5606);function i(t,e){a(t,e),o(t)}function o(t){t._writableState&&!t._writableState.emitClose||t._readableState&&!t._readableState.emitClose||t.emit("close")}function a(t,e){t.emit("error",e)}t.exports={destroy:function(t,e){var r=this,s=this._readableState&&this._readableState.destroyed,u=this._writableState&&this._writableState.destroyed;return s||u?(e?e(t):t&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,n.nextTick(a,this,t)):n.nextTick(a,this,t)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(t||null,function(t){!e&&t?r._writableState?r._writableState.errorEmitted?n.nextTick(o,r):(r._writableState.errorEmitted=!0,n.nextTick(i,r,t)):n.nextTick(i,r,t):e?(n.nextTick(o,r),e(t)):n.nextTick(o,r)}),this)},undestroy:function(){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)},errorOrDestroy:function(t,e){var r=t._readableState,n=t._writableState;r&&r.autoDestroy||n&&n.autoDestroy?t.destroy(e):t.emit("error",e)}}},1484:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.isHash=e.validateObject=e.memoized=e.notImplemented=e.createHmacDrbg=e.bitMask=e.bitSet=e.bitGet=e.bitLen=e.aInRange=e.inRange=e.asciiToBytes=e.copyBytes=e.equalBytes=e.ensureBytes=e.numberToVarBytesBE=e.numberToBytesLE=e.numberToBytesBE=e.bytesToNumberLE=e.bytesToNumberBE=e.hexToNumber=e.numberToHexUnpadded=e.abool=e.utf8ToBytes=e.randomBytes=e.isBytes=e.hexToBytes=e.concatBytes=e.bytesToUtf8=e.bytesToHex=e.anumber=e.abytes=void 0;const n=r(8627);e.abytes=n.abytes,e.anumber=n.anumber,e.bytesToHex=n.bytesToHex,e.bytesToUtf8=n.bytesToUtf8,e.concatBytes=n.concatBytes,e.hexToBytes=n.hexToBytes,e.isBytes=n.isBytes,e.randomBytes=n.randomBytes,e.utf8ToBytes=n.utf8ToBytes,e.abool=n.abool,e.numberToHexUnpadded=n.numberToHexUnpadded,e.hexToNumber=n.hexToNumber,e.bytesToNumberBE=n.bytesToNumberBE,e.bytesToNumberLE=n.bytesToNumberLE,e.numberToBytesBE=n.numberToBytesBE,e.numberToBytesLE=n.numberToBytesLE,e.numberToVarBytesBE=n.numberToVarBytesBE,e.ensureBytes=n.ensureBytes,e.equalBytes=n.equalBytes,e.copyBytes=n.copyBytes,e.asciiToBytes=n.asciiToBytes,e.inRange=n.inRange,e.aInRange=n.aInRange,e.bitLen=n.bitLen,e.bitGet=n.bitGet,e.bitSet=n.bitSet,e.bitMask=n.bitMask,e.createHmacDrbg=n.createHmacDrbg,e.notImplemented=n.notImplemented,e.memoized=n.memoized,e.validateObject=n.validateObject,e.isHash=n.isHash},1514:t=>{t.exports=Math.abs},1603:(t,e,r)=>{(e=t.exports=r(6736)).Stream=e,e.Readable=e,e.Writable=r(2192),e.Duplex=r(2818),e.Transform=r(3054),e.PassThrough=r(5860),e.finished=r(5826),e.pipeline=r(9434)},1705:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.DER=e.DERErr=void 0,e._splitEndoScalar=c,e._normFnElement=v,e.weierstrassN=w,e.SWUFpSqrtRatio=S,e.mapToCurveSimpleSWU=function(t,e){(0,s.validateField)(t);const{A:r,B:n,Z:i}=e;if(!t.isValid(r)||!t.isValid(n)||!t.isValid(i))throw new Error("mapToCurveSimpleSWU: invalid opts");const o=S(t,i);if(!t.isOdd)throw new Error("Field does not have .isOdd()");return e=>{let a,u,c,f,l,h,p,d;a=t.sqr(e),a=t.mul(a,i),u=t.sqr(a),u=t.add(u,a),c=t.add(u,t.ONE),c=t.mul(c,n),f=t.cmov(i,t.neg(u),!t.eql(u,t.ZERO)),f=t.mul(f,r),u=t.sqr(c),h=t.sqr(f),l=t.mul(h,r),u=t.add(u,l),u=t.mul(u,c),h=t.mul(h,f),l=t.mul(h,n),u=t.add(u,l),p=t.mul(a,c);const{isValid:y,value:b}=o(u,h);d=t.mul(a,e),d=t.mul(d,b),p=t.cmov(p,c,y),d=t.cmov(d,b,y);const g=t.isOdd(e)===t.isOdd(d);d=t.cmov(t.neg(d),d,g);const v=(0,s.FpInvertBatch)(t,[f],!0)[0];return p=t.mul(p,v),{x:p,y:d}}},e.ecdh=E,e.ecdsa=k,e.weierstrassPoints=function(t){const{CURVE:e,curveOpts:r}=O(t);return function(t,e){const{Fp:r,Fn:n}=e;const i=T(r,t.a,t.b);return Object.assign({},{CURVE:t,Point:e,ProjectivePoint:e,normPrivateKeyToScalar:t=>v(n,t),weierstrassEquation:i,isWithinCurveOrder:function(t){return(0,o.inRange)(t,d,n.ORDER)}})}(t,w(e,r))},e._legacyHelperEquat=T,e.weierstrass=function(t){const{CURVE:e,curveOpts:r,hash:n,ecdsaOpts:i}=function(t){const{CURVE:e,curveOpts:r}=O(t),n={hmac:t.hmac,randomBytes:t.randomBytes,lowS:t.lowS,bits2int:t.bits2int,bits2int_modN:t.bits2int_modN};return{CURVE:e,curveOpts:r,hash:t.hash,ecdsaOpts:n}}(t);return function(t,e){const r=e.Point;return Object.assign({},e,{ProjectivePoint:r,CURVE:Object.assign({},t,(0,s.nLength)(r.Fn.ORDER,r.Fn.BITS))})}(t,k(w(e,r),n,i))};const n=r(9615),i=r(9175),o=r(8627),a=r(2422),s=r(4967),u=(t,e)=>(t+(t>=0?e:-e)/y)/e;function c(t,e,r){const[[n,i],[a,s]]=e,c=u(s*t,r),f=u(-i*t,r);let l=t-c*n-f*a,h=-c*i-f*s;const y=l<p,b=h<p;y&&(l=-l),b&&(h=-h);const g=(0,o.bitMask)(Math.ceil((0,o.bitLen)(r)/2))+d;if(l<p||l>=g||h<p||h>=g)throw new Error("splitScalar (endomorphism): failed, k="+t);return{k1neg:y,k1:l,k2neg:b,k2:h}}function f(t){if(!["compact","recovered","der"].includes(t))throw new Error('Signature format must be "compact", "recovered", or "der"');return t}function l(t,e){const r={};for(let n of Object.keys(e))r[n]=void 0===t[n]?e[n]:t[n];return(0,o._abool2)(r.lowS,"lowS"),(0,o._abool2)(r.prehash,"prehash"),void 0!==r.format&&f(r.format),r}class h extends Error{constructor(t=""){super(t)}}e.DERErr=h,e.DER={Err:h,_tlv:{encode:(t,r)=>{const{Err:n}=e.DER;if(t<0||t>256)throw new n("tlv.encode: wrong tag");if(1&r.length)throw new n("tlv.encode: unpadded data");const i=r.length/2,a=(0,o.numberToHexUnpadded)(i);if(a.length/2&128)throw new n("tlv.encode: long form length too big");const s=i>127?(0,o.numberToHexUnpadded)(a.length/2|128):"";return(0,o.numberToHexUnpadded)(t)+s+a+r},decode(t,r){const{Err:n}=e.DER;let i=0;if(t<0||t>256)throw new n("tlv.encode: wrong tag");if(r.length<2||r[i++]!==t)throw new n("tlv.decode: wrong tlv");const o=r[i++];let a=0;if(128&o){const t=127&o;if(!t)throw new n("tlv.decode(long): indefinite length not supported");if(t>4)throw new n("tlv.decode(long): byte length is too big");const e=r.subarray(i,i+t);if(e.length!==t)throw new n("tlv.decode: length bytes not complete");if(0===e[0])throw new n("tlv.decode(long): zero leftmost byte");for(const t of e)a=a<<8|t;if(i+=t,a<128)throw new n("tlv.decode(long): not minimal encoding")}else a=o;const s=r.subarray(i,i+a);if(s.length!==a)throw new n("tlv.decode: wrong value length");return{v:s,l:r.subarray(i+a)}}},_int:{encode(t){const{Err:r}=e.DER;if(t<p)throw new r("integer: negative integers are not allowed");let n=(0,o.numberToHexUnpadded)(t);if(8&Number.parseInt(n[0],16)&&(n="00"+n),1&n.length)throw new r("unexpected DER parsing assertion: unpadded hex");return n},decode(t){const{Err:r}=e.DER;if(128&t[0])throw new r("invalid signature integer: negative");if(0===t[0]&&!(128&t[1]))throw new r("invalid signature integer: unnecessary leading zero");return(0,o.bytesToNumberBE)(t)}},toSig(t){const{Err:r,_int:n,_tlv:i}=e.DER,a=(0,o.ensureBytes)("signature",t),{v:s,l:u}=i.decode(48,a);if(u.length)throw new r("invalid signature: left bytes after parsing");const{v:c,l:f}=i.decode(2,s),{v:l,l:h}=i.decode(2,f);if(h.length)throw new r("invalid signature: left bytes after parsing");return{r:n.decode(c),s:n.decode(l)}},hexFromSig(t){const{_tlv:r,_int:n}=e.DER,i=r.encode(2,n.encode(t.r))+r.encode(2,n.encode(t.s));return r.encode(48,i)}};const p=BigInt(0),d=BigInt(1),y=BigInt(2),b=BigInt(3),g=BigInt(4);function v(t,e){const{BYTES:r}=t;let n;if("bigint"==typeof e)n=e;else{let i=(0,o.ensureBytes)("private key",e);try{n=t.fromBytes(i)}catch(t){throw new Error(`invalid private key: expected ui8a of size ${r}, got ${typeof e}`)}}if(!t.isValidNot0(n))throw new Error("invalid private key: out of range [1..N-1]");return n}function w(t,e={}){const r=(0,a._createCurveFields)("weierstrass",t,e),{Fp:n,Fn:i}=r;let s=r.CURVE;const{h:u,n:f}=s;(0,o._validateObject)(e,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object",wrapPrivateKey:"boolean"});const{endo:l}=e;if(l&&(!n.is0(s.a)||"bigint"!=typeof l.beta||!Array.isArray(l.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');const h=_(n,i);function y(){if(!n.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}const w=e.toBytes||function(t,e,r){const{x:i,y:a}=e.toAffine(),s=n.toBytes(i);if((0,o._abool2)(r,"isCompressed"),r){y();const t=!n.isOdd(a);return(0,o.concatBytes)(m(t),s)}return(0,o.concatBytes)(Uint8Array.of(4),s,n.toBytes(a))},S=e.fromBytes||function(t){(0,o._abytes2)(t,void 0,"Point");const{publicKey:e,publicKeyUncompressed:r}=h,i=t.length,a=t[0],s=t.subarray(1);if(i!==e||2!==a&&3!==a){if(i===r&&4===a){const t=n.BYTES,e=n.fromBytes(s.subarray(0,t)),r=n.fromBytes(s.subarray(t,2*t));if(!k(e,r))throw new Error("bad point: is not on curve");return{x:e,y:r}}throw new Error(`bad point: got length ${i}, expected compressed=${e} or uncompressed=${r}`)}{const t=n.fromBytes(s);if(!n.isValid(t))throw new Error("bad point: is not on curve, wrong x");const e=E(t);let r;try{r=n.sqrt(e)}catch(t){const e=t instanceof Error?": "+t.message:"";throw new Error("bad point: is not on curve, sqrt error"+e)}return y(),!(1&~a)!==n.isOdd(r)&&(r=n.neg(r)),{x:t,y:r}}};function E(t){const e=n.sqr(t),r=n.mul(e,t);return n.add(n.add(r,n.mul(t,s.a)),s.b)}function k(t,e){const r=n.sqr(e),i=E(t);return n.eql(r,i)}if(!k(s.Gx,s.Gy))throw new Error("bad curve params: generator point");const O=n.mul(n.pow(s.a,b),g),T=n.mul(n.sqr(s.b),BigInt(27));if(n.is0(n.add(O,T)))throw new Error("bad curve params: a or b");function A(t,e,r=!1){if(!n.isValid(e)||r&&n.is0(e))throw new Error(`bad point coordinate ${t}`);return e}function I(t){if(!(t instanceof U))throw new Error("ProjectivePoint expected")}function P(t){if(!l||!l.basises)throw new Error("no endo");return c(t,l.basises,i.ORDER)}const x=(0,o.memoized)((t,e)=>{const{X:r,Y:i,Z:o}=t;if(n.eql(o,n.ONE))return{x:r,y:i};const a=t.is0();null==e&&(e=a?n.ONE:n.inv(o));const s=n.mul(r,e),u=n.mul(i,e),c=n.mul(o,e);if(a)return{x:n.ZERO,y:n.ZERO};if(!n.eql(c,n.ONE))throw new Error("invZ was invalid");return{x:s,y:u}}),B=(0,o.memoized)(t=>{if(t.is0()){if(e.allowInfinityPoint&&!n.is0(t.Y))return;throw new Error("bad point: ZERO")}const{x:r,y:i}=t.toAffine();if(!n.isValid(r)||!n.isValid(i))throw new Error("bad point: x or y not field elements");if(!k(r,i))throw new Error("bad point: equation left != right");if(!t.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});function R(t,e,r,i,o){return r=new U(n.mul(r.X,t),r.Y,r.Z),e=(0,a.negateCt)(i,e),r=(0,a.negateCt)(o,r),e.add(r)}class U{constructor(t,e,r){this.X=A("x",t),this.Y=A("y",e,!0),this.Z=A("z",r),Object.freeze(this)}static CURVE(){return s}static fromAffine(t){const{x:e,y:r}=t||{};if(!t||!n.isValid(e)||!n.isValid(r))throw new Error("invalid affine point");if(t instanceof U)throw new Error("projective point not allowed");return n.is0(e)&&n.is0(r)?U.ZERO:new U(e,r,n.ONE)}static fromBytes(t){const e=U.fromAffine(S((0,o._abytes2)(t,void 0,"point")));return e.assertValidity(),e}static fromHex(t){return U.fromBytes((0,o.ensureBytes)("pointHex",t))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(t=8,e=!0){return N.createCache(this,t),e||this.multiply(b),this}assertValidity(){B(this)}hasEvenY(){const{y:t}=this.toAffine();if(!n.isOdd)throw new Error("Field doesn't support isOdd");return!n.isOdd(t)}equals(t){I(t);const{X:e,Y:r,Z:i}=this,{X:o,Y:a,Z:s}=t,u=n.eql(n.mul(e,s),n.mul(o,i)),c=n.eql(n.mul(r,s),n.mul(a,i));return u&&c}negate(){return new U(this.X,n.neg(this.Y),this.Z)}double(){const{a:t,b:e}=s,r=n.mul(e,b),{X:i,Y:o,Z:a}=this;let u=n.ZERO,c=n.ZERO,f=n.ZERO,l=n.mul(i,i),h=n.mul(o,o),p=n.mul(a,a),d=n.mul(i,o);return d=n.add(d,d),f=n.mul(i,a),f=n.add(f,f),u=n.mul(t,f),c=n.mul(r,p),c=n.add(u,c),u=n.sub(h,c),c=n.add(h,c),c=n.mul(u,c),u=n.mul(d,u),f=n.mul(r,f),p=n.mul(t,p),d=n.sub(l,p),d=n.mul(t,d),d=n.add(d,f),f=n.add(l,l),l=n.add(f,l),l=n.add(l,p),l=n.mul(l,d),c=n.add(c,l),p=n.mul(o,a),p=n.add(p,p),l=n.mul(p,d),u=n.sub(u,l),f=n.mul(p,h),f=n.add(f,f),f=n.add(f,f),new U(u,c,f)}add(t){I(t);const{X:e,Y:r,Z:i}=this,{X:o,Y:a,Z:u}=t;let c=n.ZERO,f=n.ZERO,l=n.ZERO;const h=s.a,p=n.mul(s.b,b);let d=n.mul(e,o),y=n.mul(r,a),g=n.mul(i,u),v=n.add(e,r),w=n.add(o,a);v=n.mul(v,w),w=n.add(d,y),v=n.sub(v,w),w=n.add(e,i);let m=n.add(o,u);return w=n.mul(w,m),m=n.add(d,g),w=n.sub(w,m),m=n.add(r,i),c=n.add(a,u),m=n.mul(m,c),c=n.add(y,g),m=n.sub(m,c),l=n.mul(h,w),c=n.mul(p,g),l=n.add(c,l),c=n.sub(y,l),l=n.add(y,l),f=n.mul(c,l),y=n.add(d,d),y=n.add(y,d),g=n.mul(h,g),w=n.mul(p,w),y=n.add(y,g),g=n.sub(d,g),g=n.mul(h,g),w=n.add(w,g),d=n.mul(y,w),f=n.add(f,d),d=n.mul(m,w),c=n.mul(v,c),c=n.sub(c,d),d=n.mul(v,y),l=n.mul(m,l),l=n.add(l,d),new U(c,f,l)}subtract(t){return this.add(t.negate())}is0(){return this.equals(U.ZERO)}multiply(t){const{endo:r}=e;if(!i.isValidNot0(t))throw new Error("invalid scalar: out of range");let n,o;const s=t=>N.cached(this,t,t=>(0,a.normalizeZ)(U,t));if(r){const{k1neg:e,k1:i,k2neg:a,k2:u}=P(t),{p:c,f}=s(i),{p:l,f:h}=s(u);o=f.add(h),n=R(r.beta,c,l,e,a)}else{const{p:e,f:r}=s(t);n=e,o=r}return(0,a.normalizeZ)(U,[n,o])[0]}multiplyUnsafe(t){const{endo:r}=e,n=this;if(!i.isValid(t))throw new Error("invalid scalar: out of range");if(t===p||n.is0())return U.ZERO;if(t===d)return n;if(N.hasCache(this))return this.multiply(t);if(r){const{k1neg:e,k1:i,k2neg:o,k2:s}=P(t),{p1:u,p2:c}=(0,a.mulEndoUnsafe)(U,n,i,s);return R(r.beta,u,c,e,o)}return N.unsafe(n,t)}multiplyAndAddUnsafe(t,e,r){const n=this.multiplyUnsafe(e).add(t.multiplyUnsafe(r));return n.is0()?void 0:n}toAffine(t){return x(this,t)}isTorsionFree(){const{isTorsionFree:t}=e;return u===d||(t?t(U,this):N.unsafe(this,f).is0())}clearCofactor(){const{clearCofactor:t}=e;return u===d?this:t?t(U,this):this.multiplyUnsafe(u)}isSmallOrder(){return this.multiplyUnsafe(u).is0()}toBytes(t=!0){return(0,o._abool2)(t,"isCompressed"),this.assertValidity(),w(U,this,t)}toHex(t=!0){return(0,o.bytesToHex)(this.toBytes(t))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}get px(){return this.X}get py(){return this.X}get pz(){return this.Z}toRawBytes(t=!0){return this.toBytes(t)}_setWindowSize(t){this.precompute(t)}static normalizeZ(t){return(0,a.normalizeZ)(U,t)}static msm(t,e){return(0,a.pippenger)(U,i,t,e)}static fromPrivateKey(t){return U.BASE.multiply(v(i,t))}}U.BASE=new U(s.Gx,s.Gy,n.ONE),U.ZERO=new U(n.ZERO,n.ONE,n.ZERO),U.Fp=n,U.Fn=i;const j=i.BITS,N=new a.wNAF(U,e.endo?Math.ceil(j/2):j);return U.BASE.precompute(8),U}function m(t){return Uint8Array.of(t?2:3)}function S(t,e){const r=t.ORDER;let n=p;for(let t=r-d;t%y===p;t/=y)n+=d;const i=n,o=y<<i-d-d,a=o*y,s=(r-d)/a,u=(s-d)/y,c=a-d,f=o,l=t.pow(e,s),h=t.pow(e,(s+d)/y);let v=(e,r)=>{let n=l,o=t.pow(r,c),a=t.sqr(o);a=t.mul(a,r);let s=t.mul(e,a);s=t.pow(s,u),s=t.mul(s,o),o=t.mul(s,r),a=t.mul(s,e);let p=t.mul(a,o);s=t.pow(p,f);let b=t.eql(s,t.ONE);o=t.mul(a,h),s=t.mul(p,n),a=t.cmov(o,a,b),p=t.cmov(s,p,b);for(let e=i;e>d;e--){let r=e-y;r=y<<r-d;let i=t.pow(p,r);const s=t.eql(i,t.ONE);o=t.mul(a,n),n=t.mul(n,n),i=t.mul(p,n),a=t.cmov(o,a,s),p=t.cmov(i,p,s)}return{isValid:b,value:a}};if(t.ORDER%g===b){const r=(t.ORDER-b)/g,n=t.sqrt(t.neg(e));v=(e,i)=>{let o=t.sqr(i);const a=t.mul(e,i);o=t.mul(o,a);let s=t.pow(o,r);s=t.mul(s,a);const u=t.mul(s,n),c=t.mul(t.sqr(s),i),f=t.eql(c,e);return{isValid:f,value:t.cmov(u,s,f)}}}return v}function _(t,e){return{secretKey:e.BYTES,publicKey:1+t.BYTES,publicKeyUncompressed:1+2*t.BYTES,publicKeyHasPrefix:!0,signature:2*e.BYTES}}function E(t,e={}){const{Fn:r}=t,n=e.randomBytes||o.randomBytes,i=Object.assign(_(t.Fp,r),{seed:(0,s.getMinHashLength)(r.ORDER)});function a(t){try{return!!v(r,t)}catch(t){return!1}}function u(t=n(i.seed)){return(0,s.mapHashToField)((0,o._abytes2)(t,i.seed,"seed"),r.ORDER)}function c(e,n=!0){return t.BASE.multiply(v(r,e)).toBytes(n)}function f(e){if("bigint"==typeof e)return!1;if(e instanceof t)return!0;const{secretKey:n,publicKey:a,publicKeyUncompressed:s}=i;if(r.allowedLengths||n===a)return;const u=(0,o.ensureBytes)("key",e).length;return u===a||u===s}const l={isValidSecretKey:a,isValidPublicKey:function(e,r){const{publicKey:n,publicKeyUncompressed:o}=i;try{const i=e.length;return!(!0===r&&i!==n||!1===r&&i!==o||!t.fromBytes(e))}catch(t){return!1}},randomSecretKey:u,isValidPrivateKey:a,randomPrivateKey:u,normPrivateKeyToScalar:t=>v(r,t),precompute:(e=8,r=t.BASE)=>r.precompute(e,!1)};return Object.freeze({getPublicKey:c,getSharedSecret:function(e,n,i=!0){if(!0===f(e))throw new Error("first arg must be private key");if(!1===f(n))throw new Error("second arg must be public key");const o=v(r,e);return t.fromHex(n).multiply(o).toBytes(i)},keygen:function(t){const e=u(t);return{secretKey:e,publicKey:c(e)}},Point:t,utils:l,lengths:i})}function k(t,r,a={}){(0,i.ahash)(r),(0,o._validateObject)(a,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});const s=a.randomBytes||o.randomBytes,u=a.hmac||((t,...e)=>(0,n.hmac)(r,t,(0,o.concatBytes)(...e))),{Fp:c,Fn:h}=t,{ORDER:b,BITS:g}=h,{keygen:w,getPublicKey:S,getSharedSecret:_,utils:k,lengths:O}=E(t,a),T={prehash:!1,lowS:"boolean"==typeof a.lowS&&a.lowS,format:void 0,extraEntropy:!1},A="compact";function I(t){return t>b>>d}function P(t,e){if(!h.isValidNot0(e))throw new Error(`invalid signature ${t}: out of range 1..Point.Fn.ORDER`);return e}class x{constructor(t,e,r){this.r=P("r",t),this.s=P("s",e),null!=r&&(this.recovery=r),Object.freeze(this)}static fromBytes(t,r=A){let n;if(function(t,e){f(e);const r=O.signature,n="compact"===e?r:"recovered"===e?r+1:void 0;(0,o._abytes2)(t,n,`${e} signature`)}(t,r),"der"===r){const{r,s:n}=e.DER.toSig((0,o._abytes2)(t));return new x(r,n)}"recovered"===r&&(n=t[0],r="compact",t=t.subarray(1));const i=h.BYTES,a=t.subarray(0,i),s=t.subarray(i,2*i);return new x(h.fromBytes(a),h.fromBytes(s),n)}static fromHex(t,e){return this.fromBytes((0,o.hexToBytes)(t),e)}addRecoveryBit(t){return new x(this.r,this.s,t)}recoverPublicKey(e){const r=c.ORDER,{r:n,s:i,recovery:a}=this;if(null==a||![0,1,2,3].includes(a))throw new Error("recovery id invalid");if(b*y<r&&a>1)throw new Error("recovery id is ambiguous for h>1 curve");const s=2===a||3===a?n+b:n;if(!c.isValid(s))throw new Error("recovery id 2 or 3 invalid");const u=c.toBytes(s),f=t.fromBytes((0,o.concatBytes)(m(!(1&a)),u)),l=h.inv(s),p=R((0,o.ensureBytes)("msgHash",e)),d=h.create(-p*l),g=h.create(i*l),v=t.BASE.multiplyUnsafe(d).add(f.multiplyUnsafe(g));if(v.is0())throw new Error("point at infinify");return v.assertValidity(),v}hasHighS(){return I(this.s)}toBytes(t=A){if(f(t),"der"===t)return(0,o.hexToBytes)(e.DER.hexFromSig(this));const r=h.toBytes(this.r),n=h.toBytes(this.s);if("recovered"===t){if(null==this.recovery)throw new Error("recovery bit must be present");return(0,o.concatBytes)(Uint8Array.of(this.recovery),r,n)}return(0,o.concatBytes)(r,n)}toHex(t){return(0,o.bytesToHex)(this.toBytes(t))}assertValidity(){}static fromCompact(t){return x.fromBytes((0,o.ensureBytes)("sig",t),"compact")}static fromDER(t){return x.fromBytes((0,o.ensureBytes)("sig",t),"der")}normalizeS(){return this.hasHighS()?new x(this.r,h.neg(this.s),this.recovery):this}toDERRawBytes(){return this.toBytes("der")}toDERHex(){return(0,o.bytesToHex)(this.toBytes("der"))}toCompactRawBytes(){return this.toBytes("compact")}toCompactHex(){return(0,o.bytesToHex)(this.toBytes("compact"))}}const B=a.bits2int||function(t){if(t.length>8192)throw new Error("input is too large");const e=(0,o.bytesToNumberBE)(t),r=8*t.length-g;return r>0?e>>BigInt(r):e},R=a.bits2int_modN||function(t){return h.create(B(t))},U=(0,o.bitMask)(g);function j(t){return(0,o.aInRange)("num < 2^"+g,t,p,U),h.toBytes(t)}function N(t,e){return(0,o._abytes2)(t,void 0,"message"),e?(0,o._abytes2)(r(t),void 0,"prehashed message"):t}return Object.freeze({keygen:w,getPublicKey:S,getSharedSecret:_,utils:k,lengths:O,Point:t,sign:function(e,n,i={}){e=(0,o.ensureBytes)("message",e);const{seed:a,k2sig:c}=function(e,r,n){if(["recovered","canonical"].some(t=>t in n))throw new Error("sign() legacy options not supported");const{lowS:i,prehash:a,extraEntropy:u}=l(n,T);e=N(e,a);const c=R(e),f=v(h,r),y=[j(f),j(c)];if(null!=u&&!1!==u){const t=!0===u?s(O.secretKey):u;y.push((0,o.ensureBytes)("extraEntropy",t))}const b=(0,o.concatBytes)(...y),g=c;return{seed:b,k2sig:function(e){const r=B(e);if(!h.isValidNot0(r))return;const n=h.inv(r),o=t.BASE.multiply(r).toAffine(),a=h.create(o.x);if(a===p)return;const s=h.create(n*h.create(g+a*f));if(s===p)return;let u=(o.x===a?0:2)|Number(o.y&d),c=s;return i&&I(s)&&(c=h.neg(s),u^=1),new x(a,c,u)}}}(e,n,i);return(0,o.createHmacDrbg)(r.outputLen,h.BYTES,u)(a,c)},verify:function(r,n,i,a={}){const{lowS:s,prehash:u,format:c}=l(a,T);if(i=(0,o.ensureBytes)("publicKey",i),n=N((0,o.ensureBytes)("message",n),u),"strict"in a)throw new Error("options.strict was renamed to lowS");const f=void 0===c?function(t){let r;const n="string"==typeof t||(0,o.isBytes)(t),i=!n&&null!==t&&"object"==typeof t&&"bigint"==typeof t.r&&"bigint"==typeof t.s;if(!n&&!i)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");if(i)r=new x(t.r,t.s);else if(n){try{r=x.fromBytes((0,o.ensureBytes)("sig",t),"der")}catch(t){if(!(t instanceof e.DER.Err))throw t}if(!r)try{r=x.fromBytes((0,o.ensureBytes)("sig",t),"compact")}catch(t){return!1}}return r||!1}(r):x.fromBytes((0,o.ensureBytes)("sig",r),c);if(!1===f)return!1;try{const e=t.fromBytes(i);if(s&&f.hasHighS())return!1;const{r,s:o}=f,a=R(n),u=h.inv(o),c=h.create(a*u),l=h.create(r*u),p=t.BASE.multiplyUnsafe(c).add(e.multiplyUnsafe(l));return!p.is0()&&h.create(p.x)===r}catch(t){return!1}},recoverPublicKey:function(t,e,r={}){const{prehash:n}=l(r,T);return e=N(e,n),x.fromBytes(t,"recovered").recoverPublicKey(e).toBytes()},Signature:x,hash:r})}function O(t){const e={a:t.a,b:t.b,p:t.Fp.ORDER,n:t.n,h:t.h,Gx:t.Gx,Gy:t.Gy},r=t.Fp;let n=t.allowedPrivateKeyLengths?Array.from(new Set(t.allowedPrivateKeyLengths.map(t=>Math.ceil(t/2)))):void 0;return{CURVE:e,curveOpts:{Fp:r,Fn:(0,s.Field)(e.n,{BITS:t.nBitLength,allowedLengths:n,modFromBytes:t.wrapPrivateKey}),allowInfinityPoint:t.allowInfinityPoint,endo:t.endo,isTorsionFree:t.isTorsionFree,clearCofactor:t.clearCofactor,fromBytes:t.fromBytes,toBytes:t.toBytes}}}function T(t,e,r){return function(n){const i=t.sqr(n),o=t.mul(i,n);return t.add(t.add(o,t.mul(n,e)),r)}}},1761:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e._DST_scalar=void 0,e.expand_message_xmd=f,e.expand_message_xof=l,e.hash_to_field=h,e.isogenyMap=function(t,e){const r=e.map(t=>Array.from(t).reverse());return(e,n)=>{const[o,a,s,u]=r.map(r=>r.reduce((r,n)=>t.add(t.mul(r,e),n))),[c,f]=(0,i.FpInvertBatch)(t,[a,u],!0);return e=t.mul(o,c),n=t.mul(n,t.mul(s,f)),{x:e,y:n}}},e.createHasher=function(t,r,n){if("function"!=typeof r)throw new Error("mapToCurve() must be defined");function i(e){return t.fromAffine(r(e))}function o(e){const r=e.clearCofactor();return r.equals(t.ZERO)?t.ZERO:(r.assertValidity(),r)}return{defaults:n,hashToCurve(t,e){const r=h(t,2,Object.assign({},n,e)),a=i(r[0]),s=i(r[1]);return o(a.add(s))},encodeToCurve(t,e){const r=n.encodeDST?{DST:n.encodeDST}:{};return o(i(h(t,1,Object.assign({},n,r,e))[0]))},mapToCurve(t){if(!Array.isArray(t))throw new Error("expected array of bigints");for(const e of t)if("bigint"!=typeof e)throw new Error("expected array of bigints");return o(i(t))},hashToScalar(r,i){const o=t.Fn.ORDER;return h(r,1,Object.assign({},n,{p:o,m:1,DST:e._DST_scalar},i))[0][0]}}};const n=r(8627),i=r(4967),o=n.bytesToNumberBE;function a(t,e){if(u(t),u(e),t<0||t>=1<<8*e)throw new Error("invalid I2OSP input: "+t);const r=Array.from({length:e}).fill(0);for(let n=e-1;n>=0;n--)r[n]=255&t,t>>>=8;return new Uint8Array(r)}function s(t,e){const r=new Uint8Array(t.length);for(let n=0;n<t.length;n++)r[n]=t[n]^e[n];return r}function u(t){if(!Number.isSafeInteger(t))throw new Error("number expected")}function c(t){if(!(0,n.isBytes)(t)&&"string"!=typeof t)throw new Error("DST must be Uint8Array or string");return"string"==typeof t?(0,n.utf8ToBytes)(t):t}function f(t,e,r,i){(0,n.abytes)(t),u(r),(e=c(e)).length>255&&(e=i((0,n.concatBytes)((0,n.utf8ToBytes)("H2C-OVERSIZE-DST-"),e)));const{outputLen:o,blockLen:f}=i,l=Math.ceil(r/o);if(r>65535||l>255)throw new Error("expand_message_xmd: invalid lenInBytes");const h=(0,n.concatBytes)(e,a(e.length,1)),p=a(0,f),d=a(r,2),y=new Array(l),b=i((0,n.concatBytes)(p,t,d,a(0,1),h));y[0]=i((0,n.concatBytes)(b,a(1,1),h));for(let t=1;t<=l;t++){const e=[s(b,y[t-1]),a(t+1,1),h];y[t]=i((0,n.concatBytes)(...e))}return(0,n.concatBytes)(...y).slice(0,r)}function l(t,e,r,i,o){if((0,n.abytes)(t),u(r),(e=c(e)).length>255){const t=Math.ceil(2*i/8);e=o.create({dkLen:t}).update((0,n.utf8ToBytes)("H2C-OVERSIZE-DST-")).update(e).digest()}if(r>65535||e.length>255)throw new Error("expand_message_xof: invalid lenInBytes");return o.create({dkLen:r}).update(t).update(a(r,2)).update(e).update(a(e.length,1)).digest()}function h(t,e,r){(0,n._validateObject)(r,{p:"bigint",m:"number",k:"number",hash:"function"});const{p:a,k:s,m:c,hash:h,expand:p,DST:d}=r;if(!(0,n.isHash)(r.hash))throw new Error("expected valid hash");(0,n.abytes)(t),u(e);const y=a.toString(2).length,b=Math.ceil((y+s)/8),g=e*c*b;let v;if("xmd"===p)v=f(t,d,g,h);else if("xof"===p)v=l(t,d,g,s,h);else{if("_internal_pass"!==p)throw new Error('expand must be "xmd" or "xof"');v=t}const w=new Array(e);for(let t=0;t<e;t++){const e=new Array(c);for(let r=0;r<c;r++){const n=b*(r+t*c),s=v.subarray(n,n+b);e[r]=(0,i.mod)(o(s),a)}w[t]=e}return w}e._DST_scalar=(0,n.utf8ToBytes)("HashToScalar-")},1766:(t,e,r)=>{function n(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function i(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?n(Object(r),!0).forEach(function(e){o(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):n(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function o(t,e,r){return(e=s(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function a(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,s(n.key),n)}}function s(t){var e=function(t){if("object"!=typeof t||null===t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==typeof e?e:String(e)}var u=r(8287).Buffer,c=r(3779).inspect,f=c&&c.custom||"inspect";function l(t,e,r){u.prototype.copy.call(t,e,r)}t.exports=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.head=null,this.tail=null,this.length=0}var e,r;return e=t,r=[{key:"push",value:function(t){var e={data:t,next:null};this.length>0?this.tail.next=e:this.head=e,this.tail=e,++this.length}},{key:"unshift",value:function(t){var e={data:t,next:this.head};0===this.length&&(this.tail=e),this.head=e,++this.length}},{key:"shift",value:function(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(t){if(0===this.length)return"";for(var e=this.head,r=""+e.data;e=e.next;)r+=t+e.data;return r}},{key:"concat",value:function(t){if(0===this.length)return u.alloc(0);for(var e=u.allocUnsafe(t>>>0),r=this.head,n=0;r;)l(r.data,e,n),n+=r.data.length,r=r.next;return e}},{key:"consume",value:function(t,e){var r;return t<this.head.data.length?(r=this.head.data.slice(0,t),this.head.data=this.head.data.slice(t)):r=t===this.head.data.length?this.shift():e?this._getString(t):this._getBuffer(t),r}},{key:"first",value:function(){return this.head.data}},{key:"_getString",value:function(t){var e=this.head,r=1,n=e.data;for(t-=n.length;e=e.next;){var i=e.data,o=t>i.length?i.length:t;if(o===i.length?n+=i:n+=i.slice(0,t),0===(t-=o)){o===i.length?(++r,e.next?this.head=e.next:this.head=this.tail=null):(this.head=e,e.data=i.slice(o));break}++r}return this.length-=r,n}},{key:"_getBuffer",value:function(t){var e=u.allocUnsafe(t),r=this.head,n=1;for(r.data.copy(e),t-=r.data.length;r=r.next;){var i=r.data,o=t>i.length?i.length:t;if(i.copy(e,e.length-t,0,o),0===(t-=o)){o===i.length?(++n,r.next?this.head=r.next:this.head=this.tail=null):(this.head=r,r.data=i.slice(o));break}++n}return this.length-=n,e}},{key:f,value:function(t,e){return c(this,i(i({},e),{},{depth:0,customInspect:!1}))}}],r&&a(e.prototype,r),Object.defineProperty(e,"prototype",{writable:!1}),t}()},1998:(t,e,r)=>{var n=r(9805),i=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],o=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],a=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],s=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];t.exports=function(t,e,r,u,c,f,l,h){var p,d,y,b,g,v,w,m,S,_=h.bits,E=0,k=0,O=0,T=0,A=0,I=0,P=0,x=0,B=0,R=0,U=null,j=0,N=new n.Buf16(16),L=new n.Buf16(16),C=null,F=0;for(E=0;E<=15;E++)N[E]=0;for(k=0;k<u;k++)N[e[r+k]]++;for(A=_,T=15;T>=1&&0===N[T];T--);if(A>T&&(A=T),0===T)return c[f++]=20971520,c[f++]=20971520,h.bits=1,0;for(O=1;O<T&&0===N[O];O++);for(A<O&&(A=O),x=1,E=1;E<=15;E++)if(x<<=1,(x-=N[E])<0)return-1;if(x>0&&(0===t||1!==T))return-1;for(L[1]=0,E=1;E<15;E++)L[E+1]=L[E]+N[E];for(k=0;k<u;k++)0!==e[r+k]&&(l[L[e[r+k]]++]=k);if(0===t?(U=C=l,v=19):1===t?(U=i,j-=257,C=o,F-=257,v=256):(U=a,C=s,v=-1),R=0,k=0,E=O,g=f,I=A,P=0,y=-1,b=(B=1<<A)-1,1===t&&B>852||2===t&&B>592)return 1;for(;;){w=E-P,l[k]<v?(m=0,S=l[k]):l[k]>v?(m=C[F+l[k]],S=U[j+l[k]]):(m=96,S=0),p=1<<E-P,O=d=1<<I;do{c[g+(R>>P)+(d-=p)]=w<<24|m<<16|S}while(0!==d);for(p=1<<E-1;R&p;)p>>=1;if(0!==p?(R&=p-1,R+=p):R=0,k++,0===--N[E]){if(E===T)break;E=e[r+l[k]]}if(E>A&&(R&b)!==y){for(0===P&&(P=A),g+=O,x=1<<(I=E-P);I+P<T&&!((x-=N[I+P])<=0);)I++,x<<=1;if(B+=1<<I,1===t&&B>852||2===t&&B>592)return 1;c[y=R&b]=A<<24|I<<16|g-f}}return 0!==R&&(c[g+R]=E-P<<24|64<<16),h.bits=A,0}},1999:(t,e,r)=>{var n,i=r(5606);function o(t){var e=this;this.next=null,this.entry=null,this.finish=function(){!function(t,e){var r=t.entry;for(t.entry=null;r;){var n=r.callback;e.pendingcb--,n(undefined),r=r.next}e.corkedRequestsFree.next=t}(e,t)}}t.exports=O,O.WritableState=k;var a,s={deprecate:r(4643)},u=r(1396),c=r(8287).Buffer,f=(void 0!==r.g?r.g:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{}).Uint8Array||function(){},l=r(4347),h=r(6644).getHighWaterMark,p=r(2463).F,d=p.ERR_INVALID_ARG_TYPE,y=p.ERR_METHOD_NOT_IMPLEMENTED,b=p.ERR_MULTIPLE_CALLBACK,g=p.ERR_STREAM_CANNOT_PIPE,v=p.ERR_STREAM_DESTROYED,w=p.ERR_STREAM_NULL_VALUES,m=p.ERR_STREAM_WRITE_AFTER_END,S=p.ERR_UNKNOWN_ENCODING,_=l.errorOrDestroy;function E(){}function k(t,e,a){n=n||r(8101),t=t||{},"boolean"!=typeof a&&(a=e instanceof n),this.objectMode=!!t.objectMode,a&&(this.objectMode=this.objectMode||!!t.writableObjectMode),this.highWaterMark=h(this,t,"writableHighWaterMark",a),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var s=!1===t.decodeStrings;this.decodeStrings=!s,this.defaultEncoding=t.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(t){!function(t,e){var r=t._writableState,n=r.sync,o=r.writecb;if("function"!=typeof o)throw new b;if(function(t){t.writing=!1,t.writecb=null,t.length-=t.writelen,t.writelen=0}(r),e)!function(t,e,r,n,o){--e.pendingcb,r?(i.nextTick(o,n),i.nextTick(B,t,e),t._writableState.errorEmitted=!0,_(t,n)):(o(n),t._writableState.errorEmitted=!0,_(t,n),B(t,e))}(t,r,n,e,o);else{var a=P(r)||t.destroyed;a||r.corked||r.bufferProcessing||!r.bufferedRequest||I(t,r),n?i.nextTick(A,t,r,a,o):A(t,r,a,o)}}(e,t)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=!1!==t.emitClose,this.autoDestroy=!!t.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new o(this)}function O(t){var e=this instanceof(n=n||r(8101));if(!e&&!a.call(O,this))return new O(t);this._writableState=new k(t,this,e),this.writable=!0,t&&("function"==typeof t.write&&(this._write=t.write),"function"==typeof t.writev&&(this._writev=t.writev),"function"==typeof t.destroy&&(this._destroy=t.destroy),"function"==typeof t.final&&(this._final=t.final)),u.call(this)}function T(t,e,r,n,i,o,a){e.writelen=n,e.writecb=a,e.writing=!0,e.sync=!0,e.destroyed?e.onwrite(new v("write")):r?t._writev(i,e.onwrite):t._write(i,o,e.onwrite),e.sync=!1}function A(t,e,r,n){r||function(t,e){0===e.length&&e.needDrain&&(e.needDrain=!1,t.emit("drain"))}(t,e),e.pendingcb--,n(),B(t,e)}function I(t,e){e.bufferProcessing=!0;var r=e.bufferedRequest;if(t._writev&&r&&r.next){var n=e.bufferedRequestCount,i=new Array(n),a=e.corkedRequestsFree;a.entry=r;for(var s=0,u=!0;r;)i[s]=r,r.isBuf||(u=!1),r=r.next,s+=1;i.allBuffers=u,T(t,e,!0,e.length,i,"",a.finish),e.pendingcb++,e.lastBufferedRequest=null,a.next?(e.corkedRequestsFree=a.next,a.next=null):e.corkedRequestsFree=new o(e),e.bufferedRequestCount=0}else{for(;r;){var c=r.chunk,f=r.encoding,l=r.callback;if(T(t,e,!1,e.objectMode?1:c.length,c,f,l),r=r.next,e.bufferedRequestCount--,e.writing)break}null===r&&(e.lastBufferedRequest=null)}e.bufferedRequest=r,e.bufferProcessing=!1}function P(t){return t.ending&&0===t.length&&null===t.bufferedRequest&&!t.finished&&!t.writing}function x(t,e){t._final(function(r){e.pendingcb--,r&&_(t,r),e.prefinished=!0,t.emit("prefinish"),B(t,e)})}function B(t,e){var r=P(e);if(r&&(function(t,e){e.prefinished||e.finalCalled||("function"!=typeof t._final||e.destroyed?(e.prefinished=!0,t.emit("prefinish")):(e.pendingcb++,e.finalCalled=!0,i.nextTick(x,t,e)))}(t,e),0===e.pendingcb&&(e.finished=!0,t.emit("finish"),e.autoDestroy))){var n=t._readableState;(!n||n.autoDestroy&&n.endEmitted)&&t.destroy()}return r}r(6698)(O,u),k.prototype.getBuffer=function(){for(var t=this.bufferedRequest,e=[];t;)e.push(t),t=t.next;return e},function(){try{Object.defineProperty(k.prototype,"buffer",{get:s.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(t){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(a=Function.prototype[Symbol.hasInstance],Object.defineProperty(O,Symbol.hasInstance,{value:function(t){return!!a.call(this,t)||this===O&&t&&t._writableState instanceof k}})):a=function(t){return t instanceof this},O.prototype.pipe=function(){_(this,new g)},O.prototype.write=function(t,e,r){var n,o=this._writableState,a=!1,s=!o.objectMode&&(n=t,c.isBuffer(n)||n instanceof f);return s&&!c.isBuffer(t)&&(t=function(t){return c.from(t)}(t)),"function"==typeof e&&(r=e,e=null),s?e="buffer":e||(e=o.defaultEncoding),"function"!=typeof r&&(r=E),o.ending?function(t,e){var r=new m;_(t,r),i.nextTick(e,r)}(this,r):(s||function(t,e,r,n){var o;return null===r?o=new w:"string"==typeof r||e.objectMode||(o=new d("chunk",["string","Buffer"],r)),!o||(_(t,o),i.nextTick(n,o),!1)}(this,o,t,r))&&(o.pendingcb++,a=function(t,e,r,n,i,o){if(!r){var a=function(t,e,r){return t.objectMode||!1===t.decodeStrings||"string"!=typeof e||(e=c.from(e,r)),e}(e,n,i);n!==a&&(r=!0,i="buffer",n=a)}var s=e.objectMode?1:n.length;e.length+=s;var u=e.length<e.highWaterMark;if(u||(e.needDrain=!0),e.writing||e.corked){var f=e.lastBufferedRequest;e.lastBufferedRequest={chunk:n,encoding:i,isBuf:r,callback:o,next:null},f?f.next=e.lastBufferedRequest:e.bufferedRequest=e.lastBufferedRequest,e.bufferedRequestCount+=1}else T(t,e,!1,s,n,i,o);return u}(this,o,s,t,e,r)),a},O.prototype.cork=function(){this._writableState.corked++},O.prototype.uncork=function(){var t=this._writableState;t.corked&&(t.corked--,t.writing||t.corked||t.bufferProcessing||!t.bufferedRequest||I(this,t))},O.prototype.setDefaultEncoding=function(t){if("string"==typeof t&&(t=t.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((t+"").toLowerCase())>-1))throw new S(t);return this._writableState.defaultEncoding=t,this},Object.defineProperty(O.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(O.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),O.prototype._write=function(t,e,r){r(new y("_write()"))},O.prototype._writev=null,O.prototype.end=function(t,e,r){var n=this._writableState;return"function"==typeof t?(r=t,t=null,e=null):"function"==typeof e&&(r=e,e=null),null!=t&&this.write(t,e),n.corked&&(n.corked=1,this.uncork()),n.ending||function(t,e,r){e.ending=!0,B(t,e),r&&(e.finished?i.nextTick(r):t.once("finish",r)),e.ended=!0,t.writable=!1}(this,n,r),this},Object.defineProperty(O.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(O.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(t){this._writableState&&(this._writableState.destroyed=t)}}),O.prototype.destroy=l.destroy,O.prototype._undestroy=l.undestroy,O.prototype._destroy=function(t,e){e(t)}},2006:t=>{var e={}.toString;t.exports=Array.isArray||function(t){return"[object Array]"==e.call(t)}},2113:t=>{var e={Array:function(t){return null!=t&&t.constructor===Array},Boolean:function(t){return"boolean"==typeof t},Function:function(t){return"function"==typeof t},Nil:function(t){return null==t},Number:function(t){return"number"==typeof t},Object:function(t){return"object"==typeof t},String:function(t){return"string"==typeof t},"":function(){return!0}};for(var r in e.Null=e.Nil,e)e[r].toJSON=function(t){return t}.bind(null,r);t.exports=e},2192:(t,e,r)=>{var n,i=r(5606);function o(t){var e=this;this.next=null,this.entry=null,this.finish=function(){!function(t,e){var r=t.entry;for(t.entry=null;r;){var n=r.callback;e.pendingcb--,n(undefined),r=r.next}e.corkedRequestsFree.next=t}(e,t)}}t.exports=O,O.WritableState=k;var a,s={deprecate:r(4643)},u=r(1181),c=r(8287).Buffer,f=(void 0!==r.g?r.g:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{}).Uint8Array||function(){},l=r(1468),h=r(8775).getHighWaterMark,p=r(2260).F,d=p.ERR_INVALID_ARG_TYPE,y=p.ERR_METHOD_NOT_IMPLEMENTED,b=p.ERR_MULTIPLE_CALLBACK,g=p.ERR_STREAM_CANNOT_PIPE,v=p.ERR_STREAM_DESTROYED,w=p.ERR_STREAM_NULL_VALUES,m=p.ERR_STREAM_WRITE_AFTER_END,S=p.ERR_UNKNOWN_ENCODING,_=l.errorOrDestroy;function E(){}function k(t,e,a){n=n||r(2818),t=t||{},"boolean"!=typeof a&&(a=e instanceof n),this.objectMode=!!t.objectMode,a&&(this.objectMode=this.objectMode||!!t.writableObjectMode),this.highWaterMark=h(this,t,"writableHighWaterMark",a),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var s=!1===t.decodeStrings;this.decodeStrings=!s,this.defaultEncoding=t.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(t){!function(t,e){var r=t._writableState,n=r.sync,o=r.writecb;if("function"!=typeof o)throw new b;if(function(t){t.writing=!1,t.writecb=null,t.length-=t.writelen,t.writelen=0}(r),e)!function(t,e,r,n,o){--e.pendingcb,r?(i.nextTick(o,n),i.nextTick(B,t,e),t._writableState.errorEmitted=!0,_(t,n)):(o(n),t._writableState.errorEmitted=!0,_(t,n),B(t,e))}(t,r,n,e,o);else{var a=P(r)||t.destroyed;a||r.corked||r.bufferProcessing||!r.bufferedRequest||I(t,r),n?i.nextTick(A,t,r,a,o):A(t,r,a,o)}}(e,t)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=!1!==t.emitClose,this.autoDestroy=!!t.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new o(this)}function O(t){var e=this instanceof(n=n||r(2818));if(!e&&!a.call(O,this))return new O(t);this._writableState=new k(t,this,e),this.writable=!0,t&&("function"==typeof t.write&&(this._write=t.write),"function"==typeof t.writev&&(this._writev=t.writev),"function"==typeof t.destroy&&(this._destroy=t.destroy),"function"==typeof t.final&&(this._final=t.final)),u.call(this)}function T(t,e,r,n,i,o,a){e.writelen=n,e.writecb=a,e.writing=!0,e.sync=!0,e.destroyed?e.onwrite(new v("write")):r?t._writev(i,e.onwrite):t._write(i,o,e.onwrite),e.sync=!1}function A(t,e,r,n){r||function(t,e){0===e.length&&e.needDrain&&(e.needDrain=!1,t.emit("drain"))}(t,e),e.pendingcb--,n(),B(t,e)}function I(t,e){e.bufferProcessing=!0;var r=e.bufferedRequest;if(t._writev&&r&&r.next){var n=e.bufferedRequestCount,i=new Array(n),a=e.corkedRequestsFree;a.entry=r;for(var s=0,u=!0;r;)i[s]=r,r.isBuf||(u=!1),r=r.next,s+=1;i.allBuffers=u,T(t,e,!0,e.length,i,"",a.finish),e.pendingcb++,e.lastBufferedRequest=null,a.next?(e.corkedRequestsFree=a.next,a.next=null):e.corkedRequestsFree=new o(e),e.bufferedRequestCount=0}else{for(;r;){var c=r.chunk,f=r.encoding,l=r.callback;if(T(t,e,!1,e.objectMode?1:c.length,c,f,l),r=r.next,e.bufferedRequestCount--,e.writing)break}null===r&&(e.lastBufferedRequest=null)}e.bufferedRequest=r,e.bufferProcessing=!1}function P(t){return t.ending&&0===t.length&&null===t.bufferedRequest&&!t.finished&&!t.writing}function x(t,e){t._final(function(r){e.pendingcb--,r&&_(t,r),e.prefinished=!0,t.emit("prefinish"),B(t,e)})}function B(t,e){var r=P(e);if(r&&(function(t,e){e.prefinished||e.finalCalled||("function"!=typeof t._final||e.destroyed?(e.prefinished=!0,t.emit("prefinish")):(e.pendingcb++,e.finalCalled=!0,i.nextTick(x,t,e)))}(t,e),0===e.pendingcb&&(e.finished=!0,t.emit("finish"),e.autoDestroy))){var n=t._readableState;(!n||n.autoDestroy&&n.endEmitted)&&t.destroy()}return r}r(6698)(O,u),k.prototype.getBuffer=function(){for(var t=this.bufferedRequest,e=[];t;)e.push(t),t=t.next;return e},function(){try{Object.defineProperty(k.prototype,"buffer",{get:s.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(t){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(a=Function.prototype[Symbol.hasInstance],Object.defineProperty(O,Symbol.hasInstance,{value:function(t){return!!a.call(this,t)||this===O&&t&&t._writableState instanceof k}})):a=function(t){return t instanceof this},O.prototype.pipe=function(){_(this,new g)},O.prototype.write=function(t,e,r){var n,o=this._writableState,a=!1,s=!o.objectMode&&(n=t,c.isBuffer(n)||n instanceof f);return s&&!c.isBuffer(t)&&(t=function(t){return c.from(t)}(t)),"function"==typeof e&&(r=e,e=null),s?e="buffer":e||(e=o.defaultEncoding),"function"!=typeof r&&(r=E),o.ending?function(t,e){var r=new m;_(t,r),i.nextTick(e,r)}(this,r):(s||function(t,e,r,n){var o;return null===r?o=new w:"string"==typeof r||e.objectMode||(o=new d("chunk",["string","Buffer"],r)),!o||(_(t,o),i.nextTick(n,o),!1)}(this,o,t,r))&&(o.pendingcb++,a=function(t,e,r,n,i,o){if(!r){var a=function(t,e,r){return t.objectMode||!1===t.decodeStrings||"string"!=typeof e||(e=c.from(e,r)),e}(e,n,i);n!==a&&(r=!0,i="buffer",n=a)}var s=e.objectMode?1:n.length;e.length+=s;var u=e.length<e.highWaterMark;if(u||(e.needDrain=!0),e.writing||e.corked){var f=e.lastBufferedRequest;e.lastBufferedRequest={chunk:n,encoding:i,isBuf:r,callback:o,next:null},f?f.next=e.lastBufferedRequest:e.bufferedRequest=e.lastBufferedRequest,e.bufferedRequestCount+=1}else T(t,e,!1,s,n,i,o);return u}(this,o,s,t,e,r)),a},O.prototype.cork=function(){this._writableState.corked++},O.prototype.uncork=function(){var t=this._writableState;t.corked&&(t.corked--,t.writing||t.corked||t.bufferProcessing||!t.bufferedRequest||I(this,t))},O.prototype.setDefaultEncoding=function(t){if("string"==typeof t&&(t=t.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((t+"").toLowerCase())>-1))throw new S(t);return this._writableState.defaultEncoding=t,this},Object.defineProperty(O.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(O.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),O.prototype._write=function(t,e,r){r(new y("_write()"))},O.prototype._writev=null,O.prototype.end=function(t,e,r){var n=this._writableState;return"function"==typeof t?(r=t,t=null,e=null):"function"==typeof e&&(r=e,e=null),null!=t&&this.write(t,e),n.corked&&(n.corked=1,this.uncork()),n.ending||function(t,e,r){e.ending=!0,B(t,e),r&&(e.finished?i.nextTick(r):t.once("finish",r)),e.ended=!0,t.writable=!1}(this,n,r),this},Object.defineProperty(O.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(O.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(t){this._writableState&&(this._writableState.destroyed=t)}}),O.prototype.destroy=l.destroy,O.prototype._undestroy=l.undestroy,O.prototype._destroy=function(t,e){e(t)}},2205:(t,e,r)=>{var n=r(6743),i=r(1002),o=r(3144);t.exports=function(){return o(n,i,arguments)}},2260:t=>{var e={};function r(t,r,n){n||(n=Error);var i=function(t){var e,n;function i(e,n,i){return t.call(this,function(t,e,n){return"string"==typeof r?r:r(t,e,n)}(e,n,i))||this}return n=t,(e=i).prototype=Object.create(n.prototype),e.prototype.constructor=e,e.__proto__=n,i}(n);i.prototype.name=n.name,i.prototype.code=t,e[t]=i}function n(t,e){if(Array.isArray(t)){var r=t.length;return t=t.map(function(t){return String(t)}),r>2?"one of ".concat(e," ").concat(t.slice(0,r-1).join(", "),", or ")+t[r-1]:2===r?"one of ".concat(e," ").concat(t[0]," or ").concat(t[1]):"of ".concat(e," ").concat(t[0])}return"of ".concat(e," ").concat(String(t))}r("ERR_INVALID_OPT_VALUE",function(t,e){return'The value "'+e+'" is invalid for option "'+t+'"'},TypeError),r("ERR_INVALID_ARG_TYPE",function(t,e,r){var i,o,a;if("string"==typeof e&&(a="not ",e.substr(0,4)===a)?(i="must not be",e=e.replace(/^not /,"")):i="must be",function(t,e,r){return(void 0===r||r>t.length)&&(r=t.length),t.substring(r-9,r)===e}(t," argument"))o="The ".concat(t," ").concat(i," ").concat(n(e,"type"));else{var s=function(t,e,r){return"number"!=typeof r&&(r=0),!(r+1>t.length)&&-1!==t.indexOf(".",r)}(t)?"property":"argument";o='The "'.concat(t,'" ').concat(s," ").concat(i," ").concat(n(e,"type"))}return o+". Received type ".concat(typeof r)},TypeError),r("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),r("ERR_METHOD_NOT_IMPLEMENTED",function(t){return"The "+t+" method is not implemented"}),r("ERR_STREAM_PREMATURE_CLOSE","Premature close"),r("ERR_STREAM_DESTROYED",function(t){return"Cannot call "+t+" after a stream was destroyed"}),r("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),r("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),r("ERR_STREAM_WRITE_AFTER_END","write after end"),r("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),r("ERR_UNKNOWN_ENCODING",function(t){return"Unknown encoding: "+t},TypeError),r("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),t.exports.F=e},2299:(t,e,r)=>{function n(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,i,o,a,s=[],u=!0,c=!1;try{if(o=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=o.call(r)).done)&&(s.push(n.value),s.length!==e);u=!0);}catch(t){c=!0,i=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(c)throw i}}return s}}(t,e)||function(t,e){if(t){if("string"==typeof t)return i(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?i(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function i(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function o(t){return o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},o(t)}var a=void 0!==/a/g.flags,s=function(t){var e=[];return t.forEach(function(t){return e.push(t)}),e},u=function(t){var e=[];return t.forEach(function(t,r){return e.push([r,t])}),e},c=Object.is?Object.is:r(7653),f=Object.getOwnPropertySymbols?Object.getOwnPropertySymbols:function(){return[]},l=Number.isNaN?Number.isNaN:r(4133);function h(t){return t.call.bind(t)}var p=h(Object.prototype.hasOwnProperty),d=h(Object.prototype.propertyIsEnumerable),y=h(Object.prototype.toString),b=r(537).types,g=b.isAnyArrayBuffer,v=b.isArrayBufferView,w=b.isDate,m=b.isMap,S=b.isRegExp,_=b.isSet,E=b.isNativeError,k=b.isBoxedPrimitive,O=b.isNumberObject,T=b.isStringObject,A=b.isBooleanObject,I=b.isBigIntObject,P=b.isSymbolObject,x=b.isFloat32Array,B=b.isFloat64Array;function R(t){if(0===t.length||t.length>10)return!0;for(var e=0;e<t.length;e++){var r=t.charCodeAt(e);if(r<48||r>57)return!0}return 10===t.length&&t>=Math.pow(2,32)}function U(t){return Object.keys(t).filter(R).concat(f(t).filter(Object.prototype.propertyIsEnumerable.bind(t)))}function j(t,e){if(t===e)return 0;for(var r=t.length,n=e.length,i=0,o=Math.min(r,n);i<o;++i)if(t[i]!==e[i]){r=t[i],n=e[i];break}return r<n?-1:n<r?1:0}function N(t,e,r,n){if(t===e)return 0!==t||!r||c(t,e);if(r){if("object"!==o(t))return"number"==typeof t&&l(t)&&l(e);if("object"!==o(e)||null===t||null===e)return!1;if(Object.getPrototypeOf(t)!==Object.getPrototypeOf(e))return!1}else{if(null===t||"object"!==o(t))return(null===e||"object"!==o(e))&&t==e;if(null===e||"object"!==o(e))return!1}var i,s,u=y(t);if(u!==y(e))return!1;if(Array.isArray(t)){if(t.length!==e.length)return!1;var f=U(t),h=U(e);return f.length===h.length&&C(t,e,r,n,1,f)}if("[object Object]"===u&&(!m(t)&&m(e)||!_(t)&&_(e)))return!1;if(w(t)){if(!w(e)||Date.prototype.getTime.call(t)!==Date.prototype.getTime.call(e))return!1}else if(S(t)){if(!S(e)||!function(t,e){return a?t.source===e.source&&t.flags===e.flags:RegExp.prototype.toString.call(t)===RegExp.prototype.toString.call(e)}(t,e))return!1}else if(E(t)||t instanceof Error){if(t.message!==e.message||t.name!==e.name)return!1}else{if(v(t)){if(r||!x(t)&&!B(t)){if(!function(t,e){return t.byteLength===e.byteLength&&0===j(new Uint8Array(t.buffer,t.byteOffset,t.byteLength),new Uint8Array(e.buffer,e.byteOffset,e.byteLength))}(t,e))return!1}else if(!function(t,e){if(t.byteLength!==e.byteLength)return!1;for(var r=0;r<t.byteLength;r++)if(t[r]!==e[r])return!1;return!0}(t,e))return!1;var p=U(t),d=U(e);return p.length===d.length&&C(t,e,r,n,0,p)}if(_(t))return!(!_(e)||t.size!==e.size)&&C(t,e,r,n,2);if(m(t))return!(!m(e)||t.size!==e.size)&&C(t,e,r,n,3);if(g(t)){if(s=e,(i=t).byteLength!==s.byteLength||0!==j(new Uint8Array(i),new Uint8Array(s)))return!1}else if(k(t)&&!function(t,e){return O(t)?O(e)&&c(Number.prototype.valueOf.call(t),Number.prototype.valueOf.call(e)):T(t)?T(e)&&String.prototype.valueOf.call(t)===String.prototype.valueOf.call(e):A(t)?A(e)&&Boolean.prototype.valueOf.call(t)===Boolean.prototype.valueOf.call(e):I(t)?I(e)&&BigInt.prototype.valueOf.call(t)===BigInt.prototype.valueOf.call(e):P(e)&&Symbol.prototype.valueOf.call(t)===Symbol.prototype.valueOf.call(e)}(t,e))return!1}return C(t,e,r,n,0)}function L(t,e){return e.filter(function(e){return d(t,e)})}function C(t,e,r,i,a,c){if(5===arguments.length){c=Object.keys(t);var l=Object.keys(e);if(c.length!==l.length)return!1}for(var h=0;h<c.length;h++)if(!p(e,c[h]))return!1;if(r&&5===arguments.length){var y=f(t);if(0!==y.length){var b=0;for(h=0;h<y.length;h++){var g=y[h];if(d(t,g)){if(!d(e,g))return!1;c.push(g),b++}else if(d(e,g))return!1}var v=f(e);if(y.length!==v.length&&L(e,v).length!==b)return!1}else{var w=f(e);if(0!==w.length&&0!==L(e,w).length)return!1}}if(0===c.length&&(0===a||1===a&&0===t.length||0===t.size))return!0;if(void 0===i)i={val1:new Map,val2:new Map,position:0};else{var m=i.val1.get(t);if(void 0!==m){var S=i.val2.get(e);if(void 0!==S)return m===S}i.position++}i.val1.set(t,i.position),i.val2.set(e,i.position);var _=function(t,e,r,i,a,c){var f=0;if(2===c){if(!function(t,e,r,n){for(var i=null,a=s(t),u=0;u<a.length;u++){var c=a[u];if("object"===o(c)&&null!==c)null===i&&(i=new Set),i.add(c);else if(!e.has(c)){if(r)return!1;if(!H(t,e,c))return!1;null===i&&(i=new Set),i.add(c)}}if(null!==i){for(var f=s(e),l=0;l<f.length;l++){var h=f[l];if("object"===o(h)&&null!==h){if(!F(i,h,r,n))return!1}else if(!r&&!t.has(h)&&!F(i,h,r,n))return!1}return 0===i.size}return!0}(t,e,r,a))return!1}else if(3===c){if(!function(t,e,r,i){for(var a=null,s=u(t),c=0;c<s.length;c++){var f=n(s[c],2),l=f[0],h=f[1];if("object"===o(l)&&null!==l)null===a&&(a=new Set),a.add(l);else{var p=e.get(l);if(void 0===p&&!e.has(l)||!N(h,p,r,i)){if(r)return!1;if(!M(t,e,l,h,i))return!1;null===a&&(a=new Set),a.add(l)}}}if(null!==a){for(var d=u(e),y=0;y<d.length;y++){var b=n(d[y],2),g=b[0],v=b[1];if("object"===o(g)&&null!==g){if(!K(a,t,g,v,r,i))return!1}else if(!(r||t.has(g)&&N(t.get(g),v,!1,i)||K(a,t,g,v,!1,i)))return!1}return 0===a.size}return!0}(t,e,r,a))return!1}else if(1===c)for(;f<t.length;f++){if(!p(t,f)){if(p(e,f))return!1;for(var l=Object.keys(t);f<l.length;f++){var h=l[f];if(!p(e,h)||!N(t[h],e[h],r,a))return!1}return l.length===Object.keys(e).length}if(!p(e,f)||!N(t[f],e[f],r,a))return!1}for(f=0;f<i.length;f++){var d=i[f];if(!N(t[d],e[d],r,a))return!1}return!0}(t,e,r,c,i,a);return i.val1.delete(t),i.val2.delete(e),_}function F(t,e,r,n){for(var i=s(t),o=0;o<i.length;o++){var a=i[o];if(N(e,a,r,n))return t.delete(a),!0}return!1}function D(t){switch(o(t)){case"undefined":return null;case"object":return;case"symbol":return!1;case"string":t=+t;case"number":if(l(t))return!1}return!0}function H(t,e,r){var n=D(r);return null!=n?n:e.has(n)&&!t.has(n)}function M(t,e,r,n,i){var o=D(r);if(null!=o)return o;var a=e.get(o);return!(void 0===a&&!e.has(o)||!N(n,a,!1,i))&&!t.has(o)&&N(n,a,!1,i)}function K(t,e,r,n,i,o){for(var a=s(t),u=0;u<a.length;u++){var c=a[u];if(N(r,c,i,o)&&N(n,e.get(c),i,o))return t.delete(c),!0}return!1}t.exports={isDeepEqual:function(t,e){return N(t,e,!1)},isDeepStrictEqual:function(t,e){return N(t,e,!0)}}},2318:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.toBig=e.shrSL=e.shrSH=e.rotrSL=e.rotrSH=e.rotrBL=e.rotrBH=e.rotr32L=e.rotr32H=e.rotlSL=e.rotlSH=e.rotlBL=e.rotlBH=e.add5L=e.add5H=e.add4L=e.add4H=e.add3L=e.add3H=void 0,e.add=w,e.fromBig=i,e.split=o;const r=BigInt(2**32-1),n=BigInt(32);function i(t,e=!1){return e?{h:Number(t&r),l:Number(t>>n&r)}:{h:0|Number(t>>n&r),l:0|Number(t&r)}}function o(t,e=!1){const r=t.length;let n=new Uint32Array(r),o=new Uint32Array(r);for(let a=0;a<r;a++){const{h:r,l:s}=i(t[a],e);[n[a],o[a]]=[r,s]}return[n,o]}const a=(t,e)=>BigInt(t>>>0)<<n|BigInt(e>>>0);e.toBig=a;const s=(t,e,r)=>t>>>r;e.shrSH=s;const u=(t,e,r)=>t<<32-r|e>>>r;e.shrSL=u;const c=(t,e,r)=>t>>>r|e<<32-r;e.rotrSH=c;const f=(t,e,r)=>t<<32-r|e>>>r;e.rotrSL=f;const l=(t,e,r)=>t<<64-r|e>>>r-32;e.rotrBH=l;const h=(t,e,r)=>t>>>r-32|e<<64-r;e.rotrBL=h;const p=(t,e)=>e;e.rotr32H=p;const d=(t,e)=>t;e.rotr32L=d;const y=(t,e,r)=>t<<r|e>>>32-r;e.rotlSH=y;const b=(t,e,r)=>e<<r|t>>>32-r;e.rotlSL=b;const g=(t,e,r)=>e<<r-32|t>>>64-r;e.rotlBH=g;const v=(t,e,r)=>t<<r-32|e>>>64-r;function w(t,e,r,n){const i=(e>>>0)+(n>>>0);return{h:t+r+(i/2**32|0)|0,l:0|i}}e.rotlBL=v;const m=(t,e,r)=>(t>>>0)+(e>>>0)+(r>>>0);e.add3L=m;const S=(t,e,r,n)=>e+r+n+(t/2**32|0)|0;e.add3H=S;const _=(t,e,r,n)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0);e.add4L=_;const E=(t,e,r,n,i)=>e+r+n+i+(t/2**32|0)|0;e.add4H=E;const k=(t,e,r,n,i)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0)+(i>>>0);e.add5L=k;const O=(t,e,r,n,i,o)=>e+r+n+i+o+(t/2**32|0)|0;e.add5H=O;const T={fromBig:i,split:o,toBig:a,shrSH:s,shrSL:u,rotrSH:c,rotrSL:f,rotrBH:l,rotrBL:h,rotr32H:p,rotr32L:d,rotlSH:y,rotlSL:b,rotlBH:g,rotlBL:v,add:w,add3L:m,add3H:S,add4L:_,add4H:E,add5H:O,add5L:k};e.default=T},2343:(t,e)=>{e.p2=e.I=void 0;const r="qpzry9x8gf2tvdw0s3jn54khce6mua7l",n={};for(let t=0;t<32;t++){const e=r.charAt(t);n[e]=t}function i(t){const e=t>>25;return(33554431&t)<<5^996825010&-(1&e)^642813549&-(e>>1&1)^513874426&-(e>>2&1)^1027748829&-(e>>3&1)^705979059&-(e>>4&1)}function o(t){let e=1;for(let r=0;r<t.length;++r){const n=t.charCodeAt(r);if(n<33||n>126)return"Invalid prefix ("+t+")";e=i(e)^n>>5}e=i(e);for(let r=0;r<t.length;++r){const n=t.charCodeAt(r);e=i(e)^31&n}return e}function a(t,e,r,n){let i=0,o=0;const a=(1<<r)-1,s=[];for(let n=0;n<t.length;++n)for(i=i<<e|t[n],o+=e;o>=r;)o-=r,s.push(i>>o&a);if(n)o>0&&s.push(i<<r-o&a);else{if(o>=e)return"Excess padding";if(i<<r-o&a)return"Non-zero padding"}return s}function s(t){return a(t,8,5,!0)}function u(t){const e=a(t,5,8,!1);if(Array.isArray(e))return e}function c(t){const e=a(t,5,8,!1);if(Array.isArray(e))return e;throw new Error(e)}function f(t){let e;function a(t,r){if(r=r||90,t.length<8)return t+" too short";if(t.length>r)return"Exceeds length limit";const a=t.toLowerCase(),s=t.toUpperCase();if(t!==a&&t!==s)return"Mixed-case string "+t;const u=(t=a).lastIndexOf("1");if(-1===u)return"No separator character for "+t;if(0===u)return"Missing prefix for "+t;const c=t.slice(0,u),f=t.slice(u+1);if(f.length<6)return"Data too short";let l=o(c);if("string"==typeof l)return l;const h=[];for(let t=0;t<f.length;++t){const e=f.charAt(t),r=n[e];if(void 0===r)return"Unknown character "+e;l=i(l)^r,t+6>=f.length||h.push(r)}return l!==e?"Invalid checksum for "+t:{prefix:c,words:h}}return e="bech32"===t?1:734539939,{decodeUnsafe:function(t,e){const r=a(t,e);if("object"==typeof r)return r},decode:function(t,e){const r=a(t,e);if("object"==typeof r)return r;throw new Error(r)},encode:function(t,n,a){if(a=a||90,t.length+7+n.length>a)throw new TypeError("Exceeds length limit");let s=o(t=t.toLowerCase());if("string"==typeof s)throw new Error(s);let u=t+"1";for(let t=0;t<n.length;++t){const e=n[t];if(e>>5)throw new Error("Non 5-bit word");s=i(s)^e,u+=r.charAt(e)}for(let t=0;t<6;++t)s=i(s);s^=e;for(let t=0;t<6;++t)u+=r.charAt(s>>5*(5-t)&31);return u},toWords:s,fromWordsUnsafe:u,fromWords:c}}e.I=f("bech32"),e.p2=f("bech32m")},2382:()=>{},2389:(t,e,r)=>{function n(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function i(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?n(Object(r),!0).forEach(function(e){o(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):n(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function o(t,e,r){return(e=s(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function a(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,s(n.key),n)}}function s(t){var e=function(t){if("object"!=typeof t||null===t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==typeof e?e:String(e)}var u=r(8287).Buffer,c=r(8460).inspect,f=c&&c.custom||"inspect";function l(t,e,r){u.prototype.copy.call(t,e,r)}t.exports=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.head=null,this.tail=null,this.length=0}var e,r;return e=t,r=[{key:"push",value:function(t){var e={data:t,next:null};this.length>0?this.tail.next=e:this.head=e,this.tail=e,++this.length}},{key:"unshift",value:function(t){var e={data:t,next:this.head};0===this.length&&(this.tail=e),this.head=e,++this.length}},{key:"shift",value:function(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(t){if(0===this.length)return"";for(var e=this.head,r=""+e.data;e=e.next;)r+=t+e.data;return r}},{key:"concat",value:function(t){if(0===this.length)return u.alloc(0);for(var e=u.allocUnsafe(t>>>0),r=this.head,n=0;r;)l(r.data,e,n),n+=r.data.length,r=r.next;return e}},{key:"consume",value:function(t,e){var r;return t<this.head.data.length?(r=this.head.data.slice(0,t),this.head.data=this.head.data.slice(t)):r=t===this.head.data.length?this.shift():e?this._getString(t):this._getBuffer(t),r}},{key:"first",value:function(){return this.head.data}},{key:"_getString",value:function(t){var e=this.head,r=1,n=e.data;for(t-=n.length;e=e.next;){var i=e.data,o=t>i.length?i.length:t;if(o===i.length?n+=i:n+=i.slice(0,t),0===(t-=o)){o===i.length?(++r,e.next?this.head=e.next:this.head=this.tail=null):(this.head=e,e.data=i.slice(o));break}++r}return this.length-=r,n}},{key:"_getBuffer",value:function(t){var e=u.allocUnsafe(t),r=this.head,n=1;for(r.data.copy(e),t-=r.data.length;r=r.next;){var i=r.data,o=t>i.length?i.length:t;if(i.copy(e,e.length-t,0,o),0===(t-=o)){o===i.length?(++n,r.next?this.head=r.next:this.head=this.tail=null):(this.head=r,r.data=i.slice(o));break}++n}return this.length-=n,e}},{key:f,value:function(t,e){return c(this,i(i({},e),{},{depth:0,customInspect:!1}))}}],r&&a(e.prototype,r),Object.defineProperty(e,"prototype",{writable:!1}),t}()},2422:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.wNAF=void 0,e.negateCt=s,e.normalizeZ=function(t,e){const r=(0,i.FpInvertBatch)(t.Fp,e.map(t=>t.Z));return e.map((e,n)=>t.fromAffine(e.toAffine(r[n])))},e.mulEndoUnsafe=function(t,e,r,n){let i=e,s=t.ZERO,u=t.ZERO;for(;r>o||n>o;)r&a&&(s=s.add(i)),n&a&&(u=u.add(i)),i=i.double(),r>>=a,n>>=a;return{p1:s,p2:u}},e.pippenger=function(t,e,r,i){l(r,t),h(i,e);const o=r.length,a=i.length;if(o!==a)throw new Error("arrays of points and scalars must have equal length");const s=t.ZERO,u=(0,n.bitLen)(BigInt(o));let c=1;u>12?c=u-3:u>4?c=u-2:u>0&&(c=2);const f=(0,n.bitMask)(c),p=new Array(Number(f)+1).fill(s);let d=s;for(let t=Math.floor((e.BITS-1)/c)*c;t>=0;t-=c){p.fill(s);for(let e=0;e<a;e++){const n=i[e],o=Number(n>>BigInt(t)&f);p[o]=p[o].add(r[e])}let e=s;for(let t=p.length-1,r=s;t>0;t--)r=r.add(p[t]),e=e.add(r);if(d=d.add(e),0!==t)for(let t=0;t<c;t++)d=d.double()}return d},e.precomputeMSMUnsafe=function(t,e,r,i){u(i,e.BITS),l(r,t);const o=t.ZERO,a=2**i-1,s=Math.ceil(e.BITS/i),c=(0,n.bitMask)(i),f=r.map(t=>{const e=[];for(let r=0,n=t;r<a;r++)e.push(n),n=n.add(t);return e});return t=>{if(h(t,e),t.length>r.length)throw new Error("array of scalars must be smaller than array of points");let n=o;for(let e=0;e<s;e++){if(n!==o)for(let t=0;t<i;t++)n=n.double();const r=BigInt(s*i-(e+1)*i);for(let e=0;e<t.length;e++){const i=t[e],o=Number(i>>r&c);o&&(n=n.add(f[e][o-1]))}}return n}},e.validateBasic=function(t){return(0,i.validateField)(t.Fp),(0,n.validateObject)(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...(0,i.nLength)(t.n,t.nBitLength),...t,p:t.Fp.ORDER})},e._createCurveFields=function(t,e,r={},n){if(void 0===n&&(n="edwards"===t),!e||"object"!=typeof e)throw new Error(`expected valid ${t} CURVE object`);for(const t of["p","n","h"]){const r=e[t];if(!("bigint"==typeof r&&r>o))throw new Error(`CURVE.${t} must be positive bigint`)}const i=g(e.p,r.Fp,n),a=g(e.n,r.Fn,n),s=["Gx","Gy","a","weierstrass"===t?"b":"d"];for(const t of s)if(!i.isValid(e[t]))throw new Error(`CURVE.${t} must be valid field element of CURVE.Fp`);return{CURVE:e=Object.freeze(Object.assign({},e)),Fp:i,Fn:a}};const n=r(8627),i=r(4967),o=BigInt(0),a=BigInt(1);function s(t,e){const r=e.negate();return t?r:e}function u(t,e){if(!Number.isSafeInteger(t)||t<=0||t>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+t)}function c(t,e){u(t,e);const r=2**t;return{windows:Math.ceil(e/t)+1,windowSize:2**(t-1),mask:(0,n.bitMask)(t),maxNumber:r,shiftBy:BigInt(t)}}function f(t,e,r){const{windowSize:n,mask:i,maxNumber:o,shiftBy:s}=r;let u=Number(t&i),c=t>>s;u>n&&(u-=o,c+=a);const f=e*n;return{nextN:c,offset:f+Math.abs(u)-1,isZero:0===u,isNeg:u<0,isNegF:e%2!=0,offsetF:f}}function l(t,e){if(!Array.isArray(t))throw new Error("array expected");t.forEach((t,r)=>{if(!(t instanceof e))throw new Error("invalid point at index "+r)})}function h(t,e){if(!Array.isArray(t))throw new Error("array of scalars expected");t.forEach((t,r)=>{if(!e.isValid(t))throw new Error("invalid scalar at index "+r)})}const p=new WeakMap,d=new WeakMap;function y(t){return d.get(t)||1}function b(t){if(t!==o)throw new Error("invalid wNAF")}function g(t,e,r){if(e){if(e.ORDER!==t)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return(0,i.validateField)(e),e}return(0,i.Field)(t,{isLE:r})}e.wNAF=class{constructor(t,e){this.BASE=t.BASE,this.ZERO=t.ZERO,this.Fn=t.Fn,this.bits=e}_unsafeLadder(t,e,r=this.ZERO){let n=t;for(;e>o;)e&a&&(r=r.add(n)),n=n.double(),e>>=a;return r}precomputeWindow(t,e){const{windows:r,windowSize:n}=c(e,this.bits),i=[];let o=t,a=o;for(let t=0;t<r;t++){a=o,i.push(a);for(let t=1;t<n;t++)a=a.add(o),i.push(a);o=a.double()}return i}wNAF(t,e,r){if(!this.Fn.isValid(r))throw new Error("invalid scalar");let n=this.ZERO,i=this.BASE;const o=c(t,this.bits);for(let t=0;t<o.windows;t++){const{nextN:a,offset:u,isZero:c,isNeg:l,isNegF:h,offsetF:p}=f(r,t,o);r=a,c?i=i.add(s(h,e[p])):n=n.add(s(l,e[u]))}return b(r),{p:n,f:i}}wNAFUnsafe(t,e,r,n=this.ZERO){const i=c(t,this.bits);for(let t=0;t<i.windows&&r!==o;t++){const{nextN:o,offset:a,isZero:s,isNeg:u}=f(r,t,i);if(r=o,!s){const t=e[a];n=n.add(u?t.negate():t)}}return b(r),n}getPrecomputes(t,e,r){let n=p.get(e);return n||(n=this.precomputeWindow(e,t),1!==t&&("function"==typeof r&&(n=r(n)),p.set(e,n))),n}cached(t,e,r){const n=y(t);return this.wNAF(n,this.getPrecomputes(n,t,r),e)}unsafe(t,e,r,n){const i=y(t);return 1===i?this._unsafeLadder(t,e,n):this.wNAFUnsafe(i,this.getPrecomputes(i,t,r),e,n)}createCache(t,e){u(e,this.bits),d.set(t,e),p.delete(t)}hasCache(t){return 1!==y(t)}}},2463:t=>{var e={};function r(t,r,n){n||(n=Error);var i=function(t){var e,n;function i(e,n,i){return t.call(this,function(t,e,n){return"string"==typeof r?r:r(t,e,n)}(e,n,i))||this}return n=t,(e=i).prototype=Object.create(n.prototype),e.prototype.constructor=e,e.__proto__=n,i}(n);i.prototype.name=n.name,i.prototype.code=t,e[t]=i}function n(t,e){if(Array.isArray(t)){var r=t.length;return t=t.map(function(t){return String(t)}),r>2?"one of ".concat(e," ").concat(t.slice(0,r-1).join(", "),", or ")+t[r-1]:2===r?"one of ".concat(e," ").concat(t[0]," or ").concat(t[1]):"of ".concat(e," ").concat(t[0])}return"of ".concat(e," ").concat(String(t))}r("ERR_INVALID_OPT_VALUE",function(t,e){return'The value "'+e+'" is invalid for option "'+t+'"'},TypeError),r("ERR_INVALID_ARG_TYPE",function(t,e,r){var i,o,a;if("string"==typeof e&&(a="not ",e.substr(0,4)===a)?(i="must not be",e=e.replace(/^not /,"")):i="must be",function(t,e,r){return(void 0===r||r>t.length)&&(r=t.length),t.substring(r-9,r)===e}(t," argument"))o="The ".concat(t," ").concat(i," ").concat(n(e,"type"));else{var s=function(t,e,r){return"number"!=typeof r&&(r=0),!(r+1>t.length)&&-1!==t.indexOf(".",r)}(t)?"property":"argument";o='The "'.concat(t,'" ').concat(s," ").concat(i," ").concat(n(e,"type"))}return o+". Received type ".concat(typeof r)},TypeError),r("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),r("ERR_METHOD_NOT_IMPLEMENTED",function(t){return"The "+t+" method is not implemented"}),r("ERR_STREAM_PREMATURE_CLOSE","Premature close"),r("ERR_STREAM_DESTROYED",function(t){return"Cannot call "+t+" after a stream was destroyed"}),r("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),r("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),r("ERR_STREAM_WRITE_AFTER_END","write after end"),r("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),r("ERR_UNKNOWN_ENCODING",function(t){return"Unknown encoding: "+t},TypeError),r("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),t.exports.F=e},2464:(t,e,r)=>{var n=r(8452),i=r(6642);t.exports=function(){var t=i();return n(Number,{isNaN:t},{isNaN:function(){return Number.isNaN!==t}}),t}},2577:(t,e,r)=>{var n=r(7108),i=r(8212);t.exports=i(function(t){var e=n("sha256").update(t).digest();return n("sha256").update(e).digest()})},2682:(t,e,r)=>{var n=r(9600),i=Object.prototype.toString,o=Object.prototype.hasOwnProperty;t.exports=function(t,e,r){if(!n(e))throw new TypeError("iterator must be a function");var a;arguments.length>=3&&(a=r),function(t){return"[object Array]"===i.call(t)}(t)?function(t,e,r){for(var n=0,i=t.length;n<i;n++)o.call(t,n)&&(null==r?e(t[n],n,t):e.call(r,t[n],n,t))}(t,e,a):"string"==typeof t?function(t,e,r){for(var n=0,i=t.length;n<i;n++)null==r?e(t.charAt(n),n,t):e.call(r,t.charAt(n),n,t)}(t,e,a):function(t,e,r){for(var n in t)o.call(t,n)&&(null==r?e(t[n],n,t):e.call(r,t[n],n,t))}(t,e,a)}},2802:(t,e,r)=>{t.exports=function(e){var r=e.toLowerCase(),n=t.exports[r];if(!n)throw new Error(r+" is not supported (we accept pull requests)");return new n},t.exports.sha=r(7816),t.exports.sha1=r(3737),t.exports.sha224=r(6710),t.exports.sha256=r(4107),t.exports.sha384=r(2827),t.exports.sha512=r(2890)},2818:(t,e,r)=>{var n=r(5606),i=Object.keys||function(t){var e=[];for(var r in t)e.push(r);return e};t.exports=f;var o=r(6736),a=r(2192);r(6698)(f,o);for(var s=i(a.prototype),u=0;u<s.length;u++){var c=s[u];f.prototype[c]||(f.prototype[c]=a.prototype[c])}function f(t){if(!(this instanceof f))return new f(t);o.call(this,t),a.call(this,t),this.allowHalfOpen=!0,t&&(!1===t.readable&&(this.readable=!1),!1===t.writable&&(this.writable=!1),!1===t.allowHalfOpen&&(this.allowHalfOpen=!1,this.once("end",l)))}function l(){this._writableState.ended||n.nextTick(h,this)}function h(t){t.end()}Object.defineProperty(f.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(f.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(f.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(f.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._readableState&&void 0!==this._writableState&&this._readableState.destroyed&&this._writableState.destroyed},set:function(t){void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed=t,this._writableState.destroyed=t)}})},2827:(t,e,r)=>{var n=r(6698),i=r(2890),o=r(392),a=r(2861).Buffer,s=new Array(160);function u(){this.init(),this._w=s,o.call(this,128,112)}n(u,i),u.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},u.prototype._hash=function(){var t=a.allocUnsafe(48);function e(e,r,n){t.writeInt32BE(e,n),t.writeInt32BE(r,n+4)}return e(this._ah,this._al,0),e(this._bh,this._bl,8),e(this._ch,this._cl,16),e(this._dh,this._dl,24),e(this._eh,this._el,32),e(this._fh,this._fl,40),t},t.exports=u},2861:(t,e,r)=>{var n=r(8287),i=n.Buffer;function o(t,e){for(var r in t)e[r]=t[r]}function a(t,e,r){return i(t,e,r)}i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?t.exports=n:(o(n,e),e.Buffer=a),a.prototype=Object.create(i.prototype),o(i,a),a.from=function(t,e,r){if("number"==typeof t)throw new TypeError("Argument must not be a number");return i(t,e,r)},a.alloc=function(t,e,r){if("number"!=typeof t)throw new TypeError("Argument must be a number");var n=i(t);return void 0!==e?"string"==typeof r?n.fill(e,r):n.fill(e):n.fill(0),n},a.allocUnsafe=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return i(t)},a.allocUnsafeSlow=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return n.SlowBuffer(t)}},2890:(t,e,r)=>{var n=r(6698),i=r(392),o=r(2861).Buffer,a=[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],s=new Array(160);function u(){this.init(),this._w=s,i.call(this,128,112)}function c(t,e,r){return r^t&(e^r)}function f(t,e,r){return t&e|r&(t|e)}function l(t,e){return(t>>>28|e<<4)^(e>>>2|t<<30)^(e>>>7|t<<25)}function h(t,e){return(t>>>14|e<<18)^(t>>>18|e<<14)^(e>>>9|t<<23)}function p(t,e){return(t>>>1|e<<31)^(t>>>8|e<<24)^t>>>7}function d(t,e){return(t>>>1|e<<31)^(t>>>8|e<<24)^(t>>>7|e<<25)}function y(t,e){return(t>>>19|e<<13)^(e>>>29|t<<3)^t>>>6}function b(t,e){return(t>>>19|e<<13)^(e>>>29|t<<3)^(t>>>6|e<<26)}function g(t,e){return t>>>0<e>>>0?1:0}n(u,i),u.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},u.prototype._update=function(t){for(var e=this._w,r=0|this._ah,n=0|this._bh,i=0|this._ch,o=0|this._dh,s=0|this._eh,u=0|this._fh,v=0|this._gh,w=0|this._hh,m=0|this._al,S=0|this._bl,_=0|this._cl,E=0|this._dl,k=0|this._el,O=0|this._fl,T=0|this._gl,A=0|this._hl,I=0;I<32;I+=2)e[I]=t.readInt32BE(4*I),e[I+1]=t.readInt32BE(4*I+4);for(;I<160;I+=2){var P=e[I-30],x=e[I-30+1],B=p(P,x),R=d(x,P),U=y(P=e[I-4],x=e[I-4+1]),j=b(x,P),N=e[I-14],L=e[I-14+1],C=e[I-32],F=e[I-32+1],D=R+L|0,H=B+N+g(D,R)|0;H=(H=H+U+g(D=D+j|0,j)|0)+C+g(D=D+F|0,F)|0,e[I]=H,e[I+1]=D}for(var M=0;M<160;M+=2){H=e[M],D=e[M+1];var K=f(r,n,i),V=f(m,S,_),W=l(r,m),G=l(m,r),q=h(s,k),z=h(k,s),Z=a[M],X=a[M+1],Y=c(s,u,v),$=c(k,O,T),J=A+z|0,Q=w+q+g(J,A)|0;Q=(Q=(Q=Q+Y+g(J=J+$|0,$)|0)+Z+g(J=J+X|0,X)|0)+H+g(J=J+D|0,D)|0;var tt=G+V|0,et=W+K+g(tt,G)|0;w=v,A=T,v=u,T=O,u=s,O=k,s=o+Q+g(k=E+J|0,E)|0,o=i,E=_,i=n,_=S,n=r,S=m,r=Q+et+g(m=J+tt|0,J)|0}this._al=this._al+m|0,this._bl=this._bl+S|0,this._cl=this._cl+_|0,this._dl=this._dl+E|0,this._el=this._el+k|0,this._fl=this._fl+O|0,this._gl=this._gl+T|0,this._hl=this._hl+A|0,this._ah=this._ah+r+g(this._al,m)|0,this._bh=this._bh+n+g(this._bl,S)|0,this._ch=this._ch+i+g(this._cl,_)|0,this._dh=this._dh+o+g(this._dl,E)|0,this._eh=this._eh+s+g(this._el,k)|0,this._fh=this._fh+u+g(this._fl,O)|0,this._gh=this._gh+v+g(this._gl,T)|0,this._hh=this._hh+w+g(this._hl,A)|0},u.prototype._hash=function(){var t=o.allocUnsafe(64);function e(e,r,n){t.writeInt32BE(e,n),t.writeInt32BE(r,n+4)}return e(this._ah,this._al,0),e(this._bh,this._bl,8),e(this._ch,this._cl,16),e(this._dh,this._dl,24),e(this._eh,this._el,32),e(this._fh,this._fl,40),e(this._gh,this._gl,48),e(this._hh,this._hl,56),t},t.exports=u},3003:t=>{t.exports=function(t){return t!=t}},3054:(t,e,r)=>{t.exports=f;var n=r(2260).F,i=n.ERR_METHOD_NOT_IMPLEMENTED,o=n.ERR_MULTIPLE_CALLBACK,a=n.ERR_TRANSFORM_ALREADY_TRANSFORMING,s=n.ERR_TRANSFORM_WITH_LENGTH_0,u=r(2818);function c(t,e){var r=this._transformState;r.transforming=!1;var n=r.writecb;if(null===n)return this.emit("error",new o);r.writechunk=null,r.writecb=null,null!=e&&this.push(e),n(t);var i=this._readableState;i.reading=!1,(i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}function f(t){if(!(this instanceof f))return new f(t);u.call(this,t),this._transformState={afterTransform:c.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,t&&("function"==typeof t.transform&&(this._transform=t.transform),"function"==typeof t.flush&&(this._flush=t.flush)),this.on("prefinish",l)}function l(){var t=this;"function"!=typeof this._flush||this._readableState.destroyed?h(this,null,null):this._flush(function(e,r){h(t,e,r)})}function h(t,e,r){if(e)return t.emit("error",e);if(null!=r&&t.push(r),t._writableState.length)throw new s;if(t._transformState.transforming)throw new a;return t.push(null)}r(6698)(f,u),f.prototype.push=function(t,e){return this._transformState.needTransform=!1,u.prototype.push.call(this,t,e)},f.prototype._transform=function(t,e,r){r(new i("_transform()"))},f.prototype._write=function(t,e,r){var n=this._transformState;if(n.writecb=r,n.writechunk=t,n.writeencoding=e,!n.transforming){var i=this._readableState;(n.needTransform||i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}},f.prototype._read=function(t){var e=this._transformState;null===e.writechunk||e.transforming?e.needTransform=!0:(e.transforming=!0,this._transform(e.writechunk,e.writeencoding,e.afterTransform))},f.prototype._destroy=function(t,e){u.prototype._destroy.call(this,t,function(t){e(t)})}},3093:(t,e,r)=>{var n=r(4459);t.exports=function(t){return n(t)||0===t?t:t<0?-1:1}},3126:(t,e,r)=>{var n=r(6743),i=r(9675),o=r(76),a=r(3144);t.exports=function(t){if(t.length<1||"function"!=typeof t[0])throw new i("a function is required");return a(n,o,t)}},3144:(t,e,r)=>{var n=r(6743),i=r(1002),o=r(76),a=r(7119);t.exports=a||n.call(o,i)},3209:(t,e,r)=>{var n=r(5606),i=65536,o=r(2861).Buffer,a=r.g.crypto||r.g.msCrypto;a&&a.getRandomValues?t.exports=function(t,e){if(t>4294967295)throw new RangeError("requested too many random bytes");var r=o.allocUnsafe(t);if(t>0)if(t>i)for(var s=0;s<t;s+=i)a.getRandomValues(r.slice(s,s+i));else a.getRandomValues(r);return"function"==typeof e?n.nextTick(function(){e(null,r)}):r}:t.exports=function(){throw new Error("Secure random number generation is not supported by this browser.\nUse Chrome, Firefox or Internet Explorer 11")}},3269:t=>{t.exports=function(t,e,r,n){for(var i=65535&t,o=t>>>16&65535,a=0;0!==r;){r-=a=r>2e3?2e3:r;do{o=o+(i=i+e[n++]|0)|0}while(--a);i%=65521,o%=65521}return i|o<<16}},3513:(t,e,r)=>{var n=r(8510),i=r(4967),o=r(1484);function a(t){var e=Object.create(null);return t&&Object.keys(t).forEach(function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,n.get?n:{enumerable:!0,get:function(){return t[r]}})}}),e.default=t,Object.freeze(e)}var s=a(i),u=a(o);const c=n.secp256k1.ProjectivePoint,f="Expected Private",l="Expected Point",h="Expected Tweak",p="Expected Signature",d="Expected Extra Data (32 bytes)",y="Expected Scalar",b=new Uint8Array([255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,186,174,220,230,175,72,160,59,191,210,94,140,208,54,65,65]),g=new Uint8Array(32),v=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,69,81,35,25,80,183,95,196,64,45,161,114,47,201,186,238]),w=BigInt(1);function m(t,e){for(let r=0;r<32;++r)if(t[r]!==e[r])return t[r]<e[r]?-1:1;return 0}function S(t){return 0===m(t,g)}function _(t){return t instanceof Uint8Array&&32===t.length&&!(m(t,b)>=0)}function E(t){return t instanceof Uint8Array&&64===t.length&&m(t.subarray(0,32),b)<0&&m(t.subarray(32,64),b)<0}function k(t){return t instanceof Uint8Array&&32===t.length}function O(t){return void 0===t||t instanceof Uint8Array&&32===t.length}function T(t){let e;if("bigint"==typeof t)e=t;else if("number"==typeof t&&Number.isSafeInteger(t)&&t>=0)e=BigInt(t);else if("string"==typeof t){if(64!==t.length)throw new Error("Expected 32 bytes of private scalar");e=u.hexToNumber(t)}else{if(!(t instanceof Uint8Array))throw new TypeError("Expected valid private scalar");if(32!==t.length)throw new Error("Expected 32 bytes of private scalar");e=u.bytesToNumberBE(t)}if(e<0)throw new Error("Expected private scalar >= 0");return e}function A(t){return n.secp256k1.utils.normPrivateKeyToScalar(t)}function I(t,e,r){const n=R(t),i=T(e),o=c.BASE.multiplyAndAddUnsafe(n,i,w);if(!o)throw new Error("Tweaked point at infinity");return o.toRawBytes(r)}function P(t,e){return void 0===t?void 0===e||N(e):!!t}function x(t){try{return t()}catch(t){return null}}function B(t){return n.schnorr.utils.lift_x(u.bytesToNumberBE(t))}function R(t){return 32===t.length?B(t):c.fromHex(t)}function U(t,e){if(32===t.length!==e)return!1;try{return e?!!B(t):!!c.fromHex(t)}catch(t){return!1}}function j(t){return U(t,!1)}function N(t){return U(t,!1)&&33===t.length}function L(t){return n.secp256k1.utils.isValidPrivateKey(t)}function C(t){return U(t,!0)}function F(t){if(!j(t))throw new Error(l);return t.slice(1,33)}function D(t,e){if(!L(t))throw new Error(f);return x(()=>n.secp256k1.getPublicKey(t,P(e)))}e.isPoint=j,e.isPointCompressed=N,e.isPrivate=L,e.isXOnlyPoint=C,e.pointAdd=function(t,e,r){if(!j(t)||!j(e))throw new Error(l);return x(()=>{const n=R(t),i=R(e);return n.equals(i.negate())?null:n.add(i).toRawBytes(P(r,t))})},e.pointAddScalar=function(t,e,r){if(!j(t))throw new Error(l);if(!_(e))throw new Error(h);return x(()=>I(t,e,P(r,t)))},e.pointCompress=function(t,e){if(!j(t))throw new Error(l);return R(t).toRawBytes(P(e,t))},e.pointFromScalar=D,e.pointMultiply=function(t,e,r){if(!j(t))throw new Error(l);if(!_(e))throw new Error(h);return x(()=>function(t,e,r){const n=R(t),i="string"==typeof e?e:u.bytesToHex(e),o=u.hexToNumber(i);return n.multiply(o).toRawBytes(r)}(t,e,P(r,t)))},e.privateAdd=function(t,e){if(!L(t))throw new Error(f);if(!_(e))throw new Error(h);return x(()=>function(t,e){const r=A(t),i=T(e),o=u.numberToBytesBE(s.mod(r+i,n.secp256k1.CURVE.n),32);return n.secp256k1.utils.isValidPrivateKey(o)?o:null}(t,e))},e.privateNegate=function(t){if(!L(t))throw new Error(f);return function(t){const e=A(t),r=u.numberToBytesBE(n.secp256k1.CURVE.n-e,32);return n.secp256k1.utils.isValidPrivateKey(r)?r:null}(t)},e.privateSub=function(t,e){if(!L(t))throw new Error(f);if(!_(e))throw new Error(h);return x(()=>function(t,e){const r=A(t),i=T(e),o=u.numberToBytesBE(s.mod(r-i,n.secp256k1.CURVE.n),32);return n.secp256k1.utils.isValidPrivateKey(o)?o:null}(t,e))},e.recover=function(t,e,r,i){if(!k(t))throw new Error("Expected Hash");if(!E(e)||!function(t){return!(S(t.subarray(0,32))||S(t.subarray(32,64)))}(e))throw new Error(p);if(2&r&&!function(t){return t instanceof Uint8Array&&64===t.length&&m(t.subarray(0,32),v)<0}(e))throw new Error("Bad Recovery Id");if(!C(e.subarray(0,32)))throw new Error(p);const o=n.secp256k1.Signature.fromCompact(e).addRecoveryBit(r).recoverPublicKey(t);if(!o)throw new Error(p);return o.toRawBytes(P(i))},e.sign=function(t,e,r){if(!L(e))throw new Error(f);if(!k(t))throw new Error(y);if(!O(r))throw new Error(d);return n.secp256k1.sign(t,e,{extraEntropy:r}).toCompactRawBytes()},e.signRecoverable=function(t,e,r){if(!L(e))throw new Error(f);if(!k(t))throw new Error(y);if(!O(r))throw new Error(d);const i=n.secp256k1.sign(t,e,{extraEntropy:r});return{signature:i.toCompactRawBytes(),recoveryId:i.recovery}},e.signSchnorr=function(t,e,r){if(!L(e))throw new Error(f);if(!k(t))throw new Error(y);if(!O(r))throw new Error(d);return n.schnorr.sign(t,e,r)},e.verify=function(t,e,r,i){if(!j(e))throw new Error(l);if(!E(r))throw new Error(p);if(!k(t))throw new Error(y);return n.secp256k1.verify(r,t,e,{lowS:i})},e.verifySchnorr=function(t,e,r){if(!C(e))throw new Error(l);if(!E(r))throw new Error(p);if(!k(t))throw new Error(y);return n.schnorr.verify(r,t,e)},e.xOnlyPointAddTweak=function(t,e){if(!C(t))throw new Error(l);if(!_(e))throw new Error(h);return x(()=>{const r=I(t,e,!0);return{parity:r[0]%2==1?1:0,xOnlyPubkey:r.slice(1)}})},e.xOnlyPointFromPoint=F,e.xOnlyPointFromScalar=function(t){if(!L(t))throw new Error(f);return F(D(t))}},3516:(t,e,r)=>{var n=r(2861).Buffer,i=n.isEncoding||function(t){switch((t=""+t)&&t.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function o(t){var e;switch(this.encoding=function(t){var e=function(t){if(!t)return"utf8";for(var e;;)switch(t){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return t;default:if(e)return;t=(""+t).toLowerCase(),e=!0}}(t);if("string"!=typeof e&&(n.isEncoding===i||!i(t)))throw new Error("Unknown encoding: "+t);return e||t}(t),this.encoding){case"utf16le":this.text=u,this.end=c,e=4;break;case"utf8":this.fillLast=s,e=4;break;case"base64":this.text=f,this.end=l,e=3;break;default:return this.write=h,void(this.end=p)}this.lastNeed=0,this.lastTotal=0,this.lastChar=n.allocUnsafe(e)}function a(t){return t<=127?0:t>>5==6?2:t>>4==14?3:t>>3==30?4:t>>6==2?-1:-2}function s(t){var e=this.lastTotal-this.lastNeed,r=function(t,e){if(128!=(192&e[0]))return t.lastNeed=0,"�";if(t.lastNeed>1&&e.length>1){if(128!=(192&e[1]))return t.lastNeed=1,"�";if(t.lastNeed>2&&e.length>2&&128!=(192&e[2]))return t.lastNeed=2,"�"}}(this,t);return void 0!==r?r:this.lastNeed<=t.length?(t.copy(this.lastChar,e,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(t.copy(this.lastChar,e,0,t.length),void(this.lastNeed-=t.length))}function u(t,e){if((t.length-e)%2==0){var r=t.toString("utf16le",e);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=t[t.length-1],t.toString("utf16le",e,t.length-1)}function c(t){var e=t&&t.length?this.write(t):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return e+this.lastChar.toString("utf16le",0,r)}return e}function f(t,e){var r=(t.length-e)%3;return 0===r?t.toString("base64",e):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=t[t.length-1]:(this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1]),t.toString("base64",e,t.length-r))}function l(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+this.lastChar.toString("base64",0,3-this.lastNeed):e}function h(t){return t.toString(this.encoding)}function p(t){return t&&t.length?this.write(t):""}e.I=o,o.prototype.write=function(t){if(0===t.length)return"";var e,r;if(this.lastNeed){if(void 0===(e=this.fillLast(t)))return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r<t.length?e?e+this.text(t,r):this.text(t,r):e||""},o.prototype.end=function(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+"�":e},o.prototype.text=function(t,e){var r=function(t,e,r){var n=e.length-1;if(n<r)return 0;var i=a(e[n]);return i>=0?(i>0&&(t.lastNeed=i-1),i):--n<r||-2===i?0:(i=a(e[n]))>=0?(i>0&&(t.lastNeed=i-2),i):--n<r||-2===i?0:(i=a(e[n]))>=0?(i>0&&(2===i?i=0:t.lastNeed=i-3),i):0}(this,t,e);if(!this.lastNeed)return t.toString("utf8",e);this.lastTotal=r;var n=t.length-(r-this.lastNeed);return t.copy(this.lastChar,0,n),t.toString("utf8",e,n)},o.prototype.fillLast=function(t){if(this.lastNeed<=t.length)return t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,t.length),this.lastNeed-=t.length}},3562:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.getHash=function(t){return{hash:t}},e.createCurve=function(t,e){const r=e=>(0,n.weierstrass)({...t,hash:e});return{...r(e),create:r}};const n=r(1705)},3628:(t,e,r)=>{var n=r(8648),i=r(1064),o=r(7176);t.exports=n?function(t){return n(t)}:i?function(t){if(!t||"object"!=typeof t&&"function"!=typeof t)throw new TypeError("getProto: not an object");return i(t)}:o?function(t){return o(t)}:null},3665:(t,e,r)=>{var n=r(9805);function i(t){for(var e=t.length;--e>=0;)t[e]=0}var o=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],a=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],s=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],u=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],c=new Array(576);i(c);var f=new Array(60);i(f);var l=new Array(512);i(l);var h=new Array(256);i(h);var p=new Array(29);i(p);var d,y,b,g=new Array(30);function v(t,e,r,n,i){this.static_tree=t,this.extra_bits=e,this.extra_base=r,this.elems=n,this.max_length=i,this.has_stree=t&&t.length}function w(t,e){this.dyn_tree=t,this.max_code=0,this.stat_desc=e}function m(t){return t<256?l[t]:l[256+(t>>>7)]}function S(t,e){t.pending_buf[t.pending++]=255&e,t.pending_buf[t.pending++]=e>>>8&255}function _(t,e,r){t.bi_valid>16-r?(t.bi_buf|=e<<t.bi_valid&65535,S(t,t.bi_buf),t.bi_buf=e>>16-t.bi_valid,t.bi_valid+=r-16):(t.bi_buf|=e<<t.bi_valid&65535,t.bi_valid+=r)}function E(t,e,r){_(t,r[2*e],r[2*e+1])}function k(t,e){var r=0;do{r|=1&t,t>>>=1,r<<=1}while(--e>0);return r>>>1}function O(t,e,r){var n,i,o=new Array(16),a=0;for(n=1;n<=15;n++)o[n]=a=a+r[n-1]<<1;for(i=0;i<=e;i++){var s=t[2*i+1];0!==s&&(t[2*i]=k(o[s]++,s))}}function T(t){var e;for(e=0;e<286;e++)t.dyn_ltree[2*e]=0;for(e=0;e<30;e++)t.dyn_dtree[2*e]=0;for(e=0;e<19;e++)t.bl_tree[2*e]=0;t.dyn_ltree[512]=1,t.opt_len=t.static_len=0,t.last_lit=t.matches=0}function A(t){t.bi_valid>8?S(t,t.bi_buf):t.bi_valid>0&&(t.pending_buf[t.pending++]=t.bi_buf),t.bi_buf=0,t.bi_valid=0}function I(t,e,r,n){var i=2*e,o=2*r;return t[i]<t[o]||t[i]===t[o]&&n[e]<=n[r]}function P(t,e,r){for(var n=t.heap[r],i=r<<1;i<=t.heap_len&&(i<t.heap_len&&I(e,t.heap[i+1],t.heap[i],t.depth)&&i++,!I(e,n,t.heap[i],t.depth));)t.heap[r]=t.heap[i],r=i,i<<=1;t.heap[r]=n}function x(t,e,r){var n,i,s,u,c=0;if(0!==t.last_lit)do{n=t.pending_buf[t.d_buf+2*c]<<8|t.pending_buf[t.d_buf+2*c+1],i=t.pending_buf[t.l_buf+c],c++,0===n?E(t,i,e):(E(t,(s=h[i])+256+1,e),0!==(u=o[s])&&_(t,i-=p[s],u),E(t,s=m(--n),r),0!==(u=a[s])&&_(t,n-=g[s],u))}while(c<t.last_lit);E(t,256,e)}function B(t,e){var r,n,i,o=e.dyn_tree,a=e.stat_desc.static_tree,s=e.stat_desc.has_stree,u=e.stat_desc.elems,c=-1;for(t.heap_len=0,t.heap_max=573,r=0;r<u;r++)0!==o[2*r]?(t.heap[++t.heap_len]=c=r,t.depth[r]=0):o[2*r+1]=0;for(;t.heap_len<2;)o[2*(i=t.heap[++t.heap_len]=c<2?++c:0)]=1,t.depth[i]=0,t.opt_len--,s&&(t.static_len-=a[2*i+1]);for(e.max_code=c,r=t.heap_len>>1;r>=1;r--)P(t,o,r);i=u;do{r=t.heap[1],t.heap[1]=t.heap[t.heap_len--],P(t,o,1),n=t.heap[1],t.heap[--t.heap_max]=r,t.heap[--t.heap_max]=n,o[2*i]=o[2*r]+o[2*n],t.depth[i]=(t.depth[r]>=t.depth[n]?t.depth[r]:t.depth[n])+1,o[2*r+1]=o[2*n+1]=i,t.heap[1]=i++,P(t,o,1)}while(t.heap_len>=2);t.heap[--t.heap_max]=t.heap[1],function(t,e){var r,n,i,o,a,s,u=e.dyn_tree,c=e.max_code,f=e.stat_desc.static_tree,l=e.stat_desc.has_stree,h=e.stat_desc.extra_bits,p=e.stat_desc.extra_base,d=e.stat_desc.max_length,y=0;for(o=0;o<=15;o++)t.bl_count[o]=0;for(u[2*t.heap[t.heap_max]+1]=0,r=t.heap_max+1;r<573;r++)(o=u[2*u[2*(n=t.heap[r])+1]+1]+1)>d&&(o=d,y++),u[2*n+1]=o,n>c||(t.bl_count[o]++,a=0,n>=p&&(a=h[n-p]),s=u[2*n],t.opt_len+=s*(o+a),l&&(t.static_len+=s*(f[2*n+1]+a)));if(0!==y){do{for(o=d-1;0===t.bl_count[o];)o--;t.bl_count[o]--,t.bl_count[o+1]+=2,t.bl_count[d]--,y-=2}while(y>0);for(o=d;0!==o;o--)for(n=t.bl_count[o];0!==n;)(i=t.heap[--r])>c||(u[2*i+1]!==o&&(t.opt_len+=(o-u[2*i+1])*u[2*i],u[2*i+1]=o),n--)}}(t,e),O(o,c,t.bl_count)}function R(t,e,r){var n,i,o=-1,a=e[1],s=0,u=7,c=4;for(0===a&&(u=138,c=3),e[2*(r+1)+1]=65535,n=0;n<=r;n++)i=a,a=e[2*(n+1)+1],++s<u&&i===a||(s<c?t.bl_tree[2*i]+=s:0!==i?(i!==o&&t.bl_tree[2*i]++,t.bl_tree[32]++):s<=10?t.bl_tree[34]++:t.bl_tree[36]++,s=0,o=i,0===a?(u=138,c=3):i===a?(u=6,c=3):(u=7,c=4))}function U(t,e,r){var n,i,o=-1,a=e[1],s=0,u=7,c=4;for(0===a&&(u=138,c=3),n=0;n<=r;n++)if(i=a,a=e[2*(n+1)+1],!(++s<u&&i===a)){if(s<c)do{E(t,i,t.bl_tree)}while(0!==--s);else 0!==i?(i!==o&&(E(t,i,t.bl_tree),s--),E(t,16,t.bl_tree),_(t,s-3,2)):s<=10?(E(t,17,t.bl_tree),_(t,s-3,3)):(E(t,18,t.bl_tree),_(t,s-11,7));s=0,o=i,0===a?(u=138,c=3):i===a?(u=6,c=3):(u=7,c=4)}}i(g);var j=!1;function N(t,e,r,i){_(t,0+(i?1:0),3),function(t,e,r){A(t),S(t,r),S(t,~r),n.arraySet(t.pending_buf,t.window,e,r,t.pending),t.pending+=r}(t,e,r)}e._tr_init=function(t){j||(function(){var t,e,r,n,i,u=new Array(16);for(r=0,n=0;n<28;n++)for(p[n]=r,t=0;t<1<<o[n];t++)h[r++]=n;for(h[r-1]=n,i=0,n=0;n<16;n++)for(g[n]=i,t=0;t<1<<a[n];t++)l[i++]=n;for(i>>=7;n<30;n++)for(g[n]=i<<7,t=0;t<1<<a[n]-7;t++)l[256+i++]=n;for(e=0;e<=15;e++)u[e]=0;for(t=0;t<=143;)c[2*t+1]=8,t++,u[8]++;for(;t<=255;)c[2*t+1]=9,t++,u[9]++;for(;t<=279;)c[2*t+1]=7,t++,u[7]++;for(;t<=287;)c[2*t+1]=8,t++,u[8]++;for(O(c,287,u),t=0;t<30;t++)f[2*t+1]=5,f[2*t]=k(t,5);d=new v(c,o,257,286,15),y=new v(f,a,0,30,15),b=new v(new Array(0),s,0,19,7)}(),j=!0),t.l_desc=new w(t.dyn_ltree,d),t.d_desc=new w(t.dyn_dtree,y),t.bl_desc=new w(t.bl_tree,b),t.bi_buf=0,t.bi_valid=0,T(t)},e._tr_stored_block=N,e._tr_flush_block=function(t,e,r,n){var i,o,a=0;t.level>0?(2===t.strm.data_type&&(t.strm.data_type=function(t){var e,r=4093624447;for(e=0;e<=31;e++,r>>>=1)if(1&r&&0!==t.dyn_ltree[2*e])return 0;if(0!==t.dyn_ltree[18]||0!==t.dyn_ltree[20]||0!==t.dyn_ltree[26])return 1;for(e=32;e<256;e++)if(0!==t.dyn_ltree[2*e])return 1;return 0}(t)),B(t,t.l_desc),B(t,t.d_desc),a=function(t){var e;for(R(t,t.dyn_ltree,t.l_desc.max_code),R(t,t.dyn_dtree,t.d_desc.max_code),B(t,t.bl_desc),e=18;e>=3&&0===t.bl_tree[2*u[e]+1];e--);return t.opt_len+=3*(e+1)+5+5+4,e}(t),i=t.opt_len+3+7>>>3,(o=t.static_len+3+7>>>3)<=i&&(i=o)):i=o=r+5,r+4<=i&&-1!==e?N(t,e,r,n):4===t.strategy||o===i?(_(t,2+(n?1:0),3),x(t,c,f)):(_(t,4+(n?1:0),3),function(t,e,r,n){var i;for(_(t,e-257,5),_(t,r-1,5),_(t,n-4,4),i=0;i<n;i++)_(t,t.bl_tree[2*u[i]+1],3);U(t,t.dyn_ltree,e-1),U(t,t.dyn_dtree,r-1)}(t,t.l_desc.max_code+1,t.d_desc.max_code+1,a+1),x(t,t.dyn_ltree,t.dyn_dtree)),T(t),n&&A(t)},e._tr_tally=function(t,e,r){return t.pending_buf[t.d_buf+2*t.last_lit]=e>>>8&255,t.pending_buf[t.d_buf+2*t.last_lit+1]=255&e,t.pending_buf[t.l_buf+t.last_lit]=255&r,t.last_lit++,0===e?t.dyn_ltree[2*r]++:(t.matches++,e--,t.dyn_ltree[2*(h[r]+256+1)]++,t.dyn_dtree[2*m(e)]++),t.last_lit===t.lit_bufsize-1},e._tr_align=function(t){_(t,2,3),E(t,256,c),function(t){16===t.bi_valid?(S(t,t.bi_buf),t.bi_buf=0,t.bi_valid=0):t.bi_valid>=8&&(t.pending_buf[t.pending++]=255&t.bi_buf,t.bi_buf>>=8,t.bi_valid-=8)}(t)}},3681:(t,e,r)=>{t.exports=i;var n=r(9083);function i(t){if(!(this instanceof i))return new i(t);n.call(this,t)}r(6698)(i,n),i.prototype._transform=function(t,e,r){r(null,t)}},3737:(t,e,r)=>{var n=r(6698),i=r(392),o=r(2861).Buffer,a=[1518500249,1859775393,-1894007588,-899497514],s=new Array(80);function u(){this.init(),this._w=s,i.call(this,64,56)}function c(t){return t<<1|t>>>31}function f(t){return t<<5|t>>>27}function l(t){return t<<30|t>>>2}function h(t,e,r,n){return 0===t?e&r|~e&n:2===t?e&r|e&n|r&n:e^r^n}n(u,i),u.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},u.prototype._update=function(t){for(var e=this._w,r=0|this._a,n=0|this._b,i=0|this._c,o=0|this._d,s=0|this._e,u=0;u<16;++u)e[u]=t.readInt32BE(4*u);for(;u<80;++u)e[u]=c(e[u-3]^e[u-8]^e[u-14]^e[u-16]);for(var p=0;p<80;++p){var d=~~(p/20),y=f(r)+h(d,n,i,o)+s+e[p]+a[d]|0;s=o,o=i,i=l(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},u.prototype._hash=function(){var t=o.allocUnsafe(20);return t.writeInt32BE(0|this._a,0),t.writeInt32BE(0|this._b,4),t.writeInt32BE(0|this._c,8),t.writeInt32BE(0|this._d,12),t.writeInt32BE(0|this._e,16),t},t.exports=u},3779:()=>{},3835:(t,e,r)=>{var n=r(9284);t.exports=n("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")},3918:(t,e,r)=>{var n=r(5606);function i(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function o(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?i(Object(r),!0).forEach(function(e){var n,i,o;n=t,i=e,o=r[e],(i=s(i))in n?Object.defineProperty(n,i,{value:o,enumerable:!0,configurable:!0,writable:!0}):n[i]=o}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):i(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function a(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,s(n.key),n)}}function s(t){var e=function(t){if("object"!==y(t)||null===t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!==y(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"===y(e)?e:String(e)}function u(t,e){if(e&&("object"===y(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return c(t)}function c(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function f(t){var e="function"==typeof Map?new Map:void 0;return f=function(t){if(null===t||!function(t){return-1!==Function.toString.call(t).indexOf("[native code]")}(t))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,r)}function r(){return l(t,arguments,d(this).constructor)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),p(r,t)},f(t)}function l(t,e,r){return l=h()?Reflect.construct.bind():function(t,e,r){var n=[null];n.push.apply(n,e);var i=new(Function.bind.apply(t,n));return r&&p(i,r.prototype),i},l.apply(null,arguments)}function h(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(t){return!1}}function p(t,e){return p=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},p(t,e)}function d(t){return d=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},d(t)}function y(t){return y="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},y(t)}var b=r(537).inspect,g=r(9597).codes.ERR_INVALID_ARG_TYPE;function v(t,e,r){return(void 0===r||r>t.length)&&(r=t.length),t.substring(r-e.length,r)===e}var w="",m="",S="",_="",E={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:"};function k(t){var e=Object.keys(t),r=Object.create(Object.getPrototypeOf(t));return e.forEach(function(e){r[e]=t[e]}),Object.defineProperty(r,"message",{value:t.message}),r}function O(t){return b(t,{compact:!1,customInspect:!1,depth:1e3,maxArrayLength:1/0,showHidden:!1,breakLength:1/0,showProxy:!1,sorted:!0,getters:!0})}var T=function(t,e){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&p(t,e)}(T,t);var r,i,s,f,l=(r=T,i=h(),function(){var t,e=d(r);if(i){var n=d(this).constructor;t=Reflect.construct(e,arguments,n)}else t=e.apply(this,arguments);return u(this,t)});function T(t){var e;if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,T),"object"!==y(t)||null===t)throw new g("options","Object",t);var r=t.message,i=t.operator,o=t.stackStartFn,a=t.actual,s=t.expected,f=Error.stackTraceLimit;if(Error.stackTraceLimit=0,null!=r)e=l.call(this,String(r));else if(n.stderr&&n.stderr.isTTY&&(n.stderr&&n.stderr.getColorDepth&&1!==n.stderr.getColorDepth()?(w="",m="",_="",S=""):(w="",m="",_="",S="")),"object"===y(a)&&null!==a&&"object"===y(s)&&null!==s&&"stack"in a&&a instanceof Error&&"stack"in s&&s instanceof Error&&(a=k(a),s=k(s)),"deepStrictEqual"===i||"strictEqual"===i)e=l.call(this,function(t,e,r){var i="",o="",a=0,s="",u=!1,c=O(t),f=c.split("\n"),l=O(e).split("\n"),h=0,p="";if("strictEqual"===r&&"object"===y(t)&&"object"===y(e)&&null!==t&&null!==e&&(r="strictEqualObject"),1===f.length&&1===l.length&&f[0]!==l[0]){var d=f[0].length+l[0].length;if(d<=10){if(!("object"===y(t)&&null!==t||"object"===y(e)&&null!==e||0===t&&0===e))return"".concat(E[r],"\n\n")+"".concat(f[0]," !== ").concat(l[0],"\n")}else if("strictEqualObject"!==r&&d<(n.stderr&&n.stderr.isTTY?n.stderr.columns:80)){for(;f[0][h]===l[0][h];)h++;h>2&&(p="\n ".concat(function(t,e){if(e=Math.floor(e),0==t.length||0==e)return"";var r=t.length*e;for(e=Math.floor(Math.log(e)/Math.log(2));e;)t+=t,e--;return t+t.substring(0,r-t.length)}(" ",h),"^"),h=0)}}for(var b=f[f.length-1],g=l[l.length-1];b===g&&(h++<2?s="\n ".concat(b).concat(s):i=b,f.pop(),l.pop(),0!==f.length&&0!==l.length);)b=f[f.length-1],g=l[l.length-1];var k=Math.max(f.length,l.length);if(0===k){var T=c.split("\n");if(T.length>30)for(T[26]="".concat(w,"...").concat(_);T.length>27;)T.pop();return"".concat(E.notIdentical,"\n\n").concat(T.join("\n"),"\n")}h>3&&(s="\n".concat(w,"...").concat(_).concat(s),u=!0),""!==i&&(s="\n ".concat(i).concat(s),i="");var A=0,I=E[r]+"\n".concat(m,"+ actual").concat(_," ").concat(S,"- expected").concat(_),P=" ".concat(w,"...").concat(_," Lines skipped");for(h=0;h<k;h++){var x=h-a;if(f.length<h+1)x>1&&h>2&&(x>4?(o+="\n".concat(w,"...").concat(_),u=!0):x>3&&(o+="\n ".concat(l[h-2]),A++),o+="\n ".concat(l[h-1]),A++),a=h,i+="\n".concat(S,"-").concat(_," ").concat(l[h]),A++;else if(l.length<h+1)x>1&&h>2&&(x>4?(o+="\n".concat(w,"...").concat(_),u=!0):x>3&&(o+="\n ".concat(f[h-2]),A++),o+="\n ".concat(f[h-1]),A++),a=h,o+="\n".concat(m,"+").concat(_," ").concat(f[h]),A++;else{var B=l[h],R=f[h],U=R!==B&&(!v(R,",")||R.slice(0,-1)!==B);U&&v(B,",")&&B.slice(0,-1)===R&&(U=!1,R+=","),U?(x>1&&h>2&&(x>4?(o+="\n".concat(w,"...").concat(_),u=!0):x>3&&(o+="\n ".concat(f[h-2]),A++),o+="\n ".concat(f[h-1]),A++),a=h,o+="\n".concat(m,"+").concat(_," ").concat(R),i+="\n".concat(S,"-").concat(_," ").concat(B),A+=2):(o+=i,i="",1!==x&&0!==h||(o+="\n ".concat(R),A++))}if(A>20&&h<k-2)return"".concat(I).concat(P,"\n").concat(o,"\n").concat(w,"...").concat(_).concat(i,"\n")+"".concat(w,"...").concat(_)}return"".concat(I).concat(u?P:"","\n").concat(o).concat(i).concat(s).concat(p)}(a,s,i));else if("notDeepStrictEqual"===i||"notStrictEqual"===i){var h=E[i],p=O(a).split("\n");if("notStrictEqual"===i&&"object"===y(a)&&null!==a&&(h=E.notStrictEqualObject),p.length>30)for(p[26]="".concat(w,"...").concat(_);p.length>27;)p.pop();e=1===p.length?l.call(this,"".concat(h," ").concat(p[0])):l.call(this,"".concat(h,"\n\n").concat(p.join("\n"),"\n"))}else{var d=O(a),b="",A=E[i];"notDeepEqual"===i||"notEqual"===i?(d="".concat(E[i],"\n\n").concat(d)).length>1024&&(d="".concat(d.slice(0,1021),"...")):(b="".concat(O(s)),d.length>512&&(d="".concat(d.slice(0,509),"...")),b.length>512&&(b="".concat(b.slice(0,509),"...")),"deepEqual"===i||"equal"===i?d="".concat(A,"\n\n").concat(d,"\n\nshould equal\n\n"):b=" ".concat(i," ").concat(b)),e=l.call(this,"".concat(d).concat(b))}return Error.stackTraceLimit=f,e.generatedMessage=!r,Object.defineProperty(c(e),"name",{value:"AssertionError [ERR_ASSERTION]",enumerable:!1,writable:!0,configurable:!0}),e.code="ERR_ASSERTION",e.actual=a,e.expected=s,e.operator=i,Error.captureStackTrace&&Error.captureStackTrace(c(e),o),e.stack,e.name="AssertionError",u(e)}return s=T,(f=[{key:"toString",value:function(){return"".concat(this.name," [").concat(this.code,"]: ").concat(this.message)}},{key:e,value:function(t,e){return b(this,o(o({},e),{},{customInspect:!1,depth:0}))}}])&&a(s.prototype,f),Object.defineProperty(s,"prototype",{writable:!1}),T}(f(Error),b.custom);t.exports=T},4035:(t,e,r)=>{var n,i=r(6556),o=r(9092)(),a=r(9957),s=r(5795);if(o){var u=i("RegExp.prototype.exec"),c={},f=function(){throw c},l={toString:f,valueOf:f};"symbol"==typeof Symbol.toPrimitive&&(l[Symbol.toPrimitive]=f),n=function(t){if(!t||"object"!=typeof t)return!1;var e=s(t,"lastIndex");if(!e||!a(e,"value"))return!1;try{u(t,l)}catch(t){return t===c}}}else{var h=i("Object.prototype.toString");n=function(t){return!(!t||"object"!=typeof t&&"function"!=typeof t)&&"[object RegExp]"===h(t)}}t.exports=n},4039:(t,e,r)=>{var n="undefined"!=typeof Symbol&&Symbol,i=r(1333);t.exports=function(){return"function"==typeof n&&"function"==typeof Symbol&&"symbol"==typeof n("foo")&&"symbol"==typeof Symbol("bar")&&i()}},4107:(t,e,r)=>{var n=r(6698),i=r(392),o=r(2861).Buffer,a=[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],s=new Array(64);function u(){this.init(),this._w=s,i.call(this,64,56)}function c(t,e,r){return r^t&(e^r)}function f(t,e,r){return t&e|r&(t|e)}function l(t){return(t>>>2|t<<30)^(t>>>13|t<<19)^(t>>>22|t<<10)}function h(t){return(t>>>6|t<<26)^(t>>>11|t<<21)^(t>>>25|t<<7)}function p(t){return(t>>>7|t<<25)^(t>>>18|t<<14)^t>>>3}function d(t){return(t>>>17|t<<15)^(t>>>19|t<<13)^t>>>10}n(u,i),u.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},u.prototype._update=function(t){for(var e=this._w,r=0|this._a,n=0|this._b,i=0|this._c,o=0|this._d,s=0|this._e,u=0|this._f,y=0|this._g,b=0|this._h,g=0;g<16;++g)e[g]=t.readInt32BE(4*g);for(;g<64;++g)e[g]=d(e[g-2])+e[g-7]+p(e[g-15])+e[g-16]|0;for(var v=0;v<64;++v){var w=b+h(s)+c(s,u,y)+a[v]+e[v]|0,m=l(r)+f(r,n,i)|0;b=y,y=u,u=s,s=o+w|0,o=i,i=n,n=r,r=w+m|0}this._a=r+this._a|0,this._b=n+this._b|0,this._c=i+this._c|0,this._d=o+this._d|0,this._e=s+this._e|0,this._f=u+this._f|0,this._g=y+this._g|0,this._h=b+this._h|0},u.prototype._hash=function(){var t=o.allocUnsafe(32);return t.writeInt32BE(this._a,0),t.writeInt32BE(this._b,4),t.writeInt32BE(this._c,8),t.writeInt32BE(this._d,12),t.writeInt32BE(this._e,16),t.writeInt32BE(this._f,20),t.writeInt32BE(this._g,24),t.writeInt32BE(this._h,28),t},t.exports=u},4133:(t,e,r)=>{var n=r(487),i=r(8452),o=r(3003),a=r(6642),s=r(2464),u=n(a(),Number);i(u,{getPolyfill:a,implementation:o,shim:s}),t.exports=u},4148:(t,e,r)=>{var n=r(5606);function i(t){return i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},i(t)}function o(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,s(n.key),n)}}function a(t,e,r){return e&&o(t.prototype,e),r&&o(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function s(t){var e=function(t){if("object"!==i(t)||null===t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!==i(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"===i(e)?e:String(e)}var u,c,f=r(9597).codes,l=f.ERR_AMBIGUOUS_ARGUMENT,h=f.ERR_INVALID_ARG_TYPE,p=f.ERR_INVALID_ARG_VALUE,d=f.ERR_INVALID_RETURN_VALUE,y=f.ERR_MISSING_ARGS,b=r(3918),g=r(537).inspect,v=r(537).types,w=v.isPromise,m=v.isRegExp,S=r(9133)(),_=r(9394)(),E=r(8075)("RegExp.prototype.test");function k(){var t=r(2299);u=t.isDeepEqual,c=t.isDeepStrictEqual}new Map;var O=!1,T=t.exports=x,A={};function I(t){if(t.message instanceof Error)throw t.message;throw new b(t)}function P(t,e,r,n){if(!r){var i=!1;if(0===e)i=!0,n="No value argument passed to `assert.ok()`";else if(n instanceof Error)throw n;var o=new b({actual:r,expected:!0,message:n,operator:"==",stackStartFn:t});throw o.generatedMessage=i,o}}function x(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];P.apply(void 0,[x,e.length].concat(e))}T.fail=function t(e,r,i,o,a){var s,u=arguments.length;if(0===u?s="Failed":1===u?(i=e,e=void 0):(!1===O&&(O=!0,(n.emitWarning?n.emitWarning:console.warn.bind(console))("assert.fail() with more than one argument is deprecated. Please use assert.strictEqual() instead or only pass a message.","DeprecationWarning","DEP0094")),2===u&&(o="!=")),i instanceof Error)throw i;var c={actual:e,expected:r,operator:void 0===o?"fail":o,stackStartFn:a||t};void 0!==i&&(c.message=i);var f=new b(c);throw s&&(f.message=s,f.generatedMessage=!0),f},T.AssertionError=b,T.ok=x,T.equal=function t(e,r,n){if(arguments.length<2)throw new y("actual","expected");e!=r&&I({actual:e,expected:r,message:n,operator:"==",stackStartFn:t})},T.notEqual=function t(e,r,n){if(arguments.length<2)throw new y("actual","expected");e==r&&I({actual:e,expected:r,message:n,operator:"!=",stackStartFn:t})},T.deepEqual=function t(e,r,n){if(arguments.length<2)throw new y("actual","expected");void 0===u&&k(),u(e,r)||I({actual:e,expected:r,message:n,operator:"deepEqual",stackStartFn:t})},T.notDeepEqual=function t(e,r,n){if(arguments.length<2)throw new y("actual","expected");void 0===u&&k(),u(e,r)&&I({actual:e,expected:r,message:n,operator:"notDeepEqual",stackStartFn:t})},T.deepStrictEqual=function t(e,r,n){if(arguments.length<2)throw new y("actual","expected");void 0===u&&k(),c(e,r)||I({actual:e,expected:r,message:n,operator:"deepStrictEqual",stackStartFn:t})},T.notDeepStrictEqual=function t(e,r,n){if(arguments.length<2)throw new y("actual","expected");void 0===u&&k(),c(e,r)&&I({actual:e,expected:r,message:n,operator:"notDeepStrictEqual",stackStartFn:t})},T.strictEqual=function t(e,r,n){if(arguments.length<2)throw new y("actual","expected");_(e,r)||I({actual:e,expected:r,message:n,operator:"strictEqual",stackStartFn:t})},T.notStrictEqual=function t(e,r,n){if(arguments.length<2)throw new y("actual","expected");_(e,r)&&I({actual:e,expected:r,message:n,operator:"notStrictEqual",stackStartFn:t})};var B=a(function t(e,r,n){var i=this;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),r.forEach(function(t){t in e&&(void 0!==n&&"string"==typeof n[t]&&m(e[t])&&E(e[t],n[t])?i[t]=n[t]:i[t]=e[t])})});function R(t,e,r,n){if("function"!=typeof e){if(m(e))return E(e,t);if(2===arguments.length)throw new h("expected",["Function","RegExp"],e);if("object"!==i(t)||null===t){var o=new b({actual:t,expected:e,message:r,operator:"deepStrictEqual",stackStartFn:n});throw o.operator=n.name,o}var a=Object.keys(e);if(e instanceof Error)a.push("name","message");else if(0===a.length)throw new p("error",e,"may not be an empty object");return void 0===u&&k(),a.forEach(function(i){"string"==typeof t[i]&&m(e[i])&&E(e[i],t[i])||function(t,e,r,n,i,o){if(!(r in t)||!c(t[r],e[r])){if(!n){var a=new B(t,i),s=new B(e,i,t),u=new b({actual:a,expected:s,operator:"deepStrictEqual",stackStartFn:o});throw u.actual=t,u.expected=e,u.operator=o.name,u}I({actual:t,expected:e,message:n,operator:o.name,stackStartFn:o})}}(t,e,i,r,a,n)}),!0}return void 0!==e.prototype&&t instanceof e||!Error.isPrototypeOf(e)&&!0===e.call({},t)}function U(t){if("function"!=typeof t)throw new h("fn","Function",t);try{t()}catch(t){return t}return A}function j(t){return w(t)||null!==t&&"object"===i(t)&&"function"==typeof t.then&&"function"==typeof t.catch}function N(t){return Promise.resolve().then(function(){var e;if("function"==typeof t){if(!j(e=t()))throw new d("instance of Promise","promiseFn",e)}else{if(!j(t))throw new h("promiseFn",["Function","Promise"],t);e=t}return Promise.resolve().then(function(){return e}).then(function(){return A}).catch(function(t){return t})})}function L(t,e,r,n){if("string"==typeof r){if(4===arguments.length)throw new h("error",["Object","Error","Function","RegExp"],r);if("object"===i(e)&&null!==e){if(e.message===r)throw new l("error/message",'The error message "'.concat(e.message,'" is identical to the message.'))}else if(e===r)throw new l("error/message",'The error "'.concat(e,'" is identical to the message.'));n=r,r=void 0}else if(null!=r&&"object"!==i(r)&&"function"!=typeof r)throw new h("error",["Object","Error","Function","RegExp"],r);if(e===A){var o="";r&&r.name&&(o+=" (".concat(r.name,")")),o+=n?": ".concat(n):".";var a="rejects"===t.name?"rejection":"exception";I({actual:void 0,expected:r,operator:t.name,message:"Missing expected ".concat(a).concat(o),stackStartFn:t})}if(r&&!R(e,r,n,t))throw e}function C(t,e,r,n){if(e!==A){if("string"==typeof r&&(n=r,r=void 0),!r||R(e,r)){var i=n?": ".concat(n):".",o="doesNotReject"===t.name?"rejection":"exception";I({actual:e,expected:r,operator:t.name,message:"Got unwanted ".concat(o).concat(i,"\n")+'Actual message: "'.concat(e&&e.message,'"'),stackStartFn:t})}throw e}}function F(t,e,r,n,o){if(!m(e))throw new h("regexp","RegExp",e);var a="match"===o;if("string"!=typeof t||E(e,t)!==a){if(r instanceof Error)throw r;var s=!r;r=r||("string"!=typeof t?'The "string" argument must be of type string. Received type '+"".concat(i(t)," (").concat(g(t),")"):(a?"The input did not match the regular expression ":"The input was expected to not match the regular expression ")+"".concat(g(e),". Input:\n\n").concat(g(t),"\n"));var u=new b({actual:t,expected:e,message:r,operator:o,stackStartFn:n});throw u.generatedMessage=s,u}}function D(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];P.apply(void 0,[D,e.length].concat(e))}T.throws=function t(e){for(var r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];L.apply(void 0,[t,U(e)].concat(n))},T.rejects=function t(e){for(var r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];return N(e).then(function(e){return L.apply(void 0,[t,e].concat(n))})},T.doesNotThrow=function t(e){for(var r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];C.apply(void 0,[t,U(e)].concat(n))},T.doesNotReject=function t(e){for(var r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];return N(e).then(function(e){return C.apply(void 0,[t,e].concat(n))})},T.ifError=function t(e){if(null!=e){var r="ifError got unwanted exception: ";"object"===i(e)&&"string"==typeof e.message?0===e.message.length&&e.constructor?r+=e.constructor.name:r+=e.message:r+=g(e);var n=new b({actual:e,expected:null,operator:"ifError",message:r,stackStartFn:t}),o=e.stack;if("string"==typeof o){var a=o.split("\n");a.shift();for(var s=n.stack.split("\n"),u=0;u<a.length;u++){var c=s.indexOf(a[u]);if(-1!==c){s=s.slice(0,c);break}}n.stack="".concat(s.join("\n"),"\n").concat(a.join("\n"))}throw n}},T.match=function t(e,r,n){F(e,r,n,t,"match")},T.doesNotMatch=function t(e,r,n){F(e,r,n,t,"doesNotMatch")},T.strict=S(D,T,{equal:T.strictEqual,deepEqual:T.deepStrictEqual,notEqual:T.notStrictEqual,notDeepEqual:T.notDeepStrictEqual}),T.strict.strict=T.strict},4257:(t,e,r)=>{var n=r(2463).F.ERR_STREAM_PREMATURE_CLOSE;function i(){}t.exports=function t(e,r,o){if("function"==typeof r)return t(e,null,r);r||(r={}),o=function(t){var e=!1;return function(){if(!e){e=!0;for(var r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];t.apply(this,n)}}}(o||i);var a=r.readable||!1!==r.readable&&e.readable,s=r.writable||!1!==r.writable&&e.writable,u=function(){e.writable||f()},c=e._writableState&&e._writableState.finished,f=function(){s=!1,c=!0,a||o.call(e)},l=e._readableState&&e._readableState.endEmitted,h=function(){a=!1,l=!0,s||o.call(e)},p=function(t){o.call(e,t)},d=function(){var t;return a&&!l?(e._readableState&&e._readableState.ended||(t=new n),o.call(e,t)):s&&!c?(e._writableState&&e._writableState.ended||(t=new n),o.call(e,t)):void 0},y=function(){e.req.on("finish",f)};return function(t){return t.setHeader&&"function"==typeof t.abort}(e)?(e.on("complete",f),e.on("abort",d),e.req?y():e.on("request",y)):s&&!e._writableState&&(e.on("end",u),e.on("close",u)),e.on("end",h),e.on("finish",f),!1!==r.error&&e.on("error",p),e.on("close",d),function(){e.removeListener("complete",f),e.removeListener("abort",d),e.removeListener("request",y),e.req&&e.req.removeListener("finish",f),e.removeListener("end",u),e.removeListener("close",u),e.removeListener("finish",f),e.removeListener("end",h),e.removeListener("error",p),e.removeListener("close",d)}}},4347:(t,e,r)=>{var n=r(5606);function i(t,e){a(t,e),o(t)}function o(t){t._writableState&&!t._writableState.emitClose||t._readableState&&!t._readableState.emitClose||t.emit("close")}function a(t,e){t.emit("error",e)}t.exports={destroy:function(t,e){var r=this,s=this._readableState&&this._readableState.destroyed,u=this._writableState&&this._writableState.destroyed;return s||u?(e?e(t):t&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,n.nextTick(a,this,t)):n.nextTick(a,this,t)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(t||null,function(t){!e&&t?r._writableState?r._writableState.errorEmitted?n.nextTick(o,r):(r._writableState.errorEmitted=!0,n.nextTick(i,r,t)):n.nextTick(i,r,t):e?(n.nextTick(o,r),e(t)):n.nextTick(o,r)}),this)},undestroy:function(){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)},errorOrDestroy:function(t,e){var r=t._readableState,n=t._writableState;r&&r.autoDestroy||n&&n.autoDestroy?t.destroy(e):t.emit("error",e)}}},4372:(t,e,r)=>{var n=r(9675),i=r(6556)("TypedArray.prototype.buffer",!0),o=r(5680);t.exports=i||function(t){if(!o(t))throw new n("Not a Typed Array");return t.buffer}},4442:t=>{t.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},4459:t=>{t.exports=Number.isNaN||function(t){return t!=t}},4643:(t,e,r)=>{function n(t){try{if(!r.g.localStorage)return!1}catch(t){return!1}var e=r.g.localStorage[t];return null!=e&&"true"===String(e).toLowerCase()}t.exports=function(t,e){if(n("noDeprecation"))return t;var r=!1;return function(){if(!r){if(n("throwDeprecation"))throw new Error(e);n("traceDeprecation")?console.trace(e):console.warn(e),r=!0}return t.apply(this,arguments)}}},4674:t=>{t.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},4729:(t,e,r)=>{var n=r(2861).Buffer,i=r(1603).Transform;function o(t){i.call(this),this._block=n.allocUnsafe(t),this._blockSize=t,this._blockOffset=0,this._length=[0,0,0,0],this._finalized=!1}r(6698)(o,i),o.prototype._transform=function(t,e,r){var n=null;try{this.update(t,e)}catch(t){n=t}r(n)},o.prototype._flush=function(t){var e=null;try{this.push(this.digest())}catch(t){e=t}t(e)},o.prototype.update=function(t,e){if(function(t){if(!n.isBuffer(t)&&"string"!=typeof t)throw new TypeError("Data must be a string or a buffer")}(t),this._finalized)throw new Error("Digest already called");n.isBuffer(t)||(t=n.from(t,e));for(var r=this._block,i=0;this._blockOffset+t.length-i>=this._blockSize;){for(var o=this._blockOffset;o<this._blockSize;)r[o++]=t[i++];this._update(),this._blockOffset=0}for(;i<t.length;)r[this._blockOffset++]=t[i++];for(var a=0,s=8*t.length;s>0;++a)this._length[a]+=s,(s=this._length[a]/4294967296|0)>0&&(this._length[a]-=4294967296*s);return this},o.prototype._update=function(){throw new Error("_update is not implemented")},o.prototype.digest=function(t){if(this._finalized)throw new Error("Digest already called");this._finalized=!0;var e=this._digest();void 0!==t&&(e=e.toString(t)),this._block.fill(0),this._blockOffset=0;for(var r=0;r<4;++r)this._length[r]=0;return e},o.prototype._digest=function(){throw new Error("_digest is not implemented")},t.exports=o},4743:(t,e,r)=>{var n,i=r(5606);function o(t,e,r){return(e=function(t){var e=function(t){if("object"!=typeof t||null===t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var a=r(5826),s=Symbol("lastResolve"),u=Symbol("lastReject"),c=Symbol("error"),f=Symbol("ended"),l=Symbol("lastPromise"),h=Symbol("handlePromise"),p=Symbol("stream");function d(t,e){return{value:t,done:e}}function y(t){var e=t[s];if(null!==e){var r=t[p].read();null!==r&&(t[l]=null,t[s]=null,t[u]=null,e(d(r,!1)))}}function b(t){i.nextTick(y,t)}var g=Object.getPrototypeOf(function(){}),v=Object.setPrototypeOf((o(n={get stream(){return this[p]},next:function(){var t=this,e=this[c];if(null!==e)return Promise.reject(e);if(this[f])return Promise.resolve(d(void 0,!0));if(this[p].destroyed)return new Promise(function(e,r){i.nextTick(function(){t[c]?r(t[c]):e(d(void 0,!0))})});var r,n=this[l];if(n)r=new Promise(function(t,e){return function(r,n){t.then(function(){e[f]?r(d(void 0,!0)):e[h](r,n)},n)}}(n,this));else{var o=this[p].read();if(null!==o)return Promise.resolve(d(o,!1));r=new Promise(this[h])}return this[l]=r,r}},Symbol.asyncIterator,function(){return this}),o(n,"return",function(){var t=this;return new Promise(function(e,r){t[p].destroy(null,function(t){t?r(t):e(d(void 0,!0))})})}),n),g);t.exports=function(t){var e,r=Object.create(v,(o(e={},p,{value:t,writable:!0}),o(e,s,{value:null,writable:!0}),o(e,u,{value:null,writable:!0}),o(e,c,{value:null,writable:!0}),o(e,f,{value:t._readableState.endEmitted,writable:!0}),o(e,h,{value:function(t,e){var n=r[p].read();n?(r[l]=null,r[s]=null,r[u]=null,t(d(n,!1))):(r[s]=t,r[u]=e)},writable:!0}),e));return r[l]=null,a(t,function(t){if(t&&"ERR_STREAM_PREMATURE_CLOSE"!==t.code){var e=r[u];return null!==e&&(r[l]=null,r[s]=null,r[u]=null,e(t)),void(r[c]=t)}var n=r[s];null!==n&&(r[l]=null,r[s]=null,r[u]=null,n(d(void 0,!0))),r[f]=!0}),t.on("readable",b.bind(null,r)),r}},4823:t=>{var e=function(){for(var t,e=[],r=0;r<256;r++){t=r;for(var n=0;n<8;n++)t=1&t?3988292384^t>>>1:t>>>1;e[r]=t}return e}();t.exports=function(t,r,n,i){var o=e,a=i+n;t^=-1;for(var s=i;s<a;s++)t=t>>>8^o[255&(t^r[s])];return-1^t}},4967:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.isNegativeLE=void 0,e.mod=d,e.pow=function(t,e,r){return _(T(r),t,e)},e.pow2=function(t,e,r){let n=t;for(;e-- >i;)n*=n,n%=r;return n},e.invert=y,e.tonelliShanks=w,e.FpSqrt=m,e.validateField=function(t){const e=S.reduce((t,e)=>(t[e]="function",t),{ORDER:"bigint",MASK:"bigint",BYTES:"number",BITS:"number"});return(0,n._validateObject)(t,e),t},e.FpPow=_,e.FpInvertBatch=E,e.FpDiv=function(t,e,r){return t.mul(e,"bigint"==typeof r?y(r,t.ORDER):t.inv(r))},e.FpLegendre=k,e.FpIsSquare=function(t,e){return 1===k(t,e)},e.nLength=O,e.Field=T,e.FpSqrtOdd=function(t,e){if(!t.isOdd)throw new Error("Field doesn't have isOdd");const r=t.sqrt(e);return t.isOdd(r)?r:t.neg(r)},e.FpSqrtEven=function(t,e){if(!t.isOdd)throw new Error("Field doesn't have isOdd");const r=t.sqrt(e);return t.isOdd(r)?t.neg(r):r},e.hashToPrivateScalar=function(t,e,r=!1){const i=(t=(0,n.ensureBytes)("privateHash",t)).length,a=O(e).nByteLength+8;if(a<24||i<a||i>1024)throw new Error("hashToPrivateScalar: expected "+a+"-1024 bytes of input, got "+i);return d(r?(0,n.bytesToNumberLE)(t):(0,n.bytesToNumberBE)(t),e-o)+o},e.getFieldBytesLength=A,e.getMinHashLength=I,e.mapHashToField=function(t,e,r=!1){const i=t.length,a=A(e),s=I(e);if(i<16||i<s||i>1024)throw new Error("expected "+s+"-1024 bytes of input, got "+i);const u=d(r?(0,n.bytesToNumberLE)(t):(0,n.bytesToNumberBE)(t),e-o)+o;return r?(0,n.numberToBytesLE)(u,a):(0,n.numberToBytesBE)(u,a)};const n=r(8627),i=BigInt(0),o=BigInt(1),a=BigInt(2),s=BigInt(3),u=BigInt(4),c=BigInt(5),f=BigInt(7),l=BigInt(8),h=BigInt(9),p=BigInt(16);function d(t,e){const r=t%e;return r>=i?r:e+r}function y(t,e){if(t===i)throw new Error("invert: expected non-zero number");if(e<=i)throw new Error("invert: expected positive modulus, got "+e);let r=d(t,e),n=e,a=i,s=o,u=o,c=i;for(;r!==i;){const t=n/r,e=n%r,i=a-u*t,o=s-c*t;n=r,r=e,a=u,s=c,u=i,c=o}if(n!==o)throw new Error("invert: does not exist");return d(a,e)}function b(t,e,r){if(!t.eql(t.sqr(e),r))throw new Error("Cannot find square root")}function g(t,e){const r=(t.ORDER+o)/u,n=t.pow(e,r);return b(t,n,e),n}function v(t,e){const r=(t.ORDER-c)/l,n=t.mul(e,a),i=t.pow(n,r),o=t.mul(e,i),s=t.mul(t.mul(o,a),i),u=t.mul(o,t.sub(s,t.ONE));return b(t,u,e),u}function w(t){if(t<s)throw new Error("sqrt is not defined for small field");let e=t-o,r=0;for(;e%a===i;)e/=a,r++;let n=a;const u=T(t);for(;1===k(u,n);)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(1===r)return g;let c=u.pow(n,e);const f=(e+o)/a;return function(t,n){if(t.is0(n))return n;if(1!==k(t,n))throw new Error("Cannot find square root");let i=r,a=t.mul(t.ONE,c),s=t.pow(n,e),u=t.pow(n,f);for(;!t.eql(s,t.ONE);){if(t.is0(s))return t.ZERO;let e=1,r=t.sqr(s);for(;!t.eql(r,t.ONE);)if(e++,r=t.sqr(r),e===i)throw new Error("Cannot find square root");const n=o<<BigInt(i-e-1),c=t.pow(a,n);i=e,a=t.sqr(c),s=t.mul(s,a),u=t.mul(u,c)}return u}}function m(t){return t%u===s?g:t%l===c?v:t%p===h?function(t){const e=T(t),r=w(t),n=r(e,e.neg(e.ONE)),i=r(e,n),o=r(e,e.neg(n)),a=(t+f)/p;return(t,e)=>{let r=t.pow(e,a),s=t.mul(r,n);const u=t.mul(r,i),c=t.mul(r,o),f=t.eql(t.sqr(s),e),l=t.eql(t.sqr(u),e);r=t.cmov(r,s,f),s=t.cmov(c,u,l);const h=t.eql(t.sqr(s),e),p=t.cmov(r,s,h);return b(t,p,e),p}}(t):w(t)}e.isNegativeLE=(t,e)=>(d(t,e)&o)===o;const S=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function _(t,e,r){if(r<i)throw new Error("invalid exponent, negatives unsupported");if(r===i)return t.ONE;if(r===o)return e;let n=t.ONE,a=e;for(;r>i;)r&o&&(n=t.mul(n,a)),a=t.sqr(a),r>>=o;return n}function E(t,e,r=!1){const n=new Array(e.length).fill(r?t.ZERO:void 0),i=e.reduce((e,r,i)=>t.is0(r)?e:(n[i]=e,t.mul(e,r)),t.ONE),o=t.inv(i);return e.reduceRight((e,r,i)=>t.is0(r)?e:(n[i]=t.mul(e,n[i]),t.mul(e,r)),o),n}function k(t,e){const r=(t.ORDER-o)/a,n=t.pow(e,r),i=t.eql(n,t.ONE),s=t.eql(n,t.ZERO),u=t.eql(n,t.neg(t.ONE));if(!i&&!s&&!u)throw new Error("invalid Legendre symbol result");return i?1:s?0:-1}function O(t,e){void 0!==e&&(0,n.anumber)(e);const r=void 0!==e?e:t.toString(2).length;return{nBitLength:r,nByteLength:Math.ceil(r/8)}}function T(t,e,r=!1,a={}){if(t<=i)throw new Error("invalid field: expected ORDER > 0, got "+t);let s,u,c,f=!1;if("object"==typeof e&&null!=e){if(a.sqrt||r)throw new Error("cannot specify opts in two arguments");const t=e;t.BITS&&(s=t.BITS),t.sqrt&&(u=t.sqrt),"boolean"==typeof t.isLE&&(r=t.isLE),"boolean"==typeof t.modFromBytes&&(f=t.modFromBytes),c=t.allowedLengths}else"number"==typeof e&&(s=e),a.sqrt&&(u=a.sqrt);const{nBitLength:l,nByteLength:h}=O(t,s);if(h>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let p;const b=Object.freeze({ORDER:t,isLE:r,BITS:l,BYTES:h,MASK:(0,n.bitMask)(l),ZERO:i,ONE:o,allowedLengths:c,create:e=>d(e,t),isValid:e=>{if("bigint"!=typeof e)throw new Error("invalid field element: expected bigint, got "+typeof e);return i<=e&&e<t},is0:t=>t===i,isValidNot0:t=>!b.is0(t)&&b.isValid(t),isOdd:t=>(t&o)===o,neg:e=>d(-e,t),eql:(t,e)=>t===e,sqr:e=>d(e*e,t),add:(e,r)=>d(e+r,t),sub:(e,r)=>d(e-r,t),mul:(e,r)=>d(e*r,t),pow:(t,e)=>_(b,t,e),div:(e,r)=>d(e*y(r,t),t),sqrN:t=>t*t,addN:(t,e)=>t+e,subN:(t,e)=>t-e,mulN:(t,e)=>t*e,inv:e=>y(e,t),sqrt:u||(e=>(p||(p=m(t)),p(b,e))),toBytes:t=>r?(0,n.numberToBytesLE)(t,h):(0,n.numberToBytesBE)(t,h),fromBytes:(e,i=!0)=>{if(c){if(!c.includes(e.length)||e.length>h)throw new Error("Field.fromBytes: expected "+c+" bytes, got "+e.length);const t=new Uint8Array(h);t.set(e,r?0:t.length-e.length),e=t}if(e.length!==h)throw new Error("Field.fromBytes: expected "+h+" bytes, got "+e.length);let o=r?(0,n.bytesToNumberLE)(e):(0,n.bytesToNumberBE)(e);if(f&&(o=d(o,t)),!i&&!b.isValid(o))throw new Error("invalid field element: outside of range 0..ORDER");return o},invertBatch:t=>E(b,t),cmov:(t,e,r)=>r?e:t});return Object.freeze(b)}function A(t){if("bigint"!=typeof t)throw new Error("field order must be bigint");const e=t.toString(2).length;return Math.ceil(e/8)}function I(t){const e=A(t);return e+Math.ceil(e/2)}},5034:(t,e,r)=>{var n,i=r(5606);function o(t,e,r){return(e=function(t){var e=function(t){if("object"!=typeof t||null===t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var a=r(4257),s=Symbol("lastResolve"),u=Symbol("lastReject"),c=Symbol("error"),f=Symbol("ended"),l=Symbol("lastPromise"),h=Symbol("handlePromise"),p=Symbol("stream");function d(t,e){return{value:t,done:e}}function y(t){var e=t[s];if(null!==e){var r=t[p].read();null!==r&&(t[l]=null,t[s]=null,t[u]=null,e(d(r,!1)))}}function b(t){i.nextTick(y,t)}var g=Object.getPrototypeOf(function(){}),v=Object.setPrototypeOf((o(n={get stream(){return this[p]},next:function(){var t=this,e=this[c];if(null!==e)return Promise.reject(e);if(this[f])return Promise.resolve(d(void 0,!0));if(this[p].destroyed)return new Promise(function(e,r){i.nextTick(function(){t[c]?r(t[c]):e(d(void 0,!0))})});var r,n=this[l];if(n)r=new Promise(function(t,e){return function(r,n){t.then(function(){e[f]?r(d(void 0,!0)):e[h](r,n)},n)}}(n,this));else{var o=this[p].read();if(null!==o)return Promise.resolve(d(o,!1));r=new Promise(this[h])}return this[l]=r,r}},Symbol.asyncIterator,function(){return this}),o(n,"return",function(){var t=this;return new Promise(function(e,r){t[p].destroy(null,function(t){t?r(t):e(d(void 0,!0))})})}),n),g);t.exports=function(t){var e,r=Object.create(v,(o(e={},p,{value:t,writable:!0}),o(e,s,{value:null,writable:!0}),o(e,u,{value:null,writable:!0}),o(e,c,{value:null,writable:!0}),o(e,f,{value:t._readableState.endEmitted,writable:!0}),o(e,h,{value:function(t,e){var n=r[p].read();n?(r[l]=null,r[s]=null,r[u]=null,t(d(n,!1))):(r[s]=t,r[u]=e)},writable:!0}),e));return r[l]=null,a(t,function(t){if(t&&"ERR_STREAM_PREMATURE_CLOSE"!==t.code){var e=r[u];return null!==e&&(r[l]=null,r[s]=null,r[u]=null,e(t)),void(r[c]=t)}var n=r[s];null!==n&&(r[l]=null,r[s]=null,r[u]=null,n(d(void 0,!0))),r[f]=!0}),t.on("readable",b.bind(null,r)),r}},5049:t=>{t.exports=function(){throw new Error("Readable.from is not available in the browser")}},5145:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.crypto=void 0,e.crypto="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0},5170:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),e.ECPairFactory=e.networks=void 0;const i=r(5249);e.networks=i;const o=r(953),a=r(3209),s=r(8377),u=r(709),c=o.typeforce.maybe(o.typeforce.compile({compressed:o.maybe(o.Boolean),network:o.maybe(o.Network)}));e.ECPairFactory=function(t){function e(e,r){if(o.typeforce(o.Buffer256bit,e),!t.isPrivate(e))throw new TypeError("Private key not in range [1, n)");return o.typeforce(c,r),new f(e,void 0,r)}function r(e,r){return o.typeforce(t.isPoint,e),o.typeforce(c,r),new f(void 0,e,r)}(0,u.testEcc)(t);class f{__D;__Q;compressed;network;lowR;constructor(e,r,o){this.__D=e,this.__Q=r,this.lowR=!1,void 0===o&&(o={}),this.compressed=void 0===o.compressed||o.compressed,this.network=o.network||i.bitcoin,void 0!==r&&(this.__Q=n.from(t.pointCompress(r,this.compressed)))}get privateKey(){return this.__D}get publicKey(){if(!this.__Q){const e=t.pointFromScalar(this.__D,this.compressed);this.__Q=n.from(e)}return this.__Q}toWIF(){if(!this.__D)throw new Error("Missing private key");return s.encode(this.network.wif,this.__D,this.compressed)}tweak(t){return this.privateKey?this.tweakFromPrivateKey(t):this.tweakFromPublicKey(t)}sign(e,r){if(!this.__D)throw new Error("Missing private key");if(void 0===r&&(r=this.lowR),!1===r)return n.from(t.sign(e,this.__D));{let r=t.sign(e,this.__D);const i=n.alloc(32,0);let o=0;for(;r[0]>127;)o++,i.writeUIntLE(o,0,6),r=t.sign(e,this.__D,i);return n.from(r)}}signSchnorr(e){if(!this.privateKey)throw new Error("Missing private key");if(!t.signSchnorr)throw new Error("signSchnorr not supported by ecc library");return n.from(t.signSchnorr(e,this.privateKey))}verify(e,r){return t.verify(e,this.publicKey,r)}verifySchnorr(e,r){if(!t.verifySchnorr)throw new Error("verifySchnorr not supported by ecc library");return t.verifySchnorr(e,this.publicKey.subarray(1,33),r)}tweakFromPublicKey(e){const i=32===(o=this.publicKey).length?o:o.slice(1,33);var o;const a=t.xOnlyPointAddTweak(i,e);if(!a||null===a.xOnlyPubkey)throw new Error("Cannot tweak public key!");const s=n.from([0===a.parity?2:3]);return r(n.concat([s,a.xOnlyPubkey]),{network:this.network,compressed:this.compressed})}tweakFromPrivateKey(r){const i=3!==this.publicKey[0]&&(4!==this.publicKey[0]||1&~this.publicKey[64])?this.privateKey:t.privateNegate(this.privateKey),o=t.privateAdd(i,r);if(!o)throw new Error("Invalid tweaked private key!");return e(n.from(o),{network:this.network,compressed:this.compressed})}}return{isPoint:function(e){return t.isPoint(e)},fromPrivateKey:e,fromPublicKey:r,fromWIF:function(t,r){const n=s.decode(t),a=n.version;if(o.Array(r)){if(r=r.filter(t=>a===t.wif).pop(),!r)throw new Error("Unknown network version")}else if(r=r||i.bitcoin,a!==r.wif)throw new Error("Invalid network version");return e(n.privateKey,{compressed:n.compressed,network:r})},makeRandom:function(r){o.typeforce(c,r),void 0===r&&(r={});const n=r.rng||a;let i;do{i=n(32),o.typeforce(o.Buffer256bit,i)}while(!t.isPrivate(i));return e(i,r)}}}},5249:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.testnet=e.bitcoin=void 0,e.bitcoin={messagePrefix:"Bitcoin Signed Message:\n",bech32:"bc",bip32:{public:76067358,private:76066276},pubKeyHash:0,scriptHash:5,wif:128},e.testnet={messagePrefix:"Bitcoin Signed Message:\n",bech32:"tb",bip32:{public:70617039,private:70615956},pubKeyHash:111,scriptHash:196,wif:239}},5267:(t,e,r)=>{var n,i=r(2463).F,o=i.ERR_MISSING_ARGS,a=i.ERR_STREAM_DESTROYED;function s(t){if(t)throw t}function u(t){t()}function c(t,e){return t.pipe(e)}t.exports=function(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];var f,l=function(t){return t.length?"function"!=typeof t[t.length-1]?s:t.pop():s}(e);if(Array.isArray(e[0])&&(e=e[0]),e.length<2)throw new o("streams");var h=e.map(function(t,i){var o=i<e.length-1;return function(t,e,i,o){o=function(t){var e=!1;return function(){e||(e=!0,t.apply(void 0,arguments))}}(o);var s=!1;t.on("close",function(){s=!0}),void 0===n&&(n=r(4257)),n(t,{readable:e,writable:i},function(t){if(t)return o(t);s=!0,o()});var u=!1;return function(e){if(!s&&!u)return u=!0,function(t){return t.setHeader&&"function"==typeof t.abort}(t)?t.abort():"function"==typeof t.destroy?t.destroy():void o(e||new a("pipe"))}}(t,o,i>0,function(t){f||(f=t),t&&h.forEach(u),o||(h.forEach(u),l(f))})});return e.reduce(c)}},5345:t=>{t.exports=URIError},5377:(t,e,r)=>{var n=r(2861).Buffer,i=r(2006),o=r(4372),a=ArrayBuffer.isView||function(t){try{return o(t),!0}catch(t){return!1}},s="undefined"!=typeof Uint8Array,u="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof Uint8Array,c=u&&(n.prototype instanceof Uint8Array||n.TYPED_ARRAY_SUPPORT);t.exports=function(t,e){if(t instanceof n)return t;if("string"==typeof t)return n.from(t,e);if(u&&a(t)){if(0===t.byteLength)return n.alloc(0);if(c){var r=n.from(t.buffer,t.byteOffset,t.byteLength);if(r.byteLength===t.byteLength)return r}var o=t instanceof Uint8Array?t:new Uint8Array(t.buffer,t.byteOffset,t.byteLength),f=n.from(o);if(f.length===t.byteLength)return f}if(s&&t instanceof Uint8Array)return n.from(t);var l=i(t);if(l)for(var h=0;h<t.length;h+=1){var p=t[h];if("number"!=typeof p||p<0||p>255||~~p!==p)throw new RangeError("Array items must be numbers in the range 0-255.")}if(l||n.isBuffer(t)&&t.constructor&&"function"==typeof t.constructor.isBuffer&&t.constructor.isBuffer(t))return n.from(t);throw new TypeError('The "data" argument must be a string, an Array, a Buffer, a Uint8Array, or a DataView.')}},5606:t=>{var e,r,n=t.exports={};function i(){throw new Error("setTimeout has not been defined")}function o(){throw new Error("clearTimeout has not been defined")}function a(t){if(e===setTimeout)return setTimeout(t,0);if((e===i||!e)&&setTimeout)return e=setTimeout,setTimeout(t,0);try{return e(t,0)}catch(r){try{return e.call(null,t,0)}catch(r){return e.call(this,t,0)}}}!function(){try{e="function"==typeof setTimeout?setTimeout:i}catch(t){e=i}try{r="function"==typeof clearTimeout?clearTimeout:o}catch(t){r=o}}();var s,u=[],c=!1,f=-1;function l(){c&&s&&(c=!1,s.length?u=s.concat(u):f=-1,u.length&&h())}function h(){if(!c){var t=a(l);c=!0;for(var e=u.length;e;){for(s=u,u=[];++f<e;)s&&s[f].run();f=-1,e=u.length}s=null,c=!1,function(t){if(r===clearTimeout)return clearTimeout(t);if((r===o||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(t);try{return r(t)}catch(e){try{return r.call(null,t)}catch(e){return r.call(this,t)}}}(t)}}function p(t,e){this.fun=t,this.array=e}function d(){}n.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)e[r-1]=arguments[r];u.push(new p(t,e)),1!==u.length||c||a(h)},p.prototype.run=function(){this.fun.apply(null,this.array)},n.title="browser",n.browser=!0,n.env={},n.argv=[],n.version="",n.versions={},n.on=d,n.addListener=d,n.once=d,n.off=d,n.removeListener=d,n.removeAllListeners=d,n.emit=d,n.prependListener=d,n.prependOnceListener=d,n.listeners=function(t){return[]},n.binding=function(t){throw new Error("process.binding is not supported")},n.cwd=function(){return"/"},n.chdir=function(t){throw new Error("process.chdir is not supported")},n.umask=function(){return 0}},5680:(t,e,r)=>{var n=r(5767);t.exports=function(t){return!!n(t)}},5767:(t,e,r)=>{var n=r(2682),i=r(9209),o=r(487),a=r(6556),s=r(5795),u=r(3628),c=a("Object.prototype.toString"),f=r(9092)(),l="undefined"==typeof globalThis?r.g:globalThis,h=i(),p=a("String.prototype.slice"),d=a("Array.prototype.indexOf",!0)||function(t,e){for(var r=0;r<t.length;r+=1)if(t[r]===e)return r;return-1},y={__proto__:null};n(h,f&&s&&u?function(t){var e=new l[t];if(Symbol.toStringTag in e&&u){var r=u(e),n=s(r,Symbol.toStringTag);if(!n&&r){var i=u(r);n=s(i,Symbol.toStringTag)}y["$"+t]=o(n.get)}}:function(t){var e=new l[t],r=e.slice||e.set;r&&(y["$"+t]=o(r))}),t.exports=function(t){if(!t||"object"!=typeof t)return!1;if(!f){var e=p(c(t),8,-1);return d(h,e)>-1?e:"Object"===e&&function(t){var e=!1;return n(y,function(r,n){if(!e)try{r(t),e=p(n,1)}catch(t){}}),e}(t)}return s?function(t){var e=!1;return n(y,function(r,n){if(!e)try{"$"+r(t)===n&&(e=p(n,1))}catch(t){}}),e}(t):null}},5795:(t,e,r)=>{var n=r(6549);if(n)try{n([],"length")}catch(t){n=null}t.exports=n},5826:(t,e,r)=>{var n=r(2260).F.ERR_STREAM_PREMATURE_CLOSE;function i(){}t.exports=function t(e,r,o){if("function"==typeof r)return t(e,null,r);r||(r={}),o=function(t){var e=!1;return function(){if(!e){e=!0;for(var r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];t.apply(this,n)}}}(o||i);var a=r.readable||!1!==r.readable&&e.readable,s=r.writable||!1!==r.writable&&e.writable,u=function(){e.writable||f()},c=e._writableState&&e._writableState.finished,f=function(){s=!1,c=!0,a||o.call(e)},l=e._readableState&&e._readableState.endEmitted,h=function(){a=!1,l=!0,s||o.call(e)},p=function(t){o.call(e,t)},d=function(){var t;return a&&!l?(e._readableState&&e._readableState.ended||(t=new n),o.call(e,t)):s&&!c?(e._writableState&&e._writableState.ended||(t=new n),o.call(e,t)):void 0},y=function(){e.req.on("finish",f)};return function(t){return t.setHeader&&"function"==typeof t.abort}(e)?(e.on("complete",f),e.on("abort",d),e.req?y():e.on("request",y)):s&&!e._writableState&&(e.on("end",u),e.on("close",u)),e.on("end",h),e.on("finish",f),!1!==r.error&&e.on("error",p),e.on("close",d),function(){e.removeListener("complete",f),e.removeListener("abort",d),e.removeListener("request",y),e.req&&e.req.removeListener("finish",f),e.removeListener("end",u),e.removeListener("close",u),e.removeListener("finish",f),e.removeListener("end",h),e.removeListener("error",p),e.removeListener("close",d)}}},5860:(t,e,r)=>{t.exports=i;var n=r(3054);function i(t){if(!(this instanceof i))return new i(t);n.call(this,t)}r(6698)(i,n),i.prototype._transform=function(t,e,r){r(null,t)}},5880:t=>{t.exports=Math.pow},5974:(t,e,r)=>{var n=r(8287).Buffer,i=r(5606),o=r(4148),a=r(4442),s=r(8411),u=r(1447),c=r(9681);for(var f in c)e[f]=c[f];function l(t){if("number"!=typeof t||t<e.DEFLATE||t>e.UNZIP)throw new TypeError("Bad argument");this.dictionary=null,this.err=0,this.flush=0,this.init_done=!1,this.level=0,this.memLevel=0,this.mode=t,this.strategy=0,this.windowBits=0,this.write_in_progress=!1,this.pending_close=!1,this.gzip_id_bytes_read=0}e.NONE=0,e.DEFLATE=1,e.INFLATE=2,e.GZIP=3,e.GUNZIP=4,e.DEFLATERAW=5,e.INFLATERAW=6,e.UNZIP=7,l.prototype.close=function(){this.write_in_progress?this.pending_close=!0:(this.pending_close=!1,o(this.init_done,"close before init"),o(this.mode<=e.UNZIP),this.mode===e.DEFLATE||this.mode===e.GZIP||this.mode===e.DEFLATERAW?s.deflateEnd(this.strm):this.mode!==e.INFLATE&&this.mode!==e.GUNZIP&&this.mode!==e.INFLATERAW&&this.mode!==e.UNZIP||u.inflateEnd(this.strm),this.mode=e.NONE,this.dictionary=null)},l.prototype.write=function(t,e,r,n,i,o,a){return this._write(!0,t,e,r,n,i,o,a)},l.prototype.writeSync=function(t,e,r,n,i,o,a){return this._write(!1,t,e,r,n,i,o,a)},l.prototype._write=function(t,r,a,s,u,c,f,l){if(o.equal(arguments.length,8),o(this.init_done,"write before init"),o(this.mode!==e.NONE,"already finalized"),o.equal(!1,this.write_in_progress,"write already in progress"),o.equal(!1,this.pending_close,"close is pending"),this.write_in_progress=!0,o.equal(!1,void 0===r,"must provide flush value"),this.write_in_progress=!0,r!==e.Z_NO_FLUSH&&r!==e.Z_PARTIAL_FLUSH&&r!==e.Z_SYNC_FLUSH&&r!==e.Z_FULL_FLUSH&&r!==e.Z_FINISH&&r!==e.Z_BLOCK)throw new Error("Invalid flush value");if(null==a&&(a=n.alloc(0),u=0,s=0),this.strm.avail_in=u,this.strm.input=a,this.strm.next_in=s,this.strm.avail_out=l,this.strm.output=c,this.strm.next_out=f,this.flush=r,!t)return this._process(),this._checkError()?this._afterSync():void 0;var h=this;return i.nextTick(function(){h._process(),h._after()}),this},l.prototype._afterSync=function(){var t=this.strm.avail_out,e=this.strm.avail_in;return this.write_in_progress=!1,[e,t]},l.prototype._process=function(){var t=null;switch(this.mode){case e.DEFLATE:case e.GZIP:case e.DEFLATERAW:this.err=s.deflate(this.strm,this.flush);break;case e.UNZIP:switch(this.strm.avail_in>0&&(t=this.strm.next_in),this.gzip_id_bytes_read){case 0:if(null===t)break;if(31!==this.strm.input[t]){this.mode=e.INFLATE;break}if(this.gzip_id_bytes_read=1,t++,1===this.strm.avail_in)break;case 1:if(null===t)break;139===this.strm.input[t]?(this.gzip_id_bytes_read=2,this.mode=e.GUNZIP):this.mode=e.INFLATE;break;default:throw new Error("invalid number of gzip magic number bytes read")}case e.INFLATE:case e.GUNZIP:case e.INFLATERAW:for(this.err=u.inflate(this.strm,this.flush),this.err===e.Z_NEED_DICT&&this.dictionary&&(this.err=u.inflateSetDictionary(this.strm,this.dictionary),this.err===e.Z_OK?this.err=u.inflate(this.strm,this.flush):this.err===e.Z_DATA_ERROR&&(this.err=e.Z_NEED_DICT));this.strm.avail_in>0&&this.mode===e.GUNZIP&&this.err===e.Z_STREAM_END&&0!==this.strm.next_in[0];)this.reset(),this.err=u.inflate(this.strm,this.flush);break;default:throw new Error("Unknown mode "+this.mode)}},l.prototype._checkError=function(){switch(this.err){case e.Z_OK:case e.Z_BUF_ERROR:if(0!==this.strm.avail_out&&this.flush===e.Z_FINISH)return this._error("unexpected end of file"),!1;break;case e.Z_STREAM_END:break;case e.Z_NEED_DICT:return null==this.dictionary?this._error("Missing dictionary"):this._error("Bad dictionary"),!1;default:return this._error("Zlib error"),!1}return!0},l.prototype._after=function(){if(this._checkError()){var t=this.strm.avail_out,e=this.strm.avail_in;this.write_in_progress=!1,this.callback(e,t),this.pending_close&&this.close()}},l.prototype._error=function(t){this.strm.msg&&(t=this.strm.msg),this.onerror(t,this.err),this.write_in_progress=!1,this.pending_close&&this.close()},l.prototype.init=function(t,r,n,i,a){o(4===arguments.length||5===arguments.length,"init(windowBits, level, memLevel, strategy, [dictionary])"),o(t>=8&&t<=15,"invalid windowBits"),o(r>=-1&&r<=9,"invalid compression level"),o(n>=1&&n<=9,"invalid memlevel"),o(i===e.Z_FILTERED||i===e.Z_HUFFMAN_ONLY||i===e.Z_RLE||i===e.Z_FIXED||i===e.Z_DEFAULT_STRATEGY,"invalid strategy"),this._init(r,t,n,i,a),this._setDictionary()},l.prototype.params=function(){throw new Error("deflateParams Not supported")},l.prototype.reset=function(){this._reset(),this._setDictionary()},l.prototype._init=function(t,r,n,i,o){switch(this.level=t,this.windowBits=r,this.memLevel=n,this.strategy=i,this.flush=e.Z_NO_FLUSH,this.err=e.Z_OK,this.mode!==e.GZIP&&this.mode!==e.GUNZIP||(this.windowBits+=16),this.mode===e.UNZIP&&(this.windowBits+=32),this.mode!==e.DEFLATERAW&&this.mode!==e.INFLATERAW||(this.windowBits=-1*this.windowBits),this.strm=new a,this.mode){case e.DEFLATE:case e.GZIP:case e.DEFLATERAW:this.err=s.deflateInit2(this.strm,this.level,e.Z_DEFLATED,this.windowBits,this.memLevel,this.strategy);break;case e.INFLATE:case e.GUNZIP:case e.INFLATERAW:case e.UNZIP:this.err=u.inflateInit2(this.strm,this.windowBits);break;default:throw new Error("Unknown mode "+this.mode)}this.err!==e.Z_OK&&this._error("Init error"),this.dictionary=o,this.write_in_progress=!1,this.init_done=!0},l.prototype._setDictionary=function(){if(null!=this.dictionary){switch(this.err=e.Z_OK,this.mode){case e.DEFLATE:case e.DEFLATERAW:this.err=s.deflateSetDictionary(this.strm,this.dictionary)}this.err!==e.Z_OK&&this._error("Failed to set dictionary")}},l.prototype._reset=function(){switch(this.err=e.Z_OK,this.mode){case e.DEFLATE:case e.DEFLATERAW:case e.GZIP:this.err=s.deflateReset(this.strm);break;case e.INFLATE:case e.INFLATERAW:case e.GUNZIP:this.err=u.inflateReset(this.strm)}this.err!==e.Z_OK&&this._error("Failed to reset stream")},e.Zlib=l},6011:(t,e,r)=>{var n=r(8287).Buffer,i=r(6698),o=r(4729),a=new Array(16),s=[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],u=[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],c=[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],f=[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],l=[0,1518500249,1859775393,2400959708,2840853838],h=[1352829926,1548603684,1836072691,2053994217,0];function p(){o.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520}function d(t,e){return t<<e|t>>>32-e}function y(t,e,r,n,i,o,a,s){return d(t+(e^r^n)+o+a|0,s)+i|0}function b(t,e,r,n,i,o,a,s){return d(t+(e&r|~e&n)+o+a|0,s)+i|0}function g(t,e,r,n,i,o,a,s){return d(t+((e|~r)^n)+o+a|0,s)+i|0}function v(t,e,r,n,i,o,a,s){return d(t+(e&n|r&~n)+o+a|0,s)+i|0}function w(t,e,r,n,i,o,a,s){return d(t+(e^(r|~n))+o+a|0,s)+i|0}i(p,o),p.prototype._update=function(){for(var t=a,e=0;e<16;++e)t[e]=this._block.readInt32LE(4*e);for(var r=0|this._a,n=0|this._b,i=0|this._c,o=0|this._d,p=0|this._e,m=0|this._a,S=0|this._b,_=0|this._c,E=0|this._d,k=0|this._e,O=0;O<80;O+=1){var T,A;O<16?(T=y(r,n,i,o,p,t[s[O]],l[0],c[O]),A=w(m,S,_,E,k,t[u[O]],h[0],f[O])):O<32?(T=b(r,n,i,o,p,t[s[O]],l[1],c[O]),A=v(m,S,_,E,k,t[u[O]],h[1],f[O])):O<48?(T=g(r,n,i,o,p,t[s[O]],l[2],c[O]),A=g(m,S,_,E,k,t[u[O]],h[2],f[O])):O<64?(T=v(r,n,i,o,p,t[s[O]],l[3],c[O]),A=b(m,S,_,E,k,t[u[O]],h[3],f[O])):(T=w(r,n,i,o,p,t[s[O]],l[4],c[O]),A=y(m,S,_,E,k,t[u[O]],h[4],f[O])),r=p,p=o,o=d(i,10),i=n,n=T,m=k,k=E,E=d(_,10),_=S,S=A}var I=this._b+i+E|0;this._b=this._c+o+k|0,this._c=this._d+p+m|0,this._d=this._e+r+S|0,this._e=this._a+n+_|0,this._a=I},p.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var t=n.alloc?n.alloc(20):new n(20);return t.writeInt32LE(this._a,0),t.writeInt32LE(this._b,4),t.writeInt32LE(this._c,8),t.writeInt32LE(this._d,12),t.writeInt32LE(this._e,16),t},t.exports=p},6168:(t,e,r)=>{var n=r(2861).Buffer,i=r(8310).Transform,o=r(9579).I;function a(t){i.call(this),this.hashMode="string"==typeof t,this.hashMode?this[t]=this._finalOrDigest:this.final=this._finalOrDigest,this._final&&(this.__final=this._final,this._final=null),this._decoder=null,this._encoding=null}r(6698)(a,i);var s="undefined"!=typeof Uint8Array,u="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof Uint8Array&&ArrayBuffer.isView&&(n.prototype instanceof Uint8Array||n.TYPED_ARRAY_SUPPORT);a.prototype.update=function(t,e,r){var i=function(t,e){if(t instanceof n)return t;if("string"==typeof t)return n.from(t,e);if(u&&ArrayBuffer.isView(t)){if(0===t.byteLength)return n.alloc(0);var r=n.from(t.buffer,t.byteOffset,t.byteLength);if(r.byteLength===t.byteLength)return r}if(s&&t instanceof Uint8Array)return n.from(t);if(n.isBuffer(t)&&t.constructor&&"function"==typeof t.constructor.isBuffer&&t.constructor.isBuffer(t))return n.from(t);throw new TypeError('The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView.')}(t,e),o=this._update(i);return this.hashMode?this:(r&&(o=this._toString(o,r)),o)},a.prototype.setAutoPadding=function(){},a.prototype.getAuthTag=function(){throw new Error("trying to get auth tag in unsupported state")},a.prototype.setAuthTag=function(){throw new Error("trying to set auth tag in unsupported state")},a.prototype.setAAD=function(){throw new Error("trying to set aad in unsupported state")},a.prototype._transform=function(t,e,r){var n;try{this.hashMode?this._update(t):this.push(this._update(t))}catch(t){n=t}finally{r(n)}},a.prototype._flush=function(t){var e;try{this.push(this.__final())}catch(t){e=t}t(e)},a.prototype._finalOrDigest=function(t){var e=this.__final()||n.alloc(0);return t&&(e=this._toString(e,t,!0)),e},a.prototype._toString=function(t,e,r){if(this._decoder||(this._decoder=new o(e),this._encoding=e),this._encoding!==e)throw new Error("can’t switch encodings");var n=this._decoder.write(t);return r&&(n+=this._decoder.end()),n},t.exports=a},6188:t=>{t.exports=Math.max},6549:t=>{t.exports=Object.getOwnPropertyDescriptor},6556:(t,e,r)=>{var n=r(453),i=r(3126),o=i([n("%String.prototype.indexOf%")]);t.exports=function(t,e){var r=n(t,!!e);return"function"==typeof r&&o(t,".prototype.")>-1?i([r]):r}},6576:(t,e,r)=>{var n=r(9394),i=r(8452);t.exports=function(){var t=n();return i(Object,{is:t},{is:function(){return Object.is!==t}}),t}},6578:t=>{t.exports=["Float16Array","Float32Array","Float64Array","Int8Array","Int16Array","Int32Array","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array"]},6642:(t,e,r)=>{var n=r(3003);t.exports=function(){return Number.isNaN&&Number.isNaN(NaN)&&!Number.isNaN("a")?Number.isNaN:n}},6644:(t,e,r)=>{var n=r(2463).F.ERR_INVALID_OPT_VALUE;t.exports={getHighWaterMark:function(t,e,r,i){var o=function(t,e,r){return null!=t.highWaterMark?t.highWaterMark:e?t[r]:null}(e,i,r);if(null!=o){if(!isFinite(o)||Math.floor(o)!==o||o<0)throw new n(i?r:"highWaterMark",o);return Math.floor(o)}return t.objectMode?16:16384}}},6698:t=>{"function"==typeof Object.create?t.exports=function(t,e){e&&(t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:t.exports=function(t,e){if(e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}}},6710:(t,e,r)=>{var n=r(6698),i=r(4107),o=r(392),a=r(2861).Buffer,s=new Array(64);function u(){this.init(),this._w=s,o.call(this,64,56)}n(u,i),u.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},u.prototype._hash=function(){var t=a.allocUnsafe(28);return t.writeInt32BE(this._a,0),t.writeInt32BE(this._b,4),t.writeInt32BE(this._c,8),t.writeInt32BE(this._d,12),t.writeInt32BE(this._e,16),t.writeInt32BE(this._f,20),t.writeInt32BE(this._g,24),t},t.exports=u},6736:(t,e,r)=>{var n,i=r(5606);t.exports=O,O.ReadableState=k,r(7007).EventEmitter;var o,a=function(t,e){return t.listeners(e).length},s=r(1181),u=r(8287).Buffer,c=(void 0!==r.g?r.g:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{}).Uint8Array||function(){},f=r(2382);o=f&&f.debuglog?f.debuglog("stream"):function(){};var l,h,p,d=r(2389),y=r(1468),b=r(8775).getHighWaterMark,g=r(2260).F,v=g.ERR_INVALID_ARG_TYPE,w=g.ERR_STREAM_PUSH_AFTER_EOF,m=g.ERR_METHOD_NOT_IMPLEMENTED,S=g.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;r(6698)(O,s);var _=y.errorOrDestroy,E=["error","close","destroy","pause","resume"];function k(t,e,i){n=n||r(2818),t=t||{},"boolean"!=typeof i&&(i=e instanceof n),this.objectMode=!!t.objectMode,i&&(this.objectMode=this.objectMode||!!t.readableObjectMode),this.highWaterMark=b(this,t,"readableHighWaterMark",i),this.buffer=new d,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=!1!==t.emitClose,this.autoDestroy=!!t.autoDestroy,this.destroyed=!1,this.defaultEncoding=t.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,t.encoding&&(l||(l=r(7137).I),this.decoder=new l(t.encoding),this.encoding=t.encoding)}function O(t){if(n=n||r(2818),!(this instanceof O))return new O(t);var e=this instanceof n;this._readableState=new k(t,this,e),this.readable=!0,t&&("function"==typeof t.read&&(this._read=t.read),"function"==typeof t.destroy&&(this._destroy=t.destroy)),s.call(this)}function T(t,e,r,n,i){o("readableAddChunk",e);var a,s=t._readableState;if(null===e)s.reading=!1,function(t,e){if(o("onEofChunk"),!e.ended){if(e.decoder){var r=e.decoder.end();r&&r.length&&(e.buffer.push(r),e.length+=e.objectMode?1:r.length)}e.ended=!0,e.sync?x(t):(e.needReadable=!1,e.emittedReadable||(e.emittedReadable=!0,B(t)))}}(t,s);else if(i||(a=function(t,e){var r,n;return n=e,u.isBuffer(n)||n instanceof c||"string"==typeof e||void 0===e||t.objectMode||(r=new v("chunk",["string","Buffer","Uint8Array"],e)),r}(s,e)),a)_(t,a);else if(s.objectMode||e&&e.length>0)if("string"==typeof e||s.objectMode||Object.getPrototypeOf(e)===u.prototype||(e=function(t){return u.from(t)}(e)),n)s.endEmitted?_(t,new S):A(t,s,e,!0);else if(s.ended)_(t,new w);else{if(s.destroyed)return!1;s.reading=!1,s.decoder&&!r?(e=s.decoder.write(e),s.objectMode||0!==e.length?A(t,s,e,!1):R(t,s)):A(t,s,e,!1)}else n||(s.reading=!1,R(t,s));return!s.ended&&(s.length<s.highWaterMark||0===s.length)}function A(t,e,r,n){e.flowing&&0===e.length&&!e.sync?(e.awaitDrain=0,t.emit("data",r)):(e.length+=e.objectMode?1:r.length,n?e.buffer.unshift(r):e.buffer.push(r),e.needReadable&&x(t)),R(t,e)}Object.defineProperty(O.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._readableState&&this._readableState.destroyed},set:function(t){this._readableState&&(this._readableState.destroyed=t)}}),O.prototype.destroy=y.destroy,O.prototype._undestroy=y.undestroy,O.prototype._destroy=function(t,e){e(t)},O.prototype.push=function(t,e){var r,n=this._readableState;return n.objectMode?r=!0:"string"==typeof t&&((e=e||n.defaultEncoding)!==n.encoding&&(t=u.from(t,e),e=""),r=!0),T(this,t,e,!1,r)},O.prototype.unshift=function(t){return T(this,t,null,!0,!1)},O.prototype.isPaused=function(){return!1===this._readableState.flowing},O.prototype.setEncoding=function(t){l||(l=r(7137).I);var e=new l(t);this._readableState.decoder=e,this._readableState.encoding=this._readableState.decoder.encoding;for(var n=this._readableState.buffer.head,i="";null!==n;)i+=e.write(n.data),n=n.next;return this._readableState.buffer.clear(),""!==i&&this._readableState.buffer.push(i),this._readableState.length=i.length,this};var I=1073741824;function P(t,e){return t<=0||0===e.length&&e.ended?0:e.objectMode?1:t!=t?e.flowing&&e.length?e.buffer.head.data.length:e.length:(t>e.highWaterMark&&(e.highWaterMark=function(t){return t>=I?t=I:(t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++),t}(t)),t<=e.length?t:e.ended?e.length:(e.needReadable=!0,0))}function x(t){var e=t._readableState;o("emitReadable",e.needReadable,e.emittedReadable),e.needReadable=!1,e.emittedReadable||(o("emitReadable",e.flowing),e.emittedReadable=!0,i.nextTick(B,t))}function B(t){var e=t._readableState;o("emitReadable_",e.destroyed,e.length,e.ended),e.destroyed||!e.length&&!e.ended||(t.emit("readable"),e.emittedReadable=!1),e.needReadable=!e.flowing&&!e.ended&&e.length<=e.highWaterMark,C(t)}function R(t,e){e.readingMore||(e.readingMore=!0,i.nextTick(U,t,e))}function U(t,e){for(;!e.reading&&!e.ended&&(e.length<e.highWaterMark||e.flowing&&0===e.length);){var r=e.length;if(o("maybeReadMore read 0"),t.read(0),r===e.length)break}e.readingMore=!1}function j(t){var e=t._readableState;e.readableListening=t.listenerCount("readable")>0,e.resumeScheduled&&!e.paused?e.flowing=!0:t.listenerCount("data")>0&&t.resume()}function N(t){o("readable nexttick read 0"),t.read(0)}function L(t,e){o("resume",e.reading),e.reading||t.read(0),e.resumeScheduled=!1,t.emit("resume"),C(t),e.flowing&&!e.reading&&t.read(0)}function C(t){var e=t._readableState;for(o("flow",e.flowing);e.flowing&&null!==t.read(););}function F(t,e){return 0===e.length?null:(e.objectMode?r=e.buffer.shift():!t||t>=e.length?(r=e.decoder?e.buffer.join(""):1===e.buffer.length?e.buffer.first():e.buffer.concat(e.length),e.buffer.clear()):r=e.buffer.consume(t,e.decoder),r);var r}function D(t){var e=t._readableState;o("endReadable",e.endEmitted),e.endEmitted||(e.ended=!0,i.nextTick(H,e,t))}function H(t,e){if(o("endReadableNT",t.endEmitted,t.length),!t.endEmitted&&0===t.length&&(t.endEmitted=!0,e.readable=!1,e.emit("end"),t.autoDestroy)){var r=e._writableState;(!r||r.autoDestroy&&r.finished)&&e.destroy()}}function M(t,e){for(var r=0,n=t.length;r<n;r++)if(t[r]===e)return r;return-1}O.prototype.read=function(t){o("read",t),t=parseInt(t,10);var e=this._readableState,r=t;if(0!==t&&(e.emittedReadable=!1),0===t&&e.needReadable&&((0!==e.highWaterMark?e.length>=e.highWaterMark:e.length>0)||e.ended))return o("read: emitReadable",e.length,e.ended),0===e.length&&e.ended?D(this):x(this),null;if(0===(t=P(t,e))&&e.ended)return 0===e.length&&D(this),null;var n,i=e.needReadable;return o("need readable",i),(0===e.length||e.length-t<e.highWaterMark)&&o("length less than watermark",i=!0),e.ended||e.reading?o("reading or ended",i=!1):i&&(o("do read"),e.reading=!0,e.sync=!0,0===e.length&&(e.needReadable=!0),this._read(e.highWaterMark),e.sync=!1,e.reading||(t=P(r,e))),null===(n=t>0?F(t,e):null)?(e.needReadable=e.length<=e.highWaterMark,t=0):(e.length-=t,e.awaitDrain=0),0===e.length&&(e.ended||(e.needReadable=!0),r!==t&&e.ended&&D(this)),null!==n&&this.emit("data",n),n},O.prototype._read=function(t){_(this,new m("_read()"))},O.prototype.pipe=function(t,e){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=t;break;case 1:n.pipes=[n.pipes,t];break;default:n.pipes.push(t)}n.pipesCount+=1,o("pipe count=%d opts=%j",n.pipesCount,e);var s=e&&!1===e.end||t===i.stdout||t===i.stderr?y:u;function u(){o("onend"),t.end()}n.endEmitted?i.nextTick(s):r.once("end",s),t.on("unpipe",function e(i,a){o("onunpipe"),i===r&&a&&!1===a.hasUnpiped&&(a.hasUnpiped=!0,o("cleanup"),t.removeListener("close",p),t.removeListener("finish",d),t.removeListener("drain",c),t.removeListener("error",h),t.removeListener("unpipe",e),r.removeListener("end",u),r.removeListener("end",y),r.removeListener("data",l),f=!0,!n.awaitDrain||t._writableState&&!t._writableState.needDrain||c())});var c=function(t){return function(){var e=t._readableState;o("pipeOnDrain",e.awaitDrain),e.awaitDrain&&e.awaitDrain--,0===e.awaitDrain&&a(t,"data")&&(e.flowing=!0,C(t))}}(r);t.on("drain",c);var f=!1;function l(e){o("ondata");var i=t.write(e);o("dest.write",i),!1===i&&((1===n.pipesCount&&n.pipes===t||n.pipesCount>1&&-1!==M(n.pipes,t))&&!f&&(o("false write response, pause",n.awaitDrain),n.awaitDrain++),r.pause())}function h(e){o("onerror",e),y(),t.removeListener("error",h),0===a(t,"error")&&_(t,e)}function p(){t.removeListener("finish",d),y()}function d(){o("onfinish"),t.removeListener("close",p),y()}function y(){o("unpipe"),r.unpipe(t)}return r.on("data",l),function(t,e,r){if("function"==typeof t.prependListener)return t.prependListener(e,r);t._events&&t._events[e]?Array.isArray(t._events[e])?t._events[e].unshift(r):t._events[e]=[r,t._events[e]]:t.on(e,r)}(t,"error",h),t.once("close",p),t.once("finish",d),t.emit("pipe",r),n.flowing||(o("pipe resume"),r.resume()),t},O.prototype.unpipe=function(t){var e=this._readableState,r={hasUnpiped:!1};if(0===e.pipesCount)return this;if(1===e.pipesCount)return t&&t!==e.pipes||(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit("unpipe",this,r)),this;if(!t){var n=e.pipes,i=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var o=0;o<i;o++)n[o].emit("unpipe",this,{hasUnpiped:!1});return this}var a=M(e.pipes,t);return-1===a||(e.pipes.splice(a,1),e.pipesCount-=1,1===e.pipesCount&&(e.pipes=e.pipes[0]),t.emit("unpipe",this,r)),this},O.prototype.on=function(t,e){var r=s.prototype.on.call(this,t,e),n=this._readableState;return"data"===t?(n.readableListening=this.listenerCount("readable")>0,!1!==n.flowing&&this.resume()):"readable"===t&&(n.endEmitted||n.readableListening||(n.readableListening=n.needReadable=!0,n.flowing=!1,n.emittedReadable=!1,o("on readable",n.length,n.reading),n.length?x(this):n.reading||i.nextTick(N,this))),r},O.prototype.addListener=O.prototype.on,O.prototype.removeListener=function(t,e){var r=s.prototype.removeListener.call(this,t,e);return"readable"===t&&i.nextTick(j,this),r},O.prototype.removeAllListeners=function(t){var e=s.prototype.removeAllListeners.apply(this,arguments);return"readable"!==t&&void 0!==t||i.nextTick(j,this),e},O.prototype.resume=function(){var t=this._readableState;return t.flowing||(o("resume"),t.flowing=!t.readableListening,function(t,e){e.resumeScheduled||(e.resumeScheduled=!0,i.nextTick(L,t,e))}(this,t)),t.paused=!1,this},O.prototype.pause=function(){return o("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(o("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this},O.prototype.wrap=function(t){var e=this,r=this._readableState,n=!1;for(var i in t.on("end",function(){if(o("wrapped end"),r.decoder&&!r.ended){var t=r.decoder.end();t&&t.length&&e.push(t)}e.push(null)}),t.on("data",function(i){o("wrapped data"),r.decoder&&(i=r.decoder.write(i)),r.objectMode&&null==i||(r.objectMode||i&&i.length)&&(e.push(i)||(n=!0,t.pause()))}),t)void 0===this[i]&&"function"==typeof t[i]&&(this[i]=function(e){return function(){return t[e].apply(t,arguments)}}(i));for(var a=0;a<E.length;a++)t.on(E[a],this.emit.bind(this,E[a]));return this._read=function(e){o("wrapped _read",e),n&&(n=!1,t.resume())},this},"function"==typeof Symbol&&(O.prototype[Symbol.asyncIterator]=function(){return void 0===h&&(h=r(4743)),h(this)}),Object.defineProperty(O.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty(O.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty(O.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(t){this._readableState&&(this._readableState.flowing=t)}}),O._fromList=F,Object.defineProperty(O.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}}),"function"==typeof Symbol&&(O.from=function(t,e){return void 0===p&&(p=r(5049)),p(O,t,e)})},6743:(t,e,r)=>{var n=r(9353);t.exports=Function.prototype.bind||n},6891:(t,e,r)=>{var n,i=r(5606);t.exports=O,O.ReadableState=k,r(7007).EventEmitter;var o,a=function(t,e){return t.listeners(e).length},s=r(1396),u=r(8287).Buffer,c=(void 0!==r.g?r.g:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{}).Uint8Array||function(){},f=r(7199);o=f&&f.debuglog?f.debuglog("stream"):function(){};var l,h,p,d=r(1766),y=r(4347),b=r(6644).getHighWaterMark,g=r(2463).F,v=g.ERR_INVALID_ARG_TYPE,w=g.ERR_STREAM_PUSH_AFTER_EOF,m=g.ERR_METHOD_NOT_IMPLEMENTED,S=g.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;r(6698)(O,s);var _=y.errorOrDestroy,E=["error","close","destroy","pause","resume"];function k(t,e,i){n=n||r(8101),t=t||{},"boolean"!=typeof i&&(i=e instanceof n),this.objectMode=!!t.objectMode,i&&(this.objectMode=this.objectMode||!!t.readableObjectMode),this.highWaterMark=b(this,t,"readableHighWaterMark",i),this.buffer=new d,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=!1!==t.emitClose,this.autoDestroy=!!t.autoDestroy,this.destroyed=!1,this.defaultEncoding=t.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,t.encoding&&(l||(l=r(3516).I),this.decoder=new l(t.encoding),this.encoding=t.encoding)}function O(t){if(n=n||r(8101),!(this instanceof O))return new O(t);var e=this instanceof n;this._readableState=new k(t,this,e),this.readable=!0,t&&("function"==typeof t.read&&(this._read=t.read),"function"==typeof t.destroy&&(this._destroy=t.destroy)),s.call(this)}function T(t,e,r,n,i){o("readableAddChunk",e);var a,s=t._readableState;if(null===e)s.reading=!1,function(t,e){if(o("onEofChunk"),!e.ended){if(e.decoder){var r=e.decoder.end();r&&r.length&&(e.buffer.push(r),e.length+=e.objectMode?1:r.length)}e.ended=!0,e.sync?x(t):(e.needReadable=!1,e.emittedReadable||(e.emittedReadable=!0,B(t)))}}(t,s);else if(i||(a=function(t,e){var r,n;return n=e,u.isBuffer(n)||n instanceof c||"string"==typeof e||void 0===e||t.objectMode||(r=new v("chunk",["string","Buffer","Uint8Array"],e)),r}(s,e)),a)_(t,a);else if(s.objectMode||e&&e.length>0)if("string"==typeof e||s.objectMode||Object.getPrototypeOf(e)===u.prototype||(e=function(t){return u.from(t)}(e)),n)s.endEmitted?_(t,new S):A(t,s,e,!0);else if(s.ended)_(t,new w);else{if(s.destroyed)return!1;s.reading=!1,s.decoder&&!r?(e=s.decoder.write(e),s.objectMode||0!==e.length?A(t,s,e,!1):R(t,s)):A(t,s,e,!1)}else n||(s.reading=!1,R(t,s));return!s.ended&&(s.length<s.highWaterMark||0===s.length)}function A(t,e,r,n){e.flowing&&0===e.length&&!e.sync?(e.awaitDrain=0,t.emit("data",r)):(e.length+=e.objectMode?1:r.length,n?e.buffer.unshift(r):e.buffer.push(r),e.needReadable&&x(t)),R(t,e)}Object.defineProperty(O.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._readableState&&this._readableState.destroyed},set:function(t){this._readableState&&(this._readableState.destroyed=t)}}),O.prototype.destroy=y.destroy,O.prototype._undestroy=y.undestroy,O.prototype._destroy=function(t,e){e(t)},O.prototype.push=function(t,e){var r,n=this._readableState;return n.objectMode?r=!0:"string"==typeof t&&((e=e||n.defaultEncoding)!==n.encoding&&(t=u.from(t,e),e=""),r=!0),T(this,t,e,!1,r)},O.prototype.unshift=function(t){return T(this,t,null,!0,!1)},O.prototype.isPaused=function(){return!1===this._readableState.flowing},O.prototype.setEncoding=function(t){l||(l=r(3516).I);var e=new l(t);this._readableState.decoder=e,this._readableState.encoding=this._readableState.decoder.encoding;for(var n=this._readableState.buffer.head,i="";null!==n;)i+=e.write(n.data),n=n.next;return this._readableState.buffer.clear(),""!==i&&this._readableState.buffer.push(i),this._readableState.length=i.length,this};var I=1073741824;function P(t,e){return t<=0||0===e.length&&e.ended?0:e.objectMode?1:t!=t?e.flowing&&e.length?e.buffer.head.data.length:e.length:(t>e.highWaterMark&&(e.highWaterMark=function(t){return t>=I?t=I:(t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++),t}(t)),t<=e.length?t:e.ended?e.length:(e.needReadable=!0,0))}function x(t){var e=t._readableState;o("emitReadable",e.needReadable,e.emittedReadable),e.needReadable=!1,e.emittedReadable||(o("emitReadable",e.flowing),e.emittedReadable=!0,i.nextTick(B,t))}function B(t){var e=t._readableState;o("emitReadable_",e.destroyed,e.length,e.ended),e.destroyed||!e.length&&!e.ended||(t.emit("readable"),e.emittedReadable=!1),e.needReadable=!e.flowing&&!e.ended&&e.length<=e.highWaterMark,C(t)}function R(t,e){e.readingMore||(e.readingMore=!0,i.nextTick(U,t,e))}function U(t,e){for(;!e.reading&&!e.ended&&(e.length<e.highWaterMark||e.flowing&&0===e.length);){var r=e.length;if(o("maybeReadMore read 0"),t.read(0),r===e.length)break}e.readingMore=!1}function j(t){var e=t._readableState;e.readableListening=t.listenerCount("readable")>0,e.resumeScheduled&&!e.paused?e.flowing=!0:t.listenerCount("data")>0&&t.resume()}function N(t){o("readable nexttick read 0"),t.read(0)}function L(t,e){o("resume",e.reading),e.reading||t.read(0),e.resumeScheduled=!1,t.emit("resume"),C(t),e.flowing&&!e.reading&&t.read(0)}function C(t){var e=t._readableState;for(o("flow",e.flowing);e.flowing&&null!==t.read(););}function F(t,e){return 0===e.length?null:(e.objectMode?r=e.buffer.shift():!t||t>=e.length?(r=e.decoder?e.buffer.join(""):1===e.buffer.length?e.buffer.first():e.buffer.concat(e.length),e.buffer.clear()):r=e.buffer.consume(t,e.decoder),r);var r}function D(t){var e=t._readableState;o("endReadable",e.endEmitted),e.endEmitted||(e.ended=!0,i.nextTick(H,e,t))}function H(t,e){if(o("endReadableNT",t.endEmitted,t.length),!t.endEmitted&&0===t.length&&(t.endEmitted=!0,e.readable=!1,e.emit("end"),t.autoDestroy)){var r=e._writableState;(!r||r.autoDestroy&&r.finished)&&e.destroy()}}function M(t,e){for(var r=0,n=t.length;r<n;r++)if(t[r]===e)return r;return-1}O.prototype.read=function(t){o("read",t),t=parseInt(t,10);var e=this._readableState,r=t;if(0!==t&&(e.emittedReadable=!1),0===t&&e.needReadable&&((0!==e.highWaterMark?e.length>=e.highWaterMark:e.length>0)||e.ended))return o("read: emitReadable",e.length,e.ended),0===e.length&&e.ended?D(this):x(this),null;if(0===(t=P(t,e))&&e.ended)return 0===e.length&&D(this),null;var n,i=e.needReadable;return o("need readable",i),(0===e.length||e.length-t<e.highWaterMark)&&o("length less than watermark",i=!0),e.ended||e.reading?o("reading or ended",i=!1):i&&(o("do read"),e.reading=!0,e.sync=!0,0===e.length&&(e.needReadable=!0),this._read(e.highWaterMark),e.sync=!1,e.reading||(t=P(r,e))),null===(n=t>0?F(t,e):null)?(e.needReadable=e.length<=e.highWaterMark,t=0):(e.length-=t,e.awaitDrain=0),0===e.length&&(e.ended||(e.needReadable=!0),r!==t&&e.ended&&D(this)),null!==n&&this.emit("data",n),n},O.prototype._read=function(t){_(this,new m("_read()"))},O.prototype.pipe=function(t,e){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=t;break;case 1:n.pipes=[n.pipes,t];break;default:n.pipes.push(t)}n.pipesCount+=1,o("pipe count=%d opts=%j",n.pipesCount,e);var s=e&&!1===e.end||t===i.stdout||t===i.stderr?y:u;function u(){o("onend"),t.end()}n.endEmitted?i.nextTick(s):r.once("end",s),t.on("unpipe",function e(i,a){o("onunpipe"),i===r&&a&&!1===a.hasUnpiped&&(a.hasUnpiped=!0,o("cleanup"),t.removeListener("close",p),t.removeListener("finish",d),t.removeListener("drain",c),t.removeListener("error",h),t.removeListener("unpipe",e),r.removeListener("end",u),r.removeListener("end",y),r.removeListener("data",l),f=!0,!n.awaitDrain||t._writableState&&!t._writableState.needDrain||c())});var c=function(t){return function(){var e=t._readableState;o("pipeOnDrain",e.awaitDrain),e.awaitDrain&&e.awaitDrain--,0===e.awaitDrain&&a(t,"data")&&(e.flowing=!0,C(t))}}(r);t.on("drain",c);var f=!1;function l(e){o("ondata");var i=t.write(e);o("dest.write",i),!1===i&&((1===n.pipesCount&&n.pipes===t||n.pipesCount>1&&-1!==M(n.pipes,t))&&!f&&(o("false write response, pause",n.awaitDrain),n.awaitDrain++),r.pause())}function h(e){o("onerror",e),y(),t.removeListener("error",h),0===a(t,"error")&&_(t,e)}function p(){t.removeListener("finish",d),y()}function d(){o("onfinish"),t.removeListener("close",p),y()}function y(){o("unpipe"),r.unpipe(t)}return r.on("data",l),function(t,e,r){if("function"==typeof t.prependListener)return t.prependListener(e,r);t._events&&t._events[e]?Array.isArray(t._events[e])?t._events[e].unshift(r):t._events[e]=[r,t._events[e]]:t.on(e,r)}(t,"error",h),t.once("close",p),t.once("finish",d),t.emit("pipe",r),n.flowing||(o("pipe resume"),r.resume()),t},O.prototype.unpipe=function(t){var e=this._readableState,r={hasUnpiped:!1};if(0===e.pipesCount)return this;if(1===e.pipesCount)return t&&t!==e.pipes||(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit("unpipe",this,r)),this;if(!t){var n=e.pipes,i=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var o=0;o<i;o++)n[o].emit("unpipe",this,{hasUnpiped:!1});return this}var a=M(e.pipes,t);return-1===a||(e.pipes.splice(a,1),e.pipesCount-=1,1===e.pipesCount&&(e.pipes=e.pipes[0]),t.emit("unpipe",this,r)),this},O.prototype.on=function(t,e){var r=s.prototype.on.call(this,t,e),n=this._readableState;return"data"===t?(n.readableListening=this.listenerCount("readable")>0,!1!==n.flowing&&this.resume()):"readable"===t&&(n.endEmitted||n.readableListening||(n.readableListening=n.needReadable=!0,n.flowing=!1,n.emittedReadable=!1,o("on readable",n.length,n.reading),n.length?x(this):n.reading||i.nextTick(N,this))),r},O.prototype.addListener=O.prototype.on,O.prototype.removeListener=function(t,e){var r=s.prototype.removeListener.call(this,t,e);return"readable"===t&&i.nextTick(j,this),r},O.prototype.removeAllListeners=function(t){var e=s.prototype.removeAllListeners.apply(this,arguments);return"readable"!==t&&void 0!==t||i.nextTick(j,this),e},O.prototype.resume=function(){var t=this._readableState;return t.flowing||(o("resume"),t.flowing=!t.readableListening,function(t,e){e.resumeScheduled||(e.resumeScheduled=!0,i.nextTick(L,t,e))}(this,t)),t.paused=!1,this},O.prototype.pause=function(){return o("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(o("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this},O.prototype.wrap=function(t){var e=this,r=this._readableState,n=!1;for(var i in t.on("end",function(){if(o("wrapped end"),r.decoder&&!r.ended){var t=r.decoder.end();t&&t.length&&e.push(t)}e.push(null)}),t.on("data",function(i){o("wrapped data"),r.decoder&&(i=r.decoder.write(i)),r.objectMode&&null==i||(r.objectMode||i&&i.length)&&(e.push(i)||(n=!0,t.pause()))}),t)void 0===this[i]&&"function"==typeof t[i]&&(this[i]=function(e){return function(){return t[e].apply(t,arguments)}}(i));for(var a=0;a<E.length;a++)t.on(E[a],this.emit.bind(this,E[a]));return this._read=function(e){o("wrapped _read",e),n&&(n=!1,t.resume())},this},"function"==typeof Symbol&&(O.prototype[Symbol.asyncIterator]=function(){return void 0===h&&(h=r(5034)),h(this)}),Object.defineProperty(O.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty(O.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty(O.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(t){this._readableState&&(this._readableState.flowing=t)}}),O._fromList=F,Object.defineProperty(O.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}}),"function"==typeof Symbol&&(O.from=function(t,e){return void 0===p&&(p=r(968)),p(O,t,e)})},6897:(t,e,r)=>{var n=r(453),i=r(41),o=r(592)(),a=r(5795),s=r(9675),u=n("%Math.floor%");t.exports=function(t,e){if("function"!=typeof t)throw new s("`fn` is not a function");if("number"!=typeof e||e<0||e>4294967295||u(e)!==e)throw new s("`length` must be a positive 32-bit integer");var r=arguments.length>2&&!!arguments[2],n=!0,c=!0;if("length"in t&&a){var f=a(t,"length");f&&!f.configurable&&(n=!1),f&&!f.writable&&(c=!1)}return(n||c||!r)&&(o?i(t,"length",e,!0,!0):i(t,"length",e)),t}},7007:t=>{var e,r="object"==typeof Reflect?Reflect:null,n=r&&"function"==typeof r.apply?r.apply:function(t,e,r){return Function.prototype.apply.call(t,e,r)};e=r&&"function"==typeof r.ownKeys?r.ownKeys:Object.getOwnPropertySymbols?function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:function(t){return Object.getOwnPropertyNames(t)};var i=Number.isNaN||function(t){return t!=t};function o(){o.init.call(this)}t.exports=o,t.exports.once=function(t,e){return new Promise(function(r,n){function i(r){t.removeListener(e,o),n(r)}function o(){"function"==typeof t.removeListener&&t.removeListener("error",i),r([].slice.call(arguments))}y(t,e,o,{once:!0}),"error"!==e&&function(t,e){"function"==typeof t.on&&y(t,"error",e,{once:!0})}(t,i)})},o.EventEmitter=o,o.prototype._events=void 0,o.prototype._eventsCount=0,o.prototype._maxListeners=void 0;var a=10;function s(t){if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}function u(t){return void 0===t._maxListeners?o.defaultMaxListeners:t._maxListeners}function c(t,e,r,n){var i,o,a,c;if(s(r),void 0===(o=t._events)?(o=t._events=Object.create(null),t._eventsCount=0):(void 0!==o.newListener&&(t.emit("newListener",e,r.listener?r.listener:r),o=t._events),a=o[e]),void 0===a)a=o[e]=r,++t._eventsCount;else if("function"==typeof a?a=o[e]=n?[r,a]:[a,r]:n?a.unshift(r):a.push(r),(i=u(t))>0&&a.length>i&&!a.warned){a.warned=!0;var f=new Error("Possible EventEmitter memory leak detected. "+a.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");f.name="MaxListenersExceededWarning",f.emitter=t,f.type=e,f.count=a.length,c=f,console&&console.warn&&console.warn(c)}return t}function f(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function l(t,e,r){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},i=f.bind(n);return i.listener=r,n.wrapFn=i,i}function h(t,e,r){var n=t._events;if(void 0===n)return[];var i=n[e];return void 0===i?[]:"function"==typeof i?r?[i.listener||i]:[i]:r?function(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}(i):d(i,i.length)}function p(t){var e=this._events;if(void 0!==e){var r=e[t];if("function"==typeof r)return 1;if(void 0!==r)return r.length}return 0}function d(t,e){for(var r=new Array(e),n=0;n<e;++n)r[n]=t[n];return r}function y(t,e,r,n){if("function"==typeof t.on)n.once?t.once(e,r):t.on(e,r);else{if("function"!=typeof t.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t);t.addEventListener(e,function i(o){n.once&&t.removeEventListener(e,i),r(o)})}}Object.defineProperty(o,"defaultMaxListeners",{enumerable:!0,get:function(){return a},set:function(t){if("number"!=typeof t||t<0||i(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");a=t}}),o.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},o.prototype.setMaxListeners=function(t){if("number"!=typeof t||t<0||i(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},o.prototype.getMaxListeners=function(){return u(this)},o.prototype.emit=function(t){for(var e=[],r=1;r<arguments.length;r++)e.push(arguments[r]);var i="error"===t,o=this._events;if(void 0!==o)i=i&&void 0===o.error;else if(!i)return!1;if(i){var a;if(e.length>0&&(a=e[0]),a instanceof Error)throw a;var s=new Error("Unhandled error."+(a?" ("+a.message+")":""));throw s.context=a,s}var u=o[t];if(void 0===u)return!1;if("function"==typeof u)n(u,this,e);else{var c=u.length,f=d(u,c);for(r=0;r<c;++r)n(f[r],this,e)}return!0},o.prototype.addListener=function(t,e){return c(this,t,e,!1)},o.prototype.on=o.prototype.addListener,o.prototype.prependListener=function(t,e){return c(this,t,e,!0)},o.prototype.once=function(t,e){return s(e),this.on(t,l(this,t,e)),this},o.prototype.prependOnceListener=function(t,e){return s(e),this.prependListener(t,l(this,t,e)),this},o.prototype.removeListener=function(t,e){var r,n,i,o,a;if(s(e),void 0===(n=this._events))return this;if(void 0===(r=n[t]))return this;if(r===e||r.listener===e)0===--this._eventsCount?this._events=Object.create(null):(delete n[t],n.removeListener&&this.emit("removeListener",t,r.listener||e));else if("function"!=typeof r){for(i=-1,o=r.length-1;o>=0;o--)if(r[o]===e||r[o].listener===e){a=r[o].listener,i=o;break}if(i<0)return this;0===i?r.shift():function(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}(r,i),1===r.length&&(n[t]=r[0]),void 0!==n.removeListener&&this.emit("removeListener",t,a||e)}return this},o.prototype.off=o.prototype.removeListener,o.prototype.removeAllListeners=function(t){var e,r,n;if(void 0===(r=this._events))return this;if(void 0===r.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==r[t]&&(0===--this._eventsCount?this._events=Object.create(null):delete r[t]),this;if(0===arguments.length){var i,o=Object.keys(r);for(n=0;n<o.length;++n)"removeListener"!==(i=o[n])&&this.removeAllListeners(i);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(e=r[t]))this.removeListener(t,e);else if(void 0!==e)for(n=e.length-1;n>=0;n--)this.removeListener(t,e[n]);return this},o.prototype.listeners=function(t){return h(this,t,!0)},o.prototype.rawListeners=function(t){return h(this,t,!1)},o.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):p.call(t,e)},o.prototype.listenerCount=p,o.prototype.eventNames=function(){return this._eventsCount>0?e(this._events):[]}},7076:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.sha512_224=e.sha512_256=e.sha384=e.sha512=e.sha224=e.sha256=e.SHA512_256=e.SHA512_224=e.SHA384=e.SHA512=e.SHA224=e.SHA256=void 0;const n=r(7202),i=r(2318),o=r(9175),a=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]),s=new Uint32Array(64);class u extends n.HashMD{constructor(t=32){super(64,t,8,!1),this.A=0|n.SHA256_IV[0],this.B=0|n.SHA256_IV[1],this.C=0|n.SHA256_IV[2],this.D=0|n.SHA256_IV[3],this.E=0|n.SHA256_IV[4],this.F=0|n.SHA256_IV[5],this.G=0|n.SHA256_IV[6],this.H=0|n.SHA256_IV[7]}get(){const{A:t,B:e,C:r,D:n,E:i,F:o,G:a,H:s}=this;return[t,e,r,n,i,o,a,s]}set(t,e,r,n,i,o,a,s){this.A=0|t,this.B=0|e,this.C=0|r,this.D=0|n,this.E=0|i,this.F=0|o,this.G=0|a,this.H=0|s}process(t,e){for(let r=0;r<16;r++,e+=4)s[r]=t.getUint32(e,!1);for(let t=16;t<64;t++){const e=s[t-15],r=s[t-2],n=(0,o.rotr)(e,7)^(0,o.rotr)(e,18)^e>>>3,i=(0,o.rotr)(r,17)^(0,o.rotr)(r,19)^r>>>10;s[t]=i+s[t-7]+n+s[t-16]|0}let{A:r,B:i,C:u,D:c,E:f,F:l,G:h,H:p}=this;for(let t=0;t<64;t++){const e=p+((0,o.rotr)(f,6)^(0,o.rotr)(f,11)^(0,o.rotr)(f,25))+(0,n.Chi)(f,l,h)+a[t]+s[t]|0,d=((0,o.rotr)(r,2)^(0,o.rotr)(r,13)^(0,o.rotr)(r,22))+(0,n.Maj)(r,i,u)|0;p=h,h=l,l=f,f=c+e|0,c=u,u=i,i=r,r=e+d|0}r=r+this.A|0,i=i+this.B|0,u=u+this.C|0,c=c+this.D|0,f=f+this.E|0,l=l+this.F|0,h=h+this.G|0,p=p+this.H|0,this.set(r,i,u,c,f,l,h,p)}roundClean(){(0,o.clean)(s)}destroy(){this.set(0,0,0,0,0,0,0,0),(0,o.clean)(this.buffer)}}e.SHA256=u;class c extends u{constructor(){super(28),this.A=0|n.SHA224_IV[0],this.B=0|n.SHA224_IV[1],this.C=0|n.SHA224_IV[2],this.D=0|n.SHA224_IV[3],this.E=0|n.SHA224_IV[4],this.F=0|n.SHA224_IV[5],this.G=0|n.SHA224_IV[6],this.H=0|n.SHA224_IV[7]}}e.SHA224=c;const f=(()=>i.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(t=>BigInt(t))))(),l=(()=>f[0])(),h=(()=>f[1])(),p=new Uint32Array(80),d=new Uint32Array(80);class y extends n.HashMD{constructor(t=64){super(128,t,16,!1),this.Ah=0|n.SHA512_IV[0],this.Al=0|n.SHA512_IV[1],this.Bh=0|n.SHA512_IV[2],this.Bl=0|n.SHA512_IV[3],this.Ch=0|n.SHA512_IV[4],this.Cl=0|n.SHA512_IV[5],this.Dh=0|n.SHA512_IV[6],this.Dl=0|n.SHA512_IV[7],this.Eh=0|n.SHA512_IV[8],this.El=0|n.SHA512_IV[9],this.Fh=0|n.SHA512_IV[10],this.Fl=0|n.SHA512_IV[11],this.Gh=0|n.SHA512_IV[12],this.Gl=0|n.SHA512_IV[13],this.Hh=0|n.SHA512_IV[14],this.Hl=0|n.SHA512_IV[15]}get(){const{Ah:t,Al:e,Bh:r,Bl:n,Ch:i,Cl:o,Dh:a,Dl:s,Eh:u,El:c,Fh:f,Fl:l,Gh:h,Gl:p,Hh:d,Hl:y}=this;return[t,e,r,n,i,o,a,s,u,c,f,l,h,p,d,y]}set(t,e,r,n,i,o,a,s,u,c,f,l,h,p,d,y){this.Ah=0|t,this.Al=0|e,this.Bh=0|r,this.Bl=0|n,this.Ch=0|i,this.Cl=0|o,this.Dh=0|a,this.Dl=0|s,this.Eh=0|u,this.El=0|c,this.Fh=0|f,this.Fl=0|l,this.Gh=0|h,this.Gl=0|p,this.Hh=0|d,this.Hl=0|y}process(t,e){for(let r=0;r<16;r++,e+=4)p[r]=t.getUint32(e),d[r]=t.getUint32(e+=4);for(let t=16;t<80;t++){const e=0|p[t-15],r=0|d[t-15],n=i.rotrSH(e,r,1)^i.rotrSH(e,r,8)^i.shrSH(e,r,7),o=i.rotrSL(e,r,1)^i.rotrSL(e,r,8)^i.shrSL(e,r,7),a=0|p[t-2],s=0|d[t-2],u=i.rotrSH(a,s,19)^i.rotrBH(a,s,61)^i.shrSH(a,s,6),c=i.rotrSL(a,s,19)^i.rotrBL(a,s,61)^i.shrSL(a,s,6),f=i.add4L(o,c,d[t-7],d[t-16]),l=i.add4H(f,n,u,p[t-7],p[t-16]);p[t]=0|l,d[t]=0|f}let{Ah:r,Al:n,Bh:o,Bl:a,Ch:s,Cl:u,Dh:c,Dl:f,Eh:y,El:b,Fh:g,Fl:v,Gh:w,Gl:m,Hh:S,Hl:_}=this;for(let t=0;t<80;t++){const e=i.rotrSH(y,b,14)^i.rotrSH(y,b,18)^i.rotrBH(y,b,41),E=i.rotrSL(y,b,14)^i.rotrSL(y,b,18)^i.rotrBL(y,b,41),k=y&g^~y&w,O=b&v^~b&m,T=i.add5L(_,E,O,h[t],d[t]),A=i.add5H(T,S,e,k,l[t],p[t]),I=0|T,P=i.rotrSH(r,n,28)^i.rotrBH(r,n,34)^i.rotrBH(r,n,39),x=i.rotrSL(r,n,28)^i.rotrBL(r,n,34)^i.rotrBL(r,n,39),B=r&o^r&s^o&s,R=n&a^n&u^a&u;S=0|w,_=0|m,w=0|g,m=0|v,g=0|y,v=0|b,({h:y,l:b}=i.add(0|c,0|f,0|A,0|I)),c=0|s,f=0|u,s=0|o,u=0|a,o=0|r,a=0|n;const U=i.add3L(I,x,R);r=i.add3H(U,A,P,B),n=0|U}({h:r,l:n}=i.add(0|this.Ah,0|this.Al,0|r,0|n)),({h:o,l:a}=i.add(0|this.Bh,0|this.Bl,0|o,0|a)),({h:s,l:u}=i.add(0|this.Ch,0|this.Cl,0|s,0|u)),({h:c,l:f}=i.add(0|this.Dh,0|this.Dl,0|c,0|f)),({h:y,l:b}=i.add(0|this.Eh,0|this.El,0|y,0|b)),({h:g,l:v}=i.add(0|this.Fh,0|this.Fl,0|g,0|v)),({h:w,l:m}=i.add(0|this.Gh,0|this.Gl,0|w,0|m)),({h:S,l:_}=i.add(0|this.Hh,0|this.Hl,0|S,0|_)),this.set(r,n,o,a,s,u,c,f,y,b,g,v,w,m,S,_)}roundClean(){(0,o.clean)(p,d)}destroy(){(0,o.clean)(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}e.SHA512=y;class b extends y{constructor(){super(48),this.Ah=0|n.SHA384_IV[0],this.Al=0|n.SHA384_IV[1],this.Bh=0|n.SHA384_IV[2],this.Bl=0|n.SHA384_IV[3],this.Ch=0|n.SHA384_IV[4],this.Cl=0|n.SHA384_IV[5],this.Dh=0|n.SHA384_IV[6],this.Dl=0|n.SHA384_IV[7],this.Eh=0|n.SHA384_IV[8],this.El=0|n.SHA384_IV[9],this.Fh=0|n.SHA384_IV[10],this.Fl=0|n.SHA384_IV[11],this.Gh=0|n.SHA384_IV[12],this.Gl=0|n.SHA384_IV[13],this.Hh=0|n.SHA384_IV[14],this.Hl=0|n.SHA384_IV[15]}}e.SHA384=b;const g=Uint32Array.from([2352822216,424955298,1944164710,2312950998,502970286,855612546,1738396948,1479516111,258812777,2077511080,2011393907,79989058,1067287976,1780299464,286451373,2446758561]),v=Uint32Array.from([573645204,4230739756,2673172387,3360449730,596883563,1867755857,2520282905,1497426621,2519219938,2827943907,3193839141,1401305490,721525244,746961066,246885852,2177182882]);class w extends y{constructor(){super(28),this.Ah=0|g[0],this.Al=0|g[1],this.Bh=0|g[2],this.Bl=0|g[3],this.Ch=0|g[4],this.Cl=0|g[5],this.Dh=0|g[6],this.Dl=0|g[7],this.Eh=0|g[8],this.El=0|g[9],this.Fh=0|g[10],this.Fl=0|g[11],this.Gh=0|g[12],this.Gl=0|g[13],this.Hh=0|g[14],this.Hl=0|g[15]}}e.SHA512_224=w;class m extends y{constructor(){super(32),this.Ah=0|v[0],this.Al=0|v[1],this.Bh=0|v[2],this.Bl=0|v[3],this.Ch=0|v[4],this.Cl=0|v[5],this.Dh=0|v[6],this.Dl=0|v[7],this.Eh=0|v[8],this.El=0|v[9],this.Fh=0|v[10],this.Fl=0|v[11],this.Gh=0|v[12],this.Gl=0|v[13],this.Hh=0|v[14],this.Hl=0|v[15]}}e.SHA512_256=m,e.sha256=(0,o.createHasher)(()=>new u),e.sha224=(0,o.createHasher)(()=>new c),e.sha512=(0,o.createHasher)(()=>new y),e.sha384=(0,o.createHasher)(()=>new b),e.sha512_256=(0,o.createHasher)(()=>new m),e.sha512_224=(0,o.createHasher)(()=>new w)},7108:(t,e,r)=>{var n=r(6698),i=r(320),o=r(6011),a=r(2802),s=r(6168);function u(t){s.call(this,"digest"),this._hash=t}n(u,s),u.prototype._update=function(t){this._hash.update(t)},u.prototype._final=function(){return this._hash.digest()},t.exports=function(t){return"md5"===(t=t.toLowerCase())?new i:"rmd160"===t||"ripemd160"===t?new o:new u(a(t))}},7119:t=>{t.exports="undefined"!=typeof Reflect&&Reflect&&Reflect.apply},7137:(t,e,r)=>{var n=r(2861).Buffer,i=n.isEncoding||function(t){switch((t=""+t)&&t.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function o(t){var e;switch(this.encoding=function(t){var e=function(t){if(!t)return"utf8";for(var e;;)switch(t){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return t;default:if(e)return;t=(""+t).toLowerCase(),e=!0}}(t);if("string"!=typeof e&&(n.isEncoding===i||!i(t)))throw new Error("Unknown encoding: "+t);return e||t}(t),this.encoding){case"utf16le":this.text=u,this.end=c,e=4;break;case"utf8":this.fillLast=s,e=4;break;case"base64":this.text=f,this.end=l,e=3;break;default:return this.write=h,void(this.end=p)}this.lastNeed=0,this.lastTotal=0,this.lastChar=n.allocUnsafe(e)}function a(t){return t<=127?0:t>>5==6?2:t>>4==14?3:t>>3==30?4:t>>6==2?-1:-2}function s(t){var e=this.lastTotal-this.lastNeed,r=function(t,e){if(128!=(192&e[0]))return t.lastNeed=0,"�";if(t.lastNeed>1&&e.length>1){if(128!=(192&e[1]))return t.lastNeed=1,"�";if(t.lastNeed>2&&e.length>2&&128!=(192&e[2]))return t.lastNeed=2,"�"}}(this,t);return void 0!==r?r:this.lastNeed<=t.length?(t.copy(this.lastChar,e,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(t.copy(this.lastChar,e,0,t.length),void(this.lastNeed-=t.length))}function u(t,e){if((t.length-e)%2==0){var r=t.toString("utf16le",e);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=t[t.length-1],t.toString("utf16le",e,t.length-1)}function c(t){var e=t&&t.length?this.write(t):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return e+this.lastChar.toString("utf16le",0,r)}return e}function f(t,e){var r=(t.length-e)%3;return 0===r?t.toString("base64",e):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=t[t.length-1]:(this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1]),t.toString("base64",e,t.length-r))}function l(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+this.lastChar.toString("base64",0,3-this.lastNeed):e}function h(t){return t.toString(this.encoding)}function p(t){return t&&t.length?this.write(t):""}e.I=o,o.prototype.write=function(t){if(0===t.length)return"";var e,r;if(this.lastNeed){if(void 0===(e=this.fillLast(t)))return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r<t.length?e?e+this.text(t,r):this.text(t,r):e||""},o.prototype.end=function(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+"�":e},o.prototype.text=function(t,e){var r=function(t,e,r){var n=e.length-1;if(n<r)return 0;var i=a(e[n]);return i>=0?(i>0&&(t.lastNeed=i-1),i):--n<r||-2===i?0:(i=a(e[n]))>=0?(i>0&&(t.lastNeed=i-2),i):--n<r||-2===i?0:(i=a(e[n]))>=0?(i>0&&(2===i?i=0:t.lastNeed=i-3),i):0}(this,t,e);if(!this.lastNeed)return t.toString("utf8",e);this.lastTotal=r;var n=t.length-(r-this.lastNeed);return t.copy(this.lastChar,0,n),t.toString("utf8",e,n)},o.prototype.fillLast=function(t){if(this.lastNeed<=t.length)return t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,t.length),this.lastNeed-=t.length}},7176:(t,e,r)=>{var n,i=r(3126),o=r(5795);try{n=[].__proto__===Array.prototype}catch(t){if(!t||"object"!=typeof t||!("code"in t)||"ERR_PROTO_ACCESS"!==t.code)throw t}var a=!!n&&o&&o(Object.prototype,"__proto__"),s=Object,u=s.getPrototypeOf;t.exports=a&&"function"==typeof a.get?i([a.get]):"function"==typeof u&&function(t){return u(null==t?t:s(t))}},7199:()=>{},7202:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.SHA512_IV=e.SHA384_IV=e.SHA224_IV=e.SHA256_IV=e.HashMD=void 0,e.setBigUint64=i,e.Chi=function(t,e,r){return t&e^~t&r},e.Maj=function(t,e,r){return t&e^t&r^e&r};const n=r(9175);function i(t,e,r,n){if("function"==typeof t.setBigUint64)return t.setBigUint64(e,r,n);const i=BigInt(32),o=BigInt(4294967295),a=Number(r>>i&o),s=Number(r&o),u=n?4:0,c=n?0:4;t.setUint32(e+u,a,n),t.setUint32(e+c,s,n)}class o extends n.Hash{constructor(t,e,r,i){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=t,this.outputLen=e,this.padOffset=r,this.isLE=i,this.buffer=new Uint8Array(t),this.view=(0,n.createView)(this.buffer)}update(t){(0,n.aexists)(this),t=(0,n.toBytes)(t),(0,n.abytes)(t);const{view:e,buffer:r,blockLen:i}=this,o=t.length;for(let a=0;a<o;){const s=Math.min(i-this.pos,o-a);if(s===i){const e=(0,n.createView)(t);for(;i<=o-a;a+=i)this.process(e,a);continue}r.set(t.subarray(a,a+s),this.pos),this.pos+=s,a+=s,this.pos===i&&(this.process(e,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){(0,n.aexists)(this),(0,n.aoutput)(t,this),this.finished=!0;const{buffer:e,view:r,blockLen:o,isLE:a}=this;let{pos:s}=this;e[s++]=128,(0,n.clean)(this.buffer.subarray(s)),this.padOffset>o-s&&(this.process(r,0),s=0);for(let t=s;t<o;t++)e[t]=0;i(r,o-8,BigInt(8*this.length),a),this.process(r,0);const u=(0,n.createView)(t),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const f=c/4,l=this.get();if(f>l.length)throw new Error("_sha2: outputLen bigger than state");for(let t=0;t<f;t++)u.setUint32(4*t,l[t],a)}digest(){const{buffer:t,outputLen:e}=this;this.digestInto(t);const r=t.slice(0,e);return this.destroy(),r}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:e,buffer:r,length:n,finished:i,destroyed:o,pos:a}=this;return t.destroyed=o,t.finished=i,t.length=n,t.pos=a,n%e&&t.buffer.set(r),t}clone(){return this._cloneInto()}}e.HashMD=o,e.SHA256_IV=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),e.SHA224_IV=Uint32Array.from([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]),e.SHA384_IV=Uint32Array.from([3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]),e.SHA512_IV=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209])},7244:(t,e,r)=>{var n=r(9092)(),i=r(6556)("Object.prototype.toString"),o=function(t){return!(n&&t&&"object"==typeof t&&Symbol.toStringTag in t)&&"[object Arguments]"===i(t)},a=function(t){return!!o(t)||null!==t&&"object"==typeof t&&"length"in t&&"number"==typeof t.length&&t.length>=0&&"[object Array]"!==i(t)&&"callee"in t&&"[object Function]"===i(t.callee)},s=function(){return o(arguments)}();o.isLegacyArguments=a,t.exports=s?o:a},7293:t=>{t.exports=function(t,e){var r,n,i,o,a,s,u,c,f,l,h,p,d,y,b,g,v,w,m,S,_,E,k,O,T;r=t.state,n=t.next_in,O=t.input,i=n+(t.avail_in-5),o=t.next_out,T=t.output,a=o-(e-t.avail_out),s=o+(t.avail_out-257),u=r.dmax,c=r.wsize,f=r.whave,l=r.wnext,h=r.window,p=r.hold,d=r.bits,y=r.lencode,b=r.distcode,g=(1<<r.lenbits)-1,v=(1<<r.distbits)-1;t:do{d<15&&(p+=O[n++]<<d,d+=8,p+=O[n++]<<d,d+=8),w=y[p&g];e:for(;;){if(p>>>=m=w>>>24,d-=m,0==(m=w>>>16&255))T[o++]=65535&w;else{if(!(16&m)){if(64&m){if(32&m){r.mode=12;break t}t.msg="invalid literal/length code",r.mode=30;break t}w=y[(65535&w)+(p&(1<<m)-1)];continue e}for(S=65535&w,(m&=15)&&(d<m&&(p+=O[n++]<<d,d+=8),S+=p&(1<<m)-1,p>>>=m,d-=m),d<15&&(p+=O[n++]<<d,d+=8,p+=O[n++]<<d,d+=8),w=b[p&v];;){if(p>>>=m=w>>>24,d-=m,16&(m=w>>>16&255)){if(_=65535&w,d<(m&=15)&&(p+=O[n++]<<d,(d+=8)<m&&(p+=O[n++]<<d,d+=8)),(_+=p&(1<<m)-1)>u){t.msg="invalid distance too far back",r.mode=30;break t}if(p>>>=m,d-=m,_>(m=o-a)){if((m=_-m)>f&&r.sane){t.msg="invalid distance too far back",r.mode=30;break t}if(E=0,k=h,0===l){if(E+=c-m,m<S){S-=m;do{T[o++]=h[E++]}while(--m);E=o-_,k=T}}else if(l<m){if(E+=c+l-m,(m-=l)<S){S-=m;do{T[o++]=h[E++]}while(--m);if(E=0,l<S){S-=m=l;do{T[o++]=h[E++]}while(--m);E=o-_,k=T}}}else if(E+=l-m,m<S){S-=m;do{T[o++]=h[E++]}while(--m);E=o-_,k=T}for(;S>2;)T[o++]=k[E++],T[o++]=k[E++],T[o++]=k[E++],S-=3;S&&(T[o++]=k[E++],S>1&&(T[o++]=k[E++]))}else{E=o-_;do{T[o++]=T[E++],T[o++]=T[E++],T[o++]=T[E++],S-=3}while(S>2);S&&(T[o++]=T[E++],S>1&&(T[o++]=T[E++]))}break}if(64&m){t.msg="invalid distance code",r.mode=30;break t}w=b[(65535&w)+(p&(1<<m)-1)]}}break}}while(n<i&&o<s);n-=S=d>>3,p&=(1<<(d-=S<<3))-1,t.next_in=n,t.next_out=o,t.avail_in=n<i?i-n+5:5-(n-i),t.avail_out=o<s?s-o+257:257-(o-s),r.hold=p,r.bits=d}},7526:(t,e)=>{e.byteLength=function(t){var e=s(t),r=e[0],n=e[1];return 3*(r+n)/4-n},e.toByteArray=function(t){var e,r,o=s(t),a=o[0],u=o[1],c=new i(function(t,e,r){return 3*(e+r)/4-r}(0,a,u)),f=0,l=u>0?a-4:a;for(r=0;r<l;r+=4)e=n[t.charCodeAt(r)]<<18|n[t.charCodeAt(r+1)]<<12|n[t.charCodeAt(r+2)]<<6|n[t.charCodeAt(r+3)],c[f++]=e>>16&255,c[f++]=e>>8&255,c[f++]=255&e;return 2===u&&(e=n[t.charCodeAt(r)]<<2|n[t.charCodeAt(r+1)]>>4,c[f++]=255&e),1===u&&(e=n[t.charCodeAt(r)]<<10|n[t.charCodeAt(r+1)]<<4|n[t.charCodeAt(r+2)]>>2,c[f++]=e>>8&255,c[f++]=255&e),c},e.fromByteArray=function(t){for(var e,n=t.length,i=n%3,o=[],a=16383,s=0,u=n-i;s<u;s+=a)o.push(c(t,s,s+a>u?u:s+a));return 1===i?(e=t[n-1],o.push(r[e>>2]+r[e<<4&63]+"==")):2===i&&(e=(t[n-2]<<8)+t[n-1],o.push(r[e>>10]+r[e>>4&63]+r[e<<2&63]+"=")),o.join("")};for(var r=[],n=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0;a<64;++a)r[a]=o[a],n[o.charCodeAt(a)]=a;function s(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function u(t){return r[t>>18&63]+r[t>>12&63]+r[t>>6&63]+r[63&t]}function c(t,e,r){for(var n,i=[],o=e;o<r;o+=3)n=(t[o]<<16&16711680)+(t[o+1]<<8&65280)+(255&t[o+2]),i.push(u(n));return i.join("")}n["-".charCodeAt(0)]=62,n["_".charCodeAt(0)]=63},7653:(t,e,r)=>{var n=r(8452),i=r(487),o=r(9211),a=r(9394),s=r(6576),u=i(a(),Object);n(u,{getPolyfill:a,implementation:o,shim:s}),t.exports=u},7816:(t,e,r)=>{var n=r(6698),i=r(392),o=r(2861).Buffer,a=[1518500249,1859775393,-1894007588,-899497514],s=new Array(80);function u(){this.init(),this._w=s,i.call(this,64,56)}function c(t){return t<<5|t>>>27}function f(t){return t<<30|t>>>2}function l(t,e,r,n){return 0===t?e&r|~e&n:2===t?e&r|e&n|r&n:e^r^n}n(u,i),u.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},u.prototype._update=function(t){for(var e=this._w,r=0|this._a,n=0|this._b,i=0|this._c,o=0|this._d,s=0|this._e,u=0;u<16;++u)e[u]=t.readInt32BE(4*u);for(;u<80;++u)e[u]=e[u-3]^e[u-8]^e[u-14]^e[u-16];for(var h=0;h<80;++h){var p=~~(h/20),d=c(r)+l(p,n,i,o)+s+e[h]+a[p]|0;s=o,o=i,i=f(n),n=r,r=d}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},u.prototype._hash=function(){var t=o.allocUnsafe(20);return t.writeInt32BE(0|this._a,0),t.writeInt32BE(0|this._b,4),t.writeInt32BE(0|this._c,8),t.writeInt32BE(0|this._d,12),t.writeInt32BE(0|this._e,16),t},t.exports=u},8002:t=>{t.exports=Math.min},8068:t=>{t.exports=SyntaxError},8075:(t,e,r)=>{var n=r(453),i=r(487),o=i(n("String.prototype.indexOf"));t.exports=function(t,e){var r=n(t,!!e);return"function"==typeof r&&o(t,".prototype.")>-1?i(r):r}},8101:(t,e,r)=>{var n=r(5606),i=Object.keys||function(t){var e=[];for(var r in t)e.push(r);return e};t.exports=f;var o=r(6891),a=r(1999);r(6698)(f,o);for(var s=i(a.prototype),u=0;u<s.length;u++){var c=s[u];f.prototype[c]||(f.prototype[c]=a.prototype[c])}function f(t){if(!(this instanceof f))return new f(t);o.call(this,t),a.call(this,t),this.allowHalfOpen=!0,t&&(!1===t.readable&&(this.readable=!1),!1===t.writable&&(this.writable=!1),!1===t.allowHalfOpen&&(this.allowHalfOpen=!1,this.once("end",l)))}function l(){this._writableState.ended||n.nextTick(h,this)}function h(t){t.end()}Object.defineProperty(f.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(f.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(f.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(f.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._readableState&&void 0!==this._writableState&&this._readableState.destroyed&&this._writableState.destroyed},set:function(t){void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed=t,this._writableState.destroyed=t)}})},8184:(t,e,r)=>{var n,i=r(6556),o=r(9721)(/^\s*(?:function)?\*/),a=r(9092)(),s=r(3628),u=i("Object.prototype.toString"),c=i("Function.prototype.toString");t.exports=function(t){if("function"!=typeof t)return!1;if(o(c(t)))return!0;if(!a)return"[object GeneratorFunction]"===u(t);if(!s)return!1;if(void 0===n){var e=function(){if(!a)return!1;try{return Function("return function*() {}")()}catch(t){}}();n=!!e&&s(e)}return s(t)===n}},8212:(t,e,r)=>{var n=r(3835),i=r(2861).Buffer;t.exports=function(t){function e(e){var r=e.slice(0,-4),n=e.slice(-4),i=t(r);if(!(n[0]^i[0]|n[1]^i[1]|n[2]^i[2]|n[3]^i[3]))return r}return{encode:function(e){var r=t(e);return n.encode(i.concat([e,r],e.length+4))},decode:function(t){var r=e(n.decode(t));if(!r)throw new Error("Invalid checksum");return r},decodeUnsafe:function(t){var r=n.decodeUnsafe(t);if(r)return e(r)}}}},8287:(t,e,r)=>{const n=r(7526),i=r(251),o="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;e.Buffer=u,e.SlowBuffer=function(t){return+t!=t&&(t=0),u.alloc(+t)},e.INSPECT_MAX_BYTES=50;const a=2147483647;function s(t){if(t>a)throw new RangeError('The value "'+t+'" is invalid for option "size"');const e=new Uint8Array(t);return Object.setPrototypeOf(e,u.prototype),e}function u(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return l(t)}return c(t,e,r)}function c(t,e,r){if("string"==typeof t)return function(t,e){if("string"==typeof e&&""!==e||(e="utf8"),!u.isEncoding(e))throw new TypeError("Unknown encoding: "+e);const r=0|y(t,e);let n=s(r);const i=n.write(t,e);return i!==r&&(n=n.slice(0,i)),n}(t,e);if(ArrayBuffer.isView(t))return function(t){if(X(t,Uint8Array)){const e=new Uint8Array(t);return p(e.buffer,e.byteOffset,e.byteLength)}return h(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(X(t,ArrayBuffer)||t&&X(t.buffer,ArrayBuffer))return p(t,e,r);if("undefined"!=typeof SharedArrayBuffer&&(X(t,SharedArrayBuffer)||t&&X(t.buffer,SharedArrayBuffer)))return p(t,e,r);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');const n=t.valueOf&&t.valueOf();if(null!=n&&n!==t)return u.from(n,e,r);const i=function(t){if(u.isBuffer(t)){const e=0|d(t.length),r=s(e);return 0===r.length||t.copy(r,0,0,e),r}return void 0!==t.length?"number"!=typeof t.length||Y(t.length)?s(0):h(t):"Buffer"===t.type&&Array.isArray(t.data)?h(t.data):void 0}(t);if(i)return i;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return u.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function f(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function l(t){return f(t),s(t<0?0:0|d(t))}function h(t){const e=t.length<0?0:0|d(t.length),r=s(e);for(let n=0;n<e;n+=1)r[n]=255&t[n];return r}function p(t,e,r){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(r||0))throw new RangeError('"length" is outside of buffer bounds');let n;return n=void 0===e&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,e):new Uint8Array(t,e,r),Object.setPrototypeOf(n,u.prototype),n}function d(t){if(t>=a)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+a.toString(16)+" bytes");return 0|t}function y(t,e){if(u.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||X(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);const r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;let i=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return q(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return z(t).length;default:if(i)return n?-1:q(t).length;e=(""+e).toLowerCase(),i=!0}}function b(t,e,r){let n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return x(this,e,r);case"utf8":case"utf-8":return T(this,e,r);case"ascii":return I(this,e,r);case"latin1":case"binary":return P(this,e,r);case"base64":return O(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return B(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function g(t,e,r){const n=t[e];t[e]=t[r],t[r]=n}function v(t,e,r,n,i){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),Y(r=+r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof e&&(e=u.from(e,n)),u.isBuffer(e))return 0===e.length?-1:w(t,e,r,n,i);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):w(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function w(t,e,r,n,i){let o,a=1,s=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;a=2,s/=2,u/=2,r/=2}function c(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(i){let n=-1;for(o=r;o<s;o++)if(c(t,o)===c(e,-1===n?0:o-n)){if(-1===n&&(n=o),o-n+1===u)return n*a}else-1!==n&&(o-=o-n),n=-1}else for(r+u>s&&(r=s-u),o=r;o>=0;o--){let r=!0;for(let n=0;n<u;n++)if(c(t,o+n)!==c(e,n)){r=!1;break}if(r)return o}return-1}function m(t,e,r,n){r=Number(r)||0;const i=t.length-r;n?(n=Number(n))>i&&(n=i):n=i;const o=e.length;let a;for(n>o/2&&(n=o/2),a=0;a<n;++a){const n=parseInt(e.substr(2*a,2),16);if(Y(n))return a;t[r+a]=n}return a}function S(t,e,r,n){return Z(q(e,t.length-r),t,r,n)}function _(t,e,r,n){return Z(function(t){const e=[];for(let r=0;r<t.length;++r)e.push(255&t.charCodeAt(r));return e}(e),t,r,n)}function E(t,e,r,n){return Z(z(e),t,r,n)}function k(t,e,r,n){return Z(function(t,e){let r,n,i;const o=[];for(let a=0;a<t.length&&!((e-=2)<0);++a)r=t.charCodeAt(a),n=r>>8,i=r%256,o.push(i),o.push(n);return o}(e,t.length-r),t,r,n)}function O(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function T(t,e,r){r=Math.min(t.length,r);const n=[];let i=e;for(;i<r;){const e=t[i];let o=null,a=e>239?4:e>223?3:e>191?2:1;if(i+a<=r){let r,n,s,u;switch(a){case 1:e<128&&(o=e);break;case 2:r=t[i+1],128==(192&r)&&(u=(31&e)<<6|63&r,u>127&&(o=u));break;case 3:r=t[i+1],n=t[i+2],128==(192&r)&&128==(192&n)&&(u=(15&e)<<12|(63&r)<<6|63&n,u>2047&&(u<55296||u>57343)&&(o=u));break;case 4:r=t[i+1],n=t[i+2],s=t[i+3],128==(192&r)&&128==(192&n)&&128==(192&s)&&(u=(15&e)<<18|(63&r)<<12|(63&n)<<6|63&s,u>65535&&u<1114112&&(o=u))}}null===o?(o=65533,a=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|1023&o),n.push(o),i+=a}return function(t){const e=t.length;if(e<=A)return String.fromCharCode.apply(String,t);let r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=A));return r}(n)}e.kMaxLength=a,u.TYPED_ARRAY_SUPPORT=function(){try{const t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),42===t.foo()}catch(t){return!1}}(),u.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||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."),Object.defineProperty(u.prototype,"parent",{enumerable:!0,get:function(){if(u.isBuffer(this))return this.buffer}}),Object.defineProperty(u.prototype,"offset",{enumerable:!0,get:function(){if(u.isBuffer(this))return this.byteOffset}}),u.poolSize=8192,u.from=function(t,e,r){return c(t,e,r)},Object.setPrototypeOf(u.prototype,Uint8Array.prototype),Object.setPrototypeOf(u,Uint8Array),u.alloc=function(t,e,r){return function(t,e,r){return f(t),t<=0?s(t):void 0!==e?"string"==typeof r?s(t).fill(e,r):s(t).fill(e):s(t)}(t,e,r)},u.allocUnsafe=function(t){return l(t)},u.allocUnsafeSlow=function(t){return l(t)},u.isBuffer=function(t){return null!=t&&!0===t._isBuffer&&t!==u.prototype},u.compare=function(t,e){if(X(t,Uint8Array)&&(t=u.from(t,t.offset,t.byteLength)),X(e,Uint8Array)&&(e=u.from(e,e.offset,e.byteLength)),!u.isBuffer(t)||!u.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;let r=t.length,n=e.length;for(let i=0,o=Math.min(r,n);i<o;++i)if(t[i]!==e[i]){r=t[i],n=e[i];break}return r<n?-1:n<r?1:0},u.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}},u.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return u.alloc(0);let r;if(void 0===e)for(e=0,r=0;r<t.length;++r)e+=t[r].length;const n=u.allocUnsafe(e);let i=0;for(r=0;r<t.length;++r){let e=t[r];if(X(e,Uint8Array))i+e.length>n.length?(u.isBuffer(e)||(e=u.from(e)),e.copy(n,i)):Uint8Array.prototype.set.call(n,e,i);else{if(!u.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(n,i)}i+=e.length}return n},u.byteLength=y,u.prototype._isBuffer=!0,u.prototype.swap16=function(){const t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;e<t;e+=2)g(this,e,e+1);return this},u.prototype.swap32=function(){const t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let e=0;e<t;e+=4)g(this,e,e+3),g(this,e+1,e+2);return this},u.prototype.swap64=function(){const t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let e=0;e<t;e+=8)g(this,e,e+7),g(this,e+1,e+6),g(this,e+2,e+5),g(this,e+3,e+4);return this},u.prototype.toString=function(){const t=this.length;return 0===t?"":0===arguments.length?T(this,0,t):b.apply(this,arguments)},u.prototype.toLocaleString=u.prototype.toString,u.prototype.equals=function(t){if(!u.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===u.compare(this,t)},u.prototype.inspect=function(){let t="";const r=e.INSPECT_MAX_BYTES;return t=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(t+=" ... "),"<Buffer "+t+">"},o&&(u.prototype[o]=u.prototype.inspect),u.prototype.compare=function(t,e,r,n,i){if(X(t,Uint8Array)&&(t=u.from(t,t.offset,t.byteLength)),!u.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),e<0||r>t.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&e>=r)return 0;if(n>=i)return-1;if(e>=r)return 1;if(this===t)return 0;let o=(i>>>=0)-(n>>>=0),a=(r>>>=0)-(e>>>=0);const s=Math.min(o,a),c=this.slice(n,i),f=t.slice(e,r);for(let t=0;t<s;++t)if(c[t]!==f[t]){o=c[t],a=f[t];break}return o<a?-1:a<o?1:0},u.prototype.includes=function(t,e,r){return-1!==this.indexOf(t,e,r)},u.prototype.indexOf=function(t,e,r){return v(this,t,e,r,!0)},u.prototype.lastIndexOf=function(t,e,r){return v(this,t,e,r,!1)},u.prototype.write=function(t,e,r,n){if(void 0===e)n="utf8",r=this.length,e=0;else if(void 0===r&&"string"==typeof e)n=e,r=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e>>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}const i=this.length-e;if((void 0===r||r>i)&&(r=i),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");let o=!1;for(;;)switch(n){case"hex":return m(this,t,e,r);case"utf8":case"utf-8":return S(this,t,e,r);case"ascii":case"latin1":case"binary":return _(this,t,e,r);case"base64":return E(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,t,e,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const A=4096;function I(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(127&t[i]);return n}function P(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(t[i]);return n}function x(t,e,r){const n=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>n)&&(r=n);let i="";for(let n=e;n<r;++n)i+=$[t[n]];return i}function B(t,e,r){const n=t.slice(e,r);let i="";for(let t=0;t<n.length-1;t+=2)i+=String.fromCharCode(n[t]+256*n[t+1]);return i}function R(t,e,r){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}function U(t,e,r,n,i,o){if(!u.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||e<o)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}function j(t,e,r,n,i){K(e,n,i,t,r,7);let o=Number(e&BigInt(4294967295));t[r++]=o,o>>=8,t[r++]=o,o>>=8,t[r++]=o,o>>=8,t[r++]=o;let a=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=a,a>>=8,t[r++]=a,a>>=8,t[r++]=a,a>>=8,t[r++]=a,r}function N(t,e,r,n,i){K(e,n,i,t,r,7);let o=Number(e&BigInt(4294967295));t[r+7]=o,o>>=8,t[r+6]=o,o>>=8,t[r+5]=o,o>>=8,t[r+4]=o;let a=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=a,a>>=8,t[r+2]=a,a>>=8,t[r+1]=a,a>>=8,t[r]=a,r+8}function L(t,e,r,n,i,o){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function C(t,e,r,n,o){return e=+e,r>>>=0,o||L(t,0,r,4),i.write(t,e,r,n,23,4),r+4}function F(t,e,r,n,o){return e=+e,r>>>=0,o||L(t,0,r,8),i.write(t,e,r,n,52,8),r+8}u.prototype.slice=function(t,e){const r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e<t&&(e=t);const n=this.subarray(t,e);return Object.setPrototypeOf(n,u.prototype),n},u.prototype.readUintLE=u.prototype.readUIntLE=function(t,e,r){t>>>=0,e>>>=0,r||R(t,e,this.length);let n=this[t],i=1,o=0;for(;++o<e&&(i*=256);)n+=this[t+o]*i;return n},u.prototype.readUintBE=u.prototype.readUIntBE=function(t,e,r){t>>>=0,e>>>=0,r||R(t,e,this.length);let n=this[t+--e],i=1;for(;e>0&&(i*=256);)n+=this[t+--e]*i;return n},u.prototype.readUint8=u.prototype.readUInt8=function(t,e){return t>>>=0,e||R(t,1,this.length),this[t]},u.prototype.readUint16LE=u.prototype.readUInt16LE=function(t,e){return t>>>=0,e||R(t,2,this.length),this[t]|this[t+1]<<8},u.prototype.readUint16BE=u.prototype.readUInt16BE=function(t,e){return t>>>=0,e||R(t,2,this.length),this[t]<<8|this[t+1]},u.prototype.readUint32LE=u.prototype.readUInt32LE=function(t,e){return t>>>=0,e||R(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},u.prototype.readUint32BE=u.prototype.readUInt32BE=function(t,e){return t>>>=0,e||R(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},u.prototype.readBigUInt64LE=J(function(t){V(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||W(t,this.length-8);const n=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,i=this[++t]+256*this[++t]+65536*this[++t]+r*2**24;return BigInt(n)+(BigInt(i)<<BigInt(32))}),u.prototype.readBigUInt64BE=J(function(t){V(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||W(t,this.length-8);const n=e*2**24+65536*this[++t]+256*this[++t]+this[++t],i=this[++t]*2**24+65536*this[++t]+256*this[++t]+r;return(BigInt(n)<<BigInt(32))+BigInt(i)}),u.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||R(t,e,this.length);let n=this[t],i=1,o=0;for(;++o<e&&(i*=256);)n+=this[t+o]*i;return i*=128,n>=i&&(n-=Math.pow(2,8*e)),n},u.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||R(t,e,this.length);let n=e,i=1,o=this[t+--n];for(;n>0&&(i*=256);)o+=this[t+--n]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*e)),o},u.prototype.readInt8=function(t,e){return t>>>=0,e||R(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},u.prototype.readInt16LE=function(t,e){t>>>=0,e||R(t,2,this.length);const r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt16BE=function(t,e){t>>>=0,e||R(t,2,this.length);const r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt32LE=function(t,e){return t>>>=0,e||R(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},u.prototype.readInt32BE=function(t,e){return t>>>=0,e||R(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},u.prototype.readBigInt64LE=J(function(t){V(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||W(t,this.length-8);const n=this[t+4]+256*this[t+5]+65536*this[t+6]+(r<<24);return(BigInt(n)<<BigInt(32))+BigInt(e+256*this[++t]+65536*this[++t]+this[++t]*2**24)}),u.prototype.readBigInt64BE=J(function(t){V(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||W(t,this.length-8);const n=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return(BigInt(n)<<BigInt(32))+BigInt(this[++t]*2**24+65536*this[++t]+256*this[++t]+r)}),u.prototype.readFloatLE=function(t,e){return t>>>=0,e||R(t,4,this.length),i.read(this,t,!0,23,4)},u.prototype.readFloatBE=function(t,e){return t>>>=0,e||R(t,4,this.length),i.read(this,t,!1,23,4)},u.prototype.readDoubleLE=function(t,e){return t>>>=0,e||R(t,8,this.length),i.read(this,t,!0,52,8)},u.prototype.readDoubleBE=function(t,e){return t>>>=0,e||R(t,8,this.length),i.read(this,t,!1,52,8)},u.prototype.writeUintLE=u.prototype.writeUIntLE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||U(this,t,e,r,Math.pow(2,8*r)-1,0);let i=1,o=0;for(this[e]=255&t;++o<r&&(i*=256);)this[e+o]=t/i&255;return e+r},u.prototype.writeUintBE=u.prototype.writeUIntBE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||U(this,t,e,r,Math.pow(2,8*r)-1,0);let i=r-1,o=1;for(this[e+i]=255&t;--i>=0&&(o*=256);)this[e+i]=t/o&255;return e+r},u.prototype.writeUint8=u.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,1,255,0),this[e]=255&t,e+1},u.prototype.writeUint16LE=u.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},u.prototype.writeUint16BE=u.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},u.prototype.writeUint32LE=u.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},u.prototype.writeUint32BE=u.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},u.prototype.writeBigUInt64LE=J(function(t,e=0){return j(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))}),u.prototype.writeBigUInt64BE=J(function(t,e=0){return N(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))}),u.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);U(this,t,e,r,n-1,-n)}let i=0,o=1,a=0;for(this[e]=255&t;++i<r&&(o*=256);)t<0&&0===a&&0!==this[e+i-1]&&(a=1),this[e+i]=(t/o|0)-a&255;return e+r},u.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);U(this,t,e,r,n-1,-n)}let i=r-1,o=1,a=0;for(this[e+i]=255&t;--i>=0&&(o*=256);)t<0&&0===a&&0!==this[e+i+1]&&(a=1),this[e+i]=(t/o|0)-a&255;return e+r},u.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},u.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},u.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},u.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},u.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},u.prototype.writeBigInt64LE=J(function(t,e=0){return j(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),u.prototype.writeBigInt64BE=J(function(t,e=0){return N(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),u.prototype.writeFloatLE=function(t,e,r){return C(this,t,e,!0,r)},u.prototype.writeFloatBE=function(t,e,r){return C(this,t,e,!1,r)},u.prototype.writeDoubleLE=function(t,e,r){return F(this,t,e,!0,r)},u.prototype.writeDoubleBE=function(t,e,r){return F(this,t,e,!1,r)},u.prototype.copy=function(t,e,r,n){if(!u.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n<r&&(n=r),n===r)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e<n-r&&(n=t.length-e+r);const i=n-r;return this===t&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(e,r,n):Uint8Array.prototype.set.call(t,this.subarray(r,n),e),i},u.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!u.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===t.length){const e=t.charCodeAt(0);("utf8"===n&&e<128||"latin1"===n)&&(t=e)}}else"number"==typeof t?t&=255:"boolean"==typeof t&&(t=Number(t));if(e<0||this.length<e||this.length<r)throw new RangeError("Out of range index");if(r<=e)return this;let i;if(e>>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(i=e;i<r;++i)this[i]=t;else{const o=u.isBuffer(t)?t:u.from(t,n),a=o.length;if(0===a)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(i=0;i<r-e;++i)this[i+e]=o[i%a]}return this};const D={};function H(t,e,r){D[t]=class extends r{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${t}]`,this.stack,delete this.name}get code(){return t}set code(t){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:t,writable:!0})}toString(){return`${this.name} [${t}]: ${this.message}`}}}function M(t){let e="",r=t.length;const n="-"===t[0]?1:0;for(;r>=n+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}function K(t,e,r,n,i,o){if(t>r||t<e){const n="bigint"==typeof e?"n":"";let i;throw i=o>3?0===e||e===BigInt(0)?`>= 0${n} and < 2${n} ** ${8*(o+1)}${n}`:`>= -(2${n} ** ${8*(o+1)-1}${n}) and < 2 ** ${8*(o+1)-1}${n}`:`>= ${e}${n} and <= ${r}${n}`,new D.ERR_OUT_OF_RANGE("value",i,t)}!function(t,e,r){V(e,"offset"),void 0!==t[e]&&void 0!==t[e+r]||W(e,t.length-(r+1))}(n,i,o)}function V(t,e){if("number"!=typeof t)throw new D.ERR_INVALID_ARG_TYPE(e,"number",t)}function W(t,e,r){if(Math.floor(t)!==t)throw V(t,r),new D.ERR_OUT_OF_RANGE(r||"offset","an integer",t);if(e<0)throw new D.ERR_BUFFER_OUT_OF_BOUNDS;throw new D.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}H("ERR_BUFFER_OUT_OF_BOUNDS",function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),H("ERR_INVALID_ARG_TYPE",function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`},TypeError),H("ERR_OUT_OF_RANGE",function(t,e,r){let n=`The value of "${t}" is out of range.`,i=r;return Number.isInteger(r)&&Math.abs(r)>2**32?i=M(String(r)):"bigint"==typeof r&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=M(i)),i+="n"),n+=` It must be ${e}. Received ${i}`,n},RangeError);const G=/[^+/0-9A-Za-z-_]/g;function q(t,e){let r;e=e||1/0;const n=t.length;let i=null;const o=[];for(let a=0;a<n;++a){if(r=t.charCodeAt(a),r>55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(a+1===n){(e-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;o.push(r)}else if(r<2048){if((e-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function z(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(G,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function Z(t,e,r,n){let i;for(i=0;i<n&&!(i+r>=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function X(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function Y(t){return t!=t}const $=function(){const t="0123456789abcdef",e=new Array(256);for(let r=0;r<16;++r){const n=16*r;for(let i=0;i<16;++i)e[n+i]=t[r]+t[i]}return e}();function J(t){return"undefined"==typeof BigInt?Q:t}function Q(){throw new Error("BigInt not supported")}},8310:(t,e,r)=>{t.exports=i;var n=r(7007).EventEmitter;function i(){n.call(this)}r(6698)(i,n),i.Readable=r(6891),i.Writable=r(1999),i.Duplex=r(8101),i.Transform=r(9083),i.PassThrough=r(3681),i.finished=r(4257),i.pipeline=r(5267),i.Stream=i,i.prototype.pipe=function(t,e){var r=this;function i(e){t.writable&&!1===t.write(e)&&r.pause&&r.pause()}function o(){r.readable&&r.resume&&r.resume()}r.on("data",i),t.on("drain",o),t._isStdio||e&&!1===e.end||(r.on("end",s),r.on("close",u));var a=!1;function s(){a||(a=!0,t.end())}function u(){a||(a=!0,"function"==typeof t.destroy&&t.destroy())}function c(t){if(f(),0===n.listenerCount(this,"error"))throw t}function f(){r.removeListener("data",i),t.removeListener("drain",o),r.removeListener("end",s),r.removeListener("close",u),r.removeListener("error",c),t.removeListener("error",c),r.removeListener("end",f),r.removeListener("close",f),t.removeListener("close",f)}return r.on("error",c),t.on("error",c),r.on("end",f),r.on("close",f),t.on("close",f),t.emit("pipe",r),t}},8377:(t,e,r)=>{var n=r(8287).Buffer,i=r(2577);function o(t,e){if(void 0!==e&&t[0]!==e)throw new Error("Invalid network version");if(33===t.length)return{version:t[0],privateKey:t.slice(1,33),compressed:!1};if(34!==t.length)throw new Error("Invalid WIF length");if(1!==t[33])throw new Error("Invalid compression flag");return{version:t[0],privateKey:t.slice(1,33),compressed:!0}}function a(t,e,r){var i=new n(r?34:33);return i.writeUInt8(t,0),e.copy(i,1),r&&(i[33]=1),i}t.exports={decode:function(t,e){return o(i.decode(t),e)},decodeRaw:o,encode:function(t,e,r){return"number"==typeof t?i.encode(a(t,e,r)):i.encode(a(t.version,t.privateKey,t.compressed))},encodeRaw:a}},8403:(t,e,r)=>{var n=r(1189),i=r(1333)(),o=r(6556),a=r(9612),s=o("Array.prototype.push"),u=o("Object.prototype.propertyIsEnumerable"),c=i?a.getOwnPropertySymbols:null;t.exports=function(t,e){if(null==t)throw new TypeError("target must be an object");var r=a(t);if(1===arguments.length)return r;for(var o=1;o<arguments.length;++o){var f=a(arguments[o]),l=n(f),h=i&&(a.getOwnPropertySymbols||c);if(h)for(var p=h(f),d=0;d<p.length;++d){var y=p[d];u(f,y)&&s(l,y)}for(var b=0;b<l.length;++b){var g=l[b];if(u(f,g)){var v=f[g];r[g]=v}}}return r}},8411:(t,e,r)=>{var n,i=r(9805),o=r(3665),a=r(3269),s=r(4823),u=r(4674),c=-2,f=258,l=262,h=103,p=113,d=666;function y(t,e){return t.msg=u[e],e}function b(t){return(t<<1)-(t>4?9:0)}function g(t){for(var e=t.length;--e>=0;)t[e]=0}function v(t){var e=t.state,r=e.pending;r>t.avail_out&&(r=t.avail_out),0!==r&&(i.arraySet(t.output,e.pending_buf,e.pending_out,r,t.next_out),t.next_out+=r,e.pending_out+=r,t.total_out+=r,t.avail_out-=r,e.pending-=r,0===e.pending&&(e.pending_out=0))}function w(t,e){o._tr_flush_block(t,t.block_start>=0?t.block_start:-1,t.strstart-t.block_start,e),t.block_start=t.strstart,v(t.strm)}function m(t,e){t.pending_buf[t.pending++]=e}function S(t,e){t.pending_buf[t.pending++]=e>>>8&255,t.pending_buf[t.pending++]=255&e}function _(t,e,r,n){var o=t.avail_in;return o>n&&(o=n),0===o?0:(t.avail_in-=o,i.arraySet(e,t.input,t.next_in,o,r),1===t.state.wrap?t.adler=a(t.adler,e,o,r):2===t.state.wrap&&(t.adler=s(t.adler,e,o,r)),t.next_in+=o,t.total_in+=o,o)}function E(t,e){var r,n,i=t.max_chain_length,o=t.strstart,a=t.prev_length,s=t.nice_match,u=t.strstart>t.w_size-l?t.strstart-(t.w_size-l):0,c=t.window,h=t.w_mask,p=t.prev,d=t.strstart+f,y=c[o+a-1],b=c[o+a];t.prev_length>=t.good_match&&(i>>=2),s>t.lookahead&&(s=t.lookahead);do{if(c[(r=e)+a]===b&&c[r+a-1]===y&&c[r]===c[o]&&c[++r]===c[o+1]){o+=2,r++;do{}while(c[++o]===c[++r]&&c[++o]===c[++r]&&c[++o]===c[++r]&&c[++o]===c[++r]&&c[++o]===c[++r]&&c[++o]===c[++r]&&c[++o]===c[++r]&&c[++o]===c[++r]&&o<d);if(n=f-(d-o),o=d-f,n>a){if(t.match_start=e,a=n,n>=s)break;y=c[o+a-1],b=c[o+a]}}}while((e=p[e&h])>u&&0!==--i);return a<=t.lookahead?a:t.lookahead}function k(t){var e,r,n,o,a,s=t.w_size;do{if(o=t.window_size-t.lookahead-t.strstart,t.strstart>=s+(s-l)){i.arraySet(t.window,t.window,s,s,0),t.match_start-=s,t.strstart-=s,t.block_start-=s,e=r=t.hash_size;do{n=t.head[--e],t.head[e]=n>=s?n-s:0}while(--r);e=r=s;do{n=t.prev[--e],t.prev[e]=n>=s?n-s:0}while(--r);o+=s}if(0===t.strm.avail_in)break;if(r=_(t.strm,t.window,t.strstart+t.lookahead,o),t.lookahead+=r,t.lookahead+t.insert>=3)for(a=t.strstart-t.insert,t.ins_h=t.window[a],t.ins_h=(t.ins_h<<t.hash_shift^t.window[a+1])&t.hash_mask;t.insert&&(t.ins_h=(t.ins_h<<t.hash_shift^t.window[a+3-1])&t.hash_mask,t.prev[a&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=a,a++,t.insert--,!(t.lookahead+t.insert<3)););}while(t.lookahead<l&&0!==t.strm.avail_in)}function O(t,e){for(var r,n;;){if(t.lookahead<l){if(k(t),t.lookahead<l&&0===e)return 1;if(0===t.lookahead)break}if(r=0,t.lookahead>=3&&(t.ins_h=(t.ins_h<<t.hash_shift^t.window[t.strstart+3-1])&t.hash_mask,r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),0!==r&&t.strstart-r<=t.w_size-l&&(t.match_length=E(t,r)),t.match_length>=3)if(n=o._tr_tally(t,t.strstart-t.match_start,t.match_length-3),t.lookahead-=t.match_length,t.match_length<=t.max_lazy_match&&t.lookahead>=3){t.match_length--;do{t.strstart++,t.ins_h=(t.ins_h<<t.hash_shift^t.window[t.strstart+3-1])&t.hash_mask,r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart}while(0!==--t.match_length);t.strstart++}else t.strstart+=t.match_length,t.match_length=0,t.ins_h=t.window[t.strstart],t.ins_h=(t.ins_h<<t.hash_shift^t.window[t.strstart+1])&t.hash_mask;else n=o._tr_tally(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++;if(n&&(w(t,!1),0===t.strm.avail_out))return 1}return t.insert=t.strstart<2?t.strstart:2,4===e?(w(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(w(t,!1),0===t.strm.avail_out)?1:2}function T(t,e){for(var r,n,i;;){if(t.lookahead<l){if(k(t),t.lookahead<l&&0===e)return 1;if(0===t.lookahead)break}if(r=0,t.lookahead>=3&&(t.ins_h=(t.ins_h<<t.hash_shift^t.window[t.strstart+3-1])&t.hash_mask,r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),t.prev_length=t.match_length,t.prev_match=t.match_start,t.match_length=2,0!==r&&t.prev_length<t.max_lazy_match&&t.strstart-r<=t.w_size-l&&(t.match_length=E(t,r),t.match_length<=5&&(1===t.strategy||3===t.match_length&&t.strstart-t.match_start>4096)&&(t.match_length=2)),t.prev_length>=3&&t.match_length<=t.prev_length){i=t.strstart+t.lookahead-3,n=o._tr_tally(t,t.strstart-1-t.prev_match,t.prev_length-3),t.lookahead-=t.prev_length-1,t.prev_length-=2;do{++t.strstart<=i&&(t.ins_h=(t.ins_h<<t.hash_shift^t.window[t.strstart+3-1])&t.hash_mask,r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart)}while(0!==--t.prev_length);if(t.match_available=0,t.match_length=2,t.strstart++,n&&(w(t,!1),0===t.strm.avail_out))return 1}else if(t.match_available){if((n=o._tr_tally(t,0,t.window[t.strstart-1]))&&w(t,!1),t.strstart++,t.lookahead--,0===t.strm.avail_out)return 1}else t.match_available=1,t.strstart++,t.lookahead--}return t.match_available&&(n=o._tr_tally(t,0,t.window[t.strstart-1]),t.match_available=0),t.insert=t.strstart<2?t.strstart:2,4===e?(w(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(w(t,!1),0===t.strm.avail_out)?1:2}function A(t,e,r,n,i){this.good_length=t,this.max_lazy=e,this.nice_length=r,this.max_chain=n,this.func=i}function I(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=8,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new i.Buf16(1146),this.dyn_dtree=new i.Buf16(122),this.bl_tree=new i.Buf16(78),g(this.dyn_ltree),g(this.dyn_dtree),g(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new i.Buf16(16),this.heap=new i.Buf16(573),g(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new i.Buf16(573),g(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function P(t){var e;return t&&t.state?(t.total_in=t.total_out=0,t.data_type=2,(e=t.state).pending=0,e.pending_out=0,e.wrap<0&&(e.wrap=-e.wrap),e.status=e.wrap?42:p,t.adler=2===e.wrap?0:1,e.last_flush=0,o._tr_init(e),0):y(t,c)}function x(t){var e=P(t);return 0===e&&function(t){t.window_size=2*t.w_size,g(t.head),t.max_lazy_match=n[t.level].max_lazy,t.good_match=n[t.level].good_length,t.nice_match=n[t.level].nice_length,t.max_chain_length=n[t.level].max_chain,t.strstart=0,t.block_start=0,t.lookahead=0,t.insert=0,t.match_length=t.prev_length=2,t.match_available=0,t.ins_h=0}(t.state),e}function B(t,e,r,n,o,a){if(!t)return c;var s=1;if(-1===e&&(e=6),n<0?(s=0,n=-n):n>15&&(s=2,n-=16),o<1||o>9||8!==r||n<8||n>15||e<0||e>9||a<0||a>4)return y(t,c);8===n&&(n=9);var u=new I;return t.state=u,u.strm=t,u.wrap=s,u.gzhead=null,u.w_bits=n,u.w_size=1<<u.w_bits,u.w_mask=u.w_size-1,u.hash_bits=o+7,u.hash_size=1<<u.hash_bits,u.hash_mask=u.hash_size-1,u.hash_shift=~~((u.hash_bits+3-1)/3),u.window=new i.Buf8(2*u.w_size),u.head=new i.Buf16(u.hash_size),u.prev=new i.Buf16(u.w_size),u.lit_bufsize=1<<o+6,u.pending_buf_size=4*u.lit_bufsize,u.pending_buf=new i.Buf8(u.pending_buf_size),u.d_buf=1*u.lit_bufsize,u.l_buf=3*u.lit_bufsize,u.level=e,u.strategy=a,u.method=r,x(t)}n=[new A(0,0,0,0,function(t,e){var r=65535;for(r>t.pending_buf_size-5&&(r=t.pending_buf_size-5);;){if(t.lookahead<=1){if(k(t),0===t.lookahead&&0===e)return 1;if(0===t.lookahead)break}t.strstart+=t.lookahead,t.lookahead=0;var n=t.block_start+r;if((0===t.strstart||t.strstart>=n)&&(t.lookahead=t.strstart-n,t.strstart=n,w(t,!1),0===t.strm.avail_out))return 1;if(t.strstart-t.block_start>=t.w_size-l&&(w(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,4===e?(w(t,!0),0===t.strm.avail_out?3:4):(t.strstart>t.block_start&&(w(t,!1),t.strm.avail_out),1)}),new A(4,4,8,4,O),new A(4,5,16,8,O),new A(4,6,32,32,O),new A(4,4,16,16,T),new A(8,16,32,32,T),new A(8,16,128,128,T),new A(8,32,128,256,T),new A(32,128,258,1024,T),new A(32,258,258,4096,T)],e.deflateInit=function(t,e){return B(t,e,8,15,8,0)},e.deflateInit2=B,e.deflateReset=x,e.deflateResetKeep=P,e.deflateSetHeader=function(t,e){return t&&t.state?2!==t.state.wrap?c:(t.state.gzhead=e,0):c},e.deflate=function(t,e){var r,i,a,u;if(!t||!t.state||e>5||e<0)return t?y(t,c):c;if(i=t.state,!t.output||!t.input&&0!==t.avail_in||i.status===d&&4!==e)return y(t,0===t.avail_out?-5:c);if(i.strm=t,r=i.last_flush,i.last_flush=e,42===i.status)if(2===i.wrap)t.adler=0,m(i,31),m(i,139),m(i,8),i.gzhead?(m(i,(i.gzhead.text?1:0)+(i.gzhead.hcrc?2:0)+(i.gzhead.extra?4:0)+(i.gzhead.name?8:0)+(i.gzhead.comment?16:0)),m(i,255&i.gzhead.time),m(i,i.gzhead.time>>8&255),m(i,i.gzhead.time>>16&255),m(i,i.gzhead.time>>24&255),m(i,9===i.level?2:i.strategy>=2||i.level<2?4:0),m(i,255&i.gzhead.os),i.gzhead.extra&&i.gzhead.extra.length&&(m(i,255&i.gzhead.extra.length),m(i,i.gzhead.extra.length>>8&255)),i.gzhead.hcrc&&(t.adler=s(t.adler,i.pending_buf,i.pending,0)),i.gzindex=0,i.status=69):(m(i,0),m(i,0),m(i,0),m(i,0),m(i,0),m(i,9===i.level?2:i.strategy>=2||i.level<2?4:0),m(i,3),i.status=p);else{var l=8+(i.w_bits-8<<4)<<8;l|=(i.strategy>=2||i.level<2?0:i.level<6?1:6===i.level?2:3)<<6,0!==i.strstart&&(l|=32),l+=31-l%31,i.status=p,S(i,l),0!==i.strstart&&(S(i,t.adler>>>16),S(i,65535&t.adler)),t.adler=1}if(69===i.status)if(i.gzhead.extra){for(a=i.pending;i.gzindex<(65535&i.gzhead.extra.length)&&(i.pending!==i.pending_buf_size||(i.gzhead.hcrc&&i.pending>a&&(t.adler=s(t.adler,i.pending_buf,i.pending-a,a)),v(t),a=i.pending,i.pending!==i.pending_buf_size));)m(i,255&i.gzhead.extra[i.gzindex]),i.gzindex++;i.gzhead.hcrc&&i.pending>a&&(t.adler=s(t.adler,i.pending_buf,i.pending-a,a)),i.gzindex===i.gzhead.extra.length&&(i.gzindex=0,i.status=73)}else i.status=73;if(73===i.status)if(i.gzhead.name){a=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>a&&(t.adler=s(t.adler,i.pending_buf,i.pending-a,a)),v(t),a=i.pending,i.pending===i.pending_buf_size)){u=1;break}u=i.gzindex<i.gzhead.name.length?255&i.gzhead.name.charCodeAt(i.gzindex++):0,m(i,u)}while(0!==u);i.gzhead.hcrc&&i.pending>a&&(t.adler=s(t.adler,i.pending_buf,i.pending-a,a)),0===u&&(i.gzindex=0,i.status=91)}else i.status=91;if(91===i.status)if(i.gzhead.comment){a=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>a&&(t.adler=s(t.adler,i.pending_buf,i.pending-a,a)),v(t),a=i.pending,i.pending===i.pending_buf_size)){u=1;break}u=i.gzindex<i.gzhead.comment.length?255&i.gzhead.comment.charCodeAt(i.gzindex++):0,m(i,u)}while(0!==u);i.gzhead.hcrc&&i.pending>a&&(t.adler=s(t.adler,i.pending_buf,i.pending-a,a)),0===u&&(i.status=h)}else i.status=h;if(i.status===h&&(i.gzhead.hcrc?(i.pending+2>i.pending_buf_size&&v(t),i.pending+2<=i.pending_buf_size&&(m(i,255&t.adler),m(i,t.adler>>8&255),t.adler=0,i.status=p)):i.status=p),0!==i.pending){if(v(t),0===t.avail_out)return i.last_flush=-1,0}else if(0===t.avail_in&&b(e)<=b(r)&&4!==e)return y(t,-5);if(i.status===d&&0!==t.avail_in)return y(t,-5);if(0!==t.avail_in||0!==i.lookahead||0!==e&&i.status!==d){var _=2===i.strategy?function(t,e){for(var r;;){if(0===t.lookahead&&(k(t),0===t.lookahead)){if(0===e)return 1;break}if(t.match_length=0,r=o._tr_tally(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++,r&&(w(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,4===e?(w(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(w(t,!1),0===t.strm.avail_out)?1:2}(i,e):3===i.strategy?function(t,e){for(var r,n,i,a,s=t.window;;){if(t.lookahead<=f){if(k(t),t.lookahead<=f&&0===e)return 1;if(0===t.lookahead)break}if(t.match_length=0,t.lookahead>=3&&t.strstart>0&&(n=s[i=t.strstart-1])===s[++i]&&n===s[++i]&&n===s[++i]){a=t.strstart+f;do{}while(n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&i<a);t.match_length=f-(a-i),t.match_length>t.lookahead&&(t.match_length=t.lookahead)}if(t.match_length>=3?(r=o._tr_tally(t,1,t.match_length-3),t.lookahead-=t.match_length,t.strstart+=t.match_length,t.match_length=0):(r=o._tr_tally(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++),r&&(w(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,4===e?(w(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(w(t,!1),0===t.strm.avail_out)?1:2}(i,e):n[i.level].func(i,e);if(3!==_&&4!==_||(i.status=d),1===_||3===_)return 0===t.avail_out&&(i.last_flush=-1),0;if(2===_&&(1===e?o._tr_align(i):5!==e&&(o._tr_stored_block(i,0,0,!1),3===e&&(g(i.head),0===i.lookahead&&(i.strstart=0,i.block_start=0,i.insert=0))),v(t),0===t.avail_out))return i.last_flush=-1,0}return 4!==e?0:i.wrap<=0?1:(2===i.wrap?(m(i,255&t.adler),m(i,t.adler>>8&255),m(i,t.adler>>16&255),m(i,t.adler>>24&255),m(i,255&t.total_in),m(i,t.total_in>>8&255),m(i,t.total_in>>16&255),m(i,t.total_in>>24&255)):(S(i,t.adler>>>16),S(i,65535&t.adler)),v(t),i.wrap>0&&(i.wrap=-i.wrap),0!==i.pending?0:1)},e.deflateEnd=function(t){var e;return t&&t.state?42!==(e=t.state.status)&&69!==e&&73!==e&&91!==e&&e!==h&&e!==p&&e!==d?y(t,c):(t.state=null,e===p?y(t,-3):0):c},e.deflateSetDictionary=function(t,e){var r,n,o,s,u,f,l,h,p=e.length;if(!t||!t.state)return c;if(2===(s=(r=t.state).wrap)||1===s&&42!==r.status||r.lookahead)return c;for(1===s&&(t.adler=a(t.adler,e,p,0)),r.wrap=0,p>=r.w_size&&(0===s&&(g(r.head),r.strstart=0,r.block_start=0,r.insert=0),h=new i.Buf8(r.w_size),i.arraySet(h,e,p-r.w_size,r.w_size,0),e=h,p=r.w_size),u=t.avail_in,f=t.next_in,l=t.input,t.avail_in=p,t.next_in=0,t.input=e,k(r);r.lookahead>=3;){n=r.strstart,o=r.lookahead-2;do{r.ins_h=(r.ins_h<<r.hash_shift^r.window[n+3-1])&r.hash_mask,r.prev[n&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=n,n++}while(--o);r.strstart=n,r.lookahead=2,k(r)}return r.strstart+=r.lookahead,r.block_start=r.strstart,r.insert=r.lookahead,r.lookahead=0,r.match_length=r.prev_length=2,r.match_available=0,t.next_in=f,t.input=l,t.avail_in=u,r.wrap=s,0},e.deflateInfo="pako deflate (from Nodeca project)"},8452:(t,e,r)=>{var n=r(1189),i="function"==typeof Symbol&&"symbol"==typeof Symbol("foo"),o=Object.prototype.toString,a=Array.prototype.concat,s=r(41),u=r(592)(),c=function(t,e,r,n){if(e in t)if(!0===n){if(t[e]===r)return}else if(!function(t){return"function"==typeof t&&"[object Function]"===o.call(t)}(n)||!n())return;u?s(t,e,r,!0):s(t,e,r)},f=function(t,e){var r=arguments.length>2?arguments[2]:{},o=n(e);i&&(o=a.call(o,Object.getOwnPropertySymbols(e)));for(var s=0;s<o.length;s+=1)c(t,o[s],e[o[s]],r[o[s]])};f.supportsDescriptors=!!u,t.exports=f},8460:()=>{},8510:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.encodeToCurve=e.hashToCurve=e.secp256k1_hasher=e.schnorr=e.secp256k1=void 0;const n=r(7076),i=r(9175),o=r(3562),a=r(1761),s=r(4967),u=r(1705),c=r(8627),f={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},l={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]},h=BigInt(0),p=BigInt(1),d=BigInt(2),y=(0,s.Field)(f.p,{sqrt:function(t){const e=f.p,r=BigInt(3),n=BigInt(6),i=BigInt(11),o=BigInt(22),a=BigInt(23),u=BigInt(44),c=BigInt(88),l=t*t*t%e,h=l*l*t%e,p=(0,s.pow2)(h,r,e)*h%e,b=(0,s.pow2)(p,r,e)*h%e,g=(0,s.pow2)(b,d,e)*l%e,v=(0,s.pow2)(g,i,e)*g%e,w=(0,s.pow2)(v,o,e)*v%e,m=(0,s.pow2)(w,u,e)*w%e,S=(0,s.pow2)(m,c,e)*m%e,_=(0,s.pow2)(S,u,e)*w%e,E=(0,s.pow2)(_,r,e)*h%e,k=(0,s.pow2)(E,a,e)*v%e,O=(0,s.pow2)(k,n,e)*l%e,T=(0,s.pow2)(O,d,e);if(!y.eql(y.sqr(T),t))throw new Error("Cannot find square root");return T}});e.secp256k1=(0,o.createCurve)({...f,Fp:y,lowS:!0,endo:l},n.sha256);const b={};function g(t,...e){let r=b[t];if(void 0===r){const e=(0,n.sha256)((0,c.utf8ToBytes)(t));r=(0,c.concatBytes)(e,e),b[t]=r}return(0,n.sha256)((0,c.concatBytes)(r,...e))}const v=t=>t.toBytes(!0).slice(1),w=(()=>e.secp256k1.Point)(),m=t=>t%d===h;function S(t){const{Fn:e,BASE:r}=w,n=(0,u._normFnElement)(e,t),i=r.multiply(n);return{scalar:m(i.y)?n:e.neg(n),bytes:v(i)}}function _(t){const e=y;if(!e.isValidNot0(t))throw new Error("invalid x: Fail if x ≥ p");const r=e.create(t*t),n=e.create(r*t+BigInt(7));let i=e.sqrt(n);m(i)||(i=e.neg(i));const o=w.fromAffine({x:t,y:i});return o.assertValidity(),o}const E=c.bytesToNumberBE;function k(...t){return w.Fn.create(E(g("BIP0340/challenge",...t)))}function O(t){return S(t).bytes}function T(t,e,r=(0,i.randomBytes)(32)){const{Fn:n}=w,o=(0,c.ensureBytes)("message",t),{bytes:a,scalar:s}=S(e),u=(0,c.ensureBytes)("auxRand",r,32),f=n.toBytes(s^E(g("BIP0340/aux",u))),l=g("BIP0340/nonce",f,a,o),{bytes:h,scalar:p}=S(l),d=k(h,a,o),y=new Uint8Array(64);if(y.set(h,0),y.set(n.toBytes(n.create(p+d*s)),32),!A(y,o,a))throw new Error("sign: Invalid signature produced");return y}function A(t,e,r){const{Fn:n,BASE:i}=w,o=(0,c.ensureBytes)("signature",t,64),a=(0,c.ensureBytes)("message",e),s=(0,c.ensureBytes)("publicKey",r,32);try{const t=_(E(s)),e=E(o.subarray(0,32));if(!(0,c.inRange)(e,p,f.p))return!1;const r=E(o.subarray(32,64));if(!(0,c.inRange)(r,p,f.n))return!1;const u=k(n.toBytes(e),v(t),a),l=i.multiplyUnsafe(r).add(t.multiplyUnsafe(n.neg(u))),{x:h,y:d}=l.toAffine();return!(l.is0()||!m(d)||h!==e)}catch(t){return!1}}e.schnorr=(()=>{const t=(t=(0,i.randomBytes)(48))=>(0,s.mapHashToField)(t,f.n);return e.secp256k1.utils.randomSecretKey,{keygen:function(e){const r=t(e);return{secretKey:r,publicKey:O(r)}},getPublicKey:O,sign:T,verify:A,Point:w,utils:{randomSecretKey:t,randomPrivateKey:t,taggedHash:g,lift_x:_,pointToBytes:v,numberToBytesBE:c.numberToBytesBE,bytesToNumberBE:c.bytesToNumberBE,mod:s.mod},lengths:{secretKey:32,publicKey:32,publicKeyHasPrefix:!1,signature:64,seed:48}}})();const I=(()=>(0,a.isogenyMap)(y,[["0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa8c7","0x7d3d4c80bc321d5b9f315cea7fd44c5d595d2fc0bf63b92dfff1044f17c6581","0x534c328d23f234e6e2a413deca25caece4506144037c40314ecbd0b53d9dd262","0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa88c"],["0xd35771193d94918a9ca34ccbb7b640dd86cd409542f8487d9fe6b745781eb49b","0xedadc6f64383dc1df7c4b2d51b54225406d36b641f5e41bbc52a56612a8c6d14","0x0000000000000000000000000000000000000000000000000000000000000001"],["0x4bda12f684bda12f684bda12f684bda12f684bda12f684bda12f684b8e38e23c","0xc75e0c32d5cb7c0fa9d0a54b12a0a6d5647ab046d686da6fdffc90fc201d71a3","0x29a6194691f91a73715209ef6512e576722830a201be2018a765e85a9ecee931","0x2f684bda12f684bda12f684bda12f684bda12f684bda12f684bda12f38e38d84"],["0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffff93b","0x7a06534bb8bdb49fd5e9e6632722c2989467c1bfc8e8d978dfb425d2685c2573","0x6484aa716545ca2cf3a70c3fa8fe337e0a3d21162f0d6299a7bf8192bfd2a76f","0x0000000000000000000000000000000000000000000000000000000000000001"]].map(t=>t.map(t=>BigInt(t)))))(),P=(()=>(0,u.mapToCurveSimpleSWU)(y,{A:BigInt("0x3f8731abdd661adca08a5558f0f5d272e953d363cb6f0e5d405447c01a444533"),B:BigInt("1771"),Z:y.create(BigInt("-11"))}))();e.secp256k1_hasher=(0,a.createHasher)(e.secp256k1.Point,t=>{const{x:e,y:r}=P(y.create(t[0]));return I(e,r)},{DST:"secp256k1_XMD:SHA-256_SSWU_RO_",encodeDST:"secp256k1_XMD:SHA-256_SSWU_NU_",p:y.ORDER,m:1,k:128,expand:"xmd",hash:n.sha256}),e.hashToCurve=e.secp256k1_hasher.hashToCurve,e.encodeToCurve=e.secp256k1_hasher.encodeToCurve},8559:(t,e,r)=>{var n=r(5606),i=r(8287).Buffer,o=r(8310).Transform,a=r(5974),s=r(537),u=r(4148).ok,c=r(8287).kMaxLength,f="Cannot create final Buffer. It would be larger than 0x"+c.toString(16)+" bytes";a.Z_MIN_WINDOWBITS=8,a.Z_MAX_WINDOWBITS=15,a.Z_DEFAULT_WINDOWBITS=15,a.Z_MIN_CHUNK=64,a.Z_MAX_CHUNK=1/0,a.Z_DEFAULT_CHUNK=16384,a.Z_MIN_MEMLEVEL=1,a.Z_MAX_MEMLEVEL=9,a.Z_DEFAULT_MEMLEVEL=8,a.Z_MIN_LEVEL=-1,a.Z_MAX_LEVEL=9,a.Z_DEFAULT_LEVEL=a.Z_DEFAULT_COMPRESSION;for(var l=Object.keys(a),h=0;h<l.length;h++){var p=l[h];p.match(/^Z/)&&Object.defineProperty(e,p,{enumerable:!0,value:a[p],writable:!1})}for(var d={Z_OK:a.Z_OK,Z_STREAM_END:a.Z_STREAM_END,Z_NEED_DICT:a.Z_NEED_DICT,Z_ERRNO:a.Z_ERRNO,Z_STREAM_ERROR:a.Z_STREAM_ERROR,Z_DATA_ERROR:a.Z_DATA_ERROR,Z_MEM_ERROR:a.Z_MEM_ERROR,Z_BUF_ERROR:a.Z_BUF_ERROR,Z_VERSION_ERROR:a.Z_VERSION_ERROR},y=Object.keys(d),b=0;b<y.length;b++){var g=y[b];d[d[g]]=g}function v(t,e,r){var n=[],o=0;function a(){for(var e;null!==(e=t.read());)n.push(e),o+=e.length;t.once("readable",a)}function s(){var e,a=null;o>=c?a=new RangeError(f):e=i.concat(n,o),n=[],t.close(),r(a,e)}t.on("error",function(e){t.removeListener("end",s),t.removeListener("readable",a),r(e)}),t.on("end",s),t.end(e),a()}function w(t,e){if("string"==typeof e&&(e=i.from(e)),!i.isBuffer(e))throw new TypeError("Not a string or buffer");var r=t._finishFlushFlag;return t._processChunk(e,r)}function m(t){if(!(this instanceof m))return new m(t);I.call(this,t,a.DEFLATE)}function S(t){if(!(this instanceof S))return new S(t);I.call(this,t,a.INFLATE)}function _(t){if(!(this instanceof _))return new _(t);I.call(this,t,a.GZIP)}function E(t){if(!(this instanceof E))return new E(t);I.call(this,t,a.GUNZIP)}function k(t){if(!(this instanceof k))return new k(t);I.call(this,t,a.DEFLATERAW)}function O(t){if(!(this instanceof O))return new O(t);I.call(this,t,a.INFLATERAW)}function T(t){if(!(this instanceof T))return new T(t);I.call(this,t,a.UNZIP)}function A(t){return t===a.Z_NO_FLUSH||t===a.Z_PARTIAL_FLUSH||t===a.Z_SYNC_FLUSH||t===a.Z_FULL_FLUSH||t===a.Z_FINISH||t===a.Z_BLOCK}function I(t,r){var n=this;if(this._opts=t=t||{},this._chunkSize=t.chunkSize||e.Z_DEFAULT_CHUNK,o.call(this,t),t.flush&&!A(t.flush))throw new Error("Invalid flush flag: "+t.flush);if(t.finishFlush&&!A(t.finishFlush))throw new Error("Invalid flush flag: "+t.finishFlush);if(this._flushFlag=t.flush||a.Z_NO_FLUSH,this._finishFlushFlag=void 0!==t.finishFlush?t.finishFlush:a.Z_FINISH,t.chunkSize&&(t.chunkSize<e.Z_MIN_CHUNK||t.chunkSize>e.Z_MAX_CHUNK))throw new Error("Invalid chunk size: "+t.chunkSize);if(t.windowBits&&(t.windowBits<e.Z_MIN_WINDOWBITS||t.windowBits>e.Z_MAX_WINDOWBITS))throw new Error("Invalid windowBits: "+t.windowBits);if(t.level&&(t.level<e.Z_MIN_LEVEL||t.level>e.Z_MAX_LEVEL))throw new Error("Invalid compression level: "+t.level);if(t.memLevel&&(t.memLevel<e.Z_MIN_MEMLEVEL||t.memLevel>e.Z_MAX_MEMLEVEL))throw new Error("Invalid memLevel: "+t.memLevel);if(t.strategy&&t.strategy!=e.Z_FILTERED&&t.strategy!=e.Z_HUFFMAN_ONLY&&t.strategy!=e.Z_RLE&&t.strategy!=e.Z_FIXED&&t.strategy!=e.Z_DEFAULT_STRATEGY)throw new Error("Invalid strategy: "+t.strategy);if(t.dictionary&&!i.isBuffer(t.dictionary))throw new Error("Invalid dictionary: it should be a Buffer instance");this._handle=new a.Zlib(r);var s=this;this._hadError=!1,this._handle.onerror=function(t,r){P(s),s._hadError=!0;var n=new Error(t);n.errno=r,n.code=e.codes[r],s.emit("error",n)};var u=e.Z_DEFAULT_COMPRESSION;"number"==typeof t.level&&(u=t.level);var c=e.Z_DEFAULT_STRATEGY;"number"==typeof t.strategy&&(c=t.strategy),this._handle.init(t.windowBits||e.Z_DEFAULT_WINDOWBITS,u,t.memLevel||e.Z_DEFAULT_MEMLEVEL,c,t.dictionary),this._buffer=i.allocUnsafe(this._chunkSize),this._offset=0,this._level=u,this._strategy=c,this.once("end",this.close),Object.defineProperty(this,"_closed",{get:function(){return!n._handle},configurable:!0,enumerable:!0})}function P(t,e){e&&n.nextTick(e),t._handle&&(t._handle.close(),t._handle=null)}function x(t){t.emit("close")}Object.defineProperty(e,"codes",{enumerable:!0,value:Object.freeze(d),writable:!1}),e.Deflate=m,e.Inflate=S,e.Gzip=_,e.Gunzip=E,e.DeflateRaw=k,e.InflateRaw=O,e.Unzip=T,e.createDeflate=function(t){return new m(t)},e.createInflate=function(t){return new S(t)},e.createDeflateRaw=function(t){return new k(t)},e.createInflateRaw=function(t){return new O(t)},e.createGzip=function(t){return new _(t)},e.createGunzip=function(t){return new E(t)},e.createUnzip=function(t){return new T(t)},e.deflate=function(t,e,r){return"function"==typeof e&&(r=e,e={}),v(new m(e),t,r)},e.deflateSync=function(t,e){return w(new m(e),t)},e.gzip=function(t,e,r){return"function"==typeof e&&(r=e,e={}),v(new _(e),t,r)},e.gzipSync=function(t,e){return w(new _(e),t)},e.deflateRaw=function(t,e,r){return"function"==typeof e&&(r=e,e={}),v(new k(e),t,r)},e.deflateRawSync=function(t,e){return w(new k(e),t)},e.unzip=function(t,e,r){return"function"==typeof e&&(r=e,e={}),v(new T(e),t,r)},e.unzipSync=function(t,e){return w(new T(e),t)},e.inflate=function(t,e,r){return"function"==typeof e&&(r=e,e={}),v(new S(e),t,r)},e.inflateSync=function(t,e){return w(new S(e),t)},e.gunzip=function(t,e,r){return"function"==typeof e&&(r=e,e={}),v(new E(e),t,r)},e.gunzipSync=function(t,e){return w(new E(e),t)},e.inflateRaw=function(t,e,r){return"function"==typeof e&&(r=e,e={}),v(new O(e),t,r)},e.inflateRawSync=function(t,e){return w(new O(e),t)},s.inherits(I,o),I.prototype.params=function(t,r,i){if(t<e.Z_MIN_LEVEL||t>e.Z_MAX_LEVEL)throw new RangeError("Invalid compression level: "+t);if(r!=e.Z_FILTERED&&r!=e.Z_HUFFMAN_ONLY&&r!=e.Z_RLE&&r!=e.Z_FIXED&&r!=e.Z_DEFAULT_STRATEGY)throw new TypeError("Invalid strategy: "+r);if(this._level!==t||this._strategy!==r){var o=this;this.flush(a.Z_SYNC_FLUSH,function(){u(o._handle,"zlib binding closed"),o._handle.params(t,r),o._hadError||(o._level=t,o._strategy=r,i&&i())})}else n.nextTick(i)},I.prototype.reset=function(){return u(this._handle,"zlib binding closed"),this._handle.reset()},I.prototype._flush=function(t){this._transform(i.alloc(0),"",t)},I.prototype.flush=function(t,e){var r=this,o=this._writableState;("function"==typeof t||void 0===t&&!e)&&(e=t,t=a.Z_FULL_FLUSH),o.ended?e&&n.nextTick(e):o.ending?e&&this.once("end",e):o.needDrain?e&&this.once("drain",function(){return r.flush(t,e)}):(this._flushFlag=t,this.write(i.alloc(0),"",e))},I.prototype.close=function(t){P(this,t),n.nextTick(x,this)},I.prototype._transform=function(t,e,r){var n,o=this._writableState,s=(o.ending||o.ended)&&(!t||o.length===t.length);return null===t||i.isBuffer(t)?this._handle?(s?n=this._finishFlushFlag:(n=this._flushFlag,t.length>=o.length&&(this._flushFlag=this._opts.flush||a.Z_NO_FLUSH)),void this._processChunk(t,n,r)):r(new Error("zlib binding closed")):r(new Error("invalid input"))},I.prototype._processChunk=function(t,e,r){var n=t&&t.length,o=this._chunkSize-this._offset,a=0,s=this,l="function"==typeof r;if(!l){var h,p=[],d=0;this.on("error",function(t){h=t}),u(this._handle,"zlib binding closed");do{var y=this._handle.writeSync(e,t,a,n,this._buffer,this._offset,o)}while(!this._hadError&&v(y[0],y[1]));if(this._hadError)throw h;if(d>=c)throw P(this),new RangeError(f);var b=i.concat(p,d);return P(this),b}u(this._handle,"zlib binding closed");var g=this._handle.write(e,t,a,n,this._buffer,this._offset,o);function v(c,f){if(this&&(this.buffer=null,this.callback=null),!s._hadError){var h=o-f;if(u(h>=0,"have should not go down"),h>0){var y=s._buffer.slice(s._offset,s._offset+h);s._offset+=h,l?s.push(y):(p.push(y),d+=y.length)}if((0===f||s._offset>=s._chunkSize)&&(o=s._chunkSize,s._offset=0,s._buffer=i.allocUnsafe(s._chunkSize)),0===f){if(a+=n-c,n=c,!l)return!0;var b=s._handle.write(e,t,a,n,s._buffer,s._offset,s._chunkSize);return b.callback=v,void(b.buffer=t)}if(!l)return!1;r()}}g.buffer=t,g.callback=v},s.inherits(m,I),s.inherits(S,I),s.inherits(_,I),s.inherits(E,I),s.inherits(k,I),s.inherits(O,I),s.inherits(T,I)},8627:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.notImplemented=e.bitMask=e.utf8ToBytes=e.randomBytes=e.isBytes=e.hexToBytes=e.concatBytes=e.bytesToUtf8=e.bytesToHex=e.anumber=e.abytes=void 0,e.abool=function(t,e){if("boolean"!=typeof e)throw new Error(t+" boolean expected, got "+e)},e._abool2=function(t,e=""){if("boolean"!=typeof t)throw new Error((e&&`"${e}"`)+"expected boolean, got type="+typeof t);return t},e._abytes2=function(t,e,r=""){const i=(0,n.isBytes)(t),o=t?.length,a=void 0!==e;if(!i||a&&o!==e)throw new Error((r&&`"${r}" `)+"expected Uint8Array"+(a?` of length ${e}`:"")+", got "+(i?`length=${o}`:"type="+typeof t));return t},e.numberToHexUnpadded=s,e.hexToNumber=u,e.bytesToNumberBE=function(t){return u((0,n.bytesToHex)(t))},e.bytesToNumberLE=function(t){return(0,n.abytes)(t),u((0,n.bytesToHex)(Uint8Array.from(t).reverse()))},e.numberToBytesBE=c,e.numberToBytesLE=function(t,e){return c(t,e).reverse()},e.numberToVarBytesBE=function(t){return(0,n.hexToBytes)(s(t))},e.ensureBytes=function(t,e,r){let i;if("string"==typeof e)try{i=(0,n.hexToBytes)(e)}catch(e){throw new Error(t+" must be hex string or Uint8Array, cause: "+e)}else{if(!(0,n.isBytes)(e))throw new Error(t+" must be hex string or Uint8Array");i=Uint8Array.from(e)}const o=i.length;if("number"==typeof r&&o!==r)throw new Error(t+" of length "+r+" expected, got "+o);return i},e.equalBytes=function(t,e){if(t.length!==e.length)return!1;let r=0;for(let n=0;n<t.length;n++)r|=t[n]^e[n];return 0===r},e.copyBytes=function(t){return Uint8Array.from(t)},e.asciiToBytes=function(t){return Uint8Array.from(t,(e,r)=>{const n=e.charCodeAt(0);if(1!==e.length||n>127)throw new Error(`string contains non-ASCII character "${t[r]}" with code ${n} at position ${r}`);return n})},e.inRange=l,e.aInRange=function(t,e,r,n){if(!l(e,r,n))throw new Error("expected valid "+t+": "+r+" <= n < "+n+", got "+e)},e.bitLen=function(t){let e;for(e=0;t>o;t>>=a,e+=1);return e},e.bitGet=function(t,e){return t>>BigInt(e)&a},e.bitSet=function(t,e,r){return t|(r?a:o)<<BigInt(e)},e.createHmacDrbg=function(t,e,r){if("number"!=typeof t||t<2)throw new Error("hashLen must be a number");if("number"!=typeof e||e<2)throw new Error("qByteLen must be a number");if("function"!=typeof r)throw new Error("hmacFn must be a function");const i=t=>new Uint8Array(t),o=t=>Uint8Array.of(t);let a=i(t),s=i(t),u=0;const c=()=>{a.fill(1),s.fill(0),u=0},f=(...t)=>r(s,a,...t),l=(t=i(0))=>{s=f(o(0),t),a=f(),0!==t.length&&(s=f(o(1),t),a=f())},h=()=>{if(u++>=1e3)throw new Error("drbg: tried 1000 values");let t=0;const r=[];for(;t<e;){a=f();const e=a.slice();r.push(e),t+=a.length}return(0,n.concatBytes)(...r)};return(t,e)=>{let r;for(c(),l(t);!(r=e(h()));)l();return c(),r}},e.validateObject=function(t,e,r={}){const n=(e,r,n)=>{const i=h[r];if("function"!=typeof i)throw new Error("invalid validator function");const o=t[e];if(!(n&&void 0===o||i(o,t)))throw new Error("param "+String(e)+" is invalid. Expected "+r+", got "+o)};for(const[t,r]of Object.entries(e))n(t,r,!1);for(const[t,e]of Object.entries(r))n(t,e,!0);return t},e.isHash=function(t){return"function"==typeof t&&Number.isSafeInteger(t.outputLen)},e._validateObject=function(t,e,r={}){if(!t||"object"!=typeof t)throw new Error("expected valid options object");function n(e,r,n){const i=t[e];if(n&&void 0===i)return;const o=typeof i;if(o!==r||null===i)throw new Error(`param "${e}" is invalid: expected ${r}, got ${o}`)}Object.entries(e).forEach(([t,e])=>n(t,e,!1)),Object.entries(r).forEach(([t,e])=>n(t,e,!0))},e.memoized=function(t){const e=new WeakMap;return(r,...n)=>{const i=e.get(r);if(void 0!==i)return i;const o=t(r,...n);return e.set(r,o),o}};const n=r(9175);var i=r(9175);Object.defineProperty(e,"abytes",{enumerable:!0,get:function(){return i.abytes}}),Object.defineProperty(e,"anumber",{enumerable:!0,get:function(){return i.anumber}}),Object.defineProperty(e,"bytesToHex",{enumerable:!0,get:function(){return i.bytesToHex}}),Object.defineProperty(e,"bytesToUtf8",{enumerable:!0,get:function(){return i.bytesToUtf8}}),Object.defineProperty(e,"concatBytes",{enumerable:!0,get:function(){return i.concatBytes}}),Object.defineProperty(e,"hexToBytes",{enumerable:!0,get:function(){return i.hexToBytes}}),Object.defineProperty(e,"isBytes",{enumerable:!0,get:function(){return i.isBytes}}),Object.defineProperty(e,"randomBytes",{enumerable:!0,get:function(){return i.randomBytes}}),Object.defineProperty(e,"utf8ToBytes",{enumerable:!0,get:function(){return i.utf8ToBytes}});const o=BigInt(0),a=BigInt(1);function s(t){const e=t.toString(16);return 1&e.length?"0"+e:e}function u(t){if("string"!=typeof t)throw new Error("hex string expected, got "+typeof t);return""===t?o:BigInt("0x"+t)}function c(t,e){return(0,n.hexToBytes)(t.toString(16).padStart(2*e,"0"))}const f=t=>"bigint"==typeof t&&o<=t;function l(t,e,r){return f(t)&&f(e)&&f(r)&&e<=t&&t<r}e.bitMask=t=>(a<<BigInt(t))-a;const h={bigint:t=>"bigint"==typeof t,function:t=>"function"==typeof t,boolean:t=>"boolean"==typeof t,string:t=>"string"==typeof t,stringOrUint8Array:t=>"string"==typeof t||(0,n.isBytes)(t),isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,e)=>e.Fp.isValid(t),hash:t=>"function"==typeof t&&Number.isSafeInteger(t.outputLen)};e.notImplemented=()=>{throw new Error("not implemented")}},8648:t=>{t.exports="undefined"!=typeof Reflect&&Reflect.getPrototypeOf||null},8676:(t,e,r)=>{var n=r(1061),i=r(2113),o=n.tfJSON,a=n.TfTypeError,s=n.TfPropertyTypeError,u=n.tfSubError,c=n.getValueTypeName,f={arrayOf:function(t,e){function r(r,n){return!!i.Array(r)&&!i.Nil(r)&&!(void 0!==e.minLength&&r.length<e.minLength)&&!(void 0!==e.maxLength&&r.length>e.maxLength)&&(void 0===e.length||r.length===e.length)&&r.every(function(e,r){try{return h(t,e,n)}catch(t){throw u(t,r)}})}return t=l(t),e=e||{},r.toJSON=function(){var r="["+o(t)+"]";return void 0!==e.length?r+="{"+e.length+"}":void 0===e.minLength&&void 0===e.maxLength||(r+="{"+(void 0===e.minLength?0:e.minLength)+","+(void 0===e.maxLength?1/0:e.maxLength)+"}"),r},r},maybe:function t(e){function r(r,n){return i.Nil(r)||e(r,n,t)}return e=l(e),r.toJSON=function(){return"?"+o(e)},r},map:function(t,e){function r(r,n){if(!i.Object(r))return!1;if(i.Nil(r))return!1;for(var o in r){try{e&&h(e,o,n)}catch(t){throw u(t,o,"key")}try{var a=r[o];h(t,a,n)}catch(t){throw u(t,o)}}return!0}return t=l(t),e&&(e=l(e)),r.toJSON=e?function(){return"{"+o(e)+": "+o(t)+"}"}:function(){return"{"+o(t)+"}"},r},object:function(t){var e={};for(var r in t)e[r]=l(t[r]);function n(t,r){if(!i.Object(t))return!1;if(i.Nil(t))return!1;var n;try{for(n in e)h(e[n],t[n],r)}catch(t){throw u(t,n)}if(r)for(n in t)if(!e[n])throw new s(void 0,n);return!0}return n.toJSON=function(){return o(e)},n},anyOf:function(){var t=[].slice.call(arguments).map(l);function e(e,r){return t.some(function(t){try{return h(t,e,r)}catch(t){return!1}})}return e.toJSON=function(){return t.map(o).join("|")},e},allOf:function(){var t=[].slice.call(arguments).map(l);function e(e,r){return t.every(function(t){try{return h(t,e,r)}catch(t){return!1}})}return e.toJSON=function(){return t.map(o).join(" & ")},e},quacksLike:function(t){function e(e){return t===c(e)}return e.toJSON=function(){return t},e},tuple:function(){var t=[].slice.call(arguments).map(l);function e(e,r){return!i.Nil(e)&&!i.Nil(e.length)&&(!r||e.length===t.length)&&t.every(function(t,n){try{return h(t,e[n],r)}catch(t){throw u(t,n)}})}return e.toJSON=function(){return"("+t.map(o).join(", ")+")"},e},value:function(t){function e(e){return e===t}return e.toJSON=function(){return t},e}};function l(t){if(i.String(t))return"?"===t[0]?f.maybe(t.slice(1)):i[t]||f.quacksLike(t);if(t&&i.Object(t)){if(i.Array(t)){if(1!==t.length)throw new TypeError("Expected compile() parameter of type Array of length 1");return f.arrayOf(t[0])}return f.object(t)}return i.Function(t)?t:f.value(t)}function h(t,e,r,n){if(i.Function(t)){if(t(e,r))return!0;throw new a(n||t,e)}return h(l(t),e,r)}for(var p in f.oneOf=f.anyOf,i)h[p]=i[p];for(p in f)h[p]=f[p];var d=r(9542);for(p in d)h[p]=d[p];h.compile=l,h.TfTypeError=a,h.TfPropertyTypeError=s,t.exports=h},8700:(t,e,r)=>{e.dg=void 0;var n=r(5170);Object.defineProperty(e,"dg",{enumerable:!0,get:function(){return n.ECPairFactory}})},8775:(t,e,r)=>{var n=r(2260).F.ERR_INVALID_OPT_VALUE;t.exports={getHighWaterMark:function(t,e,r,i){var o=function(t,e,r){return null!=t.highWaterMark?t.highWaterMark:e?t[r]:null}(e,i,r);if(null!=o){if(!isFinite(o)||Math.floor(o)!==o||o<0)throw new n(i?r:"highWaterMark",o);return Math.floor(o)}return t.objectMode?16:16384}}},8875:(t,e,r)=>{var n;if(!Object.keys){var i=Object.prototype.hasOwnProperty,o=Object.prototype.toString,a=r(1093),s=Object.prototype.propertyIsEnumerable,u=!s.call({toString:null},"toString"),c=s.call(function(){},"prototype"),f=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],l=function(t){var e=t.constructor;return e&&e.prototype===t},h={$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},p=function(){if("undefined"==typeof window)return!1;for(var t in window)try{if(!h["$"+t]&&i.call(window,t)&&null!==window[t]&&"object"==typeof window[t])try{l(window[t])}catch(t){return!0}}catch(t){return!0}return!1}();n=function(t){var e=null!==t&&"object"==typeof t,r="[object Function]"===o.call(t),n=a(t),s=e&&"[object String]"===o.call(t),h=[];if(!e&&!r&&!n)throw new TypeError("Object.keys called on a non-object");var d=c&&r;if(s&&t.length>0&&!i.call(t,0))for(var y=0;y<t.length;++y)h.push(String(y));if(n&&t.length>0)for(var b=0;b<t.length;++b)h.push(String(b));else for(var g in t)d&&"prototype"===g||!i.call(t,g)||h.push(String(g));if(u)for(var v=function(t){if("undefined"==typeof window||!p)return l(t);try{return l(t)}catch(t){return!1}}(t),w=0;w<f.length;++w)v&&"constructor"===f[w]||!i.call(t,f[w])||h.push(f[w]);return h}}t.exports=n},8968:t=>{t.exports=Math.floor},9032:(t,e,r)=>{var n=r(7244),i=r(8184),o=r(5767),a=r(5680);function s(t){return t.call.bind(t)}var u="undefined"!=typeof BigInt,c="undefined"!=typeof Symbol,f=s(Object.prototype.toString),l=s(Number.prototype.valueOf),h=s(String.prototype.valueOf),p=s(Boolean.prototype.valueOf);if(u)var d=s(BigInt.prototype.valueOf);if(c)var y=s(Symbol.prototype.valueOf);function b(t,e){if("object"!=typeof t)return!1;try{return e(t),!0}catch(t){return!1}}function g(t){return"[object Map]"===f(t)}function v(t){return"[object Set]"===f(t)}function w(t){return"[object WeakMap]"===f(t)}function m(t){return"[object WeakSet]"===f(t)}function S(t){return"[object ArrayBuffer]"===f(t)}function _(t){return"undefined"!=typeof ArrayBuffer&&(S.working?S(t):t instanceof ArrayBuffer)}function E(t){return"[object DataView]"===f(t)}function k(t){return"undefined"!=typeof DataView&&(E.working?E(t):t instanceof DataView)}e.isArgumentsObject=n,e.isGeneratorFunction=i,e.isTypedArray=a,e.isPromise=function(t){return"undefined"!=typeof Promise&&t instanceof Promise||null!==t&&"object"==typeof t&&"function"==typeof t.then&&"function"==typeof t.catch},e.isArrayBufferView=function(t){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(t):a(t)||k(t)},e.isUint8Array=function(t){return"Uint8Array"===o(t)},e.isUint8ClampedArray=function(t){return"Uint8ClampedArray"===o(t)},e.isUint16Array=function(t){return"Uint16Array"===o(t)},e.isUint32Array=function(t){return"Uint32Array"===o(t)},e.isInt8Array=function(t){return"Int8Array"===o(t)},e.isInt16Array=function(t){return"Int16Array"===o(t)},e.isInt32Array=function(t){return"Int32Array"===o(t)},e.isFloat32Array=function(t){return"Float32Array"===o(t)},e.isFloat64Array=function(t){return"Float64Array"===o(t)},e.isBigInt64Array=function(t){return"BigInt64Array"===o(t)},e.isBigUint64Array=function(t){return"BigUint64Array"===o(t)},g.working="undefined"!=typeof Map&&g(new Map),e.isMap=function(t){return"undefined"!=typeof Map&&(g.working?g(t):t instanceof Map)},v.working="undefined"!=typeof Set&&v(new Set),e.isSet=function(t){return"undefined"!=typeof Set&&(v.working?v(t):t instanceof Set)},w.working="undefined"!=typeof WeakMap&&w(new WeakMap),e.isWeakMap=function(t){return"undefined"!=typeof WeakMap&&(w.working?w(t):t instanceof WeakMap)},m.working="undefined"!=typeof WeakSet&&m(new WeakSet),e.isWeakSet=function(t){return m(t)},S.working="undefined"!=typeof ArrayBuffer&&S(new ArrayBuffer),e.isArrayBuffer=_,E.working="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof DataView&&E(new DataView(new ArrayBuffer(1),0,1)),e.isDataView=k;var O="undefined"!=typeof SharedArrayBuffer?SharedArrayBuffer:void 0;function T(t){return"[object SharedArrayBuffer]"===f(t)}function A(t){return void 0!==O&&(void 0===T.working&&(T.working=T(new O)),T.working?T(t):t instanceof O)}function I(t){return b(t,l)}function P(t){return b(t,h)}function x(t){return b(t,p)}function B(t){return u&&b(t,d)}function R(t){return c&&b(t,y)}e.isSharedArrayBuffer=A,e.isAsyncFunction=function(t){return"[object AsyncFunction]"===f(t)},e.isMapIterator=function(t){return"[object Map Iterator]"===f(t)},e.isSetIterator=function(t){return"[object Set Iterator]"===f(t)},e.isGeneratorObject=function(t){return"[object Generator]"===f(t)},e.isWebAssemblyCompiledModule=function(t){return"[object WebAssembly.Module]"===f(t)},e.isNumberObject=I,e.isStringObject=P,e.isBooleanObject=x,e.isBigIntObject=B,e.isSymbolObject=R,e.isBoxedPrimitive=function(t){return I(t)||P(t)||x(t)||B(t)||R(t)},e.isAnyArrayBuffer=function(t){return"undefined"!=typeof Uint8Array&&(_(t)||A(t))},["isProxy","isExternal","isModuleNamespaceObject"].forEach(function(t){Object.defineProperty(e,t,{enumerable:!1,value:function(){throw new Error(t+" is not supported in userland")}})})},9083:(t,e,r)=>{t.exports=f;var n=r(2463).F,i=n.ERR_METHOD_NOT_IMPLEMENTED,o=n.ERR_MULTIPLE_CALLBACK,a=n.ERR_TRANSFORM_ALREADY_TRANSFORMING,s=n.ERR_TRANSFORM_WITH_LENGTH_0,u=r(8101);function c(t,e){var r=this._transformState;r.transforming=!1;var n=r.writecb;if(null===n)return this.emit("error",new o);r.writechunk=null,r.writecb=null,null!=e&&this.push(e),n(t);var i=this._readableState;i.reading=!1,(i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}function f(t){if(!(this instanceof f))return new f(t);u.call(this,t),this._transformState={afterTransform:c.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,t&&("function"==typeof t.transform&&(this._transform=t.transform),"function"==typeof t.flush&&(this._flush=t.flush)),this.on("prefinish",l)}function l(){var t=this;"function"!=typeof this._flush||this._readableState.destroyed?h(this,null,null):this._flush(function(e,r){h(t,e,r)})}function h(t,e,r){if(e)return t.emit("error",e);if(null!=r&&t.push(r),t._writableState.length)throw new s;if(t._transformState.transforming)throw new a;return t.push(null)}r(6698)(f,u),f.prototype.push=function(t,e){return this._transformState.needTransform=!1,u.prototype.push.call(this,t,e)},f.prototype._transform=function(t,e,r){r(new i("_transform()"))},f.prototype._write=function(t,e,r){var n=this._transformState;if(n.writecb=r,n.writechunk=t,n.writeencoding=e,!n.transforming){var i=this._readableState;(n.needTransform||i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}},f.prototype._read=function(t){var e=this._transformState;null===e.writechunk||e.transforming?e.needTransform=!0:(e.transforming=!0,this._transform(e.writechunk,e.writeencoding,e.afterTransform))},f.prototype._destroy=function(t,e){u.prototype._destroy.call(this,t,function(t){e(t)})}},9092:(t,e,r)=>{var n=r(1333);t.exports=function(){return n()&&!!Symbol.toStringTag}},9133:(t,e,r)=>{var n=r(8403);t.exports=function(){return Object.assign?function(){if(!Object.assign)return!1;for(var t="abcdefghijklmnopqrst",e=t.split(""),r={},n=0;n<e.length;++n)r[e[n]]=e[n];var i=Object.assign({},r),o="";for(var a in i)o+=a;return t!==o}()||function(){if(!Object.assign||!Object.preventExtensions)return!1;var t=Object.preventExtensions({1:2});try{Object.assign(t,"xy")}catch(e){return"y"===t[1]}return!1}()?n:Object.assign:n}},9175:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.wrapXOFConstructorWithOpts=e.wrapConstructorWithOpts=e.wrapConstructor=e.Hash=e.nextTick=e.swap32IfBE=e.byteSwapIfBE=e.swap8IfBE=e.isLE=void 0,e.isBytes=i,e.anumber=o,e.abytes=a,e.ahash=function(t){if("function"!=typeof t||"function"!=typeof t.create)throw new Error("Hash should be wrapped by utils.createHasher");o(t.outputLen),o(t.blockLen)},e.aexists=function(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")},e.aoutput=function(t,e){a(t);const r=e.outputLen;if(t.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)},e.u8=function(t){return new Uint8Array(t.buffer,t.byteOffset,t.byteLength)},e.u32=function(t){return new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4))},e.clean=function(...t){for(let e=0;e<t.length;e++)t[e].fill(0)},e.createView=function(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)},e.rotr=function(t,e){return t<<32-e|t>>>e},e.rotl=function(t,e){return t<<e|t>>>32-e>>>0},e.byteSwap=s,e.byteSwap32=u,e.bytesToHex=function(t){if(a(t),c)return t.toHex();let e="";for(let r=0;r<t.length;r++)e+=f[t[r]];return e},e.hexToBytes=function(t){if("string"!=typeof t)throw new Error("hex string expected, got "+typeof t);if(c)return Uint8Array.fromHex(t);const e=t.length,r=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);const n=new Uint8Array(r);for(let e=0,i=0;e<r;e++,i+=2){const r=h(t.charCodeAt(i)),o=h(t.charCodeAt(i+1));if(void 0===r||void 0===o){const e=t[i]+t[i+1];throw new Error('hex string expected, got non-hex character "'+e+'" at index '+i)}n[e]=16*r+o}return n},e.asyncLoop=async function(t,r,n){let i=Date.now();for(let o=0;o<t;o++){n(o);const t=Date.now()-i;t>=0&&t<r||(await(0,e.nextTick)(),i+=t)}},e.utf8ToBytes=p,e.bytesToUtf8=function(t){return(new TextDecoder).decode(t)},e.toBytes=d,e.kdfInputToBytes=function(t){return"string"==typeof t&&(t=p(t)),a(t),t},e.concatBytes=function(...t){let e=0;for(let r=0;r<t.length;r++){const n=t[r];a(n),e+=n.length}const r=new Uint8Array(e);for(let e=0,n=0;e<t.length;e++){const i=t[e];r.set(i,n),n+=i.length}return r},e.checkOpts=function(t,e){if(void 0!==e&&"[object Object]"!=={}.toString.call(e))throw new Error("options should be object or undefined");return Object.assign(t,e)},e.createHasher=y,e.createOptHasher=b,e.createXOFer=g,e.randomBytes=function(t=32){if(n.crypto&&"function"==typeof n.crypto.getRandomValues)return n.crypto.getRandomValues(new Uint8Array(t));if(n.crypto&&"function"==typeof n.crypto.randomBytes)return Uint8Array.from(n.crypto.randomBytes(t));throw new Error("crypto.getRandomValues must be defined")};const n=r(5145);function i(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&"Uint8Array"===t.constructor.name}function o(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function a(t,...e){if(!i(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function s(t){return t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255}function u(t){for(let e=0;e<t.length;e++)t[e]=s(t[e]);return t}e.isLE=68===new Uint8Array(new Uint32Array([287454020]).buffer)[0],e.swap8IfBE=e.isLE?t=>t:t=>s(t),e.byteSwapIfBE=e.swap8IfBE,e.swap32IfBE=e.isLE?t=>t:u;const c=(()=>"function"==typeof Uint8Array.from([]).toHex&&"function"==typeof Uint8Array.fromHex)(),f=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0")),l={_0:48,_9:57,A:65,F:70,a:97,f:102};function h(t){return t>=l._0&&t<=l._9?t-l._0:t>=l.A&&t<=l.F?t-(l.A-10):t>=l.a&&t<=l.f?t-(l.a-10):void 0}function p(t){if("string"!=typeof t)throw new Error("string expected");return new Uint8Array((new TextEncoder).encode(t))}function d(t){return"string"==typeof t&&(t=p(t)),a(t),t}function y(t){const e=e=>t().update(d(e)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function b(t){const e=(e,r)=>t(r).update(d(e)).digest(),r=t({});return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=e=>t(e),e}function g(t){const e=(e,r)=>t(r).update(d(e)).digest(),r=t({});return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=e=>t(e),e}e.nextTick=async()=>{},e.Hash=class{},e.wrapConstructor=y,e.wrapConstructorWithOpts=b,e.wrapXOFConstructorWithOpts=g},9209:(t,e,r)=>{var n=r(6578),i="undefined"==typeof globalThis?r.g:globalThis;t.exports=function(){for(var t=[],e=0;e<n.length;e++)"function"==typeof i[n[e]]&&(t[t.length]=n[e]);return t}},9211:t=>{var e=function(t){return t!=t};t.exports=function(t,r){return 0===t&&0===r?1/t==1/r:t===r||!(!e(t)||!e(r))}},9284:(t,e,r)=>{var n=r(2861).Buffer;t.exports=function(t){if(t.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),r=0;r<e.length;r++)e[r]=255;for(var i=0;i<t.length;i++){var o=t.charAt(i),a=o.charCodeAt(0);if(255!==e[a])throw new TypeError(o+" is ambiguous");e[a]=i}var s=t.length,u=t.charAt(0),c=Math.log(s)/Math.log(256),f=Math.log(256)/Math.log(s);function l(t){if("string"!=typeof t)throw new TypeError("Expected String");if(0===t.length)return n.alloc(0);for(var r=0,i=0,o=0;t[r]===u;)i++,r++;for(var a=(t.length-r)*c+1>>>0,f=new Uint8Array(a);r<t.length;){var l=t.charCodeAt(r);if(l>255)return;var h=e[l];if(255===h)return;for(var p=0,d=a-1;(0!==h||p<o)&&-1!==d;d--,p++)h+=s*f[d]>>>0,f[d]=h%256>>>0,h=h/256>>>0;if(0!==h)throw new Error("Non-zero carry");o=p,r++}for(var y=a-o;y!==a&&0===f[y];)y++;var b=n.allocUnsafe(i+(a-y));b.fill(0,0,i);for(var g=i;y!==a;)b[g++]=f[y++];return b}return{encode:function(e){if((Array.isArray(e)||e instanceof Uint8Array)&&(e=n.from(e)),!n.isBuffer(e))throw new TypeError("Expected Buffer");if(0===e.length)return"";for(var r=0,i=0,o=0,a=e.length;o!==a&&0===e[o];)o++,r++;for(var c=(a-o)*f+1>>>0,l=new Uint8Array(c);o!==a;){for(var h=e[o],p=0,d=c-1;(0!==h||p<i)&&-1!==d;d--,p++)h+=256*l[d]>>>0,l[d]=h%s>>>0,h=h/s>>>0;if(0!==h)throw new Error("Non-zero carry");i=p,o++}for(var y=c-i;y!==c&&0===l[y];)y++;for(var b=u.repeat(r);y<c;++y)b+=t.charAt(l[y]);return b},decodeUnsafe:l,decode:function(t){var e=l(t);if(e)return e;throw new Error("Non-base"+s+" character")}}}},9290:t=>{t.exports=RangeError},9353:t=>{var e=Object.prototype.toString,r=Math.max,n=function(t,e){for(var r=[],n=0;n<t.length;n+=1)r[n]=t[n];for(var i=0;i<e.length;i+=1)r[i+t.length]=e[i];return r};t.exports=function(t){var i=this;if("function"!=typeof i||"[object Function]"!==e.apply(i))throw new TypeError("Function.prototype.bind called on incompatible "+i);for(var o,a=function(t){for(var e=[],r=1,n=0;r<t.length;r+=1,n+=1)e[n]=t[r];return e}(arguments),s=r(0,i.length-a.length),u=[],c=0;c<s;c++)u[c]="$"+c;if(o=Function("binder","return function ("+function(t){for(var e="",r=0;r<t.length;r+=1)e+=t[r],r+1<t.length&&(e+=",");return e}(u)+"){ return binder.apply(this,arguments); }")(function(){if(this instanceof o){var e=i.apply(this,n(a,arguments));return Object(e)===e?e:this}return i.apply(t,n(a,arguments))}),i.prototype){var f=function(){};f.prototype=i.prototype,o.prototype=new f,f.prototype=null}return o}},9383:t=>{t.exports=Error},9394:(t,e,r)=>{var n=r(9211);t.exports=function(){return"function"==typeof Object.is?Object.is:n}},9434:(t,e,r)=>{var n,i=r(2260).F,o=i.ERR_MISSING_ARGS,a=i.ERR_STREAM_DESTROYED;function s(t){if(t)throw t}function u(t){t()}function c(t,e){return t.pipe(e)}t.exports=function(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];var f,l=function(t){return t.length?"function"!=typeof t[t.length-1]?s:t.pop():s}(e);if(Array.isArray(e[0])&&(e=e[0]),e.length<2)throw new o("streams");var h=e.map(function(t,i){var o=i<e.length-1;return function(t,e,i,o){o=function(t){var e=!1;return function(){e||(e=!0,t.apply(void 0,arguments))}}(o);var s=!1;t.on("close",function(){s=!0}),void 0===n&&(n=r(5826)),n(t,{readable:e,writable:i},function(t){if(t)return o(t);s=!0,o()});var u=!1;return function(e){if(!s&&!u)return u=!0,function(t){return t.setHeader&&"function"==typeof t.abort}(t)?t.abort():"function"==typeof t.destroy?t.destroy():void o(e||new a("pipe"))}}(t,o,i>0,function(t){f||(f=t),t&&h.forEach(u),o||(h.forEach(u),l(f))})});return e.reduce(c)}},9538:t=>{t.exports=ReferenceError},9542:(t,e,r)=>{var n=r(8287).Buffer,i=r(2113),o=r(1061);function a(t){return n.isBuffer(t)}function s(t){return"string"==typeof t&&/^([0-9a-f]{2})+$/i.test(t)}function u(t,e){var r=t.toJSON();function n(n){if(!t(n))return!1;if(n.length===e)return!0;throw o.tfCustomError(r+"(Length: "+e+")",r+"(Length: "+n.length+")")}return n.toJSON=function(){return r},n}var c=u.bind(null,i.Array),f=u.bind(null,a),l=u.bind(null,s),h=u.bind(null,i.String),p=Math.pow(2,53)-1,d={ArrayN:c,Buffer:a,BufferN:f,Finite:function(t){return"number"==typeof t&&isFinite(t)},Hex:s,HexN:l,Int8:function(t){return t<<24>>24===t},Int16:function(t){return t<<16>>16===t},Int32:function(t){return(0|t)===t},Int53:function(t){return"number"==typeof t&&t>=-p&&t<=p&&Math.floor(t)===t},Range:function(t,e,r){function n(n,i){return r(n,i)&&n>t&&n<e}return r=r||i.Number,n.toJSON=function(){return`${r.toJSON()} between [${t}, ${e}]`},n},StringN:h,UInt8:function(t){return(255&t)===t},UInt16:function(t){return(65535&t)===t},UInt32:function(t){return t>>>0===t},UInt53:function(t){return"number"==typeof t&&t>=0&&t<=p&&Math.floor(t)===t}};for(var y in d)d[y].toJSON=function(t){return t}.bind(null,y);t.exports=d},9579:(t,e,r)=>{var n=r(8287).Buffer,i=n.isEncoding||function(t){switch(t&&t.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}},o=e.I=function(t){switch(this.encoding=(t||"utf8").toLowerCase().replace(/[-_]/,""),function(t){if(t&&!i(t))throw new Error("Unknown encoding: "+t)}(t),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=s;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=u;break;default:return void(this.write=a)}this.charBuffer=new n(6),this.charReceived=0,this.charLength=0};function a(t){return t.toString(this.encoding)}function s(t){this.charReceived=t.length%2,this.charLength=this.charReceived?2:0}function u(t){this.charReceived=t.length%3,this.charLength=this.charReceived?3:0}o.prototype.write=function(t){for(var e="";this.charLength;){var r=t.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:t.length;if(t.copy(this.charBuffer,this.charReceived,0,r),this.charReceived+=r,this.charReceived<this.charLength)return"";if(t=t.slice(r,t.length),!((n=(e=this.charBuffer.slice(0,this.charLength).toString(this.encoding)).charCodeAt(e.length-1))>=55296&&n<=56319)){if(this.charReceived=this.charLength=0,0===t.length)return e;break}this.charLength+=this.surrogateSize,e=""}this.detectIncompleteChar(t);var n,i=t.length;if(this.charLength&&(t.copy(this.charBuffer,0,t.length-this.charReceived,i),i-=this.charReceived),i=(e+=t.toString(this.encoding,0,i)).length-1,(n=e.charCodeAt(i))>=55296&&n<=56319){var o=this.surrogateSize;return this.charLength+=o,this.charReceived+=o,this.charBuffer.copy(this.charBuffer,o,0,o),t.copy(this.charBuffer,0,0,o),e.substring(0,i)}return e},o.prototype.detectIncompleteChar=function(t){for(var e=t.length>=3?3:t.length;e>0;e--){var r=t[t.length-e];if(1==e&&r>>5==6){this.charLength=2;break}if(e<=2&&r>>4==14){this.charLength=3;break}if(e<=3&&r>>3==30){this.charLength=4;break}}this.charReceived=e},o.prototype.end=function(t){var e="";if(t&&t.length&&(e=this.write(t)),this.charReceived){var r=this.charReceived,n=this.charBuffer,i=this.encoding;e+=n.slice(0,r).toString(i)}return e}},9597:(t,e,r)=>{function n(t){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n(t)}function i(t,e){return i=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},i(t,e)}function o(t){return o=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},o(t)}var a,s,u={};function c(t,e,r){r||(r=Error);var a=function(r){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&i(t,e)}(f,r);var a,s,u,c=(s=f,u=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(t){return!1}}(),function(){var t,e=o(s);if(u){var r=o(this).constructor;t=Reflect.construct(e,arguments,r)}else t=e.apply(this,arguments);return function(t,e){if(e&&("object"===n(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(this,t)});function f(r,n,i){var o;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,f),o=c.call(this,function(t,r,n){return"string"==typeof e?e:e(t,r,n)}(r,n,i)),o.code=t,o}return a=f,Object.defineProperty(a,"prototype",{writable:!1}),a}(r);u[t]=a}function f(t,e){if(Array.isArray(t)){var r=t.length;return t=t.map(function(t){return String(t)}),r>2?"one of ".concat(e," ").concat(t.slice(0,r-1).join(", "),", or ")+t[r-1]:2===r?"one of ".concat(e," ").concat(t[0]," or ").concat(t[1]):"of ".concat(e," ").concat(t[0])}return"of ".concat(e," ").concat(String(t))}c("ERR_AMBIGUOUS_ARGUMENT",'The "%s" argument is ambiguous. %s',TypeError),c("ERR_INVALID_ARG_TYPE",function(t,e,i){var o,s,u;if(void 0===a&&(a=r(4148)),a("string"==typeof t,"'name' must be a string"),"string"==typeof e&&(u="not ",e.substr(0,4)===u)?(o="must not be",e=e.replace(/^not /,"")):o="must be",function(t,e,r){return(void 0===r||r>t.length)&&(r=t.length),t.substring(r-9,r)===e}(t," argument"))s="The ".concat(t," ").concat(o," ").concat(f(e,"type"));else{var c=function(t,e,r){return"number"!=typeof r&&(r=0),!(r+1>t.length)&&-1!==t.indexOf(".",r)}(t)?"property":"argument";s='The "'.concat(t,'" ').concat(c," ").concat(o," ").concat(f(e,"type"))}return s+". Received type ".concat(n(i))},TypeError),c("ERR_INVALID_ARG_VALUE",function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"is invalid";void 0===s&&(s=r(537));var i=s.inspect(e);return i.length>128&&(i="".concat(i.slice(0,128),"...")),"The argument '".concat(t,"' ").concat(n,". Received ").concat(i)},TypeError,RangeError),c("ERR_INVALID_RETURN_VALUE",function(t,e,r){var i;return i=r&&r.constructor&&r.constructor.name?"instance of ".concat(r.constructor.name):"type ".concat(n(r)),"Expected ".concat(t,' to be returned from the "').concat(e,'"')+" function but got ".concat(i,".")},TypeError),c("ERR_MISSING_ARGS",function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];void 0===a&&(a=r(4148)),a(e.length>0,"At least one arg needs to be specified");var i="The ",o=e.length;switch(e=e.map(function(t){return'"'.concat(t,'"')}),o){case 1:i+="".concat(e[0]," argument");break;case 2:i+="".concat(e[0]," and ").concat(e[1]," arguments");break;default:i+=e.slice(0,o-1).join(", "),i+=", and ".concat(e[o-1]," arguments")}return"".concat(i," must be specified")},TypeError),t.exports.codes=u},9600:t=>{var e,r,n=Function.prototype.toString,i="object"==typeof Reflect&&null!==Reflect&&Reflect.apply;if("function"==typeof i&&"function"==typeof Object.defineProperty)try{e=Object.defineProperty({},"length",{get:function(){throw r}}),r={},i(function(){throw 42},null,e)}catch(t){t!==r&&(i=null)}else i=null;var o=/^\s*class\b/,a=function(t){try{var e=n.call(t);return o.test(e)}catch(t){return!1}},s=function(t){try{return!a(t)&&(n.call(t),!0)}catch(t){return!1}},u=Object.prototype.toString,c="function"==typeof Symbol&&!!Symbol.toStringTag,f=!(0 in[,]),l=function(){return!1};if("object"==typeof document){var h=document.all;u.call(h)===u.call(document.all)&&(l=function(t){if((f||!t)&&(void 0===t||"object"==typeof t))try{var e=u.call(t);return("[object HTMLAllCollection]"===e||"[object HTML document.all class]"===e||"[object HTMLCollection]"===e||"[object Object]"===e)&&null==t("")}catch(t){}return!1})}t.exports=i?function(t){if(l(t))return!0;if(!t)return!1;if("function"!=typeof t&&"object"!=typeof t)return!1;try{i(t,null,e)}catch(t){if(t!==r)return!1}return!a(t)&&s(t)}:function(t){if(l(t))return!0;if(!t)return!1;if("function"!=typeof t&&"object"!=typeof t)return!1;if(c)return s(t);if(a(t))return!1;var e=u.call(t);return!("[object Function]"!==e&&"[object GeneratorFunction]"!==e&&!/^\[object HTML/.test(e))&&s(t)}},9612:t=>{t.exports=Object},9615:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.hmac=e.HMAC=void 0;const n=r(9175);class i extends n.Hash{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,(0,n.ahash)(t);const r=(0,n.toBytes)(e);if(this.iHash=t.create(),"function"!=typeof this.iHash.update)throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const i=this.blockLen,o=new Uint8Array(i);o.set(r.length>i?t.create().update(r).digest():r);for(let t=0;t<o.length;t++)o[t]^=54;this.iHash.update(o),this.oHash=t.create();for(let t=0;t<o.length;t++)o[t]^=106;this.oHash.update(o),(0,n.clean)(o)}update(t){return(0,n.aexists)(this),this.iHash.update(t),this}digestInto(t){(0,n.aexists)(this),(0,n.abytes)(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){const t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));const{oHash:e,iHash:r,finished:n,destroyed:i,blockLen:o,outputLen:a}=this;return t.finished=n,t.destroyed=i,t.blockLen=o,t.outputLen=a,t.oHash=e._cloneInto(t.oHash),t.iHash=r._cloneInto(t.iHash),t}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}e.HMAC=i,e.hmac=(t,e,r)=>new i(t,e).update(r).digest(),e.hmac.create=(t,e)=>new i(t,e)},9675:t=>{t.exports=TypeError},9681:t=>{t.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},9721:(t,e,r)=>{var n=r(6556),i=r(4035),o=n("RegExp.prototype.exec"),a=r(9675);t.exports=function(t){if(!i(t))throw new a("`regex` must be a RegExp");return function(e){return null!==o(t,e)}}},9805:(t,e)=>{var r="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Int32Array;function n(t,e){return Object.prototype.hasOwnProperty.call(t,e)}e.assign=function(t){for(var e=Array.prototype.slice.call(arguments,1);e.length;){var r=e.shift();if(r){if("object"!=typeof r)throw new TypeError(r+"must be non-object");for(var i in r)n(r,i)&&(t[i]=r[i])}}return t},e.shrinkBuf=function(t,e){return t.length===e?t:t.subarray?t.subarray(0,e):(t.length=e,t)};var i={arraySet:function(t,e,r,n,i){if(e.subarray&&t.subarray)t.set(e.subarray(r,r+n),i);else for(var o=0;o<n;o++)t[i+o]=e[r+o]},flattenChunks:function(t){var e,r,n,i,o,a;for(n=0,e=0,r=t.length;e<r;e++)n+=t[e].length;for(a=new Uint8Array(n),i=0,e=0,r=t.length;e<r;e++)o=t[e],a.set(o,i),i+=o.length;return a}},o={arraySet:function(t,e,r,n,i){for(var o=0;o<n;o++)t[i+o]=e[r+o]},flattenChunks:function(t){return[].concat.apply([],t)}};e.setTyped=function(t){t?(e.Buf8=Uint8Array,e.Buf16=Uint16Array,e.Buf32=Int32Array,e.assign(e,i)):(e.Buf8=Array,e.Buf16=Array,e.Buf32=Array,e.assign(e,o))},e.setTyped(r)},9957:(t,e,r)=>{var n=Function.prototype.call,i=Object.prototype.hasOwnProperty,o=r(6743);t.exports=o.call(n,i)}},n={};function i(t){var e=n[t];if(void 0!==e)return e.exports;var o=n[t]={exports:{}};return r[t](o,o.exports,i),o.exports}i.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return i.d(e,{a:e}),e},e=Object.getPrototypeOf?t=>Object.getPrototypeOf(t):t=>t.__proto__,i.t=function(r,n){if(1&n&&(r=this(r)),8&n)return r;if("object"==typeof r&&r){if(4&n&&r.__esModule)return r;if(16&n&&"function"==typeof r.then)return r}var o=Object.create(null);i.r(o);var a={};t=t||[null,e({}),e([]),e(e)];for(var s=2&n&&r;("object"==typeof s||"function"==typeof s)&&!~t.indexOf(s);s=e(s))Object.getOwnPropertyNames(s).forEach(t=>a[t]=()=>r[t]);return a.default=()=>r,i.d(o,a),o},i.d=(t,e)=>{for(var r in e)i.o(e,r)&&!i.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},i.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),i.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),i.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var o={};i.r(o),i.d(o,{ABICoder:()=>ow,ABIDataTypes:()=>Jv,ADDRESS_BYTE_LENGTH:()=>gf,ANCHOR_SCRIPT:()=>xy,Address:()=>ih,AddressGenerator:()=>xp,AddressMap:()=>Jf,AddressSet:()=>lw,AddressTypes:()=>hl,AddressVerificator:()=>vl,BOOLEAN_BYTE_LENGTH:()=>Bf,BinaryReader:()=>uh,BinaryWriter:()=>ph,BitcoinUtils:()=>sl,BufferHelper:()=>Lf,CSVModes:()=>Kd,CalldataGenerator:()=>Uh,ChainId:()=>$y,ChallengeSolution:()=>Gg,ChallengeSubmission:()=>Wg,ChallengeVerification:()=>Vg,Compressor:()=>h,Consensus:()=>Qy,ContractAddress:()=>xl,ContractBaseMetadata:()=>tb,CustomGenerator:()=>Hh,CustomKeypair:()=>zw,CustomScriptTransaction:()=>_b,DeploymentGenerator:()=>Jh,DeploymentTransaction:()=>Jb,DeterministicMap:()=>Ow,DeterministicSet:()=>Uw,EcKeyPair:()=>bf,EpochValidator:()=>Cg,FACTORY_ADDRESS_FRACTAL:()=>Km,FACTORY_ADDRESS_REGTEST:()=>Rm,FACTORY_ADDRESS_TESTNET:()=>Cm,Features:()=>hh,FundingTransaction:()=>cg,Generator:()=>_h,I128_BYTE_LENGTH:()=>Tf,I16_BYTE_LENGTH:()=>Pf,I256_BYTE_LENGTH:()=>Of,I32_BYTE_LENGTH:()=>If,I64_BYTE_LENGTH:()=>Af,I8_BYTE_LENGTH:()=>xf,InteractionTransaction:()=>vg,InteractionTransactionP2WDA:()=>xg,LegacyCalldataGenerator:()=>cp,MINIMUM_AMOUNT_CA:()=>Py,MINIMUM_AMOUNT_REWARD:()=>Iy,MOTO_ADDRESS_FRACTAL:()=>Gm,MOTO_ADDRESS_REGTEST:()=>Nm,MOTO_ADDRESS_TESTNET:()=>Hm,MessageSigner:()=>Ky,MessageType:()=>Gw,MultiSignGenerator:()=>yp,MultiSignTransaction:()=>_v,NetEvent:()=>Fw,OPNET_DEPLOYMENT_VERSION:()=>Yh,OPNetConsensusConfig:()=>nb,OPNetLimitedProvider:()=>Cv,OPNetMetadata:()=>Zm,OPNetNetwork:()=>Bm,OPNetTokenAddressManager:()=>zm,P2TR_MS:()=>Qv,P2WDADetector:()=>pl,P2WDAGenerator:()=>Op,POOL_ADDRESS_FRACTAL:()=>Vm,POOL_ADDRESS_REGTEST:()=>Um,POOL_ADDRESS_TESTNET:()=>Fm,PSBTTypes:()=>zv,PsbtTransaction:()=>Zv,ROUTER_ADDRESS_FRACTAL:()=>qm,ROUTER_ADDRESS_REGTEST:()=>Lm,ROUTER_ADDRESS_TESTNET:()=>Mm,RoswellConsensus:()=>eb,SELECTOR_BYTE_LENGTH:()=>vf,Secp256k1PointDeriver:()=>kl,SharedInteractionTransaction:()=>Cb,SignatureType:()=>qw,SigningProtocol:()=>km,TapscriptVerificator:()=>Ly,TimeLockGenerator:()=>jl,TransactionBuilder:()=>By,TransactionFactory:()=>ov,TransactionSequence:()=>Md,TransactionType:()=>Jy,TweakedSigner:()=>Vd,TweakedTransaction:()=>uy,U128_BYTE_LENGTH:()=>mf,U16_BYTE_LENGTH:()=>Ef,U256_BYTE_LENGTH:()=>wf,U32_BYTE_LENGTH:()=>_f,U64_BYTE_LENGTH:()=>Sf,U8_BYTE_LENGTH:()=>kf,UnisatChainType:()=>Ww,UnisatNetwork:()=>Vw,UnisatSigner:()=>sm,WBTC_ADDRESS_FRACTAL:()=>Wm,WBTC_ADDRESS_REGTEST:()=>jm,WBTC_ADDRESS_TESTNET:()=>Dm,Wallet:()=>zy,XverseNetwork:()=>Em,XverseSigner:()=>Om,currentConsensus:()=>ib,currentConsensusConfig:()=>ob,version:()=>a,versionBuffer:()=>$h});var a="1.6.7",s=i(8559),u=i.n(s);function c(t){return c="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},c(t)}function f(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,l(n.key),n)}}function l(t){var e=function(t){if("object"!=c(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=c(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==c(e)?e:e+""}var h=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)}return function(t,e,r){return r&&f(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,0,[{key:"compress",value:function(e){return u().gzipSync(e,t.zlibOptions)}},{key:"decompress",value:function(e){return u().gunzipSync(e,t.zlibOptions)}}])}();!function(t,e,r){(e=l(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r}(h,"zlibOptions",{level:9,maxOutputLength:16777216});var p={34:(t,e,r)=>{var n=r(287).hp;Object.defineProperty(e,"__esModule",{value:!0});const i=r(80);e.decode=function(t){if(t.key[0]!==i.InputTypes.TAP_SCRIPT_SIG)throw new Error("Decode Error: could not decode tapScriptSig with key 0x"+t.key.toString("hex"));if(65!==t.key.length)throw new Error("Decode Error: tapScriptSig has invalid key 0x"+t.key.toString("hex"));if(64!==t.value.length&&65!==t.value.length)throw new Error("Decode Error: tapScriptSig has invalid signature in key 0x"+t.key.toString("hex"));return{pubkey:t.key.slice(1,33),leafHash:t.key.slice(33),signature:t.value}},e.encode=function(t){const e=n.from([i.InputTypes.TAP_SCRIPT_SIG]);return{key:n.concat([e,t.pubkey,t.leafHash]),value:t.signature}},e.expected="{ pubkey: Buffer; leafHash: Buffer; signature: Buffer; }",e.check=function(t){return n.isBuffer(t.pubkey)&&n.isBuffer(t.leafHash)&&n.isBuffer(t.signature)&&32===t.pubkey.length&&32===t.leafHash.length&&(64===t.signature.length||65===t.signature.length)},e.canAddToArray=function(t,e,r){const n=e.pubkey.toString("hex")+e.leafHash.toString("hex");return!r.has(n)&&(r.add(n),0===t.filter(t=>t.pubkey.equals(e.pubkey)&&t.leafHash.equals(e.leafHash)).length)}},61:(t,e,r)=>{var n=r(113);function i(t){return t.name||t.toString().match(/function (.*?)\s*\(/)[1]}function o(t){return n.Nil(t)?"":i(t.constructor)}function a(t,e){Error.captureStackTrace&&Error.captureStackTrace(t,e)}function s(t){return n.Function(t)?t.toJSON?t.toJSON():i(t):n.Array(t)?"Array":t&&n.Object(t)?"Object":void 0!==t?t:""}function u(t,e,r){var i=function(t){return n.Function(t)?"":n.String(t)?JSON.stringify(t):t&&n.Object(t)?"":t}(e);return"Expected "+s(t)+", got"+(""!==r?" "+r:"")+(""!==i?" "+i:"")}function c(t,e,r){r=r||o(e),this.message=u(t,e,r),a(this,c),this.__type=t,this.__value=e,this.__valueTypeName=r}function f(t,e,r,n,i){t?(i=i||o(n),this.message=function(t,e,r,n,i){var o='" of type ';return"key"===e&&(o='" with key type '),u('property "'+s(r)+o+s(t),n,i)}(t,r,e,n,i)):this.message='Unexpected property "'+e+'"',a(this,c),this.__label=r,this.__property=e,this.__type=t,this.__value=n,this.__valueTypeName=i}c.prototype=Object.create(Error.prototype),c.prototype.constructor=c,f.prototype=Object.create(Error.prototype),f.prototype.constructor=c,t.exports={TfTypeError:c,TfPropertyTypeError:f,tfCustomError:function(t,e){return new c(t,{},e)},tfSubError:function(t,e,r){return t instanceof f?(e=e+"."+t.__property,t=new f(t.__type,e,t.__label,t.__value,t.__valueTypeName)):t instanceof c&&(t=new f(t.__type,e,r,t.__value,t.__valueTypeName)),a(t),t},tfJSON:s,getValueTypeName:o}},80:(t,e)=>{var r,n,i;Object.defineProperty(e,"__esModule",{value:!0}),(i=e.GlobalTypes||(e.GlobalTypes={}))[i.UNSIGNED_TX=0]="UNSIGNED_TX",i[i.GLOBAL_XPUB=1]="GLOBAL_XPUB",e.GLOBAL_TYPE_NAMES=["unsignedTx","globalXpub"],(n=e.InputTypes||(e.InputTypes={}))[n.NON_WITNESS_UTXO=0]="NON_WITNESS_UTXO",n[n.WITNESS_UTXO=1]="WITNESS_UTXO",n[n.PARTIAL_SIG=2]="PARTIAL_SIG",n[n.SIGHASH_TYPE=3]="SIGHASH_TYPE",n[n.REDEEM_SCRIPT=4]="REDEEM_SCRIPT",n[n.WITNESS_SCRIPT=5]="WITNESS_SCRIPT",n[n.BIP32_DERIVATION=6]="BIP32_DERIVATION",n[n.FINAL_SCRIPTSIG=7]="FINAL_SCRIPTSIG",n[n.FINAL_SCRIPTWITNESS=8]="FINAL_SCRIPTWITNESS",n[n.POR_COMMITMENT=9]="POR_COMMITMENT",n[n.TAP_KEY_SIG=19]="TAP_KEY_SIG",n[n.TAP_SCRIPT_SIG=20]="TAP_SCRIPT_SIG",n[n.TAP_LEAF_SCRIPT=21]="TAP_LEAF_SCRIPT",n[n.TAP_BIP32_DERIVATION=22]="TAP_BIP32_DERIVATION",n[n.TAP_INTERNAL_KEY=23]="TAP_INTERNAL_KEY",n[n.TAP_MERKLE_ROOT=24]="TAP_MERKLE_ROOT",e.INPUT_TYPE_NAMES=["nonWitnessUtxo","witnessUtxo","partialSig","sighashType","redeemScript","witnessScript","bip32Derivation","finalScriptSig","finalScriptWitness","porCommitment","tapKeySig","tapScriptSig","tapLeafScript","tapBip32Derivation","tapInternalKey","tapMerkleRoot"],(r=e.OutputTypes||(e.OutputTypes={}))[r.REDEEM_SCRIPT=0]="REDEEM_SCRIPT",r[r.WITNESS_SCRIPT=1]="WITNESS_SCRIPT",r[r.BIP32_DERIVATION=2]="BIP32_DERIVATION",r[r.TAP_INTERNAL_KEY=5]="TAP_INTERNAL_KEY",r[r.TAP_TREE=6]="TAP_TREE",r[r.TAP_BIP32_DERIVATION=7]="TAP_BIP32_DERIVATION",e.OUTPUT_TYPE_NAMES=["redeemScript","witnessScript","bip32Derivation","tapInternalKey","tapTree","tapBip32Derivation"]},113:t=>{var e={Array:function(t){return null!=t&&t.constructor===Array},Boolean:function(t){return"boolean"==typeof t},Function:function(t){return"function"==typeof t},Nil:function(t){return null==t},Number:function(t){return"number"==typeof t},Object:function(t){return"object"==typeof t},String:function(t){return"string"==typeof t},"":function(){return!0}};for(var r in e.Null=e.Nil,e)e[r].toJSON=function(t){return t}.bind(null,r);t.exports=e},133:(t,e,r)=>{var n=r(287).hp;Object.defineProperty(e,"__esModule",{value:!0});const i=r(394);function o(t){const e=t.key.length,r=t.value.length,o=i.encodingLength(e),a=i.encodingLength(r),s=n.allocUnsafe(o+e+a+r);return i.encode(e,s,0),t.key.copy(s,o),i.encode(r,s,o+e),t.value.copy(s,o+e+a),s}function a(t,e){if("number"!=typeof t)throw new Error("cannot write a non-number as a number");if(t<0)throw new Error("specified a negative value for writing an unsigned value");if(t>e)throw new Error("RangeError: value out of range");if(Math.floor(t)!==t)throw new Error("value has a fractional component")}e.range=t=>[...Array(t).keys()],e.reverseBuffer=function(t){if(t.length<1)return t;let e=t.length-1,r=0;for(let n=0;n<t.length/2;n++)r=t[n],t[n]=t[e],t[e]=r,e--;return t},e.keyValsToBuffer=function(t){const e=t.map(o);return e.push(n.from([0])),n.concat(e)},e.keyValToBuffer=o,e.readUInt64LE=function(t,e){const r=t.readUInt32LE(e);let n=t.readUInt32LE(e+4);return n*=4294967296,a(n+r,9007199254740991),n+r},e.writeUInt64LE=function(t,e,r){return a(e,9007199254740991),t.writeInt32LE(-1&e,r),t.writeUInt32LE(Math.floor(e/4294967296),r+4),r+8}},213:(t,e,r)=>{var n=r(287).hp;Object.defineProperty(e,"__esModule",{value:!0});const i=r(80);e.encode=function(t){return{key:n.from([i.GlobalTypes.UNSIGNED_TX]),value:t.toBuffer()}}},223:(t,e,r)=>{var n=r(287).hp;Object.defineProperty(e,"__esModule",{value:!0}),e.makeConverter=function(t){return{decode:function(e){if(e.key[0]!==t||1!==e.key.length)throw new Error("Decode Error: could not decode tapInternalKey with key 0x"+e.key.toString("hex"));if(32!==e.value.length)throw new Error("Decode Error: tapInternalKey not a 32-byte x-only pubkey");return e.value},encode:function(e){return{key:n.from([t]),value:e}},check:function(t){return n.isBuffer(t)&&32===t.length},expected:"Buffer",canAdd:function(t,e){return!!t&&!!e&&void 0===t.tapInternalKey}}}},238:(t,e,r)=>{var n=r(287).hp;Object.defineProperty(e,"__esModule",{value:!0});const i=r(706),o=r(133);e.psbtToBuffer=function({globalMap:t,inputs:e,outputs:r}){const{globalKeyVals:i,inputKeyVals:a,outputKeyVals:s}=u({globalMap:t,inputs:e,outputs:r}),c=o.keyValsToBuffer(i),f=t=>0===t.length?[n.from([0])]:t.map(o.keyValsToBuffer),l=f(a),h=f(s),p=n.allocUnsafe(5);return p.writeUIntBE(482972169471,0,5),n.concat([p,c].concat(l,h))};const a=(t,e)=>t.key.compare(e.key);function s(t,e){const r=new Set,n=Object.entries(t).reduce((t,[n,i])=>{if("unknownKeyVals"===n)return t;const o=e[n];if(void 0===o)return t;const a=(Array.isArray(i)?i:[i]).map(o.encode);return a.map(t=>t.key.toString("hex")).forEach(t=>{if(r.has(t))throw new Error("Serialize Error: Duplicate key: "+t);r.add(t)}),t.concat(a)},[]),i=t.unknownKeyVals?t.unknownKeyVals.filter(t=>!r.has(t.key.toString("hex"))):[];return n.concat(i).sort(a)}function u({globalMap:t,inputs:e,outputs:r}){return{globalKeyVals:s(t,i.globals),inputKeyVals:e.map(t=>s(t,i.inputs)),outputKeyVals:r.map(t=>s(t,i.outputs))}}e.psbtToKeyVals=u},251:(t,e)=>{e.read=function(t,e,r,n,i){var o,a,s=8*i-n-1,u=(1<<s)-1,c=u>>1,f=-7,l=r?i-1:0,h=r?-1:1,p=t[e+l];for(l+=h,o=p&(1<<-f)-1,p>>=-f,f+=s;f>0;o=256*o+t[e+l],l+=h,f-=8);for(a=o&(1<<-f)-1,o>>=-f,f+=n;f>0;a=256*a+t[e+l],l+=h,f-=8);if(0===o)o=1-c;else{if(o===u)return a?NaN:1/0*(p?-1:1);a+=Math.pow(2,n),o-=c}return(p?-1:1)*a*Math.pow(2,o-n)},e.write=function(t,e,r,n,i,o){var a,s,u,c=8*o-i-1,f=(1<<c)-1,l=f>>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:o-1,d=n?1:-1,y=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,a=f):(a=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-a))<1&&(a--,u*=2),(e+=a+l>=1?h/u:h*Math.pow(2,1-l))*u>=2&&(a++,u/=2),a+l>=f?(s=0,a=f):a+l>=1?(s=(e*u-1)*Math.pow(2,i),a+=l):(s=e*Math.pow(2,l-1)*Math.pow(2,i),a=0));i>=8;t[r+p]=255&s,p+=d,s/=256,i-=8);for(a=a<<i|s,c+=i;c>0;t[r+p]=255&a,p+=d,a/=256,c-=8);t[r+p-d]|=128*y}},263:(t,e,r)=>{var n=r(287).hp;Object.defineProperty(e,"__esModule",{value:!0});const i=r(706),o=r(133),a=r(394),s=r(80);function u(t,e,r){if(!e.equals(n.from([r])))throw new Error(`Format Error: Invalid ${t} key: ${e.toString("hex")}`)}function c(t,{globalMapKeyVals:e,inputKeyVals:r,outputKeyVals:n}){const a={unsignedTx:t};let c=0;for(const t of e)switch(t.key[0]){case s.GlobalTypes.UNSIGNED_TX:if(u("global",t.key,s.GlobalTypes.UNSIGNED_TX),c>0)throw new Error("Format Error: GlobalMap has multiple UNSIGNED_TX");c++;break;case s.GlobalTypes.GLOBAL_XPUB:void 0===a.globalXpub&&(a.globalXpub=[]),a.globalXpub.push(i.globals.globalXpub.decode(t));break;default:a.unknownKeyVals||(a.unknownKeyVals=[]),a.unknownKeyVals.push(t)}const f=r.length,l=n.length,h=[],p=[];for(const t of o.range(f)){const e={};for(const n of r[t])switch(i.inputs.checkPubkey(n),n.key[0]){case s.InputTypes.NON_WITNESS_UTXO:if(u("input",n.key,s.InputTypes.NON_WITNESS_UTXO),void 0!==e.nonWitnessUtxo)throw new Error("Format Error: Input has multiple NON_WITNESS_UTXO");e.nonWitnessUtxo=i.inputs.nonWitnessUtxo.decode(n);break;case s.InputTypes.WITNESS_UTXO:if(u("input",n.key,s.InputTypes.WITNESS_UTXO),void 0!==e.witnessUtxo)throw new Error("Format Error: Input has multiple WITNESS_UTXO");e.witnessUtxo=i.inputs.witnessUtxo.decode(n);break;case s.InputTypes.PARTIAL_SIG:void 0===e.partialSig&&(e.partialSig=[]),e.partialSig.push(i.inputs.partialSig.decode(n));break;case s.InputTypes.SIGHASH_TYPE:if(u("input",n.key,s.InputTypes.SIGHASH_TYPE),void 0!==e.sighashType)throw new Error("Format Error: Input has multiple SIGHASH_TYPE");e.sighashType=i.inputs.sighashType.decode(n);break;case s.InputTypes.REDEEM_SCRIPT:if(u("input",n.key,s.InputTypes.REDEEM_SCRIPT),void 0!==e.redeemScript)throw new Error("Format Error: Input has multiple REDEEM_SCRIPT");e.redeemScript=i.inputs.redeemScript.decode(n);break;case s.InputTypes.WITNESS_SCRIPT:if(u("input",n.key,s.InputTypes.WITNESS_SCRIPT),void 0!==e.witnessScript)throw new Error("Format Error: Input has multiple WITNESS_SCRIPT");e.witnessScript=i.inputs.witnessScript.decode(n);break;case s.InputTypes.BIP32_DERIVATION:void 0===e.bip32Derivation&&(e.bip32Derivation=[]),e.bip32Derivation.push(i.inputs.bip32Derivation.decode(n));break;case s.InputTypes.FINAL_SCRIPTSIG:u("input",n.key,s.InputTypes.FINAL_SCRIPTSIG),e.finalScriptSig=i.inputs.finalScriptSig.decode(n);break;case s.InputTypes.FINAL_SCRIPTWITNESS:u("input",n.key,s.InputTypes.FINAL_SCRIPTWITNESS),e.finalScriptWitness=i.inputs.finalScriptWitness.decode(n);break;case s.InputTypes.POR_COMMITMENT:u("input",n.key,s.InputTypes.POR_COMMITMENT),e.porCommitment=i.inputs.porCommitment.decode(n);break;case s.InputTypes.TAP_KEY_SIG:u("input",n.key,s.InputTypes.TAP_KEY_SIG),e.tapKeySig=i.inputs.tapKeySig.decode(n);break;case s.InputTypes.TAP_SCRIPT_SIG:void 0===e.tapScriptSig&&(e.tapScriptSig=[]),e.tapScriptSig.push(i.inputs.tapScriptSig.decode(n));break;case s.InputTypes.TAP_LEAF_SCRIPT:void 0===e.tapLeafScript&&(e.tapLeafScript=[]),e.tapLeafScript.push(i.inputs.tapLeafScript.decode(n));break;case s.InputTypes.TAP_BIP32_DERIVATION:void 0===e.tapBip32Derivation&&(e.tapBip32Derivation=[]),e.tapBip32Derivation.push(i.inputs.tapBip32Derivation.decode(n));break;case s.InputTypes.TAP_INTERNAL_KEY:u("input",n.key,s.InputTypes.TAP_INTERNAL_KEY),e.tapInternalKey=i.inputs.tapInternalKey.decode(n);break;case s.InputTypes.TAP_MERKLE_ROOT:u("input",n.key,s.InputTypes.TAP_MERKLE_ROOT),e.tapMerkleRoot=i.inputs.tapMerkleRoot.decode(n);break;default:e.unknownKeyVals||(e.unknownKeyVals=[]),e.unknownKeyVals.push(n)}h.push(e)}for(const t of o.range(l)){const e={};for(const r of n[t])switch(i.outputs.checkPubkey(r),r.key[0]){case s.OutputTypes.REDEEM_SCRIPT:if(u("output",r.key,s.OutputTypes.REDEEM_SCRIPT),void 0!==e.redeemScript)throw new Error("Format Error: Output has multiple REDEEM_SCRIPT");e.redeemScript=i.outputs.redeemScript.decode(r);break;case s.OutputTypes.WITNESS_SCRIPT:if(u("output",r.key,s.OutputTypes.WITNESS_SCRIPT),void 0!==e.witnessScript)throw new Error("Format Error: Output has multiple WITNESS_SCRIPT");e.witnessScript=i.outputs.witnessScript.decode(r);break;case s.OutputTypes.BIP32_DERIVATION:void 0===e.bip32Derivation&&(e.bip32Derivation=[]),e.bip32Derivation.push(i.outputs.bip32Derivation.decode(r));break;case s.OutputTypes.TAP_INTERNAL_KEY:u("output",r.key,s.OutputTypes.TAP_INTERNAL_KEY),e.tapInternalKey=i.outputs.tapInternalKey.decode(r);break;case s.OutputTypes.TAP_TREE:u("output",r.key,s.OutputTypes.TAP_TREE),e.tapTree=i.outputs.tapTree.decode(r);break;case s.OutputTypes.TAP_BIP32_DERIVATION:void 0===e.tapBip32Derivation&&(e.tapBip32Derivation=[]),e.tapBip32Derivation.push(i.outputs.tapBip32Derivation.decode(r));break;default:e.unknownKeyVals||(e.unknownKeyVals=[]),e.unknownKeyVals.push(r)}p.push(e)}return{globalMap:a,inputs:h,outputs:p}}e.psbtFromBuffer=function(t,e){let r=0;function n(){const e=a.decode(t,r);r+=a.encodingLength(e);const n=t.slice(r,r+e);return r+=e,n}function i(){return{key:n(),value:n()}}function u(){if(r>=t.length)throw new Error("Format Error: Unexpected End of PSBT");const e=0===t.readUInt8(r);return e&&r++,e}if(1886610036!==function(){const e=t.readUInt32BE(r);return r+=4,e}())throw new Error("Format Error: Invalid Magic Number");if(255!==function(){const e=t.readUInt8(r);return r+=1,e}())throw new Error("Format Error: Magic Number must be followed by 0xff separator");const f=[],l={};for(;!u();){const t=i(),e=t.key.toString("hex");if(l[e])throw new Error("Format Error: Keys must be unique for global keymap: key "+e);l[e]=1,f.push(t)}const h=f.filter(t=>t.key[0]===s.GlobalTypes.UNSIGNED_TX);if(1!==h.length)throw new Error("Format Error: Only one UNSIGNED_TX allowed");const p=e(h[0].value),{inputCount:d,outputCount:y}=p.getInputOutputCounts(),b=[],g=[];for(const t of o.range(d)){const e={},r=[];for(;!u();){const n=i(),o=n.key.toString("hex");if(e[o])throw new Error("Format Error: Keys must be unique for each input: input index "+t+" key "+o);e[o]=1,r.push(n)}b.push(r)}for(const t of o.range(y)){const e={},r=[];for(;!u();){const n=i(),o=n.key.toString("hex");if(e[o])throw new Error("Format Error: Keys must be unique for each output: output index "+t+" key "+o);e[o]=1,r.push(n)}g.push(r)}return c(p,{globalMapKeyVals:f,inputKeyVals:b,outputKeyVals:g})},e.checkKeyBuffer=u,e.psbtFromKeyVals=c},287:(t,e,r)=>{const n=r(526),i=r(251),o="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;e.hp=u,e.IS=50;const a=2147483647;function s(t){if(t>a)throw new RangeError('The value "'+t+'" is invalid for option "size"');const e=new Uint8Array(t);return Object.setPrototypeOf(e,u.prototype),e}function u(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return l(t)}return c(t,e,r)}function c(t,e,r){if("string"==typeof t)return function(t,e){if("string"==typeof e&&""!==e||(e="utf8"),!u.isEncoding(e))throw new TypeError("Unknown encoding: "+e);const r=0|y(t,e);let n=s(r);const i=n.write(t,e);return i!==r&&(n=n.slice(0,i)),n}(t,e);if(ArrayBuffer.isView(t))return function(t){if(X(t,Uint8Array)){const e=new Uint8Array(t);return p(e.buffer,e.byteOffset,e.byteLength)}return h(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(X(t,ArrayBuffer)||t&&X(t.buffer,ArrayBuffer))return p(t,e,r);if("undefined"!=typeof SharedArrayBuffer&&(X(t,SharedArrayBuffer)||t&&X(t.buffer,SharedArrayBuffer)))return p(t,e,r);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');const n=t.valueOf&&t.valueOf();if(null!=n&&n!==t)return u.from(n,e,r);const i=function(t){if(u.isBuffer(t)){const e=0|d(t.length),r=s(e);return 0===r.length||t.copy(r,0,0,e),r}return void 0!==t.length?"number"!=typeof t.length||Y(t.length)?s(0):h(t):"Buffer"===t.type&&Array.isArray(t.data)?h(t.data):void 0}(t);if(i)return i;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return u.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function f(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function l(t){return f(t),s(t<0?0:0|d(t))}function h(t){const e=t.length<0?0:0|d(t.length),r=s(e);for(let n=0;n<e;n+=1)r[n]=255&t[n];return r}function p(t,e,r){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(r||0))throw new RangeError('"length" is outside of buffer bounds');let n;return n=void 0===e&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,e):new Uint8Array(t,e,r),Object.setPrototypeOf(n,u.prototype),n}function d(t){if(t>=a)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+a.toString(16)+" bytes");return 0|t}function y(t,e){if(u.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||X(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);const r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;let i=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return q(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return z(t).length;default:if(i)return n?-1:q(t).length;e=(""+e).toLowerCase(),i=!0}}function b(t,e,r){let n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return x(this,e,r);case"utf8":case"utf-8":return T(this,e,r);case"ascii":return I(this,e,r);case"latin1":case"binary":return P(this,e,r);case"base64":return O(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return B(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function g(t,e,r){const n=t[e];t[e]=t[r],t[r]=n}function v(t,e,r,n,i){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),Y(r=+r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof e&&(e=u.from(e,n)),u.isBuffer(e))return 0===e.length?-1:w(t,e,r,n,i);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):w(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function w(t,e,r,n,i){let o,a=1,s=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;a=2,s/=2,u/=2,r/=2}function c(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(i){let n=-1;for(o=r;o<s;o++)if(c(t,o)===c(e,-1===n?0:o-n)){if(-1===n&&(n=o),o-n+1===u)return n*a}else-1!==n&&(o-=o-n),n=-1}else for(r+u>s&&(r=s-u),o=r;o>=0;o--){let r=!0;for(let n=0;n<u;n++)if(c(t,o+n)!==c(e,n)){r=!1;break}if(r)return o}return-1}function m(t,e,r,n){r=Number(r)||0;const i=t.length-r;n?(n=Number(n))>i&&(n=i):n=i;const o=e.length;let a;for(n>o/2&&(n=o/2),a=0;a<n;++a){const n=parseInt(e.substr(2*a,2),16);if(Y(n))return a;t[r+a]=n}return a}function S(t,e,r,n){return Z(q(e,t.length-r),t,r,n)}function _(t,e,r,n){return Z(function(t){const e=[];for(let r=0;r<t.length;++r)e.push(255&t.charCodeAt(r));return e}(e),t,r,n)}function E(t,e,r,n){return Z(z(e),t,r,n)}function k(t,e,r,n){return Z(function(t,e){let r,n,i;const o=[];for(let a=0;a<t.length&&!((e-=2)<0);++a)r=t.charCodeAt(a),n=r>>8,i=r%256,o.push(i),o.push(n);return o}(e,t.length-r),t,r,n)}function O(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function T(t,e,r){r=Math.min(t.length,r);const n=[];let i=e;for(;i<r;){const e=t[i];let o=null,a=e>239?4:e>223?3:e>191?2:1;if(i+a<=r){let r,n,s,u;switch(a){case 1:e<128&&(o=e);break;case 2:r=t[i+1],128==(192&r)&&(u=(31&e)<<6|63&r,u>127&&(o=u));break;case 3:r=t[i+1],n=t[i+2],128==(192&r)&&128==(192&n)&&(u=(15&e)<<12|(63&r)<<6|63&n,u>2047&&(u<55296||u>57343)&&(o=u));break;case 4:r=t[i+1],n=t[i+2],s=t[i+3],128==(192&r)&&128==(192&n)&&128==(192&s)&&(u=(15&e)<<18|(63&r)<<12|(63&n)<<6|63&s,u>65535&&u<1114112&&(o=u))}}null===o?(o=65533,a=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|1023&o),n.push(o),i+=a}return function(t){const e=t.length;if(e<=A)return String.fromCharCode.apply(String,t);let r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=A));return r}(n)}u.TYPED_ARRAY_SUPPORT=function(){try{const t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),42===t.foo()}catch(t){return!1}}(),u.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||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."),Object.defineProperty(u.prototype,"parent",{enumerable:!0,get:function(){if(u.isBuffer(this))return this.buffer}}),Object.defineProperty(u.prototype,"offset",{enumerable:!0,get:function(){if(u.isBuffer(this))return this.byteOffset}}),u.poolSize=8192,u.from=function(t,e,r){return c(t,e,r)},Object.setPrototypeOf(u.prototype,Uint8Array.prototype),Object.setPrototypeOf(u,Uint8Array),u.alloc=function(t,e,r){return function(t,e,r){return f(t),t<=0?s(t):void 0!==e?"string"==typeof r?s(t).fill(e,r):s(t).fill(e):s(t)}(t,e,r)},u.allocUnsafe=function(t){return l(t)},u.allocUnsafeSlow=function(t){return l(t)},u.isBuffer=function(t){return null!=t&&!0===t._isBuffer&&t!==u.prototype},u.compare=function(t,e){if(X(t,Uint8Array)&&(t=u.from(t,t.offset,t.byteLength)),X(e,Uint8Array)&&(e=u.from(e,e.offset,e.byteLength)),!u.isBuffer(t)||!u.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;let r=t.length,n=e.length;for(let i=0,o=Math.min(r,n);i<o;++i)if(t[i]!==e[i]){r=t[i],n=e[i];break}return r<n?-1:n<r?1:0},u.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}},u.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return u.alloc(0);let r;if(void 0===e)for(e=0,r=0;r<t.length;++r)e+=t[r].length;const n=u.allocUnsafe(e);let i=0;for(r=0;r<t.length;++r){let e=t[r];if(X(e,Uint8Array))i+e.length>n.length?(u.isBuffer(e)||(e=u.from(e)),e.copy(n,i)):Uint8Array.prototype.set.call(n,e,i);else{if(!u.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(n,i)}i+=e.length}return n},u.byteLength=y,u.prototype._isBuffer=!0,u.prototype.swap16=function(){const t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;e<t;e+=2)g(this,e,e+1);return this},u.prototype.swap32=function(){const t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let e=0;e<t;e+=4)g(this,e,e+3),g(this,e+1,e+2);return this},u.prototype.swap64=function(){const t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let e=0;e<t;e+=8)g(this,e,e+7),g(this,e+1,e+6),g(this,e+2,e+5),g(this,e+3,e+4);return this},u.prototype.toString=function(){const t=this.length;return 0===t?"":0===arguments.length?T(this,0,t):b.apply(this,arguments)},u.prototype.toLocaleString=u.prototype.toString,u.prototype.equals=function(t){if(!u.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===u.compare(this,t)},u.prototype.inspect=function(){let t="";const r=e.IS;return t=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(t+=" ... "),"<Buffer "+t+">"},o&&(u.prototype[o]=u.prototype.inspect),u.prototype.compare=function(t,e,r,n,i){if(X(t,Uint8Array)&&(t=u.from(t,t.offset,t.byteLength)),!u.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),e<0||r>t.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&e>=r)return 0;if(n>=i)return-1;if(e>=r)return 1;if(this===t)return 0;let o=(i>>>=0)-(n>>>=0),a=(r>>>=0)-(e>>>=0);const s=Math.min(o,a),c=this.slice(n,i),f=t.slice(e,r);for(let t=0;t<s;++t)if(c[t]!==f[t]){o=c[t],a=f[t];break}return o<a?-1:a<o?1:0},u.prototype.includes=function(t,e,r){return-1!==this.indexOf(t,e,r)},u.prototype.indexOf=function(t,e,r){return v(this,t,e,r,!0)},u.prototype.lastIndexOf=function(t,e,r){return v(this,t,e,r,!1)},u.prototype.write=function(t,e,r,n){if(void 0===e)n="utf8",r=this.length,e=0;else if(void 0===r&&"string"==typeof e)n=e,r=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e>>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}const i=this.length-e;if((void 0===r||r>i)&&(r=i),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");let o=!1;for(;;)switch(n){case"hex":return m(this,t,e,r);case"utf8":case"utf-8":return S(this,t,e,r);case"ascii":case"latin1":case"binary":return _(this,t,e,r);case"base64":return E(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,t,e,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const A=4096;function I(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(127&t[i]);return n}function P(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(t[i]);return n}function x(t,e,r){const n=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>n)&&(r=n);let i="";for(let n=e;n<r;++n)i+=$[t[n]];return i}function B(t,e,r){const n=t.slice(e,r);let i="";for(let t=0;t<n.length-1;t+=2)i+=String.fromCharCode(n[t]+256*n[t+1]);return i}function R(t,e,r){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}function U(t,e,r,n,i,o){if(!u.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||e<o)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}function j(t,e,r,n,i){K(e,n,i,t,r,7);let o=Number(e&BigInt(4294967295));t[r++]=o,o>>=8,t[r++]=o,o>>=8,t[r++]=o,o>>=8,t[r++]=o;let a=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=a,a>>=8,t[r++]=a,a>>=8,t[r++]=a,a>>=8,t[r++]=a,r}function N(t,e,r,n,i){K(e,n,i,t,r,7);let o=Number(e&BigInt(4294967295));t[r+7]=o,o>>=8,t[r+6]=o,o>>=8,t[r+5]=o,o>>=8,t[r+4]=o;let a=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=a,a>>=8,t[r+2]=a,a>>=8,t[r+1]=a,a>>=8,t[r]=a,r+8}function L(t,e,r,n,i,o){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function C(t,e,r,n,o){return e=+e,r>>>=0,o||L(t,0,r,4),i.write(t,e,r,n,23,4),r+4}function F(t,e,r,n,o){return e=+e,r>>>=0,o||L(t,0,r,8),i.write(t,e,r,n,52,8),r+8}u.prototype.slice=function(t,e){const r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e<t&&(e=t);const n=this.subarray(t,e);return Object.setPrototypeOf(n,u.prototype),n},u.prototype.readUintLE=u.prototype.readUIntLE=function(t,e,r){t>>>=0,e>>>=0,r||R(t,e,this.length);let n=this[t],i=1,o=0;for(;++o<e&&(i*=256);)n+=this[t+o]*i;return n},u.prototype.readUintBE=u.prototype.readUIntBE=function(t,e,r){t>>>=0,e>>>=0,r||R(t,e,this.length);let n=this[t+--e],i=1;for(;e>0&&(i*=256);)n+=this[t+--e]*i;return n},u.prototype.readUint8=u.prototype.readUInt8=function(t,e){return t>>>=0,e||R(t,1,this.length),this[t]},u.prototype.readUint16LE=u.prototype.readUInt16LE=function(t,e){return t>>>=0,e||R(t,2,this.length),this[t]|this[t+1]<<8},u.prototype.readUint16BE=u.prototype.readUInt16BE=function(t,e){return t>>>=0,e||R(t,2,this.length),this[t]<<8|this[t+1]},u.prototype.readUint32LE=u.prototype.readUInt32LE=function(t,e){return t>>>=0,e||R(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},u.prototype.readUint32BE=u.prototype.readUInt32BE=function(t,e){return t>>>=0,e||R(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},u.prototype.readBigUInt64LE=J(function(t){V(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||W(t,this.length-8);const n=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,i=this[++t]+256*this[++t]+65536*this[++t]+r*2**24;return BigInt(n)+(BigInt(i)<<BigInt(32))}),u.prototype.readBigUInt64BE=J(function(t){V(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||W(t,this.length-8);const n=e*2**24+65536*this[++t]+256*this[++t]+this[++t],i=this[++t]*2**24+65536*this[++t]+256*this[++t]+r;return(BigInt(n)<<BigInt(32))+BigInt(i)}),u.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||R(t,e,this.length);let n=this[t],i=1,o=0;for(;++o<e&&(i*=256);)n+=this[t+o]*i;return i*=128,n>=i&&(n-=Math.pow(2,8*e)),n},u.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||R(t,e,this.length);let n=e,i=1,o=this[t+--n];for(;n>0&&(i*=256);)o+=this[t+--n]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*e)),o},u.prototype.readInt8=function(t,e){return t>>>=0,e||R(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},u.prototype.readInt16LE=function(t,e){t>>>=0,e||R(t,2,this.length);const r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt16BE=function(t,e){t>>>=0,e||R(t,2,this.length);const r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt32LE=function(t,e){return t>>>=0,e||R(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},u.prototype.readInt32BE=function(t,e){return t>>>=0,e||R(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},u.prototype.readBigInt64LE=J(function(t){V(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||W(t,this.length-8);const n=this[t+4]+256*this[t+5]+65536*this[t+6]+(r<<24);return(BigInt(n)<<BigInt(32))+BigInt(e+256*this[++t]+65536*this[++t]+this[++t]*2**24)}),u.prototype.readBigInt64BE=J(function(t){V(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||W(t,this.length-8);const n=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return(BigInt(n)<<BigInt(32))+BigInt(this[++t]*2**24+65536*this[++t]+256*this[++t]+r)}),u.prototype.readFloatLE=function(t,e){return t>>>=0,e||R(t,4,this.length),i.read(this,t,!0,23,4)},u.prototype.readFloatBE=function(t,e){return t>>>=0,e||R(t,4,this.length),i.read(this,t,!1,23,4)},u.prototype.readDoubleLE=function(t,e){return t>>>=0,e||R(t,8,this.length),i.read(this,t,!0,52,8)},u.prototype.readDoubleBE=function(t,e){return t>>>=0,e||R(t,8,this.length),i.read(this,t,!1,52,8)},u.prototype.writeUintLE=u.prototype.writeUIntLE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||U(this,t,e,r,Math.pow(2,8*r)-1,0);let i=1,o=0;for(this[e]=255&t;++o<r&&(i*=256);)this[e+o]=t/i&255;return e+r},u.prototype.writeUintBE=u.prototype.writeUIntBE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||U(this,t,e,r,Math.pow(2,8*r)-1,0);let i=r-1,o=1;for(this[e+i]=255&t;--i>=0&&(o*=256);)this[e+i]=t/o&255;return e+r},u.prototype.writeUint8=u.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,1,255,0),this[e]=255&t,e+1},u.prototype.writeUint16LE=u.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},u.prototype.writeUint16BE=u.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},u.prototype.writeUint32LE=u.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},u.prototype.writeUint32BE=u.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},u.prototype.writeBigUInt64LE=J(function(t,e=0){return j(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))}),u.prototype.writeBigUInt64BE=J(function(t,e=0){return N(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))}),u.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);U(this,t,e,r,n-1,-n)}let i=0,o=1,a=0;for(this[e]=255&t;++i<r&&(o*=256);)t<0&&0===a&&0!==this[e+i-1]&&(a=1),this[e+i]=(t/o|0)-a&255;return e+r},u.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);U(this,t,e,r,n-1,-n)}let i=r-1,o=1,a=0;for(this[e+i]=255&t;--i>=0&&(o*=256);)t<0&&0===a&&0!==this[e+i+1]&&(a=1),this[e+i]=(t/o|0)-a&255;return e+r},u.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},u.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},u.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},u.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},u.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},u.prototype.writeBigInt64LE=J(function(t,e=0){return j(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),u.prototype.writeBigInt64BE=J(function(t,e=0){return N(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),u.prototype.writeFloatLE=function(t,e,r){return C(this,t,e,!0,r)},u.prototype.writeFloatBE=function(t,e,r){return C(this,t,e,!1,r)},u.prototype.writeDoubleLE=function(t,e,r){return F(this,t,e,!0,r)},u.prototype.writeDoubleBE=function(t,e,r){return F(this,t,e,!1,r)},u.prototype.copy=function(t,e,r,n){if(!u.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n<r&&(n=r),n===r)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e<n-r&&(n=t.length-e+r);const i=n-r;return this===t&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(e,r,n):Uint8Array.prototype.set.call(t,this.subarray(r,n),e),i},u.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!u.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===t.length){const e=t.charCodeAt(0);("utf8"===n&&e<128||"latin1"===n)&&(t=e)}}else"number"==typeof t?t&=255:"boolean"==typeof t&&(t=Number(t));if(e<0||this.length<e||this.length<r)throw new RangeError("Out of range index");if(r<=e)return this;let i;if(e>>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(i=e;i<r;++i)this[i]=t;else{const o=u.isBuffer(t)?t:u.from(t,n),a=o.length;if(0===a)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(i=0;i<r-e;++i)this[i+e]=o[i%a]}return this};const D={};function H(t,e,r){D[t]=class extends r{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${t}]`,this.stack,delete this.name}get code(){return t}set code(t){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:t,writable:!0})}toString(){return`${this.name} [${t}]: ${this.message}`}}}function M(t){let e="",r=t.length;const n="-"===t[0]?1:0;for(;r>=n+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}function K(t,e,r,n,i,o){if(t>r||t<e){const n="bigint"==typeof e?"n":"";let i;throw i=o>3?0===e||e===BigInt(0)?`>= 0${n} and < 2${n} ** ${8*(o+1)}${n}`:`>= -(2${n} ** ${8*(o+1)-1}${n}) and < 2 ** ${8*(o+1)-1}${n}`:`>= ${e}${n} and <= ${r}${n}`,new D.ERR_OUT_OF_RANGE("value",i,t)}!function(t,e,r){V(e,"offset"),void 0!==t[e]&&void 0!==t[e+r]||W(e,t.length-(r+1))}(n,i,o)}function V(t,e){if("number"!=typeof t)throw new D.ERR_INVALID_ARG_TYPE(e,"number",t)}function W(t,e,r){if(Math.floor(t)!==t)throw V(t,r),new D.ERR_OUT_OF_RANGE(r||"offset","an integer",t);if(e<0)throw new D.ERR_BUFFER_OUT_OF_BOUNDS;throw new D.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}H("ERR_BUFFER_OUT_OF_BOUNDS",function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),H("ERR_INVALID_ARG_TYPE",function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`},TypeError),H("ERR_OUT_OF_RANGE",function(t,e,r){let n=`The value of "${t}" is out of range.`,i=r;return Number.isInteger(r)&&Math.abs(r)>2**32?i=M(String(r)):"bigint"==typeof r&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=M(i)),i+="n"),n+=` It must be ${e}. Received ${i}`,n},RangeError);const G=/[^+/0-9A-Za-z-_]/g;function q(t,e){let r;e=e||1/0;const n=t.length;let i=null;const o=[];for(let a=0;a<n;++a){if(r=t.charCodeAt(a),r>55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(a+1===n){(e-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;o.push(r)}else if(r<2048){if((e-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function z(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(G,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function Z(t,e,r,n){let i;for(i=0;i<n&&!(i+r>=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function X(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function Y(t){return t!=t}const $=function(){const t="0123456789abcdef",e=new Array(256);for(let r=0;r<16;++r){const n=16*r;for(let i=0;i<16;++i)e[n+i]=t[r]+t[i]}return e}();function J(t){return"undefined"==typeof BigInt?Q:t}function Q(){throw new Error("BigInt not supported")}},307:(t,e,r)=>{var n=r(287).hp;Object.defineProperty(e,"__esModule",{value:!0}),e.makeConverter=function(t){return{decode:function(e){if(e.key[0]!==t)throw new Error("Decode Error: could not decode redeemScript with key 0x"+e.key.toString("hex"));return e.value},encode:function(e){return{key:n.from([t]),value:e}},check:function(t){return n.isBuffer(t)},expected:"Buffer",canAdd:function(t,e){return!!t&&!!e&&void 0===t.redeemScript}}}},343:(t,e)=>{e.p2=e.I=void 0;const r="qpzry9x8gf2tvdw0s3jn54khce6mua7l",n={};for(let t=0;t<32;t++){const e=r.charAt(t);n[e]=t}function i(t){const e=t>>25;return(33554431&t)<<5^996825010&-(1&e)^642813549&-(e>>1&1)^513874426&-(e>>2&1)^1027748829&-(e>>3&1)^705979059&-(e>>4&1)}function o(t){let e=1;for(let r=0;r<t.length;++r){const n=t.charCodeAt(r);if(n<33||n>126)return"Invalid prefix ("+t+")";e=i(e)^n>>5}e=i(e);for(let r=0;r<t.length;++r){const n=t.charCodeAt(r);e=i(e)^31&n}return e}function a(t,e,r,n){let i=0,o=0;const a=(1<<r)-1,s=[];for(let n=0;n<t.length;++n)for(i=i<<e|t[n],o+=e;o>=r;)o-=r,s.push(i>>o&a);if(n)o>0&&s.push(i<<r-o&a);else{if(o>=e)return"Excess padding";if(i<<r-o&a)return"Non-zero padding"}return s}function s(t){return a(t,8,5,!0)}function u(t){const e=a(t,5,8,!1);if(Array.isArray(e))return e}function c(t){const e=a(t,5,8,!1);if(Array.isArray(e))return e;throw new Error(e)}function f(t){let e;function a(t,r){if(r=r||90,t.length<8)return t+" too short";if(t.length>r)return"Exceeds length limit";const a=t.toLowerCase(),s=t.toUpperCase();if(t!==a&&t!==s)return"Mixed-case string "+t;const u=(t=a).lastIndexOf("1");if(-1===u)return"No separator character for "+t;if(0===u)return"Missing prefix for "+t;const c=t.slice(0,u),f=t.slice(u+1);if(f.length<6)return"Data too short";let l=o(c);if("string"==typeof l)return l;const h=[];for(let t=0;t<f.length;++t){const e=f.charAt(t),r=n[e];if(void 0===r)return"Unknown character "+e;l=i(l)^r,t+6>=f.length||h.push(r)}return l!==e?"Invalid checksum for "+t:{prefix:c,words:h}}return e="bech32"===t?1:734539939,{decodeUnsafe:function(t,e){const r=a(t,e);if("object"==typeof r)return r},decode:function(t,e){const r=a(t,e);if("object"==typeof r)return r;throw new Error(r)},encode:function(t,n,a){if(a=a||90,t.length+7+n.length>a)throw new TypeError("Exceeds length limit");let s=o(t=t.toLowerCase());if("string"==typeof s)throw new Error(s);let u=t+"1";for(let t=0;t<n.length;++t){const e=n[t];if(e>>5)throw new Error("Non 5-bit word");s=i(s)^e,u+=r.charAt(e)}for(let t=0;t<6;++t)s=i(s);s^=e;for(let t=0;t<6;++t)u+=r.charAt(s>>5*(5-t)&31);return u},toWords:s,fromWordsUnsafe:u,fromWords:c}}e.I=f("bech32"),e.p2=f("bech32m")},344:(t,e,r)=>{var n=r(287).hp;Object.defineProperty(e,"__esModule",{value:!0});const i=r(80);e.decode=function(t){if(t.key[0]!==i.InputTypes.SIGHASH_TYPE)throw new Error("Decode Error: could not decode sighashType with key 0x"+t.key.toString("hex"));return t.value.readUInt32LE(0)},e.encode=function(t){const e=n.from([i.InputTypes.SIGHASH_TYPE]),r=n.allocUnsafe(4);return r.writeUInt32LE(t,0),{key:e,value:r}},e.expected="number",e.check=function(t){return"number"==typeof t},e.canAdd=function(t,e){return!!t&&!!e&&void 0===t.sighashType}},394:(t,e,r)=>{var n=r(287).hp;function i(t){if(t<0||t>9007199254740991||t%1!=0)throw new RangeError("value out of range")}function o(t){return i(t),t<253?1:t<=65535?3:t<=4294967295?5:9}Object.defineProperty(e,"__esModule",{value:!0}),e.encode=function t(e,r,a){if(i(e),r||(r=n.allocUnsafe(o(e))),!n.isBuffer(r))throw new TypeError("buffer must be a Buffer instance");return a||(a=0),e<253?(r.writeUInt8(e,a),Object.assign(t,{bytes:1})):e<=65535?(r.writeUInt8(253,a),r.writeUInt16LE(e,a+1),Object.assign(t,{bytes:3})):e<=4294967295?(r.writeUInt8(254,a),r.writeUInt32LE(e,a+1),Object.assign(t,{bytes:5})):(r.writeUInt8(255,a),r.writeUInt32LE(e>>>0,a+1),r.writeUInt32LE(e/4294967296|0,a+5),Object.assign(t,{bytes:9})),r},e.decode=function t(e,r){if(!n.isBuffer(e))throw new TypeError("buffer must be a Buffer instance");r||(r=0);const o=e.readUInt8(r);if(o<253)return Object.assign(t,{bytes:1}),o;if(253===o)return Object.assign(t,{bytes:3}),e.readUInt16LE(r+1);if(254===o)return Object.assign(t,{bytes:5}),e.readUInt32LE(r+1);{Object.assign(t,{bytes:9});const n=e.readUInt32LE(r+1),o=4294967296*e.readUInt32LE(r+5)+n;return i(o),o}},e.encodingLength=o},412:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.makeChecker=function(t){return function(e){let r;if(t.includes(e.key[0])&&(r=e.key.slice(1),33!==r.length&&65!==r.length||![2,3,4].includes(r[0])))throw new Error("Format Error: invalid pubkey in key 0x"+e.key.toString("hex"));return r}}},431:(t,e,r)=>{var n=r(287).hp;Object.defineProperty(e,"__esModule",{value:!0});const i=r(80);e.decode=function(t){if(t.key[0]!==i.InputTypes.NON_WITNESS_UTXO)throw new Error("Decode Error: could not decode nonWitnessUtxo with key 0x"+t.key.toString("hex"));return t.value},e.encode=function(t){return{key:n.from([i.InputTypes.NON_WITNESS_UTXO]),value:t}},e.expected="Buffer",e.check=function(t){return n.isBuffer(t)},e.canAdd=function(t,e){return!!t&&!!e&&void 0===t.nonWitnessUtxo}},454:(t,e,r)=>{var n=r(287).hp;Object.defineProperty(e,"__esModule",{value:!0});const i=r(80);function o(t){return n.isBuffer(t)&&32===t.length}e.decode=function(t){if(t.key[0]!==i.InputTypes.TAP_MERKLE_ROOT||1!==t.key.length)throw new Error("Decode Error: could not decode tapMerkleRoot with key 0x"+t.key.toString("hex"));if(!o(t.value))throw new Error("Decode Error: tapMerkleRoot not a 32-byte hash");return t.value},e.encode=function(t){return{key:n.from([i.InputTypes.TAP_MERKLE_ROOT]),value:t}},e.expected="Buffer",e.check=o,e.canAdd=function(t,e){return!!t&&!!e&&void 0===t.tapMerkleRoot}},457:(t,e,r)=>{function n(t){for(var r in t)e.hasOwnProperty(r)||(e[r]=t[r])}Object.defineProperty(e,"__esModule",{value:!0}),n(r(263)),n(r(238))},526:(t,e)=>{e.byteLength=function(t){var e=s(t),r=e[0],n=e[1];return 3*(r+n)/4-n},e.toByteArray=function(t){var e,r,o=s(t),a=o[0],u=o[1],c=new i(function(t,e,r){return 3*(e+r)/4-r}(0,a,u)),f=0,l=u>0?a-4:a;for(r=0;r<l;r+=4)e=n[t.charCodeAt(r)]<<18|n[t.charCodeAt(r+1)]<<12|n[t.charCodeAt(r+2)]<<6|n[t.charCodeAt(r+3)],c[f++]=e>>16&255,c[f++]=e>>8&255,c[f++]=255&e;return 2===u&&(e=n[t.charCodeAt(r)]<<2|n[t.charCodeAt(r+1)]>>4,c[f++]=255&e),1===u&&(e=n[t.charCodeAt(r)]<<10|n[t.charCodeAt(r+1)]<<4|n[t.charCodeAt(r+2)]>>2,c[f++]=e>>8&255,c[f++]=255&e),c},e.fromByteArray=function(t){for(var e,n=t.length,i=n%3,o=[],a=16383,s=0,c=n-i;s<c;s+=a)o.push(u(t,s,s+a>c?c:s+a));return 1===i?(e=t[n-1],o.push(r[e>>2]+r[e<<4&63]+"==")):2===i&&(e=(t[n-2]<<8)+t[n-1],o.push(r[e>>10]+r[e>>4&63]+r[e<<2&63]+"=")),o.join("")};for(var r=[],n=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0;a<64;++a)r[a]=o[a],n[o.charCodeAt(a)]=a;function s(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function u(t,e,n){for(var i,o,a=[],s=e;s<n;s+=3)i=(t[s]<<16&16711680)+(t[s+1]<<8&65280)+(255&t[s+2]),a.push(r[(o=i)>>18&63]+r[o>>12&63]+r[o>>6&63]+r[63&o]);return a.join("")}n["-".charCodeAt(0)]=62,n["_".charCodeAt(0)]=63},542:(t,e,r)=>{var n=r(287).hp,i=r(113),o=r(61);function a(t){return n.isBuffer(t)}function s(t){return"string"==typeof t&&/^([0-9a-f]{2})+$/i.test(t)}function u(t,e){var r=t.toJSON();function n(n){if(!t(n))return!1;if(n.length===e)return!0;throw o.tfCustomError(r+"(Length: "+e+")",r+"(Length: "+n.length+")")}return n.toJSON=function(){return r},n}var c=u.bind(null,i.Array),f=u.bind(null,a),l=u.bind(null,s),h=u.bind(null,i.String),p=Math.pow(2,53)-1,d={ArrayN:c,Buffer:a,BufferN:f,Finite:function(t){return"number"==typeof t&&isFinite(t)},Hex:s,HexN:l,Int8:function(t){return t<<24>>24===t},Int16:function(t){return t<<16>>16===t},Int32:function(t){return(0|t)===t},Int53:function(t){return"number"==typeof t&&t>=-p&&t<=p&&Math.floor(t)===t},Range:function(t,e,r){function n(n,i){return r(n,i)&&n>t&&n<e}return r=r||i.Number,n.toJSON=function(){return`${r.toJSON()} between [${t}, ${e}]`},n},StringN:h,UInt8:function(t){return(255&t)===t},UInt16:function(t){return(65535&t)===t},UInt32:function(t){return t>>>0===t},UInt53:function(t){return"number"==typeof t&&t>=0&&t<=p&&Math.floor(t)===t}};for(var y in d)d[y].toJSON=function(t){return t}.bind(null,y);t.exports=d},545:(t,e,r)=>{var n=r(287).hp;Object.defineProperty(e,"__esModule",{value:!0});const i=t=>33===t.length&&[2,3].includes(t[0])||65===t.length&&4===t[0];e.makeConverter=function(t,e=i){return{decode:function(r){if(r.key[0]!==t)throw new Error("Decode Error: could not decode bip32Derivation with key 0x"+r.key.toString("hex"));const n=r.key.slice(1);if(!e(n))throw new Error("Decode Error: bip32Derivation has invalid pubkey in key 0x"+r.key.toString("hex"));if(r.value.length/4%1!=0)throw new Error("Decode Error: Input BIP32_DERIVATION value length should be multiple of 4");const i={masterFingerprint:r.value.slice(0,4),pubkey:n,path:"m"};for(const t of(o=r.value.length/4-1,[...Array(o).keys()])){const e=r.value.readUInt32LE(4*t+4),n=!!(2147483648&e),o=2147483647&e;i.path+="/"+o.toString(10)+(n?"'":"")}var o;return i},encode:function(e){const r=n.from([t]),i=n.concat([r,e.pubkey]),o=e.path.split("/"),a=n.allocUnsafe(4*o.length);e.masterFingerprint.copy(a,0);let s=4;return o.slice(1).forEach(t=>{const e="'"===t.slice(-1);let r=2147483647&parseInt(e?t.slice(0,-1):t,10);e&&(r+=2147483648),a.writeUInt32LE(r,s),s+=4}),{key:i,value:a}},check:function(t){return n.isBuffer(t.pubkey)&&n.isBuffer(t.masterFingerprint)&&"string"==typeof t.path&&e(t.pubkey)&&4===t.masterFingerprint.length},expected:"{ masterFingerprint: Buffer; pubkey: Buffer; path: string; }",canAddToArray:function(t,e,r){const n=e.pubkey.toString("hex");return!r.has(n)&&(r.add(n),0===t.filter(t=>t.pubkey.equals(e.pubkey)).length)}}}},578:(t,e,r)=>{var n=r(287).hp;Object.defineProperty(e,"__esModule",{value:!0}),e.makeConverter=function(t){return{decode:function(e){if(e.key[0]!==t)throw new Error("Decode Error: could not decode witnessScript with key 0x"+e.key.toString("hex"));return e.value},encode:function(e){return{key:n.from([t]),value:e}},check:function(t){return n.isBuffer(t)},expected:"Buffer",canAdd:function(t,e){return!!t&&!!e&&void 0===t.witnessScript}}}},605:(t,e,r)=>{var n=r(287).hp;Object.defineProperty(e,"__esModule",{value:!0});const i=r(80);e.decode=function(t){if(t.key[0]!==i.InputTypes.FINAL_SCRIPTSIG)throw new Error("Decode Error: could not decode finalScriptSig with key 0x"+t.key.toString("hex"));return t.value},e.encode=function(t){return{key:n.from([i.InputTypes.FINAL_SCRIPTSIG]),value:t}},e.expected="Buffer",e.check=function(t){return n.isBuffer(t)},e.canAdd=function(t,e){return!!t&&!!e&&void 0===t.finalScriptSig}},614:(t,e,r)=>{var n=r(287).hp;const i=r(863),o=r(457),a=r(80),s=r(699);e.i=class{constructor(t){this.inputs=[],this.outputs=[],this.globalMap={unsignedTx:t}}static fromBase64(t,e){const r=n.from(t,"base64");return this.fromBuffer(r,e)}static fromHex(t,e){const r=n.from(t,"hex");return this.fromBuffer(r,e)}static fromBuffer(t,e){const r=o.psbtFromBuffer(t,e),n=new this(r.globalMap.unsignedTx);return Object.assign(n,r),n}toBase64(){return this.toBuffer().toString("base64")}toHex(){return this.toBuffer().toString("hex")}toBuffer(){return o.psbtToBuffer(this)}updateGlobal(t){return s.updateGlobal(t,this.globalMap),this}updateInput(t,e){const r=s.checkForInput(this.inputs,t);return s.updateInput(e,r),this}updateOutput(t,e){const r=s.checkForOutput(this.outputs,t);return s.updateOutput(e,r),this}addUnknownKeyValToGlobal(t){return s.checkHasKey(t,this.globalMap.unknownKeyVals,s.getEnumLength(a.GlobalTypes)),this.globalMap.unknownKeyVals||(this.globalMap.unknownKeyVals=[]),this.globalMap.unknownKeyVals.push(t),this}addUnknownKeyValToInput(t,e){const r=s.checkForInput(this.inputs,t);return s.checkHasKey(e,r.unknownKeyVals,s.getEnumLength(a.InputTypes)),r.unknownKeyVals||(r.unknownKeyVals=[]),r.unknownKeyVals.push(e),this}addUnknownKeyValToOutput(t,e){const r=s.checkForOutput(this.outputs,t);return s.checkHasKey(e,r.unknownKeyVals,s.getEnumLength(a.OutputTypes)),r.unknownKeyVals||(r.unknownKeyVals=[]),r.unknownKeyVals.push(e),this}addInput(t){this.globalMap.unsignedTx.addInput(t),this.inputs.push({unknownKeyVals:[]});const e=t.unknownKeyVals||[],r=this.inputs.length-1;if(!Array.isArray(e))throw new Error("unknownKeyVals must be an Array");return e.forEach(t=>this.addUnknownKeyValToInput(r,t)),s.addInputAttributes(this.inputs,t),this}addOutput(t){this.globalMap.unsignedTx.addOutput(t),this.outputs.push({unknownKeyVals:[]});const e=t.unknownKeyVals||[],r=this.outputs.length-1;if(!Array.isArray(e))throw new Error("unknownKeyVals must be an Array");return e.forEach(t=>this.addUnknownKeyValToOutput(r,t)),s.addOutputAttributes(this.outputs,t),this}clearFinalizedInput(t){const e=s.checkForInput(this.inputs,t);s.inputCheckUncleanFinalized(t,e);for(const t of Object.keys(e))["witnessUtxo","nonWitnessUtxo","finalScriptSig","finalScriptWitness","unknownKeyVals"].includes(t)||delete e[t];return this}combine(...t){const e=i.combine([this].concat(t));return Object.assign(this,e),this}getTransaction(){return this.globalMap.unsignedTx.toBuffer()}}},636:(t,e,r)=>{var n=r(287).hp;Object.defineProperty(e,"__esModule",{value:!0});const i=r(394),o=r(545),a=t=>32===t.length;e.makeConverter=function(t){const e=o.makeConverter(t,a);return{decode:function(t){const r=i.decode(t.value),n=i.encodingLength(r),o=e.decode({key:t.key,value:t.value.slice(n+32*r)}),a=new Array(r);for(let e=0,i=n;e<r;e++,i+=32)a[e]=t.value.slice(i,i+32);return Object.assign({},o,{leafHashes:a})},encode:function(t){const r=e.encode(t),o=i.encodingLength(t.leafHashes.length),a=n.allocUnsafe(o);i.encode(t.leafHashes.length,a);const s=n.concat([a,...t.leafHashes,r.value]);return Object.assign({},r,{value:s})},check:function(t){return Array.isArray(t.leafHashes)&&t.leafHashes.every(t=>n.isBuffer(t)&&32===t.length)&&e.check(t)},expected:"{ masterFingerprint: Buffer; pubkey: Buffer; path: string; leafHashes: Buffer[]; }",canAddToArray:e.canAddToArray}}},676:(t,e,r)=>{var n=r(61),i=r(113),o=n.tfJSON,a=n.TfTypeError,s=n.TfPropertyTypeError,u=n.tfSubError,c=n.getValueTypeName,f={arrayOf:function(t,e){function r(r,n){return!!i.Array(r)&&!i.Nil(r)&&!(void 0!==e.minLength&&r.length<e.minLength)&&!(void 0!==e.maxLength&&r.length>e.maxLength)&&(void 0===e.length||r.length===e.length)&&r.every(function(e,r){try{return h(t,e,n)}catch(t){throw u(t,r)}})}return t=l(t),e=e||{},r.toJSON=function(){var r="["+o(t)+"]";return void 0!==e.length?r+="{"+e.length+"}":void 0===e.minLength&&void 0===e.maxLength||(r+="{"+(void 0===e.minLength?0:e.minLength)+","+(void 0===e.maxLength?1/0:e.maxLength)+"}"),r},r},maybe:function t(e){function r(r,n){return i.Nil(r)||e(r,n,t)}return e=l(e),r.toJSON=function(){return"?"+o(e)},r},map:function(t,e){function r(r,n){if(!i.Object(r))return!1;if(i.Nil(r))return!1;for(var o in r){try{e&&h(e,o,n)}catch(t){throw u(t,o,"key")}try{var a=r[o];h(t,a,n)}catch(t){throw u(t,o)}}return!0}return t=l(t),e&&(e=l(e)),r.toJSON=e?function(){return"{"+o(e)+": "+o(t)+"}"}:function(){return"{"+o(t)+"}"},r},object:function(t){var e={};for(var r in t)e[r]=l(t[r]);function n(t,r){if(!i.Object(t))return!1;if(i.Nil(t))return!1;var n;try{for(n in e)h(e[n],t[n],r)}catch(t){throw u(t,n)}if(r)for(n in t)if(!e[n])throw new s(void 0,n);return!0}return n.toJSON=function(){return o(e)},n},anyOf:function(){var t=[].slice.call(arguments).map(l);function e(e,r){return t.some(function(t){try{return h(t,e,r)}catch(t){return!1}})}return e.toJSON=function(){return t.map(o).join("|")},e},allOf:function(){var t=[].slice.call(arguments).map(l);function e(e,r){return t.every(function(t){try{return h(t,e,r)}catch(t){return!1}})}return e.toJSON=function(){return t.map(o).join(" & ")},e},quacksLike:function(t){function e(e){return t===c(e)}return e.toJSON=function(){return t},e},tuple:function(){var t=[].slice.call(arguments).map(l);function e(e,r){return!i.Nil(e)&&!i.Nil(e.length)&&(!r||e.length===t.length)&&t.every(function(t,n){try{return h(t,e[n],r)}catch(t){throw u(t,n)}})}return e.toJSON=function(){return"("+t.map(o).join(", ")+")"},e},value:function(t){function e(e){return e===t}return e.toJSON=function(){return t},e}};function l(t){if(i.String(t))return"?"===t[0]?f.maybe(t.slice(1)):i[t]||f.quacksLike(t);if(t&&i.Object(t)){if(i.Array(t)){if(1!==t.length)throw new TypeError("Expected compile() parameter of type Array of length 1");return f.arrayOf(t[0])}return f.object(t)}return i.Function(t)?t:f.value(t)}function h(t,e,r,n){if(i.Function(t)){if(t(e,r))return!0;throw new a(n||t,e)}return h(l(t),e,r)}for(var p in f.oneOf=f.anyOf,i)h[p]=i[p];for(p in f)h[p]=f[p];var d=r(542);for(p in d)h[p]=d[p];h.compile=l,h.TfTypeError=a,h.TfPropertyTypeError=s,t.exports=h},695:(t,e,r)=>{var n=r(287).hp;Object.defineProperty(e,"__esModule",{value:!0});const i=r(80);e.decode=function(t){if(t.key[0]!==i.InputTypes.TAP_LEAF_SCRIPT)throw new Error("Decode Error: could not decode tapLeafScript with key 0x"+t.key.toString("hex"));if((t.key.length-2)%32!=0)throw new Error("Decode Error: tapLeafScript has invalid control block in key 0x"+t.key.toString("hex"));const e=t.value[t.value.length-1];if((254&t.key[1])!==e)throw new Error("Decode Error: tapLeafScript bad leaf version in key 0x"+t.key.toString("hex"));const r=t.value.slice(0,-1);return{controlBlock:t.key.slice(1),script:r,leafVersion:e}},e.encode=function(t){const e=n.from([i.InputTypes.TAP_LEAF_SCRIPT]),r=n.from([t.leafVersion]);return{key:n.concat([e,t.controlBlock]),value:n.concat([t.script,r])}},e.expected="{ controlBlock: Buffer; leafVersion: number, script: Buffer; }",e.check=function(t){return n.isBuffer(t.controlBlock)&&(t.controlBlock.length-1)%32==0&&(254&t.controlBlock[0])===t.leafVersion&&n.isBuffer(t.script)},e.canAddToArray=function(t,e,r){const n=e.controlBlock.toString("hex");return!r.has(n)&&(r.add(n),0===t.filter(t=>t.controlBlock.equals(e.controlBlock)).length)}},699:(t,e,r)=>{var n=r(287).hp;Object.defineProperty(e,"__esModule",{value:!0});const i=r(706);function o(t,e){const r=t[e];if(void 0===r)throw new Error(`No input #${e}`);return r}function a(t,e){const r=t[e];if(void 0===r)throw new Error(`No output #${e}`);return r}function s(t,e,r,n){throw new Error(`Data for ${t} key ${e} is incorrect: Expected ${r} and got ${JSON.stringify(n)}`)}function u(t){return(e,r)=>{for(const n of Object.keys(e)){const o=e[n],{canAdd:a,canAddToArray:u,check:c,expected:f}=i[t+"s"][n]||{};if(c)if(u){if(!Array.isArray(o)||r[n]&&!Array.isArray(r[n]))throw new Error(`Key type ${n} must be an array`);o.every(c)||s(t,n,f,o);const e=r[n]||[],i=new Set;if(!o.every(t=>u(e,t,i)))throw new Error("Can not add duplicate data to array");r[n]=e.concat(o)}else{if(c(o)||s(t,n,f,o),!a(r,o))throw new Error(`Can not add duplicate data to ${t}`);r[n]=o}}}}e.checkForInput=o,e.checkForOutput=a,e.checkHasKey=function(t,e,r){if(t.key[0]<r)throw new Error("Use the method for your specific key instead of addUnknownKeyVal*");if(e&&0!==e.filter(e=>e.key.equals(t.key)).length)throw new Error(`Duplicate Key: ${t.key.toString("hex")}`)},e.getEnumLength=function(t){let e=0;return Object.keys(t).forEach(t=>{Number(isNaN(Number(t)))&&e++}),e},e.inputCheckUncleanFinalized=function(t,e){let r=!1;if(e.nonWitnessUtxo||e.witnessUtxo){const t=!!e.redeemScript,n=!!e.witnessScript,i=!t||!!e.finalScriptSig,o=!n||!!e.finalScriptWitness,a=!!e.finalScriptSig||!!e.finalScriptWitness;r=i&&o&&a}if(!1===r)throw new Error(`Input #${t} has too much or too little data to clean`)},e.updateGlobal=u("global"),e.updateInput=u("input"),e.updateOutput=u("output"),e.addInputAttributes=function(t,r){const n=o(t,t.length-1);e.updateInput(r,n)},e.addOutputAttributes=function(t,r){const n=a(t,t.length-1);e.updateOutput(r,n)},e.defaultVersionSetter=function(t,e){if(!n.isBuffer(e)||e.length<4)throw new Error("Set Version: Invalid Transaction");return e.writeUInt32LE(t,0),e},e.defaultLocktimeSetter=function(t,e){if(!n.isBuffer(e)||e.length<4)throw new Error("Set Locktime: Invalid Transaction");return e.writeUInt32LE(t,e.length-4),e}},706:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0});const n=r(80),i=r(834),o=r(213),a=r(605),s=r(795),u=r(431),c=r(907),f=r(949),l=r(344),h=r(760),p=r(695),d=r(454),y=r(34),b=r(926),g=r(851),v=r(545),w=r(412),m=r(307),S=r(636),_=r(223),E=r(578),k={unsignedTx:o,globalXpub:i,checkPubkey:w.makeChecker([])};e.globals=k;const O={nonWitnessUtxo:u,partialSig:c,sighashType:l,finalScriptSig:a,finalScriptWitness:s,porCommitment:f,witnessUtxo:b,bip32Derivation:v.makeConverter(n.InputTypes.BIP32_DERIVATION),redeemScript:m.makeConverter(n.InputTypes.REDEEM_SCRIPT),witnessScript:E.makeConverter(n.InputTypes.WITNESS_SCRIPT),checkPubkey:w.makeChecker([n.InputTypes.PARTIAL_SIG,n.InputTypes.BIP32_DERIVATION]),tapKeySig:h,tapScriptSig:y,tapLeafScript:p,tapBip32Derivation:S.makeConverter(n.InputTypes.TAP_BIP32_DERIVATION),tapInternalKey:_.makeConverter(n.InputTypes.TAP_INTERNAL_KEY),tapMerkleRoot:d};e.inputs=O;const T={bip32Derivation:v.makeConverter(n.OutputTypes.BIP32_DERIVATION),redeemScript:m.makeConverter(n.OutputTypes.REDEEM_SCRIPT),witnessScript:E.makeConverter(n.OutputTypes.WITNESS_SCRIPT),checkPubkey:w.makeChecker([n.OutputTypes.BIP32_DERIVATION]),tapBip32Derivation:S.makeConverter(n.OutputTypes.TAP_BIP32_DERIVATION),tapTree:g,tapInternalKey:_.makeConverter(n.OutputTypes.TAP_INTERNAL_KEY)};e.outputs=T},760:(t,e,r)=>{var n=r(287).hp;Object.defineProperty(e,"__esModule",{value:!0});const i=r(80);function o(t){return n.isBuffer(t)&&(64===t.length||65===t.length)}e.decode=function(t){if(t.key[0]!==i.InputTypes.TAP_KEY_SIG||1!==t.key.length)throw new Error("Decode Error: could not decode tapKeySig with key 0x"+t.key.toString("hex"));if(!o(t.value))throw new Error("Decode Error: tapKeySig not a valid 64-65-byte BIP340 signature");return t.value},e.encode=function(t){return{key:n.from([i.InputTypes.TAP_KEY_SIG]),value:t}},e.expected="Buffer",e.check=o,e.canAdd=function(t,e){return!!t&&!!e&&void 0===t.tapKeySig}},795:(t,e,r)=>{var n=r(287).hp;Object.defineProperty(e,"__esModule",{value:!0});const i=r(80);e.decode=function(t){if(t.key[0]!==i.InputTypes.FINAL_SCRIPTWITNESS)throw new Error("Decode Error: could not decode finalScriptWitness with key 0x"+t.key.toString("hex"));return t.value},e.encode=function(t){return{key:n.from([i.InputTypes.FINAL_SCRIPTWITNESS]),value:t}},e.expected="Buffer",e.check=function(t){return n.isBuffer(t)},e.canAdd=function(t,e){return!!t&&!!e&&void 0===t.finalScriptWitness}},834:(t,e,r)=>{var n=r(287).hp;Object.defineProperty(e,"__esModule",{value:!0});const i=r(80);e.decode=function(t){if(t.key[0]!==i.GlobalTypes.GLOBAL_XPUB)throw new Error("Decode Error: could not decode globalXpub with key 0x"+t.key.toString("hex"));if(79!==t.key.length||![2,3].includes(t.key[46]))throw new Error("Decode Error: globalXpub has invalid extended pubkey in key 0x"+t.key.toString("hex"));if(t.value.length/4%1!=0)throw new Error("Decode Error: Global GLOBAL_XPUB value length should be multiple of 4");const e=t.key.slice(1),r={masterFingerprint:t.value.slice(0,4),extendedPubkey:e,path:"m"};for(const e of(n=t.value.length/4-1,[...Array(n).keys()])){const n=t.value.readUInt32LE(4*e+4),i=!!(2147483648&n),o=2147483647&n;r.path+="/"+o.toString(10)+(i?"'":"")}var n;return r},e.encode=function(t){const e=n.from([i.GlobalTypes.GLOBAL_XPUB]),r=n.concat([e,t.extendedPubkey]),o=t.path.split("/"),a=n.allocUnsafe(4*o.length);t.masterFingerprint.copy(a,0);let s=4;return o.slice(1).forEach(t=>{const e="'"===t.slice(-1);let r=2147483647&parseInt(e?t.slice(0,-1):t,10);e&&(r+=2147483648),a.writeUInt32LE(r,s),s+=4}),{key:r,value:a}},e.expected="{ masterFingerprint: Buffer; extendedPubkey: Buffer; path: string; }",e.check=function(t){const e=t.extendedPubkey,r=t.masterFingerprint,i=t.path;return n.isBuffer(e)&&78===e.length&&[2,3].indexOf(e[45])>-1&&n.isBuffer(r)&&4===r.length&&"string"==typeof i&&!!i.match(/^m(\/\d+'?)*$/)},e.canAddToArray=function(t,e,r){const n=e.extendedPubkey.toString("hex");return!r.has(n)&&(r.add(n),0===t.filter(t=>t.extendedPubkey.equals(e.extendedPubkey)).length)}},851:(t,e,r)=>{var n=r(287).hp;Object.defineProperty(e,"__esModule",{value:!0});const i=r(80),o=r(394);e.decode=function(t){if(t.key[0]!==i.OutputTypes.TAP_TREE||1!==t.key.length)throw new Error("Decode Error: could not decode tapTree with key 0x"+t.key.toString("hex"));let e=0;const r=[];for(;e<t.value.length;){const n=t.value[e++],i=t.value[e++],a=o.decode(t.value,e);e+=o.encodingLength(a),r.push({depth:n,leafVersion:i,script:t.value.slice(e,e+a)}),e+=a}return{leaves:r}},e.encode=function(t){const e=n.from([i.OutputTypes.TAP_TREE]),r=[].concat(...t.leaves.map(t=>[n.of(t.depth,t.leafVersion),o.encode(t.script.length),t.script]));return{key:e,value:n.concat(r)}},e.expected="{ leaves: [{ depth: number; leafVersion: number, script: Buffer; }] }",e.check=function(t){return Array.isArray(t.leaves)&&t.leaves.every(t=>t.depth>=0&&t.depth<=128&&(254&t.leafVersion)===t.leafVersion&&n.isBuffer(t.script))},e.canAdd=function(t,e){return!!t&&!!e&&void 0===t.tapTree}},863:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0});const n=r(457);function i(t,e,r){return n=>{if(t.has(n))return;const i=r.filter(t=>t.key.toString("hex")===n)[0];e.push(i),t.add(n)}}function o(t){return t.globalMap.unsignedTx}function a(t){const e=new Set;return t.forEach(t=>{const r=t.key.toString("hex");if(e.has(r))throw new Error("Combine: KeyValue Map keys should be unique");e.add(r)}),e}e.combine=function(t){const e=t[0],r=n.psbtToKeyVals(e),s=t.slice(1);if(0===s.length)throw new Error("Combine: Nothing to combine");const u=o(e);if(void 0===u)throw new Error("Combine: Self missing transaction");const c=a(r.globalKeyVals),f=r.inputKeyVals.map(a),l=r.outputKeyVals.map(a);for(const t of s){const e=o(t);if(void 0===e||!e.toBuffer().equals(u.toBuffer()))throw new Error("Combine: One of the Psbts does not have the same transaction.");const s=n.psbtToKeyVals(t);a(s.globalKeyVals).forEach(i(c,r.globalKeyVals,s.globalKeyVals)),s.inputKeyVals.map(a).forEach((t,e)=>t.forEach(i(f[e],r.inputKeyVals[e],s.inputKeyVals[e]))),s.outputKeyVals.map(a).forEach((t,e)=>t.forEach(i(l[e],r.outputKeyVals[e],s.outputKeyVals[e])))}return n.psbtFromKeyVals(u,{globalMapKeyVals:r.globalKeyVals,inputKeyVals:r.inputKeyVals,outputKeyVals:r.outputKeyVals})}},907:(t,e,r)=>{var n=r(287).hp;Object.defineProperty(e,"__esModule",{value:!0});const i=r(80);e.decode=function(t){if(t.key[0]!==i.InputTypes.PARTIAL_SIG)throw new Error("Decode Error: could not decode partialSig with key 0x"+t.key.toString("hex"));if(34!==t.key.length&&66!==t.key.length||![2,3,4].includes(t.key[1]))throw new Error("Decode Error: partialSig has invalid pubkey in key 0x"+t.key.toString("hex"));return{pubkey:t.key.slice(1),signature:t.value}},e.encode=function(t){const e=n.from([i.InputTypes.PARTIAL_SIG]);return{key:n.concat([e,t.pubkey]),value:t.signature}},e.expected="{ pubkey: Buffer; signature: Buffer; }",e.check=function(t){return n.isBuffer(t.pubkey)&&n.isBuffer(t.signature)&&[33,65].includes(t.pubkey.length)&&[2,3,4].includes(t.pubkey[0])&&function(t){if(!n.isBuffer(t)||t.length<9)return!1;if(48!==t[0])return!1;if(t.length!==t[1]+3)return!1;if(2!==t[2])return!1;const e=t[3];if(e>33||e<1)return!1;if(2!==t[3+e+1])return!1;const r=t[3+e+2];return!(r>33||r<1)&&t.length===3+e+2+r+2}(t.signature)},e.canAddToArray=function(t,e,r){const n=e.pubkey.toString("hex");return!r.has(n)&&(r.add(n),0===t.filter(t=>t.pubkey.equals(e.pubkey)).length)}},926:(t,e,r)=>{var n=r(287).hp;Object.defineProperty(e,"__esModule",{value:!0});const i=r(80),o=r(133),a=r(394);e.decode=function(t){if(t.key[0]!==i.InputTypes.WITNESS_UTXO)throw new Error("Decode Error: could not decode witnessUtxo with key 0x"+t.key.toString("hex"));const e=o.readUInt64LE(t.value,0);let r=8;const n=a.decode(t.value,r);r+=a.encodingLength(n);const s=t.value.slice(r);if(s.length!==n)throw new Error("Decode Error: WITNESS_UTXO script is not proper length");return{script:s,value:e}},e.encode=function(t){const{script:e,value:r}=t,s=a.encodingLength(e.length),u=n.allocUnsafe(8+s+e.length);return o.writeUInt64LE(u,r,0),a.encode(e.length,u,8),e.copy(u,8+s),{key:n.from([i.InputTypes.WITNESS_UTXO]),value:u}},e.expected="{ script: Buffer; value: number; }",e.check=function(t){return n.isBuffer(t.script)&&"number"==typeof t.value},e.canAdd=function(t,e){return!!t&&!!e&&void 0===t.witnessUtxo}},949:(t,e,r)=>{var n=r(287).hp;Object.defineProperty(e,"__esModule",{value:!0});const i=r(80);e.decode=function(t){if(t.key[0]!==i.InputTypes.POR_COMMITMENT)throw new Error("Decode Error: could not decode porCommitment with key 0x"+t.key.toString("hex"));return t.value.toString("utf8")},e.encode=function(t){return{key:n.from([i.InputTypes.POR_COMMITMENT]),value:n.from(t,"utf8")}},e.expected="string",e.check=function(t){return"string"==typeof t},e.canAdd=function(t,e){return!!t&&!!e&&void 0===t.porCommitment}}},d={};function y(t){var e=d[t];if(void 0!==e)return e.exports;var r=d[t]={exports:{}};return p[t](r,r.exports,y),r.exports}y.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return y.d(e,{a:e}),e},y.d=(t,e)=>{for(var r in e)y.o(e,r)&&!y.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},y.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),y.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var b={};y.r(b),y.d(b,{bitcoin:()=>O,bitcoinCash:()=>R,bitcoinCashTestnet:()=>U,dash:()=>j,dashTestnet:()=>N,dogecoin:()=>I,dogecoinTestnet:()=>P,litecoin:()=>x,litecoinTestnet:()=>B,regtest:()=>T,testnet:()=>A});var g={};y.r(g),y.d(g,{decode:()=>pt,encode:()=>dt});var v={};y.r(v),y.d(v,{decode:()=>Gt,encode:()=>qt});var w={};y.r(w),y.d(w,{OPS:()=>it,compile:()=>re,countNonPushOnlyOPs:()=>Jt,decompile:()=>ne,fromASM:()=>oe,isCanonicalPubKey:()=>se,isCanonicalScriptSignature:()=>ce,isDefinedHashType:()=>ue,isPushOnly:()=>$t,number:()=>fe,signature:()=>le,toASM:()=>ie,toStack:()=>ae});var m={};y.r(m),y.d(m,{FUTURE_MAX_VERSION:()=>ge,FUTURE_OPNET_VERSION:()=>ve,FUTURE_SEGWIT_MAX_SIZE:()=>de,FUTURE_SEGWIT_MAX_VERSION:()=>be,FUTURE_SEGWIT_MIN_SIZE:()=>ye,FUTURE_SEGWIT_MIN_VERSION:()=>we,FUTURE_SEGWIT_VERSION_DIFF:()=>me,_toFutureSegwitAddress:()=>ke,fromBase58Check:()=>Oe,fromBech32:()=>Te,fromOutputScript:()=>Pe,isUnknownSegwitVersion:()=>_e,toBase58Check:()=>Ae,toBech32:()=>Ie,toFutureOPNetAddress:()=>Ee,toOutputScript:()=>xe});var S={};y.r(S),y.d(S,{TAGGED_HASH_PREFIXES:()=>ir,TAGS:()=>nr,hash160:()=>er,hash256:()=>rr,ripemd160:()=>Je,sha1:()=>Qe,sha256:()=>tr,taggedHash:()=>or});var _={};y.r(_),y.d(_,{decode:()=>gr,encode:()=>br,encodingLength:()=>vr});var E={};y.r(E),y.d(E,{Transaction:()=>hi});var k={};y.r(k),y.d(k,{LEAF_VERSION_TAPSCRIPT:()=>Ur,MAX_TAPTREE_DEPTH:()=>jr,PaymentType:()=>Yi,findScriptPath:()=>Fr,p2data:()=>qr,p2ms:()=>Xr,p2op:()=>Ui,p2pk:()=>$r,p2pkh:()=>Qi,p2sh:()=>Dn,p2tr:()=>Vn,p2wpkh:()=>zn,p2wsh:()=>Jn,prop:()=>Vr,rootHashFromPath:()=>Lr,tapTweakHash:()=>Hr,tapleafHash:()=>Dr,toHashTree:()=>Cr,tweakKey:()=>Mr,value:()=>Wr});var O={messagePrefix:"Bitcoin Signed Message:\n",bech32:"bc",bech32Opnet:"op",bip32:{public:76067358,private:76066276},pubKeyHash:0,scriptHash:5,wif:128},T={messagePrefix:"Bitcoin Signed Message:\n",bech32:"bcrt",bech32Opnet:"opr",bip32:{public:70617039,private:70615956},pubKeyHash:111,scriptHash:196,wif:239},A={messagePrefix:"Bitcoin Signed Message:\n",bech32:"tb",bech32Opnet:"opt",bip32:{public:70617039,private:70615956},pubKeyHash:111,scriptHash:196,wif:239},I={messagePrefix:"Dogecoin Signed Message:\n",bech32:"",bech32Opnet:"",bip32:{public:49990397,private:49988504},pubKeyHash:30,scriptHash:22,wif:158},P={messagePrefix:"Dogecoin Signed Message:\n",bech32:"",bech32Opnet:"",bip32:{public:70429096,private:70427203},pubKeyHash:113,scriptHash:196,wif:241},x={messagePrefix:"Litecoin Signed Message:\n",bech32:"ltc",bech32Opnet:"opl",bip32:{public:27108450,private:27106558},pubKeyHash:48,scriptHash:50,wif:176},B={messagePrefix:"Litecoin Signed Message:\n",bech32:"tltc",bech32Opnet:"oplt",bip32:{public:70709117,private:70711009},pubKeyHash:111,scriptHash:58,wif:239},R={messagePrefix:"Bitcoin Signed Message:\n",bech32:"bitcoincash",bech32Opnet:"opbch",bip32:{public:76067358,private:76066276},pubKeyHash:0,scriptHash:5,wif:128},U={messagePrefix:"Bitcoin Signed Message:\n",bech32:"bchtest",bech32Opnet:"opbcht",bip32:{public:70617039,private:70615956},pubKeyHash:111,scriptHash:196,wif:239},j={messagePrefix:"DarkCoin Signed Message:\n",bech32:"",bech32Opnet:"",bip32:{public:50221772,private:50221816},pubKeyHash:76,scriptHash:16,wif:204},N={messagePrefix:"DarkCoin Signed Message:\n",bech32:"",bech32Opnet:"",bip32:{public:981492128,private:981489719},pubKeyHash:140,scriptHash:19,wif:239},L=y(343);function C(t,...e){if(!((r=t)instanceof Uint8Array||ArrayBuffer.isView(r)&&"Uint8Array"===r.constructor.name))throw new Error("Uint8Array expected");var r;if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function F(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function D(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}function H(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function M(t,e){return t<<32-e|t>>>e}function K(t,e){return t<<e|t>>>32-e>>>0}function V(t){return"string"==typeof t&&(t=function(t){if("string"!=typeof t)throw new Error("string expected");return new Uint8Array((new TextEncoder).encode(t))}(t)),C(t),t}class W{}function G(t){const e=e=>t().update(V(e)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function q(t,e,r){return t&e^~t&r}function z(t,e,r){return t&e^t&r^e&r}class Z extends W{constructor(t,e,r,n){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=t,this.outputLen=e,this.padOffset=r,this.isLE=n,this.buffer=new Uint8Array(t),this.view=H(this.buffer)}update(t){F(this),C(t=V(t));const{view:e,buffer:r,blockLen:n}=this,i=t.length;for(let o=0;o<i;){const a=Math.min(n-this.pos,i-o);if(a!==n)r.set(t.subarray(o,o+a),this.pos),this.pos+=a,o+=a,this.pos===n&&(this.process(e,0),this.pos=0);else{const e=H(t);for(;n<=i-o;o+=n)this.process(e,o)}}return this.length+=t.length,this.roundClean(),this}digestInto(t){F(this),function(t,e){C(t);const r=e.outputLen;if(t.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}(t,this),this.finished=!0;const{buffer:e,view:r,blockLen:n,isLE:i}=this;let{pos:o}=this;e[o++]=128,D(this.buffer.subarray(o)),this.padOffset>n-o&&(this.process(r,0),o=0);for(let t=o;t<n;t++)e[t]=0;!function(t,e,r,n){if("function"==typeof t.setBigUint64)return t.setBigUint64(e,r,n);const i=BigInt(32),o=BigInt(4294967295),a=Number(r>>i&o),s=Number(r&o),u=n?4:0,c=n?0:4;t.setUint32(e+u,a,n),t.setUint32(e+c,s,n)}(r,n-8,BigInt(8*this.length),i),this.process(r,0);const a=H(t),s=this.outputLen;if(s%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const u=s/4,c=this.get();if(u>c.length)throw new Error("_sha2: outputLen bigger than state");for(let t=0;t<u;t++)a.setUint32(4*t,c[t],i)}digest(){const{buffer:t,outputLen:e}=this;this.digestInto(t);const r=t.slice(0,e);return this.destroy(),r}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:e,buffer:r,length:n,finished:i,destroyed:o,pos:a}=this;return t.destroyed=o,t.finished=i,t.length=n,t.pos=a,n%e&&t.buffer.set(r),t}clone(){return this._cloneInto()}}const X=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Y=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]),$=new Uint32Array(64);class J extends Z{constructor(t=32){super(64,t,8,!1),this.A=0|X[0],this.B=0|X[1],this.C=0|X[2],this.D=0|X[3],this.E=0|X[4],this.F=0|X[5],this.G=0|X[6],this.H=0|X[7]}get(){const{A:t,B:e,C:r,D:n,E:i,F:o,G:a,H:s}=this;return[t,e,r,n,i,o,a,s]}set(t,e,r,n,i,o,a,s){this.A=0|t,this.B=0|e,this.C=0|r,this.D=0|n,this.E=0|i,this.F=0|o,this.G=0|a,this.H=0|s}process(t,e){for(let r=0;r<16;r++,e+=4)$[r]=t.getUint32(e,!1);for(let t=16;t<64;t++){const e=$[t-15],r=$[t-2],n=M(e,7)^M(e,18)^e>>>3,i=M(r,17)^M(r,19)^r>>>10;$[t]=i+$[t-7]+n+$[t-16]|0}let{A:r,B:n,C:i,D:o,E:a,F:s,G:u,H:c}=this;for(let t=0;t<64;t++){const e=c+(M(a,6)^M(a,11)^M(a,25))+q(a,s,u)+Y[t]+$[t]|0,f=(M(r,2)^M(r,13)^M(r,22))+z(r,n,i)|0;c=u,u=s,s=a,a=o+e|0,o=i,i=n,n=r,r=e+f|0}r=r+this.A|0,n=n+this.B|0,i=i+this.C|0,o=o+this.D|0,a=a+this.E|0,s=s+this.F|0,u=u+this.G|0,c=c+this.H|0,this.set(r,n,i,o,a,s,u,c)}roundClean(){D($)}destroy(){this.set(0,0,0,0,0,0,0,0),D(this.buffer)}}const Q=G(()=>new J),tt=function(t){const e=new Uint8Array(256);for(let t=0;t<e.length;t++)e[t]=255;for(let r=0;r<58;r++){const n=t.charAt(r),i=n.charCodeAt(0);if(255!==e[i])throw new TypeError(n+" is ambiguous");e[i]=r}const r=t.charAt(0),n=Math.log(58)/Math.log(256),i=Math.log(256)/Math.log(58);function o(t){if("string"!=typeof t)throw new TypeError("Expected String");if(0===t.length)return new Uint8Array;let i=0,o=0,a=0;for(;t[i]===r;)o++,i++;const s=(t.length-i)*n+1>>>0,u=new Uint8Array(s);for(;t[i];){let r=e[t.charCodeAt(i)];if(255===r)return;let n=0;for(let t=s-1;(0!==r||n<a)&&-1!==t;t--,n++)r+=58*u[t]>>>0,u[t]=r%256>>>0,r=r/256>>>0;if(0!==r)throw new Error("Non-zero carry");a=n,i++}let c=s-a;for(;c!==s&&0===u[c];)c++;const f=new Uint8Array(o+(s-c));let l=o;for(;c!==s;)f[l++]=u[c++];return f}return{encode:function(e){if(e instanceof Uint8Array||(ArrayBuffer.isView(e)?e=new Uint8Array(e.buffer,e.byteOffset,e.byteLength):Array.isArray(e)&&(e=Uint8Array.from(e))),!(e instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===e.length)return"";let n=0,o=0,a=0;const s=e.length;for(;a!==s&&0===e[a];)a++,n++;const u=(s-a)*i+1>>>0,c=new Uint8Array(u);for(;a!==s;){let t=e[a],r=0;for(let e=u-1;(0!==t||r<o)&&-1!==e;e--,r++)t+=256*c[e]>>>0,c[e]=t%58>>>0,t=t/58>>>0;if(0!==t)throw new Error("Non-zero carry");o=r,a++}let f=u-o;for(;f!==u&&0===c[f];)f++;let l=r.repeat(n);for(;f<u;++f)l+=t.charAt(c[f]);return l},decodeUnsafe:o,decode:function(t){const e=o(t);if(e)return e;throw new Error("Non-base58 character")}}}("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),et=function(t){function e(e){var r=e.slice(0,-4),n=e.slice(-4),i=t(r);if(!(n[0]^i[0]|n[1]^i[1]|n[2]^i[2]|n[3]^i[3]))return r}return{encode:function(e){var r=Uint8Array.from(e),n=t(r),i=r.length+4,o=new Uint8Array(i);return o.set(r,0),o.set(n.subarray(0,4),r.length),tt.encode(o)},decode:function(t){var r=e(tt.decode(t));if(null==r)throw new Error("Invalid checksum");return r},decodeUnsafe:function(t){var r=tt.decodeUnsafe(t);if(null!=r)return e(r)}}}(function(t){return Q(Q(t))});var rt=y(287).hp;function nt(t,e){var r=t.length,n=e.length;if(0===r)throw new Error("R length is zero");if(0===n)throw new Error("S length is zero");if(r>33)throw new Error("R length is too long");if(n>33)throw new Error("S length is too long");if(128&t[0])throw new Error("R value is negative");if(128&e[0])throw new Error("S value is negative");if(r>1&&0===t[0]&&!(128&t[1]))throw new Error("R value excessively padded");if(n>1&&0===e[0]&&!(128&e[1]))throw new Error("S value excessively padded");var i=rt.allocUnsafe(6+r+n);return i[0]=48,i[1]=i.length-2,i[2]=2,i[3]=t.length,t.copy(i,4),i[4+r]=2,i[5+r]=e.length,e.copy(i,6+r),i}for(var it={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_SUBSTR:127,OP_LEFT:128,OP_RIGHT: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_NOP1:176,OP_NOP2:177,OP_CHECKLOCKTIMEVERIFY:177,OP_NOP3:178,OP_CHECKSEQUENCEVERIFY:178,OP_NOP4:179,OP_NOP5:180,OP_NOP6:181,OP_NOP7:182,OP_NOP8:183,OP_NOP9:184,OP_NOP10:185,OP_CHECKSIGADD:186,OP_PUBKEYHASH:253,OP_PUBKEY:254,OP_INVALIDOPCODE:255},ot={},at=0,st=Object.keys(it);at<st.length;at++){var ut=st[at],ct=it[ut];ot[ct]=ut}function ft(t){return t<it.OP_PUSHDATA1?1:t<=255?2:t<=65535?3:5}function lt(t,e){var r,n,i=t.readUInt8(e);if(i<it.OP_PUSHDATA1)r=i,n=1;else if(i===it.OP_PUSHDATA1){if(e+2>t.length)return null;r=t.readUInt8(e+1),n=2}else if(i===it.OP_PUSHDATA2){if(e+3>t.length)return null;r=t.readUInt16LE(e+1),n=3}else{if(e+5>t.length)return null;if(i!==it.OP_PUSHDATA4)throw new Error("Unexpected opcode");r=t.readUInt32LE(e+1),n=5}return{opcode:i,number:r,size:n}}var ht=y(287).hp;function pt(t,e,r){e=e||4,r=void 0===r||r;var n=t.length;if(0===n)return 0;if(n>e)throw new TypeError("Script number overflow");if(r&&!(127&t[n-1]||!(n<=1)&&128&t[n-2]))throw new Error("Non-minimally encoded script number");if(5===n){var i=t.readUInt32LE(0),o=t.readUInt8(4);return 128&o?-(4294967296*(-129&o)+i):4294967296*o+i}for(var a=0,s=0;s<n;++s)a|=t[s]<<8*s;return 128&t[n-1]?-(a&~(128<<8*(n-1))):a}function dt(t){for(var e=Math.abs(t),r=function(t){return t>2147483647?5:t>8388607?4:t>32767?3:t>127?2:t>0?1:0}(e),n=ht.allocUnsafe(r),i=t<0,o=0;o<r;++o)n.writeUInt8(255&e,o),e>>=8;return 128&n[r-1]?n.writeUInt8(i?128:0,r-1):i&&(n[r-1]|=128),n}var yt=y(287),bt=y(676),gt=y.n(bt)(),vt=yt.hp.alloc(32,0),wt=yt.hp.from("fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f","hex");function mt(t,e){return t.length===e.length&&t.every(function(t,r){return t.equals(e[r])})}function St(t){if(!yt.hp.isBuffer(t))return!1;if(t.length<33)return!1;var e=t[0],r=t.slice(1,33);if(0===r.compare(vt))return!1;if(r.compare(wt)>=0)return!1;if((2===e||3===e)&&33===t.length)return!0;if(65!==t.length)return!1;var n=t.slice(33);return!(0===n.compare(vt)||n.compare(wt)>=0||4!==e&&6!==e&&7!==e)}function _t(t){return gt.UInt53(t)&&t<=21e14}var Et=254;function kt(t){return!(!t||!("output"in t)||!yt.hp.isBuffer(t.output)||void 0!==t.version&&(t.version&Et)!==t.version)}function Ot(t){return Pt(t)?2===t.length&&t.every(function(t){return Ot(t)}):kt(t)}gt.BufferN(32);var Tt=gt.BufferN(20),At=gt.BufferN(32),It=gt.Number,Pt=gt.Array,xt=(gt.Boolean,gt.String),Bt=gt.Buffer,Rt=gt.Hex,Ut=gt.maybe,jt=gt.tuple,Nt=gt.UInt8,Lt=gt.UInt32,Ct=gt.Function,Ft=gt.BufferN,Dt=gt.Null,Ht=(gt.oneOf,y(287).hp),Mt=gt,Kt=Ht.alloc(1,0);function Vt(t){for(var e=0;0===t[e];)++e;return e===t.length?Kt:128&(t=t.slice(e))[0]?Ht.concat([Kt,t],1+t.length):t}function Wt(t){0===t[0]&&(t=t.slice(1));var e=Ht.alloc(32,0),r=Math.max(0,32-t.length);return t.copy(e,r),e}function Gt(t){var e=t.readUInt8(t.length-1);if(!ue(e))throw new Error("Invalid hashType "+e);var r=function(t){if(t.length<8)throw new Error("DER sequence length is too short");if(t.length>72)throw new Error("DER sequence length is too long");if(48!==t[0])throw new Error("Expected DER sequence");if(t[1]!==t.length-2)throw new Error("DER sequence length is invalid");if(2!==t[2])throw new Error("Expected DER integer");var e=t[3];if(0===e)throw new Error("R length is zero");if(5+e>=t.length)throw new Error("R length is too long");if(2!==t[4+e])throw new Error("Expected DER integer (2)");var r=t[5+e];if(0===r)throw new Error("S length is zero");if(6+e+r!==t.length)throw new Error("S length is invalid");if(128&t[4])throw new Error("R value is negative");if(e>1&&0===t[4]&&!(128&t[5]))throw new Error("R value excessively padded");if(128&t[e+6])throw new Error("S value is negative");if(r>1&&0===t[e+6]&&!(128&t[e+7]))throw new Error("S value excessively padded");return{r:t.slice(4,4+e),s:t.slice(6+e)}}(t.slice(0,-1)),n=Wt(r.r),i=Wt(r.s);return{signature:Ht.concat([n,i],64),hashType:e}}function qt(t,e){if(Mt({signature:Ft(64),hashType:Nt},{signature:t,hashType:e}),!ue(e))throw new Error("Invalid hashType "+e);var r=Ht.allocUnsafe(1);r.writeUInt8(e,0);var n=Vt(t.slice(0,32)),i=Vt(t.slice(32,64));return Ht.concat([nt(n,i),r])}var zt=y(287).hp,Zt=gt,Xt=it.OP_RESERVED;function Yt(t){return Bt(t)||function(t){return It(t)&&(t===it.OP_0||t>=it.OP_1&&t<=it.OP_16||t===it.OP_1NEGATE)}(t)}function $t(t){return Pt(t)&&t.every(Yt)}function Jt(t){return t.length-t.filter(Yt).length}function Qt(t){return 0===t.length?it.OP_0:1===t.length?t[0]>=1&&t[0]<=16?Xt+t[0]:129===t[0]?it.OP_1NEGATE:void 0:void 0}function te(t){return zt.isBuffer(t)}function ee(t){return zt.isBuffer(t)}function re(t){if(te(t))return t;Zt(Pt,t);var e=t.reduce(function(t,e){return ee(e)?1===e.length&&void 0!==Qt(e)?t+1:t+ft(e.length)+e.length:t+1},0),r=zt.allocUnsafe(e),n=0;if(t.forEach(function(t){if(ee(t)){var e=Qt(t);if(void 0!==e)return r.writeUInt8(e,n),void(n+=1);n+=function(t,e,r){var n=ft(e);return 1===n?t.writeUInt8(e,r):2===n?(t.writeUInt8(it.OP_PUSHDATA1,r),t.writeUInt8(e,r+1)):3===n?(t.writeUInt8(it.OP_PUSHDATA2,r),t.writeUInt16LE(e,r+1)):(t.writeUInt8(it.OP_PUSHDATA4,r),t.writeUInt32LE(e,r+1)),n}(r,t.length,n),t.copy(r,n),n+=t.length}else r.writeUInt8(t,n),n+=1}),n!==r.length)throw new Error("Could not decode chunks");return r}function ne(t){if(Pt(t))return t;Zt(Bt,t);for(var e=[],r=0;r<t.length;){var n=t[r];if(n>it.OP_0&&n<=it.OP_PUSHDATA4){var i=lt(t,r);if(null===i)return null;if((r+=i.size)+i.number>t.length)return null;var o=t.slice(r,r+i.number);r+=i.number;var a=Qt(o);void 0!==a?e.push(a):e.push(o)}else e.push(n),r+=1}return e}function ie(t){if(te(t)&&(t=ne(t)),!t)throw new Error("Could not convert invalid chunks to ASM");return t.map(function(t){if(ee(t)){var e=Qt(t);if(void 0===e)return t.toString("hex");t=e}return ot[t]}).join(" ")}function oe(t){return Zt(xt,t),re(t.split(" ").map(function(t){return void 0!==it[t]?it[t]:(Zt(Rt,t),zt.from(t,"hex"))}))}function ae(t){return t=ne(t),Zt($t,t),t.map(function(t){return ee(t)?t:t===it.OP_0?zt.allocUnsafe(0):dt(t-Xt)})}function se(t){return St(t)}function ue(t){var e=-129&t;return e>0&&e<4}function ce(t){return!!zt.isBuffer(t)&&!!ue(t[t.length-1])&&function(t){if(t.length<8)return!1;if(t.length>72)return!1;if(48!==t[0])return!1;if(t[1]!==t.length-2)return!1;if(2!==t[2])return!1;var e=t[3];if(0===e)return!1;if(5+e>=t.length)return!1;if(2!==t[4+e])return!1;var r=t[5+e];return!(0===r||6+e+r!==t.length||128&t[4]||e>1&&0===t[4]&&!(128&t[5])||128&t[e+6]||r>1&&0===t[e+6]&&!(128&t[e+7]))}(t.slice(0,-1))}var fe=g,le=v,he=y(287).hp;function pe(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}var de=40,ye=2,be=15,ge=16,ve=16,we=2,me=80,Se="WARNING: Sending to a future segwit version address can lead to loss of funds. End users MUST be warned carefully in the GUI and asked if they wish to proceed with caution. Wallets should verify the segwit version from the output of fromBech32, then decide when it is safe to use which version of segwit.",_e=function(t){try{var e=t.subarray(2);if(e.length<ye||e.length>de)throw new TypeError("Invalid program length for segwit address");var r=t[0]-me;if(r<we||r>be+1)throw new TypeError("Invalid version for segwit address");if(1===r)throw new TypeError("taproot");return!0}catch(t){}return!1};function Ee(t,e){if(!he.isBuffer(t))throw new TypeError("output must be a Buffer");if(!e.bech32Opnet)throw new Error("Network does not support opnet");var r,n=t[0],i=1;if(t[1]<76)r=t[1],i=2;else{if(76!==t[1])throw new TypeError("Unsupported push opcode in script");r=t[2],i=3}var o=t.subarray(i,i+r);if(o.length<ye||o.length>de)throw new TypeError("Invalid program length for segwit address");var a=n===it.OP_0?0:n>=it.OP_1&&n<=it.OP_16?n-(it.OP_1-1):-1;if(a<be||a>ge)throw new TypeError("Invalid segwit version ".concat(a));var s,u=[a].concat(function(t){if(Array.isArray(t))return pe(t)}(s=L.p2.toWords(o))||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(s)||function(t,e){if(t){if("string"==typeof t)return pe(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?pe(t,e):void 0}}(s)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}());return L.p2.encode(e.bech32Opnet,u)}function ke(t,e){var r=t.subarray(2);if(r.length<ye||r.length>de)throw new TypeError("Invalid program length for segwit address");var n=t[0]-me;if(n<we||n>be)throw new TypeError("Invalid version for segwit address");if(t[1]!==r.length)throw new TypeError("Invalid script for segwit address ".concat(t[1]," !== ").concat(r.length));return Ie(r,n,e.bech32,e.bech32Opnet)}function Oe(t){var e=he.from(et.decode(t));if(e.length<21)throw new TypeError(t+" is too short");if(e.length>21)throw new TypeError(t+" is too long");return{version:e.readUInt8(0),hash:e.subarray(1)}}function Te(t){var e,r;try{e=L.I.decode(t)}catch(t){}if(e){if(0!==(r=e.words[0]))throw new TypeError(t+" uses wrong encoding")}else if(0===(r=(e=L.p2.decode(t)).words[0]))throw new TypeError(t+" uses wrong encoding");var n=L.I.fromWords(e.words.slice(1));return{version:r,prefix:e.prefix,data:he.from(n)}}function Ae(t,e){gt(jt(Tt,Nt),arguments);var r=he.allocUnsafe(21);return r.writeUInt8(e,0),t.copy(r,1),et.encode(r)}function Ie(t,e,r,n){var i=L.I.toWords(t);return i.unshift(e),e===ve&&n?L.p2.encode(n,i):0===e?L.I.encode(r,i):L.p2.encode(r,i)}function Pe(t,e){e=e||O;try{return Qi({output:t,network:e}).address}catch(t){}try{return Dn({output:t,network:e}).address}catch(t){}try{return zn({output:t,network:e}).address}catch(t){}try{return Jn({output:t,network:e}).address}catch(t){}try{return Vn({output:t,network:e}).address}catch(t){}try{return Ee(t,e)}catch(t){}try{return ke(t,e)}catch(t){}throw new Error(ie(t)+" has no matching Address")}function xe(t,e){var r,n;e=e||O;try{r=Oe(t)}catch(t){}if(r){if(r.version===e.pubKeyHash)return Qi({hash:r.hash}).output;if(r.version===e.scriptHash)return Dn({hash:r.hash}).output}else{try{n=Te(t)}catch(t){}if(n){if(n.prefix!==e.bech32&&e.bech32Opnet&&n.prefix!==e.bech32Opnet)throw new Error(t+" has an invalid prefix");if(0===n.version){if(20===n.data.length)return zn({hash:n.data}).output;if(32===n.data.length)return Jn({hash:n.data}).output}else if(1===n.version){if(32===n.data.length)return Vn({pubkey:n.data}).output}else{if(n.version===ve){if(!e.bech32Opnet)throw new Error(t+" has an invalid prefix");return Ui({program:n.data,network:e}).output}if(n.version>=we&&n.version<=be&&n.data.length>=ye&&n.data.length<=de)return n.version!==ve&&console.warn(Se),re([n.version+me,n.data])}}}return he.from(t,"hex")}const Be=Uint32Array.from([1732584193,4023233417,2562383102,271733878,3285377520]),Re=new Uint32Array(80);class Ue extends Z{constructor(){super(64,20,8,!1),this.A=0|Be[0],this.B=0|Be[1],this.C=0|Be[2],this.D=0|Be[3],this.E=0|Be[4]}get(){const{A:t,B:e,C:r,D:n,E:i}=this;return[t,e,r,n,i]}set(t,e,r,n,i){this.A=0|t,this.B=0|e,this.C=0|r,this.D=0|n,this.E=0|i}process(t,e){for(let r=0;r<16;r++,e+=4)Re[r]=t.getUint32(e,!1);for(let t=16;t<80;t++)Re[t]=K(Re[t-3]^Re[t-8]^Re[t-14]^Re[t-16],1);let{A:r,B:n,C:i,D:o,E:a}=this;for(let t=0;t<80;t++){let e,s;t<20?(e=q(n,i,o),s=1518500249):t<40?(e=n^i^o,s=1859775393):t<60?(e=z(n,i,o),s=2400959708):(e=n^i^o,s=3395469782);const u=K(r,5)+e+a+s+Re[t]|0;a=o,o=i,i=K(n,30),n=r,r=u}r=r+this.A|0,n=n+this.B|0,i=i+this.C|0,o=o+this.D|0,a=a+this.E|0,this.set(r,n,i,o,a)}roundClean(){D(Re)}destroy(){this.set(0,0,0,0,0),D(this.buffer)}}const je=G(()=>new Ue),Ne=Uint8Array.from([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),Le=Uint8Array.from(new Array(16).fill(0).map((t,e)=>e)),Ce=Le.map(t=>(9*t+5)%16),Fe=(()=>{const t=[[Le],[Ce]];for(let e=0;e<4;e++)for(let r of t)r.push(r[e].map(t=>Ne[t]));return t})(),De=Fe[0],He=Fe[1],Me=[[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8],[12,13,11,15,6,9,9,7,12,15,11,13,7,8,7,7],[13,15,14,11,7,7,6,8,13,14,13,12,5,5,6,9],[14,11,12,14,8,6,5,5,15,12,15,14,9,9,8,6],[15,12,13,13,9,5,8,6,14,11,12,11,8,6,5,5]].map(t=>Uint8Array.from(t)),Ke=De.map((t,e)=>t.map(t=>Me[e][t])),Ve=He.map((t,e)=>t.map(t=>Me[e][t])),We=Uint32Array.from([0,1518500249,1859775393,2400959708,2840853838]),Ge=Uint32Array.from([1352829926,1548603684,1836072691,2053994217,0]);function qe(t,e,r,n){return 0===t?e^r^n:1===t?e&r|~e&n:2===t?(e|~r)^n:3===t?e&n|r&~n:e^(r|~n)}const ze=new Uint32Array(16);class Ze extends Z{constructor(){super(64,20,8,!0),this.h0=1732584193,this.h1=-271733879,this.h2=-1732584194,this.h3=271733878,this.h4=-1009589776}get(){const{h0:t,h1:e,h2:r,h3:n,h4:i}=this;return[t,e,r,n,i]}set(t,e,r,n,i){this.h0=0|t,this.h1=0|e,this.h2=0|r,this.h3=0|n,this.h4=0|i}process(t,e){for(let r=0;r<16;r++,e+=4)ze[r]=t.getUint32(e,!0);let r=0|this.h0,n=r,i=0|this.h1,o=i,a=0|this.h2,s=a,u=0|this.h3,c=u,f=0|this.h4,l=f;for(let t=0;t<5;t++){const e=4-t,h=We[t],p=Ge[t],d=De[t],y=He[t],b=Ke[t],g=Ve[t];for(let e=0;e<16;e++){const n=K(r+qe(t,i,a,u)+ze[d[e]]+h,b[e])+f|0;r=f,f=u,u=0|K(a,10),a=i,i=n}for(let t=0;t<16;t++){const r=K(n+qe(e,o,s,c)+ze[y[t]]+p,g[t])+l|0;n=l,l=c,c=0|K(s,10),s=o,o=r}}this.set(this.h1+a+c|0,this.h2+u+l|0,this.h3+f+n|0,this.h4+r+o|0,this.h0+i+s|0)}roundClean(){D(ze)}destroy(){this.destroyed=!0,D(this.buffer),this.set(0,0,0,0,0)}}const Xe=G(()=>new Ze),Ye=je;var $e=y(287).hp;function Je(t){return $e.from(Xe(Uint8Array.from(t)))}function Qe(t){return $e.from(Ye(Uint8Array.from(t)))}function tr(t){return $e.from(Q(Uint8Array.from(t)))}function er(t){return $e.from(Xe(Q(Uint8Array.from(t))))}function rr(t){return $e.from(Q(Q(Uint8Array.from(t))))}var nr=["BIP0340/challenge","BIP0340/aux","BIP0340/nonce","TapLeaf","TapBranch","TapSighash","TapTweak","KeyAgg list","KeyAgg coefficient"],ir={"BIP0340/challenge":$e.from([123,181,45,122,159,239,88,50,62,177,191,122,64,125,179,130,210,243,242,216,27,177,34,79,73,254,81,143,109,72,211,124,123,181,45,122,159,239,88,50,62,177,191,122,64,125,179,130,210,243,242,216,27,177,34,79,73,254,81,143,109,72,211,124]),"BIP0340/aux":$e.from([241,239,78,94,192,99,202,218,109,148,202,250,157,152,126,160,105,38,88,57,236,193,31,151,45,119,165,46,216,193,204,144,241,239,78,94,192,99,202,218,109,148,202,250,157,152,126,160,105,38,88,57,236,193,31,151,45,119,165,46,216,193,204,144]),"BIP0340/nonce":$e.from([7,73,119,52,167,155,203,53,91,155,140,125,3,79,18,28,244,52,215,62,247,45,218,25,135,0,97,251,82,191,235,47,7,73,119,52,167,155,203,53,91,155,140,125,3,79,18,28,244,52,215,62,247,45,218,25,135,0,97,251,82,191,235,47]),TapLeaf:$e.from([174,234,143,220,66,8,152,49,5,115,75,88,8,29,30,38,56,211,95,28,181,64,8,212,211,87,202,3,190,120,233,238,174,234,143,220,66,8,152,49,5,115,75,88,8,29,30,38,56,211,95,28,181,64,8,212,211,87,202,3,190,120,233,238]),TapBranch:$e.from([25,65,161,242,229,110,185,95,162,169,241,148,190,92,1,247,33,111,51,237,130,176,145,70,52,144,208,91,245,22,160,21,25,65,161,242,229,110,185,95,162,169,241,148,190,92,1,247,33,111,51,237,130,176,145,70,52,144,208,91,245,22,160,21]),TapSighash:$e.from([244,10,72,223,75,42,112,200,180,146,75,242,101,70,97,237,61,149,253,102,163,19,235,135,35,117,151,198,40,228,160,49,244,10,72,223,75,42,112,200,180,146,75,242,101,70,97,237,61,149,253,102,163,19,235,135,35,117,151,198,40,228,160,49]),TapTweak:$e.from([232,15,225,99,156,156,160,80,227,175,27,57,193,67,198,62,66,156,188,235,21,217,64,251,181,197,161,244,175,87,197,233,232,15,225,99,156,156,160,80,227,175,27,57,193,67,198,62,66,156,188,235,21,217,64,251,181,197,161,244,175,87,197,233]),"KeyAgg list":$e.from([72,28,151,28,60,11,70,215,240,178,117,174,89,141,78,44,126,215,49,156,89,74,92,110,199,158,160,212,153,2,148,240,72,28,151,28,60,11,70,215,240,178,117,174,89,141,78,44,126,215,49,156,89,74,92,110,199,158,160,212,153,2,148,240]),"KeyAgg coefficient":$e.from([191,201,4,3,77,28,136,232,200,14,34,229,61,36,86,109,100,130,78,214,66,114,129,192,145,0,249,77,205,82,201,129,191,201,4,3,77,28,136,232,200,14,34,229,61,36,86,109,100,130,78,214,66,114,129,192,145,0,249,77,205,82,201,129])};function or(t,e){return tr($e.concat([ir[t],e]))}var ar=y(287).hp,sr={};function ur(t){var e;t?t!==sr.eccLib&&(lr("function"==typeof(e=t).isXOnlyPoint),lr(e.isXOnlyPoint(fr("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),lr(e.isXOnlyPoint(fr("fffffffffffffffffffffffffffffffffffffffffffffffffffffffeeffffc2e"))),lr(e.isXOnlyPoint(fr("f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9"))),lr(e.isXOnlyPoint(fr("0000000000000000000000000000000000000000000000000000000000000001"))),lr(!e.isXOnlyPoint(fr("0000000000000000000000000000000000000000000000000000000000000000"))),lr(!e.isXOnlyPoint(fr("fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"))),lr("function"==typeof e.xOnlyPointAddTweak),hr.forEach(function(t){var r=e.xOnlyPointAddTweak(fr(t.pubkey),fr(t.tweak));null===t.result?lr(null===r):(lr(null!==r),lr(r.parity===t.parity),lr(ar.from(r.xOnlyPubkey).equals(fr(t.result))))}),sr.eccLib=t):sr.eccLib=t}function cr(){if(!sr.eccLib)throw new Error("No ECC Library provided. You must call initEccLib() with a valid TinySecp256k1Interface instance");return sr.eccLib}var fr=function(t){return ar.from(t,"hex")};function lr(t){if(!t)throw new Error("ecc library invalid")}var hr=[{pubkey:"79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798",tweak:"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140",parity:-1,result:null},{pubkey:"1617d38ed8d8657da4d4761e8057bc396ea9e4b9d29776d4be096016dbd2509b",tweak:"a8397a935f0dfceba6ba9618f6451ef4d80637abf4e6af2669fbc9de6a8fd2ac",parity:1,result:"e478f99dab91052ab39a33ea35fd5e6e4933f4d28023cd597c9a1f6760346adf"},{pubkey:"2c0b7cf95324a07d05398b240174dc0c2be444d96b159aa6c7f7b1e668680991",tweak:"823c3cd2142744b075a87eade7e1b8678ba308d566226a0056ca2b7a76f86b47",parity:0,result:"9534f8dc8c6deda2dc007655981c78b49c5d96c778fbf363462a11ec9dfd948c"}];const pr="0123456789abcdefABCDEF";pr.split("").map(t=>t.codePointAt(0)),Array(256).fill(!0).map((t,e)=>{const r=String.fromCodePoint(e),n=pr.indexOf(r);return n<0?void 0:n<16?n:n-6}),new TextEncoder,new TextDecoder;const dr=t=>{if(t<0||t>0xffffffffffffffffn)throw new RangeError("value out of range")};function yr(t){"number"==typeof t?function(t){if(t<0||t>Number.MAX_SAFE_INTEGER||t%1!=0)throw new RangeError("value out of range")}(t):dr(t)}function br(t,e,r){yr(t),void 0===r&&(r=0),void 0===e&&(e=new Uint8Array(vr(t)));let n=0;return t<253?(e.set([Number(t)],r),n=1):t<=65535?(e.set([253],r),function(t,e,r,n){if(e+2>t.length)throw new Error("Offset is outside the bounds of Uint8Array");if(n=n.toUpperCase(),r>65535)throw new Error(`The value of "value" is out of range. It must be >= 0 and <= 65535. Received ${r}`);"LE"===n?(t[e]=255&r,t[e+1]=r>>8&255):(t[e]=r>>8&255,t[e+1]=255&r)}(e,r+1,Number(t),"LE"),n=3):t<=4294967295?(e.set([254],r),function(t,e,r,n){if(e+4>t.length)throw new Error("Offset is outside the bounds of Uint8Array");if(n=n.toUpperCase(),r>4294967295)throw new Error(`The value of "value" is out of range. It must be >= 0 and <= 4294967295. Received ${r}`);"LE"===n?(t[e]=255&r,t[e+1]=r>>8&255,t[e+2]=r>>16&255,t[e+3]=r>>24&255):(t[e]=r>>24&255,t[e+1]=r>>16&255,t[e+2]=r>>8&255,t[e+3]=255&r)}(e,r+1,Number(t),"LE"),n=5):(e.set([255],r),function(t,e,r,n){if(e+8>t.length)throw new Error("Offset is outside the bounds of Uint8Array");if(n=n.toUpperCase(),r>0xffffffffffffffffn)throw new Error(`The value of "value" is out of range. It must be >= 0 and <= 18446744073709551615. Received ${r}`);"LE"===n?(t[e]=Number(0xffn&r),t[e+1]=Number(r>>8n&0xffn),t[e+2]=Number(r>>16n&0xffn),t[e+3]=Number(r>>24n&0xffn),t[e+4]=Number(r>>32n&0xffn),t[e+5]=Number(r>>40n&0xffn),t[e+6]=Number(r>>48n&0xffn),t[e+7]=Number(r>>56n&0xffn)):(t[e]=Number(r>>56n&0xffn),t[e+1]=Number(r>>48n&0xffn),t[e+2]=Number(r>>40n&0xffn),t[e+3]=Number(r>>32n&0xffn),t[e+4]=Number(r>>24n&0xffn),t[e+5]=Number(r>>16n&0xffn),t[e+6]=Number(r>>8n&0xffn),t[e+7]=Number(0xffn&r))}(e,r+1,BigInt(t),"LE"),n=9),{buffer:e,bytes:n}}function gr(t,e){void 0===e&&(e=0);const r=t.at(e);if(void 0===r)throw new Error("buffer too small");if(r<253)return{numberValue:r,bigintValue:BigInt(r),bytes:1};if(253===r){const r=function(t,e,r){if(e+2>t.length)throw new Error("Offset is outside the bounds of Uint8Array");if("LE"===(r=r.toUpperCase())){let r=0;return r=(r<<8)+t[e+1],r=(r<<8)+t[e],r}{let r=0;return r=(r<<8)+t[e],r=(r<<8)+t[e+1],r}}(t,e+1,"LE");return{numberValue:r,bigintValue:BigInt(r),bytes:3}}if(254===r){const r=function(t,e,r){if(e+4>t.length)throw new Error("Offset is outside the bounds of Uint8Array");if("LE"===(r=r.toUpperCase())){let r=0;return r=(r<<8)+t[e+3]>>>0,r=(r<<8)+t[e+2]>>>0,r=(r<<8)+t[e+1]>>>0,r=(r<<8)+t[e]>>>0,r}{let r=0;return r=(r<<8)+t[e]>>>0,r=(r<<8)+t[e+1]>>>0,r=(r<<8)+t[e+2]>>>0,r=(r<<8)+t[e+3]>>>0,r}}(t,e+1,"LE");return{numberValue:r,bigintValue:BigInt(r),bytes:5}}{const r=function(t,e,r){if(e+8>t.length)throw new Error("Offset is outside the bounds of Uint8Array");if("LE"===(r=r.toUpperCase())){let r=0n;return r=(r<<8n)+BigInt(t[e+7]),r=(r<<8n)+BigInt(t[e+6]),r=(r<<8n)+BigInt(t[e+5]),r=(r<<8n)+BigInt(t[e+4]),r=(r<<8n)+BigInt(t[e+3]),r=(r<<8n)+BigInt(t[e+2]),r=(r<<8n)+BigInt(t[e+1]),r=(r<<8n)+BigInt(t[e]),r}{let r=0n;return r=(r<<8n)+BigInt(t[e]),r=(r<<8n)+BigInt(t[e+1]),r=(r<<8n)+BigInt(t[e+2]),r=(r<<8n)+BigInt(t[e+3]),r=(r<<8n)+BigInt(t[e+4]),r=(r<<8n)+BigInt(t[e+5]),r=(r<<8n)+BigInt(t[e+6]),r=(r<<8n)+BigInt(t[e+7]),r}}(t,e+1,"LE");return{numberValue:r<=Number.MAX_SAFE_INTEGER?Number(r):null,bigintValue:r,bytes:9}}}function vr(t){return yr(t),t<253?1:t<=65535?3:t<=4294967295?5:9}var wr=y(287).hp;function mr(t){return mr="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},mr(t)}function Sr(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function _r(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,kr(n.key),n)}}function Er(t,e,r){return e&&_r(t.prototype,e),r&&_r(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function kr(t){var e=function(t){if("object"!=mr(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=mr(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==mr(e)?e:e+""}var Or=gt;function Tr(t,e){if("number"!=typeof t)throw new Error("cannot write a non-number as a number");if(t<0)throw new Error("specified a negative value for writing an unsigned value");if(t>e)throw new Error("RangeError: value out of range");if(Math.floor(t)!==t)throw new Error("value has a fractional component")}function Ar(t){if(t.length<1)return t;for(var e=t.length-1,r=0,n=0;n<t.length/2;n++)r=t[n],t[n]=t[e],t[e]=r,e--;return t}function Ir(t){var e=wr.allocUnsafe(t.length);return t.copy(e),e}var Pr=function(){function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;Sr(this,t),this.buffer=e,this.offset=r,Or(jt(Bt,Lt),[e,r])}return Er(t,[{key:"writeUInt8",value:function(t){this.offset=this.buffer.writeUInt8(t,this.offset)}},{key:"writeInt32",value:function(t){this.offset=this.buffer.writeInt32LE(t,this.offset)}},{key:"writeUInt32",value:function(t){this.offset=this.buffer.writeUInt32LE(t,this.offset)}},{key:"writeUInt64",value:function(t){this.offset=function(t,e,r){return Tr(e,9007199254740991),t.writeInt32LE(-1&e,r),t.writeUInt32LE(Math.floor(e/4294967296),r+4),r+8}(this.buffer,t,this.offset)}},{key:"writeVarInt",value:function(t){var e=br(t,this.buffer,this.offset);this.offset+=e.bytes}},{key:"writeSlice",value:function(t){if(this.buffer.length<this.offset+t.length)throw new Error("Cannot write slice out of bounds");this.offset+=t.copy(this.buffer,this.offset)}},{key:"writeVarSlice",value:function(t){this.writeVarInt(t.length),this.writeSlice(t)}},{key:"writeVector",value:function(t){var e=this;this.writeVarInt(t.length),t.forEach(function(t){return e.writeVarSlice(t)})}},{key:"end",value:function(){if(this.buffer.length===this.offset)return this.buffer;throw new Error("buffer size ".concat(this.buffer.length,", offset ").concat(this.offset))}}],[{key:"withCapacity",value:function(e){return new t(wr.alloc(e))}}])}(),xr=Er(function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;Sr(this,t),this.buffer=e,this.offset=r,Or(jt(Bt,Lt),[e,r])},[{key:"readUInt8",value:function(){var t=this.buffer.readUInt8(this.offset);return this.offset++,t}},{key:"readInt32",value:function(){var t=this.buffer.readInt32LE(this.offset);return this.offset+=4,t}},{key:"readUInt32",value:function(){var t=this.buffer.readUInt32LE(this.offset);return this.offset+=4,t}},{key:"readUInt64",value:function(){var t=function(t,e){var r=t.readUInt32LE(e),n=t.readUInt32LE(e+4);return Tr((n*=4294967296)+r,9007199254740991),n+r}(this.buffer,this.offset);return this.offset+=8,t}},{key:"readVarInt",value:function(){var t=gr(this.buffer,this.offset);return this.offset+=t.bytes,t.numberValue||0}},{key:"readSlice",value:function(t){if(this.buffer.length<this.offset+t)throw new Error("Cannot read slice out of bounds");var e=this.buffer.subarray(this.offset,this.offset+t);return this.offset+=t,e}},{key:"readVarSlice",value:function(){return this.readSlice(this.readVarInt())}},{key:"readVector",value:function(){for(var t=this.readVarInt(),e=[],r=0;r<t;r++)e.push(this.readVarSlice());return e}}]);function Br(t){return function(t){if(Array.isArray(t))return Rr(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return Rr(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Rr(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Rr(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}var Ur=192,jr=128,Nr=function(t){return"left"in t&&"right"in t};function Lr(t,e){if(t.length<33)throw new TypeError("The control-block length is too small. Got ".concat(t.length,", expected min 33."));for(var r=(t.length-33)/32,n=e,i=0;i<r;i++){var o=t.slice(33+32*i,65+32*i);n=n.compare(o)<0?Kr(n,o):Kr(o,n)}return n}function Cr(t){if(kt(t))return{hash:Dr(t)};var e=[Cr(t[0]),Cr(t[1])];e.sort(function(t,e){return t.hash.compare(e.hash)});var r=e[0],n=e[1];return{hash:Kr(r.hash,n.hash),left:r,right:n}}function Fr(t,e){if(Nr(t)){var r=Fr(t.left,e);if(void 0!==r)return[].concat(Br(r),[t.right.hash]);var n=Fr(t.right,e);if(void 0!==n)return[].concat(Br(n),[t.left.hash])}else if(t.hash.equals(e))return[]}function Dr(t){var e,r,n,i=t.version||Ur;return or("TapLeaf",yt.hp.concat([yt.hp.from([i]),(e=t.output,r=vr(e.length),n=yt.hp.allocUnsafe(r),br(e.length,n),yt.hp.concat([n,e]))]))}function Hr(t,e){return or("TapTweak",yt.hp.concat(e?[t,e]:[t]))}function Mr(t,e){if(!yt.hp.isBuffer(t))return null;if(32!==t.length)return null;if(e&&32!==e.length)return null;var r=Hr(t,e),n=cr().xOnlyPointAddTweak(t,r);return n&&null!==n.xOnlyPubkey?{parity:n.parity,x:yt.hp.from(n.xOnlyPubkey)}:null}function Kr(t,e){return or("TapBranch",yt.hp.concat([t,e]))}function Vr(t,e,r){Object.defineProperty(t,e,{configurable:!0,enumerable:!0,get:function(){var t=r.call(this);return this[e]=t,t},set:function(t){Object.defineProperty(this,e,{configurable:!0,enumerable:!0,value:t,writable:!0})}})}function Wr(t){var e;return function(){return void 0!==e?e:e=t()}}var Gr=it;function qr(t,e){if(!t.data&&!t.output)throw new TypeError("Not enough data");e=Object.assign({validate:!0},e||{}),gt({network:gt.maybe(gt.Object),output:gt.maybe(gt.Buffer),data:gt.maybe(gt.arrayOf(gt.Buffer))},t);var r=t.network||O,n={name:Yi.Embed,network:r,data:[]};if(Vr(n,"output",function(){if(t.data)return re([Gr.OP_RETURN].concat(t.data))}),Vr(n,"data",function(){if(t.output){var e=ne(t.output);if(null!=e)return e.slice(1)}}),e.validate&&t.output){var i=ne(t.output);if(i[0]!==Gr.OP_RETURN)throw new TypeError("Output is invalid");if(!i.slice(1).every(gt.Buffer))throw new TypeError("Output is invalid");if(t.data&&!mt(t.data,n.data))throw new TypeError("Data mismatch")}return Object.assign(n,t)}var zr=it,Zr=zr.OP_RESERVED;function Xr(t,e){if(!(t.input||t.output||t.pubkeys&&void 0!==t.m||t.signatures))throw new TypeError("Not enough data");function r(t){return ce(t)||void 0!==(e.allowIncomplete&&t===zr.OP_0)}e=Object.assign({validate:!0},e||{}),gt({network:gt.maybe(gt.Object),m:gt.maybe(gt.Number),n:gt.maybe(gt.Number),output:gt.maybe(gt.Buffer),pubkeys:gt.maybe(gt.arrayOf(St)),signatures:gt.maybe(gt.arrayOf(r)),input:gt.maybe(gt.Buffer)},t);var n={network:t.network||O,name:Yi.P2MS},i=[],o=!1;function a(t){o||(o=!0,i=ne(t),n.m=i[0]-Zr,n.n=i[i.length-2]-Zr,n.pubkeys=i.slice(1,-2))}if(Vr(n,"output",function(){if(t.m&&n.n&&t.pubkeys)return re([].concat(Zr+t.m,t.pubkeys,Zr+n.n,zr.OP_CHECKMULTISIG))}),Vr(n,"m",function(){if(n.output)return a(n.output),n.m}),Vr(n,"n",function(){if(n.pubkeys)return n.pubkeys.length}),Vr(n,"pubkeys",function(){if(t.output)return a(t.output),n.pubkeys}),Vr(n,"signatures",function(){if(t.input){var e=ne(t.input);if(null!=e)return e.slice(1)}}),Vr(n,"input",function(){if(t.signatures)return re([zr.OP_0].concat(t.signatures))}),Vr(n,"witness",function(){if(n.input)return[]}),Vr(n,"name",function(){if(n.m&&n.n)return"p2ms(".concat(n.m," of ").concat(n.n,")")}),e.validate){if(t.output){if(a(t.output),!gt.Number(i[0]))throw new TypeError("Output is invalid");if(!gt.Number(i[i.length-2]))throw new TypeError("Output is invalid");if(i[i.length-1]!==zr.OP_CHECKMULTISIG)throw new TypeError("Output is invalid");if(n.m<=0||n.n>16||n.m>n.n||n.n!==i.length-3)throw new TypeError("Output is invalid");if(!n.pubkeys.every(function(t){return St(t)}))throw new TypeError("Output is invalid");if(void 0!==t.m&&t.m!==n.m)throw new TypeError("m mismatch");if(void 0!==t.n&&t.n!==n.n)throw new TypeError("n mismatch");if(t.pubkeys&&!mt(t.pubkeys,n.pubkeys))throw new TypeError("Pubkeys mismatch")}if(t.pubkeys){if(void 0!==t.n&&t.n!==t.pubkeys.length)throw new TypeError("Pubkey count mismatch");if(n.n=t.pubkeys.length,n.n<n.m)throw new TypeError("Pubkey count cannot be less than m")}if(t.signatures){if(t.signatures.length<n.m)throw new TypeError("Not enough signatures provided");if(t.signatures.length>n.m)throw new TypeError("Too many signatures provided")}if(t.input){if(t.input[0]!==zr.OP_0)throw new TypeError("Input is invalid");if(0===n.signatures.length||!n.signatures.every(r))throw new TypeError("Input has invalid signature(s)");if(t.signatures&&!mt(t.signatures,n.signatures))throw new TypeError("Signature mismatch");if(void 0!==t.m&&t.m!==t.signatures.length)throw new TypeError("Signature count mismatch")}}return Object.assign(n,t)}var Yr=it;function $r(t,e){if(!(t.input||t.output||t.pubkey||t.input||t.signature))throw new TypeError("Not enough data");e=Object.assign({validate:!0},e||{}),gt({network:gt.maybe(gt.Object),output:gt.maybe(gt.Buffer),pubkey:gt.maybe(St),signature:gt.maybe(ce),input:gt.maybe(gt.Buffer)},t);var r=Wr(function(){return ne(t.input)}),n=t.network||O,i={name:Yi.P2PK,network:n,pubkey:void 0};if(Vr(i,"output",function(){if(t.pubkey)return re([t.pubkey,Yr.OP_CHECKSIG])}),Vr(i,"pubkey",function(){if(t.output)return t.output.slice(1,-1)}),Vr(i,"signature",function(){if(t.input)return r()[0]}),Vr(i,"input",function(){if(t.signature)return re([t.signature])}),Vr(i,"witness",function(){if(i.input)return[]}),e.validate){if(t.output){if(t.output[t.output.length-1]!==Yr.OP_CHECKSIG)throw new TypeError("Output is invalid");if(!St(i.pubkey))throw new TypeError("Output pubkey is invalid");if(t.pubkey&&!t.pubkey.equals(i.pubkey))throw new TypeError("Pubkey mismatch")}if(t.signature&&t.input&&!t.input.equals(i.input))throw new TypeError("Signature mismatch");if(t.input){if(1!==r().length)throw new TypeError("Input is invalid");if(!ce(i.signature))throw new TypeError("Input has invalid signature")}}return Object.assign(i,t)}const Jr=2n**256n,Qr=Jr-0x1000003d1n,tn=Jr-0x14551231950b75fc4402da1732fc9bebfn,en=0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798n,rn=0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8n,nn={p:Qr,n:tn,a:0n,b:7n,Gx:en,Gy:rn},on=t=>dn(dn(t*t)*t+nn.b),an=(t="")=>{throw new Error(t)},sn=t=>"bigint"==typeof t,un=t=>"string"==typeof t,cn=t=>sn(t)&&0n<t&&t<Qr,fn=t=>sn(t)&&0n<t&&t<tn,ln=(t,e)=>!(t=>t instanceof Uint8Array||ArrayBuffer.isView(t)&&"Uint8Array"===t.constructor.name)(t)||"number"==typeof e&&e>0&&t.length!==e?an("Uint8Array expected"):t,hn=t=>new Uint8Array(t),pn=(t,e)=>ln(un(t)?_n(t):hn(ln(t)),e),dn=(t,e=Qr)=>{const r=t%e;return r>=0n?r:e+r},yn=t=>t instanceof bn?t:an("Point expected");class bn{constructor(t,e,r){this.px=t,this.py=e,this.pz=r,Object.freeze(this)}static fromAffine(t){return 0n===t.x&&0n===t.y?vn:new bn(t.x,t.y,1n)}static fromHex(t){let e;const r=(t=pn(t))[0],n=t.subarray(1),i=kn(n,0,32),o=t.length;if(33===o&&[2,3].includes(r)){cn(i)||an("Point hex invalid: x not FE");let t=Pn(on(i));!(1&~r)!=(1n==(1n&t))&&(t=dn(-t)),e=new bn(i,t,1n)}return 65===o&&4===r&&(e=new bn(i,kn(n,32,64),1n)),e?e.ok():an("Point invalid: not on curve")}static fromPrivateKey(t){return gn.mul(xn(t))}get x(){return this.aff().x}get y(){return this.aff().y}equals(t){const{px:e,py:r,pz:n}=this,{px:i,py:o,pz:a}=yn(t),s=dn(e*a),u=dn(i*n),c=dn(r*a),f=dn(o*n);return s===u&&c===f}negate(){return new bn(this.px,dn(-this.py),this.pz)}double(){return this.add(this)}add(t){const{px:e,py:r,pz:n}=this,{px:i,py:o,pz:a}=yn(t),{a:s,b:u}=nn;let c=0n,f=0n,l=0n;const h=dn(3n*u);let p=dn(e*i),d=dn(r*o),y=dn(n*a),b=dn(e+r),g=dn(i+o);b=dn(b*g),g=dn(p+d),b=dn(b-g),g=dn(e+n);let v=dn(i+a);return g=dn(g*v),v=dn(p+y),g=dn(g-v),v=dn(r+n),c=dn(o+a),v=dn(v*c),c=dn(d+y),v=dn(v-c),l=dn(s*g),c=dn(h*y),l=dn(c+l),c=dn(d-l),l=dn(d+l),f=dn(c*l),d=dn(p+p),d=dn(d+p),y=dn(s*y),g=dn(h*g),d=dn(d+y),y=dn(p-y),y=dn(s*y),g=dn(g+y),p=dn(d*g),f=dn(f+p),p=dn(v*g),c=dn(b*c),c=dn(c-p),p=dn(b*d),l=dn(v*l),l=dn(l+p),new bn(c,f,l)}mul(t,e=!0){if(!e&&0n===t)return vn;if(fn(t)||an("scalar invalid"),this.equals(gn))return Nn(t).p;let r=vn,n=gn;for(let i=this;t>0n;i=i.double(),t>>=1n)1n&t?r=r.add(i):e&&(n=n.add(i));return r}mulAddQUns(t,e,r){return this.mul(e,!1).add(t.mul(r,!1)).ok()}toAffine(){const{px:t,py:e,pz:r}=this;if(this.equals(vn))return{x:0n,y:0n};if(1n===r)return{x:t,y:e};const n=In(r,Qr);return 1n!==dn(r*n)&&an("inverse invalid"),{x:dn(t*n),y:dn(e*n)}}assertValidity(){const{x:t,y:e}=this.aff();return cn(t)&&cn(e)||an("Point invalid: x or y"),dn(e*e)===on(t)?this:an("Point invalid: not on curve")}multiply(t){return this.mul(t)}aff(){return this.toAffine()}ok(){return this.assertValidity()}toHex(t=!0){const{x:e,y:r}=this.aff();return(t?0n==(1n&r)?"02":"03":"04")+Tn(e)+(t?"":Tn(r))}toRawBytes(t=!0){return _n(this.toHex(t))}}bn.BASE=new bn(en,rn,1n),bn.ZERO=new bn(0n,1n,0n);const{BASE:gn,ZERO:vn}=bn,wn=(t,e)=>t.toString(16).padStart(e,"0"),mn=t=>Array.from(ln(t)).map(t=>wn(t,2)).join(""),Sn=t=>t>=48&&t<=57?t-48:t>=65&&t<=70?t-55:t>=97&&t<=102?t-87:void 0,_n=t=>{const e="hex invalid";if(!un(t))return an(e);const r=t.length,n=r/2;if(r%2)return an(e);const i=hn(n);for(let r=0,o=0;r<n;r++,o+=2){const n=Sn(t.charCodeAt(o)),a=Sn(t.charCodeAt(o+1));if(void 0===n||void 0===a)return an(e);i[r]=16*n+a}return i},En=t=>BigInt("0x"+(mn(t)||"0")),kn=(t,e,r)=>En(t.slice(e,r)),On=t=>sn(t)&&t>=0n&&t<Jr?_n(wn(t,64)):an("bigint expected"),Tn=t=>mn(On(t)),An=(...t)=>{const e=hn(t.reduce((t,e)=>t+ln(e).length,0));let r=0;return t.forEach(t=>{e.set(t,r),r+=t.length}),e},In=(t,e)=>{(0n===t||e<=0n)&&an("no inverse n="+t+" mod="+e);let r=dn(t,e),n=e,i=0n,o=1n,a=1n,s=0n;for(;0n!==r;){const t=n/r,e=n%r,u=i-a*t,c=o-s*t;n=r,r=e,i=a,o=s,a=u,s=c}return 1n===n?dn(i,e):an("no inverse")},Pn=t=>{let e=1n;for(let r=t,n=(Qr+1n)/4n;n>0n;n>>=1n)1n&n&&(e=e*r%Qr),r=r*r%Qr;return dn(e*e)===t?e:an("sqrt invalid")},xn=t=>(sn(t)||(t=En(pn(t,32))),fn(t)?t:an("private key invalid 3")),Bn=()=>"object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0;let Rn;const Un={hexToBytes:_n,bytesToHex:mn,concatBytes:An,bytesToNumberBE:En,numberToBytesBE:On,mod:dn,invert:In,hmacSha256Async:async(t,...e)=>{const r=Bn(),n=r&&r.subtle;if(!n)return an("etc.hmacSha256Async or crypto.subtle must be defined");const i=await n.importKey("raw",t,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]);return hn(await n.sign("HMAC",i,An(...e)))},hmacSha256Sync:Rn,hashToPrivateKey:t=>{((t=pn(t)).length<40||t.length>1024)&&an("expected 40-1024b");const e=dn(En(t),tn-1n);return On(e+1n)},randomBytes:(t=32)=>{const e=Bn();return e&&e.getRandomValues||an("crypto.getRandomValues must be defined"),e.getRandomValues(hn(t))}};let jn;Object.defineProperties(Un,{hmacSha256Sync:{configurable:!1,get:()=>Rn,set(t){Rn||(Rn=t)}}});const Nn=t=>{const e=jn||(jn=(()=>{const t=[];let e=gn,r=e;for(let n=0;n<33;n++){r=e,t.push(r);for(let n=1;n<128;n++)r=r.add(e),t.push(r);e=r.double()}return t})()),r=(t,e)=>{let r=e.negate();return t?r:e};let n=vn,i=gn;const o=BigInt(255),a=BigInt(8);for(let s=0;s<33;s++){const u=128*s;let c=Number(t&o);t>>=a,c>128&&(c-=256,t+=1n);const f=u,l=u+Math.abs(c)-1,h=s%2!=0,p=c<0;0===c?i=i.add(r(h,e[f])):n=n.add(r(p,e[l]))}return{p:n,f:i}};var Ln=y(394),Cn=y(287).hp,Fn=it;function Dn(t,e){if(!(t.address||t.hash||t.output||t.redeem||t.input))throw new TypeError("Not enough data");e=Object.assign({validate:!0},e||{}),gt({network:gt.maybe(gt.Object),address:gt.maybe(gt.String),hash:gt.maybe(gt.BufferN(20)),output:gt.maybe(gt.BufferN(23)),redeem:gt.maybe({network:gt.maybe(gt.Object),output:gt.maybe(gt.Buffer),input:gt.maybe(gt.Buffer),witness:gt.maybe(gt.arrayOf(gt.Buffer))}),input:gt.maybe(gt.Buffer),witness:gt.maybe(gt.arrayOf(gt.Buffer))},t);var r=t.network;r||(r=t.redeem&&t.redeem.network||O);var n={network:r,name:Yi.P2SH},i=Wr(function(){var e=Cn.from(et.decode(t.address));return{version:e.readUInt8(0),hash:e.slice(1)}}),o=Wr(function(){return ne(t.input)}),a=Wr(function(){var e=o(),n=e[e.length-1];return{network:r,output:n===Fn.OP_FALSE?Cn.from([]):n,input:re(e.slice(0,-1)),witness:t.witness||[]}});if(Vr(n,"address",function(){if(n.hash){var t=Cn.allocUnsafe(21);return t.writeUInt8(n.network.scriptHash,0),n.hash.copy(t,1),et.encode(t)}}),Vr(n,"hash",function(){return t.output?t.output.slice(2,22):t.address?i().hash:n.redeem&&n.redeem.output?er(n.redeem.output):void 0}),Vr(n,"output",function(){if(n.hash)return re([Fn.OP_HASH160,n.hash,Fn.OP_EQUAL])}),Vr(n,"redeem",function(){if(t.input)return a()}),Vr(n,"input",function(){if(t.redeem&&t.redeem.input&&t.redeem.output)return re([].concat(ne(t.redeem.input),t.redeem.output))}),Vr(n,"witness",function(){return n.redeem&&n.redeem.witness?n.redeem.witness:n.input?[]:void 0}),Vr(n,"name",function(){var t=["p2sh"];return void 0!==n.redeem&&void 0!==n.redeem.name&&t.push(n.redeem.name),t.join("-")}),e.validate){var s=Cn.from([]);if(t.address){if(i().version!==r.scriptHash)throw new TypeError("Invalid version or Network mismatch");if(20!==i().hash.length)throw new TypeError("Invalid address");s=i().hash}if(t.hash){if(s.length>0&&!s.equals(t.hash))throw new TypeError("Hash mismatch");s=t.hash}if(t.output){if(23!==t.output.length||t.output[0]!==Fn.OP_HASH160||20!==t.output[1]||t.output[22]!==Fn.OP_EQUAL)throw new TypeError("Output is invalid");var u=t.output.slice(2,22);if(s.length>0&&!s.equals(u))throw new TypeError("Hash mismatch");s=u}var c=function(t){if(t.output){var e=ne(t.output);if(!e||e.length<1)throw new TypeError("Redeem.output too short");if(t.output.byteLength>520)throw new TypeError("Redeem.output unspendable if larger than 520 bytes");if(Jt(e)>201)throw new TypeError("Redeem.output unspendable with more than 201 non-push ops");var r=er(t.output);if(s.length>0&&!s.equals(r))throw new TypeError("Hash mismatch");s=r}if(t.input){var n=t.input.length>0,i=t.witness&&t.witness.length>0;if(!n&&!i)throw new TypeError("Empty input");if(n&&i)throw new TypeError("Input and witness provided");if(n&&!$t(ne(t.input)))throw new TypeError("Non push-only scriptSig")}};if(t.input){var f=o();if(!f||f.length<1)throw new TypeError("Input too short");if(!Cn.isBuffer(a().output))throw new TypeError("Input is invalid");c(a())}if(t.redeem){if(t.redeem.network&&t.redeem.network!==r)throw new TypeError("Network mismatch");if(t.input){var l=a();if(t.redeem.output&&!t.redeem.output.equals(l.output))throw new TypeError("Redeem.output mismatch");if(t.redeem.input&&!t.redeem.input.equals(l.input))throw new TypeError("Redeem.input mismatch")}c(t.redeem)}if(t.witness&&t.redeem&&t.redeem.witness&&!mt(t.redeem.witness,t.witness))throw new TypeError("Witness and redeem.witness mismatch")}return Object.assign(n,t)}var Hn=it,Mn=1,Kn=80;function Vn(t,e){if(!(t.address||t.output||t.pubkey||t.internalPubkey||t.witness&&t.witness.length>1))throw new TypeError("Not enough data");e=Object.assign({validate:!0},e||{}),gt({address:gt.maybe(gt.String),input:gt.maybe(gt.BufferN(0)),network:gt.maybe(gt.Object),output:gt.maybe(gt.BufferN(34)),internalPubkey:gt.maybe(gt.BufferN(32)),hash:gt.maybe(gt.BufferN(32)),pubkey:gt.maybe(gt.BufferN(32)),signature:gt.maybe(gt.anyOf(gt.BufferN(64),gt.BufferN(65))),witness:gt.maybe(gt.arrayOf(gt.Buffer)),scriptTree:gt.maybe(Ot),redeem:gt.maybe({output:gt.maybe(gt.Buffer),redeemVersion:gt.maybe(gt.Number),witness:gt.maybe(gt.arrayOf(gt.Buffer))}),redeemVersion:gt.maybe(gt.Number)},t);var r=Wr(function(){return Te(t.address)}),n=Wr(function(){if(t.witness&&t.witness.length)return t.witness.length>=2&&t.witness[t.witness.length-1][0]===Kn?t.witness.slice(0,-1):t.witness.slice()}),i=Wr(function(){return t.scriptTree?Cr(t.scriptTree):t.hash?{hash:t.hash}:void 0}),o=t.network||O,a={name:Yi.P2TR,network:o};if(Vr(a,"address",function(){if(a.pubkey){var t=L.p2.toWords(a.pubkey);return t.unshift(Mn),L.p2.encode(o.bech32,t)}}),Vr(a,"hash",function(){var t=i();if(t)return t.hash;var e=n();if(e&&e.length>1){var r=e[e.length-1],o=r[0]&Et;return Lr(r,Dr({output:e[e.length-2],version:o}))}}),Vr(a,"output",function(){if(a.pubkey)return re([Hn.OP_1,a.pubkey])}),Vr(a,"redeemVersion",function(){return t.redeemVersion?t.redeemVersion:t.redeem&&void 0!==t.redeem.redeemVersion&&null!==t.redeem.redeemVersion?t.redeem.redeemVersion:Ur}),Vr(a,"redeem",function(){var t=n();if(t&&!(t.length<2))return{output:t[t.length-2],witness:t.slice(0,-2),redeemVersion:t[t.length-1][0]&Et}}),Vr(a,"pubkey",function(){if(t.pubkey)return t.pubkey;if(t.output)return t.output.slice(2);if(t.address)return r().data;if(a.internalPubkey){var e=Mr(a.internalPubkey,a.hash);if(e)return e.x}}),Vr(a,"internalPubkey",function(){if(t.internalPubkey)return t.internalPubkey;var e=n();return e&&e.length>1?e[e.length-1].slice(1,33):void 0}),Vr(a,"signature",function(){if(t.signature)return t.signature;var e=n();return e&&1===e.length?e[0]:void 0}),Vr(a,"witness",function(){if(t.witness)return t.witness;var e=i();if(e&&t.redeem&&t.redeem.output&&t.internalPubkey){var r=Fr(e,Dr({output:t.redeem.output,version:a.redeemVersion}));if(!r)return;var n=Mr(t.internalPubkey,e.hash);if(!n)return;var o=yt.hp.concat([yt.hp.from([a.redeemVersion|n.parity]),t.internalPubkey].concat(r));return[t.redeem.output,o]}return t.signature?[t.signature]:void 0}),e.validate){var s=yt.hp.from([]);if(t.address){if(o&&o.bech32!==r().prefix)throw new TypeError("Invalid prefix or Network mismatch");if(r().version!==Mn)throw new TypeError("Invalid address version");if(32!==r().data.length)throw new TypeError("Invalid address data");s=r().data}if(t.pubkey){if(s.length>0&&!s.equals(t.pubkey))throw new TypeError("Pubkey mismatch");s=t.pubkey}if(t.output){if(34!==t.output.length||t.output[0]!==Hn.OP_1||32!==t.output[1])throw new TypeError("Output is invalid");if(s.length>0&&!s.equals(t.output.slice(2)))throw new TypeError("Pubkey mismatch");s=t.output.slice(2)}if(t.internalPubkey){var u=Mr(t.internalPubkey,a.hash);if(s.length>0&&!s.equals(u.x))throw new TypeError("Pubkey mismatch");s=u.x}var c=i();if(t.hash&&c&&!t.hash.equals(c.hash))throw new TypeError("Hash mismatch");if(t.redeem&&t.redeem.output&&c&&!Fr(c,Dr({output:t.redeem.output,version:a.redeemVersion})))throw new TypeError("Redeem script not in tree");var f=n();if(t.redeem&&a.redeem){if(t.redeem.redeemVersion&&t.redeem.redeemVersion!==a.redeem.redeemVersion)throw new TypeError("Redeem.redeemVersion and witness mismatch");if(t.redeem.output){if(0===ne(t.redeem.output).length)throw new TypeError("Redeem.output is invalid");if(a.redeem.output&&!t.redeem.output.equals(a.redeem.output))throw new TypeError("Redeem.output and witness mismatch")}if(t.redeem.witness&&a.redeem.witness&&!mt(t.redeem.witness,a.redeem.witness))throw new TypeError("Redeem.witness and witness mismatch")}if(f&&f.length)if(1===f.length){if(t.signature&&!t.signature.equals(f[0]))throw new TypeError("Signature mismatch")}else{var l=f[f.length-1];if(l.length<33)throw new TypeError("The control-block length is too small. Got ".concat(l.length,", expected min 33."));if((l.length-33)%32!=0)throw new TypeError("The control-block length of ".concat(l.length," is incorrect!"));var h=(l.length-33)/32;if(h>128)throw new TypeError("The script path is too long. Got ".concat(h,", expected max 128."));var p=l.slice(1,33);if(t.internalPubkey&&!t.internalPubkey.equals(p))throw new TypeError("Internal pubkey mismatch");if(!cr().isXOnlyPoint(p))throw new TypeError("Invalid internalPubkey for p2tr witness");var d=l[0]&Et,y=Mr(p,Lr(l,Dr({output:f[f.length-2],version:d})));if(!y)throw new TypeError("Invalid outputKey for p2tr witness");if(s.length&&!s.equals(y.x))throw new TypeError("Pubkey mismatch for p2tr witness");if(y.parity!==(1&l[0]))throw new Error("Incorrect parity")}}return Object.assign(a,t)}var Wn=y(287).hp,Gn=it,qn=Wn.alloc(0);function zn(t,e){if(!(t.address||t.hash||t.output||t.pubkey||t.witness))throw new TypeError("Not enough data");e=Object.assign({validate:!0},e||{}),gt({address:gt.maybe(gt.String),hash:gt.maybe(gt.BufferN(20)),input:gt.maybe(gt.BufferN(0)),network:gt.maybe(gt.Object),output:gt.maybe(gt.BufferN(22)),pubkey:gt.maybe(St),signature:gt.maybe(ce),witness:gt.maybe(gt.arrayOf(gt.Buffer))},t);var r=Wr(function(){var e=L.I.decode(t.address),r=e.words.shift(),n=L.I.fromWords(e.words);return{version:r,prefix:e.prefix,data:Wn.from(n)}}),n=t.network||O,i={name:Yi.P2WPKH,network:n};if(Vr(i,"address",function(){if(i.hash){var t=L.I.toWords(i.hash);return t.unshift(0),L.I.encode(n.bech32,t)}}),Vr(i,"hash",function(){return t.output?t.output.slice(2,22):t.address?r().data:t.pubkey||i.pubkey?er(t.pubkey||i.pubkey):void 0}),Vr(i,"output",function(){if(i.hash)return re([Gn.OP_0,i.hash])}),Vr(i,"pubkey",function(){return t.pubkey?t.pubkey:t.witness?t.witness[1]:void 0}),Vr(i,"signature",function(){if(t.witness)return t.witness[0]}),Vr(i,"input",function(){if(i.witness)return qn}),Vr(i,"witness",function(){if(t.pubkey&&t.signature)return[t.signature,t.pubkey]}),e.validate){var o=Wn.from([]);if(t.address){if(n&&n.bech32!==r().prefix)throw new TypeError("Invalid prefix or Network mismatch");if(0!==r().version)throw new TypeError("Invalid address version");if(20!==r().data.length)throw new TypeError("Invalid address data");o=r().data}if(t.hash){if(o.length>0&&!o.equals(t.hash))throw new TypeError("Hash mismatch");o=t.hash}if(t.output){if(22!==t.output.length||t.output[0]!==Gn.OP_0||20!==t.output[1])throw new TypeError("Output is invalid");if(o.length>0&&!o.equals(t.output.slice(2)))throw new TypeError("Hash mismatch");o=t.output.slice(2)}if(t.pubkey){var a=er(t.pubkey);if(o.length>0&&!o.equals(a))throw new TypeError("Hash mismatch");if(o=a,!St(t.pubkey)||33!==t.pubkey.length)throw new TypeError("Invalid pubkey for p2wpkh")}if(t.witness){if(2!==t.witness.length)throw new TypeError("Witness is invalid");if(!ce(t.witness[0]))throw new TypeError("Witness has invalid signature");if(!St(t.witness[1])||33!==t.witness[1].length)throw new TypeError("Witness has invalid pubkey");if(t.signature&&!t.signature.equals(t.witness[0]))throw new TypeError("Signature mismatch");if(t.pubkey&&!t.pubkey.equals(t.witness[1]))throw new TypeError("Pubkey mismatch");var s=er(t.witness[1]);if(o.length>0&&!o.equals(s))throw new TypeError("Hash mismatch")}}return Object.assign(i,t)}var Zn=y(287).hp,Xn=it,Yn=Zn.alloc(0);function $n(t){return!(!Zn.isBuffer(t)||65!==t.length||4!==t[0]||!St(t))}function Jn(t,e){if(!(t.address||t.hash||t.output||t.redeem||t.witness))throw new TypeError("Not enough data");e=Object.assign({validate:!0},e||{}),gt({network:gt.maybe(gt.Object),address:gt.maybe(gt.String),hash:gt.maybe(gt.BufferN(32)),output:gt.maybe(gt.BufferN(34)),redeem:gt.maybe({input:gt.maybe(gt.Buffer),network:gt.maybe(gt.Object),output:gt.maybe(gt.Buffer),witness:gt.maybe(gt.arrayOf(gt.Buffer))}),input:gt.maybe(gt.BufferN(0)),witness:gt.maybe(gt.arrayOf(gt.Buffer))},t);var r=Wr(function(){var e=L.I.decode(t.address),r=e.words.shift(),n=L.I.fromWords(e.words);return{version:r,prefix:e.prefix,data:Zn.from(n)}}),n=Wr(function(){return ne(t.redeem.input)}),i=t.network;i||(i=t.redeem&&t.redeem.network||O);var o={network:i,name:Yi.P2WSH};if(Vr(o,"address",function(){if(o.hash){var t=L.I.toWords(o.hash);return t.unshift(0),L.I.encode(i.bech32,t)}}),Vr(o,"hash",function(){return t.output?t.output.slice(2):t.address?r().data:o.redeem&&o.redeem.output?tr(o.redeem.output):void 0}),Vr(o,"output",function(){if(o.hash)return re([Xn.OP_0,o.hash])}),Vr(o,"redeem",function(){if(t.witness)return{output:t.witness[t.witness.length-1],input:Yn,witness:t.witness.slice(0,-1)}}),Vr(o,"input",function(){if(o.witness)return Yn}),Vr(o,"witness",function(){if(t.redeem&&t.redeem.input&&t.redeem.input.length>0&&t.redeem.output&&t.redeem.output.length>0){var e=ae(n());return o.redeem=Object.assign({witness:e},t.redeem),o.redeem.input=Yn,[].concat(e,t.redeem.output)}if(t.redeem&&t.redeem.output&&t.redeem.witness)return[].concat(t.redeem.witness,t.redeem.output)}),Vr(o,"name",function(){var t=["p2wsh"];return void 0!==o.redeem&&void 0!==o.redeem.name&&t.push(o.redeem.name),t.join("-")}),e.validate){var a=Zn.from([]);if(t.address){if(r().prefix!==i.bech32)throw new TypeError("Invalid prefix or Network mismatch");if(0!==r().version)throw new TypeError("Invalid address version");if(32!==r().data.length)throw new TypeError("Invalid address data");a=r().data}if(t.hash){if(a.length>0&&!a.equals(t.hash))throw new TypeError("Hash mismatch");a=t.hash}if(t.output){if(34!==t.output.length||t.output[0]!==Xn.OP_0||32!==t.output[1])throw new TypeError("Output is invalid");var s=t.output.slice(2);if(a.length>0&&!a.equals(s))throw new TypeError("Hash mismatch");a=s}if(t.redeem){if(t.redeem.network&&t.redeem.network!==i)throw new TypeError("Network mismatch");if(t.redeem.input&&t.redeem.input.length>0&&t.redeem.witness&&t.redeem.witness.length>0)throw new TypeError("Ambiguous witness source");if(t.redeem.output){var u=ne(t.redeem.output);if(!u||u.length<1)throw new TypeError("Redeem.output is invalid");if(t.redeem.output.byteLength>3600)throw new TypeError("Redeem.output unspendable if larger than 3600 bytes");if(Jt(u)>201)throw new TypeError("Redeem.output unspendable with more than 201 non-push ops");var c=tr(t.redeem.output);if(a.length>0&&!a.equals(c))throw new TypeError("Hash mismatch");a=c}if(t.redeem.input&&!$t(n()))throw new TypeError("Non push-only scriptSig");if(t.witness&&t.redeem.witness&&!mt(t.witness,t.redeem.witness))throw new TypeError("Witness and redeem.witness mismatch");if(t.redeem.input&&n().some($n)||t.redeem.output&&(ne(t.redeem.output)||[]).some($n))throw new TypeError("redeem.input or redeem.output contains uncompressed pubkey")}if(t.witness&&t.witness.length>0){var f=t.witness[t.witness.length-1];if(t.redeem&&t.redeem.output&&!t.redeem.output.equals(f))throw new TypeError("Witness and redeem.output mismatch");if(t.witness.some($n)||(ne(f)||[]).some($n))throw new TypeError("Witness contains uncompressed pubkey")}}return Object.assign(o,t)}var Qn=y(287).hp;function ti(t){return ti="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ti(t)}function ei(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,ni(n.key),n)}}function ri(t,e,r){return(e=ni(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function ni(t){var e=function(t){if("object"!=ti(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=ti(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==ti(e)?e:e+""}var ii=gt;function oi(t){var e=t.length;return vr(e)+e}var ai=Qn.allocUnsafe(0),si=[],ui=Qn.from("0000000000000000000000000000000000000000000000000000000000000000","hex"),ci=Qn.from("0000000000000000000000000000000000000000000000000000000000000001","hex"),fi=Qn.from("ffffffffffffffff","hex"),li={script:ai,valueBuffer:fi},hi=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),ri(this,"version",1),ri(this,"locktime",0),ri(this,"ins",[]),ri(this,"outs",[])}return e=t,r=[{key:"isCoinbase",value:function(){return 1===this.ins.length&&t.isCoinbaseHash(this.ins[0].hash)}},{key:"addInput",value:function(e,r,n,i){return ii(jt(At,Lt,Ut(Lt),Ut(Bt)),arguments),Dt(n)&&(n=t.DEFAULT_SEQUENCE),this.ins.push({hash:e,index:r,script:i||ai,sequence:n,witness:si})-1}},{key:"addOutput",value:function(t,e){return ii(jt(Bt,_t),arguments),this.outs.push({script:t,value:e})-1}},{key:"hasWitnesses",value:function(){return this.ins.some(function(t){return 0!==t.witness.length})}},{key:"weight",value:function(){return 3*this.byteLength(!1)+this.byteLength(!0)}},{key:"virtualSize",value:function(){return Math.ceil(this.weight()/4)}},{key:"byteLength",value:function(){var t=(!(arguments.length>0&&void 0!==arguments[0])||arguments[0])&&this.hasWitnesses();return(t?10:8)+vr(this.ins.length)+vr(this.outs.length)+this.ins.reduce(function(t,e){return t+40+oi(e.script)},0)+this.outs.reduce(function(t,e){return t+8+oi(e.script)},0)+(t?this.ins.reduce(function(t,e){return t+(vr((r=e.witness).length)+r.reduce(function(t,e){return t+oi(e)},0));var r},0):0)}},{key:"clone",value:function(){var e=new t;return e.version=this.version,e.locktime=this.locktime,e.ins=this.ins.map(function(t){return{hash:t.hash,index:t.index,script:t.script,sequence:t.sequence,witness:t.witness}}),e.outs=this.outs.map(function(t){return{script:t.script,value:t.value}}),e}},{key:"hashForSignature",value:function(e,r,n){if(ii(jt(Lt,Bt,It),arguments),e>=this.ins.length)return ci;var i=re(ne(r).filter(function(t){return t!==it.OP_CODESEPARATOR})),o=this.clone();if((31&n)===t.SIGHASH_NONE)o.outs=[],o.ins.forEach(function(t,r){r!==e&&(t.sequence=0)});else if((31&n)===t.SIGHASH_SINGLE){if(e>=this.outs.length)return ci;o.outs.length=e+1;for(var a=0;a<e;a++)o.outs[a]=li;o.ins.forEach(function(t,r){r!==e&&(t.sequence=0)})}n&t.SIGHASH_ANYONECANPAY?(o.ins=[o.ins[e]],o.ins[0].script=i):(o.ins.forEach(function(t){t.script=ai}),o.ins[e].script=i);var s=Qn.allocUnsafe(o.byteLength(!1)+4);return s.writeInt32LE(n,s.length-4),o.__toBuffer(s,0,!1),rr(s)}},{key:"hashForWitnessV1",value:function(e,r,n,i,o,a){if(ii(jt(Lt,ii.arrayOf(Bt),ii.arrayOf(_t),Lt),arguments),n.length!==this.ins.length||r.length!==this.ins.length)throw new Error("Must supply prevout script and value for all inputs");var s=i===t.SIGHASH_DEFAULT?t.SIGHASH_ALL:i&t.SIGHASH_OUTPUT_MASK,u=(i&t.SIGHASH_INPUT_MASK)===t.SIGHASH_ANYONECANPAY,c=s===t.SIGHASH_NONE,f=s===t.SIGHASH_SINGLE,l=ai,h=ai,p=ai,d=ai,y=ai;if(!u){var b=Pr.withCapacity(36*this.ins.length);this.ins.forEach(function(t){b.writeSlice(t.hash),b.writeUInt32(t.index)}),l=tr(b.end()),b=Pr.withCapacity(8*this.ins.length),n.forEach(function(t){return b.writeUInt64(t)}),h=tr(b.end()),b=Pr.withCapacity(r.map(oi).reduce(function(t,e){return t+e})),r.forEach(function(t){return b.writeVarSlice(t)}),p=tr(b.end()),b=Pr.withCapacity(4*this.ins.length),this.ins.forEach(function(t){return b.writeUInt32(t.sequence)}),d=tr(b.end())}if(c||f){if(f&&e<this.outs.length){var g=this.outs[e],v=Pr.withCapacity(8+oi(g.script));v.writeUInt64(g.value),v.writeVarSlice(g.script),y=tr(v.end())}}else{if(!this.outs.length)throw new Error("Add outputs to the transaction before signing.");var w=this.outs.map(function(t){return 8+oi(t.script)}).reduce(function(t,e){return t+e}),m=Pr.withCapacity(w);this.outs.forEach(function(t){m.writeUInt64(t.value),m.writeVarSlice(t.script)}),y=tr(m.end())}var S=(o?2:0)+(a?1:0),_=174-(u?49:0)-(c?32:0)+(a?32:0)+(o?37:0),E=Pr.withCapacity(_);if(E.writeUInt8(i),E.writeInt32(this.version),E.writeUInt32(this.locktime),E.writeSlice(l),E.writeSlice(h),E.writeSlice(p),E.writeSlice(d),c||f||E.writeSlice(y),E.writeUInt8(S),u){var k=this.ins[e];E.writeSlice(k.hash),E.writeUInt32(k.index),E.writeUInt64(n[e]),E.writeVarSlice(r[e]),E.writeUInt32(k.sequence)}else E.writeUInt32(e);if(a){var O=Pr.withCapacity(oi(a));O.writeVarSlice(a),E.writeSlice(tr(O.end()))}return f&&E.writeSlice(y),o&&(E.writeSlice(o),E.writeUInt8(0),E.writeUInt32(4294967295)),or("TapSighash",Qn.concat([Qn.from([0]),E.end()]))}},{key:"hashForWitnessV0",value:function(e,r,n,i){ii(jt(Lt,Bt,_t,Lt),arguments);var o,a=Qn.from([]),s=ui,u=ui,c=ui;if(i&t.SIGHASH_ANYONECANPAY||(a=Qn.allocUnsafe(36*this.ins.length),o=new Pr(a,0),this.ins.forEach(function(t){o.writeSlice(t.hash),o.writeUInt32(t.index)}),u=rr(a)),i&t.SIGHASH_ANYONECANPAY||(31&i)===t.SIGHASH_SINGLE||(31&i)===t.SIGHASH_NONE||(a=Qn.allocUnsafe(4*this.ins.length),o=new Pr(a,0),this.ins.forEach(function(t){o.writeUInt32(t.sequence)}),c=rr(a)),(31&i)!==t.SIGHASH_SINGLE&&(31&i)!==t.SIGHASH_NONE){var f=this.outs.reduce(function(t,e){return t+8+oi(e.script)},0);a=Qn.allocUnsafe(f),o=new Pr(a,0),this.outs.forEach(function(t){o.writeUInt64(t.value),o.writeVarSlice(t.script)}),s=rr(a)}else if((31&i)===t.SIGHASH_SINGLE&&e<this.outs.length){var l=this.outs[e];a=Qn.allocUnsafe(8+oi(l.script)),(o=new Pr(a,0)).writeUInt64(l.value),o.writeVarSlice(l.script),s=rr(a)}a=Qn.allocUnsafe(156+oi(r)),o=new Pr(a,0);var h=this.ins[e];return o.writeInt32(this.version),o.writeSlice(u),o.writeSlice(c),o.writeSlice(h.hash),o.writeUInt32(h.index),o.writeVarSlice(r),o.writeUInt64(n),o.writeUInt32(h.sequence),o.writeSlice(s),o.writeUInt32(this.locktime),o.writeUInt32(i),rr(a)}},{key:"getHash",value:function(t){return t&&this.isCoinbase()?Qn.alloc(32,0):rr(this.__toBuffer(void 0,void 0,t))}},{key:"getId",value:function(){return Ar(this.getHash(!1)).toString("hex")}},{key:"toBuffer",value:function(t,e){return this.__toBuffer(t,e,!0)}},{key:"toHex",value:function(){return this.toBuffer(void 0,void 0).toString("hex")}},{key:"setInputScript",value:function(t,e){ii(jt(It,Bt),arguments),this.ins[t].script=e}},{key:"setWitness",value:function(t,e){ii(jt(It,[Bt]),arguments),this.ins[t].witness=e}},{key:"__toBuffer",value:function(e,r){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];e||(e=Qn.allocUnsafe(this.byteLength(n)));var i=new Pr(e,r||0);i.writeInt32(this.version);var o=n&&this.hasWitnesses();return o&&(i.writeUInt8(t.ADVANCED_TRANSACTION_MARKER),i.writeUInt8(t.ADVANCED_TRANSACTION_FLAG)),i.writeVarInt(this.ins.length),this.ins.forEach(function(t){i.writeSlice(t.hash),i.writeUInt32(t.index),i.writeVarSlice(t.script),i.writeUInt32(t.sequence)}),i.writeVarInt(this.outs.length),this.outs.forEach(function(t){void 0!==t.value?i.writeUInt64(t.value):i.writeSlice(t.valueBuffer),i.writeVarSlice(t.script)}),o&&this.ins.forEach(function(t){i.writeVector(t.witness)}),i.writeUInt32(this.locktime),void 0!==r?e.slice(r,i.offset):e}}],n=[{key:"fromBuffer",value:function(e,r){var n=new xr(e),i=new t;i.version=n.readInt32();var o=n.readUInt8(),a=n.readUInt8(),s=!1;o===t.ADVANCED_TRANSACTION_MARKER&&a===t.ADVANCED_TRANSACTION_FLAG?s=!0:n.offset-=2;for(var u=n.readVarInt(),c=0;c<u;++c){var f=n.readSlice(32),l=n.readUInt32(),h=n.readVarSlice(),p=n.readUInt32();i.ins.push({hash:f,index:l,script:h,sequence:p,witness:si})}for(var d=n.readVarInt(),y=0;y<d;++y)i.outs.push({value:n.readUInt64(),script:n.readVarSlice()});if(s){for(var b=0;b<u;++b)i.ins[b].witness=n.readVector();if(!i.hasWitnesses())throw new Error("Transaction has superfluous witness data")}if(i.locktime=n.readUInt32(),r)return i;if(n.offset!==e.length)throw new Error("Transaction has unexpected data");return i}},{key:"fromHex",value:function(e){return t.fromBuffer(Qn.from(e,"hex"),!1)}},{key:"isCoinbaseHash",value:function(t){ii(At,t);for(var e=0;e<32;++e)if(0!==t[e])return!1;return!0}}],r&&ei(e.prototype,r),n&&ei(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,r,n}();ri(hi,"DEFAULT_SEQUENCE",4294967295),ri(hi,"SIGHASH_DEFAULT",0),ri(hi,"SIGHASH_ALL",1),ri(hi,"SIGHASH_NONE",2),ri(hi,"SIGHASH_SINGLE",3),ri(hi,"SIGHASH_ANYONECANPAY",128),ri(hi,"SIGHASH_OUTPUT_MASK",3),ri(hi,"SIGHASH_INPUT_MASK",128),ri(hi,"ADVANCED_TRANSACTION_MARKER",0),ri(hi,"ADVANCED_TRANSACTION_FLAG",1),ri(hi,"TRUC_VERSION",3),ri(hi,"TRUC_MAX_VSIZE",1e4),ri(hi,"TRUC_CHILD_MAX_VSIZE",1e3);var pi=y(287).hp;function di(t,e){if(t){if("string"==typeof t)return yi(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?yi(t,e):void 0}}function yi(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}var bi=function(t){var e=32===t.length?t:t.slice(1,33);return pi.isBuffer(e)?e:pi.from(e)};function gi(t,e,r){var n=function(t,e,r){if(!t.tapScriptSig||!t.tapScriptSig.length)throw new Error("Can not finalize taproot input #".concat(e,". No tapleaf script signature provided."));var n=(t.tapLeafScript||[]).sort(function(t,e){return t.controlBlock.length-e.controlBlock.length}).find(function(e){return function(t,e,r){var n=Dr({output:t.script,version:t.leafVersion});return(!r||r.equals(n))&&void 0!==e.find(function(t){return t.leafHash.equals(n)})}(e,t.tapScriptSig,r)});if(!n)throw new Error("Can not finalize taproot input #".concat(e,". Signature for tapleaf script not found."));return n}(e,t,r);try{var i=function(t,e){var r=Dr({output:e.script,version:e.leafVersion});return(t.tapScriptSig||[]).filter(function(t){return t.leafHash.equals(r)}).map(function(t){return function(t,e){return Object.assign({positionInScript:zi(e.pubkey,t)},e)}(e.script,t)}).sort(function(t,e){return e.positionInScript-t.positionInScript}).map(function(t){return t.signature})}(e,n);return{finalScriptWitness:Vi(i.concat(n.script).concat(n.controlBlock))}}catch(e){throw new Error("Can not finalize taproot input #".concat(t,": ").concat(e))}}function vi(t,e){var r=e?pi.from([e]):pi.from([]);return pi.concat([t,r])}function wi(t){return t&&!!(t.tapInternalKey||t.tapMerkleRoot||t.tapLeafScript&&t.tapLeafScript.length||t.tapBip32Derivation&&t.tapBip32Derivation.length||t.witnessUtxo&&Ki(t.witnessUtxo.script))}function mi(t,e){return t&&!!(t.tapInternalKey||t.tapTree||t.tapBip32Derivation&&t.tapBip32Derivation.length||e&&Ki(e))}function Si(t,e,r){!function(t,e,r){var n=wi(t)&&Ai(e),i=Ai(t)&&wi(e),o=t===e&&wi(e)&&Ai(e);if(n||i||o)throw new Error("Invalid arguments for Psbt.".concat(r,". ")+"Cannot use both taproot and non-taproot fields.")}(t,e,r),function(t,e,r){if(e.tapMerkleRoot){var n=(e.tapLeafScript||[]).every(function(t){return Ti(t,e.tapMerkleRoot)}),i=(t.tapLeafScript||[]).every(function(t){return Ti(t,e.tapMerkleRoot)});if(!n||!i)throw new Error("Invalid arguments for Psbt.".concat(r,". Tapleaf not part of taptree."))}else if(t.tapMerkleRoot&&!(e.tapLeafScript||[]).every(function(e){return Ti(e,t.tapMerkleRoot)}))throw new Error("Invalid arguments for Psbt.".concat(r,". Tapleaf not part of taptree."))}(t,e,r)}function _i(t,e,r){!function(t,e,r){var n=mi(t)&&Ai(e),i=Ai(t)&&mi(e),o=t===e&&mi(e)&&Ai(e);if(n||i||o)throw new Error("Invalid arguments for Psbt.".concat(r,". ")+"Cannot use both taproot and non-taproot fields.")}(t,e,r),function(t,e){if(e.tapTree||e.tapInternalKey){var r=e.tapInternalKey||t.tapInternalKey,n=e.tapTree||t.tapTree;if(r){var i=t.script,o=function(t,e){return Vn({internalPubkey:t,scriptTree:e&&Ei(e.leaves)}).output}(r,n);if(i&&!i.equals(o))throw new Error("Error adding output. Script or address missmatch.")}}}(t,e)}function Ei(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return 1===t.length&&0===t[0].depth?{output:t[0].script,version:t[0].leafVersion}:function(t){var e,r,n=function(t){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=di(t))){e&&(t=e);var r=0,n=function(){};return{s:n,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:n}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,o=!0,a=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return o=t.done,t},e:function(t){a=!0,i=t},f:function(){try{o||null==e.return||e.return()}finally{if(a)throw i}}}}(t);try{for(n.s();!(r=n.n()).done;)if(!(e=Oi(r.value,e)))throw new Error("No room left to insert tapleaf in tree")}catch(t){n.e(t)}finally{n.f()}return e}(t)}function ki(t){return{signature:t.slice(0,64),hashType:t.slice(64)[0]||hi.SIGHASH_DEFAULT}}function Oi(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;if(r>jr)throw new Error("Max taptree depth exceeded.");if(t.depth===r)return e?void 0:{output:t.script,version:t.leafVersion};if(!kt(e)){var n=Oi(t,e&&e[0],r+1);if(n)return[n,e&&e[1]];var i=Oi(t,e&&e[1],r+1);return i?[e&&e[0],i]:void 0}}function Ti(t,e){if(!e)return!0;var r=Dr({output:t.script,version:t.leafVersion});return Lr(t.controlBlock,r).equals(e)}function Ai(t){return t&&!!(t.redeemScript||t.witnessScript||t.bip32Derivation&&t.bip32Derivation.length)}var Ii=y(287).hp,Pi=it,xi=16,Bi=2,Ri=40;function Ui(t,e){if(!(t.address||t.output||t.program||void 0!==t.deploymentVersion&&t.hash160))throw new TypeError("At least one of address, output or program must be provided");e=Object.assign({validate:!0},e||{}),gt({address:gt.maybe(gt.String),output:gt.maybe(gt.Buffer),program:gt.maybe(gt.Buffer),network:gt.maybe(gt.Object),deploymentVersion:gt.maybe(gt.Number),hash160:gt.maybe(gt.BufferN(20))},t);var r=function(){if(void 0!==t.deploymentVersion&&void 0!==t.hash160){if(20!==t.hash160.length)throw new TypeError("hash160 must be exactly 20 bytes");if(t.deploymentVersion<0||t.deploymentVersion>255)throw new TypeError("deploymentVersion must fit in one byte");return Ii.concat([Ii.of(t.deploymentVersion),t.hash160])}},n=Wr(function(){return Te(t.address)}),i=t.network||O,o={name:Yi.P2OP,network:i,deploymentVersion:0};if(Vr(o,"program",function(){if(t.program)return t.program;var e=r();if(e)return e;if(t.output){if(t.output[0]!==Pi.OP_16)throw new TypeError("Invalid P2OP script");var i,o=1;if(t.output[1]<76)i=t.output[1],o=2;else{if(76!==t.output[1])throw new TypeError("Unsupported push opcode in P2OP script");i=t.output[2],o=3}return t.output.slice(o,o+i)}return t.address?n().data:void 0}),Vr(o,"deploymentVersion",function(){if(o.program)return o.program[0]}),Vr(o,"hash160",function(){if(o.program)return o.program.slice(1)}),Vr(o,"output",function(){if(o.program)return re([Pi.OP_16,o.program])}),Vr(o,"address",function(){if(o.program){if(!i.bech32Opnet)throw new TypeError("Network does not support opnet");var t=L.p2.toWords(o.program);return t.unshift(xi),L.p2.encode(i.bech32Opnet,t)}}),e.validate){var a=yt.hp.alloc(0);if(t.address){var s=n();if(i.bech32Opnet!==s.prefix)throw new TypeError("Invalid prefix or network mismatch");if(s.version!==xi)throw new TypeError("Invalid witness version for p2op");if(s.data.length<Bi||s.data.length>Ri)throw new TypeError("Invalid witness program length");a=s.data}if(t.program){if(a.length&&!a.equals(t.program))throw new TypeError("Program mismatch");a=t.program}if(!a.length&&void 0!==t.deploymentVersion&&t.hash160&&(a=r()),t.output){var u=o.program;if(a.length&&!a.equals(u))throw new TypeError("Program mismatch (output vs other source)");a=u}if(a.length<Bi||a.length>Ri)throw new TypeError("Witness program must be 2–40 bytes. Was ".concat(a.length," bytes"));if(void 0!==t.deploymentVersion&&t.deploymentVersion!==a[0])throw new TypeError("deploymentVersion mismatch");if(t.hash160&&!t.hash160.equals(a.slice(1)))throw new TypeError("hash160 mismatch")}return Object.assign(o,t)}var ji=y(287).hp;function Ni(t){return function(e){try{return t({output:e}),!0}catch(t){return!1}}}var Li=Ni(Xr),Ci=Ni($r),Fi=Ni(Qi),Di=Ni(zn),Hi=Ni(Jn),Mi=Ni(Dn),Ki=Ni(Vn);function Vi(t){var e,r=ji.allocUnsafe(0);function n(t){var e=r.length,n=Ln.encodingLength(t);r=ji.concat([r,ji.allocUnsafe(n)]),Ln.encode(t,r,e)}return n((e=t).length),e.forEach(function(t){n(t.length),function(t){r=ji.concat([r,ji.from(t)])}(t)}),r}function Wi(t){if(32!==t.length){if([33,65].includes(t.length)){var e;try{e=bn.fromHex(t)}catch(t){throw new Error("Invalid secp256k1 public key bytes. Cannot parse.")}var r=Gi(e.x),n=Gi(e.y),i=e.y%2n==0n?6:7,o=ji.alloc(65);return o[0]=i,r.copy(o,1),n.copy(o,33),{hybrid:o,uncompressed:ji.concat([ji.from([4]),r,n])}}console.warn("Unsupported key length=".concat(t.length,". Must be 33 (compressed) or 65 (uncompressed)."))}}function Gi(t){var e=t.toString(16);return(e=e.padStart(64,"0")).length>64&&(e=e.slice(-64)),ji.from(e,"hex")}function qi(t,e){if(t.equals(e))return!0;if(65===t.length&&65===e.length){var r=ji.from(t),n=ji.from(e);return 6!==r[0]&&7!==r[0]||(r[0]=4),6!==n[0]&&7!==n[0]||(n[0]=4),r.equals(n)}return!1}function zi(t,e){var r=ne(e);if(null===r)throw new Error("Unknown script error");var n=er(t),i=bi(t),o=Wi(t),a=null!=o&&o.hybrid?er(o.hybrid):void 0,s=null!=o&&o.uncompressed?er(o.uncompressed):void 0;return r.findIndex(function(e){if("number"==typeof e)return!1;if(qi(e,t))return!0;if(qi(e,i))return!0;if(e.equals(n))return!0;if(o){if(qi(e,o.uncompressed))return!0;if(qi(e,o.hybrid))return!0;if(a&&e.equals(a)||s&&e.equals(s))return!0}})}function Zi(t,e){return-1!==zi(t,e)}function Xi(t,e,r){var n=e(t).hashType,i=[];switch(n&hi.SIGHASH_ANYONECANPAY&&i.push("addInput"),31&n){case hi.SIGHASH_ALL:break;case hi.SIGHASH_SINGLE:case hi.SIGHASH_NONE:i.push("addOutput"),i.push("setInputSequence")}return-1===i.indexOf(r)}Ni(Ui);var Yi,$i=y(287).hp,Ji=it;function Qi(t,e){if(!(t.address||t.hash||t.output||t.pubkey||t.input))throw new TypeError("Not enough data");e=Object.assign({validate:!0},e||{}),gt({network:gt.maybe(gt.Object),address:gt.maybe(gt.String),hash:gt.maybe(gt.BufferN(20)),output:gt.maybe(gt.BufferN(25)),pubkey:gt.maybe(St),signature:gt.maybe(ce),input:gt.maybe(gt.Buffer)},t);var r=Wr(function(){var e=$i.from(et.decode(t.address));return{version:e.readUInt8(0),hash:e.slice(1)}}),n=Wr(function(){return ne(t.input)}),i=t.network||O,o={name:Yi.P2PKH,network:i,hash:void 0};if(Vr(o,"address",function(){if(o.hash){var t=$i.allocUnsafe(21);return t.writeUInt8(i.pubKeyHash,0),o.hash.copy(t,1),et.encode(t)}}),Vr(o,"hash",function(){return t.output?t.output.slice(3,23):t.address?r().hash:t.pubkey||o.pubkey?er(t.pubkey||o.pubkey):void 0}),Vr(o,"output",function(){if(o.hash)return re([Ji.OP_DUP,Ji.OP_HASH160,o.hash,Ji.OP_EQUALVERIFY,Ji.OP_CHECKSIG])}),Vr(o,"pubkey",function(){if(t.input)return n()[1]}),Vr(o,"signature",function(){if(t.input)return n()[0]}),Vr(o,"input",function(){if(t.pubkey&&t.signature){var e=t.pubkey;if(t.useHybrid||t.useUncompressed){var r=Wi(t.pubkey);r&&(e=t.useUncompressed?r.uncompressed:r.hybrid)}return re([t.signature,e])}}),Vr(o,"witness",function(){if(o.input)return[]}),e.validate){var a=$i.from([]);if(t.address){if(r().version!==i.pubKeyHash)throw new TypeError("Invalid version or Network mismatch");if(20!==r().hash.length)throw new TypeError("Invalid address");a=r().hash}if(t.hash){if(a.length>0&&!a.equals(t.hash))throw new TypeError("Hash mismatch");a=t.hash}if(t.output){if(25!==t.output.length||t.output[0]!==Ji.OP_DUP||t.output[1]!==Ji.OP_HASH160||20!==t.output[2]||t.output[23]!==Ji.OP_EQUALVERIFY||t.output[24]!==Ji.OP_CHECKSIG)throw new TypeError("Output is invalid");var s=t.output.slice(3,23);if(a.length>0&&!a.equals(s))throw new TypeError("Hash mismatch");a=s}if(t.pubkey){var u=er(t.pubkey),c=a.length>0&&!a.equals(u);if(c&&(33===t.pubkey.length&&(2===t.pubkey[0]||3===t.pubkey[0])||65===t.pubkey.length&&4===t.pubkey[0])){var f=Wi(t.pubkey);if(f){var l=er(f.uncompressed);if(a.equals(l))c=!1,t.useUncompressed=!0;else{var h=er(f.hybrid);(c=!a.equals(h))||(t.useHybrid=!0)}}}if(c)throw new TypeError("Hash mismatch");a=u}if(t.input){var p=n();if(2!==p.length)throw new TypeError("Input is invalid");if(!ce(p[0]))throw new TypeError("Input has invalid signature");if(!St(p[1]))throw new TypeError("Input has invalid pubkey");if(t.signature&&!t.signature.equals(p[0]))throw new TypeError("Signature mismatch");if(t.pubkey&&!t.pubkey.equals(p[1]))throw new TypeError("Pubkey mismatch");var d=er(p[1]);if(a.length>0&&!a.equals(d))throw new TypeError("Hash mismatch (input)")}}return Object.assign(o,t)}!function(t){t.P2PK="p2pk",t.P2PKH="p2pkh",t.P2SH="p2sh",t.P2MS="p2ms",t.P2WPKH="p2wpkh",t.P2WSH="p2wsh",t.P2TR="p2tr",t.P2OP="p2op",t.Embed="embed",t.ScriptRedeem="scriptRedeem"}(Yi||(Yi={}));var to=y(287).hp,eo=y(287).hp;function ro(t){return ro="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ro(t)}function no(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,oo(n.key),n)}}function io(t,e,r){return(e=oo(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function oo(t){var e=function(t){if("object"!=ro(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=ro(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==ro(e)?e:e+""}var ao=gt,so=new TypeError("Cannot compute merkle root for zero transactions"),uo=new TypeError("Cannot compute witness commit for non-segwit block");function co(t){return t instanceof Array&&t[0]&&t[0].ins&&t[0].ins instanceof Array&&t[0].ins[0]&&t[0].ins[0].witness&&t[0].ins[0].witness instanceof Array&&t[0].ins[0].witness.length>0}!function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),io(this,"version",1),io(this,"prevHash",void 0),io(this,"merkleRoot",void 0),io(this,"timestamp",0),io(this,"witnessCommit",void 0),io(this,"bits",0),io(this,"nonce",0),io(this,"transactions",void 0)}return e=t,r=[{key:"getWitnessCommit",value:function(){if(!co(this.transactions))return null;var t=this.transactions[0].outs.filter(function(t){return t.script.slice(0,6).equals(eo.from("6a24aa21a9ed","hex"))}).map(function(t){return t.script.slice(6,38)});if(0===t.length)return null;var e=t[t.length-1];return e instanceof eo&&32===e.length?e:null}},{key:"hasWitnessCommit",value:function(){return this.witnessCommit instanceof eo&&32===this.witnessCommit.length||null!==this.getWitnessCommit()}},{key:"hasWitness",value:function(){return(t=this.transactions)instanceof Array&&t.some(function(t){return"object"===ro(t)&&t.ins instanceof Array&&t.ins.some(function(t){return"object"===ro(t)&&t.witness instanceof Array&&t.witness.length>0})});var t}},{key:"weight",value:function(){return 3*this.byteLength(!1,!1)+this.byteLength(!1,!0)}},{key:"byteLength",value:function(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return t||!this.transactions?80:80+vr(this.transactions.length)+this.transactions.reduce(function(t,r){return t+r.byteLength(e)},0)}},{key:"getHash",value:function(){return rr(this.toBuffer(!0))}},{key:"getId",value:function(){return Ar(this.getHash()).toString("hex")}},{key:"getUTCDate",value:function(){var t=new Date(0);return t.setUTCSeconds(this.timestamp),t}},{key:"toBuffer",value:function(t){var e=eo.allocUnsafe(this.byteLength(t)),r=new Pr(e);if(r.writeInt32(this.version),r.writeSlice(this.prevHash),r.writeSlice(this.merkleRoot),r.writeUInt32(this.timestamp),r.writeUInt32(this.bits),r.writeUInt32(this.nonce),t||!this.transactions)return e;var n=br(this.transactions.length,e,r.offset);return r.offset+=n.bytes,this.transactions.forEach(function(t){var n=t.byteLength();t.toBuffer(e,r.offset),r.offset+=n}),e}},{key:"toHex",value:function(t){return this.toBuffer(t).toString("hex")}},{key:"checkTxRoots",value:function(){var t=this.hasWitnessCommit();return!(!t&&this.hasWitness())&&this.__checkMerkleRoot()&&(!t||this.__checkWitnessCommit())}},{key:"checkProofOfWork",value:function(){var e=Ar(this.getHash()),r=t.calculateTarget(this.bits);return e.compare(r)<=0}},{key:"__checkMerkleRoot",value:function(){if(!this.transactions)throw so;var e=t.calculateMerkleRoot(this.transactions);return 0===this.merkleRoot.compare(e)}},{key:"__checkWitnessCommit",value:function(){if(!this.transactions)throw so;if(!this.hasWitnessCommit())throw uo;var e=t.calculateMerkleRoot(this.transactions,!0);return 0===this.witnessCommit.compare(e)}}],n=[{key:"fromBuffer",value:function(e){if(e.length<80)throw new Error("Buffer too small (< 80 bytes)");var r=new xr(e),n=new t;if(n.version=r.readInt32(),n.prevHash=r.readSlice(32),n.merkleRoot=r.readSlice(32),n.timestamp=r.readUInt32(),n.bits=r.readUInt32(),n.nonce=r.readUInt32(),80===e.length)return n;var i=function(){var t=hi.fromBuffer(r.buffer.slice(r.offset),!0);return r.offset+=t.byteLength(),t},o=r.readVarInt();n.transactions=[];for(var a=0;a<o;++a){var s=i();n.transactions.push(s)}var u=n.getWitnessCommit();return u&&(n.witnessCommit=u),n}},{key:"fromHex",value:function(e){return t.fromBuffer(eo.from(e,"hex"))}},{key:"calculateTarget",value:function(t){var e=((4278190080&t)>>24)-3,r=8388607&t,n=eo.alloc(32,0);return n.writeUIntBE(r,29-e,3),n}},{key:"calculateMerkleRoot",value:function(t,e){if(ao([{getHash:Ct}],t),0===t.length)throw so;if(e&&!co(t))throw uo;var r=function(t,e){if(!Array.isArray(t))throw TypeError("Expected values Array");if("function"!=typeof e)throw TypeError("Expected digest Function");for(var r=t.length,n=t.concat();r>1;){for(var i=0,o=0;o<r;o+=2,++i){var a=n[o],s=o+1===r?a:n[o+1],u=to.concat([a,s]);n[i]=e(u)}r=i}return n[0]}(t.map(function(t){return t.getHash(e)}),rr);return e?rr(eo.concat([r,t[0].ins[0].witness[0]])):r}}],r&&no(e.prototype,r),n&&no(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,r,n}();var fo=y(614),lo=y(699),ho=y(287).hp;function po(t){return po="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},po(t)}function yo(){yo=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,i="function"==typeof Symbol?Symbol:{},o=i.iterator||"@@iterator",a=i.asyncIterator||"@@asyncIterator",s=i.toStringTag||"@@toStringTag";function u(t,e,r,n){return Object.defineProperty(t,e,{value:r,enumerable:!n,configurable:!n,writable:!n})}try{u({},"")}catch(t){u=function(t,e,r){return t[e]=r}}function c(e,r,n,i){var o=r&&r.prototype instanceof h?r:h,a=Object.create(o.prototype);return u(a,"_invoke",function(e,r,n){var i=1;return function(o,a){if(3===i)throw Error("Generator is already running");if(4===i){if("throw"===o)throw a;return{value:t,done:!0}}for(n.method=o,n.arg=a;;){var s=n.delegate;if(s){var u=S(s,n);if(u){if(u===l)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(1===i)throw i=4,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=3;var c=f(e,r,n);if("normal"===c.type){if(i=n.done?4:2,c.arg===l)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(i=4,n.method="throw",n.arg=c.arg)}}}(e,n,new k(i||[])),!0),a}function f(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=c;var l={};function h(){}function p(){}function d(){}var y={};u(y,o,function(){return this});var b=Object.getPrototypeOf,g=b&&b(b(O([])));g&&g!==r&&n.call(g,o)&&(y=g);var v=d.prototype=h.prototype=Object.create(y);function w(t){["next","throw","return"].forEach(function(e){u(t,e,function(t){return this._invoke(e,t)})})}function m(t,e){function r(i,o,a,s){var u=f(t[i],t,o);if("throw"!==u.type){var c=u.arg,l=c.value;return l&&"object"==po(l)&&n.call(l,"__await")?e.resolve(l.__await).then(function(t){r("next",t,a,s)},function(t){r("throw",t,a,s)}):e.resolve(l).then(function(t){c.value=t,a(c)},function(t){return r("throw",t,a,s)})}s(u.arg)}var i;u(this,"_invoke",function(t,n){function o(){return new e(function(e,i){r(t,n,e,i)})}return i=i?i.then(o,o):o()},!0)}function S(e,r){var n=r.method,i=e.i[n];if(i===t)return r.delegate=null,"throw"===n&&e.i.return&&(r.method="return",r.arg=t,S(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),l;var o=f(i,e.i,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,l;var a=o.arg;return a?a.done?(r[e.r]=a.value,r.next=e.n,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,l):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,l)}function _(t){this.tryEntries.push(t)}function E(e){var r=e[4]||{};r.type="normal",r.arg=t,e[4]=r}function k(t){this.tryEntries=[[-1]],t.forEach(_,this),this.reset(!0)}function O(e){if(null!=e){var r=e[o];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,a=function r(){for(;++i<e.length;)if(n.call(e,i))return r.value=e[i],r.done=!1,r;return r.value=t,r.done=!0,r};return a.next=a}}throw new TypeError(po(e)+" is not iterable")}return p.prototype=d,u(v,"constructor",d),u(d,"constructor",p),p.displayName=u(d,s,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===p||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,d):(t.__proto__=d,u(t,s,"GeneratorFunction")),t.prototype=Object.create(v),t},e.awrap=function(t){return{__await:t}},w(m.prototype),u(m.prototype,a,function(){return this}),e.AsyncIterator=m,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new m(c(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then(function(t){return t.done?t.value:a.next()})},w(v),u(v,s,"Generator"),u(v,o,function(){return this}),u(v,"toString",function(){return"[object Generator]"}),e.keys=function(t){var e=Object(t),r=[];for(var n in e)r.unshift(n);return function t(){for(;r.length;)if((n=r.pop())in e)return t.value=n,t.done=!1,t;return t.done=!0,t}},e.values=O,k.prototype={constructor:k,reset:function(e){if(this.prev=this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(E),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0][4];if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function n(t){a.type="throw",a.arg=e,r.next=t}for(var i=r.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],a=o[4],s=this.prev,u=o[1],c=o[2];if(-1===o[0])return n("end"),!1;if(!u&&!c)throw Error("try statement without catch or finally");if(null!=o[0]&&o[0]<=s){if(s<u)return this.method="next",this.arg=t,n(u),!0;if(s<c)return n(c),!1}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n[0]>-1&&n[0]<=this.prev&&this.prev<n[2]){var i=n;break}}i&&("break"===t||"continue"===t)&&i[0]<=e&&e<=i[2]&&(i=null);var o=i?i[4]:{};return o.type=t,o.arg=e,i?(this.method="next",this.next=i[2],l):this.complete(o)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),l},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r[2]===t)return this.complete(r[4],r[3]),E(r),l}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r[0]===t){var n=r[4];if("throw"===n.type){var i=n.arg;E(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={i:O(e),r,n},"next"===this.method&&(this.arg=t),l}},e}function bo(t,e,r,n,i,o,a){try{var s=t[o](a),u=s.value}catch(t){return void r(t)}s.done?e(u):Promise.resolve(u).then(n,i)}function go(t){return function(){var e=this,r=arguments;return new Promise(function(n,i){var o=t.apply(e,r);function a(t){bo(o,n,i,a,s,"next",t)}function s(t){bo(o,n,i,a,s,"throw",t)}a(void 0)})}}function vo(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=mo(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}function wo(t){return function(t){if(Array.isArray(t))return So(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||mo(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function mo(t,e){if(t){if("string"==typeof t)return So(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?So(t,e):void 0}}function So(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function _o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function Eo(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Oo(n.key),n)}}function ko(t,e,r){return e&&Eo(t.prototype,e),r&&Eo(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function Oo(t){var e=function(t){if("object"!=po(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=po(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==po(e)?e:e+""}var To={network:O,maximumFeeRate:5e3},Ao=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new fo.i(new Po);_o(this,t),this.data=r,this.opts=Object.assign({},To,e),this.__CACHE={__NON_WITNESS_UTXO_TX_CACHE:[],__NON_WITNESS_UTXO_BUF_CACHE:[],__TX_IN_CACHE:{},__TX:this.data.globalMap.unsignedTx.tx,__UNSAFE_SIGN_NONSEGWIT:!1},3===e.version?this.setVersionTRUC():0===this.data.inputs.length&&this.setVersion(2);var n=function(t,e,r,n){Object.defineProperty(t,e,{enumerable:r,writable:n})};n(this,"__CACHE",!1,!0),n(this,"opts",!1,!0)}return ko(t,[{key:"inputCount",get:function(){return this.data.inputs.length}},{key:"version",get:function(){return this.__CACHE.__TX.version},set:function(t){this.setVersion(t)}},{key:"locktime",get:function(){return this.__CACHE.__TX.locktime},set:function(t){this.setLocktime(t)}},{key:"txInputs",get:function(){return this.__CACHE.__TX.ins.map(function(t){return{hash:Ir(t.hash),index:t.index,sequence:t.sequence}})}},{key:"txOutputs",get:function(){var t=this;return this.__CACHE.__TX.outs.map(function(e){var r;try{r=Pe(e.script,t.opts.network)}catch(t){}return{script:Ir(e.script),value:e.value,address:r}})}},{key:"combine",value:function(){for(var t,e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];return(t=this.data).combine.apply(t,wo(r.map(function(t){return t.data}))),this}},{key:"clone",value:function(){return t.fromBuffer(this.data.toBuffer(),JSON.parse(JSON.stringify(this.opts)))}},{key:"setMaximumFeeRate",value:function(t){jo(t),this.opts.maximumFeeRate=t}},{key:"setVersion",value:function(t){jo(t),No(this.data.inputs,"setVersion");var e=this.__CACHE;return e.__TX.version=t,e.__EXTRACTED_TX=void 0,this}},{key:"setVersionTRUC",value:function(){return this.setVersion(hi.TRUC_VERSION)}},{key:"setLocktime",value:function(t){jo(t),No(this.data.inputs,"setLocktime");var e=this.__CACHE;return e.__TX.locktime=t,e.__EXTRACTED_TX=void 0,this}},{key:"setInputSequence",value:function(t,e){jo(e),No(this.data.inputs,"setInputSequence");var r=this.__CACHE;if(r.__TX.ins.length<=t)throw new Error("Input index too high");return r.__TX.ins[t].sequence=e,r.__EXTRACTED_TX=void 0,this}},{key:"addInputs",value:function(t){var e=this,r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return t.forEach(function(t){return e.addInput(t,r)}),this}},{key:"addInput",value:function(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(!t||void 0===t.hash||void 0===t.index)throw new Error("Invalid arguments for Psbt.addInput. Requires single object with at least [hash] and [index]");Si(t,t,"addInput"),e&&No(this.data.inputs,"addInput"),t.witnessScript&&ia(t.witnessScript);var r=this.__CACHE;this.data.addInput(t),Co(r,r.__TX.ins[r.__TX.ins.length-1]);var n=this.data.inputs.length-1,i=this.data.inputs[n];return i.nonWitnessUtxo&&$o(this.__CACHE,i,n),r.__FEE=void 0,r.__FEE_RATE=void 0,r.__EXTRACTED_TX=void 0,this}},{key:"addOutputs",value:function(t){var e=this;return t.forEach(function(t){return e.addOutput(t)}),this}},{key:"addOutput",value:function(t){if(arguments.length>1||!t||void 0===t.value||void 0===t.address&&void 0===t.script)throw new Error("Invalid arguments for Psbt.addOutput. Requires single object with at least [script or address] and [value]");No(this.data.inputs,"addOutput");var e=t.address;if("string"==typeof e){var r=xe(e,this.opts.network);t=Object.assign({},t,{script:r})}_i(t,t,"addOutput");var n=this.__CACHE;return this.data.addOutput(t),n.__FEE=void 0,n.__FEE_RATE=void 0,n.__EXTRACTED_TX=void 0,this}},{key:"extractTransaction",value:function(t,e){if(e&&(this.data.inputs=this.data.inputs.filter(function(t){return!t.partialSig})),!this.data.inputs.every(Ro))throw new Error("Not finalized");var r=this.__CACHE;if(t||function(t,e,r){var n=e.__FEE_RATE||t.getFeeRate(),i=e.__EXTRACTED_TX.virtualSize(),o=n*i;if(n>=r.maximumFeeRate)throw new Error("Warning: You are paying around ".concat((o/1e8).toFixed(8)," in ")+"fees, which is ".concat(n," satoshi per byte for a transaction ")+"with a VSize of ".concat(i," bytes (segwit counted as 0.25 byte per ")+"byte). Use setMaximumFeeRate method to raise your threshold, or pass true to the first arg of extractTransaction.")}(this,r,this.opts),r.__EXTRACTED_TX)return r.__EXTRACTED_TX;var n=r.__TX.clone();return Jo(this.data.inputs,n,r,!0,e),n}},{key:"getFeeRate",value:function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return Mo("__FEE_RATE","fee rate",this.data.inputs,this.__CACHE,t)}},{key:"getFee",value:function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return Mo("__FEE","fee",this.data.inputs,this.__CACHE,t)}},{key:"finalizeAllInputs",value:function(){var t=this;return(0,lo.checkForInput)(this.data.inputs,0),aa(this.data.inputs.length).forEach(function(e){return t.finalizeInput(e)}),this}},{key:"finalizeInput",value:function(t,e,r){var n=(0,lo.checkForInput)(this.data.inputs,t);return wi(n)?this._finalizeTaprootInput(t,n,void 0,e):this._finalizeInput(t,n,e,null==r||r)}},{key:"finalizeTaprootInput",value:function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:gi,n=(0,lo.checkForInput)(this.data.inputs,t);if(wi(n))return this._finalizeTaprootInput(t,n,e,r);throw new Error("Cannot finalize input #".concat(t,". Not Taproot."))}},{key:"getInputType",value:function(t){var e=(0,lo.checkForInput)(this.data.inputs,t),r=na(ta(t,e,this.__CACHE),t,"input",e.redeemScript||function(t){if(t){var e=ne(t);if(e){var r=e[e.length-1];if(ho.isBuffer(r)&&!ra(r)&&!ce(r)&&ne(r))return r}}}(e.finalScriptSig),e.witnessScript||function(t){if(t){var e=Yo(t),r=e[e.length-1];if(!ra(r)&&ne(r))return r}}(e.finalScriptWitness));return("raw"===r.type?"":r.type+"-")+oa(r.meaningfulScript)}},{key:"inputHasPubkey",value:function(t,e){return function(t,e,r,n){return Zi(t,na(ta(r,e,n),r,"input",e.redeemScript,e.witnessScript).meaningfulScript)}(e,(0,lo.checkForInput)(this.data.inputs,t),t,this.__CACHE)}},{key:"inputHasHDKey",value:function(t,e){var r=(0,lo.checkForInput)(this.data.inputs,t),n=Uo(e);return!!r.bip32Derivation&&r.bip32Derivation.some(n)}},{key:"outputHasPubkey",value:function(t,e){return function(t,e,r,n){return Zi(t,na(n.__TX.outs[r].script,r,"output",e.redeemScript,e.witnessScript).meaningfulScript)}(e,(0,lo.checkForOutput)(this.data.outputs,t),t,this.__CACHE)}},{key:"outputHasHDKey",value:function(t,e){var r=(0,lo.checkForOutput)(this.data.outputs,t),n=Uo(e);return!!r.bip32Derivation&&r.bip32Derivation.some(n)}},{key:"validateSignaturesOfAllInputs",value:function(t){var e=this;return(0,lo.checkForInput)(this.data.inputs,0),aa(this.data.inputs.length).map(function(r){return e.validateSignaturesOfInput(r,t)}).reduce(function(t,e){return!0===e&&t},!0)}},{key:"validateSignaturesOfInput",value:function(t,e,r){return wi(this.data.inputs[t])?this.validateSignaturesOfTaprootInput(t,e,r):this._validateSignaturesOfInput(t,e,r)}},{key:"signAllInputsHD",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[hi.SIGHASH_ALL];if(!t||!t.publicKey||!t.fingerprint)throw new Error("Need HDSigner to sign input");var r,n=[],i=vo(aa(this.data.inputs.length));try{for(i.s();!(r=i.n()).done;){var o=r.value;try{this.signInputHD(o,t,e),n.push(!0)}catch(t){n.push(!1)}}}catch(t){i.e(t)}finally{i.f()}if(n.every(function(t){return!1===t}))throw new Error("No inputs were signed");return this}},{key:"signAllInputsHDAsync",value:function(t){var e=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[hi.SIGHASH_ALL];return new Promise(function(n,i){if(!t||!t.publicKey||!t.fingerprint)return i(new Error("Need HDSigner to sign input"));var o,a=[],s=[],u=vo(aa(e.data.inputs.length));try{for(u.s();!(o=u.n()).done;){var c=o.value;s.push(e.signInputHDAsync(c,t,r).then(function(){a.push(!0)},function(){a.push(!1)}))}}catch(t){u.e(t)}finally{u.f()}return Promise.all(s).then(function(){if(a.every(function(t){return!1===t}))return i(new Error("No inputs were signed"));n()})})}},{key:"signInputHD",value:function(t,e){var r=this,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[hi.SIGHASH_ALL];if(!e||!e.publicKey||!e.fingerprint)throw new Error("Need HDSigner to sign input");return Xo(t,this.data.inputs,e).forEach(function(e){return r.signInput(t,e,n)}),this}},{key:"signInputHDAsync",value:function(t,e){var r=this,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[hi.SIGHASH_ALL];return new Promise(function(i,o){if(!e||!e.publicKey||!e.fingerprint)return o(new Error("Need HDSigner to sign input"));var a=Xo(t,r.data.inputs,e).map(function(e){return r.signInputAsync(t,e,n)});return Promise.all(a).then(function(){i()}).catch(o)})}},{key:"signAllInputs",value:function(t,e){if(!t||!t.publicKey)throw new Error("Need Signer to sign input");var r,n=[],i=vo(aa(this.data.inputs.length));try{for(i.s();!(r=i.n()).done;){var o=r.value;try{this.signInput(o,t,e),n.push(!0)}catch(t){n.push(!1)}}}catch(t){i.e(t)}finally{i.f()}if(n.every(function(t){return!1===t}))throw new Error("No inputs were signed");return this}},{key:"signAllInputsAsync",value:function(t,e){var r=this;return new Promise(function(n,i){if(!t||!t.publicKey)return i(new Error("Need Signer to sign input"));var o,a,s=[],u=[],c=vo(r.data.inputs.entries());try{for(c.s();!(o=c.n()).done;){var f=(a=o.value,function(t){if(Array.isArray(t))return t}(a)||function(t){var e=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=e){var r,n,i,o,a=[],s=!0,u=!1;try{for(i=(e=e.call(t)).next;!(s=(r=i.call(e)).done)&&(a.push(r.value),1!==a.length);s=!0);}catch(t){u=!0,n=t}finally{try{if(!s&&null!=e.return&&(o=e.return(),Object(o)!==o))return}finally{if(u)throw n}}return a}}(a)||mo(a,1)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())[0];u.push(r.signInputAsync(f,t,e).then(function(){s.push(!0)},function(){s.push(!1)}))}}catch(t){c.e(t)}finally{c.f()}return Promise.all(u).then(function(){if(s.every(function(t){return!1===t}))return i(new Error("No inputs were signed"));n()})})}},{key:"signInput",value:function(t,e,r){if(!e||!e.publicKey)throw new Error("Need Signer to sign input");var n=(0,lo.checkForInput)(this.data.inputs,t);return wi(n)?this._signTaprootInput(t,n,e,void 0,r):this._signInput(t,e,r)}},{key:"signTaprootInput",value:function(t,e,r,n){if(!e||!e.publicKey)throw new Error("Need Signer to sign input");var i=(0,lo.checkForInput)(this.data.inputs,t);if(wi(i))return this._signTaprootInput(t,i,e,r,n);throw new Error("Input #".concat(t," is not of type Taproot."))}},{key:"signInputAsync",value:function(t,e,r){var n=this;return Promise.resolve().then(function(){if(!e||!e.publicKey)throw new Error("Need Signer to sign input");var i=(0,lo.checkForInput)(n.data.inputs,t);return wi(i)?n._signTaprootInputAsync(t,i,e,void 0,r):n._signInputAsync(t,e,r)})}},{key:"signTaprootInputAsync",value:function(t,e,r,n){var i=this;return Promise.resolve().then(function(){if(!e||!e.publicKey)throw new Error("Need Signer to sign input");var o=(0,lo.checkForInput)(i.data.inputs,t);if(wi(o))return i._signTaprootInputAsync(t,o,e,r,n);throw new Error("Input #".concat(t," is not of type Taproot."))})}},{key:"toBuffer",value:function(){return xo(this.__CACHE),this.data.toBuffer()}},{key:"toHex",value:function(){return xo(this.__CACHE),this.data.toHex()}},{key:"toBase64",value:function(){return xo(this.__CACHE),this.data.toBase64()}},{key:"updateGlobal",value:function(t){return this.data.updateGlobal(t),this}},{key:"updateInput",value:function(t,e){return e.witnessScript&&ia(e.witnessScript),Si(this.data.inputs[t],e,"updateInput"),this.data.updateInput(t,e),e.nonWitnessUtxo&&$o(this.__CACHE,this.data.inputs[t],t),this}},{key:"updateOutput",value:function(t,e){return _i(this.data.outputs[t],e,"updateOutput"),this.data.updateOutput(t,e),this}},{key:"addUnknownKeyValToGlobal",value:function(t){return this.data.addUnknownKeyValToGlobal(t),this}},{key:"addUnknownKeyValToInput",value:function(t,e){return this.data.addUnknownKeyValToInput(t,e),this}},{key:"addUnknownKeyValToOutput",value:function(t,e){return this.data.addUnknownKeyValToOutput(t,e),this}},{key:"clearFinalizedInput",value:function(t){return this.data.clearFinalizedInput(t),this}},{key:"checkTaprootHashesForSig",value:function(t,e,r,n,i){if("function"!=typeof r.signSchnorr)throw new Error("Need Schnorr Signer to sign taproot input #".concat(t,"."));var o=zo(t,e,this.data.inputs,r.publicKey,this.__CACHE,n,i);if(!o||!o.length)throw new Error("Can not sign for input #".concat(t," with the key ").concat(r.publicKey.toString("hex")));return o}},{key:"_finalizeInput",value:function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Ko,n=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],i=function(t,e,r){var n=r.__TX,i={script:null,isSegwit:!1,isP2SH:!1,isP2WSH:!1};if(i.isP2SH=!!e.redeemScript,i.isP2WSH=!!e.witnessScript,e.witnessScript)i.script=e.witnessScript;else if(e.redeemScript)i.script=e.redeemScript;else if(e.nonWitnessUtxo){var o=Qo(r,e,t),a=n.ins[t].index;i.script=o.outs[a].script}else e.witnessUtxo&&(i.script=e.witnessUtxo.script);if(e.witnessScript||Di(i.script))i.isSegwit=!0;else try{var s=i.script;if(!s)throw new TypeError("Invalid script for segwit address");i.isSegwit=_e(s)}catch(t){}return i}(t,e,this.__CACHE),o=i.script,a=i.isP2SH,s=i.isP2WSH,u=i.isSegwit;if(!o)throw new Error("No script found for input #".concat(t));!function(t){if(t.sighashType&&t.partialSig){var e=t.partialSig,r=t.sighashType;e.forEach(function(t){var e=le.decode(t.signature).hashType;if(r!==e)throw new Error("Signature sighash does not match input sighash type")})}}(e);var c=r(t,e,o,u,a,s,n),f=c.finalScriptSig,l=c.finalScriptWitness;if(f&&this.data.updateInput(t,{finalScriptSig:f}),l&&this.data.updateInput(t,{finalScriptWitness:l}),!f&&!l)throw new Error("Unknown error finalizing input #".concat(t));return this.data.clearFinalizedInput(t),this}},{key:"_finalizeTaprootInput",value:function(t,e,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:gi;if(!e.witnessUtxo)throw new Error("Cannot finalize input #".concat(t,". Missing witness utxo."));if(e.tapKeySig){var i=Vi(Vn({output:e.witnessUtxo.script,signature:e.tapKeySig}).witness);this.data.updateInput(t,{finalScriptWitness:i})}else{var o=n(t,e,r).finalScriptWitness;this.data.updateInput(t,{finalScriptWitness:o})}return this.data.clearFinalizedInput(t),this}},{key:"_validateSignaturesOfInput",value:function(t,e,r){var n=this.data.inputs[t],i=(n||{}).partialSig;if(!n||!i||i.length<1)throw new Error("No signatures to validate");if("function"!=typeof e)throw new Error("Need validator function to validate signatures");var o=r?i.filter(function(t){return t.pubkey.equals(r)}):i;if(o.length<1)throw new Error("No signatures for this pubkey");var a,s,u,c,f=[],l=vo(o);try{for(l.s();!(c=l.n()).done;){var h=c.value,p=le.decode(h.signature),d=u!==p.hashType?Wo(t,Object.assign({},n,{sighashType:p.hashType}),this.__CACHE,!0):{hash:a,script:s},y=d.hash,b=d.script;u=p.hashType,a=y,s=b,Lo(h.pubkey,b,"verify"),f.push(e(h.pubkey,y,p.signature))}}catch(t){l.e(t)}finally{l.f()}return f.every(function(t){return!0===t})}},{key:"validateSignaturesOfTaprootInput",value:function(t,e,r){var n=this.data.inputs[t],i=(n||{}).tapKeySig,o=(n||{}).tapScriptSig;if(!n&&!i&&(!o||o.length))throw new Error("No signatures to validate");if("function"!=typeof e)throw new Error("Need validator function to validate signatures");var a=(r=r&&bi(r))?zo(t,n,this.data.inputs,r,this.__CACHE):function(t,e,r,n){var i=[];if(e.tapInternalKey){var o=Go(t,e,n);o&&i.push(o)}if(e.tapScriptSig){var a=e.tapScriptSig.map(function(t){return t.pubkey});i.push.apply(i,wo(a))}return i.map(function(i){return zo(t,e,r,i,n)}).flat()}(t,n,this.data.inputs,this.__CACHE);if(!a.length)throw new Error("No signatures for this pubkey");var s=a.find(function(t){return!t.leafHash}),u=0;if(i&&s){if(!e(s.pubkey,s.hash,qo(i)))return!1;u++}if(o){var c,f=vo(o);try{var l,h=function(){var t=c.value,r=a.find(function(e){return t.pubkey.equals(e.pubkey)});if(r){if(!e(t.pubkey,r.hash,qo(t.signature)))return{v:!1};u++}};for(f.s();!(c=f.n()).done;)if(l=h())return l.v}catch(t){f.e(t)}finally{f.f()}}return u>0}},{key:"_signInput",value:function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[hi.SIGHASH_ALL],n=Vo(this.data.inputs,t,e.publicKey,this.__CACHE,r),i=n.hash,o=n.sighashType,a=[{pubkey:e.publicKey,signature:le.encode(e.sign(i),o)}];return this.data.updateInput(t,{partialSig:a}),this}},{key:"_signTaprootInput",value:function(t,e,r,n){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:[hi.SIGHASH_DEFAULT],o=this.checkTaprootHashesForSig(t,e,r,n,i),a=o.filter(function(t){return!t.leafHash}).map(function(t){return vi(r.signSchnorr(t.hash),e.sighashType)})[0],s=o.filter(function(t){return!!t.leafHash}).map(function(t){return{pubkey:bi(r.publicKey),signature:vi(r.signSchnorr(t.hash),e.sighashType),leafHash:t.leafHash}});return a&&this.data.updateInput(t,{tapKeySig:a}),s.length&&this.data.updateInput(t,{tapScriptSig:s}),this}},{key:"_signInputAsync",value:function(t,e){var r=this,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[hi.SIGHASH_ALL],i=Vo(this.data.inputs,t,e.publicKey,this.__CACHE,n),o=i.hash,a=i.sighashType;return Promise.resolve(e.sign(o)).then(function(n){var i=[{pubkey:e.publicKey,signature:le.encode(n,a)}];r.data.updateInput(t,{partialSig:i})})}},{key:"_signTaprootInputAsync",value:(e=go(yo().mark(function t(e,r,n,i){var o,a,s,u,c,f,l,h,p,d,y,b=arguments;return yo().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return o=b.length>4&&void 0!==b[4]?b[4]:[hi.SIGHASH_DEFAULT],a=this.checkTaprootHashesForSig(e,r,n,i,o),s=[],u=a.filter(function(t){return!t.leafHash})[0],u&&(c=Promise.resolve(n.signSchnorr(u.hash)).then(function(t){return{tapKeySig:vi(t,r.sighashType)}}),s.push(c)),f=a.filter(function(t){return!!t.leafHash}),f.length&&(l=f.map(function(){var t=go(yo().mark(function t(e){var i,o;return yo().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,n.signSchnorr(e.hash);case 2:return i=t.sent,o=[{pubkey:bi(n.publicKey),signature:vi(i,r.sighashType),leafHash:e.leafHash}],t.abrupt("return",{tapScriptSig:o});case 5:case"end":return t.stop()}},t)}));return function(e){return t.apply(this,arguments)}}()),s.push.apply(s,wo(l))),t.next=9,Promise.all(s);case 9:h=t.sent,p=vo(h);try{for(p.s();!(d=p.n()).done;)y=d.value,this.data.updateInput(e,y)}catch(t){p.e(t)}finally{p.f()}case 12:case"end":return t.stop()}},t,this)})),function(t,r,n,i){return e.apply(this,arguments)})}],[{key:"fromBase64",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=ho.from(t,"base64");return this.fromBuffer(r,e)}},{key:"fromHex",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=ho.from(t,"hex");return this.fromBuffer(r,e)}},{key:"fromBuffer",value:function(e){var r,n,i=new t(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},fo.i.fromBuffer(e,Io));return r=i.__CACHE.__TX,n=i.__CACHE,r.ins.forEach(function(t){Co(n,t)}),i}}]);var e}(),Io=function(t){return new Po(t)},Po=ko(function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:ho.from([2,0,0,0,0,0,0,0,0,0]);_o(this,t),this.tx=hi.fromBuffer(e),function(t){if(!t.ins.every(function(t){return t.script&&0===t.script.length&&t.witness&&0===t.witness.length}))throw new Error("Format Error: Transaction ScriptSigs are not empty")}(this.tx),Object.defineProperty(this,"tx",{enumerable:!1,writable:!0})},[{key:"getInputOutputCounts",value:function(){return{inputCount:this.tx.ins.length,outputCount:this.tx.outs.length}}},{key:"addInput",value:function(t){if(void 0===t.hash||void 0===t.index||!ho.isBuffer(t.hash)&&"string"!=typeof t.hash||"number"!=typeof t.index)throw new Error("Error adding input.");var e="string"==typeof t.hash?Ar(ho.from(t.hash,"hex")):t.hash;this.tx.addInput(e,t.index,t.sequence)}},{key:"addOutput",value:function(t){if(void 0===t.script||void 0===t.value||!ho.isBuffer(t.script)||"number"!=typeof t.value)throw new Error("Error adding output.");this.tx.addOutput(t.script,t.value)}},{key:"toBuffer",value:function(){return this.tx.toBuffer()}}]);function xo(t){if(!1!==t.__UNSAFE_SIGN_NONSEGWIT)throw new Error("Not BIP174 compliant, can not export")}function Bo(t,e,r){if(!e)return!1;var n;if((n=r?r.map(function(t){var r=function(t){if(65===t.length){var e=1&t[64],r=t.slice(0,33);return r[0]=2|e,r}return t.slice()}(t);return e.find(function(t){return t.pubkey.equals(r)})}).filter(function(t){return!!t}):e).length>t)throw new Error("Too many signatures");return n.length===t}function Ro(t){return!!t.finalScriptSig||!!t.finalScriptWitness}function Uo(t){return function(e){return!!e.masterFingerprint.equals(t.fingerprint)&&!!t.derivePath(e.path).publicKey.equals(e.pubkey)}}function jo(t){if("number"!=typeof t||t!==Math.floor(t)||t>4294967295||t<0)throw new Error("Invalid 32 bit integer")}function No(t,e){t.forEach(function(t){if(wi(t)?function(t,e){var r=function(t){var e,r=[];if(t.tapKeySig&&r.push(t.tapKeySig),t.tapScriptSig&&r.push.apply(r,function(t){if(Array.isArray(t))return yi(t)}(e=t.tapScriptSig.map(function(t){return t.signature}))||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(e)||di(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),!r.length){var n=function(t){if(t){var e=t.slice(2);return 64===e.length||65===e.length?e:void 0}}(t.finalScriptWitness);n&&r.push(n)}return r}(t);return r.some(function(t){return Xi(t,ki,e)})}(t,e):function(t,e){var r=function(t){var e=[];if(0===(t.partialSig||[]).length){if(!t.finalScriptSig&&!t.finalScriptWitness)return[];e=function(t){var e=t.finalScriptSig&&ne(t.finalScriptSig)||[],r=t.finalScriptWitness&&ne(t.finalScriptWitness)||[];return e.concat(r).filter(function(t){return ji.isBuffer(t)&&ce(t)}).map(function(t){return{signature:t}})}(t)}else e=t.partialSig;return e.map(function(t){return t.signature})}(t);return r.some(function(t){return Xi(t,le.decode,e)})}(t,e))throw new Error("Can not modify transaction, signatures exist.")})}function Lo(t,e,r){if(!Zi(t,e))throw new Error("Can not ".concat(r," for this input with the key ").concat(t.toString("hex")))}function Co(t,e){var r=Ar(ho.from(e.hash)).toString("hex")+":"+e.index;if(t.__TX_IN_CACHE[r])throw new Error("Duplicate input detected.");t.__TX_IN_CACHE[r]=1}function Fo(t,e){return function(r,n,i,o){var a=t({redeem:{output:i}}).output;if(!n.equals(a))throw new Error("".concat(e," for ").concat(o," #").concat(r," doesn't match the scriptPubKey in the prevout"))}}var Do=Fo(Dn,"Redeem script"),Ho=Fo(Jn,"Witness script");function Mo(t,e,r,n){var i,o=arguments.length>4&&void 0!==arguments[4]&&arguments[4];if(!r.every(Ro))throw new Error("PSBT must be finalized to calculate ".concat(e));if("__FEE_RATE"===t&&n.__FEE_RATE)return n.__FEE_RATE;if("__FEE"===t&&n.__FEE)return n.__FEE;var a=!0;return n.__EXTRACTED_TX?(i=n.__EXTRACTED_TX,a=!1):i=n.__TX.clone(),Jo(r,i,n,a,o),"__FEE_RATE"===t?n.__FEE_RATE:"__FEE"===t?n.__FEE:void 0}function Ko(t,e,r,n,i,o){var a=!(arguments.length>6&&void 0!==arguments[6])||arguments[6],s=arguments.length>7?arguments[7]:void 0,u=oa(r);if(!function(t,e,r){switch(r){case"pubkey":case"pubkeyhash":case"witnesspubkeyhash":return Bo(1,t.partialSig);case"multisig":var n=Xr({output:e});return Bo(n.m,t.partialSig,n.pubkeys);case"nonstandard":return!0;default:return!1}}(e,r,u)&&a)throw new Error("Can not finalize input #".concat(t));return function(t,e,r,n,i,o,a){var s,u,c=function(t,e,r){var n;switch(e){case"multisig":var i=function(t,e){return Xr({output:t}).pubkeys.map(function(t){return(e.filter(function(e){return e.pubkey.equals(t)})[0]||{}).signature}).filter(function(t){return!!t})}(t,r);n=Xr({output:t,signatures:i});break;case"pubkey":n=$r({output:t,signature:r[0].signature});break;case"pubkeyhash":n=Qi({output:t,pubkey:r[0].pubkey,signature:r[0].signature});break;case"witnesspubkeyhash":n=zn({output:t,pubkey:r[0].pubkey,signature:r[0].signature})}return n}(t,e,r),f=o?Jn({redeem:c}):null,l=i?Dn({redeem:f||c}):null;return n?(u=Vi(f?f.witness:c?c.witness:null!=a?a:[ho.from([0])]),l&&(s=null==l?void 0:l.input)):s=l?null==l?void 0:l.input:c?c.input:Array.isArray(a)&&a[0]?a[0]:ho.from([1]),{finalScriptSig:s,finalScriptWitness:u}}(r,u,e.partialSig,n,i,o,s)}function Vo(t,e,r,n,i){var o=Wo(e,(0,lo.checkForInput)(t,e),n,!1,i),a=o.hash,s=o.sighashType;return Lo(r,o.script,"sign"),{hash:a,sighashType:s}}function Wo(t,e,r,n,i){var o,a,s=r.__TX,u=e.sighashType||hi.SIGHASH_ALL;if(Zo(u,i),e.nonWitnessUtxo){var c=Qo(r,e,t),f=s.ins[t].hash,l=c.getHash();if(!f.equals(l))throw new Error("Non-witness UTXO hash for input #".concat(t," doesn't match the hash specified in the prevout"));var h=s.ins[t].index;a=c.outs[h]}else{if(!e.witnessUtxo)throw new Error("Need a Utxo input item for signing");a=e.witnessUtxo}var p=na(a.script,t,"input",e.redeemScript,e.witnessScript),d=p.meaningfulScript,y=p.type;if(["p2sh-p2wsh","p2wsh"].indexOf(y)>=0)o=s.hashForWitnessV0(t,d,a.value,u);else if(Di(d)){var b=Qi({hash:d.slice(2)}).output;o=s.hashForWitnessV0(t,b,a.value,u)}else{if(void 0===e.nonWitnessUtxo&&!1===r.__UNSAFE_SIGN_NONSEGWIT)throw new Error("Input #".concat(t," has witnessUtxo but non-segwit script: ")+"".concat(d.toString("hex")));n||!1===r.__UNSAFE_SIGN_NONSEGWIT||console.warn("Warning: Signing non-segwit inputs without the full parent transaction means there is a chance that a miner could feed you incorrect information to trick you into paying large fees. This behavior is the same as Psbt's predecessor (TransactionBuilder - now removed) when signing non-segwit scripts. You are not able to export this Psbt with toBuffer|toBase64|toHex since it is not BIP174 compliant.\n*********************\nPROCEED WITH CAUTION!\n*********************"),o=s.hashForSignature(t,d,u)}return{script:d,sighashType:u,hash:o}}function Go(t,e,r){var n=ea(t,e,r).script;return Ki(n)?n.subarray(2,34):null}function qo(t){return 64===t.length?t:t.subarray(0,64)}function zo(t,e,r,n,i,o,a){var s=i.__TX,u=e.sighashType||hi.SIGHASH_DEFAULT;Zo(u,a);var c=r.map(function(t,e){return ea(e,t,i)}),f=c.map(function(t){return t.script}),l=c.map(function(t){return t.value}),h=[];if(e.tapInternalKey&&!o){var p=Go(t,e,i)||ho.from([]);if(bi(n).equals(p)){var d=s.hashForWitnessV1(t,f,l,u);h.push({pubkey:n,hash:d})}}var y=(e.tapLeafScript||[]).filter(function(t){return Zi(n,t.script)}).map(function(t){var e=Dr({output:t.script,version:t.leafVersion});return Object.assign({hash:e},t)}).filter(function(t){return!o||o.equals(t.hash)}).map(function(e){var r=s.hashForWitnessV1(t,f,l,u,e.hash);return{pubkey:n,hash:r,leafHash:e.hash}});return h.concat(y)}function Zo(t,e){if(e&&e.indexOf(t)<0){var r=function(t){var e=t&hi.SIGHASH_ANYONECANPAY?"SIGHASH_ANYONECANPAY | ":"";switch(31&t){case hi.SIGHASH_ALL:e+="SIGHASH_ALL";break;case hi.SIGHASH_SINGLE:e+="SIGHASH_SINGLE";break;case hi.SIGHASH_NONE:e+="SIGHASH_NONE"}return e}(t);throw new Error("Sighash type is not allowed. Retry the sign method passing the "+"sighashTypes array of whitelisted types. Sighash type: ".concat(r))}}function Xo(t,e,r){var n=(0,lo.checkForInput)(e,t);if(!n.bip32Derivation||0===n.bip32Derivation.length)throw new Error("Need bip32Derivation to sign with HD");var i=n.bip32Derivation.map(function(t){return t.masterFingerprint.equals(r.fingerprint)?t:void 0}).filter(function(t){return!!t});if(0===i.length)throw new Error("Need one bip32Derivation masterFingerprint to match the HDSigner fingerprint");return i.map(function(t){var e=r.derivePath(t.path);if(!t.pubkey.equals(e.publicKey))throw new Error("pubkey did not match bip32Derivation");return e})}function Yo(t){var e=0;function r(){var r=Ln.decode(t,e);return e+=Ln.decode.bytes,r}return function(){for(var n=r(),i=[],o=0;o<n;o++)i.push((a=r(),e+=a,t.slice(e-a,e)));var a;return i}()}function $o(t,e,r){t.__NON_WITNESS_UTXO_BUF_CACHE[r]=e.nonWitnessUtxo,t.__NON_WITNESS_UTXO_TX_CACHE[r]=hi.fromBuffer(e.nonWitnessUtxo);var n=t,i=r;delete e.nonWitnessUtxo,Object.defineProperty(e,"nonWitnessUtxo",{enumerable:!0,get:function(){var t=n.__NON_WITNESS_UTXO_BUF_CACHE[i],e=n.__NON_WITNESS_UTXO_TX_CACHE[i];if(void 0!==t)return t;var r=e.toBuffer();return n.__NON_WITNESS_UTXO_BUF_CACHE[i]=r,r},set:function(t){n.__NON_WITNESS_UTXO_BUF_CACHE[i]=t}})}function Jo(t,e,r,n,i){var o=0;t.forEach(function(t,i){if(n&&t.finalScriptSig&&(e.ins[i].script=t.finalScriptSig),n&&t.finalScriptWitness&&(e.ins[i].witness=Yo(t.finalScriptWitness)),t.witnessUtxo)o+=t.witnessUtxo.value;else if(t.nonWitnessUtxo){var a=Qo(r,t,i),s=e.ins[i].index,u=a.outs[s];o+=u.value}});var a=e.outs.reduce(function(t,e){return t+e.value},0),s=o-a;if(!i&&s<0)throw new Error("Outputs are spending more than Inputs ".concat(o," < ").concat(a));var u=e.virtualSize();r.__FEE=s,r.__EXTRACTED_TX=e,r.__FEE_RATE=Math.floor(s/u)}function Qo(t,e,r){var n=t.__NON_WITNESS_UTXO_TX_CACHE;return n[r]||$o(t,e,r),n[r]}function ta(t,e,r){return ea(t,e,r).script}function ea(t,e,r){if(void 0!==e.witnessUtxo)return{script:e.witnessUtxo.script,value:e.witnessUtxo.value};if(void 0!==e.nonWitnessUtxo){var n=Qo(r,e,t).outs[r.__TX.ins[t].index];return{script:n.script,value:n.value}}throw new Error("Can't find pubkey in input without Utxo data")}function ra(t){return 33===t.length&&se(t)}function na(t,e,r,n,i){var o,a=Mi(t),s=a&&n&&Hi(n),u=Hi(t);if(a&&void 0===n)throw new Error("scriptPubkey is P2SH but redeemScript missing");if((u||s)&&void 0===i)throw new Error("scriptPubkey or redeemScript is P2WSH but witnessScript missing");return s?(o=i,Do(e,t,n,r),Ho(e,n,i,r),ia(o)):u?(o=i,Ho(e,t,i,r),ia(o)):a?(o=n,Do(e,t,n,r)):o=t,{meaningfulScript:o,type:s?"p2sh-p2wsh":a?"p2sh":u?"p2wsh":"raw"}}function ia(t){if(Di(t)||Mi(t))throw new Error("P2WPKH or P2SH can not be contained within P2WSH")}function oa(t){return Di(t)?"witnesspubkeyhash":Fi(t)?"pubkeyhash":Li(t)?"multisig":Ci(t)?"pubkey":"nonstandard"}function aa(t){return wo(Array(t).keys())}const sa={networks:b,address:m,payments:k,script:w,crypto:S,Transaction:E};var ua=i(3513),ca=i.t(ua,2);const fa="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0;function la(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&"Uint8Array"===t.constructor.name}function ha(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function pa(t,...e){if(!la(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function da(t){if("function"!=typeof t||"function"!=typeof t.create)throw new Error("Hash should be wrapped by utils.createHasher");ha(t.outputLen),ha(t.blockLen)}function ya(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function ba(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}function ga(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function va(t,e){return t<<32-e|t>>>e}function wa(t,e){return t<<e|t>>>32-e>>>0}const ma=(()=>"function"==typeof Uint8Array.from([]).toHex&&"function"==typeof Uint8Array.fromHex)(),Sa=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function _a(t){if(pa(t),ma)return t.toHex();let e="";for(let r=0;r<t.length;r++)e+=Sa[t[r]];return e}function Ea(t){return t>=48&&t<=57?t-48:t>=65&&t<=70?t-55:t>=97&&t<=102?t-87:void 0}function ka(t){if("string"!=typeof t)throw new Error("hex string expected, got "+typeof t);if(ma)return Uint8Array.fromHex(t);const e=t.length,r=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);const n=new Uint8Array(r);for(let e=0,i=0;e<r;e++,i+=2){const r=Ea(t.charCodeAt(i)),o=Ea(t.charCodeAt(i+1));if(void 0===r||void 0===o){const e=t[i]+t[i+1];throw new Error('hex string expected, got non-hex character "'+e+'" at index '+i)}n[e]=16*r+o}return n}function Oa(t){if("string"!=typeof t)throw new Error("string expected");return new Uint8Array((new TextEncoder).encode(t))}function Ta(t){return"string"==typeof t&&(t=Oa(t)),pa(t),t}function Aa(...t){let e=0;for(let r=0;r<t.length;r++){const n=t[r];pa(n),e+=n.length}const r=new Uint8Array(e);for(let e=0,n=0;e<t.length;e++){const i=t[e];r.set(i,n),n+=i.length}return r}class Ia{}function Pa(t){const e=e=>t().update(Ta(e)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function xa(t=32){if(fa&&"function"==typeof fa.getRandomValues)return fa.getRandomValues(new Uint8Array(t));if(fa&&"function"==typeof fa.randomBytes)return Uint8Array.from(fa.randomBytes(t));throw new Error("crypto.getRandomValues must be defined")}class Ba extends Ia{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,da(t);const r=Ta(e);if(this.iHash=t.create(),"function"!=typeof this.iHash.update)throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const n=this.blockLen,i=new Uint8Array(n);i.set(r.length>n?t.create().update(r).digest():r);for(let t=0;t<i.length;t++)i[t]^=54;this.iHash.update(i),this.oHash=t.create();for(let t=0;t<i.length;t++)i[t]^=106;this.oHash.update(i),ba(i)}update(t){return ya(this),this.iHash.update(t),this}digestInto(t){ya(this),pa(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){const t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));const{oHash:e,iHash:r,finished:n,destroyed:i,blockLen:o,outputLen:a}=this;return t.finished=n,t.destroyed=i,t.blockLen=o,t.outputLen=a,t.oHash=e._cloneInto(t.oHash),t.iHash=r._cloneInto(t.iHash),t}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const Ra=(t,e,r)=>new Ba(t,e).update(r).digest();function Ua(t,e,r){return t&e^~t&r}function ja(t,e,r){return t&e^t&r^e&r}Ra.create=(t,e)=>new Ba(t,e);class Na extends Ia{constructor(t,e,r,n){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=t,this.outputLen=e,this.padOffset=r,this.isLE=n,this.buffer=new Uint8Array(t),this.view=ga(this.buffer)}update(t){ya(this),pa(t=Ta(t));const{view:e,buffer:r,blockLen:n}=this,i=t.length;for(let o=0;o<i;){const a=Math.min(n-this.pos,i-o);if(a===n){const e=ga(t);for(;n<=i-o;o+=n)this.process(e,o);continue}r.set(t.subarray(o,o+a),this.pos),this.pos+=a,o+=a,this.pos===n&&(this.process(e,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){ya(this),function(t,e){pa(t);const r=e.outputLen;if(t.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}(t,this),this.finished=!0;const{buffer:e,view:r,blockLen:n,isLE:i}=this;let{pos:o}=this;e[o++]=128,ba(this.buffer.subarray(o)),this.padOffset>n-o&&(this.process(r,0),o=0);for(let t=o;t<n;t++)e[t]=0;!function(t,e,r,n){if("function"==typeof t.setBigUint64)return t.setBigUint64(e,r,n);const i=BigInt(32),o=BigInt(4294967295),a=Number(r>>i&o),s=Number(r&o),u=n?4:0,c=n?0:4;t.setUint32(e+u,a,n),t.setUint32(e+c,s,n)}(r,n-8,BigInt(8*this.length),i),this.process(r,0);const a=ga(t),s=this.outputLen;if(s%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const u=s/4,c=this.get();if(u>c.length)throw new Error("_sha2: outputLen bigger than state");for(let t=0;t<u;t++)a.setUint32(4*t,c[t],i)}digest(){const{buffer:t,outputLen:e}=this;this.digestInto(t);const r=t.slice(0,e);return this.destroy(),r}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:e,buffer:r,length:n,finished:i,destroyed:o,pos:a}=this;return t.destroyed=o,t.finished=i,t.length=n,t.pos=a,n%e&&t.buffer.set(r),t}clone(){return this._cloneInto()}}const La=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Ca=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]),Fa=Uint8Array.from([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),Da=(()=>Uint8Array.from(new Array(16).fill(0).map((t,e)=>e)))(),Ha=(()=>Da.map(t=>(9*t+5)%16))(),Ma=(()=>{const t=[[Da],[Ha]];for(let e=0;e<4;e++)for(let r of t)r.push(r[e].map(t=>Fa[t]));return t})(),Ka=(()=>Ma[0])(),Va=(()=>Ma[1])(),Wa=[[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8],[12,13,11,15,6,9,9,7,12,15,11,13,7,8,7,7],[13,15,14,11,7,7,6,8,13,14,13,12,5,5,6,9],[14,11,12,14,8,6,5,5,15,12,15,14,9,9,8,6],[15,12,13,13,9,5,8,6,14,11,12,11,8,6,5,5]].map(t=>Uint8Array.from(t)),Ga=Ka.map((t,e)=>t.map(t=>Wa[e][t])),qa=Va.map((t,e)=>t.map(t=>Wa[e][t])),za=Uint32Array.from([0,1518500249,1859775393,2400959708,2840853838]),Za=Uint32Array.from([1352829926,1548603684,1836072691,2053994217,0]);function Xa(t,e,r,n){return 0===t?e^r^n:1===t?e&r|~e&n:2===t?(e|~r)^n:3===t?e&n|r&~n:e^(r|~n)}const Ya=new Uint32Array(16);class $a extends Na{constructor(){super(64,20,8,!0),this.h0=1732584193,this.h1=-271733879,this.h2=-1732584194,this.h3=271733878,this.h4=-1009589776}get(){const{h0:t,h1:e,h2:r,h3:n,h4:i}=this;return[t,e,r,n,i]}set(t,e,r,n,i){this.h0=0|t,this.h1=0|e,this.h2=0|r,this.h3=0|n,this.h4=0|i}process(t,e){for(let r=0;r<16;r++,e+=4)Ya[r]=t.getUint32(e,!0);let r=0|this.h0,n=r,i=0|this.h1,o=i,a=0|this.h2,s=a,u=0|this.h3,c=u,f=0|this.h4,l=f;for(let t=0;t<5;t++){const e=4-t,h=za[t],p=Za[t],d=Ka[t],y=Va[t],b=Ga[t],g=qa[t];for(let e=0;e<16;e++){const n=wa(r+Xa(t,i,a,u)+Ya[d[e]]+h,b[e])+f|0;r=f,f=u,u=0|wa(a,10),a=i,i=n}for(let t=0;t<16;t++){const r=wa(n+Xa(e,o,s,c)+Ya[y[t]]+p,g[t])+l|0;n=l,l=c,c=0|wa(s,10),s=o,o=r}}this.set(this.h1+a+c|0,this.h2+u+l|0,this.h3+f+n|0,this.h4+r+o|0,this.h0+i+s|0)}roundClean(){ba(Ya)}destroy(){this.destroyed=!0,ba(this.buffer),this.set(0,0,0,0,0)}}const Ja=Pa(()=>new $a),Qa=BigInt(2**32-1),ts=BigInt(32);function es(t,e=!1){return e?{h:Number(t&Qa),l:Number(t>>ts&Qa)}:{h:0|Number(t>>ts&Qa),l:0|Number(t&Qa)}}const rs=(t,e,r)=>t>>>r,ns=(t,e,r)=>t<<32-r|e>>>r,is=(t,e,r)=>t>>>r|e<<32-r,os=(t,e,r)=>t<<32-r|e>>>r,as=(t,e,r)=>t<<64-r|e>>>r-32,ss=(t,e,r)=>t>>>r-32|e<<64-r;function us(t,e,r,n){const i=(e>>>0)+(n>>>0);return{h:t+r+(i/2**32|0)|0,l:0|i}}const cs=(t,e,r)=>(t>>>0)+(e>>>0)+(r>>>0),fs=(t,e,r,n)=>e+r+n+(t/2**32|0)|0,ls=(t,e,r,n)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0),hs=(t,e,r,n,i)=>e+r+n+i+(t/2**32|0)|0,ps=(t,e,r,n,i)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0)+(i>>>0),ds=(t,e,r,n,i,o)=>e+r+n+i+o+(t/2**32|0)|0,ys=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]),bs=new Uint32Array(64);class gs extends Na{constructor(t=32){super(64,t,8,!1),this.A=0|La[0],this.B=0|La[1],this.C=0|La[2],this.D=0|La[3],this.E=0|La[4],this.F=0|La[5],this.G=0|La[6],this.H=0|La[7]}get(){const{A:t,B:e,C:r,D:n,E:i,F:o,G:a,H:s}=this;return[t,e,r,n,i,o,a,s]}set(t,e,r,n,i,o,a,s){this.A=0|t,this.B=0|e,this.C=0|r,this.D=0|n,this.E=0|i,this.F=0|o,this.G=0|a,this.H=0|s}process(t,e){for(let r=0;r<16;r++,e+=4)bs[r]=t.getUint32(e,!1);for(let t=16;t<64;t++){const e=bs[t-15],r=bs[t-2],n=va(e,7)^va(e,18)^e>>>3,i=va(r,17)^va(r,19)^r>>>10;bs[t]=i+bs[t-7]+n+bs[t-16]|0}let{A:r,B:n,C:i,D:o,E:a,F:s,G:u,H:c}=this;for(let t=0;t<64;t++){const e=c+(va(a,6)^va(a,11)^va(a,25))+Ua(a,s,u)+ys[t]+bs[t]|0,f=(va(r,2)^va(r,13)^va(r,22))+ja(r,n,i)|0;c=u,u=s,s=a,a=o+e|0,o=i,i=n,n=r,r=e+f|0}r=r+this.A|0,n=n+this.B|0,i=i+this.C|0,o=o+this.D|0,a=a+this.E|0,s=s+this.F|0,u=u+this.G|0,c=c+this.H|0,this.set(r,n,i,o,a,s,u,c)}roundClean(){ba(bs)}destroy(){this.set(0,0,0,0,0,0,0,0),ba(this.buffer)}}const vs=(()=>function(t,e=!1){const r=t.length;let n=new Uint32Array(r),i=new Uint32Array(r);for(let o=0;o<r;o++){const{h:r,l:a}=es(t[o],e);[n[o],i[o]]=[r,a]}return[n,i]}(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(t=>BigInt(t))))(),ws=(()=>vs[0])(),ms=(()=>vs[1])(),Ss=new Uint32Array(80),_s=new Uint32Array(80);class Es extends Na{constructor(t=64){super(128,t,16,!1),this.Ah=0|Ca[0],this.Al=0|Ca[1],this.Bh=0|Ca[2],this.Bl=0|Ca[3],this.Ch=0|Ca[4],this.Cl=0|Ca[5],this.Dh=0|Ca[6],this.Dl=0|Ca[7],this.Eh=0|Ca[8],this.El=0|Ca[9],this.Fh=0|Ca[10],this.Fl=0|Ca[11],this.Gh=0|Ca[12],this.Gl=0|Ca[13],this.Hh=0|Ca[14],this.Hl=0|Ca[15]}get(){const{Ah:t,Al:e,Bh:r,Bl:n,Ch:i,Cl:o,Dh:a,Dl:s,Eh:u,El:c,Fh:f,Fl:l,Gh:h,Gl:p,Hh:d,Hl:y}=this;return[t,e,r,n,i,o,a,s,u,c,f,l,h,p,d,y]}set(t,e,r,n,i,o,a,s,u,c,f,l,h,p,d,y){this.Ah=0|t,this.Al=0|e,this.Bh=0|r,this.Bl=0|n,this.Ch=0|i,this.Cl=0|o,this.Dh=0|a,this.Dl=0|s,this.Eh=0|u,this.El=0|c,this.Fh=0|f,this.Fl=0|l,this.Gh=0|h,this.Gl=0|p,this.Hh=0|d,this.Hl=0|y}process(t,e){for(let r=0;r<16;r++,e+=4)Ss[r]=t.getUint32(e),_s[r]=t.getUint32(e+=4);for(let t=16;t<80;t++){const e=0|Ss[t-15],r=0|_s[t-15],n=is(e,r,1)^is(e,r,8)^rs(e,0,7),i=os(e,r,1)^os(e,r,8)^ns(e,r,7),o=0|Ss[t-2],a=0|_s[t-2],s=is(o,a,19)^as(o,a,61)^rs(o,0,6),u=os(o,a,19)^ss(o,a,61)^ns(o,a,6),c=ls(i,u,_s[t-7],_s[t-16]),f=hs(c,n,s,Ss[t-7],Ss[t-16]);Ss[t]=0|f,_s[t]=0|c}let{Ah:r,Al:n,Bh:i,Bl:o,Ch:a,Cl:s,Dh:u,Dl:c,Eh:f,El:l,Fh:h,Fl:p,Gh:d,Gl:y,Hh:b,Hl:g}=this;for(let t=0;t<80;t++){const e=is(f,l,14)^is(f,l,18)^as(f,l,41),v=os(f,l,14)^os(f,l,18)^ss(f,l,41),w=f&h^~f&d,m=ps(g,v,l&p^~l&y,ms[t],_s[t]),S=ds(m,b,e,w,ws[t],Ss[t]),_=0|m,E=is(r,n,28)^as(r,n,34)^as(r,n,39),k=os(r,n,28)^ss(r,n,34)^ss(r,n,39),O=r&i^r&a^i&a,T=n&o^n&s^o&s;b=0|d,g=0|y,d=0|h,y=0|p,h=0|f,p=0|l,({h:f,l}=us(0|u,0|c,0|S,0|_)),u=0|a,c=0|s,a=0|i,s=0|o,i=0|r,o=0|n;const A=cs(_,k,T);r=fs(A,S,E,O),n=0|A}({h:r,l:n}=us(0|this.Ah,0|this.Al,0|r,0|n)),({h:i,l:o}=us(0|this.Bh,0|this.Bl,0|i,0|o)),({h:a,l:s}=us(0|this.Ch,0|this.Cl,0|a,0|s)),({h:u,l:c}=us(0|this.Dh,0|this.Dl,0|u,0|c)),({h:f,l}=us(0|this.Eh,0|this.El,0|f,0|l)),({h,l:p}=us(0|this.Fh,0|this.Fl,0|h,0|p)),({h:d,l:y}=us(0|this.Gh,0|this.Gl,0|d,0|y)),({h:b,l:g}=us(0|this.Hh,0|this.Hl,0|b,0|g)),this.set(r,n,i,o,a,s,u,c,f,l,h,p,d,y,b,g)}roundClean(){ba(Ss,_s)}destroy(){ba(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const ks=Pa(()=>new gs),Os=ks,Ts=Pa(()=>new Es);function As(t,e){return Ra(Ts,t,e)}const Is="0123456789abcdefABCDEF",Ps=(Is.split("").map(t=>t.codePointAt(0)),Array(256).fill(!0).map((t,e)=>{const r=String.fromCodePoint(e),n=Is.indexOf(r);return n<0?void 0:n<16?n:n-6})),xs=new TextEncoder;function Bs(t,e){const r=Math.min(t.length,e.length);for(let n=0;n<r;++n)if(t[n]!==e[n])return t[n]<e[n]?-1:1;return t.length===e.length?0:t.length>e.length?1:-1}function Rs(t,e,r){if(e+1>t.length)throw new Error("Offset is outside the bounds of Uint8Array");if(r>255)throw new Error(`The value of "value" is out of range. It must be >= 0 and <= 255. Received ${r}`);t[e]=r}function Us(t,e,r,n){if(e+4>t.length)throw new Error("Offset is outside the bounds of Uint8Array");if(n=n.toUpperCase(),r>4294967295)throw new Error(`The value of "value" is out of range. It must be >= 0 and <= 4294967295. Received ${r}`);"LE"===n?(t[e]=255&r,t[e+1]=r>>8&255,t[e+2]=r>>16&255,t[e+3]=r>>24&255):(t[e]=r>>24&255,t[e+1]=r>>16&255,t[e+2]=r>>8&255,t[e+3]=255&r)}function js(t,e,r){if(e+4>t.length)throw new Error("Offset is outside the bounds of Uint8Array");if("LE"===(r=r.toUpperCase())){let r=0;return r=(r<<8)+t[e+3]>>>0,r=(r<<8)+t[e+2]>>>0,r=(r<<8)+t[e+1]>>>0,r=(r<<8)+t[e]>>>0,r}{let r=0;return r=(r<<8)+t[e]>>>0,r=(r<<8)+t[e+1]>>>0,r=(r<<8)+t[e+2]>>>0,r=(r<<8)+t[e+3]>>>0,r}}new TextDecoder;const Ns=t=>function(t){const e=xs.encode(t||""),r=new Uint8Array(Math.floor(e.length/2));let n;for(n=0;n<r.length;n++){const t=Ps[e[2*n]],i=Ps[e[2*n+1]];if(void 0===t||void 0===i)break;r[n]=t<<4|i}return n===r.length?r:r.slice(0,n)}(t);function Ls(t){if(!t)throw new Error("ecc library invalid")}function Cs(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&"Uint8Array"===t.constructor.name}function Fs(t,e){return!!Array.isArray(e)&&(0===e.length||(t?e.every(t=>"string"==typeof t):e.every(t=>Number.isSafeInteger(t))))}function Ds(t){if("function"!=typeof t)throw new Error("function expected");return!0}function Hs(t,e){if("string"!=typeof e)throw new Error(`${t}: string expected`);return!0}function Ms(t){if(!Number.isSafeInteger(t))throw new Error(`invalid integer: ${t}`)}function Ks(t){if(!Array.isArray(t))throw new Error("array expected")}function Vs(t,e){if(!Fs(!0,e))throw new Error(`${t}: array of strings expected`)}function Ws(t,e){if(!Fs(!1,e))throw new Error(`${t}: array of numbers expected`)}function Gs(...t){const e=t=>t,r=(t,e)=>r=>t(e(r)),n=t.map(t=>t.encode).reduceRight(r,e),i=t.map(t=>t.decode).reduce(r,e);return{encode:n,decode:i}}function qs(t){const e="string"==typeof t?t.split(""):t,r=e.length;Vs("alphabet",e);const n=new Map(e.map((t,e)=>[t,e]));return{encode:n=>(Ks(n),n.map(n=>{if(!Number.isSafeInteger(n)||n<0||n>=r)throw new Error(`alphabet.encode: digit index outside alphabet "${n}". Allowed: ${t}`);return e[n]})),decode:e=>(Ks(e),e.map(e=>{Hs("alphabet.decode",e);const r=n.get(e);if(void 0===r)throw new Error(`Unknown letter: "${e}". Allowed: ${t}`);return r}))}}function zs(t=""){return Hs("join",t),{encode:e=>(Vs("join.decode",e),e.join(t)),decode:e=>(Hs("join.decode",e),e.split(t))}}function Zs(t,e="="){return Ms(t),Hs("padding",e),{encode(r){for(Vs("padding.encode",r);r.length*t%8;)r.push(e);return r},decode(r){Vs("padding.decode",r);let n=r.length;if(n*t%8)throw new Error("padding: invalid, string should have whole number of bytes");for(;n>0&&r[n-1]===e;n--)if((n-1)*t%8==0)throw new Error("padding: invalid, string has too much padding");return r.slice(0,n)}}}function Xs(t){return Ds(t),{encode:t=>t,decode:e=>t(e)}}function Ys(t,e,r){if(e<2)throw new Error(`convertRadix: invalid from=${e}, base cannot be less than 2`);if(r<2)throw new Error(`convertRadix: invalid to=${r}, base cannot be less than 2`);if(Ks(t),!t.length)return[];let n=0;const i=[],o=Array.from(t,t=>{if(Ms(t),t<0||t>=e)throw new Error(`invalid integer: ${t}`);return t}),a=o.length;for(;;){let t=0,s=!0;for(let i=n;i<a;i++){const a=o[i],u=e*t,c=u+a;if(!Number.isSafeInteger(c)||u/e!==t||c-a!==u)throw new Error("convertRadix: carry overflow");const f=c/r;t=c%r;const l=Math.floor(f);if(o[i]=l,!Number.isSafeInteger(l)||l*r+t!==c)throw new Error("convertRadix: carry overflow");s&&(l?s=!1:n=i)}if(i.push(t),s)break}for(let e=0;e<t.length-1&&0===t[e];e++)i.push(0);return i.reverse()}const $s=(t,e)=>0===e?t:$s(e,t%e),Js=(t,e)=>t+(e-$s(t,e)),Qs=(()=>{let t=[];for(let e=0;e<40;e++)t.push(2**e);return t})();function tu(t,e,r,n){if(Ks(t),e<=0||e>32)throw new Error(`convertRadix2: wrong from=${e}`);if(r<=0||r>32)throw new Error(`convertRadix2: wrong to=${r}`);if(Js(e,r)>32)throw new Error(`convertRadix2: carry overflow from=${e} to=${r} carryBits=${Js(e,r)}`);let i=0,o=0;const a=Qs[e],s=Qs[r]-1,u=[];for(const n of t){if(Ms(n),n>=a)throw new Error(`convertRadix2: invalid data word=${n} from=${e}`);if(i=i<<e|n,o+e>32)throw new Error(`convertRadix2: carry overflow pos=${o} from=${e}`);for(o+=e;o>=r;o-=r)u.push((i>>o-r&s)>>>0);const t=Qs[o];if(void 0===t)throw new Error("invalid carry");i&=t-1}if(i=i<<r-o&s,!n&&o>=e)throw new Error("Excess padding");if(!n&&i>0)throw new Error(`Non-zero padding: ${i}`);return n&&o>0&&u.push(i>>>0),u}function eu(t,e=!1){if(Ms(t),t<=0||t>32)throw new Error("radix2: bits should be in (0..32]");if(Js(8,t)>32||Js(t,8)>32)throw new Error("radix2: carry overflow");return{encode:r=>{if(!Cs(r))throw new Error("radix2.encode input should be Uint8Array");return tu(Array.from(r),8,t,!e)},decode:r=>(Ws("radix2.decode",r),Uint8Array.from(tu(r,t,8,e)))}}function ru(t){return Ds(t),function(...e){try{return t.apply(null,e)}catch(t){}}}Gs(eu(4),qs("0123456789ABCDEF"),zs("")),Gs(eu(5),qs("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),Zs(5),zs("")),Gs(eu(5),qs("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),zs("")),Gs(eu(5),qs("0123456789ABCDEFGHIJKLMNOPQRSTUV"),Zs(5),zs("")),Gs(eu(5),qs("0123456789ABCDEFGHIJKLMNOPQRSTUV"),zs("")),Gs(eu(5),qs("0123456789ABCDEFGHJKMNPQRSTVWXYZ"),zs(""),Xs(t=>t.toUpperCase().replace(/O/g,"0").replace(/[IL]/g,"1")));const nu=(()=>"function"==typeof Uint8Array.from([]).toBase64&&"function"==typeof Uint8Array.fromBase64)(),iu=(nu||Gs(eu(6),qs("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),Zs(6),zs("")),Gs(eu(6),qs("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),zs("")),nu||Gs(eu(6),qs("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),Zs(6),zs("")),Gs(eu(6),qs("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),zs("")),t=>{return Gs((Ms(e=58),{encode:t=>{if(!Cs(t))throw new Error("radix.encode input should be Uint8Array");return Ys(Array.from(t),256,e)},decode:t=>(Ws("radix.decode",t),Uint8Array.from(Ys(t,e,256)))}),qs(t),zs(""));var e}),ou=iu("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),au=(iu("123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"),iu("rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz"),t=>Gs(function(t,e){return Ms(t),Ds(e),{encode(r){if(!Cs(r))throw new Error("checksum.encode: input should be Uint8Array");const n=e(r).slice(0,t),i=new Uint8Array(r.length+t);return i.set(r),i.set(n,r.length),i},decode(r){if(!Cs(r))throw new Error("checksum.decode: input should be Uint8Array");const n=r.slice(0,-t),i=r.slice(-t),o=e(n).slice(0,t);for(let e=0;e<t;e++)if(o[e]!==i[e])throw new Error("Invalid checksum");return n}}}(4,e=>t(t(e))),ou)),su=Gs(qs("qpzry9x8gf2tvdw0s3jn54khce6mua7l"),zs("")),uu=[996825010,642813549,513874426,1027748829,705979059];function cu(t){const e=t>>25;let r=(33554431&t)<<5;for(let t=0;t<uu.length;t++)1==(e>>t&1)&&(r^=uu[t]);return r}function fu(t,e,r=1){const n=t.length;let i=1;for(let e=0;e<n;e++){const r=t.charCodeAt(e);if(r<33||r>126)throw new Error(`Invalid prefix (${t})`);i=cu(i)^r>>5}i=cu(i);for(let e=0;e<n;e++)i=cu(i)^31&t.charCodeAt(e);for(let t of e)i=cu(i)^t;for(let t=0;t<6;t++)i=cu(i);return i^=r,su.encode(tu([i%Qs[30]],30,5,!1))}function lu(t){const e="bech32"===t?1:734539939,r=eu(5),n=r.decode,i=r.encode,o=ru(n);function a(t,r,n=90){Hs("bech32.encode prefix",t),Cs(r)&&(r=Array.from(r)),Ws("bech32.encode",r);const i=t.length;if(0===i)throw new TypeError(`Invalid prefix length ${i}`);const o=i+7+r.length;if(!1!==n&&o>n)throw new TypeError(`Length ${o} exceeds limit ${n}`);const a=t.toLowerCase(),s=fu(a,r,e);return`${a}1${su.encode(r)}${s}`}function s(t,r=90){Hs("bech32.decode input",t);const n=t.length;if(n<8||!1!==r&&n>r)throw new TypeError(`invalid string length: ${n} (${t}). Expected (8..${r})`);const i=t.toLowerCase();if(t!==i&&t!==t.toUpperCase())throw new Error("String must be lowercase or uppercase");const o=i.lastIndexOf("1");if(0===o||-1===o)throw new Error('Letter "1" must be present between prefix and data only');const a=i.slice(0,o),s=i.slice(o+1);if(s.length<6)throw new Error("Data must be at least 6 characters long");const u=su.decode(s).slice(0,-6),c=fu(a,u,e);if(!s.endsWith(c))throw new Error(`Invalid checksum in ${t}: expected "${c}"`);return{prefix:a,words:u}}return{encode:a,decode:s,encodeFromBytes:function(t,e){return a(t,i(e))},decodeToBytes:function(t){const{prefix:e,words:r}=s(t,!1);return{prefix:e,words:r,bytes:n(r)}},decodeUnsafe:ru(s),fromWords:n,fromWordsUnsafe:o,toWords:i}}lu("bech32"),lu("bech32m");function hu(t){const e=typeof t;return"string"===e?`"${t}"`:"number"===e||"bigint"===e||"boolean"===e?`${t}`:"object"===e||"function"===e?(t&&Object.getPrototypeOf(t)?.constructor?.name)??"null":e}function pu(t,e,r,n,i){const o=i&&"input"in i?i.input:r.value,a=i?.expected??t.expects??null,s=i?.received??hu(o),u={kind:t.kind,type:t.type,input:o,expected:a,received:s,message:`Invalid ${e}: ${a?`Expected ${a} but r`:"R"}eceived ${s}`,requirement:t.requirement,path:i?.path,issues:i?.issues,lang:n.lang,abortEarly:n.abortEarly,abortPipeEarly:n.abortPipeEarly},c="schema"===t.kind,f=i?.message??t.message??(t.reference,void u.lang)??(c?void u.lang:null)??n.message??void u.lang;f&&(u.message="function"==typeof f?f(u):f),c&&(r.typed=!1),r.issues?r.issues.push(u):r.issues=[u]}(()=>"function"==typeof Uint8Array.from([]).toHex&&"function"==typeof Uint8Array.fromHex)()||Gs(eu(4),qs("0123456789abcdef"),zs(""),Xs(t=>{if("string"!=typeof t||t.length%2!=0)throw new TypeError(`hex.decode: expected string, got ${typeof t} with length ${t.length}`);return t.toLowerCase()}));var du=class extends Error{issues;constructor(t){super(t[0].message),this.name="ValiError",this.issues=t}};function yu(t){return{kind:"validation",type:"integer",reference:yu,async:!1,expects:null,requirement:Number.isInteger,message:t,_run(t,e){return t.typed&&!this.requirement(t.value)&&pu(this,"integer",t,e),t}}}function bu(t,e){return{kind:"validation",type:"length",reference:bu,async:!1,expects:`${t}`,requirement:t,message:e,_run(t,e){return t.typed&&t.value.length!==this.requirement&&pu(this,"length",t,e,{received:`${t.value.length}`}),t}}}function gu(t,e){return{kind:"validation",type:"max_value",reference:gu,async:!1,expects:`<=${t instanceof Date?t.toJSON():hu(t)}`,requirement:t,message:e,_run(t,e){return t.typed&&t.value>this.requirement&&pu(this,"value",t,e,{received:t.value instanceof Date?t.value.toJSON():hu(t.value)}),t}}}function vu(t,e){return{kind:"validation",type:"min_value",reference:vu,async:!1,expects:`>=${t instanceof Date?t.toJSON():hu(t)}`,requirement:t,message:e,_run(t,e){return t.typed&&t.value<this.requirement&&pu(this,"value",t,e,{received:t.value instanceof Date?t.value.toJSON():hu(t.value)}),t}}}function wu(t,e){return{kind:"schema",type:"instance",reference:wu,expects:t.name,async:!1,class:t,message:e,_run(t,e){return t.value instanceof this.class?t.typed=!0:pu(this,"type",t,e),t}}}function mu(t){return{kind:"schema",type:"number",reference:mu,expects:"number",async:!1,message:t,_run(t,e){return"number"!=typeof t.value||isNaN(t.value)?pu(this,"type",t,e):t.typed=!0,t}}}function Su(t,e){return{kind:"schema",type:"object",reference:Su,expects:"Object",async:!1,entries:t,message:e,_run(t,e){const r=t.value;if(r&&"object"==typeof r){t.typed=!0,t.value={};for(const n in this.entries){const i=r[n],o=this.entries[n]._run({typed:!1,value:i},e);if(o.issues){const a={type:"object",origin:"value",input:r,key:n,value:i};for(const e of o.issues)e.path?e.path.unshift(a):e.path=[a],t.issues?.push(e);if(t.issues||(t.issues=o.issues),e.abortEarly){t.typed=!1;break}}o.typed||(t.typed=!1),(void 0!==o.value||n in r)&&(t.value[n]=o.value)}}else pu(this,"type",t,e);return t}}}function _u(t,e,r){const n=t._run({typed:!1,value:e},function(t){return{lang:t?.lang??void 0,message:t?.message,abortEarly:t?.abortEarly??void 0,abortPipeEarly:t?.abortPipeEarly??void 0}}(r));if(n.issues)throw new du(n.issues);return n.value}function Eu(...t){return{...t[0],pipe:t,_run(e,r){for(const n of t)if("metadata"!==n.kind){if(e.issues&&("schema"===n.kind||"transformation"===n.kind)){e.typed=!1;break}e.issues&&(r.abortEarly||r.abortPipeEarly)||(e=n._run(e,r))}return e}}}const ku=Eu(mu(),yu(),vu(0),gu(4294967295)),Ou=Eu(mu(),yu(),vu(0),gu(2147483647)),Tu=Eu(mu(),yu(),vu(0),gu(255)),Au=Eu(wu(Uint8Array),bu(32)),Iu=Eu(wu(Uint8Array),bu(33)),Pu=Su({wif:Tu,bip32:Su({public:ku,private:ku})}),xu=Eu(function t(e){return{kind:"schema",type:"string",reference:t,expects:"string",async:!1,message:e,_run(t,e){return"string"==typeof t.value?t.typed=!0:pu(this,"type",t,e),t}}}(),function t(e,r){return{kind:"validation",type:"regex",reference:t,async:!1,expects:`${e}`,requirement:e,message:r,_run(t,e){return t.typed&&!this.requirement.test(t.value)&&pu(this,"format",t,e),t}}}(/^(m\/)?(\d+'?\/)*\d+'?$/)),Bu=function(t){if(t.length>=255)throw new TypeError("Alphabet too long");const e=new Uint8Array(256);for(let t=0;t<e.length;t++)e[t]=255;for(let r=0;r<t.length;r++){const n=t.charAt(r),i=n.charCodeAt(0);if(255!==e[i])throw new TypeError(n+" is ambiguous");e[i]=r}const r=t.length,n=t.charAt(0),i=Math.log(r)/Math.log(256),o=Math.log(256)/Math.log(r);function a(t){if("string"!=typeof t)throw new TypeError("Expected String");if(0===t.length)return new Uint8Array;let o=0,a=0,s=0;for(;t[o]===n;)a++,o++;const u=(t.length-o)*i+1>>>0,c=new Uint8Array(u);for(;o<t.length;){const n=t.charCodeAt(o);if(n>255)return;let i=e[n];if(255===i)return;let a=0;for(let t=u-1;(0!==i||a<s)&&-1!==t;t--,a++)i+=r*c[t]>>>0,c[t]=i%256>>>0,i=i/256>>>0;if(0!==i)throw new Error("Non-zero carry");s=a,o++}let f=u-s;for(;f!==u&&0===c[f];)f++;const l=new Uint8Array(a+(u-f));let h=a;for(;f!==u;)l[h++]=c[f++];return l}return{encode:function(e){if(e instanceof Uint8Array||(ArrayBuffer.isView(e)?e=new Uint8Array(e.buffer,e.byteOffset,e.byteLength):Array.isArray(e)&&(e=Uint8Array.from(e))),!(e instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===e.length)return"";let i=0,a=0,s=0;const u=e.length;for(;s!==u&&0===e[s];)s++,i++;const c=(u-s)*o+1>>>0,f=new Uint8Array(c);for(;s!==u;){let t=e[s],n=0;for(let e=c-1;(0!==t||n<a)&&-1!==e;e--,n++)t+=256*f[e]>>>0,f[e]=t%r>>>0,t=t/r>>>0;if(0!==t)throw new Error("Non-zero carry");a=n,s++}let l=c-a;for(;l!==c&&0===f[l];)l++;let h=n.repeat(i);for(;l<c;++l)h+=t.charAt(f[l]);return h},decodeUnsafe:a,decode:function(t){const e=a(t);if(e)return e;throw new Error("Non-base"+r+" character")}}}("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),Ru=function(t){function e(e){var r=e.slice(0,-4),n=e.slice(-4),i=t(r);if(!(n[0]^i[0]|n[1]^i[1]|n[2]^i[2]|n[3]^i[3]))return r}return{encode:function(e){var r=Uint8Array.from(e),n=t(r),i=r.length+4,o=new Uint8Array(i);return o.set(r,0),o.set(n.subarray(0,4),r.length),Bu.encode(o)},decode:function(t){var r=e(Bu.decode(t));if(null==r)throw new Error("Invalid checksum");return r},decodeUnsafe:function(t){var r=Bu.decodeUnsafe(t);if(null!=r)return e(r)}}}(function(t){return Os(Os(t))});const Uu=au(Os);var ju=i(8700);const Nu=BigInt(0),Lu=BigInt(1);function Cu(t,e=""){if("boolean"!=typeof t)throw new Error((e&&`"${e}"`)+"expected boolean, got type="+typeof t);return t}function Fu(t,e,r=""){const n=la(t),i=t?.length,o=void 0!==e;if(!n||o&&i!==e)throw new Error((r&&`"${r}" `)+"expected Uint8Array"+(o?` of length ${e}`:"")+", got "+(n?`length=${i}`:"type="+typeof t));return t}function Du(t){const e=t.toString(16);return 1&e.length?"0"+e:e}function Hu(t){if("string"!=typeof t)throw new Error("hex string expected, got "+typeof t);return""===t?Nu:BigInt("0x"+t)}function Mu(t){return Hu(_a(t))}function Ku(t){return pa(t),Hu(_a(Uint8Array.from(t).reverse()))}function Vu(t,e){return ka(t.toString(16).padStart(2*e,"0"))}function Wu(t,e){return Vu(t,e).reverse()}function Gu(t,e,r){let n;if("string"==typeof e)try{n=ka(e)}catch(e){throw new Error(t+" must be hex string or Uint8Array, cause: "+e)}else{if(!la(e))throw new Error(t+" must be hex string or Uint8Array");n=Uint8Array.from(e)}const i=n.length;if("number"==typeof r&&i!==r)throw new Error(t+" of length "+r+" expected, got "+i);return n}const qu=t=>"bigint"==typeof t&&Nu<=t;function zu(t,e,r,n){if(!function(t,e,r){return qu(t)&&qu(e)&&qu(r)&&e<=t&&t<r}(e,r,n))throw new Error("expected valid "+t+": "+r+" <= n < "+n+", got "+e)}function Zu(t){let e;for(e=0;t>Nu;t>>=Lu,e+=1);return e}const Xu=t=>(Lu<<BigInt(t))-Lu;function Yu(t,e,r={}){if(!t||"object"!=typeof t)throw new Error("expected valid options object");function n(e,r,n){const i=t[e];if(n&&void 0===i)return;const o=typeof i;if(o!==r||null===i)throw new Error(`param "${e}" is invalid: expected ${r}, got ${o}`)}Object.entries(e).forEach(([t,e])=>n(t,e,!1)),Object.entries(r).forEach(([t,e])=>n(t,e,!0))}function $u(t){const e=new WeakMap;return(r,...n)=>{const i=e.get(r);if(void 0!==i)return i;const o=t(r,...n);return e.set(r,o),o}}const Ju=BigInt(0),Qu=BigInt(1),tc=BigInt(2),ec=BigInt(3),rc=BigInt(4),nc=BigInt(5),ic=BigInt(7),oc=BigInt(8),ac=BigInt(9),sc=BigInt(16);function uc(t,e){const r=t%e;return r>=Ju?r:e+r}function cc(t,e,r){let n=t;for(;e-- >Ju;)n*=n,n%=r;return n}function fc(t,e){if(t===Ju)throw new Error("invert: expected non-zero number");if(e<=Ju)throw new Error("invert: expected positive modulus, got "+e);let r=uc(t,e),n=e,i=Ju,o=Qu,a=Qu,s=Ju;for(;r!==Ju;){const t=n/r,e=n%r,u=i-a*t,c=o-s*t;n=r,r=e,i=a,o=s,a=u,s=c}if(n!==Qu)throw new Error("invert: does not exist");return uc(i,e)}function lc(t,e,r){if(!t.eql(t.sqr(e),r))throw new Error("Cannot find square root")}function hc(t,e){const r=(t.ORDER+Qu)/rc,n=t.pow(e,r);return lc(t,n,e),n}function pc(t,e){const r=(t.ORDER-nc)/oc,n=t.mul(e,tc),i=t.pow(n,r),o=t.mul(e,i),a=t.mul(t.mul(o,tc),i),s=t.mul(o,t.sub(a,t.ONE));return lc(t,s,e),s}function dc(t){if(t<ec)throw new Error("sqrt is not defined for small field");let e=t-Qu,r=0;for(;e%tc===Ju;)e/=tc,r++;let n=tc;const i=wc(t);for(;1===gc(i,n);)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(1===r)return hc;let o=i.pow(n,e);const a=(e+Qu)/tc;return function(t,n){if(t.is0(n))return n;if(1!==gc(t,n))throw new Error("Cannot find square root");let i=r,s=t.mul(t.ONE,o),u=t.pow(n,e),c=t.pow(n,a);for(;!t.eql(u,t.ONE);){if(t.is0(u))return t.ZERO;let e=1,r=t.sqr(u);for(;!t.eql(r,t.ONE);)if(e++,r=t.sqr(r),e===i)throw new Error("Cannot find square root");const n=Qu<<BigInt(i-e-1),o=t.pow(s,n);i=e,s=t.sqr(o),u=t.mul(u,s),c=t.mul(c,o)}return c}}const yc=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function bc(t,e,r=!1){const n=new Array(e.length).fill(r?t.ZERO:void 0),i=e.reduce((e,r,i)=>t.is0(r)?e:(n[i]=e,t.mul(e,r)),t.ONE),o=t.inv(i);return e.reduceRight((e,r,i)=>t.is0(r)?e:(n[i]=t.mul(e,n[i]),t.mul(e,r)),o),n}function gc(t,e){const r=(t.ORDER-Qu)/tc,n=t.pow(e,r),i=t.eql(n,t.ONE),o=t.eql(n,t.ZERO),a=t.eql(n,t.neg(t.ONE));if(!i&&!o&&!a)throw new Error("invalid Legendre symbol result");return i?1:o?0:-1}function vc(t,e){void 0!==e&&ha(e);const r=void 0!==e?e:t.toString(2).length;return{nBitLength:r,nByteLength:Math.ceil(r/8)}}function wc(t,e,r=!1,n={}){if(t<=Ju)throw new Error("invalid field: expected ORDER > 0, got "+t);let i,o,a,s=!1;if("object"==typeof e&&null!=e){if(n.sqrt||r)throw new Error("cannot specify opts in two arguments");const t=e;t.BITS&&(i=t.BITS),t.sqrt&&(o=t.sqrt),"boolean"==typeof t.isLE&&(r=t.isLE),"boolean"==typeof t.modFromBytes&&(s=t.modFromBytes),a=t.allowedLengths}else"number"==typeof e&&(i=e),n.sqrt&&(o=n.sqrt);const{nBitLength:u,nByteLength:c}=vc(t,i);if(c>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let f;const l=Object.freeze({ORDER:t,isLE:r,BITS:u,BYTES:c,MASK:Xu(u),ZERO:Ju,ONE:Qu,allowedLengths:a,create:e=>uc(e,t),isValid:e=>{if("bigint"!=typeof e)throw new Error("invalid field element: expected bigint, got "+typeof e);return Ju<=e&&e<t},is0:t=>t===Ju,isValidNot0:t=>!l.is0(t)&&l.isValid(t),isOdd:t=>(t&Qu)===Qu,neg:e=>uc(-e,t),eql:(t,e)=>t===e,sqr:e=>uc(e*e,t),add:(e,r)=>uc(e+r,t),sub:(e,r)=>uc(e-r,t),mul:(e,r)=>uc(e*r,t),pow:(t,e)=>function(t,e,r){if(r<Ju)throw new Error("invalid exponent, negatives unsupported");if(r===Ju)return t.ONE;if(r===Qu)return e;let n=t.ONE,i=e;for(;r>Ju;)r&Qu&&(n=t.mul(n,i)),i=t.sqr(i),r>>=Qu;return n}(l,t,e),div:(e,r)=>uc(e*fc(r,t),t),sqrN:t=>t*t,addN:(t,e)=>t+e,subN:(t,e)=>t-e,mulN:(t,e)=>t*e,inv:e=>fc(e,t),sqrt:o||(e=>(f||(f=function(t){return t%rc===ec?hc:t%oc===nc?pc:t%sc===ac?function(t){const e=wc(t),r=dc(t),n=r(e,e.neg(e.ONE)),i=r(e,n),o=r(e,e.neg(n)),a=(t+ic)/sc;return(t,e)=>{let r=t.pow(e,a),s=t.mul(r,n);const u=t.mul(r,i),c=t.mul(r,o),f=t.eql(t.sqr(s),e),l=t.eql(t.sqr(u),e);r=t.cmov(r,s,f),s=t.cmov(c,u,l);const h=t.eql(t.sqr(s),e),p=t.cmov(r,s,h);return lc(t,p,e),p}}(t):dc(t)}(t)),f(l,e))),toBytes:t=>r?Wu(t,c):Vu(t,c),fromBytes:(e,n=!0)=>{if(a){if(!a.includes(e.length)||e.length>c)throw new Error("Field.fromBytes: expected "+a+" bytes, got "+e.length);const t=new Uint8Array(c);t.set(e,r?0:t.length-e.length),e=t}if(e.length!==c)throw new Error("Field.fromBytes: expected "+c+" bytes, got "+e.length);let i=r?Ku(e):Mu(e);if(s&&(i=uc(i,t)),!n&&!l.isValid(i))throw new Error("invalid field element: outside of range 0..ORDER");return i},invertBatch:t=>bc(l,t),cmov:(t,e,r)=>r?e:t});return Object.freeze(l)}function mc(t){if("bigint"!=typeof t)throw new Error("field order must be bigint");const e=t.toString(2).length;return Math.ceil(e/8)}function Sc(t){const e=mc(t);return e+Math.ceil(e/2)}const _c=BigInt(0),Ec=BigInt(1);function kc(t,e){const r=e.negate();return t?r:e}function Oc(t,e){const r=bc(t.Fp,e.map(t=>t.Z));return e.map((e,n)=>t.fromAffine(e.toAffine(r[n])))}function Tc(t,e){if(!Number.isSafeInteger(t)||t<=0||t>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+t)}function Ac(t,e){Tc(t,e);const r=2**t;return{windows:Math.ceil(e/t)+1,windowSize:2**(t-1),mask:Xu(t),maxNumber:r,shiftBy:BigInt(t)}}function Ic(t,e,r){const{windowSize:n,mask:i,maxNumber:o,shiftBy:a}=r;let s=Number(t&i),u=t>>a;s>n&&(s-=o,u+=Ec);const c=e*n;return{nextN:u,offset:c+Math.abs(s)-1,isZero:0===s,isNeg:s<0,isNegF:e%2!=0,offsetF:c}}const Pc=new WeakMap,xc=new WeakMap;function Bc(t){return xc.get(t)||1}function Rc(t){if(t!==_c)throw new Error("invalid wNAF")}class Uc{constructor(t,e){this.BASE=t.BASE,this.ZERO=t.ZERO,this.Fn=t.Fn,this.bits=e}_unsafeLadder(t,e,r=this.ZERO){let n=t;for(;e>_c;)e&Ec&&(r=r.add(n)),n=n.double(),e>>=Ec;return r}precomputeWindow(t,e){const{windows:r,windowSize:n}=Ac(e,this.bits),i=[];let o=t,a=o;for(let t=0;t<r;t++){a=o,i.push(a);for(let t=1;t<n;t++)a=a.add(o),i.push(a);o=a.double()}return i}wNAF(t,e,r){if(!this.Fn.isValid(r))throw new Error("invalid scalar");let n=this.ZERO,i=this.BASE;const o=Ac(t,this.bits);for(let t=0;t<o.windows;t++){const{nextN:a,offset:s,isZero:u,isNeg:c,isNegF:f,offsetF:l}=Ic(r,t,o);r=a,u?i=i.add(kc(f,e[l])):n=n.add(kc(c,e[s]))}return Rc(r),{p:n,f:i}}wNAFUnsafe(t,e,r,n=this.ZERO){const i=Ac(t,this.bits);for(let t=0;t<i.windows&&r!==_c;t++){const{nextN:o,offset:a,isZero:s,isNeg:u}=Ic(r,t,i);if(r=o,!s){const t=e[a];n=n.add(u?t.negate():t)}}return Rc(r),n}getPrecomputes(t,e,r){let n=Pc.get(e);return n||(n=this.precomputeWindow(e,t),1!==t&&("function"==typeof r&&(n=r(n)),Pc.set(e,n))),n}cached(t,e,r){const n=Bc(t);return this.wNAF(n,this.getPrecomputes(n,t,r),e)}unsafe(t,e,r,n){const i=Bc(t);return 1===i?this._unsafeLadder(t,e,n):this.wNAFUnsafe(i,this.getPrecomputes(i,t,r),e,n)}createCache(t,e){Tc(e,this.bits),xc.set(t,e),Pc.delete(t)}hasCache(t){return 1!==Bc(t)}}function jc(t,e,r){if(e){if(e.ORDER!==t)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return function(t){Yu(t,yc.reduce((t,e)=>(t[e]="function",t),{ORDER:"bigint",MASK:"bigint",BYTES:"number",BITS:"number"}))}(e),e}return wc(t,{isLE:r})}const Nc=(t,e)=>(t+(t>=0?e:-e)/Kc)/e;function Lc(t){if(!["compact","recovered","der"].includes(t))throw new Error('Signature format must be "compact", "recovered", or "der"');return t}function Cc(t,e){const r={};for(let n of Object.keys(e))r[n]=void 0===t[n]?e[n]:t[n];return Cu(r.lowS,"lowS"),Cu(r.prehash,"prehash"),void 0!==r.format&&Lc(r.format),r}class Fc extends Error{constructor(t=""){super(t)}}const Dc={Err:Fc,_tlv:{encode:(t,e)=>{const{Err:r}=Dc;if(t<0||t>256)throw new r("tlv.encode: wrong tag");if(1&e.length)throw new r("tlv.encode: unpadded data");const n=e.length/2,i=Du(n);if(i.length/2&128)throw new r("tlv.encode: long form length too big");const o=n>127?Du(i.length/2|128):"";return Du(t)+o+i+e},decode(t,e){const{Err:r}=Dc;let n=0;if(t<0||t>256)throw new r("tlv.encode: wrong tag");if(e.length<2||e[n++]!==t)throw new r("tlv.decode: wrong tlv");const i=e[n++];let o=0;if(128&i){const t=127&i;if(!t)throw new r("tlv.decode(long): indefinite length not supported");if(t>4)throw new r("tlv.decode(long): byte length is too big");const a=e.subarray(n,n+t);if(a.length!==t)throw new r("tlv.decode: length bytes not complete");if(0===a[0])throw new r("tlv.decode(long): zero leftmost byte");for(const t of a)o=o<<8|t;if(n+=t,o<128)throw new r("tlv.decode(long): not minimal encoding")}else o=i;const a=e.subarray(n,n+o);if(a.length!==o)throw new r("tlv.decode: wrong value length");return{v:a,l:e.subarray(n+o)}}},_int:{encode(t){const{Err:e}=Dc;if(t<Hc)throw new e("integer: negative integers are not allowed");let r=Du(t);if(8&Number.parseInt(r[0],16)&&(r="00"+r),1&r.length)throw new e("unexpected DER parsing assertion: unpadded hex");return r},decode(t){const{Err:e}=Dc;if(128&t[0])throw new e("invalid signature integer: negative");if(0===t[0]&&!(128&t[1]))throw new e("invalid signature integer: unnecessary leading zero");return Mu(t)}},toSig(t){const{Err:e,_int:r,_tlv:n}=Dc,i=Gu("signature",t),{v:o,l:a}=n.decode(48,i);if(a.length)throw new e("invalid signature: left bytes after parsing");const{v:s,l:u}=n.decode(2,o),{v:c,l:f}=n.decode(2,u);if(f.length)throw new e("invalid signature: left bytes after parsing");return{r:r.decode(s),s:r.decode(c)}},hexFromSig(t){const{_tlv:e,_int:r}=Dc,n=e.encode(2,r.encode(t.r))+e.encode(2,r.encode(t.s));return e.encode(48,n)}},Hc=BigInt(0),Mc=BigInt(1),Kc=BigInt(2),Vc=BigInt(3),Wc=BigInt(4);function Gc(t,e){const{BYTES:r}=t;let n;if("bigint"==typeof e)n=e;else{let i=Gu("private key",e);try{n=t.fromBytes(i)}catch(t){throw new Error(`invalid private key: expected ui8a of size ${r}, got ${typeof e}`)}}if(!t.isValidNot0(n))throw new Error("invalid private key: out of range [1..N-1]");return n}function qc(t,e={}){const r=function(t,e,r={},n){if(void 0===n&&(n="edwards"===t),!e||"object"!=typeof e)throw new Error(`expected valid ${t} CURVE object`);for(const t of["p","n","h"]){const r=e[t];if(!("bigint"==typeof r&&r>_c))throw new Error(`CURVE.${t} must be positive bigint`)}const i=jc(e.p,r.Fp,n),o=jc(e.n,r.Fn,n),a=["Gx","Gy","a","weierstrass"===t?"b":"d"];for(const t of a)if(!i.isValid(e[t]))throw new Error(`CURVE.${t} must be valid field element of CURVE.Fp`);return{CURVE:e=Object.freeze(Object.assign({},e)),Fp:i,Fn:o}}("weierstrass",t,e),{Fp:n,Fn:i}=r;let o=r.CURVE;const{h:a,n:s}=o;Yu(e,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object",wrapPrivateKey:"boolean"});const{endo:u}=e;if(u&&(!n.is0(o.a)||"bigint"!=typeof u.beta||!Array.isArray(u.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');const c=Zc(n,i);function f(){if(!n.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}const l=e.toBytes||function(t,e,r){const{x:i,y:o}=e.toAffine(),a=n.toBytes(i);return Cu(r,"isCompressed"),r?(f(),Aa(zc(!n.isOdd(o)),a)):Aa(Uint8Array.of(4),a,n.toBytes(o))},h=e.fromBytes||function(t){Fu(t,void 0,"Point");const{publicKey:e,publicKeyUncompressed:r}=c,i=t.length,o=t[0],a=t.subarray(1);if(i!==e||2!==o&&3!==o){if(i===r&&4===o){const t=n.BYTES,e=n.fromBytes(a.subarray(0,t)),r=n.fromBytes(a.subarray(t,2*t));if(!d(e,r))throw new Error("bad point: is not on curve");return{x:e,y:r}}throw new Error(`bad point: got length ${i}, expected compressed=${e} or uncompressed=${r}`)}{const t=n.fromBytes(a);if(!n.isValid(t))throw new Error("bad point: is not on curve, wrong x");const e=p(t);let r;try{r=n.sqrt(e)}catch(t){const e=t instanceof Error?": "+t.message:"";throw new Error("bad point: is not on curve, sqrt error"+e)}return f(),!(1&~o)!==n.isOdd(r)&&(r=n.neg(r)),{x:t,y:r}}};function p(t){const e=n.sqr(t),r=n.mul(e,t);return n.add(n.add(r,n.mul(t,o.a)),o.b)}function d(t,e){const r=n.sqr(e),i=p(t);return n.eql(r,i)}if(!d(o.Gx,o.Gy))throw new Error("bad curve params: generator point");const y=n.mul(n.pow(o.a,Vc),Wc),b=n.mul(n.sqr(o.b),BigInt(27));if(n.is0(n.add(y,b)))throw new Error("bad curve params: a or b");function g(t,e,r=!1){if(!n.isValid(e)||r&&n.is0(e))throw new Error(`bad point coordinate ${t}`);return e}function v(t){if(!(t instanceof E))throw new Error("ProjectivePoint expected")}function w(t){if(!u||!u.basises)throw new Error("no endo");return function(t,e,r){const[[n,i],[o,a]]=e,s=Nc(a*t,r),u=Nc(-i*t,r);let c=t-s*n-u*o,f=-s*i-u*a;const l=c<Hc,h=f<Hc;l&&(c=-c),h&&(f=-f);const p=Xu(Math.ceil(Zu(r)/2))+Mc;if(c<Hc||c>=p||f<Hc||f>=p)throw new Error("splitScalar (endomorphism): failed, k="+t);return{k1neg:l,k1:c,k2neg:h,k2:f}}(t,u.basises,i.ORDER)}const m=$u((t,e)=>{const{X:r,Y:i,Z:o}=t;if(n.eql(o,n.ONE))return{x:r,y:i};const a=t.is0();null==e&&(e=a?n.ONE:n.inv(o));const s=n.mul(r,e),u=n.mul(i,e),c=n.mul(o,e);if(a)return{x:n.ZERO,y:n.ZERO};if(!n.eql(c,n.ONE))throw new Error("invZ was invalid");return{x:s,y:u}}),S=$u(t=>{if(t.is0()){if(e.allowInfinityPoint&&!n.is0(t.Y))return;throw new Error("bad point: ZERO")}const{x:r,y:i}=t.toAffine();if(!n.isValid(r)||!n.isValid(i))throw new Error("bad point: x or y not field elements");if(!d(r,i))throw new Error("bad point: equation left != right");if(!t.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});function _(t,e,r,i,o){return r=new E(n.mul(r.X,t),r.Y,r.Z),e=kc(i,e),r=kc(o,r),e.add(r)}class E{constructor(t,e,r){this.X=g("x",t),this.Y=g("y",e,!0),this.Z=g("z",r),Object.freeze(this)}static CURVE(){return o}static fromAffine(t){const{x:e,y:r}=t||{};if(!t||!n.isValid(e)||!n.isValid(r))throw new Error("invalid affine point");if(t instanceof E)throw new Error("projective point not allowed");return n.is0(e)&&n.is0(r)?E.ZERO:new E(e,r,n.ONE)}static fromBytes(t){const e=E.fromAffine(h(Fu(t,void 0,"point")));return e.assertValidity(),e}static fromHex(t){return E.fromBytes(Gu("pointHex",t))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(t=8,e=!0){return O.createCache(this,t),e||this.multiply(Vc),this}assertValidity(){S(this)}hasEvenY(){const{y:t}=this.toAffine();if(!n.isOdd)throw new Error("Field doesn't support isOdd");return!n.isOdd(t)}equals(t){v(t);const{X:e,Y:r,Z:i}=this,{X:o,Y:a,Z:s}=t,u=n.eql(n.mul(e,s),n.mul(o,i)),c=n.eql(n.mul(r,s),n.mul(a,i));return u&&c}negate(){return new E(this.X,n.neg(this.Y),this.Z)}double(){const{a:t,b:e}=o,r=n.mul(e,Vc),{X:i,Y:a,Z:s}=this;let u=n.ZERO,c=n.ZERO,f=n.ZERO,l=n.mul(i,i),h=n.mul(a,a),p=n.mul(s,s),d=n.mul(i,a);return d=n.add(d,d),f=n.mul(i,s),f=n.add(f,f),u=n.mul(t,f),c=n.mul(r,p),c=n.add(u,c),u=n.sub(h,c),c=n.add(h,c),c=n.mul(u,c),u=n.mul(d,u),f=n.mul(r,f),p=n.mul(t,p),d=n.sub(l,p),d=n.mul(t,d),d=n.add(d,f),f=n.add(l,l),l=n.add(f,l),l=n.add(l,p),l=n.mul(l,d),c=n.add(c,l),p=n.mul(a,s),p=n.add(p,p),l=n.mul(p,d),u=n.sub(u,l),f=n.mul(p,h),f=n.add(f,f),f=n.add(f,f),new E(u,c,f)}add(t){v(t);const{X:e,Y:r,Z:i}=this,{X:a,Y:s,Z:u}=t;let c=n.ZERO,f=n.ZERO,l=n.ZERO;const h=o.a,p=n.mul(o.b,Vc);let d=n.mul(e,a),y=n.mul(r,s),b=n.mul(i,u),g=n.add(e,r),w=n.add(a,s);g=n.mul(g,w),w=n.add(d,y),g=n.sub(g,w),w=n.add(e,i);let m=n.add(a,u);return w=n.mul(w,m),m=n.add(d,b),w=n.sub(w,m),m=n.add(r,i),c=n.add(s,u),m=n.mul(m,c),c=n.add(y,b),m=n.sub(m,c),l=n.mul(h,w),c=n.mul(p,b),l=n.add(c,l),c=n.sub(y,l),l=n.add(y,l),f=n.mul(c,l),y=n.add(d,d),y=n.add(y,d),b=n.mul(h,b),w=n.mul(p,w),y=n.add(y,b),b=n.sub(d,b),b=n.mul(h,b),w=n.add(w,b),d=n.mul(y,w),f=n.add(f,d),d=n.mul(m,w),c=n.mul(g,c),c=n.sub(c,d),d=n.mul(g,y),l=n.mul(m,l),l=n.add(l,d),new E(c,f,l)}subtract(t){return this.add(t.negate())}is0(){return this.equals(E.ZERO)}multiply(t){const{endo:r}=e;if(!i.isValidNot0(t))throw new Error("invalid scalar: out of range");let n,o;const a=t=>O.cached(this,t,t=>Oc(E,t));if(r){const{k1neg:e,k1:i,k2neg:s,k2:u}=w(t),{p:c,f}=a(i),{p:l,f:h}=a(u);o=f.add(h),n=_(r.beta,c,l,e,s)}else{const{p:e,f:r}=a(t);n=e,o=r}return Oc(E,[n,o])[0]}multiplyUnsafe(t){const{endo:r}=e,n=this;if(!i.isValid(t))throw new Error("invalid scalar: out of range");if(t===Hc||n.is0())return E.ZERO;if(t===Mc)return n;if(O.hasCache(this))return this.multiply(t);if(r){const{k1neg:e,k1:i,k2neg:o,k2:a}=w(t),{p1:s,p2:u}=function(t,e,r,n){let i=e,o=t.ZERO,a=t.ZERO;for(;r>_c||n>_c;)r&Ec&&(o=o.add(i)),n&Ec&&(a=a.add(i)),i=i.double(),r>>=Ec,n>>=Ec;return{p1:o,p2:a}}(E,n,i,a);return _(r.beta,s,u,e,o)}return O.unsafe(n,t)}multiplyAndAddUnsafe(t,e,r){const n=this.multiplyUnsafe(e).add(t.multiplyUnsafe(r));return n.is0()?void 0:n}toAffine(t){return m(this,t)}isTorsionFree(){const{isTorsionFree:t}=e;return a===Mc||(t?t(E,this):O.unsafe(this,s).is0())}clearCofactor(){const{clearCofactor:t}=e;return a===Mc?this:t?t(E,this):this.multiplyUnsafe(a)}isSmallOrder(){return this.multiplyUnsafe(a).is0()}toBytes(t=!0){return Cu(t,"isCompressed"),this.assertValidity(),l(E,this,t)}toHex(t=!0){return _a(this.toBytes(t))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}get px(){return this.X}get py(){return this.X}get pz(){return this.Z}toRawBytes(t=!0){return this.toBytes(t)}_setWindowSize(t){this.precompute(t)}static normalizeZ(t){return Oc(E,t)}static msm(t,e){return function(t,e,r,n){(function(t,e){if(!Array.isArray(t))throw new Error("array expected");t.forEach((t,r)=>{if(!(t instanceof e))throw new Error("invalid point at index "+r)})})(r,t),function(t,e){if(!Array.isArray(t))throw new Error("array of scalars expected");t.forEach((t,r)=>{if(!e.isValid(t))throw new Error("invalid scalar at index "+r)})}(n,e);const i=r.length,o=n.length;if(i!==o)throw new Error("arrays of points and scalars must have equal length");const a=t.ZERO,s=Zu(BigInt(i));let u=1;s>12?u=s-3:s>4?u=s-2:s>0&&(u=2);const c=Xu(u),f=new Array(Number(c)+1).fill(a);let l=a;for(let t=Math.floor((e.BITS-1)/u)*u;t>=0;t-=u){f.fill(a);for(let e=0;e<o;e++){const i=n[e],o=Number(i>>BigInt(t)&c);f[o]=f[o].add(r[e])}let e=a;for(let t=f.length-1,r=a;t>0;t--)r=r.add(f[t]),e=e.add(r);if(l=l.add(e),0!==t)for(let t=0;t<u;t++)l=l.double()}return l}(E,i,t,e)}static fromPrivateKey(t){return E.BASE.multiply(Gc(i,t))}}E.BASE=new E(o.Gx,o.Gy,n.ONE),E.ZERO=new E(n.ZERO,n.ONE,n.ZERO),E.Fp=n,E.Fn=i;const k=i.BITS,O=new Uc(E,e.endo?Math.ceil(k/2):k);return E.BASE.precompute(8),E}function zc(t){return Uint8Array.of(t?2:3)}function Zc(t,e){return{secretKey:e.BYTES,publicKey:1+t.BYTES,publicKeyUncompressed:1+2*t.BYTES,publicKeyHasPrefix:!0,signature:2*e.BYTES}}function Xc(t,e,r={}){da(e),Yu(r,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});const n=r.randomBytes||xa,i=r.hmac||((t,...r)=>Ra(e,t,Aa(...r))),{Fp:o,Fn:a}=t,{ORDER:s,BITS:u}=a,{keygen:c,getPublicKey:f,getSharedSecret:l,utils:h,lengths:p}=function(t,e={}){const{Fn:r}=t,n=e.randomBytes||xa,i=Object.assign(Zc(t.Fp,r),{seed:Sc(r.ORDER)});function o(t){try{return!!Gc(r,t)}catch(t){return!1}}function a(t=n(i.seed)){return function(t,e,r=!1){const n=t.length,i=mc(e),o=Sc(e);if(n<16||n<o||n>1024)throw new Error("expected "+o+"-1024 bytes of input, got "+n);const a=uc(r?Ku(t):Mu(t),e-Qu)+Qu;return r?Wu(a,i):Vu(a,i)}(Fu(t,i.seed,"seed"),r.ORDER)}function s(e,n=!0){return t.BASE.multiply(Gc(r,e)).toBytes(n)}function u(e){if("bigint"==typeof e)return!1;if(e instanceof t)return!0;const{secretKey:n,publicKey:o,publicKeyUncompressed:a}=i;if(r.allowedLengths||n===o)return;const s=Gu("key",e).length;return s===o||s===a}const c={isValidSecretKey:o,isValidPublicKey:function(e,r){const{publicKey:n,publicKeyUncompressed:o}=i;try{const i=e.length;return!(!0===r&&i!==n||!1===r&&i!==o||!t.fromBytes(e))}catch(t){return!1}},randomSecretKey:a,isValidPrivateKey:o,randomPrivateKey:a,normPrivateKeyToScalar:t=>Gc(r,t),precompute:(e=8,r=t.BASE)=>r.precompute(e,!1)};return Object.freeze({getPublicKey:s,getSharedSecret:function(e,n,i=!0){if(!0===u(e))throw new Error("first arg must be private key");if(!1===u(n))throw new Error("second arg must be public key");const o=Gc(r,e);return t.fromHex(n).multiply(o).toBytes(i)},keygen:function(t){const e=a(t);return{secretKey:e,publicKey:s(e)}},Point:t,utils:c,lengths:i})}(t,r),d={prehash:!1,lowS:"boolean"==typeof r.lowS&&r.lowS,format:void 0,extraEntropy:!1},y="compact";function b(t){return t>s>>Mc}function g(t,e){if(!a.isValidNot0(e))throw new Error(`invalid signature ${t}: out of range 1..Point.Fn.ORDER`);return e}class v{constructor(t,e,r){this.r=g("r",t),this.s=g("s",e),null!=r&&(this.recovery=r),Object.freeze(this)}static fromBytes(t,e=y){let r;if(function(t,e){Lc(e);const r=p.signature;Fu(t,"compact"===e?r:"recovered"===e?r+1:void 0,`${e} signature`)}(t,e),"der"===e){const{r:e,s:r}=Dc.toSig(Fu(t));return new v(e,r)}"recovered"===e&&(r=t[0],e="compact",t=t.subarray(1));const n=a.BYTES,i=t.subarray(0,n),o=t.subarray(n,2*n);return new v(a.fromBytes(i),a.fromBytes(o),r)}static fromHex(t,e){return this.fromBytes(ka(t),e)}addRecoveryBit(t){return new v(this.r,this.s,t)}recoverPublicKey(e){const r=o.ORDER,{r:n,s:i,recovery:u}=this;if(null==u||![0,1,2,3].includes(u))throw new Error("recovery id invalid");if(s*Kc<r&&u>1)throw new Error("recovery id is ambiguous for h>1 curve");const c=2===u||3===u?n+s:n;if(!o.isValid(c))throw new Error("recovery id 2 or 3 invalid");const f=o.toBytes(c),l=t.fromBytes(Aa(zc(!(1&u)),f)),h=a.inv(c),p=m(Gu("msgHash",e)),d=a.create(-p*h),y=a.create(i*h),b=t.BASE.multiplyUnsafe(d).add(l.multiplyUnsafe(y));if(b.is0())throw new Error("point at infinify");return b.assertValidity(),b}hasHighS(){return b(this.s)}toBytes(t=y){if(Lc(t),"der"===t)return ka(Dc.hexFromSig(this));const e=a.toBytes(this.r),r=a.toBytes(this.s);if("recovered"===t){if(null==this.recovery)throw new Error("recovery bit must be present");return Aa(Uint8Array.of(this.recovery),e,r)}return Aa(e,r)}toHex(t){return _a(this.toBytes(t))}assertValidity(){}static fromCompact(t){return v.fromBytes(Gu("sig",t),"compact")}static fromDER(t){return v.fromBytes(Gu("sig",t),"der")}normalizeS(){return this.hasHighS()?new v(this.r,a.neg(this.s),this.recovery):this}toDERRawBytes(){return this.toBytes("der")}toDERHex(){return _a(this.toBytes("der"))}toCompactRawBytes(){return this.toBytes("compact")}toCompactHex(){return _a(this.toBytes("compact"))}}const w=r.bits2int||function(t){if(t.length>8192)throw new Error("input is too large");const e=Mu(t),r=8*t.length-u;return r>0?e>>BigInt(r):e},m=r.bits2int_modN||function(t){return a.create(w(t))},S=Xu(u);function _(t){return zu("num < 2^"+u,t,Hc,S),a.toBytes(t)}function E(t,r){return Fu(t,void 0,"message"),r?Fu(e(t),void 0,"prehashed message"):t}return Object.freeze({keygen:c,getPublicKey:f,getSharedSecret:l,utils:h,lengths:p,Point:t,sign:function(r,o,s={}){r=Gu("message",r);const{seed:u,k2sig:c}=function(e,r,i){if(["recovered","canonical"].some(t=>t in i))throw new Error("sign() legacy options not supported");const{lowS:o,prehash:s,extraEntropy:u}=Cc(i,d);e=E(e,s);const c=m(e),f=Gc(a,r),l=[_(f),_(c)];if(null!=u&&!1!==u){const t=!0===u?n(p.secretKey):u;l.push(Gu("extraEntropy",t))}const h=Aa(...l),y=c;return{seed:h,k2sig:function(e){const r=w(e);if(!a.isValidNot0(r))return;const n=a.inv(r),i=t.BASE.multiply(r).toAffine(),s=a.create(i.x);if(s===Hc)return;const u=a.create(n*a.create(y+s*f));if(u===Hc)return;let c=(i.x===s?0:2)|Number(i.y&Mc),l=u;return o&&b(u)&&(l=a.neg(u),c^=1),new v(s,l,c)}}}(r,o,s);return function(t,e,r){if("number"!=typeof t||t<2)throw new Error("hashLen must be a number");if("number"!=typeof e||e<2)throw new Error("qByteLen must be a number");if("function"!=typeof r)throw new Error("hmacFn must be a function");const n=t=>new Uint8Array(t),i=t=>Uint8Array.of(t);let o=n(t),a=n(t),s=0;const u=()=>{o.fill(1),a.fill(0),s=0},c=(...t)=>r(a,o,...t),f=(t=n(0))=>{a=c(i(0),t),o=c(),0!==t.length&&(a=c(i(1),t),o=c())},l=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let t=0;const r=[];for(;t<e;){o=c();const e=o.slice();r.push(e),t+=o.length}return Aa(...r)};return(t,e)=>{let r;for(u(),f(t);!(r=e(l()));)f();return u(),r}}(e.outputLen,a.BYTES,i)(u,c)},verify:function(e,r,n,i={}){const{lowS:o,prehash:s,format:u}=Cc(i,d);if(n=Gu("publicKey",n),r=E(Gu("message",r),s),"strict"in i)throw new Error("options.strict was renamed to lowS");const c=void 0===u?function(t){let e;const r="string"==typeof t||la(t),n=!r&&null!==t&&"object"==typeof t&&"bigint"==typeof t.r&&"bigint"==typeof t.s;if(!r&&!n)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");if(n)e=new v(t.r,t.s);else if(r){try{e=v.fromBytes(Gu("sig",t),"der")}catch(t){if(!(t instanceof Dc.Err))throw t}if(!e)try{e=v.fromBytes(Gu("sig",t),"compact")}catch(t){return!1}}return e||!1}(e):v.fromBytes(Gu("sig",e),u);if(!1===c)return!1;try{const e=t.fromBytes(n);if(o&&c.hasHighS())return!1;const{r:i,s}=c,u=m(r),f=a.inv(s),l=a.create(u*f),h=a.create(i*f),p=t.BASE.multiplyUnsafe(l).add(e.multiplyUnsafe(h));return!p.is0()&&a.create(p.x)===i}catch(t){return!1}},recoverPublicKey:function(t,e,r={}){const{prehash:n}=Cc(r,d);return e=E(e,n),v.fromBytes(t,"recovered").recoverPublicKey(e).toBytes()},Signature:v,hash:e})}function Yc(t){const{CURVE:e,curveOpts:r,hash:n,ecdsaOpts:i}=function(t){const{CURVE:e,curveOpts:r}=function(t){const e={a:t.a,b:t.b,p:t.Fp.ORDER,n:t.n,h:t.h,Gx:t.Gx,Gy:t.Gy},r=t.Fp;let n=t.allowedPrivateKeyLengths?Array.from(new Set(t.allowedPrivateKeyLengths.map(t=>Math.ceil(t/2)))):void 0;return{CURVE:e,curveOpts:{Fp:r,Fn:wc(e.n,{BITS:t.nBitLength,allowedLengths:n,modFromBytes:t.wrapPrivateKey}),allowInfinityPoint:t.allowInfinityPoint,endo:t.endo,isTorsionFree:t.isTorsionFree,clearCofactor:t.clearCofactor,fromBytes:t.fromBytes,toBytes:t.toBytes}}}(t),n={hmac:t.hmac,randomBytes:t.randomBytes,lowS:t.lowS,bits2int:t.bits2int,bits2int_modN:t.bits2int_modN};return{CURVE:e,curveOpts:r,hash:t.hash,ecdsaOpts:n}}(t);return function(t,e){const r=e.Point;return Object.assign({},e,{ProjectivePoint:r,CURVE:Object.assign({},t,vc(r.Fn.ORDER,r.Fn.BITS))})}(t,Xc(qc(e,r),n,i))}const $c={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},Jc={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]},Qc=BigInt(2),tf=wc($c.p,{sqrt:function(t){const e=$c.p,r=BigInt(3),n=BigInt(6),i=BigInt(11),o=BigInt(22),a=BigInt(23),s=BigInt(44),u=BigInt(88),c=t*t*t%e,f=c*c*t%e,l=cc(f,r,e)*f%e,h=cc(l,r,e)*f%e,p=cc(h,Qc,e)*c%e,d=cc(p,i,e)*p%e,y=cc(d,o,e)*d%e,b=cc(y,s,e)*y%e,g=cc(b,u,e)*b%e,v=cc(g,s,e)*y%e,w=cc(v,r,e)*f%e,m=cc(w,a,e)*d%e,S=cc(m,n,e)*c%e,_=cc(S,Qc,e);if(!tf.eql(tf.sqr(_),t))throw new Error("Cannot find square root");return _}}),ef=function(t){const e=e=>Yc({...t,hash:e});return{...e(ks),create:e}}({...$c,Fp:tf,lowS:!0,endo:Jc}),rf=Aa,nf=Oa,of=Mu;var af=i(8287).Buffer;function sf(t){return sf="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},sf(t)}function uf(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,ff(n.key),n)}}function cf(t,e,r){return(e=ff(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function ff(t){var e=function(t){if("object"!=sf(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=sf(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==sf(e)?e:e+""}ur(ca);var lf=function(t){!function(t){if(Ls(t.isPoint(Ns("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),Ls(!t.isPoint(Ns("030000000000000000000000000000000000000000000000000000000000000005"))),Ls(t.isPrivate(Ns("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),Ls(t.isPrivate(Ns("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"))),Ls(!t.isPrivate(Ns("0000000000000000000000000000000000000000000000000000000000000000"))),Ls(!t.isPrivate(Ns("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"))),Ls(!t.isPrivate(Ns("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364142"))),Ls(0===Bs(t.pointFromScalar(Ns("b1121e4088a66a28f5b6b0f5844943ecd9f610196d7bb83b25214b60452c09af")),Ns("02b07ba9dca9523b7ef4bd97703d43d20399eb698e194704791a25ce77a400df99"))),t.xOnlyPointAddTweak){Ls(null===t.xOnlyPointAddTweak(Ns("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Ns("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140")));let e=t.xOnlyPointAddTweak(Ns("1617d38ed8d8657da4d4761e8057bc396ea9e4b9d29776d4be096016dbd2509b"),Ns("a8397a935f0dfceba6ba9618f6451ef4d80637abf4e6af2669fbc9de6a8fd2ac"));Ls(0===Bs(e.xOnlyPubkey,Ns("e478f99dab91052ab39a33ea35fd5e6e4933f4d28023cd597c9a1f6760346adf"))&&1===e.parity),e=t.xOnlyPointAddTweak(Ns("2c0b7cf95324a07d05398b240174dc0c2be444d96b159aa6c7f7b1e668680991"),Ns("823c3cd2142744b075a87eade7e1b8678ba308d566226a0056ca2b7a76f86b47"))}Ls(0===Bs(t.pointAddScalar(Ns("0379be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Ns("0000000000000000000000000000000000000000000000000000000000000003")),Ns("02c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee5"))),Ls(0===Bs(t.privateAdd(Ns("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd036413e"),Ns("0000000000000000000000000000000000000000000000000000000000000002")),Ns("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"))),t.privateNegate&&(Ls(0===Bs(t.privateNegate(Ns("0000000000000000000000000000000000000000000000000000000000000001")),Ns("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"))),Ls(0===Bs(t.privateNegate(Ns("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd036413e")),Ns("0000000000000000000000000000000000000000000000000000000000000003"))),Ls(0===Bs(t.privateNegate(Ns("b1121e4088a66a28f5b6b0f5844943ecd9f610196d7bb83b25214b60452c09af")),Ns("4eede1bf775995d70a494f0a7bb6bc11e0b8cccd41cce8009ab1132c8b0a3792")))),Ls(0===Bs(t.sign(Ns("5e9f0a0d593efdcf78ac923bc3313e4e7d408d574354ee2b3288c0da9fbba6ed"),Ns("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140")),Ns("54c4a33c6423d689378f160a7ff8b61330444abb58fb470f96ea16d99d4a2fed07082304410efa6b2943111b6a4e0aaa7b7db55a07e9861d1fb3cb1f421044a5"))),Ls(t.verify(Ns("5e9f0a0d593efdcf78ac923bc3313e4e7d408d574354ee2b3288c0da9fbba6ed"),Ns("0379be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Ns("54c4a33c6423d689378f160a7ff8b61330444abb58fb470f96ea16d99d4a2fed07082304410efa6b2943111b6a4e0aaa7b7db55a07e9861d1fb3cb1f421044a5"))),t.signSchnorr&&Ls(0===Bs(t.signSchnorr(Ns("7e2d58d8b3bcdf1abadec7829054f90dda9805aab56c77333024b9d0a508b75c"),Ns("c90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b14e5c9"),Ns("c87aa53824b4d7ae2eb035a2b5bbbccc080e76cdc6d1692c4b0b62d798e6d906")),Ns("5831aaeed7b44bb74e5eab94ba9d4294c49bcf2a60728d8b4c200f50dd313c1bab745879a5ad954a72c45a91c3a51d3c7adea98d82f8481e0e1e03674a6f3fb7"))),t.verifySchnorr&&Ls(t.verifySchnorr(Ns("7e2d58d8b3bcdf1abadec7829054f90dda9805aab56c77333024b9d0a508b75c"),Ns("dd308afec5777e13121fa72b9cc1b7cc0139715309b086c960e18fd969774eb8"),Ns("5831aaeed7b44bb74e5eab94ba9d4294c49bcf2a60728d8b4c200f50dd313c1bab745879a5ad954a72c45a91c3a51d3c7adea98d82f8481e0e1e03674a6f3fb7")))}(t);const e={messagePrefix:"Bitcoin Signed Message:\n",bech32:"bc",bip32:{public:76067358,private:76066276},pubKeyHash:0,scriptHash:5,wif:128},r=2147483648;class n{__D;__Q;lowR=!1;constructor(t,e){this.__D=t,this.__Q=e}get publicKey(){return void 0===this.__Q&&(this.__Q=t.pointFromScalar(this.__D,!0)),this.__Q}get privateKey(){return this.__D}sign(e,r){if(!this.privateKey)throw new Error("Missing private key");if(void 0===r&&(r=this.lowR),!1===r)return t.sign(e,this.privateKey);{let r=t.sign(e,this.privateKey);const n=new Uint8Array(32);let i=0;for(;r[0]>127;)i++,Us(n,0,i,"LE"),r=t.sign(e,this.privateKey,n);return r}}signSchnorr(e){if(!this.privateKey)throw new Error("Missing private key");if(!t.signSchnorr)throw new Error("signSchnorr not supported by ecc library");return t.signSchnorr(e,this.privateKey)}verify(e,r){return t.verify(e,this.publicKey,r)}verifySchnorr(e,r){if(!t.verifySchnorr)throw new Error("verifySchnorr not supported by ecc library");return t.verifySchnorr(e,this.publicKey.subarray(1,33),r)}}class i extends n{chainCode;network;__DEPTH;__INDEX;__PARENT_FINGERPRINT;constructor(t,e,r,n,i=0,o=0,a=0){super(t,e),this.chainCode=r,this.network=n,this.__DEPTH=i,this.__INDEX=o,this.__PARENT_FINGERPRINT=a,_u(Pu,n)}get depth(){return this.__DEPTH}get index(){return this.__INDEX}get parentFingerprint(){return this.__PARENT_FINGERPRINT}get identifier(){return function(t){return Ja(Os(t))}(this.publicKey)}get fingerprint(){return this.identifier.slice(0,4)}get compressed(){return!0}isNeutered(){return void 0===this.__D}neutered(){return s(this.publicKey,this.chainCode,this.network,this.depth,this.index,this.parentFingerprint)}toBase58(){const t=this.network,e=this.isNeutered()?t.bip32.public:t.bip32.private,r=new Uint8Array(78);return Us(r,0,e,"BE"),Rs(r,4,this.depth),Us(r,5,this.parentFingerprint,"BE"),Us(r,9,this.index,"BE"),r.set(this.chainCode,13),this.isNeutered()?r.set(this.publicKey,45):(Rs(r,45,0),r.set(this.privateKey,46)),n=r,Uu.encode(n);var n}toWIF(){if(!this.privateKey)throw new TypeError("Missing private key");return t={version:this.network.wif,privateKey:this.privateKey,compressed:!0},Ru.encode(function(t,e,r){if(32!==e.length)throw new TypeError("Invalid privateKey length");var n=new Uint8Array(r?34:33);return new DataView(n.buffer).setUint8(0,t),n.set(e,1),r&&(n[33]=1),n}(t.version,t.privateKey,t.compressed));var t}derive(e){_u(ku,e);const n=e>=r,i=new Uint8Array(37);if(n){if(this.isNeutered())throw new TypeError("Missing private key for hardened child key");i[0]=0,i.set(this.privateKey,1),Us(i,33,e,"BE")}else i.set(this.publicKey,0),Us(i,33,e,"BE");const o=As(this.chainCode,i),u=o.slice(0,32),c=o.slice(32);if(!t.isPrivate(u))return this.derive(e+1);let f;if(this.isNeutered()){const r=t.pointAddScalar(this.publicKey,u,!0);if(null===r)return this.derive(e+1);f=s(r,c,this.network,this.depth+1,e,js(this.fingerprint,0,"BE"))}else{const r=t.privateAdd(this.privateKey,u);if(null==r)return this.derive(e+1);f=a(r,c,this.network,this.depth+1,e,js(this.fingerprint,0,"BE"))}return f}deriveHardened(t){if("number"==typeof _u(Ou,t))return this.derive(t+r);throw new TypeError("Expected UInt31, got "+t)}derivePath(t){_u(xu,t);let e=t.split("/");if("m"===e[0]){if(this.parentFingerprint)throw new TypeError("Expected master, got child");e=e.slice(1)}return e.reduce((t,e)=>{let r;return"'"===e.slice(-1)?(r=parseInt(e.slice(0,-1),10),t.deriveHardened(r)):(r=parseInt(e,10),t.derive(r))},this)}tweak(t){return this.privateKey?this.tweakFromPrivateKey(t):this.tweakFromPublicKey(t)}tweakFromPublicKey(e){const r=32===(i=this.publicKey).length?i:i.slice(1,33);var i;if(!t.xOnlyPointAddTweak)throw new Error("xOnlyPointAddTweak not supported by ecc library");const o=t.xOnlyPointAddTweak(r,e);if(!o||null===o.xOnlyPubkey)throw new Error("Cannot tweak public key!");const a=function(t){const e=t.reduce((t,e)=>t+e.length,0),r=new Uint8Array(e);let n=0;for(const e of t)r.set(e,n),n+=e.length;return r}([Uint8Array.from([0===o.parity?2:3]),o.xOnlyPubkey]);return new n(void 0,a)}tweakFromPrivateKey(e){const r=3===this.publicKey[0]||4===this.publicKey[0]&&!(1&~this.publicKey[64]),i=(()=>{if(r){if(t.privateNegate)return t.privateNegate(this.privateKey);throw new Error("privateNegate not supported by ecc library")}return this.privateKey})(),o=t.privateAdd(i,e);if(!o)throw new Error("Invalid tweaked private key!");return new n(o,void 0)}}function o(t,e,r){return a(t,e,r)}function a(r,n,o,a,s,u){if(_u(Au,r),_u(Au,n),o=o||e,!t.isPrivate(r))throw new TypeError("Private key not in range [1, n)");return new i(r,void 0,n,o,a,s,u)}function s(r,n,o,a,s,u){if(_u(Iu,r),_u(Au,n),o=o||e,!t.isPoint(r))throw new TypeError("Point is not on the curve");return new i(void 0,r,n,o,a,s,u)}return{fromSeed:function(t,r){if(_u(wu(Uint8Array),t),t.length<16)throw new TypeError("Seed should be at least 128 bits");if(t.length>64)throw new TypeError("Seed should be at most 512 bits");r=r||e;const n=As(xs.encode("Bitcoin seed"),t);return o(n.slice(0,32),n.slice(32),r)},fromBase58:function(t,r){const n=(i=t,Uu.decode(i));var i;if(78!==n.length)throw new TypeError("Invalid buffer length");r=r||e;const o=js(n,0,"BE");if(o!==r.bip32.private&&o!==r.bip32.public)throw new TypeError("Invalid network version");const u=n[4],c=js(n,5,"BE");if(0===u&&0!==c)throw new TypeError("Invalid parent fingerprint");const f=js(n,9,"BE");if(0===u&&0!==f)throw new TypeError("Invalid index");const l=n.slice(13,45);let h;if(o===r.bip32.private){if(0!==n[45])throw new TypeError("Invalid private key");h=a(n.slice(46,78),l,r,u,f,c)}else h=s(n.slice(45,78),l,r,u,f,c);return h},fromPublicKey:function(t,e,r){return s(t,e,r)},fromPrivateKey:o}};if(!lf)throw new Error("Failed to load BIP32 library");var hf=ef.Point,pf=hf.Fn.ORDER,df=nf("TapTweak"),yf=ks(df),bf=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)}return function(t,e,r){return r&&uf(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,0,[{key:"fromWIF",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:b.bitcoin;return this.ECPair.fromWIF(t,e)}},{key:"fromPrivateKey",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:b.bitcoin;return this.ECPair.fromPrivateKey(af.isBuffer(t)?t:af.from(t),{network:e})}},{key:"fromPublicKey",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:b.bitcoin,r=af.isBuffer(t)?t:af.from(t);return this.ECPair.fromPublicKey(r,{network:e})}},{key:"generateMultiSigAddress",value:function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:b.bitcoin,n=this.verifyPubKeys(t,r);if(n.length!==t.length)throw new Error("Contains invalid public keys");var i=k.p2ms({m:e,pubkeys:n,network:r}),o=k.p2wsh({redeem:i,network:r}).address;if(!o)throw new Error("Failed to generate address");return o}},{key:"verifyPubKeys",value:function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:b.bitcoin;return e.map(function(e){var n=t.fromPublicKey(e,r);if(!n)throw new Error("Failed to regenerate key");return af.from(n.publicKey)})}},{key:"getP2WPKHAddress",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:b.bitcoin,r=k.p2wpkh({pubkey:af.from(t.publicKey),network:e});if(!r.address)throw new Error("Failed to generate wallet");return r.address}},{key:"tweakedPubKeyToAddress",value:function(e,r){e.startsWith("0x")&&(e=e.slice(2));var n=af.from(e,"hex");return 32!==n.length&&(n=bi(n)),t.tweakedPubKeyBufferToAddress(n,r)}},{key:"tweakedPubKeyBufferToAddress",value:function(t,e){var r=k.p2tr({pubkey:af.isBuffer(t)?t:af.from(t),network:e}).address;if(!r)throw new Error("Failed to generate Taproot address");return r}},{key:"p2op",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:b.bitcoin,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=af.concat([af.from([r]),sa.crypto.hash160(af.from(t))]);if(n.length<2||n.length>40)throw new Error("Witness program must be 2-40 bytes.");return Pe(w.compile([it.OP_16,n]),e)}},{key:"xOnlyTweakedPubKeyToAddress",value:function(t,e){t.startsWith("0x")&&(t=t.slice(2));var r=af.from(t,"hex"),n=k.p2tr({pubkey:r,network:e}).address;if(!n)throw new Error("Failed to generate Taproot address");return n}},{key:"tweakPublicKey",value:function(t){"string"==typeof t&&t.startsWith("0x")&&(t=t.slice(2));var e=hf.fromHex(t),r=0n==(1n&e.y)?e:e.negate(),n=function(t){return ks(rf(yf,yf,t))}(r.toBytes(!0).subarray(1)),i=uc(of(n),pf),o=r.add(hf.BASE.multiply(i));return af.from(o.toBytes(!0))}},{key:"tweakBatchSharedT",value:function(t,e){var r=hf.BASE.multiply(e);return t.map(function(t){var e=hf.fromHex(t);return(e.y%2n==0n?e:e.negate()).add(r).toBytes(!0)})}},{key:"generateWallet",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:b.bitcoin,e=this.ECPair.makeRandom({network:t}),r=this.getP2WPKHAddress(e,t);if(!r)throw new Error("Failed to generate wallet");return{address:r,privateKey:e.toWIF(),publicKey:af.from(e.publicKey).toString("hex")}}},{key:"verifyContractAddress",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:b.bitcoin;return!!m.toOutputScript(t,e)}},{key:"getLegacySegwitAddress",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:b.bitcoin,r=k.p2sh({redeem:k.p2wpkh({pubkey:af.from(t.publicKey),network:e}),network:e});if(!r.address)throw new Error("Failed to generate wallet");return r.address}},{key:"getLegacyAddress",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:b.bitcoin,r=k.p2pkh({pubkey:af.from(t.publicKey),network:e});if(!r.address)throw new Error("Failed to generate wallet");return r.address}},{key:"getP2PKH",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:b.bitcoin,r=k.p2pkh({pubkey:af.from(t),network:e});if(!r.address)throw new Error("Failed to generate wallet");return r.address}},{key:"getP2PKAddress",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:b.bitcoin,r=k.p2pk({pubkey:af.from(t.publicKey),network:e});if(!r.output)throw new Error("Failed to generate wallet");return"0x"+r.output.toString("hex")}},{key:"generateRandomKeyPair",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:b.bitcoin;return this.ECPair.makeRandom({network:t})}},{key:"fromSeed",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:b.bitcoin;return this.BIP32.fromSeed(t,e)}},{key:"getTaprootAddress",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:b.bitcoin,r=k.p2tr({internalPubkey:bi(af.from(t.publicKey)),network:e}).address;if(!r)throw new Error("Failed to generate sender address for transaction");return r}},{key:"getTaprootAddressFromAddress",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:b.bitcoin,r=k.p2tr({address:t,network:e}).address;if(!r)throw new Error("Failed to generate sender address for transaction");return r}},{key:"fromSeedKeyPair",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:b.bitcoin,r=this.BIP32.fromSeed(t,e).privateKey;if(!r)throw new Error("Failed to generate key pair");return this.ECPair.fromPrivateKey(af.from(r),{network:e})}}])}();cf(bf,"BIP32",lf(ca)),cf(bf,"ECPair",(0,ju.dg)(ca)),hf.BASE.precompute(8);var gf=32,vf=4,wf=32,mf=16,Sf=8,_f=4,Ef=2,kf=1,Of=32,Tf=16,Af=8,If=4,Pf=2,xf=1,Bf=1,Rf=i(8287).Buffer;function Uf(t){return Uf="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Uf(t)}function jf(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Nf(n.key),n)}}function Nf(t){var e=function(t){if("object"!=Uf(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Uf(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Uf(e)?e:e+""}var Lf=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)}return function(t,e,r){return r&&jf(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,0,[{key:"bufferToUint8Array",value:function(t){if(Rf.isBuffer(t)){for(var e=t.byteLength,r=new ArrayBuffer(e),n=new Uint8Array(r),i=0;i<e;++i)n[i]=t[i];return n}return t}},{key:"uint8ArrayToHex",value:function(t){return Rf.from(t.buffer,0,t.byteLength).toString("hex")}},{key:"hexToUint8Array",value:function(t){t.startsWith("0x")&&(t=t.substring(2)),t.length%2!=0&&(t="0"+t);for(var e=t.length/2,r=new Uint8Array(e),n=0;n<e;n++)r[n]=parseInt(t.substring(2*n,2*n+2),16);return r}},{key:"pointerToUint8Array",value:function(e){var r=e.toString(16).padStart(64,"0");return t.hexToUint8Array(r)}},{key:"uint8ArrayToPointer",value:function(e){var r=t.uint8ArrayToHex(e);return BigInt("0x"+r)}},{key:"valueToUint8Array",value:function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:wf,n=e.toString(16).padStart(2*r,"0");return t.hexToUint8Array(n)}},{key:"uint8ArrayToValue",value:function(e){var r=t.uint8ArrayToHex(e);return r?BigInt("0x"+r):BigInt(0)}}])}();function Cf(t){return Cf="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Cf(t)}function Ff(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Hf(n.key),n)}}function Df(t,e,r){return(e=Hf(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Hf(t){var e=function(t){if("object"!=Cf(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Cf(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Cf(e)?e:e+""}!function(t,e){(e=Nf(e))in t?Object.defineProperty(t,e,{value:32,enumerable:!0,configurable:!0,writable:!0}):t[e]=32}(Lf,"EXPECTED_BUFFER_LENGTH");var Mf=function(){return function(t,e){return e&&Ff(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}(function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),Df(this,"_keys",[]),Df(this,"_values",[])},[{key:"size",get:function(){return this._keys.length}},{key:"keys",value:function(){return this._keys}},{key:"values",value:function(){return this._values}},{key:"entries",value:function(){for(var t=[],e=0;e<this._keys.length;e++)t.push([this._keys[e],this._values[e]]);return t}},{key:"set",value:function(t,e){var r=this.indexOf(t);-1==r?(this._keys.push(t),this._values.push(e)):this._values[r]=e}},{key:"indexOf",value:function(t){for(var e=0;e<this._keys.length;e++)if(this._keys[e]==t)return e;return-1}},{key:"get",value:function(t){var e=this.indexOf(t);if(-1!=e)return this._values[e]}},{key:"has",value:function(t){return-1!=this.indexOf(t)}},{key:"delete",value:function(t){var e=this.indexOf(t);return-1!=e&&(this._keys.splice(e,1),this._values.splice(e,1),!0)}},{key:"clear",value:function(){this._keys=[],this._values=[]}}])}();function Kf(t){return Kf="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Kf(t)}function Vf(){var t,e,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",i=r.toStringTag||"@@toStringTag";function o(r,n,i,o){var u=n&&n.prototype instanceof s?n:s,c=Object.create(u.prototype);return Wf(c,"_invoke",function(r,n,i){var o,s,u,c=0,f=i||[],l=!1,h={p:0,n:0,v:t,a:p,f:p.bind(t,4),d:function(e,r){return o=e,s=0,u=t,h.n=r,a}};function p(r,n){for(s=r,u=n,e=0;!l&&c&&!i&&e<f.length;e++){var i,o=f[e],p=h.p,d=o[2];r>3?(i=d===n)&&(u=o[(s=o[4])?5:(s=3,3)],o[4]=o[5]=t):o[0]<=p&&((i=r<2&&p<o[1])?(s=0,h.v=n,h.n=o[1]):p<d&&(i=r<3||o[0]>n||n>d)&&(o[4]=r,o[5]=n,h.n=d,s=0))}if(i||r>1)return a;throw l=!0,n}return function(i,f,d){if(c>1)throw TypeError("Generator is already running");for(l&&1===f&&p(f,d),s=f,u=d;(e=s<2?t:u)||!l;){o||(s?s<3?(s>1&&(h.n=-1),p(s,u)):h.n=u:h.v=u);try{if(c=2,o){if(s||(i="next"),e=o[i]){if(!(e=e.call(o,u)))throw TypeError("iterator result is not an object");if(!e.done)return e;u=e.value,s<2&&(s=0)}else 1===s&&(e=o.return)&&e.call(o),s<2&&(u=TypeError("The iterator does not provide a '"+i+"' method"),s=1);o=t}else if((e=(l=h.n<0)?u:r.call(n,h))!==a)break}catch(e){o=t,s=1,u=e}finally{c=1}}return{value:e,done:l}}}(r,i,o),!0),c}var a={};function s(){}function u(){}function c(){}e=Object.getPrototypeOf;var f=[][n]?e(e([][n]())):(Wf(e={},n,function(){return this}),e),l=c.prototype=s.prototype=Object.create(f);function h(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,c):(t.__proto__=c,Wf(t,i,"GeneratorFunction")),t.prototype=Object.create(l),t}return u.prototype=c,Wf(l,"constructor",c),Wf(c,"constructor",u),u.displayName="GeneratorFunction",Wf(c,i,"GeneratorFunction"),Wf(l),Wf(l,i,"Generator"),Wf(l,n,function(){return this}),Wf(l,"toString",function(){return"[object Generator]"}),(Vf=function(){return{w:o,m:h}})()}function Wf(t,e,r,n){var i=Object.defineProperty;try{i({},"",{})}catch(t){i=0}Wf=function(t,e,r,n){function o(e,r){Wf(t,e,function(t){return this._invoke(e,r,t)})}e?i?i(t,e,{value:r,enumerable:!n,configurable:!n,writable:!n}):t[e]=r:(o("next",0),o("throw",1),o("return",2))},Wf(t,e,r,n)}function Gf(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return qf(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?qf(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}function qf(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function zf(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Zf(n.key),n)}}function Zf(t){var e=function(t){if("object"!=Kf(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Kf(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Kf(e)?e:e+""}function Xf(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(Xf=function(){return!!t})()}function Yf(t){return Yf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Yf(t)}function $f(t,e){return $f=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},$f(t,e)}var Jf=function(){function t(){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),function(t,e,r){return e=Yf(e),function(t,e){if(e&&("object"==Kf(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,Xf()?Reflect.construct(e,r||[],Yf(t).constructor):e.apply(t,r))}(this,t,arguments)}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&$f(t,e)}(t,Mf),function(t,e){return e&&zf(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"set",value:function(t,e){var r=this.indexOf(t);-1==r?(this._keys.push(t),this._values.push(e)):this._values[r]=e}},{key:"indexOf",value:function(t){for(var e=0;e<this._keys.length;e++){var r=this._keys[e];if(t.equals(r))return e}return-1}},{key:"has",value:function(t){for(var e=0;e<this._keys.length;e++)if(t.equals(this._keys[e]))return!0;return!1}},{key:"get",value:function(t){var e=this.indexOf(t);if(-1!=e)return this._values[e]}},{key:"delete",value:function(t){var e=this.indexOf(t);return-1!=e&&(this._keys.splice(e,1),this._values.splice(e,1),!0)}},{key:Symbol.iterator,value:Vf().m(function t(){var e,r,n,i;return Vf().w(function(t){for(;;)switch(t.p=t.n){case 0:e=Gf(this._keys),t.p=1,e.s();case 2:if((r=e.n()).done){t.n=4;break}return n=r.value,t.n=3,[n,this.get(n)];case 3:t.n=2;break;case 4:t.n=6;break;case 5:t.p=5,i=t.v,e.e(i);case 6:return t.p=6,e.f(),t.f(6);case 7:return t.a(2)}},t,this,[[1,5,6,7]])})}])}(),Qf=i(4148);var tl=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if("undefined"!=typeof global)return global;throw new Error("unable to locate global object")}();function el(t){switch(t){case"sha256":return Os.create();case"sha512":return Ts.create()}Qf(!1,"invalid hashing algorithm name","INVALID_ARGUMENT",{argument:"algorithm",value:t})}tl.crypto||tl.msCrypto;var rl=i(8287).Buffer;function nl(t){return nl="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},nl(t)}function il(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,ol(n.key),n)}}function ol(t){var e=function(t){if("object"!=nl(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=nl(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==nl(e)?e:e+""}var al=/^[0-9a-fA-F]+$/,sl=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)}return function(t,e,r){return r&&il(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,0,[{key:"btcToSatoshi",value:function(t){return BigInt(1e8*t)}},{key:"rndBytes",value:function(){var e=t.getSafeRandomValues(64);return rl.from(e)}},{key:"getSafeRandomValues",value:function(t){if(void 0!==globalThis.window&&globalThis.window.crypto&&"function"==typeof globalThis.window.crypto.getRandomValues){var e=new Uint8Array(t);return window.crypto.getRandomValues(e),rl.from(e)}if(globalThis.crypto&&"function"==typeof globalThis.crypto.getRandomValues){var r=new Uint8Array(t);return globalThis.crypto.getRandomValues(r),rl.from(r)}throw console.log("No secure random number generator available. Please upgrade your environment.",globalThis.window.crypto,globalThis.crypto),new Error("No secure random number generator available. Please upgrade your environment.")}},{key:"isValidHex",value:function(t){return al.test(t)}},{key:"opnetHash",value:function(t){var e=el("sha512");e.update(t);var r=e.digest();return"0x".concat(rl.from(r).toString("hex"))}}])}(),ul=i(8287);function cl(t){return cl="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},cl(t)}function fl(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,ll(n.key),n)}}function ll(t){var e=function(t){if("object"!=cl(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=cl(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==cl(e)?e:e+""}var hl,pl=function(){return function(t,e,r){return r&&fl(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)},0,[{key:"isP2WDAUTXO",value:function(t){if(!t.witnessScript)return!1;var e=ul.Buffer.isBuffer(t.witnessScript)?t.witnessScript:ul.Buffer.from(t.witnessScript,"hex");return this.isP2WDAWitnessScript(e)}},{key:"isP2WDAWitnessScript",value:function(t){try{var e=w.decompile(t);if(!e||7!==e.length)return!1;for(var r=0;r<5;r++)if(e[r]!==it.OP_2DROP)return!1;return ul.Buffer.isBuffer(e[5])&&33===e[5].length&&e[6]===it.OP_CHECKSIG}catch(t){return!1}}},{key:"generateP2WDAAddress",value:function(t,e){if(33!==t.length)throw new Error("Public key must be 33 bytes (compressed)");var r=w.compile([it.OP_2DROP,it.OP_2DROP,it.OP_2DROP,it.OP_2DROP,it.OP_2DROP,t,it.OP_CHECKSIG]),n=k.p2wsh({redeem:{output:r},network:e});if(!n.address||!n.output)throw new Error("Failed to generate P2WDA address");return{address:n.address,witnessScript:r,scriptPubKey:n.output}}},{key:"extractPublicKeyFromP2WDA",value:function(t){try{var e=w.decompile(t);if(!e||7!==e.length)return null;for(var r=0;r<5;r++)if(e[r]!==it.OP_2DROP)return null;return ul.Buffer.isBuffer(e[5])&&33===e[5].length&&e[6]===it.OP_CHECKSIG?e[5]:null}catch(t){return null}}},{key:"createSimpleP2WDAWitness",value:function(t,e){for(var r=[t],n=0;n<10;n++)r.push(ul.Buffer.alloc(0));return r.push(e),r}},{key:"validateP2WDASignature",value:function(t,e,r){return 64===e.length}},{key:"estimateP2WDAWitnessSize",value:function(){return 72+(arguments.length>0&&void 0!==arguments[0]?arguments[0]:0)+39+12}},{key:"couldBeP2WDA",value:function(t){return 34===t.length&&0===t[0]&&32===t[1]}}])}(),dl=i(8287).Buffer;function yl(t){return yl="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},yl(t)}function bl(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,gl(n.key),n)}}function gl(t){var e=function(t){if("object"!=yl(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=yl(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==yl(e)?e:e+""}ur(ca),function(t){t.P2PKH="P2PKH",t.P2OP="P2OP",t.P2SH_OR_P2SH_P2WPKH="P2SH_OR_P2SH-P2WPKH",t.P2PK="P2PK",t.P2TR="P2TR",t.P2WPKH="P2WPKH",t.P2WSH="P2WSH",t.P2WDA="P2WDA"}(hl||(hl={}));var vl=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)}return function(t,e,r){return r&&bl(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,0,[{key:"isValidP2TRAddress",value:function(t,e){if(!t||t.length<50)return!1;var r=!1;try{m.toOutputScript(t,e),r=1===m.fromBech32(t).version}catch(t){}return r}},{key:"isP2WPKHAddress",value:function(t,e){if(!t||t.length<20||t.length>50)return!1;var r=!1;try{var n=m.fromBech32(t);m.toOutputScript(t,e),r=0===n.version&&20===n.data.length}catch(t){}return r}},{key:"isP2WDAWitnessScript",value:function(t){return pl.isP2WDAWitnessScript(t)}},{key:"isP2PKHOrP2SH",value:function(t,e){try{var r=m.fromBase58Check(t);return r.version===e.pubKeyHash||r.version===e.scriptHash}catch(t){return!1}}},{key:"isValidPublicKey",value:function(t,e){try{if(t.startsWith("0x")&&(t=t.slice(2)),!sl.isValidHex(t))return!1;if(64===t.length)return!0;var r=dl.from(t,"hex");if(130===t.length&&6===r[0]||7===r[0])return!0;if(66===t.length||130===t.length)return bf.fromPublicKey(r,e),!0}catch(t){return!1}return!1}},{key:"requireRedeemScript",value:function(t,e){try{var r=m.fromBase58Check(t);return r.version!==e.pubKeyHash&&r.version===e.scriptHash}catch(t){return!1}}},{key:"detectAddressType",value:function(e,r){if(t.isValidPublicKey(e,r))return hl.P2PK;try{var n=m.fromBase58Check(e);if(n.version===r.pubKeyHash)return hl.P2PKH;if(n.version===r.scriptHash)return hl.P2SH_OR_P2SH_P2WPKH}catch(t){}try{var i=m.fromBech32(e);if((i.prefix===r.bech32Opnet||i.prefix===r.bech32)&&16===i.version)return hl.P2OP;if(i.prefix===r.bech32){if(0===i.version&&20===i.data.length)return hl.P2WPKH;if(0===i.version&&32===i.data.length)return hl.P2WSH;if(1===i.version&&32===i.data.length)return hl.P2TR}}catch(t){}return null}},{key:"detectAddressTypeWithWitnessScript",value:function(e,r,n){var i=t.detectAddressType(e,r);return i===hl.P2WSH&&n&&t.isP2WDAWitnessScript(n)?hl.P2WDA:i}},{key:"validateP2WDAAddress",value:function(e,r,n){try{if(t.detectAddressType(e,r)!==hl.P2WSH)return{isValid:!1,isPotentiallyP2WDA:!1,isDefinitelyP2WDA:!1,error:"Not a P2WSH address"};if(!n)return{isValid:!0,isPotentiallyP2WDA:!0,isDefinitelyP2WDA:!1};if(!t.isP2WDAWitnessScript(n))return{isValid:!0,isPotentiallyP2WDA:!0,isDefinitelyP2WDA:!1,error:"Witness script does not match P2WDA pattern"};if(k.p2wsh({redeem:{output:n},network:r}).address!==e)return{isValid:!1,isPotentiallyP2WDA:!1,isDefinitelyP2WDA:!1,error:"Witness script does not match address"};var i=pl.extractPublicKeyFromP2WDA(n);return i?{isValid:!0,isPotentiallyP2WDA:!0,isDefinitelyP2WDA:!0,publicKey:i}:{isValid:!1,isPotentiallyP2WDA:!1,isDefinitelyP2WDA:!1,error:"Failed to extract public key from witness script"}}catch(t){return{isValid:!1,isPotentiallyP2WDA:!1,isDefinitelyP2WDA:!1,error:t.message}}}}])}();function wl(t){return wl="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},wl(t)}function ml(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function Sl(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,_l(n.key),n)}}function _l(t){var e=function(t){if("object"!=wl(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=wl(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==wl(e)?e:e+""}var El=0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2fn,kl=function(){return function(t,e){return e&&Sl(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}(function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1e4;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.maxTries=e},[{key:"findOrDeriveValidPoint",value:function(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.maxTries;if(32!==t.length)throw new Error("xBytes must be exactly 32 bytes.");var n=this.bytesToBigInt(t)%El,i=this.isValidX(n);if(e&&null===i)throw new Error("The given x is not a valid curve point.");for(var o=0;null===i;)if(n=(n+1n)%El,i=this.isValidX(n),++o>r)throw new Error("Could not find a valid X point within ".concat(r," increments."));return{x:n,y1:i,y2:(El-i)%El}}},{key:"getCanonicalY",value:function(t,e){return t<e?t:e}},{key:"getHybridPublicKey",value:function(t,e){var r=e%2n==0n?6:7,n=this.bigIntTo32Bytes(t),i=this.bigIntTo32Bytes(e),o=new Uint8Array(65);return o[0]=r,o.set(n,1),o.set(i,33),o}},{key:"isValidX",value:function(t){var e=(this.modPow(t,3n,El)+7n)%El;return this.sqrtModP(e,El)}},{key:"modPow",value:function(t,e,r){for(var n=1n,i=t%r,o=e;o>0;)1n==(1n&o)&&(n=n*i%r),i=i*i%r,o>>=1n;return n}},{key:"sqrtModP",value:function(t,e){var r=this.modPow(t,e+1n>>2n,e);return r*r%e!==t%e?null:r}},{key:"bytesToBigInt",value:function(t){var e,r=0n,n=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return ml(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?ml(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}(t);try{for(n.s();!(e=n.n()).done;){var i=e.value;r=r<<8n|BigInt(i)}}catch(t){n.e(t)}finally{n.f()}return r}},{key:"bigIntTo32Bytes",value:function(t){for(var e=new Uint8Array(32),r=31;r>=0;r--)e[r]=Number(0xffn&t),t>>=8n;return e}}])}(),Ol=i(8287).Buffer;function Tl(t){return Tl="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Tl(t)}function Al(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Il(n.key),n)}}function Il(t){var e=function(t){if("object"!=Tl(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Tl(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Tl(e)?e:e+""}var Pl=function(){return function(t,e){return e&&Al(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}(function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),function(t,e,r){(e=Il(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r}(this,"deriver",new kl)},[{key:"generateHybridKeyFromHash",value:function(t){var e=this.deriver.findOrDeriveValidPoint(this.cloneBuffer(t),!1),r=this.deriver.getCanonicalY(e.y1,e.y2);return Ol.from(this.deriver.getHybridPublicKey(e.x,r))}},{key:"cloneBuffer",value:function(t){return Ol.from(t)}}])}(),xl=new Pl;function Bl(t){return Bl="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Bl(t)}function Rl(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Ul(n.key),n)}}function Ul(t){var e=function(t){if("object"!=Bl(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Bl(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Bl(e)?e:e+""}var jl=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)}return function(t,e,r){return r&&Rl(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,0,[{key:"generateTimeLockAddress",value:function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:b.bitcoin,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t.CSV_BLOCKS,i=w.compile([w.number.encode(n),it.OP_CHECKSEQUENCEVERIFY,it.OP_DROP,e,it.OP_CHECKSIG]),o=sa.payments.p2wsh({redeem:{output:i},network:r});if(!o.address)throw new Error("Failed to generate P2WSH address");return{address:o.address,witnessScript:i}}}])}();!function(t,e){(e=Ul(e))in t?Object.defineProperty(t,e,{value:75,enumerable:!0,configurable:!0,writable:!0}):t[e]=75}(jl,"CSV_BLOCKS");var Nl=i(8287).Buffer;function Ll(t){return Ll="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Ll(t)}function Cl(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Fl(n.key),n)}}function Fl(t){var e=function(t){if("object"!=Ll(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Ll(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Ll(e)?e:e+""}function Dl(t,e){if(e&&("object"==Ll(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function Hl(t,e,r,n){var i=Ml(Gl(1&n?t.prototype:t),e,r);return 2&n&&"function"==typeof i?function(t){return i.apply(r,t)}:i}function Ml(){return Ml="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,r){var n=function(t,e){for(;!{}.hasOwnProperty.call(t,e)&&null!==(t=Gl(t)););return t}(t,e);if(n){var i=Object.getOwnPropertyDescriptor(n,e);return i.get?i.get.call(arguments.length<3?t:r):i.value}},Ml.apply(null,arguments)}function Kl(t){var e="function"==typeof Map?new Map:void 0;return Kl=function(t){if(null===t||!function(t){try{return-1!==Function.toString.call(t).indexOf("[native code]")}catch(e){return"function"==typeof t}}(t))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,r)}function r(){return function(t,e,r){if(Vl())return Reflect.construct.apply(null,arguments);var n=[null];n.push.apply(n,e);var i=new(t.bind.apply(t,n));return r&&Wl(i,r.prototype),i}(t,arguments,Gl(this).constructor)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),Wl(r,t)},Kl(t)}function Vl(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(Vl=function(){return!!t})()}function Wl(t,e){return Wl=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Wl(t,e)}function Gl(t){return Gl=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Gl(t)}function ql(t,e,r){(function(t,e){if(e.has(t))throw new TypeError("Cannot initialize the same private elements twice on an object")})(t,e),e.set(t,r)}function zl(t,e,r){return t.set(Xl(t,e),r),r}function Zl(t,e){return t.get(Xl(t,e))}function Xl(t,e,r){if("function"==typeof t?t===e:t.has(e))return arguments.length<3?e:r;throw new TypeError("Private element is not present on this object")}var Yl=new WeakMap,$l=new WeakMap,Jl=new WeakMap,Ql=new WeakMap,th=new WeakMap,eh=new WeakMap,rh=new WeakMap,nh=new WeakMap,ih=function(){function t(e){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),r=function(t,e,r){return e=Gl(e),Dl(t,Vl()?Reflect.construct(e,r||[],Gl(t).constructor):e.apply(t,r))}(this,t,[gf]),ql(r,Yl,void 0),ql(r,$l,void 0),ql(r,Jl,void 0),ql(r,Ql,void 0),ql(r,th,void 0),ql(r,eh,void 0),ql(r,rh,void 0),ql(r,nh,void 0),e?(r.set(e),r):Dl(r)}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Wl(t,e)}(t,Kl(Uint8Array)),function(t,e,r){return e&&Cl(t.prototype,e),r&&Cl(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"originalPublicKey",get:function(){return Zl(Ql,this)}},{key:"keyPair",get:function(){if(!Zl(th,this))throw new Error("Public key not set for address");return Zl(th,this)}},{key:"toHex",value:function(){return"0x"+Nl.from(this).toString("hex")}},{key:"toBuffer",value:function(){return Nl.from(this)}},{key:"toUncompressedHex",value:function(){if(!Zl(eh,this))throw new Error("Public key not set");return"0x"+Zl(eh,this).uncompressed.toString("hex")}},{key:"toUncompressedBuffer",value:function(){if(!Zl(eh,this))throw new Error("Public key not set");return Zl(eh,this).uncompressed}},{key:"toHybridPublicKeyHex",value:function(){if(!Zl(eh,this))throw new Error("Public key not set");return"0x"+Zl(eh,this).hybrid.toString("hex")}},{key:"toHybridPublicKeyBuffer",value:function(){if(!Zl(eh,this))throw new Error("Public key not set");return Zl(eh,this).hybrid}},{key:"originalPublicKeyBuffer",value:function(){if(!Zl(Ql,this))throw new Error("Public key not set");return Nl.from(Zl(Ql,this))}},{key:"equals",value:function(t){var e=this;if(t.length!==e.length)return!1;for(var r=0;r<e.length;r++)if(e[r]!==t[r])return!1;return!0}},{key:"lessThan",value:function(t){for(var e=0;e<gf;e++){var r=this[e],n=t[e];if(r<n)return!0;if(r>n)return!1}return!1}},{key:"greaterThan",value:function(t){for(var e=0;e<gf;e++){var r=this[e],n=t[e];if(r>n)return!0;if(r<n)return!1}return!1}},{key:"set",value:function(e){if(![gf,33,65].includes(e.length))throw new Error("Invalid public key length ".concat(e.length));if(e.length===gf){var r=Nl.alloc(gf);r.set(e),zl(rh,this,xl.generateHybridKeyFromHash(r)),Hl(t,"set",this,3)([e])}else this.autoFormat(e)}},{key:"isValid",value:function(t){return vl.isValidPublicKey(Nl.from(this).toString("hex"),t)}},{key:"p2pk",value:function(){return this.toHex()}},{key:"p2wpkh",value:function(t){return bf.getP2WPKHAddress(this.keyPair,t)}},{key:"p2pkh",value:function(t){return bf.getLegacyAddress(this.keyPair,t)}},{key:"p2shp2wpkh",value:function(t){return bf.getLegacySegwitAddress(this.keyPair,t)}},{key:"toString",value:function(){return this.toHex()}},{key:"toJSON",value:function(){return this.toHex()}},{key:"p2tr",value:function(t){if(Zl(Yl,this)&&Zl(Jl,this)===t)return Zl(Yl,this);var e=bf.tweakedPubKeyBufferToAddress(this,t);if(e)return zl(Jl,this,t),zl(Yl,this,e),e;throw new Error("Public key not set")}},{key:"p2wda",value:function(t){if(Zl(nh,this)&&Zl(Jl,this)===t)return Zl(nh,this);if(!Zl(Ql,this))throw new Error("Cannot create P2WDA address: public key not set");var e=Nl.from(Zl(Ql,this));if(33!==e.length)throw new Error("P2WDA requires a compressed public key (33 bytes)");try{var r=pl.generateP2WDAAddress(e,t);return zl(Jl,this,t),zl(nh,this,r),{address:r.address,witnessScript:r.witnessScript}}catch(t){throw new Error("Failed to generate P2WDA address: ".concat(t.message))}}},{key:"toCSV",value:function(t,e){var r=Number(t);if(r<1||r>65535)throw new Error("CSV block number must be between 1 and 65535");if(!Zl(Ql,this))throw new Error("Cannot create CSV address: public key not set");var n=Nl.from(Zl(Ql,this));return jl.generateTimeLockAddress(n,e,r)}},{key:"p2op",value:function(t){if(Zl($l,this)&&Zl(Jl,this)===t)return Zl($l,this);var e=bf.p2op(this,t);if(e)return zl(Jl,this,t),zl($l,this,e),e;throw new Error("Public key not set")}},{key:"toTweakedHybridPublicKeyHex",value:function(){if(!Zl(rh,this))throw new Error("Public key not set");return"0x"+Zl(rh,this).toString("hex")}},{key:"toTweakedHybridPublicKeyBuffer",value:function(){if(!Zl(rh,this))throw new Error("Public key not set");return Zl(rh,this)}},{key:"autoFormat",value:function(e){var r=e[0];3===r||2===r||4!==r&&6!==r&&7!==r||(e=t.uncompressedToCompressed(e)),zl(Ql,this,Uint8Array.from(e)),zl(th,this,bf.fromPublicKey(Zl(Ql,this))),zl(eh,this,Wi(Zl(Ql,this)));var n=bi(bf.tweakPublicKey(Nl.from(Zl(Ql,this))));zl(rh,this,xl.generateHybridKeyFromHash(n)),Hl(t,"set",this,3)([n])}}],[{key:"dead",value:function(){return t.fromString("0x04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f")}},{key:"zero",value:function(){return new t}},{key:"fromString",value:function(e){if(!e)throw new Error("Invalid public key");if(e.startsWith("0x")&&(e=e.slice(2)),!sl.isValidHex(e))throw new Error('You must only pass public keys in hexadecimal format. If you have an address such as bc1q... you must convert it to a public key first. Please refer to await provider.getPublicKeyInfo("bc1q..."). If the public key associated with the address is not found, you must force the user to enter the destination public key. It looks like: 0x020373626d317ae8788ce3280b491068610d840c23ecb64c14075bbb9f670af52c.');return new t(Nl.from(e,"hex"))}},{key:"wrap",value:function(e){return new t(e)}},{key:"uncompressedToCompressed",value:function(t){var e=Uint8Array.from(t),r=e.slice(1,33),n=e.slice(33),i=Nl.alloc(33);return i[0]=2+(1&n[n.length-1]),i.set(r,1),i}}])}();function oh(t){return oh="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},oh(t)}function ah(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,sh(n.key),n)}}function sh(t){var e=function(t){if("object"!=oh(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=oh(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==oh(e)?e:e+""}var uh=function(){return function(t,e,r){return e&&ah(t.prototype,e),r&&ah(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),function(t,e){(e=sh(e))in t?Object.defineProperty(t,e,{value:0,enumerable:!0,configurable:!0,writable:!0}):t[e]=0}(this,"currentOffset"),this.buffer=new DataView(e.buffer,e.byteOffset,e.byteLength)},[{key:"setBuffer",value:function(t){this.buffer=new DataView(t.buffer,t.byteOffset,t.byteLength),this.currentOffset=0}},{key:"length",value:function(){return this.buffer.byteLength}},{key:"bytesLeft",value:function(){return this.buffer.byteLength-this.currentOffset}},{key:"readU8",value:function(){this.verifyEnd(this.currentOffset+kf);var t=this.buffer.getUint8(this.currentOffset);return this.currentOffset+=kf,t}},{key:"readU16",value:function(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];this.verifyEnd(this.currentOffset+Ef);var e=this.buffer.getUint16(this.currentOffset,!t);return this.currentOffset+=Ef,e}},{key:"readU32",value:function(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];this.verifyEnd(this.currentOffset+_f);var e=this.buffer.getUint32(this.currentOffset,!t);return this.currentOffset+=_f,e}},{key:"readU64",value:function(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];this.verifyEnd(this.currentOffset+Sf);var e=this.buffer.getBigUint64(this.currentOffset,!t);return this.currentOffset+=Sf,e}},{key:"readU128",value:function(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],e=this.readBytes(mf),r=e;return t||(r=this.reverseBytes(e)),BigInt("0x"+this.toHexString(r))}},{key:"readU256",value:function(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],e=this.readBytes(wf),r=e;return t||(r=this.reverseBytes(e)),BigInt("0x"+this.toHexString(r))}},{key:"readI128",value:function(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],e=this.readBytes(Tf),r=e;t||(r=this.reverseBytes(e));var n=BigInt("0x"+this.toHexString(r));return 128&r[0]&&(n-=BigInt(1)<<BigInt(128)),n}},{key:"readBoolean",value:function(){return 0!==this.readU8()}},{key:"readSelector",value:function(){return this.readU32(!0)}},{key:"readBytes",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.verifyEnd(this.currentOffset+t);for(var r=new Uint8Array(t),n=0;n<t;n++){var i=this.buffer.getUint8(this.currentOffset++);if(e&&0===i){r=r.subarray(0,n);break}r[n]=i}return r}},{key:"readString",value:function(t){var e=new TextDecoder,r=this.readBytes(t,!1);return e.decode(r)}},{key:"readStringWithLength",value:function(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],e=this.readU32(t);return this.readString(e)}},{key:"readAddress",value:function(){var t=Array.from(this.readBytes(gf));return new ih(t)}},{key:"readBytesWithLength",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],r=this.readU32(e);if(t>0&&r>t)throw new Error("Data length exceeds maximum length.");return this.readBytes(r)}},{key:"readAddressArray",value:function(){for(var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],e=this.readU16(t),r=new Array(e),n=0;n<e;n++)r[n]=this.readAddress();return r}},{key:"readU256Array",value:function(){for(var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],e=this.readU16(t),r=new Array(e),n=0;n<e;n++)r[n]=this.readU256(t);return r}},{key:"readU128Array",value:function(){for(var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],e=this.readU16(t),r=new Array(e),n=0;n<e;n++)r[n]=this.readU128(t);return r}},{key:"readU64Array",value:function(){for(var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],e=this.readU16(t),r=new Array(e),n=0;n<e;n++)r[n]=this.readU64(t);return r}},{key:"readU32Array",value:function(){for(var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],e=this.readU16(t),r=new Array(e),n=0;n<e;n++)r[n]=this.readU32(t);return r}},{key:"readU16Array",value:function(){for(var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],e=this.readU16(t),r=new Array(e),n=0;n<e;n++)r[n]=this.readU16(t);return r}},{key:"readU8Array",value:function(){for(var t=this.readU16(!0),e=new Array(t),r=0;r<t;r++)e[r]=this.readU8();return e}},{key:"readStringArray",value:function(){for(var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],e=this.readU16(t),r=new Array(e),n=0;n<e;n++)r[n]=this.readStringWithLength(t);return r}},{key:"readBytesArray",value:function(){for(var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],e=this.readU16(t),r=new Array(e),n=0;n<e;n++)r[n]=this.readBytesWithLength(0,t);return r}},{key:"readAddressValueTuple",value:function(){for(var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],e=this.readU16(t),r=new Jf,n=0;n<e;n++){var i=this.readAddress(),o=this.readU256(t);if(r.has(i))throw new Error("Duplicate address found in map");r.set(i,o)}return r}},{key:"getOffset",value:function(){return this.currentOffset}},{key:"setOffset",value:function(t){this.currentOffset=t}},{key:"verifyEnd",value:function(t){if(t>this.buffer.byteLength)throw new Error("Attempt to read beyond buffer length: requested up to byte offset ".concat(t,", but buffer is only ").concat(this.buffer.byteLength," bytes."))}},{key:"reverseBytes",value:function(t){for(var e=new Uint8Array(t.length),r=0;r<t.length;r++)e[r]=t[t.length-1-r];return e}},{key:"toHexString",value:function(t){return Array.from(t,function(t){return t.toString(16).padStart(2,"0")}).join("")}}],[{key:"stringCompare",value:function(t,e){return t.localeCompare(e)}},{key:"bigintCompare",value:function(t,e){return t<e?-1:t>e?1:0}},{key:"numberCompare",value:function(t,e){return t<e?-1:t>e?1:0}}])}();function ch(t){return ch="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ch(t)}function fh(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,lh(n.key),n)}}function lh(t){var e=function(t){if("object"!=ch(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=ch(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==ch(e)?e:e+""}var hh,ph=function(){return function(t,e){return e&&fh(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}(function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),function(t,e){(e=lh(e))in t?Object.defineProperty(t,e,{value:0,enumerable:!0,configurable:!0,writable:!0}):t[e]=0}(this,"currentOffset"),this.buffer=this.getDefaultBuffer(e)},[{key:"writeU8",value:function(t){if(t>255)throw new Error("u8 value is too large.");this.allocSafe(kf),this.buffer.setUint8(this.currentOffset++,t)}},{key:"writeU16",value:function(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(t>65535)throw new Error("u16 value is too large.");this.allocSafe(Ef),this.buffer.setUint16(this.currentOffset,t,!e),this.currentOffset+=2}},{key:"writeU32",value:function(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(t>4294967295)throw new Error("u32 value is too large.");this.allocSafe(_f),this.buffer.setUint32(this.currentOffset,t,!e),this.currentOffset+=4}},{key:"writeU64",value:function(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(t>18446744073709551615n)throw new Error("u64 value is too large.");this.allocSafe(Sf),this.buffer.setBigUint64(this.currentOffset,t,!e),this.currentOffset+=8}},{key:"writeSelector",value:function(t){this.writeU32(t,!0)}},{key:"writeBoolean",value:function(t){this.writeU8(t?1:0)}},{key:"writeI128",value:function(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(t>170141183460469231731687303715884105727n||t<-170141183460469231731687303715884105728n)throw new Error("i128 value is too large.");this.allocSafe(Tf);var r=Lf.valueToUint8Array(t,Tf);if(r.byteLength!==Tf)throw new Error("Invalid i128 value: ".concat(t));if(e)for(var n=0;n<r.byteLength;n++)this.writeU8(r[n]);else for(var i=r.byteLength-1;i>=0;i--)this.writeU8(r[i])}},{key:"writeU256",value:function(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(t>115792089237316195423570985008687907853269984665640564039457584007913129639935n&&t<0n)throw new Error("u256 value is too large or negative.");this.allocSafe(wf);var r=Lf.valueToUint8Array(t);if(r.byteLength!==wf)throw new Error("Invalid u256 value: ".concat(t));if(e)for(var n=0;n<r.byteLength;n++)this.writeU8(r[n]);else for(var i=r.byteLength-1;i>=0;i--)this.writeU8(r[i])}},{key:"writeU128",value:function(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(t>340282366920938463463374607431768211455n&&t<0n)throw new Error("u128 value is too large or negative.");this.allocSafe(mf);var r=Lf.valueToUint8Array(t,mf);if(r.byteLength!==mf)throw new Error("Invalid u128 value: ".concat(t));if(e)for(var n=0;n<r.byteLength;n++)this.writeU8(r[n]);else for(var i=r.byteLength-1;i>=0;i--)this.writeU8(r[i])}},{key:"writeBytes",value:function(t){this.allocSafe(t.byteLength);for(var e=0;e<t.byteLength;e++)this.writeU8(t[e])}},{key:"writeString",value:function(t){var e=(new TextEncoder).encode(t);this.allocSafe(e.length),this.writeBytes(e)}},{key:"writeStringWithLength",value:function(t){var e=(new TextEncoder).encode(t);this.allocSafe(_f+e.length),this.writeU32(e.length),this.writeBytes(e)}},{key:"writeAddress",value:function(t){this.verifyAddress(t),this.writeBytes(t)}},{key:"getBuffer",value:function(){for(var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],e=new Uint8Array(this.buffer.byteLength),r=0;r<this.buffer.byteLength;r++)e[r]=this.buffer.getUint8(r);return t&&this.clear(),e}},{key:"reset",value:function(){this.currentOffset=0,this.buffer=this.getDefaultBuffer(4)}},{key:"toBytesReader",value:function(){return new uh(this.getBuffer())}},{key:"getOffset",value:function(){return this.currentOffset}},{key:"setOffset",value:function(t){this.currentOffset=t}},{key:"clear",value:function(){this.currentOffset=0,this.buffer=this.getDefaultBuffer()}},{key:"allocSafe",value:function(t){this.currentOffset+t>this.buffer.byteLength&&this.resize(t)}},{key:"writeAddressValueTuple",value:function(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(t.size>65535)throw new Error("Map size is too large");this.writeU16(t.size,e);for(var r=Array.from(t.keys()),n=0;n<r.length;n++){var i=r[n],o=t.get(i);if(null==o)throw new Error("Value not found");this.writeAddress(i),this.writeU256(o,e)}}},{key:"writeBytesWithLength",value:function(t){this.writeU32(t.length),this.writeBytes(t)}},{key:"writeAddressArray",value:function(t){if(t.length>65535)throw new Error("Array size is too large");this.writeU16(t.length);for(var e=0;e<t.length;e++)this.writeAddress(t[e])}},{key:"writeU32Array",value:function(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(t.length>65535)throw new Error("Array size is too large");this.writeU16(t.length,e);for(var r=0;r<t.length;r++)this.writeU32(t[r],e)}},{key:"writeU256Array",value:function(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(t.length>65535)throw new Error("Array size is too large");this.writeU16(t.length,e);for(var r=0;r<t.length;r++)this.writeU256(t[r],e)}},{key:"writeU128Array",value:function(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(t.length>65535)throw new Error("Array size is too large");this.writeU16(t.length,e);for(var r=0;r<t.length;r++)this.writeU128(t[r],e)}},{key:"writeStringArray",value:function(t){if(t.length>65535)throw new Error("Array size is too large");this.writeU16(t.length);for(var e=0;e<t.length;e++)this.writeStringWithLength(t[e])}},{key:"writeU16Array",value:function(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(t.length>65535)throw new Error("Array size is too large");this.writeU16(t.length,e);for(var r=0;r<t.length;r++)this.writeU16(t[r],e)}},{key:"writeU8Array",value:function(t){if(t.length>65535)throw new Error("Array size is too large");this.writeU16(t.length);for(var e=0;e<t.length;e++)this.writeU8(t[e])}},{key:"writeU64Array",value:function(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(t.length>65535)throw new Error("Array size is too large");this.writeU16(t.length,e);for(var r=0;r<t.length;r++)this.writeU64(t[r],e)}},{key:"writeBytesArray",value:function(t){if(t.length>65535)throw new Error("Array size is too large");this.writeU16(t.length);for(var e=0;e<t.length;e++)this.writeBytesWithLength(t[e])}},{key:"verifyAddress",value:function(t){if(t.byteLength>gf)throw new Error("Address is too long ".concat(t.byteLength," > ").concat(gf," bytes"))}},{key:"resize",value:function(t){for(var e=new Uint8Array(this.buffer.byteLength+t),r=0;r<this.buffer.byteLength;r++)e[r]=this.buffer.getUint8(r);this.buffer=new DataView(e.buffer,e.byteOffset,e.byteLength)}},{key:"getDefaultBuffer",value:function(){return new DataView(new ArrayBuffer(arguments.length>0&&void 0!==arguments[0]?arguments[0]:0))}}])}();!function(t){t[t.ACCESS_LIST=1]="ACCESS_LIST",t[t.EPOCH_SUBMISSION=2]="EPOCH_SUBMISSION"}(hh||(hh={}));var dh=i(8287).Buffer;function yh(t){return yh="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},yh(t)}function bh(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=gh(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}function gh(t,e){if(t){if("string"==typeof t)return vh(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?vh(t,e):void 0}}function vh(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function wh(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Sh(n.key),n)}}function mh(t,e,r){return(e=Sh(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Sh(t){var e=function(t){if("object"!=yh(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=yh(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==yh(e)?e:e+""}var _h=function(){function t(e,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:b.bitcoin;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),mh(this,"network",b.bitcoin),this.senderPubKey=e,this.contractSaltPubKey=r,this.network=n,this.xSenderPubKey=bi(e)}return function(t,e){return e&&wh(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"buildHeader",value:function(t){var e,r=0,n=bh(t);try{for(n.s();!(e=n.n()).done;)r|=e.value}catch(t){n.e(t)}finally{n.f()}var i=dh.alloc(3);return i.writeUIntBE(r,0,3),dh.from([this.senderPubKey[0]].concat(function(t){return function(t){if(Array.isArray(t))return vh(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||gh(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}(i)))}},{key:"getHeader",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],r=new ph(12);return r.writeBytes(this.buildHeader(e)),r.writeU64(t),dh.from(r.getBuffer())}},{key:"splitBufferIntoChunks",value:function(e){for(var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t.DATA_CHUNK_SIZE,n=[],i=0;i<e.length;i+=r){for(var o=Math.min(r,e.length-i),a=dh.alloc(o),s=0;s<o;s++)a.writeUInt8(e[i+s],s);n.push([a])}return n}},{key:"encodeFeature",value:function(t){switch(t.opcode){case hh.ACCESS_LIST:return this.splitBufferIntoChunks(this.encodeAccessListFeature(t));case hh.EPOCH_SUBMISSION:return this.splitBufferIntoChunks(this.encodeChallengeSubmission(t));default:throw new Error("Unknown feature type: ".concat(t.opcode))}}},{key:"encodeAccessListFeature",value:function(t){var e=new ph;for(var r in e.writeU16(Object.keys(t.data).length),t.data){var n=ih.fromString(r),i=t.data[r];e.writeAddress(n),e.writeU32(i.length);var o,a=bh(i);try{for(a.s();!(o=a.n()).done;){var s=o.value,u=dh.from(s,"base64");if(32!==u.length)throw new Error("Invalid pointer length: ".concat(u.length));e.writeBytes(u)}}catch(t){a.e(t)}finally{a.f()}}return h.compress(dh.from(e.getBuffer()))}},{key:"encodeChallengeSubmission",value:function(t){if("verifySignature"in t.data&&!t.data.verifySignature())throw new Error("Invalid signature in challenge submission feature");var e=new ph;return e.writeBytes(t.data.publicKey.originalPublicKeyBuffer()),e.writeBytes(t.data.solution),t.data.graffiti&&e.writeBytesWithLength(t.data.graffiti),dh.from(e.getBuffer())}}])}();mh(_h,"DATA_CHUNK_SIZE",512),mh(_h,"MAGIC",dh.from("op","utf-8"));var Eh=i(8287).Buffer;function kh(t){return kh="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},kh(t)}function Oh(t){return function(t){if(Array.isArray(t))return Ah(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||Th(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Th(t,e){if(t){if("string"==typeof t)return Ah(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Ah(t,e):void 0}}function Ah(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function Ih(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Ph(n.key),n)}}function Ph(t){var e=function(t){if("object"!=kh(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=kh(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==kh(e)?e:e+""}function xh(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(xh=function(){return!!t})()}function Bh(t){return Bh=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Bh(t)}function Rh(t,e){return Rh=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Rh(t,e)}var Uh=function(){function t(e,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:b.bitcoin;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),function(t,e,r){return e=Bh(e),function(t,e){if(e&&("object"==kh(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,xh()?Reflect.construct(e,r||[],Bh(t).constructor):e.apply(t,r))}(this,t,[e,r,n])}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Rh(t,e)}(t,_h),function(t,e,r){return e&&Ih(t.prototype,e),r&&Ih(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"compile",value:function(t,e,r,n){var i,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:[];if(!this.contractSaltPubKey)throw new Error("Contract salt public key not set");var a=this.splitBufferIntoChunks(t);if(!a.length)throw new Error("No data chunks found");for(var s=[],u=[],c=0;c<o.length;c++){var f=o[c];s.push(f.opcode);var l=this.encodeFeature(f);u.push.apply(u,Oh(l))}var h=[this.getHeader(n,s),it.OP_TOALTSTACK,r.publicKey.originalPublicKeyBuffer(),it.OP_TOALTSTACK,r.solution,it.OP_TOALTSTACK,this.xSenderPubKey,it.OP_DUP,it.OP_HASH256,S.hash256(this.xSenderPubKey),it.OP_EQUALVERIFY,it.OP_CHECKSIGVERIFY,this.contractSaltPubKey,it.OP_CHECKSIGVERIFY,it.OP_HASH160,S.hash160(e),it.OP_EQUALVERIFY,it.OP_DEPTH,it.OP_1,it.OP_NUMEQUAL,it.OP_IF,_h.MAGIC],p=(h=(i=h).concat.apply(i,u.concat([it.OP_1NEGATE].concat(Oh(a),[it.OP_ELSE,it.OP_1,it.OP_ENDIF])))).flat(),d=w.compile(p);if(!w.decompile(d))throw new Error("Failed to decompile script??");return d}}],[{key:"getPubKeyAsBuffer",value:function(t,e){var r,n=Eh.alloc(0),i=function(t){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=Th(t))){e&&(t=e);var r=0,n=function(){};return{s:n,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:n}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,o=!0,a=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return o=t.done,t},e:function(t){a=!0,i=t},f:function(){try{o||null==e.return||e.return()}finally{if(a)throw i}}}}(t);try{for(i.s();!(r=i.n()).done;){var o=r.value;if(!bf.fromPublicKey(o,e).compressed)throw new Error("Public key must be compressed");if(33!==o.byteLength)throw new Error("Public key must be 33 bytes, got ".concat(o.byteLength," bytes."));n=Eh.concat([n,o])}}catch(t){i.e(t)}finally{i.f()}var a=h.compress(n);return a.byteLength>=n.byteLength?n:a}}])}();function jh(t){return jh="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},jh(t)}function Nh(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Lh(n.key),n)}}function Lh(t){var e=function(t){if("object"!=jh(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=jh(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==jh(e)?e:e+""}function Ch(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(Ch=function(){return!!t})()}function Fh(t){return Fh=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Fh(t)}function Dh(t,e){return Dh=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Dh(t,e)}var Hh=function(){function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:b.bitcoin;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),function(t,e,r){return e=Fh(e),function(t,e){if(e&&("object"==jh(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,Ch()?Reflect.construct(e,r||[],Fh(t).constructor):e.apply(t,r))}(this,t,[e,void 0,r])}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Dh(t,e)}(t,_h),function(t,e){return e&&Nh(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"compile",value:function(t){var e=t.flat(),r=w.compile(e);if(!w.decompile(r))throw new Error("Failed to decompile script??");return r}}])}(),Mh=i(8287).Buffer;function Kh(t){return Kh="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Kh(t)}function Vh(t){return function(t){if(Array.isArray(t))return Wh(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return Wh(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Wh(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Wh(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function Gh(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,qh(n.key),n)}}function qh(t){var e=function(t){if("object"!=Kh(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Kh(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Kh(e)?e:e+""}function zh(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(zh=function(){return!!t})()}function Zh(t){return Zh=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Zh(t)}function Xh(t,e){return Xh=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Xh(t,e)}var Yh=0,$h=Mh.from([Yh]),Jh=function(){function t(e,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:b.bitcoin;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),function(t,e,r){return e=Zh(e),function(t,e){if(e&&("object"==Kh(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,zh()?Reflect.construct(e,r||[],Zh(t).constructor):e.apply(t,r))}(this,t,[e,r,n])}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Xh(t,e)}(t,_h),function(t,e){return e&&Gh(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"compile",value:function(t,e,r,n,i,o){var a=this.getAsm(t,e,r,n,i,o),s=w.compile(a);if(!w.decompile(s))throw new Error("Failed to decompile script??");return s}},{key:"getAsm",value:function(t,e,r,n,i,o){if(!this.contractSaltPubKey)throw new Error("Contract salt public key not set");var a=this.splitBufferIntoChunks(t),s=i?this.splitBufferIntoChunks(i):[],u=[],c=[];if(o)for(var f=0;f<o.length;f++){var l=o[f];u.push(l.opcode);var h=this.encodeFeature(l);c.push.apply(c,Vh(h))}return[this.getHeader(n,u),it.OP_TOALTSTACK,r.publicKey.originalPublicKeyBuffer(),it.OP_TOALTSTACK,r.solution,it.OP_TOALTSTACK,this.xSenderPubKey,it.OP_DUP,it.OP_HASH256,S.hash256(this.xSenderPubKey),it.OP_EQUALVERIFY,it.OP_CHECKSIGVERIFY,this.contractSaltPubKey,it.OP_CHECKSIGVERIFY,it.OP_HASH256,S.hash256(e),it.OP_EQUALVERIFY,it.OP_DEPTH,it.OP_1,it.OP_NUMEQUAL,it.OP_IF,_h.MAGIC].concat(c,[it.OP_0],Vh(s),[it.OP_1NEGATE],Vh(a),[it.OP_ELSE,it.OP_1,it.OP_ENDIF]).flat()}}])}(),Qh=i(8287).Buffer;function tp(t){return tp="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},tp(t)}function ep(t){return function(t){if(Array.isArray(t))return np(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||rp(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function rp(t,e){if(t){if("string"==typeof t)return np(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?np(t,e):void 0}}function np(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function ip(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,op(n.key),n)}}function op(t){var e=function(t){if("object"!=tp(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=tp(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==tp(e)?e:e+""}function ap(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(ap=function(){return!!t})()}function sp(t){return sp=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},sp(t)}function up(t,e){return up=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},up(t,e)}var cp=function(){function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:b.bitcoin;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),function(t,e,r){return e=sp(e),function(t,e){if(e&&("object"==tp(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,ap()?Reflect.construct(e,r||[],sp(t).constructor):e.apply(t,r))}(this,t,[e,Qh.alloc(0),r])}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&up(t,e)}(t,_h),function(t,e,r){return e&&ip(t.prototype,e),r&&ip(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"compile",value:function(t,e,r,n){var i,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:[],a=this.splitBufferIntoChunks(t);if(!a.length)throw new Error("No data chunks found");for(var s=[],u=[],c=0;c<o.length;c++){var f=o[c];s.push(f.opcode);var l=this.encodeFeature(f);u.push.apply(u,ep(l))}var h=[this.getHeader(n,s),it.OP_TOALTSTACK,r,it.OP_TOALTSTACK,this.senderPubKey,it.OP_DUP,it.OP_HASH256,S.hash256(this.senderPubKey),it.OP_EQUALVERIFY,it.OP_CHECKSIGVERIFY,e,it.OP_TOALTSTACK,it.OP_DEPTH,it.OP_1,it.OP_NUMEQUAL,it.OP_IF,_h.MAGIC],p=(h=(i=h).concat.apply(i,u.concat([it.OP_1NEGATE].concat(ep(a),[it.OP_ELSE,it.OP_1,it.OP_ENDIF])))).flat(),d=w.compile(p);if(!w.decompile(d))throw new Error("Failed to decompile script??");return d}}],[{key:"getPubKeyAsBuffer",value:function(t,e){var r,n=Qh.alloc(0),i=function(t){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=rp(t))){e&&(t=e);var r=0,n=function(){};return{s:n,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:n}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,o=!0,a=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return o=t.done,t},e:function(t){a=!0,i=t},f:function(){try{o||null==e.return||e.return()}finally{if(a)throw i}}}}(t);try{for(i.s();!(r=i.n()).done;){var o=r.value;if(!bf.fromPublicKey(o,e).compressed)throw new Error("Public key must be compressed");if(33!==o.byteLength)throw new Error("Public key must be 33 bytes, got ".concat(o.byteLength," bytes."));n=Qh.concat([n,o])}}catch(t){i.e(t)}finally{i.f()}var a=h.compress(n);return a.byteLength>=n.byteLength?n:a}}])}(),fp=i(8287).Buffer;function lp(t){return lp="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},lp(t)}function hp(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function pp(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,dp(n.key),n)}}function dp(t){var e=function(t){if("object"!=lp(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=lp(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==lp(e)?e:e+""}var yp=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)}return function(t,e,r){return r&&pp(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,0,[{key:"compile",value:function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2?arguments[2]:void 0;if(r<2)throw new Error("Minimum signatures must be greater than 1");if(e.length<r)throw new Error("The amount of public keys is lower than the minimum required");if(r>t.MAXIMUM_SUPPORTED_SIGNATURE)throw new Error("The maximum amount of signatures is ".concat(t.MAXIMUM_SUPPORTED_SIGNATURE));var i=fp.alloc(1);i.writeUInt8(r),e=(e=e.filter(function(t,e,r){return e===r.findIndex(function(e){return t.equals(e)})})).sort(function(t,e){return t.compare(e)});var o=!1,a=e.map(function(t){var e=bi(t);return n&&!o&&(o=n.equals(e)),e});n&&!o&&a.push(n);var s=[it.OP_0].concat(function(t){return function(t){if(Array.isArray(t))return hp(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return hp(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?hp(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}(a.flatMap(function(t){return[t,it.OP_CHECKSIGADD]})),[i,it.OP_NUMEQUAL]).flat(),u=w.compile(s);if(!w.decompile(u))throw new Error("Failed to decompile script.");return u}}])}();!function(t,e){(e=dp(e))in t?Object.defineProperty(t,e,{value:255,enumerable:!0,configurable:!0,writable:!0}):t[e]=255}(yp,"MAXIMUM_SUPPORTED_SIGNATURE");var bp=i(8287).Buffer;function gp(t){return gp="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},gp(t)}function vp(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function wp(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,kp(n.key),n)}}function mp(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(mp=function(){return!!t})()}function Sp(){return Sp="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,r){var n=function(t,e){for(;!{}.hasOwnProperty.call(t,e)&&null!==(t=_p(t)););return t}(t,e);if(n){var i=Object.getOwnPropertyDescriptor(n,e);return i.get?i.get.call(arguments.length<3?t:r):i.value}},Sp.apply(null,arguments)}function _p(t){return _p=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},_p(t)}function Ep(t,e){return Ep=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Ep(t,e)}function kp(t){var e=function(t){if("object"!=gp(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=gp(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==gp(e)?e:e+""}var Op=function(){function t(e,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:b.bitcoin;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),function(t,e,r){return e=_p(e),function(t,e){if(e&&("object"==gp(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,mp()?Reflect.construct(e,r||[],_p(t).constructor):e.apply(t,r))}(this,t,[e,r,n])}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Ep(t,e)}(t,_h),function(t,e,r){return e&&wp(t.prototype,e),r&&wp(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"compile",value:function(e,r,n,i){var o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:[];if(!this.contractSaltPubKey)throw new Error("Contract salt public key not set");if(32!==r.length)throw new Error("Contract secret must be exactly 32 bytes");var a=new ph;return a.writeU8(t.P2WDA_VERSION),a.writeBytes(this.getHeader(i,o.map(function(t){return t.opcode}))),a.writeBytes(r),a.writeBytes(n.publicKey.originalPublicKeyBuffer()),a.writeBytes(n.solution),a.writeU32(e.length),a.writeBytes(e),this.writeFeatures(a,o),bp.from(a.getBuffer())}},{key:"getHeader",value:function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];return function(t,e,r){var n=Sp(_p(t.prototype),"getHeader",r);return"function"==typeof n?function(t){return n.apply(r,t)}:n}(t,0,this)([e,r])}},{key:"writeFeatures",value:function(t,e){t.writeU16(e.length);var r,n=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return vp(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?vp(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}(e);try{for(n.s();!(r=n.n()).done;){var i=r.value;t.writeU8(i.opcode);var o=this.encodeFeatureData(i);t.writeU32(o.length),t.writeBytes(o)}}catch(t){n.e(t)}finally{n.f()}}},{key:"encodeFeatureData",value:function(t){switch(t.opcode){case hh.ACCESS_LIST:var e=this.encodeFeature(t);return bp.concat(e.flat());case hh.EPOCH_SUBMISSION:var r=this.encodeFeature(t);return bp.concat(r.flat());default:throw new Error("Unknown feature type: ".concat(t.opcode))}}}],[{key:"validateWitnessSize",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:10,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:80,n=t+64,i=Math.ceil(.7*n);return Math.ceil(i/r)<=e}}])}();!function(t,e){(e=kp(e))in t?Object.defineProperty(t,e,{value:1,enumerable:!0,configurable:!0,writable:!0}):t[e]=1}(Op,"P2WDA_VERSION");var Tp=i(2343);function Ap(t){return Ap="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Ap(t)}function Ip(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Pp(n.key),n)}}function Pp(t){var e=function(t){if("object"!=Ap(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Ap(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Ap(e)?e:e+""}ur(ca);var xp=function(){return function(t,e,r){return r&&Ip(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)},0,[{key:"generatePKSH",value:function(t,e){if(32!==t.length)throw new Error("Invalid hash length");var r=Je(t);return this.toSegwitAddress(r,e)}},{key:"generateTaprootAddress",value:function(t,e){if(32!==t.length)throw new Error("Invalid public key length");var r=Tp.p2.toWords(t);return r.unshift(1),Tp.p2.encode(e.bech32,r)}},{key:"toSegwitAddress",value:function(t,e){var r=Tp.I.toWords(t);return r.unshift(0),Tp.I.encode(e.bech32,r)}}])}(),Bp={d:(t,e)=>{for(var r in e)Bp.o(e,r)&&!Bp.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},Rp={};Bp.d(Rp,{q$:()=>jd,Vy:()=>Nd,$7:()=>Up,rE:()=>jp});var Up={};Bp.r(Up),Bp.d(Up,{DebugLevel:()=>jd,Logger:()=>Nd,version:()=>jp});var jp="1.0.2";function Np(t,e){t=t.replace("#","");var r=parseInt(t,16),n=Math.round(2.55*e),i=(r>>16)+n,o=(r>>8&255)+n,a=(255&r)+n;return(16777216+65536*(i<255?i<1?0:i:255)+256*(o<255?o<1?0:o:255)+(a<255?a<1?0:a:255)).toString(16).slice(1)}const Lp=(t=0)=>e=>`[${e+t}m`,Cp=(t=0)=>e=>`[${38+t};5;${e}m`,Fp=(t=0)=>(e,r,n)=>`[${38+t};2;${e};${r};${n}m`,Dp={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};Object.keys(Dp.modifier),Object.keys(Dp.color),Object.keys(Dp.bgColor);const Hp=function(){const t=new Map;for(const[e,r]of Object.entries(Dp)){for(const[e,n]of Object.entries(r))Dp[e]={open:`[${n[0]}m`,close:`[${n[1]}m`},r[e]=Dp[e],t.set(n[0],n[1]);Object.defineProperty(Dp,e,{value:r,enumerable:!1})}return Object.defineProperty(Dp,"codes",{value:t,enumerable:!1}),Dp.color.close="",Dp.bgColor.close="",Dp.color.ansi=Lp(),Dp.color.ansi256=Cp(),Dp.color.ansi16m=Fp(),Dp.bgColor.ansi=Lp(10),Dp.bgColor.ansi256=Cp(10),Dp.bgColor.ansi16m=Fp(10),Object.defineProperties(Dp,{rgbToAnsi256:{value:(t,e,r)=>t===e&&e===r?t<8?16:t>248?231:Math.round((t-8)/247*24)+232:16+36*Math.round(t/255*5)+6*Math.round(e/255*5)+Math.round(r/255*5),enumerable:!1},hexToRgb:{value(t){const e=/[a-f\d]{6}|[a-f\d]{3}/i.exec(t.toString(16));if(!e)return[0,0,0];let[r]=e;3===r.length&&(r=[...r].map(t=>t+t).join(""));const n=Number.parseInt(r,16);return[n>>16&255,n>>8&255,255&n]},enumerable:!1},hexToAnsi256:{value:t=>Dp.rgbToAnsi256(...Dp.hexToRgb(t)),enumerable:!1},ansi256ToAnsi:{value(t){if(t<8)return 30+t;if(t<16)return t-8+90;let e,r,n;if(t>=232)e=(10*(t-232)+8)/255,r=e,n=e;else{const i=(t-=16)%36;e=Math.floor(t/36)/5,r=Math.floor(i/6)/5,n=i%6/5}const i=2*Math.max(e,r,n);if(0===i)return 30;let o=30+(Math.round(n)<<2|Math.round(r)<<1|Math.round(e));return 2===i&&(o+=60),o},enumerable:!1},rgbToAnsi:{value:(t,e,r)=>Dp.ansi256ToAnsi(Dp.rgbToAnsi256(t,e,r)),enumerable:!1},hexToAnsi:{value:t=>Dp.ansi256ToAnsi(Dp.hexToAnsi256(t)),enumerable:!1}}),Dp}(),Mp=(()=>{if(navigator.userAgentData){const t=navigator.userAgentData.brands.find(({brand:t})=>"Chromium"===t);if(t&&t.version>93)return 3}return/\b(Chrome|Chromium)\//.test(navigator.userAgent)?1:0})(),Kp=0!==Mp&&{level:Mp,hasBasic:!0,has256:Mp>=2,has16m:Mp>=3},Vp={stdout:Kp,stderr:Kp};function Wp(t,e,r){let n=t.indexOf(e);if(-1===n)return t;const i=e.length;let o=0,a="";do{a+=t.slice(o,n)+e+r,o=n+i,n=t.indexOf(e,o)}while(-1!==n);return a+=t.slice(o),a}const{stdout:Gp,stderr:qp}=Vp,zp=Symbol("GENERATOR"),Zp=Symbol("STYLER"),Xp=Symbol("IS_EMPTY"),Yp=["ansi","ansi","ansi256","ansi16m"],$p=Object.create(null);class Jp{constructor(t){return Qp(t)}}const Qp=t=>{const e=(...t)=>t.join(" ");return((t,e={})=>{if(e.level&&!(Number.isInteger(e.level)&&e.level>=0&&e.level<=3))throw new Error("The `level` option should be an integer from 0 to 3");const r=Gp?Gp.level:0;t.level=void 0===e.level?r:e.level})(e,t),Object.setPrototypeOf(e,td.prototype),e};function td(t){return Qp(t)}Object.setPrototypeOf(td.prototype,Function.prototype);for(const[t,e]of Object.entries(Hp))$p[t]={get(){const r=od(this,id(e.open,e.close,this[Zp]),this[Xp]);return Object.defineProperty(this,t,{value:r}),r}};$p.visible={get(){const t=od(this,this[Zp],!0);return Object.defineProperty(this,"visible",{value:t}),t}};const ed=(t,e,r,...n)=>"rgb"===t?"ansi16m"===e?Hp[r].ansi16m(...n):"ansi256"===e?Hp[r].ansi256(Hp.rgbToAnsi256(...n)):Hp[r].ansi(Hp.rgbToAnsi(...n)):"hex"===t?ed("rgb",e,r,...Hp.hexToRgb(...n)):Hp[r][t](...n),rd=["rgb","hex","ansi256"];for(const t of rd)$p[t]={get(){const{level:e}=this;return function(...r){const n=id(ed(t,Yp[e],"color",...r),Hp.color.close,this[Zp]);return od(this,n,this[Xp])}}},$p["bg"+t[0].toUpperCase()+t.slice(1)]={get(){const{level:e}=this;return function(...r){const n=id(ed(t,Yp[e],"bgColor",...r),Hp.bgColor.close,this[Zp]);return od(this,n,this[Xp])}}};const nd=Object.defineProperties(()=>{},{...$p,level:{enumerable:!0,get(){return this[zp].level},set(t){this[zp].level=t}}}),id=(t,e,r)=>{let n,i;return void 0===r?(n=t,i=e):(n=r.openAll+t,i=e+r.closeAll),{open:t,close:e,openAll:n,closeAll:i,parent:r}},od=(t,e,r)=>{const n=(...t)=>ad(n,1===t.length?""+t[0]:t.join(" "));return Object.setPrototypeOf(n,nd),n[zp]=t,n[Zp]=e,n[Xp]=r,n},ad=(t,e)=>{if(t.level<=0||!e)return t[Xp]?"":e;let r=t[Zp];if(void 0===r)return e;const{openAll:n,closeAll:i}=r;if(e.includes(""))for(;void 0!==r;)e=Wp(e,r.close,r.open),r=r.parent;const o=e.indexOf("\n");return-1!==o&&(e=function(t,e,r,n){let i=0,o="";do{const a="\r"===t[n-1];o+=t.slice(i,a?n-1:n)+e+(a?"\r\n":"\n")+r,i=n+1,n=t.indexOf("\n",i)}while(-1!==n);return o+=t.slice(i),o}(e,i,n,o)),n+e+i};function sd(t){return sd="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},sd(t)}function ud(t,e,r){(function(t,e){if(e.has(t))throw new TypeError("Cannot initialize the same private elements twice on an object")})(t,e),e.set(t,r)}function cd(t,e,r){return(e=fd(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function fd(t){var e=function(t){if("object"!=sd(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=sd(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==sd(e)?e:e+""}function ld(t,e){return t.get(function(t,e,r){if("function"==typeof t?t===e:t.has(e))return arguments.length<3?e:r;throw new TypeError("Private element is not present on this object")}(t,e))}Object.defineProperties(td.prototype,$p),td(),td({level:qp?qp.level:0});var hd=new WeakMap,pd=new WeakMap,dd=new WeakMap,yd=new WeakMap,bd=new WeakMap,gd=new WeakMap,vd=new WeakMap,wd=new WeakMap,md=new WeakMap,Sd=new WeakMap,_d=new WeakMap,Ed=new WeakMap,kd=new WeakMap,Od=new WeakMap,Td=new WeakMap,Ad=new WeakMap,Id=new WeakMap,Pd=function(){return t=function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new Jp;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),cd(this,"moduleName",""),cd(this,"logColor","#00bfff"),cd(this,"enableLogs",!0),cd(this,"hideLogs",!1),ud(this,hd,"#ff00ff"),ud(this,pd,Np(ld(hd,this),75)),ud(this,dd,"#9400d3"),ud(this,yd,Np(ld(dd,this),15)),ud(this,bd,Np(ld(yd,this),15)),ud(this,gd,"#7cfc00"),ud(this,vd,Np(ld(gd,this),15)),ud(this,wd,"#ffdead"),ud(this,md,Np(ld(wd,this),15)),ud(this,Sd,"#ff8c00"),ud(this,_d,Np(ld(Sd,this),15)),ud(this,Ed,"#ff4500"),ud(this,kd,Np(ld(Ed,this),15)),ud(this,Od,"#ffffff"),ud(this,Td,Np(ld(Od,this),15)),ud(this,Ad,"#8b0000"),ud(this,Id,Np(ld(Ad,this),15)),cd(this,"prefix",""),this.chalk=e,this.moduleName=this.constructor.name},e=[{key:"setLogPrefix",value:function(t){this.prefix=t}},{key:"getStartPrefix",value:function(){return this.prefix}},{key:"disable",value:function(){this.enableLogs=!1}},{key:"enable",value:function(){this.enableLogs=!0}},{key:"fancyLog",value:function(t,e,r,n,i){this.enableLogs&&console.log(this.chalk.hex(ld(hd,this))("".concat(this.getStartPrefix(),"[").concat(this.moduleName," INFO]: "))+this.chalk.hex(ld(Od,this))(t)+" "+this.chalk.hex(ld(_d,this))(e)+" "+this.chalk.hex(ld(Od,this))(r)+" "+this.chalk.hex(ld(bd,this))(n)+" "+this.chalk.hex(ld(Od,this))(i))}},{key:"log",value:function(){if(this.enableLogs&&!this.hideLogs){var t=Np(this.logColor,15);console.log(this.chalk.hex(this.logColor)("".concat(this.getStartPrefix(),"[").concat(this.moduleName," LOG]: "))+this.chalk.hex(t).apply(void 0,arguments))}}},{key:"lightOrangeLog",value:function(){this.enableLogs&&(this.hideLogs||console.log(this.chalk.hex(ld(_d,this))("".concat(this.getStartPrefix(),"[").concat(this.moduleName," LOG]: "))+this.chalk.hex(ld(Od,this)).apply(void 0,arguments)))}},{key:"error",value:function(){this.enableLogs&&console.log(this.chalk.hex(ld(Ed,this))("".concat(this.getStartPrefix(),"[").concat(this.moduleName," ERROR]: "))+this.chalk.hex(ld(kd,this)).apply(void 0,arguments))}},{key:"warn",value:function(){this.enableLogs&&console.log(this.chalk.hex(ld(Sd,this))("".concat(this.getStartPrefix(),"[").concat(this.moduleName," WARN]: "))+this.chalk.hex(ld(_d,this)).apply(void 0,arguments))}},{key:"debug",value:function(){this.enableLogs&&(this.hideLogs||console.log(this.chalk.hex(ld(wd,this))("".concat(this.getStartPrefix(),"[").concat(this.moduleName," DEBUG]: "))+this.chalk.hex(ld(md,this)).apply(void 0,arguments)))}},{key:"success",value:function(){this.enableLogs&&(this.hideLogs||console.log(this.chalk.hex(ld(gd,this))("".concat(this.getStartPrefix(),"[").concat(this.moduleName," SUCCESS]: "))+this.chalk.hex(ld(vd,this)).apply(void 0,arguments)))}},{key:"fail",value:function(){this.enableLogs&&(this.hideLogs||console.log(this.chalk.hex(ld(Ed,this))("".concat(this.getStartPrefix(),"[").concat(this.moduleName," FAIL]: "))+this.chalk.hex(ld(kd,this)).apply(void 0,arguments)))}},{key:"debugBright",value:function(){this.enableLogs&&(this.hideLogs||console.log(this.chalk.hex(ld(dd,this))("".concat(this.getStartPrefix(),"[").concat(this.moduleName," DEBUG]: "))+this.chalk.hex(ld(yd,this)).apply(void 0,arguments)))}},{key:"important",value:function(){this.enableLogs&&console.log(this.chalk.hex(ld(hd,this))("".concat(this.getStartPrefix(),"[").concat(this.moduleName," IMPORTANT]: "))+this.chalk.hex(ld(pd,this)).apply(void 0,arguments))}},{key:"panic",value:function(){this.enableLogs&&console.log(this.chalk.hex(ld(Ad,this))("".concat(this.getStartPrefix(),"[").concat(this.moduleName," HELP PANIC]: "))+this.chalk.hex(ld(Id,this)).apply(void 0,arguments))}},{key:"info",value:function(){this.enableLogs&&console.log(this.chalk.hex(ld(hd,this))("".concat(this.getStartPrefix(),"[").concat(this.moduleName," INFO]: "))+this.chalk.hex(ld(Od,this)).apply(void 0,arguments))}},{key:"securityNotice",value:function(){this.enableLogs&&console.log(this.chalk.hex("#22d8e6")("".concat(this.getStartPrefix(),"[").concat(this.moduleName," SECURITY NOTICE]: "))+this.chalk.hex("#22e3e6").apply(void 0,arguments))}},{key:"traceLog",value:function(){this.enableLogs&&console.log(this.chalk.hex("#ffffff")("".concat(this.getStartPrefix(),"[").concat(this.moduleName," TRACE LOG]: "))+this.chalk.hex(ld(Td,this)).apply(void 0,arguments))}}],e&&function(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,fd(n.key),n)}}(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}();function xd(t){return xd="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},xd(t)}function Bd(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(Bd=function(){return!!t})()}function Rd(t){return Rd=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Rd(t)}function Ud(t,e){return Ud=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Ud(t,e)}var jd,Nd=function(){function t(){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),function(t,e){return e=Rd(e),function(t,e){if(e&&("object"==xd(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,Bd()?Reflect.construct(e,[],Rd(t).constructor):e.apply(t,void 0))}(this,t)}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Ud(t,e)}(t,Pd),e=t,Object.defineProperty(e,"prototype",{writable:!1}),e;var e}();!function(t){t[t.NONE=0]="NONE",t[t.ERROR=1]="ERROR",t[t.WARN=2]="WARN",t[t.INFO=3]="INFO",t[t.DEBUG=4]="DEBUG",t[t.TRACE=5]="TRACE",t[t.ALL=6]="ALL"}(jd||(jd={}));var Ld=Rp.Vy,Cd=i(8287).Buffer;function Fd(t){return Fd="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Fd(t)}function Dd(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Hd(n.key),n)}}function Hd(t){var e=function(t){if("object"!=Fd(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Fd(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Fd(e)?e:e+""}ur(ca);var Md,Kd,Vd=function(){return function(t,e,r){return r&&Dd(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)},0,[{key:"tweakSigner",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.privateKey;if(!r)throw new Error("Private key is required for tweaking signer!");3===t.publicKey[0]&&(r=ua.privateNegate(r));var n=ua.privateAdd(r,Hr(bi(Cd.from(t.publicKey)),e.tweakHash));if(!n)throw new Error("Invalid tweaked private key!");return bf.fromPrivateKey(Cd.from(n),e.network)}}])}();function Wd(t){return t&&!!(t.tapInternalKey||t.tapMerkleRoot||t.tapLeafScript&&t.tapLeafScript.length||t.tapBip32Derivation&&t.tapBip32Derivation.length||t.witnessUtxo&&Ki(t.witnessUtxo.script))}function Gd(t,e){if(t.nonWitnessUtxo&&!t.redeemScript&&!t.witnessScript&&!t.witnessUtxo||t.redeemScript)return!0;var r=function(t){return t.redeemScript?t.redeemScript:t.witnessScript?t.witnessScript:t.witnessUtxo?t.witnessUtxo.script:(t.nonWitnessUtxo,null)}(t);return!!r&&qd(e,r)}function qd(t,e){return-1!==zi(t,e)}function zd(t){return zd="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},zd(t)}function Zd(){var t,e,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",i=r.toStringTag||"@@toStringTag";function o(r,n,i,o){var u=n&&n.prototype instanceof s?n:s,c=Object.create(u.prototype);return Xd(c,"_invoke",function(r,n,i){var o,s,u,c=0,f=i||[],l=!1,h={p:0,n:0,v:t,a:p,f:p.bind(t,4),d:function(e,r){return o=e,s=0,u=t,h.n=r,a}};function p(r,n){for(s=r,u=n,e=0;!l&&c&&!i&&e<f.length;e++){var i,o=f[e],p=h.p,d=o[2];r>3?(i=d===n)&&(u=o[(s=o[4])?5:(s=3,3)],o[4]=o[5]=t):o[0]<=p&&((i=r<2&&p<o[1])?(s=0,h.v=n,h.n=o[1]):p<d&&(i=r<3||o[0]>n||n>d)&&(o[4]=r,o[5]=n,h.n=d,s=0))}if(i||r>1)return a;throw l=!0,n}return function(i,f,d){if(c>1)throw TypeError("Generator is already running");for(l&&1===f&&p(f,d),s=f,u=d;(e=s<2?t:u)||!l;){o||(s?s<3?(s>1&&(h.n=-1),p(s,u)):h.n=u:h.v=u);try{if(c=2,o){if(s||(i="next"),e=o[i]){if(!(e=e.call(o,u)))throw TypeError("iterator result is not an object");if(!e.done)return e;u=e.value,s<2&&(s=0)}else 1===s&&(e=o.return)&&e.call(o),s<2&&(u=TypeError("The iterator does not provide a '"+i+"' method"),s=1);o=t}else if((e=(l=h.n<0)?u:r.call(n,h))!==a)break}catch(e){o=t,s=1,u=e}finally{c=1}}return{value:e,done:l}}}(r,i,o),!0),c}var a={};function s(){}function u(){}function c(){}e=Object.getPrototypeOf;var f=[][n]?e(e([][n]())):(Xd(e={},n,function(){return this}),e),l=c.prototype=s.prototype=Object.create(f);function h(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,c):(t.__proto__=c,Xd(t,i,"GeneratorFunction")),t.prototype=Object.create(l),t}return u.prototype=c,Xd(l,"constructor",c),Xd(c,"constructor",u),u.displayName="GeneratorFunction",Xd(c,i,"GeneratorFunction"),Xd(l),Xd(l,i,"Generator"),Xd(l,n,function(){return this}),Xd(l,"toString",function(){return"[object Generator]"}),(Zd=function(){return{w:o,m:h}})()}function Xd(t,e,r,n){var i=Object.defineProperty;try{i({},"",{})}catch(t){i=0}Xd=function(t,e,r,n){function o(e,r){Xd(t,e,function(t){return this._invoke(e,r,t)})}e?i?i(t,e,{value:r,enumerable:!n,configurable:!n,writable:!n}):t[e]=r:(o("next",0),o("throw",1),o("return",2))},Xd(t,e,r,n)}function Yd(t,e,r,n,i,o,a){try{var s=t[o](a),u=s.value}catch(t){return void r(t)}s.done?e(u):Promise.resolve(u).then(n,i)}function $d(t){return function(){var e=this,r=arguments;return new Promise(function(n,i){var o=t.apply(e,r);function a(t){Yd(o,n,i,a,s,"next",t)}function s(t){Yd(o,n,i,a,s,"throw",t)}a(void 0)})}}function Jd(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=ty(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}function Qd(t){return function(t){if(Array.isArray(t))return ey(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||ty(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function ty(t,e){if(t){if("string"==typeof t)return ey(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?ey(t,e):void 0}}function ey(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function ry(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,sy(n.key),n)}}function ny(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(ny=function(){return!!t})()}function iy(t){return iy=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},iy(t)}function oy(t,e){return oy=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},oy(t,e)}function ay(t,e,r){return(e=sy(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function sy(t){var e=function(t){if("object"!=zd(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=zd(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==zd(e)?e:e+""}!function(t){t[t.REPLACE_BY_FEE=4294967293]="REPLACE_BY_FEE",t[t.FINAL=4294967295]="FINAL"}(Md||(Md={})),function(t){t[t.BLOCKS=0]="BLOCKS",t[t.TIMESTAMPS=1]="TIMESTAMPS"}(Kd||(Kd={}));var uy=function(){function t(e){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),ay(r=function(t,e,r){return e=iy(e),function(t,e){if(e&&("object"==zd(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,ny()?Reflect.construct(e,r||[],iy(t).constructor):e.apply(t,r))}(this,t),"logColor","#00ffe1"),ay(r,"finalized",!1),ay(r,"signed",!1),ay(r,"scriptData",null),ay(r,"tapData",null),ay(r,"inputs",[]),ay(r,"sequence",Md.REPLACE_BY_FEE),ay(r,"tapLeafScript",null),ay(r,"isBrowser",!1),ay(r,"csvInputIndices",new Set),ay(r,"anchorInputIndices",new Set),ay(r,"regenerated",!1),ay(r,"ignoreSignatureErrors",!1),ay(r,"noSignatures",!1),ay(r,"txVersion",2),ay(r,"customFinalizerP2SH",function(t,e,n,i,o,a){var s=r.inputs[t];if(o&&e.partialSig&&s&&s.redeemScript){var u=e.partialSig.map(function(t){return t.signature})||[];return{finalScriptSig:w.compile([].concat(Qd(u),[s.redeemScript])),finalScriptWitness:void 0}}if(r.anchorInputIndices.has(t))return{finalScriptSig:void 0,finalScriptWitness:ul.Buffer.from([0])};if(a&&i&&e.witnessScript){if(!e.partialSig||0===e.partialSig.length)throw new Error("No signatures for P2WSH input #".concat(t));if(pl.isP2WDAWitnessScript(e.witnessScript))return r.finalizeSecondaryP2WDA(t,e);if(r.csvInputIndices.has(t)){var c=[e.partialSig[0].signature,e.witnessScript];return{finalScriptSig:void 0,finalScriptWitness:By.witnessStackToScriptWitness(c)}}}return Ko(t,e,n,i,o,a,!0,r.unlockScript)}),r.signer=e.signer,r.network=e.network,r.noSignatures=e.noSignatures||!1,r.nonWitnessUtxo=e.nonWitnessUtxo,r.unlockScript=e.unlockScript,r.isBrowser="undefined"!=typeof window,e.txVersion&&(r.txVersion=e.txVersion),r}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&oy(t,e)}(t,Ld),function(t,e,r){return e&&ry(t.prototype,e),r&&ry(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"ignoreSignatureError",value:function(){this.ignoreSignatureErrors=!0}},{key:"getScriptAddress",value:function(){if(!this.scriptData||!this.scriptData.address)throw new Error("Tap data is required");return this.scriptData.address}},{key:"getTransaction",value:function(){return this.transaction.extractTransaction(!1)}},{key:"getTapAddress",value:function(){if(!this.tapData||!this.tapData.address)throw new Error("Tap data is required");return this.tapData.address}},{key:"disableRBF",value:function(){if(this.signed)throw new Error("Transaction is already signed");this.sequence=Md.FINAL;var t,e=Jd(this.inputs);try{for(e.s();!(t=e.n()).done;){var r=t.value;this.csvInputIndices.has(this.inputs.indexOf(r))||(r.sequence=Md.FINAL)}}catch(t){e.e(t)}finally{e.f()}}},{key:"getTweakerHash",value:function(){var t;return null===(t=this.tapData)||void 0===t?void 0:t.hash}},{key:"preEstimateTransactionFees",value:function(t,e,r,n,i){var o=10n+41n*e+68n*r;return(3n*o+(o+(144n*n+34n*i+(1n+35n*i+1n+n))))/4n*t}},{key:"generateTapData",value:function(){return{internalPubkey:this.internalPubKeyToXOnly(),network:this.network,name:Yi.P2TR}}},{key:"generateScriptAddress",value:function(){return{internalPubkey:this.internalPubKeyToXOnly(),network:this.network,name:Yi.P2TR}}},{key:"getSignerKey",value:function(){return this.signer}},{key:"signInput",value:(s=$d(Zd().m(function t(e,r,n,i){var o,a,s,u,c,f,l,h,p=arguments;return Zd().w(function(t){for(;;)switch(t.p=t.n){case 0:if(o=p.length>4&&void 0!==p[4]&&p[4],a=p.length>5&&void 0!==p[5]&&p[5],!this.anchorInputIndices.has(n)){t.n=1;break}return t.a(2);case 1:if(s=i.publicKey,u=Wd(r),o&&(u=!u),c=!1,f=!1,!u){t.n=6;break}return t.p=2,t.n=3,this.attemptSignTaproot(e,r,n,i,s);case 3:c=!0,t.n=5;break;case 4:t.p=4,l=t.v,this.error("Failed to sign Taproot script path input ".concat(n," (reverse: ").concat(o,"): ").concat(l.message)),f=!0;case 5:t.n=10;break;case 6:if(!o&&!Gd(r,s)){t.n=10;break}return t.p=7,t.n=8,this.signNonTaprootInput(i,e,n);case 8:c=!0,t.n=10;break;case 9:t.p=9,h=t.v,this.error("Failed to sign non-Taproot input ".concat(n,": ").concat(h.stack)),f=!0;case 10:if(c){t.n=14;break}if(!f||!a){t.n=11;break}throw new Error("Failed to sign input ".concat(n," with the provided signer."));case 11:return t.p=11,t.n=12,this.signInput(e,r,n,i,!0,f);case 12:t.n=14;break;case 13:throw t.p=13,t.v,new Error("Cannot sign input ".concat(n," with the provided signer."));case 14:return t.a(2)}},t,this,[[11,13],[7,9],[2,4]])})),function(t,e,r,n){return s.apply(this,arguments)})},{key:"splitArray",value:function(t,e){if(e<=0)throw new Error("Chunk size must be greater than 0.");for(var r=[],n=0;n<t.length;n+=e)r.push(t.slice(n,n+e));return r}},{key:"signInputs",value:(a=$d(Zd().m(function t(e){return Zd().w(function(t){for(;;)switch(t.n){case 0:if(!("multiSignPsbt"in this.signer)){t.n=2;break}return t.n=1,this.signInputsWalletBased(e);case 1:case 3:return t.a(2);case 2:return t.n=3,this.signInputsNonWalletBased(e)}},t,this)})),function(t){return a.apply(this,arguments)})},{key:"signInputsNonWalletBased",value:(o=$d(Zd().m(function t(e){var r,n,i,o,a,s,u,c,f,l,h;return Zd().w(function(t){for(;;)switch(t.n){case 0:if(r=e.data.inputs,n=20,i=this.splitArray(r,n),this.noSignatures){t.n=3;break}o=0;case 1:if(!(o<i.length)){t.n=3;break}for(a=i[o],s=[],u=o*n,c=0;c<a.length;c++){f=u+c,l=a[c];try{s.push(this.signInput(e,l,f,this.signer))}catch(t){this.log("Failed to sign input ".concat(f,": ").concat(t.stack))}}return t.n=2,Promise.all(s);case 2:o++,t.n=1;break;case 3:for(h=0;h<e.data.inputs.length;h++)e.finalizeInput(h,this.customFinalizerP2SH.bind(this));this.finalized=!0;case 4:return t.a(2)}},t,this)})),function(t){return o.apply(this,arguments)})},{key:"internalPubKeyToXOnly",value:function(){return bi(ul.Buffer.from(this.signer.publicKey))}},{key:"internalInit",value:function(){this.scriptData=k.p2tr(this.generateScriptAddress()),this.tapData=k.p2tr(this.generateTapData())}},{key:"tweakSigner",value:function(){this.tweakedSigner||(this.tweakedSigner=this.getTweakedSigner(!0))}},{key:"getTweakedSigner",value:function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0],e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.signer,r={network:this.network};if(t&&(r.tweakHash=this.getTweakerHash()),"privateKey"in e)return Vd.tweakSigner(e,r)}},{key:"generateP2SHRedeemScript",value:function(t){var e=k.p2wsh({redeem:{output:t},network:this.network});return k.p2sh({redeem:e,network:this.network}).output}},{key:"generateP2SHRedeemScriptLegacy",value:function(t){var e=S.hash160(this.signer.publicKey),r=w.compile([it.OP_DUP,it.OP_HASH160,e,it.OP_EQUALVERIFY,it.OP_CHECKSIG]),n=S.hash160(r),i=w.compile([it.OP_HASH160,n,it.OP_EQUAL]),o=k.p2wsh({redeem:{output:r},network:this.network}),a=k.p2sh({redeem:o,network:this.network});if(m.fromOutputScript(i,this.network)===t&&a.redeem&&a.redeem.output)return{redeemScript:r,outputScript:a.redeem.output}}},{key:"generateP2SHP2PKHRedeemScript",value:function(t){var e,r=ul.Buffer.isBuffer(this.signer.publicKey)?this.signer.publicKey:ul.Buffer.from(this.signer.publicKey,"hex"),n=k.p2wpkh({pubkey:r,network:this.network}),i=k.p2sh({redeem:n,network:this.network}),o=i.address;if(!(null===(e=i.redeem)||void 0===e?void 0:e.output))throw new Error("Failed to generate P2SH-P2WPKH redeem script");if(o===t&&i.redeem&&i.redeem.output&&i.output)return{redeemScript:i.redeem.output,outputScript:i.output}}},{key:"generatePsbtInputExtended",value:function(e,r){var n=ul.Buffer.from(e.scriptPubKey.hex,"hex"),i={hash:e.transactionId,index:e.outputIndex,sequence:this.sequence,witnessUtxo:{value:Number(e.value),script:n}};if(Fi(n)){if(!e.nonWitnessUtxo)throw new Error("Missing nonWitnessUtxo for P2PKH UTXO");i.nonWitnessUtxo=ul.Buffer.isBuffer(e.nonWitnessUtxo)?e.nonWitnessUtxo:ul.Buffer.from(e.nonWitnessUtxo,"hex")}else if(Di(n)||_e(n));else if(Hi(n))this.processP2WSHInput(e,i,r);else if(Mi(n)){var o;if(e.redeemScript)o=ul.Buffer.isBuffer(e.redeemScript)?e.redeemScript:ul.Buffer.from(e.redeemScript,"hex");else{if(!e.scriptPubKey.address)throw new Error("Missing redeemScript and no address to regenerate it for P2SH UTXO");var a=this.generateP2SHP2PKHRedeemScript(e.scriptPubKey.address);if(!a)throw new Error("Missing redeemScript for P2SH UTXO and unable to regenerate");o=a.redeemScript}i.redeemScript=o;var s=k.p2sh({redeem:{output:i.redeemScript}});if(!s.redeem)throw new Error("Failed to extract redeem script from P2SH UTXO");var u=s.redeem.output;if(!u)throw new Error("Failed to extract redeem output from P2SH UTXO");e.nonWitnessUtxo&&(i.nonWitnessUtxo=ul.Buffer.isBuffer(e.nonWitnessUtxo)?e.nonWitnessUtxo:ul.Buffer.from(e.nonWitnessUtxo,"hex")),Di(u)?delete i.nonWitnessUtxo:Hi(u)?(delete i.nonWitnessUtxo,this.processP2WSHInput(e,i,r)):delete i.witnessUtxo}else if(Ki(n)){if(this.sighashTypes){var c=t.calculateSignHash(this.sighashTypes);c&&(i.sighashType=c)}this.tweakSigner(),i.tapInternalKey=this.internalPubKeyToXOnly()}else if(function(t){return 4===t.length&&81===t[0]&&2===t[1]&&78===t[2]&&115===t[3]}(n))this.anchorInputIndices.add(r),i.isPayToAnchor=!0;else if(Ci(n)||Li(n)){if(!e.nonWitnessUtxo)throw new Error("Missing nonWitnessUtxo for P2PK or P2MS UTXO");i.nonWitnessUtxo=ul.Buffer.isBuffer(e.nonWitnessUtxo)?e.nonWitnessUtxo:ul.Buffer.from(e.nonWitnessUtxo,"hex")}else this.error("Unknown or unsupported script type for output: ".concat(e.scriptPubKey.hex));return 0===r&&(this.tapLeafScript&&(i.tapLeafScript=[this.tapLeafScript]),this.nonWitnessUtxo&&(i.nonWitnessUtxo=this.nonWitnessUtxo)),i}},{key:"processP2WSHInput",value:function(t,e,r){if(!t.witnessScript)throw new Error("Missing witnessScript for P2WSH UTXO");e.witnessScript=ul.Buffer.isBuffer(t.witnessScript)?t.witnessScript:ul.Buffer.from(t.witnessScript,"hex");var n=w.decompile(e.witnessScript);if(n&&this.isCSVScript(n)){var i=w.decompile(e.witnessScript);if(i&&this.isCSVScript(i)){this.csvInputIndices.add(r);var o=this.extractCSVBlocks(i);console.log("csvBlocks",o),e.sequence=this.setCSVSequence(o,this.sequence)}}}},{key:"secondsToCSVTimeUnits",value:function(t){return Math.floor(t/512)}},{key:"createTimeBasedCSV",value:function(t){var e=this.secondsToCSVTimeUnits(t);if(e>65535)throw new Error("Time units ".concat(e," exceeds maximum of 65,535"));return e|1<<22}},{key:"isCSVEnabled",value:function(t){return!(t&1<<31)}},{key:"extractCSVValue",value:function(t){return 65535&t}},{key:"finalizeSecondaryP2WDA",value:function(t,e){if(!e.partialSig||0===e.partialSig.length)throw new Error("No signature for P2WDA input #".concat(t));if(!e.witnessScript)throw new Error("No witness script for P2WDA input #".concat(t));var r=pl.createSimpleP2WDAWitness(e.partialSig[0].signature,e.witnessScript);return{finalScriptSig:void 0,finalScriptWitness:By.witnessStackToScriptWitness(r)}}},{key:"signInputsWalletBased",value:(i=$d(Zd().m(function t(e){var r,n;return Zd().w(function(t){for(;;)switch(t.n){case 0:return r=this.signer,t.n=1,r.multiSignPsbt([e]);case 1:for(n=0;n<e.data.inputs.length;n++)e.finalizeInput(n,this.customFinalizerP2SH.bind(this));this.finalized=!0;case 2:return t.a(2)}},t,this)})),function(t){return i.apply(this,arguments)})},{key:"isCSVScript",value:function(t){return t.some(function(t){return t===it.OP_CHECKSEQUENCEVERIFY})}},{key:"setCSVSequence",value:function(t,e){if(this.txVersion<2)throw new Error("CSV requires transaction version 2 or higher");if(t>65535)throw new Error("CSV blocks ".concat(t," exceeds maximum of 65,535"));var r=65535&t;return!!(t&1<<22)&&(r|=1<<22),e===Md.REPLACE_BY_FEE&&(r|=1<<25),2147483647&r}},{key:"getCSVType",value:function(t){return t&1<<22?Kd.TIMESTAMPS:Kd.BLOCKS}},{key:"extractCSVBlocks",value:function(t){for(var e=0;e<t.length;e++)if(t[e]===it.OP_CHECKSEQUENCEVERIFY&&e>0){var r=t[e-1];if(ul.Buffer.isBuffer(r))return w.number.decode(r);if("number"==typeof r){if(r===it.OP_0||r===it.OP_FALSE)return 0;if(r===it.OP_1NEGATE)return-1;if(r>=it.OP_1&&r<=it.OP_16)return r-it.OP_1+1;throw new Error("Unexpected raw number in script: ".concat(r))}}return 0}},{key:"attemptSignTaproot",value:(n=$d(Zd().m(function t(e,r,n,i,o){var a;return Zd().w(function(t){for(;;)switch(t.p=t.n){case 0:if(!this.isTaprootScriptSpend(r,o)){t.n=2;break}return t.n=1,this.signTaprootInput(i,e,n);case 1:t.n=9;break;case 2:if(i!==this.signer?a=this.getTweakedSigner(!0,i):(this.tweakedSigner||this.tweakSigner(),a=this.tweakedSigner),!a){t.n=8;break}return t.p=3,t.n=4,this.signTaprootInput(a,e,n);case 4:t.n=7;break;case 5:if(t.p=5,t.v,a=this.getTweakedSigner(!1,this.signer)){t.n=6;break}throw new Error("Failed to obtain tweaked signer for input ".concat(n,"."));case 6:return t.n=7,this.signTaprootInput(a,e,n);case 7:t.n=9;break;case 8:this.error("Failed to obtain tweaked signer for input ".concat(n,"."));case 9:return t.a(2)}},t,this,[[3,5]])})),function(t,e,r,i,o){return n.apply(this,arguments)})},{key:"isTaprootScriptSpend",value:function(t,e){if(t.tapLeafScript&&t.tapLeafScript.length>0){var r,n=Jd(t.tapLeafScript);try{for(n.s();!(r=n.n()).done;)if(qd(e,r.value.script))return!0}catch(t){n.e(t)}finally{n.f()}}return!1}},{key:"signTaprootInput",value:(r=$d(Zd().m(function t(e,r,n,i){return Zd().w(function(t){for(;;)switch(t.p=t.n){case 0:if(!("signTaprootInput"in e)){t.n=5;break}return t.p=1,t.n=2,e.signTaprootInput(r,n,i);case 2:t.n=4;break;case 3:throw t.p=3,t.v,new Error("Failed to sign Taproot input with provided signer.");case 4:t.n=6;break;case 5:r.signTaprootInput(n,e);case 6:return t.a(2)}},t,null,[[1,3]])})),function(t,e,n,i){return r.apply(this,arguments)})},{key:"signNonTaprootInput",value:(e=$d(Zd().m(function t(e,r,n){return Zd().w(function(t){for(;;)switch(t.n){case 0:if(!("signInput"in e)){t.n=2;break}return t.n=1,e.signInput(r,n);case 1:t.n=3;break;case 2:r.signInput(n,e);case 3:return t.a(2)}},t)})),function(t,r,n){return e.apply(this,arguments)})}],[{key:"readScriptWitnessToWitnessStack",value:function(t){var e=0;function r(){var r=_.decode(t,e);return e+=r.bytes,r.numberValue||0}function n(){return function(r){var n=t.subarray(e,e+r);return e+=r,n}(r())}return function(){for(var t=r(),e=[],i=0;i<t;i++)e.push(n());return e}()}},{key:"preEstimateTaprootTransactionFees",value:function(t,e,r,n,i,o){var a=10n+41n*e+68n*r;return(3n*a+(a+(1n*e+n*i+(arguments.length>6&&void 0!==arguments[6]?arguments[6]:32n)*e+(arguments.length>7&&void 0!==arguments[7]?arguments[7]:139n)*e+o)))/4n*t}},{key:"signInput",value:function(t,e,r,n,i){i&&i[0]&&(e.sighashType=i[0]),t.signInput(r,n,i.length?i:void 0)}},{key:"calculateSignHash",value:function(t){if(!t)throw new Error("Sighash types are required");var e,r=0,n=Jd(t);try{for(n.s();!(e=n.n()).done;)r|=e.value}catch(t){n.e(t)}finally{n.f()}return r||0}}]);var e,r,n,i,o,a,s}(),cy=i(8287).Buffer;function fy(t){return fy="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},fy(t)}function ly(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function hy(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?ly(Object(r),!0).forEach(function(e){Ty(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):ly(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function py(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=dy(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}function dy(t,e){if(t){if("string"==typeof t)return yy(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?yy(t,e):void 0}}function yy(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function by(t){if(null!=t){var e=t["function"==typeof Symbol&&Symbol.iterator||"@@iterator"],r=0;if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length))return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}}}throw new TypeError(fy(t)+" is not iterable")}function gy(){var t,e,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",i=r.toStringTag||"@@toStringTag";function o(r,n,i,o){var u=n&&n.prototype instanceof s?n:s,c=Object.create(u.prototype);return vy(c,"_invoke",function(r,n,i){var o,s,u,c=0,f=i||[],l=!1,h={p:0,n:0,v:t,a:p,f:p.bind(t,4),d:function(e,r){return o=e,s=0,u=t,h.n=r,a}};function p(r,n){for(s=r,u=n,e=0;!l&&c&&!i&&e<f.length;e++){var i,o=f[e],p=h.p,d=o[2];r>3?(i=d===n)&&(u=o[(s=o[4])?5:(s=3,3)],o[4]=o[5]=t):o[0]<=p&&((i=r<2&&p<o[1])?(s=0,h.v=n,h.n=o[1]):p<d&&(i=r<3||o[0]>n||n>d)&&(o[4]=r,o[5]=n,h.n=d,s=0))}if(i||r>1)return a;throw l=!0,n}return function(i,f,d){if(c>1)throw TypeError("Generator is already running");for(l&&1===f&&p(f,d),s=f,u=d;(e=s<2?t:u)||!l;){o||(s?s<3?(s>1&&(h.n=-1),p(s,u)):h.n=u:h.v=u);try{if(c=2,o){if(s||(i="next"),e=o[i]){if(!(e=e.call(o,u)))throw TypeError("iterator result is not an object");if(!e.done)return e;u=e.value,s<2&&(s=0)}else 1===s&&(e=o.return)&&e.call(o),s<2&&(u=TypeError("The iterator does not provide a '"+i+"' method"),s=1);o=t}else if((e=(l=h.n<0)?u:r.call(n,h))!==a)break}catch(e){o=t,s=1,u=e}finally{c=1}}return{value:e,done:l}}}(r,i,o),!0),c}var a={};function s(){}function u(){}function c(){}e=Object.getPrototypeOf;var f=[][n]?e(e([][n]())):(vy(e={},n,function(){return this}),e),l=c.prototype=s.prototype=Object.create(f);function h(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,c):(t.__proto__=c,vy(t,i,"GeneratorFunction")),t.prototype=Object.create(l),t}return u.prototype=c,vy(l,"constructor",c),vy(c,"constructor",u),u.displayName="GeneratorFunction",vy(c,i,"GeneratorFunction"),vy(l),vy(l,i,"Generator"),vy(l,n,function(){return this}),vy(l,"toString",function(){return"[object Generator]"}),(gy=function(){return{w:o,m:h}})()}function vy(t,e,r,n){var i=Object.defineProperty;try{i({},"",{})}catch(t){i=0}vy=function(t,e,r,n){function o(e,r){vy(t,e,function(t){return this._invoke(e,r,t)})}e?i?i(t,e,{value:r,enumerable:!n,configurable:!n,writable:!n}):t[e]=r:(o("next",0),o("throw",1),o("return",2))},vy(t,e,r,n)}function wy(t,e,r,n,i,o,a){try{var s=t[o](a),u=s.value}catch(t){return void r(t)}s.done?e(u):Promise.resolve(u).then(n,i)}function my(t){return function(){var e=this,r=arguments;return new Promise(function(n,i){var o=t.apply(e,r);function a(t){wy(o,n,i,a,s,"next",t)}function s(t){wy(o,n,i,a,s,"throw",t)}a(void 0)})}}function Sy(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Ay(n.key),n)}}function _y(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(_y=function(){return!!t})()}function Ey(){return Ey="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,r){var n=function(t,e){for(;!{}.hasOwnProperty.call(t,e)&&null!==(t=ky(t)););return t}(t,e);if(n){var i=Object.getOwnPropertyDescriptor(n,e);return i.get?i.get.call(arguments.length<3?t:r):i.value}},Ey.apply(null,arguments)}function ky(t){return ky=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},ky(t)}function Oy(t,e){return Oy=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Oy(t,e)}function Ty(t,e,r){return(e=Ay(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Ay(t){var e=function(t){if("object"!=fy(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=fy(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==fy(e)?e:e+""}ur(ca);var Iy=330n,Py=297n,xy=cy.from("51024e73","hex"),By=function(){function t(e){var r,n,i,o;if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),Ty(o=function(t,e,r){return e=ky(e),function(t,e){if(e&&("object"==fy(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,_y()?Reflect.construct(e,r||[],ky(t).constructor):e.apply(t,r))}(this,t,[e]),"logColor","#785def"),Ty(o,"debugFees",!1),Ty(o,"overflowFees",0n),Ty(o,"transactionFee",0n),Ty(o,"estimatedFees",0n),Ty(o,"updateInputs",[]),Ty(o,"outputs",[]),Ty(o,"feeOutput",null),Ty(o,"_maximumFeeRate",1e8),Ty(o,"optionalOutputsAdded",!1),e.estimatedFees&&(o.estimatedFees=e.estimatedFees),o.signer=e.signer,o.network=e.network,o.feeRate=e.feeRate,o.priorityFee=null!==(r=e.priorityFee)&&void 0!==r?r:0n,o.gasSatFee=null!==(n=e.gasSatFee)&&void 0!==n?n:0n,o.utxos=e.utxos,o.optionalInputs=e.optionalInputs||[],o.to=e.to||void 0,o.debugFees=e.debugFees||!1,e.note&&("string"==typeof e.note?o.note=cy.from(e.note,"utf8"):o.note=e.note),o.anchor=null!==(i=e.anchor)&&void 0!==i&&i,o.isPubKeyDestination=!!o.to&&vl.isValidPublicKey(o.to,o.network),o.optionalOutputs=e.optionalOutputs,o.from=t.getFrom(e.from,o.signer,o.network),o.totalInputAmount=o.calculateTotalUTXOAmount(),o.calculateTotalVOutAmount()<o.totalInputAmount)throw new Error("Vout value is less than the value to send");return o.transaction=new Ao({network:o.network,version:o.txVersion}),o}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Oy(t,e)}(t,uy),function(t,e,r){return e&&Sy(t.prototype,e),r&&Sy(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"addOPReturn",value:function(t){var e=w.compile([it.OP_RETURN,t]);this.addOutput({value:0,script:e})}},{key:"addAnchor",value:function(){this.addOutput({value:0,script:xy})}},{key:"getFundingTransactionParameters",value:(c=my(gy().m(function t(){var e,r;return gy().w(function(t){for(;;)switch(t.n){case 0:if(this.estimatedFees){t.n=2;break}return t.n=1,this.estimateTransactionFees();case 1:this.estimatedFees=t.v;case 2:return t.a(2,{utxos:this.utxos,to:this.getScriptAddress(),signer:this.signer,network:this.network,feeRate:this.feeRate,priorityFee:null!==(e=this.priorityFee)&&void 0!==e?e:0n,gasSatFee:null!==(r=this.gasSatFee)&&void 0!==r?r:0n,from:this.from,amount:this.estimatedFees,optionalOutputs:this.optionalOutputs,optionalInputs:this.optionalInputs})}},t,this)})),function(){return c.apply(this,arguments)})},{key:"setDestinationAddress",value:function(t){this.to=t}},{key:"setMaximumFeeRate",value:function(t){this._maximumFeeRate=t}},{key:"signTransaction",value:(u=my(gy().m(function t(){return gy().w(function(t){for(;;)switch(t.n){case 0:if(this.utxos.length){t.n=1;break}throw new Error("No UTXOs specified");case 1:if(!this.to||this.isPubKeyDestination||bf.verifyContractAddress(this.to,this.network)){t.n=2;break}throw new Error("Invalid contract address. The contract address must be a taproot address.");case 2:if(!this.signed){t.n=3;break}throw new Error("Transaction is already signed");case 3:return this.signed=!0,t.n=4,this.buildTransaction();case 4:return t.n=5,this.internalBuildTransaction(this.transaction);case 5:if(!t.v){t.n=7;break}if(!this.regenerated){t.n=6;break}throw new Error("Transaction was regenerated");case 6:return t.a(2,this.transaction.extractTransaction(!0,!0));case 7:throw new Error("Could not sign transaction");case 8:return t.a(2)}},t,this)})),function(){return u.apply(this,arguments)})},{key:"generateTransactionMinimalSignatures",value:(s=my(gy().m(function t(){var e,r,n,i,o=arguments;return gy().w(function(t){for(;;)switch(t.n){case 0:if(e=o.length>0&&void 0!==o[0]&&o[0],!this.to||this.isPubKeyDestination||bf.verifyContractAddress(this.to,this.network)){t.n=1;break}throw new Error("Invalid contract address. The contract address must be a taproot address.");case 1:return t.n=2,this.buildTransaction();case 2:if(0===this.transaction.data.inputs.length){for(r=this.getInputs(),n=this.getOutputs(),this.transaction.setMaximumFeeRate(this._maximumFeeRate),this.transaction.addInputs(r,e),i=0;i<this.updateInputs.length;i++)this.transaction.updateInput(i,this.updateInputs[i]);this.transaction.addOutputs(n)}case 3:return t.a(2)}},t,this)})),function(){return s.apply(this,arguments)})},{key:"signPSBT",value:(a=my(gy().m(function t(){return gy().w(function(t){for(;;)switch(t.n){case 0:return t.n=1,this.signTransaction();case 1:if(!t.v){t.n=2;break}return t.a(2,this.transaction);case 2:throw new Error("Could not sign transaction");case 3:return t.a(2)}},t,this)})),function(){return a.apply(this,arguments)})},{key:"addInput",value:function(t){this.inputs.push(t)}},{key:"addOutput",value:function(e){var r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(0===e.value){var n=e;if(!n.script||0===n.script.length)throw new Error("Output value is 0 and no script provided");if(n.script.length<2)throw new Error("Output script is too short");if(n.script[0]!==it.OP_RETURN&&!n.script.equals(xy))throw new Error("Output script must start with OP_RETURN or be an ANCHOR when value is 0")}else if(!r&&e.value<t.MINIMUM_DUST)throw new Error("Output value is less than the minimum dust ".concat(e.value," < ").concat(t.MINIMUM_DUST));this.outputs.push(e)}},{key:"getTotalOutputValue",value:function(){return this.outputs.reduce(function(t,e){return t+BigInt(e.value)},0n)}},{key:"toAddress",value:function(){return this.to}},{key:"address",value:function(){var t;return null===(t=this.tapData)||void 0===t?void 0:t.address}},{key:"estimateTransactionFees",value:(o=my(gy().m(function e(){var r,n,i,o,a,s,u,c,f,l,h,p,d,y,b=this;return gy().w(function(e){for(;;)switch(e.p=e.n){case 0:return e.n=1,Promise.resolve();case 1:r=new Ao({network:this.network}),n=this.getInputs(),i=this.getOutputs(),r.addInputs(n),r.addOutputs(i),o=cy.alloc(64,0),a=cy.alloc(72,0),s=cy.alloc(33,2),u=function(e,r){var n,i;if(r.isPayToAnchor||b.anchorInputIndices.has(e))return{finalScriptSig:void 0,finalScriptWitness:cy.from([0])};if(r.witnessScript&&pl.isP2WDAWitnessScript(r.witnessScript)){for(var u=[],c=0;c<10;c++)u.push(cy.alloc(0));var f=cy.alloc(72,0);return{finalScriptWitness:t.witnessStackToScriptWitness([].concat(u,[f,r.witnessScript]))}}if(0===e&&b.tapLeafScript){var l=cy.alloc(32,0),h=b.tapLeafScript.script,p=cy.alloc(65,0);return{finalScriptWitness:t.witnessStackToScriptWitness([l,o,o,h,p])}}if(!r.witnessUtxo&&r.nonWitnessUtxo)return{finalScriptSig:sa.script.compile([a,s]),finalScriptWitness:void 0};if(r.witnessScript){if(b.csvInputIndices.has(e))return{finalScriptWitness:t.witnessStackToScriptWitness([a,r.witnessScript])};if(r.redeemScript){var d=[a,r.witnessScript];return{finalScriptSig:r.redeemScript,finalScriptWitness:t.witnessStackToScriptWitness(d)}}var y=sa.script.decompile(r.witnessScript);if(y&&y.length>=4){var g=y[0],v=y[y.length-1];if("number"==typeof g&&g>=it.OP_1&&v===it.OP_CHECKMULTISIG){for(var w=g-it.OP_1+1,m=[],S=0;S<w;S++)m.push(a);return{finalScriptWitness:t.witnessStackToScriptWitness([cy.alloc(0)].concat(m,[r.witnessScript]))}}}return{finalScriptWitness:t.witnessStackToScriptWitness([a,r.witnessScript])}}if(r.redeemScript){var _=sa.script.decompile(r.redeemScript);if(_&&2===_.length&&_[0]===it.OP_0&&cy.isBuffer(_[1])&&20===_[1].length)return{finalScriptSig:r.redeemScript,finalScriptWitness:t.witnessStackToScriptWitness([a,s])}}if(r.redeemScript&&!r.witnessScript&&!r.witnessUtxo)return{finalScriptSig:sa.script.compile([a,r.redeemScript]),finalScriptWitness:void 0};var E=null===(n=r.witnessUtxo)||void 0===n?void 0:n.script;return E?r.tapInternalKey?{finalScriptWitness:t.witnessStackToScriptWitness([o])}:22===E.length&&E[0]===it.OP_0||22===(null===(i=r.redeemScript)||void 0===i?void 0:i.length)&&r.redeemScript[0]===it.OP_0?{finalScriptWitness:t.witnessStackToScriptWitness([a,s])}:Ko(e,r,E,!0,!!r.redeemScript,!!r.witnessScript):{finalScriptSig:void 0,finalScriptWitness:void 0}},e.p=2,c=gy().m(function t(){var e;return gy().w(function(t){for(;;)switch(t.n){case 0:(e=n[f])&&r.finalizeInput(f,function(t){return u(t,e)});case 1:return t.a(2)}},t)}),f=0;case 3:if(!(f<r.data.inputs.length)){e.n=5;break}return e.d(by(c()),4);case 4:f++,e.n=3;break;case 5:e.n=7;break;case 6:e.p=6,y=e.v,this.warn("Could not finalize dummy tx: ".concat(y.message));case 7:return l=r.extractTransaction(!0,!0),h=l.virtualSize(),p=this.feeRate*h,d=BigInt(Math.ceil(p)),this.debugFees&&this.log("Estimating fees: feeRate=".concat(this.feeRate,", accurate_vSize=").concat(h,", fee=").concat(d,"n")),e.a(2,d)}},e,this,[[2,6]])})),function(){return o.apply(this,arguments)})},{key:"rebuildFromBase64",value:(i=my(gy().m(function t(e){return gy().w(function(t){for(;;)switch(t.n){case 0:return this.transaction=Ao.fromBase64(e,{network:this.network,version:this.txVersion}),this.signed=!1,this.sighashTypes=[hi.SIGHASH_ANYONECANPAY,hi.SIGHASH_ALL],t.n=1,this.signPSBT();case 1:return t.a(2,t.v)}},t,this)})),function(t){return i.apply(this,arguments)})},{key:"setPSBT",value:function(t){this.transaction=t}},{key:"getInputs",value:function(){return this.inputs}},{key:"getOutputs",value:function(){var t=function(t){return function(t){if(Array.isArray(t))return yy(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||dy(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}(this.outputs);return this.feeOutput&&t.push(this.feeOutput),t}},{key:"getOptionalOutputValue",value:function(){if(!this.optionalOutputs)return 0n;for(var t=0n,e=0;e<this.optionalOutputs.length;e++)t+=BigInt(this.optionalOutputs[e].value);return t}},{key:"addRefundOutput",value:(n=my(gy().m(function e(r){var n,i,o,a,s,u,c;return gy().w(function(e){for(;;)switch(e.n){case 0:this.note&&this.addOPReturn(this.note),this.anchor&&this.addAnchor(),n=-1n,i=0n,o=0,a=5;case 1:if(!(o<a&&i!==n)){e.n=6;break}return n=i,e.n=2,this.estimateTransactionFees();case 2:if(i=e.v,s=r+i,u=this.totalInputAmount-s,this.debugFees&&this.log("Iteration ".concat(o+1,": inputAmount=").concat(this.totalInputAmount,", totalSpent=").concat(s,", sendBackAmount=").concat(u)),!(u>=t.MINIMUM_DUST)){e.n=3;break}vl.isValidP2TRAddress(this.from,this.network)?this.feeOutput={value:Number(u),address:this.from,tapInternalKey:this.internalPubKeyToXOnly()}:vl.isValidPublicKey(this.from,this.network)?(c=w.compile([cy.from(this.from.replace("0x",""),"hex"),it.OP_CHECKSIG]),this.feeOutput={value:Number(u),script:c}):this.feeOutput={value:Number(u),address:this.from},this.overflowFees=u,e.n=5;break;case 3:if(this.feeOutput=null,this.overflowFees=0n,!(u<0n)){e.n=4;break}throw new Error("Insufficient funds: need ".concat(s," sats but only have ").concat(this.totalInputAmount," sats"));case 4:this.debugFees&&this.warn("Amount to send back (".concat(u," sat) is less than minimum dust..."));case 5:o++,e.n=1;break;case 6:o>=a&&this.warn("Fee calculation did not stabilize after ".concat(a," iterations")),this.transactionFee=i,this.debugFees&&this.log("Final fee: ".concat(i," sats, Change output: ").concat(this.feeOutput?"".concat(this.feeOutput.value," sats"):"none"));case 7:return e.a(2)}},e,this)})),function(t){return n.apply(this,arguments)})},{key:"addValueToToOutput",value:function(e){if(e<t.MINIMUM_DUST)throw new Error("Value to send is less than the minimum dust ".concat(e," < ").concat(t.MINIMUM_DUST));var r,n=py(this.outputs);try{for(n.s();!(r=n.n()).done;){var i=r.value;if("address"in i&&i.address===this.to)return void(i.value+=Number(e))}}catch(t){n.e(t)}finally{n.f()}throw new Error("Output not found")}},{key:"getTransactionOPNetFee",value:function(){var e=this.priorityFee+this.gasSatFee;return e>t.MINIMUM_DUST?e:t.MINIMUM_DUST}},{key:"calculateTotalUTXOAmount",value:function(){var t,e=0n,r=py(this.utxos);try{for(r.s();!(t=r.n()).done;)e+=t.value.value}catch(t){r.e(t)}finally{r.f()}var n,i=py(this.optionalInputs);try{for(i.s();!(n=i.n()).done;)e+=n.value.value}catch(t){i.e(t)}finally{i.f()}return e}},{key:"calculateTotalVOutAmount",value:function(){var t,e=0n,r=py(this.utxos);try{for(r.s();!(t=r.n()).done;)e+=t.value.value}catch(t){r.e(t)}finally{r.f()}var n,i=py(this.optionalInputs);try{for(i.s();!(n=i.n()).done;)e+=n.value.value}catch(t){i.e(t)}finally{i.f()}return e}},{key:"addOptionalOutputsAndGetAmount",value:function(){if(!this.optionalOutputs||this.optionalOutputsAdded)return 0n;for(var t=0n,e=0;e<this.optionalOutputs.length;e++)this.addOutput(this.optionalOutputs[e]),t+=BigInt(this.optionalOutputs[e].value);return this.optionalOutputsAdded=!0,t}},{key:"addInputsFromUTXO",value:function(){if(this.utxos.length){if(this.totalInputAmount<t.MINIMUM_DUST)throw new Error("Total input amount is ".concat(this.totalInputAmount," sat which is less than the minimum dust ").concat(t.MINIMUM_DUST," sat."));for(var e=0;e<this.utxos.length;e++){var r=this.utxos[e],n=this.generatePsbtInputExtended(r,e);this.addInput(n)}}if(this.optionalInputs)for(var i=this.utxos.length;i<this.optionalInputs.length+this.utxos.length;i++){var o=this.optionalInputs[i-this.utxos.length],a=this.generatePsbtInputExtended(o,i,!0);this.addInput(a)}}},{key:"internalInit",value:function(){this.verifyUTXOValidity(),function(t,e,r){var n=Ey(ky(t.prototype),"internalInit",r);return"function"==typeof n?function(t){return n.apply(r,t)}:n}(t,0,this)([])}},{key:"updateInput",value:function(t){this.updateInputs.push(t)}},{key:"addFeeToOutput",value:function(t,e,r,n){if(n){var i;i=t>Iy+Py?Py:t,this.addOutput({value:Number(i),address:e},!0),i===Py&&t-Py>Iy&&this.addOutput({value:Number(t-i),address:r.address},!0)}else{var o=t<Iy?Iy:t;this.addOutput({value:Number(o),address:r.address},!0)}}},{key:"getWitness",value:function(){if(!this.tapData||!this.tapData.witness)throw new Error("Witness is required");if(0===this.tapData.witness.length)throw new Error("Witness is empty");return this.tapData.witness[this.tapData.witness.length-1]}},{key:"getTapOutput",value:function(){if(!this.tapData||!this.tapData.output)throw new Error("Tap data is required");return this.tapData.output}},{key:"verifyUTXOValidity",value:function(){var t,e=py(this.utxos);try{for(e.s();!(t=e.n()).done;)if(!t.value.scriptPubKey)throw new Error("Address is required")}catch(t){e.e(t)}finally{e.f()}var r,n=py(this.optionalInputs);try{for(n.s();!(r=n.n()).done;)if(!r.value.scriptPubKey)throw new Error("Address is required")}catch(t){n.e(t)}finally{n.f()}}},{key:"setFeeOutput",value:(r=my(gy().m(function e(r){var n,i,o,a,s,u;return gy().w(function(e){for(;;)switch(e.n){case 0:n=r.value,this.feeOutput=null,i=0n,o=-1n,this.log("setFeeOutput: Starting fee calculation for change. Initial available value: ".concat(n," sats.")),a=0;case 1:if(!(a<3&&i!==o)){e.n=6;break}return o=i,e.n=2,this.estimateTransactionFees();case 2:if(i=e.v,s=BigInt(n)-i,this.debugFees&&this.log(" -> Iteration ".concat(a+1,": Estimated fee is ").concat(i," sats. Value left for change: ").concat(s," sats.")),!(s>=t.MINIMUM_DUST)){e.n=3;break}this.feeOutput=hy(hy({},r),{},{value:Number(s)}),this.overflowFees=s,e.n=5;break;case 3:return this.feeOutput=null,this.overflowFees=0n,e.n=4,this.estimateTransactionFees();case 4:i=e.v,this.debugFees&&this.log(" -> Change is less than dust. Final fee without change output: ".concat(i," sats."));case 5:a++,e.n=1;break;case 6:if(!((u=BigInt(n)-i)<0)){e.n=7;break}throw new Error("setFeeOutput: Insufficient funds to pay the fees. Required fee: ".concat(i,", Available: ").concat(n,". Total input: ").concat(this.totalInputAmount," sat"));case 7:u>=t.MINIMUM_DUST?(this.feeOutput=hy(hy({},r),{},{value:Number(u)}),this.overflowFees=u,this.debugFees&&this.log("setFeeOutput: Final change output set to ".concat(u," sats. Final fee: ").concat(i," sats."))):(this.warn("Amount to send back (".concat(u," sat) is less than the minimum dust (").concat(t.MINIMUM_DUST," sat), it will be consumed in fees instead.")),this.feeOutput=null,this.overflowFees=0n);case 8:return e.a(2)}},e,this)})),function(t){return r.apply(this,arguments)})},{key:"internalBuildTransaction",value:(e=my(gy().m(function t(e){var r,n,i,o,a,s,u=arguments;return gy().w(function(t){for(;;)switch(t.p=t.n){case 0:if(r=u.length>1&&void 0!==u[1]&&u[1],0===e.data.inputs.length){for(n=this.getInputs(),i=this.getOutputs(),e.setMaximumFeeRate(this._maximumFeeRate),e.addInputs(n,r),o=0;o<this.updateInputs.length;o++)e.updateInput(o,this.updateInputs[o]);e.addOutputs(i)}return t.p=1,t.n=2,this.signInputs(e);case 2:return this.finalized&&(this.transactionFee=BigInt(e.getFee())),t.a(2,!0);case 3:return t.p=3,s=t.v,a=s,this.error("[internalBuildTransaction] Something went wrong while getting building the transaction: ".concat(a.stack)),t.a(2,!1)}},t,this,[[1,3]])})),function(t){return e.apply(this,arguments)})}],[{key:"getFrom",value:function(t,e,r){return t||bf.getTaprootAddress(e,r)}},{key:"witnessStackToScriptWitness",value:function(t){var e,r=cy.allocUnsafe(0);function n(t){var e=r.length,n=_.encodingLength(t);r=cy.concat([r,cy.allocUnsafe(n)]),_.encode(t,r,e)}return n((e=t).length),e.forEach(function(t){n(t.length),function(t){r=cy.concat([r,cy.from(t)])}(t)}),r}}]);var e,r,n,i,o,a,s,u,c}();Ty(By,"LOCK_LEAF_SCRIPT",w.compile([it.OP_FALSE,it.OP_VERIFY])),Ty(By,"MINIMUM_DUST",330n);var Ry=i(8287).Buffer;function Uy(t){return Uy="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Uy(t)}function jy(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Ny(n.key),n)}}function Ny(t){var e=function(t){if("object"!=Uy(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Uy(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Uy(e)?e:e+""}var Ly=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)}return function(t,e,r){return r&&jy(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,0,[{key:"getContractAddress",value:function(e){var r=e.network||b.bitcoin,n=[{output:new Jh(e.deployerPubKey,bi(e.contractSaltPubKey),r).compile(e.bytecode,e.originalSalt,e.challenge,e.priorityFee,e.calldata,e.features),version:t.TAP_SCRIPT_VERSION},{output:By.LOCK_LEAF_SCRIPT,version:t.TAP_SCRIPT_VERSION}];return t.generateAddressFromScript(e,n)}},{key:"verifyControlBlock",value:function(e,r){var n=e.network||b.bitcoin,i=new Jh(e.deployerPubKey,bi(e.contractSaltPubKey),n).compile(e.bytecode,e.originalSalt,e.challenge,e.priorityFee,e.calldata,e.features),o=[{output:i,version:t.TAP_SCRIPT_VERSION},{output:By.LOCK_LEAF_SCRIPT,version:t.TAP_SCRIPT_VERSION}],a=k.p2tr({internalPubkey:bi(e.deployerPubKey),network:n,scriptTree:o,redeem:{output:i,redeemVersion:t.TAP_SCRIPT_VERSION}}).witness;return!(!a||0===a.length)&&a[a.length-1].equals(r)}},{key:"getContractSeed",value:function(t,e,r){var n=S.hash256(e),i=Ry.concat([t,r,n]);return S.hash256(i)}},{key:"generateAddressFromScript",value:function(t,e){var r=t.network||b.bitcoin,n={internalPubkey:bi(t.deployerPubKey),network:r,scriptTree:e};return k.p2tr(n).address}}])}();!function(t,e){(e=Ny(e))in t?Object.defineProperty(t,e,{value:192,enumerable:!0,configurable:!0,writable:!0}):t[e]=192}(Ly,"TAP_SCRIPT_VERSION");var Cy=i(8287).Buffer;function Fy(t){return Fy="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Fy(t)}function Dy(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Hy(n.key),n)}}function Hy(t){var e=function(t){if("object"!=Fy(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Fy(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Fy(e)?e:e+""}var My=function(){return function(t,e){return e&&Dy(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}(function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)},[{key:"sha256",value:function(t){return S.sha256(Cy.from(t))}},{key:"tweakAndSignMessage",value:function(t,e,r){var n=Vd.tweakSigner(t,{network:r});return this.signMessage(n,e)}},{key:"signMessage",value:function(t,e){if("string"==typeof e&&(e=Cy.from(e,"utf-8")),!t.privateKey)throw new Error("Private key not found in keypair.");var r=this.sha256(e);return{signature:ua.signSchnorr(r,t.privateKey),message:r}}},{key:"verifySignature",value:function(t,e,r){if("string"==typeof e&&(e=Cy.from(e,"utf-8")),64!==r.length)throw new Error("Invalid signature length.");var n=this.sha256(e);return ua.verifySchnorr(n,bi(Cy.from(t)),r)}},{key:"tweakAndVerifySignature",value:function(t,e,r){var n=bf.tweakPublicKey(Cy.from(t));return this.verifySignature(n,e,r)}}])}(),Ky=new My,Vy=i(8287).Buffer;function Wy(t){return Wy="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Wy(t)}function Gy(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,qy(n.key),n)}}function qy(t){var e=function(t){if("object"!=Wy(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Wy(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Wy(e)?e:e+""}var zy=function(){function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:b.bitcoin;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.network=r;var n=e.startsWith("0x")?e.replace("0x",""):e;sl.isValidHex(n)?this._keypair=bf.fromPrivateKey(Vy.from(n,"hex"),this.network):this._keypair=bf.fromWIF(n,this.network),this._bufferPubKey=this._keypair.publicKey,this._address=new ih(this._keypair.publicKey),this._p2tr=this._address.p2tr(this.network),this._p2wpkh=this._address.p2wpkh(this.network),this._legacy=this._address.p2pkh(this.network),this._segwitLegacy=this._address.p2wpkh(this.network),this._p2wda=this._address.p2wda(this.network),this._tweakedKey=this._address.toBuffer()}return function(t,e,r){return e&&Gy(t.prototype,e),r&&Gy(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"address",get:function(){return this._address}},{key:"tweakedPubKeyKey",get:function(){return this._tweakedKey}},{key:"keypair",get:function(){if(!this._keypair)throw new Error("Keypair not set");return this._keypair}},{key:"p2wpkh",get:function(){return this._p2wpkh}},{key:"p2tr",get:function(){return this._p2tr}},{key:"p2wda",get:function(){return this._p2wda}},{key:"legacy",get:function(){return this._legacy}},{key:"addresses",get:function(){return[this.p2wpkh,this.p2tr,this.legacy,this.segwitLegacy]}},{key:"segwitLegacy",get:function(){return this._segwitLegacy}},{key:"publicKey",get:function(){if(!this._bufferPubKey)throw new Error("Public key not set");return this._bufferPubKey}},{key:"xOnly",get:function(){if(!this.keypair)throw new Error("Keypair not set");return bi(this._bufferPubKey)}}],[{key:"fromWif",value:function(e){return new t(e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:b.bitcoin)}},{key:"new",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:b.bitcoin;return new t(bf.generateWallet(e).privateKey,e)}}])}();function Zy(t){return Zy="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Zy(t)}function Xy(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Yy(n.key),n)}}function Yy(t){var e=function(t){if("object"!=Zy(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Zy(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Zy(e)?e:e+""}var $y,Jy,Qy,tb=function(){return function(t,e,r){return e&&Xy(t.prototype,e),r&&Xy(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:b.bitcoin;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.network=e},[{key:"getAddress",value:function(){return this.address}}],[{key:"getAddress",value:function(){throw new Error("Method not implemented.")}}])}();!function(t){t[t.Bitcoin=0]="Bitcoin",t[t.Fractal=1]="Fractal"}($y||($y={})),function(t){t[t.GENERIC=0]="GENERIC",t[t.FUNDING=1]="FUNDING",t[t.DEPLOYMENT=2]="DEPLOYMENT",t[t.INTERACTION=3]="INTERACTION",t[t.MULTI_SIG=4]="MULTI_SIG",t[t.CUSTOM_CODE=5]="CUSTOM_CODE",t[t.CHALLENGE_SOLUTION=6]="CHALLENGE_SOLUTION"}(Jy||(Jy={})),function(t){t[t.Roswell=0]="Roswell",t[t.Rachel=1]="Rachel",t[t.Kecksburg=2]="Kecksburg",t[t.Phoenix=3]="Phoenix",t[t.Aurora=4]="Aurora",t[t.Rendlesham=5]="Rendlesham",t[t.Lazar=6]="Lazar",t[t.ShagHarbor=7]="ShagHarbor",t[t.Exeter=8]="Exeter",t[t.Stephenville=9]="Stephenville",t[t.Valensole=10]="Valensole",t[t.Socorro=11]="Socorro",t[t.Pascagoula=12]="Pascagoula",t[t.Tehran=13]="Tehran",t[t.Westall=14]="Westall",t[t.Hopkinsville=15]="Hopkinsville",t[t.Belgium=16]="Belgium",t[t.Breeze=17]="Breeze",t[t.Flatwoods=18]="Flatwoods",t[t.Maury=20]="Maury",t[t.Varginha=21]="Varginha",t[t.Trindade=22]="Trindade",t[t.Levelland=23]="Levelland",t[t.Wanaque=24]="Wanaque",t[t.Coyame=25]="Coyame",t[t.Delphos=26]="Delphos"}(Qy||(Qy={}));var eb={CONSENSUS:Qy.Roswell,CONSENSUS_NAME:"Roswell",ENABLED_AT_BLOCK:0n};function rb(t){return rb="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},rb(t)}var nb=function(t,e,r){return(e=function(t){var e=function(t){if("object"!=rb(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=rb(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==rb(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}({},Qy.Roswell,eb),ib=Qy.Roswell,ob=nb[ib],ab=i(8287).Buffer;function sb(t){return sb="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},sb(t)}function ub(t,e){if(t){if("string"==typeof t)return cb(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?cb(t,e):void 0}}function cb(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function fb(){var t,e,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",i=r.toStringTag||"@@toStringTag";function o(r,n,i,o){var u=n&&n.prototype instanceof s?n:s,c=Object.create(u.prototype);return lb(c,"_invoke",function(r,n,i){var o,s,u,c=0,f=i||[],l=!1,h={p:0,n:0,v:t,a:p,f:p.bind(t,4),d:function(e,r){return o=e,s=0,u=t,h.n=r,a}};function p(r,n){for(s=r,u=n,e=0;!l&&c&&!i&&e<f.length;e++){var i,o=f[e],p=h.p,d=o[2];r>3?(i=d===n)&&(u=o[(s=o[4])?5:(s=3,3)],o[4]=o[5]=t):o[0]<=p&&((i=r<2&&p<o[1])?(s=0,h.v=n,h.n=o[1]):p<d&&(i=r<3||o[0]>n||n>d)&&(o[4]=r,o[5]=n,h.n=d,s=0))}if(i||r>1)return a;throw l=!0,n}return function(i,f,d){if(c>1)throw TypeError("Generator is already running");for(l&&1===f&&p(f,d),s=f,u=d;(e=s<2?t:u)||!l;){o||(s?s<3?(s>1&&(h.n=-1),p(s,u)):h.n=u:h.v=u);try{if(c=2,o){if(s||(i="next"),e=o[i]){if(!(e=e.call(o,u)))throw TypeError("iterator result is not an object");if(!e.done)return e;u=e.value,s<2&&(s=0)}else 1===s&&(e=o.return)&&e.call(o),s<2&&(u=TypeError("The iterator does not provide a '"+i+"' method"),s=1);o=t}else if((e=(l=h.n<0)?u:r.call(n,h))!==a)break}catch(e){o=t,s=1,u=e}finally{c=1}}return{value:e,done:l}}}(r,i,o),!0),c}var a={};function s(){}function u(){}function c(){}e=Object.getPrototypeOf;var f=[][n]?e(e([][n]())):(lb(e={},n,function(){return this}),e),l=c.prototype=s.prototype=Object.create(f);function h(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,c):(t.__proto__=c,lb(t,i,"GeneratorFunction")),t.prototype=Object.create(l),t}return u.prototype=c,lb(l,"constructor",c),lb(c,"constructor",u),u.displayName="GeneratorFunction",lb(c,i,"GeneratorFunction"),lb(l),lb(l,i,"Generator"),lb(l,n,function(){return this}),lb(l,"toString",function(){return"[object Generator]"}),(fb=function(){return{w:o,m:h}})()}function lb(t,e,r,n){var i=Object.defineProperty;try{i({},"",{})}catch(t){i=0}lb=function(t,e,r,n){function o(e,r){lb(t,e,function(t){return this._invoke(e,r,t)})}e?i?i(t,e,{value:r,enumerable:!n,configurable:!n,writable:!n}):t[e]=r:(o("next",0),o("throw",1),o("return",2))},lb(t,e,r,n)}function hb(t,e,r,n,i,o,a){try{var s=t[o](a),u=s.value}catch(t){return void r(t)}s.done?e(u):Promise.resolve(u).then(n,i)}function pb(t){return function(){var e=this,r=arguments;return new Promise(function(n,i){var o=t.apply(e,r);function a(t){hb(o,n,i,a,s,"next",t)}function s(t){hb(o,n,i,a,s,"throw",t)}a(void 0)})}}function db(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Sb(n.key),n)}}function yb(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(yb=function(){return!!t})()}function bb(t,e,r,n){var i=gb(vb(1&n?t.prototype:t),e,r);return 2&n&&"function"==typeof i?function(t){return i.apply(r,t)}:i}function gb(){return gb="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,r){var n=function(t,e){for(;!{}.hasOwnProperty.call(t,e)&&null!==(t=vb(t)););return t}(t,e);if(n){var i=Object.getOwnPropertyDescriptor(n,e);return i.get?i.get.call(arguments.length<3?t:r):i.value}},gb.apply(null,arguments)}function vb(t){return vb=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},vb(t)}function wb(t,e){return wb=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},wb(t,e)}function mb(t,e,r){return(e=Sb(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Sb(t){var e=function(t){if("object"!=sb(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=sb(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==sb(e)?e:e+""}var _b=function(){function t(e){var r;if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),mb(r=function(t,e,r){return e=vb(e),function(t,e){if(e&&("object"==sb(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,yb()?Reflect.construct(e,r||[],vb(t).constructor):e.apply(t,r))}(this,t,[e]),"type",Jy.CUSTOM_CODE),mb(r,"tapLeafScript",null),mb(r,"targetScriptRedeem",null),mb(r,"leftOverFundsScriptRedeem",null),mb(r,"customFinalizer",function(t,e){if(!r.tapLeafScript)throw new Error("Tap leaf script is required");var n=r.getScriptSolution(e).concat(r.tapLeafScript.script).concat(r.tapLeafScript.controlBlock);if(r.annexData&&r.annexData.length>0){var i=80===r.annexData[0]?r.annexData:ab.concat([ab.from([80]),r.annexData]);n.push(i)}return{finalScriptWitness:By.witnessStackToScriptWitness(n)}}),!e.script)throw new Error("Bitcoin script is required");if(!e.witnesses)throw new Error("Witness(es) are required");return r.witnesses=e.witnesses,r.randomBytes=e.randomBytes||sl.rndBytes(),r.scriptSeed=r.getContractSeed(),r.contractSigner=bf.fromSeedKeyPair(r.scriptSeed,r.network),r.generator=new Hh(r.internalPubKeyToXOnly(),r.network),r.compiledTargetScript=r.generator.compile(e.script),r.scriptTree=r.getScriptTree(),r.internalInit(),r._scriptAddress=xp.generatePKSH(r.scriptSeed,r.network),r}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&wb(t,e)}(t,By),function(t,e){return e&&db(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"scriptAddress",get:function(){return this._scriptAddress}},{key:"p2trAddress",get:function(){return this.to||this.getScriptAddress()}},{key:"getRndBytes",value:function(){return this.randomBytes}},{key:"contractSignerXOnlyPubKey",value:function(){return bi(ab.from(this.contractSigner.publicKey))}},{key:"buildTransaction",value:(r=pb(fb().m(function t(){var e,r;return fb().w(function(t){for(;;)switch(t.n){case 0:if(this.to||(this.to=this.getScriptAddress()),e=this.contractSigner?this.targetScriptRedeem:this.leftOverFundsScriptRedeem){t.n=1;break}throw new Error("Left over funds script redeem is required");case 1:if(e.redeemVersion){t.n=2;break}throw new Error("Left over funds script redeem version is required");case 2:if(e.output){t.n=3;break}throw new Error("Left over funds script redeem output is required");case 3:return this.tapLeafScript={leafVersion:e.redeemVersion,script:e.output,controlBlock:this.getWitness()},this.addInputsFromUTXO(),r=this.getTransactionOPNetFee(),this.addOutput({value:Number(r),address:this.to}),t.n=4,this.addRefundOutput(r+this.addOptionalOutputsAndGetAmount());case 4:return t.a(2)}},t,this)})),function(){return r.apply(this,arguments)})},{key:"signInputs",value:(e=pb(fb().m(function e(r){var n;return fb().w(function(e){for(;;)switch(e.n){case 0:if(this.contractSigner){e.n=2;break}return e.n=1,bb(t,"signInputs",this,3)([r]);case 1:return e.a(2);case 2:for(n=0;n<r.data.inputs.length;n++)if(0===n){try{r.signInput(0,this.contractSigner)}catch(t){}r.signInput(0,this.getSignerKey()),r.finalizeInput(0,this.customFinalizer)}else r.signInput(n,this.getSignerKey()),r.finalizeInput(n);case 3:return e.a(2)}},e,this)})),function(t){return e.apply(this,arguments)})},{key:"generateScriptAddress",value:function(){return{internalPubkey:this.internalPubKeyToXOnly(),network:this.network,scriptTree:this.scriptTree,name:Yi.P2TR}}},{key:"generateTapData",value:function(){var t=this.contractSigner?this.targetScriptRedeem:this.leftOverFundsScriptRedeem;if(!t)throw new Error("Left over funds script redeem is required");if(!this.scriptTree)throw new Error("Script tree is required");return{internalPubkey:this.internalPubKeyToXOnly(),network:this.network,scriptTree:this.scriptTree,redeem:t,name:Yi.P2TR}}},{key:"getScriptSolution",value:function(t){if(!t.tapScriptSig)throw new Error("Tap script signature is required");var e=function(t){return function(t){if(Array.isArray(t))return cb(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||ub(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}(this.witnesses);if(t.tapScriptSig){var r,n=function(t){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=ub(t))){e&&(t=e);var r=0,n=function(){};return{s:n,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:n}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,o=!0,a=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return o=t.done,t},e:function(t){a=!0,i=t},f:function(){try{o||null==e.return||e.return()}finally{if(a)throw i}}}}(t.tapScriptSig);try{for(n.s();!(r=n.n()).done;){var i=r.value;e.push(i.signature)}}catch(t){n.e(t)}finally{n.f()}}return e}},{key:"getContractSeed",value:function(){return S.hash256(this.randomBytes)}},{key:"getPubKeys",value:function(){var t=[ab.from(this.signer.publicKey)];return this.contractSigner&&t.push(ab.from(this.contractSigner.publicKey)),t}},{key:"generateRedeemScripts",value:function(){this.targetScriptRedeem={name:Yi.P2TR,output:this.compiledTargetScript,redeemVersion:192},this.leftOverFundsScriptRedeem={name:Yi.P2TR,output:this.getLeafScript(),redeemVersion:192}}},{key:"getLeafScript",value:function(){return By.LOCK_LEAF_SCRIPT}},{key:"getScriptTree",value:function(){return this.generateRedeemScripts(),[{output:this.compiledTargetScript,version:192},{output:this.getLeafScript(),version:192}]}}]);var e,r}(),Eb=i(8287).Buffer;function kb(t){return kb="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},kb(t)}function Ob(){var t,e,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",i=r.toStringTag||"@@toStringTag";function o(r,n,i,o){var u=n&&n.prototype instanceof s?n:s,c=Object.create(u.prototype);return Tb(c,"_invoke",function(r,n,i){var o,s,u,c=0,f=i||[],l=!1,h={p:0,n:0,v:t,a:p,f:p.bind(t,4),d:function(e,r){return o=e,s=0,u=t,h.n=r,a}};function p(r,n){for(s=r,u=n,e=0;!l&&c&&!i&&e<f.length;e++){var i,o=f[e],p=h.p,d=o[2];r>3?(i=d===n)&&(u=o[(s=o[4])?5:(s=3,3)],o[4]=o[5]=t):o[0]<=p&&((i=r<2&&p<o[1])?(s=0,h.v=n,h.n=o[1]):p<d&&(i=r<3||o[0]>n||n>d)&&(o[4]=r,o[5]=n,h.n=d,s=0))}if(i||r>1)return a;throw l=!0,n}return function(i,f,d){if(c>1)throw TypeError("Generator is already running");for(l&&1===f&&p(f,d),s=f,u=d;(e=s<2?t:u)||!l;){o||(s?s<3?(s>1&&(h.n=-1),p(s,u)):h.n=u:h.v=u);try{if(c=2,o){if(s||(i="next"),e=o[i]){if(!(e=e.call(o,u)))throw TypeError("iterator result is not an object");if(!e.done)return e;u=e.value,s<2&&(s=0)}else 1===s&&(e=o.return)&&e.call(o),s<2&&(u=TypeError("The iterator does not provide a '"+i+"' method"),s=1);o=t}else if((e=(l=h.n<0)?u:r.call(n,h))!==a)break}catch(e){o=t,s=1,u=e}finally{c=1}}return{value:e,done:l}}}(r,i,o),!0),c}var a={};function s(){}function u(){}function c(){}e=Object.getPrototypeOf;var f=[][n]?e(e([][n]())):(Tb(e={},n,function(){return this}),e),l=c.prototype=s.prototype=Object.create(f);function h(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,c):(t.__proto__=c,Tb(t,i,"GeneratorFunction")),t.prototype=Object.create(l),t}return u.prototype=c,Tb(l,"constructor",c),Tb(c,"constructor",u),u.displayName="GeneratorFunction",Tb(c,i,"GeneratorFunction"),Tb(l),Tb(l,i,"Generator"),Tb(l,n,function(){return this}),Tb(l,"toString",function(){return"[object Generator]"}),(Ob=function(){return{w:o,m:h}})()}function Tb(t,e,r,n){var i=Object.defineProperty;try{i({},"",{})}catch(t){i=0}Tb=function(t,e,r,n){function o(e,r){Tb(t,e,function(t){return this._invoke(e,r,t)})}e?i?i(t,e,{value:r,enumerable:!n,configurable:!n,writable:!n}):t[e]=r:(o("next",0),o("throw",1),o("return",2))},Tb(t,e,r,n)}function Ab(t,e,r,n,i,o,a){try{var s=t[o](a),u=s.value}catch(t){return void r(t)}s.done?e(u):Promise.resolve(u).then(n,i)}function Ib(t){return function(){var e=this,r=arguments;return new Promise(function(n,i){var o=t.apply(e,r);function a(t){Ab(o,n,i,a,s,"next",t)}function s(t){Ab(o,n,i,a,s,"throw",t)}a(void 0)})}}function Pb(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Lb(n.key),n)}}function xb(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(xb=function(){return!!t})()}function Bb(t,e,r,n){var i=Rb(Ub(1&n?t.prototype:t),e,r);return 2&n&&"function"==typeof i?function(t){return i.apply(r,t)}:i}function Rb(){return Rb="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,r){var n=function(t,e){for(;!{}.hasOwnProperty.call(t,e)&&null!==(t=Ub(t)););return t}(t,e);if(n){var i=Object.getOwnPropertyDescriptor(n,e);return i.get?i.get.call(arguments.length<3?t:r):i.value}},Rb.apply(null,arguments)}function Ub(t){return Ub=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Ub(t)}function jb(t,e){return jb=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},jb(t,e)}function Nb(t,e,r){return(e=Lb(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Lb(t){var e=function(t){if("object"!=kb(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=kb(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==kb(e)?e:e+""}var Cb=function(){function t(e){var r;if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),Nb(r=function(t,e,r){return e=Ub(e),function(t,e){if(e&&("object"==kb(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,xb()?Reflect.construct(e,r||[],Ub(t).constructor):e.apply(t,r))}(this,t,[e]),"targetScriptRedeem",null),Nb(r,"leftOverFundsScriptRedeem",null),Nb(r,"customFinalizer",function(t,e){if(!r.tapLeafScript)throw new Error("Tap leaf script is required");if(!r.contractSecret)throw new Error("Contract secret is required");var n=r.getScriptSolution(e).concat(r.tapLeafScript.script).concat(r.tapLeafScript.controlBlock);return{finalScriptWitness:By.witnessStackToScriptWitness(n)}}),!e.calldata)throw new Error("Calldata is required");if(!e.challenge)throw new Error("Challenge solution is required");return r.challenge=e.challenge,r.disableAutoRefund=e.disableAutoRefund||!1,r.epochChallenge=jl.generateTimeLockAddress(r.challenge.publicKey.originalPublicKeyBuffer(),r.network),r.calldata=h.compress(e.calldata),r.randomBytes=e.randomBytes||sl.rndBytes(),r.scriptSigner=r.generateKeyPairFromSeed(),r.calldataGenerator=new Uh(Eb.from(r.signer.publicKey),r.scriptSignerXOnlyPubKey(),r.network),r}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&jb(t,e)}(t,By),function(t,e){return e&&Pb(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"getContractSecret",value:function(){return this.contractSecret}},{key:"getRndBytes",value:function(){return this.randomBytes}},{key:"getChallenge",value:function(){return this.challenge}},{key:"scriptSignerXOnlyPubKey",value:function(){return bi(Eb.from(this.scriptSigner.publicKey))}},{key:"generateKeyPairFromSeed",value:function(){return bf.fromSeedKeyPair(this.randomBytes,this.network)}},{key:"buildTransaction",value:(o=Ib(Ob().m(function t(){var e;return Ob().w(function(t){for(;;)switch(t.n){case 0:if(e=this.scriptSigner?this.targetScriptRedeem:this.leftOverFundsScriptRedeem){t.n=1;break}throw new Error("Left over funds script redeem is required");case 1:if(e.redeemVersion){t.n=2;break}throw new Error("Left over funds script redeem version is required");case 2:if(e.output){t.n=3;break}throw new Error("Left over funds script redeem output is required");case 3:return this.tapLeafScript={leafVersion:e.redeemVersion,script:e.output,controlBlock:this.getWitness()},this.regenerated||this.addInputsFromUTXO(),t.n=4,this.createMineableRewardOutputs();case 4:return t.a(2)}},t,this)})),function(){return o.apply(this,arguments)})},{key:"signInputs",value:(i=Ib(Ob().m(function e(r){return Ob().w(function(e){for(;;)switch(e.n){case 0:if(this.scriptSigner){e.n=2;break}return e.n=1,Bb(t,"signInputs",this,3)([r]);case 1:case 5:return e.a(2);case 2:if(!("multiSignPsbt"in this.signer)){e.n=4;break}return e.n=3,this.signInputsWalletBased(r);case 3:e.n=5;break;case 4:return e.n=5,this.signInputsNonWalletBased(r)}},e,this)})),function(t){return i.apply(this,arguments)})},{key:"generateScriptAddress",value:function(){return{internalPubkey:this.internalPubKeyToXOnly(),network:this.network,scriptTree:this.scriptTree,name:Yi.P2TR}}},{key:"generateTapData",value:function(){var t=this.scriptSigner?this.targetScriptRedeem:this.leftOverFundsScriptRedeem;if(!t)throw new Error("Left over funds script redeem is required");if(!this.scriptTree)throw new Error("Script tree is required");return{internalPubkey:this.internalPubKeyToXOnly(),network:this.network,scriptTree:this.scriptTree,redeem:t,name:Yi.P2TR}}},{key:"getScriptSolution",value:function(t){if(!t.tapScriptSig)throw new Error("Tap script signature is required");return[this.contractSecret,t.tapScriptSig[0].signature,t.tapScriptSig[1].signature]}},{key:"getScriptTree",value:function(){if(!this.calldata)throw new Error("Calldata is required");return this.generateRedeemScripts(),[{output:this.compiledTargetScript,version:192},{output:t.LOCK_LEAF_SCRIPT,version:192}]}},{key:"signInputsWalletBased",value:(n=Ib(Ob().m(function t(e){var r,n;return Ob().w(function(t){for(;;)switch(t.n){case 0:return r=this.signer,t.n=1,this.signInput(e,e.data.inputs[0],0,this.scriptSigner);case 1:return t.n=2,r.multiSignPsbt([e]);case 2:for(n=0;n<e.data.inputs.length;n++)if(0===n)e.finalizeInput(n,this.customFinalizer.bind(this));else try{e.finalizeInput(n,this.customFinalizerP2SH.bind(this))}catch(t){e.finalizeInput(n)}case 3:return t.a(2)}},t,this)})),function(t){return n.apply(this,arguments)})},{key:"signInputsNonWalletBased",value:(r=Ib(Ob().m(function t(e){var r;return Ob().w(function(t){for(;;)switch(t.n){case 0:r=0;case 1:if(!(r<e.data.inputs.length)){t.n=7;break}if(0!==r){t.n=4;break}return t.n=2,this.signInput(e,e.data.inputs[r],r,this.scriptSigner);case 2:return t.n=3,this.signInput(e,e.data.inputs[r],r,this.getSignerKey());case 3:e.finalizeInput(0,this.customFinalizer.bind(this)),t.n=6;break;case 4:return t.n=5,this.signInput(e,e.data.inputs[r],r,this.signer);case 5:try{e.finalizeInput(r,this.customFinalizerP2SH.bind(this))}catch(t){e.finalizeInput(r)}case 6:r++,t.n=1;break;case 7:return t.a(2)}},t,this)})),function(t){return r.apply(this,arguments)})},{key:"createMineableRewardOutputs",value:(e=Ib(Ob().m(function t(){var e,r,n;return Ob().w(function(t){for(;;)switch(t.n){case 0:if(this.to){t.n=1;break}throw new Error("To address is required");case 1:if(e=this.getTransactionOPNetFee(),this.addFeeToOutput(e,this.to,this.epochChallenge,!1),r=e<Iy?Iy:e,n=this.addOptionalOutputsAndGetAmount(),this.disableAutoRefund){t.n=2;break}return t.n=2,this.addRefundOutput(r+n);case 2:return t.a(2)}},t,this)})),function(){return e.apply(this,arguments)})},{key:"getPubKeys",value:function(){var t=[Eb.from(this.signer.publicKey)];return this.scriptSigner&&t.push(Eb.from(this.scriptSigner.publicKey)),t}},{key:"generateRedeemScripts",value:function(){this.targetScriptRedeem={name:Yi.P2TR,output:this.compiledTargetScript,redeemVersion:192},this.leftOverFundsScriptRedeem={name:Yi.P2TR,output:t.LOCK_LEAF_SCRIPT,redeemVersion:192}}}]);var e,r,n,i,o}();Nb(Cb,"MAXIMUM_CALLDATA_SIZE",1048576);var Fb=i(8287).Buffer;function Db(t){return Db="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Db(t)}function Hb(){var t,e,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",i=r.toStringTag||"@@toStringTag";function o(r,n,i,o){var u=n&&n.prototype instanceof s?n:s,c=Object.create(u.prototype);return Mb(c,"_invoke",function(r,n,i){var o,s,u,c=0,f=i||[],l=!1,h={p:0,n:0,v:t,a:p,f:p.bind(t,4),d:function(e,r){return o=e,s=0,u=t,h.n=r,a}};function p(r,n){for(s=r,u=n,e=0;!l&&c&&!i&&e<f.length;e++){var i,o=f[e],p=h.p,d=o[2];r>3?(i=d===n)&&(u=o[(s=o[4])?5:(s=3,3)],o[4]=o[5]=t):o[0]<=p&&((i=r<2&&p<o[1])?(s=0,h.v=n,h.n=o[1]):p<d&&(i=r<3||o[0]>n||n>d)&&(o[4]=r,o[5]=n,h.n=d,s=0))}if(i||r>1)return a;throw l=!0,n}return function(i,f,d){if(c>1)throw TypeError("Generator is already running");for(l&&1===f&&p(f,d),s=f,u=d;(e=s<2?t:u)||!l;){o||(s?s<3?(s>1&&(h.n=-1),p(s,u)):h.n=u:h.v=u);try{if(c=2,o){if(s||(i="next"),e=o[i]){if(!(e=e.call(o,u)))throw TypeError("iterator result is not an object");if(!e.done)return e;u=e.value,s<2&&(s=0)}else 1===s&&(e=o.return)&&e.call(o),s<2&&(u=TypeError("The iterator does not provide a '"+i+"' method"),s=1);o=t}else if((e=(l=h.n<0)?u:r.call(n,h))!==a)break}catch(e){o=t,s=1,u=e}finally{c=1}}return{value:e,done:l}}}(r,i,o),!0),c}var a={};function s(){}function u(){}function c(){}e=Object.getPrototypeOf;var f=[][n]?e(e([][n]())):(Mb(e={},n,function(){return this}),e),l=c.prototype=s.prototype=Object.create(f);function h(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,c):(t.__proto__=c,Mb(t,i,"GeneratorFunction")),t.prototype=Object.create(l),t}return u.prototype=c,Mb(l,"constructor",c),Mb(c,"constructor",u),u.displayName="GeneratorFunction",Mb(c,i,"GeneratorFunction"),Mb(l),Mb(l,i,"Generator"),Mb(l,n,function(){return this}),Mb(l,"toString",function(){return"[object Generator]"}),(Hb=function(){return{w:o,m:h}})()}function Mb(t,e,r,n){var i=Object.defineProperty;try{i({},"",{})}catch(t){i=0}Mb=function(t,e,r,n){function o(e,r){Mb(t,e,function(t){return this._invoke(e,r,t)})}e?i?i(t,e,{value:r,enumerable:!n,configurable:!n,writable:!n}):t[e]=r:(o("next",0),o("throw",1),o("return",2))},Mb(t,e,r,n)}function Kb(t,e,r,n,i,o,a){try{var s=t[o](a),u=s.value}catch(t){return void r(t)}s.done?e(u):Promise.resolve(u).then(n,i)}function Vb(t){return function(){var e=this,r=arguments;return new Promise(function(n,i){var o=t.apply(e,r);function a(t){Kb(o,n,i,a,s,"next",t)}function s(t){Kb(o,n,i,a,s,"throw",t)}a(void 0)})}}function Wb(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,$b(n.key),n)}}function Gb(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(Gb=function(){return!!t})()}function qb(t,e,r,n){var i=zb(Zb(1&n?t.prototype:t),e,r);return 2&n&&"function"==typeof i?function(t){return i.apply(r,t)}:i}function zb(){return zb="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,r){var n=function(t,e){for(;!{}.hasOwnProperty.call(t,e)&&null!==(t=Zb(t)););return t}(t,e);if(n){var i=Object.getOwnPropertyDescriptor(n,e);return i.get?i.get.call(arguments.length<3?t:r):i.value}},zb.apply(null,arguments)}function Zb(t){return Zb=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Zb(t)}function Xb(t,e){return Xb=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Xb(t,e)}function Yb(t,e,r){return(e=$b(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function $b(t){var e=function(t){if("object"!=Db(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Db(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Db(e)?e:e+""}var Jb=function(){function t(e){var r;if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),Yb(r=function(t,e,r){return e=Zb(e),function(t,e){if(e&&("object"==Db(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,Gb()?Reflect.construct(e,r||[],Zb(t).constructor):e.apply(t,r))}(this,t,[e]),"type",Jy.DEPLOYMENT),Yb(r,"tapLeafScript",null),Yb(r,"deploymentVersion",0),Yb(r,"targetScriptRedeem",null),Yb(r,"leftOverFundsScriptRedeem",null),Yb(r,"customFinalizer",function(t,e){if(!r.tapLeafScript)throw new Error("Tap leaf script is required");if(!e.tapScriptSig)throw new Error("Tap script signature is required");var n=[r.randomBytes,e.tapScriptSig[0].signature,e.tapScriptSig[1].signature].concat(r.tapLeafScript.script).concat(r.tapLeafScript.controlBlock);return{finalScriptWitness:By.witnessStackToScriptWitness(n)}}),r.bytecode=h.compress(Fb.concat([$h,e.bytecode])),r.verifyBytecode(),e.calldata&&(r.calldata=e.calldata,r.verifyCalldata()),!e.challenge)throw new Error("Challenge solution is required");return r.randomBytes=e.randomBytes||sl.rndBytes(),r.challenge=e.challenge,r.epochChallenge=jl.generateTimeLockAddress(r.challenge.publicKey.originalPublicKeyBuffer(),r.network),r.contractSeed=r.getContractSeed(),r.contractSigner=bf.fromSeedKeyPair(r.contractSeed,r.network),r.deploymentGenerator=new Jh(Fb.from(r.signer.publicKey),r.contractSignerXOnlyPubKey(),r.network),r.compiledTargetScript=r.deploymentGenerator.compile(r.bytecode,r.randomBytes,r.challenge,r.priorityFee,r.calldata,r.generateFeatures(e)),r.scriptTree=r.getScriptTree(),r.internalInit(),r._contractPubKey="0x"+r.contractSeed.toString("hex"),r._contractAddress=new ih(r.contractSeed),r}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Xb(t,e)}(t,By),function(t,e){return e&&Wb(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"contractPubKey",get:function(){return this._contractPubKey}},{key:"contractAddress",get:function(){return this._contractAddress}},{key:"p2trAddress",get:function(){return this.to||this.getScriptAddress()}},{key:"getRndBytes",value:function(){return this.randomBytes}},{key:"getChallenge",value:function(){return this.challenge}},{key:"getContractAddress",value:function(){return this._computedAddress||(this._computedAddress=bf.p2op(this.contractSeed,this.network,this.deploymentVersion)),this._computedAddress}},{key:"contractSignerXOnlyPubKey",value:function(){return bi(Fb.from(this.contractSigner.publicKey))}},{key:"buildTransaction",value:(n=Vb(Hb().m(function t(){var e,r;return Hb().w(function(t){for(;;)switch(t.n){case 0:if(this.to||(this.to=this.getScriptAddress()),e=this.contractSigner?this.targetScriptRedeem:this.leftOverFundsScriptRedeem){t.n=1;break}throw new Error("Left over funds script redeem is required");case 1:if(e.redeemVersion){t.n=2;break}throw new Error("Left over funds script redeem version is required");case 2:if(e.output){t.n=3;break}throw new Error("Left over funds script redeem output is required");case 3:return this.tapLeafScript={leafVersion:e.redeemVersion,script:e.output,controlBlock:this.getWitness()},this.addInputsFromUTXO(),r=this.getTransactionOPNetFee(),this.addFeeToOutput(r,this.getContractAddress(),this.epochChallenge,!0),t.n=4,this.addRefundOutput(r+this.addOptionalOutputsAndGetAmount());case 4:return t.a(2)}},t,this)})),function(){return n.apply(this,arguments)})},{key:"signInputsWalletBased",value:(r=Vb(Hb().m(function t(e){var r,n;return Hb().w(function(t){for(;;)switch(t.n){case 0:return r=this.signer,t.n=1,this.signInput(e,e.data.inputs[0],0,this.contractSigner);case 1:return t.n=2,r.multiSignPsbt([e]);case 2:for(n=0;n<e.data.inputs.length;n++)if(0===n)e.finalizeInput(n,this.customFinalizer.bind(this));else try{e.finalizeInput(n,this.customFinalizerP2SH.bind(this))}catch(t){e.finalizeInput(n)}case 3:return t.a(2)}},t,this)})),function(t){return r.apply(this,arguments)})},{key:"signInputs",value:(e=Vb(Hb().m(function e(r){var n;return Hb().w(function(e){for(;;)switch(e.n){case 0:if(this.contractSigner){e.n=2;break}return e.n=1,qb(t,"signInputs",this,3)([r]);case 1:return e.a(2);case 2:if(!("multiSignPsbt"in this.signer)){e.n=4;break}return e.n=3,this.signInputsWalletBased(r);case 3:return e.a(2);case 4:for(n=0;n<r.data.inputs.length;n++)if(0===n)r.signInput(0,this.contractSigner),r.signInput(0,this.getSignerKey()),r.finalizeInput(0,this.customFinalizer.bind(this));else{r.signInput(n,this.getSignerKey());try{r.finalizeInput(n,this.customFinalizerP2SH.bind(this))}catch(t){r.finalizeInput(n)}}case 5:return e.a(2)}},e,this)})),function(t){return e.apply(this,arguments)})},{key:"generateScriptAddress",value:function(){return{name:Yi.P2TR,internalPubkey:this.internalPubKeyToXOnly(),network:this.network,scriptTree:this.scriptTree}}},{key:"generateTapData",value:function(){var t=this.contractSigner?this.targetScriptRedeem:this.leftOverFundsScriptRedeem;if(!t)throw new Error("Left over funds script redeem is required");if(!this.scriptTree)throw new Error("Script tree is required");return{name:Yi.P2TR,internalPubkey:this.internalPubKeyToXOnly(),network:this.network,scriptTree:this.scriptTree,redeem:t}}},{key:"generateFeatures",value:function(t){var e=[],r=t.challenge.getSubmission();return r&&e.push({opcode:hh.EPOCH_SUBMISSION,data:r}),e}},{key:"verifyCalldata",value:function(){if(this.calldata&&this.calldata.length>Cb.MAXIMUM_CALLDATA_SIZE)throw new Error("Calldata size overflow.")}},{key:"verifyBytecode",value:function(){if(!this.bytecode)throw new Error("Bytecode is required");if(this.bytecode.length>t.MAXIMUM_CONTRACT_SIZE)throw new Error("Contract size overflow.")}},{key:"getContractSeed",value:function(){if(!this.bytecode)throw new Error("Bytecode is required");var t=this.internalPubKeyToXOnly(),e=S.hash256(this.randomBytes),r=S.hash256(this.bytecode),n=Fb.concat([t,e,r]);return S.hash256(n)}},{key:"getPubKeys",value:function(){var t=[Fb.from(this.signer.publicKey)];return this.contractSigner&&t.push(Fb.from(this.contractSigner.publicKey)),t}},{key:"generateRedeemScripts",value:function(){this.targetScriptRedeem={name:Yi.P2TR,output:this.compiledTargetScript,redeemVersion:192},this.leftOverFundsScriptRedeem={name:Yi.P2TR,output:this.getLeafScript(),redeemVersion:192}}},{key:"getLeafScript",value:function(){return By.LOCK_LEAF_SCRIPT}},{key:"getScriptTree",value:function(){if(!this.bytecode)throw new Error("Contract bytecode is required");return this.generateRedeemScripts(),[{output:this.compiledTargetScript,version:192},{output:this.getLeafScript(),version:192}]}}]);var e,r,n}();Yb(Jb,"MAXIMUM_CONTRACT_SIZE",131072);var Qb=i(8287).Buffer;function tg(t){return tg="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},tg(t)}function eg(){var t,e,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",i=r.toStringTag||"@@toStringTag";function o(r,n,i,o){var u=n&&n.prototype instanceof s?n:s,c=Object.create(u.prototype);return rg(c,"_invoke",function(r,n,i){var o,s,u,c=0,f=i||[],l=!1,h={p:0,n:0,v:t,a:p,f:p.bind(t,4),d:function(e,r){return o=e,s=0,u=t,h.n=r,a}};function p(r,n){for(s=r,u=n,e=0;!l&&c&&!i&&e<f.length;e++){var i,o=f[e],p=h.p,d=o[2];r>3?(i=d===n)&&(u=o[(s=o[4])?5:(s=3,3)],o[4]=o[5]=t):o[0]<=p&&((i=r<2&&p<o[1])?(s=0,h.v=n,h.n=o[1]):p<d&&(i=r<3||o[0]>n||n>d)&&(o[4]=r,o[5]=n,h.n=d,s=0))}if(i||r>1)return a;throw l=!0,n}return function(i,f,d){if(c>1)throw TypeError("Generator is already running");for(l&&1===f&&p(f,d),s=f,u=d;(e=s<2?t:u)||!l;){o||(s?s<3?(s>1&&(h.n=-1),p(s,u)):h.n=u:h.v=u);try{if(c=2,o){if(s||(i="next"),e=o[i]){if(!(e=e.call(o,u)))throw TypeError("iterator result is not an object");if(!e.done)return e;u=e.value,s<2&&(s=0)}else 1===s&&(e=o.return)&&e.call(o),s<2&&(u=TypeError("The iterator does not provide a '"+i+"' method"),s=1);o=t}else if((e=(l=h.n<0)?u:r.call(n,h))!==a)break}catch(e){o=t,s=1,u=e}finally{c=1}}return{value:e,done:l}}}(r,i,o),!0),c}var a={};function s(){}function u(){}function c(){}e=Object.getPrototypeOf;var f=[][n]?e(e([][n]())):(rg(e={},n,function(){return this}),e),l=c.prototype=s.prototype=Object.create(f);function h(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,c):(t.__proto__=c,rg(t,i,"GeneratorFunction")),t.prototype=Object.create(l),t}return u.prototype=c,rg(l,"constructor",c),rg(c,"constructor",u),u.displayName="GeneratorFunction",rg(c,i,"GeneratorFunction"),rg(l),rg(l,i,"Generator"),rg(l,n,function(){return this}),rg(l,"toString",function(){return"[object Generator]"}),(eg=function(){return{w:o,m:h}})()}function rg(t,e,r,n){var i=Object.defineProperty;try{i({},"",{})}catch(t){i=0}rg=function(t,e,r,n){function o(e,r){rg(t,e,function(t){return this._invoke(e,r,t)})}e?i?i(t,e,{value:r,enumerable:!n,configurable:!n,writable:!n}):t[e]=r:(o("next",0),o("throw",1),o("return",2))},rg(t,e,r,n)}function ng(t,e,r,n,i,o,a){try{var s=t[o](a),u=s.value}catch(t){return void r(t)}s.done?e(u):Promise.resolve(u).then(n,i)}function ig(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,ug(n.key),n)}}function og(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(og=function(){return!!t})()}function ag(t){return ag=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},ag(t)}function sg(t,e){return sg=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},sg(t,e)}function ug(t){var e=function(t){if("object"!=tg(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=tg(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==tg(e)?e:e+""}var cg=function(){function t(e){var r,n;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),function(t,e,r){(e=ug(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r}(n=function(t,e,r){return e=ag(e),function(t,e){if(e&&("object"==tg(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,og()?Reflect.construct(e,r||[],ag(t).constructor):e.apply(t,r))}(this,t,[e]),"type",Jy.FUNDING),n.amount=e.amount,n.splitInputsInto=null!==(r=e.splitInputsInto)&&void 0!==r?r:1,n.internalInit(),n}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&sg(t,e)}(t,By),function(t,e){return e&&ig(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"buildTransaction",value:(e=function(t){return function(){var e=this,r=arguments;return new Promise(function(n,i){var o=t.apply(e,r);function a(t){ng(o,n,i,a,s,"next",t)}function s(t){ng(o,n,i,a,s,"throw",t)}a(void 0)})}}(eg().m(function t(){var e,r;return eg().w(function(t){for(;;)switch(t.n){case 0:if(this.to){t.n=1;break}throw new Error("Recipient address is required");case 1:return this.addInputsFromUTXO(),this.splitInputsInto>1?this.splitInputs(this.amount):this.isPubKeyDestination?(e=w.compile([Qb.from(this.to.replace("0x",""),"hex"),it.OP_CHECKSIG]),this.addOutput({value:Number(this.amount),script:e})):this.addOutput({value:Number(this.amount),address:this.to}),r=this.amount+this.addOptionalOutputsAndGetAmount(),t.n=2,this.addRefundOutput(r);case 2:return t.a(2)}},t,this)})),function(){return e.apply(this,arguments)})},{key:"splitInputs",value:function(t){if(!this.to)throw new Error("Recipient address is required");for(var e=t/BigInt(this.splitInputsInto),r=0;r<this.splitInputsInto;r++)this.isPubKeyDestination?this.addOutput({value:Number(e),script:Qb.from(this.to.slice(2),"hex")}):this.addOutput({value:Number(e),address:this.to})}},{key:"getSignerKey",value:function(){return this.signer}}]);var e}(),fg=i(8287).Buffer;function lg(t){return lg="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},lg(t)}function hg(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,gg(n.key),n)}}function pg(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(pg=function(){return!!t})()}function dg(t){return dg=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},dg(t)}function yg(t,e){return yg=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},yg(t,e)}function bg(t,e,r){return(e=gg(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function gg(t){var e=function(t){if("object"!=lg(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=lg(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==lg(e)?e:e+""}var vg=function(){function t(e){var r;if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),bg(r=function(t,e,r){return e=dg(e),function(t,e){if(e&&("object"==lg(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,pg()?Reflect.construct(e,r||[],dg(t).constructor):e.apply(t,r))}(this,t,[e]),"type",Jy.INTERACTION),bg(r,"tapLeafScript",null),!e.contract)throw new Error("parameters.contract is required for interaction transaction.");if(r.contractSecret=fg.from(e.contract.replace("0x",""),"hex"),32!==r.contractSecret.length)throw new Error("Invalid contract secret length. Expected 32 bytes.");return r.compiledTargetScript=r.calldataGenerator.compile(r.calldata,r.contractSecret,r.challenge,r.priorityFee,r.generateFeatures(e)),r.scriptTree=r.getScriptTree(),r.internalInit(),r}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&yg(t,e)}(t,Cb),function(t,e){return e&&hg(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"generateFeatures",value:function(t){var e=[];t.loadedStorage&&e.push({opcode:hh.ACCESS_LIST,data:t.loadedStorage});var r=t.challenge.getSubmission();return r&&e.push({opcode:hh.EPOCH_SUBMISSION,data:r}),e}}])}();function wg(t){return wg="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},wg(t)}function mg(){var t,e,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",i=r.toStringTag||"@@toStringTag";function o(r,n,i,o){var u=n&&n.prototype instanceof s?n:s,c=Object.create(u.prototype);return Sg(c,"_invoke",function(r,n,i){var o,s,u,c=0,f=i||[],l=!1,h={p:0,n:0,v:t,a:p,f:p.bind(t,4),d:function(e,r){return o=e,s=0,u=t,h.n=r,a}};function p(r,n){for(s=r,u=n,e=0;!l&&c&&!i&&e<f.length;e++){var i,o=f[e],p=h.p,d=o[2];r>3?(i=d===n)&&(u=o[(s=o[4])?5:(s=3,3)],o[4]=o[5]=t):o[0]<=p&&((i=r<2&&p<o[1])?(s=0,h.v=n,h.n=o[1]):p<d&&(i=r<3||o[0]>n||n>d)&&(o[4]=r,o[5]=n,h.n=d,s=0))}if(i||r>1)return a;throw l=!0,n}return function(i,f,d){if(c>1)throw TypeError("Generator is already running");for(l&&1===f&&p(f,d),s=f,u=d;(e=s<2?t:u)||!l;){o||(s?s<3?(s>1&&(h.n=-1),p(s,u)):h.n=u:h.v=u);try{if(c=2,o){if(s||(i="next"),e=o[i]){if(!(e=e.call(o,u)))throw TypeError("iterator result is not an object");if(!e.done)return e;u=e.value,s<2&&(s=0)}else 1===s&&(e=o.return)&&e.call(o),s<2&&(u=TypeError("The iterator does not provide a '"+i+"' method"),s=1);o=t}else if((e=(l=h.n<0)?u:r.call(n,h))!==a)break}catch(e){o=t,s=1,u=e}finally{c=1}}return{value:e,done:l}}}(r,i,o),!0),c}var a={};function s(){}function u(){}function c(){}e=Object.getPrototypeOf;var f=[][n]?e(e([][n]())):(Sg(e={},n,function(){return this}),e),l=c.prototype=s.prototype=Object.create(f);function h(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,c):(t.__proto__=c,Sg(t,i,"GeneratorFunction")),t.prototype=Object.create(l),t}return u.prototype=c,Sg(l,"constructor",c),Sg(c,"constructor",u),u.displayName="GeneratorFunction",Sg(c,i,"GeneratorFunction"),Sg(l),Sg(l,i,"Generator"),Sg(l,n,function(){return this}),Sg(l,"toString",function(){return"[object Generator]"}),(mg=function(){return{w:o,m:h}})()}function Sg(t,e,r,n){var i=Object.defineProperty;try{i({},"",{})}catch(t){i=0}Sg=function(t,e,r,n){function o(e,r){Sg(t,e,function(t){return this._invoke(e,r,t)})}e?i?i(t,e,{value:r,enumerable:!n,configurable:!n,writable:!n}):t[e]=r:(o("next",0),o("throw",1),o("return",2))},Sg(t,e,r,n)}function _g(t,e,r,n,i,o,a){try{var s=t[o](a),u=s.value}catch(t){return void r(t)}s.done?e(u):Promise.resolve(u).then(n,i)}function Eg(t){return function(){var e=this,r=arguments;return new Promise(function(n,i){var o=t.apply(e,r);function a(t){_g(o,n,i,a,s,"next",t)}function s(t){_g(o,n,i,a,s,"throw",t)}a(void 0)})}}function kg(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Pg(n.key),n)}}function Og(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(Og=function(){return!!t})()}function Tg(t){return Tg=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Tg(t)}function Ag(t,e){return Ag=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Ag(t,e)}function Ig(t,e,r){return(e=Pg(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Pg(t){var e=function(t){if("object"!=wg(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=wg(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==wg(e)?e:e+""}var xg=function(){function t(e){var r;if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),Ig(r=function(t,e,r){return e=Tg(e),function(t,e){if(e&&("object"==wg(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,Og()?Reflect.construct(e,r||[],Tg(t).constructor):e.apply(t,r))}(this,t,[e]),"type",Jy.INTERACTION),Ig(r,"p2wdaInputIndices",new Set),Ig(r,"compiledOperationData",null),!e.to)throw new Error("Contract address (to) is required");if(!e.contract)throw new Error("Contract secret is required");if(!e.calldata)throw new Error("Calldata is required");if(!e.challenge)throw new Error("Challenge solution is required");if(r.disableAutoRefund=e.disableAutoRefund||!1,r.contractAddress=e.to,r.contractSecret=ul.Buffer.from(e.contract.replace("0x",""),"hex"),r.calldata=h.compress(e.calldata),r.challenge=e.challenge,r.randomBytes=e.randomBytes||sl.rndBytes(),r.scriptSigner=r.generateKeyPairFromSeed(),r.p2wdaGenerator=new Op(ul.Buffer.from(r.signer.publicKey),r.scriptSignerXOnlyPubKey(),r.network),32!==r.contractSecret.length)throw new Error("Invalid contract secret length. Expected 32 bytes.");return r.epochChallenge=jl.generateTimeLockAddress(r.challenge.publicKey.originalPublicKeyBuffer(),r.network),r.validateP2WDAInputs(),r.compiledOperationData=r.p2wdaGenerator.compile(r.calldata,r.contractSecret,r.challenge,r.priorityFee,r.generateFeatures(e)),r.validateOperationDataSize(),r.internalInit(),r}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Ag(t,e)}(t,By),function(t,e){return e&&kg(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"getRndBytes",value:function(){return this.randomBytes}},{key:"getChallenge",value:function(){return this.challenge}},{key:"getContractSecret",value:function(){return this.contractSecret}},{key:"buildTransaction",value:(n=Eg(mg().m(function t(){return mg().w(function(t){for(;;)switch(t.n){case 0:return this.regenerated||this.addInputsFromUTXO(),t.n=1,this.createMineableRewardOutputs();case 1:return t.a(2)}},t,this)})),function(){return n.apply(this,arguments)})},{key:"createMineableRewardOutputs",value:(r=Eg(mg().m(function t(){var e,r;return mg().w(function(t){for(;;)switch(t.n){case 0:if(this.to){t.n=1;break}throw new Error("To address is required");case 1:if(e=this.getTransactionOPNetFee(),this.addFeeToOutput(e,this.to,this.epochChallenge,!1),r=this.addOptionalOutputsAndGetAmount(),this.disableAutoRefund){t.n=2;break}return t.n=2,this.addRefundOutput(e+r);case 2:return t.a(2)}},t,this)})),function(){return r.apply(this,arguments)})},{key:"signInputs",value:(e=Eg(mg().m(function t(e){var r,n;return mg().w(function(t){for(;;)switch(t.n){case 0:r=0;case 1:if(!(r<e.data.inputs.length)){t.n=3;break}return t.n=2,this.signInput(e,e.data.inputs[r],r,this.signer);case 2:r++,t.n=1;break;case 3:for(n=0;n<e.data.inputs.length;n++)this.p2wdaInputIndices.has(n)?0===n?e.finalizeInput(n,this.finalizePrimaryP2WDA.bind(this)):e.finalizeInput(n,this.finalizeSecondaryP2WDA.bind(this)):e.finalizeInput(n,this.customFinalizerP2SH.bind(this));this.finalized=!0;case 4:return t.a(2)}},t,this)})),function(t){return e.apply(this,arguments)})},{key:"generateFeatures",value:function(t){var e=[];t.loadedStorage&&e.push({opcode:hh.ACCESS_LIST,data:t.loadedStorage});var r=t.challenge.getSubmission();return r&&e.push({opcode:hh.EPOCH_SUBMISSION,data:r}),e}},{key:"generateKeyPairFromSeed",value:function(){return bf.fromSeedKeyPair(this.randomBytes,this.network)}},{key:"scriptSignerXOnlyPubKey",value:function(){return bi(ul.Buffer.from(this.scriptSigner.publicKey))}},{key:"validateP2WDAInputs",value:function(){if(0===this.utxos.length||!pl.isP2WDAUTXO(this.utxos[0]))throw new Error("Input 0 must be a P2WDA UTXO");for(var t=0;t<this.utxos.length;t++)pl.isP2WDAUTXO(this.utxos[t])&&this.p2wdaInputIndices.add(t);for(var e=0;e<this.optionalInputs.length;e++){var r=this.utxos.length+e;pl.isP2WDAUTXO(this.optionalInputs[e])&&this.p2wdaInputIndices.add(r)}}},{key:"validateOperationDataSize",value:function(){if(!this.compiledOperationData)throw new Error("Operation data not compiled");var e=this.compiledOperationData.length;if(!Op.validateWitnessSize(e)){var r=e+64,n=Math.ceil(.7*r),i=Math.ceil(n/t.MAX_BYTES_PER_WITNESS);throw new Error("Please dont use P2WDA for this operation. Data too large. Raw size: ".concat(e," bytes, ")+"estimated compressed: ".concat(n," bytes, ")+"needs ".concat(i," witness fields, max is ").concat(t.MAX_WITNESS_FIELDS))}}},{key:"finalizePrimaryP2WDA",value:function(e,r){if(!r.partialSig||0===r.partialSig.length)throw new Error("No signature for P2WDA input #".concat(e));if(!r.witnessScript)throw new Error("No witness script for P2WDA input #".concat(e));if(!this.compiledOperationData)throw new Error("Operation data not compiled");var n=r.partialSig[0].signature,i=ul.Buffer.concat([n,this.compiledOperationData]),o=Ky.signMessage(this.signer,i),a=ul.Buffer.from(o.signature),s=ul.Buffer.concat([a,this.compiledOperationData]),u=h.compress(s),c=this.splitIntoWitnessChunks(u);if(c.length>t.MAX_WITNESS_FIELDS)throw new Error("Compressed data needs ".concat(c.length," witness fields, max is ").concat(t.MAX_WITNESS_FIELDS));for(var f=[n],l=0;l<t.MAX_WITNESS_FIELDS;l++)f.push(l<c.length?c[l]:ul.Buffer.alloc(0));return f.push(r.witnessScript),{finalScriptSig:void 0,finalScriptWitness:By.witnessStackToScriptWitness(f)}}},{key:"splitIntoWitnessChunks",value:function(e){for(var r=[],n=0;n<e.length;){var i=Math.min(t.MAX_BYTES_PER_WITNESS,e.length-n);r.push(e.subarray(n,n+i)),n+=i}return r}}]);var e,r,n}();Ig(xg,"MAX_WITNESS_FIELDS",10),Ig(xg,"MAX_BYTES_PER_WITNESS",80);var Bg=i(8287).Buffer;function Rg(t){return Bg.from(t.replace("0x",""),"hex")}var Ug=i(8287).Buffer;function jg(t){return jg="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},jg(t)}function Ng(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Lg(n.key),n)}}function Lg(t){var e=function(t){if("object"!=jg(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=jg(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==jg(e)?e:e+""}var Cg=function(){return function(t,e,r){return r&&Ng(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)},0,[{key:"bufferToUint8Array",value:function(t){return new Uint8Array(t)}},{key:"uint8ArrayToBuffer",value:function(t){return Ug.from(t)}},{key:"sha1",value:function(t){return S.sha1(Ug.isBuffer(t)?t:Ug.from(t))}},{key:"calculatePreimage",value:function(t,e,r){if(32!==t.length||32!==e.length||32!==r.length)throw new Error("All inputs must be 32 bytes");for(var n=Ug.alloc(32),i=0;i<32;i++)n[i]=t[i]^e[i]^r[i];return n}},{key:"countMatchingBits",value:function(t,e){var r=0;if(t.length!==e.length)throw new Error("Hashes must be of the same length");for(var n=Math.min(t.length,e.length),i=0;i<n;i++){var o=t[i],a=e[i];if(o===a)r+=8;else for(var s=7;s>=0;s--){if((o>>s&1)!=(a>>s&1))return r;r++}}return r}},{key:"verifySolution",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];try{var r=t.verification,n=this.calculatePreimage(r.targetChecksum,t.publicKey.toBuffer(),t.salt),i=this.sha1(n),o=this.uint8ArrayToBuffer(i);if(!o.equals(t.solution))return!1;if(this.countMatchingBits(o,r.targetHash)!==t.difficulty)return!1;var a=t.epochNumber*this.BLOCKS_PER_EPOCH,s=a+this.BLOCKS_PER_EPOCH-1n;return!(r.startBlock!==a||r.endBlock!==s)}catch(t){return e&&console.error("Verification error:",t),!1}}},{key:"getMiningTargetBlock",value:function(t){return 0n===t?null:t*this.BLOCKS_PER_EPOCH-1n}},{key:"validateEpochWinner",value:function(t){var e=new Gg(t);return this.verifySolution(e)}},{key:"validateChallengeSolution",value:function(t){return this.verifySolution(t)}},{key:"calculateSolution",value:function(t,e,r){var n=this.calculatePreimage(t,e,r),i=this.sha1(this.bufferToUint8Array(n));return this.uint8ArrayToBuffer(i)}},{key:"checkDifficulty",value:function(t,e,r){var n=this.countMatchingBits(t,e);return{valid:n>=r,difficulty:n}}}])}();function Fg(t){return Fg="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Fg(t)}function Dg(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Mg(n.key),n)}}function Hg(t,e,r){return e&&Dg(t.prototype,e),r&&Dg(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function Mg(t){var e=function(t){if("object"!=Fg(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Fg(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Fg(e)?e:e+""}function Kg(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}!function(t,e){(e=Lg(e))in t?Object.defineProperty(t,e,{value:5n,enumerable:!0,configurable:!0,writable:!0}):t[e]=5n}(Cg,"BLOCKS_PER_EPOCH");var Vg=Hg(function t(e){Kg(this,t),this.epochHash=Rg(e.epochHash),this.epochRoot=Rg(e.epochRoot),this.targetHash=Rg(e.targetHash),this.targetChecksum=Rg(e.targetChecksum),this.startBlock=BigInt(e.startBlock),this.endBlock=BigInt(e.endBlock),this.proofs=Object.freeze(e.proofs.map(function(t){return Rg(t)}))}),Wg=function(){return Hg(function t(e,r){Kg(this,t),this.epochNumber=r,this.publicKey=ih.fromString(e.publicKey),this.solution=Rg(e.solution),this.graffiti=e.graffiti?Rg(e.graffiti):void 0,this.signature=Rg(e.signature)},[{key:"verifySignature",value:function(){var t=new ph;t.writeAddress(this.publicKey),t.writeU64(this.epochNumber),t.writeBytes(this.solution),this.graffiti&&t.writeBytes(this.graffiti);var e=t.getBuffer();return Ky.verifySignature(this.publicKey,e,this.signature)}}])}(),Gg=function(){return Hg(function t(e){Kg(this,t),this.epochNumber=BigInt(e.epochNumber),this.publicKey=ih.fromString(e.publicKey),this.solution=Rg(e.solution),this.salt=Rg(e.salt),this.graffiti=Rg(e.graffiti),this.difficulty=e.difficulty,this.verification=new Vg(e.verification),this.submission=e.submission?new Wg(e.submission,this.epochNumber+2n):e.submission},[{key:"verifySubmissionSignature",value:function(){if(!this.submission)throw new Error("No submission provided in request.");return this.submission.verifySignature()}},{key:"getSubmission",value:function(){if(this.submission){if(!this.verifySubmissionSignature())throw new Error("Invalid submission signature.");return this.submission}}},{key:"verify",value:function(){return Cg.validateChallengeSolution(this)}},{key:"toBuffer",value:function(){return this.solution}},{key:"toHex",value:function(){return"0x"+this.solution.toString("hex")}},{key:"toRaw",value:function(){return{epochNumber:this.epochNumber.toString(),publicKey:this.publicKey.toHex(),solution:this.toHex(),salt:"0x"+this.salt.toString("hex"),graffiti:"0x"+this.graffiti.toString("hex"),difficulty:this.difficulty,verification:{epochHash:"0x"+this.verification.epochHash.toString("hex"),epochRoot:"0x"+this.verification.epochRoot.toString("hex"),targetHash:"0x"+this.verification.targetHash.toString("hex"),targetChecksum:"0x"+this.verification.targetChecksum.toString("hex"),startBlock:this.verification.startBlock.toString(),endBlock:this.verification.endBlock.toString(),proofs:this.verification.proofs.map(function(t){return"0x"+t.toString("hex")})}}}},{key:"calculateSolution",value:function(){return Cg.calculateSolution(this.verification.targetChecksum,this.publicKey.toBuffer(),this.salt)}},{key:"checkDifficulty",value:function(t){return Cg.checkDifficulty(this.solution,this.verification.targetHash,t)}},{key:"getMiningTargetBlock",value:function(){return Cg.getMiningTargetBlock(this.epochNumber)}}],[{key:"validateRaw",value:function(t){return Cg.validateEpochWinner(t)}}])}(),qg=i(8287).Buffer;function zg(t){return zg="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},zg(t)}function Zg(t){return function(t){if(Array.isArray(t))return Xg(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return Xg(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Xg(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Xg(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function Yg(){var t,e,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",i=r.toStringTag||"@@toStringTag";function o(r,n,i,o){var u=n&&n.prototype instanceof s?n:s,c=Object.create(u.prototype);return $g(c,"_invoke",function(r,n,i){var o,s,u,c=0,f=i||[],l=!1,h={p:0,n:0,v:t,a:p,f:p.bind(t,4),d:function(e,r){return o=e,s=0,u=t,h.n=r,a}};function p(r,n){for(s=r,u=n,e=0;!l&&c&&!i&&e<f.length;e++){var i,o=f[e],p=h.p,d=o[2];r>3?(i=d===n)&&(u=o[(s=o[4])?5:(s=3,3)],o[4]=o[5]=t):o[0]<=p&&((i=r<2&&p<o[1])?(s=0,h.v=n,h.n=o[1]):p<d&&(i=r<3||o[0]>n||n>d)&&(o[4]=r,o[5]=n,h.n=d,s=0))}if(i||r>1)return a;throw l=!0,n}return function(i,f,d){if(c>1)throw TypeError("Generator is already running");for(l&&1===f&&p(f,d),s=f,u=d;(e=s<2?t:u)||!l;){o||(s?s<3?(s>1&&(h.n=-1),p(s,u)):h.n=u:h.v=u);try{if(c=2,o){if(s||(i="next"),e=o[i]){if(!(e=e.call(o,u)))throw TypeError("iterator result is not an object");if(!e.done)return e;u=e.value,s<2&&(s=0)}else 1===s&&(e=o.return)&&e.call(o),s<2&&(u=TypeError("The iterator does not provide a '"+i+"' method"),s=1);o=t}else if((e=(l=h.n<0)?u:r.call(n,h))!==a)break}catch(e){o=t,s=1,u=e}finally{c=1}}return{value:e,done:l}}}(r,i,o),!0),c}var a={};function s(){}function u(){}function c(){}e=Object.getPrototypeOf;var f=[][n]?e(e([][n]())):($g(e={},n,function(){return this}),e),l=c.prototype=s.prototype=Object.create(f);function h(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,c):(t.__proto__=c,$g(t,i,"GeneratorFunction")),t.prototype=Object.create(l),t}return u.prototype=c,$g(l,"constructor",c),$g(c,"constructor",u),u.displayName="GeneratorFunction",$g(c,i,"GeneratorFunction"),$g(l),$g(l,i,"Generator"),$g(l,n,function(){return this}),$g(l,"toString",function(){return"[object Generator]"}),(Yg=function(){return{w:o,m:h}})()}function $g(t,e,r,n){var i=Object.defineProperty;try{i({},"",{})}catch(t){i=0}$g=function(t,e,r,n){function o(e,r){$g(t,e,function(t){return this._invoke(e,r,t)})}e?i?i(t,e,{value:r,enumerable:!n,configurable:!n,writable:!n}):t[e]=r:(o("next",0),o("throw",1),o("return",2))},$g(t,e,r,n)}function Jg(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function Qg(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?Jg(Object(r),!0).forEach(function(e){nv(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Jg(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function tv(t,e,r,n,i,o,a){try{var s=t[o](a),u=s.value}catch(t){return void r(t)}s.done?e(u):Promise.resolve(u).then(n,i)}function ev(t){return function(){var e=this,r=arguments;return new Promise(function(n,i){var o=t.apply(e,r);function a(t){tv(o,n,i,a,s,"next",t)}function s(t){tv(o,n,i,a,s,"throw",t)}a(void 0)})}}function rv(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,iv(n.key),n)}}function nv(t,e,r){return(e=iv(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function iv(t){var e=function(t){if("object"!=zg(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=zg(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==zg(e)?e:e+""}var ov=function(){return function(t,e){return e&&rv(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}(function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),nv(this,"debug",!1),nv(this,"DUMMY_PUBKEY",qg.alloc(32,1)),nv(this,"P2TR_SCRIPT",qg.concat([qg.from([81,32]),this.DUMMY_PUBKEY])),nv(this,"INITIAL_FUNDING_ESTIMATE",2000n),nv(this,"MAX_ITERATIONS",10)},[{key:"createCustomScriptTransaction",value:(u=ev(Yg().m(function t(e){var r,n,i,o,a,s,u,c,f,l,h=this;return Yg().w(function(t){for(;;)switch(t.n){case 0:if(e.to){t.n=1;break}throw new Error('Field "to" not provided.');case 1:if(e.from){t.n=2;break}throw new Error('Field "from" not provided.');case 2:if(e.utxos[0]){t.n=3;break}throw new Error("Missing at least one UTXO.");case 3:if("signer"in e){t.n=4;break}throw new Error('Field "signer" not provided, OP_WALLET not detected.');case 4:return r=this.parseOptionalInputs(e.optionalInputs),t.n=5,this.iterateFundingAmount(Qg(Qg({},e),{},{optionalInputs:r}),_b,function(){var t=ev(Yg().m(function t(r){var n,i,o;return Yg().w(function(t){for(;;)switch(t.n){case 0:return t.n=1,r.estimateTransactionFees();case 1:return n=t.v,i=h.getPriorityFee(e),o=r.getOptionalOutputValue(),t.a(2,n+i+o)}},t)}));return function(e){return t.apply(this,arguments)}}(),"CustomScript");case 5:return n=t.v,i=n.finalTransaction,o=n.estimatedAmount,n.challenge,t.n=6,i.getFundingTransactionParameters();case 6:return(a=t.v).utxos=e.utxos,a.amount=o,t.n=7,this.createFundTransaction(Qg(Qg({},a),{},{optionalOutputs:[],optionalInputs:[]}));case 7:if(s=t.v){t.n=8;break}throw new Error("Could not sign funding transaction.");case 8:return a.estimatedFees=s.estimatedFees,t.n=9,this.createFundTransaction(Qg(Qg({},a),{},{optionalOutputs:[],optionalInputs:[]}));case 9:if(u=t.v){t.n=10;break}throw new Error("Could not sign funding transaction.");case 10:return c=Qg(Qg({},e),{},{utxos:this.getUTXOAsTransaction(u.tx,e.to,0),randomBytes:i.getRndBytes(),nonWitnessUtxo:u.tx.toBuffer(),estimatedFees:i.estimatedFees,optionalInputs:r}),f=new _b(c),t.n=11,f.signTransaction();case 11:return l=t.v,t.a(2,[u.tx.toHex(),l.toHex(),this.getUTXOAsTransaction(u.tx,e.from,1)])}},t,this)})),function(t){return u.apply(this,arguments)})},{key:"signInteraction",value:(s=ev(Yg().m(function t(e){var r,n,i,o,a,s,u,c,f,l,h,p;return Yg().w(function(t){for(;;)switch(t.n){case 0:if(e.to){t.n=1;break}throw new Error('Field "to" not provided.');case 1:if(e.from){t.n=2;break}throw new Error('Field "from" not provided.');case 2:if(e.utxos[0]){t.n=3;break}throw new Error("Missing at least one UTXO.");case 3:return t.n=4,this.detectInteractionOPWallet(e);case 4:if(!(r=t.v)){t.n=5;break}return t.a(2,r);case 5:if("signer"in e){t.n=6;break}throw new Error('Field "signer" not provided, OP_WALLET not detected.');case 6:if(!this.hasP2WDAInputs(e.utxos)){t.n=7;break}return t.a(2,this.signP2WDAInteraction(e));case 7:return n=this.parseOptionalInputs(e.optionalInputs),t.n=8,this.iterateFundingAmount(Qg(Qg({},e),{},{optionalInputs:n}),vg,function(){var t=ev(Yg().m(function t(e){var r,n;return Yg().w(function(t){for(;;)switch(t.n){case 0:return t.n=1,e.estimateTransactionFees();case 1:return r=t.v,n=e.getTotalOutputValue(),t.a(2,r+n)}},t)}));return function(e){return t.apply(this,arguments)}}(),"Interaction");case 8:if(i=t.v,o=i.finalTransaction,a=i.estimatedAmount,s=i.challenge){t.n=9;break}throw new Error("Failed to get challenge from interaction transaction");case 9:return t.n=10,o.getFundingTransactionParameters();case 10:return(u=t.v).utxos=e.utxos,u.amount=a,t.n=11,this.createFundTransaction(Qg(Qg({},u),{},{optionalOutputs:[],optionalInputs:[]}));case 11:if(c=t.v){t.n=12;break}throw new Error("Could not sign funding transaction.");case 12:return u.estimatedFees=c.estimatedFees,t.n=13,this.createFundTransaction(Qg(Qg({},u),{},{optionalOutputs:[],optionalInputs:[]}));case 13:if(f=t.v){t.n=14;break}throw new Error("Could not sign funding transaction.");case 14:return l=Qg(Qg({},e),{},{utxos:this.getUTXOAsTransaction(f.tx,o.getScriptAddress(),0),randomBytes:o.getRndBytes(),challenge:s,nonWitnessUtxo:f.tx.toBuffer(),estimatedFees:o.estimatedFees,optionalInputs:n}),h=new vg(l),t.n=15,h.signTransaction();case 15:return p=t.v,t.a(2,{fundingTransaction:f.tx.toHex(),interactionTransaction:p.toHex(),estimatedFees:h.transactionFee,nextUTXOs:this.getUTXOAsTransaction(f.tx,e.from,1),challenge:s.toRaw()})}},t,this)})),function(t){return s.apply(this,arguments)})},{key:"signDeployment",value:(a=ev(Yg().m(function t(e){var r,n,i,o,a,s,u,c,f,l,h,p,d,y,b,g,v,w=this;return Yg().w(function(t){for(;;)switch(t.n){case 0:return t.n=1,this.detectDeploymentOPWallet(e);case 1:if(!(r=t.v)){t.n=2;break}return t.a(2,r);case 2:if("signer"in e){t.n=3;break}throw new Error('Field "signer" not provided, OP_WALLET not detected.');case 3:return n=this.parseOptionalInputs(e.optionalInputs),t.n=4,this.iterateFundingAmount(Qg(Qg({},e),{},{optionalInputs:n}),Jb,function(){var t=ev(Yg().m(function t(r){var n,i,o;return Yg().w(function(t){for(;;)switch(t.n){case 0:return t.n=1,r.estimateTransactionFees();case 1:return n=t.v,i=w.getPriorityFee(e),o=r.getOptionalOutputValue(),t.a(2,n+i+o)}},t)}));return function(e){return t.apply(this,arguments)}}(),"Deployment");case 4:if(i=t.v,o=i.finalTransaction,a=i.estimatedAmount,s=i.challenge){t.n=5;break}throw new Error("Failed to get challenge from deployment transaction");case 5:return t.n=6,o.getFundingTransactionParameters();case 6:return(u=t.v).utxos=e.utxos,u.amount=a,t.n=7,this.createFundTransaction(Qg(Qg({},u),{},{optionalOutputs:[],optionalInputs:[]}));case 7:if(c=t.v){t.n=8;break}throw new Error("Could not sign funding transaction.");case 8:return u.estimatedFees=c.estimatedFees,f=new cg(Qg(Qg({},u),{},{optionalInputs:[],optionalOutputs:[]})),t.n=9,f.signTransaction();case 9:if(l=t.v){t.n=10;break}throw new Error("Could not sign funding transaction.");case 10:return h=l.outs[0],p={transactionId:l.getId(),outputIndex:0,scriptPubKey:{hex:h.script.toString("hex"),address:o.getScriptAddress()},value:BigInt(h.value)},d=Qg(Qg({},e),{},{utxos:[p],randomBytes:o.getRndBytes(),challenge:s,nonWitnessUtxo:l.toBuffer(),estimatedFees:o.estimatedFees,optionalInputs:n}),y=new Jb(d),t.n=11,y.signTransaction();case 11:return b=t.v,g=l.outs[1],v={transactionId:l.getId(),outputIndex:1,scriptPubKey:{hex:g.script.toString("hex"),address:e.from},value:BigInt(g.value)},t.a(2,{transaction:[l.toHex(),b.toHex()],contractAddress:y.getContractAddress(),contractPubKey:y.contractPubKey,utxos:[v],challenge:s.toRaw()})}},t,this)})),function(t){return a.apply(this,arguments)})},{key:"createBTCTransfer",value:(o=ev(Yg().m(function t(e){var r;return Yg().w(function(t){for(;;)switch(t.n){case 0:if(e.from){t.n=1;break}throw new Error('Field "from" not provided.');case 1:return t.n=2,this.createFundTransaction(e);case 2:return r=t.v,t.a(2,{estimatedFees:r.estimatedFees,original:r.original,tx:r.tx.toHex(),nextUTXOs:this.getAllNewUTXOs(r.original,r.tx,e.from)})}},t,this)})),function(t){return o.apply(this,arguments)})},{key:"getAllNewUTXOs",value:function(t,e,r){for(var n=t.getOutputs(),i=[],o=0;o<e.outs.length;o++){var a=n[o];"address"in a&&a.address===r&&i.push.apply(i,Zg(this.getUTXOAsTransaction(e,r,o)))}return i}},{key:"parseOptionalInputs",value:function(t){return(t||[]).map(function(t){var e=t.nonWitnessUtxo;return!e||e instanceof Uint8Array||"object"!==zg(e)||(e=qg.from(Uint8Array.from(Object.values(t.nonWitnessUtxo)))),Qg(Qg({},t),{},{nonWitnessUtxo:e})})}},{key:"detectInteractionOPWallet",value:(i=ev(Yg().m(function t(e){var r,n,i;return Yg().w(function(t){for(;;)switch(t.n){case 0:if("undefined"!=typeof window){t.n=1;break}return t.a(2,null);case 1:if((r=window)&&r.opnet&&r.opnet.web3){t.n=2;break}return t.a(2,null);case 2:return n=r.opnet.web3,t.n=3,n.signInteraction(Qg(Qg({},e),{},{signer:void 0}));case 3:if(i=t.v){t.n=4;break}throw new Error("Could not sign interaction transaction.");case 4:return t.a(2,i)}},t)})),function(t){return i.apply(this,arguments)})},{key:"detectDeploymentOPWallet",value:(n=ev(Yg().m(function t(e){var r,n,i;return Yg().w(function(t){for(;;)switch(t.n){case 0:if("undefined"!=typeof window){t.n=1;break}return t.a(2,null);case 1:if((r=window)&&r.opnet&&r.opnet.web3){t.n=2;break}return t.a(2,null);case 2:return n=r.opnet.web3,t.n=3,n.deployContract(Qg(Qg({},e),{},{signer:void 0}));case 3:if(i=t.v){t.n=4;break}throw new Error("Could not sign interaction transaction.");case 4:return t.a(2,i)}},t)})),function(t){return n.apply(this,arguments)})},{key:"createFundTransaction",value:(r=ev(Yg().m(function t(e){var r,n;return Yg().w(function(t){for(;;)switch(t.n){case 0:if(e.to){t.n=1;break}throw new Error('Field "to" not provided.');case 1:return r=new cg(e),t.n=2,r.signTransaction();case 2:if(n=t.v){t.n=3;break}throw new Error("Could not sign funding transaction.");case 3:return t.a(2,{tx:n,original:r,estimatedFees:r.estimatedFees,nextUTXOs:this.getUTXOAsTransaction(n,e.to,0)})}},t,this)})),function(t){return r.apply(this,arguments)})},{key:"hasP2WDAInputs",value:function(t){return t.some(function(t){return pl.isP2WDAUTXO(t)})}},{key:"writePSBTHeader",value:function(t,e){var r=qg.from(e,"base64"),n=qg.alloc(2);return n.writeUInt8(t,0),n.writeUInt8(ib,1),qg.concat([n,r]).toString("hex")}},{key:"signP2WDAInteraction",value:(e=ev(Yg().m(function t(e){var r,n,i,o;return Yg().w(function(t){for(;;)switch(t.n){case 0:if(e.from){t.n=1;break}throw new Error('Field "from" not provided.');case 1:if("signer"in e){t.n=2;break}throw new Error("P2WDA interactions require a signer. OP_WALLET is not supported for P2WDA.");case 2:return r=this.parseOptionalInputs(e.optionalInputs),n=new xg(Qg(Qg({},e),{},{optionalInputs:r})),t.n=3,n.signTransaction();case 3:return i=t.v,o=i.toHex(),t.a(2,{fundingTransaction:null,interactionTransaction:o,estimatedFees:n.estimatedFees,nextUTXOs:this.getUTXOAsTransaction(i,e.from,i.outs.length-1),challenge:e.challenge.toRaw()})}},t,this)})),function(t){return e.apply(this,arguments)})},{key:"getPriorityFee",value:function(t){var e=t.priorityFee+t.gasSatFee;return e<By.MINIMUM_DUST?By.MINIMUM_DUST:e}},{key:"iterateFundingAmount",value:(t=ev(Yg().m(function t(e,r,n,i){var o,a,s,u,c,f,l,h,p,d,y,b,g,v,w,m,S;return Yg().w(function(t){for(;;)switch(t.p=t.n){case 0:a="randomBytes"in e&&null!==(o=e.randomBytes)&&void 0!==o?o:sl.rndBytes(),s=ih.dead().p2tr(e.network),u=this.INITIAL_FUNDING_ESTIMATE,c=0n,f=0,l=null,h=null;case 1:if(!(f<this.MAX_ITERATIONS&&u!==c)){t.n=10;break}return c=u,(p=new hi).addOutput(this.P2TR_SCRIPT,Number(u)),d={transactionId:qg.alloc(32,0).toString("hex"),outputIndex:0,scriptPubKey:{hex:this.P2TR_SCRIPT.toString("hex"),address:s},value:u,nonWitnessUtxo:p.toBuffer()},y=void 0,"challenge"in e&&e.challenge?(b=Qg(Qg({},e),{},{utxos:[d],randomBytes:a,challenge:null!=h?h:e.challenge}),y=b):(g=Qg(Qg({},e),{},{utxos:[d],randomBytes:a}),y=g),v=new r(y),t.p=2,t.n=3,v.generateTransactionMinimalSignatures();case 3:return t.n=4,n(v);case 4:u=t.v,t.n=9;break;case 5:if(t.p=5,!((S=t.v)instanceof Error)){t.n=8;break}if(!(w=S.message.match(/need (\d+) sats but only have (\d+) sats/))){t.n=6;break}u=BigInt(w[1]),this.debug&&console.log("".concat(i,": Caught insufficient funds, updating to ").concat(u)),t.n=7;break;case 6:throw S;case 7:t.n=9;break;case 8:throw new Error("Unknown error during fee estimation");case 9:l=v,"getChallenge"in v&&"function"==typeof v.getChallenge&&(m=v.getChallenge())instanceof Gg&&(h=m),f++,this.debug&&console.log("".concat(i," Iteration ").concat(f,": Previous=").concat(c,", New=").concat(u)),t.n=1;break;case 10:if(l){t.n=11;break}throw new Error("Failed to converge on ".concat(i," funding amount"));case 11:return t.a(2,{finalTransaction:l,estimatedAmount:u,challenge:h})}},t,this,[[2,5]])})),function(e,r,n,i){return t.apply(this,arguments)})},{key:"getUTXOAsTransaction",value:function(t,e,r){if(!t.outs[r])return[];var n=t.outs[r];return[{transactionId:t.getId(),outputIndex:r,scriptPubKey:{hex:n.script.toString("hex"),address:e},value:BigInt(n.value)}]}}]);var t,e,r,n,i,o,a,s,u}(),av=i(8287).Buffer;function sv(t){return sv="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},sv(t)}function uv(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return cv(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?cv(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}function cv(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function fv(){var t,e,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",i=r.toStringTag||"@@toStringTag";function o(r,n,i,o){var u=n&&n.prototype instanceof s?n:s,c=Object.create(u.prototype);return lv(c,"_invoke",function(r,n,i){var o,s,u,c=0,f=i||[],l=!1,h={p:0,n:0,v:t,a:p,f:p.bind(t,4),d:function(e,r){return o=e,s=0,u=t,h.n=r,a}};function p(r,n){for(s=r,u=n,e=0;!l&&c&&!i&&e<f.length;e++){var i,o=f[e],p=h.p,d=o[2];r>3?(i=d===n)&&(u=o[(s=o[4])?5:(s=3,3)],o[4]=o[5]=t):o[0]<=p&&((i=r<2&&p<o[1])?(s=0,h.v=n,h.n=o[1]):p<d&&(i=r<3||o[0]>n||n>d)&&(o[4]=r,o[5]=n,h.n=d,s=0))}if(i||r>1)return a;throw l=!0,n}return function(i,f,d){if(c>1)throw TypeError("Generator is already running");for(l&&1===f&&p(f,d),s=f,u=d;(e=s<2?t:u)||!l;){o||(s?s<3?(s>1&&(h.n=-1),p(s,u)):h.n=u:h.v=u);try{if(c=2,o){if(s||(i="next"),e=o[i]){if(!(e=e.call(o,u)))throw TypeError("iterator result is not an object");if(!e.done)return e;u=e.value,s<2&&(s=0)}else 1===s&&(e=o.return)&&e.call(o),s<2&&(u=TypeError("The iterator does not provide a '"+i+"' method"),s=1);o=t}else if((e=(l=h.n<0)?u:r.call(n,h))!==a)break}catch(e){o=t,s=1,u=e}finally{c=1}}return{value:e,done:l}}}(r,i,o),!0),c}var a={};function s(){}function u(){}function c(){}e=Object.getPrototypeOf;var f=[][n]?e(e([][n]())):(lv(e={},n,function(){return this}),e),l=c.prototype=s.prototype=Object.create(f);function h(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,c):(t.__proto__=c,lv(t,i,"GeneratorFunction")),t.prototype=Object.create(l),t}return u.prototype=c,lv(l,"constructor",c),lv(c,"constructor",u),u.displayName="GeneratorFunction",lv(c,i,"GeneratorFunction"),lv(l),lv(l,i,"Generator"),lv(l,n,function(){return this}),lv(l,"toString",function(){return"[object Generator]"}),(fv=function(){return{w:o,m:h}})()}function lv(t,e,r,n){var i=Object.defineProperty;try{i({},"",{})}catch(t){i=0}lv=function(t,e,r,n){function o(e,r){lv(t,e,function(t){return this._invoke(e,r,t)})}e?i?i(t,e,{value:r,enumerable:!n,configurable:!n,writable:!n}):t[e]=r:(o("next",0),o("throw",1),o("return",2))},lv(t,e,r,n)}function hv(t,e,r,n,i,o,a){try{var s=t[o](a),u=s.value}catch(t){return void r(t)}s.done?e(u):Promise.resolve(u).then(n,i)}function pv(t){return function(){var e=this,r=arguments;return new Promise(function(n,i){var o=t.apply(e,r);function a(t){hv(o,n,i,a,s,"next",t)}function s(t){hv(o,n,i,a,s,"throw",t)}a(void 0)})}}function dv(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function yv(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?dv(Object(r),!0).forEach(function(e){mv(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):dv(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function bv(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Sv(n.key),n)}}function gv(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(gv=function(){return!!t})()}function vv(t){return vv=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},vv(t)}function wv(t,e){return wv=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},wv(t,e)}function mv(t,e,r){return(e=Sv(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Sv(t){var e=function(t){if("object"!=sv(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=sv(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==sv(e)?e:e+""}var _v=function(){function t(e){var r;if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),!e.refundVault)throw new Error("Refund vault is required");if(!e.requestedAmount)throw new Error("Requested amount is required");if(!e.receiver)throw new Error("Receiver is required");if(mv(r=function(t,e,r){return e=vv(e),function(t,e){if(e&&("object"==sv(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,gv()?Reflect.construct(e,r||[],vv(t).constructor):e.apply(t,r))}(this,t,[yv(yv({},e),{},{signer:bf.fromPrivateKey(S.sha256(av.from("aaaaaaaa","utf-8"))),priorityFee:0n,gasSatFee:0n})]),"type",Jy.MULTI_SIG),mv(r,"targetScriptRedeem",null),mv(r,"leftOverFundsScriptRedeem",null),mv(r,"originalInputCount",0),mv(r,"sighashTypes",t.signHashTypesArray),mv(r,"customFinalizer",function(t,e){if(!r.tapLeafScript)throw new Error("Tap leaf script is required");var n=r.getScriptSolution(e).concat(r.tapLeafScript.script).concat(r.tapLeafScript.controlBlock);return{finalScriptWitness:By.witnessStackToScriptWitness(n)}}),!e.pubkeys)throw new Error("Pubkeys are required");return e.psbt&&(r.log("Using provided PSBT."),r.transaction=e.psbt,r.originalInputCount=r.transaction.data.inputs.length),r.refundVault=e.refundVault,r.requestedAmount=e.requestedAmount,r.receiver=e.receiver,r.publicKeys=e.pubkeys,r.minimumSignatures=e.minimumSignatures,r.compiledTargetScript=yp.compile(e.pubkeys,r.minimumSignatures),r.scriptTree=r.getScriptTree(),r.internalInit(),r}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&wv(t,e)}(t,By),function(t,e,r){return e&&bv(t.prototype,e),r&&bv(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"finalizeTransactionInputs",value:function(){var t=!1;try{for(var e=this.originalInputCount;e<this.transaction.data.inputs.length;e++)this.transaction.finalizeInput(e,this.customFinalizer.bind(this));t=!0}catch(t){this.error("Error finalizing transaction inputs: ".concat(t.stack))}return t}},{key:"signPSBT",value:(i=pv(fv().m(function t(){return fv().w(function(t){for(;;)switch(t.n){case 0:return t.n=1,this.signTransaction();case 1:if(!t.v){t.n=2;break}return t.a(2,this.transaction);case 2:throw new Error("Could not sign transaction");case 3:return t.a(2)}},t,this)})),function(){return i.apply(this,arguments)})},{key:"buildTransaction",value:(n=pv(fv().m(function t(){var e,r;return fv().w(function(t){for(;;)switch(t.n){case 0:if(e=this.targetScriptRedeem){t.n=1;break}throw new Error("Left over funds script redeem is required");case 1:if(e.redeemVersion){t.n=2;break}throw new Error("Left over funds script redeem version is required");case 2:if(e.output){t.n=3;break}throw new Error("Left over funds script redeem output is required");case 3:if(this.tapLeafScript={leafVersion:e.redeemVersion,script:e.output,controlBlock:this.getWitness()},this.addInputsFromUTXO(),!((r=this.calculateOutputLeftAmountFromVaults(this.utxos))<0)){t.n=4;break}throw new Error("Output value left is negative ".concat(r,"."));case 4:this.addOutput({address:this.refundVault,value:Number(r)}),this.addOutput({address:this.receiver,value:Number(this.requestedAmount)});case 5:return t.a(2)}},t,this)})),function(){return n.apply(this,arguments)})},{key:"internalBuildTransaction",value:(r=pv(fv().m(function t(e){var r,n,i,o,a,s,u=arguments;return fv().w(function(t){for(;;)switch(t.p=t.n){case 0:for(r=u.length>1&&void 0!==u[1]&&u[1],n=this.getInputs(),i=this.getOutputs(),e.setMaximumFeeRate(this._maximumFeeRate),e.addInputs(n,r),o=0;o<this.updateInputs.length;o++)e.updateInput(o,this.updateInputs[o]);return e.addOutputs(i),t.p=1,t.n=2,this.signInputs(e);case 2:return t.a(2,this.finalizeTransactionInputs());case 3:return t.p=3,s=t.v,a=s,this.error("[internalBuildTransaction] Something went wrong while getting building the transaction: ".concat(a.stack)),t.a(2,!1)}},t,this,[[1,3]])})),function(t){return r.apply(this,arguments)})},{key:"signInputs",value:(e=pv(fv().m(function t(e){return fv().w(function(t){for(;;)if(0===t.n)return t.a(2)},t)})),function(t){return e.apply(this,arguments)})},{key:"generateScriptAddress",value:function(){return{internalPubkey:bi(t.numsPoint),network:this.network,scriptTree:this.scriptTree,name:Yi.P2TR}}},{key:"generateTapData",value:function(){var e=this.targetScriptRedeem;if(!e)throw new Error("Left over funds script redeem is required");if(!this.scriptTree)throw new Error("Script tree is required");return{internalPubkey:bi(t.numsPoint),network:this.network,scriptTree:this.scriptTree,redeem:e,name:Yi.P2TR}}},{key:"getScriptSolution",value:function(t){return t.tapScriptSig?t.tapScriptSig.map(function(t){return t.signature}):[]}},{key:"getScriptTree",value:function(){return this.generateRedeemScripts(),[{output:this.compiledTargetScript,version:192},{output:t.LOCK_LEAF_SCRIPT,version:192}]}},{key:"getTotalOutputAmount",value:function(t){var e,r=0n,n=uv(t);try{for(n.s();!(e=n.n()).done;)r+=e.value.value}catch(t){n.e(t)}finally{n.f()}return r}},{key:"calculateOutputLeftAmountFromVaults",value:function(t){return this.getTotalOutputAmount(t)-this.requestedAmount}},{key:"generateRedeemScripts",value:function(){this.targetScriptRedeem={name:Yi.P2TR,output:this.compiledTargetScript,redeemVersion:192},this.leftOverFundsScriptRedeem={name:Yi.P2TR,output:t.LOCK_LEAF_SCRIPT,redeemVersion:192}}}],[{key:"fromBase64",value:function(e){var r=Ao.fromBase64(e.psbt,{network:e.network});return new t(yv(yv({},e),{},{psbt:r}))}},{key:"verifyIfSigned",value:function(t,e){for(var r=!1,n=1;n<t.data.inputs.length;n++){var i=t.data.inputs[n];if(i.finalScriptWitness){var o=By.readScriptWitnessToWitnessStack(i.finalScriptWitness);if(!(o.length<3))for(var a=0;a<o.length-2;a+=3)if(o[a+2].equals(e)){r=!0;break}}}return r}},{key:"signPartial",value:function(e,r,n,i){for(var o=!1,a=!0,s=n;s<e.data.inputs.length;s++){var u=e.data.inputs[s];u.tapInternalKey||(u.tapInternalKey=bi(t.numsPoint));var c=[];if(u.finalScriptWitness){var f=By.readScriptWitnessToWitnessStack(u.finalScriptWitness);u.tapLeafScript=[{leafVersion:192,script:f[f.length-2],controlBlock:f[f.length-1]}];for(var l=0;l<f.length-2;l+=3)c.push({signature:f[l],leafHash:f[l+1],pubkey:f[l+2]});u.tapScriptSig=(u.tapScriptSig||[]).concat(c)}delete u.finalScriptWitness;var h=t.signHashTypesArray?[t.calculateSignHash(t.signHashTypesArray)]:[];try{t.signInput(e,u,s,r,h),o=!0}catch(t){console.log(t)}if(o){if(!u.tapScriptSig)throw new Error("No new signatures for input");u.tapScriptSig.length!==i[s-n]&&(a=!1)}}return{signed:o,final:!!o&&a}}},{key:"dedupeSignatures",value:function(t,e){var r,n=new Map,i=uv(t);try{for(i.s();!(r=i.n()).done;){var o=r.value;n.set(o.pubkey.toString("hex"),o)}}catch(t){i.e(t)}finally{i.f()}var a,s=uv(e);try{for(s.s();!(a=s.n()).done;){var u=a.value;n.has(u.pubkey.toString("hex"))||n.set(u.pubkey.toString("hex"),u)}}catch(t){s.e(t)}finally{s.f()}return Array.from(n.values())}},{key:"attemptFinalizeInputs",value:function(e,r,n,i){for(var o=0,a=function(a){try{var s=e.data.inputs[a];s.tapInternalKey||(s.tapInternalKey=bi(t.numsPoint));var u=[];if(s.finalScriptWitness){for(var c=By.readScriptWitnessToWitnessStack(s.finalScriptWitness),f=0;f<c.length-2;f+=3)u.push({signature:c[f],leafHash:c[f+1],pubkey:c[f+2]});s.tapLeafScript=[{leafVersion:192,script:c[c.length-2],controlBlock:c[c.length-1]}],s.tapScriptSig=t.dedupeSignatures(s.tapScriptSig||[],u)}delete s.finalScriptWitness,e.finalizeInput(a,function(e,o){return t.partialFinalizer(e,o,[],n[a-r],i)}),o++}catch(t){}},s=r;s<e.data.inputs.length;s++)a(s);return o===e.data.inputs.length-r}}]);var e,r,n,i}();mv(_v,"LOCK_LEAF_SCRIPT",w.compile([it.OP_XOR,it.OP_NOP,it.OP_CODESEPARATOR])),mv(_v,"signHashTypesArray",[]),mv(_v,"numsPoint",av.from("50929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac0","hex")),mv(_v,"partialFinalizer",function(t,e,r,n,i){if(!e.tapLeafScript||!e.tapLeafScript[0].script||!e.tapLeafScript[0].controlBlock)throw new Error("Tap leaf script is required");if(!e.tapScriptSig)throw new Error("No new signatures for input ".concat(t,"."));var o=[];if(i){var a,s=uv(n);try{for(s.s();!(a=s.n()).done;){var u,c=a.value,f=!1,l=uv(e.tapScriptSig);try{for(l.s();!(u=l.n()).done;){var h=u.value;h.pubkey.equals(bi(c))&&(o.push(h.signature),f=!0)}}catch(t){l.e(t)}finally{l.f()}f||o.push(av.alloc(0))}}catch(t){s.e(t)}finally{s.f()}o=o.reverse()}else o=e.tapScriptSig.map(function(t){return[t.signature,t.leafHash,t.pubkey]}).flat();r.length>0&&(o=o.concat(r));var p=o.concat(e.tapLeafScript[0].script).concat(e.tapLeafScript[0].controlBlock);return{finalScriptWitness:By.witnessStackToScriptWitness(p)}});var Ev=i(8287).Buffer;function kv(t){return kv="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},kv(t)}function Ov(t){if(null!=t){var e=t["function"==typeof Symbol&&Symbol.iterator||"@@iterator"],r=0;if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length))return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}}}throw new TypeError(kv(t)+" is not iterable")}function Tv(){var t,e,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",i=r.toStringTag||"@@toStringTag";function o(r,n,i,o){var u=n&&n.prototype instanceof s?n:s,c=Object.create(u.prototype);return Av(c,"_invoke",function(r,n,i){var o,s,u,c=0,f=i||[],l=!1,h={p:0,n:0,v:t,a:p,f:p.bind(t,4),d:function(e,r){return o=e,s=0,u=t,h.n=r,a}};function p(r,n){for(s=r,u=n,e=0;!l&&c&&!i&&e<f.length;e++){var i,o=f[e],p=h.p,d=o[2];r>3?(i=d===n)&&(u=o[(s=o[4])?5:(s=3,3)],o[4]=o[5]=t):o[0]<=p&&((i=r<2&&p<o[1])?(s=0,h.v=n,h.n=o[1]):p<d&&(i=r<3||o[0]>n||n>d)&&(o[4]=r,o[5]=n,h.n=d,s=0))}if(i||r>1)return a;throw l=!0,n}return function(i,f,d){if(c>1)throw TypeError("Generator is already running");for(l&&1===f&&p(f,d),s=f,u=d;(e=s<2?t:u)||!l;){o||(s?s<3?(s>1&&(h.n=-1),p(s,u)):h.n=u:h.v=u);try{if(c=2,o){if(s||(i="next"),e=o[i]){if(!(e=e.call(o,u)))throw TypeError("iterator result is not an object");if(!e.done)return e;u=e.value,s<2&&(s=0)}else 1===s&&(e=o.return)&&e.call(o),s<2&&(u=TypeError("The iterator does not provide a '"+i+"' method"),s=1);o=t}else if((e=(l=h.n<0)?u:r.call(n,h))!==a)break}catch(e){o=t,s=1,u=e}finally{c=1}}return{value:e,done:l}}}(r,i,o),!0),c}var a={};function s(){}function u(){}function c(){}e=Object.getPrototypeOf;var f=[][n]?e(e([][n]())):(Av(e={},n,function(){return this}),e),l=c.prototype=s.prototype=Object.create(f);function h(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,c):(t.__proto__=c,Av(t,i,"GeneratorFunction")),t.prototype=Object.create(l),t}return u.prototype=c,Av(l,"constructor",c),Av(c,"constructor",u),u.displayName="GeneratorFunction",Av(c,i,"GeneratorFunction"),Av(l),Av(l,i,"Generator"),Av(l,n,function(){return this}),Av(l,"toString",function(){return"[object Generator]"}),(Tv=function(){return{w:o,m:h}})()}function Av(t,e,r,n){var i=Object.defineProperty;try{i({},"",{})}catch(t){i=0}Av=function(t,e,r,n){function o(e,r){Av(t,e,function(t){return this._invoke(e,r,t)})}e?i?i(t,e,{value:r,enumerable:!n,configurable:!n,writable:!n}):t[e]=r:(o("next",0),o("throw",1),o("return",2))},Av(t,e,r,n)}function Iv(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=xv(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}function Pv(t){return function(t){if(Array.isArray(t))return Bv(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||xv(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function xv(t,e){if(t){if("string"==typeof t)return Bv(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Bv(t,e):void 0}}function Bv(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function Rv(t,e,r,n,i,o,a){try{var s=t[o](a),u=s.value}catch(t){return void r(t)}s.done?e(u):Promise.resolve(u).then(n,i)}function Uv(t){return function(){var e=this,r=arguments;return new Promise(function(n,i){var o=t.apply(e,r);function a(t){Rv(o,n,i,a,s,"next",t)}function s(t){Rv(o,n,i,a,s,"throw",t)}a(void 0)})}}function jv(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Lv(n.key),n)}}function Nv(t,e,r){return(e=Lv(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Lv(t){var e=function(t){if("object"!=kv(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=kv(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==kv(e)?e:e+""}var Cv=function(){return function(t,e){return e&&jv(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}(function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),Nv(this,"utxoPath","address/utxos"),Nv(this,"rpc","json-rpc"),this.opnetAPIUrl=e},[{key:"fetchUTXO",value:(i=Uv(Tv().m(function t(e){var r,n,i,o,a,s,u,c,f,l,h,p,d,y,b,g,v,w,m,S;return Tv().w(function(t){for(;;)switch(t.p=t.n){case 0:return void 0===e.usePendingUTXO&&(e.usePendingUTXO=!0),void 0===e.optimized&&(e.optimized=!0),n={method:"GET",headers:{"Content-Type":"application/json"}},i="".concat(this.opnetAPIUrl,"/api/v1/").concat(this.utxoPath,"?address=").concat(e.address,"&optimize=").concat(null!==(r=e.optimized)&&void 0!==r&&r),t.n=1,fetch(i,n);case 1:if((o=t.v).ok){t.n=2;break}throw new Error("Failed to fetch UTXO data: ".concat(o.statusText));case 2:return t.n=3,o.json();case 3:a=t.v,s=e.usePendingUTXO?[].concat(Pv(a.confirmed),Pv(a.pending)):a.confirmed,u=[],c=Iv(s),t.p=4,l=Tv().m(function t(){var e;return Tv().w(function(t){for(;;)switch(t.n){case 0:if(e=f.value,!a.spentTransactions.some(function(t){return t.transactionId===e.transactionId&&t.outputIndex===e.outputIndex})){t.n=1;break}return t.a(2,1);case 1:u.push(e);case 2:return t.a(2)}},t)}),c.s();case 5:if((f=c.n()).done){t.n=8;break}return t.d(Ov(l()),6);case 6:if(!t.v){t.n=7;break}return t.a(3,7);case 7:t.n=5;break;case 8:t.n=10;break;case 9:t.p=9,m=t.v,c.e(m);case 10:return t.p=10,c.f(),t.f(10);case 11:if(0!==u.length){t.n=12;break}throw new Error("No UTXO found");case 12:if(h=u.filter(function(t){return BigInt(t.value)>=e.minAmount}),0!==h.length){t.n=13;break}throw new Error("No UTXO found (minAmount)");case 13:p=[],d=0n,y=e.requestedAmount,b=Iv(h),t.p=14,b.s();case 15:if((g=b.n()).done){t.n=18;break}if(v=g.value,!((w=BigInt(v.value))<=0n)){t.n=16;break}return t.a(3,17);case 16:if(d+=w,p.push({transactionId:v.transactionId,outputIndex:v.outputIndex,value:w,scriptPubKey:v.scriptPubKey,nonWitnessUtxo:Ev.from(v.raw,"base64")}),!(d>y)){t.n=17;break}return t.a(3,18);case 17:t.n=15;break;case 18:t.n=20;break;case 19:t.p=19,S=t.v,b.e(S);case 20:return t.p=20,b.f(),t.f(20);case 21:return t.a(2,p)}},t,this,[[14,19,20,21],[4,9,10,11]])})),function(t){return i.apply(this,arguments)})},{key:"fetchUTXOMultiAddr",value:(n=Uv(Tv().m(function t(e){var r,n,i,o,a,s,u,c,f,l,h,p;return Tv().w(function(t){for(;;)switch(t.n){case 0:r=[],n=Iv(e.addresses);try{for(n.s();!(i=n.n()).done;)o=i.value,a={address:o,minAmount:e.minAmount,requestedAmount:e.requestedAmount,optimized:e.optimized,usePendingUTXO:e.usePendingUTXO},s=this.fetchUTXO(a).catch(function(){return[]}),r.push(s)}catch(t){n.e(t)}finally{n.f()}return t.n=1,Promise.all(r);case 1:u=t.v,c=u.flat(),f=[],l=0n,h=0;case 2:if(!(h<c.length)){t.n=5;break}if(p=c[h],!(l>=e.requestedAmount)){t.n=3;break}return t.a(3,5);case 3:l+=p.value,f.push(p);case 4:h++,t.n=2;break;case 5:return t.a(2,f)}},t,this)})),function(t){return n.apply(this,arguments)})},{key:"broadcastTransaction",value:(r=Uv(Tv().m(function t(e,r){var n,i;return Tv().w(function(t){for(;;)switch(t.n){case 0:return n=[e,r],t.n=1,this.rpcMethod("btc_sendRawTransaction",n);case 1:if(i=t.v){t.n=2;break}return t.a(2);case 2:return t.a(2,i)}},t,this)})),function(t,e){return r.apply(this,arguments)})},{key:"splitUTXOs",value:(e=Uv(Tv().m(function t(e,r,n,i){var o,a,s,u,c,f,l;return Tv().w(function(t){for(;;)switch(t.n){case 0:return o={addresses:[e.p2wpkh,e.p2tr],minAmount:330n,requestedAmount:1000000000000000n},t.n=1,this.fetchUTXOMultiAddr(o);case 1:if((a=t.v)&&a.length){t.n=2;break}return t.a(2,{error:"No UTXOs found"});case 2:return s=BigInt(n)*i,u={amount:s,feeRate:500,from:e.p2tr,utxos:a,signer:e.keypair,network:r,to:e.p2tr,splitInputsInto:n,priorityFee:0n,gasSatFee:330n},c=new ov,t.n=3,c.createBTCTransfer(u);case 3:return f=t.v,t.n=4,this.broadcastTransaction(f.tx,!1);case 4:if(l=t.v){t.n=5;break}return t.a(2,{error:"Could not broadcast transaction"});case 5:return t.a(2,l)}},t,this)})),function(t,r,n,i){return e.apply(this,arguments)})},{key:"rpcMethod",value:(t=Uv(Tv().m(function t(e,r){var n,i,o,a,s;return Tv().w(function(t){for(;;)switch(t.n){case 0:return n={method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({jsonrpc:"2.0",method:e,params:r,id:1})},i="".concat(this.opnetAPIUrl,"/api/v1/").concat(this.rpc),t.n=1,fetch(i,n);case 1:if((o=t.v).ok){t.n=2;break}throw new Error("Failed to fetch to rpc: ".concat(o.statusText));case 2:return t.n=3,o.json();case 3:if(a=t.v){t.n=4;break}throw new Error("No data fetched");case 4:if(s=a.result){t.n=5;break}throw new Error("No rpc parameters found");case 5:if(!("error"in s)){t.n=6;break}throw new Error("Error in fetching to rpc ".concat(s.error));case 6:return t.a(2,s)}},t,this)})),function(e,r){return t.apply(this,arguments)})}]);var t,e,r,n,i}();function Fv(t){return Fv="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Fv(t)}function Dv(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function Hv(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?Dv(Object(r),!0).forEach(function(e){Gv(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Dv(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function Mv(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,qv(n.key),n)}}function Kv(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(Kv=function(){return!!t})()}function Vv(t){return Vv=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Vv(t)}function Wv(t,e){return Wv=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Wv(t,e)}function Gv(t,e,r){return(e=qv(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function qv(t){var e=function(t){if("object"!=Fv(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Fv(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Fv(e)?e:e+""}var zv,Zv=function(){function t(e){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),Gv(r=function(t,e,r){return e=Vv(e),function(t,e){if(e&&("object"==Fv(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,Kv()?Reflect.construct(e,r||[],Vv(t).constructor):e.apply(t,r))}(this,t,[e]),"logColor","#00ffe1"),Gv(r,"feesAddition",10000n),Gv(r,"sighashTypes",[]),r.signer=e.signer,r.network=e.network,r.transaction=e.psbt,r.ignoreSignatureError(),r.tweakSigner(),r.internalInit(),r}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Wv(t,e)}(t,uy),function(t,e,r){return e&&Mv(t.prototype,e),r&&Mv(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"extractTransaction",value:function(){return this.transaction.extractTransaction()}},{key:"final",value:function(){return this.extractTransaction().toHex()}},{key:"toHex",value:function(){return this.transaction.toHex()}},{key:"addInput",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.transaction.addInput(t,e)}},{key:"addOutput",value:function(t){t.value&&this.transaction.addOutput(t)}},{key:"attemptFinalizeInputs",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;try{for(var e=this.transaction.data.inputs,r=t;r<e.length;r++){var n=e[r];n.finalScriptWitness?this.transaction.finalizeTaprootInput(r,n.finalScriptWitness):this.transaction.finalizeInput(r)}return!0}catch(t){return this.warn(t.stack||"Couldn't finalize inputs"),!1}}},{key:"getPSBT",value:function(){return this.transaction}}],[{key:"fromBase64",value:function(e,r){var n=Ao.fromBase64(e,{network:r.network});return new t(Hv(Hv({},r),{},{psbt:n}))}},{key:"fromHex",value:function(e,r){var n=Ao.fromHex(e,{network:r.network});return new t(Hv(Hv({},r),{},{psbt:n}))}},{key:"from",value:function(e){var r=new Ao({network:e.network});return new t(Hv(Hv({},e),{},{psbt:r}))}}])}();function Xv(t){return Xv="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Xv(t)}function Yv(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,$v(n.key),n)}}function $v(t){var e=function(t){if("object"!=Xv(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Xv(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Xv(e)?e:e+""}!function(t){t[t.UNWRAP=0]="UNWRAP"}(zv||(zv={}));var Jv,Qv=function(){return function(t,e,r){return r&&Yv(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)},0,[{key:"generateMultiSigAddress",value:function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:b.bitcoin;if(bf.verifyPubKeys(t,r).length!==t.length)throw new Error("Contains invalid public keys");var n=new _v({network:r,utxos:[],pubkeys:t,minimumSignatures:e,feeRate:100,receiver:"a",requestedAmount:1n,refundVault:"a"}).getScriptAddress();if(!n)throw new Error("Failed to generate address");return n}}])}(),tw=i(2802),ew=i.n(tw);function rw(t){return rw="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},rw(t)}function nw(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,iw(n.key),n)}}function iw(t){var e=function(t){if("object"!=rw(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=rw(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==rw(e)?e:e+""}!function(t){t.UINT8="UINT8",t.UINT16="UINT16",t.UINT32="UINT32",t.UINT64="UINT64",t.UINT128="UINT128",t.UINT256="UINT256",t.INT128="INT128",t.BOOL="BOOL",t.ADDRESS="ADDRESS",t.STRING="STRING",t.BYTES4="BYTES4",t.BYTES32="BYTES32",t.BYTES="BYTES",t.ADDRESS_UINT256_TUPLE="ADDRESS_UINT256_TUPLE",t.ARRAY_OF_ADDRESSES="ARRAY_OF_ADDRESSES",t.ARRAY_OF_UINT256="ARRAY_OF_UINT256",t.ARRAY_OF_UINT128="ARRAY_OF_UINT128",t.ARRAY_OF_UINT64="ARRAY_OF_UINT64",t.ARRAY_OF_UINT32="ARRAY_OF_UINT32",t.ARRAY_OF_UINT16="ARRAY_OF_UINT16",t.ARRAY_OF_UINT8="ARRAY_OF_UINT8",t.ARRAY_OF_STRING="ARRAY_OF_STRING",t.ARRAY_OF_BYTES="ARRAY_OF_BYTES"}(Jv||(Jv={}));var ow=function(){return function(t,e){return e&&nw(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}(function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)},[{key:"decodeData",value:function(t,e){for(var r=new uh(t),n=[],i=0;i<e.length;i++)switch(e[i]){case Jv.UINT8:n.push(r.readU8());break;case Jv.UINT16:n.push(r.readU16());break;case Jv.UINT32:n.push(r.readU32());break;case Jv.BYTES4:n.push(r.readBytes(4));break;case Jv.BYTES32:n.push(r.readBytes(32));break;case Jv.BOOL:n.push(r.readBoolean());break;case Jv.ADDRESS:n.push(r.readAddress());break;case Jv.STRING:n.push(r.readStringWithLength());break;case Jv.UINT128:n.push(r.readU128());break;case Jv.UINT256:n.push(r.readU256());break;case Jv.INT128:n.push(r.readI128());break;case Jv.ADDRESS_UINT256_TUPLE:n.push(r.readAddressValueTuple());break;case Jv.BYTES:n.push(r.readBytesWithLength());break;case Jv.UINT64:n.push(r.readU64());break;case Jv.ARRAY_OF_ADDRESSES:n.push(r.readAddressArray());break;case Jv.ARRAY_OF_UINT256:n.push(r.readU256Array());break;case Jv.ARRAY_OF_UINT128:n.push(r.readU128Array());break;case Jv.ARRAY_OF_UINT64:n.push(r.readU64Array());break;case Jv.ARRAY_OF_UINT32:n.push(r.readU32Array());break;case Jv.ARRAY_OF_UINT16:n.push(r.readU16Array());break;case Jv.ARRAY_OF_UINT8:n.push(r.readU8Array());break;case Jv.ARRAY_OF_STRING:n.push(r.readStringArray());break;case Jv.ARRAY_OF_BYTES:n.push(r.readBytesArray())}return n}},{key:"encodeSelector",value:function(t){return this.sha256(t).subarray(0,4).toString("hex")}},{key:"numericSelectorToHex",value:function(t){return t.toString(16)}},{key:"bigIntToUint8Array",value:function(t,e){for(var r=new Uint8Array(e),n=Lf.valueToUint8Array(t),i=0;i<e;i++)r[i]=n[i]||0;return r}},{key:"sha256",value:function(t){return(new(ew().sha256)).update(t).digest()}}])}();function aw(t){return aw="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},aw(t)}function sw(){var t,e,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",i=r.toStringTag||"@@toStringTag";function o(r,n,i,o){var u=n&&n.prototype instanceof s?n:s,c=Object.create(u.prototype);return uw(c,"_invoke",function(r,n,i){var o,s,u,c=0,f=i||[],l=!1,h={p:0,n:0,v:t,a:p,f:p.bind(t,4),d:function(e,r){return o=e,s=0,u=t,h.n=r,a}};function p(r,n){for(s=r,u=n,e=0;!l&&c&&!i&&e<f.length;e++){var i,o=f[e],p=h.p,d=o[2];r>3?(i=d===n)&&(u=o[(s=o[4])?5:(s=3,3)],o[4]=o[5]=t):o[0]<=p&&((i=r<2&&p<o[1])?(s=0,h.v=n,h.n=o[1]):p<d&&(i=r<3||o[0]>n||n>d)&&(o[4]=r,o[5]=n,h.n=d,s=0))}if(i||r>1)return a;throw l=!0,n}return function(i,f,d){if(c>1)throw TypeError("Generator is already running");for(l&&1===f&&p(f,d),s=f,u=d;(e=s<2?t:u)||!l;){o||(s?s<3?(s>1&&(h.n=-1),p(s,u)):h.n=u:h.v=u);try{if(c=2,o){if(s||(i="next"),e=o[i]){if(!(e=e.call(o,u)))throw TypeError("iterator result is not an object");if(!e.done)return e;u=e.value,s<2&&(s=0)}else 1===s&&(e=o.return)&&e.call(o),s<2&&(u=TypeError("The iterator does not provide a '"+i+"' method"),s=1);o=t}else if((e=(l=h.n<0)?u:r.call(n,h))!==a)break}catch(e){o=t,s=1,u=e}finally{c=1}}return{value:e,done:l}}}(r,i,o),!0),c}var a={};function s(){}function u(){}function c(){}e=Object.getPrototypeOf;var f=[][n]?e(e([][n]())):(uw(e={},n,function(){return this}),e),l=c.prototype=s.prototype=Object.create(f);function h(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,c):(t.__proto__=c,uw(t,i,"GeneratorFunction")),t.prototype=Object.create(l),t}return u.prototype=c,uw(l,"constructor",c),uw(c,"constructor",u),u.displayName="GeneratorFunction",uw(c,i,"GeneratorFunction"),uw(l),uw(l,i,"Generator"),uw(l,n,function(){return this}),uw(l,"toString",function(){return"[object Generator]"}),(sw=function(){return{w:o,m:h}})()}function uw(t,e,r,n){var i=Object.defineProperty;try{i({},"",{})}catch(t){i=0}uw=function(t,e,r,n){function o(e,r){uw(t,e,function(t){return this._invoke(e,r,t)})}e?i?i(t,e,{value:r,enumerable:!n,configurable:!n,writable:!n}):t[e]=r:(o("next",0),o("throw",1),o("return",2))},uw(t,e,r,n)}function cw(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,fw(n.key),n)}}function fw(t){var e=function(t){if("object"!=aw(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=aw(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==aw(e)?e:e+""}var lw=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.keys=e}return function(t,e){return e&&cw(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"size",get:function(){return this.keys.length}},{key:"add",value:function(t){this.has(t)||this.keys.push(t)}},{key:"has",value:function(t){for(var e=0;e<this.keys.length;e++)if(this.keys[e].equals(t))return!0;return!1}},{key:"remove",value:function(t){var e=this.keys.findIndex(function(e){return e.equals(t)});-1!==e&&this.keys.splice(e,1)}},{key:"clone",value:function(){for(var e=new t,r=0;r<this.keys.length;r++)e.add(this.keys[r]);return e}},{key:"clear",value:function(){this.keys=[]}},{key:"combine",value:function(t){for(var e=this.clone(),r=0;r<t.keys.length;r++)e.add(t.keys[r]);return e}},{key:Symbol.iterator,value:sw().m(function t(){var e;return sw().w(function(t){for(;;)switch(t.n){case 0:e=0;case 1:if(!(e<this.keys.length)){t.n=3;break}return t.n=2,this.keys[e];case 2:e++,t.n=1;break;case 3:return t.a(2)}},t,this)})}])}();function hw(t){return hw="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},hw(t)}function pw(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,i,o,a,s=[],u=!0,c=!1;try{if(o=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=o.call(r)).done)&&(s.push(n.value),s.length!==e);u=!0);}catch(t){c=!0,i=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(c)throw i}}return s}}(t,e)||gw(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function dw(){var t,e,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",i=r.toStringTag||"@@toStringTag";function o(r,n,i,o){var u=n&&n.prototype instanceof s?n:s,c=Object.create(u.prototype);return yw(c,"_invoke",function(r,n,i){var o,s,u,c=0,f=i||[],l=!1,h={p:0,n:0,v:t,a:p,f:p.bind(t,4),d:function(e,r){return o=e,s=0,u=t,h.n=r,a}};function p(r,n){for(s=r,u=n,e=0;!l&&c&&!i&&e<f.length;e++){var i,o=f[e],p=h.p,d=o[2];r>3?(i=d===n)&&(u=o[(s=o[4])?5:(s=3,3)],o[4]=o[5]=t):o[0]<=p&&((i=r<2&&p<o[1])?(s=0,h.v=n,h.n=o[1]):p<d&&(i=r<3||o[0]>n||n>d)&&(o[4]=r,o[5]=n,h.n=d,s=0))}if(i||r>1)return a;throw l=!0,n}return function(i,f,d){if(c>1)throw TypeError("Generator is already running");for(l&&1===f&&p(f,d),s=f,u=d;(e=s<2?t:u)||!l;){o||(s?s<3?(s>1&&(h.n=-1),p(s,u)):h.n=u:h.v=u);try{if(c=2,o){if(s||(i="next"),e=o[i]){if(!(e=e.call(o,u)))throw TypeError("iterator result is not an object");if(!e.done)return e;u=e.value,s<2&&(s=0)}else 1===s&&(e=o.return)&&e.call(o),s<2&&(u=TypeError("The iterator does not provide a '"+i+"' method"),s=1);o=t}else if((e=(l=h.n<0)?u:r.call(n,h))!==a)break}catch(e){o=t,s=1,u=e}finally{c=1}}return{value:e,done:l}}}(r,i,o),!0),c}var a={};function s(){}function u(){}function c(){}e=Object.getPrototypeOf;var f=[][n]?e(e([][n]())):(yw(e={},n,function(){return this}),e),l=c.prototype=s.prototype=Object.create(f);function h(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,c):(t.__proto__=c,yw(t,i,"GeneratorFunction")),t.prototype=Object.create(l),t}return u.prototype=c,yw(l,"constructor",c),yw(c,"constructor",u),u.displayName="GeneratorFunction",yw(c,i,"GeneratorFunction"),yw(l),yw(l,i,"Generator"),yw(l,n,function(){return this}),yw(l,"toString",function(){return"[object Generator]"}),(dw=function(){return{w:o,m:h}})()}function yw(t,e,r,n){var i=Object.defineProperty;try{i({},"",{})}catch(t){i=0}yw=function(t,e,r,n){function o(e,r){yw(t,e,function(t){return this._invoke(e,r,t)})}e?i?i(t,e,{value:r,enumerable:!n,configurable:!n,writable:!n}):t[e]=r:(o("next",0),o("throw",1),o("return",2))},yw(t,e,r,n)}function bw(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=gw(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}function gw(t,e){if(t){if("string"==typeof t)return vw(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?vw(t,e):void 0}}function vw(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function ww(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,mw(n.key),n)}}function mw(t){var e=function(t){if("object"!=hw(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=hw(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==hw(e)?e:e+""}function Sw(t,e){return t.get(Ew(t,e))}function _w(t,e,r){return t.set(Ew(t,e),r),r}function Ew(t,e,r){if("function"==typeof t?t===e:t.has(e))return arguments.length<3?e:r;throw new TypeError("Private element is not present on this object")}var kw=new WeakMap,Ow=function(){function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),function(t,e,r){(function(t,e){if(e.has(t))throw new TypeError("Cannot initialize the same private elements twice on an object")})(t,e),e.set(t,r)}(this,kw,void 0),this.compareFn=e,this.map=new Map,_w(kw,this,[])}return function(t,e,r){return e&&ww(t.prototype,e),r&&ww(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"size",get:function(){return this.map.size}},{key:"set",value:function(t,e){this.map.has(t)||(Sw(kw,this).push(t),Sw(kw,this).sort(this.compareFn)),this.map.set(t,e)}},{key:"get",value:function(t){return this.map.get(t)}},{key:"keys",value:function(){return Sw(kw,this).values()}},{key:"values",value:function(){for(var t=[],e=0;e<Sw(kw,this).length;e++){var r=Sw(kw,this)[e],n=this.map.get(r);if(!n)throw new Error("Value not found");t.push(n)}return t.values()}},{key:"has",value:function(t){return this.map.has(t)}},{key:"delete",value:function(t){return!!this.map.has(t)&&(this.map.delete(t),_w(kw,this,Sw(kw,this).filter(function(e){return e!==t})),!0)}},{key:"clear",value:function(){this.map.clear(),_w(kw,this,[])}},{key:"forEach",value:function(t){var e,r=bw(Sw(kw,this));try{for(r.s();!(e=r.n()).done;){var n=e.value;t(this.map.get(n),n,this)}}catch(t){r.e(t)}finally{r.f()}}},{key:Symbol.iterator,value:dw().m(function t(){var e,r,n,i;return dw().w(function(t){for(;;)switch(t.p=t.n){case 0:e=bw(Sw(kw,this)),t.p=1,e.s();case 2:if((r=e.n()).done){t.n=4;break}return n=r.value,t.n=3,[n,this.map.get(n)];case 3:t.n=2;break;case 4:t.n=6;break;case 5:t.p=5,i=t.v,e.e(i);case 6:return t.p=6,e.f(),t.f(6);case 7:return t.a(2)}},t,this,[[1,5,6,7]])})}],[{key:"fromMap",value:function(e,r){var n,i=new t(r),o=bw(e);try{for(o.s();!(n=o.n()).done;){var a=pw(n.value,2),s=a[0],u=a[1];i.set(s,u)}}catch(t){o.e(t)}finally{o.f()}return i}}])}();function Tw(t){return Tw="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Tw(t)}function Aw(){var t,e,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",i=r.toStringTag||"@@toStringTag";function o(r,n,i,o){var u=n&&n.prototype instanceof s?n:s,c=Object.create(u.prototype);return Iw(c,"_invoke",function(r,n,i){var o,s,u,c=0,f=i||[],l=!1,h={p:0,n:0,v:t,a:p,f:p.bind(t,4),d:function(e,r){return o=e,s=0,u=t,h.n=r,a}};function p(r,n){for(s=r,u=n,e=0;!l&&c&&!i&&e<f.length;e++){var i,o=f[e],p=h.p,d=o[2];r>3?(i=d===n)&&(u=o[(s=o[4])?5:(s=3,3)],o[4]=o[5]=t):o[0]<=p&&((i=r<2&&p<o[1])?(s=0,h.v=n,h.n=o[1]):p<d&&(i=r<3||o[0]>n||n>d)&&(o[4]=r,o[5]=n,h.n=d,s=0))}if(i||r>1)return a;throw l=!0,n}return function(i,f,d){if(c>1)throw TypeError("Generator is already running");for(l&&1===f&&p(f,d),s=f,u=d;(e=s<2?t:u)||!l;){o||(s?s<3?(s>1&&(h.n=-1),p(s,u)):h.n=u:h.v=u);try{if(c=2,o){if(s||(i="next"),e=o[i]){if(!(e=e.call(o,u)))throw TypeError("iterator result is not an object");if(!e.done)return e;u=e.value,s<2&&(s=0)}else 1===s&&(e=o.return)&&e.call(o),s<2&&(u=TypeError("The iterator does not provide a '"+i+"' method"),s=1);o=t}else if((e=(l=h.n<0)?u:r.call(n,h))!==a)break}catch(e){o=t,s=1,u=e}finally{c=1}}return{value:e,done:l}}}(r,i,o),!0),c}var a={};function s(){}function u(){}function c(){}e=Object.getPrototypeOf;var f=[][n]?e(e([][n]())):(Iw(e={},n,function(){return this}),e),l=c.prototype=s.prototype=Object.create(f);function h(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,c):(t.__proto__=c,Iw(t,i,"GeneratorFunction")),t.prototype=Object.create(l),t}return u.prototype=c,Iw(l,"constructor",c),Iw(c,"constructor",u),u.displayName="GeneratorFunction",Iw(c,i,"GeneratorFunction"),Iw(l),Iw(l,i,"Generator"),Iw(l,n,function(){return this}),Iw(l,"toString",function(){return"[object Generator]"}),(Aw=function(){return{w:o,m:h}})()}function Iw(t,e,r,n){var i=Object.defineProperty;try{i({},"",{})}catch(t){i=0}Iw=function(t,e,r,n){function o(e,r){Iw(t,e,function(t){return this._invoke(e,r,t)})}e?i?i(t,e,{value:r,enumerable:!n,configurable:!n,writable:!n}):t[e]=r:(o("next",0),o("throw",1),o("return",2))},Iw(t,e,r,n)}function Pw(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return xw(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?xw(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}function xw(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function Bw(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Rw(n.key),n)}}function Rw(t){var e=function(t){if("object"!=Tw(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Tw(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Tw(e)?e:e+""}var Uw=function(){function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.compareFn=e,this.elements=[]}return function(t,e,r){return e&&Bw(t.prototype,e),r&&Bw(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"add",value:function(t){this.elements.includes(t)||(this.elements.push(t),this.elements.sort(this.compareFn))}},{key:"delete",value:function(t){var e=this.elements.indexOf(t);return-1!==e&&(this.elements.splice(e,1),!0)}},{key:"has",value:function(t){return this.elements.includes(t)}},{key:"clear",value:function(){this.elements=[]}},{key:"forEach",value:function(t){var e,r=Pw(this.elements);try{for(r.s();!(e=r.n()).done;)t(e.value,this)}catch(t){r.e(t)}finally{r.f()}}},{key:"size",get:function(){return this.elements.length}},{key:Symbol.iterator,value:Aw().m(function(){var t,e,r,n;return Aw().w(function(i){for(;;)switch(i.p=i.n){case 0:t=Pw(this.elements),i.p=1,t.s();case 2:if((e=t.n()).done){i.n=4;break}return r=e.value,i.n=3,r;case 3:i.n=2;break;case 4:i.n=6;break;case 5:i.p=5,n=i.v,t.e(n);case 6:return i.p=6,t.f(),i.f(6);case 7:return i.a(2)}},r,this,[[1,5,6,7]])})}],[{key:"fromSet",value:function(e,r){var n,i=new t(r),o=Pw(e);try{for(o.s();!(n=o.n()).done;){var a=n.value;i.add(a)}}catch(t){o.e(t)}finally{o.f()}return i}}])}();function jw(t){return jw="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},jw(t)}function Nw(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Cw(n.key),n)}}function Lw(t,e,r){return e&&Nw(t.prototype,e),r&&Nw(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function Cw(t){var e=function(t){if("object"!=jw(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=jw(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==jw(e)?e:e+""}var Fw=Lw(function t(e,r){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.type=e,this.data=r});function Dw(t){return Dw="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Dw(t)}function Hw(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Kw(n.key),n)}}function Mw(t,e,r){return e&&Hw(t.prototype,e),r&&Hw(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function Kw(t){var e=function(t){if("object"!=Dw(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Dw(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Dw(e)?e:e+""}var Vw,Ww,Gw,qw,zw=Mw(function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)});!function(t){t.testnet="testnet",t.mainnet="livenet",t.regtest="regtest"}(Vw||(Vw={})),function(t){t.BITCOIN_MAINNET="BITCOIN_MAINNET",t.BITCOIN_TESTNET="BITCOIN_TESTNET",t.BITCOIN_TESTNET4="BITCOIN_TESTNET4",t.BITCOIN_REGTEST="BITCOIN_REGTEST",t.BITCOIN_SIGNET="BITCOIN_SIGNET",t.FRACTAL_BITCOIN_MAINNET="FRACTAL_BITCOIN_MAINNET",t.FRACTAL_BITCOIN_TESTNET="FRACTAL_BITCOIN_TESTNET"}(Ww||(Ww={})),function(t){t.ecdsa="ecdsa",t.bip322="bip322-simple"}(Gw||(Gw={})),function(t){t.ecdsa="ecdsa",t.schnorr="schnorr"}(qw||(qw={}));var Zw=i(8287).Buffer;function Xw(t){return Xw="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Xw(t)}function Yw(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return $w(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?$w(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}function $w(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function Jw(){var t,e,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",i=r.toStringTag||"@@toStringTag";function o(r,n,i,o){var u=n&&n.prototype instanceof s?n:s,c=Object.create(u.prototype);return Qw(c,"_invoke",function(r,n,i){var o,s,u,c=0,f=i||[],l=!1,h={p:0,n:0,v:t,a:p,f:p.bind(t,4),d:function(e,r){return o=e,s=0,u=t,h.n=r,a}};function p(r,n){for(s=r,u=n,e=0;!l&&c&&!i&&e<f.length;e++){var i,o=f[e],p=h.p,d=o[2];r>3?(i=d===n)&&(u=o[(s=o[4])?5:(s=3,3)],o[4]=o[5]=t):o[0]<=p&&((i=r<2&&p<o[1])?(s=0,h.v=n,h.n=o[1]):p<d&&(i=r<3||o[0]>n||n>d)&&(o[4]=r,o[5]=n,h.n=d,s=0))}if(i||r>1)return a;throw l=!0,n}return function(i,f,d){if(c>1)throw TypeError("Generator is already running");for(l&&1===f&&p(f,d),s=f,u=d;(e=s<2?t:u)||!l;){o||(s?s<3?(s>1&&(h.n=-1),p(s,u)):h.n=u:h.v=u);try{if(c=2,o){if(s||(i="next"),e=o[i]){if(!(e=e.call(o,u)))throw TypeError("iterator result is not an object");if(!e.done)return e;u=e.value,s<2&&(s=0)}else 1===s&&(e=o.return)&&e.call(o),s<2&&(u=TypeError("The iterator does not provide a '"+i+"' method"),s=1);o=t}else if((e=(l=h.n<0)?u:r.call(n,h))!==a)break}catch(e){o=t,s=1,u=e}finally{c=1}}return{value:e,done:l}}}(r,i,o),!0),c}var a={};function s(){}function u(){}function c(){}e=Object.getPrototypeOf;var f=[][n]?e(e([][n]())):(Qw(e={},n,function(){return this}),e),l=c.prototype=s.prototype=Object.create(f);function h(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,c):(t.__proto__=c,Qw(t,i,"GeneratorFunction")),t.prototype=Object.create(l),t}return u.prototype=c,Qw(l,"constructor",c),Qw(c,"constructor",u),u.displayName="GeneratorFunction",Qw(c,i,"GeneratorFunction"),Qw(l),Qw(l,i,"Generator"),Qw(l,n,function(){return this}),Qw(l,"toString",function(){return"[object Generator]"}),(Jw=function(){return{w:o,m:h}})()}function Qw(t,e,r,n){var i=Object.defineProperty;try{i({},"",{})}catch(t){i=0}Qw=function(t,e,r,n){function o(e,r){Qw(t,e,function(t){return this._invoke(e,r,t)})}e?i?i(t,e,{value:r,enumerable:!n,configurable:!n,writable:!n}):t[e]=r:(o("next",0),o("throw",1),o("return",2))},Qw(t,e,r,n)}function tm(t,e,r,n,i,o,a){try{var s=t[o](a),u=s.value}catch(t){return void r(t)}s.done?e(u):Promise.resolve(u).then(n,i)}function em(t){return function(){var e=this,r=arguments;return new Promise(function(n,i){var o=t.apply(e,r);function a(t){tm(o,n,i,a,s,"next",t)}function s(t){tm(o,n,i,a,s,"throw",t)}a(void 0)})}}function rm(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,am(n.key),n)}}function nm(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(nm=function(){return!!t})()}function im(t){return im=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},im(t)}function om(t,e){return om=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},om(t,e)}function am(t){var e=function(t){if("object"!=Xw(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Xw(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Xw(e)?e:e+""}var sm=function(){function t(){var e;if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),function(t,e,r){(e=am(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r}(e=function(t,e,r){return e=im(e),function(t,e){if(e&&("object"==Xw(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,nm()?Reflect.construct(e,r||[],im(t).constructor):e.apply(t,r))}(this,t),"isInitialized",!1),!window)throw new Error("UnisatSigner can only be used in a browser environment");return e}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&om(t,e)}(t,zw),function(t,e){return e&&rm(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"p2tr",get:function(){if(!this._p2tr)throw new Error("P2TR address not set");return this._p2tr}},{key:"p2wpkh",get:function(){if(!this._p2wpkh)throw new Error("P2PKH address not set");return this._p2wpkh}},{key:"addresses",get:function(){if(!this._addresses)throw new Error("Addresses not set");return this._addresses}},{key:"publicKey",get:function(){if(!this._publicKey)throw new Error("Public key not set");return this._publicKey}},{key:"network",get:function(){if(!this._network)throw new Error("Network not set");return this._network}},{key:"unisat",get:function(){if(!window)throw new Error("Window not found");var t=window.unisat;if(!t)throw new Error("Unisat extension not found");return t}},{key:"signData",value:(a=em(Jw().m(function t(e,r){var n,i;return Jw().w(function(t){for(;;)switch(t.n){case 0:return n=e.toString("hex"),t.n=1,this.unisat.signData(n,r);case 1:return i=t.v,t.a(2,Zw.from(i,"hex"))}},t,this)})),function(t,e){return a.apply(this,arguments)})},{key:"init",value:(o=em(Jw().m(function t(){var e,r,n;return Jw().w(function(t){for(;;)switch(t.n){case 0:if(!this.isInitialized){t.n=1;break}return t.a(2);case 1:return t.n=2,this.unisat.getNetwork();case 2:e=t.v,n=e,t.n=n===Vw.mainnet?3:n===Vw.testnet?4:n===Vw.regtest?5:6;break;case 3:return this._network=b.bitcoin,t.a(3,7);case 4:return this._network=b.testnet,t.a(3,7);case 5:return this._network=b.regtest,t.a(3,7);case 6:throw new Error("Invalid network: ".concat(e));case 7:return t.n=8,this.unisat.getPublicKey();case 8:if(""!==(r=t.v)){t.n=9;break}throw new Error("Unlock your wallet first");case 9:this._publicKey=Zw.from(r,"hex"),this._p2wpkh=bf.getP2WPKHAddress(this,this.network),this._p2tr=bf.getTaprootAddress(this,this.network),this._addresses=[this._p2wpkh,this._p2tr],this.isInitialized=!0;case 10:return t.a(2)}},t,this)})),function(){return o.apply(this,arguments)})},{key:"getPublicKey",value:function(){if(!this.isInitialized)throw new Error("UnisatSigner not initialized");return this.publicKey}},{key:"sign",value:function(t,e){throw new Error("Not implemented: sign")}},{key:"signSchnorr",value:function(t){throw new Error("Not implemented: signSchnorr")}},{key:"verify",value:function(t,e){throw new Error("Not implemented: verify")}},{key:"signTaprootInput",value:(i=em(Jw().m(function t(e,r,n){var i,o;return Jw().w(function(t){for(;;)switch(t.n){case 0:if(!((i=e.data.inputs[r]).tapKeySig||i.finalScriptSig||Array.isArray(i.partialSig)&&i.partialSig.length&&this.hasAlreadyPartialSig(i.partialSig)||Array.isArray(i.tapScriptSig)&&i.tapScriptSig.length&&this.hasAlreadySignedTapScriptSig(i.tapScriptSig))){t.n=1;break}return t.a(2);case 1:return t.n=2,this.signAllTweaked(e,n,!1);case 2:o=t.v,this.combine(e,o,r);case 3:return t.a(2)}},t,this)})),function(t,e,r){return i.apply(this,arguments)})},{key:"signInput",value:(n=em(Jw().m(function t(e,r,n){var i,o;return Jw().w(function(t){for(;;)switch(t.n){case 0:if(!((i=e.data.inputs[r]).tapKeySig||i.finalScriptSig||Array.isArray(i.partialSig)&&i.partialSig.length&&this.hasAlreadyPartialSig(i.partialSig)||Array.isArray(i.tapScriptSig)&&i.tapScriptSig.length&&this.hasAlreadySignedTapScriptSig(i.tapScriptSig))){t.n=1;break}return t.a(2);case 1:return t.n=2,this.signAllTweaked(e,n,!0);case 2:o=t.v,this.combine(e,o,r);case 3:return t.a(2)}},t,this)})),function(t,e,r){return n.apply(this,arguments)})},{key:"multiSignPsbt",value:(r=em(Jw().m(function t(e){var r,n,i,o,a,s,u,c,f,l=this;return Jw().w(function(t){for(;;)switch(t.n){case 0:r=[],n=[],i=Yw(e);try{for(i.s();!(o=i.n()).done;)a=o.value,s=a.toHex(),r.push(s),u=a.data.inputs.map(function(t,e){var r=!1,n=!1;if(Wd(t)){if(t.tapLeafScript&&t.tapLeafScript.length>0){var i,o=Yw(t.tapLeafScript);try{for(o.s();!(i=o.n()).done;){var a=i.value;if(um(l.publicKey,a.script)){r=!0,n=!1;break}}}catch(t){o.e(t)}finally{o.f()}}if(!r&&t.tapInternalKey){var s=t.tapInternalKey,u=bi(l.publicKey);s.equals(u)&&(r=!0,n=!0)}}else Gd(t,l.publicKey)&&(r=!0,n=!1);return r?{index:e,publicKey:l.publicKey.toString("hex"),disableTweakSigner:!n}:null}).filter(function(t){return null!==t}),n.push({autoFinalized:!1,toSignInputs:u})}catch(t){i.e(t)}finally{i.f()}return t.n=1,this.unisat.signPsbt(r[0],n[0]);case 1:c=t.v,f=Ao.fromHex(c),e[0].combine(f);case 2:return t.a(2)}},t,this)})),function(t){return r.apply(this,arguments)})},{key:"hasAlreadySignedTapScriptSig",value:function(t){for(var e=0;e<t.length;e++){var r=t[e];if(Zw.from(r.pubkey).equals(this.publicKey)&&r.signature)return!0}return!1}},{key:"hasAlreadyPartialSig",value:function(t){for(var e=0;e<t.length;e++){var r=t[e];if(Zw.from(r.pubkey).equals(this.publicKey)&&r.signature)return!0}return!1}},{key:"combine",value:function(t,e,r){var n,i=e.data.inputs[r],o=t.data.inputs[r];if(i.partialSig&&t.updateInput(r,{partialSig:i.partialSig}),i.tapKeySig&&!o.tapKeySig&&t.updateInput(r,{tapKeySig:i.tapKeySig}),null!==(n=i.tapScriptSig)&&void 0!==n&&n.length){var a=o.tapScriptSig;if(a){var s=this.getNonDuplicateScriptSig(a,i.tapScriptSig);s.length&&t.updateInput(r,{tapScriptSig:s})}else t.updateInput(r,{tapScriptSig:i.tapScriptSig})}}},{key:"signAllTweaked",value:(e=em(Jw().m(function t(e,r){var n,i,o,a,s,u,c=arguments;return Jw().w(function(t){for(;;)switch(t.n){case 0:return n=c.length>2&&void 0!==c[2]&&c[2],i=this.publicKey.toString("hex"),o=e.data.inputs.map(function(t,e){return[{index:e,publicKey:i,sighashTypes:r,disableTweakSigner:n}]}),a={autoFinalized:!1,toSignInputs:o.flat()},s=e.toHex(),t.n=1,this.unisat.signPsbt(s,a);case 1:return u=t.v,t.a(2,Ao.fromHex(u))}},t,this)})),function(t,r){return e.apply(this,arguments)})},{key:"getNonDuplicateScriptSig",value:function(t,e){for(var r=[],n=function(n){t.find(function(t){return t.pubkey.equals(e[n].pubkey)})||r.push(e[n])},i=0;i<e.length;i++)n(i);return r}}]);var e,r,n,i,o,a}();function um(t,e){return-1!==function(t,e){var r=S.hash160(t),n=bi(t),i=w.decompile(e);if(null===i)throw new Error("Unknown script error");return i.findIndex(function(e){return"number"!=typeof e&&Zw.isBuffer(e)&&(e.equals(t)||e.equals(r)||e.equals(n))})}(t,e)}var cm=i(8287).Buffer;function fm(t){return fm="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},fm(t)}function lm(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return hm(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?hm(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}function hm(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function pm(){var t,e,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",i=r.toStringTag||"@@toStringTag";function o(r,n,i,o){var u=n&&n.prototype instanceof s?n:s,c=Object.create(u.prototype);return dm(c,"_invoke",function(r,n,i){var o,s,u,c=0,f=i||[],l=!1,h={p:0,n:0,v:t,a:p,f:p.bind(t,4),d:function(e,r){return o=e,s=0,u=t,h.n=r,a}};function p(r,n){for(s=r,u=n,e=0;!l&&c&&!i&&e<f.length;e++){var i,o=f[e],p=h.p,d=o[2];r>3?(i=d===n)&&(u=o[(s=o[4])?5:(s=3,3)],o[4]=o[5]=t):o[0]<=p&&((i=r<2&&p<o[1])?(s=0,h.v=n,h.n=o[1]):p<d&&(i=r<3||o[0]>n||n>d)&&(o[4]=r,o[5]=n,h.n=d,s=0))}if(i||r>1)return a;throw l=!0,n}return function(i,f,d){if(c>1)throw TypeError("Generator is already running");for(l&&1===f&&p(f,d),s=f,u=d;(e=s<2?t:u)||!l;){o||(s?s<3?(s>1&&(h.n=-1),p(s,u)):h.n=u:h.v=u);try{if(c=2,o){if(s||(i="next"),e=o[i]){if(!(e=e.call(o,u)))throw TypeError("iterator result is not an object");if(!e.done)return e;u=e.value,s<2&&(s=0)}else 1===s&&(e=o.return)&&e.call(o),s<2&&(u=TypeError("The iterator does not provide a '"+i+"' method"),s=1);o=t}else if((e=(l=h.n<0)?u:r.call(n,h))!==a)break}catch(e){o=t,s=1,u=e}finally{c=1}}return{value:e,done:l}}}(r,i,o),!0),c}var a={};function s(){}function u(){}function c(){}e=Object.getPrototypeOf;var f=[][n]?e(e([][n]())):(dm(e={},n,function(){return this}),e),l=c.prototype=s.prototype=Object.create(f);function h(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,c):(t.__proto__=c,dm(t,i,"GeneratorFunction")),t.prototype=Object.create(l),t}return u.prototype=c,dm(l,"constructor",c),dm(c,"constructor",u),u.displayName="GeneratorFunction",dm(c,i,"GeneratorFunction"),dm(l),dm(l,i,"Generator"),dm(l,n,function(){return this}),dm(l,"toString",function(){return"[object Generator]"}),(pm=function(){return{w:o,m:h}})()}function dm(t,e,r,n){var i=Object.defineProperty;try{i({},"",{})}catch(t){i=0}dm=function(t,e,r,n){function o(e,r){dm(t,e,function(t){return this._invoke(e,r,t)})}e?i?i(t,e,{value:r,enumerable:!n,configurable:!n,writable:!n}):t[e]=r:(o("next",0),o("throw",1),o("return",2))},dm(t,e,r,n)}function ym(t,e,r,n,i,o,a){try{var s=t[o](a),u=s.value}catch(t){return void r(t)}s.done?e(u):Promise.resolve(u).then(n,i)}function bm(t){return function(){var e=this,r=arguments;return new Promise(function(n,i){var o=t.apply(e,r);function a(t){ym(o,n,i,a,s,"next",t)}function s(t){ym(o,n,i,a,s,"throw",t)}a(void 0)})}}function gm(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,_m(n.key),n)}}function vm(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(vm=function(){return!!t})()}function wm(t){return wm=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},wm(t)}function mm(t,e){return mm=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},mm(t,e)}function Sm(t,e,r){return(e=_m(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function _m(t){var e=function(t){if("object"!=fm(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=fm(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==fm(e)?e:e+""}var Em,km,Om=function(){function t(){var e;if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),Sm(e=function(t,e,r){return e=wm(e),function(t,e){if(e&&("object"==fm(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,vm()?Reflect.construct(e,r||[],wm(t).constructor):e.apply(t,r))}(this,t),"isInitialized",!1),!window)throw new Error("XverseSigner can only be used in a browser environment");return e}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&mm(t,e)}(t,zw),function(t,e){return e&&gm(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"p2tr",get:function(){if(!this._p2tr)throw new Error("P2TR address not set");return this._p2tr}},{key:"p2wpkh",get:function(){if(!this._p2wpkh)throw new Error("P2PKH address not set");return this._p2wpkh}},{key:"addresses",get:function(){if(!this._addresses)throw new Error("Addresses not set");return this._addresses}},{key:"publicKey",get:function(){if(!this._publicKey)throw new Error("Public key not set");return this._publicKey}},{key:"network",get:function(){if(!this._network)throw new Error("Network not set");return this._network}},{key:"BitcoinProvider",get:function(){var t=window.BitcoinProvider;if(!t)throw new Error("Xverse Wallet extension not found");return t}},{key:"init",value:(a=bm(pm().m(function t(){var e,r,n;return pm().w(function(t){for(;;)switch(t.n){case 0:if(!this.isInitialized){t.n=1;break}return t.a(2);case 1:return t.n=2,this.BitcoinProvider.request("wallet_connect",null);case 2:if(!("error"in(e=t.v))){t.n=3;break}throw new Error(e.error.message);case 3:if(r=e.result.addresses.find(function(t){return"payment"===t.purpose})){t.n=4;break}throw new Error("Payment address not found");case 4:if(n=r.address.startsWith("tb")?b.testnet:r.address.startsWith("bc")?b.bitcoin:null){t.n=5;break}throw new Error("Network not supported");case 5:this._network=n,this._publicKey=cm.from(r.publicKey,"hex"),this._p2wpkh=bf.getP2WPKHAddress(this,this.network),this._p2tr=bf.getTaprootAddress(this,this.network),this._addresses=[this._p2wpkh,this._p2tr],this.isInitialized=!0;case 6:return t.a(2)}},t,this)})),function(){return a.apply(this,arguments)})},{key:"signData",value:(o=bm(pm().m(function t(e,r,n){var i,o;return pm().w(function(t){for(;;)switch(t.n){case 0:if(this.isInitialized){t.n=1;break}throw new Error("UnisatSigner not initialized");case 1:return t.n=2,this.BitcoinProvider.request("signMessage",{address:r,message:e.toString(),protocol:n});case 2:if(!("error"in(i=t.v))){t.n=3;break}throw new Error(i.error.message);case 3:if((o=i.result).signature){t.n=4;break}throw new Error("Signature not found");case 4:return t.a(2,cm.from(o.signature,"hex"))}},t,this)})),function(t,e,r){return o.apply(this,arguments)})},{key:"getPublicKey",value:function(){if(!this.isInitialized)throw new Error("UnisatSigner not initialized");return this.publicKey}},{key:"sign",value:function(t,e){throw new Error("Not implemented: sign")}},{key:"signSchnorr",value:function(t){throw new Error("Not implemented: signSchnorr")}},{key:"verify",value:function(t,e){throw new Error("Not implemented: verify")}},{key:"signTaprootInput",value:(i=bm(pm().m(function t(e,r,n){var i,o;return pm().w(function(t){for(;;)switch(t.n){case 0:if(!((i=e.data.inputs[r]).tapKeySig||i.finalScriptSig||Array.isArray(i.partialSig)&&i.partialSig.length&&this.hasAlreadyPartialSig(i.partialSig)||Array.isArray(i.tapScriptSig)&&i.tapScriptSig.length&&this.hasAlreadySignedTapScriptSig(i.tapScriptSig))){t.n=1;break}return t.a(2);case 1:return t.n=2,this.signAllTweaked(e,n,!1);case 2:o=t.v,this.combine(e,o,r);case 3:return t.a(2)}},t,this)})),function(t,e,r){return i.apply(this,arguments)})},{key:"signInput",value:(n=bm(pm().m(function t(e,r,n){var i,o;return pm().w(function(t){for(;;)switch(t.n){case 0:if(!((i=e.data.inputs[r]).tapKeySig||i.finalScriptSig||Array.isArray(i.partialSig)&&i.partialSig.length&&this.hasAlreadyPartialSig(i.partialSig)||Array.isArray(i.tapScriptSig)&&i.tapScriptSig.length&&this.hasAlreadySignedTapScriptSig(i.tapScriptSig))){t.n=1;break}return t.a(2);case 1:return t.n=2,this.signAllTweaked(e,n,!0);case 2:o=t.v,this.combine(e,o,r);case 3:return t.a(2)}},t,this)})),function(t,e,r){return n.apply(this,arguments)})},{key:"multiSignPsbt",value:(r=bm(pm().m(function t(e){var r,n,i,o,a,s,u,c,f,l,h,p=this;return pm().w(function(t){for(;;)switch(t.n){case 0:n=[],i=[],o=lm(e);try{for(o.s();!(a=o.n()).done;)s=a.value,u=s.toBase64(),n.push(u),c=s.data.inputs.map(function(t,e){var r=!1,n=!1;if(Wd(t)){if(t.tapLeafScript&&t.tapLeafScript.length>0){var i,o=lm(t.tapLeafScript);try{for(o.s();!(i=o.n()).done;){var a=i.value;if(qd(p.publicKey,a.script)){r=!0,n=!1;break}}}catch(t){o.e(t)}finally{o.f()}}if(!r&&t.tapInternalKey){var s=t.tapInternalKey,u=bi(p.publicKey);s.equals(u)&&(r=!0,n=!0)}}else Gd(t,p.publicKey)&&(r=!0,n=!1);return r?{index:e,publicKey:p.publicKey.toString("hex"),disableTweakSigner:!n}:null}).filter(function(t){return null!==t}),i.push({autoFinalized:!1,toSignInputs:c})}catch(t){o.e(t)}finally{o.f()}return f=Sm({},this.p2wpkh,(null===(r=i[0].toSignInputs)||void 0===r?void 0:r.map(function(t){return t.index}))||[]),t.n=1,this.BitcoinProvider.request("signPsbt",{psbt:n[0],signInputs:f});case 1:if(!("error"in(l=t.v))){t.n=2;break}throw new Error(l.error.message);case 2:h=Ao.fromBase64(l.result.psbt),e[0].combine(h);case 3:return t.a(2)}},t,this)})),function(t){return r.apply(this,arguments)})},{key:"hasAlreadySignedTapScriptSig",value:function(t){for(var e=0;e<t.length;e++){var r=t[e];if(cm.from(r.pubkey).equals(this.publicKey)&&r.signature)return!0}return!1}},{key:"hasAlreadyPartialSig",value:function(t){for(var e=0;e<t.length;e++){var r=t[e];if(cm.from(r.pubkey).equals(this.publicKey)&&r.signature)return!0}return!1}},{key:"combine",value:function(t,e,r){var n,i=e.data.inputs[r],o=t.data.inputs[r];if(i.partialSig&&t.updateInput(r,{partialSig:i.partialSig}),i.tapKeySig&&!o.tapKeySig&&t.updateInput(r,{tapKeySig:i.tapKeySig}),null!==(n=i.tapScriptSig)&&void 0!==n&&n.length){var a=o.tapScriptSig;if(a){var s=this.getNonDuplicateScriptSig(a,i.tapScriptSig);s.length&&t.updateInput(r,{tapScriptSig:s})}else t.updateInput(r,{tapScriptSig:i.tapScriptSig})}}},{key:"signAllTweaked",value:(e=bm(pm().m(function t(e,r){var n,i,o,a,s,u,c,f,l=arguments;return pm().w(function(t){for(;;)switch(t.n){case 0:return i=l.length>2&&void 0!==l[2]&&l[2],o=this.publicKey.toString("hex"),a=e.data.inputs.map(function(t,e){return[{index:e,publicKey:o,sighashTypes:r,disableTweakSigner:i}]}),s={autoFinalized:!1,toSignInputs:a.flat()},u=e.toBase64(),c=Sm({},this.p2wpkh,(null===(n=s.toSignInputs)||void 0===n?void 0:n.map(function(t){return t.index}))||[]),t.n=1,this.BitcoinProvider.request("signPsbt",{psbt:u,signInputs:c});case 1:if(!("error"in(f=t.v))){t.n=2;break}throw new Error(f.error.message);case 2:return t.a(2,Ao.fromBase64(f.result.psbt))}},t,this)})),function(t,r){return e.apply(this,arguments)})},{key:"getNonDuplicateScriptSig",value:function(t,e){for(var r=[],n=function(n){t.find(function(t){return t.pubkey.equals(e[n].pubkey)})||r.push(e[n])},i=0;i<e.length;i++)n(i);return r}}]);var e,r,n,i,o,a}();function Tm(t){return Tm="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Tm(t)}function Am(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Pm(n.key),n)}}function Im(t,e,r){return(e=Pm(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Pm(t){var e=function(t){if("object"!=Tm(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Tm(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Tm(e)?e:e+""}function xm(){return ih.dead()}!function(t){t.mainnet="mainnet",t.testnet="testnet",t.signet="Signet"}(Em||(Em={})),function(t){t.ECDSA="ECDSA",t.BIP322="BIP322"}(km||(km={}));var Bm,Rm=xm(),Um=xm(),jm=xm(),Nm=xm(),Lm=xm(),Cm=xm(),Fm=xm(),Dm=xm(),Hm=xm(),Mm=xm(),Km=xm(),Vm=xm(),Wm=xm(),Gm=xm(),qm=xm();!function(t){t.Mainnet="mainnet",t.Testnet="testnet",t.Regtest="regtest"}(Bm||(Bm={}));var zm=function(){return function(t,e){return e&&Am(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}(function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),Im(this,"metadata",Im(Im({},$y.Bitcoin,Im(Im({},Bm.Testnet,{factory:Cm,pool:Fm,wbtc:Dm,moto:Hm,router:Mm}),Bm.Regtest,{factory:Rm,pool:Um,wbtc:jm,moto:Nm,router:Lm})),$y.Fractal,Im({},Bm.Mainnet,{factory:Km,pool:Vm,wbtc:Wm,moto:Gm,router:qm})))},[{key:"getFactoryAddress",value:function(t,e){var r,n=null===(r=this.metadata[e][t])||void 0===r?void 0:r.factory;if(!n)throw new Error("Factory address not found for network ".concat(t," and chainId ").concat(e));return n}},{key:"getPoolAddress",value:function(t,e){var r,n=null===(r=this.metadata[e][t])||void 0===r?void 0:r.pool;if(!n)throw new Error("Pool address not found for network ".concat(t," and chainId ").concat(e));return n}},{key:"getWBTCAddress",value:function(t,e){var r,n=null===(r=this.metadata[e][t])||void 0===r?void 0:r.wbtc;if(!n)throw new Error("WBTC address not found for network ".concat(t," and chainId ").concat(e));return n}},{key:"getMOTOAddress",value:function(t,e){var r,n=null===(r=this.metadata[e][t])||void 0===r?void 0:r.moto;if(!n)throw new Error("MOTO address not found for network ".concat(t," and chainId ").concat(e));return n}},{key:"getRouterAddress",value:function(t,e){var r,n=null===(r=this.metadata[e][t])||void 0===r?void 0:r.router;if(!n)throw new Error("Router address not found for network ".concat(t," and chainId ").concat(e));return n}},{key:"getAddresses",value:function(t,e){var r=this.metadata[e][t];if(!r)throw new Error("Metadata not found for network ".concat(t," and chainId ").concat(e));return r}}])}(),Zm=new zm;export{ow as ABICoder,Jv as ABIDataTypes,gf as ADDRESS_BYTE_LENGTH,xy as ANCHOR_SCRIPT,ih as Address,xp as AddressGenerator,Jf as AddressMap,lw as AddressSet,hl as AddressTypes,vl as AddressVerificator,Bf as BOOLEAN_BYTE_LENGTH,uh as BinaryReader,ph as BinaryWriter,sl as BitcoinUtils,Lf as BufferHelper,Kd as CSVModes,Uh as CalldataGenerator,$y as ChainId,Gg as ChallengeSolution,Wg as ChallengeSubmission,Vg as ChallengeVerification,h as Compressor,Qy as Consensus,xl as ContractAddress,tb as ContractBaseMetadata,Hh as CustomGenerator,zw as CustomKeypair,_b as CustomScriptTransaction,Jh as DeploymentGenerator,Jb as DeploymentTransaction,Ow as DeterministicMap,Uw as DeterministicSet,bf as EcKeyPair,Cg as EpochValidator,Km as FACTORY_ADDRESS_FRACTAL,Rm as FACTORY_ADDRESS_REGTEST,Cm as FACTORY_ADDRESS_TESTNET,hh as Features,cg as FundingTransaction,_h as Generator,Tf as I128_BYTE_LENGTH,Pf as I16_BYTE_LENGTH,Of as I256_BYTE_LENGTH,If as I32_BYTE_LENGTH,Af as I64_BYTE_LENGTH,xf as I8_BYTE_LENGTH,vg as InteractionTransaction,xg as InteractionTransactionP2WDA,cp as LegacyCalldataGenerator,Py as MINIMUM_AMOUNT_CA,Iy as MINIMUM_AMOUNT_REWARD,Gm as MOTO_ADDRESS_FRACTAL,Nm as MOTO_ADDRESS_REGTEST,Hm as MOTO_ADDRESS_TESTNET,Ky as MessageSigner,Gw as MessageType,yp as MultiSignGenerator,_v as MultiSignTransaction,Fw as NetEvent,Yh as OPNET_DEPLOYMENT_VERSION,nb as OPNetConsensusConfig,Cv as OPNetLimitedProvider,Zm as OPNetMetadata,Bm as OPNetNetwork,zm as OPNetTokenAddressManager,Qv as P2TR_MS,pl as P2WDADetector,Op as P2WDAGenerator,Vm as POOL_ADDRESS_FRACTAL,Um as POOL_ADDRESS_REGTEST,Fm as POOL_ADDRESS_TESTNET,zv as PSBTTypes,Zv as PsbtTransaction,qm as ROUTER_ADDRESS_FRACTAL,Lm as ROUTER_ADDRESS_REGTEST,Mm as ROUTER_ADDRESS_TESTNET,eb as RoswellConsensus,vf as SELECTOR_BYTE_LENGTH,kl as Secp256k1PointDeriver,Cb as SharedInteractionTransaction,qw as SignatureType,km as SigningProtocol,Ly as TapscriptVerificator,jl as TimeLockGenerator,By as TransactionBuilder,ov as TransactionFactory,Md as TransactionSequence,Jy as TransactionType,Vd as TweakedSigner,uy as TweakedTransaction,mf as U128_BYTE_LENGTH,Ef as U16_BYTE_LENGTH,wf as U256_BYTE_LENGTH,_f as U32_BYTE_LENGTH,Sf as U64_BYTE_LENGTH,kf as U8_BYTE_LENGTH,Ww as UnisatChainType,Vw as UnisatNetwork,sm as UnisatSigner,Wm as WBTC_ADDRESS_FRACTAL,jm as WBTC_ADDRESS_REGTEST,Dm as WBTC_ADDRESS_TESTNET,zy as Wallet,Em as XverseNetwork,Om as XverseSigner,ib as currentConsensus,ob as currentConsensusConfig,o as opnet,a as version,$h as versionBuffer};