opnet 1.0.2 → 1.0.11

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.
Files changed (54) hide show
  1. package/.babelrc +7 -0
  2. package/.idea/{OPNet.iml → opnet.iml} +1 -0
  3. package/browser/block/Block.d.ts +27 -0
  4. package/browser/index.d.ts +15 -0
  5. package/browser/index.js +2 -0
  6. package/browser/index.js.LICENSE.txt +14 -0
  7. package/browser/interfaces/blocks/IBlock.d.ts +28 -0
  8. package/browser/interfaces/opnet/OPNetTransactionTypes.d.ts +5 -0
  9. package/browser/interfaces/transactions/ITransaction.d.ts +31 -0
  10. package/browser/providers/JSONRpcProvider.d.ts +12 -0
  11. package/browser/scripts/test.d.ts +1 -0
  12. package/browser/transactions/DeploymentTransaction.d.ts +6 -0
  13. package/browser/transactions/GenericTransaction.d.ts +6 -0
  14. package/browser/transactions/InteractionTransaction.d.ts +17 -0
  15. package/browser/transactions/Transaction.d.ts +17 -0
  16. package/browser/transactions/TransactionInput.d.ts +16 -0
  17. package/browser/transactions/TransactionOutput.d.ts +19 -0
  18. package/build/providers/JSONRpcProvider.d.ts +1 -1
  19. package/build/transactions/InteractionTransaction.d.ts +1 -0
  20. package/build/transactions/InteractionTransaction.js +1 -0
  21. package/cjs/block/Block.d.ts +27 -0
  22. package/cjs/block/Block.js +72 -0
  23. package/cjs/index.d.ts +11 -0
  24. package/cjs/index.js +26 -0
  25. package/cjs/interfaces/blocks/IBlock.d.ts +28 -0
  26. package/cjs/interfaces/blocks/IBlock.js +2 -0
  27. package/cjs/interfaces/opnet/OPNetTransactionTypes.d.ts +5 -0
  28. package/cjs/interfaces/opnet/OPNetTransactionTypes.js +9 -0
  29. package/cjs/interfaces/transactions/ITransaction.d.ts +31 -0
  30. package/cjs/interfaces/transactions/ITransaction.js +2 -0
  31. package/cjs/providers/JSONRpcProvider.d.ts +12 -0
  32. package/cjs/providers/JSONRpcProvider.js +52 -0
  33. package/cjs/scripts/test.d.ts +1 -0
  34. package/cjs/scripts/test.js +10 -0
  35. package/cjs/transactions/DeploymentTransaction.d.ts +6 -0
  36. package/cjs/transactions/DeploymentTransaction.js +10 -0
  37. package/cjs/transactions/GenericTransaction.d.ts +6 -0
  38. package/cjs/transactions/GenericTransaction.js +10 -0
  39. package/cjs/transactions/InteractionTransaction.d.ts +17 -0
  40. package/cjs/transactions/InteractionTransaction.js +29 -0
  41. package/cjs/transactions/Transaction.d.ts +17 -0
  42. package/cjs/transactions/Transaction.js +28 -0
  43. package/cjs/transactions/TransactionInput.d.ts +16 -0
  44. package/cjs/transactions/TransactionInput.js +18 -0
  45. package/cjs/transactions/TransactionOutput.d.ts +19 -0
  46. package/cjs/transactions/TransactionOutput.js +20 -0
  47. package/gulpfile.js +152 -152
  48. package/package.json +94 -71
  49. package/src/index.ts +4 -0
  50. package/src/providers/JSONRpcProvider.ts +66 -67
  51. package/src/transactions/InteractionTransaction.ts +1 -0
  52. package/tsconfig.base.json +10 -2
  53. package/tsconfig.webpack.json +11 -0
  54. package/webpack.config.js +58 -0
@@ -0,0 +1,2 @@
1
+ /*! For license information please see index.js.LICENSE.txt */
2
+ var t={7557:(t,e)=>{function r(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`positive integer expected, not ${t}`)}function n(t){if("boolean"!=typeof t)throw new Error(`boolean expected, not ${t}`)}function i(t){return t instanceof Uint8Array||null!=t&&"object"==typeof t&&"Uint8Array"===t.constructor.name}function s(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}, not of length=${t.length}`)}function o(t){if("function"!=typeof t||"function"!=typeof t.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");r(t.outputLen),r(t.blockLen)}function a(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 u(t,e){s(t);const r=e.outputLen;if(t.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}Object.defineProperty(e,"__esModule",{value:!0}),e.output=e.exists=e.hash=e.bytes=e.bool=e.number=e.isBytes=void 0,e.number=r,e.bool=n,e.isBytes=i,e.bytes=s,e.hash=o,e.exists=a,e.output=u;const c={number:r,bool:n,bytes:s,hash:o,exists:a,output:u};e.default=c},7202:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.HashMD=e.Maj=e.Chi=void 0;const n=r(7557),i=r(9175);e.Chi=(t,e,r)=>t&e^~t&r,e.Maj=(t,e,r)=>t&e^t&r^e&r;class s extends i.Hash{constructor(t,e,r,n){super(),this.blockLen=t,this.outputLen=e,this.padOffset=r,this.isLE=n,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=(0,i.createView)(this.buffer)}update(t){(0,n.exists)(this);const{view:e,buffer:r,blockLen:s}=this,o=(t=(0,i.toBytes)(t)).length;for(let n=0;n<o;){const a=Math.min(s-this.pos,o-n);if(a!==s)r.set(t.subarray(n,n+a),this.pos),this.pos+=a,n+=a,this.pos===s&&(this.process(e,0),this.pos=0);else{const e=(0,i.createView)(t);for(;s<=o-n;n+=s)this.process(e,n)}}return this.length+=t.length,this.roundClean(),this}digestInto(t){(0,n.exists)(this),(0,n.output)(t,this),this.finished=!0;const{buffer:e,view:r,blockLen:s,isLE:o}=this;let{pos:a}=this;e[a++]=128,this.buffer.subarray(a).fill(0),this.padOffset>s-a&&(this.process(r,0),a=0);for(let t=a;t<s;t++)e[t]=0;!function(t,e,r,n){if("function"==typeof t.setBigUint64)return t.setBigUint64(e,r,n);const i=BigInt(32),s=BigInt(4294967295),o=Number(r>>i&s),a=Number(r&s),u=n?4:0,c=n?0:4;t.setUint32(e+u,o,n),t.setUint32(e+c,a,n)}(r,s-8,BigInt(8*this.length),o),this.process(r,0);const u=(0,i.createView)(t),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const l=c/4,f=this.get();if(l>f.length)throw new Error("_sha2: outputLen bigger than state");for(let t=0;t<l;t++)u.setUint32(4*t,f[t],o)}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:s,pos:o}=this;return t.length=n,t.pos=o,t.finished=i,t.destroyed=s,n%e&&t.buffer.set(r),t}}e.HashMD=s},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},3238:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ripemd160=e.RIPEMD160=void 0;const n=r(7202),i=r(9175),s=new Uint8Array([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),o=new Uint8Array(new Array(16).fill(0).map(((t,e)=>e)));let a=[o],u=[o.map((t=>(9*t+5)%16))];for(let t=0;t<4;t++)for(let e of[a,u])e.push(e[t].map((t=>s[t])));const c=[[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8],[12,13,11,15,6,9,9,7,12,15,11,13,7,8,7,7],[13,15,14,11,7,7,6,8,13,14,13,12,5,5,6,9],[14,11,12,14,8,6,5,5,15,12,15,14,9,9,8,6],[15,12,13,13,9,5,8,6,14,11,12,11,8,6,5,5]].map((t=>new Uint8Array(t))),l=a.map(((t,e)=>t.map((t=>c[e][t])))),f=u.map(((t,e)=>t.map((t=>c[e][t])))),h=new Uint32Array([0,1518500249,1859775393,2400959708,2840853838]),p=new Uint32Array([1352829926,1548603684,1836072691,2053994217,0]);function d(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 g=new Uint32Array(16);class y extends n.HashMD{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)g[r]=t.getUint32(e,!0);let r=0|this.h0,n=r,s=0|this.h1,o=s,c=0|this.h2,y=c,w=0|this.h3,m=w,b=0|this.h4,A=b;for(let t=0;t<5;t++){const e=4-t,E=h[t],v=p[t],S=a[t],I=u[t],k=l[t],T=f[t];for(let e=0;e<16;e++){const n=(0,i.rotl)(r+d(t,s,c,w)+g[S[e]]+E,k[e])+b|0;r=b,b=w,w=0|(0,i.rotl)(c,10),c=s,s=n}for(let t=0;t<16;t++){const r=(0,i.rotl)(n+d(e,o,y,m)+g[I[t]]+v,T[t])+A|0;n=A,A=m,m=0|(0,i.rotl)(y,10),y=o,o=r}}this.set(this.h1+c+m|0,this.h2+w+A|0,this.h3+b+n|0,this.h4+r+o|0,this.h0+s+y|0)}roundClean(){g.fill(0)}destroy(){this.destroyed=!0,this.buffer.fill(0),this.set(0,0,0,0,0)}}e.RIPEMD160=y,e.ripemd160=(0,i.wrapConstructor)((()=>new y))},1549:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.sha1=void 0;const n=r(7202),i=r(9175),s=new Uint32Array([1732584193,4023233417,2562383102,271733878,3285377520]),o=new Uint32Array(80);class a extends n.HashMD{constructor(){super(64,20,8,!1),this.A=0|s[0],this.B=0|s[1],this.C=0|s[2],this.D=0|s[3],this.E=0|s[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)o[r]=t.getUint32(e,!1);for(let t=16;t<80;t++)o[t]=(0,i.rotl)(o[t-3]^o[t-8]^o[t-14]^o[t-16],1);let{A:r,B:s,C:a,D:u,E:c}=this;for(let t=0;t<80;t++){let e,l;t<20?(e=(0,n.Chi)(s,a,u),l=1518500249):t<40?(e=s^a^u,l=1859775393):t<60?(e=(0,n.Maj)(s,a,u),l=2400959708):(e=s^a^u,l=3395469782);const f=(0,i.rotl)(r,5)+e+c+l+o[t]|0;c=u,u=a,a=(0,i.rotl)(s,30),s=r,r=f}r=r+this.A|0,s=s+this.B|0,a=a+this.C|0,u=u+this.D|0,c=c+this.E|0,this.set(r,s,a,u,c)}roundClean(){o.fill(0)}destroy(){this.set(0,0,0,0,0),this.buffer.fill(0)}}e.sha1=(0,i.wrapConstructor)((()=>new a))},2623:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.sha224=e.sha256=void 0;const n=r(7202),i=r(9175),s=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),o=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),a=new Uint32Array(64);class u extends n.HashMD{constructor(){super(64,32,8,!1),this.A=0|o[0],this.B=0|o[1],this.C=0|o[2],this.D=0|o[3],this.E=0|o[4],this.F=0|o[5],this.G=0|o[6],this.H=0|o[7]}get(){const{A:t,B:e,C:r,D:n,E:i,F:s,G:o,H:a}=this;return[t,e,r,n,i,s,o,a]}set(t,e,r,n,i,s,o,a){this.A=0|t,this.B=0|e,this.C=0|r,this.D=0|n,this.E=0|i,this.F=0|s,this.G=0|o,this.H=0|a}process(t,e){for(let r=0;r<16;r++,e+=4)a[r]=t.getUint32(e,!1);for(let t=16;t<64;t++){const e=a[t-15],r=a[t-2],n=(0,i.rotr)(e,7)^(0,i.rotr)(e,18)^e>>>3,s=(0,i.rotr)(r,17)^(0,i.rotr)(r,19)^r>>>10;a[t]=s+a[t-7]+n+a[t-16]|0}let{A:r,B:o,C:u,D:c,E:l,F:f,G:h,H:p}=this;for(let t=0;t<64;t++){const e=p+((0,i.rotr)(l,6)^(0,i.rotr)(l,11)^(0,i.rotr)(l,25))+(0,n.Chi)(l,f,h)+s[t]+a[t]|0,d=((0,i.rotr)(r,2)^(0,i.rotr)(r,13)^(0,i.rotr)(r,22))+(0,n.Maj)(r,o,u)|0;p=h,h=f,f=l,l=c+e|0,c=u,u=o,o=r,r=e+d|0}r=r+this.A|0,o=o+this.B|0,u=u+this.C|0,c=c+this.D|0,l=l+this.E|0,f=f+this.F|0,h=h+this.G|0,p=p+this.H|0,this.set(r,o,u,c,l,f,h,p)}roundClean(){a.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}class c extends u{constructor(){super(),this.A=-1056596264,this.B=914150663,this.C=812702999,this.D=-150054599,this.E=-4191439,this.F=1750603025,this.G=1694076839,this.H=-1090891868,this.outputLen=28}}e.sha256=(0,i.wrapConstructor)((()=>new u)),e.sha224=(0,i.wrapConstructor)((()=>new c))},9175:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.randomBytes=e.wrapXOFConstructorWithOpts=e.wrapConstructorWithOpts=e.wrapConstructor=e.checkOpts=e.Hash=e.concatBytes=e.toBytes=e.utf8ToBytes=e.asyncLoop=e.nextTick=e.hexToBytes=e.bytesToHex=e.byteSwap32=e.byteSwapIfBE=e.byteSwap=e.isLE=e.rotl=e.rotr=e.createView=e.u32=e.u8=e.isBytes=void 0;const n=r(5145),i=r(7557);e.isBytes=function(t){return t instanceof Uint8Array||null!=t&&"object"==typeof t&&"Uint8Array"===t.constructor.name},e.u8=t=>new Uint8Array(t.buffer,t.byteOffset,t.byteLength),e.u32=t=>new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4)),e.createView=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),e.rotr=(t,e)=>t<<32-e|t>>>e,e.rotl=(t,e)=>t<<e|t>>>32-e>>>0,e.isLE=68===new Uint8Array(new Uint32Array([287454020]).buffer)[0],e.byteSwap=t=>t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255,e.byteSwapIfBE=e.isLE?t=>t:t=>(0,e.byteSwap)(t),e.byteSwap32=function(t){for(let r=0;r<t.length;r++)t[r]=(0,e.byteSwap)(t[r])};const s=Array.from({length:256},((t,e)=>e.toString(16).padStart(2,"0")));e.bytesToHex=function(t){(0,i.bytes)(t);let e="";for(let r=0;r<t.length;r++)e+=s[t[r]];return e};const o=48,a=57,u=65,c=70,l=97,f=102;function h(t){return t>=o&&t<=a?t-o:t>=u&&t<=c?t-(u-10):t>=l&&t<=f?t-(l-10):void 0}function p(t){if("string"!=typeof t)throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array((new TextEncoder).encode(t))}function d(t){return"string"==typeof t&&(t=p(t)),(0,i.bytes)(t),t}e.hexToBytes=function(t){if("string"!=typeof t)throw new Error("hex string expected, got "+typeof t);const e=t.length,r=e/2;if(e%2)throw new Error("padded 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)),s=h(t.charCodeAt(i+1));if(void 0===r||void 0===s){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+s}return n},e.nextTick=async()=>{},e.asyncLoop=async function(t,r,n){let i=Date.now();for(let s=0;s<t;s++){n(s);const t=Date.now()-i;t>=0&&t<r||(await(0,e.nextTick)(),i+=t)}},e.utf8ToBytes=p,e.toBytes=d,e.concatBytes=function(...t){let e=0;for(let r=0;r<t.length;r++){const n=t[r];(0,i.bytes)(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.Hash=class{clone(){return this._cloneInto()}};const g={}.toString;e.checkOpts=function(t,e){if(void 0!==e&&"[object Object]"!==g.call(e))throw new Error("Options should be object or undefined");return Object.assign(t,e)},e.wrapConstructor=function(t){const e=e=>t().update(d(e)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e},e.wrapConstructorWithOpts=function(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.wrapXOFConstructorWithOpts=function(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.randomBytes=function(t=32){if(n.crypto&&"function"==typeof n.crypto.getRandomValues)return n.crypto.getRandomValues(new Uint8Array(t));throw new Error("crypto.getRandomValues must be defined")}},5364:t=>{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 n=0;n<t.length;n++){var i=t.charAt(n),s=i.charCodeAt(0);if(255!==e[s])throw new TypeError(i+" is ambiguous");e[s]=n}var o=t.length,a=t.charAt(0),u=Math.log(o)/Math.log(256),c=Math.log(256)/Math.log(o);function l(t){if("string"!=typeof t)throw new TypeError("Expected String");if(0===t.length)return new Uint8Array;for(var r=0,n=0,i=0;t[r]===a;)n++,r++;for(var s=(t.length-r)*u+1>>>0,c=new Uint8Array(s);t[r];){var l=e[t.charCodeAt(r)];if(255===l)return;for(var f=0,h=s-1;(0!==l||f<i)&&-1!==h;h--,f++)l+=o*c[h]>>>0,c[h]=l%256>>>0,l=l/256>>>0;if(0!==l)throw new Error("Non-zero carry");i=f,r++}for(var p=s-i;p!==s&&0===c[p];)p++;for(var d=new Uint8Array(n+(s-p)),g=n;p!==s;)d[g++]=c[p++];return d}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"";for(var r=0,n=0,i=0,s=e.length;i!==s&&0===e[i];)i++,r++;for(var u=(s-i)*c+1>>>0,l=new Uint8Array(u);i!==s;){for(var f=e[i],h=0,p=u-1;(0!==f||h<n)&&-1!==p;p--,h++)f+=256*l[p]>>>0,l[p]=f%o>>>0,f=f/o>>>0;if(0!==f)throw new Error("Non-zero carry");n=h,i++}for(var d=u-n;d!==u&&0===l[d];)d++;for(var g=a.repeat(r);d<u;++d)g+=t.charAt(l[d]);return g},decodeUnsafe:l,decode:function(t){var e=l(t);if(e)return e;throw new Error("Non-base"+o+" character")}}}},7526:(t,e)=>{e.byteLength=function(t){var e=a(t),r=e[0],n=e[1];return 3*(r+n)/4-n},e.toByteArray=function(t){var e,r,s=a(t),o=s[0],u=s[1],c=new i(function(t,e,r){return 3*(e+r)/4-r}(0,o,u)),l=0,f=u>0?o-4:o;for(r=0;r<f;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[l++]=e>>16&255,c[l++]=e>>8&255,c[l++]=255&e;return 2===u&&(e=n[t.charCodeAt(r)]<<2|n[t.charCodeAt(r+1)]>>4,c[l++]=255&e),1===u&&(e=n[t.charCodeAt(r)]<<10|n[t.charCodeAt(r+1)]<<4|n[t.charCodeAt(r+2)]>>2,c[l++]=e>>8&255,c[l++]=255&e),c},e.fromByteArray=function(t){for(var e,n=t.length,i=n%3,s=[],o=16383,a=0,c=n-i;a<c;a+=o)s.push(u(t,a,a+o>c?c:a+o));return 1===i?(e=t[n-1],s.push(r[e>>2]+r[e<<4&63]+"==")):2===i&&(e=(t[n-2]<<8)+t[n-1],s.push(r[e>>10]+r[e>>4&63]+r[e<<2&63]+"=")),s.join("")};for(var r=[],n=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=0;o<64;++o)r[o]=s[o],n[s.charCodeAt(o)]=o;function a(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,s,o=[],a=e;a<n;a+=3)i=(t[a]<<16&16711680)+(t[a+1]<<8&65280)+(255&t[a+2]),o.push(r[(s=i)>>18&63]+r[s>>12&63]+r[s>>6&63]+r[63&s]);return o.join("")}n["-".charCodeAt(0)]=62,n["_".charCodeAt(0)]=63},2343:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.bech32m=e.bech32=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 s(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 o(t,e,r,n){let i=0,s=0;const o=(1<<r)-1,a=[];for(let n=0;n<t.length;++n)for(i=i<<e|t[n],s+=e;s>=r;)s-=r,a.push(i>>s&o);if(n)s>0&&a.push(i<<r-s&o);else{if(s>=e)return"Excess padding";if(i<<r-s&o)return"Non-zero padding"}return a}function a(t){return o(t,8,5,!0)}function u(t){const e=o(t,5,8,!1);if(Array.isArray(e))return e}function c(t){const e=o(t,5,8,!1);if(Array.isArray(e))return e;throw new Error(e)}function l(t){let e;function o(t,r){if(r=r||90,t.length<8)return t+" too short";if(t.length>r)return"Exceeds length limit";const o=t.toLowerCase(),a=t.toUpperCase();if(t!==o&&t!==a)return"Mixed-case string "+t;const u=(t=o).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),l=t.slice(u+1);if(l.length<6)return"Data too short";let f=s(c);if("string"==typeof f)return f;const h=[];for(let t=0;t<l.length;++t){const e=l.charAt(t),r=n[e];if(void 0===r)return"Unknown character "+e;f=i(f)^r,t+6>=l.length||h.push(r)}return f!==e?"Invalid checksum for "+t:{prefix:c,words:h}}return e="bech32"===t?1:734539939,{decodeUnsafe:function(t,e){const r=o(t,e);if("object"==typeof r)return r},decode:function(t,e){const r=o(t,e);if("object"==typeof r)return r;throw new Error(r)},encode:function(t,n,o){if(o=o||90,t.length+7+n.length>o)throw new TypeError("Exceeds length limit");let a=s(t=t.toLowerCase());if("string"==typeof a)throw new Error(a);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");a=i(a)^e,u+=r.charAt(e)}for(let t=0;t<6;++t)a=i(a);a^=e;for(let t=0;t<6;++t)u+=r.charAt(a>>5*(5-t)&31);return u},toWords:a,fromWordsUnsafe:u,fromWords:c}}e.bech32=l("bech32"),e.bech32m=l("bech32m")},4863:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0});const n=r(1457);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 s(t){return t.globalMap.unsignedTx}function o(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),a=t.slice(1);if(0===a.length)throw new Error("Combine: Nothing to combine");const u=s(e);if(void 0===u)throw new Error("Combine: Self missing transaction");const c=o(r.globalKeyVals),l=r.inputKeyVals.map(o),f=r.outputKeyVals.map(o);for(const t of a){const e=s(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 a=n.psbtToKeyVals(t);o(a.globalKeyVals).forEach(i(c,r.globalKeyVals,a.globalKeyVals)),a.inputKeyVals.map(o).forEach(((t,e)=>t.forEach(i(l[e],r.inputKeyVals[e],a.inputKeyVals[e])))),a.outputKeyVals.map(o).forEach(((t,e)=>t.forEach(i(f[e],r.outputKeyVals[e],a.outputKeyVals[e]))))}return n.psbtFromKeyVals(u,{globalMapKeyVals:r.globalKeyVals,inputKeyVals:r.inputKeyVals,outputKeyVals:r.outputKeyVals})}},4834:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(9080);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),s=2147483647&n;r.path+="/"+s.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]),s=t.path.split("/"),o=n.allocUnsafe(4*s.length);t.masterFingerprint.copy(o,0);let a=4;return s.slice(1).forEach((t=>{const e="'"===t.slice(-1);let r=2147483647&parseInt(e?t.slice(0,-1):t,10);e&&(r+=2147483648),o.writeUInt32LE(r,a),a+=4})),{key:r,value:o}},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)}},4213:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(9080);e.encode=function(t){return{key:n.from([i.GlobalTypes.UNSIGNED_TX]),value:t.toBuffer()}}},2706:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0});const n=r(9080),i=r(4834),s=r(4213),o=r(6605),a=r(1795),u=r(4431),c=r(6907),l=r(5949),f=r(9344),h=r(2760),p=r(1695),d=r(8454),g=r(9034),y=r(2926),w=r(7851),m=r(7545),b=r(2412),A=r(4307),E=r(7636),v=r(2223),S=r(5578),I={unsignedTx:s,globalXpub:i,checkPubkey:b.makeChecker([])};e.globals=I;const k={nonWitnessUtxo:u,partialSig:c,sighashType:f,finalScriptSig:o,finalScriptWitness:a,porCommitment:l,witnessUtxo:y,bip32Derivation:m.makeConverter(n.InputTypes.BIP32_DERIVATION),redeemScript:A.makeConverter(n.InputTypes.REDEEM_SCRIPT),witnessScript:S.makeConverter(n.InputTypes.WITNESS_SCRIPT),checkPubkey:b.makeChecker([n.InputTypes.PARTIAL_SIG,n.InputTypes.BIP32_DERIVATION]),tapKeySig:h,tapScriptSig:g,tapLeafScript:p,tapBip32Derivation:E.makeConverter(n.InputTypes.TAP_BIP32_DERIVATION),tapInternalKey:v.makeConverter(n.InputTypes.TAP_INTERNAL_KEY),tapMerkleRoot:d};e.inputs=k;const T={bip32Derivation:m.makeConverter(n.OutputTypes.BIP32_DERIVATION),redeemScript:A.makeConverter(n.OutputTypes.REDEEM_SCRIPT),witnessScript:S.makeConverter(n.OutputTypes.WITNESS_SCRIPT),checkPubkey:b.makeChecker([n.OutputTypes.BIP32_DERIVATION]),tapBip32Derivation:E.makeConverter(n.OutputTypes.TAP_BIP32_DERIVATION),tapTree:w,tapInternalKey:v.makeConverter(n.OutputTypes.TAP_INTERNAL_KEY)};e.outputs=T},6605:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(9080);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}},1795:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(9080);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}},4431:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(9080);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}},6907:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(9080);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)}},5949:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(9080);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}},9344:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(9080);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}},2760:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(9080);function s(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(!s(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=s,e.canAdd=function(t,e){return!!t&&!!e&&void 0===t.tapKeySig}},1695:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(9080);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)}},8454:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(9080);function s(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(!s(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=s,e.canAdd=function(t,e){return!!t&&!!e&&void 0===t.tapMerkleRoot}},9034:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(9080);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)}},2926:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(9080),s=r(8133),o=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=s.readUInt64LE(t.value,0);let r=8;const n=o.decode(t.value,r);r+=o.encodingLength(n);const a=t.value.slice(r);if(a.length!==n)throw new Error("Decode Error: WITNESS_UTXO script is not proper length");return{script:a,value:e}},e.encode=function(t){const{script:e,value:r}=t,a=o.encodingLength(e.length),u=n.allocUnsafe(8+a+e.length);return s.writeUInt64LE(u,r,0),o.encode(e.length,u,8),e.copy(u,8+a),{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}},7851:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(9080),s=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++],o=s.decode(t.value,e);e+=s.encodingLength(o),r.push({depth:n,leafVersion:i,script:t.value.slice(e,e+o)}),e+=o}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),s.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}},7545:(t,e,r)=>{var n=r(8287).Buffer;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(s=r.value.length/4-1,[...Array(s).keys()])){const e=r.value.readUInt32LE(4*t+4),n=!!(2147483648&e),s=2147483647&e;i.path+="/"+s.toString(10)+(n?"'":"")}var s;return i},encode:function(e){const r=n.from([t]),i=n.concat([r,e.pubkey]),s=e.path.split("/"),o=n.allocUnsafe(4*s.length);e.masterFingerprint.copy(o,0);let a=4;return s.slice(1).forEach((t=>{const e="'"===t.slice(-1);let r=2147483647&parseInt(e?t.slice(0,-1):t,10);e&&(r+=2147483648),o.writeUInt32LE(r,a),a+=4})),{key:i,value:o}},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)}}}},2412:(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}}},4307:(t,e,r)=>{var n=r(8287).Buffer;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}}}},7636:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(394),s=r(7545),o=t=>32===t.length;e.makeConverter=function(t){const e=s.makeConverter(t,o);return{decode:function(t){const r=i.decode(t.value),n=i.encodingLength(r),s=e.decode({key:t.key,value:t.value.slice(n+32*r)}),o=new Array(r);for(let e=0,i=n;e<r;e++,i+=32)o[e]=t.value.slice(i,i+32);return Object.assign({},s,{leafHashes:o})},encode:function(t){const r=e.encode(t),s=i.encodingLength(t.leafHashes.length),o=n.allocUnsafe(s);i.encode(t.leafHashes.length,o);const a=n.concat([o,...t.leafHashes,r.value]);return Object.assign({},r,{value:a})},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}}},2223:(t,e,r)=>{var n=r(8287).Buffer;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}}}},5578:(t,e,r)=>{var n=r(8287).Buffer;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}}}},8133:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(394);function s(t){const e=t.key.length,r=t.value.length,s=i.encodingLength(e),o=i.encodingLength(r),a=n.allocUnsafe(s+e+o+r);return i.encode(e,a,0),t.key.copy(a,s),i.encode(r,a,s+e),t.value.copy(a,s+e+o),a}function o(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(s);return e.push(n.from([0])),n.concat(e)},e.keyValToBuffer=s,e.readUInt64LE=function(t,e){const r=t.readUInt32LE(e);let n=t.readUInt32LE(e+4);return n*=4294967296,o(n+r,9007199254740991),n+r},e.writeUInt64LE=function(t,e,r){return o(e,9007199254740991),t.writeInt32LE(-1&e,r),t.writeUInt32LE(Math.floor(e/4294967296),r+4),r+8}},394:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=9007199254740991;function s(t){if(t<0||t>i||t%1!=0)throw new RangeError("value out of range")}function o(t){return s(t),t<253?1:t<=65535?3:t<=4294967295?5:9}e.encode=function t(e,r,i){if(s(e),r||(r=n.allocUnsafe(o(e))),!n.isBuffer(r))throw new TypeError("buffer must be a Buffer instance");return i||(i=0),e<253?(r.writeUInt8(e,i),Object.assign(t,{bytes:1})):e<=65535?(r.writeUInt8(253,i),r.writeUInt16LE(e,i+1),Object.assign(t,{bytes:3})):e<=4294967295?(r.writeUInt8(254,i),r.writeUInt32LE(e,i+1),Object.assign(t,{bytes:5})):(r.writeUInt8(255,i),r.writeUInt32LE(e>>>0,i+1),r.writeUInt32LE(e/4294967296|0,i+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 i=e.readUInt8(r);if(i<253)return Object.assign(t,{bytes:1}),i;if(253===i)return Object.assign(t,{bytes:3}),e.readUInt16LE(r+1);if(254===i)return Object.assign(t,{bytes:5}),e.readUInt32LE(r+1);{Object.assign(t,{bytes:9});const n=e.readUInt32LE(r+1),i=4294967296*e.readUInt32LE(r+5)+n;return s(i),i}},e.encodingLength=o},6263:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(2706),s=r(8133),o=r(394),a=r(9080);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 o={unsignedTx:t};let c=0;for(const t of e)switch(t.key[0]){case a.GlobalTypes.UNSIGNED_TX:if(u("global",t.key,a.GlobalTypes.UNSIGNED_TX),c>0)throw new Error("Format Error: GlobalMap has multiple UNSIGNED_TX");c++;break;case a.GlobalTypes.GLOBAL_XPUB:void 0===o.globalXpub&&(o.globalXpub=[]),o.globalXpub.push(i.globals.globalXpub.decode(t));break;default:o.unknownKeyVals||(o.unknownKeyVals=[]),o.unknownKeyVals.push(t)}const l=r.length,f=n.length,h=[],p=[];for(const t of s.range(l)){const e={};for(const n of r[t])switch(i.inputs.checkPubkey(n),n.key[0]){case a.InputTypes.NON_WITNESS_UTXO:if(u("input",n.key,a.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 a.InputTypes.WITNESS_UTXO:if(u("input",n.key,a.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 a.InputTypes.PARTIAL_SIG:void 0===e.partialSig&&(e.partialSig=[]),e.partialSig.push(i.inputs.partialSig.decode(n));break;case a.InputTypes.SIGHASH_TYPE:if(u("input",n.key,a.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 a.InputTypes.REDEEM_SCRIPT:if(u("input",n.key,a.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 a.InputTypes.WITNESS_SCRIPT:if(u("input",n.key,a.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 a.InputTypes.BIP32_DERIVATION:void 0===e.bip32Derivation&&(e.bip32Derivation=[]),e.bip32Derivation.push(i.inputs.bip32Derivation.decode(n));break;case a.InputTypes.FINAL_SCRIPTSIG:u("input",n.key,a.InputTypes.FINAL_SCRIPTSIG),e.finalScriptSig=i.inputs.finalScriptSig.decode(n);break;case a.InputTypes.FINAL_SCRIPTWITNESS:u("input",n.key,a.InputTypes.FINAL_SCRIPTWITNESS),e.finalScriptWitness=i.inputs.finalScriptWitness.decode(n);break;case a.InputTypes.POR_COMMITMENT:u("input",n.key,a.InputTypes.POR_COMMITMENT),e.porCommitment=i.inputs.porCommitment.decode(n);break;case a.InputTypes.TAP_KEY_SIG:u("input",n.key,a.InputTypes.TAP_KEY_SIG),e.tapKeySig=i.inputs.tapKeySig.decode(n);break;case a.InputTypes.TAP_SCRIPT_SIG:void 0===e.tapScriptSig&&(e.tapScriptSig=[]),e.tapScriptSig.push(i.inputs.tapScriptSig.decode(n));break;case a.InputTypes.TAP_LEAF_SCRIPT:void 0===e.tapLeafScript&&(e.tapLeafScript=[]),e.tapLeafScript.push(i.inputs.tapLeafScript.decode(n));break;case a.InputTypes.TAP_BIP32_DERIVATION:void 0===e.tapBip32Derivation&&(e.tapBip32Derivation=[]),e.tapBip32Derivation.push(i.inputs.tapBip32Derivation.decode(n));break;case a.InputTypes.TAP_INTERNAL_KEY:u("input",n.key,a.InputTypes.TAP_INTERNAL_KEY),e.tapInternalKey=i.inputs.tapInternalKey.decode(n);break;case a.InputTypes.TAP_MERKLE_ROOT:u("input",n.key,a.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 s.range(f)){const e={};for(const r of n[t])switch(i.outputs.checkPubkey(r),r.key[0]){case a.OutputTypes.REDEEM_SCRIPT:if(u("output",r.key,a.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 a.OutputTypes.WITNESS_SCRIPT:if(u("output",r.key,a.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 a.OutputTypes.BIP32_DERIVATION:void 0===e.bip32Derivation&&(e.bip32Derivation=[]),e.bip32Derivation.push(i.outputs.bip32Derivation.decode(r));break;case a.OutputTypes.TAP_INTERNAL_KEY:u("output",r.key,a.OutputTypes.TAP_INTERNAL_KEY),e.tapInternalKey=i.outputs.tapInternalKey.decode(r);break;case a.OutputTypes.TAP_TREE:u("output",r.key,a.OutputTypes.TAP_TREE),e.tapTree=i.outputs.tapTree.decode(r);break;case a.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:o,inputs:h,outputs:p}}e.psbtFromBuffer=function(t,e){let r=0;function n(){const e=o.decode(t,r);r+=o.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 l=[],f={};for(;!u();){const t=i(),e=t.key.toString("hex");if(f[e])throw new Error("Format Error: Keys must be unique for global keymap: key "+e);f[e]=1,l.push(t)}const h=l.filter((t=>t.key[0]===a.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:g}=p.getInputOutputCounts(),y=[],w=[];for(const t of s.range(d)){const e={},r=[];for(;!u();){const n=i(),s=n.key.toString("hex");if(e[s])throw new Error("Format Error: Keys must be unique for each input: input index "+t+" key "+s);e[s]=1,r.push(n)}y.push(r)}for(const t of s.range(g)){const e={},r=[];for(;!u();){const n=i(),s=n.key.toString("hex");if(e[s])throw new Error("Format Error: Keys must be unique for each output: output index "+t+" key "+s);e[s]=1,r.push(n)}w.push(r)}return c(p,{globalMapKeyVals:l,inputKeyVals:y,outputKeyVals:w})},e.checkKeyBuffer=u,e.psbtFromKeyVals=c},1457:(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(6263)),n(r(238))},238:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(2706),s=r(8133);e.psbtToBuffer=function({globalMap:t,inputs:e,outputs:r}){const{globalKeyVals:i,inputKeyVals:o,outputKeyVals:a}=u({globalMap:t,inputs:e,outputs:r}),c=s.keyValsToBuffer(i),l=t=>0===t.length?[n.from([0])]:t.map(s.keyValsToBuffer),f=l(o),h=l(a),p=n.allocUnsafe(5);return p.writeUIntBE(482972169471,0,5),n.concat([p,c].concat(f,h))};const o=(t,e)=>t.key.compare(e.key);function a(t,e){const r=new Set,n=Object.entries(t).reduce(((t,[n,i])=>{if("unknownKeyVals"===n)return t;const s=e[n];if(void 0===s)return t;const o=(Array.isArray(i)?i:[i]).map(s.encode);return o.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(o)}),[]),i=t.unknownKeyVals?t.unknownKeyVals.filter((t=>!r.has(t.key.toString("hex")))):[];return n.concat(i).sort(o)}function u({globalMap:t,inputs:e,outputs:r}){return{globalKeyVals:a(t,i.globals),inputKeyVals:e.map((t=>a(t,i.inputs))),outputKeyVals:r.map((t=>a(t,i.outputs)))}}e.psbtToKeyVals=u},1614:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(4863),s=r(1457),o=r(9080),a=r(5080);e.Psbt=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=s.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 s.psbtToBuffer(this)}updateGlobal(t){return a.updateGlobal(t,this.globalMap),this}updateInput(t,e){const r=a.checkForInput(this.inputs,t);return a.updateInput(e,r),this}updateOutput(t,e){const r=a.checkForOutput(this.outputs,t);return a.updateOutput(e,r),this}addUnknownKeyValToGlobal(t){return a.checkHasKey(t,this.globalMap.unknownKeyVals,a.getEnumLength(o.GlobalTypes)),this.globalMap.unknownKeyVals||(this.globalMap.unknownKeyVals=[]),this.globalMap.unknownKeyVals.push(t),this}addUnknownKeyValToInput(t,e){const r=a.checkForInput(this.inputs,t);return a.checkHasKey(e,r.unknownKeyVals,a.getEnumLength(o.InputTypes)),r.unknownKeyVals||(r.unknownKeyVals=[]),r.unknownKeyVals.push(e),this}addUnknownKeyValToOutput(t,e){const r=a.checkForOutput(this.outputs,t);return a.checkHasKey(e,r.unknownKeyVals,a.getEnumLength(o.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))),a.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))),a.addOutputAttributes(this.outputs,t),this}clearFinalizedInput(t){const e=a.checkForInput(this.inputs,t);a.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()}}},9080:(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"]},5080:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(2706);function s(t,e){const r=t[e];if(void 0===r)throw new Error(`No input #${e}`);return r}function o(t,e){const r=t[e];if(void 0===r)throw new Error(`No output #${e}`);return r}function a(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 s=e[n],{canAdd:o,canAddToArray:u,check:c,expected:l}=i[t+"s"][n]||{};if(c)if(u){if(!Array.isArray(s)||r[n]&&!Array.isArray(r[n]))throw new Error(`Key type ${n} must be an array`);s.every(c)||a(t,n,l,s);const e=r[n]||[],i=new Set;if(!s.every((t=>u(e,t,i))))throw new Error("Can not add duplicate data to array");r[n]=e.concat(s)}else{if(c(s)||a(t,n,l,s),!o(r,s))throw new Error(`Can not add duplicate data to ${t}`);r[n]=s}}}}e.checkForInput=s,e.checkForOutput=o,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,s=!n||!!e.finalScriptWitness,o=!!e.finalScriptSig||!!e.finalScriptWitness;r=i&&s&&o}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=s(t,t.length-1);e.updateInput(r,n)},e.addOutputAttributes=function(t,r){const n=o(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}},57:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),e.toOutputScript=e.fromOutputScript=e.toBech32=e.toBase58Check=e.fromBech32=e.fromBase58Check=void 0;const i=r(622),s=r(885),o=r(7038),a=r(8116),u=r(2343),c=r(1889),l="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.";function f(t){const e=n.from(c.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.slice(1)}}function h(t){let e,r;try{e=u.bech32.decode(t)}catch(t){}if(e){if(r=e.words[0],0!==r)throw new TypeError(t+" uses wrong encoding")}else if(e=u.bech32m.decode(t),r=e.words[0],0===r)throw new TypeError(t+" uses wrong encoding");const i=u.bech32.fromWords(e.words.slice(1));return{version:r,prefix:e.prefix,data:n.from(i)}}function p(t,e,r){const n=u.bech32.toWords(t);return n.unshift(e),0===e?u.bech32.encode(r,n):u.bech32m.encode(r,n)}e.fromBase58Check=f,e.fromBech32=h,e.toBase58Check=function(t,e){(0,a.typeforce)((0,a.tuple)(a.Hash160bit,a.UInt8),arguments);const r=n.allocUnsafe(21);return r.writeUInt8(e,0),t.copy(r,1),c.encode(r)},e.toBech32=p,e.fromOutputScript=function(t,e){e=e||i.bitcoin;try{return s.p2pkh({output:t,network:e}).address}catch(t){}try{return s.p2sh({output:t,network:e}).address}catch(t){}try{return s.p2wpkh({output:t,network:e}).address}catch(t){}try{return s.p2wsh({output:t,network:e}).address}catch(t){}try{return s.p2tr({output:t,network:e}).address}catch(t){}try{return function(t,e){const r=t.slice(2);if(r.length<2||r.length>40)throw new TypeError("Invalid program length for segwit address");const n=t[0]-80;if(n<2||n>16)throw new TypeError("Invalid version for segwit address");if(t[1]!==r.length)throw new TypeError("Invalid script for segwit address");return console.warn(l),p(r,n,e.bech32)}(t,e)}catch(t){}throw new Error(o.toASM(t)+" has no matching Address")},e.toOutputScript=function(t,e){let r,n;e=e||i.bitcoin;try{r=f(t)}catch(t){}if(r){if(r.version===e.pubKeyHash)return s.p2pkh({hash:r.hash}).output;if(r.version===e.scriptHash)return s.p2sh({hash:r.hash}).output}else{try{n=h(t)}catch(t){}if(n){if(n.prefix!==e.bech32)throw new Error(t+" has an invalid prefix");if(0===n.version){if(20===n.data.length)return s.p2wpkh({hash:n.data}).output;if(32===n.data.length)return s.p2wsh({hash:n.data}).output}else if(1===n.version){if(32===n.data.length)return s.p2tr({pubkey:n.data}).output}else if(n.version>=2&&n.version<=16&&n.data.length>=2&&n.data.length<=40)return console.warn(l),o.compile([n.version+80,n.data])}}throw new Error(t+" has no matching Script")}},3966:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),e.encode=e.decode=e.check=void 0,e.check=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;const e=t[3];if(0===e)return!1;if(5+e>=t.length)return!1;if(2!==t[4+e])return!1;const 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]))},e.decode=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");const 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)");const 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)}},e.encode=function(t,e){const r=t.length,i=e.length;if(0===r)throw new Error("R length is zero");if(0===i)throw new Error("S length is zero");if(r>33)throw new Error("R length is too long");if(i>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(i>1&&0===e[0]&&!(128&e[1]))throw new Error("S value excessively padded");const s=n.allocUnsafe(6+r+i);return s[0]=48,s[1]=s.length-2,s[2]=2,s[3]=t.length,t.copy(s,4),s[4+r]=2,s[5+r]=e.length,e.copy(s,6+r),s}},1696:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),e.Block=void 0;const i=r(606),s=r(1944),o=r(1015),a=r(2021),u=r(8116),{typeforce:c}=u,l=new TypeError("Cannot compute merkle root for zero transactions"),f=new TypeError("Cannot compute witness commit for non-segwit block");class h{constructor(){this.version=1,this.prevHash=void 0,this.merkleRoot=void 0,this.timestamp=0,this.witnessCommit=void 0,this.bits=0,this.nonce=0,this.transactions=void 0}static fromBuffer(t){if(t.length<80)throw new Error("Buffer too small (< 80 bytes)");const e=new i.BufferReader(t),r=new h;if(r.version=e.readInt32(),r.prevHash=e.readSlice(32),r.merkleRoot=e.readSlice(32),r.timestamp=e.readUInt32(),r.bits=e.readUInt32(),r.nonce=e.readUInt32(),80===t.length)return r;const n=()=>{const t=a.Transaction.fromBuffer(e.buffer.slice(e.offset),!0);return e.offset+=t.byteLength(),t},s=e.readVarInt();r.transactions=[];for(let t=0;t<s;++t){const t=n();r.transactions.push(t)}const o=r.getWitnessCommit();return o&&(r.witnessCommit=o),r}static fromHex(t){return h.fromBuffer(n.from(t,"hex"))}static calculateTarget(t){const e=((4278190080&t)>>24)-3,r=8388607&t,i=n.alloc(32,0);return i.writeUIntBE(r,29-e,3),i}static calculateMerkleRoot(t,e){if(c([{getHash:u.Function}],t),0===t.length)throw l;if(e&&!p(t))throw f;const r=t.map((t=>t.getHash(e))),i=(0,o.fastMerkleRoot)(r,s.hash256);return e?s.hash256(n.concat([i,t[0].ins[0].witness[0]])):i}getWitnessCommit(){if(!p(this.transactions))return null;const t=this.transactions[0].outs.filter((t=>t.script.slice(0,6).equals(n.from("6a24aa21a9ed","hex")))).map((t=>t.script.slice(6,38)));if(0===t.length)return null;const e=t[t.length-1];return e instanceof n&&32===e.length?e:null}hasWitnessCommit(){return this.witnessCommit instanceof n&&32===this.witnessCommit.length||null!==this.getWitnessCommit()}hasWitness(){return(t=this.transactions)instanceof Array&&t.some((t=>"object"==typeof t&&t.ins instanceof Array&&t.ins.some((t=>"object"==typeof t&&t.witness instanceof Array&&t.witness.length>0))));var t}weight(){return 3*this.byteLength(!1,!1)+this.byteLength(!1,!0)}byteLength(t,e=!0){return t||!this.transactions?80:80+i.varuint.encodingLength(this.transactions.length)+this.transactions.reduce(((t,r)=>t+r.byteLength(e)),0)}getHash(){return s.hash256(this.toBuffer(!0))}getId(){return(0,i.reverseBuffer)(this.getHash()).toString("hex")}getUTCDate(){const t=new Date(0);return t.setUTCSeconds(this.timestamp),t}toBuffer(t){const e=n.allocUnsafe(this.byteLength(t)),r=new i.BufferWriter(e);return 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||(i.varuint.encode(this.transactions.length,e,r.offset),r.offset+=i.varuint.encode.bytes,this.transactions.forEach((t=>{const n=t.byteLength();t.toBuffer(e,r.offset),r.offset+=n}))),e}toHex(t){return this.toBuffer(t).toString("hex")}checkTxRoots(){const t=this.hasWitnessCommit();return!(!t&&this.hasWitness())&&this.__checkMerkleRoot()&&(!t||this.__checkWitnessCommit())}checkProofOfWork(){const t=(0,i.reverseBuffer)(this.getHash()),e=h.calculateTarget(this.bits);return t.compare(e)<=0}__checkMerkleRoot(){if(!this.transactions)throw l;const t=h.calculateMerkleRoot(this.transactions);return 0===this.merkleRoot.compare(t)}__checkWitnessCommit(){if(!this.transactions)throw l;if(!this.hasWitnessCommit())throw f;const t=h.calculateMerkleRoot(this.transactions,!0);return 0===this.witnessCommit.compare(t)}}function p(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}e.Block=h},606:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),e.BufferReader=e.BufferWriter=e.cloneBuffer=e.reverseBuffer=e.writeUInt64LE=e.readUInt64LE=e.varuint=void 0;const i=r(8116),{typeforce:s}=i,o=r(8469);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")}function u(t,e){const r=t.readUInt32LE(e);let n=t.readUInt32LE(e+4);return n*=4294967296,a(n+r,9007199254740991),n+r}function c(t,e,r){return a(e,9007199254740991),t.writeInt32LE(-1&e,r),t.writeUInt32LE(Math.floor(e/4294967296),r+4),r+8}e.varuint=o,e.readUInt64LE=u,e.writeUInt64LE=c,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.cloneBuffer=function(t){const e=n.allocUnsafe(t.length);return t.copy(e),e};class l{static withCapacity(t){return new l(n.alloc(t))}constructor(t,e=0){this.buffer=t,this.offset=e,s(i.tuple(i.Buffer,i.UInt32),[t,e])}writeUInt8(t){this.offset=this.buffer.writeUInt8(t,this.offset)}writeInt32(t){this.offset=this.buffer.writeInt32LE(t,this.offset)}writeUInt32(t){this.offset=this.buffer.writeUInt32LE(t,this.offset)}writeUInt64(t){this.offset=c(this.buffer,t,this.offset)}writeVarInt(t){o.encode(t,this.buffer,this.offset),this.offset+=o.encode.bytes}writeSlice(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)}writeVarSlice(t){this.writeVarInt(t.length),this.writeSlice(t)}writeVector(t){this.writeVarInt(t.length),t.forEach((t=>this.writeVarSlice(t)))}end(){if(this.buffer.length===this.offset)return this.buffer;throw new Error(`buffer size ${this.buffer.length}, offset ${this.offset}`)}}e.BufferWriter=l,e.BufferReader=class{constructor(t,e=0){this.buffer=t,this.offset=e,s(i.tuple(i.Buffer,i.UInt32),[t,e])}readUInt8(){const t=this.buffer.readUInt8(this.offset);return this.offset++,t}readInt32(){const t=this.buffer.readInt32LE(this.offset);return this.offset+=4,t}readUInt32(){const t=this.buffer.readUInt32LE(this.offset);return this.offset+=4,t}readUInt64(){const t=u(this.buffer,this.offset);return this.offset+=8,t}readVarInt(){const t=o.decode(this.buffer,this.offset);return this.offset+=o.decode.bytes,t}readSlice(t){if(this.buffer.length<this.offset+t)throw new Error("Cannot read slice out of bounds");const e=this.buffer.slice(this.offset,this.offset+t);return this.offset+=t,e}readVarSlice(){return this.readSlice(this.readVarInt())}readVector(){const t=this.readVarInt(),e=[];for(let r=0;r<t;r++)e.push(this.readVarSlice());return e}}},1944:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),e.taggedHash=e.TAGGED_HASH_PREFIXES=e.TAGS=e.hash256=e.hash160=e.sha256=e.sha1=e.ripemd160=void 0;const i=r(3238),s=r(1549),o=r(2623);function a(t){return n.from((0,o.sha256)(Uint8Array.from(t)))}e.ripemd160=function(t){return n.from((0,i.ripemd160)(Uint8Array.from(t)))},e.sha1=function(t){return n.from((0,s.sha1)(Uint8Array.from(t)))},e.sha256=a,e.hash160=function(t){return n.from((0,i.ripemd160)((0,o.sha256)(Uint8Array.from(t))))},e.hash256=function(t){return n.from((0,o.sha256)((0,o.sha256)(Uint8Array.from(t))))},e.TAGS=["BIP0340/challenge","BIP0340/aux","BIP0340/nonce","TapLeaf","TapBranch","TapSighash","TapTweak","KeyAgg list","KeyAgg coefficient"],e.TAGGED_HASH_PREFIXES={"BIP0340/challenge":n.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":n.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":n.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:n.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:n.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:n.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:n.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":n.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":n.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])},e.taggedHash=function(t,r){return a(n.concat([e.TAGGED_HASH_PREFIXES[t],r]))}},916:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),e.getEccLib=e.initEccLib=void 0;const i={};e.initEccLib=function(t){var e;t?t!==i.eccLib&&(o("function"==typeof(e=t).isXOnlyPoint),o(e.isXOnlyPoint(s("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),o(e.isXOnlyPoint(s("fffffffffffffffffffffffffffffffffffffffffffffffffffffffeeffffc2e"))),o(e.isXOnlyPoint(s("f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9"))),o(e.isXOnlyPoint(s("0000000000000000000000000000000000000000000000000000000000000001"))),o(!e.isXOnlyPoint(s("0000000000000000000000000000000000000000000000000000000000000000"))),o(!e.isXOnlyPoint(s("fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"))),o("function"==typeof e.xOnlyPointAddTweak),a.forEach((t=>{const r=e.xOnlyPointAddTweak(s(t.pubkey),s(t.tweak));null===t.result?o(null===r):(o(null!==r),o(r.parity===t.parity),o(n.from(r.xOnlyPubkey).equals(s(t.result))))})),i.eccLib=t):i.eccLib=t},e.getEccLib=function(){if(!i.eccLib)throw new Error("No ECC Library provided. You must call initEccLib() with a valid TinySecp256k1Interface instance");return i.eccLib};const s=t=>n.from(t,"hex");function o(t){if(!t)throw new Error("ecc library invalid")}const a=[{pubkey:"79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798",tweak:"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140",parity:-1,result:null},{pubkey:"1617d38ed8d8657da4d4761e8057bc396ea9e4b9d29776d4be096016dbd2509b",tweak:"a8397a935f0dfceba6ba9618f6451ef4d80637abf4e6af2669fbc9de6a8fd2ac",parity:1,result:"e478f99dab91052ab39a33ea35fd5e6e4933f4d28023cd597c9a1f6760346adf"},{pubkey:"2c0b7cf95324a07d05398b240174dc0c2be444d96b159aa6c7f7b1e668680991",tweak:"823c3cd2142744b075a87eade7e1b8678ba308d566226a0056ca2b7a76f86b47",parity:0,result:"9534f8dc8c6deda2dc007655981c78b49c5d96c778fbf363462a11ec9dfd948c"}]},1757:(t,e,r)=>{e.K$=void 0,r(57),r(1944),r(622),r(885);const n=r(7038);e.K$=n;r(1696),r(9646),r(8417),r(2021),r(916)},1015:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),e.fastMerkleRoot=void 0,e.fastMerkleRoot=function(t,e){if(!Array.isArray(t))throw TypeError("Expected values Array");if("function"!=typeof e)throw TypeError("Expected digest Function");let r=t.length;const i=t.concat();for(;r>1;){let t=0;for(let s=0;s<r;s+=2,++t){const o=i[s],a=s+1===r?o:i[s+1],u=n.concat([o,a]);i[t]=e(u)}r=t}return i[0]}},622:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.testnet=e.regtest=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.regtest={messagePrefix:"Bitcoin Signed Message:\n",bech32:"bcrt",bip32:{public:70617039,private:70615956},pubKeyHash:111,scriptHash:196,wif:239},e.testnet={messagePrefix:"Bitcoin Signed Message:\n",bech32:"tb",bip32:{public:70617039,private:70615956},pubKeyHash:111,scriptHash:196,wif:239}},8417:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.REVERSE_OPS=e.OPS=void 0;const r={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};e.OPS=r;const n={};e.REVERSE_OPS=n;for(const t of Object.keys(r))n[r[t]]=t},2218:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.tweakKey=e.tapTweakHash=e.tapleafHash=e.findScriptPath=e.toHashTree=e.rootHashFromPath=e.MAX_TAPTREE_DEPTH=e.LEAF_VERSION_TAPSCRIPT=void 0;const n=r(8287),i=r(916),s=r(1944),o=r(606),a=r(8116);function u(t){const r=t.version||e.LEAF_VERSION_TAPSCRIPT;return s.taggedHash("TapLeaf",n.Buffer.concat([n.Buffer.from([r]),f(t.output)]))}function c(t,e){return s.taggedHash("TapTweak",n.Buffer.concat(e?[t,e]:[t]))}function l(t,e){return s.taggedHash("TapBranch",n.Buffer.concat([t,e]))}function f(t){const e=o.varuint.encodingLength(t.length),r=n.Buffer.allocUnsafe(e);return o.varuint.encode(t.length,r),n.Buffer.concat([r,t])}e.LEAF_VERSION_TAPSCRIPT=192,e.MAX_TAPTREE_DEPTH=128,e.rootHashFromPath=function(t,e){if(t.length<33)throw new TypeError(`The control-block length is too small. Got ${t.length}, expected min 33.`);const r=(t.length-33)/32;let n=e;for(let e=0;e<r;e++){const r=t.slice(33+32*e,65+32*e);n=n.compare(r)<0?l(n,r):l(r,n)}return n},e.toHashTree=function t(e){if((0,a.isTapleaf)(e))return{hash:u(e)};const r=[t(e[0]),t(e[1])];r.sort(((t,e)=>t.hash.compare(e.hash)));const[n,i]=r;return{hash:l(n.hash,i.hash),left:n,right:i}},e.findScriptPath=function t(e,r){if("left"in(n=e)&&"right"in n){const n=t(e.left,r);if(void 0!==n)return[...n,e.right.hash];const i=t(e.right,r);if(void 0!==i)return[...i,e.left.hash]}else if(e.hash.equals(r))return[];var n},e.tapleafHash=u,e.tapTweakHash=c,e.tweakKey=function(t,e){if(!n.Buffer.isBuffer(t))return null;if(32!==t.length)return null;if(e&&32!==e.length)return null;const r=c(t,e),s=(0,i.getEccLib)().xOnlyPointAddTweak(t,r);return s&&null!==s.xOnlyPubkey?{parity:s.parity,x:n.Buffer.from(s.xOnlyPubkey)}:null}},5472:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.p2data=void 0;const n=r(622),i=r(7038),s=r(8116),o=r(7883),a=i.OPS;e.p2data=function(t,e){if(!t.data&&!t.output)throw new TypeError("Not enough data");e=Object.assign({validate:!0},e||{}),(0,s.typeforce)({network:s.typeforce.maybe(s.typeforce.Object),output:s.typeforce.maybe(s.typeforce.Buffer),data:s.typeforce.maybe(s.typeforce.arrayOf(s.typeforce.Buffer))},t);const r={name:"embed",network:t.network||n.bitcoin};if(o.prop(r,"output",(()=>{if(t.data)return i.compile([a.OP_RETURN].concat(t.data))})),o.prop(r,"data",(()=>{if(t.output)return i.decompile(t.output).slice(1)})),e.validate&&t.output){const e=i.decompile(t.output);if(e[0]!==a.OP_RETURN)throw new TypeError("Output is invalid");if(!e.slice(1).every(s.typeforce.Buffer))throw new TypeError("Output is invalid");if(t.data&&!function(t,e){return t.length===e.length&&t.every(((t,r)=>t.equals(e[r])))}(t.data,r.data))throw new TypeError("Data mismatch")}return Object.assign(r,t)}},885:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.p2tr=e.p2wsh=e.p2wpkh=e.p2sh=e.p2pkh=e.p2pk=e.p2ms=e.embed=void 0;const n=r(5472);Object.defineProperty(e,"embed",{enumerable:!0,get:function(){return n.p2data}});const i=r(1395);Object.defineProperty(e,"p2ms",{enumerable:!0,get:function(){return i.p2ms}});const s=r(4930);Object.defineProperty(e,"p2pk",{enumerable:!0,get:function(){return s.p2pk}});const o=r(3504);Object.defineProperty(e,"p2pkh",{enumerable:!0,get:function(){return o.p2pkh}});const a=r(8368);Object.defineProperty(e,"p2sh",{enumerable:!0,get:function(){return a.p2sh}});const u=r(7027);Object.defineProperty(e,"p2wpkh",{enumerable:!0,get:function(){return u.p2wpkh}});const c=r(9041);Object.defineProperty(e,"p2wsh",{enumerable:!0,get:function(){return c.p2wsh}});const l=r(5501);Object.defineProperty(e,"p2tr",{enumerable:!0,get:function(){return l.p2tr}})},7883:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.value=e.prop=void 0,e.prop=function(t,e,r){Object.defineProperty(t,e,{configurable:!0,enumerable:!0,get(){const t=r.call(this);return this[e]=t,t},set(t){Object.defineProperty(this,e,{configurable:!0,enumerable:!0,value:t,writable:!0})}})},e.value=function(t){let e;return()=>(void 0!==e||(e=t()),e)}},1395:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.p2ms=void 0;const n=r(622),i=r(7038),s=r(8116),o=r(7883),a=i.OPS,u=a.OP_RESERVED;function c(t,e){return t.length===e.length&&t.every(((t,r)=>t.equals(e[r])))}e.p2ms=function(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 i.isCanonicalScriptSignature(t)||void 0!==(e.allowIncomplete&&t===a.OP_0)}e=Object.assign({validate:!0},e||{}),(0,s.typeforce)({network:s.typeforce.maybe(s.typeforce.Object),m:s.typeforce.maybe(s.typeforce.Number),n:s.typeforce.maybe(s.typeforce.Number),output:s.typeforce.maybe(s.typeforce.Buffer),pubkeys:s.typeforce.maybe(s.typeforce.arrayOf(s.isPoint)),signatures:s.typeforce.maybe(s.typeforce.arrayOf(r)),input:s.typeforce.maybe(s.typeforce.Buffer)},t);const l={network:t.network||n.bitcoin};let f=[],h=!1;function p(t){h||(h=!0,f=i.decompile(t),l.m=f[0]-u,l.n=f[f.length-2]-u,l.pubkeys=f.slice(1,-2))}if(o.prop(l,"output",(()=>{if(t.m&&l.n&&t.pubkeys)return i.compile([].concat(u+t.m,t.pubkeys,u+l.n,a.OP_CHECKMULTISIG))})),o.prop(l,"m",(()=>{if(l.output)return p(l.output),l.m})),o.prop(l,"n",(()=>{if(l.pubkeys)return l.pubkeys.length})),o.prop(l,"pubkeys",(()=>{if(t.output)return p(t.output),l.pubkeys})),o.prop(l,"signatures",(()=>{if(t.input)return i.decompile(t.input).slice(1)})),o.prop(l,"input",(()=>{if(t.signatures)return i.compile([a.OP_0].concat(t.signatures))})),o.prop(l,"witness",(()=>{if(l.input)return[]})),o.prop(l,"name",(()=>{if(l.m&&l.n)return`p2ms(${l.m} of ${l.n})`})),e.validate){if(t.output){if(p(t.output),!s.typeforce.Number(f[0]))throw new TypeError("Output is invalid");if(!s.typeforce.Number(f[f.length-2]))throw new TypeError("Output is invalid");if(f[f.length-1]!==a.OP_CHECKMULTISIG)throw new TypeError("Output is invalid");if(l.m<=0||l.n>16||l.m>l.n||l.n!==f.length-3)throw new TypeError("Output is invalid");if(!l.pubkeys.every((t=>(0,s.isPoint)(t))))throw new TypeError("Output is invalid");if(void 0!==t.m&&t.m!==l.m)throw new TypeError("m mismatch");if(void 0!==t.n&&t.n!==l.n)throw new TypeError("n mismatch");if(t.pubkeys&&!c(t.pubkeys,l.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(l.n=t.pubkeys.length,l.n<l.m)throw new TypeError("Pubkey count cannot be less than m")}if(t.signatures){if(t.signatures.length<l.m)throw new TypeError("Not enough signatures provided");if(t.signatures.length>l.m)throw new TypeError("Too many signatures provided")}if(t.input){if(t.input[0]!==a.OP_0)throw new TypeError("Input is invalid");if(0===l.signatures.length||!l.signatures.every(r))throw new TypeError("Input has invalid signature(s)");if(t.signatures&&!c(t.signatures,l.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(l,t)}},4930:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.p2pk=void 0;const n=r(622),i=r(7038),s=r(8116),o=r(7883),a=i.OPS;e.p2pk=function(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||{}),(0,s.typeforce)({network:s.typeforce.maybe(s.typeforce.Object),output:s.typeforce.maybe(s.typeforce.Buffer),pubkey:s.typeforce.maybe(s.isPoint),signature:s.typeforce.maybe(i.isCanonicalScriptSignature),input:s.typeforce.maybe(s.typeforce.Buffer)},t);const r=o.value((()=>i.decompile(t.input))),u={name:"p2pk",network:t.network||n.bitcoin};if(o.prop(u,"output",(()=>{if(t.pubkey)return i.compile([t.pubkey,a.OP_CHECKSIG])})),o.prop(u,"pubkey",(()=>{if(t.output)return t.output.slice(1,-1)})),o.prop(u,"signature",(()=>{if(t.input)return r()[0]})),o.prop(u,"input",(()=>{if(t.signature)return i.compile([t.signature])})),o.prop(u,"witness",(()=>{if(u.input)return[]})),e.validate){if(t.output){if(t.output[t.output.length-1]!==a.OP_CHECKSIG)throw new TypeError("Output is invalid");if(!(0,s.isPoint)(u.pubkey))throw new TypeError("Output pubkey is invalid");if(t.pubkey&&!t.pubkey.equals(u.pubkey))throw new TypeError("Pubkey mismatch")}if(t.signature&&t.input&&!t.input.equals(u.input))throw new TypeError("Signature mismatch");if(t.input){if(1!==r().length)throw new TypeError("Input is invalid");if(!i.isCanonicalScriptSignature(u.signature))throw new TypeError("Input has invalid signature")}}return Object.assign(u,t)}},3504:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),e.p2pkh=void 0;const i=r(1944),s=r(622),o=r(7038),a=r(8116),u=r(7883),c=r(1889),l=o.OPS;e.p2pkh=function(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||{}),(0,a.typeforce)({network:a.typeforce.maybe(a.typeforce.Object),address:a.typeforce.maybe(a.typeforce.String),hash:a.typeforce.maybe(a.typeforce.BufferN(20)),output:a.typeforce.maybe(a.typeforce.BufferN(25)),pubkey:a.typeforce.maybe(a.isPoint),signature:a.typeforce.maybe(o.isCanonicalScriptSignature),input:a.typeforce.maybe(a.typeforce.Buffer)},t);const r=u.value((()=>{const e=n.from(c.decode(t.address));return{version:e.readUInt8(0),hash:e.slice(1)}})),f=u.value((()=>o.decompile(t.input))),h=t.network||s.bitcoin,p={name:"p2pkh",network:h};if(u.prop(p,"address",(()=>{if(!p.hash)return;const t=n.allocUnsafe(21);return t.writeUInt8(h.pubKeyHash,0),p.hash.copy(t,1),c.encode(t)})),u.prop(p,"hash",(()=>t.output?t.output.slice(3,23):t.address?r().hash:t.pubkey||p.pubkey?i.hash160(t.pubkey||p.pubkey):void 0)),u.prop(p,"output",(()=>{if(p.hash)return o.compile([l.OP_DUP,l.OP_HASH160,p.hash,l.OP_EQUALVERIFY,l.OP_CHECKSIG])})),u.prop(p,"pubkey",(()=>{if(t.input)return f()[1]})),u.prop(p,"signature",(()=>{if(t.input)return f()[0]})),u.prop(p,"input",(()=>{if(t.pubkey&&t.signature)return o.compile([t.signature,t.pubkey])})),u.prop(p,"witness",(()=>{if(p.input)return[]})),e.validate){let e=n.from([]);if(t.address){if(r().version!==h.pubKeyHash)throw new TypeError("Invalid version or Network mismatch");if(20!==r().hash.length)throw new TypeError("Invalid address");e=r().hash}if(t.hash){if(e.length>0&&!e.equals(t.hash))throw new TypeError("Hash mismatch");e=t.hash}if(t.output){if(25!==t.output.length||t.output[0]!==l.OP_DUP||t.output[1]!==l.OP_HASH160||20!==t.output[2]||t.output[23]!==l.OP_EQUALVERIFY||t.output[24]!==l.OP_CHECKSIG)throw new TypeError("Output is invalid");const r=t.output.slice(3,23);if(e.length>0&&!e.equals(r))throw new TypeError("Hash mismatch");e=r}if(t.pubkey){const r=i.hash160(t.pubkey);if(e.length>0&&!e.equals(r))throw new TypeError("Hash mismatch");e=r}if(t.input){const r=f();if(2!==r.length)throw new TypeError("Input is invalid");if(!o.isCanonicalScriptSignature(r[0]))throw new TypeError("Input has invalid signature");if(!(0,a.isPoint)(r[1]))throw new TypeError("Input has invalid pubkey");if(t.signature&&!t.signature.equals(r[0]))throw new TypeError("Signature mismatch");if(t.pubkey&&!t.pubkey.equals(r[1]))throw new TypeError("Pubkey mismatch");const n=i.hash160(r[1]);if(e.length>0&&!e.equals(n))throw new TypeError("Hash mismatch")}}return Object.assign(p,t)}},8368:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),e.p2sh=void 0;const i=r(1944),s=r(622),o=r(7038),a=r(8116),u=r(7883),c=r(1889),l=o.OPS;e.p2sh=function(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||{}),(0,a.typeforce)({network:a.typeforce.maybe(a.typeforce.Object),address:a.typeforce.maybe(a.typeforce.String),hash:a.typeforce.maybe(a.typeforce.BufferN(20)),output:a.typeforce.maybe(a.typeforce.BufferN(23)),redeem:a.typeforce.maybe({network:a.typeforce.maybe(a.typeforce.Object),output:a.typeforce.maybe(a.typeforce.Buffer),input:a.typeforce.maybe(a.typeforce.Buffer),witness:a.typeforce.maybe(a.typeforce.arrayOf(a.typeforce.Buffer))}),input:a.typeforce.maybe(a.typeforce.Buffer),witness:a.typeforce.maybe(a.typeforce.arrayOf(a.typeforce.Buffer))},t);let r=t.network;r||(r=t.redeem&&t.redeem.network||s.bitcoin);const f={network:r},h=u.value((()=>{const e=n.from(c.decode(t.address));return{version:e.readUInt8(0),hash:e.slice(1)}})),p=u.value((()=>o.decompile(t.input))),d=u.value((()=>{const e=p(),i=e[e.length-1];return{network:r,output:i===l.OP_FALSE?n.from([]):i,input:o.compile(e.slice(0,-1)),witness:t.witness||[]}}));if(u.prop(f,"address",(()=>{if(!f.hash)return;const t=n.allocUnsafe(21);return t.writeUInt8(f.network.scriptHash,0),f.hash.copy(t,1),c.encode(t)})),u.prop(f,"hash",(()=>t.output?t.output.slice(2,22):t.address?h().hash:f.redeem&&f.redeem.output?i.hash160(f.redeem.output):void 0)),u.prop(f,"output",(()=>{if(f.hash)return o.compile([l.OP_HASH160,f.hash,l.OP_EQUAL])})),u.prop(f,"redeem",(()=>{if(t.input)return d()})),u.prop(f,"input",(()=>{if(t.redeem&&t.redeem.input&&t.redeem.output)return o.compile([].concat(o.decompile(t.redeem.input),t.redeem.output))})),u.prop(f,"witness",(()=>f.redeem&&f.redeem.witness?f.redeem.witness:f.input?[]:void 0)),u.prop(f,"name",(()=>{const t=["p2sh"];return void 0!==f.redeem&&void 0!==f.redeem.name&&t.push(f.redeem.name),t.join("-")})),e.validate){let e=n.from([]);if(t.address){if(h().version!==r.scriptHash)throw new TypeError("Invalid version or Network mismatch");if(20!==h().hash.length)throw new TypeError("Invalid address");e=h().hash}if(t.hash){if(e.length>0&&!e.equals(t.hash))throw new TypeError("Hash mismatch");e=t.hash}if(t.output){if(23!==t.output.length||t.output[0]!==l.OP_HASH160||20!==t.output[1]||t.output[22]!==l.OP_EQUAL)throw new TypeError("Output is invalid");const r=t.output.slice(2,22);if(e.length>0&&!e.equals(r))throw new TypeError("Hash mismatch");e=r}const s=t=>{if(t.output){const r=o.decompile(t.output);if(!r||r.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(o.countNonPushOnlyOPs(r)>201)throw new TypeError("Redeem.output unspendable with more than 201 non-push ops");const n=i.hash160(t.output);if(e.length>0&&!e.equals(n))throw new TypeError("Hash mismatch");e=n}if(t.input){const e=t.input.length>0,r=t.witness&&t.witness.length>0;if(!e&&!r)throw new TypeError("Empty input");if(e&&r)throw new TypeError("Input and witness provided");if(e){const e=o.decompile(t.input);if(!o.isPushOnly(e))throw new TypeError("Non push-only scriptSig")}}};if(t.input){const t=p();if(!t||t.length<1)throw new TypeError("Input too short");if(!n.isBuffer(d().output))throw new TypeError("Input is invalid");s(d())}if(t.redeem){if(t.redeem.network&&t.redeem.network!==r)throw new TypeError("Network mismatch");if(t.input){const e=d();if(t.redeem.output&&!t.redeem.output.equals(e.output))throw new TypeError("Redeem.output mismatch");if(t.redeem.input&&!t.redeem.input.equals(e.input))throw new TypeError("Redeem.input mismatch")}s(t.redeem)}if(t.witness&&t.redeem&&t.redeem.witness&&!function(t,e){return t.length===e.length&&t.every(((t,r)=>t.equals(e[r])))}(t.redeem.witness,t.witness))throw new TypeError("Witness and redeem.witness mismatch")}return Object.assign(f,t)}},5501:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.p2tr=void 0;const n=r(8287),i=r(622),s=r(7038),o=r(8116),a=r(916),u=r(2218),c=r(7883),l=r(2343),f=s.OPS;e.p2tr=function(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||{}),(0,o.typeforce)({address:o.typeforce.maybe(o.typeforce.String),input:o.typeforce.maybe(o.typeforce.BufferN(0)),network:o.typeforce.maybe(o.typeforce.Object),output:o.typeforce.maybe(o.typeforce.BufferN(34)),internalPubkey:o.typeforce.maybe(o.typeforce.BufferN(32)),hash:o.typeforce.maybe(o.typeforce.BufferN(32)),pubkey:o.typeforce.maybe(o.typeforce.BufferN(32)),signature:o.typeforce.maybe(o.typeforce.anyOf(o.typeforce.BufferN(64),o.typeforce.BufferN(65))),witness:o.typeforce.maybe(o.typeforce.arrayOf(o.typeforce.Buffer)),scriptTree:o.typeforce.maybe(o.isTaptree),redeem:o.typeforce.maybe({output:o.typeforce.maybe(o.typeforce.Buffer),redeemVersion:o.typeforce.maybe(o.typeforce.Number),witness:o.typeforce.maybe(o.typeforce.arrayOf(o.typeforce.Buffer))}),redeemVersion:o.typeforce.maybe(o.typeforce.Number)},t);const r=c.value((()=>{const e=l.bech32m.decode(t.address),r=e.words.shift(),i=l.bech32m.fromWords(e.words);return{version:r,prefix:e.prefix,data:n.Buffer.from(i)}})),h=c.value((()=>{if(t.witness&&t.witness.length)return t.witness.length>=2&&80===t.witness[t.witness.length-1][0]?t.witness.slice(0,-1):t.witness.slice()})),p=c.value((()=>t.scriptTree?(0,u.toHashTree)(t.scriptTree):t.hash?{hash:t.hash}:void 0)),d=t.network||i.bitcoin,g={name:"p2tr",network:d};if(c.prop(g,"address",(()=>{if(!g.pubkey)return;const t=l.bech32m.toWords(g.pubkey);return t.unshift(1),l.bech32m.encode(d.bech32,t)})),c.prop(g,"hash",(()=>{const t=p();if(t)return t.hash;const e=h();if(e&&e.length>1){const t=e[e.length-1],r=t[0]&o.TAPLEAF_VERSION_MASK,n=e[e.length-2],i=(0,u.tapleafHash)({output:n,version:r});return(0,u.rootHashFromPath)(t,i)}return null})),c.prop(g,"output",(()=>{if(g.pubkey)return s.compile([f.OP_1,g.pubkey])})),c.prop(g,"redeemVersion",(()=>t.redeemVersion?t.redeemVersion:t.redeem&&void 0!==t.redeem.redeemVersion&&null!==t.redeem.redeemVersion?t.redeem.redeemVersion:u.LEAF_VERSION_TAPSCRIPT)),c.prop(g,"redeem",(()=>{const t=h();if(t&&!(t.length<2))return{output:t[t.length-2],witness:t.slice(0,-2),redeemVersion:t[t.length-1][0]&o.TAPLEAF_VERSION_MASK}})),c.prop(g,"pubkey",(()=>{if(t.pubkey)return t.pubkey;if(t.output)return t.output.slice(2);if(t.address)return r().data;if(g.internalPubkey){const t=(0,u.tweakKey)(g.internalPubkey,g.hash);if(t)return t.x}})),c.prop(g,"internalPubkey",(()=>{if(t.internalPubkey)return t.internalPubkey;const e=h();return e&&e.length>1?e[e.length-1].slice(1,33):void 0})),c.prop(g,"signature",(()=>{if(t.signature)return t.signature;const e=h();return e&&1===e.length?e[0]:void 0})),c.prop(g,"witness",(()=>{if(t.witness)return t.witness;const e=p();if(e&&t.redeem&&t.redeem.output&&t.internalPubkey){const r=(0,u.tapleafHash)({output:t.redeem.output,version:g.redeemVersion}),i=(0,u.findScriptPath)(e,r);if(!i)return;const s=(0,u.tweakKey)(t.internalPubkey,e.hash);if(!s)return;const o=n.Buffer.concat([n.Buffer.from([g.redeemVersion|s.parity]),t.internalPubkey].concat(i));return[t.redeem.output,o]}return t.signature?[t.signature]:void 0})),e.validate){let e=n.Buffer.from([]);if(t.address){if(d&&d.bech32!==r().prefix)throw new TypeError("Invalid prefix or Network mismatch");if(1!==r().version)throw new TypeError("Invalid address version");if(32!==r().data.length)throw new TypeError("Invalid address data");e=r().data}if(t.pubkey){if(e.length>0&&!e.equals(t.pubkey))throw new TypeError("Pubkey mismatch");e=t.pubkey}if(t.output){if(34!==t.output.length||t.output[0]!==f.OP_1||32!==t.output[1])throw new TypeError("Output is invalid");if(e.length>0&&!e.equals(t.output.slice(2)))throw new TypeError("Pubkey mismatch");e=t.output.slice(2)}if(t.internalPubkey){const r=(0,u.tweakKey)(t.internalPubkey,g.hash);if(e.length>0&&!e.equals(r.x))throw new TypeError("Pubkey mismatch");e=r.x}if(e&&e.length&&!(0,a.getEccLib)().isXOnlyPoint(e))throw new TypeError("Invalid pubkey for p2tr");const i=p();if(t.hash&&i&&!t.hash.equals(i.hash))throw new TypeError("Hash mismatch");if(t.redeem&&t.redeem.output&&i){const e=(0,u.tapleafHash)({output:t.redeem.output,version:g.redeemVersion});if(!(0,u.findScriptPath)(i,e))throw new TypeError("Redeem script not in tree")}const c=h();if(t.redeem&&g.redeem){if(t.redeem.redeemVersion&&t.redeem.redeemVersion!==g.redeem.redeemVersion)throw new TypeError("Redeem.redeemVersion and witness mismatch");if(t.redeem.output){if(0===s.decompile(t.redeem.output).length)throw new TypeError("Redeem.output is invalid");if(g.redeem.output&&!t.redeem.output.equals(g.redeem.output))throw new TypeError("Redeem.output and witness mismatch")}if(t.redeem.witness&&g.redeem.witness&&!function(t,e){return t.length===e.length&&t.every(((t,r)=>t.equals(e[r])))}(t.redeem.witness,g.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{const r=c[c.length-1];if(r.length<33)throw new TypeError(`The control-block length is too small. Got ${r.length}, expected min 33.`);if((r.length-33)%32!=0)throw new TypeError(`The control-block length of ${r.length} is incorrect!`);const n=(r.length-33)/32;if(n>128)throw new TypeError(`The script path is too long. Got ${n}, expected max 128.`);const i=r.slice(1,33);if(t.internalPubkey&&!t.internalPubkey.equals(i))throw new TypeError("Internal pubkey mismatch");if(!(0,a.getEccLib)().isXOnlyPoint(i))throw new TypeError("Invalid internalPubkey for p2tr witness");const s=r[0]&o.TAPLEAF_VERSION_MASK,l=c[c.length-2],f=(0,u.tapleafHash)({output:l,version:s}),h=(0,u.rootHashFromPath)(r,f),p=(0,u.tweakKey)(i,h);if(!p)throw new TypeError("Invalid outputKey for p2tr witness");if(e.length&&!e.equals(p.x))throw new TypeError("Pubkey mismatch for p2tr witness");if(p.parity!==(1&r[0]))throw new Error("Incorrect parity")}}return Object.assign(g,t)}},7027:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),e.p2wpkh=void 0;const i=r(1944),s=r(622),o=r(7038),a=r(8116),u=r(7883),c=r(2343),l=o.OPS,f=n.alloc(0);e.p2wpkh=function(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||{}),(0,a.typeforce)({address:a.typeforce.maybe(a.typeforce.String),hash:a.typeforce.maybe(a.typeforce.BufferN(20)),input:a.typeforce.maybe(a.typeforce.BufferN(0)),network:a.typeforce.maybe(a.typeforce.Object),output:a.typeforce.maybe(a.typeforce.BufferN(22)),pubkey:a.typeforce.maybe(a.isPoint),signature:a.typeforce.maybe(o.isCanonicalScriptSignature),witness:a.typeforce.maybe(a.typeforce.arrayOf(a.typeforce.Buffer))},t);const r=u.value((()=>{const e=c.bech32.decode(t.address),r=e.words.shift(),i=c.bech32.fromWords(e.words);return{version:r,prefix:e.prefix,data:n.from(i)}})),h=t.network||s.bitcoin,p={name:"p2wpkh",network:h};if(u.prop(p,"address",(()=>{if(!p.hash)return;const t=c.bech32.toWords(p.hash);return t.unshift(0),c.bech32.encode(h.bech32,t)})),u.prop(p,"hash",(()=>t.output?t.output.slice(2,22):t.address?r().data:t.pubkey||p.pubkey?i.hash160(t.pubkey||p.pubkey):void 0)),u.prop(p,"output",(()=>{if(p.hash)return o.compile([l.OP_0,p.hash])})),u.prop(p,"pubkey",(()=>t.pubkey?t.pubkey:t.witness?t.witness[1]:void 0)),u.prop(p,"signature",(()=>{if(t.witness)return t.witness[0]})),u.prop(p,"input",(()=>{if(p.witness)return f})),u.prop(p,"witness",(()=>{if(t.pubkey&&t.signature)return[t.signature,t.pubkey]})),e.validate){let e=n.from([]);if(t.address){if(h&&h.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");e=r().data}if(t.hash){if(e.length>0&&!e.equals(t.hash))throw new TypeError("Hash mismatch");e=t.hash}if(t.output){if(22!==t.output.length||t.output[0]!==l.OP_0||20!==t.output[1])throw new TypeError("Output is invalid");if(e.length>0&&!e.equals(t.output.slice(2)))throw new TypeError("Hash mismatch");e=t.output.slice(2)}if(t.pubkey){const r=i.hash160(t.pubkey);if(e.length>0&&!e.equals(r))throw new TypeError("Hash mismatch");if(e=r,!(0,a.isPoint)(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(!o.isCanonicalScriptSignature(t.witness[0]))throw new TypeError("Witness has invalid signature");if(!(0,a.isPoint)(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");const r=i.hash160(t.witness[1]);if(e.length>0&&!e.equals(r))throw new TypeError("Hash mismatch")}}return Object.assign(p,t)}},9041:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),e.p2wsh=void 0;const i=r(1944),s=r(622),o=r(7038),a=r(8116),u=r(7883),c=r(2343),l=o.OPS,f=n.alloc(0);function h(t){return!(!n.isBuffer(t)||65!==t.length||4!==t[0]||!(0,a.isPoint)(t))}e.p2wsh=function(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||{}),(0,a.typeforce)({network:a.typeforce.maybe(a.typeforce.Object),address:a.typeforce.maybe(a.typeforce.String),hash:a.typeforce.maybe(a.typeforce.BufferN(32)),output:a.typeforce.maybe(a.typeforce.BufferN(34)),redeem:a.typeforce.maybe({input:a.typeforce.maybe(a.typeforce.Buffer),network:a.typeforce.maybe(a.typeforce.Object),output:a.typeforce.maybe(a.typeforce.Buffer),witness:a.typeforce.maybe(a.typeforce.arrayOf(a.typeforce.Buffer))}),input:a.typeforce.maybe(a.typeforce.BufferN(0)),witness:a.typeforce.maybe(a.typeforce.arrayOf(a.typeforce.Buffer))},t);const r=u.value((()=>{const e=c.bech32.decode(t.address),r=e.words.shift(),i=c.bech32.fromWords(e.words);return{version:r,prefix:e.prefix,data:n.from(i)}})),p=u.value((()=>o.decompile(t.redeem.input)));let d=t.network;d||(d=t.redeem&&t.redeem.network||s.bitcoin);const g={network:d};if(u.prop(g,"address",(()=>{if(!g.hash)return;const t=c.bech32.toWords(g.hash);return t.unshift(0),c.bech32.encode(d.bech32,t)})),u.prop(g,"hash",(()=>t.output?t.output.slice(2):t.address?r().data:g.redeem&&g.redeem.output?i.sha256(g.redeem.output):void 0)),u.prop(g,"output",(()=>{if(g.hash)return o.compile([l.OP_0,g.hash])})),u.prop(g,"redeem",(()=>{if(t.witness)return{output:t.witness[t.witness.length-1],input:f,witness:t.witness.slice(0,-1)}})),u.prop(g,"input",(()=>{if(g.witness)return f})),u.prop(g,"witness",(()=>{if(t.redeem&&t.redeem.input&&t.redeem.input.length>0&&t.redeem.output&&t.redeem.output.length>0){const e=o.toStack(p());return g.redeem=Object.assign({witness:e},t.redeem),g.redeem.input=f,[].concat(e,t.redeem.output)}if(t.redeem&&t.redeem.output&&t.redeem.witness)return[].concat(t.redeem.witness,t.redeem.output)})),u.prop(g,"name",(()=>{const t=["p2wsh"];return void 0!==g.redeem&&void 0!==g.redeem.name&&t.push(g.redeem.name),t.join("-")})),e.validate){let e=n.from([]);if(t.address){if(r().prefix!==d.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");e=r().data}if(t.hash){if(e.length>0&&!e.equals(t.hash))throw new TypeError("Hash mismatch");e=t.hash}if(t.output){if(34!==t.output.length||t.output[0]!==l.OP_0||32!==t.output[1])throw new TypeError("Output is invalid");const r=t.output.slice(2);if(e.length>0&&!e.equals(r))throw new TypeError("Hash mismatch");e=r}if(t.redeem){if(t.redeem.network&&t.redeem.network!==d)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){const r=o.decompile(t.redeem.output);if(!r||r.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(o.countNonPushOnlyOPs(r)>201)throw new TypeError("Redeem.output unspendable with more than 201 non-push ops");const n=i.sha256(t.redeem.output);if(e.length>0&&!e.equals(n))throw new TypeError("Hash mismatch");e=n}if(t.redeem.input&&!o.isPushOnly(p()))throw new TypeError("Non push-only scriptSig");if(t.witness&&t.redeem.witness&&!function(t,e){return t.length===e.length&&t.every(((t,r)=>t.equals(e[r])))}(t.witness,t.redeem.witness))throw new TypeError("Witness and redeem.witness mismatch");if(t.redeem.input&&p().some(h)||t.redeem.output&&(o.decompile(t.redeem.output)||[]).some(h))throw new TypeError("redeem.input or redeem.output contains uncompressed pubkey")}if(t.witness&&t.witness.length>0){const e=t.witness[t.witness.length-1];if(t.redeem&&t.redeem.output&&!t.redeem.output.equals(e))throw new TypeError("Witness and redeem.output mismatch");if(t.witness.some(h)||(o.decompile(e)||[]).some(h))throw new TypeError("Witness contains uncompressed pubkey")}}return Object.assign(g,t)}},9646:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),e.Psbt=void 0;const i=r(1614),s=r(394),o=r(5080),a=r(57),u=r(606),c=r(622),l=r(885),f=r(2218),h=r(7038),p=r(2021),d=r(477),g=r(4929),y={network:c.bitcoin,maximumFeeRate:5e3};class w{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=i.Psbt.fromBuffer(t,m),n=new w(e,r);var s,o;return s=n.__CACHE.__TX,o=n.__CACHE,s.ins.forEach((t=>{P(o,t)})),n}constructor(t={},e=new i.Psbt(new b)){this.data=e,this.opts=Object.assign({},y,t),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},0===this.data.inputs.length&&this.setVersion(2);const r=(t,e,r,n)=>Object.defineProperty(t,e,{enumerable:r,writable:n});r(this,"__CACHE",!1,!0),r(this,"opts",!1,!0)}get inputCount(){return this.data.inputs.length}get version(){return this.__CACHE.__TX.version}set version(t){this.setVersion(t)}get locktime(){return this.__CACHE.__TX.locktime}set locktime(t){this.setLocktime(t)}get txInputs(){return this.__CACHE.__TX.ins.map((t=>({hash:(0,u.cloneBuffer)(t.hash),index:t.index,sequence:t.sequence})))}get txOutputs(){return this.__CACHE.__TX.outs.map((t=>{let e;try{e=(0,a.fromOutputScript)(t.script,this.opts.network)}catch(t){}return{script:(0,u.cloneBuffer)(t.script),value:t.value,address:e}}))}combine(...t){return this.data.combine(...t.map((t=>t.data))),this}clone(){const t=w.fromBuffer(this.data.toBuffer());return t.opts=JSON.parse(JSON.stringify(this.opts)),t}setMaximumFeeRate(t){I(t),this.opts.maximumFeeRate=t}setVersion(t){I(t),k(this.data.inputs,"setVersion");const e=this.__CACHE;return e.__TX.version=t,e.__EXTRACTED_TX=void 0,this}setLocktime(t){I(t),k(this.data.inputs,"setLocktime");const e=this.__CACHE;return e.__TX.locktime=t,e.__EXTRACTED_TX=void 0,this}setInputSequence(t,e){I(e),k(this.data.inputs,"setInputSequence");const 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}addInputs(t){return t.forEach((t=>this.addInput(t))),this}addInput(t){if(arguments.length>1||!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]");(0,d.checkTaprootInputFields)(t,t,"addInput"),k(this.data.inputs,"addInput"),t.witnessScript&&J(t.witnessScript);const e=this.__CACHE;this.data.addInput(t),P(e,e.__TX.ins[e.__TX.ins.length-1]);const r=this.data.inputs.length-1,n=this.data.inputs[r];return n.nonWitnessUtxo&&G(this.__CACHE,n,r),e.__FEE=void 0,e.__FEE_RATE=void 0,e.__EXTRACTED_TX=void 0,this}addOutputs(t){return t.forEach((t=>this.addOutput(t))),this}addOutput(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]");k(this.data.inputs,"addOutput");const{address:e}=t;if("string"==typeof e){const{network:r}=this.opts,n=(0,a.toOutputScript)(e,r);t=Object.assign(t,{script:n})}(0,d.checkTaprootOutputFields)(t,t,"addOutput");const r=this.__CACHE;return this.data.addOutput(t),r.__FEE=void 0,r.__FEE_RATE=void 0,r.__EXTRACTED_TX=void 0,this}extractTransaction(t){if(!this.data.inputs.every(v))throw new Error("Not finalized");const e=this.__CACHE;if(t||function(t,e,r){const n=e.__FEE_RATE||t.getFeeRate(),i=e.__EXTRACTED_TX.virtualSize(),s=n*i;if(n>=r.maximumFeeRate)throw new Error(`Warning: You are paying around ${(s/1e8).toFixed(8)} in fees, which is ${n} satoshi per byte for a transaction with a VSize of ${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,e,this.opts),e.__EXTRACTED_TX)return e.__EXTRACTED_TX;const r=e.__TX.clone();return j(this.data.inputs,r,e,!0),r}getFeeRate(){return x("__FEE_RATE","fee rate",this.data.inputs,this.__CACHE)}getFee(){return x("__FEE","fee",this.data.inputs,this.__CACHE)}finalizeAllInputs(){return(0,o.checkForInput)(this.data.inputs,0),X(this.data.inputs.length).forEach((t=>this.finalizeInput(t))),this}finalizeInput(t,e){const r=(0,o.checkForInput)(this.data.inputs,t);return(0,d.isTaprootInput)(r)?this._finalizeTaprootInput(t,r,void 0,e):this._finalizeInput(t,r,e)}finalizeTaprootInput(t,e,r=d.tapScriptFinalizer){const n=(0,o.checkForInput)(this.data.inputs,t);if((0,d.isTaprootInput)(n))return this._finalizeTaprootInput(t,n,e,r);throw new Error(`Cannot finalize input #${t}. Not Taproot.`)}_finalizeInput(t,e,r=C){const{script:n,isP2SH:i,isP2WSH:s,isSegwit:o}=function(t,e,r){const 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){const s=V(r,e,t),o=n.ins[t].index;i.script=s.outs[o].script}else e.witnessUtxo&&(i.script=e.witnessUtxo.script);return(e.witnessScript||(0,g.isP2WPKH)(i.script))&&(i.isSegwit=!0),i}(t,e,this.__CACHE);if(!n)throw new Error(`No script found for input #${t}`);!function(t){if(!t.sighashType||!t.partialSig)return;const{partialSig:e,sighashType:r}=t;e.forEach((t=>{const{hashType:e}=h.signature.decode(t.signature);if(r!==e)throw new Error("Signature sighash does not match input sighash type")}))}(e);const{finalScriptSig:a,finalScriptWitness:u}=r(t,e,n,o,i,s);if(a&&this.data.updateInput(t,{finalScriptSig:a}),u&&this.data.updateInput(t,{finalScriptWitness:u}),!a&&!u)throw new Error(`Unknown error finalizing input #${t}`);return this.data.clearFinalizedInput(t),this}_finalizeTaprootInput(t,e,r,n=d.tapScriptFinalizer){if(!e.witnessUtxo)throw new Error(`Cannot finalize input #${t}. Missing withness utxo.`);if(e.tapKeySig){const r=l.p2tr({output:e.witnessUtxo.script,signature:e.tapKeySig}),n=(0,g.witnessStackToScriptWitness)(r.witness);this.data.updateInput(t,{finalScriptWitness:n})}else{const{finalScriptWitness:i}=n(t,e,r);this.data.updateInput(t,{finalScriptWitness:i})}return this.data.clearFinalizedInput(t),this}getInputType(t){const e=(0,o.checkForInput)(this.data.inputs,t),r=z(K(t,e,this.__CACHE),t,"input",e.redeemScript||function(t){if(!t)return;const e=h.decompile(t);if(!e)return;const r=e[e.length-1];var i;if(n.isBuffer(r)&&!W(r)&&(i=r,!h.isCanonicalScriptSignature(i))&&h.decompile(r))return r}(e.finalScriptSig),e.witnessScript||function(t){if(!t)return;const e=M(t),r=e[e.length-1];return!W(r)&&h.decompile(r)?r:void 0}(e.finalScriptWitness));return("raw"===r.type?"":r.type+"-")+q(r.meaningfulScript)}inputHasPubkey(t,e){return function(t,e,r,n){const i=K(r,e,n),{meaningfulScript:s}=z(i,r,"input",e.redeemScript,e.witnessScript);return(0,g.pubkeyInScript)(t,s)}(e,(0,o.checkForInput)(this.data.inputs,t),t,this.__CACHE)}inputHasHDKey(t,e){const r=(0,o.checkForInput)(this.data.inputs,t),n=S(e);return!!r.bip32Derivation&&r.bip32Derivation.some(n)}outputHasPubkey(t,e){return function(t,e,r,n){const i=n.__TX.outs[r].script,{meaningfulScript:s}=z(i,r,"output",e.redeemScript,e.witnessScript);return(0,g.pubkeyInScript)(t,s)}(e,(0,o.checkForOutput)(this.data.outputs,t),t,this.__CACHE)}outputHasHDKey(t,e){const r=(0,o.checkForOutput)(this.data.outputs,t),n=S(e);return!!r.bip32Derivation&&r.bip32Derivation.some(n)}validateSignaturesOfAllInputs(t){return(0,o.checkForInput)(this.data.inputs,0),X(this.data.inputs.length).map((e=>this.validateSignaturesOfInput(e,t))).reduce(((t,e)=>!0===e&&t),!0)}validateSignaturesOfInput(t,e,r){const n=this.data.inputs[t];return(0,d.isTaprootInput)(n)?this.validateSignaturesOfTaprootInput(t,e,r):this._validateSignaturesOfInput(t,e,r)}_validateSignaturesOfInput(t,e,r){const 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");const s=r?i.filter((t=>t.pubkey.equals(r))):i;if(s.length<1)throw new Error("No signatures for this pubkey");const o=[];let a,u,c;for(const r of s){const i=h.signature.decode(r.signature),{hash:s,script:l}=c!==i.hashType?R(t,Object.assign({},n,{sighashType:i.hashType}),this.__CACHE,!0):{hash:a,script:u};c=i.hashType,a=s,u=l,T(r.pubkey,l,"verify"),o.push(e(r.pubkey,s,i.signature))}return o.every((t=>!0===t))}validateSignaturesOfTaprootInput(t,e,r){const n=this.data.inputs[t],i=(n||{}).tapKeySig,s=(n||{}).tapScriptSig;if(!n&&!i&&(!s||s.length))throw new Error("No signatures to validate");if("function"!=typeof e)throw new Error("Need validator function to validate signatures");const o=(r=r&&(0,d.toXOnly)(r))?F(t,n,this.data.inputs,r,this.__CACHE):function(t,e,r,n){const i=[];if(e.tapInternalKey){const r=U(t,e,n);r&&i.push(r)}if(e.tapScriptSig){const t=e.tapScriptSig.map((t=>t.pubkey));i.push(...t)}return i.map((i=>F(t,e,r,i,n))).flat()}(t,n,this.data.inputs,this.__CACHE);if(!o.length)throw new Error("No signatures for this pubkey");const a=o.find((t=>!t.leafHash));let u=0;if(i&&a){if(!e(a.pubkey,a.hash,L(i)))return!1;u++}if(s)for(const t of s){const r=o.find((e=>t.pubkey.equals(e.pubkey)));if(r){if(!e(t.pubkey,r.hash,L(t.signature)))return!1;u++}}return u>0}signAllInputsHD(t,e=[p.Transaction.SIGHASH_ALL]){if(!t||!t.publicKey||!t.fingerprint)throw new Error("Need HDSigner to sign input");const r=[];for(const n of X(this.data.inputs.length))try{this.signInputHD(n,t,e),r.push(!0)}catch(t){r.push(!1)}if(r.every((t=>!1===t)))throw new Error("No inputs were signed");return this}signAllInputsHDAsync(t,e=[p.Transaction.SIGHASH_ALL]){return new Promise(((r,n)=>{if(!t||!t.publicKey||!t.fingerprint)return n(new Error("Need HDSigner to sign input"));const i=[],s=[];for(const r of X(this.data.inputs.length))s.push(this.signInputHDAsync(r,t,e).then((()=>{i.push(!0)}),(()=>{i.push(!1)})));return Promise.all(s).then((()=>{if(i.every((t=>!1===t)))return n(new Error("No inputs were signed"));r()}))}))}signInputHD(t,e,r=[p.Transaction.SIGHASH_ALL]){if(!e||!e.publicKey||!e.fingerprint)throw new Error("Need HDSigner to sign input");return H(t,this.data.inputs,e).forEach((e=>this.signInput(t,e,r))),this}signInputHDAsync(t,e,r=[p.Transaction.SIGHASH_ALL]){return new Promise(((n,i)=>{if(!e||!e.publicKey||!e.fingerprint)return i(new Error("Need HDSigner to sign input"));const s=H(t,this.data.inputs,e).map((e=>this.signInputAsync(t,e,r)));return Promise.all(s).then((()=>{n()})).catch(i)}))}signAllInputs(t,e){if(!t||!t.publicKey)throw new Error("Need Signer to sign input");const r=[];for(const n of X(this.data.inputs.length))try{this.signInput(n,t,e),r.push(!0)}catch(t){r.push(!1)}if(r.every((t=>!1===t)))throw new Error("No inputs were signed");return this}signAllInputsAsync(t,e){return new Promise(((r,n)=>{if(!t||!t.publicKey)return n(new Error("Need Signer to sign input"));const i=[],s=[];for(const[r]of this.data.inputs.entries())s.push(this.signInputAsync(r,t,e).then((()=>{i.push(!0)}),(()=>{i.push(!1)})));return Promise.all(s).then((()=>{if(i.every((t=>!1===t)))return n(new Error("No inputs were signed"));r()}))}))}signInput(t,e,r){if(!e||!e.publicKey)throw new Error("Need Signer to sign input");const n=(0,o.checkForInput)(this.data.inputs,t);return(0,d.isTaprootInput)(n)?this._signTaprootInput(t,n,e,void 0,r):this._signInput(t,e,r)}signTaprootInput(t,e,r,n){if(!e||!e.publicKey)throw new Error("Need Signer to sign input");const i=(0,o.checkForInput)(this.data.inputs,t);if((0,d.isTaprootInput)(i))return this._signTaprootInput(t,i,e,r,n);throw new Error(`Input #${t} is not of type Taproot.`)}_signInput(t,e,r=[p.Transaction.SIGHASH_ALL]){const{hash:n,sighashType:i}=_(this.data.inputs,t,e.publicKey,this.__CACHE,r),s=[{pubkey:e.publicKey,signature:h.signature.encode(e.sign(n),i)}];return this.data.updateInput(t,{partialSig:s}),this}_signTaprootInput(t,e,r,n,i=[p.Transaction.SIGHASH_DEFAULT]){const s=this.checkTaprootHashesForSig(t,e,r,n,i),o=s.filter((t=>!t.leafHash)).map((t=>(0,d.serializeTaprootSignature)(r.signSchnorr(t.hash),e.sighashType)))[0],a=s.filter((t=>!!t.leafHash)).map((t=>({pubkey:(0,d.toXOnly)(r.publicKey),signature:(0,d.serializeTaprootSignature)(r.signSchnorr(t.hash),e.sighashType),leafHash:t.leafHash})));return o&&this.data.updateInput(t,{tapKeySig:o}),a.length&&this.data.updateInput(t,{tapScriptSig:a}),this}signInputAsync(t,e,r){return Promise.resolve().then((()=>{if(!e||!e.publicKey)throw new Error("Need Signer to sign input");const n=(0,o.checkForInput)(this.data.inputs,t);return(0,d.isTaprootInput)(n)?this._signTaprootInputAsync(t,n,e,void 0,r):this._signInputAsync(t,e,r)}))}signTaprootInputAsync(t,e,r,n){return Promise.resolve().then((()=>{if(!e||!e.publicKey)throw new Error("Need Signer to sign input");const i=(0,o.checkForInput)(this.data.inputs,t);if((0,d.isTaprootInput)(i))return this._signTaprootInputAsync(t,i,e,r,n);throw new Error(`Input #${t} is not of type Taproot.`)}))}_signInputAsync(t,e,r=[p.Transaction.SIGHASH_ALL]){const{hash:n,sighashType:i}=_(this.data.inputs,t,e.publicKey,this.__CACHE,r);return Promise.resolve(e.sign(n)).then((r=>{const n=[{pubkey:e.publicKey,signature:h.signature.encode(r,i)}];this.data.updateInput(t,{partialSig:n})}))}async _signTaprootInputAsync(t,e,r,n,i=[p.Transaction.SIGHASH_DEFAULT]){const s=this.checkTaprootHashesForSig(t,e,r,n,i),o=[],a=s.filter((t=>!t.leafHash))[0];if(a){const t=Promise.resolve(r.signSchnorr(a.hash)).then((t=>({tapKeySig:(0,d.serializeTaprootSignature)(t,e.sighashType)})));o.push(t)}const u=s.filter((t=>!!t.leafHash));if(u.length){const t=u.map((t=>Promise.resolve(r.signSchnorr(t.hash)).then((n=>({tapScriptSig:[{pubkey:(0,d.toXOnly)(r.publicKey),signature:(0,d.serializeTaprootSignature)(n,e.sighashType),leafHash:t.leafHash}]})))));o.push(...t)}return Promise.all(o).then((e=>{e.forEach((e=>this.data.updateInput(t,e)))}))}checkTaprootHashesForSig(t,e,r,n,i){if("function"!=typeof r.signSchnorr)throw new Error(`Need Schnorr Signer to sign taproot input #${t}.`);const s=F(t,e,this.data.inputs,r.publicKey,this.__CACHE,n,i);if(!s||!s.length)throw new Error(`Can not sign for input #${t} with the key ${r.publicKey.toString("hex")}`);return s}toBuffer(){return A(this.__CACHE),this.data.toBuffer()}toHex(){return A(this.__CACHE),this.data.toHex()}toBase64(){return A(this.__CACHE),this.data.toBase64()}updateGlobal(t){return this.data.updateGlobal(t),this}updateInput(t,e){return e.witnessScript&&J(e.witnessScript),(0,d.checkTaprootInputFields)(this.data.inputs[t],e,"updateInput"),this.data.updateInput(t,e),e.nonWitnessUtxo&&G(this.__CACHE,this.data.inputs[t],t),this}updateOutput(t,e){const r=this.data.outputs[t];return(0,d.checkTaprootOutputFields)(r,e,"updateOutput"),this.data.updateOutput(t,e),this}addUnknownKeyValToGlobal(t){return this.data.addUnknownKeyValToGlobal(t),this}addUnknownKeyValToInput(t,e){return this.data.addUnknownKeyValToInput(t,e),this}addUnknownKeyValToOutput(t,e){return this.data.addUnknownKeyValToOutput(t,e),this}clearFinalizedInput(t){return this.data.clearFinalizedInput(t),this}}e.Psbt=w;const m=t=>new b(t);class b{constructor(t=n.from([2,0,0,0,0,0,0,0,0,0])){this.tx=p.Transaction.fromBuffer(t),function(t){if(!t.ins.every((t=>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})}getInputOutputCounts(){return{inputCount:this.tx.ins.length,outputCount:this.tx.outs.length}}addInput(t){if(void 0===t.hash||void 0===t.index||!n.isBuffer(t.hash)&&"string"!=typeof t.hash||"number"!=typeof t.index)throw new Error("Error adding input.");const e="string"==typeof t.hash?(0,u.reverseBuffer)(n.from(t.hash,"hex")):t.hash;this.tx.addInput(e,t.index,t.sequence)}addOutput(t){if(void 0===t.script||void 0===t.value||!n.isBuffer(t.script)||"number"!=typeof t.value)throw new Error("Error adding output.");this.tx.addOutput(t.script,t.value)}toBuffer(){return this.tx.toBuffer()}}function A(t){if(!1!==t.__UNSAFE_SIGN_NONSEGWIT)throw new Error("Not BIP174 compliant, can not export")}function E(t,e,r){if(!e)return!1;let n;if(n=r?r.map((t=>{const r=function(t){if(65===t.length){const e=1&t[64],r=t.slice(0,33);return r[0]=2|e,r}return t.slice()}(t);return e.find((t=>t.pubkey.equals(r)))})).filter((t=>!!t)):e,n.length>t)throw new Error("Too many signatures");return n.length===t}function v(t){return!!t.finalScriptSig||!!t.finalScriptWitness}function S(t){return e=>!!e.masterFingerprint.equals(t.fingerprint)&&!!t.derivePath(e.path).publicKey.equals(e.pubkey)}function I(t){if("number"!=typeof t||t!==Math.floor(t)||t>4294967295||t<0)throw new Error("Invalid 32 bit integer")}function k(t,e){t.forEach((t=>{if((0,d.isTaprootInput)(t)?(0,d.checkTaprootInputForSigs)(t,e):(0,g.checkInputForSig)(t,e))throw new Error("Can not modify transaction, signatures exist.")}))}function T(t,e,r){if(!(0,g.pubkeyInScript)(t,e))throw new Error(`Can not ${r} for this input with the key ${t.toString("hex")}`)}function P(t,e){const r=(0,u.reverseBuffer)(n.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 O(t,e){return(r,n,i,s)=>{const o=t({redeem:{output:i}}).output;if(!n.equals(o))throw new Error(`${e} for ${s} #${r} doesn't match the scriptPubKey in the prevout`)}}const B=O(l.p2sh,"Redeem script"),N=O(l.p2wsh,"Witness script");function x(t,e,r,n){if(!r.every(v))throw new Error(`PSBT must be finalized to calculate ${e}`);if("__FEE_RATE"===t&&n.__FEE_RATE)return n.__FEE_RATE;if("__FEE"===t&&n.__FEE)return n.__FEE;let i,s=!0;return n.__EXTRACTED_TX?(i=n.__EXTRACTED_TX,s=!1):i=n.__TX.clone(),j(r,i,n,s),"__FEE_RATE"===t?n.__FEE_RATE:"__FEE"===t?n.__FEE:void 0}function C(t,e,r,n,i,s){const o=q(r);if(!function(t,e,r){switch(r){case"pubkey":case"pubkeyhash":case"witnesspubkeyhash":return E(1,t.partialSig);case"multisig":const r=l.p2ms({output:e});return E(r.m,t.partialSig,r.pubkeys);default:return!1}}(e,r,o))throw new Error(`Can not finalize input #${t}`);return function(t,e,r,n,i,s){let o,a;const u=function(t,e,r){let n;switch(e){case"multisig":const e=function(t,e){return l.p2ms({output:t}).pubkeys.map((t=>(e.filter((e=>e.pubkey.equals(t)))[0]||{}).signature)).filter((t=>!!t))}(t,r);n=l.p2ms({output:t,signatures:e});break;case"pubkey":n=l.p2pk({output:t,signature:r[0].signature});break;case"pubkeyhash":n=l.p2pkh({output:t,pubkey:r[0].pubkey,signature:r[0].signature});break;case"witnesspubkeyhash":n=l.p2wpkh({output:t,pubkey:r[0].pubkey,signature:r[0].signature})}return n}(t,e,r),c=s?l.p2wsh({redeem:u}):null,f=i?l.p2sh({redeem:c||u}):null;return n?(a=c?(0,g.witnessStackToScriptWitness)(c.witness):(0,g.witnessStackToScriptWitness)(u.witness),f&&(o=f.input)):o=f?f.input:u.input,{finalScriptSig:o,finalScriptWitness:a}}(r,o,e.partialSig,n,i,s)}function _(t,e,r,n,i){const s=(0,o.checkForInput)(t,e),{hash:a,sighashType:u,script:c}=R(e,s,n,!1,i);return T(r,c,"sign"),{hash:a,sighashType:u}}function R(t,e,r,n,i){const s=r.__TX,o=e.sighashType||p.Transaction.SIGHASH_ALL;let a,u;if(D(o,i),e.nonWitnessUtxo){const n=V(r,e,t),i=s.ins[t].hash,o=n.getHash();if(!i.equals(o))throw new Error(`Non-witness UTXO hash for input #${t} doesn't match the hash specified in the prevout`);const a=s.ins[t].index;u=n.outs[a]}else{if(!e.witnessUtxo)throw new Error("Need a Utxo input item for signing");u=e.witnessUtxo}const{meaningfulScript:c,type:f}=z(u.script,t,"input",e.redeemScript,e.witnessScript);if(["p2sh-p2wsh","p2wsh"].indexOf(f)>=0)a=s.hashForWitnessV0(t,c,u.value,o);else if((0,g.isP2WPKH)(c)){const e=l.p2pkh({hash:c.slice(2)}).output;a=s.hashForWitnessV0(t,e,u.value,o)}else{if(void 0===e.nonWitnessUtxo&&!1===r.__UNSAFE_SIGN_NONSEGWIT)throw new Error(`Input #${t} has witnessUtxo but non-segwit script: ${c.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 predecesor (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*********************"),a=s.hashForSignature(t,c,o)}return{script:c,sighashType:o,hash:a}}function U(t,e,r){const{script:n}=Q(t,e,r);return(0,g.isP2TR)(n)?n.subarray(2,34):null}function L(t){return 64===t.length?t:t.subarray(0,64)}function F(t,e,r,i,s,o,a){const u=s.__TX,c=e.sighashType||p.Transaction.SIGHASH_DEFAULT;D(c,a);const l=r.map(((t,e)=>Q(e,t,s))),h=l.map((t=>t.script)),y=l.map((t=>t.value)),w=[];if(e.tapInternalKey&&!o){const r=U(t,e,s)||n.from([]);if((0,d.toXOnly)(i).equals(r)){const e=u.hashForWitnessV1(t,h,y,c);w.push({pubkey:i,hash:e})}}const m=(e.tapLeafScript||[]).filter((t=>(0,g.pubkeyInScript)(i,t.script))).map((t=>{const e=(0,f.tapleafHash)({output:t.script,version:t.leafVersion});return Object.assign({hash:e},t)})).filter((t=>!o||o.equals(t.hash))).map((e=>{const r=u.hashForWitnessV1(t,h,y,p.Transaction.SIGHASH_DEFAULT,e.hash);return{pubkey:i,hash:r,leafHash:e.hash}}));return w.concat(m)}function D(t,e){if(e&&e.indexOf(t)<0){const e=function(t){let e=t&p.Transaction.SIGHASH_ANYONECANPAY?"SIGHASH_ANYONECANPAY | ":"";switch(31&t){case p.Transaction.SIGHASH_ALL:e+="SIGHASH_ALL";break;case p.Transaction.SIGHASH_SINGLE:e+="SIGHASH_SINGLE";break;case p.Transaction.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: ${e}`)}}function H(t,e,r){const n=(0,o.checkForInput)(e,t);if(!n.bip32Derivation||0===n.bip32Derivation.length)throw new Error("Need bip32Derivation to sign with HD");const i=n.bip32Derivation.map((t=>t.masterFingerprint.equals(r.fingerprint)?t:void 0)).filter((t=>!!t));if(0===i.length)throw new Error("Need one bip32Derivation masterFingerprint to match the HDSigner fingerprint");return i.map((t=>{const e=r.derivePath(t.path);if(!t.pubkey.equals(e.publicKey))throw new Error("pubkey did not match bip32Derivation");return e}))}function M(t){let e=0;function r(){const r=s.decode(t,e);return e+=s.decode.bytes,r}return function(){const n=r(),i=[];for(let o=0;o<n;o++)i.push((s=void 0,s=r(),e+=s,t.slice(e-s,e)));var s;return i}()}function G(t,e,r){t.__NON_WITNESS_UTXO_BUF_CACHE[r]=e.nonWitnessUtxo;const n=p.Transaction.fromBuffer(e.nonWitnessUtxo);t.__NON_WITNESS_UTXO_TX_CACHE[r]=n;const i=t,s=r;delete e.nonWitnessUtxo,Object.defineProperty(e,"nonWitnessUtxo",{enumerable:!0,get(){const t=i.__NON_WITNESS_UTXO_BUF_CACHE[s],e=i.__NON_WITNESS_UTXO_TX_CACHE[s];if(void 0!==t)return t;{const t=e.toBuffer();return i.__NON_WITNESS_UTXO_BUF_CACHE[s]=t,t}},set(t){i.__NON_WITNESS_UTXO_BUF_CACHE[s]=t}})}function j(t,e,r,n){let i=0;t.forEach(((t,s)=>{if(n&&t.finalScriptSig&&(e.ins[s].script=t.finalScriptSig),n&&t.finalScriptWitness&&(e.ins[s].witness=M(t.finalScriptWitness)),t.witnessUtxo)i+=t.witnessUtxo.value;else if(t.nonWitnessUtxo){const n=V(r,t,s),o=e.ins[s].index,a=n.outs[o];i+=a.value}}));const s=e.outs.reduce(((t,e)=>t+e.value),0),o=i-s;if(o<0)throw new Error("Outputs are spending more than Inputs");const a=e.virtualSize();r.__FEE=o,r.__EXTRACTED_TX=e,r.__FEE_RATE=Math.floor(o/a)}function V(t,e,r){const n=t.__NON_WITNESS_UTXO_TX_CACHE;return n[r]||G(t,e,r),n[r]}function K(t,e,r){const{script:n}=Q(t,e,r);return n}function Q(t,e,r){if(void 0!==e.witnessUtxo)return{script:e.witnessUtxo.script,value:e.witnessUtxo.value};if(void 0!==e.nonWitnessUtxo){const n=V(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 W(t){return 33===t.length&&h.isCanonicalPubKey(t)}function z(t,e,r,n,i){const s=(0,g.isP2SHScript)(t),o=s&&n&&(0,g.isP2WSHScript)(n),a=(0,g.isP2WSHScript)(t);if(s&&void 0===n)throw new Error("scriptPubkey is P2SH but redeemScript missing");if((a||o)&&void 0===i)throw new Error("scriptPubkey or redeemScript is P2WSH but witnessScript missing");let u;return o?(u=i,B(e,t,n,r),N(e,n,i,r),J(u)):a?(u=i,N(e,t,i,r),J(u)):s?(u=n,B(e,t,n,r)):u=t,{meaningfulScript:u,type:o?"p2sh-p2wsh":s?"p2sh":a?"p2wsh":"raw"}}function J(t){if((0,g.isP2WPKH)(t)||(0,g.isP2SHScript)(t))throw new Error("P2WPKH or P2SH can not be contained within P2WSH")}function q(t){return(0,g.isP2WPKH)(t)?"witnesspubkeyhash":(0,g.isP2PKH)(t)?"pubkeyhash":(0,g.isP2MS)(t)?"multisig":(0,g.isP2PK)(t)?"pubkey":"nonstandard"}function X(t){return[...Array(t).keys()]}},477:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),e.checkTaprootInputForSigs=e.tapTreeFromList=e.tapTreeToList=e.tweakInternalPubKey=e.checkTaprootOutputFields=e.checkTaprootInputFields=e.isTaprootOutput=e.isTaprootInput=e.serializeTaprootSignature=e.tapScriptFinalizer=e.toXOnly=void 0;const i=r(8116),s=r(2021),o=r(4929),a=r(2218),u=r(885),c=r(4929);function l(t){return t&&!!(t.tapInternalKey||t.tapMerkleRoot||t.tapLeafScript&&t.tapLeafScript.length||t.tapBip32Derivation&&t.tapBip32Derivation.length||t.witnessUtxo&&(0,o.isP2TR)(t.witnessUtxo.script))}function f(t,e){return t&&!!(t.tapInternalKey||t.tapTree||t.tapBip32Derivation&&t.tapBip32Derivation.length||e&&(0,o.isP2TR)(e))}function h(t=[]){return 1===t.length&&0===t[0].depth?{output:t[0].script,version:t[0].leafVersion}:function(t){let e;for(const r of t)if(e=g(r,e),!e)throw new Error("No room left to insert tapleaf in tree");return e}(t)}function p(t){return{signature:t.slice(0,64),hashType:t.slice(64)[0]||s.Transaction.SIGHASH_DEFAULT}}function d(t,e=[],r=0){if(r>a.MAX_TAPTREE_DEPTH)throw new Error("Max taptree depth exceeded.");return t?(0,i.isTapleaf)(t)?(e.push({depth:r,leafVersion:t.version||a.LEAF_VERSION_TAPSCRIPT,script:t.output}),e):(t[0]&&d(t[0],e,r+1),t[1]&&d(t[1],e,r+1),e):[]}function g(t,e,r=0){if(r>a.MAX_TAPTREE_DEPTH)throw new Error("Max taptree depth exceeded.");if(t.depth===r)return e?void 0:{output:t.script,version:t.leafVersion};if((0,i.isTapleaf)(e))return;const n=g(t,e&&e[0],r+1);if(n)return[n,e&&e[1]];const s=g(t,e&&e[1],r+1);return s?[e&&e[0],s]:void 0}function y(t,e){if(!e)return!0;const r=(0,a.tapleafHash)({output:t.script,version:t.leafVersion});return(0,a.rootHashFromPath)(t.controlBlock,r).equals(e)}function w(t){return t&&!!(t.redeemScript||t.witnessScript||t.bip32Derivation&&t.bip32Derivation.length)}e.toXOnly=t=>32===t.length?t:t.slice(1,33),e.tapScriptFinalizer=function(t,e,r){const n=function(t,e,r){if(!t.tapScriptSig||!t.tapScriptSig.length)throw new Error(`Can not finalize taproot input #${e}. No tapleaf script signature provided.`);const n=(t.tapLeafScript||[]).sort(((t,e)=>t.controlBlock.length-e.controlBlock.length)).find((e=>function(t,e,r){const n=(0,a.tapleafHash)({output:t.script,version:t.leafVersion});return(!r||r.equals(n))&&void 0!==e.find((t=>t.leafHash.equals(n)))}(e,t.tapScriptSig,r)));if(!n)throw new Error(`Can not finalize taproot input #${e}. Signature for tapleaf script not found.`);return n}(e,t,r);try{const t=function(t,e){const r=(0,a.tapleafHash)({output:e.script,version:e.leafVersion});return(t.tapScriptSig||[]).filter((t=>t.leafHash.equals(r))).map((t=>function(t,e){return Object.assign({positionInScript:(0,o.pubkeyPositionInScript)(e.pubkey,t)},e)}(e.script,t))).sort(((t,e)=>e.positionInScript-t.positionInScript)).map((t=>t.signature))}(e,n),r=t.concat(n.script).concat(n.controlBlock);return{finalScriptWitness:(0,o.witnessStackToScriptWitness)(r)}}catch(e){throw new Error(`Can not finalize taproot input #${t}: ${e}`)}},e.serializeTaprootSignature=function(t,e){const r=e?n.from([e]):n.from([]);return n.concat([t,r])},e.isTaprootInput=l,e.isTaprootOutput=f,e.checkTaprootInputFields=function(t,e,r){!function(t,e,r){const n=l(t)&&w(e),i=w(t)&&l(e),s=t===e&&l(e)&&w(e);if(n||i||s)throw new Error(`Invalid arguments for Psbt.${r}. Cannot use both taproot and non-taproot fields.`)}(t,e,r),function(t,e,r){if(e.tapMerkleRoot){const n=(e.tapLeafScript||[]).every((t=>y(t,e.tapMerkleRoot))),i=(t.tapLeafScript||[]).every((t=>y(t,e.tapMerkleRoot)));if(!n||!i)throw new Error(`Invalid arguments for Psbt.${r}. Tapleaf not part of taptree.`)}else if(t.tapMerkleRoot&&!(e.tapLeafScript||[]).every((e=>y(e,t.tapMerkleRoot))))throw new Error(`Invalid arguments for Psbt.${r}. Tapleaf not part of taptree.`)}(t,e,r)},e.checkTaprootOutputFields=function(t,e,r){!function(t,e,r){const n=f(t)&&w(e),i=w(t)&&f(e),s=t===e&&f(e)&&w(e);if(n||i||s)throw new Error(`Invalid arguments for Psbt.${r}. Cannot use both taproot and non-taproot fields.`)}(t,e,r),function(t,e){if(!e.tapTree&&!e.tapInternalKey)return;const r=e.tapInternalKey||t.tapInternalKey,n=e.tapTree||t.tapTree;if(r){const{script:e}=t,i=function(t,e){const r=e&&h(e.leaves),{output:n}=(0,u.p2tr)({internalPubkey:t,scriptTree:r});return n}(r,n);if(e&&!e.equals(i))throw new Error("Error adding output. Script or address missmatch.")}}(t,e)},e.tweakInternalPubKey=function(t,e){const r=e.tapInternalKey,n=r&&(0,a.tweakKey)(r,e.tapMerkleRoot);if(!n)throw new Error(`Cannot tweak tap internal key for input #${t}. Public key: ${r&&r.toString("hex")}`);return n.x},e.tapTreeToList=function(t){if(!(0,i.isTaptree)(t))throw new Error("Cannot convert taptree to tapleaf list. Expecting a tapree structure.");return d(t)},e.tapTreeFromList=h,e.checkTaprootInputForSigs=function(t,e){return function(t){const e=[];if(t.tapKeySig&&e.push(t.tapKeySig),t.tapScriptSig&&e.push(...t.tapScriptSig.map((t=>t.signature))),!e.length){const r=function(t){if(!t)return;const e=t.slice(2);return 64===e.length||65===e.length?e:void 0}(t.finalScriptWitness);r&&e.push(r)}return e}(t).some((t=>(0,c.signatureBlocksAction)(t,p,e)))}},4929:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),e.signatureBlocksAction=e.checkInputForSig=e.pubkeyInScript=e.pubkeyPositionInScript=e.witnessStackToScriptWitness=e.isP2TR=e.isP2SHScript=e.isP2WSHScript=e.isP2WPKH=e.isP2PKH=e.isP2PK=e.isP2MS=void 0;const i=r(394),s=r(7038),o=r(2021),a=r(1944),u=r(885);function c(t){return e=>{try{return t({output:e}),!0}catch(t){return!1}}}function l(t,e){const r=(0,a.hash160)(t),n=t.slice(1,33),i=s.decompile(e);if(null===i)throw new Error("Unknown script error");return i.findIndex((e=>"number"!=typeof e&&(e.equals(t)||e.equals(r)||e.equals(n))))}function f(t,e,r){const{hashType:n}=e(t),i=[];switch(n&o.Transaction.SIGHASH_ANYONECANPAY&&i.push("addInput"),31&n){case o.Transaction.SIGHASH_ALL:break;case o.Transaction.SIGHASH_SINGLE:case o.Transaction.SIGHASH_NONE:i.push("addOutput"),i.push("setInputSequence")}return-1===i.indexOf(r)}e.isP2MS=c(u.p2ms),e.isP2PK=c(u.p2pk),e.isP2PKH=c(u.p2pkh),e.isP2WPKH=c(u.p2wpkh),e.isP2WSHScript=c(u.p2wsh),e.isP2SHScript=c(u.p2sh),e.isP2TR=c(u.p2tr),e.witnessStackToScriptWitness=function(t){let e=n.allocUnsafe(0);function r(t){const r=e.length,s=i.encodingLength(t);e=n.concat([e,n.allocUnsafe(s)]),i.encode(t,e,r)}var s;return r((s=t).length),s.forEach((function(t){r(t.length),function(t){e=n.concat([e,n.from(t)])}(t)})),e},e.pubkeyPositionInScript=l,e.pubkeyInScript=function(t,e){return-1!==l(t,e)},e.checkInputForSig=function(t,e){return function(t){let e=[];if(0===(t.partialSig||[]).length){if(!t.finalScriptSig&&!t.finalScriptWitness)return[];e=function(t){const e=t.finalScriptSig&&s.decompile(t.finalScriptSig)||[],r=t.finalScriptWitness&&s.decompile(t.finalScriptWitness)||[];return e.concat(r).filter((t=>n.isBuffer(t)&&s.isCanonicalScriptSignature(t))).map((t=>({signature:t})))}(t)}else e=t.partialSig;return e.map((t=>t.signature))}(t).some((t=>f(t,s.signature.decode,e)))},e.signatureBlocksAction=f},4344:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.decode=e.encode=e.encodingLength=void 0;const n=r(8417);function i(t){return t<n.OPS.OP_PUSHDATA1?1:t<=255?2:t<=65535?3:5}e.encodingLength=i,e.encode=function(t,e,r){const s=i(e);return 1===s?t.writeUInt8(e,r):2===s?(t.writeUInt8(n.OPS.OP_PUSHDATA1,r),t.writeUInt8(e,r+1)):3===s?(t.writeUInt8(n.OPS.OP_PUSHDATA2,r),t.writeUInt16LE(e,r+1)):(t.writeUInt8(n.OPS.OP_PUSHDATA4,r),t.writeUInt32LE(e,r+1)),s},e.decode=function(t,e){const r=t.readUInt8(e);let i,s;if(r<n.OPS.OP_PUSHDATA1)i=r,s=1;else if(r===n.OPS.OP_PUSHDATA1){if(e+2>t.length)return null;i=t.readUInt8(e+1),s=2}else if(r===n.OPS.OP_PUSHDATA2){if(e+3>t.length)return null;i=t.readUInt16LE(e+1),s=3}else{if(e+5>t.length)return null;if(r!==n.OPS.OP_PUSHDATA4)throw new Error("Unexpected opcode");i=t.readUInt32LE(e+1),s=5}return{opcode:r,number:i,size:s}}},7038:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),e.signature=e.number=e.isCanonicalScriptSignature=e.isDefinedHashType=e.isCanonicalPubKey=e.toStack=e.fromASM=e.toASM=e.decompile=e.compile=e.countNonPushOnlyOPs=e.isPushOnly=e.OPS=void 0;const i=r(3966),s=r(8417);Object.defineProperty(e,"OPS",{enumerable:!0,get:function(){return s.OPS}});const o=r(4344),a=r(9464),u=r(1043),c=r(8116),{typeforce:l}=c,f=s.OPS.OP_RESERVED;function h(t){return c.Buffer(t)||function(t){return c.Number(t)&&(t===s.OPS.OP_0||t>=s.OPS.OP_1&&t<=s.OPS.OP_16||t===s.OPS.OP_1NEGATE)}(t)}function p(t){return c.Array(t)&&t.every(h)}function d(t){return 0===t.length?s.OPS.OP_0:1===t.length?t[0]>=1&&t[0]<=16?f+t[0]:129===t[0]?s.OPS.OP_1NEGATE:void 0:void 0}function g(t){return n.isBuffer(t)}function y(t){return n.isBuffer(t)}function w(t){if(g(t))return t;l(c.Array,t);const e=t.reduce(((t,e)=>y(e)?1===e.length&&void 0!==d(e)?t+1:t+o.encodingLength(e.length)+e.length:t+1),0),r=n.allocUnsafe(e);let i=0;if(t.forEach((t=>{if(y(t)){const e=d(t);if(void 0!==e)return r.writeUInt8(e,i),void(i+=1);i+=o.encode(r,t.length,i),t.copy(r,i),i+=t.length}else r.writeUInt8(t,i),i+=1})),i!==r.length)throw new Error("Could not decode chunks");return r}function m(t){if(e=t,c.Array(e))return t;var e;l(c.Buffer,t);const r=[];let n=0;for(;n<t.length;){const e=t[n];if(e>s.OPS.OP_0&&e<=s.OPS.OP_PUSHDATA4){const e=o.decode(t,n);if(null===e)return null;if(n+=e.size,n+e.number>t.length)return null;const i=t.slice(n,n+e.number);n+=e.number;const s=d(i);void 0!==s?r.push(s):r.push(i)}else r.push(e),n+=1}return r}function b(t){const e=-129&t;return e>0&&e<4}e.isPushOnly=p,e.countNonPushOnlyOPs=function(t){return t.length-t.filter(h).length},e.compile=w,e.decompile=m,e.toASM=function(t){return g(t)&&(t=m(t)),t.map((t=>{if(y(t)){const e=d(t);if(void 0===e)return t.toString("hex");t=e}return s.REVERSE_OPS[t]})).join(" ")},e.fromASM=function(t){return l(c.String,t),w(t.split(" ").map((t=>void 0!==s.OPS[t]?s.OPS[t]:(l(c.Hex,t),n.from(t,"hex")))))},e.toStack=function(t){return t=m(t),l(p,t),t.map((t=>y(t)?t:t===s.OPS.OP_0?n.allocUnsafe(0):a.encode(t-f)))},e.isCanonicalPubKey=function(t){return c.isPoint(t)},e.isDefinedHashType=b,e.isCanonicalScriptSignature=function(t){return!!n.isBuffer(t)&&!!b(t[t.length-1])&&i.check(t.slice(0,-1))},e.number=a,e.signature=u},9464:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),e.encode=e.decode=void 0,e.decode=function(t,e,r){e=e||4,r=void 0===r||r;const 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){const e=t.readUInt32LE(0),r=t.readUInt8(4);return 128&r?-(4294967296*(-129&r)+e):4294967296*r+e}let i=0;for(let e=0;e<n;++e)i|=t[e]<<8*e;return 128&t[n-1]?-(i&~(128<<8*(n-1))):i},e.encode=function(t){let e=Math.abs(t);const r=(i=e)>2147483647?5:i>8388607?4:i>32767?3:i>127?2:i>0?1:0;var i;const s=n.allocUnsafe(r),o=t<0;for(let t=0;t<r;++t)s.writeUInt8(255&e,t),e>>=8;return 128&s[r-1]?s.writeUInt8(o?128:0,r-1):o&&(s[r-1]|=128),s}},1043:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),e.encode=e.decode=void 0;const i=r(3966),s=r(8116),{typeforce:o}=s,a=n.alloc(1,0);function u(t){let e=0;for(;0===t[e];)++e;return e===t.length?a:128&(t=t.slice(e))[0]?n.concat([a,t],1+t.length):t}function c(t){0===t[0]&&(t=t.slice(1));const e=n.alloc(32,0),r=Math.max(0,32-t.length);return t.copy(e,r),e}e.decode=function(t){const e=t.readUInt8(t.length-1),r=-129&e;if(r<=0||r>=4)throw new Error("Invalid hashType "+e);const s=i.decode(t.slice(0,-1)),o=c(s.r),a=c(s.s);return{signature:n.concat([o,a],64),hashType:e}},e.encode=function(t,e){o({signature:s.BufferN(64),hashType:s.UInt8},{signature:t,hashType:e});const r=-129&e;if(r<=0||r>=4)throw new Error("Invalid hashType "+e);const a=n.allocUnsafe(1);a.writeUInt8(e,0);const c=u(t.slice(0,32)),l=u(t.slice(32,64));return n.concat([i.encode(c,l),a])}},2021:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),e.Transaction=void 0;const i=r(606),s=r(1944),o=r(7038),a=r(7038),u=r(8116),{typeforce:c}=u;function l(t){const e=t.length;return i.varuint.encodingLength(e)+e}const f=n.allocUnsafe(0),h=[],p=n.from("0000000000000000000000000000000000000000000000000000000000000000","hex"),d=n.from("0000000000000000000000000000000000000000000000000000000000000001","hex"),g=n.from("ffffffffffffffff","hex"),y={script:f,valueBuffer:g};class w{constructor(){this.version=1,this.locktime=0,this.ins=[],this.outs=[]}static fromBuffer(t,e){const r=new i.BufferReader(t),n=new w;n.version=r.readInt32();const s=r.readUInt8(),o=r.readUInt8();let a=!1;s===w.ADVANCED_TRANSACTION_MARKER&&o===w.ADVANCED_TRANSACTION_FLAG?a=!0:r.offset-=2;const u=r.readVarInt();for(let t=0;t<u;++t)n.ins.push({hash:r.readSlice(32),index:r.readUInt32(),script:r.readVarSlice(),sequence:r.readUInt32(),witness:h});const c=r.readVarInt();for(let t=0;t<c;++t)n.outs.push({value:r.readUInt64(),script:r.readVarSlice()});if(a){for(let t=0;t<u;++t)n.ins[t].witness=r.readVector();if(!n.hasWitnesses())throw new Error("Transaction has superfluous witness data")}if(n.locktime=r.readUInt32(),e)return n;if(r.offset!==t.length)throw new Error("Transaction has unexpected data");return n}static fromHex(t){return w.fromBuffer(n.from(t,"hex"),!1)}static isCoinbaseHash(t){c(u.Hash256bit,t);for(let e=0;e<32;++e)if(0!==t[e])return!1;return!0}isCoinbase(){return 1===this.ins.length&&w.isCoinbaseHash(this.ins[0].hash)}addInput(t,e,r,n){return c(u.tuple(u.Hash256bit,u.UInt32,u.maybe(u.UInt32),u.maybe(u.Buffer)),arguments),u.Null(r)&&(r=w.DEFAULT_SEQUENCE),this.ins.push({hash:t,index:e,script:n||f,sequence:r,witness:h})-1}addOutput(t,e){return c(u.tuple(u.Buffer,u.Satoshi),arguments),this.outs.push({script:t,value:e})-1}hasWitnesses(){return this.ins.some((t=>0!==t.witness.length))}weight(){return 3*this.byteLength(!1)+this.byteLength(!0)}virtualSize(){return Math.ceil(this.weight()/4)}byteLength(t=!0){const e=t&&this.hasWitnesses();return(e?10:8)+i.varuint.encodingLength(this.ins.length)+i.varuint.encodingLength(this.outs.length)+this.ins.reduce(((t,e)=>t+40+l(e.script)),0)+this.outs.reduce(((t,e)=>t+8+l(e.script)),0)+(e?this.ins.reduce(((t,e)=>t+function(t){const e=t.length;return i.varuint.encodingLength(e)+t.reduce(((t,e)=>t+l(e)),0)}(e.witness)),0):0)}clone(){const t=new w;return t.version=this.version,t.locktime=this.locktime,t.ins=this.ins.map((t=>({hash:t.hash,index:t.index,script:t.script,sequence:t.sequence,witness:t.witness}))),t.outs=this.outs.map((t=>({script:t.script,value:t.value}))),t}hashForSignature(t,e,r){if(c(u.tuple(u.UInt32,u.Buffer,u.Number),arguments),t>=this.ins.length)return d;const i=o.compile(o.decompile(e).filter((t=>t!==a.OPS.OP_CODESEPARATOR))),l=this.clone();if((31&r)===w.SIGHASH_NONE)l.outs=[],l.ins.forEach(((e,r)=>{r!==t&&(e.sequence=0)}));else if((31&r)===w.SIGHASH_SINGLE){if(t>=this.outs.length)return d;l.outs.length=t+1;for(let e=0;e<t;e++)l.outs[e]=y;l.ins.forEach(((e,r)=>{r!==t&&(e.sequence=0)}))}r&w.SIGHASH_ANYONECANPAY?(l.ins=[l.ins[t]],l.ins[0].script=i):(l.ins.forEach((t=>{t.script=f})),l.ins[t].script=i);const h=n.allocUnsafe(l.byteLength(!1)+4);return h.writeInt32LE(r,h.length-4),l.__toBuffer(h,0,!1),s.hash256(h)}hashForWitnessV1(t,e,r,o,a,h){if(c(u.tuple(u.UInt32,c.arrayOf(u.Buffer),c.arrayOf(u.Satoshi),u.UInt32),arguments),r.length!==this.ins.length||e.length!==this.ins.length)throw new Error("Must supply prevout script and value for all inputs");const p=o===w.SIGHASH_DEFAULT?w.SIGHASH_ALL:o&w.SIGHASH_OUTPUT_MASK,d=(o&w.SIGHASH_INPUT_MASK)===w.SIGHASH_ANYONECANPAY,g=p===w.SIGHASH_NONE,y=p===w.SIGHASH_SINGLE;let m=f,b=f,A=f,E=f,v=f;if(!d){let t=i.BufferWriter.withCapacity(36*this.ins.length);this.ins.forEach((e=>{t.writeSlice(e.hash),t.writeUInt32(e.index)})),m=s.sha256(t.end()),t=i.BufferWriter.withCapacity(8*this.ins.length),r.forEach((e=>t.writeUInt64(e))),b=s.sha256(t.end()),t=i.BufferWriter.withCapacity(e.map(l).reduce(((t,e)=>t+e))),e.forEach((e=>t.writeVarSlice(e))),A=s.sha256(t.end()),t=i.BufferWriter.withCapacity(4*this.ins.length),this.ins.forEach((e=>t.writeUInt32(e.sequence))),E=s.sha256(t.end())}if(g||y){if(y&&t<this.outs.length){const e=this.outs[t],r=i.BufferWriter.withCapacity(8+l(e.script));r.writeUInt64(e.value),r.writeVarSlice(e.script),v=s.sha256(r.end())}}else{const t=this.outs.map((t=>8+l(t.script))).reduce(((t,e)=>t+e)),e=i.BufferWriter.withCapacity(t);this.outs.forEach((t=>{e.writeUInt64(t.value),e.writeVarSlice(t.script)})),v=s.sha256(e.end())}const S=(a?2:0)+(h?1:0),I=174-(d?49:0)-(g?32:0)+(h?32:0)+(a?37:0),k=i.BufferWriter.withCapacity(I);if(k.writeUInt8(o),k.writeInt32(this.version),k.writeUInt32(this.locktime),k.writeSlice(m),k.writeSlice(b),k.writeSlice(A),k.writeSlice(E),g||y||k.writeSlice(v),k.writeUInt8(S),d){const n=this.ins[t];k.writeSlice(n.hash),k.writeUInt32(n.index),k.writeUInt64(r[t]),k.writeVarSlice(e[t]),k.writeUInt32(n.sequence)}else k.writeUInt32(t);if(h){const t=i.BufferWriter.withCapacity(l(h));t.writeVarSlice(h),k.writeSlice(s.sha256(t.end()))}return y&&k.writeSlice(v),a&&(k.writeSlice(a),k.writeUInt8(0),k.writeUInt32(4294967295)),s.taggedHash("TapSighash",n.concat([n.from([0]),k.end()]))}hashForWitnessV0(t,e,r,o){c(u.tuple(u.UInt32,u.Buffer,u.Satoshi,u.UInt32),arguments);let a,f=n.from([]),h=p,d=p,g=p;if(o&w.SIGHASH_ANYONECANPAY||(f=n.allocUnsafe(36*this.ins.length),a=new i.BufferWriter(f,0),this.ins.forEach((t=>{a.writeSlice(t.hash),a.writeUInt32(t.index)})),d=s.hash256(f)),o&w.SIGHASH_ANYONECANPAY||(31&o)===w.SIGHASH_SINGLE||(31&o)===w.SIGHASH_NONE||(f=n.allocUnsafe(4*this.ins.length),a=new i.BufferWriter(f,0),this.ins.forEach((t=>{a.writeUInt32(t.sequence)})),g=s.hash256(f)),(31&o)!==w.SIGHASH_SINGLE&&(31&o)!==w.SIGHASH_NONE){const t=this.outs.reduce(((t,e)=>t+8+l(e.script)),0);f=n.allocUnsafe(t),a=new i.BufferWriter(f,0),this.outs.forEach((t=>{a.writeUInt64(t.value),a.writeVarSlice(t.script)})),h=s.hash256(f)}else if((31&o)===w.SIGHASH_SINGLE&&t<this.outs.length){const e=this.outs[t];f=n.allocUnsafe(8+l(e.script)),a=new i.BufferWriter(f,0),a.writeUInt64(e.value),a.writeVarSlice(e.script),h=s.hash256(f)}f=n.allocUnsafe(156+l(e)),a=new i.BufferWriter(f,0);const y=this.ins[t];return a.writeInt32(this.version),a.writeSlice(d),a.writeSlice(g),a.writeSlice(y.hash),a.writeUInt32(y.index),a.writeVarSlice(e),a.writeUInt64(r),a.writeUInt32(y.sequence),a.writeSlice(h),a.writeUInt32(this.locktime),a.writeUInt32(o),s.hash256(f)}getHash(t){return t&&this.isCoinbase()?n.alloc(32,0):s.hash256(this.__toBuffer(void 0,void 0,t))}getId(){return(0,i.reverseBuffer)(this.getHash(!1)).toString("hex")}toBuffer(t,e){return this.__toBuffer(t,e,!0)}toHex(){return this.toBuffer(void 0,void 0).toString("hex")}setInputScript(t,e){c(u.tuple(u.Number,u.Buffer),arguments),this.ins[t].script=e}setWitness(t,e){c(u.tuple(u.Number,[u.Buffer]),arguments),this.ins[t].witness=e}__toBuffer(t,e,r=!1){t||(t=n.allocUnsafe(this.byteLength(r)));const s=new i.BufferWriter(t,e||0);s.writeInt32(this.version);const o=r&&this.hasWitnesses();return o&&(s.writeUInt8(w.ADVANCED_TRANSACTION_MARKER),s.writeUInt8(w.ADVANCED_TRANSACTION_FLAG)),s.writeVarInt(this.ins.length),this.ins.forEach((t=>{s.writeSlice(t.hash),s.writeUInt32(t.index),s.writeVarSlice(t.script),s.writeUInt32(t.sequence)})),s.writeVarInt(this.outs.length),this.outs.forEach((t=>{void 0!==t.value?s.writeUInt64(t.value):s.writeSlice(t.valueBuffer),s.writeVarSlice(t.script)})),o&&this.ins.forEach((t=>{s.writeVector(t.witness)})),s.writeUInt32(this.locktime),void 0!==e?t.slice(e,s.offset):t}}e.Transaction=w,w.DEFAULT_SEQUENCE=4294967295,w.SIGHASH_DEFAULT=0,w.SIGHASH_ALL=1,w.SIGHASH_NONE=2,w.SIGHASH_SINGLE=3,w.SIGHASH_ANYONECANPAY=128,w.SIGHASH_OUTPUT_MASK=3,w.SIGHASH_INPUT_MASK=128,w.ADVANCED_TRANSACTION_MARKER=0,w.ADVANCED_TRANSACTION_FLAG=1},8116:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.oneOf=e.Null=e.BufferN=e.Function=e.UInt32=e.UInt8=e.tuple=e.maybe=e.Hex=e.Buffer=e.String=e.Boolean=e.Array=e.Number=e.Hash256bit=e.Hash160bit=e.Buffer256bit=e.isTaptree=e.isTapleaf=e.TAPLEAF_VERSION_MASK=e.Network=e.ECPoint=e.Satoshi=e.Signer=e.BIP32Path=e.UInt31=e.isPoint=e.typeforce=void 0;const n=r(8287);e.typeforce=r(8676);const i=n.Buffer.alloc(32,0),s=n.Buffer.from("fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f","hex");e.isPoint=function(t){if(!n.Buffer.isBuffer(t))return!1;if(t.length<33)return!1;const e=t[0],r=t.slice(1,33);if(0===r.compare(i))return!1;if(r.compare(s)>=0)return!1;if((2===e||3===e)&&33===t.length)return!0;const o=t.slice(33);return 0!==o.compare(i)&&!(o.compare(s)>=0)&&4===e&&65===t.length};const o=Math.pow(2,31)-1;function a(t){return e.typeforce.String(t)&&!!t.match(/^(m\/)?(\d+'?\/)*\d+'?$/)}function u(t){return!(!t||!("output"in t)||!n.Buffer.isBuffer(t.output)||void 0!==t.version&&(t.version&e.TAPLEAF_VERSION_MASK)!==t.version)}e.UInt31=function(t){return e.typeforce.UInt32(t)&&t<=o},e.BIP32Path=a,a.toJSON=()=>"BIP32 derivation path",e.Signer=function(t){return(e.typeforce.Buffer(t.publicKey)||"function"==typeof t.getPublicKey)&&"function"==typeof t.sign},e.Satoshi=function(t){return e.typeforce.UInt53(t)&&t<=21e14},e.ECPoint=e.typeforce.quacksLike("Point"),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.TAPLEAF_VERSION_MASK=254,e.isTapleaf=u,e.isTaptree=function t(r){return(0,e.Array)(r)?2===r.length&&r.every((e=>t(e))):u(r)},e.Buffer256bit=e.typeforce.BufferN(32),e.Hash160bit=e.typeforce.BufferN(20),e.Hash256bit=e.typeforce.BufferN(32),e.Number=e.typeforce.Number,e.Array=e.typeforce.Array,e.Boolean=e.typeforce.Boolean,e.String=e.typeforce.String,e.Buffer=e.typeforce.Buffer,e.Hex=e.typeforce.Hex,e.maybe=e.typeforce.maybe,e.tuple=e.typeforce.tuple,e.UInt8=e.typeforce.UInt8,e.UInt32=e.typeforce.UInt32,e.Function=e.typeforce.Function,e.BufferN=e.typeforce.BufferN,e.Null=e.typeforce.Null,e.oneOf=e.typeforce.oneOf},6763:(t,e,r)=>{const n=r(5364);t.exports=n("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")},9204:(t,e,r)=>{var n=r(6763);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=Uint8Array.from(e),i=t(r),s=r.length+4,o=new Uint8Array(s);return o.set(r,0),o.set(i.subarray(0,4),r.length),n.encode(o,s)},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)}}}},1889:(t,e,r)=>{var{sha256:n}=r(2623),i=r(9204);t.exports=i((function(t){return n(n(t))}))},8287:(t,e,r)=>{const n=r(7526),i=r(251),s="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 o=2147483647;function a(t){if(t>o)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 f(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|g(t,e);let n=a(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(q(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(q(t,ArrayBuffer)||t&&q(t.buffer,ArrayBuffer))return p(t,e,r);if("undefined"!=typeof SharedArrayBuffer&&(q(t,SharedArrayBuffer)||t&&q(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=a(e);return 0===r.length||t.copy(r,0,0,e),r}return void 0!==t.length?"number"!=typeof t.length||X(t.length)?a(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 l(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 f(t){return l(t),a(t<0?0:0|d(t))}function h(t){const e=t.length<0?0:0|d(t.length),r=a(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>=o)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o.toString(16)+" bytes");return 0|t}function g(t,e){if(u.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||q(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 W(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:W(t).length;e=(""+e).toLowerCase(),i=!0}}function y(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 N(this,e,r);case"utf8":case"utf-8":return T(this,e,r);case"ascii":return O(this,e,r);case"latin1":case"binary":return B(this,e,r);case"base64":return k(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return x(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function w(t,e,r){const n=t[e];t[e]=t[r],t[r]=n}function m(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),X(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:b(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):b(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function b(t,e,r,n,i){let s,o=1,a=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;o=2,a/=2,u/=2,r/=2}function c(t,e){return 1===o?t[e]:t.readUInt16BE(e*o)}if(i){let n=-1;for(s=r;s<a;s++)if(c(t,s)===c(e,-1===n?0:s-n)){if(-1===n&&(n=s),s-n+1===u)return n*o}else-1!==n&&(s-=s-n),n=-1}else for(r+u>a&&(r=a-u),s=r;s>=0;s--){let r=!0;for(let n=0;n<u;n++)if(c(t,s+n)!==c(e,n)){r=!1;break}if(r)return s}return-1}function A(t,e,r,n){r=Number(r)||0;const i=t.length-r;n?(n=Number(n))>i&&(n=i):n=i;const s=e.length;let o;for(n>s/2&&(n=s/2),o=0;o<n;++o){const n=parseInt(e.substr(2*o,2),16);if(X(n))return o;t[r+o]=n}return o}function E(t,e,r,n){return J(W(e,t.length-r),t,r,n)}function v(t,e,r,n){return J(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 S(t,e,r,n){return J(z(e),t,r,n)}function I(t,e,r,n){return J(function(t,e){let r,n,i;const s=[];for(let o=0;o<t.length&&!((e-=2)<0);++o)r=t.charCodeAt(o),n=r>>8,i=r%256,s.push(i),s.push(n);return s}(e,t.length-r),t,r,n)}function k(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 s=null,o=e>239?4:e>223?3:e>191?2:1;if(i+o<=r){let r,n,a,u;switch(o){case 1:e<128&&(s=e);break;case 2:r=t[i+1],128==(192&r)&&(u=(31&e)<<6|63&r,u>127&&(s=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)&&(s=u));break;case 4:r=t[i+1],n=t[i+2],a=t[i+3],128==(192&r)&&128==(192&n)&&128==(192&a)&&(u=(15&e)<<18|(63&r)<<12|(63&n)<<6|63&a,u>65535&&u<1114112&&(s=u))}}null===s?(s=65533,o=1):s>65535&&(s-=65536,n.push(s>>>10&1023|55296),s=56320|1023&s),n.push(s),i+=o}return function(t){const e=t.length;if(e<=P)return String.fromCharCode.apply(String,t);let r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=P));return r}(n)}e.kMaxLength=o,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 l(t),t<=0?a(t):void 0!==e?"string"==typeof r?a(t).fill(e,r):a(t).fill(e):a(t)}(t,e,r)},u.allocUnsafe=function(t){return f(t)},u.allocUnsafeSlow=function(t){return f(t)},u.isBuffer=function(t){return null!=t&&!0===t._isBuffer&&t!==u.prototype},u.compare=function(t,e){if(q(t,Uint8Array)&&(t=u.from(t,t.offset,t.byteLength)),q(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,s=Math.min(r,n);i<s;++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(q(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=g,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)w(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)w(this,e,e+3),w(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)w(this,e,e+7),w(this,e+1,e+6),w(this,e+2,e+5),w(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):y.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+">"},s&&(u.prototype[s]=u.prototype.inspect),u.prototype.compare=function(t,e,r,n,i){if(q(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 s=(i>>>=0)-(n>>>=0),o=(r>>>=0)-(e>>>=0);const a=Math.min(s,o),c=this.slice(n,i),l=t.slice(e,r);for(let t=0;t<a;++t)if(c[t]!==l[t]){s=c[t],o=l[t];break}return s<o?-1:o<s?1:0},u.prototype.includes=function(t,e,r){return-1!==this.indexOf(t,e,r)},u.prototype.indexOf=function(t,e,r){return m(this,t,e,r,!0)},u.prototype.lastIndexOf=function(t,e,r){return m(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 s=!1;for(;;)switch(n){case"hex":return A(this,t,e,r);case"utf8":case"utf-8":return E(this,t,e,r);case"ascii":case"latin1":case"binary":return v(this,t,e,r);case"base64":return S(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return I(this,t,e,r);default:if(s)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),s=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const P=4096;function O(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 B(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 N(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+=Y[t[n]];return i}function x(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 C(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 _(t,e,r,n,i,s){if(!u.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||e<s)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}function R(t,e,r,n,i){j(e,n,i,t,r,7);let s=Number(e&BigInt(4294967295));t[r++]=s,s>>=8,t[r++]=s,s>>=8,t[r++]=s,s>>=8,t[r++]=s;let o=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=o,o>>=8,t[r++]=o,o>>=8,t[r++]=o,o>>=8,t[r++]=o,r}function U(t,e,r,n,i){j(e,n,i,t,r,7);let s=Number(e&BigInt(4294967295));t[r+7]=s,s>>=8,t[r+6]=s,s>>=8,t[r+5]=s,s>>=8,t[r+4]=s;let o=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=o,o>>=8,t[r+2]=o,o>>=8,t[r+1]=o,o>>=8,t[r]=o,r+8}function L(t,e,r,n,i,s){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function F(t,e,r,n,s){return e=+e,r>>>=0,s||L(t,0,r,4),i.write(t,e,r,n,23,4),r+4}function D(t,e,r,n,s){return e=+e,r>>>=0,s||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||C(t,e,this.length);let n=this[t],i=1,s=0;for(;++s<e&&(i*=256);)n+=this[t+s]*i;return n},u.prototype.readUintBE=u.prototype.readUIntBE=function(t,e,r){t>>>=0,e>>>=0,r||C(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||C(t,1,this.length),this[t]},u.prototype.readUint16LE=u.prototype.readUInt16LE=function(t,e){return t>>>=0,e||C(t,2,this.length),this[t]|this[t+1]<<8},u.prototype.readUint16BE=u.prototype.readUInt16BE=function(t,e){return t>>>=0,e||C(t,2,this.length),this[t]<<8|this[t+1]},u.prototype.readUint32LE=u.prototype.readUInt32LE=function(t,e){return t>>>=0,e||C(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||C(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},u.prototype.readBigUInt64LE=Z((function(t){V(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||K(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=Z((function(t){V(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||K(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||C(t,e,this.length);let n=this[t],i=1,s=0;for(;++s<e&&(i*=256);)n+=this[t+s]*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||C(t,e,this.length);let n=e,i=1,s=this[t+--n];for(;n>0&&(i*=256);)s+=this[t+--n]*i;return i*=128,s>=i&&(s-=Math.pow(2,8*e)),s},u.prototype.readInt8=function(t,e){return t>>>=0,e||C(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},u.prototype.readInt16LE=function(t,e){t>>>=0,e||C(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||C(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||C(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||C(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},u.prototype.readBigInt64LE=Z((function(t){V(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||K(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=Z((function(t){V(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||K(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||C(t,4,this.length),i.read(this,t,!0,23,4)},u.prototype.readFloatBE=function(t,e){return t>>>=0,e||C(t,4,this.length),i.read(this,t,!1,23,4)},u.prototype.readDoubleLE=function(t,e){return t>>>=0,e||C(t,8,this.length),i.read(this,t,!0,52,8)},u.prototype.readDoubleBE=function(t,e){return t>>>=0,e||C(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||_(this,t,e,r,Math.pow(2,8*r)-1,0);let i=1,s=0;for(this[e]=255&t;++s<r&&(i*=256);)this[e+s]=t/i&255;return e+r},u.prototype.writeUintBE=u.prototype.writeUIntBE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||_(this,t,e,r,Math.pow(2,8*r)-1,0);let i=r-1,s=1;for(this[e+i]=255&t;--i>=0&&(s*=256);)this[e+i]=t/s&255;return e+r},u.prototype.writeUint8=u.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||_(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||_(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||_(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||_(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||_(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=Z((function(t,e=0){return R(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),u.prototype.writeBigUInt64BE=Z((function(t,e=0){return U(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);_(this,t,e,r,n-1,-n)}let i=0,s=1,o=0;for(this[e]=255&t;++i<r&&(s*=256);)t<0&&0===o&&0!==this[e+i-1]&&(o=1),this[e+i]=(t/s|0)-o&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);_(this,t,e,r,n-1,-n)}let i=r-1,s=1,o=0;for(this[e+i]=255&t;--i>=0&&(s*=256);)t<0&&0===o&&0!==this[e+i+1]&&(o=1),this[e+i]=(t/s|0)-o&255;return e+r},u.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||_(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||_(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||_(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||_(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||_(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=Z((function(t,e=0){return R(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),u.prototype.writeBigInt64BE=Z((function(t,e=0){return U(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),u.prototype.writeFloatLE=function(t,e,r){return F(this,t,e,!0,r)},u.prototype.writeFloatBE=function(t,e,r){return F(this,t,e,!1,r)},u.prototype.writeDoubleLE=function(t,e,r){return D(this,t,e,!0,r)},u.prototype.writeDoubleBE=function(t,e,r){return D(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 s=u.isBuffer(t)?t:u.from(t,n),o=s.length;if(0===o)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(i=0;i<r-e;++i)this[i+e]=s[i%o]}return this};const H={};function M(t,e,r){H[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 G(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 j(t,e,r,n,i,s){if(t>r||t<e){const n="bigint"==typeof e?"n":"";let i;throw i=s>3?0===e||e===BigInt(0)?`>= 0${n} and < 2${n} ** ${8*(s+1)}${n}`:`>= -(2${n} ** ${8*(s+1)-1}${n}) and < 2 ** ${8*(s+1)-1}${n}`:`>= ${e}${n} and <= ${r}${n}`,new H.ERR_OUT_OF_RANGE("value",i,t)}!function(t,e,r){V(e,"offset"),void 0!==t[e]&&void 0!==t[e+r]||K(e,t.length-(r+1))}(n,i,s)}function V(t,e){if("number"!=typeof t)throw new H.ERR_INVALID_ARG_TYPE(e,"number",t)}function K(t,e,r){if(Math.floor(t)!==t)throw V(t,r),new H.ERR_OUT_OF_RANGE(r||"offset","an integer",t);if(e<0)throw new H.ERR_BUFFER_OUT_OF_BOUNDS;throw new H.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}M("ERR_BUFFER_OUT_OF_BOUNDS",(function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"}),RangeError),M("ERR_INVALID_ARG_TYPE",(function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`}),TypeError),M("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=G(String(r)):"bigint"==typeof r&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=G(i)),i+="n"),n+=` It must be ${e}. Received ${i}`,n}),RangeError);const Q=/[^+/0-9A-Za-z-_]/g;function W(t,e){let r;e=e||1/0;const n=t.length;let i=null;const s=[];for(let o=0;o<n;++o){if(r=t.charCodeAt(o),r>55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&s.push(239,191,189);continue}if(o+1===n){(e-=3)>-1&&s.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&s.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(e-=3)>-1&&s.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;s.push(r)}else if(r<2048){if((e-=2)<0)break;s.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;s.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;s.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return s}function z(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(Q,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function J(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 q(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function X(t){return t!=t}const Y=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 Z(t){return"undefined"==typeof BigInt?$:t}function $(){throw new Error("BigInt not supported")}},251:(t,e)=>{e.read=function(t,e,r,n,i){var s,o,a=8*i-n-1,u=(1<<a)-1,c=u>>1,l=-7,f=r?i-1:0,h=r?-1:1,p=t[e+f];for(f+=h,s=p&(1<<-l)-1,p>>=-l,l+=a;l>0;s=256*s+t[e+f],f+=h,l-=8);for(o=s&(1<<-l)-1,s>>=-l,l+=n;l>0;o=256*o+t[e+f],f+=h,l-=8);if(0===s)s=1-c;else{if(s===u)return o?NaN:1/0*(p?-1:1);o+=Math.pow(2,n),s-=c}return(p?-1:1)*o*Math.pow(2,s-n)},e.write=function(t,e,r,n,i,s){var o,a,u,c=8*s-i-1,l=(1<<c)-1,f=l>>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:s-1,d=n?1:-1,g=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,o=l):(o=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-o))<1&&(o--,u*=2),(e+=o+f>=1?h/u:h*Math.pow(2,1-f))*u>=2&&(o++,u/=2),o+f>=l?(a=0,o=l):o+f>=1?(a=(e*u-1)*Math.pow(2,i),o+=f):(a=e*Math.pow(2,f-1)*Math.pow(2,i),o=0));i>=8;t[r+p]=255&a,p+=d,a/=256,i-=8);for(o=o<<i|a,c+=i;c>0;t[r+p]=255&o,p+=d,o/=256,c-=8);t[r+p-d]|=128*g}},2861:(t,e,r)=>{var n=r(8287),i=n.Buffer;function s(t,e){for(var r in t)e[r]=t[r]}function o(t,e,r){return i(t,e,r)}i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?t.exports=n:(s(n,e),e.Buffer=o),s(i,o),o.from=function(t,e,r){if("number"==typeof t)throw new TypeError("Argument must not be a number");return i(t,e,r)},o.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},o.allocUnsafe=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return i(t)},o.allocUnsafeSlow=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return n.SlowBuffer(t)}},1061:(t,e,r)=>{var n=r(2113);function i(t){return t.name||t.toString().match(/function (.*?)\s*\(/)[1]}function s(t){return n.Nil(t)?"":i(t.constructor)}function o(t,e){Error.captureStackTrace&&Error.captureStackTrace(t,e)}function a(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 "+a(t)+", got"+(""!==r?" "+r:"")+(""!==i?" "+i:"")}function c(t,e,r){r=r||s(e),this.message=u(t,e,r),o(this,c),this.__type=t,this.__value=e,this.__valueTypeName=r}function l(t,e,r,n,i){t?(i=i||s(n),this.message=function(t,e,r,n,i){var s='" of type ';return"key"===e&&(s='" with key type '),u('property "'+a(r)+s+a(t),n,i)}(t,r,e,n,i)):this.message='Unexpected property "'+e+'"',o(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,l.prototype=Object.create(Error.prototype),l.prototype.constructor=c,t.exports={TfTypeError:c,TfPropertyTypeError:l,tfCustomError:function(t,e){return new c(t,{},e)},tfSubError:function(t,e,r){return t instanceof l?(e=e+"."+t.__property,t=new l(t.__type,e,t.__label,t.__value,t.__valueTypeName)):t instanceof c&&(t=new l(t.__type,e,r,t.__value,t.__valueTypeName)),o(t),t},tfJSON:a,getValueTypeName:s}},9542:(t,e,r)=>{var n=r(8287).Buffer,i=r(2113),s=r(1061);function o(t){return n.isBuffer(t)}function a(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 s.tfCustomError(r+"(Length: "+e+")",r+"(Length: "+n.length+")")}return n.toJSON=function(){return r},n}var c=u.bind(null,i.Array),l=u.bind(null,o),f=u.bind(null,a),h=u.bind(null,i.String),p=Math.pow(2,53)-1,d={ArrayN:c,Buffer:o,BufferN:l,Finite:function(t){return"number"==typeof t&&isFinite(t)},Hex:a,HexN:f,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 g in d)d[g].toJSON=function(t){return t}.bind(null,g);t.exports=d},8676:(t,e,r)=>{var n=r(1061),i=r(2113),s=n.tfJSON,o=n.TfTypeError,a=n.TfPropertyTypeError,u=n.tfSubError,c=n.getValueTypeName,l={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=f(t),e=e||{},r.toJSON=function(){var r="["+s(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=f(e),r.toJSON=function(){return"?"+s(e)},r},map:function(t,e){function r(r,n){if(!i.Object(r))return!1;if(i.Nil(r))return!1;for(var s in r){try{e&&h(e,s,n)}catch(t){throw u(t,s,"key")}try{var o=r[s];h(t,o,n)}catch(t){throw u(t,s)}}return!0}return t=f(t),e&&(e=f(e)),r.toJSON=e?function(){return"{"+s(e)+": "+s(t)+"}"}:function(){return"{"+s(t)+"}"},r},object:function(t){var e={};for(var r in t)e[r]=f(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 a(void 0,n);return!0}return n.toJSON=function(){return s(e)},n},anyOf:function(){var t=[].slice.call(arguments).map(f);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(s).join("|")},e},allOf:function(){var t=[].slice.call(arguments).map(f);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(s).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(f);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(s).join(", ")+")"},e},value:function(t){function e(e){return e===t}return e.toJSON=function(){return t},e}};function f(t){if(i.String(t))return"?"===t[0]?l.maybe(t.slice(1)):i[t]||l.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 l.arrayOf(t[0])}return l.object(t)}return i.Function(t)?t:l.value(t)}function h(t,e,r,n){if(i.Function(t)){if(t(e,r))return!0;throw new o(n||t,e)}return h(f(t),e,r)}for(var p in l.oneOf=l.anyOf,i)h[p]=i[p];for(p in l)h[p]=l[p];var d=r(9542);for(p in d)h[p]=d[p];h.compile=f,h.TfTypeError=o,h.TfPropertyTypeError=a,t.exports=h},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},8469:(t,e,r)=>{var n=r(2861).Buffer,i=9007199254740991;function s(t){if(t<0||t>i||t%1!=0)throw new RangeError("value out of range")}function o(t){return s(t),t<253?1:t<=65535?3:t<=4294967295?5:9}t.exports={encode:function t(e,r,i){if(s(e),r||(r=n.allocUnsafe(o(e))),!n.isBuffer(r))throw new TypeError("buffer must be a Buffer instance");return i||(i=0),e<253?(r.writeUInt8(e,i),t.bytes=1):e<=65535?(r.writeUInt8(253,i),r.writeUInt16LE(e,i+1),t.bytes=3):e<=4294967295?(r.writeUInt8(254,i),r.writeUInt32LE(e,i+1),t.bytes=5):(r.writeUInt8(255,i),r.writeUInt32LE(e>>>0,i+1),r.writeUInt32LE(e/4294967296|0,i+5),t.bytes=9),r},decode:function t(e,r){if(!n.isBuffer(e))throw new TypeError("buffer must be a Buffer instance");r||(r=0);var i=e.readUInt8(r);if(i<253)return t.bytes=1,i;if(253===i)return t.bytes=3,e.readUInt16LE(r+1);if(254===i)return t.bytes=5,e.readUInt32LE(r+1);t.bytes=9;var o=e.readUInt32LE(r+1),a=4294967296*e.readUInt32LE(r+5)+o;return s(a),a},encodingLength:o}}},e={};function r(n){var i=e[n];if(void 0!==i)return i.exports;var s=e[n]={exports:{}};return t[n](s,s.exports,r),s.exports}r.d=(t,e)=>{for(var n in e)r.o(e,n)&&!r.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var n={};(()=>{r.d(n,{eB:()=>Mc,qT:()=>B,Yy:()=>U,Bc:()=>K,r:()=>Jc,W4:()=>t,OB:()=>S,PN:()=>c,Mw:()=>y,Ay:()=>qc});var t,e={};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 s(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,u(n.key),n)}}function o(t,e,r){return e&&s(t.prototype,e),r&&s(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function a(t,e,r){return(e=u(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function u(t){var e=function(t,e){if("object"!=i(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=i(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==i(e)?e:e+""}r.r(e),r.d(e,{OG:()=>aa,My:()=>Zo,bytesToNumberBE:()=>ea,lX:()=>ra,Id:()=>oa,fg:()=>la,qj:()=>sa,hexToBytes:()=>ta,lq:()=>na,z:()=>ia,Q5:()=>ha}),function(t){t.Generic="Generic",t.Deployment="Deployment",t.Interaction="Interaction"}(t||(t={}));var c=o((function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),a(this,"originalTransactionId",void 0),a(this,"outputTransactionIndex",void 0),a(this,"scriptSignature",void 0),a(this,"sequenceId",void 0),a(this,"transactionInWitness",[]),this.originalTransactionId=e.originalTransactionId,this.outputTransactionIndex=e.outputTransactionIndex,this.scriptSignature=e.scriptSignature,this.sequenceId=e.sequenceId,this.transactionInWitness=e.transactionInWitness||[]})),l=r(1757),f=r(8287).Buffer;function h(t){return h="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},h(t)}function p(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,g(n.key),n)}}function d(t,e,r){return(e=g(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function g(t){var e=function(t,e){if("object"!=h(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=h(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==h(e)?e:e+""}var y=function(){return t=function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),d(this,"value",void 0),d(this,"index",void 0),d(this,"scriptPubKey",void 0),d(this,"script",void 0),this.value=this.convertValue(e.value),this.index=e.index,this.scriptPubKey=e.scriptPubKey,this.script=l.K$.decompile(f.from(this.scriptPubKey.hex,"hex"))},(e=[{key:"convertValue",value:function(t){return BigInt(t)}}])&&p(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}(),w=r(8287).Buffer;function m(t){return m="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},m(t)}function b(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 A(t,e,r){return e&&b(t.prototype,e),r&&b(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function E(t,e,r){return(e=v(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function v(t){var e=function(t,e){if("object"!=m(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=m(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==m(e)?e:e+""}var S=A((function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),E(this,"id",void 0),E(this,"hash",void 0),E(this,"index",void 0),E(this,"burnedBitcoin",void 0),E(this,"revert",void 0),E(this,"inputs",void 0),E(this,"outputs",void 0),E(this,"OPNetType",void 0),this.id=e.id,this.hash=e.hash,this.index=e.index,this.burnedBitcoin=e.burnedBitcoin,this.inputs=e.inputs.map((function(t){return new c(t)})),this.outputs=e.outputs.map((function(t){return new y(t)})),this.revert=e.revert?w.from(e.revert,"base64"):void 0,this.OPNetType=e.OPNetType}));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 k(t,e,r){return e=P(e),function(t,e){if(e&&("object"===I(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,T()?Reflect.construct(e,r||[],P(t).constructor):e.apply(t,r))}function T(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(T=function(){return!!t})()}function P(t){return P=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},P(t)}function O(t,e){return O=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},O(t,e)}var B=function(t){function e(t){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),k(this,e,[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&&O(t,e)}(e,t),r=e,Object.defineProperty(r,"prototype",{writable:!1}),r;var r}(S);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 x(t,e,r){return e=_(e),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)}(t,C()?Reflect.construct(e,r||[],_(t).constructor):e.apply(t,r))}function C(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(C=function(){return!!t})()}function _(t){return _=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},_(t)}function R(t,e){return R=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},R(t,e)}var U=function(t){function e(t){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),x(this,e,[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&&R(t,e)}(e,t),r=e,Object.defineProperty(r,"prototype",{writable:!1}),r;var r}(S),L=r(8287);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 D(t,e,r){return e=M(e),function(t,e){if(e&&("object"===F(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,H()?Reflect.construct(e,r||[],M(t).constructor):e.apply(t,r))}function H(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(H=function(){return!!t})()}function M(t){return M=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},M(t)}function G(t,e){return G=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},G(t,e)}function j(t,e,r){return(e=V(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function V(t){var e=function(t,e){if("object"!=F(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=F(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==F(e)?e:e+""}var K=function(t){function e(t){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),j(r=D(this,e,[t]),"calldata",void 0),j(r,"senderPubKeyHash",void 0),j(r,"contractSecret",void 0),j(r,"interactionPubKey",void 0),j(r,"wasCompressed",void 0),j(r,"events",void 0),j(r,"receipt",void 0),j(r,"receiptProofs",void 0),r.calldata=L.Buffer.from(t.calldata,"base64"),r.senderPubKeyHash=L.Buffer.from(t.senderPubKeyHash,"base64"),r.contractSecret=L.Buffer.from(t.contractSecret,"base64"),r.interactionPubKey=L.Buffer.from(t.interactionPubKey,"base64"),r.wasCompressed=t.wasCompressed,r.events=t.events,r.receipt=t.receipt?L.Buffer.from(t.receipt,"base64"):void 0,r.receiptProofs=t.receiptProofs,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&&G(t,e)}(e,t),r=e,Object.defineProperty(r,"prototype",{writable:!1}),r;var r}(S);const Q="6.12.1";function W(t,e,r){const n=e.split("|").map((t=>t.trim()));for(let r=0;r<n.length;r++)switch(e){case"any":return;case"bigint":case"boolean":case"number":case"string":if(typeof t===e)return}const i=new Error(`invalid value for type ${e}`);throw i.code="INVALID_ARGUMENT",i.argument=`value.${r}`,i.value=t,i}async function z(t){const e=Object.keys(t);return(await Promise.all(e.map((e=>Promise.resolve(t[e]))))).reduce(((t,r,n)=>(t[e[n]]=r,t)),{})}function J(t,e,r){for(let n in e){let i=e[n];const s=r?r[n]:null;s&&W(i,s,n),Object.defineProperty(t,n,{enumerable:!0,value:i,writable:!1})}}function q(t){if(null==t)return"null";if(Array.isArray(t))return"[ "+t.map(q).join(", ")+" ]";if(t instanceof Uint8Array){const e="0123456789abcdef";let r="0x";for(let n=0;n<t.length;n++)r+=e[t[n]>>4],r+=e[15&t[n]];return r}if("object"==typeof t&&"function"==typeof t.toJSON)return q(t.toJSON());switch(typeof t){case"boolean":case"symbol":case"number":return t.toString();case"bigint":return BigInt(t).toString();case"string":return JSON.stringify(t);case"object":{const e=Object.keys(t);return e.sort(),"{ "+e.map((e=>`${q(e)}: ${q(t[e])}`)).join(", ")+" }"}}return"[ COULD NOT SERIALIZE ]"}function X(t,e){return t&&t.code===e}function Y(t){return X(t,"CALL_EXCEPTION")}function Z(t,e,r){let n,i=t;{const n=[];if(r){if("message"in r||"code"in r||"name"in r)throw new Error(`value will overwrite populated values: ${q(r)}`);for(const t in r){if("shortMessage"===t)continue;const e=r[t];n.push(t+"="+q(e))}}n.push(`code=${e}`),n.push(`version=${Q}`),n.length&&(t+=" ("+n.join(", ")+")")}switch(e){case"INVALID_ARGUMENT":n=new TypeError(t);break;case"NUMERIC_FAULT":case"BUFFER_OVERRUN":n=new RangeError(t);break;default:n=new Error(t)}return J(n,{code:e}),r&&Object.assign(n,r),null==n.shortMessage&&J(n,{shortMessage:i}),n}function $(t,e,r,n){if(!t)throw Z(e,r,n)}function tt(t,e,r,n){$(t,e,"INVALID_ARGUMENT",{argument:r,value:n})}function et(t,e,r){null==r&&(r=""),r&&(r=": "+r),$(t>=e,"missing arguemnt"+r,"MISSING_ARGUMENT",{count:t,expectedCount:e}),$(t<=e,"too many arguments"+r,"UNEXPECTED_ARGUMENT",{count:t,expectedCount:e})}const rt=["NFD","NFC","NFKD","NFKC"].reduce(((t,e)=>{try{if("test"!=="test".normalize(e))throw new Error("bad");if("NFD"===e){if(String.fromCharCode(233).normalize("NFD")!==String.fromCharCode(101,769))throw new Error("broken")}t.push(e)}catch(t){}return t}),[]);function nt(t,e,r){if(null==r&&(r=""),t!==e){let t=r,e="new";r&&(t+=".",e+=" "+r),$(!1,`private constructor; use ${t}from* methods`,"UNSUPPORTED_OPERATION",{operation:e})}}function it(t,e,r){if(t instanceof Uint8Array)return r?new Uint8Array(t):t;if("string"==typeof t&&t.match(/^0x([0-9a-f][0-9a-f])*$/i)){const e=new Uint8Array((t.length-2)/2);let r=2;for(let n=0;n<e.length;n++)e[n]=parseInt(t.substring(r,r+2),16),r+=2;return e}tt(!1,"invalid BytesLike value",e||"value",t)}function st(t,e){return it(t,e,!1)}function ot(t,e){return it(t,e,!0)}function at(t,e){return!("string"!=typeof t||!t.match(/^0x[0-9A-Fa-f]*$/)||"number"==typeof e&&t.length!==2+2*e||!0===e&&t.length%2!=0)}function ut(t){return at(t,!0)||t instanceof Uint8Array}const ct="0123456789abcdef";function lt(t){const e=st(t);let r="0x";for(let t=0;t<e.length;t++){const n=e[t];r+=ct[(240&n)>>4]+ct[15&n]}return r}function ft(t){return"0x"+t.map((t=>lt(t).substring(2))).join("")}function ht(t){return at(t,!0)?(t.length-2)/2:st(t).length}function pt(t,e,r){const n=st(t);return null!=r&&r>n.length&&$(!1,"cannot slice beyond data bounds","BUFFER_OVERRUN",{buffer:n,length:n.length,offset:r}),lt(n.slice(null==e?0:e,null==r?n.length:r))}function dt(t,e,r){const n=st(t);$(e>=n.length,"padding exceeds data length","BUFFER_OVERRUN",{buffer:new Uint8Array(n),length:e,offset:e+1});const i=new Uint8Array(e);return i.fill(0),r?i.set(n,e-n.length):i.set(n,0),lt(i)}function gt(t,e){return dt(t,e,!0)}const yt=BigInt(0),wt=BigInt(1),mt=9007199254740991;function bt(t,e){let r=Et(t,"value");const n=BigInt(kt(e,"width")),i=wt<<n-wt;return r<yt?(r=-r,$(r<=i,"too low","NUMERIC_FAULT",{operation:"toTwos",fault:"overflow",value:t}),(~r&(wt<<n)-wt)+wt):($(r<i,"too high","NUMERIC_FAULT",{operation:"toTwos",fault:"overflow",value:t}),r)}function At(t,e){const r=vt(t,"value"),n=BigInt(kt(e,"bits"));return r&(wt<<n)-wt}function Et(t,e){switch(typeof t){case"bigint":return t;case"number":return tt(Number.isInteger(t),"underflow",e||"value",t),tt(t>=-mt&&t<=mt,"overflow",e||"value",t),BigInt(t);case"string":try{if(""===t)throw new Error("empty string");return"-"===t[0]&&"-"!==t[1]?-BigInt(t.substring(1)):BigInt(t)}catch(r){tt(!1,`invalid BigNumberish string: ${r.message}`,e||"value",t)}}tt(!1,"invalid BigNumberish value",e||"value",t)}function vt(t,e){const r=Et(t,e);return $(r>=yt,"unsigned value cannot be negative","NUMERIC_FAULT",{fault:"overflow",operation:"getUint",value:t}),r}const St="0123456789abcdef";function It(t){if(t instanceof Uint8Array){let e="0x0";for(const r of t)e+=St[r>>4],e+=St[15&r];return BigInt(e)}return Et(t)}function kt(t,e){switch(typeof t){case"bigint":return tt(t>=-mt&&t<=mt,"overflow",e||"value",t),Number(t);case"number":return tt(Number.isInteger(t),"underflow",e||"value",t),tt(t>=-mt&&t<=mt,"overflow",e||"value",t),t;case"string":try{if(""===t)throw new Error("empty string");return kt(BigInt(t),e)}catch(r){tt(!1,`invalid numeric string: ${r.message}`,e||"value",t)}}tt(!1,"invalid numeric value",e||"value",t)}function Tt(t,e){let r=vt(t,"value").toString(16);if(null==e)r.length%2&&(r="0"+r);else{const n=kt(e,"width");for($(2*n>=r.length,`value exceeds width (${n} bytes)`,"NUMERIC_FAULT",{operation:"toBeHex",fault:"overflow",value:t});r.length<2*n;)r="0"+r}return"0x"+r}function Pt(t){const e=vt(t,"value");if(e===yt)return new Uint8Array([]);let r=e.toString(16);r.length%2&&(r="0"+r);const n=new Uint8Array(r.length/2);for(let t=0;t<n.length;t++){const e=2*t;n[t]=parseInt(r.substring(e,e+2),16)}return n}function Ot(t){let e=lt(ut(t)?t:Pt(t)).substring(2);for(;e.startsWith("0");)e=e.substring(1);return""===e&&(e="0"),"0x"+e}const Bt=32,Nt=new Uint8Array(Bt),xt=["then"],Ct={};function _t(t,e){const r=new Error(`deferred error during ABI decoding triggered accessing ${t}`);throw r.error=e,r}class Rt extends Array{#t;constructor(...t){const e=t[0];let r=t[1],n=(t[2]||[]).slice(),i=!0;e!==Ct&&(r=t,n=[],i=!1),super(r.length),r.forEach(((t,e)=>{this[e]=t}));const s=n.reduce(((t,e)=>("string"==typeof e&&t.set(e,(t.get(e)||0)+1),t)),new Map);if(this.#t=Object.freeze(r.map(((t,e)=>{const r=n[e];return null!=r&&1===s.get(r)?r:null}))),i)return Object.freeze(this),new Proxy(this,{get:(t,e,r)=>{if("string"==typeof e){if(e.match(/^[0-9]+$/)){const r=kt(e,"%index");if(r<0||r>=this.length)throw new RangeError("out of result range");const n=t[r];return n instanceof Error&&_t(`index ${r}`,n),n}if(xt.indexOf(e)>=0)return Reflect.get(t,e,r);const n=t[e];if(n instanceof Function)return function(...e){return n.apply(this===r?t:this,e)};if(!(e in t))return t.getValue.apply(this===r?t:this,[e])}return Reflect.get(t,e,r)}})}toArray(t){const e=[];return this.forEach(((r,n)=>{r instanceof Error&&_t(`index ${n}`,r),t&&r instanceof Rt&&(r=r.toArray(t)),e.push(r)})),e}toObject(t){return this.#t.reduce(((e,r,n)=>{if($(null!=r,"value at index ${ index } unnamed","UNSUPPORTED_OPERATION",{operation:"toObject()"}),!(r in e)){let n=this.getValue(r);t&&n instanceof Rt&&(n=n.toObject(t)),e[r]=n}return e}),{})}slice(t,e){null==t&&(t=0),t<0&&(t+=this.length)<0&&(t=0),null==e&&(e=this.length),e<0&&(e+=this.length)<0&&(e=0),e>this.length&&(e=this.length);const r=[],n=[];for(let i=t;i<e;i++)r.push(this[i]),n.push(this.#t[i]);return new Rt(Ct,r,n)}filter(t,e){const r=[],n=[];for(let i=0;i<this.length;i++){const s=this[i];s instanceof Error&&_t(`index ${i}`,s),t.call(e,s,i,this)&&(r.push(s),n.push(this.#t[i]))}return new Rt(Ct,r,n)}map(t,e){const r=[];for(let n=0;n<this.length;n++){const i=this[n];i instanceof Error&&_t(`index ${n}`,i),r.push(t.call(e,i,n,this))}return r}getValue(t){const e=this.#t.indexOf(t);if(-1===e)return;const r=this[e];return r instanceof Error&&_t(`property ${JSON.stringify(t)}`,r.error),r}static fromItems(t,e){return new Rt(Ct,t,e)}}function Ut(t){let e=Pt(t);return $(e.length<=Bt,"value out-of-bounds","BUFFER_OVERRUN",{buffer:e,length:Bt,offset:e.length}),e.length!==Bt&&(e=ot(ft([Nt.slice(e.length%Bt),e]))),e}class Lt{name;type;localName;dynamic;constructor(t,e,r,n){J(this,{name:t,type:e,localName:r,dynamic:n},{name:"string",type:"string",localName:"string",dynamic:"boolean"})}_throwError(t,e){tt(!1,t,this.localName,e)}}class Ft{#e;#r;constructor(){this.#e=[],this.#r=0}get data(){return ft(this.#e)}get length(){return this.#r}#n(t){return this.#e.push(t),this.#r+=t.length,t.length}appendWriter(t){return this.#n(ot(t.data))}writeBytes(t){let e=ot(t);const r=e.length%Bt;return r&&(e=ot(ft([e,Nt.slice(r)]))),this.#n(e)}writeValue(t){return this.#n(Ut(t))}writeUpdatableValue(){const t=this.#e.length;return this.#e.push(Nt),this.#r+=Bt,e=>{this.#e[t]=Ut(e)}}}class Dt{allowLoose;#e;#i;#s;#o;#a;constructor(t,e,r){J(this,{allowLoose:!!e}),this.#e=ot(t),this.#s=0,this.#o=null,this.#a=null!=r?r:1024,this.#i=0}get data(){return lt(this.#e)}get dataLength(){return this.#e.length}get consumed(){return this.#i}get bytes(){return new Uint8Array(this.#e)}#u(t){if(this.#o)return this.#o.#u(t);this.#s+=t,$(this.#a<1||this.#s<=this.#a*this.dataLength,`compressed ABI data exceeds inflation ratio of ${this.#a} ( see: https://github.com/ethers-io/ethers.js/issues/4537 )`,"BUFFER_OVERRUN",{buffer:ot(this.#e),offset:this.#i,length:t,info:{bytesRead:this.#s,dataLength:this.dataLength}})}#c(t,e,r){let n=Math.ceil(e/Bt)*Bt;return this.#i+n>this.#e.length&&(this.allowLoose&&r&&this.#i+e<=this.#e.length?n=e:$(!1,"data out-of-bounds","BUFFER_OVERRUN",{buffer:ot(this.#e),length:this.#e.length,offset:this.#i+n})),this.#e.slice(this.#i,this.#i+n)}subReader(t){const e=new Dt(this.#e.slice(this.#i+t),this.allowLoose,this.#a);return e.#o=this,e}readBytes(t,e){let r=this.#c(0,t,!!e);return this.#u(t),this.#i+=r.length,r.slice(0,t)}readValue(){return It(this.readBytes(Bt))}readIndex(){return kt(It(this.readBytes(Bt)))}}function Ht(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`Wrong positive integer: ${t}`)}function Mt(t,...e){if(!(t instanceof Uint8Array))throw new Error("Expected Uint8Array");if(e.length>0&&!e.includes(t.length))throw new Error(`Expected Uint8Array of length ${e}, not of length=${t.length}`)}function Gt(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 jt(t,e){Mt(t);const r=e.outputLen;if(t.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}const Vt=BigInt(2**32-1),Kt=BigInt(32);function Qt(t,e=!1){return e?{h:Number(t&Vt),l:Number(t>>Kt&Vt)}:{h:0|Number(t>>Kt&Vt),l:0|Number(t&Vt)}}function Wt(t,e=!1){let r=new Uint32Array(t.length),n=new Uint32Array(t.length);for(let i=0;i<t.length;i++){const{h:s,l:o}=Qt(t[i],e);[r[i],n[i]]=[s,o]}return[r,n]}const zt=(t,e,r)=>t<<r|e>>>32-r,Jt=(t,e,r)=>e<<r|t>>>32-r,qt=(t,e,r)=>e<<r-32|t>>>64-r,Xt=(t,e,r)=>t<<r-32|e>>>64-r,Yt={fromBig:Qt,split:Wt,toBig:(t,e)=>BigInt(t>>>0)<<Kt|BigInt(e>>>0),shrSH:(t,e,r)=>t>>>r,shrSL:(t,e,r)=>t<<32-r|e>>>r,rotrSH:(t,e,r)=>t>>>r|e<<32-r,rotrSL:(t,e,r)=>t<<32-r|e>>>r,rotrBH:(t,e,r)=>t<<64-r|e>>>r-32,rotrBL:(t,e,r)=>t>>>r-32|e<<64-r,rotr32H:(t,e)=>e,rotr32L:(t,e)=>t,rotlSH:zt,rotlSL:Jt,rotlBH:qt,rotlBL:Xt,add:function(t,e,r,n){const i=(e>>>0)+(n>>>0);return{h:t+r+(i/2**32|0)|0,l:0|i}},add3L:(t,e,r)=>(t>>>0)+(e>>>0)+(r>>>0),add3H:(t,e,r,n)=>e+r+n+(t/2**32|0)|0,add4L:(t,e,r,n)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0),add4H:(t,e,r,n,i)=>e+r+n+i+(t/2**32|0)|0,add5H:(t,e,r,n,i,s)=>e+r+n+i+s+(t/2**32|0)|0,add5L:(t,e,r,n,i)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0)+(i>>>0)},Zt=t=>t instanceof Uint8Array,$t=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),te=(t,e)=>t<<32-e|t>>>e;if(68!==new Uint8Array(new Uint32Array([287454020]).buffer)[0])throw new Error("Non little-endian hardware is not supported");function ee(t){if("string"==typeof t&&(t=function(t){if("string"!=typeof t)throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array((new TextEncoder).encode(t))}(t)),!Zt(t))throw new Error("expected Uint8Array, got "+typeof t);return t}class re{clone(){return this._cloneInto()}}function ne(t){const e=e=>t().update(ee(e)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}const[ie,se,oe]=[[],[],[]],ae=BigInt(0),ue=BigInt(1),ce=BigInt(2),le=BigInt(7),fe=BigInt(256),he=BigInt(113);for(let t=0,e=ue,r=1,n=0;t<24;t++){[r,n]=[n,(2*r+3*n)%5],ie.push(2*(5*n+r)),se.push((t+1)*(t+2)/2%64);let i=ae;for(let t=0;t<7;t++)e=(e<<ue^(e>>le)*he)%fe,e&ce&&(i^=ue<<(ue<<BigInt(t))-ue);oe.push(i)}const[pe,de]=Wt(oe,!0),ge=(t,e,r)=>r>32?qt(t,e,r):zt(t,e,r),ye=(t,e,r)=>r>32?Xt(t,e,r):Jt(t,e,r);class we extends re{constructor(t,e,r,n=!1,i=24){if(super(),this.blockLen=t,this.suffix=e,this.outputLen=r,this.enableXOF=n,this.rounds=i,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,Ht(r),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");var s;this.state=new Uint8Array(200),this.state32=(s=this.state,new Uint32Array(s.buffer,s.byteOffset,Math.floor(s.byteLength/4)))}keccak(){!function(t,e=24){const r=new Uint32Array(10);for(let n=24-e;n<24;n++){for(let e=0;e<10;e++)r[e]=t[e]^t[e+10]^t[e+20]^t[e+30]^t[e+40];for(let e=0;e<10;e+=2){const n=(e+8)%10,i=(e+2)%10,s=r[i],o=r[i+1],a=ge(s,o,1)^r[n],u=ye(s,o,1)^r[n+1];for(let r=0;r<50;r+=10)t[e+r]^=a,t[e+r+1]^=u}let e=t[2],i=t[3];for(let r=0;r<24;r++){const n=se[r],s=ge(e,i,n),o=ye(e,i,n),a=ie[r];e=t[a],i=t[a+1],t[a]=s,t[a+1]=o}for(let e=0;e<50;e+=10){for(let n=0;n<10;n++)r[n]=t[e+n];for(let n=0;n<10;n++)t[e+n]^=~r[(n+2)%10]&r[(n+4)%10]}t[0]^=pe[n],t[1]^=de[n]}r.fill(0)}(this.state32,this.rounds),this.posOut=0,this.pos=0}update(t){Gt(this);const{blockLen:e,state:r}=this,n=(t=ee(t)).length;for(let i=0;i<n;){const s=Math.min(e-this.pos,n-i);for(let e=0;e<s;e++)r[this.pos++]^=t[i++];this.pos===e&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:t,suffix:e,pos:r,blockLen:n}=this;t[r]^=e,128&e&&r===n-1&&this.keccak(),t[n-1]^=128,this.keccak()}writeInto(t){Gt(this,!1),Mt(t),this.finish();const e=this.state,{blockLen:r}=this;for(let n=0,i=t.length;n<i;){this.posOut>=r&&this.keccak();const s=Math.min(r-this.posOut,i-n);t.set(e.subarray(this.posOut,this.posOut+s),n),this.posOut+=s,n+=s}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return Ht(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(jt(t,this),this.finished)throw new Error("digest() was already called");return this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(t){const{blockLen:e,suffix:r,outputLen:n,rounds:i,enableXOF:s}=this;return t||(t=new we(e,r,n,s,i)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=i,t.suffix=r,t.outputLen=n,t.enableXOF=s,t.destroyed=this.destroyed,t}}const me=((t,e,r)=>ne((()=>new we(e,t,r))))(1,136,32);let be=!1;const Ae=function(t){return me(t)};let Ee=Ae;function ve(t){const e=st(t,"data");return lt(Ee(e))}ve._=Ae,ve.lock=function(){be=!0},ve.register=function(t){if(be)throw new TypeError("keccak256 is locked");Ee=t},Object.freeze(ve);const Se=BigInt(0),Ie=BigInt(36);function ke(t){const e=(t=t.toLowerCase()).substring(2).split(""),r=new Uint8Array(40);for(let t=0;t<40;t++)r[t]=e[t].charCodeAt(0);const n=st(ve(r));for(let t=0;t<40;t+=2)n[t>>1]>>4>=8&&(e[t]=e[t].toUpperCase()),(15&n[t>>1])>=8&&(e[t+1]=e[t+1].toUpperCase());return"0x"+e.join("")}const Te={};for(let t=0;t<10;t++)Te[String(t)]=String(t);for(let t=0;t<26;t++)Te[String.fromCharCode(65+t)]=String(10+t);const Pe=15;const Oe=function(){const t={};for(let e=0;e<36;e++)t["0123456789abcdefghijklmnopqrstuvwxyz"[e]]=BigInt(e);return t}();function Be(t){if(tt("string"==typeof t,"invalid address","address",t),t.match(/^(0x)?[0-9a-fA-F]{40}$/)){t.startsWith("0x")||(t="0x"+t);const e=ke(t);return tt(!t.match(/([A-F].*[a-f])|([a-f].*[A-F])/)||e===t,"bad address checksum","address",t),e}if(t.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){tt(t.substring(2,4)===function(t){let e=(t=(t=t.toUpperCase()).substring(4)+t.substring(0,2)+"00").split("").map((t=>Te[t])).join("");for(;e.length>=Pe;){let t=e.substring(0,Pe);e=parseInt(t,10)%97+e.substring(t.length)}let r=String(98-parseInt(e,10)%97);for(;r.length<2;)r="0"+r;return r}(t),"bad icap checksum","address",t);let e=function(t){t=t.toLowerCase();let e=Se;for(let r=0;r<t.length;r++)e=e*Ie+Oe[t[r]];return e}(t.substring(4)).toString(16);for(;e.length<40;)e="0"+e;return ke("0x"+e)}tt(!1,"invalid address","address",t)}const Ne={};function xe(t,e){let r=!1;return e<0&&(r=!0,e*=-1),new Re(Ne,`${r?"":"u"}int${e}`,t,{signed:r,width:e})}function Ce(t,e){return new Re(Ne,`bytes${e||""}`,t,{size:e})}const _e=Symbol.for("_ethers_typed");class Re{type;value;#l;_typedSymbol;constructor(t,e,r,n){null==n&&(n=null),nt(Ne,t,"Typed"),J(this,{_typedSymbol:_e,type:e,value:r}),this.#l=n,this.format()}format(){if("array"===this.type)throw new Error("");if("dynamicArray"===this.type)throw new Error("");return"tuple"===this.type?`tuple(${this.value.map((t=>t.format())).join(",")})`:this.type}defaultValue(){return 0}minValue(){return 0}maxValue(){return 0}isBigInt(){return!!this.type.match(/^u?int[0-9]+$/)}isData(){return this.type.startsWith("bytes")}isString(){return"string"===this.type}get tupleName(){if("tuple"!==this.type)throw TypeError("not a tuple");return this.#l}get arrayLength(){if("array"!==this.type)throw TypeError("not an array");return!0===this.#l?-1:!1===this.#l?this.value.length:null}static from(t,e){return new Re(Ne,t,e)}static uint8(t){return xe(t,8)}static uint16(t){return xe(t,16)}static uint24(t){return xe(t,24)}static uint32(t){return xe(t,32)}static uint40(t){return xe(t,40)}static uint48(t){return xe(t,48)}static uint56(t){return xe(t,56)}static uint64(t){return xe(t,64)}static uint72(t){return xe(t,72)}static uint80(t){return xe(t,80)}static uint88(t){return xe(t,88)}static uint96(t){return xe(t,96)}static uint104(t){return xe(t,104)}static uint112(t){return xe(t,112)}static uint120(t){return xe(t,120)}static uint128(t){return xe(t,128)}static uint136(t){return xe(t,136)}static uint144(t){return xe(t,144)}static uint152(t){return xe(t,152)}static uint160(t){return xe(t,160)}static uint168(t){return xe(t,168)}static uint176(t){return xe(t,176)}static uint184(t){return xe(t,184)}static uint192(t){return xe(t,192)}static uint200(t){return xe(t,200)}static uint208(t){return xe(t,208)}static uint216(t){return xe(t,216)}static uint224(t){return xe(t,224)}static uint232(t){return xe(t,232)}static uint240(t){return xe(t,240)}static uint248(t){return xe(t,248)}static uint256(t){return xe(t,256)}static uint(t){return xe(t,256)}static int8(t){return xe(t,-8)}static int16(t){return xe(t,-16)}static int24(t){return xe(t,-24)}static int32(t){return xe(t,-32)}static int40(t){return xe(t,-40)}static int48(t){return xe(t,-48)}static int56(t){return xe(t,-56)}static int64(t){return xe(t,-64)}static int72(t){return xe(t,-72)}static int80(t){return xe(t,-80)}static int88(t){return xe(t,-88)}static int96(t){return xe(t,-96)}static int104(t){return xe(t,-104)}static int112(t){return xe(t,-112)}static int120(t){return xe(t,-120)}static int128(t){return xe(t,-128)}static int136(t){return xe(t,-136)}static int144(t){return xe(t,-144)}static int152(t){return xe(t,-152)}static int160(t){return xe(t,-160)}static int168(t){return xe(t,-168)}static int176(t){return xe(t,-176)}static int184(t){return xe(t,-184)}static int192(t){return xe(t,-192)}static int200(t){return xe(t,-200)}static int208(t){return xe(t,-208)}static int216(t){return xe(t,-216)}static int224(t){return xe(t,-224)}static int232(t){return xe(t,-232)}static int240(t){return xe(t,-240)}static int248(t){return xe(t,-248)}static int256(t){return xe(t,-256)}static int(t){return xe(t,-256)}static bytes1(t){return Ce(t,1)}static bytes2(t){return Ce(t,2)}static bytes3(t){return Ce(t,3)}static bytes4(t){return Ce(t,4)}static bytes5(t){return Ce(t,5)}static bytes6(t){return Ce(t,6)}static bytes7(t){return Ce(t,7)}static bytes8(t){return Ce(t,8)}static bytes9(t){return Ce(t,9)}static bytes10(t){return Ce(t,10)}static bytes11(t){return Ce(t,11)}static bytes12(t){return Ce(t,12)}static bytes13(t){return Ce(t,13)}static bytes14(t){return Ce(t,14)}static bytes15(t){return Ce(t,15)}static bytes16(t){return Ce(t,16)}static bytes17(t){return Ce(t,17)}static bytes18(t){return Ce(t,18)}static bytes19(t){return Ce(t,19)}static bytes20(t){return Ce(t,20)}static bytes21(t){return Ce(t,21)}static bytes22(t){return Ce(t,22)}static bytes23(t){return Ce(t,23)}static bytes24(t){return Ce(t,24)}static bytes25(t){return Ce(t,25)}static bytes26(t){return Ce(t,26)}static bytes27(t){return Ce(t,27)}static bytes28(t){return Ce(t,28)}static bytes29(t){return Ce(t,29)}static bytes30(t){return Ce(t,30)}static bytes31(t){return Ce(t,31)}static bytes32(t){return Ce(t,32)}static address(t){return new Re(Ne,"address",t)}static bool(t){return new Re(Ne,"bool",!!t)}static bytes(t){return new Re(Ne,"bytes",t)}static string(t){return new Re(Ne,"string",t)}static array(t,e){throw new Error("not implemented yet")}static tuple(t,e){throw new Error("not implemented yet")}static overrides(t){return new Re(Ne,"overrides",Object.assign({},t))}static isTyped(t){return t&&"object"==typeof t&&"_typedSymbol"in t&&t._typedSymbol===_e}static dereference(t,e){if(Re.isTyped(t)){if(t.type!==e)throw new Error(`invalid type: expecetd ${e}, got ${t.type}`);return t.value}return t}}class Ue extends Lt{constructor(t){super("address","address",t,!1)}defaultValue(){return"0x0000000000000000000000000000000000000000"}encode(t,e){let r=Re.dereference(e,"string");try{r=Be(r)}catch(t){return this._throwError(t.message,e)}return t.writeValue(r)}decode(t){return Be(Tt(t.readValue(),20))}}class Le extends Lt{coder;constructor(t){super(t.name,t.type,"_",t.dynamic),this.coder=t}defaultValue(){return this.coder.defaultValue()}encode(t,e){return this.coder.encode(t,e)}decode(t){return this.coder.decode(t)}}function Fe(t,e,r){let n=[];if(Array.isArray(r))n=r;else if(r&&"object"==typeof r){let t={};n=e.map((e=>{const n=e.localName;return $(n,"cannot encode object for signature with missing names","INVALID_ARGUMENT",{argument:"values",info:{coder:e},value:r}),$(!t[n],"cannot encode object for signature with duplicate names","INVALID_ARGUMENT",{argument:"values",info:{coder:e},value:r}),t[n]=!0,r[n]}))}else tt(!1,"invalid tuple value","tuple",r);tt(e.length===n.length,"types/value length mismatch","tuple",r);let i=new Ft,s=new Ft,o=[];e.forEach(((t,e)=>{let r=n[e];if(t.dynamic){let e=s.length;t.encode(s,r);let n=i.writeUpdatableValue();o.push((t=>{n(t+e)}))}else t.encode(i,r)})),o.forEach((t=>{t(i.length)}));let a=t.appendWriter(i);return a+=t.appendWriter(s),a}function De(t,e){let r=[],n=[],i=t.subReader(0);return e.forEach((e=>{let s=null;if(e.dynamic){let r=t.readIndex(),n=i.subReader(r);try{s=e.decode(n)}catch(t){if(X(t,"BUFFER_OVERRUN"))throw t;s=t,s.baseType=e.name,s.name=e.localName,s.type=e.type}}else try{s=e.decode(t)}catch(t){if(X(t,"BUFFER_OVERRUN"))throw t;s=t,s.baseType=e.name,s.name=e.localName,s.type=e.type}if(null==s)throw new Error("investigate");r.push(s),n.push(e.localName||null)})),Rt.fromItems(r,n)}class He extends Lt{coder;length;constructor(t,e,r){super("array",t.type+"["+(e>=0?e:"")+"]",r,-1===e||t.dynamic),J(this,{coder:t,length:e})}defaultValue(){const t=this.coder.defaultValue(),e=[];for(let r=0;r<this.length;r++)e.push(t);return e}encode(t,e){const r=Re.dereference(e,"array");Array.isArray(r)||this._throwError("expected array value",r);let n=this.length;-1===n&&(n=r.length,t.writeValue(r.length)),et(r.length,n,"coder array"+(this.localName?" "+this.localName:""));let i=[];for(let t=0;t<r.length;t++)i.push(this.coder);return Fe(t,i,r)}decode(t){let e=this.length;-1===e&&(e=t.readIndex(),$(e*Bt<=t.dataLength,"insufficient data length","BUFFER_OVERRUN",{buffer:t.bytes,offset:e*Bt,length:t.dataLength}));let r=[];for(let t=0;t<e;t++)r.push(new Le(this.coder));return De(t,r)}}class Me extends Lt{constructor(t){super("bool","bool",t,!1)}defaultValue(){return!1}encode(t,e){const r=Re.dereference(e,"bool");return t.writeValue(r?1:0)}decode(t){return!!t.readValue()}}class Ge extends Lt{constructor(t,e){super(t,t,e,!0)}defaultValue(){return"0x"}encode(t,e){e=ot(e);let r=t.writeValue(e.length);return r+=t.writeBytes(e),r}decode(t){return t.readBytes(t.readIndex(),!0)}}class je extends Ge{constructor(t){super("bytes",t)}decode(t){return lt(super.decode(t))}}class Ve extends Lt{size;constructor(t,e){let r="bytes"+String(t);super(r,r,e,!1),J(this,{size:t},{size:"number"})}defaultValue(){return"0x0000000000000000000000000000000000000000000000000000000000000000".substring(0,2+2*this.size)}encode(t,e){let r=ot(Re.dereference(e,this.type));return r.length!==this.size&&this._throwError("incorrect data length",e),t.writeBytes(r)}decode(t){return lt(t.readBytes(this.size))}}const Ke=new Uint8Array([]);class Qe extends Lt{constructor(t){super("null","",t,!1)}defaultValue(){return null}encode(t,e){return null!=e&&this._throwError("not null",e),t.writeBytes(Ke)}decode(t){return t.readBytes(0),null}}const We=BigInt(0),ze=BigInt(1),Je=BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");class qe extends Lt{size;signed;constructor(t,e,r){const n=(e?"int":"uint")+8*t;super(n,n,r,!1),J(this,{size:t,signed:e},{size:"number",signed:"boolean"})}defaultValue(){return 0}encode(t,e){let r=Et(Re.dereference(e,this.type)),n=At(Je,256);if(this.signed){let t=At(n,8*this.size-1);(r>t||r<-(t+ze))&&this._throwError("value out-of-bounds",e),r=bt(r,256)}else(r<We||r>At(n,8*this.size))&&this._throwError("value out-of-bounds",e);return t.writeValue(r)}decode(t){let e=At(t.readValue(),8*this.size);return this.signed&&(e=function(t,e){const r=vt(t,"value"),n=BigInt(kt(e,"width"));return $(r>>n===yt,"overflow","NUMERIC_FAULT",{operation:"fromTwos",fault:"overflow",value:t}),r>>n-wt?-((~r&(wt<<n)-wt)+wt):r}(e,8*this.size)),e}}function Xe(t,e,r,n,i){if("BAD_PREFIX"===t||"UNEXPECTED_CONTINUE"===t){let t=0;for(let n=e+1;n<r.length&&r[n]>>6==2;n++)t++;return t}return"OVERRUN"===t?r.length-e-1:0}const Ye=Object.freeze({error:function(t,e,r,n,i){tt(!1,`invalid codepoint at offset ${e}; ${t}`,"bytes",r)},ignore:Xe,replace:function(t,e,r,n,i){return"OVERLONG"===t?(tt("number"==typeof i,"invalid bad code point for replacement","badCodepoint",i),n.push(i),0):(n.push(65533),Xe(t,e,r))}});function Ze(t,e){tt("string"==typeof t,"invalid string value","str",t),null!=e&&(function(t){$(rt.indexOf(t)>=0,"platform missing String.prototype.normalize","UNSUPPORTED_OPERATION",{operation:"String.prototype.normalize",info:{form:t}})}(e),t=t.normalize(e));let r=[];for(let e=0;e<t.length;e++){const n=t.charCodeAt(e);if(n<128)r.push(n);else if(n<2048)r.push(n>>6|192),r.push(63&n|128);else if(55296==(64512&n)){e++;const i=t.charCodeAt(e);tt(e<t.length&&56320==(64512&i),"invalid surrogate pair","str",t);const s=65536+((1023&n)<<10)+(1023&i);r.push(s>>18|240),r.push(s>>12&63|128),r.push(s>>6&63|128),r.push(63&s|128)}else r.push(n>>12|224),r.push(n>>6&63|128),r.push(63&n|128)}return new Uint8Array(r)}function $e(t,e){return function(t,e){null==e&&(e=Ye.error);const r=st(t,"bytes"),n=[];let i=0;for(;i<r.length;){const t=r[i++];if(!(t>>7)){n.push(t);continue}let s=null,o=null;if(192==(224&t))s=1,o=127;else if(224==(240&t))s=2,o=2047;else{if(240!=(248&t)){i+=e(128==(192&t)?"UNEXPECTED_CONTINUE":"BAD_PREFIX",i-1,r,n);continue}s=3,o=65535}if(i-1+s>=r.length){i+=e("OVERRUN",i-1,r,n);continue}let a=t&(1<<8-s-1)-1;for(let t=0;t<s;t++){let t=r[i];if(128!=(192&t)){i+=e("MISSING_CONTINUE",i,r,n),a=null;break}a=a<<6|63&t,i++}null!==a&&(a>1114111?i+=e("OUT_OF_RANGE",i-1-s,r,n,a):a>=55296&&a<=57343?i+=e("UTF16_SURROGATE",i-1-s,r,n,a):a<=o?i+=e("OVERLONG",i-1-s,r,n,a):n.push(a))}return n}(t,e).map((t=>t<=65535?String.fromCharCode(t):(t-=65536,String.fromCharCode(55296+(t>>10&1023),56320+(1023&t))))).join("")}class tr extends Ge{constructor(t){super("string",t)}defaultValue(){return""}encode(t,e){return super.encode(t,Ze(Re.dereference(e,"string")))}decode(t){return $e(super.decode(t))}}class er extends Lt{coders;constructor(t,e){let r=!1;const n=[];t.forEach((t=>{t.dynamic&&(r=!0),n.push(t.type)})),super("tuple","tuple("+n.join(",")+")",e,r),J(this,{coders:Object.freeze(t.slice())})}defaultValue(){const t=[];this.coders.forEach((e=>{t.push(e.defaultValue())}));const e=this.coders.reduce(((t,e)=>{const r=e.localName;return r&&(t[r]||(t[r]=0),t[r]++),t}),{});return this.coders.forEach(((r,n)=>{let i=r.localName;i&&1===e[i]&&("length"===i&&(i="_length"),null==t[i]&&(t[i]=t[n]))})),Object.freeze(t)}encode(t,e){const r=Re.dereference(e,"tuple");return Fe(t,this.coders,r)}decode(t){return De(t,this.coders)}}function rr(t){return ve(Ze(t))}function nr(t){const e=new Set;return t.forEach((t=>e.add(t))),Object.freeze(e)}const ir=nr("external public payable override".split(" ")),sr="constant external internal payable private public pure view override",or=nr(sr.split(" ")),ar="constructor error event fallback function receive struct",ur=nr(ar.split(" ")),cr="calldata memory storage payable indexed",lr=nr(cr.split(" ")),fr=nr([ar,cr,"tuple returns",sr].join(" ").split(" ")),hr={"(":"OPEN_PAREN",")":"CLOSE_PAREN","[":"OPEN_BRACKET","]":"CLOSE_BRACKET",",":"COMMA","@":"AT"},pr=new RegExp("^(\\s*)"),dr=new RegExp("^([0-9]+)"),gr=new RegExp("^([a-zA-Z$_][a-zA-Z0-9$_]*)"),yr=new RegExp("^([a-zA-Z$_][a-zA-Z0-9$_]*)$"),wr=new RegExp("^(address|bool|bytes([0-9]*)|string|u?int([0-9]*))$");class mr{#i;#f;get offset(){return this.#i}get length(){return this.#f.length-this.#i}constructor(t){this.#i=0,this.#f=t.slice()}clone(){return new mr(this.#f)}reset(){this.#i=0}#h(t=0,e=0){return new mr(this.#f.slice(t,e).map((e=>Object.freeze(Object.assign({},e,{match:e.match-t,linkBack:e.linkBack-t,linkNext:e.linkNext-t})))))}popKeyword(t){const e=this.peek();if("KEYWORD"!==e.type||!t.has(e.text))throw new Error(`expected keyword ${e.text}`);return this.pop().text}popType(t){if(this.peek().type!==t){const e=this.peek();throw new Error(`expected ${t}; got ${e.type} ${JSON.stringify(e.text)}`)}return this.pop().text}popParen(){const t=this.peek();if("OPEN_PAREN"!==t.type)throw new Error("bad start");const e=this.#h(this.#i+1,t.match+1);return this.#i=t.match+1,e}popParams(){const t=this.peek();if("OPEN_PAREN"!==t.type)throw new Error("bad start");const e=[];for(;this.#i<t.match-1;){const t=this.peek().linkNext;e.push(this.#h(this.#i+1,t)),this.#i=t}return this.#i=t.match+1,e}peek(){if(this.#i>=this.#f.length)throw new Error("out-of-bounds");return this.#f[this.#i]}peekKeyword(t){const e=this.peekType("KEYWORD");return null!=e&&t.has(e)?e:null}peekType(t){if(0===this.length)return null;const e=this.peek();return e.type===t?e.text:null}pop(){const t=this.peek();return this.#i++,t}toString(){const t=[];for(let e=this.#i;e<this.#f.length;e++){const r=this.#f[e];t.push(`${r.type}:${r.text}`)}return`<TokenString ${t.join(" ")}>`}}function br(t){const e=[],r=e=>{const r=s<t.length?JSON.stringify(t[s]):"$EOI";throw new Error(`invalid token ${r} at ${s}: ${e}`)};let n=[],i=[],s=0;for(;s<t.length;){let o=t.substring(s),a=o.match(pr);a&&(s+=a[1].length,o=t.substring(s));const u={depth:n.length,linkBack:-1,linkNext:-1,match:-1,type:"",text:"",offset:s,value:-1};e.push(u);let c=hr[o[0]]||"";if(c){if(u.type=c,u.text=o[0],s++,"OPEN_PAREN"===c)n.push(e.length-1),i.push(e.length-1);else if("CLOSE_PAREN"==c)0===n.length&&r("no matching open bracket"),u.match=n.pop(),e[u.match].match=e.length-1,u.depth--,u.linkBack=i.pop(),e[u.linkBack].linkNext=e.length-1;else if("COMMA"===c)u.linkBack=i.pop(),e[u.linkBack].linkNext=e.length-1,i.push(e.length-1);else if("OPEN_BRACKET"===c)u.type="BRACKET";else if("CLOSE_BRACKET"===c){let t=e.pop().text;if(e.length>0&&"NUMBER"===e[e.length-1].type){const r=e.pop().text;t=r+t,e[e.length-1].value=kt(r)}if(0===e.length||"BRACKET"!==e[e.length-1].type)throw new Error("missing opening bracket");e[e.length-1].text+=t}}else if(a=o.match(gr),a){if(u.text=a[1],s+=u.text.length,fr.has(u.text)){u.type="KEYWORD";continue}if(u.text.match(wr)){u.type="TYPE";continue}u.type="ID"}else{if(a=o.match(dr),!a)throw new Error(`unexpected token ${JSON.stringify(o[0])} at position ${s}`);u.text=a[1],u.type="NUMBER",s+=u.text.length}}return new mr(e.map((t=>Object.freeze(t))))}function Ar(t,e){let r=[];for(const n in e.keys())t.has(n)&&r.push(n);if(r.length>1)throw new Error(`conflicting types: ${r.join(", ")}`)}function Er(t,e){if(e.peekKeyword(ur)){const r=e.pop().text;if(r!==t)throw new Error(`expected ${t}, got ${r}`)}return e.popType("ID")}function vr(t,e){const r=new Set;for(;;){const n=t.peekType("KEYWORD");if(null==n||e&&!e.has(n))break;if(t.pop(),r.has(n))throw new Error(`duplicate keywords: ${JSON.stringify(n)}`);r.add(n)}return Object.freeze(r)}function Sr(t){let e=vr(t,or);return Ar(e,nr("constant payable nonpayable".split(" "))),Ar(e,nr("pure view payable nonpayable".split(" "))),e.has("view")?"view":e.has("pure")?"pure":e.has("payable")?"payable":e.has("nonpayable")?"nonpayable":e.has("constant")?"view":"nonpayable"}function Ir(t,e){return t.popParams().map((t=>Dr.from(t,e)))}function kr(t){if(t.peekType("AT")){if(t.pop(),t.peekType("NUMBER"))return Et(t.pop().text);throw new Error("invalid gas")}return null}function Tr(t){if(t.length)throw new Error(`unexpected tokens at offset ${t.offset}: ${t.toString()}`)}const Pr=new RegExp(/^(.*)\[([0-9]*)\]$/);function Or(t){const e=t.match(wr);if(tt(e,"invalid type","type",t),"uint"===t)return"uint256";if("int"===t)return"int256";if(e[2]){const r=parseInt(e[2]);tt(0!==r&&r<=32,"invalid bytes length","type",t)}else if(e[3]){const r=parseInt(e[3]);tt(0!==r&&r<=256&&r%8==0,"invalid numeric width","type",t)}return t}const Br={},Nr=Symbol.for("_ethers_internal"),xr="_ParamTypeInternal",Cr="_ErrorInternal",_r="_EventInternal",Rr="_ConstructorInternal",Ur="_FallbackInternal",Lr="_FunctionInternal",Fr="_StructInternal";class Dr{name;type;baseType;indexed;components;arrayLength;arrayChildren;constructor(t,e,r,n,i,s,o,a){if(nt(t,Br,"ParamType"),Object.defineProperty(this,Nr,{value:xr}),s&&(s=Object.freeze(s.slice())),"array"===n){if(null==o||null==a)throw new Error("")}else if(null!=o||null!=a)throw new Error("");if("tuple"===n){if(null==s)throw new Error("")}else if(null!=s)throw new Error("");J(this,{name:e,type:r,baseType:n,indexed:i,components:s,arrayLength:o,arrayChildren:a})}format(t){if(null==t&&(t="sighash"),"json"===t){const e=this.name||"";if(this.isArray()){const t=JSON.parse(this.arrayChildren.format("json"));return t.name=e,t.type+=`[${this.arrayLength<0?"":String(this.arrayLength)}]`,JSON.stringify(t)}const r={type:"tuple"===this.baseType?"tuple":this.type,name:e};return"boolean"==typeof this.indexed&&(r.indexed=this.indexed),this.isTuple()&&(r.components=this.components.map((e=>JSON.parse(e.format(t))))),JSON.stringify(r)}let e="";return this.isArray()?(e+=this.arrayChildren.format(t),e+=`[${this.arrayLength<0?"":String(this.arrayLength)}]`):this.isTuple()?e+="("+this.components.map((e=>e.format(t))).join("full"===t?", ":",")+")":e+=this.type,"sighash"!==t&&(!0===this.indexed&&(e+=" indexed"),"full"===t&&this.name&&(e+=" "+this.name)),e}isArray(){return"array"===this.baseType}isTuple(){return"tuple"===this.baseType}isIndexable(){return null!=this.indexed}walk(t,e){if(this.isArray()){if(!Array.isArray(t))throw new Error("invalid array value");if(-1!==this.arrayLength&&t.length!==this.arrayLength)throw new Error("array is wrong length");const r=this;return t.map((t=>r.arrayChildren.walk(t,e)))}if(this.isTuple()){if(!Array.isArray(t))throw new Error("invalid tuple value");if(t.length!==this.components.length)throw new Error("array is wrong length");const r=this;return t.map(((t,n)=>r.components[n].walk(t,e)))}return e(this.type,t)}#p(t,e,r,n){if(this.isArray()){if(!Array.isArray(e))throw new Error("invalid array value");if(-1!==this.arrayLength&&e.length!==this.arrayLength)throw new Error("array is wrong length");const i=this.arrayChildren,s=e.slice();return s.forEach(((e,n)=>{i.#p(t,e,r,(t=>{s[n]=t}))})),void n(s)}if(this.isTuple()){const i=this.components;let s;if(Array.isArray(e))s=e.slice();else{if(null==e||"object"!=typeof e)throw new Error("invalid tuple value");s=i.map((t=>{if(!t.name)throw new Error("cannot use object value with unnamed components");if(!(t.name in e))throw new Error(`missing value for component ${t.name}`);return e[t.name]}))}if(s.length!==this.components.length)throw new Error("array is wrong length");return s.forEach(((e,n)=>{i[n].#p(t,e,r,(t=>{s[n]=t}))})),void n(s)}const i=r(this.type,e);i.then?t.push(async function(){n(await i)}()):n(i)}async walkAsync(t,e){const r=[],n=[t];return this.#p(r,t,e,(t=>{n[0]=t})),r.length&&await Promise.all(r),n[0]}static from(t,e){if(Dr.isParamType(t))return t;if("string"==typeof t)try{return Dr.from(br(t),e)}catch(e){tt(!1,"invalid param type","obj",t)}else if(t instanceof mr){let r="",n="",i=null;vr(t,nr(["tuple"])).has("tuple")||t.peekType("OPEN_PAREN")?(n="tuple",i=t.popParams().map((t=>Dr.from(t))),r=`tuple(${i.map((t=>t.format())).join(",")})`):(r=Or(t.popType("TYPE")),n=r);let s=null,o=null;for(;t.length&&t.peekType("BRACKET");){const e=t.pop();s=new Dr(Br,"",r,n,null,i,o,s),o=e.value,r+=e.text,n="array",i=null}let a=null;if(vr(t,lr).has("indexed")){if(!e)throw new Error("");a=!0}const u=t.peekType("ID")?t.pop().text:"";if(t.length)throw new Error("leftover tokens");return new Dr(Br,u,r,n,a,i,o,s)}const r=t.name;tt(!r||"string"==typeof r&&r.match(yr),"invalid name","obj.name",r);let n=t.indexed;null!=n&&(tt(e,"parameter cannot be indexed","obj.indexed",t.indexed),n=!!n);let i=t.type,s=i.match(Pr);if(s){const e=parseInt(s[2]||"-1"),o=Dr.from({type:s[1],components:t.components});return new Dr(Br,r||"",i,"array",n,null,e,o)}if("tuple"===i||i.startsWith("tuple(")||i.startsWith("(")){const e=null!=t.components?t.components.map((t=>Dr.from(t))):null;return new Dr(Br,r||"",i,"tuple",n,e,null,null)}return i=Or(t.type),new Dr(Br,r||"",i,i,n,null,null,null)}static isParamType(t){return t&&t[Nr]===xr}}class Hr{type;inputs;constructor(t,e,r){nt(t,Br,"Fragment"),J(this,{type:e,inputs:r=Object.freeze(r.slice())})}static from(t){if("string"==typeof t){try{Hr.from(JSON.parse(t))}catch(t){}return Hr.from(br(t))}if(t instanceof mr)switch(t.peekKeyword(ur)){case"constructor":return Kr.from(t);case"error":return jr.from(t);case"event":return Vr.from(t);case"fallback":case"receive":return Qr.from(t);case"function":return Wr.from(t);case"struct":return zr.from(t)}else if("object"==typeof t){switch(t.type){case"constructor":return Kr.from(t);case"error":return jr.from(t);case"event":return Vr.from(t);case"fallback":case"receive":return Qr.from(t);case"function":return Wr.from(t);case"struct":return zr.from(t)}$(!1,`unsupported type: ${t.type}`,"UNSUPPORTED_OPERATION",{operation:"Fragment.from"})}tt(!1,"unsupported frgament object","obj",t)}static isConstructor(t){return Kr.isFragment(t)}static isError(t){return jr.isFragment(t)}static isEvent(t){return Vr.isFragment(t)}static isFunction(t){return Wr.isFragment(t)}static isStruct(t){return zr.isFragment(t)}}class Mr extends Hr{name;constructor(t,e,r,n){super(t,e,n),tt("string"==typeof r&&r.match(yr),"invalid identifier","name",r),n=Object.freeze(n.slice()),J(this,{name:r})}}function Gr(t,e){return"("+e.map((e=>e.format(t))).join("full"===t?", ":",")+")"}class jr extends Mr{constructor(t,e,r){super(t,"error",e,r),Object.defineProperty(this,Nr,{value:Cr})}get selector(){return rr(this.format("sighash")).substring(0,10)}format(t){if(null==t&&(t="sighash"),"json"===t)return JSON.stringify({type:"error",name:this.name,inputs:this.inputs.map((e=>JSON.parse(e.format(t))))});const e=[];return"sighash"!==t&&e.push("error"),e.push(this.name+Gr(t,this.inputs)),e.join(" ")}static from(t){if(jr.isFragment(t))return t;if("string"==typeof t)return jr.from(br(t));if(t instanceof mr){const e=Er("error",t),r=Ir(t);return Tr(t),new jr(Br,e,r)}return new jr(Br,t.name,t.inputs?t.inputs.map(Dr.from):[])}static isFragment(t){return t&&t[Nr]===Cr}}class Vr extends Mr{anonymous;constructor(t,e,r,n){super(t,"event",e,r),Object.defineProperty(this,Nr,{value:_r}),J(this,{anonymous:n})}get topicHash(){return rr(this.format("sighash"))}format(t){if(null==t&&(t="sighash"),"json"===t)return JSON.stringify({type:"event",anonymous:this.anonymous,name:this.name,inputs:this.inputs.map((e=>JSON.parse(e.format(t))))});const e=[];return"sighash"!==t&&e.push("event"),e.push(this.name+Gr(t,this.inputs)),"sighash"!==t&&this.anonymous&&e.push("anonymous"),e.join(" ")}static getTopicHash(t,e){return e=(e||[]).map((t=>Dr.from(t))),new Vr(Br,t,e,!1).topicHash}static from(t){if(Vr.isFragment(t))return t;if("string"==typeof t)try{return Vr.from(br(t))}catch(e){tt(!1,"invalid event fragment","obj",t)}else if(t instanceof mr){const e=Er("event",t),r=Ir(t,!0),n=!!vr(t,nr(["anonymous"])).has("anonymous");return Tr(t),new Vr(Br,e,r,n)}return new Vr(Br,t.name,t.inputs?t.inputs.map((t=>Dr.from(t,!0))):[],!!t.anonymous)}static isFragment(t){return t&&t[Nr]===_r}}class Kr extends Hr{payable;gas;constructor(t,e,r,n,i){super(t,e,r),Object.defineProperty(this,Nr,{value:Rr}),J(this,{payable:n,gas:i})}format(t){if($(null!=t&&"sighash"!==t,"cannot format a constructor for sighash","UNSUPPORTED_OPERATION",{operation:"format(sighash)"}),"json"===t)return JSON.stringify({type:"constructor",stateMutability:this.payable?"payable":"undefined",payable:this.payable,gas:null!=this.gas?this.gas:void 0,inputs:this.inputs.map((e=>JSON.parse(e.format(t))))});const e=[`constructor${Gr(t,this.inputs)}`];return this.payable&&e.push("payable"),null!=this.gas&&e.push(`@${this.gas.toString()}`),e.join(" ")}static from(t){if(Kr.isFragment(t))return t;if("string"==typeof t)try{return Kr.from(br(t))}catch(e){tt(!1,"invalid constuctor fragment","obj",t)}else if(t instanceof mr){vr(t,nr(["constructor"]));const e=Ir(t),r=!!vr(t,ir).has("payable"),n=kr(t);return Tr(t),new Kr(Br,"constructor",e,r,n)}return new Kr(Br,"constructor",t.inputs?t.inputs.map(Dr.from):[],!!t.payable,null!=t.gas?t.gas:null)}static isFragment(t){return t&&t[Nr]===Rr}}class Qr extends Hr{payable;constructor(t,e,r){super(t,"fallback",e),Object.defineProperty(this,Nr,{value:Ur}),J(this,{payable:r})}format(t){const e=0===this.inputs.length?"receive":"fallback";if("json"===t){const t=this.payable?"payable":"nonpayable";return JSON.stringify({type:e,stateMutability:t})}return`${e}()${this.payable?" payable":""}`}static from(t){if(Qr.isFragment(t))return t;if("string"==typeof t)try{return Qr.from(br(t))}catch(e){tt(!1,"invalid fallback fragment","obj",t)}else if(t instanceof mr){const e=t.toString();if(tt(t.peekKeyword(nr(["fallback","receive"])),"type must be fallback or receive","obj",e),"receive"===t.popKeyword(nr(["fallback","receive"]))){const e=Ir(t);return tt(0===e.length,"receive cannot have arguments","obj.inputs",e),vr(t,nr(["payable"])),Tr(t),new Qr(Br,[],!0)}let r=Ir(t);r.length?tt(1===r.length&&"bytes"===r[0].type,"invalid fallback inputs","obj.inputs",r.map((t=>t.format("minimal"))).join(", ")):r=[Dr.from("bytes")];const n=Sr(t);if(tt("nonpayable"===n||"payable"===n,"fallback cannot be constants","obj.stateMutability",n),vr(t,nr(["returns"])).has("returns")){const e=Ir(t);tt(1===e.length&&"bytes"===e[0].type,"invalid fallback outputs","obj.outputs",e.map((t=>t.format("minimal"))).join(", "))}return Tr(t),new Qr(Br,r,"payable"===n)}if("receive"===t.type)return new Qr(Br,[],!0);if("fallback"===t.type){const e=[Dr.from("bytes")],r="payable"===t.stateMutability;return new Qr(Br,e,r)}tt(!1,"invalid fallback description","obj",t)}static isFragment(t){return t&&t[Nr]===Ur}}class Wr extends Mr{constant;outputs;stateMutability;payable;gas;constructor(t,e,r,n,i,s){super(t,"function",e,n),Object.defineProperty(this,Nr,{value:Lr}),J(this,{constant:"view"===r||"pure"===r,gas:s,outputs:i=Object.freeze(i.slice()),payable:"payable"===r,stateMutability:r})}get selector(){return rr(this.format("sighash")).substring(0,10)}format(t){if(null==t&&(t="sighash"),"json"===t)return JSON.stringify({type:"function",name:this.name,constant:this.constant,stateMutability:"nonpayable"!==this.stateMutability?this.stateMutability:void 0,payable:this.payable,gas:null!=this.gas?this.gas:void 0,inputs:this.inputs.map((e=>JSON.parse(e.format(t)))),outputs:this.outputs.map((e=>JSON.parse(e.format(t))))});const e=[];return"sighash"!==t&&e.push("function"),e.push(this.name+Gr(t,this.inputs)),"sighash"!==t&&("nonpayable"!==this.stateMutability&&e.push(this.stateMutability),this.outputs&&this.outputs.length&&(e.push("returns"),e.push(Gr(t,this.outputs))),null!=this.gas&&e.push(`@${this.gas.toString()}`)),e.join(" ")}static getSelector(t,e){return e=(e||[]).map((t=>Dr.from(t))),new Wr(Br,t,"view",e,[],null).selector}static from(t){if(Wr.isFragment(t))return t;if("string"==typeof t)try{return Wr.from(br(t))}catch(e){tt(!1,"invalid function fragment","obj",t)}else if(t instanceof mr){const e=Er("function",t),r=Ir(t),n=Sr(t);let i=[];vr(t,nr(["returns"])).has("returns")&&(i=Ir(t));const s=kr(t);return Tr(t),new Wr(Br,e,n,r,i,s)}let e=t.stateMutability;return null==e&&(e="payable","boolean"==typeof t.constant?(e="view",t.constant||(e="payable","boolean"!=typeof t.payable||t.payable||(e="nonpayable"))):"boolean"!=typeof t.payable||t.payable||(e="nonpayable")),new Wr(Br,t.name,e,t.inputs?t.inputs.map(Dr.from):[],t.outputs?t.outputs.map(Dr.from):[],null!=t.gas?t.gas:null)}static isFragment(t){return t&&t[Nr]===Lr}}class zr extends Mr{constructor(t,e,r){super(t,"struct",e,r),Object.defineProperty(this,Nr,{value:Fr})}format(){throw new Error("@TODO")}static from(t){if("string"==typeof t)try{return zr.from(br(t))}catch(e){tt(!1,"invalid struct fragment","obj",t)}else if(t instanceof mr){const e=Er("struct",t),r=Ir(t);return Tr(t),new zr(Br,e,r)}return new zr(Br,t.name,t.inputs?t.inputs.map(Dr.from):[])}static isFragment(t){return t&&t[Nr]===Fr}}const Jr=new Map;Jr.set(0,"GENERIC_PANIC"),Jr.set(1,"ASSERT_FALSE"),Jr.set(17,"OVERFLOW"),Jr.set(18,"DIVIDE_BY_ZERO"),Jr.set(33,"ENUM_RANGE_ERROR"),Jr.set(34,"BAD_STORAGE_DATA"),Jr.set(49,"STACK_UNDERFLOW"),Jr.set(50,"ARRAY_RANGE_ERROR"),Jr.set(65,"OUT_OF_MEMORY"),Jr.set(81,"UNINITIALIZED_FUNCTION_CALL");const qr=new RegExp(/^bytes([0-9]*)$/),Xr=new RegExp(/^(u?int)([0-9]*)$/);let Yr=null,Zr=1024;class $r{#d(t){if(t.isArray())return new He(this.#d(t.arrayChildren),t.arrayLength,t.name);if(t.isTuple())return new er(t.components.map((t=>this.#d(t))),t.name);switch(t.baseType){case"address":return new Ue(t.name);case"bool":return new Me(t.name);case"string":return new tr(t.name);case"bytes":return new je(t.name);case"":return new Qe(t.name)}let e=t.type.match(Xr);if(e){let r=parseInt(e[2]||"256");return tt(0!==r&&r<=256&&r%8==0,"invalid "+e[1]+" bit length","param",t),new qe(r/8,"int"===e[1],t.name)}if(e=t.type.match(qr),e){let r=parseInt(e[1]);return tt(0!==r&&r<=32,"invalid bytes length","param",t),new Ve(r,t.name)}tt(!1,"invalid type","type",t.type)}getDefaultValue(t){const e=t.map((t=>this.#d(Dr.from(t))));return new er(e,"_").defaultValue()}encode(t,e){et(e.length,t.length,"types/values length mismatch");const r=t.map((t=>this.#d(Dr.from(t)))),n=new er(r,"_"),i=new Ft;return n.encode(i,e),i.data}decode(t,e,r){const n=t.map((t=>this.#d(Dr.from(t))));return new er(n,"_").decode(new Dt(e,r,Zr))}static _setDefaultMaxInflation(t){tt("number"==typeof t&&Number.isInteger(t),"invalid defaultMaxInflation factor","value",t),Zr=t}static defaultAbiCoder(){return null==Yr&&(Yr=new $r),Yr}static getBuiltinCallException(t,e,r){return function(t,e,r,n){let i="missing revert data",s=null,o=null;if(r){i="execution reverted";const t=st(r);if(r=lt(r),0===t.length)i+=" (no data present; likely require(false) occurred",s="require(false)";else if(t.length%32!=4)i+=" (could not decode reason; invalid data length)";else if("0x08c379a0"===lt(t.slice(0,4)))try{s=n.decode(["string"],t.slice(4))[0],o={signature:"Error(string)",name:"Error",args:[s]},i+=`: ${JSON.stringify(s)}`}catch(t){i+=" (could not decode reason; invalid string data)"}else if("0x4e487b71"===lt(t.slice(0,4)))try{const e=Number(n.decode(["uint256"],t.slice(4))[0]);o={signature:"Panic(uint256)",name:"Panic",args:[e]},s=`Panic due to ${Jr.get(e)||"UNKNOWN"}(${e})`,i+=`: ${s}`}catch(t){i+=" (could not decode panic code)"}else i+=" (unknown custom error)"}const a={to:e.to?Be(e.to):null,data:e.data||"0x"};return e.from&&(a.from=Be(e.from)),Z(i,"CALL_EXCEPTION",{action:t,data:r,reason:s,transaction:a,invocation:null,revert:o})}(t,e,r,$r.defaultAbiCoder())}}function tn(t){return t&&"function"==typeof t.getAddress}async function en(t,e){const r=await e;return null!=r&&"0x0000000000000000000000000000000000000000"!==r||($("string"!=typeof t,"unconfigured name","UNCONFIGURED_NAME",{value:t}),tt(!1,"invalid AddressLike value; did not resolve to a value address","target",t)),Be(r)}function rn(t,e){return"string"==typeof t?t.match(/^0x[0-9a-f]{40}$/i)?Be(t):($(null!=e,"ENS resolution requires a provider","UNSUPPORTED_OPERATION",{operation:"resolveName"}),en(t,e.resolveName(t))):tn(t)?en(t,t.getAddress()):t&&"function"==typeof t.then?en(t,t):void tt(!1,"unsupported addressable value","target",t)}const nn=new Uint8Array(32);nn.fill(0);const sn=BigInt(-1),on=BigInt(0),an=BigInt(1),un=BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),cn=Tt(an,32),ln=Tt(on,32),fn={name:"string",version:"string",chainId:"uint256",verifyingContract:"address",salt:"bytes32"},hn=["name","version","chainId","verifyingContract","salt"];function pn(t){return function(e){return tt("string"==typeof e,`invalid domain value for ${JSON.stringify(t)}`,`domain.${t}`,e),e}}const dn={name:pn("name"),version:pn("version"),chainId:function(t){const e=Et(t,"domain.chainId");return tt(e>=0,"invalid chain ID","domain.chainId",t),Number.isSafeInteger(e)?Number(e):Ot(e)},verifyingContract:function(t){try{return Be(t).toLowerCase()}catch(t){}tt(!1,'invalid domain value "verifyingContract"',"domain.verifyingContract",t)},salt:function(t){const e=st(t,"domain.salt");return tt(32===e.length,'invalid domain value "salt"',"domain.salt",t),lt(e)}};function gn(t){{const e=t.match(/^(u?)int(\d+)$/);if(e){const r=""===e[1],n=parseInt(e[2]);tt(n%8==0&&0!==n&&n<=256&&e[2]===String(n),"invalid numeric width","type",t);const i=At(un,r?n-1:n),s=r?(i+an)*sn:on;return function(e){const n=Et(e,"value");return tt(n>=s&&n<=i,`value out-of-bounds for ${t}`,"value",n),Tt(r?bt(n,256):n,32)}}}{const e=t.match(/^bytes(\d+)$/);if(e){const r=parseInt(e[1]);return tt(0!==r&&r<=32&&e[1]===String(r),"invalid bytes width","type",t),function(e){return tt(st(e).length===r,`invalid length for ${t}`,"value",e),function(t){const e=st(t),r=e.length%32;return r?ft([e,nn.slice(r)]):lt(e)}(e)}}}switch(t){case"address":return function(t){return gt(Be(t),32)};case"bool":return function(t){return t?cn:ln};case"bytes":return function(t){return ve(t)};case"string":return function(t){return rr(t)}}return null}function yn(t,e){return`${t}(${e.map((({name:t,type:e})=>e+" "+t)).join(",")})`}function wn(t){const e=t.match(/^([^\x5b]*)((\x5b\d*\x5d)*)(\x5b(\d*)\x5d)$/);return e?{base:e[1],index:e[2]+e[4],array:{base:e[1],prefix:e[1]+e[2],count:e[5]?parseInt(e[5]):-1}}:{base:t}}class mn{primaryType;#g;get types(){return JSON.parse(this.#g)}#y;#w;constructor(t){this.#y=new Map,this.#w=new Map;const e=new Map,r=new Map,n=new Map,i={};Object.keys(t).forEach((s=>{i[s]=t[s].map((({name:e,type:r})=>{let{base:n,index:i}=wn(r);return"int"!==n||t.int||(n="int256"),"uint"!==n||t.uint||(n="uint256"),{name:e,type:n+(i||"")}})),e.set(s,new Set),r.set(s,[]),n.set(s,new Set)})),this.#g=JSON.stringify(i);for(const n in i){const s=new Set;for(const o of i[n]){tt(!s.has(o.name),`duplicate variable name ${JSON.stringify(o.name)} in ${JSON.stringify(n)}`,"types",t),s.add(o.name);const i=wn(o.type).base;tt(i!==n,`circular type reference to ${JSON.stringify(i)}`,"types",t),gn(i)||(tt(r.has(i),`unknown type ${JSON.stringify(i)}`,"types",t),r.get(i).push(n),e.get(n).add(i))}}const s=Array.from(r.keys()).filter((t=>0===r.get(t).length));tt(0!==s.length,"missing primary type","types",t),tt(1===s.length,`ambiguous primary types or unused types: ${s.map((t=>JSON.stringify(t))).join(", ")}`,"types",t),J(this,{primaryType:s[0]}),function i(s,o){tt(!o.has(s),`circular type reference to ${JSON.stringify(s)}`,"types",t),o.add(s);for(const t of e.get(s))if(r.has(t)){i(t,o);for(const e of o)n.get(e).add(t)}o.delete(s)}(this.primaryType,new Set);for(const[t,e]of n){const r=Array.from(e);r.sort(),this.#y.set(t,yn(t,i[t])+r.map((t=>yn(t,i[t]))).join(""))}}getEncoder(t){let e=this.#w.get(t);return e||(e=this.#m(t),this.#w.set(t,e)),e}#m(t){{const e=gn(t);if(e)return e}const e=wn(t).array;if(e){const t=e.prefix,r=this.getEncoder(t);return n=>{tt(-1===e.count||e.count===n.length,`array length mismatch; expected length ${e.count}`,"value",n);let i=n.map(r);return this.#y.has(t)&&(i=i.map(ve)),ve(ft(i))}}const r=this.types[t];if(r){const e=rr(this.#y.get(t));return t=>{const n=r.map((({name:e,type:r})=>{const n=this.getEncoder(r)(t[e]);return this.#y.has(r)?ve(n):n}));return n.unshift(e),ft(n)}}tt(!1,`unknown type: ${t}`,"type",t)}encodeType(t){const e=this.#y.get(t);return tt(e,`unknown type: ${JSON.stringify(t)}`,"name",t),e}encodeData(t,e){return this.getEncoder(t)(e)}hashStruct(t,e){return ve(this.encodeData(t,e))}encode(t){return this.encodeData(this.primaryType,t)}hash(t){return this.hashStruct(this.primaryType,t)}_visit(t,e,r){if(gn(t))return r(t,e);const n=wn(t).array;if(n)return tt(-1===n.count||n.count===e.length,`array length mismatch; expected length ${n.count}`,"value",e),e.map((t=>this._visit(n.prefix,t,r)));const i=this.types[t];if(i)return i.reduce(((t,{name:n,type:i})=>(t[n]=this._visit(i,e[n],r),t)),{});tt(!1,`unknown type: ${t}`,"type",t)}visit(t,e){return this._visit(this.primaryType,t,e)}static from(t){return new mn(t)}static getPrimaryType(t){return mn.from(t).primaryType}static hashStruct(t,e,r){return mn.from(e).hashStruct(t,r)}static hashDomain(t){const e=[];for(const r in t){if(null==t[r])continue;const n=fn[r];tt(n,`invalid typed-data domain key: ${JSON.stringify(r)}`,"domain",t),e.push({name:r,type:n})}return e.sort(((t,e)=>hn.indexOf(t.name)-hn.indexOf(e.name))),mn.hashStruct("EIP712Domain",{EIP712Domain:e},t)}static encode(t,e,r){return ft(["0x1901",mn.hashDomain(t),mn.from(e).hash(r)])}static hash(t,e,r){return ve(mn.encode(t,e,r))}static async resolveNames(t,e,r,n){t=Object.assign({},t);for(const e in t)null==t[e]&&delete t[e];const i={};t.verifyingContract&&!at(t.verifyingContract,20)&&(i[t.verifyingContract]="0x");const s=mn.from(e);s.visit(r,((t,e)=>("address"!==t||at(e,20)||(i[e]="0x"),e)));for(const t in i)i[t]=await n(t);return t.verifyingContract&&i[t.verifyingContract]&&(t.verifyingContract=i[t.verifyingContract]),{domain:t,value:r=s.visit(r,((t,e)=>"address"===t&&i[e]?i[e]:e))}}static getPayload(t,e,r){mn.hashDomain(t);const n={},i=[];hn.forEach((e=>{const r=t[e];null!=r&&(n[e]=dn[e](r),i.push({name:e,type:fn[e]}))}));const s=mn.from(e);e=s.types;const o=Object.assign({},e);return tt(null==o.EIP712Domain,"types must not contain EIP712Domain type","types.EIP712Domain",e),o.EIP712Domain=i,s.encode(r),{types:o,domain:n,primaryType:s.primaryType,message:s.visit(r,((t,e)=>{if(t.match(/^bytes(\d*)/))return lt(st(e));if(t.match(/^u?int/))return Et(e).toString();switch(t){case"address":return e.toLowerCase();case"bool":return!!e;case"string":return tt("string"==typeof e,"invalid string","value",e),e}tt(!1,"unsupported type","type",t)}))}}}function bn(t,e){return{address:Be(t),storageKeys:e.map(((t,e)=>(tt(at(t,32),"invalid slot",`storageKeys[${e}]`,t),t.toLowerCase())))}}function An(t){if(Array.isArray(t))return t.map(((e,r)=>Array.isArray(e)?(tt(2===e.length,"invalid slot set",`value[${r}]`,e),bn(e[0],e[1])):(tt(null!=e&&"object"==typeof e,"invalid address-slot set","value",t),bn(e.address,e.storageKeys))));tt(null!=t&&"object"==typeof t,"invalid access list","value",t);const e=Object.keys(t).map((e=>{const r=t[e].reduce(((t,e)=>(t[e]=!0,t)),{});return bn(e,Object.keys(r).sort())}));return e.sort(((t,e)=>t.address.localeCompare(e.address))),e}function En(t){return async function(t,e){const r=t.url.split(":")[0].toLowerCase();let n;if($("http"===r||"https"===r,`unsupported protocol ${r}`,"UNSUPPORTED_OPERATION",{info:{protocol:r},operation:"request"}),$("https"===r||!t.credentials||t.allowInsecureAuthentication,"insecure authorized connections unsupported","UNSUPPORTED_OPERATION",{operation:"request"}),e){const t=new AbortController;n=t.signal,e.addListener((()=>{t.abort()}))}const i={method:t.method,headers:new Headers(Array.from(t)),body:t.body||void 0,signal:n},s=await fetch(t.url,i),o={};s.headers.forEach(((t,e)=>{o[e.toLowerCase()]=t}));const a=await s.arrayBuffer(),u=null==a?null:new Uint8Array(a);return{statusCode:s.status,statusMessage:s.statusText,headers:o,body:u}}}En();let vn=En();const Sn=new RegExp("^data:([^;:]*)?(;base64)?,(.*)$","i"),In=new RegExp("^ipfs://(ipfs/)?(.*)$","i");let kn=!1;async function Tn(t,e){try{const e=t.match(Sn);if(!e)throw new Error("invalid data");return new _n(200,"OK",{"content-type":e[1]||"text/plain"},e[2]?function(t){t=atob(t);const e=new Uint8Array(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return st(e)}(e[3]):Ze(e[3].replace(/%([0-9a-f][0-9a-f])/gi,((t,e)=>String.fromCharCode(parseInt(e,16))))))}catch(e){return new _n(599,"BAD REQUEST (invalid data: URI)",{},null,new Cn(t))}}function Pn(t){return async function(e,r){try{const r=e.match(In);if(!r)throw new Error("invalid link");return new Cn(`${t}${r[2]}`)}catch(t){return new _n(599,"BAD REQUEST (invalid IPFS URI)",{},null,new Cn(e))}}}const On={data:Tn,ipfs:Pn("https://gateway.ipfs.io/ipfs/")},Bn=new WeakMap;class Nn{#b;#A;constructor(t){this.#b=[],this.#A=!1,Bn.set(t,(()=>{if(!this.#A){this.#A=!0;for(const t of this.#b)setTimeout((()=>{t()}),0);this.#b=[]}}))}addListener(t){$(!this.#A,"singal already cancelled","UNSUPPORTED_OPERATION",{operation:"fetchCancelSignal.addCancelListener"}),this.#b.push(t)}get cancelled(){return this.#A}checkSignal(){$(!this.cancelled,"cancelled","CANCELLED",{})}}function xn(t){if(null==t)throw new Error("missing signal; should not happen");return t.checkSignal(),t}class Cn{#E;#v;#S;#I;#k;#T;#P;#O;#B;#N;#x;#C;#_;#R;#U;get url(){return this.#T}set url(t){this.#T=String(t)}get body(){return null==this.#P?null:new Uint8Array(this.#P)}set body(t){if(null==t)this.#P=void 0,this.#O=void 0;else if("string"==typeof t)this.#P=Ze(t),this.#O="text/plain";else if(t instanceof Uint8Array)this.#P=t,this.#O="application/octet-stream";else{if("object"!=typeof t)throw new Error("invalid body");this.#P=Ze(JSON.stringify(t)),this.#O="application/json"}}hasBody(){return null!=this.#P}get method(){return this.#I?this.#I:this.hasBody()?"POST":"GET"}set method(t){null==t&&(t=""),this.#I=String(t).toUpperCase()}get headers(){const t=Object.assign({},this.#S);return this.#B&&(t.authorization=`Basic ${function(t){const e=st(t);let r="";for(let t=0;t<e.length;t++)r+=String.fromCharCode(e[t]);return btoa(r)}(Ze(this.#B))}`),this.allowGzip&&(t["accept-encoding"]="gzip"),null==t["content-type"]&&this.#O&&(t["content-type"]=this.#O),this.body&&(t["content-length"]=String(this.body.length)),t}getHeader(t){return this.headers[t.toLowerCase()]}setHeader(t,e){this.#S[String(t).toLowerCase()]=String(e)}clearHeaders(){this.#S={}}[Symbol.iterator](){const t=this.headers,e=Object.keys(t);let r=0;return{next:()=>{if(r<e.length){const n=e[r++];return{value:[n,t[n]],done:!1}}return{value:void 0,done:!0}}}}get credentials(){return this.#B||null}setCredentials(t,e){tt(!t.match(/:/),"invalid basic authentication username","username","[REDACTED]"),this.#B=`${t}:${e}`}get allowGzip(){return this.#v}set allowGzip(t){this.#v=!!t}get allowInsecureAuthentication(){return!!this.#E}set allowInsecureAuthentication(t){this.#E=!!t}get timeout(){return this.#k}set timeout(t){tt(t>=0,"timeout must be non-zero","timeout",t),this.#k=t}get preflightFunc(){return this.#N||null}set preflightFunc(t){this.#N=t}get processFunc(){return this.#x||null}set processFunc(t){this.#x=t}get retryFunc(){return this.#C||null}set retryFunc(t){this.#C=t}get getUrlFunc(){return this.#U||vn}set getUrlFunc(t){this.#U=t}constructor(t){this.#T=String(t),this.#E=!1,this.#v=!0,this.#S={},this.#I="",this.#k=3e5,this.#R={slotInterval:250,maxAttempts:12},this.#U=null}toString(){return`<FetchRequest method=${JSON.stringify(this.method)} url=${JSON.stringify(this.url)} headers=${JSON.stringify(this.headers)} body=${this.#P?lt(this.#P):"null"}>`}setThrottleParams(t){null!=t.slotInterval&&(this.#R.slotInterval=t.slotInterval),null!=t.maxAttempts&&(this.#R.maxAttempts=t.maxAttempts)}async#L(t,e,r,n,i){if(t>=this.#R.maxAttempts)return i.makeServerError("exceeded maximum retry limit");$(Rn()<=e,"timeout","TIMEOUT",{operation:"request.send",reason:"timeout",request:n}),r>0&&await function(t){return new Promise((e=>setTimeout(e,t)))}(r);let s=this.clone();const o=(s.url.split(":")[0]||"").toLowerCase();if(o in On){const t=await On[o](s.url,xn(n.#_));if(t instanceof _n){let e=t;if(this.processFunc){xn(n.#_);try{e=await this.processFunc(s,e)}catch(t){null!=t.throttle&&"number"==typeof t.stall||e.makeServerError("error in post-processing function",t).assertOk()}}return e}s=t}this.preflightFunc&&(s=await this.preflightFunc(s));const a=await this.getUrlFunc(s,xn(n.#_));let u=new _n(a.statusCode,a.statusMessage,a.headers,a.body,n);if(301===u.statusCode||302===u.statusCode){try{const r=u.headers.location||"";return s.redirect(r).#L(t+1,e,0,n,u)}catch(t){}return u}if(429===u.statusCode&&(null==this.retryFunc||await this.retryFunc(s,u,t))){const r=u.headers["retry-after"];let i=this.#R.slotInterval*Math.trunc(Math.random()*Math.pow(2,t));return"string"==typeof r&&r.match(/^[1-9][0-9]*$/)&&(i=parseInt(r)),s.clone().#L(t+1,e,i,n,u)}if(this.processFunc){xn(n.#_);try{u=await this.processFunc(s,u)}catch(r){null!=r.throttle&&"number"==typeof r.stall||u.makeServerError("error in post-processing function",r).assertOk();let i=this.#R.slotInterval*Math.trunc(Math.random()*Math.pow(2,t));return r.stall>=0&&(i=r.stall),s.clone().#L(t+1,e,i,n,u)}}return u}send(){return $(null==this.#_,"request already sent","UNSUPPORTED_OPERATION",{operation:"fetchRequest.send"}),this.#_=new Nn(this),this.#L(0,Rn()+this.timeout,0,this,new _n(0,"",{},null,this))}cancel(){$(null!=this.#_,"request has not been sent","UNSUPPORTED_OPERATION",{operation:"fetchRequest.cancel"});const t=Bn.get(this);if(!t)throw new Error("missing signal; should not happen");t()}redirect(t){const e=this.url.split(":")[0].toLowerCase(),r=t.split(":")[0].toLowerCase();$("GET"===this.method&&("https"!==e||"http"!==r)&&t.match(/^https?:/),"unsupported redirect","UNSUPPORTED_OPERATION",{operation:`redirect(${this.method} ${JSON.stringify(this.url)} => ${JSON.stringify(t)})`});const n=new Cn(t);return n.method="GET",n.allowGzip=this.allowGzip,n.timeout=this.timeout,n.#S=Object.assign({},this.#S),this.#P&&(n.#P=new Uint8Array(this.#P)),n.#O=this.#O,n}clone(){const t=new Cn(this.url);return t.#I=this.#I,this.#P&&(t.#P=this.#P),t.#O=this.#O,t.#S=Object.assign({},this.#S),t.#B=this.#B,this.allowGzip&&(t.allowGzip=!0),t.timeout=this.timeout,this.allowInsecureAuthentication&&(t.allowInsecureAuthentication=!0),t.#N=this.#N,t.#x=this.#x,t.#C=this.#C,t.#R=Object.assign({},this.#R),t.#U=this.#U,t}static lockConfig(){kn=!0}static getGateway(t){return On[t.toLowerCase()]||null}static registerGateway(t,e){if("http"===(t=t.toLowerCase())||"https"===t)throw new Error(`cannot intercept ${t}; use registerGetUrl`);if(kn)throw new Error("gateways locked");On[t]=e}static registerGetUrl(t){if(kn)throw new Error("gateways locked");vn=t}static createGetUrlFunc(t){return En()}static createDataGateway(){return Tn}static createIpfsGatewayFunc(t){return Pn(t)}}class _n{#F;#D;#S;#P;#H;#M;toString(){return`<FetchResponse status=${this.statusCode} body=${this.#P?lt(this.#P):"null"}>`}get statusCode(){return this.#F}get statusMessage(){return this.#D}get headers(){return Object.assign({},this.#S)}get body(){return null==this.#P?null:new Uint8Array(this.#P)}get bodyText(){try{return null==this.#P?"":$e(this.#P)}catch(t){$(!1,"response body is not valid UTF-8 data","UNSUPPORTED_OPERATION",{operation:"bodyText",info:{response:this}})}}get bodyJson(){try{return JSON.parse(this.bodyText)}catch(t){$(!1,"response body is not valid JSON","UNSUPPORTED_OPERATION",{operation:"bodyJson",info:{response:this}})}}[Symbol.iterator](){const t=this.headers,e=Object.keys(t);let r=0;return{next:()=>{if(r<e.length){const n=e[r++];return{value:[n,t[n]],done:!1}}return{value:void 0,done:!0}}}}constructor(t,e,r,n,i){this.#F=t,this.#D=e,this.#S=Object.keys(r).reduce(((t,e)=>(t[e.toLowerCase()]=String(r[e]),t)),{}),this.#P=null==n?null:new Uint8Array(n),this.#H=i||null,this.#M={message:""}}makeServerError(t,e){let r;r=t?`CLIENT ESCALATED SERVER ERROR (${this.statusCode} ${this.statusMessage}; ${t})`:`CLIENT ESCALATED SERVER ERROR (${t=`${this.statusCode} ${this.statusMessage}`})`;const n=new _n(599,r,this.headers,this.body,this.#H||void 0);return n.#M={message:t,error:e},n}throwThrottleError(t,e){null==e?e=-1:tt(Number.isInteger(e)&&e>=0,"invalid stall timeout","stall",e);const r=new Error(t||"throttling requests");throw J(r,{stall:e,throttle:!0}),r}getHeader(t){return this.headers[t.toLowerCase()]}hasBody(){return null!=this.#P}get request(){return this.#H}ok(){return""===this.#M.message&&this.statusCode>=200&&this.statusCode<300}assertOk(){if(this.ok())return;let{message:t,error:e}=this.#M;""===t&&(t=`server response ${this.statusCode} ${this.statusMessage}`);let r=null;this.request&&(r=this.request.url);let n=null;try{this.#P&&(n=$e(this.#P))}catch(t){}$(!1,t,"SERVER_ERROR",{request:this.request||"unknown request",response:this,error:e,info:{requestUrl:r,responseBody:n,responseStatus:`${this.statusCode} ${this.statusMessage}`}})}}function Rn(){return(new Date).getTime()}const Un="0x0000000000000000000000000000000000000000";class Ln{fragment;name;signature;topic;args;constructor(t,e,r){const n=t.name,i=t.format();J(this,{fragment:t,name:n,signature:i,topic:e,args:r})}}class Fn{fragment;name;args;signature;selector;value;constructor(t,e,r,n){const i=t.name,s=t.format();J(this,{fragment:t,name:i,args:r,signature:s,selector:e,value:n})}}class Dn{fragment;name;args;signature;selector;constructor(t,e,r){const n=t.name,i=t.format();J(this,{fragment:t,name:n,args:r,signature:i,selector:e})}}class Hn{hash;_isIndexed;static isIndexed(t){return!(!t||!t._isIndexed)}constructor(t){J(this,{hash:t,_isIndexed:!0})}}const Mn={0:"generic panic",1:"assert(false)",17:"arithmetic overflow",18:"division or modulo by zero",33:"enum overflow",34:"invalid encoded storage byte array accessed",49:"out-of-bounds array access; popping on an empty array",50:"out-of-bounds access of an array or bytesN",65:"out of memory",81:"uninitialized function"},Gn={"0x08c379a0":{signature:"Error(string)",name:"Error",inputs:["string"],reason:t=>`reverted with reason string ${JSON.stringify(t)}`},"0x4e487b71":{signature:"Panic(uint256)",name:"Panic",inputs:["uint256"],reason:t=>{let e="unknown panic code";return t>=0&&t<=255&&Mn[t.toString()]&&(e=Mn[t.toString()]),`reverted with panic code 0x${t.toString(16)} (${e})`}}};class jn{fragments;deploy;fallback;receive;#G;#j;#V;#K;constructor(t){let e=[];e="string"==typeof t?JSON.parse(t):t,this.#V=new Map,this.#G=new Map,this.#j=new Map;const r=[];for(const t of e)try{r.push(Hr.from(t))}catch(e){console.log(`[Warning] Invalid Fragment ${JSON.stringify(t)}:`,e.message)}J(this,{fragments:Object.freeze(r)});let n=null,i=!1;this.#K=this.getAbiCoder(),this.fragments.forEach(((t,e)=>{let r;switch(t.type){case"constructor":return this.deploy?void console.log("duplicate definition - constructor"):void J(this,{deploy:t});case"fallback":return void(0===t.inputs.length?i=!0:(tt(!n||t.payable!==n.payable,"conflicting fallback fragments",`fragments[${e}]`,t),n=t,i=n.payable));case"function":r=this.#V;break;case"event":r=this.#j;break;case"error":r=this.#G;break;default:return}const s=t.format();r.has(s)||r.set(s,t)})),this.deploy||J(this,{deploy:Kr.from("constructor()")}),J(this,{fallback:n,receive:i})}format(t){const e=t?"minimal":"full";return this.fragments.map((t=>t.format(e)))}formatJson(){const t=this.fragments.map((t=>t.format("json")));return JSON.stringify(t.map((t=>JSON.parse(t))))}getAbiCoder(){return $r.defaultAbiCoder()}#Q(t,e,r){if(at(t)){const e=t.toLowerCase();for(const t of this.#V.values())if(e===t.selector)return t;return null}if(-1===t.indexOf("(")){const n=[];for(const[e,r]of this.#V)e.split("(")[0]===t&&n.push(r);if(e){const t=e.length>0?e[e.length-1]:null;let r=e.length,i=!0;Re.isTyped(t)&&"overrides"===t.type&&(i=!1,r--);for(let t=n.length-1;t>=0;t--){const e=n[t].inputs.length;e===r||i&&e===r-1||n.splice(t,1)}for(let t=n.length-1;t>=0;t--){const r=n[t].inputs;for(let i=0;i<e.length;i++)if(Re.isTyped(e[i])){if(i>=r.length){if("overrides"===e[i].type)continue;n.splice(t,1);break}if(e[i].type!==r[i].baseType){n.splice(t,1);break}}}}if(1===n.length&&e&&e.length!==n[0].inputs.length){const t=e[e.length-1];(null==t||Array.isArray(t)||"object"!=typeof t)&&n.splice(0,1)}return 0===n.length?null:(n.length>1&&r&&tt(!1,`ambiguous function description (i.e. matches ${n.map((t=>JSON.stringify(t.format()))).join(", ")})`,"key",t),n[0])}return this.#V.get(Wr.from(t).format())||null}getFunctionName(t){const e=this.#Q(t,null,!1);return tt(e,"no matching function","key",t),e.name}hasFunction(t){return!!this.#Q(t,null,!1)}getFunction(t,e){return this.#Q(t,e||null,!0)}forEachFunction(t){const e=Array.from(this.#V.keys());e.sort(((t,e)=>t.localeCompare(e)));for(let r=0;r<e.length;r++){const n=e[r];t(this.#V.get(n),r)}}#W(t,e,r){if(at(t)){const e=t.toLowerCase();for(const t of this.#j.values())if(e===t.topicHash)return t;return null}if(-1===t.indexOf("(")){const n=[];for(const[e,r]of this.#j)e.split("(")[0]===t&&n.push(r);if(e){for(let t=n.length-1;t>=0;t--)n[t].inputs.length<e.length&&n.splice(t,1);for(let t=n.length-1;t>=0;t--){const r=n[t].inputs;for(let i=0;i<e.length;i++)if(Re.isTyped(e[i])&&e[i].type!==r[i].baseType){n.splice(t,1);break}}}return 0===n.length?null:(n.length>1&&r&&tt(!1,`ambiguous event description (i.e. matches ${n.map((t=>JSON.stringify(t.format()))).join(", ")})`,"key",t),n[0])}return this.#j.get(Vr.from(t).format())||null}getEventName(t){const e=this.#W(t,null,!1);return tt(e,"no matching event","key",t),e.name}hasEvent(t){return!!this.#W(t,null,!1)}getEvent(t,e){return this.#W(t,e||null,!0)}forEachEvent(t){const e=Array.from(this.#j.keys());e.sort(((t,e)=>t.localeCompare(e)));for(let r=0;r<e.length;r++){const n=e[r];t(this.#j.get(n),r)}}getError(t,e){if(at(t)){const e=t.toLowerCase();if(Gn[e])return jr.from(Gn[e].signature);for(const t of this.#G.values())if(e===t.selector)return t;return null}if(-1===t.indexOf("(")){const e=[];for(const[r,n]of this.#G)r.split("(")[0]===t&&e.push(n);return 0===e.length?"Error"===t?jr.from("error Error(string)"):"Panic"===t?jr.from("error Panic(uint256)"):null:(e.length>1&&tt(!1,`ambiguous error description (i.e. ${e.map((t=>JSON.stringify(t.format()))).join(", ")})`,"name",t),e[0])}if("Error(string)"===(t=jr.from(t).format()))return jr.from("error Error(string)");if("Panic(uint256)"===t)return jr.from("error Panic(uint256)");return this.#G.get(t)||null}forEachError(t){const e=Array.from(this.#G.keys());e.sort(((t,e)=>t.localeCompare(e)));for(let r=0;r<e.length;r++){const n=e[r];t(this.#G.get(n),r)}}_decodeParams(t,e){return this.#K.decode(t,e)}_encodeParams(t,e){return this.#K.encode(t,e)}encodeDeploy(t){return this._encodeParams(this.deploy.inputs,t||[])}decodeErrorResult(t,e){if("string"==typeof t){const e=this.getError(t);tt(e,"unknown error","fragment",t),t=e}return tt(pt(e,0,4)===t.selector,`data signature does not match error ${t.name}.`,"data",e),this._decodeParams(t.inputs,pt(e,4))}encodeErrorResult(t,e){if("string"==typeof t){const e=this.getError(t);tt(e,"unknown error","fragment",t),t=e}return ft([t.selector,this._encodeParams(t.inputs,e||[])])}decodeFunctionData(t,e){if("string"==typeof t){const e=this.getFunction(t);tt(e,"unknown function","fragment",t),t=e}return tt(pt(e,0,4)===t.selector,`data signature does not match function ${t.name}.`,"data",e),this._decodeParams(t.inputs,pt(e,4))}encodeFunctionData(t,e){if("string"==typeof t){const e=this.getFunction(t);tt(e,"unknown function","fragment",t),t=e}return ft([t.selector,this._encodeParams(t.inputs,e||[])])}decodeFunctionResult(t,e){if("string"==typeof t){const e=this.getFunction(t);tt(e,"unknown function","fragment",t),t=e}let r="invalid length for result data";const n=ot(e);if(n.length%32==0)try{return this.#K.decode(t.outputs,n)}catch(t){r="could not decode result data"}$(!1,r,"BAD_DATA",{value:lt(n),info:{method:t.name,signature:t.format()}})}makeError(t,e){const r=st(t,"data"),n=$r.getBuiltinCallException("call",e,r);if(n.message.startsWith("execution reverted (unknown custom error)")){const t=lt(r.slice(0,4)),e=this.getError(t);if(e)try{const t=this.#K.decode(e.inputs,r.slice(4));n.revert={name:e.name,signature:e.format(),args:t},n.reason=n.revert.signature,n.message=`execution reverted: ${n.reason}`}catch(t){n.message="execution reverted (coult not decode custom error)"}}const i=this.parseTransaction(e);return i&&(n.invocation={method:i.name,signature:i.signature,args:i.args}),n}encodeFunctionResult(t,e){if("string"==typeof t){const e=this.getFunction(t);tt(e,"unknown function","fragment",t),t=e}return lt(this.#K.encode(t.outputs,e||[]))}encodeFilterTopics(t,e){if("string"==typeof t){const e=this.getEvent(t);tt(e,"unknown event","eventFragment",t),t=e}$(e.length<=t.inputs.length,`too many arguments for ${t.format()}`,"UNEXPECTED_ARGUMENT",{count:e.length,expectedCount:t.inputs.length});const r=[];t.anonymous||r.push(t.topicHash);const n=(t,e)=>"string"===t.type?rr(e):"bytes"===t.type?ve(lt(e)):("bool"===t.type&&"boolean"==typeof e?e=e?"0x01":"0x00":t.type.match(/^u?int/)?e=Tt(e):t.type.match(/^bytes/)?e=dt(e,32,!1):"address"===t.type&&this.#K.encode(["address"],[e]),gt(lt(e),32));for(e.forEach(((e,i)=>{const s=t.inputs[i];s.indexed?null==e?r.push(null):"array"===s.baseType||"tuple"===s.baseType?tt(!1,"filtering with tuples or arrays not supported","contract."+s.name,e):Array.isArray(e)?r.push(e.map((t=>n(s,t)))):r.push(n(s,e)):tt(null==e,"cannot filter non-indexed parameters; must be null","contract."+s.name,e)}));r.length&&null===r[r.length-1];)r.pop();return r}encodeEventLog(t,e){if("string"==typeof t){const e=this.getEvent(t);tt(e,"unknown event","eventFragment",t),t=e}const r=[],n=[],i=[];return t.anonymous||r.push(t.topicHash),tt(e.length===t.inputs.length,"event arguments/values mismatch","values",e),t.inputs.forEach(((t,s)=>{const o=e[s];if(t.indexed)if("string"===t.type)r.push(rr(o));else if("bytes"===t.type)r.push(ve(o));else{if("tuple"===t.baseType||"array"===t.baseType)throw new Error("not implemented");r.push(this.#K.encode([t.type],[o]))}else n.push(t),i.push(o)})),{data:this.#K.encode(n,i),topics:r}}decodeEventLog(t,e,r){if("string"==typeof t){const e=this.getEvent(t);tt(e,"unknown event","eventFragment",t),t=e}if(null!=r&&!t.anonymous){const e=t.topicHash;tt(at(r[0],32)&&r[0].toLowerCase()===e,"fragment/topic mismatch","topics[0]",r[0]),r=r.slice(1)}const n=[],i=[],s=[];t.inputs.forEach(((t,e)=>{t.indexed?"string"===t.type||"bytes"===t.type||"tuple"===t.baseType||"array"===t.baseType?(n.push(Dr.from({type:"bytes32",name:t.name})),s.push(!0)):(n.push(t),s.push(!1)):(i.push(t),s.push(!1))}));const o=null!=r?this.#K.decode(n,ft(r)):null,a=this.#K.decode(i,e,!0),u=[],c=[];let l=0,f=0;return t.inputs.forEach(((t,e)=>{let r=null;if(t.indexed)if(null==o)r=new Hn(null);else if(s[e])r=new Hn(o[f++]);else try{r=o[f++]}catch(t){r=t}else try{r=a[l++]}catch(t){r=t}u.push(r),c.push(t.name||null)})),Rt.fromItems(u,c)}parseTransaction(t){const e=st(t.data,"tx.data"),r=Et(null!=t.value?t.value:0,"tx.value"),n=this.getFunction(lt(e.slice(0,4)));if(!n)return null;const i=this.#K.decode(n.inputs,e.slice(4));return new Fn(n,n.selector,i,r)}parseCallResult(t){throw new Error("@TODO")}parseLog(t){const e=this.getEvent(t.topics[0]);return!e||e.anonymous?null:new Ln(e,e.topicHash,this.decodeEventLog(e,t.data,t.topics))}parseError(t){const e=lt(t),r=this.getError(pt(e,0,4));if(!r)return null;const n=this.#K.decode(r.inputs,pt(e,4));return new Dn(r,r.selector,n)}static from(t){return t instanceof jn?t:"string"==typeof t?new jn(JSON.parse(t)):"function"==typeof t.formatJson?new jn(t.formatJson()):"function"==typeof t.format?new jn(t.format("json")):new jn(t)}}const Vn=BigInt(0);function Kn(t){return null==t?null:t}function Qn(t){return null==t?null:t.toString()}class Wn{gasPrice;maxFeePerGas;maxPriorityFeePerGas;constructor(t,e,r){J(this,{gasPrice:Kn(t),maxFeePerGas:Kn(e),maxPriorityFeePerGas:Kn(r)})}toJSON(){const{gasPrice:t,maxFeePerGas:e,maxPriorityFeePerGas:r}=this;return{_type:"FeeData",gasPrice:Qn(t),maxFeePerGas:Qn(e),maxPriorityFeePerGas:Qn(r)}}}function zn(t){const e={};t.to&&(e.to=t.to),t.from&&(e.from=t.from),t.data&&(e.data=lt(t.data));const r="chainId,gasLimit,gasPrice,maxFeePerBlobGas,maxFeePerGas,maxPriorityFeePerGas,value".split(/,/);for(const n of r)n in t&&null!=t[n]&&(e[n]=Et(t[n],`request.${n}`));const n="type,nonce".split(/,/);for(const r of n)r in t&&null!=t[r]&&(e[r]=kt(t[r],`request.${r}`));return t.accessList&&(e.accessList=An(t.accessList)),"blockTag"in t&&(e.blockTag=t.blockTag),"enableCcipRead"in t&&(e.enableCcipRead=!!t.enableCcipRead),"customData"in t&&(e.customData=t.customData),"blobVersionedHashes"in t&&t.blobVersionedHashes&&(e.blobVersionedHashes=t.blobVersionedHashes.slice()),"kzg"in t&&(e.kzg=t.kzg),"blobs"in t&&t.blobs&&(e.blobs=t.blobs.map((t=>ut(t)?lt(t):Object.assign({},t)))),e}class Jn{provider;number;hash;timestamp;parentHash;parentBeaconBlockRoot;nonce;difficulty;gasLimit;gasUsed;stateRoot;receiptsRoot;blobGasUsed;excessBlobGas;miner;prevRandao;extraData;baseFeePerGas;#z;constructor(t,e){this.#z=t.transactions.map((t=>"string"!=typeof t?new Yn(t,e):t)),J(this,{provider:e,hash:Kn(t.hash),number:t.number,timestamp:t.timestamp,parentHash:t.parentHash,parentBeaconBlockRoot:t.parentBeaconBlockRoot,nonce:t.nonce,difficulty:t.difficulty,gasLimit:t.gasLimit,gasUsed:t.gasUsed,blobGasUsed:t.blobGasUsed,excessBlobGas:t.excessBlobGas,miner:t.miner,prevRandao:Kn(t.prevRandao),extraData:t.extraData,baseFeePerGas:Kn(t.baseFeePerGas),stateRoot:t.stateRoot,receiptsRoot:t.receiptsRoot})}get transactions(){return this.#z.map((t=>"string"==typeof t?t:t.hash))}get prefetchedTransactions(){const t=this.#z.slice();return 0===t.length?[]:($("object"==typeof t[0],"transactions were not prefetched with block request","UNSUPPORTED_OPERATION",{operation:"transactionResponses()"}),t)}toJSON(){const{baseFeePerGas:t,difficulty:e,extraData:r,gasLimit:n,gasUsed:i,hash:s,miner:o,prevRandao:a,nonce:u,number:c,parentHash:l,parentBeaconBlockRoot:f,stateRoot:h,receiptsRoot:p,timestamp:d,transactions:g}=this;return{_type:"Block",baseFeePerGas:Qn(t),difficulty:Qn(e),extraData:r,gasLimit:Qn(n),gasUsed:Qn(i),blobGasUsed:Qn(this.blobGasUsed),excessBlobGas:Qn(this.excessBlobGas),hash:s,miner:o,prevRandao:a,nonce:u,number:c,parentHash:l,timestamp:d,parentBeaconBlockRoot:f,stateRoot:h,receiptsRoot:p,transactions:g}}[Symbol.iterator](){let t=0;const e=this.transactions;return{next:()=>t<this.length?{value:e[t++],done:!1}:{value:void 0,done:!0}}}get length(){return this.#z.length}get date(){return null==this.timestamp?null:new Date(1e3*this.timestamp)}async getTransaction(t){let e;if("number"==typeof t)e=this.#z[t];else{const r=t.toLowerCase();for(const t of this.#z){if("string"==typeof t){if(t!==r)continue;e=t;break}if(t.hash!==r){e=t;break}}}if(null==e)throw new Error("no such tx");return"string"==typeof e?await this.provider.getTransaction(e):e}getPrefetchedTransaction(t){const e=this.prefetchedTransactions;if("number"==typeof t)return e[t];t=t.toLowerCase();for(const r of e)if(r.hash===t)return r;tt(!1,"no matching transaction","indexOrHash",t)}isMined(){return!!this.hash}isLondon(){return!!this.baseFeePerGas}orphanedEvent(){if(!this.isMined())throw new Error("");return{orphan:"drop-block",hash:this.hash,number:this.number}}}class qn{provider;transactionHash;blockHash;blockNumber;removed;address;data;topics;index;transactionIndex;constructor(t,e){this.provider=e;const r=Object.freeze(t.topics.slice());J(this,{transactionHash:t.transactionHash,blockHash:t.blockHash,blockNumber:t.blockNumber,removed:t.removed,address:t.address,data:t.data,topics:r,index:t.index,transactionIndex:t.transactionIndex})}toJSON(){const{address:t,blockHash:e,blockNumber:r,data:n,index:i,removed:s,topics:o,transactionHash:a,transactionIndex:u}=this;return{_type:"log",address:t,blockHash:e,blockNumber:r,data:n,index:i,removed:s,topics:o,transactionHash:a,transactionIndex:u}}async getBlock(){const t=await this.provider.getBlock(this.blockHash);return $(!!t,"failed to find transaction","UNKNOWN_ERROR",{}),t}async getTransaction(){const t=await this.provider.getTransaction(this.transactionHash);return $(!!t,"failed to find transaction","UNKNOWN_ERROR",{}),t}async getTransactionReceipt(){const t=await this.provider.getTransactionReceipt(this.transactionHash);return $(!!t,"failed to find transaction receipt","UNKNOWN_ERROR",{}),t}removedEvent(){return{orphan:"drop-log",log:{transactionHash:(t=this).transactionHash,blockHash:t.blockHash,blockNumber:t.blockNumber,address:t.address,data:t.data,topics:Object.freeze(t.topics.slice()),index:t.index}};var t}}class Xn{provider;to;from;contractAddress;hash;index;blockHash;blockNumber;logsBloom;gasUsed;blobGasUsed;cumulativeGasUsed;gasPrice;blobGasPrice;type;status;root;#J;constructor(t,e){this.#J=Object.freeze(t.logs.map((t=>new qn(t,e))));let r=Vn;null!=t.effectiveGasPrice?r=t.effectiveGasPrice:null!=t.gasPrice&&(r=t.gasPrice),J(this,{provider:e,to:t.to,from:t.from,contractAddress:t.contractAddress,hash:t.hash,index:t.index,blockHash:t.blockHash,blockNumber:t.blockNumber,logsBloom:t.logsBloom,gasUsed:t.gasUsed,cumulativeGasUsed:t.cumulativeGasUsed,blobGasUsed:t.blobGasUsed,gasPrice:r,blobGasPrice:t.blobGasPrice,type:t.type,status:t.status,root:t.root})}get logs(){return this.#J}toJSON(){const{to:t,from:e,contractAddress:r,hash:n,index:i,blockHash:s,blockNumber:o,logsBloom:a,logs:u,status:c,root:l}=this;return{_type:"TransactionReceipt",blockHash:s,blockNumber:o,contractAddress:r,cumulativeGasUsed:Qn(this.cumulativeGasUsed),from:e,gasPrice:Qn(this.gasPrice),blobGasUsed:Qn(this.blobGasUsed),blobGasPrice:Qn(this.blobGasPrice),gasUsed:Qn(this.gasUsed),hash:n,index:i,logs:u,logsBloom:a,root:l,status:c,to:t}}get length(){return this.logs.length}[Symbol.iterator](){let t=0;return{next:()=>t<this.length?{value:this.logs[t++],done:!1}:{value:void 0,done:!0}}}get fee(){return this.gasUsed*this.gasPrice}async getBlock(){const t=await this.provider.getBlock(this.blockHash);if(null==t)throw new Error("TODO");return t}async getTransaction(){const t=await this.provider.getTransaction(this.hash);if(null==t)throw new Error("TODO");return t}async getResult(){return await this.provider.getTransactionResult(this.hash)}async confirmations(){return await this.provider.getBlockNumber()-this.blockNumber+1}removedEvent(){return $n(this)}reorderedEvent(t){return $(!t||t.isMined(),"unmined 'other' transction cannot be orphaned","UNSUPPORTED_OPERATION",{operation:"reorderedEvent(other)"}),Zn(this,t)}}class Yn{provider;blockNumber;blockHash;index;hash;type;to;from;nonce;gasLimit;gasPrice;maxPriorityFeePerGas;maxFeePerGas;maxFeePerBlobGas;data;value;chainId;signature;accessList;blobVersionedHashes;#q;constructor(t,e){this.provider=e,this.blockNumber=null!=t.blockNumber?t.blockNumber:null,this.blockHash=null!=t.blockHash?t.blockHash:null,this.hash=t.hash,this.index=t.index,this.type=t.type,this.from=t.from,this.to=t.to||null,this.gasLimit=t.gasLimit,this.nonce=t.nonce,this.data=t.data,this.value=t.value,this.gasPrice=t.gasPrice,this.maxPriorityFeePerGas=null!=t.maxPriorityFeePerGas?t.maxPriorityFeePerGas:null,this.maxFeePerGas=null!=t.maxFeePerGas?t.maxFeePerGas:null,this.maxFeePerBlobGas=null!=t.maxFeePerBlobGas?t.maxFeePerBlobGas:null,this.chainId=t.chainId,this.signature=t.signature,this.accessList=null!=t.accessList?t.accessList:null,this.blobVersionedHashes=null!=t.blobVersionedHashes?t.blobVersionedHashes:null,this.#q=-1}toJSON(){const{blockNumber:t,blockHash:e,index:r,hash:n,type:i,to:s,from:o,nonce:a,data:u,signature:c,accessList:l,blobVersionedHashes:f}=this;return{_type:"TransactionResponse",accessList:l,blockNumber:t,blockHash:e,blobVersionedHashes:f,chainId:Qn(this.chainId),data:u,from:o,gasLimit:Qn(this.gasLimit),gasPrice:Qn(this.gasPrice),hash:n,maxFeePerGas:Qn(this.maxFeePerGas),maxPriorityFeePerGas:Qn(this.maxPriorityFeePerGas),maxFeePerBlobGas:Qn(this.maxFeePerBlobGas),nonce:a,signature:c,to:s,index:r,type:i,value:Qn(this.value)}}async getBlock(){let t=this.blockNumber;if(null==t){const e=await this.getTransaction();e&&(t=e.blockNumber)}if(null==t)return null;const e=this.provider.getBlock(t);if(null==e)throw new Error("TODO");return e}async getTransaction(){return this.provider.getTransaction(this.hash)}async confirmations(){if(null==this.blockNumber){const{tx:t,blockNumber:e}=await z({tx:this.getTransaction(),blockNumber:this.provider.getBlockNumber()});return null==t||null==t.blockNumber?0:e-t.blockNumber+1}return await this.provider.getBlockNumber()-this.blockNumber+1}async wait(t,e){const r=null==t?1:t,n=null==e?0:e;let i=this.#q,s=-1,o=-1===i;const a=async()=>{if(o)return null;const{blockNumber:t,nonce:e}=await z({blockNumber:this.provider.getBlockNumber(),nonce:this.provider.getTransactionCount(this.from)});if(e<this.nonce)return void(i=t);if(o)return null;const n=await this.getTransaction();if(!n||null==n.blockNumber)for(-1===s&&(s=i-3,s<this.#q&&(s=this.#q));s<=t;){if(o)return null;const e=await this.provider.getBlock(s,!0);if(null==e)return;for(const t of e)if(t===this.hash)return;for(let n=0;n<e.length;n++){const s=await e.getTransaction(n);if(s.from===this.from&&s.nonce===this.nonce){if(o)return null;const e=await this.provider.getTransactionReceipt(s.hash);if(null==e)return;if(t-e.blockNumber+1<r)return;let n="replaced";s.data===this.data&&s.to===this.to&&s.value===this.value?n="repriced":"0x"===s.data&&s.from===s.to&&s.value===Vn&&(n="cancelled"),$(!1,"transaction was replaced","TRANSACTION_REPLACED",{cancelled:"replaced"===n||"cancelled"===n,reason:n,replacement:s.replaceableTransaction(i),hash:s.hash,receipt:e})}}s++}},u=t=>{if(null==t||0!==t.status)return t;$(!1,"transaction execution reverted","CALL_EXCEPTION",{action:"sendTransaction",data:null,reason:null,invocation:null,revert:null,transaction:{to:t.to,from:t.from,data:""},receipt:t})},c=await this.provider.getTransactionReceipt(this.hash);if(0===r)return u(c);if(c){if(await c.confirmations()>=r)return u(c)}else if(await a(),0===r)return null;const l=new Promise(((t,e)=>{const s=[],c=()=>{s.forEach((t=>t()))};if(s.push((()=>{o=!0})),n>0){const t=setTimeout((()=>{c(),e(Z("wait for transaction timeout","TIMEOUT"))}),n);s.push((()=>{clearTimeout(t)}))}const l=async n=>{if(await n.confirmations()>=r){c();try{t(u(n))}catch(t){e(t)}}};if(s.push((()=>{this.provider.off(this.hash,l)})),this.provider.on(this.hash,l),i>=0){const t=async()=>{try{await a()}catch(t){if(X(t,"TRANSACTION_REPLACED"))return c(),void e(t)}o||this.provider.once("block",t)};s.push((()=>{this.provider.off("block",t)})),this.provider.once("block",t)}}));return await l}isMined(){return null!=this.blockHash}isLegacy(){return 0===this.type}isBerlin(){return 1===this.type}isLondon(){return 2===this.type}isCancun(){return 3===this.type}removedEvent(){return $(this.isMined(),"unmined transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),$n(this)}reorderedEvent(t){return $(this.isMined(),"unmined transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),$(!t||t.isMined(),"unmined 'other' transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),Zn(this,t)}replaceableTransaction(t){tt(Number.isInteger(t)&&t>=0,"invalid startBlock","startBlock",t);const e=new Yn(this,this.provider);return e.#q=t,e}}function Zn(t,e){return{orphan:"reorder-transaction",tx:t,other:e}}function $n(t){return{orphan:"drop-transaction",tx:t}}class ti{filter;emitter;#X;constructor(t,e,r){this.#X=e,J(this,{emitter:t,filter:r})}async removeListener(){null!=this.#X&&await this.emitter.off(this.filter,this.#X)}}class ei extends qn{interface;fragment;args;constructor(t,e,r){super(t,t.provider),J(this,{args:e.decodeEventLog(r,t.data,t.topics),fragment:r,interface:e})}get eventName(){return this.fragment.name}get eventSignature(){return this.fragment.format()}}class ri extends qn{error;constructor(t,e){super(t,t.provider),J(this,{error:e})}}class ni extends Xn{#Y;constructor(t,e,r){super(r,e),this.#Y=t}get logs(){return super.logs.map((t=>{const e=t.topics.length?this.#Y.getEvent(t.topics[0]):null;if(e)try{return new ei(t,this.#Y,e)}catch(e){return new ri(t,e)}return t}))}}class ii extends Yn{#Y;constructor(t,e,r){super(r,e),this.#Y=t}async wait(t,e){const r=await super.wait(t,e);return null==r?null:new ni(this.#Y,this.provider,r)}}class si extends ti{log;constructor(t,e,r,n){super(t,e,r),J(this,{log:n})}async getBlock(){return await this.log.getBlock()}async getTransaction(){return await this.log.getTransaction()}async getTransactionReceipt(){return await this.log.getTransactionReceipt()}}class oi extends si{constructor(t,e,r,n,i){super(t,e,r,new ei(i,t.interface,n)),J(this,{args:t.interface.decodeEventLog(n,this.log.data,this.log.topics),fragment:n})}get eventName(){return this.fragment.name}get eventSignature(){return this.fragment.format()}}const ai=BigInt(0);function ui(t){return t&&"function"==typeof t.call}function ci(t){return t&&"function"==typeof t.estimateGas}function li(t){return t&&"function"==typeof t.resolveName}function fi(t){return t&&"function"==typeof t.sendTransaction}function hi(t){if(null!=t){if(li(t))return t;if(t.provider)return t.provider}}class pi{#Z;fragment;constructor(t,e,r){if(J(this,{fragment:e}),e.inputs.length<r.length)throw new Error("too many arguments");const n=di(t.runner,"resolveName"),i=li(n)?n:null;this.#Z=async function(){const n=await Promise.all(e.inputs.map(((t,e)=>null==r[e]?null:t.walkAsync(r[e],((t,e)=>"address"===t?Array.isArray(e)?Promise.all(e.map((t=>rn(t,i)))):rn(e,i):e)))));return t.interface.encodeFilterTopics(e,n)}()}getTopicFilter(){return this.#Z}}function di(t,e){return null==t?null:"function"==typeof t[e]?t:t.provider&&"function"==typeof t.provider[e]?t.provider:null}function gi(t){return null==t?null:t.provider||null}async function yi(t,e){const r=Re.dereference(t,"overrides");tt("object"==typeof r,"invalid overrides parameter","overrides",t);const n=zn(r);return tt(null==n.to||(e||[]).indexOf("to")>=0,"cannot override to","overrides.to",n.to),tt(null==n.data||(e||[]).indexOf("data")>=0,"cannot override data","overrides.data",n.data),n.from&&(n.from=n.from),n}function wi(t){const e=async function(e){const r=await yi(e,["data"]);r.to=await t.getAddress(),r.from&&(r.from=await rn(r.from,hi(t.runner)));const n=t.interface,i=Et(r.value||ai,"overrides.value")===ai,s="0x"===(r.data||"0x");return!n.fallback||n.fallback.payable||!n.receive||s||i||tt(!1,"cannot send data to receive or send value to non-payable fallback","overrides",e),tt(n.fallback||s,"cannot send data to receive-only contract","overrides.data",r.data),tt(n.receive||n.fallback&&n.fallback.payable||i,"cannot send value to non-payable fallback","overrides.value",r.value),tt(n.fallback||s,"cannot send data to receive-only contract","overrides.data",r.data),r},r=async function(r){const n=t.runner;$(fi(n),"contract runner does not support sending transactions","UNSUPPORTED_OPERATION",{operation:"sendTransaction"});const i=await n.sendTransaction(await e(r)),s=gi(t.runner);return new ii(t.interface,s,i)},n=async t=>await r(t);return J(n,{_contract:t,estimateGas:async function(r){const n=di(t.runner,"estimateGas");return $(ci(n),"contract runner does not support gas estimation","UNSUPPORTED_OPERATION",{operation:"estimateGas"}),await n.estimateGas(await e(r))},populateTransaction:e,send:r,staticCall:async function(r){const n=di(t.runner,"call");$(ui(n),"contract runner does not support calling","UNSUPPORTED_OPERATION",{operation:"call"});const i=await e(r);try{return await n.call(i)}catch(e){if(Y(e)&&e.data)throw t.interface.makeError(e.data,i);throw e}}}),n}const mi=Symbol.for("_ethersInternal_contract"),bi=new WeakMap;function Ai(t){return bi.get(t[mi])}async function Ei(t,e){let r,n=null;if(Array.isArray(e)){const n=function(e){if(at(e,32))return e;const r=t.interface.getEvent(e);return tt(r,"unknown fragment","name",e),r.topicHash};r=e.map((t=>null==t?null:Array.isArray(t)?t.map(n):n(t)))}else"*"===e?r=[null]:"string"==typeof e?at(e,32)?r=[e]:(n=t.interface.getEvent(e),tt(n,"unknown fragment","event",e),r=[n.topicHash]):(i=e)&&"object"==typeof i&&"getTopicFilter"in i&&"function"==typeof i.getTopicFilter&&i.fragment?r=await e.getTopicFilter():"fragment"in e?(n=e.fragment,r=[n.topicHash]):tt(!1,"unknown event name","event",e);var i;return r=r.map((t=>{if(null==t)return null;if(Array.isArray(t)){const e=Array.from(new Set(t.map((t=>t.toLowerCase()))).values());return 1===e.length?e[0]:(e.sort(),e)}return t.toLowerCase()})),{fragment:n,tag:r.map((t=>null==t?"null":Array.isArray(t)?t.join("|"):t)).join("&"),topics:r}}async function vi(t,e){const{subs:r}=Ai(t);return r.get((await Ei(t,e)).tag)||null}async function Si(t,e,r){const n=gi(t.runner);$(n,"contract runner does not support subscribing","UNSUPPORTED_OPERATION",{operation:e});const{fragment:i,tag:s,topics:o}=await Ei(t,r),{addr:a,subs:u}=Ai(t);let c=u.get(s);if(!c){const e={address:a||t,topics:o},l=e=>{let n=i;if(null==n)try{n=t.interface.getEvent(e.topics[0])}catch(t){}if(n){const s=n,o=i?t.interface.decodeEventLog(i,e.data,e.topics):[];ki(t,r,o,(n=>new oi(t,n,r,s,e)))}else ki(t,r,[],(n=>new si(t,n,r,e)))};let f=[];c={tag:s,listeners:[],start:()=>{f.length||f.push(n.on(e,l))},stop:async()=>{if(0==f.length)return;let t=f;f=[],await Promise.all(t),n.off(e,l)}},u.set(s,c)}return c}let Ii=Promise.resolve();async function ki(t,e,r,n){try{await Ii}catch(t){}const i=async function(t,e,r,n){await Ii;const i=await vi(t,e);if(!i)return!1;const s=i.listeners.length;return i.listeners=i.listeners.filter((({listener:e,once:i})=>{const s=Array.from(r);n&&s.push(n(i?null:e));try{e.call(t,...s)}catch(t){}return!i})),0===i.listeners.length&&(i.stop(),Ai(t).subs.delete(i.tag)),s>0}(t,e,r,n);return Ii=i,await i}const Ti=["then"];class Pi{target;interface;runner;filters;[mi];fallback;constructor(t,e,r,n){tt("string"==typeof t||tn(t),"invalid value for Contract target","target",t),null==r&&(r=null);const i=jn.from(e);let s;J(this,{target:t,runner:r,interface:i}),Object.defineProperty(this,mi,{value:{}});let o=null,a=null;if(n){const t=gi(r);a=new ii(this.interface,t,n)}let u=new Map;if("string"==typeof t)if(at(t))o=t,s=Promise.resolve(t);else{const e=di(r,"resolveName");if(!li(e))throw Z("contract runner does not support name resolution","UNSUPPORTED_OPERATION",{operation:"resolveName"});s=e.resolveName(t).then((e=>{if(null==e)throw Z("an ENS name used for a contract target must be correctly configured","UNCONFIGURED_NAME",{value:t});return Ai(this).addr=e,e}))}else s=t.getAddress().then((t=>{if(null==t)throw new Error("TODO");return Ai(this).addr=t,t}));var c;c={addrPromise:s,addr:o,deployTx:a,subs:u},bi.set(this[mi],c);const l=new Proxy({},{get:(t,e,r)=>{if("symbol"==typeof e||Ti.indexOf(e)>=0)return Reflect.get(t,e,r);try{return this.getEvent(e)}catch(t){if(!X(t,"INVALID_ARGUMENT")||"key"!==t.argument)throw t}},has:(t,e)=>Ti.indexOf(e)>=0?Reflect.has(t,e):Reflect.has(t,e)||this.interface.hasEvent(String(e))});return J(this,{filters:l}),J(this,{fallback:i.receive||i.fallback?wi(this):null}),new Proxy(this,{get:(t,e,r)=>{if("symbol"==typeof e||e in t||Ti.indexOf(e)>=0)return Reflect.get(t,e,r);try{return t.getFunction(e)}catch(t){if(!X(t,"INVALID_ARGUMENT")||"key"!==t.argument)throw t}},has:(t,e)=>"symbol"==typeof e||e in t||Ti.indexOf(e)>=0?Reflect.has(t,e):t.interface.hasFunction(e)})}connect(t){return new Pi(this.target,this.interface,t)}attach(t){return new Pi(t,this.interface,this.runner)}async getAddress(){return await Ai(this).addrPromise}async getDeployedCode(){const t=gi(this.runner);$(t,"runner does not support .provider","UNSUPPORTED_OPERATION",{operation:"getDeployedCode"});const e=await t.getCode(await this.getAddress());return"0x"===e?null:e}async waitForDeployment(){const t=this.deploymentTransaction();if(t)return await t.wait(),this;if(null!=await this.getDeployedCode())return this;const e=gi(this.runner);return $(null!=e,"contract runner does not support .provider","UNSUPPORTED_OPERATION",{operation:"waitForDeployment"}),new Promise(((t,r)=>{const n=async()=>{try{if(null!=await this.getDeployedCode())return t(this);e.once("block",n)}catch(t){r(t)}};n()}))}deploymentTransaction(){return Ai(this).deployTx}getFunction(t){return"string"!=typeof t&&(t=t.format()),function(t,e){const r=function(...r){const n=t.interface.getFunction(e,r);return $(n,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:e,args:r}}),n},n=async function(...e){const n=r(...e);let i={};if(n.inputs.length+1===e.length&&(i=await yi(e.pop()),i.from&&(i.from=await rn(i.from,hi(t.runner)))),n.inputs.length!==e.length)throw new Error("internal error: fragment inputs doesn't match arguments; should not happen");const s=await async function(t,e,r){const n=di(t,"resolveName"),i=li(n)?n:null;return await Promise.all(e.map(((t,e)=>t.walkAsync(r[e],((t,e)=>(e=Re.dereference(e,t),"address"===t?rn(e,i):e))))))}(t.runner,n.inputs,e);return Object.assign({},i,await z({to:t.getAddress(),data:t.interface.encodeFunctionData(n,s)}))},i=async function(...t){const e=await o(...t);return 1===e.length?e[0]:e},s=async function(...e){const r=t.runner;$(fi(r),"contract runner does not support sending transactions","UNSUPPORTED_OPERATION",{operation:"sendTransaction"});const i=await r.sendTransaction(await n(...e)),s=gi(t.runner);return new ii(t.interface,s,i)},o=async function(...e){const i=di(t.runner,"call");$(ui(i),"contract runner does not support calling","UNSUPPORTED_OPERATION",{operation:"call"});const s=await n(...e);let o="0x";try{o=await i.call(s)}catch(e){if(Y(e)&&e.data)throw t.interface.makeError(e.data,s);throw e}const a=r(...e);return t.interface.decodeFunctionResult(a,o)},a=async(...t)=>r(...t).constant?await i(...t):await s(...t);return J(a,{name:t.interface.getFunctionName(e),_contract:t,_key:e,getFragment:r,estimateGas:async function(...e){const r=di(t.runner,"estimateGas");return $(ci(r),"contract runner does not support gas estimation","UNSUPPORTED_OPERATION",{operation:"estimateGas"}),await r.estimateGas(await n(...e))},populateTransaction:n,send:s,staticCall:i,staticCallResult:o}),Object.defineProperty(a,"fragment",{configurable:!1,enumerable:!0,get:()=>{const r=t.interface.getFunction(e);return $(r,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:e}}),r}}),a}(this,t)}getEvent(t){return"string"!=typeof t&&(t=t.format()),function(t,e){const r=function(...r){const n=t.interface.getEvent(e,r);return $(n,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:e,args:r}}),n},n=function(...e){return new pi(t,r(...e),e)};return J(n,{name:t.interface.getEventName(e),_contract:t,_key:e,getFragment:r}),Object.defineProperty(n,"fragment",{configurable:!1,enumerable:!0,get:()=>{const r=t.interface.getEvent(e);return $(r,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:e}}),r}}),n}(this,t)}async queryTransaction(t){throw new Error("@TODO")}async queryFilter(t,e,r){null==e&&(e=0),null==r&&(r="latest");const{addr:n,addrPromise:i}=Ai(this),s=n||await i,{fragment:o,topics:a}=await Ei(this,t),u={address:s,topics:a,fromBlock:e,toBlock:r},c=gi(this.runner);return $(c,"contract runner does not have a provider","UNSUPPORTED_OPERATION",{operation:"queryFilter"}),(await c.getLogs(u)).map((t=>{let e=o;if(null==e)try{e=this.interface.getEvent(t.topics[0])}catch(t){}if(e)try{return new ei(t,this.interface,e)}catch(e){return new ri(t,e)}return new qn(t,c)}))}async on(t,e){const r=await Si(this,"on",t);return r.listeners.push({listener:e,once:!1}),r.start(),this}async once(t,e){const r=await Si(this,"once",t);return r.listeners.push({listener:e,once:!0}),r.start(),this}async emit(t,...e){return await ki(this,t,e,null)}async listenerCount(t){if(t){const e=await vi(this,t);return e?e.listeners.length:0}const{subs:e}=Ai(this);let r=0;for(const{listeners:t}of e.values())r+=t.length;return r}async listeners(t){if(t){const e=await vi(this,t);return e?e.listeners.map((({listener:t})=>t)):[]}const{subs:e}=Ai(this);let r=[];for(const{listeners:t}of e.values())r=r.concat(t.map((({listener:t})=>t)));return r}async off(t,e){const r=await vi(this,t);if(!r)return this;if(e){const t=r.listeners.map((({listener:t})=>t)).indexOf(e);t>=0&&r.listeners.splice(t,1)}return null!=e&&0!==r.listeners.length||(r.stop(),Ai(this).subs.delete(r.tag)),this}async removeAllListeners(t){if(t){const e=await vi(this,t);if(!e)return this;e.stop(),Ai(this).subs.delete(e.tag)}else{const{subs:t}=Ai(this);for(const{tag:e,stop:r}of t.values())r(),t.delete(e)}return this}async addListener(t,e){return await this.on(t,e)}async removeListener(t,e){return await this.off(t,e)}static buildClass(t){return class extends Pi{constructor(e,r=null){super(e,t,r)}}}static from(t,e,r){return null==r&&(r=null),new this(t,e,r)}}class Oi extends(function(){return Pi}()){}var Bi="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";const Ni=new Map([[8217,"apostrophe"],[8260,"fraction slash"],[12539,"middle dot"]]),xi=4;function Ci(t){return function(t){let e=0;return()=>t[e++]}(function(t){let e=0;function r(){return t[e++]<<8|t[e++]}let n=r(),i=1,s=[0,1];for(let t=1;t<n;t++)s.push(i+=r());let o=r(),a=e;e+=o;let u=0,c=0;function l(){return 0==u&&(c=c<<8|t[e++],u=8),c>>--u&1}const f=2**31,h=f>>>1,p=h>>1,d=f-1;let g=0;for(let t=0;t<31;t++)g=g<<1|l();let y=[],w=0,m=f;for(;;){let t=Math.floor(((g-w+1)*i-1)/m),e=0,r=n;for(;r-e>1;){let n=e+r>>>1;t<s[n]?r=n:e=n}if(0==e)break;y.push(e);let o=w+Math.floor(m*s[e]/i),a=w+Math.floor(m*s[e+1]/i)-1;for(;!((o^a)&h);)g=g<<1&d|l(),o=o<<1&d,a=a<<1&d|1;for(;o&~a&p;)g=g&h|g<<1&d>>>1|l(),o=o<<1^h,a=(a^h)<<1|h|1;w=o,m=1+a-o}let b=n-4;return y.map((e=>{switch(e-b){case 3:return b+65792+(t[a++]<<16|t[a++]<<8|t[a++]);case 2:return b+256+(t[a++]<<8|t[a++]);case 1:return b+t[a++];default:return e-1}}))}(function(t){let e=[];[..."ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"].forEach(((t,r)=>e[t.charCodeAt(0)]=r));let r=t.length,n=new Uint8Array(6*r>>3);for(let i=0,s=0,o=0,a=0;i<r;i++)a=a<<6|e[t.charCodeAt(i)],o+=6,o>=8&&(n[s++]=a>>(o-=8));return n}(t)))}function _i(t){return 1&t?~t>>1:t>>1}function Ri(t,e){let r=Array(t);for(let n=0,i=0;n<t;n++)r[n]=i+=_i(e());return r}function Ui(t,e=0){let r=[];for(;;){let n=t(),i=t();if(!i)break;e+=n;for(let t=0;t<i;t++)r.push(e+t);e+=i+1}return r}function Li(t){return Di((()=>{let e=Ui(t);if(e.length)return e}))}function Fi(t){let e=[];for(;;){let r=t();if(0==r)break;e.push(Mi(r,t))}for(;;){let r=t()-1;if(r<0)break;e.push(Gi(r,t))}return e.flat()}function Di(t){let e=[];for(;;){let r=t(e.length);if(!r)break;e.push(r)}return e}function Hi(t,e,r){let n=Array(t).fill().map((()=>[]));for(let i=0;i<e;i++)Ri(t,r).forEach(((t,e)=>n[e].push(t)));return n}function Mi(t,e){let r=1+e(),n=e(),i=Di(e);return Hi(i.length,1+t,e).flatMap(((t,e)=>{let[s,...o]=t;return Array(i[e]).fill().map(((t,e)=>{let i=e*n;return[s+e*r,o.map((t=>t+i))]}))}))}function Gi(t,e){return Hi(1+e(),1+t,e).map((t=>[t[0],t.slice(1)]))}function ji(t){return`{${function(t){return t.toString(16).toUpperCase().padStart(2,"0")}(t)}}`}function Vi(t){let e=t.length;if(e<4096)return String.fromCodePoint(...t);let r=[];for(let n=0;n<e;)r.push(String.fromCodePoint(...t.slice(n,n+=4096)));return r.join("")}function Ki(t,e){let r=t.length,n=r-e.length;for(let i=0;0==n&&i<r;i++)n=t[i]-e[i];return n}var Qi="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";const Wi=44032,zi=4352,Ji=4449,qi=4519,Xi=28,Yi=21*Xi,Zi=Wi+19*Yi,$i=zi+19,ts=Ji+21,es=qi+Xi;function rs(t){return t>>24&255}function ns(t){return 16777215&t}let is,ss,os,as;function us(t){return t>=Wi&&t<Zi}function cs(t,e){if(t>=zi&&t<$i&&e>=Ji&&e<ts)return Wi+(t-zi)*Yi+(e-Ji)*Xi;if(us(t)&&e>qi&&e<es&&(t-Wi)%Xi==0)return t+(e-qi);{let r=as.get(t);return r&&(r=r.get(e),r)?r:-1}}function ls(t){is||function(){let t=Ci(Qi);is=new Map(Li(t).flatMap(((t,e)=>t.map((t=>[t,e+1<<24]))))),ss=new Set(Ui(t)),os=new Map,as=new Map;for(let[e,r]of Fi(t)){if(!ss.has(e)&&2==r.length){let[t,n]=r,i=as.get(t);i||(i=new Map,as.set(t,i)),i.set(n,e)}os.set(e,r.reverse())}}();let e=[],r=[],n=!1;function i(t){let r=is.get(t);r&&(n=!0,t|=r),e.push(t)}for(let n of t)for(;;){if(n<128)e.push(n);else if(us(n)){let t=n-Wi,e=t%Yi/Xi|0,r=t%Xi;i(zi+(t/Yi|0)),i(Ji+e),r>0&&i(qi+r)}else{let t=os.get(n);t?r.push(...t):i(n)}if(!r.length)break;n=r.pop()}if(n&&e.length>1){let t=rs(e[0]);for(let r=1;r<e.length;r++){let n=rs(e[r]);if(0==n||t<=n){t=n;continue}let i=r-1;for(;;){let r=e[i+1];if(e[i+1]=e[i],e[i]=r,!i)break;if(t=rs(e[--i]),t<=n)break}t=rs(e[r])}}return e}function fs(t){return ls(t).map(ns)}function hs(t){return function(t){let e=[],r=[],n=-1,i=0;for(let s of t){let t=rs(s),o=ns(s);if(-1==n)0==t?n=o:e.push(o);else if(i>0&&i>=t)0==t?(e.push(n,...r),r.length=0,n=o):r.push(o),i=t;else{let s=cs(n,o);s>=0?n=s:0==i&&0==t?(e.push(n),n=o):(r.push(o),i=t)}}return n>=0&&e.push(n,...r),e}(ls(t))}const ps=45,ds=".",gs=65039,ys=1,ws=t=>Array.from(t);function ms(t,e){return t.P.has(e)||t.Q.has(e)}class bs extends Array{get is_emoji(){return!0}}let As,Es,vs,Ss,Is,ks,Ts,Ps,Os,Bs,Ns,xs;function Cs(){if(As)return;let t=Ci(Bi);const e=()=>Ui(t),r=()=>new Set(e()),n=(t,e)=>e.forEach((e=>t.add(e)));As=new Map(Fi(t)),Es=r(),vs=e(),Ss=new Set(e().map((t=>vs[t]))),vs=new Set(vs),Is=r(),ks=r();let i=Li(t),s=t();const o=()=>{let t=new Set;return e().forEach((e=>n(t,i[e]))),n(t,e()),t};Ts=Di((e=>{let r=Di(t).map((t=>t+96));if(r.length){let n=e>=s;return r[0]-=32,r=Vi(r),n&&(r=`Restricted[${r}]`),{N:r,P:o(),Q:o(),M:!t(),R:n}}})),Ps=r(),Os=new Map;let a=e().concat(ws(Ps)).sort(((t,e)=>t-e));a.forEach(((e,r)=>{let n=t(),i=a[r]=n?a[r-n]:{V:[],M:new Map};i.V.push(e),Ps.has(e)||Os.set(e,i)}));for(let{V:t,M:e}of new Set(Os.values())){let r=[];for(let e of t){let t=Ts.filter((t=>ms(t,e))),i=r.find((({G:e})=>t.some((t=>e.has(t)))));i||(i={G:new Set,V:[]},r.push(i)),i.V.push(e),n(i.G,t)}let i=r.flatMap((t=>ws(t.G)));for(let{G:t,V:n}of r){let r=new Set(i.filter((e=>!t.has(e))));for(let t of n)e.set(t,r)}}Bs=new Set;let u=new Set;const c=t=>Bs.has(t)?u.add(t):Bs.add(t);for(let t of Ts){for(let e of t.P)c(e);for(let e of t.Q)c(e)}for(let t of Bs)Os.has(t)||u.has(t)||Os.set(t,ys);n(Bs,fs(Bs)),Ns=function(t){let e=[],r=Ui(t);return function t({S:r,B:n},i,s){if(!(4&r&&s===i[i.length-1])){2&r&&(s=i[i.length-1]),1&r&&e.push(i);for(let e of n)for(let r of e.Q)t(e,[...i,r],s)}}(function e(n){return{S:t(),B:Di((()=>{let n=Ui(t).map((t=>r[t]));if(n.length)return e(n)})),Q:n}}([]),[]),e}(t).map((t=>bs.from(t))).sort(Ki),xs=new Map;for(let t of Ns){let e=[xs];for(let r of t){let t=e.map((t=>{let e=t.get(r);return e||(e=new Map,t.set(r,e)),e}));r===gs?e.push(...t):e=t}for(let r of e)r.V=t}}function _s(t){return(Ls(t)?"":`${Rs(Us([t]))} `)+ji(t)}function Rs(t){return`"${t}"‎`}function Us(t,e=1/0,r=ji){let n=[];var i;i=t[0],Cs(),vs.has(i)&&n.push("◌"),t.length>e&&(e>>=1,t=[...t.slice(0,e),8230,...t.slice(-e)]);let s=0,o=t.length;for(let e=0;e<o;e++){let i=t[e];Ls(i)&&(n.push(Vi(t.slice(s,e))),n.push(r(i)),s=e+1)}return n.push(Vi(t.slice(s,o))),n.join("")}function Ls(t){return Cs(),Is.has(t)}function Fs(t,e,r){if(!t)return[];Cs();let n=0;return t.split(ds).map((t=>{let i=function(t){let e=[];for(let r=0,n=t.length;r<n;){let n=t.codePointAt(r);r+=n<65536?1:2,e.push(n)}return e}(t),s={input:i,offset:n};n+=i.length+1;try{let t,n=s.tokens=function(t,e,r){let n=[],i=[];for(t=t.slice().reverse();t.length;){let s=js(t);if(s)i.length&&(n.push(e(i)),i=[]),n.push(r(s));else{let e=t.pop();if(Bs.has(e))i.push(e);else{let t=As.get(e);if(t)i.push(...t);else if(!Es.has(e))throw Ds(e)}}}return i.length&&n.push(e(i)),n}(i,e,r),o=n.length;if(!o)throw new Error("empty label");let a=s.output=n.flat();if(function(t){for(let e=t.lastIndexOf(95);e>0;)if(95!==t[--e])throw new Error("underscore allowed only at start")}(a),!(s.emoji=o>1||n[0].is_emoji)&&a.every((t=>t<128)))!function(t){if(t.length>=4&&t[2]==ps&&t[3]==ps)throw new Error(`invalid label extension: "${Vi(t.slice(0,4))}"`)}(a),t="ASCII";else{let e=n.flatMap((t=>t.is_emoji?[]:t));if(e.length){if(vs.has(a[0]))throw Ms("leading combining mark");for(let t=1;t<o;t++){let e=n[t];if(!e.is_emoji&&vs.has(e[0]))throw Ms(`emoji + combining mark: "${Vi(n[t-1])} + ${Us([e[0]])}"`)}!function(t){let e=t[0],r=Ni.get(e);if(r)throw Ms(`leading ${r}`);let n=t.length,i=-1;for(let s=1;s<n;s++){e=t[s];let n=Ni.get(e);if(n){if(i==s)throw Ms(`${r} + ${n}`);i=s+1,r=n}}if(i==n)throw Ms(`trailing ${r}`)}(a);let r=ws(new Set(e)),[i]=function(t){let e=Ts;for(let r of t){let t=e.filter((t=>ms(t,r)));if(!t.length)throw Ts.some((t=>ms(t,r)))?Hs(e[0],r):Ds(r);if(e=t,1==t.length)break}return e}(r);!function(t,e){for(let r of e)if(!ms(t,r))throw Hs(t,r);if(t.M){let t=fs(e);for(let e=1,r=t.length;e<r;e++)if(Ss.has(t[e])){let n=e+1;for(let i;n<r&&Ss.has(i=t[n]);n++)for(let r=e;r<n;r++)if(t[r]==i)throw new Error(`duplicate non-spacing marks: ${_s(i)}`);if(n-e>xi)throw new Error(`excessive non-spacing marks: ${Rs(Us(t.slice(e-1,n)))} (${n-e}/${xi})`);e=n}}}(i,e),function(t,e){let r,n=[];for(let t of e){let e=Os.get(t);if(e===ys)return;if(e){let n=e.M.get(t);if(r=r?r.filter((t=>n.has(t))):ws(n),!r.length)return}else n.push(t)}if(r)for(let e of r)if(n.every((t=>ms(e,t))))throw new Error(`whole-script confusable: ${t.N}/${e.N}`)}(i,r),t=i.N}else t="Emoji"}s.type=t}catch(t){s.error=t}return s}))}function Ds(t){return new Error(`disallowed character: ${_s(t)}`)}function Hs(t,e){let r=_s(e),n=Ts.find((t=>t.P.has(e)));return n&&(r=`${n.N} ${r}`),new Error(`illegal mixture: ${t.N} + ${r}`)}function Ms(t){return new Error(`illegal placement: ${t}`)}function Gs(t){return t.filter((t=>t!=gs))}function js(t,e){let r,n=xs,i=t.length;for(;i&&(n=n.get(t[--i]),n);){let{V:s}=n;s&&(r=s,e&&e.push(...t.slice(i).reverse()),t.length=i)}return r}const Vs=new Uint8Array(32);function Ks(t){return tt(0!==t.length,"invalid ENS name; empty component","comp",t),t}function Qs(t){const e=Ze(function(t){try{if(0===t.length)throw new Error("empty label");return function(t){return function(t){return t.map((({input:e,error:r,output:n})=>{if(r){let n=r.message;throw new Error(1==t.length?n:`Invalid label ${Rs(Us(e,63))}: ${n}`)}return Vi(n)})).join(ds)}(Fs(t,hs,Gs))}(t)}catch(e){tt(!1,`invalid ENS name (${e.message})`,"name",t)}}(t)),r=[];if(0===t.length)return r;let n=0;for(let t=0;t<e.length;t++)46===e[t]&&(r.push(Ks(e.slice(n,t))),n=t+1);return tt(n<e.length,"invalid ENS name; empty component","name",t),r.push(Ks(e.slice(n))),r}function Ws(t){tt("string"==typeof t,"invalid ENS name; not a string","name",t),tt(t.length,"invalid ENS name (empty label)","name",t);let e=Vs;const r=Qs(t);for(;r.length;)e=ve(ft([e,ve(r.pop())]));return lt(e)}function zs(t,e){const r=null!=e?e:63;return tt(r<=255,"DNS encoded label cannot exceed 255","length",r),lt(ft(Qs(t).map((e=>{tt(e.length<=r,`label ${JSON.stringify(t)} exceeds ${r} bytes`,"name",t);const n=new Uint8Array(e.length+1);return n.set(e,1),n[0]=n.length-1,n}))))+"00"}Vs.fill(0);class Js extends re{constructor(t,e,r,n){super(),this.blockLen=t,this.outputLen=e,this.padOffset=r,this.isLE=n,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=$t(this.buffer)}update(t){Gt(this);const{view:e,buffer:r,blockLen:n}=this,i=(t=ee(t)).length;for(let s=0;s<i;){const o=Math.min(n-this.pos,i-s);if(o!==n)r.set(t.subarray(s,s+o),this.pos),this.pos+=o,s+=o,this.pos===n&&(this.process(e,0),this.pos=0);else{const e=$t(t);for(;n<=i-s;s+=n)this.process(e,s)}}return this.length+=t.length,this.roundClean(),this}digestInto(t){Gt(this),jt(t,this),this.finished=!0;const{buffer:e,view:r,blockLen:n,isLE:i}=this;let{pos:s}=this;e[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>n-s&&(this.process(r,0),s=0);for(let t=s;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),s=BigInt(4294967295),o=Number(r>>i&s),a=Number(r&s),u=n?4:0,c=n?0:4;t.setUint32(e+u,o,n),t.setUint32(e+c,a,n)}(r,n-8,BigInt(8*this.length),i),this.process(r,0);const o=$t(t),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const u=a/4,c=this.get();if(u>c.length)throw new Error("_sha2: outputLen bigger than state");for(let t=0;t<u;t++)o.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:s,pos:o}=this;return t.length=n,t.pos=o,t.finished=i,t.destroyed=s,n%e&&t.buffer.set(r),t}}const qs=(t,e,r)=>t&e^~t&r,Xs=(t,e,r)=>t&e^t&r^e&r,Ys=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Zs=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),$s=new Uint32Array(64);class to extends Js{constructor(){super(64,32,8,!1),this.A=0|Zs[0],this.B=0|Zs[1],this.C=0|Zs[2],this.D=0|Zs[3],this.E=0|Zs[4],this.F=0|Zs[5],this.G=0|Zs[6],this.H=0|Zs[7]}get(){const{A:t,B:e,C:r,D:n,E:i,F:s,G:o,H:a}=this;return[t,e,r,n,i,s,o,a]}set(t,e,r,n,i,s,o,a){this.A=0|t,this.B=0|e,this.C=0|r,this.D=0|n,this.E=0|i,this.F=0|s,this.G=0|o,this.H=0|a}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=te(e,7)^te(e,18)^e>>>3,i=te(r,17)^te(r,19)^r>>>10;$s[t]=i+$s[t-7]+n+$s[t-16]|0}let{A:r,B:n,C:i,D:s,E:o,F:a,G:u,H:c}=this;for(let t=0;t<64;t++){const e=c+(te(o,6)^te(o,11)^te(o,25))+qs(o,a,u)+Ys[t]+$s[t]|0,l=(te(r,2)^te(r,13)^te(r,22))+Xs(r,n,i)|0;c=u,u=a,a=o,o=s+e|0,s=i,i=n,n=r,r=e+l|0}r=r+this.A|0,n=n+this.B|0,i=i+this.C|0,s=s+this.D|0,o=o+this.E|0,a=a+this.F|0,u=u+this.G|0,c=c+this.H|0,this.set(r,n,i,s,o,a,u,c)}roundClean(){$s.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const eo=ne((()=>new to)),[ro,no]=(()=>Yt.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)))))(),io=new Uint32Array(80),so=new Uint32Array(80);class oo extends Js{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){const{Ah:t,Al:e,Bh:r,Bl:n,Ch:i,Cl:s,Dh:o,Dl:a,Eh:u,El:c,Fh:l,Fl:f,Gh:h,Gl:p,Hh:d,Hl:g}=this;return[t,e,r,n,i,s,o,a,u,c,l,f,h,p,d,g]}set(t,e,r,n,i,s,o,a,u,c,l,f,h,p,d,g){this.Ah=0|t,this.Al=0|e,this.Bh=0|r,this.Bl=0|n,this.Ch=0|i,this.Cl=0|s,this.Dh=0|o,this.Dl=0|a,this.Eh=0|u,this.El=0|c,this.Fh=0|l,this.Fl=0|f,this.Gh=0|h,this.Gl=0|p,this.Hh=0|d,this.Hl=0|g}process(t,e){for(let r=0;r<16;r++,e+=4)io[r]=t.getUint32(e),so[r]=t.getUint32(e+=4);for(let t=16;t<80;t++){const e=0|io[t-15],r=0|so[t-15],n=Yt.rotrSH(e,r,1)^Yt.rotrSH(e,r,8)^Yt.shrSH(e,r,7),i=Yt.rotrSL(e,r,1)^Yt.rotrSL(e,r,8)^Yt.shrSL(e,r,7),s=0|io[t-2],o=0|so[t-2],a=Yt.rotrSH(s,o,19)^Yt.rotrBH(s,o,61)^Yt.shrSH(s,o,6),u=Yt.rotrSL(s,o,19)^Yt.rotrBL(s,o,61)^Yt.shrSL(s,o,6),c=Yt.add4L(i,u,so[t-7],so[t-16]),l=Yt.add4H(c,n,a,io[t-7],io[t-16]);io[t]=0|l,so[t]=0|c}let{Ah:r,Al:n,Bh:i,Bl:s,Ch:o,Cl:a,Dh:u,Dl:c,Eh:l,El:f,Fh:h,Fl:p,Gh:d,Gl:g,Hh:y,Hl:w}=this;for(let t=0;t<80;t++){const e=Yt.rotrSH(l,f,14)^Yt.rotrSH(l,f,18)^Yt.rotrBH(l,f,41),m=Yt.rotrSL(l,f,14)^Yt.rotrSL(l,f,18)^Yt.rotrBL(l,f,41),b=l&h^~l&d,A=f&p^~f&g,E=Yt.add5L(w,m,A,no[t],so[t]),v=Yt.add5H(E,y,e,b,ro[t],io[t]),S=0|E,I=Yt.rotrSH(r,n,28)^Yt.rotrBH(r,n,34)^Yt.rotrBH(r,n,39),k=Yt.rotrSL(r,n,28)^Yt.rotrBL(r,n,34)^Yt.rotrBL(r,n,39),T=r&i^r&o^i&o,P=n&s^n&a^s&a;y=0|d,w=0|g,d=0|h,g=0|p,h=0|l,p=0|f,({h:l,l:f}=Yt.add(0|u,0|c,0|v,0|S)),u=0|o,c=0|a,o=0|i,a=0|s,i=0|r,s=0|n;const O=Yt.add3L(S,k,P);r=Yt.add3H(O,v,I,T),n=0|O}({h:r,l:n}=Yt.add(0|this.Ah,0|this.Al,0|r,0|n)),({h:i,l:s}=Yt.add(0|this.Bh,0|this.Bl,0|i,0|s)),({h:o,l:a}=Yt.add(0|this.Ch,0|this.Cl,0|o,0|a)),({h:u,l:c}=Yt.add(0|this.Dh,0|this.Dl,0|u,0|c)),({h:l,l:f}=Yt.add(0|this.Eh,0|this.El,0|l,0|f)),({h,l:p}=Yt.add(0|this.Fh,0|this.Fl,0|h,0|p)),({h:d,l:g}=Yt.add(0|this.Gh,0|this.Gl,0|d,0|g)),({h:y,l:w}=Yt.add(0|this.Hh,0|this.Hl,0|y,0|w)),this.set(r,n,i,s,o,a,u,c,l,f,h,p,d,g,y,w)}roundClean(){io.fill(0),so.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const ao=ne((()=>new oo)),uo=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 co(t){switch(t){case"sha256":return eo.create();case"sha512":return ao.create()}tt(!1,"invalid hashing algorithm name","algorithm",t)}uo.crypto||uo.msCrypto;const lo=function(t){return co("sha256").update(t).digest()},fo=function(t){return co("sha512").update(t).digest()};let ho=lo,po=fo,go=!1,yo=!1;function wo(t){const e=st(t,"data");return lt(ho(e))}function mo(t){const e=st(t,"data");return lt(po(e))}wo._=lo,wo.lock=function(){go=!0},wo.register=function(t){if(go)throw new Error("sha256 is locked");ho=t},Object.freeze(wo),mo._=fo,mo.lock=function(){yo=!0},mo.register=function(t){if(yo)throw new Error("sha512 is locked");po=t},Object.freeze(wo);const bo="0x0000000000000000000000000000000000000000000000000000000000000000",Ao=BigInt(0),Eo=BigInt(1),vo=BigInt(2),So=BigInt(27),Io=BigInt(28),ko=BigInt(35),To={};function Po(t){return gt(Pt(t),32)}class Oo{#$;#tt;#et;#rt;get r(){return this.#$}set r(t){tt(32===ht(t),"invalid r","value",t),this.#$=lt(t)}get s(){return this.#tt}set s(t){tt(32===ht(t),"invalid s","value",t);const e=lt(t);tt(parseInt(e.substring(0,3))<8,"non-canonical s","value",e),this.#tt=e}get v(){return this.#et}set v(t){const e=kt(t,"value");tt(27===e||28===e,"invalid v","v",t),this.#et=e}get networkV(){return this.#rt}get legacyChainId(){const t=this.networkV;return null==t?null:Oo.getChainId(t)}get yParity(){return 27===this.v?0:1}get yParityAndS(){const t=st(this.s);return this.yParity&&(t[0]|=128),lt(t)}get compactSerialized(){return ft([this.r,this.yParityAndS])}get serialized(){return ft([this.r,this.s,this.yParity?"0x1c":"0x1b"])}constructor(t,e,r,n){nt(t,To,"Signature"),this.#$=e,this.#tt=r,this.#et=n,this.#rt=null}[Symbol.for("nodejs.util.inspect.custom")](){return`Signature { r: "${this.r}", s: "${this.s}", yParity: ${this.yParity}, networkV: ${this.networkV} }`}clone(){const t=new Oo(To,this.r,this.s,this.v);return this.networkV&&(t.#rt=this.networkV),t}toJSON(){const t=this.networkV;return{_type:"signature",networkV:null!=t?t.toString():null,r:this.r,s:this.s,v:this.v}}static getChainId(t){const e=Et(t,"v");return e==So||e==Io?Ao:(tt(e>=ko,"invalid EIP-155 v","v",t),(e-ko)/vo)}static getChainIdV(t,e){return Et(t)*vo+BigInt(35+e-27)}static getNormalizedV(t){const e=Et(t);return e===Ao||e===So?27:e===Eo||e===Io?28:(tt(e>=ko,"invalid v","v",t),e&Eo?27:28)}static from(t){function e(e,r){tt(e,r,"signature",t)}if(null==t)return new Oo(To,bo,bo,27);if("string"==typeof t){const r=st(t,"signature");if(64===r.length){const t=lt(r.slice(0,32)),e=r.slice(32,64),n=128&e[0]?28:27;return e[0]&=127,new Oo(To,t,lt(e),n)}if(65===r.length){const t=lt(r.slice(0,32)),n=r.slice(32,64);e(!(128&n[0]),"non-canonical s");const i=Oo.getNormalizedV(r[64]);return new Oo(To,t,lt(n),i)}e(!1,"invalid raw signature length")}if(t instanceof Oo)return t.clone();const r=t.r;e(null!=r,"missing r");const n=Po(r),i=function(t,r){if(null!=t)return Po(t);if(null!=r){e(at(r,32),"invalid yParityAndS");const t=st(r);return t[0]&=127,lt(t)}e(!1,"missing s")}(t.s,t.yParityAndS);e(!(128&st(i)[0]),"non-canonical s");const{networkV:s,v:o}=function(t,r,n){if(null!=t){const e=Et(t);return{networkV:e>=ko?e:void 0,v:Oo.getNormalizedV(e)}}if(null!=r)return e(at(r,32),"invalid yParityAndS"),{v:128&st(r)[0]?28:27};if(null!=n){switch(kt(n,"sig.yParity")){case 0:return{v:27};case 1:return{v:28}}e(!1,"invalid yParity")}e(!1,"missing v")}(t.v,t.yParityAndS,t.yParity),a=new Oo(To,n,i,o);return s&&(a.#rt=s),e(null==t.yParity||kt(t.yParity,"sig.yParity")===a.yParity,"yParity mismatch"),e(null==t.yParityAndS||t.yParityAndS===a.yParityAndS,"yParityAndS mismatch"),a}}function Bo(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`Wrong positive integer: ${t}`)}function No(t,...e){if(!(t instanceof Uint8Array))throw new Error("Expected Uint8Array");if(e.length>0&&!e.includes(t.length))throw new Error(`Expected Uint8Array of length ${e}, not of length=${t.length}`)}function xo(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")}const Co="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0,_o=t=>t instanceof Uint8Array,Ro=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),Uo=(t,e)=>t<<32-e|t>>>e;if(68!==new Uint8Array(new Uint32Array([287454020]).buffer)[0])throw new Error("Non little-endian hardware is not supported");function Lo(t){if("string"==typeof t&&(t=function(t){if("string"!=typeof t)throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array((new TextEncoder).encode(t))}(t)),!_o(t))throw new Error("expected Uint8Array, got "+typeof t);return t}class Fo{clone(){return this._cloneInto()}}function Do(t){const e=e=>t().update(Lo(e)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function Ho(t=32){if(Co&&"function"==typeof Co.getRandomValues)return Co.getRandomValues(new Uint8Array(t));throw new Error("crypto.getRandomValues must be defined")}class Mo extends Fo{constructor(t,e,r,n){super(),this.blockLen=t,this.outputLen=e,this.padOffset=r,this.isLE=n,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=Ro(this.buffer)}update(t){xo(this);const{view:e,buffer:r,blockLen:n}=this,i=(t=Lo(t)).length;for(let s=0;s<i;){const o=Math.min(n-this.pos,i-s);if(o!==n)r.set(t.subarray(s,s+o),this.pos),this.pos+=o,s+=o,this.pos===n&&(this.process(e,0),this.pos=0);else{const e=Ro(t);for(;n<=i-s;s+=n)this.process(e,s)}}return this.length+=t.length,this.roundClean(),this}digestInto(t){xo(this),function(t,e){No(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:s}=this;e[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>n-s&&(this.process(r,0),s=0);for(let t=s;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),s=BigInt(4294967295),o=Number(r>>i&s),a=Number(r&s),u=n?4:0,c=n?0:4;t.setUint32(e+u,o,n),t.setUint32(e+c,a,n)}(r,n-8,BigInt(8*this.length),i),this.process(r,0);const o=Ro(t),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const u=a/4,c=this.get();if(u>c.length)throw new Error("_sha2: outputLen bigger than state");for(let t=0;t<u;t++)o.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:s,pos:o}=this;return t.length=n,t.pos=o,t.finished=i,t.destroyed=s,n%e&&t.buffer.set(r),t}}const Go=(t,e,r)=>t&e^~t&r,jo=(t,e,r)=>t&e^t&r^e&r,Vo=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Ko=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Qo=new Uint32Array(64);class Wo extends Mo{constructor(){super(64,32,8,!1),this.A=0|Ko[0],this.B=0|Ko[1],this.C=0|Ko[2],this.D=0|Ko[3],this.E=0|Ko[4],this.F=0|Ko[5],this.G=0|Ko[6],this.H=0|Ko[7]}get(){const{A:t,B:e,C:r,D:n,E:i,F:s,G:o,H:a}=this;return[t,e,r,n,i,s,o,a]}set(t,e,r,n,i,s,o,a){this.A=0|t,this.B=0|e,this.C=0|r,this.D=0|n,this.E=0|i,this.F=0|s,this.G=0|o,this.H=0|a}process(t,e){for(let r=0;r<16;r++,e+=4)Qo[r]=t.getUint32(e,!1);for(let t=16;t<64;t++){const e=Qo[t-15],r=Qo[t-2],n=Uo(e,7)^Uo(e,18)^e>>>3,i=Uo(r,17)^Uo(r,19)^r>>>10;Qo[t]=i+Qo[t-7]+n+Qo[t-16]|0}let{A:r,B:n,C:i,D:s,E:o,F:a,G:u,H:c}=this;for(let t=0;t<64;t++){const e=c+(Uo(o,6)^Uo(o,11)^Uo(o,25))+Go(o,a,u)+Vo[t]+Qo[t]|0,l=(Uo(r,2)^Uo(r,13)^Uo(r,22))+jo(r,n,i)|0;c=u,u=a,a=o,o=s+e|0,s=i,i=n,n=r,r=e+l|0}r=r+this.A|0,n=n+this.B|0,i=i+this.C|0,s=s+this.D|0,o=o+this.E|0,a=a+this.F|0,u=u+this.G|0,c=c+this.H|0,this.set(r,n,i,s,o,a,u,c)}roundClean(){Qo.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const zo=Do((()=>new Wo)),Jo=(BigInt(0),BigInt(1)),qo=BigInt(2),Xo=t=>t instanceof Uint8Array,Yo=Array.from({length:256},((t,e)=>e.toString(16).padStart(2,"0")));function Zo(t){if(!Xo(t))throw new Error("Uint8Array expected");let e="";for(let r=0;r<t.length;r++)e+=Yo[t[r]];return e}function $o(t){if("string"!=typeof t)throw new Error("hex string expected, got "+typeof t);return BigInt(""===t?"0":`0x${t}`)}function ta(t){if("string"!=typeof t)throw new Error("hex string expected, got "+typeof t);const e=t.length;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);const r=new Uint8Array(e/2);for(let e=0;e<r.length;e++){const n=2*e,i=t.slice(n,n+2),s=Number.parseInt(i,16);if(Number.isNaN(s)||s<0)throw new Error("Invalid byte sequence");r[e]=s}return r}function ea(t){return $o(Zo(t))}function ra(t){if(!Xo(t))throw new Error("Uint8Array expected");return $o(Zo(Uint8Array.from(t).reverse()))}function na(t,e){return ta(t.toString(16).padStart(2*e,"0"))}function ia(t,e){return na(t,e).reverse()}function sa(t,e,r){let n;if("string"==typeof e)try{n=ta(e)}catch(r){throw new Error(`${t} must be valid hex string, got "${e}". Cause: ${r}`)}else{if(!Xo(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} expected ${r} bytes, got ${i}`);return n}function oa(...t){const e=new Uint8Array(t.reduce(((t,e)=>t+e.length),0));let r=0;return t.forEach((t=>{if(!Xo(t))throw new Error("Uint8Array expected");e.set(t,r),r+=t.length})),e}const aa=t=>(qo<<BigInt(t-1))-Jo,ua=t=>new Uint8Array(t),ca=t=>Uint8Array.from(t);function la(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");let n=ua(t),i=ua(t),s=0;const o=()=>{n.fill(1),i.fill(0),s=0},a=(...t)=>r(i,n,...t),u=(t=ua())=>{i=a(ca([0]),t),n=a(),0!==t.length&&(i=a(ca([1]),t),n=a())},c=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let t=0;const r=[];for(;t<e;){n=a();const e=n.slice();r.push(e),t+=n.length}return oa(...r)};return(t,e)=>{let r;for(o(),u(t);!(r=e(c()));)u();return o(),r}}const fa={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||t instanceof Uint8Array,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)};function ha(t,e,r={}){const n=(e,r,n)=>{const i=fa[r];if("function"!=typeof i)throw new Error(`Invalid validator "${r}", expected function`);const s=t[e];if(!(n&&void 0===s||i(s,t)))throw new Error(`Invalid param ${String(e)}=${s} (${typeof s}), expected ${r}`)};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}const pa=BigInt(0),da=BigInt(1),ga=BigInt(2),ya=BigInt(3),wa=BigInt(4),ma=BigInt(5),ba=BigInt(8);function Aa(t,e){const r=t%e;return r>=pa?r:e+r}function Ea(t,e,r){if(r<=pa||e<pa)throw new Error("Expected power/modulo > 0");if(r===da)return pa;let n=da;for(;e>pa;)e&da&&(n=n*t%r),t=t*t%r,e>>=da;return n}function va(t,e,r){let n=t;for(;e-- >pa;)n*=n,n%=r;return n}function Sa(t,e){if(t===pa||e<=pa)throw new Error(`invert: expected positive integers, got n=${t} mod=${e}`);let r=Aa(t,e),n=e,i=pa,s=da,o=da,a=pa;for(;r!==pa;){const t=n/r,e=n%r,u=i-o*t,c=s-a*t;n=r,r=e,i=o,s=a,o=u,a=c}if(n!==da)throw new Error("invert: does not exist");return Aa(i,e)}BigInt(9),BigInt(16);const Ia=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function ka(t,e){const r=void 0!==e?e:t.toString(2).length;return{nBitLength:r,nByteLength:Math.ceil(r/8)}}function Ta(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 Pa(t){const e=Ta(t);return e+Math.ceil(e/2)}class Oa extends Fo{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,function(t){if("function"!=typeof t||"function"!=typeof t.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");Bo(t.outputLen),Bo(t.blockLen)}(t);const r=Lo(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),i.fill(0)}update(t){return xo(this),this.iHash.update(t),this}digestInto(t){xo(this),No(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:s,outputLen:o}=this;return t.finished=n,t.destroyed=i,t.blockLen=s,t.outputLen=o,t.oHash=e._cloneInto(t.oHash),t.iHash=r._cloneInto(t.iHash),t}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const Ba=(t,e,r)=>new Oa(t,e).update(r).digest();Ba.create=(t,e)=>new Oa(t,e);const Na=BigInt(0),xa=BigInt(1);function Ca(t){return ha(t.Fp,Ia.reduce(((t,e)=>(t[e]="function",t)),{ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"})),ha(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...ka(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}const{bytesToNumberBE:_a,hexToBytes:Ra}=e,Ua={Err:class extends Error{constructor(t=""){super(t)}},_parseInt(t){const{Err:e}=Ua;if(t.length<2||2!==t[0])throw new e("Invalid signature integer tag");const r=t[1],n=t.subarray(2,r+2);if(!r||n.length!==r)throw new e("Invalid signature integer: wrong length");if(128&n[0])throw new e("Invalid signature integer: negative");if(0===n[0]&&!(128&n[1]))throw new e("Invalid signature integer: unnecessary leading zero");return{d:_a(n),l:t.subarray(r+2)}},toSig(t){const{Err:e}=Ua,r="string"==typeof t?Ra(t):t;if(!(r instanceof Uint8Array))throw new Error("ui8a expected");let n=r.length;if(n<2||48!=r[0])throw new e("Invalid signature tag");if(r[1]!==n-2)throw new e("Invalid signature: incorrect length");const{d:i,l:s}=Ua._parseInt(r.subarray(2)),{d:o,l:a}=Ua._parseInt(s);if(a.length)throw new e("Invalid signature: left bytes after parsing");return{r:i,s:o}},hexFromSig(t){const e=t=>8&Number.parseInt(t[0],16)?"00"+t:t,r=t=>{const e=t.toString(16);return 1&e.length?`0${e}`:e},n=e(r(t.s)),i=e(r(t.r)),s=n.length/2,o=i.length/2,a=r(s),u=r(o);return`30${r(o+s+4)}02${u}${i}02${a}${n}`}},La=BigInt(0),Fa=BigInt(1),Da=(BigInt(2),BigInt(3));function Ha(t){const e=function(t){const e=Ca(t);return ha(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}(t),{Fp:r,n}=e,i=r.BYTES+1,s=2*r.BYTES+1;function o(t){return Aa(t,n)}function a(t){return Sa(t,n)}const{ProjectivePoint:u,normPrivateKeyToScalar:c,weierstrassEquation:l,isWithinCurveOrder:f}=function(t){const e=function(t){const e=Ca(t);ha(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:r,Fp:n,a:i}=e;if(r){if(!n.eql(i,n.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if("object"!=typeof r||"bigint"!=typeof r.beta||"function"!=typeof r.splitScalar)throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...e})}(t),{Fp:r}=e,n=e.toBytes||((t,e,n)=>{const i=e.toAffine();return oa(Uint8Array.from([4]),r.toBytes(i.x),r.toBytes(i.y))}),i=e.fromBytes||(t=>{const e=t.subarray(1);return{x:r.fromBytes(e.subarray(0,r.BYTES)),y:r.fromBytes(e.subarray(r.BYTES,2*r.BYTES))}});function s(t){const{a:n,b:i}=e,s=r.sqr(t),o=r.mul(s,t);return r.add(r.add(o,r.mul(t,n)),i)}if(!r.eql(r.sqr(e.Gy),s(e.Gx)))throw new Error("bad generator point: equation left != right");function o(t){return"bigint"==typeof t&&La<t&&t<e.n}function a(t){if(!o(t))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function u(t){const{allowedPrivateKeyLengths:r,nByteLength:n,wrapPrivateKey:i,n:s}=e;if(r&&"bigint"!=typeof t){if(t instanceof Uint8Array&&(t=Zo(t)),"string"!=typeof t||!r.includes(t.length))throw new Error("Invalid key");t=t.padStart(2*n,"0")}let o;try{o="bigint"==typeof t?t:ea(sa("private key",t,n))}catch(e){throw new Error(`private key must be ${n} bytes, hex or bigint, not ${typeof t}`)}return i&&(o=Aa(o,s)),a(o),o}const c=new Map;function l(t){if(!(t instanceof f))throw new Error("ProjectivePoint expected")}class f{constructor(t,e,n){if(this.px=t,this.py=e,this.pz=n,null==t||!r.isValid(t))throw new Error("x required");if(null==e||!r.isValid(e))throw new Error("y required");if(null==n||!r.isValid(n))throw new Error("z required")}static fromAffine(t){const{x:e,y:n}=t||{};if(!t||!r.isValid(e)||!r.isValid(n))throw new Error("invalid affine point");if(t instanceof f)throw new Error("projective point not allowed");const i=t=>r.eql(t,r.ZERO);return i(e)&&i(n)?f.ZERO:new f(e,n,r.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(t){const e=r.invertBatch(t.map((t=>t.pz)));return t.map(((t,r)=>t.toAffine(e[r]))).map(f.fromAffine)}static fromHex(t){const e=f.fromAffine(i(sa("pointHex",t)));return e.assertValidity(),e}static fromPrivateKey(t){return f.BASE.multiply(u(t))}_setWindowSize(t){this._WINDOW_SIZE=t,c.delete(this)}assertValidity(){if(this.is0()){if(e.allowInfinityPoint&&!r.is0(this.py))return;throw new Error("bad point: ZERO")}const{x:t,y:n}=this.toAffine();if(!r.isValid(t)||!r.isValid(n))throw new Error("bad point: x or y not FE");const i=r.sqr(n),o=s(t);if(!r.eql(i,o))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){const{y:t}=this.toAffine();if(r.isOdd)return!r.isOdd(t);throw new Error("Field doesn't support isOdd")}equals(t){l(t);const{px:e,py:n,pz:i}=this,{px:s,py:o,pz:a}=t,u=r.eql(r.mul(e,a),r.mul(s,i)),c=r.eql(r.mul(n,a),r.mul(o,i));return u&&c}negate(){return new f(this.px,r.neg(this.py),this.pz)}double(){const{a:t,b:n}=e,i=r.mul(n,Da),{px:s,py:o,pz:a}=this;let u=r.ZERO,c=r.ZERO,l=r.ZERO,h=r.mul(s,s),p=r.mul(o,o),d=r.mul(a,a),g=r.mul(s,o);return g=r.add(g,g),l=r.mul(s,a),l=r.add(l,l),u=r.mul(t,l),c=r.mul(i,d),c=r.add(u,c),u=r.sub(p,c),c=r.add(p,c),c=r.mul(u,c),u=r.mul(g,u),l=r.mul(i,l),d=r.mul(t,d),g=r.sub(h,d),g=r.mul(t,g),g=r.add(g,l),l=r.add(h,h),h=r.add(l,h),h=r.add(h,d),h=r.mul(h,g),c=r.add(c,h),d=r.mul(o,a),d=r.add(d,d),h=r.mul(d,g),u=r.sub(u,h),l=r.mul(d,p),l=r.add(l,l),l=r.add(l,l),new f(u,c,l)}add(t){l(t);const{px:n,py:i,pz:s}=this,{px:o,py:a,pz:u}=t;let c=r.ZERO,h=r.ZERO,p=r.ZERO;const d=e.a,g=r.mul(e.b,Da);let y=r.mul(n,o),w=r.mul(i,a),m=r.mul(s,u),b=r.add(n,i),A=r.add(o,a);b=r.mul(b,A),A=r.add(y,w),b=r.sub(b,A),A=r.add(n,s);let E=r.add(o,u);return A=r.mul(A,E),E=r.add(y,m),A=r.sub(A,E),E=r.add(i,s),c=r.add(a,u),E=r.mul(E,c),c=r.add(w,m),E=r.sub(E,c),p=r.mul(d,A),c=r.mul(g,m),p=r.add(c,p),c=r.sub(w,p),p=r.add(w,p),h=r.mul(c,p),w=r.add(y,y),w=r.add(w,y),m=r.mul(d,m),A=r.mul(g,A),w=r.add(w,m),m=r.sub(y,m),m=r.mul(d,m),A=r.add(A,m),y=r.mul(w,A),h=r.add(h,y),y=r.mul(E,A),c=r.mul(b,c),c=r.sub(c,y),y=r.mul(b,w),p=r.mul(E,p),p=r.add(p,y),new f(c,h,p)}subtract(t){return this.add(t.negate())}is0(){return this.equals(f.ZERO)}wNAF(t){return p.wNAFCached(this,c,t,(t=>{const e=r.invertBatch(t.map((t=>t.pz)));return t.map(((t,r)=>t.toAffine(e[r]))).map(f.fromAffine)}))}multiplyUnsafe(t){const n=f.ZERO;if(t===La)return n;if(a(t),t===Fa)return this;const{endo:i}=e;if(!i)return p.unsafeLadder(this,t);let{k1neg:s,k1:o,k2neg:u,k2:c}=i.splitScalar(t),l=n,h=n,d=this;for(;o>La||c>La;)o&Fa&&(l=l.add(d)),c&Fa&&(h=h.add(d)),d=d.double(),o>>=Fa,c>>=Fa;return s&&(l=l.negate()),u&&(h=h.negate()),h=new f(r.mul(h.px,i.beta),h.py,h.pz),l.add(h)}multiply(t){a(t);let n,i,s=t;const{endo:o}=e;if(o){const{k1neg:t,k1:e,k2neg:a,k2:u}=o.splitScalar(s);let{p:c,f:l}=this.wNAF(e),{p:h,f:d}=this.wNAF(u);c=p.constTimeNegate(t,c),h=p.constTimeNegate(a,h),h=new f(r.mul(h.px,o.beta),h.py,h.pz),n=c.add(h),i=l.add(d)}else{const{p:t,f:e}=this.wNAF(s);n=t,i=e}return f.normalizeZ([n,i])[0]}multiplyAndAddUnsafe(t,e,r){const n=f.BASE,i=(t,e)=>e!==La&&e!==Fa&&t.equals(n)?t.multiply(e):t.multiplyUnsafe(e),s=i(this,e).add(i(t,r));return s.is0()?void 0:s}toAffine(t){const{px:e,py:n,pz:i}=this,s=this.is0();null==t&&(t=s?r.ONE:r.inv(i));const o=r.mul(e,t),a=r.mul(n,t),u=r.mul(i,t);if(s)return{x:r.ZERO,y:r.ZERO};if(!r.eql(u,r.ONE))throw new Error("invZ was invalid");return{x:o,y:a}}isTorsionFree(){const{h:t,isTorsionFree:r}=e;if(t===Fa)return!0;if(r)return r(f,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:t,clearCofactor:r}=e;return t===Fa?this:r?r(f,this):this.multiplyUnsafe(e.h)}toRawBytes(t=!0){return this.assertValidity(),n(f,this,t)}toHex(t=!0){return Zo(this.toRawBytes(t))}}f.BASE=new f(e.Gx,e.Gy,r.ONE),f.ZERO=new f(r.ZERO,r.ONE,r.ZERO);const h=e.nBitLength,p=function(t,e){const r=(t,e)=>{const r=e.negate();return t?r:e},n=t=>({windows:Math.ceil(e/t)+1,windowSize:2**(t-1)});return{constTimeNegate:r,unsafeLadder(e,r){let n=t.ZERO,i=e;for(;r>Na;)r&xa&&(n=n.add(i)),i=i.double(),r>>=xa;return n},precomputeWindow(t,e){const{windows:r,windowSize:i}=n(e),s=[];let o=t,a=o;for(let t=0;t<r;t++){a=o,s.push(a);for(let t=1;t<i;t++)a=a.add(o),s.push(a);o=a.double()}return s},wNAF(e,i,s){const{windows:o,windowSize:a}=n(e);let u=t.ZERO,c=t.BASE;const l=BigInt(2**e-1),f=2**e,h=BigInt(e);for(let t=0;t<o;t++){const e=t*a;let n=Number(s&l);s>>=h,n>a&&(n-=f,s+=xa);const o=e,p=e+Math.abs(n)-1,d=t%2!=0,g=n<0;0===n?c=c.add(r(d,i[o])):u=u.add(r(g,i[p]))}return{p:u,f:c}},wNAFCached(t,e,r,n){const i=t._WINDOW_SIZE||1;let s=e.get(t);return s||(s=this.precomputeWindow(t,i),1!==i&&e.set(t,n(s))),this.wNAF(i,s,r)}}}(f,e.endo?Math.ceil(h/2):h);return{CURVE:e,ProjectivePoint:f,normPrivateKeyToScalar:u,weierstrassEquation:s,isWithinCurveOrder:o}}({...e,toBytes(t,e,n){const i=e.toAffine(),s=r.toBytes(i.x),o=oa;return n?o(Uint8Array.from([e.hasEvenY()?2:3]),s):o(Uint8Array.from([4]),s,r.toBytes(i.y))},fromBytes(t){const e=t.length,n=t[0],o=t.subarray(1);if(e!==i||2!==n&&3!==n){if(e===s&&4===n)return{x:r.fromBytes(o.subarray(0,r.BYTES)),y:r.fromBytes(o.subarray(r.BYTES,2*r.BYTES))};throw new Error(`Point of length ${e} was invalid. Expected ${i} compressed bytes or ${s} uncompressed bytes`)}{const t=ea(o);if(!(La<(a=t)&&a<r.ORDER))throw new Error("Point is not on curve");const e=l(t);let i=r.sqrt(e);return!(1&~n)!=((i&Fa)===Fa)&&(i=r.neg(i)),{x:t,y:i}}var a}}),h=t=>Zo(na(t,e.nByteLength));function p(t){return t>n>>Fa}const d=(t,e,r)=>ea(t.slice(e,r));class g{constructor(t,e,r){this.r=t,this.s=e,this.recovery=r,this.assertValidity()}static fromCompact(t){const r=e.nByteLength;return t=sa("compactSignature",t,2*r),new g(d(t,0,r),d(t,r,2*r))}static fromDER(t){const{r:e,s:r}=Ua.toSig(sa("DER",t));return new g(e,r)}assertValidity(){if(!f(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!f(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(t){return new g(this.r,this.s,t)}recoverPublicKey(t){const{r:n,s:i,recovery:s}=this,c=b(sa("msgHash",t));if(null==s||![0,1,2,3].includes(s))throw new Error("recovery id invalid");const l=2===s||3===s?n+e.n:n;if(l>=r.ORDER)throw new Error("recovery id 2 or 3 invalid");const f=1&s?"03":"02",p=u.fromHex(f+h(l)),d=a(l),g=o(-c*d),y=o(i*d),w=u.BASE.multiplyAndAddUnsafe(p,g,y);if(!w)throw new Error("point at infinify");return w.assertValidity(),w}hasHighS(){return p(this.s)}normalizeS(){return this.hasHighS()?new g(this.r,o(-this.s),this.recovery):this}toDERRawBytes(){return ta(this.toDERHex())}toDERHex(){return Ua.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return ta(this.toCompactHex())}toCompactHex(){return h(this.r)+h(this.s)}}const y={isValidPrivateKey(t){try{return c(t),!0}catch(t){return!1}},normPrivateKeyToScalar:c,randomPrivateKey:()=>{const t=Pa(e.n);return function(t,e,r=!1){const n=t.length,i=Ta(e),s=Pa(e);if(n<16||n<s||n>1024)throw new Error(`expected ${s}-1024 bytes of input, got ${n}`);const o=Aa(r?ea(t):ra(t),e-da)+da;return r?ia(o,i):na(o,i)}(e.randomBytes(t),e.n)},precompute:(t=8,e=u.BASE)=>(e._setWindowSize(t),e.multiply(BigInt(3)),e)};function w(t){const e=t instanceof Uint8Array,r="string"==typeof t,n=(e||r)&&t.length;return e?n===i||n===s:r?n===2*i||n===2*s:t instanceof u}const m=e.bits2int||function(t){const r=ea(t),n=8*t.length-e.nBitLength;return n>0?r>>BigInt(n):r},b=e.bits2int_modN||function(t){return o(m(t))},A=aa(e.nBitLength);function E(t){if("bigint"!=typeof t)throw new Error("bigint expected");if(!(La<=t&&t<A))throw new Error(`bigint expected < 2^${e.nBitLength}`);return na(t,e.nByteLength)}const v={lowS:e.lowS,prehash:!1},S={lowS:e.lowS,prehash:!1};return u.BASE._setWindowSize(8),{CURVE:e,getPublicKey:function(t,e=!0){return u.fromPrivateKey(t).toRawBytes(e)},getSharedSecret:function(t,e,r=!0){if(w(t))throw new Error("first arg must be private key");if(!w(e))throw new Error("second arg must be public key");return u.fromHex(e).multiply(c(t)).toRawBytes(r)},sign:function(t,n,i=v){const{seed:s,k2sig:l}=function(t,n,i=v){if(["recovered","canonical"].some((t=>t in i)))throw new Error("sign() legacy options not supported");const{hash:s,randomBytes:l}=e;let{lowS:h,prehash:d,extraEntropy:y}=i;null==h&&(h=!0),t=sa("msgHash",t),d&&(t=sa("prehashed msgHash",s(t)));const w=b(t),A=c(n),S=[E(A),E(w)];if(null!=y){const t=!0===y?l(r.BYTES):y;S.push(sa("extraEntropy",t))}const I=oa(...S),k=w;return{seed:I,k2sig:function(t){const e=m(t);if(!f(e))return;const r=a(e),n=u.BASE.multiply(e).toAffine(),i=o(n.x);if(i===La)return;const s=o(r*o(k+i*A));if(s===La)return;let c=(n.x===i?0:2)|Number(n.y&Fa),l=s;return h&&p(s)&&(l=function(t){return p(t)?o(-t):t}(s),c^=1),new g(i,l,c)}}}(t,n,i),h=e;return la(h.hash.outputLen,h.nByteLength,h.hmac)(s,l)},verify:function(t,r,n,i=S){const s=t;if(r=sa("msgHash",r),n=sa("publicKey",n),"strict"in i)throw new Error("options.strict was renamed to lowS");const{lowS:c,prehash:l}=i;let f,h;try{if("string"==typeof s||s instanceof Uint8Array)try{f=g.fromDER(s)}catch(t){if(!(t instanceof Ua.Err))throw t;f=g.fromCompact(s)}else{if("object"!=typeof s||"bigint"!=typeof s.r||"bigint"!=typeof s.s)throw new Error("PARSE");{const{r:t,s:e}=s;f=new g(t,e)}}h=u.fromHex(n)}catch(t){if("PARSE"===t.message)throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(c&&f.hasHighS())return!1;l&&(r=e.hash(r));const{r:p,s:d}=f,y=b(r),w=a(d),m=o(y*w),A=o(p*w),E=u.BASE.multiplyAndAddUnsafe(h,m,A)?.toAffine();return!!E&&o(E.x)===p},ProjectivePoint:u,Signature:g,utils:y}}function Ma(t){return{hash:t,hmac:(e,...r)=>Ba(t,e,function(...t){const e=new Uint8Array(t.reduce(((t,e)=>t+e.length),0));let r=0;return t.forEach((t=>{if(!_o(t))throw new Error("Uint8Array expected");e.set(t,r),r+=t.length})),e}(...r)),randomBytes:Ho}}BigInt(4);const Ga=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),ja=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),Va=BigInt(1),Ka=BigInt(2),Qa=(t,e)=>(t+e/Ka)/e;const Wa=function(t,e,r=!1,n={}){if(t<=pa)throw new Error(`Expected Field ORDER > 0, got ${t}`);const{nBitLength:i,nByteLength:s}=ka(t,e);if(s>2048)throw new Error("Field lengths over 2048 bytes are not supported");const o=function(t){if(t%wa===ya){const e=(t+da)/wa;return function(t,r){const n=t.pow(r,e);if(!t.eql(t.sqr(n),r))throw new Error("Cannot find square root");return n}}if(t%ba===ma){const e=(t-ma)/ba;return function(t,r){const n=t.mul(r,ga),i=t.pow(n,e),s=t.mul(r,i),o=t.mul(t.mul(s,ga),i),a=t.mul(s,t.sub(o,t.ONE));if(!t.eql(t.sqr(a),r))throw new Error("Cannot find square root");return a}}return function(t){const e=(t-da)/ga;let r,n,i;for(r=t-da,n=0;r%ga===pa;r/=ga,n++);for(i=ga;i<t&&Ea(i,e,t)!==t-da;i++);if(1===n){const e=(t+da)/wa;return function(t,r){const n=t.pow(r,e);if(!t.eql(t.sqr(n),r))throw new Error("Cannot find square root");return n}}const s=(r+da)/ga;return function(t,o){if(t.pow(o,e)===t.neg(t.ONE))throw new Error("Cannot find square root");let a=n,u=t.pow(t.mul(t.ONE,i),r),c=t.pow(o,s),l=t.pow(o,r);for(;!t.eql(l,t.ONE);){if(t.eql(l,t.ZERO))return t.ZERO;let e=1;for(let r=t.sqr(l);e<a&&!t.eql(r,t.ONE);e++)r=t.sqr(r);const r=t.pow(u,da<<BigInt(a-e-1));u=t.sqr(r),c=t.mul(c,r),l=t.mul(l,u),a=e}return c}}(t)}(t),a=Object.freeze({ORDER:t,BITS:i,BYTES:s,MASK:aa(i),ZERO:pa,ONE:da,create:e=>Aa(e,t),isValid:e=>{if("bigint"!=typeof e)throw new Error("Invalid field element: expected bigint, got "+typeof e);return pa<=e&&e<t},is0:t=>t===pa,isOdd:t=>(t&da)===da,neg:e=>Aa(-e,t),eql:(t,e)=>t===e,sqr:e=>Aa(e*e,t),add:(e,r)=>Aa(e+r,t),sub:(e,r)=>Aa(e-r,t),mul:(e,r)=>Aa(e*r,t),pow:(t,e)=>function(t,e,r){if(r<pa)throw new Error("Expected power > 0");if(r===pa)return t.ONE;if(r===da)return e;let n=t.ONE,i=e;for(;r>pa;)r&da&&(n=t.mul(n,i)),i=t.sqr(i),r>>=da;return n}(a,t,e),div:(e,r)=>Aa(e*Sa(r,t),t),sqrN:t=>t*t,addN:(t,e)=>t+e,subN:(t,e)=>t-e,mulN:(t,e)=>t*e,inv:e=>Sa(e,t),sqrt:n.sqrt||(t=>o(a,t)),invertBatch:t=>function(t,e){const r=new Array(e.length),n=e.reduce(((e,n,i)=>t.is0(n)?e:(r[i]=e,t.mul(e,n))),t.ONE),i=t.inv(n);return e.reduceRight(((e,n,i)=>t.is0(n)?e:(r[i]=t.mul(e,r[i]),t.mul(e,n))),i),r}(a,t),cmov:(t,e,r)=>r?e:t,toBytes:t=>r?ia(t,s):na(t,s),fromBytes:t=>{if(t.length!==s)throw new Error(`Fp.fromBytes: expected ${s}, got ${t.length}`);return r?ra(t):ea(t)}});return Object.freeze(a)}(Ga,void 0,void 0,{sqrt:function(t){const e=Ga,r=BigInt(3),n=BigInt(6),i=BigInt(11),s=BigInt(22),o=BigInt(23),a=BigInt(44),u=BigInt(88),c=t*t*t%e,l=c*c*t%e,f=va(l,r,e)*l%e,h=va(f,r,e)*l%e,p=va(h,Ka,e)*c%e,d=va(p,i,e)*p%e,g=va(d,s,e)*d%e,y=va(g,a,e)*g%e,w=va(y,u,e)*y%e,m=va(w,a,e)*g%e,b=va(m,r,e)*l%e,A=va(b,o,e)*d%e,E=va(A,n,e)*c%e,v=va(E,Ka,e);if(!Wa.eql(Wa.sqr(v),t))throw new Error("Cannot find square root");return v}}),za=function(t,e){const r=e=>Ha({...t,...Ma(e)});return Object.freeze({...r(e),create:r})}({a:BigInt(0),b:BigInt(7),Fp:Wa,n:ja,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:t=>{const e=ja,r=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-Va*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=r,o=BigInt("0x100000000000000000000000000000000"),a=Qa(s*t,e),u=Qa(-n*t,e);let c=Aa(t-a*r-u*i,e),l=Aa(-a*n-u*s,e);const f=c>o,h=l>o;if(f&&(c=e-c),h&&(l=e-l),c>o||l>o)throw new Error("splitScalar: Endomorphism failed, k="+t);return{k1neg:f,k1:c,k2neg:h,k2:l}}}},zo);BigInt(0),za.ProjectivePoint;class Ja{#nt;constructor(t){tt(32===ht(t),"invalid private key","privateKey","[REDACTED]"),this.#nt=lt(t)}get privateKey(){return this.#nt}get publicKey(){return Ja.computePublicKey(this.#nt)}get compressedPublicKey(){return Ja.computePublicKey(this.#nt,!0)}sign(t){tt(32===ht(t),"invalid digest length","digest",t);const e=za.sign(ot(t),ot(this.#nt),{lowS:!0});return Oo.from({r:Tt(e.r,32),s:Tt(e.s,32),v:e.recovery?28:27})}computeSharedSecret(t){const e=Ja.computePublicKey(t);return lt(za.getSharedSecret(ot(this.#nt),st(e),!1))}static computePublicKey(t,e){let r=st(t,"key");if(32===r.length)return lt(za.getPublicKey(r,!!e));if(64===r.length){const t=new Uint8Array(65);t[0]=4,t.set(r,1),r=t}return lt(za.ProjectivePoint.fromHex(r).toRawBytes(e))}static recoverPublicKey(t,e){tt(32===ht(t),"invalid digest length","digest",t);const r=Oo.from(e);let n=za.Signature.fromCompact(ot(ft([r.r,r.s])));n=n.addRecoveryBit(r.yParity);const i=n.recoverPublicKey(ot(t));return tt(null!=i,"invalid signautre for digest","signature",e),"0x"+i.toHex(!1)}static addPoints(t,e,r){const n=za.ProjectivePoint.fromHex(Ja.computePublicKey(t).substring(2)),i=za.ProjectivePoint.fromHex(Ja.computePublicKey(e).substring(2));return"0x"+n.add(i).toHex(!!r)}}function qa(t){let e=t.toString(16);for(;e.length<2;)e="0"+e;return"0x"+e}function Xa(t,e,r){let n=0;for(let i=0;i<r;i++)n=256*n+t[e+i];return n}function Ya(t,e,r,n){const i=[];for(;r<e+1+n;){const s=Za(t,r);i.push(s.result),$((r+=s.consumed)<=e+1+n,"child data too short","BUFFER_OVERRUN",{buffer:t,length:n,offset:e})}return{consumed:1+n,result:i}}function Za(t,e){$(0!==t.length,"data too short","BUFFER_OVERRUN",{buffer:t,length:0,offset:1});const r=e=>{$(e<=t.length,"data short segment too short","BUFFER_OVERRUN",{buffer:t,length:t.length,offset:e})};if(t[e]>=248){const n=t[e]-247;r(e+1+n);const i=Xa(t,e+1,n);return r(e+1+n+i),Ya(t,e,e+1+n,n+i)}if(t[e]>=192){const n=t[e]-192;return r(e+1+n),Ya(t,e,e+1,n)}if(t[e]>=184){const n=t[e]-183;r(e+1+n);const i=Xa(t,e+1,n);return r(e+1+n+i),{consumed:1+n+i,result:lt(t.slice(e+1+n,e+1+n+i))}}if(t[e]>=128){const n=t[e]-128;return r(e+1+n),{consumed:1+n,result:lt(t.slice(e+1,e+1+n))}}return{consumed:1,result:qa(t[e])}}function $a(t){const e=st(t,"data"),r=Za(e,0);return tt(r.consumed===e.length,"unexpected junk after rlp payload","data",t),r.result}function tu(t){const e=[];for(;t;)e.unshift(255&t),t>>=8;return e}function eu(t){if(Array.isArray(t)){let e=[];if(t.forEach((function(t){e=e.concat(eu(t))})),e.length<=55)return e.unshift(192+e.length),e;const r=tu(e.length);return r.unshift(247+r.length),r.concat(e)}const e=Array.prototype.slice.call(st(t,"object"));if(1===e.length&&e[0]<=127)return e;if(e.length<=55)return e.unshift(128+e.length),e;const r=tu(e.length);return r.unshift(183+r.length),r.concat(e)}const ru="0123456789abcdef";function nu(t){let e="0x";for(const r of eu(t))e+=ru[r>>4],e+=ru[15&r];return e}const iu=BigInt(0),su=BigInt(2),ou=BigInt(27),au=BigInt(28),uu=BigInt(35),cu=BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),lu=131072;function fu(t,e){let r=t.toString(16);for(;r.length<2;)r="0"+r;return r+=wo(e).substring(4),"0x"+r}function hu(t){return"0x"===t?null:Be(t)}function pu(t,e){try{return An(t)}catch(r){tt(!1,r.message,e,t)}}function du(t,e){return"0x"===t?0:kt(t,e)}function gu(t,e){if("0x"===t)return iu;const r=Et(t,e);return tt(r<=cu,"value exceeds uint size",e,r),r}function yu(t,e){const r=Et(t,"value"),n=Pt(r);return tt(n.length<=32,"value too large",`tx.${e}`,r),n}function wu(t){return An(t).map((t=>[t.address,t.storageKeys]))}function mu(t,e){tt(Array.isArray(t),`invalid ${e}`,"value",t);for(let e=0;e<t.length;e++)tt(at(t[e],32),"invalid ${ param } hash",`value[${e}]`,t[e]);return t}function bu(t,e){let r;try{if(r=du(e[0],"yParity"),0!==r&&1!==r)throw new Error("bad yParity")}catch(t){tt(!1,"invalid yParity","yParity",e[0])}const n=gt(e[1],32),i=gt(e[2],32),s=Oo.from({r:n,s:i,yParity:r});t.signature=s}class Au{#it;#st;#e;#ot;#at;#ut;#ct;#lt;#ft;#ht;#pt;#dt;#gt;#yt;#wt;#mt;get type(){return this.#it}set type(t){switch(t){case null:this.#it=null;break;case 0:case"legacy":this.#it=0;break;case 1:case"berlin":case"eip-2930":this.#it=1;break;case 2:case"london":case"eip-1559":this.#it=2;break;case 3:case"cancun":case"eip-4844":this.#it=3;break;default:tt(!1,"unsupported transaction type","type",t)}}get typeName(){switch(this.type){case 0:return"legacy";case 1:return"eip-2930";case 2:return"eip-1559";case 3:return"eip-4844"}return null}get to(){const t=this.#st;return null==t&&3===this.type?Un:t}set to(t){this.#st=null==t?null:Be(t)}get nonce(){return this.#ot}set nonce(t){this.#ot=kt(t,"value")}get gasLimit(){return this.#at}set gasLimit(t){this.#at=Et(t)}get gasPrice(){const t=this.#ut;return null!=t||0!==this.type&&1!==this.type?t:iu}set gasPrice(t){this.#ut=null==t?null:Et(t,"gasPrice")}get maxPriorityFeePerGas(){const t=this.#ct;return null==t?2===this.type||3===this.type?iu:null:t}set maxPriorityFeePerGas(t){this.#ct=null==t?null:Et(t,"maxPriorityFeePerGas")}get maxFeePerGas(){const t=this.#lt;return null==t?2===this.type||3===this.type?iu:null:t}set maxFeePerGas(t){this.#lt=null==t?null:Et(t,"maxFeePerGas")}get data(){return this.#e}set data(t){this.#e=lt(t)}get value(){return this.#ft}set value(t){this.#ft=Et(t,"value")}get chainId(){return this.#ht}set chainId(t){this.#ht=Et(t)}get signature(){return this.#pt||null}set signature(t){this.#pt=null==t?null:Oo.from(t)}get accessList(){const t=this.#dt||null;return null==t?1===this.type||2===this.type||3===this.type?[]:null:t}set accessList(t){this.#dt=null==t?null:An(t)}get maxFeePerBlobGas(){const t=this.#gt;return null==t&&3===this.type?iu:t}set maxFeePerBlobGas(t){this.#gt=null==t?null:Et(t,"maxFeePerBlobGas")}get blobVersionedHashes(){let t=this.#yt;return null==t&&3===this.type?[]:t}set blobVersionedHashes(t){if(null!=t){tt(Array.isArray(t),"blobVersionedHashes must be an Array","value",t),t=t.slice();for(let e=0;e<t.length;e++)tt(at(t[e],32),"invalid blobVersionedHash",`value[${e}]`,t[e])}this.#yt=t}get blobs(){return null==this.#mt?null:this.#mt.map((t=>Object.assign({},t)))}set blobs(t){if(null==t)return void(this.#mt=null);const e=[],r=[];for(let n=0;n<t.length;n++){const i=t[n];if(ut(i)){$(this.#wt,"adding a raw blob requires a KZG library","UNSUPPORTED_OPERATION",{operation:"set blobs()"});let t=st(i);if(tt(t.length<=lu,"blob is too large",`blobs[${n}]`,i),t.length!==lu){const e=new Uint8Array(lu);e.set(t),t=e}const s=this.#wt.blobToKzgCommitment(t),o=lt(this.#wt.computeBlobKzgProof(t,s));e.push({data:lt(t),commitment:lt(s),proof:o}),r.push(fu(1,s))}else{const t=lt(i.commitment);e.push({data:lt(i.data),commitment:t,proof:lt(i.proof)}),r.push(fu(1,t))}}this.#mt=e,this.#yt=r}get kzg(){return this.#wt}set kzg(t){this.#wt=t}constructor(){this.#it=null,this.#st=null,this.#ot=0,this.#at=iu,this.#ut=null,this.#ct=null,this.#lt=null,this.#e="0x",this.#ft=iu,this.#ht=iu,this.#pt=null,this.#dt=null,this.#gt=null,this.#yt=null,this.#mt=null,this.#wt=null}get hash(){return null==this.signature?null:ve(this.#bt(!0,!1))}get unsignedHash(){return ve(this.unsignedSerialized)}get from(){return null==this.signature?null:(t=this.unsignedHash,e=this.signature,function(t){let e;return e="string"==typeof t?Ja.computePublicKey(t,!1):t.publicKey,Be(ve("0x"+e.substring(4)).substring(26))}(Ja.recoverPublicKey(t,e)));var t,e}get fromPublicKey(){return null==this.signature?null:Ja.recoverPublicKey(this.unsignedHash,this.signature)}isSigned(){return null!=this.signature}#bt(t,e){$(!t||null!=this.signature,"cannot serialize unsigned transaction; maybe you meant .unsignedSerialized","UNSUPPORTED_OPERATION",{operation:".serialized"});const r=t?this.signature:null;switch(this.inferType()){case 0:return function(t,e){const r=[yu(t.nonce,"nonce"),yu(t.gasPrice||0,"gasPrice"),yu(t.gasLimit,"gasLimit"),t.to||"0x",yu(t.value,"value"),t.data];let n=iu;if(t.chainId!=iu)n=Et(t.chainId,"tx.chainId"),tt(!e||null==e.networkV||e.legacyChainId===n,"tx.chainId/sig.v mismatch","sig",e);else if(t.signature){const e=t.signature.legacyChainId;null!=e&&(n=e)}if(!e)return n!==iu&&(r.push(Pt(n)),r.push("0x"),r.push("0x")),nu(r);let i=BigInt(27+e.yParity);return n!==iu?i=Oo.getChainIdV(n,e.v):BigInt(e.v)!==i&&tt(!1,"tx.chainId/sig.v mismatch","sig",e),r.push(Pt(i)),r.push(Pt(e.r)),r.push(Pt(e.s)),nu(r)}(this,r);case 1:return function(t,e){const r=[yu(t.chainId,"chainId"),yu(t.nonce,"nonce"),yu(t.gasPrice||0,"gasPrice"),yu(t.gasLimit,"gasLimit"),t.to||"0x",yu(t.value,"value"),t.data,wu(t.accessList||[])];return e&&(r.push(yu(e.yParity,"recoveryParam")),r.push(Pt(e.r)),r.push(Pt(e.s))),ft(["0x01",nu(r)])}(this,r);case 2:return function(t,e){const r=[yu(t.chainId,"chainId"),yu(t.nonce,"nonce"),yu(t.maxPriorityFeePerGas||0,"maxPriorityFeePerGas"),yu(t.maxFeePerGas||0,"maxFeePerGas"),yu(t.gasLimit,"gasLimit"),t.to||"0x",yu(t.value,"value"),t.data,wu(t.accessList||[])];return e&&(r.push(yu(e.yParity,"yParity")),r.push(Pt(e.r)),r.push(Pt(e.s))),ft(["0x02",nu(r)])}(this,r);case 3:return function(t,e,r){const n=[yu(t.chainId,"chainId"),yu(t.nonce,"nonce"),yu(t.maxPriorityFeePerGas||0,"maxPriorityFeePerGas"),yu(t.maxFeePerGas||0,"maxFeePerGas"),yu(t.gasLimit,"gasLimit"),t.to||Un,yu(t.value,"value"),t.data,wu(t.accessList||[]),yu(t.maxFeePerBlobGas||0,"maxFeePerBlobGas"),mu(t.blobVersionedHashes||[],"blobVersionedHashes")];return e&&(n.push(yu(e.yParity,"yParity")),n.push(Pt(e.r)),n.push(Pt(e.s)),r)?ft(["0x03",nu([n,r.map((t=>t.data)),r.map((t=>t.commitment)),r.map((t=>t.proof))])]):ft(["0x03",nu(n)])}(this,r,e?this.blobs:null)}$(!1,"unsupported transaction type","UNSUPPORTED_OPERATION",{operation:".serialized"})}get serialized(){return this.#bt(!0,!0)}get unsignedSerialized(){return this.#bt(!1,!1)}inferType(){const t=this.inferTypes();return t.indexOf(2)>=0?2:t.pop()}inferTypes(){const t=null!=this.gasPrice,e=null!=this.maxFeePerGas||null!=this.maxPriorityFeePerGas,r=null!=this.accessList,n=null!=this.#gt||this.#yt;null!=this.maxFeePerGas&&null!=this.maxPriorityFeePerGas&&$(this.maxFeePerGas>=this.maxPriorityFeePerGas,"priorityFee cannot be more than maxFee","BAD_DATA",{value:this}),$(!e||0!==this.type&&1!==this.type,"transaction type cannot have maxFeePerGas or maxPriorityFeePerGas","BAD_DATA",{value:this}),$(0!==this.type||!r,"legacy transaction cannot have accessList","BAD_DATA",{value:this});const i=[];return null!=this.type?i.push(this.type):e?i.push(2):t?(i.push(1),r||i.push(0)):r?(i.push(1),i.push(2)):(n&&this.to||(i.push(0),i.push(1),i.push(2)),i.push(3)),i.sort(),i}isLegacy(){return 0===this.type}isBerlin(){return 1===this.type}isLondon(){return 2===this.type}isCancun(){return 3===this.type}clone(){return Au.from(this)}toJSON(){const t=t=>null==t?null:t.toString();return{type:this.type,to:this.to,data:this.data,nonce:this.nonce,gasLimit:t(this.gasLimit),gasPrice:t(this.gasPrice),maxPriorityFeePerGas:t(this.maxPriorityFeePerGas),maxFeePerGas:t(this.maxFeePerGas),value:t(this.value),chainId:t(this.chainId),sig:this.signature?this.signature.toJSON():null,accessList:this.accessList}}static from(t){if(null==t)return new Au;if("string"==typeof t){const e=st(t);if(e[0]>=127)return Au.from(function(t){const e=$a(t);tt(Array.isArray(e)&&(9===e.length||6===e.length),"invalid field count for legacy transaction","data",t);const r={type:0,nonce:du(e[0],"nonce"),gasPrice:gu(e[1],"gasPrice"),gasLimit:gu(e[2],"gasLimit"),to:hu(e[3]),value:gu(e[4],"value"),data:lt(e[5]),chainId:iu};if(6===e.length)return r;const n=gu(e[6],"v"),i=gu(e[7],"r"),s=gu(e[8],"s");if(i===iu&&s===iu)r.chainId=n;else{let t=(n-uu)/su;t<iu&&(t=iu),r.chainId=t,tt(t!==iu||n===ou||n===au,"non-canonical legacy v","v",e[6]),r.signature=Oo.from({r:gt(e[7],32),s:gt(e[8],32),v:n})}return r}(e));switch(e[0]){case 1:return Au.from(function(t){const e=$a(st(t).slice(1));tt(Array.isArray(e)&&(8===e.length||11===e.length),"invalid field count for transaction type: 1","data",lt(t));const r={type:1,chainId:gu(e[0],"chainId"),nonce:du(e[1],"nonce"),gasPrice:gu(e[2],"gasPrice"),gasLimit:gu(e[3],"gasLimit"),to:hu(e[4]),value:gu(e[5],"value"),data:lt(e[6]),accessList:pu(e[7],"accessList")};return 8===e.length||bu(r,e.slice(8)),r}(e));case 2:return Au.from(function(t){const e=$a(st(t).slice(1));tt(Array.isArray(e)&&(9===e.length||12===e.length),"invalid field count for transaction type: 2","data",lt(t));const r={type:2,chainId:gu(e[0],"chainId"),nonce:du(e[1],"nonce"),maxPriorityFeePerGas:gu(e[2],"maxPriorityFeePerGas"),maxFeePerGas:gu(e[3],"maxFeePerGas"),gasPrice:null,gasLimit:gu(e[4],"gasLimit"),to:hu(e[5]),value:gu(e[6],"value"),data:lt(e[7]),accessList:pu(e[8],"accessList")};return 9===e.length||bu(r,e.slice(9)),r}(e));case 3:return Au.from(function(t){let e=$a(st(t).slice(1)),r="3",n=null;if(4===e.length&&Array.isArray(e[0])){r="3 (network format)";const t=e[1],i=e[2],s=e[3];tt(Array.isArray(t),"invalid network format: blobs not an array","fields[1]",t),tt(Array.isArray(i),"invalid network format: commitments not an array","fields[2]",i),tt(Array.isArray(s),"invalid network format: proofs not an array","fields[3]",s),tt(t.length===i.length,"invalid network format: blobs/commitments length mismatch","fields",e),tt(t.length===s.length,"invalid network format: blobs/proofs length mismatch","fields",e),n=[];for(let r=0;r<e[1].length;r++)n.push({data:t[r],commitment:i[r],proof:s[r]});e=e[0]}tt(Array.isArray(e)&&(11===e.length||14===e.length),`invalid field count for transaction type: ${r}`,"data",lt(t));const i={type:3,chainId:gu(e[0],"chainId"),nonce:du(e[1],"nonce"),maxPriorityFeePerGas:gu(e[2],"maxPriorityFeePerGas"),maxFeePerGas:gu(e[3],"maxFeePerGas"),gasPrice:null,gasLimit:gu(e[4],"gasLimit"),to:hu(e[5]),value:gu(e[6],"value"),data:lt(e[7]),accessList:pu(e[8],"accessList"),maxFeePerBlobGas:gu(e[9],"maxFeePerBlobGas"),blobVersionedHashes:e[10]};n&&(i.blobs=n),tt(null!=i.to,`invalid address for transaction type: ${r}`,"data",t),tt(Array.isArray(i.blobVersionedHashes),"invalid blobVersionedHashes: must be an array","data",t);for(let e=0;e<i.blobVersionedHashes.length;e++)tt(at(i.blobVersionedHashes[e],32),`invalid blobVersionedHash at index ${e}: must be length 32`,"data",t);return 11===e.length||bu(i,e.slice(11)),i}(e))}$(!1,"unsupported transaction type","UNSUPPORTED_OPERATION",{operation:"from"})}const e=new Au;return null!=t.type&&(e.type=t.type),null!=t.to&&(e.to=t.to),null!=t.nonce&&(e.nonce=t.nonce),null!=t.gasLimit&&(e.gasLimit=t.gasLimit),null!=t.gasPrice&&(e.gasPrice=t.gasPrice),null!=t.maxPriorityFeePerGas&&(e.maxPriorityFeePerGas=t.maxPriorityFeePerGas),null!=t.maxFeePerGas&&(e.maxFeePerGas=t.maxFeePerGas),null!=t.maxFeePerBlobGas&&(e.maxFeePerBlobGas=t.maxFeePerBlobGas),null!=t.data&&(e.data=t.data),null!=t.value&&(e.value=t.value),null!=t.chainId&&(e.chainId=t.chainId),null!=t.signature&&(e.signature=Oo.from(t.signature)),null!=t.accessList&&(e.accessList=t.accessList),null!=t.blobVersionedHashes&&(e.blobVersionedHashes=t.blobVersionedHashes),null!=t.kzg&&(e.kzg=t.kzg),null!=t.blobs&&(e.blobs=t.blobs),null!=t.hash&&(tt(e.isSigned(),"unsigned transaction cannot define '.hash'","tx",t),tt(e.hash===t.hash,"hash mismatch","tx",t)),null!=t.from&&(tt(e.isSigned(),"unsigned transaction cannot define '.from'","tx",t),tt(e.from.toLowerCase()===(t.from||"").toLowerCase(),"from mismatch","tx",t)),e}}const Eu="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";BigInt(0);const vu=BigInt(58);function Su(t){return t.match(/^ipfs:\/\/ipfs\//i)?t=t.substring(12):t.match(/^ipfs:\/\//i)?t=t.substring(7):tt(!1,"unsupported IPFS format","link",t),`https://gateway.ipfs.io/ipfs/${t}`}class Iu{name;constructor(t){J(this,{name:t})}connect(t){return this}supportsCoinType(t){return!1}async encodeAddress(t,e){throw new Error("unsupported coin")}async decodeAddress(t,e){throw new Error("unsupported coin")}}const ku=new RegExp("^(ipfs)://(.*)$","i"),Tu=[new RegExp("^(https)://(.*)$","i"),new RegExp("^(data):(.*)$","i"),ku,new RegExp("^eip155:[0-9]+/(erc[0-9]+):(.*)$","i")];class Pu{provider;address;name;#At;#Et;constructor(t,e,r){J(this,{provider:t,address:e,name:r}),this.#At=null,this.#Et=new Oi(e,["function supportsInterface(bytes4) view returns (bool)","function resolve(bytes, bytes) view returns (bytes)","function addr(bytes32) view returns (address)","function addr(bytes32, uint) view returns (bytes)","function text(bytes32, string) view returns (string)","function contenthash(bytes32) view returns (bytes)"],t)}async supportsWildcard(){return null==this.#At&&(this.#At=(async()=>{try{return await this.#Et.supportsInterface("0x9061b923")}catch(t){if(X(t,"CALL_EXCEPTION"))return!1;throw this.#At=null,t}})()),await this.#At}async#vt(t,e){e=(e||[]).slice();const r=this.#Et.interface;e.unshift(Ws(this.name));let n=null;await this.supportsWildcard()&&(n=r.getFunction(t),$(n,"missing fragment","UNKNOWN_ERROR",{info:{funcName:t}}),e=[zs(this.name,255),r.encodeFunctionData(n,e)],t="resolve(bytes,bytes)"),e.push({enableCcipRead:!0});try{const i=await this.#Et[t](...e);return n?r.decodeFunctionResult(n,i)[0]:i}catch(t){if(!X(t,"CALL_EXCEPTION"))throw t}return null}async getAddress(t){if(null==t&&(t=60),60===t)try{const t=await this.#vt("addr(bytes32)");return null==t||t===Un?null:t}catch(t){if(X(t,"CALL_EXCEPTION"))return null;throw t}if(t>=0&&t<2147483648){let e=t+2147483648;const r=await this.#vt("addr(bytes32,uint)",[e]);if(at(r,20))return Be(r)}let e=null;for(const r of this.provider.plugins)if(r instanceof Iu&&r.supportsCoinType(t)){e=r;break}if(null==e)return null;const r=await this.#vt("addr(bytes32,uint)",[t]);if(null==r||"0x"===r)return null;const n=await e.decodeAddress(t,r);if(null!=n)return n;$(!1,"invalid coin data","UNSUPPORTED_OPERATION",{operation:`getAddress(${t})`,info:{coinType:t,data:r}})}async getText(t){const e=await this.#vt("text(bytes32,string)",[t]);return null==e||"0x"===e?null:e}async getContentHash(){const t=await this.#vt("contenthash(bytes32)");if(null==t||"0x"===t)return null;const e=t.match(/^0x(e3010170|e5010172)(([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f]*))$/);if(e){const t="e3010170"===e[1]?"ipfs":"ipns",r=parseInt(e[4],16);if(e[5].length===2*r)return`${t}://${function(t){const e=st(t);let r=It(e),n="";for(;r;)n=Eu[Number(r%vu)]+n,r/=vu;for(let t=0;t<e.length&&!e[t];t++)n=Eu[0]+n;return n}("0x"+e[2])}`}const r=t.match(/^0xe40101fa011b20([0-9a-f]*)$/);if(r&&64===r[1].length)return`bzz://${r[1]}`;$(!1,"invalid or unsupported content hash data","UNSUPPORTED_OPERATION",{operation:"getContentHash()",info:{data:t}})}async getAvatar(){return(await this._getAvatar()).url}async _getAvatar(){const t=[{type:"name",value:this.name}];try{const e=await this.getText("avatar");if(null==e)return t.push({type:"!avatar",value:""}),{url:null,linkage:t};t.push({type:"avatar",value:e});for(let r=0;r<Tu.length;r++){const n=e.match(Tu[r]);if(null==n)continue;const i=n[1].toLowerCase();switch(i){case"https":case"data":return t.push({type:"url",value:e}),{linkage:t,url:e};case"ipfs":{const r=Su(e);return t.push({type:"ipfs",value:e}),t.push({type:"url",value:r}),{linkage:t,url:r}}case"erc721":case"erc1155":{const r="erc721"===i?"tokenURI(uint256)":"uri(uint256)";t.push({type:i,value:e});const s=await this.getAddress();if(null==s)return t.push({type:"!owner",value:""}),{url:null,linkage:t};const o=(n[2]||"").split("/");if(2!==o.length)return t.push({type:`!${i}caip`,value:n[2]||""}),{url:null,linkage:t};const a=o[1],u=new Oi(o[0],["function tokenURI(uint) view returns (string)","function ownerOf(uint) view returns (address)","function uri(uint) view returns (string)","function balanceOf(address, uint256) view returns (uint)"],this.provider);if("erc721"===i){const e=await u.ownerOf(a);if(s!==e)return t.push({type:"!owner",value:e}),{url:null,linkage:t};t.push({type:"owner",value:e})}else if("erc1155"===i){const e=await u.balanceOf(s,a);if(!e)return t.push({type:"!balance",value:"0"}),{url:null,linkage:t};t.push({type:"balance",value:e.toString()})}let c=await u[r](a);if(null==c||"0x"===c)return t.push({type:"!metadata-url",value:""}),{url:null,linkage:t};t.push({type:"metadata-url-base",value:c}),"erc1155"===i&&(c=c.replace("{id}",Tt(a,32).substring(2)),t.push({type:"metadata-url-expanded",value:c})),c.match(/^ipfs:/i)&&(c=Su(c)),t.push({type:"metadata-url",value:c});let l={};const f=await new Cn(c).send();f.assertOk();try{l=f.bodyJson}catch(e){try{t.push({type:"!metadata",value:f.bodyText})}catch(e){const r=f.body;return r&&t.push({type:"!metadata",value:lt(r)}),{url:null,linkage:t}}return{url:null,linkage:t}}if(!l)return t.push({type:"!metadata",value:""}),{url:null,linkage:t};t.push({type:"metadata",value:JSON.stringify(l)});let h=l.image;if("string"!=typeof h)return t.push({type:"!imageUrl",value:""}),{url:null,linkage:t};if(h.match(/^(https:\/\/|data:)/i));else{if(null==h.match(ku))return t.push({type:"!imageUrl-ipfs",value:h}),{url:null,linkage:t};t.push({type:"imageUrl-ipfs",value:h}),h=Su(h)}return t.push({type:"url",value:h}),{linkage:t,url:h}}}}}catch(t){}return{linkage:t,url:null}}static async getEnsAddress(t){const e=await t.getNetwork(),r=e.getPlugin("org.ethers.plugins.network.Ens");return $(r,"network does not support ENS","UNSUPPORTED_OPERATION",{operation:"getEnsAddress",info:{network:e}}),r.address}static async#St(t,e){const r=await Pu.getEnsAddress(t);try{const n=new Oi(r,["function resolver(bytes32) view returns (address)"],t),i=await n.resolver(Ws(e),{enableCcipRead:!0});return i===Un?null:i}catch(t){throw t}return null}static async fromName(t,e){let r=e;for(;;){if(""===r||"."===r)return null;if("eth"!==e&&"eth"===r)return null;const n=await Pu.#St(t,r);if(null!=n){const i=new Pu(t,n,e);return r===e||await i.supportsWildcard()?i:null}r=r.split(".").slice(1).join(".")}}}const Ou=BigInt(0);function Bu(t,e){return function(r){return null==r?e:t(r)}}function Nu(t,e){return r=>{if(e&&null==r)return null;if(!Array.isArray(r))throw new Error("not an array");return r.map((e=>t(e)))}}function xu(t,e){return r=>{const n={};for(const i in t){let s=i;if(e&&i in e&&!(s in r))for(const t of e[i])if(t in r){s=t;break}try{const e=t[i](r[s]);void 0!==e&&(n[i]=e)}catch(t){$(!1,`invalid value for value.${i} (${t instanceof Error?t.message:"not-an-error"})`,"BAD_DATA",{value:r})}}return n}}function Cu(t){return tt(at(t,!0),"invalid data","value",t),t}function _u(t){return tt(at(t,32),"invalid hash","value",t),t}const Ru=xu({address:Be,blockHash:_u,blockNumber:kt,data:Cu,index:kt,removed:Bu((function(t){switch(t){case!0:case"true":return!0;case!1:case"false":return!1}tt(!1,`invalid boolean; ${JSON.stringify(t)}`,"value",t)}),!1),topics:Nu(_u),transactionHash:_u,transactionIndex:kt},{index:["logIndex"]}),Uu=xu({hash:Bu(_u),parentHash:_u,parentBeaconBlockRoot:Bu(_u,null),number:kt,timestamp:kt,nonce:Bu(Cu),difficulty:Et,gasLimit:Et,gasUsed:Et,stateRoot:Bu(_u,null),receiptsRoot:Bu(_u,null),blobGasUsed:Bu(Et,null),excessBlobGas:Bu(Et,null),miner:Bu(Be),prevRandao:Bu(_u,null),extraData:Cu,baseFeePerGas:Bu(Et)},{prevRandao:["mixHash"]}),Lu=xu({transactionIndex:kt,blockNumber:kt,transactionHash:_u,address:Be,topics:Nu(_u),data:Cu,index:kt,blockHash:_u},{index:["logIndex"]}),Fu=xu({to:Bu(Be,null),from:Bu(Be,null),contractAddress:Bu(Be,null),index:kt,root:Bu(lt),gasUsed:Et,blobGasUsed:Bu(Et,null),logsBloom:Bu(Cu),blockHash:_u,hash:_u,logs:Nu((function(t){return Lu(t)})),blockNumber:kt,cumulativeGasUsed:Et,effectiveGasPrice:Bu(Et),blobGasPrice:Bu(Et,null),status:Bu(kt),type:Bu(kt,0)},{effectiveGasPrice:["gasPrice"],hash:["transactionHash"],index:["transactionIndex"]});function Du(t){t.to&&Et(t.to)===Ou&&(t.to="0x0000000000000000000000000000000000000000");const e=xu({hash:_u,index:Bu(kt,void 0),type:t=>"0x"===t||null==t?0:kt(t),accessList:Bu(An,null),blobVersionedHashes:Bu(Nu(_u,!0),null),blockHash:Bu(_u,null),blockNumber:Bu(kt,null),transactionIndex:Bu(kt,null),from:Be,gasPrice:Bu(Et),maxPriorityFeePerGas:Bu(Et),maxFeePerGas:Bu(Et),maxFeePerBlobGas:Bu(Et,null),gasLimit:Et,to:Bu(Be,null),value:Et,nonce:kt,data:Cu,creates:Bu(Be,null),chainId:Bu(Et,null)},{data:["input"],gasLimit:["gas"],index:["transactionIndex"]})(t);if(null==e.to&&null==e.creates&&(e.creates=function(t){const e=Be(t.from);let r=Et(t.nonce,"tx.nonce").toString(16);return r="0"===r?"0x":r.length%2?"0x0"+r:"0x"+r,Be(pt(ve(nu([e,r])),12))}(e)),1!==t.type&&2!==t.type||null!=t.accessList||(e.accessList=[]),t.signature?e.signature=Oo.from(t.signature):e.signature=Oo.from(t),null==e.chainId){const t=e.signature.legacyChainId;null!=t&&(e.chainId=t)}return e.blockHash&&Et(e.blockHash)===Ou&&(e.blockHash=null),e}class Hu{name;constructor(t){J(this,{name:t})}clone(){return new Hu(this.name)}}class Mu extends Hu{effectiveBlock;txBase;txCreate;txDataZero;txDataNonzero;txAccessListStorageKey;txAccessListAddress;constructor(t,e){null==t&&(t=0),super(`org.ethers.network.plugins.GasCost#${t||0}`);const r={effectiveBlock:t};function n(t,n){let i=(e||{})[t];null==i&&(i=n),tt("number"==typeof i,`invalud value for ${t}`,"costs",e),r[t]=i}n("txBase",21e3),n("txCreate",32e3),n("txDataZero",4),n("txDataNonzero",16),n("txAccessListStorageKey",1900),n("txAccessListAddress",2400),J(this,r)}clone(){return new Mu(this.effectiveBlock,this)}}class Gu extends Hu{address;targetNetwork;constructor(t,e){super("org.ethers.plugins.network.Ens"),J(this,{address:t||"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",targetNetwork:null==e?1:e})}clone(){return new Gu(this.address,this.targetNetwork)}}class ju extends Hu{#T;#It;get url(){return this.#T}get processFunc(){return this.#It}constructor(t,e){super("org.ethers.plugins.network.FetchUrlFeeDataPlugin"),this.#T=t,this.#It=e}clone(){return this}}const Vu=new Map;class Ku{#kt;#ht;#Tt;constructor(t,e){this.#kt=t,this.#ht=Et(e),this.#Tt=new Map}toJSON(){return{name:this.name,chainId:String(this.chainId)}}get name(){return this.#kt}set name(t){this.#kt=t}get chainId(){return this.#ht}set chainId(t){this.#ht=Et(t,"chainId")}matches(t){if(null==t)return!1;if("string"==typeof t){try{return this.chainId===Et(t)}catch(t){}return this.name===t}if("number"==typeof t||"bigint"==typeof t){try{return this.chainId===Et(t)}catch(t){}return!1}if("object"==typeof t){if(null!=t.chainId){try{return this.chainId===Et(t.chainId)}catch(t){}return!1}return null!=t.name&&this.name===t.name}return!1}get plugins(){return Array.from(this.#Tt.values())}attachPlugin(t){if(this.#Tt.get(t.name))throw new Error(`cannot replace existing plugin: ${t.name} `);return this.#Tt.set(t.name,t.clone()),this}getPlugin(t){return this.#Tt.get(t)||null}getPlugins(t){return this.plugins.filter((e=>e.name.split("#")[0]===t))}clone(){const t=new Ku(this.name,this.chainId);return this.plugins.forEach((e=>{t.attachPlugin(e.clone())})),t}computeIntrinsicGas(t){const e=this.getPlugin("org.ethers.plugins.network.GasCost")||new Mu;let r=e.txBase;if(null==t.to&&(r+=e.txCreate),t.data)for(let n=2;n<t.data.length;n+=2)"00"===t.data.substring(n,n+2)?r+=e.txDataZero:r+=e.txDataNonzero;if(t.accessList){const n=An(t.accessList);for(const t in n)r+=e.txAccessListAddress+e.txAccessListStorageKey*n[t].storageKeys.length}return r}static from(t){if(function(){function t(t,e,r){const n=function(){const n=new Ku(t,e);return null!=r.ensNetwork&&n.attachPlugin(new Gu(null,r.ensNetwork)),n.attachPlugin(new Mu),(r.plugins||[]).forEach((t=>{n.attachPlugin(t)})),n};Ku.register(t,n),Ku.register(e,n),r.altNames&&r.altNames.forEach((t=>{Ku.register(t,n)}))}zu||(zu=!0,t("mainnet",1,{ensNetwork:1,altNames:["homestead"]}),t("ropsten",3,{ensNetwork:3}),t("rinkeby",4,{ensNetwork:4}),t("goerli",5,{ensNetwork:5}),t("kovan",42,{ensNetwork:42}),t("sepolia",11155111,{ensNetwork:11155111}),t("holesky",17e3,{ensNetwork:17e3}),t("classic",61,{}),t("classicKotti",6,{}),t("arbitrum",42161,{ensNetwork:1}),t("arbitrum-goerli",421613,{}),t("arbitrum-sepolia",421614,{}),t("base",8453,{ensNetwork:1}),t("base-goerli",84531,{}),t("base-sepolia",84532,{}),t("bnb",56,{ensNetwork:1}),t("bnbt",97,{}),t("linea",59144,{ensNetwork:1}),t("linea-goerli",59140,{}),t("linea-sepolia",59141,{}),t("matic",137,{ensNetwork:1,plugins:[Wu("https://gasstation.polygon.technology/v2")]}),t("matic-amoy",80002,{}),t("matic-mumbai",80001,{altNames:["maticMumbai","maticmum"],plugins:[Wu("https://gasstation-testnet.polygon.technology/v2")]}),t("optimism",10,{ensNetwork:1,plugins:[]}),t("optimism-goerli",420,{}),t("optimism-sepolia",11155420,{}),t("xdai",100,{ensNetwork:1}))}(),null==t)return Ku.from("mainnet");if("number"==typeof t&&(t=BigInt(t)),"string"==typeof t||"bigint"==typeof t){const e=Vu.get(t);if(e)return e();if("bigint"==typeof t)return new Ku("unknown",t);tt(!1,"unknown network","network",t)}if("function"==typeof t.clone)return t.clone();if("object"==typeof t){tt("string"==typeof t.name&&"number"==typeof t.chainId,"invalid network object name or chainId","network",t);const e=new Ku(t.name,t.chainId);return(t.ensAddress||null!=t.ensNetwork)&&e.attachPlugin(new Gu(t.ensAddress,t.ensNetwork)),e}tt(!1,"invalid network","network",t)}static register(t,e){"number"==typeof t&&(t=BigInt(t));const r=Vu.get(t);r&&tt(!1,`conflicting network for ${JSON.stringify(r.name)}`,"nameOrChainId",t),Vu.set(t,e)}}function Qu(t,e){const r=String(t);if(!r.match(/^[0-9.]+$/))throw new Error(`invalid gwei value: ${t}`);const n=r.split(".");if(1===n.length&&n.push(""),2!==n.length)throw new Error(`invalid gwei value: ${t}`);for(;n[1].length<e;)n[1]+="0";if(n[1].length>9){let t=BigInt(n[1].substring(0,9));n[1].substring(9).match(/^0+$/)||t++,n[1]=t.toString()}return BigInt(n[0]+n[1])}function Wu(t){return new ju(t,(async(t,e,r)=>{let n;r.setHeader("User-Agent","ethers");try{const[e,i]=await Promise.all([r.send(),t()]);n=e;const s=n.bodyJson.standard;return{gasPrice:i.gasPrice,maxFeePerGas:Qu(s.maxFee,9),maxPriorityFeePerGas:Qu(s.maxPriorityFee,9)}}catch(t){$(!1,`error encountered with polygon gas station (${JSON.stringify(r.url)})`,"SERVER_ERROR",{request:r,response:n,error:t})}}))}let zu=!1;function Ju(t){return JSON.parse(JSON.stringify(t))}class qu{#Pt;#Ot;#Bt;#Nt;constructor(t){this.#Pt=t,this.#Ot=null,this.#Bt=4e3,this.#Nt=-2}get pollingInterval(){return this.#Bt}set pollingInterval(t){this.#Bt=t}async#xt(){try{const t=await this.#Pt.getBlockNumber();if(-2===this.#Nt)return void(this.#Nt=t);if(t!==this.#Nt){for(let e=this.#Nt+1;e<=t;e++){if(null==this.#Ot)return;await this.#Pt.emit("block",e)}this.#Nt=t}}catch(t){}null!=this.#Ot&&(this.#Ot=this.#Pt._setTimeout(this.#xt.bind(this),this.#Bt))}start(){this.#Ot||(this.#Ot=this.#Pt._setTimeout(this.#xt.bind(this),this.#Bt),this.#xt())}stop(){this.#Ot&&(this.#Pt._clearTimeout(this.#Ot),this.#Ot=null)}pause(t){this.stop(),t&&(this.#Nt=-2)}resume(){this.start()}}class Xu{#Pt;#xt;#Ct;constructor(t){this.#Pt=t,this.#Ct=!1,this.#xt=t=>{this._poll(t,this.#Pt)}}async _poll(t,e){throw new Error("sub-classes must override this")}start(){this.#Ct||(this.#Ct=!0,this.#xt(-2),this.#Pt.on("block",this.#xt))}stop(){this.#Ct&&(this.#Ct=!1,this.#Pt.off("block",this.#xt))}pause(t){this.stop()}resume(){this.start()}}class Yu extends Xu{#_t;#Rt;constructor(t,e){super(t),this.#_t=e,this.#Rt=-2}pause(t){t&&(this.#Rt=-2),super.pause(t)}async _poll(t,e){const r=await e.getBlock(this.#_t);null!=r&&(-2===this.#Rt?this.#Rt=r.number:r.number>this.#Rt&&(e.emit(this.#_t,r.number),this.#Rt=r.number))}}class Zu extends Xu{#Z;constructor(t,e){super(t),this.#Z=Ju(e)}async _poll(t,e){throw new Error("@TODO")}}class $u extends Xu{#Ut;constructor(t,e){super(t),this.#Ut=e}async _poll(t,e){const r=await e.getTransactionReceipt(this.#Ut);r&&e.emit(this.#Ut,r)}}class tc{#Pt;#Z;#Ot;#Ct;#Nt;constructor(t,e){this.#Pt=t,this.#Z=Ju(e),this.#Ot=this.#xt.bind(this),this.#Ct=!1,this.#Nt=-2}async#xt(t){if(-2===this.#Nt)return;const e=Ju(this.#Z);e.fromBlock=this.#Nt+1,e.toBlock=t;const r=await this.#Pt.getLogs(e);if(0!==r.length)for(const t of r)this.#Pt.emit(this.#Z,t),this.#Nt=t.blockNumber;else this.#Nt<t-60&&(this.#Nt=t-60)}start(){this.#Ct||(this.#Ct=!0,-2===this.#Nt&&this.#Pt.getBlockNumber().then((t=>{this.#Nt=t})),this.#Pt.on("block",this.#Ot))}stop(){this.#Ct&&(this.#Ct=!1,this.#Pt.off("block",this.#Ot))}pause(t){this.stop(),t&&(this.#Nt=-2)}resume(){this.start()}}const ec=BigInt(2);function rc(t){return t&&"function"==typeof t.then}function nc(t,e){return t+":"+JSON.stringify(e,((t,e)=>{if(null==e)return"null";if("bigint"==typeof e)return`bigint:${e.toString()}`;if("string"==typeof e)return e.toLowerCase();if("object"==typeof e&&!Array.isArray(e)){const t=Object.keys(e);return t.sort(),t.reduce(((t,r)=>(t[r]=e[r],t)),{})}return e}))}class ic{name;constructor(t){J(this,{name:t})}start(){}stop(){}pause(t){}resume(){}}function sc(t){return(t=Array.from(new Set(t).values())).sort(),t}async function oc(t,e){if(null==t)throw new Error("invalid event");if(Array.isArray(t)&&(t={topics:t}),"string"==typeof t)switch(t){case"block":case"debug":case"error":case"finalized":case"network":case"pending":case"safe":return{type:t,tag:t}}if(at(t,32)){const e=t.toLowerCase();return{type:"transaction",tag:nc("tx",{hash:e}),hash:e}}if(t.orphan){const e=t;return{type:"orphan",tag:nc("orphan",e),filter:(r=e,JSON.parse(JSON.stringify(r)))}}var r;if(t.address||t.topics){const r=t,n={topics:(r.topics||[]).map((t=>null==t?null:Array.isArray(t)?sc(t.map((t=>t.toLowerCase()))):t.toLowerCase()))};if(r.address){const t=[],i=[],s=r=>{at(r)?t.push(r):i.push((async()=>{t.push(await rn(r,e))})())};Array.isArray(r.address)?r.address.forEach(s):s(r.address),i.length&&await Promise.all(i),n.address=sc(t.map((t=>t.toLowerCase())))}return{filter:n,tag:nc("event",n),type:"event"}}tt(!1,"unknown ProviderEvent","event",t)}function ac(){return(new Date).getTime()}const uc={cacheTimeout:250,pollingInterval:4e3};class cc{#Lt;#Tt;#Ft;#Dt;#Ht;#Mt;#Gt;#jt;#Vt;#Kt;#Qt;#l;constructor(t,e){if(this.#l=Object.assign({},uc,e||{}),"any"===t)this.#Mt=!0,this.#Ht=null;else if(t){const e=Ku.from(t);this.#Mt=!1,this.#Ht=Promise.resolve(e),setTimeout((()=>{this.emit("network",e,null)}),0)}else this.#Mt=!1,this.#Ht=null;this.#jt=-1,this.#Gt=new Map,this.#Lt=new Map,this.#Tt=new Map,this.#Ft=null,this.#Dt=!1,this.#Vt=1,this.#Kt=new Map,this.#Qt=!1}get pollingInterval(){return this.#l.pollingInterval}get provider(){return this}get plugins(){return Array.from(this.#Tt.values())}attachPlugin(t){if(this.#Tt.get(t.name))throw new Error(`cannot replace existing plugin: ${t.name} `);return this.#Tt.set(t.name,t.connect(this)),this}getPlugin(t){return this.#Tt.get(t)||null}get disableCcipRead(){return this.#Qt}set disableCcipRead(t){this.#Qt=!!t}async#Wt(t){const e=this.#l.cacheTimeout;if(e<0)return await this._perform(t);const r=nc(t.method,t);let n=this.#Gt.get(r);return n||(n=this._perform(t),this.#Gt.set(r,n),setTimeout((()=>{this.#Gt.get(r)===n&&this.#Gt.delete(r)}),e)),await n}async ccipReadFetch(t,e,r){if(this.disableCcipRead||0===r.length||null==t.to)return null;const n=t.to.toLowerCase(),i=e.toLowerCase(),s=[];for(let e=0;e<r.length;e++){const o=r[e],a=o.replace("{sender}",n).replace("{data}",i),u=new Cn(a);-1===o.indexOf("{data}")&&(u.body={data:i,sender:n}),this.emit("debug",{action:"sendCcipReadFetchRequest",request:u,index:e,urls:r});let c="unknown error";const l=await u.send();try{const t=l.bodyJson;if(t.data)return this.emit("debug",{action:"receiveCcipReadFetchResult",request:u,result:t}),t.data;t.message&&(c=t.message),this.emit("debug",{action:"receiveCcipReadFetchError",request:u,result:t})}catch(t){}$(l.statusCode<400||l.statusCode>=500,`response not found during CCIP fetch: ${c}`,"OFFCHAIN_FAULT",{reason:"404_MISSING_RESOURCE",transaction:t,info:{url:o,errorMessage:c}}),s.push(c)}$(!1,`error encountered during CCIP fetch: ${s.map((t=>JSON.stringify(t))).join(", ")}`,"OFFCHAIN_FAULT",{reason:"500_SERVER_ERROR",transaction:t,info:{urls:r,errorMessages:s}})}_wrapBlock(t,e){return new Jn(function(t){const e=Uu(t);return e.transactions=t.transactions.map((t=>"string"==typeof t?t:Du(t))),e}(t),this)}_wrapLog(t,e){return new qn(function(t){return Ru(t)}(t),this)}_wrapTransactionReceipt(t,e){return new Xn(function(t){return Fu(t)}(t),this)}_wrapTransactionResponse(t,e){return new Yn(Du(t),this)}_detectNetwork(){$(!1,"sub-classes must implement this","UNSUPPORTED_OPERATION",{operation:"_detectNetwork"})}async _perform(t){$(!1,`unsupported method: ${t.method}`,"UNSUPPORTED_OPERATION",{operation:t.method,info:t})}async getBlockNumber(){const t=kt(await this.#Wt({method:"getBlockNumber"}),"%response");return this.#jt>=0&&(this.#jt=t),t}_getAddress(t){return rn(t,this)}_getBlockTag(t){if(null==t)return"latest";switch(t){case"earliest":return"0x0";case"finalized":case"latest":case"pending":case"safe":return t}return at(t)?at(t,32)?t:Ot(t):("bigint"==typeof t&&(t=kt(t,"blockTag")),"number"==typeof t?t>=0?Ot(t):this.#jt>=0?Ot(this.#jt+t):this.getBlockNumber().then((e=>Ot(e+t))):void tt(!1,"invalid blockTag","blockTag",t))}_getFilter(t){const e=(t.topics||[]).map((t=>null==t?null:Array.isArray(t)?sc(t.map((t=>t.toLowerCase()))):t.toLowerCase())),r="blockHash"in t?t.blockHash:void 0,n=(t,n,i)=>{let s;switch(t.length){case 0:break;case 1:s=t[0];break;default:t.sort(),s=t}if(r&&(null!=n||null!=i))throw new Error("invalid filter");const o={};return s&&(o.address=s),e.length&&(o.topics=e),n&&(o.fromBlock=n),i&&(o.toBlock=i),r&&(o.blockHash=r),o};let i,s,o=[];if(t.address)if(Array.isArray(t.address))for(const e of t.address)o.push(this._getAddress(e));else o.push(this._getAddress(t.address));return"fromBlock"in t&&(i=this._getBlockTag(t.fromBlock)),"toBlock"in t&&(s=this._getBlockTag(t.toBlock)),o.filter((t=>"string"!=typeof t)).length||null!=i&&"string"!=typeof i||null!=s&&"string"!=typeof s?Promise.all([Promise.all(o),i,s]).then((t=>n(t[0],t[1],t[2]))):n(o,i,s)}_getTransactionRequest(t){const e=zn(t),r=[];if(["to","from"].forEach((t=>{if(null==e[t])return;const n=rn(e[t],this);rc(n)?r.push(async function(){e[t]=await n}()):e[t]=n})),null!=e.blockTag){const t=this._getBlockTag(e.blockTag);rc(t)?r.push(async function(){e.blockTag=await t}()):e.blockTag=t}return r.length?async function(){return await Promise.all(r),e}():e}async getNetwork(){if(null==this.#Ht){const t=(async()=>{try{const t=await this._detectNetwork();return this.emit("network",t,null),t}catch(e){throw this.#Ht===t&&(this.#Ht=null),e}})();return this.#Ht=t,(await t).clone()}const t=this.#Ht,[e,r]=await Promise.all([t,this._detectNetwork()]);return e.chainId!==r.chainId&&(this.#Mt?(this.emit("network",r,e),this.#Ht===t&&(this.#Ht=Promise.resolve(r))):$(!1,`network changed: ${e.chainId} => ${r.chainId} `,"NETWORK_ERROR",{event:"changed"})),e.clone()}async getFeeData(){const t=await this.getNetwork(),e=async()=>{const{_block:e,gasPrice:r,priorityFee:n}=await z({_block:this.#zt("latest",!1),gasPrice:(async()=>{try{return Et(await this.#Wt({method:"getGasPrice"}),"%response")}catch(t){}return null})(),priorityFee:(async()=>{try{return Et(await this.#Wt({method:"getPriorityFee"}),"%response")}catch(t){}return null})()});let i=null,s=null;const o=this._wrapBlock(e,t);return o&&o.baseFeePerGas&&(s=null!=n?n:BigInt("1000000000"),i=o.baseFeePerGas*ec+s),new Wn(r,i,s)},r=t.getPlugin("org.ethers.plugins.network.FetchUrlFeeDataPlugin");if(r){const t=new Cn(r.url),n=await r.processFunc(e,this,t);return new Wn(n.gasPrice,n.maxFeePerGas,n.maxPriorityFeePerGas)}return await e()}async estimateGas(t){let e=this._getTransactionRequest(t);return rc(e)&&(e=await e),Et(await this.#Wt({method:"estimateGas",transaction:e}),"%response")}async#Jt(t,e,r){$(r<10,"CCIP read exceeded maximum redirections","OFFCHAIN_FAULT",{reason:"TOO_MANY_REDIRECTS",transaction:Object.assign({},t,{blockTag:e,enableCcipRead:!0})});const n=zn(t);try{return lt(await this._perform({method:"call",transaction:n,blockTag:e}))}catch(t){if(!this.disableCcipRead&&Y(t)&&t.data&&r>=0&&"latest"===e&&null!=n.to&&"0x556f1830"===pt(t.data,0,4)){const i=t.data,s=await rn(n.to,this);let o;try{o=function(t){const e={sender:"",urls:[],calldata:"",selector:"",extraData:"",errorArgs:[]};$(ht(t)>=160,"insufficient OffchainLookup data","OFFCHAIN_FAULT",{reason:"insufficient OffchainLookup data"});const r=pt(t,0,32);$(pt(r,0,12)===pt(yc,0,12),"corrupt OffchainLookup sender","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup sender"}),e.sender=pt(r,12);try{const r=[],n=kt(pt(t,32,64)),i=kt(pt(t,n,n+32)),s=pt(t,n+32);for(let t=0;t<i;t++){const e=lc(s,32*t);if(null==e)throw new Error("abort");r.push(e)}e.urls=r}catch(t){$(!1,"corrupt OffchainLookup urls","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup urls"})}try{const r=fc(t,64);if(null==r)throw new Error("abort");e.calldata=r}catch(t){$(!1,"corrupt OffchainLookup calldata","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup calldata"})}$(pt(t,100,128)===pt(yc,0,28),"corrupt OffchainLookup callbaackSelector","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup callbaackSelector"}),e.selector=pt(t,96,100);try{const r=fc(t,128);if(null==r)throw new Error("abort");e.extraData=r}catch(t){$(!1,"corrupt OffchainLookup extraData","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup extraData"})}return e.errorArgs="sender,urls,calldata,selector,extraData".split(/,/).map((t=>e[t])),e}(pt(t.data,4))}catch(t){$(!1,t.message,"OFFCHAIN_FAULT",{reason:"BAD_DATA",transaction:n,info:{data:i}})}$(o.sender.toLowerCase()===s.toLowerCase(),"CCIP Read sender mismatch","CALL_EXCEPTION",{action:"call",data:i,reason:"OffchainLookup",transaction:n,invocation:null,revert:{signature:"OffchainLookup(address,string[],bytes,bytes4,bytes)",name:"OffchainLookup",args:o.errorArgs}});const a=await this.ccipReadFetch(n,o.calldata,o.urls);$(null!=a,"CCIP Read failed to fetch data","OFFCHAIN_FAULT",{reason:"FETCH_FAILED",transaction:n,info:{data:t.data,errorArgs:o.errorArgs}});const u={to:s,data:ft([o.selector,gc([a,o.extraData])])};this.emit("debug",{action:"sendCcipReadCall",transaction:u});try{const t=await this.#Jt(u,e,r+1);return this.emit("debug",{action:"receiveCcipReadCallResult",transaction:Object.assign({},u),result:t}),t}catch(t){throw this.emit("debug",{action:"receiveCcipReadCallError",transaction:Object.assign({},u),error:t}),t}}throw t}}async#qt(t){const{value:e}=await z({network:this.getNetwork(),value:t});return e}async call(t){const{tx:e,blockTag:r}=await z({tx:this._getTransactionRequest(t),blockTag:this._getBlockTag(t.blockTag)});return await this.#qt(this.#Jt(e,r,t.enableCcipRead?0:-1))}async#Xt(t,e,r){let n=this._getAddress(e),i=this._getBlockTag(r);return"string"==typeof n&&"string"==typeof i||([n,i]=await Promise.all([n,i])),await this.#qt(this.#Wt(Object.assign(t,{address:n,blockTag:i})))}async getBalance(t,e){return Et(await this.#Xt({method:"getBalance"},t,e),"%response")}async getTransactionCount(t,e){return kt(await this.#Xt({method:"getTransactionCount"},t,e),"%response")}async getCode(t,e){return lt(await this.#Xt({method:"getCode"},t,e))}async getStorage(t,e,r){const n=Et(e,"position");return lt(await this.#Xt({method:"getStorage",position:n},t,r))}async broadcastTransaction(t){const{blockNumber:e,hash:r,network:n}=await z({blockNumber:this.getBlockNumber(),hash:this._perform({method:"broadcastTransaction",signedTransaction:t}),network:this.getNetwork()}),i=Au.from(t);if(i.hash!==r)throw new Error("@TODO: the returned hash did not match");return this._wrapTransactionResponse(i,n).replaceableTransaction(e)}async#zt(t,e){if(at(t,32))return await this.#Wt({method:"getBlock",blockHash:t,includeTransactions:e});let r=this._getBlockTag(t);return"string"!=typeof r&&(r=await r),await this.#Wt({method:"getBlock",blockTag:r,includeTransactions:e})}async getBlock(t,e){const{network:r,params:n}=await z({network:this.getNetwork(),params:this.#zt(t,!!e)});return null==n?null:this._wrapBlock(n,r)}async getTransaction(t){const{network:e,params:r}=await z({network:this.getNetwork(),params:this.#Wt({method:"getTransaction",hash:t})});return null==r?null:this._wrapTransactionResponse(r,e)}async getTransactionReceipt(t){const{network:e,params:r}=await z({network:this.getNetwork(),params:this.#Wt({method:"getTransactionReceipt",hash:t})});if(null==r)return null;if(null==r.gasPrice&&null==r.effectiveGasPrice){const e=await this.#Wt({method:"getTransaction",hash:t});if(null==e)throw new Error("report this; could not find tx or effectiveGasPrice");r.effectiveGasPrice=e.gasPrice}return this._wrapTransactionReceipt(r,e)}async getTransactionResult(t){const{result:e}=await z({network:this.getNetwork(),result:this.#Wt({method:"getTransactionResult",hash:t})});return null==e?null:lt(e)}async getLogs(t){let e=this._getFilter(t);rc(e)&&(e=await e);const{network:r,params:n}=await z({network:this.getNetwork(),params:this.#Wt({method:"getLogs",filter:e})});return n.map((t=>this._wrapLog(t,r)))}_getProvider(t){$(!1,"provider cannot connect to target network","UNSUPPORTED_OPERATION",{operation:"_getProvider()"})}async getResolver(t){return await Pu.fromName(this,t)}async getAvatar(t){const e=await this.getResolver(t);return e?await e.getAvatar():null}async resolveName(t){const e=await this.getResolver(t);return e?await e.getAddress():null}async lookupAddress(t){const e=Ws((t=Be(t)).substring(2).toLowerCase()+".addr.reverse");try{const r=await Pu.getEnsAddress(this),n=new Oi(r,["function resolver(bytes32) view returns (address)"],this),i=await n.resolver(e);if(null==i||i===Un)return null;const s=new Oi(i,["function name(bytes32) view returns (string)"],this),o=await s.name(e);return await this.resolveName(o)!==t?null:o}catch(t){if(X(t,"BAD_DATA")&&"0x"===t.value)return null;if(X(t,"CALL_EXCEPTION"))return null;throw t}return null}async waitForTransaction(t,e,r){const n=null!=e?e:1;return 0===n?this.getTransactionReceipt(t):new Promise((async(e,i)=>{let s=null;const o=async r=>{try{const i=await this.getTransactionReceipt(t);if(null!=i&&r-i.blockNumber+1>=n)return e(i),void(s&&(clearTimeout(s),s=null))}catch(t){console.log("EEE",t)}this.once("block",o)};null!=r&&(s=setTimeout((()=>{null!=s&&(s=null,this.off("block",o),i(Z("timeout","TIMEOUT",{reason:"timeout"})))}),r)),o(await this.getBlockNumber())}))}async waitForBlock(t){$(!1,"not implemented yet","NOT_IMPLEMENTED",{operation:"waitForBlock"})}_clearTimeout(t){const e=this.#Kt.get(t);e&&(e.timer&&clearTimeout(e.timer),this.#Kt.delete(t))}_setTimeout(t,e){null==e&&(e=0);const r=this.#Vt++,n=()=>{this.#Kt.delete(r),t()};if(this.paused)this.#Kt.set(r,{timer:null,func:n,time:e});else{const t=setTimeout(n,e);this.#Kt.set(r,{timer:t,func:n,time:ac()})}return r}_forEachSubscriber(t){for(const e of this.#Lt.values())t(e.subscriber)}_getSubscriber(t){switch(t.type){case"debug":case"error":case"network":return new ic(t.type);case"block":{const t=new qu(this);return t.pollingInterval=this.pollingInterval,t}case"safe":case"finalized":return new Yu(this,t.type);case"event":return new tc(this,t.filter);case"transaction":return new $u(this,t.hash);case"orphan":return new Zu(this,t.filter)}throw new Error(`unsupported event: ${t.type}`)}_recoverSubscriber(t,e){for(const r of this.#Lt.values())if(r.subscriber===t){r.started&&r.subscriber.stop(),r.subscriber=e,r.started&&e.start(),null!=this.#Ft&&e.pause(this.#Ft);break}}async#Yt(t,e){let r=await oc(t,this);return"event"===r.type&&e&&e.length>0&&!0===e[0].removed&&(r=await oc({orphan:"drop-log",log:e[0]},this)),this.#Lt.get(r.tag)||null}async#Zt(t){const e=await oc(t,this),r=e.tag;let n=this.#Lt.get(r);return n||(n={subscriber:this._getSubscriber(e),tag:r,addressableMap:new WeakMap,nameMap:new Map,started:!1,listeners:[]},this.#Lt.set(r,n)),n}async on(t,e){const r=await this.#Zt(t);return r.listeners.push({listener:e,once:!1}),r.started||(r.subscriber.start(),r.started=!0,null!=this.#Ft&&r.subscriber.pause(this.#Ft)),this}async once(t,e){const r=await this.#Zt(t);return r.listeners.push({listener:e,once:!0}),r.started||(r.subscriber.start(),r.started=!0,null!=this.#Ft&&r.subscriber.pause(this.#Ft)),this}async emit(t,...e){const r=await this.#Yt(t,e);if(!r||0===r.listeners.length)return!1;const n=r.listeners.length;return r.listeners=r.listeners.filter((({listener:r,once:n})=>{const i=new ti(this,n?null:r,t);try{r.call(this,...e,i)}catch(t){}return!n})),0===r.listeners.length&&(r.started&&r.subscriber.stop(),this.#Lt.delete(r.tag)),n>0}async listenerCount(t){if(t){const e=await this.#Yt(t);return e?e.listeners.length:0}let e=0;for(const{listeners:t}of this.#Lt.values())e+=t.length;return e}async listeners(t){if(t){const e=await this.#Yt(t);return e?e.listeners.map((({listener:t})=>t)):[]}let e=[];for(const{listeners:t}of this.#Lt.values())e=e.concat(t.map((({listener:t})=>t)));return e}async off(t,e){const r=await this.#Yt(t);if(!r)return this;if(e){const t=r.listeners.map((({listener:t})=>t)).indexOf(e);t>=0&&r.listeners.splice(t,1)}return e&&0!==r.listeners.length||(r.started&&r.subscriber.stop(),this.#Lt.delete(r.tag)),this}async removeAllListeners(t){if(t){const{tag:e,started:r,subscriber:n}=await this.#Zt(t);r&&n.stop(),this.#Lt.delete(e)}else for(const[t,{started:e,subscriber:r}]of this.#Lt)e&&r.stop(),this.#Lt.delete(t);return this}async addListener(t,e){return await this.on(t,e)}async removeListener(t,e){return this.off(t,e)}get destroyed(){return this.#Dt}destroy(){this.removeAllListeners();for(const t of this.#Kt.keys())this._clearTimeout(t);this.#Dt=!0}get paused(){return null!=this.#Ft}set paused(t){!!t!==this.paused&&(this.paused?this.resume():this.pause(!1))}pause(t){if(this.#jt=-1,null!=this.#Ft){if(this.#Ft==!!t)return;$(!1,"cannot change pause type; resume first","UNSUPPORTED_OPERATION",{operation:"pause"})}this._forEachSubscriber((e=>e.pause(t))),this.#Ft=!!t;for(const t of this.#Kt.values())t.timer&&clearTimeout(t.timer),t.time=ac()-t.time}resume(){if(null!=this.#Ft){this._forEachSubscriber((t=>t.resume())),this.#Ft=null;for(const t of this.#Kt.values()){let e=t.time;e<0&&(e=0),t.time=ac(),setTimeout(t.func,e)}}}}function lc(t,e){try{const r=fc(t,e);if(r)return $e(r)}catch(t){}return null}function fc(t,e){if("0x"===t)return null;try{const r=kt(pt(t,e,e+32)),n=kt(pt(t,r,r+32));return pt(t,r+32,r+32+n)}catch(t){}return null}function hc(t){const e=Pt(t);if(e.length>32)throw new Error("internal; should not happen");const r=new Uint8Array(32);return r.set(e,32-e.length),r}function pc(t){if(t.length%32==0)return t;const e=new Uint8Array(32*Math.ceil(t.length/32));return e.set(t),e}const dc=new Uint8Array([]);function gc(t){const e=[];let r=0;for(let n=0;n<t.length;n++)e.push(dc),r+=32;for(let n=0;n<t.length;n++){const i=st(t[n]);e[n]=hc(r),e.push(hc(i.length)),e.push(pc(i)),r+=32+32*Math.ceil(i.length/32)}return ft(e)}const yc="0x0000000000000000000000000000000000000000000000000000000000000000";function wc(t,e){if(t.provider)return t.provider;$(!1,"missing provider","UNSUPPORTED_OPERATION",{operation:e})}async function mc(t,e){let r=zn(e);if(null!=r.to&&(r.to=rn(r.to,t)),null!=r.from){const e=r.from;r.from=Promise.all([t.getAddress(),rn(e,t)]).then((([t,e])=>(tt(t.toLowerCase()===e.toLowerCase(),"transaction from mismatch","tx.from",e),t)))}else r.from=t.getAddress();return await z(r)}class bc{provider;constructor(t){J(this,{provider:t||null})}async getNonce(t){return wc(this,"getTransactionCount").getTransactionCount(await this.getAddress(),t)}async populateCall(t){return await mc(this,t)}async populateTransaction(t){const e=wc(this,"populateTransaction"),r=await mc(this,t);null==r.nonce&&(r.nonce=await this.getNonce("pending")),null==r.gasLimit&&(r.gasLimit=await this.estimateGas(r));const n=await this.provider.getNetwork();null!=r.chainId?tt(Et(r.chainId)===n.chainId,"transaction chainId mismatch","tx.chainId",t.chainId):r.chainId=n.chainId;const i=null!=r.maxFeePerGas||null!=r.maxPriorityFeePerGas;if(null==r.gasPrice||2!==r.type&&!i?0!==r.type&&1!==r.type||!i||tt(!1,"pre-eip-1559 transaction do not support maxFeePerGas/maxPriorityFeePerGas","tx",t):tt(!1,"eip-1559 transaction do not support gasPrice","tx",t),2!==r.type&&null!=r.type||null==r.maxFeePerGas||null==r.maxPriorityFeePerGas)if(0===r.type||1===r.type){const t=await e.getFeeData();$(null!=t.gasPrice,"network does not support gasPrice","UNSUPPORTED_OPERATION",{operation:"getGasPrice"}),null==r.gasPrice&&(r.gasPrice=t.gasPrice)}else{const t=await e.getFeeData();if(null==r.type)if(null!=t.maxFeePerGas&&null!=t.maxPriorityFeePerGas)if(r.type=2,null!=r.gasPrice){const t=r.gasPrice;delete r.gasPrice,r.maxFeePerGas=t,r.maxPriorityFeePerGas=t}else null==r.maxFeePerGas&&(r.maxFeePerGas=t.maxFeePerGas),null==r.maxPriorityFeePerGas&&(r.maxPriorityFeePerGas=t.maxPriorityFeePerGas);else null!=t.gasPrice?($(!i,"network does not support EIP-1559","UNSUPPORTED_OPERATION",{operation:"populateTransaction"}),null==r.gasPrice&&(r.gasPrice=t.gasPrice),r.type=0):$(!1,"failed to get consistent fee data","UNSUPPORTED_OPERATION",{operation:"signer.getFeeData"});else 2!==r.type&&3!==r.type||(null==r.maxFeePerGas&&(r.maxFeePerGas=t.maxFeePerGas),null==r.maxPriorityFeePerGas&&(r.maxPriorityFeePerGas=t.maxPriorityFeePerGas))}else r.type=2;return await z(r)}async estimateGas(t){return wc(this,"estimateGas").estimateGas(await this.populateCall(t))}async call(t){return wc(this,"call").call(await this.populateCall(t))}async resolveName(t){const e=wc(this,"resolveName");return await e.resolveName(t)}async sendTransaction(t){const e=wc(this,"sendTransaction"),r=await this.populateTransaction(t);delete r.from;const n=Au.from(r);return await e.broadcastTransaction(await this.signTransaction(n))}}class Ac{#Pt;#$t;#Ot;#Ct;#te;#ee;constructor(t){this.#Pt=t,this.#$t=null,this.#Ot=this.#xt.bind(this),this.#Ct=!1,this.#te=null,this.#ee=!1}_subscribe(t){throw new Error("subclasses must override this")}_emitResults(t,e){throw new Error("subclasses must override this")}_recover(t){throw new Error("subclasses must override this")}async#xt(t){try{null==this.#$t&&(this.#$t=this._subscribe(this.#Pt));let t=null;try{t=await this.#$t}catch(t){if(!X(t,"UNSUPPORTED_OPERATION")||"eth_newFilter"!==t.operation)throw t}if(null==t)return this.#$t=null,void this.#Pt._recoverSubscriber(this,this._recover(this.#Pt));const e=await this.#Pt.getNetwork();if(this.#te||(this.#te=e),this.#te.chainId!==e.chainId)throw new Error("chaid changed");if(this.#ee)return;const r=await this.#Pt.send("eth_getFilterChanges",[t]);await this._emitResults(this.#Pt,r)}catch(t){console.log("@TODO",t)}this.#Pt.once("block",this.#Ot)}#re(){const t=this.#$t;t&&(this.#$t=null,t.then((t=>{this.#Pt.destroyed||this.#Pt.send("eth_uninstallFilter",[t])})))}start(){this.#Ct||(this.#Ct=!0,this.#xt(-2))}stop(){this.#Ct&&(this.#Ct=!1,this.#ee=!0,this.#re(),this.#Pt.off("block",this.#Ot))}pause(t){t&&this.#re(),this.#Pt.off("block",this.#Ot)}resume(){this.start()}}class Ec extends Ac{#ne;constructor(t,e){var r;super(t),this.#ne=(r=e,JSON.parse(JSON.stringify(r)))}_recover(t){return new tc(t,this.#ne)}async _subscribe(t){return await t.send("eth_newFilter",[this.#ne])}async _emitResults(t,e){for(const r of e)t.emit(this.#ne,t._wrapLog(r,t._network))}}class vc extends Ac{async _subscribe(t){return await t.send("eth_newPendingTransactionFilter",[])}async _emitResults(t,e){for(const r of e)t.emit("pending",r)}}const Sc="bigint,boolean,function,number,string,symbol".split(/,/g);function Ic(t){if(null==t||Sc.indexOf(typeof t)>=0)return t;if("function"==typeof t.getAddress)return t;if(Array.isArray(t))return t.map(Ic);if("object"==typeof t)return Object.keys(t).reduce(((e,r)=>(e[r]=t[r],e)),{});throw new Error(`should not happen: ${t} (${typeof t})`)}function kc(t){return new Promise((e=>{setTimeout(e,t)}))}function Tc(t){return t?t.toLowerCase():t}function Pc(t){return t&&"number"==typeof t.pollingInterval}const Oc={polling:!1,staticNetwork:null,batchStallTime:10,batchMaxSize:1<<20,batchMaxCount:100,cacheTimeout:250,pollingInterval:4e3};class Bc extends bc{address;constructor(t,e){super(t),J(this,{address:e=Be(e)})}connect(t){$(!1,"cannot reconnect JsonRpcSigner","UNSUPPORTED_OPERATION",{operation:"signer.connect"})}async getAddress(){return this.address}async populateTransaction(t){return await this.populateCall(t)}async sendUncheckedTransaction(t){const e=Ic(t),r=[];if(e.from){const n=e.from;r.push((async()=>{const r=await rn(n,this.provider);tt(null!=r&&r.toLowerCase()===this.address.toLowerCase(),"from address mismatch","transaction",t),e.from=r})())}else e.from=this.address;if(null==e.gasLimit&&r.push((async()=>{e.gasLimit=await this.provider.estimateGas({...e,from:this.address})})()),null!=e.to){const t=e.to;r.push((async()=>{e.to=await rn(t,this.provider)})())}r.length&&await Promise.all(r);const n=this.provider.getRpcTransaction(e);return this.provider.send("eth_sendTransaction",[n])}async sendTransaction(t){const e=await this.provider.getBlockNumber(),r=await this.sendUncheckedTransaction(t);return await new Promise(((t,n)=>{const i=[1e3,100];let s=0;const o=async()=>{try{const n=await this.provider.getTransaction(r);if(null!=n)return void t(n.replaceableTransaction(e))}catch(t){if(X(t,"CANCELLED")||X(t,"BAD_DATA")||X(t,"NETWORK_ERROR"))return null==t.info&&(t.info={}),t.info.sendTransactionHash=r,void n(t);if(X(t,"INVALID_ARGUMENT")&&(s++,null==t.info&&(t.info={}),t.info.sendTransactionHash=r,s>10))return void n(t);this.provider.emit("error",Z("failed to fetch transation after sending (will try again)","UNKNOWN_ERROR",{error:t}))}this.provider._setTimeout((()=>{o()}),i.pop()||4e3)};o()}))}async signTransaction(t){const e=Ic(t);if(e.from){const r=await rn(e.from,this.provider);tt(null!=r&&r.toLowerCase()===this.address.toLowerCase(),"from address mismatch","transaction",t),e.from=r}else e.from=this.address;const r=this.provider.getRpcTransaction(e);return await this.provider.send("eth_signTransaction",[r])}async signMessage(t){const e="string"==typeof t?Ze(t):t;return await this.provider.send("personal_sign",[lt(e),this.address.toLowerCase()])}async signTypedData(t,e,r){const n=Ic(r),i=await mn.resolveNames(t,e,n,(async t=>{const e=await rn(t);return tt(null!=e,"TypedData does not support null address","value",t),e}));return await this.provider.send("eth_signTypedData_v4",[this.address.toLowerCase(),JSON.stringify(mn.getPayload(i.domain,e,i.value))])}async unlock(t){return this.provider.send("personal_unlockAccount",[this.address.toLowerCase(),t,null])}async _legacySignMessage(t){const e="string"==typeof t?Ze(t):t;return await this.provider.send("eth_sign",[this.address.toLowerCase(),lt(e)])}}class Nc extends cc{#l;#ie;#se;#oe;#ae;#te;#ue;#ce(){if(this.#oe)return;const t=1===this._getOption("batchMaxCount")?0:this._getOption("batchStallTime");this.#oe=setTimeout((()=>{this.#oe=null;const t=this.#se;for(this.#se=[];t.length;){const e=[t.shift()];for(;t.length&&e.length!==this.#l.batchMaxCount;)if(e.push(t.shift()),JSON.stringify(e.map((t=>t.payload))).length>this.#l.batchMaxSize){t.unshift(e.pop());break}(async()=>{const t=1===e.length?e[0].payload:e.map((t=>t.payload));this.emit("debug",{action:"sendRpcPayload",payload:t});try{const r=await this._send(t);this.emit("debug",{action:"receiveRpcResult",result:r});for(const{resolve:t,reject:n,payload:i}of e){if(this.destroyed){n(Z("provider destroyed; cancelled request","UNSUPPORTED_OPERATION",{operation:i.method}));continue}const e=r.filter((t=>t.id===i.id))[0];if(null!=e)"error"in e?n(this.getRpcError(i,e)):t(e.result);else{const t=Z("missing response for request","BAD_DATA",{value:r,info:{payload:i}});this.emit("error",t),n(t)}}}catch(t){this.emit("debug",{action:"receiveRpcError",error:t});for(const{reject:r}of e)r(t)}})()}}),t)}constructor(t,e){super(t,e),this.#ie=1,this.#l=Object.assign({},Oc,e||{}),this.#se=[],this.#oe=null,this.#te=null,this.#ue=null;{let t=null;const e=new Promise((e=>{t=e}));this.#ae={promise:e,resolve:t}}const r=this._getOption("staticNetwork");"boolean"==typeof r?(tt(!r||"any"!==t,"staticNetwork cannot be used on special network 'any'","options",e),r&&null!=t&&(this.#te=Ku.from(t))):r&&(tt(null==t||r.matches(t),"staticNetwork MUST match network object","options",e),this.#te=r)}_getOption(t){return this.#l[t]}get _network(){return $(this.#te,"network is not available yet","NETWORK_ERROR"),this.#te}async _perform(t){if("call"===t.method||"estimateGas"===t.method){let e=t.transaction;if(e&&null!=e.type&&Et(e.type)&&null==e.maxFeePerGas&&null==e.maxPriorityFeePerGas){const r=await this.getFeeData();null==r.maxFeePerGas&&null==r.maxPriorityFeePerGas&&(t=Object.assign({},t,{transaction:Object.assign({},e,{type:void 0})}))}}const e=this.getRpcRequest(t);return null!=e?await this.send(e.method,e.args):super._perform(t)}async _detectNetwork(){const t=this._getOption("staticNetwork");if(t){if(!0!==t)return t;if(this.#te)return this.#te}return this.#ue?await this.#ue:this.ready?(this.#ue=(async()=>{try{const t=Ku.from(Et(await this.send("eth_chainId",[])));return this.#ue=null,t}catch(t){throw this.#ue=null,t}})(),await this.#ue):(this.#ue=(async()=>{const t={id:this.#ie++,method:"eth_chainId",params:[],jsonrpc:"2.0"};let e;this.emit("debug",{action:"sendRpcPayload",payload:t});try{e=(await this._send(t))[0],this.#ue=null}catch(t){throw this.#ue=null,this.emit("debug",{action:"receiveRpcError",error:t}),t}if(this.emit("debug",{action:"receiveRpcResult",result:e}),"result"in e)return Ku.from(Et(e.result));throw this.getRpcError(t,e)})(),await this.#ue)}_start(){null!=this.#ae&&null!=this.#ae.resolve&&(this.#ae.resolve(),this.#ae=null,(async()=>{for(;null==this.#te&&!this.destroyed;)try{this.#te=await this._detectNetwork()}catch(t){if(this.destroyed)break;console.log("JsonRpcProvider failed to detect network and cannot start up; retry in 1s (perhaps the URL is wrong or the node is not started)"),this.emit("error",Z("failed to bootstrap network detection","NETWORK_ERROR",{event:"initial-network-discovery",info:{error:t}})),await kc(1e3)}this.#ce()})())}async _waitUntilReady(){if(null!=this.#ae)return await this.#ae.promise}_getSubscriber(t){return"pending"===t.type?new vc(this):"event"===t.type?this._getOption("polling")?new tc(this,t.filter):new Ec(this,t.filter):"orphan"===t.type&&"drop-log"===t.filter.orphan?new ic("orphan"):super._getSubscriber(t)}get ready(){return null==this.#ae}getRpcTransaction(t){const e={};return["chainId","gasLimit","gasPrice","type","maxFeePerGas","maxPriorityFeePerGas","nonce","value"].forEach((r=>{if(null==t[r])return;let n=r;"gasLimit"===r&&(n="gas"),e[n]=Ot(Et(t[r],`tx.${r}`))})),["from","to","data"].forEach((r=>{null!=t[r]&&(e[r]=lt(t[r]))})),t.accessList&&(e.accessList=An(t.accessList)),e}getRpcRequest(t){switch(t.method){case"chainId":return{method:"eth_chainId",args:[]};case"getBlockNumber":return{method:"eth_blockNumber",args:[]};case"getGasPrice":return{method:"eth_gasPrice",args:[]};case"getPriorityFee":return{method:"eth_maxPriorityFeePerGas",args:[]};case"getBalance":return{method:"eth_getBalance",args:[Tc(t.address),t.blockTag]};case"getTransactionCount":return{method:"eth_getTransactionCount",args:[Tc(t.address),t.blockTag]};case"getCode":return{method:"eth_getCode",args:[Tc(t.address),t.blockTag]};case"getStorage":return{method:"eth_getStorageAt",args:[Tc(t.address),"0x"+t.position.toString(16),t.blockTag]};case"broadcastTransaction":return{method:"eth_sendRawTransaction",args:[t.signedTransaction]};case"getBlock":if("blockTag"in t)return{method:"eth_getBlockByNumber",args:[t.blockTag,!!t.includeTransactions]};if("blockHash"in t)return{method:"eth_getBlockByHash",args:[t.blockHash,!!t.includeTransactions]};break;case"getTransaction":return{method:"eth_getTransactionByHash",args:[t.hash]};case"getTransactionReceipt":return{method:"eth_getTransactionReceipt",args:[t.hash]};case"call":return{method:"eth_call",args:[this.getRpcTransaction(t.transaction),t.blockTag]};case"estimateGas":return{method:"eth_estimateGas",args:[this.getRpcTransaction(t.transaction)]};case"getLogs":return t.filter&&null!=t.filter.address&&(Array.isArray(t.filter.address)?t.filter.address=t.filter.address.map(Tc):t.filter.address=Tc(t.filter.address)),{method:"eth_getLogs",args:[t.filter]}}return null}getRpcError(t,e){const{method:r}=t,{error:n}=e;if("eth_estimateGas"===r&&n.message){const e=n.message;if(!e.match(/revert/i)&&e.match(/insufficient funds/i))return Z("insufficient funds","INSUFFICIENT_FUNDS",{transaction:t.params[0],info:{payload:t,error:n}})}if("eth_call"===r||"eth_estimateGas"===r){const e=_c(n),i=$r.getBuiltinCallException("eth_call"===r?"call":"estimateGas",t.params[0],e?e.data:null);return i.info={error:n,payload:t},i}const i=JSON.stringify(function(t){const e=[];return Rc(t,e),e}(n));if("string"==typeof n.message&&n.message.match(/user denied|ethers-user-denied/i))return Z("user rejected action","ACTION_REJECTED",{action:{eth_sign:"signMessage",personal_sign:"signMessage",eth_signTypedData_v4:"signTypedData",eth_signTransaction:"signTransaction",eth_sendTransaction:"sendTransaction",eth_requestAccounts:"requestAccess",wallet_requestAccounts:"requestAccess"}[r]||"unknown",reason:"rejected",info:{payload:t,error:n}});if("eth_sendRawTransaction"===r||"eth_sendTransaction"===r){const e=t.params[0];if(i.match(/insufficient funds|base fee exceeds gas limit/i))return Z("insufficient funds for intrinsic transaction cost","INSUFFICIENT_FUNDS",{transaction:e,info:{error:n}});if(i.match(/nonce/i)&&i.match(/too low/i))return Z("nonce has already been used","NONCE_EXPIRED",{transaction:e,info:{error:n}});if(i.match(/replacement transaction/i)&&i.match(/underpriced/i))return Z("replacement fee too low","REPLACEMENT_UNDERPRICED",{transaction:e,info:{error:n}});if(i.match(/only replay-protected/i))return Z("legacy pre-eip-155 transactions not supported","UNSUPPORTED_OPERATION",{operation:r,info:{transaction:e,info:{error:n}}})}let s=!!i.match(/the method .* does not exist/i);return s||n&&n.details&&n.details.startsWith("Unauthorized method:")&&(s=!0),s?Z("unsupported operation","UNSUPPORTED_OPERATION",{operation:t.method,info:{error:n,payload:t}}):Z("could not coalesce error","UNKNOWN_ERROR",{error:n,payload:t})}send(t,e){if(this.destroyed)return Promise.reject(Z("provider destroyed; cancelled request","UNSUPPORTED_OPERATION",{operation:t}));const r=this.#ie++,n=new Promise(((n,i)=>{this.#se.push({resolve:n,reject:i,payload:{method:t,params:e,id:r,jsonrpc:"2.0"}})}));return this.#ce(),n}async getSigner(t){null==t&&(t=0);const e=this.send("eth_accounts",[]);if("number"==typeof t){const r=await e;if(t>=r.length)throw new Error("no such account");return new Bc(this,r[t])}const{accounts:r}=await z({network:this.getNetwork(),accounts:e});t=Be(t);for(const e of r)if(Be(e)===t)return new Bc(this,t);throw new Error("invalid account")}async listAccounts(){return(await this.send("eth_accounts",[])).map((t=>new Bc(this,t)))}destroy(){this.#oe&&(clearTimeout(this.#oe),this.#oe=null);for(const{payload:t,reject:e}of this.#se)e(Z("provider destroyed; cancelled request","UNSUPPORTED_OPERATION",{operation:t.method}));this.#se=[],super.destroy()}}class xc extends Nc{#le;constructor(t,e){super(t,e);let r=this._getOption("pollingInterval");null==r&&(r=Oc.pollingInterval),this.#le=r}_getSubscriber(t){const e=super._getSubscriber(t);return Pc(e)&&(e.pollingInterval=this.#le),e}get pollingInterval(){return this.#le}set pollingInterval(t){if(!Number.isInteger(t)||t<0)throw new Error("invalid interval");this.#le=t,this._forEachSubscriber((t=>{Pc(t)&&(t.pollingInterval=this.#le)}))}}class Cc extends xc{#fe;constructor(t,e,r){null==t&&(t="http://localhost:8545"),super(e,r),this.#fe="string"==typeof t?new Cn(t):t.clone()}_getConnection(){return this.#fe.clone()}async send(t,e){return await this._start(),await super.send(t,e)}async _send(t){const e=this._getConnection();e.body=JSON.stringify(t),e.setHeader("content-type","application/json");const r=await e.send();r.assertOk();let n=r.bodyJson;return Array.isArray(n)||(n=[n]),n}}function _c(t){if(null==t)return null;if("string"==typeof t.message&&t.message.match(/revert/i)&&at(t.data))return{message:t.message,data:t.data};if("object"==typeof t){for(const e in t){const r=_c(t[e]);if(r)return r}return null}if("string"==typeof t)try{return _c(JSON.parse(t))}catch(t){}return null}function Rc(t,e){if(null!=t){if("string"==typeof t.message&&e.push(t.message),"object"==typeof t)for(const r in t)Rc(t[r],e);if("string"==typeof t)try{return Rc(JSON.parse(t),e)}catch(t){}}}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 Lc(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 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,e){if("object"!=Uc(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=Uc(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Uc(e)?e:e+""}var Mc=function(){return e=function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),Dc(this,"height",void 0),Dc(this,"hash",void 0),Dc(this,"previousBlockHash",void 0),Dc(this,"previousBlockChecksum",void 0),Dc(this,"bits",void 0),Dc(this,"nonce",void 0),Dc(this,"version",void 0),Dc(this,"size",void 0),Dc(this,"txCount",void 0),Dc(this,"weight",void 0),Dc(this,"strippedSize",void 0),Dc(this,"time",void 0),Dc(this,"medianTime",void 0),Dc(this,"checksumRoot",void 0),Dc(this,"merkleRoot",void 0),Dc(this,"storageRoot",void 0),Dc(this,"receiptRoot",void 0),Dc(this,"checksumProofs",void 0),Dc(this,"transactions",void 0),this.height=BigInt(e.height.toString()),this.hash=e.hash,this.previousBlockHash=e.previousBlockHash,this.previousBlockChecksum=e.previousBlockChecksum,this.bits=e.bits,this.nonce=e.nonce,this.version=e.version,this.size=e.size,this.txCount=e.txCount,this.weight=e.weight,this.strippedSize=e.strippedSize,this.time=e.time,this.medianTime=e.medianTime,this.checksumRoot=e.checksumRoot,this.merkleRoot=e.merkleRoot,this.storageRoot=e.storageRoot,this.receiptRoot=e.receiptRoot,this.checksumProofs=e.checksumProofs,this.transactions=this.getTransactions(e.transactions)},(r=[{key:"getTransactions",value:function(e){if(!e)return[];var r,n=[],i=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 Lc(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)?Lc(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 s,o=!0,a=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return o=t.done,t},e:function(t){a=!0,s=t},f:function(){try{o||null==r.return||r.return()}finally{if(a)throw s}}}}(e);try{for(i.s();!(r=i.n()).done;){var s=r.value;switch(s.OPNetType){case t.Generic:n.push(new U(s));break;case t.Interaction:n.push(new K(s));break;case t.Deployment:n.push(new B(s));break;default:throw new Error("Unknown transaction type")}}}catch(t){i.e(t)}finally{i.f()}return n}}])&&Fc(e.prototype,r),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,r}();function Gc(t){return Gc="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},Gc(t)}function jc(){jc=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,i=Object.defineProperty||function(t,e,r){t[e]=r.value},s="function"==typeof Symbol?Symbol:{},o=s.iterator||"@@iterator",a=s.asyncIterator||"@@asyncIterator",u=s.toStringTag||"@@toStringTag";function c(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{c({},"")}catch(t){c=function(t,e,r){return t[e]=r}}function l(t,e,r,n){var s=e&&e.prototype instanceof w?e:w,o=Object.create(s.prototype),a=new N(n||[]);return i(o,"_invoke",{value:T(t,r,a)}),o}function f(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=l;var h="suspendedStart",p="suspendedYield",d="executing",g="completed",y={};function w(){}function m(){}function b(){}var A={};c(A,o,(function(){return this}));var E=Object.getPrototypeOf,v=E&&E(E(x([])));v&&v!==r&&n.call(v,o)&&(A=v);var S=b.prototype=w.prototype=Object.create(A);function I(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function k(t,e){function r(i,s,o,a){var u=f(t[i],t,s);if("throw"!==u.type){var c=u.arg,l=c.value;return l&&"object"==Gc(l)&&n.call(l,"__await")?e.resolve(l.__await).then((function(t){r("next",t,o,a)}),(function(t){r("throw",t,o,a)})):e.resolve(l).then((function(t){c.value=t,o(c)}),(function(t){return r("throw",t,o,a)}))}a(u.arg)}var s;i(this,"_invoke",{value:function(t,n){function i(){return new e((function(e,i){r(t,n,e,i)}))}return s=s?s.then(i,i):i()}})}function T(e,r,n){var i=h;return function(s,o){if(i===d)throw Error("Generator is already running");if(i===g){if("throw"===s)throw o;return{value:t,done:!0}}for(n.method=s,n.arg=o;;){var a=n.delegate;if(a){var u=P(a,n);if(u){if(u===y)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===h)throw i=g,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=d;var c=f(e,r,n);if("normal"===c.type){if(i=n.done?g:p,c.arg===y)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(i=g,n.method="throw",n.arg=c.arg)}}}function P(e,r){var n=r.method,i=e.iterator[n];if(i===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,P(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),y;var s=f(i,e.iterator,r.arg);if("throw"===s.type)return r.method="throw",r.arg=s.arg,r.delegate=null,y;var o=s.arg;return o?o.done?(r[e.resultName]=o.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,y):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,y)}function O(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function B(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function N(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(O,this),this.reset(!0)}function x(e){if(e||""===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,s=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 s.next=s}}throw new TypeError(Gc(e)+" is not iterable")}return m.prototype=b,i(S,"constructor",{value:b,configurable:!0}),i(b,"constructor",{value:m,configurable:!0}),m.displayName=c(b,u,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===m||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,b):(t.__proto__=b,c(t,u,"GeneratorFunction")),t.prototype=Object.create(S),t},e.awrap=function(t){return{__await:t}},I(k.prototype),c(k.prototype,a,(function(){return this})),e.AsyncIterator=k,e.async=function(t,r,n,i,s){void 0===s&&(s=Promise);var o=new k(l(t,r,n,i),s);return e.isGeneratorFunction(r)?o:o.next().then((function(t){return t.done?t.value:o.next()}))},I(S),c(S,u,"Generator"),c(S,o,(function(){return this})),c(S,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=x,N.prototype={constructor:N,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(B),!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].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function i(n,i){return a.type="throw",a.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var s=this.tryEntries.length-1;s>=0;--s){var o=this.tryEntries[s],a=o.completion;if("root"===o.tryLoc)return i("end");if(o.tryLoc<=this.prev){var u=n.call(o,"catchLoc"),c=n.call(o,"finallyLoc");if(u&&c){if(this.prev<o.catchLoc)return i(o.catchLoc,!0);if(this.prev<o.finallyLoc)return i(o.finallyLoc)}else if(u){if(this.prev<o.catchLoc)return i(o.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return i(o.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var s=i;break}}s&&("break"===t||"continue"===t)&&s.tryLoc<=e&&e<=s.finallyLoc&&(s=null);var o=s?s.completion:{};return o.type=t,o.arg=e,s?(this.method="next",this.next=s.finallyLoc,y):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),y},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),B(r),y}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var i=n.arg;B(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:x(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),y}},e}function Vc(t,e,r,n,i,s,o){try{var a=t[s](o),u=a.value}catch(t){return void r(t)}a.done?e(u):Promise.resolve(u).then(n,i)}function Kc(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var s=t.apply(e,r);function o(t){Vc(s,n,i,o,a,"next",t)}function a(t){Vc(s,n,i,o,a,"throw",t)}o(void 0)}))}}function Qc(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 Wc(t,e,r){return(e=zc(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function zc(t){var e=function(t,e){if("object"!=Gc(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=Gc(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Gc(e)?e:e+""}var Jc=function(){return t=function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),Wc(this,"provider",void 0),Wc(this,"url",void 0),Wc(this,"nextId",0),this.url=this.providerUrl(e),this.provider=new Cc(this.url)},e=[{key:"providerUrl",value:function(t){return(t=t.trim()).endsWith("/")?t.slice(0,-1):t.includes("api/v1/json-rpc")?t:"".concat(t,"/api/v1/json-rpc")}},{key:"getBlockNumber",value:(n=Kc(jc().mark((function t(){return jc().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.provider.getBlockNumber();case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)}))),function(){return n.apply(this,arguments)})},{key:"getBlock",value:(r=Kc(jc().mark((function t(e){var r,n,i,s,o,a,u=arguments;return jc().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=u.length>1&&void 0!==u[1]&&u[1],n="string"==typeof e?"btc_getBlockByHash":"btc_getBlockByNumber",i=this.buildJsonRpcPayload(n,[e,r]),t.next=5,this.provider._send(i);case 5:if(s=t.sent,o=s.shift()){t.next=9;break}throw new Error("Block not found");case 9:return a=o.result,t.abrupt("return",new Mc(a));case 11:case"end":return t.stop()}}),t,this)}))),function(t){return r.apply(this,arguments)})},{key:"buildJsonRpcPayload",value:function(t,e){return{method:t,params:e,id:this.nextId++,jsonrpc:"2.0"}}}],e&&Qc(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,r,n}();const qc={version:"0.0.1"}})();var i=n.eB,s=n.qT,o=n.Yy,a=n.Bc,u=n.r,c=n.W4,l=n.OB,f=n.PN,h=n.Mw,p=n.Ay;export{i as Block,s as DeploymentTransaction,o as GenericTransaction,a as InteractionTransaction,u as JSONRpcProvider,c as OPNetTransactionTypes,l as TransactionBase,f as TransactionInput,h as TransactionOutput,p as default};